@synerise/ds-item-picker 2.2.3 → 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 +27 -0
- package/CLAUDE.md +71 -13
- package/README.md +42 -0
- package/dist/components/ItemPickerDropdown/ItemPickerDropdown.style.js +2 -4
- package/dist/components/ItemPickerList/ItemPickerList.js +41 -11
- package/dist/components/ItemPickerList/ItemPickerList.styles.d.ts +4 -1
- package/dist/components/ItemPickerList/ItemPickerList.styles.js +24 -9
- package/dist/components/ItemPickerList/components/EmptyListMessage.d.ts +3 -2
- package/dist/components/ItemPickerList/components/EmptyListMessage.js +4 -0
- package/dist/components/ItemPickerList/components/ErrorMessage.js +2 -3
- 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 -5
- 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/components/ItemPickerTrigger/Trigger.js +3 -4
- package/dist/components/ItemPickerTrigger/Trigger.styles.js +16 -16
- 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,33 @@
|
|
|
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
|
+
|
|
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)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* integrate Token Studio design tokens across the design system ([aabb447](https://github.com/Synerise/synerise-design/commit/aabb447edfb2d0c85e3de1f07e809ef84083453b))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
6
33
|
## [2.2.3](https://github.com/Synerise/synerise-design/compare/@synerise/ds-item-picker@2.2.2...@synerise/ds-item-picker@2.2.3) (2026-10-28)
|
|
7
34
|
|
|
8
35
|
|
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 |
|
|
@@ -112,7 +115,7 @@ Current API. Generic over `ItemType extends BaseItemType` and `SectionType exten
|
|
|
112
115
|
| `tooltip?` | `ReactNode` | — | `FormField` tooltip |
|
|
113
116
|
| `tooltipConfig?` | `FormFieldCommonProps['tooltipConfig']` | — | `FormField` tooltip config |
|
|
114
117
|
| `error?` | `boolean` | — | Error state on trigger and FormField |
|
|
115
|
-
| `isObjectDeleted?` | `boolean` | — | Marks the selected item as deleted; renders its value text in
|
|
118
|
+
| `isObjectDeleted?` | `boolean` | — | Marks the selected item as deleted; renders its value text in `--ds-form-error-text-color` and drops the prefix-icon colour override |
|
|
116
119
|
| `errorText?` | `FormFieldCommonProps['errorText']` | — | Preferred error message |
|
|
117
120
|
| `errorMessage?` | `FormFieldCommonProps['errorText']` | — | **@deprecated** — use `errorText` |
|
|
118
121
|
| `disabled?` | `boolean` | — | Disables trigger and dropdown |
|
|
@@ -167,7 +170,7 @@ Use `ItemPicker` (default) with `isNewVersion` instead.
|
|
|
167
170
|
| `clearConfirmTitle?` | `string` | `'Please confirm'` | Popconfirm title |
|
|
168
171
|
| `yesText?` / `noText?` | `string` | `'Yes'` / `'No'` | Popconfirm buttons |
|
|
169
172
|
| `error?` | `boolean` | — | Error state |
|
|
170
|
-
| `isObjectDeleted?` | `boolean` | — | Marks the selected item as deleted; renders its value text in
|
|
173
|
+
| `isObjectDeleted?` | `boolean` | — | Marks the selected item as deleted; renders its value text in `--ds-form-error-text-color` |
|
|
171
174
|
| `errorMessage?` | `ReactNode` | — | Error text |
|
|
172
175
|
| `disabled?` | `boolean` | — | Disabled state |
|
|
173
176
|
| `hideSearchBar?` | `boolean` | — | Hide search bar |
|
|
@@ -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
|
|
@@ -283,10 +338,10 @@ import { ItemPickerList } from '@synerise/ds-item-picker';
|
|
|
283
338
|
|
|
284
339
|
## Styling
|
|
285
340
|
|
|
286
|
-
- All styled-components; no hardcoded colours — uses
|
|
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
|
-
- **`isObjectDeleted` prop** (on `ItemPickerNew`, `ItemPickerLegacy`, and the shared `Trigger`) flags a selected item that no longer exists. When `true`, `Trigger.styles` renders `ValueText` in
|
|
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
|
|
|
@@ -12,9 +12,7 @@ const ListItem = /* @__PURE__ */ styled(DSListItem).withConfig({
|
|
|
12
12
|
const ListWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
13
13
|
displayName: "ItemPickerDropdownstyle__ListWrapper",
|
|
14
14
|
componentId: "sc-1y4j72s-2"
|
|
15
|
-
})(["display:flex;flex-direction:column;align-items:stretch;justify-content:flex-start;padding:8px 0 8px 8px;background:
|
|
16
|
-
theme
|
|
17
|
-
}) => theme.palette.white);
|
|
15
|
+
})(["display:flex;flex-direction:column;align-items:stretch;justify-content:flex-start;padding:8px 0 8px 8px;background:var(--ds-dropdown-bg);"]);
|
|
18
16
|
const StyledScrollbar = /* @__PURE__ */ styled(Scrollbar).withConfig({
|
|
19
17
|
displayName: "ItemPickerDropdownstyle__StyledScrollbar",
|
|
20
18
|
componentId: "sc-1y4j72s-3"
|
|
@@ -22,7 +20,7 @@ const StyledScrollbar = /* @__PURE__ */ styled(Scrollbar).withConfig({
|
|
|
22
20
|
const DropdownFooter = /* @__PURE__ */ styled.div.withConfig({
|
|
23
21
|
displayName: "ItemPickerDropdownstyle__DropdownFooter",
|
|
24
22
|
componentId: "sc-1y4j72s-4"
|
|
25
|
-
})(["background-color:
|
|
23
|
+
})(["background-color:var(--ds-dropdown-footer-bg);height:52px;display:flex;align-items:center;border-top:1px solid var(--ds-dropdown-footer-border);cursor:default;margin:0;padding:0 8px;"]);
|
|
26
24
|
const BottomActionWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
27
25
|
displayName: "ItemPickerDropdownstyle__BottomActionWrapper",
|
|
28
26
|
componentId: "sc-1y4j72s-5"
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import debounce from "lodash.debounce";
|
|
3
3
|
import { forwardRef, useState, useRef, useCallback, useMemo, useImperativeHandle, useEffect } from "react";
|
|
4
|
-
import { useTheme } from "@synerise/ds-core";
|
|
5
4
|
import Dropdown from "@synerise/ds-dropdown";
|
|
6
5
|
import Icon, { ArrowLeftM } from "@synerise/ds-icon";
|
|
7
6
|
import { itemSizes, ListContextProvider } from "@synerise/ds-list-item";
|
|
@@ -16,10 +15,11 @@ import { ItemPickerListFooter } from "./components/ItemPickerListFooter.js";
|
|
|
16
15
|
import { ItemPickerListRow } from "./components/ItemPickerListRow.js";
|
|
17
16
|
import { ItemPickerListSkeleton } from "./components/ItemPickerListSkeleton.js";
|
|
18
17
|
import { ListSearchInput } from "./components/ListSearchInput.js";
|
|
19
|
-
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";
|
|
20
19
|
import { useItemsInSections } from "./hooks/useItemsInSections.js";
|
|
21
20
|
import { useListHeight } from "./hooks/useListHeight.js";
|
|
22
21
|
import { findSectionById } from "./utils/findSectionById.js";
|
|
22
|
+
import { formatFolderPath } from "./utils/formatFolderPath.js";
|
|
23
23
|
import { isNavKey } from "./utils/isNavKey.js";
|
|
24
24
|
import { isTitle } from "./utils/typeguards.utils.js";
|
|
25
25
|
const ListRow = ItemPickerListRow;
|
|
@@ -50,7 +50,6 @@ const ItemPickerListInner = ({
|
|
|
50
50
|
noResultsComponent,
|
|
51
51
|
...htmlAttributes
|
|
52
52
|
}, forwardedRef) => {
|
|
53
|
-
const theme = useTheme();
|
|
54
53
|
const [searchQuery, setSearchQuery] = useState("");
|
|
55
54
|
const scrollBarRef = useRef(null);
|
|
56
55
|
const containerRef = useRef(null);
|
|
@@ -99,7 +98,12 @@ const ItemPickerListInner = ({
|
|
|
99
98
|
searchInItem,
|
|
100
99
|
canPerformListActions,
|
|
101
100
|
reloadActiveSection,
|
|
102
|
-
activeSectionId
|
|
101
|
+
activeSectionId,
|
|
102
|
+
isMixedMode,
|
|
103
|
+
isInFolder,
|
|
104
|
+
folderId,
|
|
105
|
+
folderPath,
|
|
106
|
+
mixedRowSize
|
|
103
107
|
} = useItemsInSections({
|
|
104
108
|
items,
|
|
105
109
|
texts: allTexts,
|
|
@@ -149,6 +153,22 @@ const ItemPickerListInner = ({
|
|
|
149
153
|
focusWithArrowKeys(event, classNames.split(" ")[1], () => {
|
|
150
154
|
focusSearchInput();
|
|
151
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();
|
|
152
172
|
}
|
|
153
173
|
};
|
|
154
174
|
const getEstimatedItemSize = useCallback((index) => {
|
|
@@ -201,7 +221,7 @@ const ItemPickerListInner = ({
|
|
|
201
221
|
includeSearchBar
|
|
202
222
|
}) || 0;
|
|
203
223
|
const isActionSection = Boolean(searchByAction || searchInAction || searchInItem);
|
|
204
|
-
const isSection = Boolean(currentSection || isActionSection);
|
|
224
|
+
const isSection = Boolean(currentSection || isActionSection || isInFolder);
|
|
205
225
|
const listHeight = (isSection ? listWrapperHeight - SECTION_HEADER_HEIGHT : listWrapperHeight) - LIST_INNER_PADDING;
|
|
206
226
|
const clearSearchQuery = () => {
|
|
207
227
|
changeSearchQuery("");
|
|
@@ -212,9 +232,19 @@ const ItemPickerListInner = ({
|
|
|
212
232
|
return /* @__PURE__ */ jsx(ErrorMessage, { texts: allTexts });
|
|
213
233
|
}
|
|
214
234
|
if (isLoading || isLoadingItems) {
|
|
215
|
-
return /* @__PURE__ */ jsx(ItemPickerListSkeleton, { wrapperHeight: listWrapperHeight });
|
|
235
|
+
return /* @__PURE__ */ jsx(ItemPickerListSkeleton, { wrapperHeight: listWrapperHeight, rowSize: mixedRowSize });
|
|
216
236
|
}
|
|
217
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
|
+
}
|
|
218
248
|
const itemsPath = currentPath || [currentSection?.text];
|
|
219
249
|
const searchByActionLabel = searchByAction?.sectionTitle || searchByAction?.text;
|
|
220
250
|
const searchInActionLabel = searchInAction?.text;
|
|
@@ -227,11 +257,11 @@ const ItemPickerListInner = ({
|
|
|
227
257
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
228
258
|
isSection && /* @__PURE__ */ jsx(Dropdown.BackAction, { tooltipProps: {
|
|
229
259
|
title: allTexts.backTooltip,
|
|
230
|
-
shortCuts: ["⌘", /* @__PURE__ */ jsx(Icon, { size: 18,
|
|
260
|
+
shortCuts: ["⌘", /* @__PURE__ */ jsx(Icon, { size: 18, component: /* @__PURE__ */ jsx(ArrowLeftM, {}) }, "hint-arrow-left")]
|
|
231
261
|
}, label: getSectionLabel(), onClick: goBack }),
|
|
232
|
-
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 }) }) }) })
|
|
233
263
|
] });
|
|
234
|
-
}, [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]);
|
|
235
265
|
useEffect(() => {
|
|
236
266
|
setTimeout(focusSearchInput, 0);
|
|
237
267
|
}, [isLoading, isLoadingItems, isLoadingMore, focusSearchInput]);
|
|
@@ -251,7 +281,7 @@ const ItemPickerListInner = ({
|
|
|
251
281
|
listRef.current.resetAfterIndex(0);
|
|
252
282
|
setTimeout(focusSearchInput, 0);
|
|
253
283
|
}
|
|
254
|
-
}, [searchByAction, searchByParamConfig, searchInAction, searchInItem, currentSection, focusSearchInput]);
|
|
284
|
+
}, [searchByAction, searchByParamConfig, searchInAction, searchInItem, currentSection, folderId, focusSearchInput]);
|
|
255
285
|
useEffect(() => {
|
|
256
286
|
listRef.current && listRef.current.resetAfterIndex(0);
|
|
257
287
|
}, [mergedItemsList]);
|
|
@@ -287,7 +317,7 @@ const ItemPickerListInner = ({
|
|
|
287
317
|
});
|
|
288
318
|
const containerHeightMode = !containerHeight || typeof containerHeight === "object" ? "preset" : containerHeight;
|
|
289
319
|
return /* @__PURE__ */ jsxs(ListContainer, { "data-testid": "ds-item-picker-dropdown", ref: combinedScrollRef, onKeyDown: handleKeyDown, containerHeightMode, wrapperHeight: outerWrapperHeight, ...htmlAttributes, children: [
|
|
290
|
-
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 }),
|
|
291
321
|
/* @__PURE__ */ jsx(ListWrapper, { "data-testid": "list-wrapper", ref: scrollContainRef, wrapperHeight: listWrapperHeight, centered: showMessage, offsetSpace, children: listContent }),
|
|
292
322
|
includeFooter && /* @__PURE__ */ jsx(ItemPickerListFooter, { "data-testid": "footer-wrapper", texts: allTexts, onRefresh: handleRefresh, refreshButtonProps: {
|
|
293
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>;
|
|
@@ -27,11 +27,11 @@ const EmptyStates = /* @__PURE__ */ styled(DSEmptyStates).withConfig({
|
|
|
27
27
|
const IconWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
28
28
|
displayName: "ItemPickerListstyles__IconWrapper",
|
|
29
29
|
componentId: "sc-1r33ill-4"
|
|
30
|
-
})(["margin-right:4px;
|
|
30
|
+
})(["margin-right:4px;color:var(--ds-color-icon-base-default);"]);
|
|
31
31
|
const FooterWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
32
32
|
displayName: "ItemPickerListstyles__FooterWrapper",
|
|
33
33
|
componentId: "sc-1r33ill-5"
|
|
34
|
-
})(["background-color:
|
|
34
|
+
})(["background-color:var(--ds-dropdown-footer-bg);padding:0 8px;height:48px;flex:0 0 48px;display:flex;align-items:center;justify-content:space-between;color:var(--ds-dropdown-text-additional);font-weight:500;border-top:solid 1px var(--ds-dropdown-footer-border);&:hover{color:var(--ds-color-text-brand-default);", "{color:var(--ds-color-icon-brand-default);}}"], IconWrapper);
|
|
35
35
|
const FooterWrapperRight = /* @__PURE__ */ styled.div.withConfig({
|
|
36
36
|
displayName: "ItemPickerListstyles__FooterWrapperRight",
|
|
37
37
|
componentId: "sc-1r33ill-6"
|
|
@@ -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-
|
|
66
|
-
})(["font-size:10px;line-height:1.6;font-weight:500;text-transform:uppercase;color:
|
|
73
|
+
componentId: "sc-1r33ill-15"
|
|
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 });
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { WarningL } from "@synerise/ds-icon";
|
|
2
|
+
import Icon, { WarningL } from "@synerise/ds-icon";
|
|
4
3
|
import { EmptyStates } from "../ItemPickerList.styles.js";
|
|
5
4
|
const ErrorMessage = ({
|
|
6
5
|
texts
|
|
7
6
|
}) => {
|
|
8
|
-
return /* @__PURE__ */ jsx(EmptyStates, { customIcon: /* @__PURE__ */ jsx(WarningL, {
|
|
7
|
+
return /* @__PURE__ */ jsx(EmptyStates, { customIcon: /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(WarningL, {}), color: "var(--ds-color-icon-danger-default)" }), text: texts.errorMessageTitle, label: texts.errorMessageDetails, labelPosition: "bottom" });
|
|
9
8
|
};
|
|
10
9
|
export {
|
|
11
10
|
ErrorMessage
|
|
@@ -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 {};
|