@cloud-ru/ds-accordion 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE +201 -0
  3. package/README.md +484 -0
  4. package/dist/cjs/Accordion.d.ts +160 -0
  5. package/dist/cjs/Accordion.js +21 -0
  6. package/dist/cjs/components/CollapseBlock/CollapseBlock.d.ts +45 -0
  7. package/dist/cjs/components/CollapseBlock/CollapseBlock.js +47 -0
  8. package/dist/cjs/components/CollapseBlock/hooks.d.ts +12 -0
  9. package/dist/cjs/components/CollapseBlock/hooks.js +43 -0
  10. package/dist/cjs/components/CollapseBlock/index.d.ts +1 -0
  11. package/dist/cjs/components/CollapseBlock/index.js +17 -0
  12. package/dist/cjs/components/CollapseBlock/styles.module.css +480 -0
  13. package/dist/cjs/components/index.d.ts +1 -0
  14. package/dist/cjs/components/index.js +17 -0
  15. package/dist/cjs/constants.d.ts +22 -0
  16. package/dist/cjs/constants.js +25 -0
  17. package/dist/cjs/index.d.ts +4 -0
  18. package/dist/cjs/index.js +20 -0
  19. package/dist/cjs/package.json +3 -0
  20. package/dist/cjs/style.css +480 -0
  21. package/dist/cjs/types.d.ts +5 -0
  22. package/dist/cjs/types.js +2 -0
  23. package/dist/esm/Accordion.d.ts +160 -0
  24. package/dist/esm/Accordion.js +18 -0
  25. package/dist/esm/components/CollapseBlock/CollapseBlock.d.ts +45 -0
  26. package/dist/esm/components/CollapseBlock/CollapseBlock.js +40 -0
  27. package/dist/esm/components/CollapseBlock/hooks.d.ts +12 -0
  28. package/dist/esm/components/CollapseBlock/hooks.js +40 -0
  29. package/dist/esm/components/CollapseBlock/index.d.ts +1 -0
  30. package/dist/esm/components/CollapseBlock/index.js +1 -0
  31. package/dist/esm/components/CollapseBlock/styles.module.css +480 -0
  32. package/dist/esm/components/index.d.ts +1 -0
  33. package/dist/esm/components/index.js +1 -0
  34. package/dist/esm/constants.d.ts +22 -0
  35. package/dist/esm/constants.js +22 -0
  36. package/dist/esm/index.d.ts +4 -0
  37. package/dist/esm/index.js +4 -0
  38. package/dist/esm/style.css +480 -0
  39. package/dist/esm/types.d.ts +5 -0
  40. package/dist/esm/types.js +1 -0
  41. package/dist/tsconfig.cjs.tsbuildinfo +1 -0
  42. package/dist/tsconfig.esm.tsbuildinfo +1 -0
  43. package/package.json +49 -0
  44. package/src/Accordion.tsx +51 -0
  45. package/src/components/CollapseBlock/CollapseBlock.tsx +194 -0
  46. package/src/components/CollapseBlock/hooks.ts +49 -0
  47. package/src/components/CollapseBlock/index.ts +1 -0
  48. package/src/components/CollapseBlock/styles.module.scss +207 -0
  49. package/src/components/index.ts +1 -0
  50. package/src/constants.ts +26 -0
  51. package/src/index.ts +4 -0
  52. package/src/types.ts +9 -0
