@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud-ru/ds-list",
3
- "version": "3.1.5",
3
+ "version": "3.1.6-preview-15dc0d59.0",
4
4
  "description": "Списочный UI — компонент List для плоских/вложенных списков с выбором, группами и поиском и Droplist — тот же список в поповере.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -48,24 +48,24 @@
48
48
  "@tanstack/react-virtual": "^3.14.8",
49
49
  "classnames": "^2.5.1",
50
50
  "merge-refs": "^2.0.0",
51
- "@cloud-ru/ds-adaptive": "^1.0.6",
52
- "@cloud-ru/ds-button": "^1.0.8",
53
- "@cloud-ru/ds-bottom-sheet": "^2.3.1",
54
- "@cloud-ru/ds-drag-and-drop": "^1.1.7",
55
- "@cloud-ru/ds-divider": "^1.0.6",
56
- "@cloud-ru/ds-dropdown": "^1.2.5",
57
- "@cloud-ru/ds-icons": "^1.8.0",
58
- "@cloud-ru/ds-info-block": "^1.0.7",
59
- "@cloud-ru/ds-loader": "^1.0.7",
60
- "@cloud-ru/ds-materials": "^2.0.5",
61
- "@cloud-ru/ds-portal-context": "^1.0.6",
62
- "@cloud-ru/ds-scroll": "^1.0.9",
63
- "@cloud-ru/ds-search-private": "^1.0.23",
64
- "@cloud-ru/ds-truncate-string": "^1.0.23",
65
- "@cloud-ru/ds-toggles": "^1.1.19",
66
- "@cloud-ru/ds-utils": "^1.4.2"
51
+ "@cloud-ru/ds-adaptive": "1.0.6",
52
+ "@cloud-ru/ds-bottom-sheet": "2.3.2-preview-15dc0d59.0",
53
+ "@cloud-ru/ds-button": "1.0.9-preview-15dc0d59.0",
54
+ "@cloud-ru/ds-divider": "1.0.6",
55
+ "@cloud-ru/ds-drag-and-drop": "1.1.7",
56
+ "@cloud-ru/ds-dropdown": "1.2.6-preview-15dc0d59.0",
57
+ "@cloud-ru/ds-info-block": "1.0.7",
58
+ "@cloud-ru/ds-icons": "1.8.0",
59
+ "@cloud-ru/ds-loader": "1.0.7",
60
+ "@cloud-ru/ds-materials": "2.0.5",
61
+ "@cloud-ru/ds-scroll": "1.0.9",
62
+ "@cloud-ru/ds-portal-context": "1.0.6",
63
+ "@cloud-ru/ds-search-private": "1.0.24-preview-15dc0d59.0",
64
+ "@cloud-ru/ds-toggles": "1.1.19",
65
+ "@cloud-ru/ds-truncate-string": "1.0.23",
66
+ "@cloud-ru/ds-utils": "1.4.2"
67
67
  },
68
68
  "peerDependencies": {
69
- "@cloud-ru/ds-locale": "^1.0.0"
69
+ "@cloud-ru/ds-locale": "1.0.0"
70
70
  }
71
71
  }
@@ -1,13 +1,16 @@
1
- import { isMobileLayout, useAdaptiveLayout } from '@cloud-ru/ds-adaptive';
1
+ import { isMobileLayout, LayoutPresets, mergePresets, useAdaptiveLayout, useLayoutDefaults } from '@cloud-ru/ds-adaptive';
2
2
 
3
3
  import { DesktopDroplist } from '../../../helperComponents/DesktopDroplist';
4
4
  import { MobileDroplist } from '../../../helperComponents/MobileDroplist';
5
- import { DroplistImplProps, DroplistProps, ReorderableDroplistProps } from '../types';
5
+ import { DroplistImplProps, DroplistLayoutDefaults, DroplistProps, ReorderableDroplistProps } from '../types';
6
+
7
+ const DROPLIST_LAYOUT_PRESETS: LayoutPresets<DroplistLayoutDefaults> = { mobile: { size: 'l' } };
6
8
 
7
9
  /** @internal Общая реализация `Droplist`/`ReorderableDroplist`: свап поверхности по раскладке. */
