@cloud-ru/ds-list 3.1.5 → 3.1.6-preview-15dc0d59.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/README.md CHANGED
@@ -683,13 +683,10 @@ List в popover. Оборачивает триггер (кнопку / поле)
683
683
 
684
684
  ### Анатомия
685
685
 
686
- #### Size (default `s`)
687
-
688
- Размер задаёт высоту строки списка (Figma `listItem`): `s` = 40px, `m` = 52px, `l` = 66px. Совпадает с `size` у **List**.
686
+ #### Размер строк
689
687
 
690
- - `s` — дефолт. Компактные селекторы у кнопок toolbar/header.
691
- - `m` — списки объектов с описанием.
692
- - `l` — крупные меню, mobile.
688
+ `size` задаёт размер строк: `s`, `m` или `l`. Фактическая высота зависит от платформы и плотности темы.
689
+ Дефолты по раскладкам и их переопределение описаны в разделе [Адаптивность](#adaptive).
693
690
 
694
691
  #### Selection mode (default off)
695
692
 
@@ -966,6 +963,7 @@ export function DroplistWithHeader() {
966
963
  | `itemRender` | `((props: ItemRenderProps) => ReactNode)` | — | Рендер-функция оболочки строки вместо дефолтной разметки `BaseItem`. <br/> Не задана — строка рисуется как раньше. `itemWrapRender` по-прежнему оборачивает результат. |
967
964
  | `items` | `BaseItemWithoutNonGroup` \| `CommonGroupItem` \| `Item` \| `ScrollProps` | — | Основные элементы списка |
968
965
  | `label` | `string` | — | Только mobile (`BottomSheet`): заголовок шапки. |
966
+ | `layoutPresets` | `DroplistLayoutDefaults` \| `LayoutPresets` | — | Переопределение размера списка по раскладке. На mobile по умолчанию `l`. |
969
967
  | `limitedScrollHeight` | `boolean` | — | Ограничить максимальную высоту скролл-контейнера в зависимости от `size` |
970
968
  | `listRef` | `RefObject<HTMLElement>` | — | Ссылка на элемент выпадающего списка |
971
969
  | `loading` | `boolean` | — | Флаг, отвечающий за состояние загрузки списка |
@@ -1043,6 +1041,12 @@ export function DroplistWithHeader() {
1043
1041
  | `label` | `string \| undefined` | — | Заголовок группы |
1044
1042
  | `truncate` | `{ variant?: TruncateStringProps["variant"]; } \| undefined` | — | Настройки усечения длинного заголовка группы |
1045
1043
 
1044
+ **DroplistLayoutDefaults**
1045
+
1046
+ | Prop | Type | Default | Description |
1047
+ |------|------|---------|-------------|
1048
+ | `size` | `"l"` \| `"m"` \| `"s"` | — | Размер списка |
1049
+
1046
1050
  **EmptyStateProps**
1047
1051
 
1048
1052
  | Prop | Type | Default | Description |
@@ -1069,8 +1073,6 @@ export function DroplistWithHeader() {
1069
1073
 
1070
1074
  - `ItemId` = `string | number`
1071
1075
 
1072
- - `OnChangeHandler` = `(value: T) => void`
1073
-
1074
1076
  **ScrollProps**
1075
1077
 
1076
1078
  | Prop | Type | Default | Description |
@@ -1154,6 +1156,25 @@ export function DroplistWithHeader() {
1154
1156
 
1155
1157
  Верстайте под desktop и поставьте один `<AdaptiveProvider>` в корне приложения — mobile-поверхность включается автоматически (desktop-first). Пропа `layoutType` у компонента нет: источник раскладки — только контекст.
1156
1158
 
1159
+ #### Размер по раскладке
1160
+
1161
+ | Проп | desktop | mobile |
1162
+ |------|---------|--------|
1163
+ | `size` | `m` по умолчанию; можно задать обычным пропом | `l` по умолчанию; переопределяется через `layoutPresets.mobile.size` |
1164
+
1165
+ Приоритет: `layoutPresets` для текущей раскладки → пресет компонента → обычный проп → базовый дефолт.
1166
+ Поэтому `size='s'` задаёт размер S на desktop, а на mobile сохраняется L.
1167
+
1168
+ ```tsx
1169
+ // S на desktop, L на mobile
1170
+ <Droplist size='s' items={items}>{trigger}</Droplist>
1171
+
1172
+ // S на обеих раскладках
1173
+ <Droplist size='s' layoutPresets={{ mobile: { size: 's' } }} items={items}>
1174
+ {trigger}
1175
+ </Droplist>
1176
+ ```
1177
+
1157
1178
  #### Как форсировать платформу
1158
1179
 
1159
1180
  Форс — только контекстом, не пропом:
@@ -1183,7 +1204,8 @@ export function DroplistWithHeader() {
1183
1204
  | `trigger`, `placement`, `widthStrategy`, `triggerElemRef`, `listRef`, `triggerClassName` | используется | игнорируется |
1184
1205
  | `label`, `actionButton`, `slotAfterTitle`, `onBackButtonClick` | игнорируется | используется |
1185
1206
  | `items`, `selection`, `collapse`, `search`, `footer`, `headerDivider`, `footerDivider` | используется | используется |
1186
- | `open`, `onOpenChange`, `closeOnPopstate`, `size` | используется | используется |
1207
+ | `open`, `onOpenChange`, `closeOnPopstate` | используется | используется |
1208
+ | `size`, `layoutPresets` | размер определяется с учётом пресетов | размер определяется с учётом пресетов |
1187
1209
 
1188
1210
  #### Mobile — BottomSheet
1189
1211
 
@@ -1,7 +1,7 @@
1
1
  import { DroplistProps, ReorderableDroplistProps } from '../types';
2
2
  /**
3
3
  * Адаптивный `Droplist`: раскладку берёт из `AdaptiveProvider` (контекст). На `mobile` рендерит
4
- * список (size `m`) в `BottomSheet` (`MobileDroplist`), иначе — анкорный popover (`DesktopDroplist`).
4
+ * список (по умолчанию размера `l`) в `BottomSheet` (`MobileDroplist`), иначе — анкорный popover (`DesktopDroplist`).
5
5
  * Слоты `label` / `actionButton` / `slotAfterTitle` / `onBackButtonClick` применяются только на mobile.
6
6
  * Чтобы всегда был popover — `withLayoutType(Droplist, 'desktop')` либо вложенный
7
7
  * `<AdaptiveProvider layoutType='desktop'>`. Пропа `layoutType` у компонента нет.
@@ -6,17 +6,19 @@ const jsx_runtime_1 = require("react/jsx-runtime");
6
6
  const adaptive_1 = require("@cloud-ru/ds-adaptive");
7
7
  const DesktopDroplist_1 = require("../../../helperComponents/DesktopDroplist");
8
8
  const MobileDroplist_1 = require("../../../helperComponents/MobileDroplist");
9
+ const DROPLIST_LAYOUT_PRESETS = { mobile: { size: 'l' } };
9
10
  /** @internal Общая реализация `Droplist`/`ReorderableDroplist`: свап поверхности по раскладке. */
10
- function DroplistImpl({ children, size = 'm', label, actionButton, slotAfterTitle, onBackButtonClick, ...rest }) {
11
+ function DroplistImpl({ children, size, layoutPresets, label, actionButton, slotAfterTitle, onBackButtonClick, ...rest }) {
11
12
  const { layoutType } = (0, adaptive_1.useAdaptiveLayout)();
13
+ const { size: resolvedSize } = (0, adaptive_1.useLayoutDefaults)({ size: 'm' }, (0, adaptive_1.mergePresets)(DROPLIST_LAYOUT_PRESETS, layoutPresets), { size });
12
14
  if ((0, adaptive_1.isMobileLayout)(layoutType)) {
13
- return ((0, jsx_runtime_1.jsx)(MobileDroplist_1.MobileDroplist, { ...rest, size: 'm', label: label, actionButton: actionButton, slotAfterTitle: slotAfterTitle, onBackButtonClick: onBackButtonClick, children: children }));
15
+ return ((0, jsx_runtime_1.jsx)(MobileDroplist_1.MobileDroplist, { ...rest, size: resolvedSize, label: label, actionButton: actionButton, slotAfterTitle: slotAfterTitle, onBackButtonClick: onBackButtonClick, children: children }));
14
16
  }
15
- return ((0, jsx_runtime_1.jsx)(DesktopDroplist_1.DesktopDroplist, { ...rest, size: size, children: children }));
17
+ return ((0, jsx_runtime_1.jsx)(DesktopDroplist_1.DesktopDroplist, { ...rest, size: resolvedSize, children: children }));
16
18
  }
17
19
  /**
18
20
  * Адаптивный `Droplist`: раскладку берёт из `AdaptiveProvider` (контекст). На `mobile` рендерит
19
- * список (size `m`) в `BottomSheet` (`MobileDroplist`), иначе — анкорный popover (`DesktopDroplist`).
21
+ * список (по умолчанию размера `l`) в `BottomSheet` (`MobileDroplist`), иначе — анкорный popover (`DesktopDroplist`).
20
22
  * Слоты `label` / `actionButton` / `slotAfterTitle` / `onBackButtonClick` применяются только на mobile.
21
23
  * Чтобы всегда был popover — `withLayoutType(Droplist, 'desktop')` либо вложенный
22
24
  * `<AdaptiveProvider layoutType='desktop'>`. Пропа `layoutType` у компонента нет.
@@ -1,4 +1,5 @@
1
1
  import { DragEndEvent } from '@dnd-kit/core';
2
+ import { LayoutPresets } from '@cloud-ru/ds-adaptive';
2
3
  import { BottomSheetProps } from '@cloud-ru/ds-bottom-sheet';
3
4
  import { DropdownProps } from '@cloud-ru/ds-dropdown';
4
5
  import { WithSupportProps } from '@cloud-ru/ds-utils';
@@ -145,6 +146,11 @@ export type ReorderableBaseDroplistProps = DroplistOwnProps & DroplistListProps<
145
146
  * модели айтемов. Публичные `DroplistProps`/`ReorderableDroplistProps` плоские, см. `ListImplProps`.
146
147
  */
147
148
  export type DesktopDroplistProps = DroplistOwnProps & DroplistListProps<ListImplProps>;
149
+ export type DroplistLayoutDefaults = Pick<ListProps, 'size'>;
150
+ type DroplistAdaptiveProps = {
151
+ /** Переопределение размера списка по раскладке. На mobile по умолчанию `l`. */
152
+ layoutPresets?: LayoutPresets<DroplistLayoutDefaults>;
153
+ };
148
154
  /** Только mobile (`BottomSheet`)-слоты адаптивного `Droplist`. */
149
155
  type DroplistMobileSlots = {
150
156
  /** Только mobile (`BottomSheet`): заголовок шапки. */
@@ -159,17 +165,17 @@ type DroplistMobileSlots = {
159
165
  /**
160
166
  * Props адаптивного `Droplist` (дефолтный droplist): базовые props + mobile-слоты `BottomSheet`.
161
167
  * Раскладку берёт из `AdaptiveProvider` (контекст): на `mobile` рендерит `MobileDroplist`
162
- * (список size `m` в `BottomSheet`), иначе — `DesktopDroplist` (анкорный popover). Mobile-слоты
168
+ * (список размера `l` по умолчанию в `BottomSheet`), иначе — `DesktopDroplist` (анкорный popover). Mobile-слоты
163
169
  * применяются только на mobile.
164
170
  */
165
- export type DroplistProps = BaseDroplistProps & DroplistMobileSlots & Pick<BottomSheetProps, 'snapPoints' | 'withDividers'>;
171
+ export type DroplistProps = BaseDroplistProps & DroplistAdaptiveProps & DroplistMobileSlots & Pick<BottomSheetProps, 'snapPoints' | 'withDividers'>;
166
172
  /**
167
173
  * Props адаптивного `ReorderableDroplist`: props `ReorderableList` + popover/mobile-обвязка
168
174
  * `Droplist`. Отдельный компонент по той же причине, что и `ReorderableList`.
169
175
  */
170
- export type ReorderableDroplistProps = ReorderableBaseDroplistProps & DroplistMobileSlots;
176
+ export type ReorderableDroplistProps = ReorderableBaseDroplistProps & DroplistMobileSlots & DroplistAdaptiveProps;
171
177
  /** @internal Props общей реализации адаптивного дроплиста: реализация + mobile-слоты. */
172
- export type DroplistImplProps = DesktopDroplistProps & DroplistMobileSlots;
178
+ export type DroplistImplProps = DesktopDroplistProps & DroplistMobileSlots & DroplistAdaptiveProps;
173
179
  /**
174
180
  * @internal Props mobile-реализации (`BottomSheet`): реализация дроплиста без popover-пропов
175
181
  * + mobile-слоты.
@@ -1,7 +1,7 @@
1
1
  import { DroplistProps, ReorderableDroplistProps } from '../types.js';
2
2
  /**
3
3
  * Адаптивный `Droplist`: раскладку берёт из `AdaptiveProvider` (контекст). На `mobile` рендерит
4
- * список (size `m`) в `BottomSheet` (`MobileDroplist`), иначе — анкорный popover (`DesktopDroplist`).
4
+ * список (по умолчанию размера `l`) в `BottomSheet` (`MobileDroplist`), иначе — анкорный popover (`DesktopDroplist`).
5
5
  * Слоты `label` / `actionButton` / `slotAfterTitle` / `onBackButtonClick` применяются только на mobile.
6
6
  * Чтобы всегда был popover — `withLayoutType(Droplist, 'desktop')` либо вложенный
7
7
  * `<AdaptiveProvider layoutType='desktop'>`. Пропа `layoutType` у компонента нет.
@@ -1,18 +1,20 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { isMobileLayout, useAdaptiveLayout } from '@cloud-ru/ds-adaptive';
2
+ import { isMobileLayout, mergePresets, useAdaptiveLayout, useLayoutDefaults } from '@cloud-ru/ds-adaptive';
3
3
  import { DesktopDroplist } from '../../../helperComponents/DesktopDroplist/index.js';
4
4
  import { MobileDroplist } from '../../../helperComponents/MobileDroplist/index.js';
5
+ const DROPLIST_LAYOUT_PRESETS = { mobile: { size: 'l' } };
5
6
  /** @internal Общая реализация `Droplist`/`ReorderableDroplist`: свап поверхности по раскладке. */
6
- function DroplistImpl({ children, size = 'm', label, actionButton, slotAfterTitle, onBackButtonClick, ...rest }) {
7
+ function DroplistImpl({ children, size, layoutPresets, label, actionButton, slotAfterTitle, onBackButtonClick, ...rest }) {
7
8
  const { layoutType } = useAdaptiveLayout();
9
+ const { size: resolvedSize } = useLayoutDefaults({ size: 'm' }, mergePresets(DROPLIST_LAYOUT_PRESETS, layoutPresets), { size });
8
10
  if (isMobileLayout(layoutType)) {
9
- return (_jsx(MobileDroplist, { ...rest, size: 'm', label: label, actionButton: actionButton, slotAfterTitle: slotAfterTitle, onBackButtonClick: onBackButtonClick, children: children }));
11
+ return (_jsx(MobileDroplist, { ...rest, size: resolvedSize, label: label, actionButton: actionButton, slotAfterTitle: slotAfterTitle, onBackButtonClick: onBackButtonClick, children: children }));
10
12
  }
11
- return (_jsx(DesktopDroplist, { ...rest, size: size, children: children }));
13
+ return (_jsx(DesktopDroplist, { ...rest, size: resolvedSize, children: children }));
12
14
  }
13
15
  /**
14
16
  * Адаптивный `Droplist`: раскладку берёт из `AdaptiveProvider` (контекст). На `mobile` рендерит
15
- * список (size `m`) в `BottomSheet` (`MobileDroplist`), иначе — анкорный popover (`DesktopDroplist`).
17
+ * список (по умолчанию размера `l`) в `BottomSheet` (`MobileDroplist`), иначе — анкорный popover (`DesktopDroplist`).
16
18
  * Слоты `label` / `actionButton` / `slotAfterTitle` / `onBackButtonClick` применяются только на mobile.
17
19
  * Чтобы всегда был popover — `withLayoutType(Droplist, 'desktop')` либо вложенный
18
20
  * `<AdaptiveProvider layoutType='desktop'>`. Пропа `layoutType` у компонента нет.
@@ -1,4 +1,5 @@
1
1
  import { DragEndEvent } from '@dnd-kit/core';
2
+ import { LayoutPresets } from '@cloud-ru/ds-adaptive';
2
3
  import { BottomSheetProps } from '@cloud-ru/ds-bottom-sheet';
3
4
  import { DropdownProps } from '@cloud-ru/ds-dropdown';
4
5
  import { WithSupportProps } from '@cloud-ru/ds-utils';
@@ -145,6 +146,11 @@ export type ReorderableBaseDroplistProps = DroplistOwnProps & DroplistListProps<
145
146
  * модели айтемов. Публичные `DroplistProps`/`ReorderableDroplistProps` плоские, см. `ListImplProps`.
146
147
  */
147
148
  export type DesktopDroplistProps = DroplistOwnProps & DroplistListProps<ListImplProps>;
149
+ export type DroplistLayoutDefaults = Pick<ListProps, 'size'>;
150
+ type DroplistAdaptiveProps = {
151
+ /** Переопределение размера списка по раскладке. На mobile по умолчанию `l`. */
152
+ layoutPresets?: LayoutPresets<DroplistLayoutDefaults>;
153
+ };
148
154
  /** Только mobile (`BottomSheet`)-слоты адаптивного `Droplist`. */
149
155
  type DroplistMobileSlots = {
150
156
  /** Только mobile (`BottomSheet`): заголовок шапки. */
@@ -159,17 +165,17 @@ type DroplistMobileSlots = {
159
165
  /**
160
166
  * Props адаптивного `Droplist` (дефолтный droplist): базовые props + mobile-слоты `BottomSheet`.
161
167
  * Раскладку берёт из `AdaptiveProvider` (контекст): на `mobile` рендерит `MobileDroplist`
162
- * (список size `m` в `BottomSheet`), иначе — `DesktopDroplist` (анкорный popover). Mobile-слоты
168
+ * (список размера `l` по умолчанию в `BottomSheet`), иначе — `DesktopDroplist` (анкорный popover). Mobile-слоты
163
169
  * применяются только на mobile.
164
170
  */
165
- export type DroplistProps = BaseDroplistProps & DroplistMobileSlots & Pick<BottomSheetProps, 'snapPoints' | 'withDividers'>;
171
+ export type DroplistProps = BaseDroplistProps & DroplistAdaptiveProps & DroplistMobileSlots & Pick<BottomSheetProps, 'snapPoints' | 'withDividers'>;
166
172
  /**
167
173
  * Props адаптивного `ReorderableDroplist`: props `ReorderableList` + popover/mobile-обвязка
168
174
  * `Droplist`. Отдельный компонент по той же причине, что и `ReorderableList`.
169
175
  */
170
- export type ReorderableDroplistProps = ReorderableBaseDroplistProps & DroplistMobileSlots;
176
+ export type ReorderableDroplistProps = ReorderableBaseDroplistProps & DroplistMobileSlots & DroplistAdaptiveProps;
171
177
  /** @internal Props общей реализации адаптивного дроплиста: реализация + mobile-слоты. */
172
- export type DroplistImplProps = DesktopDroplistProps & DroplistMobileSlots;
178
+ export type DroplistImplProps = DesktopDroplistProps & DroplistMobileSlots & DroplistAdaptiveProps;
173
179
  /**
174
180
  * @internal Props mobile-реализации (`BottomSheet`): реализация дроплиста без popover-пропов
175
181
  * + mobile-слоты.