package/README.md ADDED
@@ -0,0 +1,484 @@
1
+ # Accordion
2
+
3
+ `@cloud-ru/ds-accordion` — Аккордеон дизайн-системы — контейнер Accordion и три уровня раскрываемых блоков CollapseBlock с общими токенами view, backgroundPredefined и chevronPosition.
4
+
5
+ Пакет `@cloud-ru/ds-accordion` даёт контейнер `Accordion` и три уровня раскрываемых блоков `CollapseBlockPrimary` / `CollapseBlockSecondary` / `CollapseBlockTertiary`. Контейнер отвечает за режим выбора (`single` / `multiple`) и controlled/uncontrolled состояние, блоки — за внешний вид и иерархию на странице.
6
+
7
+ - ****Accordion**** — контейнер раскрываемых блоков с режимами `single` / `multiple` и controlled/uncontrolled API.
8
+ - ****CollapseBlock**** — раскрываемые блоки трёх уровней: `Primary`, `Secondary`, `Tertiary` — для иерархии разделов на странице.
9
+
10
+ ## Когда использовать
11
+
12
+ | Задача | Как решить |
13
+ |--------|------------|
14
+ | Длинная форма / настройки с логическими секциями | `Accordion` + `CollapseBlockPrimary` на каждый раздел |
15
+ | Двух- / трёхуровневая иерархия (раздел → подраздел → деталь) | Вложенные `Accordion` с `Primary` → `Secondary` → `Tertiary` |
16
+ | Разрешить открыть один блок за раз (FAQ) | `selectionMode='single'` |
17
+ | Разрешить одновременно несколько открытых блоков | `selectionMode='multiple'` |
18
+
19
+ Когда **не** нужен аккордеон: короткие списки (≤ 3 пунктов), критичный контент, который пользователь не должен пропустить, и навигация — для неё используйте `Tabs`.
20
+
21
+ ## Установка
22
+
23
+ ```bash
24
+ pnpm add @cloud-ru/ds-accordion
25
+ ```
26
+
27
+ ```ts
28
+ import { Accordion } from '@cloud-ru/ds-accordion'
29
+ ```
30
+
31
+ ## Figma
32
+
33
+ Оба компонента следуют одному мастер-файлу Figma. Ссылки на конкретные узлы — на страницах компонентов.
34
+
35
+ ## Accordion
36
+
37
+ Контейнер-группа раскрываемых блоков. Управляет режимом выбора (single / multiple) и controlled/uncontrolled состоянием.
38
+
39
+ Контейнер, который группирует `CollapseBlock*` в одну логическую группу и управляет их раскрытием. Под капотом — `ToggleGroup` из `@cloud-ru/ds-toggles`, поэтому семантика раскрытия идентична группе переключателей.
40
+
41
+ ### Когда использовать
42
+ - Для группы раскрываемых блоков, где открытие/закрытие должно быть согласовано (один из, несколько из).
43
+ - Для двух- и трёхуровневой иерархии — вкладывайте `Accordion` внутрь блока, меняя уровень `CollapseBlock*`.
44
+
45
+ Когда **не** нужен: один изолированный раскрывающийся блок без группы — в этом случае достаточно самого `CollapseBlock*` без обёртки.
46
+
47
+ ### Анатомия
48
+
49
+ #### Selection mode
50
+ Режим раскрытия дочерних блоков: `single` — одновременно открыт максимум один блок (как radio-группа), `multiple` — можно открыть любое количество независимо.
51
+
52
+ ### Примеры использования
53
+ #### 1. Uncontrolled с начальным состоянием
54
+
55
+ expandedDefault задаёт первоначально открытый блок; дальше компонент управляет раскрытием сам.
56
+
57
+ ```tsx
58
+ import { Accordion } from '@cloud-ru/ds-accordion';
59
+
60
+ import styles from './styles.module.scss';
61
+ export function BasicAccordion() {
62
+ return (
63
+ <div className={styles.wrapper}>
64
+ <Accordion expandedDefault='profile'>
65
+ <Accordion.CollapseBlockPrimary id='profile' title='Профиль' subTitle='Контакты и предпочтения' view='outline'>
66
+ Имя, email, аватар.
67
+ </Accordion.CollapseBlockPrimary>
68
+ <Accordion.CollapseBlockPrimary id='security' title='Безопасность' view='outline'>
69
+ Пароль, сессии, 2FA.
70
+ </Accordion.CollapseBlockPrimary>
71
+ </Accordion>
72
+ </div>
73
+ );
74
+ }
75
+ ```
76
+
77
+ #### 2. Controlled + multiple
78
+
79
+ expanded + onExpandedChange в режиме multiple — значение массив id.
80
+
81
+ ```tsx
82
+ import { Accordion } from '@cloud-ru/ds-accordion';
83
+ import { useState } from 'react';
84
+
85
+ import styles from './styles.module.scss';
86
+ export function MultipleMode() {
87
+ const [expanded, setExpanded] = useState<string[]>(['email']);
88
+
89
+ return (
90
+ <div className={styles.wrapper}>
91
+ <Accordion selectionMode='multiple' expanded={expanded} onExpandedChange={next => setExpanded(next ?? [])}>
92
+ <Accordion.CollapseBlockPrimary id='email' title='Email' view='outline'>
93
+ Уведомления на почту.
94
+ </Accordion.CollapseBlockPrimary>
95
+ <Accordion.CollapseBlockPrimary id='push' title='Push' view='outline'>
96
+ Браузерные push-уведомления.
97
+ </Accordion.CollapseBlockPrimary>
98
+ <Accordion.CollapseBlockPrimary id='messenger' title='Мессенджеры' view='outline'>
99
+ Telegram, Slack, Mattermost.
100
+ </Accordion.CollapseBlockPrimary>
101
+ </Accordion>
102
+ </div>
103
+ );
104
+ }
105
+ ```
106
+
107
+ ### Props
108
+ **AccordionProps**
109
+
110
+ | Prop | Type | Default | Description |
111
+ |------|------|---------|-------------|
112
+ | `children` | `string \| number \| boolean \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal \| null \| undefined` | — | |
113
+ | `expanded` | `string \| string[]` | — | Controlled состояние |
114
+ | `expandedDefault` | `string \| string[]` | — | Начальное состояние |
115
+ | `onExpandedChange` | `((value: string) => void) \| ((value: string[]) => void) \| undefined` | — | Controlled обработчик измения состояния |
116
+ | `selectionMode` | `"multiple"` \| `"single"` | — | Режим работы аккордиона |
117
+
118
+ ## CollapseBlock
119
+
120
+ Семейство раскрываемых блоков аккордеона — Primary (l), Secondary (m), Tertiary (s). Общие пропсы title / subTitle / afterTitle / view / backgroundPredefined / chevronPosition.
121
+
122
+ Три семантических уровня раскрываемого блока: `CollapseBlockPrimary`, `CollapseBlockSecondary`, `CollapseBlockTertiary`. Уровень задаёт размер типографики заголовка и плотность отступов; все три компонента используют одно и то же API — меняется только роль в иерархии.
123
+
124
+ ### Когда использовать
125
+ - **`Primary`** (title size `l`) — верхнеуровневые разделы страницы или секции формы.
126
+ - **`Secondary`** (title size `m`) — подразделы внутри `Primary`. Типовой `view='outline'`.
127
+ - **`Tertiary`** (title size `s`) — плоские детали без дальнейшей вложенности. Без `view` / `backgroundPredefined` — только заголовок и контент.
128
+
129
+ ### Анатомия
130
+
131
+ #### Содержимое
132
+ `children` — слот целиком: компонент задаёт раскладку и отступы, но не типографику и не цвет текста. Содержимое наследует стили родителя, поэтому шрифт задаёт место использования — обёрткой с нужным классом либо компонентом `Typography`. В макете содержимое набрано `regular/body/m`.
133
+
134
+ #### View
135
+ Визуальная подача блока: `simple` — плоский фон без рамки, `outline` — с границей, `elevated` — с тенью для поверхностей поверх страницы.
136
+
137
+ #### backgroundPredefined
138
+ Слой акрила через `BACKGROUND_PREDEFINED_FILL` из `@cloud-ru/ds-materials` (как у `Card`). По умолчанию — `neutralBackground1Level`.
139
+
140
+ #### chevronPosition (default `after`)
141
+ Положение шеврона-раскрытия относительно заголовка.
142
+
143
+ - `before` — шеврон слева от заголовка.
144
+ - `after` — шеврон справа от заголовка.
145
+
146
+ #### showChevron (default `true`)
147
+ Управляет наличием шеврона-раскрытия в строке заголовка.
148
+
149
+ - `true` — шеврон показывается рядом с заголовком.
150
+ - `false` — шеврон скрыт; блок по-прежнему раскрывается кликом по строке заголовка.
151
+
152
+ ### Примеры использования
153
+
154
+ #### Цветовые схемы
155
+
156
+ Neutral — дефолт. Primary — акцент. Цветные варианты — для статусных разделов.
157
+
158
+ ```tsx
159
+ import { Accordion } from '@cloud-ru/ds-accordion';
160
+ import { BACKGROUND_PREDEFINED_FILL } from '@cloud-ru/ds-materials';
161
+
162
+ import styles from './styles.module.scss';
163
+
164
+ export function Appearances() {
165
+ return (
166
+ <div className={styles.wrapper}>
167
+ <Accordion>
168
+ <Accordion.CollapseBlockPrimary
169
+ id='neutral'
170
+ backgroundPredefined={BACKGROUND_PREDEFINED_FILL.NeutralBackground1Level}
171
+ title='Neutral'
172
+ view='outline'
173
+ >
174
+ Нейтральный акрил — значение по умолчанию.
175
+ </Accordion.CollapseBlockPrimary>
176
+ <Accordion.CollapseBlockPrimary
177
+ id='primary'
178
+ backgroundPredefined={BACKGROUND_PREDEFINED_FILL.PrimaryBackground}
179
+ title='Primary'
180
+ view='outline'
181
+ >
182
+ Акцентный раздел, выделенный основным цветом.
183
+ </Accordion.CollapseBlockPrimary>
184
+ <Accordion.CollapseBlockPrimary
185
+ id='green'
186
+ backgroundPredefined={BACKGROUND_PREDEFINED_FILL.GreenBackground}
187
+ title='Green'
188
+ view='outline'
189
+ >
190
+ Успех, подтверждённые действия.
191
+ </Accordion.CollapseBlockPrimary>
192
+ <Accordion.CollapseBlockPrimary
193
+ id='red'
194
+ backgroundPredefined={BACKGROUND_PREDEFINED_FILL.RedBackground}
195
+ title='Red'
196
+ view='outline'
197
+ >
198
+ Предупреждение или критическое внимание.
199
+ </Accordion.CollapseBlockPrimary>
200
+ </Accordion>
201
+ </div>
202
+ );
203
+ }
204
+ ```
205
+
206
+ #### Левый шеврон + afterTitle справа
207
+
208
+ Читается как «строка итогов»: название слева, значение справа, шеврон возле названия.
209
+
210
+ ```tsx
211
+ import { Accordion } from '@cloud-ru/ds-accordion';
212
+
213
+ import styles from './styles.module.scss';
214
+ export function ChevronBefore() {
215
+ return (
216
+ <div className={styles.wrapper}>
217
+ <Accordion>
218
+ <Accordion.CollapseBlockSecondary
219
+ id='summary'
220
+ view='outline'
221
+ title='Итого'
222
+ chevronPosition='before'
223
+ afterTitle='1 200 ₽'
224
+ >
225
+ Разбивка платежа по позициям.
226
+ </Accordion.CollapseBlockSecondary>
227
+ <Accordion.CollapseBlockSecondary
228
+ id='delivery'
229
+ view='outline'
230
+ title='Доставка'
231
+ chevronPosition='before'
232
+ afterTitle='бесплатно'
233
+ >
234
+ Курьер по Москве, 2–3 дня.
235
+ </Accordion.CollapseBlockSecondary>
236
+ </Accordion>
237
+ </div>
238
+ );
239
+ }
240
+ ```
241
+
242
+ #### afterTitle — счётчик
243
+
244
+ Counter в правом слоте заголовка. Не кликабельный — клик по строке раскрывает блок.
245
+
246
+ ```tsx
247
+ import { Accordion } from '@cloud-ru/ds-accordion';
248
+ import { Counter } from '@cloud-ru/ds-counter';
249
+
250
+ import styles from './styles.module.scss';
251
+
252
+ export function AfterTitle() {
253
+ return (
254
+ <div className={styles.wrapper}>
255
+ <Accordion>
256
+ <Accordion.CollapseBlockPrimary id='inbox' title='Входящие' view='outline' afterTitle={<Counter value={12} />}>
257
+ Непрочитанные сообщения и уведомления.
258
+ </Accordion.CollapseBlockPrimary>
259
+ <Accordion.CollapseBlockPrimary id='archive' title='Архив' view='outline' afterTitle={<Counter value={238} />}>
260
+ Перемещённые из входящих.
261
+ </Accordion.CollapseBlockPrimary>
262
+ </Accordion>
263
+ </div>
264
+ );
265
+ }
266
+ ```
267
+
268
+ #### Primary → Secondary → Tertiary
269
+
270
+ Каждый уровень — собственный Accordion. Вложенный не наследует состояние родителя.
271
+
272
+ ```tsx
273
+ import { Accordion } from '@cloud-ru/ds-accordion';
274
+
275
+ import styles from './styles.module.scss';
276
+ export function NestedLevels() {
277
+ return (
278
+ <div className={styles.wrapper}>
279
+ <Accordion>
280
+ <Accordion.CollapseBlockPrimary id='root' title='Платежи' view='outline'>
281
+ <Accordion>
282
+ <Accordion.CollapseBlockSecondary id='sub-cards' view='outline' title='Карты'>
283
+ <Accordion>
284
+ <Accordion.CollapseBlockTertiary id='visa' title='Visa •••• 4242'>
285
+ Основная карта, истекает 09/28.
286
+ </Accordion.CollapseBlockTertiary>
287
+ <Accordion.CollapseBlockTertiary id='mir' title='МИР •••• 7781'>
288
+ Зарплатная карта.
289
+ </Accordion.CollapseBlockTertiary>
290
+ </Accordion>
291
+ </Accordion.CollapseBlockSecondary>
292
+ <Accordion.CollapseBlockSecondary id='sub-invoices' view='outline' title='Счета'>
293
+ История операций и выставленные счета.
294
+ </Accordion.CollapseBlockSecondary>
295
+ </Accordion>
296
+ </Accordion.CollapseBlockPrimary>
297
+ </Accordion>
298
+ </div>
299
+ );
300
+ }
301
+ ```
302
+
303
+ ### Props
304
+ **CollapseBlockProps**
305
+
306
+ | Prop | Type | Default | Description |
307
+ |------|------|---------|-------------|
308
+ | `afterTitle` | `ReactNode` | — | Контент справа от заголовка |
309
+ | `backgroundPredefined` | `"blueBackground"` \| `"decorTransparent"` \| `"greenBackground"` \| `"neutralBackground1Level"` \| `"orangeBackground"` \| `"pinkBackground"` \| `"primaryBackground"` \| `"redBackground"` \| `"transparent"` \| `"violetBackground"` \| `"yellowBackground"` | `neutralBackground1Level` | Слой backgroundPredefined + acrylic (см. `BACKGROUND_PREDEFINED_FILL` в `@cloud-ru/ds-materials`). <br/> По умолчанию `material/neutralBackground1Level`. |
310
+ | `chevronPosition` | `"after"` \| `"before"` | `after` | Положение шеврона-раскрытия относительно текста (`before` \| `after`) |
311
+ | `children` | `string \| number \| boolean \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal \| null \| undefined` | — | |
312
+ | `className` | `string` | — | Дополнительный класс корневого элемента |
313
+ | `component` | `"accordionPrimary"` \| `"accordionSecondary"` \| `"accordionTertiary"` | — | Уровень аккордеона: размер типографики и отступы |
314
+ | `data-test-id` | `string` | — | |
315
+ | `id` | `string` | — | Уникальный идентификатор блока в группе переключателей |
316
+ | `keepMounted` | `boolean` | `false` | Оставлять ли контент в DOM при сворачивании |
317
+ | `showChevron` | `boolean` | `true` | Показывать ли шеврон-раскрытия рядом с заголовком (по умолчанию `true`) |
318
+ | `subTitle` | `ReactNode` | — | Подзаголовок под строкой заголовка |
319
+ | `title` | `string` | — | Начальное состояние раскрытия (uncontrolled) |
320
+ | `view` | `"elevated"` \| `"outline"` \| `"simple"` | `simple` | Визуальный вариант обложки (`simple`, `outline`, `elevated`) |
321
+
322
+ ##### Related types
323
+
324
+ - `ChevronPosition` = `"after"` \| `"before"`
325
+
326
+ - `Component` = `"accordionPrimary"` \| `"accordionSecondary"` \| `"accordionTertiary"`
327
+
328
+ - `View` = `"elevated"` \| `"outline"` \| `"simple"`
329
+
330
+ ## CollapseBlockPrimary
331
+
332
+ ```tsx
333
+ import { Accordion } from '@cloud-ru/ds-accordion';
334
+ import { Counter } from '@cloud-ru/ds-counter';
335
+
336
+ import styles from './styles.module.scss';
337
+
338
+ export function AfterTitle() {
339
+ return (
340
+ <div className={styles.wrapper}>
341
+ <Accordion>
342
+ <Accordion.CollapseBlockPrimary id='inbox' title='Входящие' view='outline' afterTitle={<Counter value={12} />}>
343
+ Непрочитанные сообщения и уведомления.
344
+ </Accordion.CollapseBlockPrimary>
345
+ <Accordion.CollapseBlockPrimary id='archive' title='Архив' view='outline' afterTitle={<Counter value={238} />}>
346
+ Перемещённые из входящих.
347
+ </Accordion.CollapseBlockPrimary>
348
+ </Accordion>
349
+ </div>
350
+ );
351
+ }
352
+ ```
353
+
354
+ ### Props `CollapseBlockPropsWithoutComponent`
355
+
356
+ | Prop | Type | Default | Description |
357
+ |------|------|---------|-------------|
358
+ | `afterTitle` | `ReactNode` | — | Контент справа от заголовка |
359
+ | `backgroundPredefined` | `"blueBackground"` \| `"decorTransparent"` \| `"greenBackground"` \| `"neutralBackground1Level"` \| `"orangeBackground"` \| `"pinkBackground"` \| `"primaryBackground"` \| `"redBackground"` \| `"transparent"` \| `"violetBackground"` \| `"yellowBackground"` | — | Слой backgroundPredefined + acrylic (см. `BACKGROUND_PREDEFINED_FILL` в `@cloud-ru/ds-materials`). <br/> По умолчанию `material/neutralBackground1Level`. |
360
+ | `chevronPosition` | `"after"` \| `"before"` | — | Положение шеврона-раскрытия относительно текста (`before` \| `after`) |
361
+ | `children` | `string \| number \| boolean \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal \| null \| undefined` | — | |
362
+ | `className` | `string` | — | Дополнительный класс корневого элемента |
363
+ | `data-test-id` | `string` | — | |
364
+ | `id` | `string` | — | Уникальный идентификатор блока в группе переключателей |
365
+ | `keepMounted` | `boolean` | — | Оставлять ли контент в DOM при сворачивании |
366
+ | `showChevron` | `boolean` | — | Показывать ли шеврон-раскрытия рядом с заголовком (по умолчанию `true`) |
367
+ | `subTitle` | `ReactNode` | — | Подзаголовок под строкой заголовка |
368
+ | `title` | `string` | — | Начальное состояние раскрытия (uncontrolled) |
369
+ | `view` | `"elevated"` \| `"outline"` \| `"simple"` | — | Визуальный вариант обложки (`simple`, `outline`, `elevated`) |
370
+
371
+ #### Related types
372
+
373
+ - `ChevronPosition` = `"after"` \| `"before"`
374
+
375
+ - `View` = `"elevated"` \| `"outline"` \| `"simple"`
376
+
377
+ ## CollapseBlockSecondary
378
+
379
+ ```tsx
380
+ import { Accordion } from '@cloud-ru/ds-accordion';
381
+
382
+ import styles from './styles.module.scss';
383
+ export function ChevronBefore() {
384
+ return (
385
+ <div className={styles.wrapper}>
386
+ <Accordion>
387
+ <Accordion.CollapseBlockSecondary
388
+ id='summary'
389
+ view='outline'
390
+ title='Итого'
391
+ chevronPosition='before'
392
+ afterTitle='1 200 ₽'
393
+ >
394
+ Разбивка платежа по позициям.
395
+ </Accordion.CollapseBlockSecondary>
396
+ <Accordion.CollapseBlockSecondary
397
+ id='delivery'
398
+ view='outline'
399
+ title='Доставка'
400
+ chevronPosition='before'
401
+ afterTitle='бесплатно'
402
+ >
403
+ Курьер по Москве, 2–3 дня.
404
+ </Accordion.CollapseBlockSecondary>
405
+ </Accordion>
406
+ </div>
407
+ );
408
+ }
409
+ ```
410
+
411
+ ### Props `CollapseBlockPropsWithoutComponent`
412
+
413
+ | Prop | Type | Default | Description |
414
+ |------|------|---------|-------------|
415
+ | `afterTitle` | `ReactNode` | — | Контент справа от заголовка |
416
+ | `backgroundPredefined` | `"blueBackground"` \| `"decorTransparent"` \| `"greenBackground"` \| `"neutralBackground1Level"` \| `"orangeBackground"` \| `"pinkBackground"` \| `"primaryBackground"` \| `"redBackground"` \| `"transparent"` \| `"violetBackground"` \| `"yellowBackground"` | — | Слой backgroundPredefined + acrylic (см. `BACKGROUND_PREDEFINED_FILL` в `@cloud-ru/ds-materials`). <br/> По умолчанию `material/neutralBackground1Level`. |
417
+ | `chevronPosition` | `"after"` \| `"before"` | — | Положение шеврона-раскрытия относительно текста (`before` \| `after`) |
418
+ | `children` | `string \| number \| boolean \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal \| null \| undefined` | — | |
419
+ | `className` | `string` | — | Дополнительный класс корневого элемента |
420
+ | `data-test-id` | `string` | — | |
421
+ | `id` | `string` | — | Уникальный идентификатор блока в группе переключателей |
422
+ | `keepMounted` | `boolean` | — | Оставлять ли контент в DOM при сворачивании |
423
+ | `showChevron` | `boolean` | — | Показывать ли шеврон-раскрытия рядом с заголовком (по умолчанию `true`) |
424
+ | `subTitle` | `ReactNode` | — | Подзаголовок под строкой заголовка |
425
+ | `title` | `string` | — | Начальное состояние раскрытия (uncontrolled) |
426
+ | `view` | `"elevated"` \| `"outline"` \| `"simple"` | — | Визуальный вариант обложки (`simple`, `outline`, `elevated`) |
427
+
428
+ #### Related types
429
+
430
+ - `ChevronPosition` = `"after"` \| `"before"`
431
+
432
+ - `View` = `"elevated"` \| `"outline"` \| `"simple"`
433
+
434
+ ## CollapseBlockTertiary
435
+
436
+ ```tsx
437
+ import { Accordion } from '@cloud-ru/ds-accordion';
438
+
439
+ import styles from './styles.module.scss';
440
+ export function NestedLevels() {
441
+ return (
442
+ <div className={styles.wrapper}>
443
+ <Accordion>
444
+ <Accordion.CollapseBlockPrimary id='root' title='Платежи' view='outline'>
445
+ <Accordion>
446
+ <Accordion.CollapseBlockSecondary id='sub-cards' view='outline' title='Карты'>
447
+ <Accordion>
448
+ <Accordion.CollapseBlockTertiary id='visa' title='Visa •••• 4242'>
449
+ Основная карта, истекает 09/28.
450
+ </Accordion.CollapseBlockTertiary>
451
+ <Accordion.CollapseBlockTertiary id='mir' title='МИР •••• 7781'>
452
+ Зарплатная карта.
453
+ </Accordion.CollapseBlockTertiary>
454
+ </Accordion>
455
+ </Accordion.CollapseBlockSecondary>
456
+ <Accordion.CollapseBlockSecondary id='sub-invoices' view='outline' title='Счета'>
457
+ История операций и выставленные счета.
458
+ </Accordion.CollapseBlockSecondary>
459
+ </Accordion>
460
+ </Accordion.CollapseBlockPrimary>
461
+ </Accordion>
462
+ </div>
463
+ );
464
+ }
465
+ ```
466
+
467
+ ### Props `CollapseBlockTertiaryProps`
468
+
469
+ | Prop | Type | Default | Description |
470
+ |------|------|---------|-------------|
471
+ | `afterTitle` | `ReactNode` | — | Контент справа от заголовка |
472
+ | `chevronPosition` | `"after"` \| `"before"` | — | Положение шеврона-раскрытия относительно текста (`before` \| `after`) |
473
+ | `children` | `string \| number \| boolean \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal \| null \| undefined` | — | |
474
+ | `className` | `string` | — | Дополнительный класс корневого элемента |
475
+ | `data-test-id` | `string` | — | |
476
+ | `id` | `string` | — | Уникальный идентификатор блока в группе переключателей |
477
+ | `keepMounted` | `boolean` | — | Оставлять ли контент в DOM при сворачивании |
478
+ | `showChevron` | `boolean` | — | Показывать ли шеврон-раскрытия рядом с заголовком (по умолчанию `true`) |
479
+ | `subTitle` | `ReactNode` | — | Подзаголовок под строкой заголовка |
480
+ | `title` | `string` | — | Начальное состояние раскрытия (uncontrolled) |
481
+
482
+ #### Related types
483
+
484
+ - `ChevronPosition` = `"after"` \| `"before"`
@@ -0,0 +1,160 @@
1
+ import { SELECTION_MODE } from '@cloud-ru/ds-toggles';
2
+ import { PropsWithChildren } from 'react';
3
+ export type AccordionProps = PropsWithChildren<{
4
+ /** Начальное состояние */
5
+ expandedDefault?: string;
6
+ /** Controlled состояние */
7
+ expanded?: string;
8
+ /** Controlled обработчик измения состояния */
9
+ onExpandedChange?(value: (string | undefined) | string): void;
10
+ /** Режим работы аккордиона */
11
+ selectionMode?: typeof SELECTION_MODE.Single;
12
+ } | {
13
+ /** Начальное состояние */
14
+ expandedDefault?: string[];
15
+ /** Controlled состояние */
16
+ expanded?: string[];
17
+ /** Controlled обработчик измения состояния */
18
+ onExpandedChange?(value: (string[] | undefined) | string[]): void;
19
+ /** Режим работы аккордиона */
20
+ selectionMode: typeof SELECTION_MODE.Multiple;
21
+ }>;
22
+ declare function AccordionBase({ selectionMode, onExpandedChange, expandedDefault, expanded, children, }: AccordionProps): import("react/jsx-runtime").JSX.Element;
23
+ export declare const Accordion: typeof AccordionBase & {
24
+ CollapseBlockPrimary: (props: {
25
+ id: string;
26
+ title?: string | undefined;
27
+ afterTitle?: import("react").ReactNode;
28
+ subTitle?: import("react").ReactNode;
29
+ children?: import("react").ReactNode;
30
+ className?: string | undefined;
31
+ view?: import("./types").View | undefined;
32
+ chevronPosition?: import("./types").ChevronPosition | undefined;
33
+ backgroundPredefined?: import("@cloud-ru/ds-materials").BackgroundPredefinedFill | undefined;
34
+ keepMounted?: boolean | undefined;
35
+ showChevron?: boolean | undefined;
36
+ 'data-test-id'?: string | undefined;
37
+ "aria-activedescendant"?: string | undefined | undefined;
38
+ "aria-atomic"?: (boolean | "true" | "false") | undefined;
39
+ "aria-autocomplete"?: "none" | "inline" | "list" | "both" | undefined | undefined;
40
+ "aria-braillelabel"?: string | undefined | undefined;
41
+ "aria-brailleroledescription"?: string | undefined | undefined;
42
+ "aria-busy"?: (boolean | "true" | "false") | undefined;
43
+ "aria-checked"?: boolean | "false" | "mixed" | "true" | undefined | undefined;
44
+ "aria-colcount"?: number | undefined | undefined;
45
+ "aria-colindex"?: number | undefined | undefined;
46
+ "aria-colindextext"?: string | undefined | undefined;
47
+ "aria-colspan"?: number | undefined | undefined;
48
+ "aria-controls"?: string | undefined | undefined;
49
+ "aria-current"?: boolean | "false" | "true" | "page" | "step" | "location" | "date" | "time" | undefined | undefined;
50
+ "aria-describedby"?: string | undefined | undefined;
51
+ "aria-description"?: string | undefined | undefined;
52
+ "aria-details"?: string | undefined | undefined;
53
+ "aria-disabled"?: (boolean | "true" | "false") | undefined;
54
+ "aria-dropeffect"?: "none" | "copy" | "execute" | "link" | "move" | "popup" | undefined | undefined;
55
+ "aria-errormessage"?: string | undefined | undefined;
56
+ "aria-expanded"?: (boolean | "true" | "false") | undefined;
57
+ "aria-flowto"?: string | undefined | undefined;
58
+ "aria-grabbed"?: (boolean | "true" | "false") | undefined;
59
+ "aria-haspopup"?: boolean | "false" | "true" | "menu" | "listbox" | "tree" | "grid" | "dialog" | undefined | undefined;
60
+ "aria-hidden"?: (boolean | "true" | "false") | undefined;
61
+ "aria-invalid"?: boolean | "false" | "true" | "grammar" | "spelling" | undefined | undefined;
62
+ "aria-keyshortcuts"?: string | undefined | undefined;
63
+ "aria-label"?: string | undefined | undefined;
64
+ "aria-labelledby"?: string | undefined | undefined;
65
+ "aria-level"?: number | undefined | undefined;
66
+ "aria-live"?: "off" | "assertive" | "polite" | undefined | undefined;
67
+ "aria-modal"?: (boolean | "true" | "false") | undefined;
68
+ "aria-multiline"?: (boolean | "true" | "false") | undefined;
69
+ "aria-multiselectable"?: (boolean | "true" | "false") | undefined;
70
+ "aria-orientation"?: "horizontal" | "vertical" | undefined | undefined;
71
+ "aria-owns"?: string | undefined | undefined;
72
+ "aria-placeholder"?: string | undefined | undefined;
73
+ "aria-posinset"?: number | undefined | undefined;
74
+ "aria-pressed"?: boolean | "false" | "mixed" | "true" | undefined | undefined;
75
+ "aria-readonly"?: (boolean | "true" | "false") | undefined;
76
+ "aria-relevant"?: "additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text" | "text additions" | "text removals" | undefined | undefined;
77
+ "aria-required"?: (boolean | "true" | "false") | undefined;
78
+ "aria-roledescription"?: string | undefined | undefined;
79
+ "aria-rowcount"?: number | undefined | undefined;
80
+ "aria-rowindex"?: number | undefined | undefined;
81
+ "aria-rowindextext"?: string | undefined | undefined;
82
+ "aria-rowspan"?: number | undefined | undefined;
83
+ "aria-selected"?: (boolean | "true" | "false") | undefined;
84
+ "aria-setsize"?: number | undefined | undefined;
85
+ "aria-sort"?: "none" | "ascending" | "descending" | "other" | undefined | undefined;
86
+ "aria-valuemax"?: number | undefined | undefined;
87
+ "aria-valuemin"?: number | undefined | undefined;
88
+ "aria-valuenow"?: number | undefined | undefined;
89
+ "aria-valuetext"?: string | undefined | undefined;
90
+ }) => import("react/jsx-runtime").JSX.Element;
91
+ CollapseBlockSecondary: (props: {
92
+ id: string;
93
+ title?: string | undefined;
94
+ afterTitle?: import("react").ReactNode;
95
+ subTitle?: import("react").ReactNode;
96
+ children?: import("react").ReactNode;
97
+ className?: string | undefined;
98
+ view?: import("./types").View | undefined;
99
+ chevronPosition?: import("./types").ChevronPosition | undefined;
100
+ backgroundPredefined?: import("@cloud-ru/ds-materials").BackgroundPredefinedFill | undefined;
101
+ keepMounted?: boolean | undefined;
102
+ showChevron?: boolean | undefined;
103
+ 'data-test-id'?: string | undefined;
104
+ "aria-activedescendant"?: string | undefined | undefined;
105
+ "aria-atomic"?: (boolean | "true" | "false") | undefined;
106
+ "aria-autocomplete"?: "none" | "inline" | "list" | "both" | undefined | undefined;
107
+ "aria-braillelabel"?: string | undefined | undefined;
108
+ "aria-brailleroledescription"?: string | undefined | undefined;
109
+ "aria-busy"?: (boolean | "true" | "false") | undefined;
110
+ "aria-checked"?: boolean | "false" | "mixed" | "true" | undefined | undefined;
111
+ "aria-colcount"?: number | undefined | undefined;
112
+ "aria-colindex"?: number | undefined | undefined;
113
+ "aria-colindextext"?: string | undefined | undefined;
114
+ "aria-colspan"?: number | undefined | undefined;
115
+ "aria-controls"?: string | undefined | undefined;
116
+ "aria-current"?: boolean | "false" | "true" | "page" | "step" | "location" | "date" | "time" | undefined | undefined;
117
+ "aria-describedby"?: string | undefined | undefined;
118
+ "aria-description"?: string | undefined | undefined;
119
+ "aria-details"?: string | undefined | undefined;
120
+ "aria-disabled"?: (boolean | "true" | "false") | undefined;
121
+ "aria-dropeffect"?: "none" | "copy" | "execute" | "link" | "move" | "popup" | undefined | undefined;
122
+ "aria-errormessage"?: string | undefined | undefined;
123
+ "aria-expanded"?: (boolean | "true" | "false") | undefined;
124
+ "aria-flowto"?: string | undefined | undefined;
125
+ "aria-grabbed"?: (boolean | "true" | "false") | undefined;
126
+ "aria-haspopup"?: boolean | "false" | "true" | "menu" | "listbox" | "tree" | "grid" | "dialog" | undefined | undefined;
127
+ "aria-hidden"?: (boolean | "true" | "false") | undefined;
128
+ "aria-invalid"?: boolean | "false" | "true" | "grammar" | "spelling" | undefined | undefined;
129
+ "aria-keyshortcuts"?: string | undefined | undefined;
130
+ "aria-label"?: string | undefined | undefined;
131
+ "aria-labelledby"?: string | undefined | undefined;
132
+ "aria-level"?: number | undefined | undefined;
133
+ "aria-live"?: "off" | "assertive" | "polite" | undefined | undefined;
134
+ "aria-modal"?: (boolean | "true" | "false") | undefined;
135
+ "aria-multiline"?: (boolean | "true" | "false") | undefined;
136
+ "aria-multiselectable"?: (boolean | "true" | "false") | undefined;
137
+ "aria-orientation"?: "horizontal" | "vertical" | undefined | undefined;
138
+ "aria-owns"?: string | undefined | undefined;
139
+ "aria-placeholder"?: string | undefined | undefined;
140
+ "aria-posinset"?: number | undefined | undefined;
141
+ "aria-pressed"?: boolean | "false" | "mixed" | "true" | undefined | undefined;
142
+ "aria-readonly"?: (boolean | "true" | "false") | undefined;
143
+ "aria-relevant"?: "additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text" | "text additions" | "text removals" | undefined | undefined;
144
+ "aria-required"?: (boolean | "true" | "false") | undefined;
145
+ "aria-roledescription"?: string | undefined | undefined;
146
+ "aria-rowcount"?: number | undefined | undefined;
147
+ "aria-rowindex"?: number | undefined | undefined;
148
+ "aria-rowindextext"?: string | undefined | undefined;
149
+ "aria-rowspan"?: number | undefined | undefined;
150
+ "aria-selected"?: (boolean | "true" | "false") | undefined;
151
+ "aria-setsize"?: number | undefined | undefined;
152
+ "aria-sort"?: "none" | "ascending" | "descending" | "other" | undefined | undefined;
153
+ "aria-valuemax"?: number | undefined | undefined;
154
+ "aria-valuemin"?: number | undefined | undefined;
155
+ "aria-valuenow"?: number | undefined | undefined;
156
+ "aria-valuetext"?: string | undefined | undefined;
157
+ }) => import("react/jsx-runtime").JSX.Element;
158
+ CollapseBlockTertiary: (props: import("./components/CollapseBlock").CollapseBlockTertiaryProps) => import("react/jsx-runtime").JSX.Element;
159
+ };
160
+ export {};