8
10
  function DroplistImpl({
9
11
  children,
10
- size = 'm',
12
+ size,
13
+ layoutPresets,
11
14
  label,
12
15
  actionButton,
13
16
  slotAfterTitle,
@@ -16,11 +19,17 @@ function DroplistImpl({
16
19
  }: DroplistImplProps) {
17
20
  const { layoutType } = useAdaptiveLayout();
18
21
 
22
+ const { size: resolvedSize } = useLayoutDefaults<DroplistLayoutDefaults>(
23
+ { size: 'm' },
24
+ mergePresets(DROPLIST_LAYOUT_PRESETS, layoutPresets),
25
+ { size },
26
+ );
27
+
19
28
  if (isMobileLayout(layoutType)) {
20
29
  return (
21
30
  <MobileDroplist
22
31
  {...rest}
23
- size='m'
32
+ size={resolvedSize}
24
33
  label={label}
25
34
  actionButton={actionButton}
26
35
  slotAfterTitle={slotAfterTitle}
@@ -32,7 +41,7 @@ function DroplistImpl({
32
41
  }
33
42
 
34
43
  return (
35
- <DesktopDroplist {...rest} size={size}>
44
+ <DesktopDroplist {...rest} size={resolvedSize}>
36
45
  {children}
37
46
  </DesktopDroplist>
38
47
  );
@@ -40,7 +49,7 @@ function DroplistImpl({
40
49
 
41
50
  /**
42
51
  * Адаптивный `Droplist`: раскладку берёт из `AdaptiveProvider` (контекст). На `mobile` рендерит
43
- * список (size `m`) в `BottomSheet` (`MobileDroplist`), иначе — анкорный popover (`DesktopDroplist`).
52
+ * список (по умолчанию размера `l`) в `BottomSheet` (`MobileDroplist`), иначе — анкорный popover (`DesktopDroplist`).
44
53
  * Слоты `label` / `actionButton` / `slotAfterTitle` / `onBackButtonClick` применяются только на mobile.
45
54
  * Чтобы всегда был popover — `withLayoutType(Droplist, 'desktop')` либо вложенный
46
55
  * `<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';
@@ -172,6 +173,13 @@ export type ReorderableBaseDroplistProps = DroplistOwnProps & DroplistListProps<
172
173
  */
173
174
  export type DesktopDroplistProps = DroplistOwnProps & DroplistListProps<ListImplProps>;
174
175
 
176
+ export type DroplistLayoutDefaults = Pick<ListProps, 'size'>;
177
+
178
+ type DroplistAdaptiveProps = {
179
+ /** Переопределение размера списка по раскладке. На mobile по умолчанию `l`. */
180
+ layoutPresets?: LayoutPresets<DroplistLayoutDefaults>;
181
+ };
182
+
175
183
  /** Только mobile (`BottomSheet`)-слоты адаптивного `Droplist`. */
176
184
  type DroplistMobileSlots = {
177
185
  /** Только mobile (`BottomSheet`): заголовок шапки. */
@@ -187,10 +195,11 @@ type DroplistMobileSlots = {
187
195
  /**
188
196
  * Props адаптивного `Droplist` (дефолтный droplist): базовые props + mobile-слоты `BottomSheet`.
189
197
  * Раскладку берёт из `AdaptiveProvider` (контекст): на `mobile` рендерит `MobileDroplist`
190
- * (список size `m` в `BottomSheet`), иначе — `DesktopDroplist` (анкорный popover). Mobile-слоты
198
+ * (список размера `l` по умолчанию в `BottomSheet`), иначе — `DesktopDroplist` (анкорный popover). Mobile-слоты
191
199
  * применяются только на mobile.
192
200
  */
193
201
  export type DroplistProps = BaseDroplistProps &
202
+ DroplistAdaptiveProps &
194
203
  DroplistMobileSlots &
195
204
  Pick<BottomSheetProps, 'snapPoints' | 'withDividers'>;
196
205
 
@@ -198,10 +207,10 @@ export type DroplistProps = BaseDroplistProps &
198
207
  * Props адаптивного `ReorderableDroplist`: props `ReorderableList` + popover/mobile-обвязка
199
208
  * `Droplist`. Отдельный компонент по той же причине, что и `ReorderableList`.
200
209
  */
201
- export type ReorderableDroplistProps = ReorderableBaseDroplistProps & DroplistMobileSlots;
210
+ export type ReorderableDroplistProps = ReorderableBaseDroplistProps & DroplistMobileSlots & DroplistAdaptiveProps;
202
211
 
203
212
  /** @internal Props общей реализации адаптивного дроплиста: реализация + mobile-слоты. */
204
- export type DroplistImplProps = DesktopDroplistProps & DroplistMobileSlots;
213
+ export type DroplistImplProps = DesktopDroplistProps & DroplistMobileSlots & DroplistAdaptiveProps;
205
214
 
206
215
  /**
207
216
  * @internal Props mobile-реализации (`BottomSheet`): реализация дроплиста без popover-пропов