@synerise/ds-item-picker 2.3.0 → 2.4.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/CHANGELOG.md +16 -0
- package/CLAUDE.md +67 -9
- package/README.md +42 -0
- package/dist/components/ItemPickerList/ItemPickerList.js +40 -8
- package/dist/components/ItemPickerList/ItemPickerList.styles.d.ts +4 -1
- package/dist/components/ItemPickerList/ItemPickerList.styles.js +21 -6
- package/dist/components/ItemPickerList/components/EmptyListMessage.d.ts +3 -2
- package/dist/components/ItemPickerList/components/EmptyListMessage.js +4 -0
- package/dist/components/ItemPickerList/components/ItemPickerListRow.js +1 -1
- package/dist/components/ItemPickerList/components/ItemPickerListSkeleton.d.ts +3 -1
- package/dist/components/ItemPickerList/components/ItemPickerListSkeleton.js +17 -10
- package/dist/components/ItemPickerList/components/ListSearchInput.d.ts +3 -1
- package/dist/components/ItemPickerList/components/ListSearchInput.js +10 -3
- package/dist/components/ItemPickerList/constants.d.ts +2 -0
- package/dist/components/ItemPickerList/constants.js +4 -0
- package/dist/components/ItemPickerList/hooks/index.d.ts +1 -0
- package/dist/components/ItemPickerList/hooks/index.js +2 -0
- package/dist/components/ItemPickerList/hooks/useFolderLevel.d.ts +9 -0
- package/dist/components/ItemPickerList/hooks/useFolderLevel.js +31 -0
- package/dist/components/ItemPickerList/hooks/useItemsInSections.d.ts +5 -0
- package/dist/components/ItemPickerList/hooks/useItemsInSections.js +208 -68
- package/dist/components/ItemPickerList/hooks/useItemsInSections.utils.d.ts +9 -1
- package/dist/components/ItemPickerList/hooks/useItemsInSections.utils.js +33 -1
- package/dist/components/ItemPickerList/types/renderMode.d.ts +1 -0
- package/dist/components/ItemPickerList/types/renderMode.js +2 -1
- package/dist/components/ItemPickerList/utils/actionItemsUtils.js +6 -2
- package/dist/components/ItemPickerList/utils/formatFolderPath.d.ts +4 -0
- package/dist/components/ItemPickerList/utils/formatFolderPath.js +13 -0
- package/dist/components/ItemPickerList/utils/index.d.ts +1 -0
- package/dist/components/ItemPickerList/utils/index.js +5 -1
- package/dist/components/ItemPickerList/utils/typeguards.utils.d.ts +7 -2
- package/dist/components/ItemPickerList/utils/typeguards.utils.js +4 -0
- package/dist/components/ItemPickerNew/ItemPickerNew.js +5 -3
- package/dist/components/ItemPickerNew/ItemPickerNew.types.d.ts +2 -1
- package/dist/components/ItemPickerNew/types/actions.types.d.ts +5 -0
- package/dist/components/ItemPickerNew/types/itemPickerListTexts.types.d.ts +1 -1
- package/dist/components/ItemPickerNew/types/mixedLoader.types.d.ts +52 -0
- package/dist/components/ItemPickerNew/types/mixedLoader.types.js +1 -0
- package/dist/hooks/useDefaultTexts.js +8 -0
- package/dist/index.d.ts +1 -0
- package/package.json +23 -23
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [2.4.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-item-picker@2.3.0...@synerise/ds-item-picker@2.4.0) (2026-11-03)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **item-picker:** keep the dropdown open when the selected item's label refreshes ([d294c83](https://github.com/Synerise/synerise-design/commit/d294c83dc48a58bedb34293fda1018cc91e94fd4))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* **item-picker:** add a mixed list mode and open row cards on keyboard focus ([7237582](https://github.com/Synerise/synerise-design/commit/7237582567e8ab83877b945f7fd5a072b9858ee6))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
# [2.3.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-item-picker@2.2.3...@synerise/ds-item-picker@2.3.0) (2026-10-29)
|
|
7
23
|
|
|
8
24
|
|
package/CLAUDE.md
CHANGED
|
@@ -19,7 +19,8 @@ src/
|
|
|
19
19
|
types/
|
|
20
20
|
actions.types.ts — Action union type (redirect | custom | searchBy | searchIn)
|
|
21
21
|
baseItemSectionType.types.ts — BaseItemType, BaseSectionType, BaseSectionTypeWithFolders
|
|
22
|
-
itemPickerListTexts.types.ts — ItemPickerListTexts (
|
|
22
|
+
itemPickerListTexts.types.ts — ItemPickerListTexts (23 list text keys)
|
|
23
|
+
mixedLoader.types.ts — MixedLoaderConfig, LoadLevelParams/Result, LevelEntry, FolderNode, PathStep
|
|
23
24
|
ItemPickerList/
|
|
24
25
|
ItemPickerList.tsx — virtualised list (react-window VariableSizeList), search, sections, keyboard nav
|
|
25
26
|
ItemPickerList.types.ts — ItemPickerListAPI, ItemSelectHandler, ItemPickerListRef
|
|
@@ -30,10 +31,12 @@ src/
|
|
|
30
31
|
useItemsInSections.tsx — core state machine: section/folder navigation, async loading, infinite scroll, search
|
|
31
32
|
useItemsInSections.utils.tsx
|
|
32
33
|
useFlattenFolders.ts — resolves nested folder structure
|
|
34
|
+
useFolderLevel.ts — mixed mode: current folderId and path; openFolder / goUp / reset
|
|
33
35
|
useListHeight.ts — calculates outer/list/offset heights from containerHeight config
|
|
34
36
|
utils/
|
|
35
37
|
actionItemsUtils.tsx — builds action rows in the list
|
|
36
38
|
createTitleFromTitlePath.ts
|
|
39
|
+
formatFolderPath.ts — mixed mode back header: " / " join, middle collapsed past 4 steps
|
|
37
40
|
findSectionById.ts — exported utility
|
|
38
41
|
getContextAwareActions.ts
|
|
39
42
|
getSearchByActionItems.tsx
|
|
@@ -84,13 +87,13 @@ Current API. Generic over `ItemType extends BaseItemType` and `SectionType exten
|
|
|
84
87
|
| Prop | Type | Default | Description |
|
|
85
88
|
|------|------|---------|-------------|
|
|
86
89
|
| `isNewVersion` | `true` | — | **Required** discriminant to select this branch via `ItemPicker` default export |
|
|
87
|
-
| `items` | `ItemType[] \| ItemsConfig<ItemType> \| ItemLoaderConfig<ItemType>` | — | Fixed array, array-with-limit config,
|
|
88
|
-
| `selectedItem?` | `ItemType` | — | Currently selected item |
|
|
90
|
+
| `items` | `ItemType[] \| ItemsConfig<ItemType> \| ItemLoaderConfig<ItemType> \| MixedLoaderConfig<ItemType>` | — | Fixed array, array-with-limit config, async loader config, or a mixed loader (mixed list: folders and items side by side) |
|
|
91
|
+
| `selectedItem?` | `ItemType` | — | Currently selected item; a new item key set via this prop closes the dropdown, a refreshed label of the same item keeps it open |
|
|
89
92
|
| `onChange?` | `(item: ItemType) => void` | — | Called when an item is selected; dropdown closes automatically |
|
|
90
93
|
| `onClear?` | `() => void` | — | Called when the trigger clear icon is clicked |
|
|
91
94
|
| `sections?` | `BaseSectionTypeWithFolders<SectionType>[]` | — | Section/folder tree; enables section-navigation mode |
|
|
92
95
|
| `recents?` | `ItemType[]` | — | Recent items shown at top |
|
|
93
|
-
| `actions?` | `Action[]` | — | Action rows (redirect / custom / searchBy / searchIn); shown on `/` keystroke |
|
|
96
|
+
| `actions?` | `Action[]` | — | Action rows (redirect / custom / searchBy / searchIn); shown on `/` keystroke. `showInList: false` on an action keeps it out of the list, offered only under `/` |
|
|
94
97
|
| `isLoading?` | `boolean` | — | External loading state (shows skeleton) |
|
|
95
98
|
| `onRefresh?` | `() => void` | — | Enables footer refresh button (async items also get an auto refresh) |
|
|
96
99
|
| `onSectionChange?` | `(section?) => void` | — | Fired when the user navigates into a section |
|
|
@@ -102,7 +105,7 @@ Current API. Generic over `ItemType extends BaseItemType` and `SectionType exten
|
|
|
102
105
|
| `searchBarProps?` | `Omit<SearchBarProps, 'value' \| 'onSearchChange' \| 'placeholder'>` | — | Extra props for the search bar |
|
|
103
106
|
| `includeFooter?` | `boolean` | `true` | Show refresh footer |
|
|
104
107
|
| `includeSearchBar?` | `boolean` | `true` | Show search bar |
|
|
105
|
-
| `texts?` | `Partial<ItemPickerTexts>` | (react-intl defaults) | Override any
|
|
108
|
+
| `texts?` | `Partial<ItemPickerTexts>` | (react-intl defaults) | Override any localised text (23 list + 5 trigger keys) |
|
|
106
109
|
| `triggerProps?` | `{ size?, allowClear?, withChangeButton?, withClearConfirmation?, informationCardTooltipProps? }` | — | Props forwarded to the default `Trigger`; its information card stays closed while the dropdown is open |
|
|
107
110
|
| `renderTrigger?` | `(props) => ReactNode` | — | Completely replace the trigger; receives `{ selected, opened, openDropdown, closeDropdown, error, disabled }` — wrap it in an `InformationCardTooltip` with `disabled={opened}` so the card never covers the open list |
|
|
108
111
|
| `placeholder?` | `ReactNode` | — | Trigger placeholder text |
|
|
@@ -201,7 +204,8 @@ The standalone trigger button, exported for custom dropdown implementations.
|
|
|
201
204
|
| `BaseItemType` | Minimum item shape |
|
|
202
205
|
| `BaseSectionType` | Minimum section shape; optional `tooltip` puts an info icon with that tooltip on the section's title row |
|
|
203
206
|
| `BaseSectionTypeWithFolders` | Section with optional `folders` tree |
|
|
204
|
-
| `ItemPickerListTexts` |
|
|
207
|
+
| `ItemPickerListTexts` | The 23 list text keys |
|
|
208
|
+
| `MixedLoaderConfig`, `LoadLevelParams`, `LoadLevelResult`, `LevelEntry`, `FolderNode`, `PathStep` | Mixed list mode |
|
|
205
209
|
| `Action` | Union of action types |
|
|
206
210
|
| `findSectionById` | Utility: finds a section by id in a nested section tree |
|
|
207
211
|
|
|
@@ -257,6 +261,57 @@ const loaderConfig: ItemLoaderConfig<MyItem> = {
|
|
|
257
261
|
/>
|
|
258
262
|
```
|
|
259
263
|
|
|
264
|
+
### Mixed list
|
|
265
|
+
|
|
266
|
+
Folders and items side by side on the same level, one level at a time (folders first). Unlike the
|
|
267
|
+
section and folder modes, a level can hold both. A folder opens the next level instead of being picked.
|
|
268
|
+
|
|
269
|
+
```tsx
|
|
270
|
+
import ItemPicker, { type MixedLoaderConfig } from '@synerise/ds-item-picker';
|
|
271
|
+
|
|
272
|
+
const folders: MixedLoaderConfig<MyItem> = {
|
|
273
|
+
rowSize: 'default', // 'large' for image-only pickers
|
|
274
|
+
loadLevel: async ({ folderId, searchQuery, searchKey, page, limit, abortController }) => {
|
|
275
|
+
const data = await fetchLevel({ folderId, searchQuery, searchKey, page, limit, signal: abortController?.signal });
|
|
276
|
+
return {
|
|
277
|
+
entries: [
|
|
278
|
+
...data.folders.map((folder) => ({ type: 'folder', folder: { id: folder.id, text: folder.name } })),
|
|
279
|
+
...data.items.map((item) => ({ type: 'item', item, location: item.path })),
|
|
280
|
+
],
|
|
281
|
+
total: data.total,
|
|
282
|
+
path: data.path, // [{ id: null, text: 'All' }, …, the current folder]
|
|
283
|
+
};
|
|
284
|
+
},
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
<ItemPicker isNewVersion items={folders} onChange={handleChange} placeholder="Choose a file" />
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
**The `loadLevel` contract**
|
|
291
|
+
- No `searchQuery`: the contents of `folderId` (`null` = root), one page, **folders first**. `total`
|
|
292
|
+
counts the whole level.
|
|
293
|
+
- With `searchQuery`: matches from `folderId` **and every level below it**. Give each entry a
|
|
294
|
+
`location` (its path); large rows show it as the second line.
|
|
295
|
+
- `searchKey`: the active Search-by parameter. A parameter folders do not have → return items only.
|
|
296
|
+
- `path`: from the root to `folderId`; the back header shows it and the root's `text` titles the top level.
|
|
297
|
+
- A folder with nothing the field can take: `disabled: true` with a `disabledReason` ("Empty") — the
|
|
298
|
+
row stays, greyed, and does not open.
|
|
299
|
+
- Respect `abortController`: the list cancels a level's load when the level or the query changes.
|
|
300
|
+
|
|
301
|
+
**Behaviour**
|
|
302
|
+
- Back header: the folder path joined with " / ", the middle collapsed past four steps (full path in
|
|
303
|
+
the tooltip). Placeholder inside a folder: `searchInFolderPlaceholder`.
|
|
304
|
+
- Recent and the "Actions" list only at the top level; while searching, matching actions are listed
|
|
305
|
+
(except `showInList: false`). **Search in is not supported** in this mode — `searchIn` actions are
|
|
306
|
+
left out.
|
|
307
|
+
- Keyboard: → opens a focused folder, ← on a row and Backspace in an empty search go one level up
|
|
308
|
+
(Backspace drops a Search-by parameter first), ⌘← as in the other modes.
|
|
309
|
+
- Search results are a flat list under "Results"; the location is in the object's card
|
|
310
|
+
(`informationCardProps`), shown on hover and keyboard focus.
|
|
311
|
+
- `rowSize: 'large'`: 50px rows with a 40px folder tile, large skeleton rows; items without their own
|
|
312
|
+
`size` follow it. The card height is the DS preset (a taller card for large rows is a follow-up).
|
|
313
|
+
- Paging: `limitPerPage` (default 30); the next page loads at the end of the list.
|
|
314
|
+
|
|
260
315
|
### Imperative reload via ref
|
|
261
316
|
|
|
262
317
|
```tsx
|
|
@@ -286,7 +341,7 @@ import { ItemPickerList } from '@synerise/ds-item-picker';
|
|
|
286
341
|
- All styled-components; no hardcoded colours — uses `var(--ds-*)` tokens.
|
|
287
342
|
- The outer wrapper is `S.ItemPickerWrapper` (just `position: relative`).
|
|
288
343
|
- List layout driven by `useListHeight`; default height 420 px, drops to 350 px below 800 px viewport threshold.
|
|
289
|
-
- `containerHeight` prop accepts `'fitContent'
|
|
344
|
+
- `containerHeight` prop accepts `'fitContent'`, `'fillSpace'` (100%), or an explicit `HeightConfig` object. `fitContent` is for lists known up front (a fixed `items` array): one height, computed for the largest view the structure can show, that stays the same across sections, folders and search so the dropdown never repositions. A loaded list (including the mixed list) uses the preset height.
|
|
290
345
|
|
|
291
346
|
---
|
|
292
347
|
|
|
@@ -314,18 +369,21 @@ import { ItemPickerList } from '@synerise/ds-item-picker';
|
|
|
314
369
|
- **Async loading race prevention**: `useItemsInSections` tracks a `requestIdRef` UUID and discards stale responses.
|
|
315
370
|
- **AbortController**: each `loadItems` call gets a fresh `AbortController`; the previous one is aborted on re-trigger (section change, search, refresh).
|
|
316
371
|
- **Search action trigger**: typing `/` into the search bar activates the global actions list (`listActions = searchQuery === '/'`).
|
|
317
|
-
- **Infinite scroll**:
|
|
372
|
+
- **Infinite scroll**: active for `ItemLoaderConfig` items in `LIST_ITEMS` and for `MixedLoaderConfig` levels. Pages are tracked via `pageToLoad.current`; a first page whose `total` fits marks the list loaded (no second request, no "All items loaded"). Deduplication relies on the caller returning accurate `total`.
|
|
318
373
|
- **Section tooltips**: a section's `tooltip` renders on its **title row** only (an `InfoFillS` icon in `ds-tooltip`), never on the folder row that opens it. Top-level section titles take it in `LIST_FOLDERS_IN_SECTIONS`; a folder's title (or title path, e.g. "Attributes - Ready to use") takes it when its items are listed under it. The icon sits in a negative-margin wrapper so the title stays as tall as its `ITEM_SIZE.title` estimate.
|
|
319
374
|
- **Measured row heights**: rows report real heights through `useMeasuredRowHeights` (`@synerise/ds-utils`). Each row's floor is its **estimate** (`getMeasuredRowStyle(style, getEstimatedItemSize(index))`), never react-window's `style.height`, so a row measures shorter again when its key last stood for a taller row. Row keys are `itemKey ?? key ?? id`, falling back to the position only for rows with no id at all.
|
|
320
375
|
- **Section/folder rendering modes** (`renderMode.ts`):
|
|
321
376
|
- `LIST_ITEMS` — flat list
|
|
322
377
|
- `LIST_ITEMS_IN_SECTIONS` — items grouped under section headers
|
|
323
378
|
- `LIST_FOLDERS_IN_SECTIONS` — folder tiles (no items loaded yet)
|
|
379
|
+
- `LIST_MIXED` — mixed list: `items` is a `MixedLoaderConfig`; level state in `useFolderLevel`, rows from `getFolderLevelRow` / `getListItem`
|
|
380
|
+
- **Rows are one stable react-window component** (`ListRow` in `ItemPickerList.tsx`). An inline renderer remounts every row on each list render and drops focus — keep it a module-level component.
|
|
381
|
+
- **Arrow keys stop at the list.** Inside a Dropdown its own `useListNavigation` would also move the focus, from a stale index once the focus has left the rows.
|
|
324
382
|
- **`ItemPickerLegacy` is marked `@deprecated`** in source with a JSDoc comment on the component itself.
|
|
325
383
|
- **`errorMessage` prop** on `ItemPickerNew` is marked `@deprecated`; prefer `errorText` (from `FormFieldCommonProps`).
|
|
326
384
|
- **`isObjectDeleted` prop** (on `ItemPickerNew`, `ItemPickerLegacy`, and the shared `Trigger`) flags a selected item that no longer exists. When `true`, `Trigger.styles` renders `ValueText` in `--ds-form-error-text-color` and skips the `--ds-form-icon-color-default` `Prefix` icon override so the deleted state reads visually. It only affects the selected-value display — it has no effect while showing the placeholder.
|
|
327
385
|
- **Several `ItemPickerTriggerProps` fields are `@deprecated`**: `clear`, `changeButtonLabel`, `clearConfirmTitle`, `yesText`, `noText` — move to `texts` object.
|
|
328
386
|
- **`Props` alias** in `Trigger.types.ts` is marked `@deprecated`; use `ItemPickerTriggerProps`.
|
|
329
|
-
- **Tests use Vitest** (`vitest run`)
|
|
387
|
+
- **Tests use Vitest** (`vitest run`), co-located `*.spec.tsx`; config only in the root `vite.config.base.ts`. The root `@testing-library/user-event` is v10, so there is no `userEvent.hover` — a `ds-tooltip` cannot be opened from these specs.
|
|
330
388
|
- The search-bar `searchPlaceholder` in `ItemPickerNew` must be overridden via `texts.searchPlaceholder` (not a top-level prop), unlike `ItemPickerLegacy` where it is a direct prop.
|
|
331
389
|
- `ItemPickerList` generates a unique per-instance CSS class via `generateUuid()` on mount; `focusWithArrowKeys` from `@synerise/ds-utils` uses this class for keyboard navigation.
|
package/README.md
CHANGED
|
@@ -15,6 +15,48 @@ yarn add @synerise/ds-item-picker
|
|
|
15
15
|
|
|
16
16
|
## Usage
|
|
17
17
|
|
|
18
|
+
The current API is `isNewVersion` — see `CLAUDE.md` in this package for every prop.
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
import ItemPicker from '@synerise/ds-item-picker'
|
|
22
|
+
|
|
23
|
+
<ItemPicker
|
|
24
|
+
isNewVersion
|
|
25
|
+
items={items} // an array, { items, limitPerSection }, { loadItems } or { loadLevel }
|
|
26
|
+
placeholder="Set customer"
|
|
27
|
+
selectedItem={selected}
|
|
28
|
+
onChange={setSelected}
|
|
29
|
+
onClear={() => setSelected(undefined)}
|
|
30
|
+
/>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Mixed list
|
|
34
|
+
|
|
35
|
+
Pass a `MixedLoaderConfig` as `items` for a mixed list: folders and items side by side on the same level,
|
|
36
|
+
one level at a time (folders first), and a folder opens the next level. `loadLevel` returns one page of a level (or of a search, which covers
|
|
37
|
+
the level and every level below it) and the level's path:
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
<ItemPicker
|
|
41
|
+
isNewVersion
|
|
42
|
+
items={{
|
|
43
|
+
loadLevel: async ({ folderId, searchQuery, searchKey, page, limit, abortController }) => ({
|
|
44
|
+
entries: [
|
|
45
|
+
{ type: 'folder', folder: { id: 'f1', text: 'Folder 1' } },
|
|
46
|
+
{ type: 'item', item: { id: 'i1', text: 'Item 1' } },
|
|
47
|
+
],
|
|
48
|
+
total: 2,
|
|
49
|
+
path: [{ id: null, text: 'All' }],
|
|
50
|
+
}),
|
|
51
|
+
}}
|
|
52
|
+
onChange={setSelected}
|
|
53
|
+
/>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Search in is not supported in this mode. Actions take `showInList: false` to be offered only under `/`.
|
|
57
|
+
|
|
58
|
+
### Legacy API (deprecated)
|
|
59
|
+
|
|
18
60
|
```
|
|
19
61
|
import ItemPicker from '@synerise/ds-item-picker'
|
|
20
62
|
|
|
@@ -15,10 +15,11 @@ import { ItemPickerListFooter } from "./components/ItemPickerListFooter.js";
|
|
|
15
15
|
import { ItemPickerListRow } from "./components/ItemPickerListRow.js";
|
|
16
16
|
import { ItemPickerListSkeleton } from "./components/ItemPickerListSkeleton.js";
|
|
17
17
|
import { ListSearchInput } from "./components/ListSearchInput.js";
|
|
18
|
-
import { ITEM_SIZE, LIST_STYLE, SECTION_HEADER_HEIGHT, LIST_INNER_PADDING } from "./constants.js";
|
|
18
|
+
import { ITEM_SIZE, LIST_STYLE, SECTION_HEADER_HEIGHT, LIST_INNER_PADDING, FOLDER_ROW_CLASS } from "./constants.js";
|
|
19
19
|
import { useItemsInSections } from "./hooks/useItemsInSections.js";
|
|
20
20
|
import { useListHeight } from "./hooks/useListHeight.js";
|
|
21
21
|
import { findSectionById } from "./utils/findSectionById.js";
|
|
22
|
+
import { formatFolderPath } from "./utils/formatFolderPath.js";
|
|
22
23
|
import { isNavKey } from "./utils/isNavKey.js";
|
|
23
24
|
import { isTitle } from "./utils/typeguards.utils.js";
|
|
24
25
|
const ListRow = ItemPickerListRow;
|
|
@@ -97,7 +98,12 @@ const ItemPickerListInner = ({
|
|
|
97
98
|
searchInItem,
|
|
98
99
|
canPerformListActions,
|
|
99
100
|
reloadActiveSection,
|
|
100
|
-
activeSectionId
|
|
101
|
+
activeSectionId,
|
|
102
|
+
isMixedMode,
|
|
103
|
+
isInFolder,
|
|
104
|
+
folderId,
|
|
105
|
+
folderPath,
|
|
106
|
+
mixedRowSize
|
|
101
107
|
} = useItemsInSections({
|
|
102
108
|
items,
|
|
103
109
|
texts: allTexts,
|
|
@@ -147,6 +153,22 @@ const ItemPickerListInner = ({
|
|
|
147
153
|
focusWithArrowKeys(event, classNames.split(" ")[1], () => {
|
|
148
154
|
focusSearchInput();
|
|
149
155
|
});
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
if (!isMixedMode || event.metaKey || event.ctrlKey) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const row = document.activeElement;
|
|
162
|
+
if (!(row instanceof HTMLElement) || !row.matches(`.${classNames.split(" ")[1]}`)) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (event.key === "ArrowRight" && row.classList.contains(FOLDER_ROW_CLASS)) {
|
|
166
|
+
event.preventDefault();
|
|
167
|
+
row.click();
|
|
168
|
+
}
|
|
169
|
+
if (event.key === "ArrowLeft" && isInFolder) {
|
|
170
|
+
event.preventDefault();
|
|
171
|
+
goBack();
|
|
150
172
|
}
|
|
151
173
|
};
|
|
152
174
|
const getEstimatedItemSize = useCallback((index) => {
|
|
@@ -199,7 +221,7 @@ const ItemPickerListInner = ({
|
|
|
199
221
|
includeSearchBar
|
|
200
222
|
}) || 0;
|
|
201
223
|
const isActionSection = Boolean(searchByAction || searchInAction || searchInItem);
|
|
202
|
-
const isSection = Boolean(currentSection || isActionSection);
|
|
224
|
+
const isSection = Boolean(currentSection || isActionSection || isInFolder);
|
|
203
225
|
const listHeight = (isSection ? listWrapperHeight - SECTION_HEADER_HEIGHT : listWrapperHeight) - LIST_INNER_PADDING;
|
|
204
226
|
const clearSearchQuery = () => {
|
|
205
227
|
changeSearchQuery("");
|
|
@@ -210,9 +232,19 @@ const ItemPickerListInner = ({
|
|
|
210
232
|
return /* @__PURE__ */ jsx(ErrorMessage, { texts: allTexts });
|
|
211
233
|
}
|
|
212
234
|
if (isLoading || isLoadingItems) {
|
|
213
|
-
return /* @__PURE__ */ jsx(ItemPickerListSkeleton, { wrapperHeight: listWrapperHeight });
|
|
235
|
+
return /* @__PURE__ */ jsx(ItemPickerListSkeleton, { wrapperHeight: listWrapperHeight, rowSize: mixedRowSize });
|
|
214
236
|
}
|
|
215
237
|
const getSectionLabel = () => {
|
|
238
|
+
if (isMixedMode) {
|
|
239
|
+
const {
|
|
240
|
+
label,
|
|
241
|
+
fullPath
|
|
242
|
+
} = formatFolderPath(folderPath.map((step) => step.text));
|
|
243
|
+
const searchByLabel = searchByAction?.sectionTitle || searchByAction?.text;
|
|
244
|
+
return /* @__PURE__ */ jsx(Text, { ellipsis: {
|
|
245
|
+
tooltip: fullPath
|
|
246
|
+
}, children: searchByLabel ? `${label} - ${searchByLabel}` : label });
|
|
247
|
+
}
|
|
216
248
|
const itemsPath = currentPath || [currentSection?.text];
|
|
217
249
|
const searchByActionLabel = searchByAction?.sectionTitle || searchByAction?.text;
|
|
218
250
|
const searchInActionLabel = searchInAction?.text;
|
|
@@ -227,9 +259,9 @@ const ItemPickerListInner = ({
|
|
|
227
259
|
title: allTexts.backTooltip,
|
|
228
260
|
shortCuts: ["⌘", /* @__PURE__ */ jsx(Icon, { size: 18, component: /* @__PURE__ */ jsx(ArrowLeftM, {}) }, "hint-arrow-left")]
|
|
229
261
|
}, label: getSectionLabel(), onClick: goBack }),
|
|
230
|
-
mergedItemsList?.length === 0 ? /* @__PURE__ */ jsx(EmptyListMessage, { buttonOnClick: () => resetCurrentSection(), listActions, hasCurrentSection: isSection, texts: allTexts, isActionSection, currentSection, searchQuery, emptyListIcon, noResultsIcon, emptyStateComponent, noResultsComponent }) : /* @__PURE__ */ jsx(StyledScrollbar, { withSectionHeader: isSection, maxHeight: listHeight, "data-maxheight": listHeight, onScroll: handleScroll, absolute: true, withDnd: false, ref: scrollBarRef, ...scrollbarProps, children: /* @__PURE__ */ jsx(ScrollContent, { children: /* @__PURE__ */ jsx(ListContextProvider, { children: /* @__PURE__ */ jsx(StyledList, { width: "100%", "data-listheight": listHeight, height: listHeight, maxHeight: listHeight, itemCount: mergedItemsList.length, itemSize: getItemSize, itemData, style: LIST_STYLE, ref: listRef, children: ListRow }) }) }) })
|
|
262
|
+
mergedItemsList?.length === 0 ? /* @__PURE__ */ jsx(EmptyListMessage, { buttonOnClick: () => resetCurrentSection(), listActions, hasCurrentSection: isSection && !isInFolder, isInFolder, texts: allTexts, isActionSection, currentSection, searchQuery, emptyListIcon, noResultsIcon, emptyStateComponent, noResultsComponent }) : /* @__PURE__ */ jsx(StyledScrollbar, { withSectionHeader: isSection, maxHeight: listHeight, "data-maxheight": listHeight, onScroll: handleScroll, absolute: true, withDnd: false, ref: scrollBarRef, ...scrollbarProps, children: /* @__PURE__ */ jsx(ScrollContent, { children: /* @__PURE__ */ jsx(ListContextProvider, { children: /* @__PURE__ */ jsx(StyledList, { width: "100%", "data-listheight": listHeight, height: listHeight, maxHeight: listHeight, itemCount: mergedItemsList.length, itemSize: getItemSize, itemData, style: LIST_STYLE, ref: listRef, children: ListRow }) }) }) })
|
|
231
263
|
] });
|
|
232
|
-
}, [allTexts, currentSection, currentPath, getItemSize, handleScroll, isLoading, isLoadingError, isLoadingItems, itemData, listHeight, goBack, mergedItemsList.length, scrollbarProps, searchQuery, listWrapperHeight]);
|
|
264
|
+
}, [allTexts, currentSection, currentPath, getItemSize, handleScroll, isLoading, isLoadingError, isLoadingItems, itemData, listHeight, goBack, mergedItemsList.length, scrollbarProps, searchQuery, listWrapperHeight, isSection, folderPath]);
|
|
233
265
|
useEffect(() => {
|
|
234
266
|
setTimeout(focusSearchInput, 0);
|
|
235
267
|
}, [isLoading, isLoadingItems, isLoadingMore, focusSearchInput]);
|
|
@@ -249,7 +281,7 @@ const ItemPickerListInner = ({
|
|
|
249
281
|
listRef.current.resetAfterIndex(0);
|
|
250
282
|
setTimeout(focusSearchInput, 0);
|
|
251
283
|
}
|
|
252
|
-
}, [searchByAction, searchByParamConfig, searchInAction, searchInItem, currentSection, focusSearchInput]);
|
|
284
|
+
}, [searchByAction, searchByParamConfig, searchInAction, searchInItem, currentSection, folderId, focusSearchInput]);
|
|
253
285
|
useEffect(() => {
|
|
254
286
|
listRef.current && listRef.current.resetAfterIndex(0);
|
|
255
287
|
}, [mergedItemsList]);
|
|
@@ -285,7 +317,7 @@ const ItemPickerListInner = ({
|
|
|
285
317
|
});
|
|
286
318
|
const containerHeightMode = !containerHeight || typeof containerHeight === "object" ? "preset" : containerHeight;
|
|
287
319
|
return /* @__PURE__ */ jsxs(ListContainer, { "data-testid": "ds-item-picker-dropdown", ref: combinedScrollRef, onKeyDown: handleKeyDown, containerHeightMode, wrapperHeight: outerWrapperHeight, ...htmlAttributes, children: [
|
|
288
|
-
includeSearchBar && /* @__PURE__ */ jsx(ListSearchInput, { clearSearchQuery, searchByParamConfig, setSearchByParamConfig, searchBarProps, debouncedChangeSearchQuery: debouncedSearchQueryChange, inputRef, changeLocalSearchQueryRef, allTexts, canPerformListActions }),
|
|
320
|
+
includeSearchBar && /* @__PURE__ */ jsx(ListSearchInput, { clearSearchQuery, searchByParamConfig, setSearchByParamConfig, searchBarProps, debouncedChangeSearchQuery: debouncedSearchQueryChange, inputRef, changeLocalSearchQueryRef, allTexts, canPerformListActions, isInFolder, onEmptyBackspace: isMixedMode ? goBack : void 0 }),
|
|
289
321
|
/* @__PURE__ */ jsx(ListWrapper, { "data-testid": "list-wrapper", ref: scrollContainRef, wrapperHeight: listWrapperHeight, centered: showMessage, offsetSpace, children: listContent }),
|
|
290
322
|
includeFooter && /* @__PURE__ */ jsx(ItemPickerListFooter, { "data-testid": "footer-wrapper", texts: allTexts, onRefresh: handleRefresh, refreshButtonProps: {
|
|
291
323
|
disabled: !refreshEnabled
|
|
@@ -25,9 +25,12 @@ export declare const Skeleton: import('styled-components').StyledComponent<({ si
|
|
|
25
25
|
export declare const SkeletonWrapper: import('styled-components').StyledComponent<"div", any, {
|
|
26
26
|
wrapperHeight?: number;
|
|
27
27
|
}, never>;
|
|
28
|
+
export declare const LargeSkeletonRow: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
29
|
+
export declare const LargeSkeletonText: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
28
30
|
export declare const Title: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
29
31
|
export declare const TitleWithTooltip: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
30
32
|
export declare const TitleTooltipIcon: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
31
33
|
export declare const SectionTitleWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
32
34
|
export declare const InfiniteLoaderItemWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
33
|
-
export declare const Loader: import('styled-components').StyledComponent<({ size, label, labelPosition, color, percent, percentFormatter, text, fontSize, mode, className, }: import('@synerise/ds-loader/dist/Loader.types').LoaderProps) => React.JSX.Element, any, {}, never>;
|
|
35
|
+
export declare const Loader: import('styled-components').StyledComponent<({ size, label, labelPosition, color, percent, percentFormatter, text, fontSize, mode, className, }: import('@synerise/ds-loader/dist/Loader.types.js').LoaderProps) => React.JSX.Element, any, {}, never>;
|
|
36
|
+
export declare const FolderDisabledReason: import('styled-components').StyledComponent<"span", any, {}, never>;
|
|
@@ -60,37 +60,52 @@ const SkeletonWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
|
60
60
|
displayName: "ItemPickerListstyles__SkeletonWrapper",
|
|
61
61
|
componentId: "sc-1r33ill-12"
|
|
62
62
|
})(["", " display:flex;flex-direction:column;gap:16px;padding:16px;", ":nth-child(odd){width:50%;}"], (props) => props.wrapperHeight !== void 0 && `height: ${props.wrapperHeight}px;`, Skeleton);
|
|
63
|
+
const LargeSkeletonRow = /* @__PURE__ */ styled.div.withConfig({
|
|
64
|
+
displayName: "ItemPickerListstyles__LargeSkeletonRow",
|
|
65
|
+
componentId: "sc-1r33ill-13"
|
|
66
|
+
})(["display:flex;align-items:center;gap:12px;"]);
|
|
67
|
+
const LargeSkeletonText = /* @__PURE__ */ styled.div.withConfig({
|
|
68
|
+
displayName: "ItemPickerListstyles__LargeSkeletonText",
|
|
69
|
+
componentId: "sc-1r33ill-14"
|
|
70
|
+
})(["flex:1;display:flex;flex-direction:column;gap:8px;", ":last-child{width:40%;}"], Skeleton);
|
|
63
71
|
const Title = /* @__PURE__ */ styled.div.withConfig({
|
|
64
72
|
displayName: "ItemPickerListstyles__Title",
|
|
65
|
-
componentId: "sc-1r33ill-
|
|
73
|
+
componentId: "sc-1r33ill-15"
|
|
66
74
|
})(["font-size:10px;line-height:1.6;font-weight:500;text-transform:uppercase;color:var(--ds-divider-header-text-color);padding:8px 12px;"]);
|
|
67
75
|
const TitleWithTooltip = /* @__PURE__ */ styled.div.withConfig({
|
|
68
76
|
displayName: "ItemPickerListstyles__TitleWithTooltip",
|
|
69
|
-
componentId: "sc-1r33ill-
|
|
77
|
+
componentId: "sc-1r33ill-16"
|
|
70
78
|
})(["display:flex;align-items:center;"]);
|
|
71
79
|
const TitleTooltipIcon = /* @__PURE__ */ styled.div.withConfig({
|
|
72
80
|
displayName: "ItemPickerListstyles__TitleTooltipIcon",
|
|
73
|
-
componentId: "sc-1r33ill-
|
|
81
|
+
componentId: "sc-1r33ill-17"
|
|
74
82
|
})(["display:flex;margin:-4px 0;color:", ";"], (props) => props.theme.palette["grey-400"]);
|
|
75
83
|
const SectionTitleWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
76
84
|
displayName: "ItemPickerListstyles__SectionTitleWrapper",
|
|
77
|
-
componentId: "sc-1r33ill-
|
|
85
|
+
componentId: "sc-1r33ill-18"
|
|
78
86
|
})([""]);
|
|
79
87
|
const InfiniteLoaderItemWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
80
88
|
displayName: "ItemPickerListstyles__InfiniteLoaderItemWrapper",
|
|
81
|
-
componentId: "sc-1r33ill-
|
|
89
|
+
componentId: "sc-1r33ill-19"
|
|
82
90
|
})([""]);
|
|
83
91
|
const Loader = /* @__PURE__ */ styled(DSLoader).withConfig({
|
|
84
92
|
displayName: "ItemPickerListstyles__Loader",
|
|
85
|
-
componentId: "sc-1r33ill-
|
|
93
|
+
componentId: "sc-1r33ill-20"
|
|
86
94
|
})(["justify-content:flex-start;"]);
|
|
95
|
+
const FolderDisabledReason = /* @__PURE__ */ styled.span.withConfig({
|
|
96
|
+
displayName: "ItemPickerListstyles__FolderDisabledReason",
|
|
97
|
+
componentId: "sc-1r33ill-21"
|
|
98
|
+
})(["color:var(--ds-color-text-base-muted);white-space:nowrap;"]);
|
|
87
99
|
export {
|
|
88
100
|
EmptyStates,
|
|
101
|
+
FolderDisabledReason,
|
|
89
102
|
FooterWrapper,
|
|
90
103
|
FooterWrapperLeft,
|
|
91
104
|
FooterWrapperRight,
|
|
92
105
|
IconWrapper,
|
|
93
106
|
InfiniteLoaderItemWrapper,
|
|
107
|
+
LargeSkeletonRow,
|
|
108
|
+
LargeSkeletonText,
|
|
94
109
|
ListContainer,
|
|
95
110
|
ListWrapper,
|
|
96
111
|
Loader,
|
|
@@ -2,8 +2,9 @@ import { default as React, ReactElement, ReactNode } from 'react';
|
|
|
2
2
|
import { BaseSectionType } from '../../ItemPickerNew/types/baseItemSectionType.types';
|
|
3
3
|
import { ItemPickerListTexts } from '../../ItemPickerNew/types/itemPickerListTexts.types';
|
|
4
4
|
type EmptyListMessageProps = {
|
|
5
|
-
texts: Pick<ItemPickerListTexts, 'noResultsInSection' | 'noResults' | 'noItems' | 'noActions' | 'emptyStateLabel' | 'searchAllFoldersButtonLabel'>;
|
|
5
|
+
texts: Pick<ItemPickerListTexts, 'noResultsInSection' | 'noResults' | 'noItems' | 'noActions' | 'emptyStateLabel' | 'searchAllFoldersButtonLabel' | 'emptyFolder'>;
|
|
6
6
|
hasCurrentSection?: boolean;
|
|
7
|
+
isInFolder?: boolean;
|
|
7
8
|
listActions: boolean;
|
|
8
9
|
isActionSection: boolean;
|
|
9
10
|
buttonOnClick: () => void;
|
|
@@ -14,5 +15,5 @@ type EmptyListMessageProps = {
|
|
|
14
15
|
emptyStateComponent?: ReactNode;
|
|
15
16
|
noResultsComponent?: ReactNode;
|
|
16
17
|
};
|
|
17
|
-
export declare const EmptyListMessage: ({ texts, listActions, isActionSection, hasCurrentSection, buttonOnClick, currentSection, searchQuery, emptyListIcon, noResultsIcon, emptyStateComponent, noResultsComponent, }: EmptyListMessageProps) => React.JSX.Element;
|
|
18
|
+
export declare const EmptyListMessage: ({ texts, listActions, isActionSection, hasCurrentSection, isInFolder, buttonOnClick, currentSection, searchQuery, emptyListIcon, noResultsIcon, emptyStateComponent, noResultsComponent, }: EmptyListMessageProps) => React.JSX.Element;
|
|
18
19
|
export {};
|
|
@@ -7,6 +7,7 @@ const EmptyListMessage = ({
|
|
|
7
7
|
listActions,
|
|
8
8
|
isActionSection,
|
|
9
9
|
hasCurrentSection,
|
|
10
|
+
isInFolder,
|
|
10
11
|
buttonOnClick,
|
|
11
12
|
currentSection,
|
|
12
13
|
searchQuery,
|
|
@@ -21,6 +22,9 @@ const EmptyListMessage = ({
|
|
|
21
22
|
if (hasCurrentSection && !isActionSection) {
|
|
22
23
|
return /* @__PURE__ */ jsx(EmptyStates, { customIcon: /* @__PURE__ */ jsx(SearchNoResultsL, {}), label: currentSection?.texts?.noResultsInSection || texts.noResultsInSection, button: /* @__PURE__ */ jsx(Button, { type: "primary", onClick: buttonOnClick, children: currentSection?.texts?.searchAllFoldersButtonLabel || texts.searchAllFoldersButtonLabel }) });
|
|
23
24
|
}
|
|
25
|
+
if (!searchQuery && isInFolder) {
|
|
26
|
+
return /* @__PURE__ */ jsx(EmptyStates, { customIcon: emptyListIcon || /* @__PURE__ */ jsx(NoData, {}), label: texts.emptyFolder });
|
|
27
|
+
}
|
|
24
28
|
if (!searchQuery) {
|
|
25
29
|
if (emptyStateComponent) {
|
|
26
30
|
return /* @__PURE__ */ jsx(Fragment, { children: emptyStateComponent });
|
|
@@ -51,7 +51,7 @@ const ItemPickerListRow = ({
|
|
|
51
51
|
] }) : listItem.text }) });
|
|
52
52
|
}
|
|
53
53
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
54
|
-
/* @__PURE__ */ jsx("div", { ref: rowRef, style: rowStyle, children: /* @__PURE__ */ jsx(DSListItem, { ...listItem, className: classNames }) }),
|
|
54
|
+
/* @__PURE__ */ jsx("div", { ref: rowRef, style: rowStyle, children: /* @__PURE__ */ jsx(DSListItem, { ...listItem, className: listItem.className ? `${classNames} ${listItem.className}` : classNames }) }),
|
|
55
55
|
index === dataSource.length - 1 && infiniteLoaderItem()
|
|
56
56
|
] });
|
|
57
57
|
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
|
|
2
|
+
import { ItemSize } from '@synerise/ds-list-item';
|
|
3
|
+
export declare const ItemPickerListSkeleton: ({ wrapperHeight, rowSize, }: {
|
|
3
4
|
wrapperHeight?: number;
|
|
5
|
+
rowSize?: ItemSize;
|
|
4
6
|
}) => React.JSX.Element;
|
|
@@ -1,15 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { itemSizes } from "@synerise/ds-list-item";
|
|
3
|
+
import { SkeletonAvatar } from "@synerise/ds-skeleton";
|
|
4
|
+
import { SkeletonWrapper, LargeSkeletonRow, LargeSkeletonText, Skeleton } from "../ItemPickerList.styles.js";
|
|
5
|
+
const ROWS = [0, 1, 2, 3, 4];
|
|
3
6
|
const ItemPickerListSkeleton = ({
|
|
4
|
-
wrapperHeight
|
|
7
|
+
wrapperHeight,
|
|
8
|
+
rowSize = itemSizes.DEFAULT
|
|
5
9
|
}) => {
|
|
6
|
-
|
|
7
|
-
/* @__PURE__ */ jsx(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
if (rowSize === itemSizes.LARGE) {
|
|
11
|
+
return /* @__PURE__ */ jsx(SkeletonWrapper, { wrapperHeight, children: ROWS.map((row) => /* @__PURE__ */ jsxs(LargeSkeletonRow, { "data-testid": "ds-item-picker-skeleton-large-row", children: [
|
|
12
|
+
/* @__PURE__ */ jsx(SkeletonAvatar, { size: "M", shape: "square" }),
|
|
13
|
+
/* @__PURE__ */ jsxs(LargeSkeletonText, { children: [
|
|
14
|
+
/* @__PURE__ */ jsx(Skeleton, { numberOfSkeletons: 1, size: "M" }),
|
|
15
|
+
/* @__PURE__ */ jsx(Skeleton, { numberOfSkeletons: 1, size: "S" })
|
|
16
|
+
] })
|
|
17
|
+
] }, row)) });
|
|
18
|
+
}
|
|
19
|
+
return /* @__PURE__ */ jsx(SkeletonWrapper, { wrapperHeight, children: ROWS.map((row) => /* @__PURE__ */ jsx(Skeleton, { numberOfSkeletons: 1, size: "M" }, row)) });
|
|
13
20
|
};
|
|
14
21
|
export {
|
|
15
22
|
ItemPickerListSkeleton
|
|
@@ -12,6 +12,8 @@ type ListSearchInputProps = {
|
|
|
12
12
|
searchBarProps?: Omit<SearchBarProps, 'value' | 'onSearchChange' | 'placeholder'>;
|
|
13
13
|
allTexts: ItemPickerTexts;
|
|
14
14
|
canPerformListActions: boolean;
|
|
15
|
+
isInFolder?: boolean;
|
|
16
|
+
onEmptyBackspace?: () => void;
|
|
15
17
|
};
|
|
16
|
-
export declare const ListSearchInput: ({ searchByParamConfig, changeLocalSearchQueryRef, clearSearchQuery, setSearchByParamConfig, debouncedChangeSearchQuery, searchBarProps, allTexts, inputRef, canPerformListActions, }: ListSearchInputProps) => React.JSX.Element;
|
|
18
|
+
export declare const ListSearchInput: ({ searchByParamConfig, changeLocalSearchQueryRef, clearSearchQuery, setSearchByParamConfig, debouncedChangeSearchQuery, searchBarProps, allTexts, inputRef, canPerformListActions, isInFolder, onEmptyBackspace, }: ListSearchInputProps) => React.JSX.Element;
|
|
17
19
|
export {};
|
|
@@ -15,7 +15,9 @@ const ListSearchInput = ({
|
|
|
15
15
|
searchBarProps,
|
|
16
16
|
allTexts,
|
|
17
17
|
inputRef,
|
|
18
|
-
canPerformListActions
|
|
18
|
+
canPerformListActions,
|
|
19
|
+
isInFolder,
|
|
20
|
+
onEmptyBackspace
|
|
19
21
|
}) => {
|
|
20
22
|
const [localSearchQuery, setLocalSearchQuery] = useState("");
|
|
21
23
|
const handleSearchChange = useCallback((value) => {
|
|
@@ -27,9 +29,14 @@ const ListSearchInput = ({
|
|
|
27
29
|
localRef.current = ref.current;
|
|
28
30
|
}, [inputRef]);
|
|
29
31
|
const handleKeyDown = (event) => {
|
|
30
|
-
if (event.key
|
|
32
|
+
if (event.key !== "Backspace" || localSearchQuery) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (searchByParamConfig) {
|
|
31
36
|
setSearchByParamConfig(void 0);
|
|
37
|
+
return;
|
|
32
38
|
}
|
|
39
|
+
onEmptyBackspace?.();
|
|
33
40
|
};
|
|
34
41
|
const handleClearInput = () => {
|
|
35
42
|
if (localSearchQuery) {
|
|
@@ -42,7 +49,7 @@ const ListSearchInput = ({
|
|
|
42
49
|
const ref = changeLocalSearchQueryRef;
|
|
43
50
|
ref.current = setLocalSearchQuery;
|
|
44
51
|
}, [changeLocalSearchQueryRef]);
|
|
45
|
-
return /* @__PURE__ */ jsx(SearchWrapper, { "data-testid": "search-wrapper", children: /* @__PURE__ */ jsx(Dropdown.SearchInput, { iconLeft: /* @__PURE__ */ jsx(Icon, { component: searchByParamConfig?.icon || /* @__PURE__ */ jsx(SearchM, {}) }), placeholder: canPerformListActions ? allTexts.searchPlaceholder : allTexts.basicSearchPlaceholder, ...searchBarProps, valuePrefix: searchByParamConfig?.paramKeyLabel, onKeyDown: handleKeyDown, clearTooltip: allTexts.clearSearchTooltip, clearTooltipProps: CLEAR_TOOLTIP_PROPS, onClearInput: handleClearInput, handleInputRef, onSearchChange: handleSearchChange, value: localSearchQuery }) });
|
|
52
|
+
return /* @__PURE__ */ jsx(SearchWrapper, { "data-testid": "search-wrapper", children: /* @__PURE__ */ jsx(Dropdown.SearchInput, { iconLeft: /* @__PURE__ */ jsx(Icon, { component: searchByParamConfig?.icon || /* @__PURE__ */ jsx(SearchM, {}) }), placeholder: isInFolder ? allTexts.searchInFolderPlaceholder : canPerformListActions ? allTexts.searchPlaceholder : allTexts.basicSearchPlaceholder, ...searchBarProps, valuePrefix: searchByParamConfig?.paramKeyLabel, onKeyDown: handleKeyDown, clearTooltip: allTexts.clearSearchTooltip, clearTooltipProps: CLEAR_TOOLTIP_PROPS, onClearInput: handleClearInput, handleInputRef, onSearchChange: handleSearchChange, value: localSearchQuery }) });
|
|
46
53
|
};
|
|
47
54
|
export {
|
|
48
55
|
ListSearchInput
|
|
@@ -25,3 +25,5 @@ export declare const ITEMS_PER_SECTION = 4;
|
|
|
25
25
|
export declare const ITEMS_PER_SECTION_IN_SEARCH = 4;
|
|
26
26
|
export declare const TITLE_PATH_SEPARATOR = " - ";
|
|
27
27
|
export declare const GET_ITEM_KEY: <ItemType extends BaseItemType>(item: ItemType) => string;
|
|
28
|
+
export declare const FOLDER_ITEMS_PER_PAGE = 30;
|
|
29
|
+
export declare const FOLDER_ROW_CLASS = "ds-item-picker-folder-row";
|
|
@@ -35,11 +35,15 @@ const GET_ITEM_KEY = (item) => {
|
|
|
35
35
|
}
|
|
36
36
|
return key;
|
|
37
37
|
};
|
|
38
|
+
const FOLDER_ITEMS_PER_PAGE = 30;
|
|
39
|
+
const FOLDER_ROW_CLASS = "ds-item-picker-folder-row";
|
|
38
40
|
export {
|
|
39
41
|
DEFAULT_HEIGHT,
|
|
40
42
|
DEFAULT_HEIGHT_BELOW_THRESHOLD,
|
|
41
43
|
DEFAULT_HEIGHT_THRESHOLD,
|
|
42
44
|
FIRST_PAGE,
|
|
45
|
+
FOLDER_ITEMS_PER_PAGE,
|
|
46
|
+
FOLDER_ROW_CLASS,
|
|
43
47
|
FOOTER_HEIGHT,
|
|
44
48
|
GET_ITEM_KEY,
|
|
45
49
|
ITEMS_PER_PAGE,
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { useFlattenFolders } from "./useFlattenFolders.js";
|
|
2
|
+
import { useFolderLevel } from "./useFolderLevel.js";
|
|
2
3
|
import { useItemsInSections } from "./useItemsInSections.js";
|
|
3
4
|
import { useListHeight } from "./useListHeight.js";
|
|
4
5
|
export {
|
|
5
6
|
useFlattenFolders,
|
|
7
|
+
useFolderLevel,
|
|
6
8
|
useItemsInSections,
|
|
7
9
|
useListHeight
|
|
8
10
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FolderNode, PathStep } from '../../ItemPickerNew/types/mixedLoader.types';
|
|
2
|
+
export declare const useFolderLevel: () => {
|
|
3
|
+
folderId: string | null;
|
|
4
|
+
path: PathStep[];
|
|
5
|
+
setPath: import('react').Dispatch<import('react').SetStateAction<PathStep[]>>;
|
|
6
|
+
openFolder: (folder: FolderNode) => void;
|
|
7
|
+
goUp: () => void;
|
|
8
|
+
reset: () => void;
|
|
9
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useState, useCallback } from "react";
|
|
2
|
+
const useFolderLevel = () => {
|
|
3
|
+
const [folderId, setFolderId] = useState(null);
|
|
4
|
+
const [path, setPath] = useState([]);
|
|
5
|
+
const openFolder = useCallback((folder) => {
|
|
6
|
+
setFolderId(folder.id);
|
|
7
|
+
setPath((current) => [...current, {
|
|
8
|
+
id: folder.id,
|
|
9
|
+
text: folder.text
|
|
10
|
+
}]);
|
|
11
|
+
}, []);
|
|
12
|
+
const goUp = useCallback(() => {
|
|
13
|
+
setFolderId(path.length > 1 ? path[path.length - 2].id : null);
|
|
14
|
+
setPath((current) => current.slice(0, -1));
|
|
15
|
+
}, [path]);
|
|
16
|
+
const reset = useCallback(() => {
|
|
17
|
+
setFolderId(null);
|
|
18
|
+
setPath((current) => current.slice(0, 1));
|
|
19
|
+
}, []);
|
|
20
|
+
return {
|
|
21
|
+
folderId,
|
|
22
|
+
path,
|
|
23
|
+
setPath,
|
|
24
|
+
openFolder,
|
|
25
|
+
goUp,
|
|
26
|
+
reset
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export {
|
|
30
|
+
useFolderLevel
|
|
31
|
+
};
|