@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.
Files changed (135) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/package.json +1 -6
  3. package/cjs/components/Autocomplete/Autocomplete.md +0 -113
  4. package/cjs/components/Button/Button.md +0 -261
  5. package/cjs/components/Calendar/Calendar.md +0 -276
  6. package/cjs/components/Calendar/CalendarDay.md +0 -70
  7. package/cjs/components/Center/Center.md +0 -26
  8. package/cjs/components/Checkbox/Checkbox.md +0 -171
  9. package/cjs/components/ComboBox/ComboBox.md +0 -574
  10. package/cjs/components/CurrencyInput/CurrencyInput.md +0 -39
  11. package/cjs/components/CurrencyLabel/CurrencyLabel.md +0 -29
  12. package/cjs/components/DateInput/DateInput.md +0 -111
  13. package/cjs/components/DatePicker/DatePicker.md +0 -368
  14. package/cjs/components/Dropdown/Dropdown.md +0 -45
  15. package/cjs/components/DropdownMenu/DropdownMenu.md +0 -290
  16. package/cjs/components/FileUploader/FileUploader.md +0 -131
  17. package/cjs/components/FxInput/FxInput.md +0 -31
  18. package/cjs/components/Gapped/Gapped.md +0 -44
  19. package/cjs/components/GlobalLoader/GlobalLoader.md +0 -97
  20. package/cjs/components/Group/Group.md +0 -19
  21. package/cjs/components/Hint/Hint.md +0 -86
  22. package/cjs/components/Input/Input.md +0 -86
  23. package/cjs/components/Kebab/Kebab.md +0 -306
  24. package/cjs/components/Link/Link.md +0 -182
  25. package/cjs/components/Loader/Loader.md +0 -33
  26. package/cjs/components/MaskedInput/MaskedInput.md +0 -114
  27. package/cjs/components/MenuFooter/MenuFooter.md +0 -27
  28. package/cjs/components/MenuHeader/MenuHeader.md +0 -35
  29. package/cjs/components/MenuItem/MenuItem.md +0 -139
  30. package/cjs/components/MenuSeparator/MenuSeparator.md +0 -14
  31. package/cjs/components/MiniModal/MiniModal.md +0 -231
  32. package/cjs/components/Modal/Modal.md +0 -56
  33. package/cjs/components/Paging/Paging.md +0 -57
  34. package/cjs/components/PasswordInput/PasswordInput.md +0 -29
  35. package/cjs/components/Radio/Radio.md +0 -57
  36. package/cjs/components/RadioGroup/RadioGroup.md +0 -44
  37. package/cjs/components/ResponsiveLayout/ResponsiveLayout.md +0 -75
  38. package/cjs/components/ScrollContainer/ScrollContainer.md +0 -224
  39. package/cjs/components/Select/Select.md +0 -113
  40. package/cjs/components/SidePage/SidePage.md +0 -65
  41. package/cjs/components/SingleToast/SingleToast.md +0 -36
  42. package/cjs/components/Spinner/Spinner.md +0 -36
  43. package/cjs/components/Sticky/Sticky.md +0 -28
  44. package/cjs/components/Switcher/Switcher.md +0 -111
  45. package/cjs/components/Tabs/Tab.md +0 -73
  46. package/cjs/components/Tabs/Tabs.md +0 -54
  47. package/cjs/components/Textarea/Textarea.md +0 -58
  48. package/cjs/components/Toast/Toast.md +0 -69
  49. package/cjs/components/Toggle/Toggle.md +0 -110
  50. package/cjs/components/Token/Token.md +0 -48
  51. package/cjs/components/TokenInput/TokenInput.md +0 -277
  52. package/cjs/components/Tooltip/Tooltip.md +0 -322
  53. package/cjs/components/TooltipMenu/TooltipMenu.md +0 -241
  54. package/cjs/internal/DataTids/DATATIDS.md +0 -12
  55. package/cjs/internal/DataTids/DataTids.d.ts +0 -12
  56. package/cjs/internal/DataTids/DataTids.js +0 -50
  57. package/cjs/internal/DataTids/DataTids.js.map +0 -1
  58. package/cjs/internal/DataTids/DataTids.styles.d.ts +0 -7
  59. package/cjs/internal/DataTids/DataTids.styles.js +0 -42
  60. package/cjs/internal/DataTids/DataTids.styles.js.map +0 -1
  61. package/cjs/internal/DataTids/componentsDataTids.d.ts +0 -5
  62. package/cjs/internal/DataTids/componentsDataTids.js +0 -15
  63. package/cjs/internal/DataTids/componentsDataTids.js.map +0 -1
  64. package/cjs/internal/ThemePlayground/Playground.md +0 -7
  65. package/cjs/lib/featureFlagsContext/FEATUREFLAGSCONTEXT.md +0 -64
  66. package/cjs/lib/locale/LOCALECONTEXT.md +0 -222
  67. package/cjs/lib/theming/ThemeContext.md +0 -265
  68. package/components/Autocomplete/Autocomplete.md +0 -113
  69. package/components/Button/Button.md +0 -261
  70. package/components/Calendar/Calendar.md +0 -276
  71. package/components/Calendar/CalendarDay.md +0 -70
  72. package/components/Center/Center.md +0 -26
  73. package/components/Checkbox/Checkbox.md +0 -171
  74. package/components/ComboBox/ComboBox.md +0 -574
  75. package/components/CurrencyInput/CurrencyInput.md +0 -39
  76. package/components/CurrencyLabel/CurrencyLabel.md +0 -29
  77. package/components/DateInput/DateInput.md +0 -111
  78. package/components/DatePicker/DatePicker.md +0 -368
  79. package/components/Dropdown/Dropdown.md +0 -45
  80. package/components/DropdownMenu/DropdownMenu.md +0 -290
  81. package/components/FileUploader/FileUploader.md +0 -131
  82. package/components/FxInput/FxInput.md +0 -31
  83. package/components/Gapped/Gapped.md +0 -44
  84. package/components/GlobalLoader/GlobalLoader.md +0 -97
  85. package/components/Group/Group.md +0 -19
  86. package/components/Hint/Hint.md +0 -86
  87. package/components/Input/Input.md +0 -86
  88. package/components/Kebab/Kebab.md +0 -306
  89. package/components/Link/Link.md +0 -182
  90. package/components/Loader/Loader.md +0 -33
  91. package/components/MaskedInput/MaskedInput.md +0 -114
  92. package/components/MenuFooter/MenuFooter.md +0 -27
  93. package/components/MenuHeader/MenuHeader.md +0 -35
  94. package/components/MenuItem/MenuItem.md +0 -139
  95. package/components/MenuSeparator/MenuSeparator.md +0 -14
  96. package/components/MiniModal/MiniModal.md +0 -231
  97. package/components/Modal/Modal.md +0 -56
  98. package/components/Paging/Paging.md +0 -57
  99. package/components/PasswordInput/PasswordInput.md +0 -29
  100. package/components/Radio/Radio.md +0 -57
  101. package/components/RadioGroup/RadioGroup.md +0 -44
  102. package/components/ResponsiveLayout/ResponsiveLayout.md +0 -75
  103. package/components/ScrollContainer/ScrollContainer.md +0 -224
  104. package/components/Select/Select.md +0 -113
  105. package/components/SidePage/SidePage.md +0 -65
  106. package/components/SingleToast/SingleToast.md +0 -36
  107. package/components/Spinner/Spinner.md +0 -36
  108. package/components/Sticky/Sticky.md +0 -28
  109. package/components/Switcher/Switcher.md +0 -111
  110. package/components/Tabs/Tab.md +0 -73
  111. package/components/Tabs/Tabs.md +0 -54
  112. package/components/Textarea/Textarea.md +0 -58
  113. package/components/Toast/Toast.md +0 -69
  114. package/components/Toggle/Toggle.md +0 -110
  115. package/components/Token/Token.md +0 -48
  116. package/components/TokenInput/TokenInput.md +0 -277
  117. package/components/Tooltip/Tooltip.md +0 -322
  118. package/components/TooltipMenu/TooltipMenu.md +0 -241
  119. package/internal/DataTids/DATATIDS.md +0 -12
  120. package/internal/DataTids/DataTids/DataTids.js +0 -69
  121. package/internal/DataTids/DataTids/DataTids.js.map +0 -1
  122. package/internal/DataTids/DataTids/package.json +0 -6
  123. package/internal/DataTids/DataTids.d.ts +0 -12
  124. package/internal/DataTids/DataTids.styles/DataTids.styles.js +0 -20
  125. package/internal/DataTids/DataTids.styles/DataTids.styles.js.map +0 -1
  126. package/internal/DataTids/DataTids.styles/package.json +0 -6
  127. package/internal/DataTids/DataTids.styles.d.ts +0 -7
  128. package/internal/DataTids/componentsDataTids/componentsDataTids.js +0 -12
  129. package/internal/DataTids/componentsDataTids/componentsDataTids.js.map +0 -1
  130. package/internal/DataTids/componentsDataTids/package.json +0 -6
  131. package/internal/DataTids/componentsDataTids.d.ts +0 -5
  132. package/internal/ThemePlayground/Playground.md +0 -7
  133. package/lib/featureFlagsContext/FEATUREFLAGSCONTEXT.md +0 -64
  134. package/lib/locale/LOCALECONTEXT.md +0 -222
  135. package/lib/theming/ThemeContext.md +0 -265
@@ -1,277 +0,0 @@
1
- ### Базовый пример
2
- ```jsx harmony
3
- import { Token } from '@skbkontur/react-ui';
4
- import { TokenInputType } from '@skbkontur/react-ui/components/TokenInput';
5
-
6
- const [selectedItems, setSelectedItems] = React.useState([]);
7
-
8
- const delay = time => args => new Promise(resolve => setTimeout(resolve, time, args));
9
-
10
- const getItems = q =>
11
- Promise.resolve(
12
- ['First', 'Second', 'Third', 'Fourth', 'Fifth', 'Sixth'].filter(
13
- x => x.toLowerCase().includes(q.toLowerCase()) || x.toString() === q,
14
- ),
15
- ).then(delay(500));
16
-
17
- <div style={{ width: '300px' }}>
18
- <TokenInput
19
- type={TokenInputType.Combined}
20
- getItems={getItems}
21
- selectedItems={selectedItems}
22
- onValueChange={setSelectedItems}
23
- renderToken={(item, tokenProps) => (
24
- <Token key={item.toString()} {...tokenProps}>
25
- {item}
26
- </Token>
27
- )}
28
- />
29
- </div>;
30
- ```
31
-
32
- ### Размер
33
-
34
- ```jsx harmony
35
- import { Token } from '@skbkontur/react-ui';
36
- import { TokenInputType } from '@skbkontur/react-ui/components/TokenInput';
37
-
38
- const [selectedItems, setSelectedItems] = React.useState([]);
39
-
40
- const delay = time => args => new Promise(resolve => setTimeout(resolve, time, args));
41
-
42
- const getItems = q =>
43
- Promise.resolve(
44
- ['First', 'Second', 'Third', 'Fourth', 'Fifth', 'Sixth'].filter(
45
- x => x.toLowerCase().includes(q.toLowerCase()) || x.toString(10) === q,
46
- ),
47
- ).then(delay(500));
48
-
49
- <div style={{ width: '300px' }}>
50
- <TokenInput
51
- size={'small'}
52
- getItems={getItems}
53
- selectedItems={selectedItems}
54
- onValueChange={setSelectedItems}
55
- />
56
- <TokenInput
57
- size={'medium'}
58
- getItems={getItems}
59
- selectedItems={selectedItems}
60
- onValueChange={setSelectedItems}
61
- />
62
- <TokenInput
63
- size={'large'}
64
- getItems={getItems}
65
- selectedItems={selectedItems}
66
- onValueChange={setSelectedItems}
67
- />
68
- </div>;
69
- ```
70
-
71
- ### Заблокированный TokenInput с кастомными Token
72
-
73
- ```jsx harmony
74
- import { Token } from '@skbkontur/react-ui';
75
- import { TokenInputType } from '@skbkontur/react-ui/components/TokenInput';
76
-
77
- const [selectedItems, setSelectedItems] = React.useState(['aaa', 'bbb', 'ccc']);
78
-
79
- async function getItems(query) {
80
- return ['aaa', 'bbb', 'ccc'].filter((s) => s.includes(query));
81
- };
82
-
83
- <TokenInput
84
- disabled
85
- type={TokenInputType.Combined}
86
- getItems={getItems}
87
- selectedItems={selectedItems}
88
- onValueChange={setSelectedItems}
89
- renderToken={(item, tokenProps) => (
90
- <Token key={item.toString()} {...tokenProps} disabled={item === 'bbb' || tokenProps.disabled} >
91
- {item}
92
- </Token>
93
- )}
94
- />
95
- ```
96
-
97
- ### Ограничение количества токенов в выпадающем списке
98
-
99
- ```jsx harmony
100
- import { Token } from '@skbkontur/react-ui';
101
- import { TokenInputType } from '@skbkontur/react-ui/components/TokenInput';
102
-
103
-
104
- const delay = time => args => new Promise(resolve => setTimeout(resolve, time, args));
105
- const { cities } = require('../ComboBox/__mocks__/cities');
106
-
107
- const maxItems = 5;
108
-
109
- const [totalCount, setTotalCount] = React.useState(cities.length);
110
- const [value, setValue] = React.useState([]);
111
-
112
- const getItems = (query) => {
113
- const items = cities
114
- .map((x) => x.City)
115
- .filter((x) => x.toLowerCase().includes(query.toLowerCase()) || x.toString() === query);
116
- const result = items.slice(0, maxItems);
117
- setTotalCount(items.length);
118
-
119
- return Promise.resolve(result).then(delay(500));
120
- };
121
-
122
- const renderTotalCount = (foundCount, totalCount) => (
123
- <span>
124
- Показано {foundCount} из {totalCount} найденных городов
125
- </span>
126
- );
127
-
128
- <div style={{ width: "300px" }}>
129
- <TokenInput
130
- type={TokenInputType.Combined}
131
- selectedItems={value}
132
- onValueChange={setValue}
133
- getItems={getItems}
134
- placeholder="Начните вводить название"
135
- renderTotalCount={renderTotalCount}
136
- totalCount={totalCount}
137
- />
138
- </div>
139
- ```
140
-
141
- ### Кастомный тип элементов меню
142
- ```jsx harmony
143
- import { Token } from '@skbkontur/react-ui';
144
- import { TokenInputType } from '@skbkontur/react-ui/components/TokenInput';
145
-
146
- const [selectedItems, setSelectedItems] = React.useState([]);
147
-
148
- const delay = time => args => new Promise(resolve => setTimeout(resolve, time, args));
149
- const getGenericItems = () => [
150
- { id: '111', value: 'aaa' },
151
- { id: '222', value: 'bbb' },
152
- { id: '333', value: 'ccc' },
153
- { id: '444', value: 'ddd' },
154
- ];
155
- const renderItem = (item) => item.value;
156
- const renderValue = (value) => value.value;
157
- const valueToItem = (item) => ({
158
- value: item,
159
- });
160
- const getModelItems = async (query) => {
161
- await delay(400);
162
- return getGenericItems().filter((s) => s.value.includes(query));
163
- }
164
-
165
- <div style={{ width: '300px' }}>
166
- <TokenInput
167
- selectedItems={selectedItems}
168
- renderItem={renderItem}
169
- renderValue={renderValue}
170
- valueToItem={valueToItem}
171
- valueToString={renderValue}
172
- getItems={getModelItems}
173
- onValueChange={setSelectedItems}
174
- placeholder="placeholder"
175
- type={TokenInputType.Combined}
176
- renderToken={(item, tokenProps) => (
177
- <Token
178
- key={item.id}
179
- {...tokenProps}
180
- >
181
- {item.value}
182
- </Token>
183
- )}
184
- />
185
- </div>;
186
- ```
187
-
188
- ### Дебаунс функции getItems
189
-
190
- Функция debounce из lodash некорректно работает с async/promise, поэтому лучше использовать кастомную функцию, как в примере ниже.
191
-
192
- ```jsx harmony
193
- import { TokenInput } from "@skbkontur/react-ui";
194
- import { TokenInputType } from "@skbkontur/react-ui/components/TokenInput";
195
-
196
- const [value, setValue] = React.useState([]);
197
-
198
- function debounceAsync(callback, wait) {
199
- let timeoutId = null;
200
-
201
- return (...args) => {
202
- if (timeoutId) {
203
- clearTimeout(timeoutId);
204
- }
205
-
206
- return new Promise((resolve) => {
207
- const timeoutPromise = new Promise((resolve) => {
208
- timeoutId = setTimeout(resolve, wait);
209
- });
210
- timeoutPromise.then(async () => {
211
- resolve(await callback(...args));
212
- });
213
- });
214
- };
215
- }
216
-
217
- const items = ["kon", "kod", "kof", "kor", "kos"];
218
-
219
- const getItems = async (query) => {
220
- console.log("query: ", query);
221
- return items.filter((item) => item.includes(query));
222
- };
223
-
224
- <TokenInput
225
- style={{ width: "300px" }}
226
- type={TokenInputType.Combined}
227
- selectedItems={value}
228
- onValueChange={setValue}
229
- getItems={debounceAsync(getItems, 300)}
230
- placeholder="Начните вводить название"
231
- />
232
- ```
233
-
234
- ### Типизированная версия функции
235
-
236
- ```typescript static
237
- function debounceAsync<T, Callback extends (...args: any[]) => Promise<T>>(
238
- callback: Callback,
239
- wait: number,
240
- ): (...args: Parameters<Callback>) => Promise<T> {
241
- let timeoutId: number | null = null;
242
-
243
- return (...args: any[]) => {
244
- if (timeoutId) {
245
- clearTimeout(timeoutId);
246
- }
247
-
248
- return new Promise<T>((resolve) => {
249
- const timeoutPromise = new Promise<void>((resolve) => {
250
- timeoutId = setTimeout(resolve, wait);
251
- });
252
- timeoutPromise.then(async () => {
253
- resolve(await callback(...args));
254
- });
255
- });
256
- };
257
- }
258
- ```
259
-
260
- ### Локали по умолчанию
261
-
262
- ```typescript static
263
- interface TokenInputLocale {
264
- addButtonComment?: string;
265
- addButtonTitle?: string;
266
- }
267
-
268
- const ru_RU = {
269
- addButtonComment: 'Нажмите запятую',
270
- addButtonTitle: 'Добавить',
271
- };
272
-
273
- const en_GB = {
274
- addButtonComment: 'Type comma',
275
- addButtonTitle: 'Add',
276
- };
277
- ```
@@ -1,322 +0,0 @@
1
- ### Базовый пример
2
- Отступы в тултипе подобраны так, чтобы базовая линия текста со шрифтом Segoe UI в тултипе совпадала с базовой линией стандартных контролов
3
-
4
- ```jsx harmony
5
- import { SearchLoupeIcon16Regular } from '@skbkontur/icons/icons/SearchLoupeIcon/SearchLoupeIcon16Regular';
6
- import { UiMenuBars3HIcon16Regular } from '@skbkontur/icons/icons/UiMenuBars3HIcon/UiMenuBars3HIcon16Regular';
7
- import { QuestionCircleIcon16Regular } from '@skbkontur/icons/icons/QuestionCircleIcon/QuestionCircleIcon16Regular';
8
- import { Button, Gapped, Input, Select, Tooltip } from '@skbkontur/react-ui';
9
-
10
- const [size, setSize] = React.useState('small');
11
-
12
- const render = () => (
13
- <div
14
- style={{
15
- width: 250,
16
- fontSize: size === 'large' ? 16 : 14,
17
- fontFamily: 'Segoe UI',
18
- }}
19
- >
20
- Задача организации, в особенности же рамки и место обучения кадров влечет за собой процесс внедрения и модернизации
21
- форм развития.
22
- </div>
23
- );
24
-
25
- <div style={{ fontFamily: 'Segoe UI' }}>
26
- <Gapped vertical>
27
- <Gapped>
28
- <div style={{ width: 40 }}>Size</div>
29
- <Select width={120} value={size} items={['small', 'medium', 'large']} onValueChange={setSize} size={size} />
30
- </Gapped>
31
- <Tooltip render={render} pos="right top">
32
- <Input size={size} leftIcon={<SearchLoupeIcon16Regular />} width={170} />
33
- </Tooltip>
34
- <Tooltip render={render} pos="right top">
35
- <Button size={size} icon={<UiMenuBars3HIcon16Regular />}>
36
- Menu
37
- </Button>
38
- </Tooltip>
39
- <Tooltip render={render} pos="right top">
40
- <QuestionCircleIcon16Regular />
41
- </Tooltip>
42
- </Gapped>
43
- </div>;
44
- ```
45
-
46
- ### Выравнивание базовой линии
47
- Выравнивание базовой линии с RadioGroup требует дополнительных отступов.
48
-
49
- ```jsx harmony
50
- import { Gapped, Tooltip, RadioGroup, Radio } from '@skbkontur/react-ui';
51
-
52
- const render = () => (
53
- <div
54
- style={{
55
- fontSize: 14,
56
- fontFamily: 'Segoe UI',
57
- }}
58
- >
59
- Выровнено по первому Radio
60
- </div>
61
- );
62
-
63
- <div style={{ fontFamily: 'Segoe UI' }}>
64
- <Tooltip useWrapper={false} render={render} pos="right top">
65
- <div style={{ padding: '10px 0', display: 'inline-block' }}>
66
- <RadioGroup>
67
- <Gapped vertical gap={0}>
68
- <Radio value="2">Two</Radio>
69
- <Radio value="4">Four</Radio>
70
- <Radio value="6">Six</Radio>
71
- <Radio value="8">Eight</Radio>
72
- </Gapped>
73
- </RadioGroup>
74
- </div>
75
- </Tooltip>
76
- </div>;
77
- ```
78
-
79
- ### Расположение тултипа
80
- Тултип может располагаться в одной из 12 позиции и триггериться одним из 8 способов.
81
-
82
- ```jsx harmony
83
- import { Button, Center, Gapped, Select, Tooltip } from '@skbkontur/react-ui';
84
-
85
- const S = 60;
86
-
87
- const Block = ({ pos, trigger, top, left, onMouseDown }) => (
88
- <div
89
- style={{
90
- top,
91
- left,
92
- display: 'inline-block',
93
- position: 'absolute',
94
- cursor: trigger === 'click' ? 'pointer' : 'default',
95
- }}
96
- >
97
- <Tooltip render={() => pos} pos={pos} trigger={trigger}>
98
- <div
99
- tabIndex={trigger === 'focus' || trigger === 'hover&focus' ? 0 : null}
100
- style={{
101
- height: S - 5,
102
- width: S - 5,
103
- background: 'gray',
104
- border: 'solid 1px',
105
- boxShadow: '0 1px 5px rgba(0, 0, 0, 0.3)',
106
- }}
107
- />
108
- </Tooltip>
109
- </div>
110
- );
111
-
112
- class UseManualTooltip extends React.Component {
113
- constructor(props) {
114
- super(props);
115
- this.tooltip = null;
116
- }
117
-
118
- render() {
119
- return (
120
- <Gapped vertical>
121
- <Gapped>
122
- <Button width={1.5 * S - 5} onClick={this.handleClickOnShow.bind(this)}>
123
- Show
124
- </Button>
125
- <Button width={1.5 * S - 5} onClick={this.handleClickOnHide.bind(this)}>
126
- Hide
127
- </Button>
128
- </Gapped>
129
- <Tooltip
130
- render={() => 'Manual tooltip'}
131
- pos="bottom center"
132
- trigger="manual"
133
- ref={element => {
134
- this.tooltip = element;
135
- }}
136
- >
137
- <div
138
- style={{
139
- width: 3 * S,
140
- height: S,
141
- lineHeight: `${S}px`,
142
- background: 'gray',
143
- border: 'solid 1px',
144
- boxShadow: '0 1px 5px rgba(0, 0, 0, 0.3)',
145
- textAlign: 'center',
146
- }}
147
- >
148
- Manual control
149
- </div>
150
- </Tooltip>
151
- </Gapped>
152
- );
153
- }
154
-
155
- handleClickOnShow() {
156
- if (this.tooltip) {
157
- this.tooltip.show();
158
- }
159
- }
160
- handleClickOnHide() {
161
- if (this.tooltip) {
162
- this.tooltip.hide();
163
- }
164
- }
165
- }
166
-
167
- const blocks = [
168
- { top: S, left: S * 2, pos: 'top left' },
169
- { top: S, left: S * 4, pos: 'top center' },
170
- { top: S, left: S * 6, pos: 'top right' },
171
- { top: S * 2, left: S * 7, pos: 'right top' },
172
- { top: S * 4, left: S * 7, pos: 'right middle' },
173
- { top: S * 6, left: S * 7, pos: 'right bottom' },
174
- { top: S * 7, left: S * 6, pos: 'bottom right' },
175
- { top: S * 7, left: S * 4, pos: 'bottom center' },
176
- { top: S * 7, left: S * 2, pos: 'bottom left' },
177
- { top: S * 6, left: S, pos: 'left bottom' },
178
- { top: S * 4, left: S, pos: 'left middle' },
179
- { top: S * 2, left: S, pos: 'left top' },
180
- ];
181
-
182
- const [trigger, setTrigger] = React.useState('hover');
183
-
184
- const isManual = trigger === 'manual';
185
-
186
- <div
187
- style={{
188
- width: S * 9,
189
- height: S * 9,
190
- position: 'relative',
191
- border: '1px solid',
192
- background: `repeating-linear-gradient(
193
- 45deg,
194
- #808080,
195
- #808080 ${S / 4}px,
196
- #d3d3d3 ${S / 4}px,
197
- #d3d3d3 ${S / 2}px
198
- )`,
199
- }}
200
- >
201
- <Center>
202
- <Gapped vertical>
203
- <Gapped>
204
- Trigger
205
- <Select
206
- width={S * 2}
207
- size="small"
208
- value={trigger}
209
- items={['click', 'hover', 'focus', 'hover&focus', 'hoverAnchor', 'opened', 'closed', 'manual']}
210
- onValueChange={setTrigger}
211
- />
212
- </Gapped>
213
- {isManual ? <UseManualTooltip /> : null}
214
- </Gapped>
215
- </Center>
216
-
217
- {!isManual && blocks.map((block, i) => <Block key={i} {...block} trigger={trigger} />)}
218
- </div>;
219
- ```
220
-
221
- ### anchorElement
222
- Есть возможность прицеплять тултип к любому HTML элементу на странице с помощью `anchorElement`. При этом сам `Tooltip` может рендериться в совершенно другом месте приложения.
223
-
224
- ```jsx harmony
225
- import { Tooltip } from '@skbkontur/react-ui';
226
-
227
- const S = 60;
228
- const blockStyle = {
229
- height: S - 5,
230
- width: S - 5,
231
- boxShadow: '0 1px 5px rgba(0, 0, 0, 0.3)',
232
- background: 'gray',
233
- border: '1px solid'
234
- };
235
- const containerStyle = {
236
- width: S * 9,
237
- height: S * 9,
238
- position: 'relative',
239
- background: `repeating-linear-gradient(
240
- 45deg,
241
- #808080,
242
- #808080 ${S / 4}px,
243
- #d3d3d3 ${S / 4}px,
244
- #d3d3d3 ${S / 2}px
245
- )`,
246
- border: '1px solid',
247
- };
248
-
249
- const blocks = [
250
- { top: S, left: S * 2 },
251
- { top: S, left: S * 4 },
252
- { top: S, left: S * 6 },
253
- { top: S * 2, left: S * 7 },
254
- { top: S * 4, left: S * 7 },
255
- { top: S * 6, left: S * 7 },
256
- { top: S * 7, left: S * 6 },
257
- { top: S * 7, left: S * 4 },
258
- { top: S * 7, left: S * 2 },
259
- { top: S * 6, left: S },
260
- { top: S * 4, left: S },
261
- { top: S * 2, left: S },
262
- ];
263
-
264
- class AnchorTooltipExample extends React.Component {
265
- constructor(props) {
266
- super(props);
267
-
268
- this.state = {
269
- blocks,
270
- anchor: null,
271
- };
272
- }
273
-
274
- render() {
275
- return (
276
- <>
277
- {this.state.anchor ? (
278
- <Tooltip anchorElement={this.state.anchor} render={() => 'Hello React'} trigger="hover" />
279
- ) : null}
280
- <div style={containerStyle}>
281
- {this.state.blocks.map(({ top, left }, i) => (
282
- <div key={i} style={{ top, left, display: 'inline-block', position: 'absolute' }}>
283
- <div
284
- style={blockStyle}
285
- onMouseEnter={event => this.setState({ anchor: event.target })}
286
- onMouseLeave={() => this.setState({ anchor: null })}
287
- />
288
- </div>
289
- ))}
290
- </div>
291
- </>
292
- );
293
- }
294
- }
295
-
296
- <AnchorTooltipExample />;
297
- ```
298
-
299
- ### Задержка перед появлением
300
- У тултипа можно переопределить задержку перед его появлением. Скрытие же происходит с задержкой по умолчанию.
301
-
302
- ```jsx harmony
303
- import { QuestionCircleIcon16Regular } from '@skbkontur/icons/icons/QuestionCircleIcon/QuestionCircleIcon16Regular';
304
- import { Input, Gapped, Tooltip } from '@skbkontur/react-ui';
305
-
306
- const [delay, setDelay] = React.useState(100);
307
-
308
- const render = () => (
309
- <div>
310
- {`Showed with ${delay}ms delay`}
311
- </div>
312
- );
313
-
314
- <div>
315
- <Gapped vertical>
316
- <Gapped>Show delay: <Input value={delay} onValueChange={setDelay} /></Gapped>
317
- <Tooltip render={render} delayBeforeShow={delay} pos="right top">
318
- <QuestionCircleIcon16Regular />
319
- </Tooltip>
320
- </Gapped>
321
- </div>;
322
- ```