@synerise/ds-item-picker 2.2.1 → 2.2.3
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 +25 -0
- package/CLAUDE.md +4 -4
- package/dist/components/ItemPickerList/ItemPickerList.js +8 -6
- package/dist/components/ItemPickerList/hooks/useItemsInSections.d.ts +2 -1
- package/dist/components/ItemPickerList/hooks/useItemsInSections.js +33 -5
- package/dist/components/ItemPickerNew/ItemPickerNew.js +1 -0
- package/dist/components/ItemPickerNew/ItemPickerNew.types.d.ts +1 -1
- package/dist/components/ItemPickerTrigger/Trigger.js +2 -2
- package/dist/components/ItemPickerTrigger/Trigger.styles.d.ts +1 -0
- package/dist/components/ItemPickerTrigger/Trigger.styles.js +8 -3
- package/package.json +27 -28
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,31 @@
|
|
|
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.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
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **item-picker:** tolerate undefined items while the consumer loads ([35cb3c8](https://github.com/Synerise/synerise-design/commit/35cb3c8c6727796ed7f1ab01768f8e8bdb16ee97))
|
|
12
|
+
* keep the information card closed while its picker is open ([4fbed93](https://github.com/Synerise/synerise-design/commit/4fbed93dc688f1f26633378ecc5246c10869bcf4))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## [2.2.2](https://github.com/Synerise/synerise-design/compare/@synerise/ds-item-picker@2.2.1...@synerise/ds-item-picker@2.2.2) (2026-10-26)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* drop vitest peer dependency and bump vulnerable runtime deps ([2467d36](https://github.com/Synerise/synerise-design/commit/2467d3606aa97141a3a2d80c3ef396e78bee285c))
|
|
24
|
+
* **item-picker:** fix list bugs found while prototyping the mixed list variant ([8104f7a](https://github.com/Synerise/synerise-design/commit/8104f7a535dd96982971a9c962f41d162a5f5114))
|
|
25
|
+
* remove per-render random keys and guard against them with a Biome plugin ([fcea7c5](https://github.com/Synerise/synerise-design/commit/fcea7c5d60b80c28cbbd191bfa2792379782a0e8))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
6
31
|
## [2.2.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-item-picker@2.2.0...@synerise/ds-item-picker@2.2.1) (2026-10-22)
|
|
7
32
|
|
|
8
33
|
**Note:** Version bump only for package @synerise/ds-item-picker
|
package/CLAUDE.md
CHANGED
|
@@ -103,8 +103,8 @@ Current API. Generic over `ItemType extends BaseItemType` and `SectionType exten
|
|
|
103
103
|
| `includeFooter?` | `boolean` | `true` | Show refresh footer |
|
|
104
104
|
| `includeSearchBar?` | `boolean` | `true` | Show search bar |
|
|
105
105
|
| `texts?` | `Partial<ItemPickerTexts>` | (react-intl defaults) | Override any of the 23 localised text strings |
|
|
106
|
-
| `triggerProps?` | `{ size?, allowClear?, withChangeButton?, withClearConfirmation?, informationCardTooltipProps? }` | — | Props forwarded to the default `Trigger
|
|
107
|
-
| `renderTrigger?` | `(props) => ReactNode` | — | Completely replace the trigger; receives `{ selected, openDropdown, closeDropdown, error, disabled }` |
|
|
106
|
+
| `triggerProps?` | `{ size?, allowClear?, withChangeButton?, withClearConfirmation?, informationCardTooltipProps? }` | — | Props forwarded to the default `Trigger`; its information card stays closed while the dropdown is open |
|
|
107
|
+
| `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
108
|
| `placeholder?` | `ReactNode` | — | Trigger placeholder text |
|
|
109
109
|
| `placeholderIcon?` | `ReactNode` | — | Icon shown in placeholder state |
|
|
110
110
|
| `label?` | `ReactNode` | — | `FormField` label |
|
|
@@ -303,7 +303,6 @@ import { ItemPickerList } from '@synerise/ds-item-picker';
|
|
|
303
303
|
| `@synerise/ds-popconfirm` | Clear-confirmation dialog |
|
|
304
304
|
| `@synerise/ds-information-card` | Optional info tooltip on trigger |
|
|
305
305
|
| `lodash.debounce` | 300 ms debounce on search query |
|
|
306
|
-
| `uuid` | Unique class-name per list instance (used by `focusWithArrowKeys`) |
|
|
307
306
|
| `react-intl` | All default text strings |
|
|
308
307
|
|
|
309
308
|
---
|
|
@@ -311,6 +310,7 @@ import { ItemPickerList } from '@synerise/ds-item-picker';
|
|
|
311
310
|
## Implementation notes
|
|
312
311
|
|
|
313
312
|
- **Version switch**: `ItemPicker` (default) checks `'isNewVersion' in props && props.isNewVersion` at render time. No runtime flag registry — purely prop-driven.
|
|
313
|
+
- **Undefined `items`**: `items` is required in the type, but `useItemsInSections` treats `undefined` as an empty fixed list, so a loosely typed consumer that passes `undefined` while its data loads gets an empty list instead of a render crash. To show a skeleton during that time, the consumer has to pass `isLoading`.
|
|
314
314
|
- **Async loading race prevention**: `useItemsInSections` tracks a `requestIdRef` UUID and discards stale responses.
|
|
315
315
|
- **AbortController**: each `loadItems` call gets a fresh `AbortController`; the previous one is aborted on re-trigger (section change, search, refresh).
|
|
316
316
|
- **Search action trigger**: typing `/` into the search bar activates the global actions list (`listActions = searchQuery === '/'`).
|
|
@@ -328,4 +328,4 @@ import { ItemPickerList } from '@synerise/ds-item-picker';
|
|
|
328
328
|
- **`Props` alias** in `Trigger.types.ts` is marked `@deprecated`; use `ItemPickerTriggerProps`.
|
|
329
329
|
- **Tests use Vitest** (`vitest run`); the root `@testing-library/user-event` is v10, so there is no `userEvent.hover` — a `ds-tooltip` cannot be opened from these specs.
|
|
330
330
|
- 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
|
-
- `ItemPickerList` generates a unique per-instance CSS class via `
|
|
331
|
+
- `ItemPickerList` generates a unique per-instance CSS class via `generateUuid()` on mount; `focusWithArrowKeys` from `@synerise/ds-utils` uses this class for keyboard navigation.
|
|
@@ -1,13 +1,12 @@
|
|
|
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 { v4 } from "uuid";
|
|
5
4
|
import { useTheme } from "@synerise/ds-core";
|
|
6
5
|
import Dropdown from "@synerise/ds-dropdown";
|
|
7
6
|
import Icon, { ArrowLeftM } from "@synerise/ds-icon";
|
|
8
7
|
import { itemSizes, ListContextProvider } from "@synerise/ds-list-item";
|
|
9
8
|
import { Text } from "@synerise/ds-typography";
|
|
10
|
-
import { useCombinedRefs, useScrollContain, useMeasuredRowHeights, useKeyboardShortcuts, focusWithArrowKeys } from "@synerise/ds-utils";
|
|
9
|
+
import { useCombinedRefs, useScrollContain, generateUuid, useMeasuredRowHeights, useKeyboardShortcuts, focusWithArrowKeys } from "@synerise/ds-utils";
|
|
11
10
|
import { useDefaultTexts } from "../../hooks/useDefaultTexts.js";
|
|
12
11
|
import { EmptyListMessage } from "./components/EmptyListMessage.js";
|
|
13
12
|
import { ErrorMessage } from "./components/ErrorMessage.js";
|
|
@@ -23,6 +22,7 @@ import { useListHeight } from "./hooks/useListHeight.js";
|
|
|
23
22
|
import { findSectionById } from "./utils/findSectionById.js";
|
|
24
23
|
import { isNavKey } from "./utils/isNavKey.js";
|
|
25
24
|
import { isTitle } from "./utils/typeguards.utils.js";
|
|
25
|
+
const ListRow = ItemPickerListRow;
|
|
26
26
|
const ItemPickerListInner = ({
|
|
27
27
|
items,
|
|
28
28
|
recents,
|
|
@@ -70,7 +70,7 @@ const ItemPickerListInner = ({
|
|
|
70
70
|
const debouncedSearchQueryChange = useRef(debounce((query) => {
|
|
71
71
|
changeSearchQuery(query);
|
|
72
72
|
}, 300)).current;
|
|
73
|
-
const classNames = useMemo(() => `ds-item-picker-dropdown ds-item-picker-dropdown-${
|
|
73
|
+
const classNames = useMemo(() => `ds-item-picker-dropdown ds-item-picker-dropdown-${generateUuid()}`, []);
|
|
74
74
|
const handleItemSelect = (item) => {
|
|
75
75
|
const section = findSectionById(sections, item.sectionId);
|
|
76
76
|
onItemSelect?.(item, section);
|
|
@@ -85,6 +85,7 @@ const ItemPickerListInner = ({
|
|
|
85
85
|
isLoadingMoreError,
|
|
86
86
|
isLoading: isLoadingItems,
|
|
87
87
|
isLoadedAll,
|
|
88
|
+
isSinglePage,
|
|
88
89
|
isLoadingError,
|
|
89
90
|
handleScrollEndReach,
|
|
90
91
|
refreshItems,
|
|
@@ -144,6 +145,7 @@ const ItemPickerListInner = ({
|
|
|
144
145
|
}, []);
|
|
145
146
|
const handleKeyDown = (event) => {
|
|
146
147
|
if (isNavKey(event)) {
|
|
148
|
+
event.stopPropagation();
|
|
147
149
|
focusWithArrowKeys(event, classNames.split(" ")[1], () => {
|
|
148
150
|
focusSearchInput();
|
|
149
151
|
});
|
|
@@ -172,12 +174,12 @@ const ItemPickerListInner = ({
|
|
|
172
174
|
getEstimatedItemSize,
|
|
173
175
|
measureRow,
|
|
174
176
|
texts: allTexts,
|
|
175
|
-
infiniteScroll: {
|
|
177
|
+
infiniteScroll: isSinglePage ? void 0 : {
|
|
176
178
|
isLoading: isLoadingMore,
|
|
177
179
|
hasMore: !isLoadedAll,
|
|
178
180
|
hasError: isLoadingMoreError
|
|
179
181
|
}
|
|
180
|
-
}), [mergedItemsList, classNames, getItemSize, getEstimatedItemSize, measureRow, allTexts, isLoadingMore, isLoadedAll, isLoadingMoreError]);
|
|
182
|
+
}), [mergedItemsList, classNames, getItemSize, getEstimatedItemSize, measureRow, allTexts, isLoadingMore, isLoadedAll, isSinglePage, isLoadingMoreError]);
|
|
181
183
|
const handleRefresh = onRefresh || refreshItems ? () => {
|
|
182
184
|
changeSearchQuery("");
|
|
183
185
|
setSearchByParamConfig(void 0);
|
|
@@ -227,7 +229,7 @@ const ItemPickerListInner = ({
|
|
|
227
229
|
title: allTexts.backTooltip,
|
|
228
230
|
shortCuts: ["⌘", /* @__PURE__ */ jsx(Icon, { size: 18, color: theme.palette.white, component: /* @__PURE__ */ jsx(ArrowLeftM, {}) }, "hint-arrow-left")]
|
|
229
231
|
}, 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:
|
|
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 }) }) }) })
|
|
231
233
|
] });
|
|
232
234
|
}, [allTexts, currentSection, currentPath, getItemSize, handleScroll, isLoading, isLoadingError, isLoadingItems, itemData, listHeight, goBack, mergedItemsList.length, scrollbarProps, searchQuery, listWrapperHeight]);
|
|
233
235
|
useEffect(() => {
|
|
@@ -17,7 +17,7 @@ type ItemsInSectionsType<ItemType extends BaseItemType, SectionType extends Base
|
|
|
17
17
|
changeSearchQuery: (query: string) => void;
|
|
18
18
|
onLoadedData?: OnLoadedData;
|
|
19
19
|
};
|
|
20
|
-
export declare const useItemsInSections: <ItemType extends BaseItemType, SectionType extends BaseSectionType | undefined>({ items, texts, selectedItem, sections, recents, actions, searchQuery, handleItemSelect, onSectionChange, getItemKey, showItemsSectionLabel, changeSearchQuery, onLoadedData, }: ItemsInSectionsType<ItemType, SectionType>) => {
|
|
20
|
+
export declare const useItemsInSections: <ItemType extends BaseItemType, SectionType extends BaseSectionType | undefined>({ items: itemsProp, texts, selectedItem, sections, recents, actions, searchQuery, handleItemSelect, onSectionChange, getItemKey, showItemsSectionLabel, changeSearchQuery, onLoadedData, }: ItemsInSectionsType<ItemType, SectionType>) => {
|
|
21
21
|
currentSection: BaseSectionType | undefined;
|
|
22
22
|
currentPath: import('react').ReactNode[] | undefined;
|
|
23
23
|
goBack: () => void;
|
|
@@ -27,6 +27,7 @@ export declare const useItemsInSections: <ItemType extends BaseItemType, Section
|
|
|
27
27
|
isLoading: boolean;
|
|
28
28
|
isLoadingMore: boolean;
|
|
29
29
|
isLoadedAll: boolean;
|
|
30
|
+
isSinglePage: boolean;
|
|
30
31
|
handleScrollEndReach: () => void;
|
|
31
32
|
refreshItems: (() => void) | undefined;
|
|
32
33
|
isLoadingError: boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useState, useRef, useMemo, useCallback, useEffect } from "react";
|
|
2
2
|
import { itemSizes } from "@synerise/ds-list-item";
|
|
3
|
+
import { generateUuid } from "@synerise/ds-utils";
|
|
3
4
|
import { FIRST_PAGE, ITEMS_PER_SECTION_IN_SEARCH, ITEMS_PER_SECTION, ITEM_SIZE, SECTION_HEADER_HEIGHT, GET_ITEM_KEY, ITEMS_PER_PAGE, SECOND_PAGE } from "../constants.js";
|
|
4
5
|
import { RENDER_MODES } from "../types/renderMode.js";
|
|
5
6
|
import { isItems, isItemsConfig, isWithOutSections } from "../utils/typeguards.utils.js";
|
|
@@ -8,13 +9,14 @@ import { getSearchByActionItems } from "../utils/getSearchByActionItems.js";
|
|
|
8
9
|
import { resolveSectionId } from "../utils/resolveSectionId.js";
|
|
9
10
|
import { useFlattenFolders } from "./useFlattenFolders.js";
|
|
10
11
|
import { matchesSearchQuery, getRecentItems, getFolderItems, getItems } from "./useItemsInSections.utils.js";
|
|
12
|
+
const EMPTY_ITEMS = [];
|
|
11
13
|
const getSectionHeight = (itemsCount, withTitle) => {
|
|
12
14
|
const itemsHeight = itemsCount * ITEM_SIZE[itemSizes.DEFAULT];
|
|
13
15
|
const titleHeight = withTitle && itemsCount ? ITEM_SIZE.title : 0;
|
|
14
16
|
return itemsHeight + titleHeight;
|
|
15
17
|
};
|
|
16
18
|
const useItemsInSections = ({
|
|
17
|
-
items,
|
|
19
|
+
items: itemsProp,
|
|
18
20
|
texts,
|
|
19
21
|
selectedItem,
|
|
20
22
|
sections,
|
|
@@ -28,6 +30,7 @@ const useItemsInSections = ({
|
|
|
28
30
|
changeSearchQuery,
|
|
29
31
|
onLoadedData
|
|
30
32
|
}) => {
|
|
33
|
+
const items = itemsProp ?? EMPTY_ITEMS;
|
|
31
34
|
const [currentSection, setCurrentSection] = useState();
|
|
32
35
|
const [previousSection, setPreviousSection] = useState();
|
|
33
36
|
const [searchByAction, setSearchByAction] = useState();
|
|
@@ -56,6 +59,7 @@ const useItemsInSections = ({
|
|
|
56
59
|
const [isLoadingMoreError, setIsLoadingMoreError] = useState(false);
|
|
57
60
|
const [isLoadingMore, setIsLoadingMore] = useState(false);
|
|
58
61
|
const [isLoadedAll, setIsLoadedAll] = useState(false);
|
|
62
|
+
const [isSinglePage, setIsSinglePage] = useState(false);
|
|
59
63
|
const [refreshTrigger, setRefreshTrigger] = useState();
|
|
60
64
|
const [currentItems, setCurrentItems] = useState(() => {
|
|
61
65
|
if (isFixedItemsList) {
|
|
@@ -237,20 +241,23 @@ const useItemsInSections = ({
|
|
|
237
241
|
}
|
|
238
242
|
setIsLoading(true);
|
|
239
243
|
setIsLoadingError(false);
|
|
240
|
-
const currentRequestId =
|
|
244
|
+
const currentRequestId = generateUuid();
|
|
241
245
|
requestIdRef.current = currentRequestId;
|
|
246
|
+
const abortController = abortControllerRef.current;
|
|
242
247
|
if (listRenderingMode === RENDER_MODES.LIST_ITEMS) {
|
|
243
248
|
try {
|
|
249
|
+
const limit = items.limitPerPage || ITEMS_PER_PAGE;
|
|
244
250
|
const {
|
|
245
251
|
items: fetchedItems2,
|
|
252
|
+
total,
|
|
246
253
|
meta
|
|
247
254
|
} = await items.loadItems({
|
|
248
255
|
page: FIRST_PAGE,
|
|
249
256
|
searchQuery,
|
|
250
257
|
sectionId: activeSectionIdWithFallback,
|
|
251
|
-
limit
|
|
258
|
+
limit,
|
|
252
259
|
meta: void 0,
|
|
253
|
-
abortController
|
|
260
|
+
abortController,
|
|
254
261
|
searchKey: searchByParamConfig?.paramKey,
|
|
255
262
|
searchInItem
|
|
256
263
|
});
|
|
@@ -259,6 +266,10 @@ const useItemsInSections = ({
|
|
|
259
266
|
}
|
|
260
267
|
setIsLoading(false);
|
|
261
268
|
pageToLoad.current = FIRST_PAGE + 1;
|
|
269
|
+
if (total <= limit) {
|
|
270
|
+
setIsLoadedAll(true);
|
|
271
|
+
setIsSinglePage(true);
|
|
272
|
+
}
|
|
262
273
|
metaRef.current[activeSectionIdWithFallback] = meta;
|
|
263
274
|
onLoadedData?.({
|
|
264
275
|
sectionId: activeSectionIdWithFallback,
|
|
@@ -268,9 +279,14 @@ const useItemsInSections = ({
|
|
|
268
279
|
setIsInitialDataLoaded(true);
|
|
269
280
|
setCurrentItems(fetchedItems2);
|
|
270
281
|
} catch (_event) {
|
|
282
|
+
if (currentRequestId !== requestIdRef.current) {
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
271
285
|
setIsLoading(false);
|
|
272
286
|
setIsInitialDataLoaded(true);
|
|
273
|
-
|
|
287
|
+
if (!abortController?.signal.aborted) {
|
|
288
|
+
setIsLoadingError(true);
|
|
289
|
+
}
|
|
274
290
|
}
|
|
275
291
|
return;
|
|
276
292
|
}
|
|
@@ -341,6 +357,7 @@ const useItemsInSections = ({
|
|
|
341
357
|
pageToLoad.current = FIRST_PAGE;
|
|
342
358
|
metaRef.current = {};
|
|
343
359
|
setIsLoadedAll(false);
|
|
360
|
+
setIsSinglePage(false);
|
|
344
361
|
setIsLoadingMore(false);
|
|
345
362
|
sectionTotals.current = {};
|
|
346
363
|
if (!isFixedItemsList) {
|
|
@@ -378,12 +395,15 @@ const useItemsInSections = ({
|
|
|
378
395
|
return;
|
|
379
396
|
}
|
|
380
397
|
setIsLoadingMore(true);
|
|
398
|
+
const pageRequestId = requestIdRef.current;
|
|
399
|
+
const isStale = () => pageRequestId !== requestIdRef.current;
|
|
381
400
|
items.loadItems({
|
|
382
401
|
page: pageToLoad.current,
|
|
383
402
|
limit: items.limitPerPage || ITEMS_PER_PAGE,
|
|
384
403
|
searchQuery,
|
|
385
404
|
sectionId: activeSectionIdWithFallback,
|
|
386
405
|
meta: metaRef.current[activeSectionIdWithFallback],
|
|
406
|
+
abortController: abortControllerRef.current,
|
|
387
407
|
searchKey: searchByParamConfig?.paramKey,
|
|
388
408
|
searchInItem
|
|
389
409
|
}).then(({
|
|
@@ -391,6 +411,9 @@ const useItemsInSections = ({
|
|
|
391
411
|
total,
|
|
392
412
|
meta
|
|
393
413
|
}) => {
|
|
414
|
+
if (isStale()) {
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
394
417
|
sectionTotals.current[activeSectionIdWithFallback] = total;
|
|
395
418
|
metaRef.current[activeSectionIdWithFallback] = meta;
|
|
396
419
|
setIsLoadingMore(false);
|
|
@@ -401,6 +424,9 @@ const useItemsInSections = ({
|
|
|
401
424
|
pageToLoad.current += 1;
|
|
402
425
|
setCurrentItems([...currentItems, ...fetchedItems]);
|
|
403
426
|
}).catch(() => {
|
|
427
|
+
if (isStale()) {
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
404
430
|
setIsLoadingMore(false);
|
|
405
431
|
setIsLoadingMoreError(true);
|
|
406
432
|
});
|
|
@@ -495,6 +521,7 @@ const useItemsInSections = ({
|
|
|
495
521
|
pageToLoad.current = FIRST_PAGE;
|
|
496
522
|
metaRef.current = {};
|
|
497
523
|
setIsLoadedAll(false);
|
|
524
|
+
setIsSinglePage(false);
|
|
498
525
|
setIsLoadingMore(false);
|
|
499
526
|
sectionTotals.current = {};
|
|
500
527
|
abortControllerRef.current?.abort();
|
|
@@ -513,6 +540,7 @@ const useItemsInSections = ({
|
|
|
513
540
|
isLoading: isLoading || !isInitialDataLoaded,
|
|
514
541
|
isLoadingMore,
|
|
515
542
|
isLoadedAll,
|
|
543
|
+
isSinglePage,
|
|
516
544
|
handleScrollEndReach,
|
|
517
545
|
refreshItems,
|
|
518
546
|
isLoadingError,
|
|
@@ -48,7 +48,7 @@ export type ItemsConfig<ItemType extends BaseItemType> = {
|
|
|
48
48
|
export type ItemPickerTexts = ItemPickerListTexts & ItemPickerTriggerTexts;
|
|
49
49
|
export type ItemPickerProps<ItemType extends BaseItemType, SectionType extends BaseSectionType | undefined> = WithHTMLAttributes<HTMLDivElement, {
|
|
50
50
|
isNewVersion: true;
|
|
51
|
-
renderTrigger?: (props: Pick<ItemPickerTriggerProps, 'disabled' | 'error' | 'selected' | 'openDropdown' | 'closeDropdown'>) => ReactNode;
|
|
51
|
+
renderTrigger?: (props: Pick<ItemPickerTriggerProps, 'disabled' | 'error' | 'selected' | 'opened' | 'openDropdown' | 'closeDropdown'>) => ReactNode;
|
|
52
52
|
texts?: Partial<ItemPickerTexts>;
|
|
53
53
|
triggerProps?: {
|
|
54
54
|
size?: ItemPickerTriggerProps['size'];
|
|
@@ -7,7 +7,7 @@ import { InformationCardTooltip } from "@synerise/ds-information-card";
|
|
|
7
7
|
import Popconfirm from "@synerise/ds-popconfirm";
|
|
8
8
|
import Tooltip from "@synerise/ds-tooltip";
|
|
9
9
|
import { useDefaultTexts } from "../../hooks/useDefaultTexts.js";
|
|
10
|
-
import { ClearIconWrapper, ClearWrapper, AngleIconWrapper, ChangeButtonWrapper, TriggerWrapper, Trigger as Trigger$1, Value, Prefix, ValueText, Placeholder, IconWrapper } from "./Trigger.styles.js";
|
|
10
|
+
import { ClearIconWrapper, ClearWrapper, AngleIconWrapper, ChangeButtonWrapper, TriggerWrapper, Trigger as Trigger$1, Value, Prefix, ValueText, Placeholder, IconWrapper, InformationCardTriggerWrapper } from "./Trigger.styles.js";
|
|
11
11
|
const Trigger = forwardRef(({
|
|
12
12
|
selected,
|
|
13
13
|
clear,
|
|
@@ -86,7 +86,7 @@ const Trigger = forwardRef(({
|
|
|
86
86
|
renderAngleIcon
|
|
87
87
|
] })
|
|
88
88
|
] }), [disabled, error, handleOpen, informationCardTooltipProps, onClear, opened, placeholder, placeholderIcon, ref, renderAngleIcon, renderChangeButton, renderClear, selected, size]);
|
|
89
|
-
return informationCardTooltipProps ? /* @__PURE__ */ jsx(
|
|
89
|
+
return informationCardTooltipProps ? /* @__PURE__ */ jsx(InformationCardTriggerWrapper, { children: /* @__PURE__ */ jsx(InformationCardTooltip, { ref, ...informationCardTooltipProps, disabled: opened || informationCardTooltipProps.disabled, children: renderedTrigger }) }) : renderedTrigger;
|
|
90
90
|
});
|
|
91
91
|
export {
|
|
92
92
|
Trigger as default
|
|
@@ -23,6 +23,7 @@ export declare const Value: import('styled-components').StyledComponent<"div", a
|
|
|
23
23
|
export declare const Trigger: import('styled-components').StyledComponent<"div", any, {
|
|
24
24
|
size: ItemPickerSize;
|
|
25
25
|
}, never>;
|
|
26
|
+
export declare const InformationCardTriggerWrapper: import('styled-components').StyledComponent<"span", any, {}, never>;
|
|
26
27
|
export declare const TriggerWrapper: import('styled-components').StyledComponent<"div", any, TriggerWrapperProps, never>;
|
|
27
28
|
export declare const ChangeButtonWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
28
29
|
export declare const ValueText: import('styled-components').StyledComponent<"span", any, {
|
|
@@ -55,9 +55,13 @@ const Trigger = /* @__PURE__ */ styled.div.withConfig({
|
|
|
55
55
|
displayName: "Triggerstyles__Trigger",
|
|
56
56
|
componentId: "sc-1t1uce7-7"
|
|
57
57
|
})(["max-width:100%;width:100%;overflow:hidden;border-radius:3px;height:", ";display:flex;align-items:center;justify-content:flex-start;position:relative;transition:all 0.3s ease;font-weight:", ";"], (props) => props.size === "small" ? "32px" : "48px", (props) => props.size === "small" ? "400" : "500");
|
|
58
|
+
const InformationCardTriggerWrapper = /* @__PURE__ */ styled.span.withConfig({
|
|
59
|
+
displayName: "Triggerstyles__InformationCardTriggerWrapper",
|
|
60
|
+
componentId: "sc-1t1uce7-8"
|
|
61
|
+
})(["display:block;width:100%;min-width:0;"]);
|
|
58
62
|
const TriggerWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
59
63
|
displayName: "Triggerstyles__TriggerWrapper",
|
|
60
|
-
componentId: "sc-1t1uce7-
|
|
64
|
+
componentId: "sc-1t1uce7-9"
|
|
61
65
|
})(["width:100%;display:flex;flex-direction:row;align-items:center;justify-content:space-between;cursor:", ";pointer-events:", ";position:relative;border-radius:3px;transition:all 0.3s ease;padding:", ";background-color:", ";", " ", " &:hover{", ";", "}&:focus{background-color:", ";", ";}&&{", ";", " ", ";", ";}"], (props) => {
|
|
62
66
|
if (props.disabled) {
|
|
63
67
|
return "not-allowed";
|
|
@@ -94,11 +98,11 @@ const TriggerWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
|
94
98
|
`, (props) => props.theme.palette["blue-050"], (props) => getFocusStyles(props), (props) => props.selected && props.size === "large" && css(["border:1px solid ", ";&:hover{border:1px solid ", ";}"], props.theme.palette["grey-300"], props.theme.palette["grey-400"]), (props) => props.opened && !props.error && css(["background-color:", ";", ";"], props.theme.palette["blue-050"], getFocusStyles(props)), (props) => Boolean(props.error) && css(["background-color:", ";", ""], props.theme.palette["red-050"], getErrorStyles(props)), (props) => Boolean(props.disabled) && css(["", "{opacity:0.4;}"], IconWrapper));
|
|
95
99
|
const ChangeButtonWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
96
100
|
displayName: "Triggerstyles__ChangeButtonWrapper",
|
|
97
|
-
componentId: "sc-1t1uce7-
|
|
101
|
+
componentId: "sc-1t1uce7-10"
|
|
98
102
|
})(["margin:0 4px 0 8px;"]);
|
|
99
103
|
const ValueText = /* @__PURE__ */ styled.span.withConfig({
|
|
100
104
|
displayName: "Triggerstyles__ValueText",
|
|
101
|
-
componentId: "sc-1t1uce7-
|
|
105
|
+
componentId: "sc-1t1uce7-11"
|
|
102
106
|
})(["text-overflow:ellipsis;overflow:hidden;white-space:nowrap;", ""], (props) => props.isObjectDeleted && css(["color:", ";"], props.theme.palette["red-600"]));
|
|
103
107
|
export {
|
|
104
108
|
AngleIconWrapper,
|
|
@@ -106,6 +110,7 @@ export {
|
|
|
106
110
|
ClearIconWrapper,
|
|
107
111
|
ClearWrapper,
|
|
108
112
|
IconWrapper,
|
|
113
|
+
InformationCardTriggerWrapper,
|
|
109
114
|
Placeholder,
|
|
110
115
|
Prefix,
|
|
111
116
|
Trigger,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-item-picker",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.3",
|
|
4
4
|
"description": "ItemPicker UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -42,40 +42,39 @@
|
|
|
42
42
|
],
|
|
43
43
|
"types": "dist/index.d.ts",
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@synerise/ds-avatar": "^2.0.
|
|
46
|
-
"@synerise/ds-button": "^2.1.
|
|
47
|
-
"@synerise/ds-dropdown": "^2.1.
|
|
48
|
-
"@synerise/ds-empty-states": "^2.0.
|
|
49
|
-
"@synerise/ds-flag": "^2.0.
|
|
50
|
-
"@synerise/ds-form-field": "^2.0.
|
|
51
|
-
"@synerise/ds-icon": "^2.2.
|
|
52
|
-
"@synerise/ds-information-card": "^2.0.
|
|
53
|
-
"@synerise/ds-inline-alert": "^2.0.
|
|
54
|
-
"@synerise/ds-list-item": "^2.2.
|
|
55
|
-
"@synerise/ds-loader": "^2.0.
|
|
56
|
-
"@synerise/ds-popconfirm": "^2.0.
|
|
57
|
-
"@synerise/ds-result": "^2.0.
|
|
58
|
-
"@synerise/ds-scrollbar": "^2.0.
|
|
59
|
-
"@synerise/ds-search": "^2.0.
|
|
60
|
-
"@synerise/ds-search-bar": "^2.0.
|
|
61
|
-
"@synerise/ds-short-cuts": "^2.0.
|
|
62
|
-
"@synerise/ds-skeleton": "^2.0.
|
|
63
|
-
"@synerise/ds-tooltip": "^2.0.
|
|
64
|
-
"@synerise/ds-typography": "^2.0.
|
|
65
|
-
"@synerise/ds-utils": "^2.2.
|
|
45
|
+
"@synerise/ds-avatar": "^2.0.11",
|
|
46
|
+
"@synerise/ds-button": "^2.1.6",
|
|
47
|
+
"@synerise/ds-dropdown": "^2.1.8",
|
|
48
|
+
"@synerise/ds-empty-states": "^2.0.8",
|
|
49
|
+
"@synerise/ds-flag": "^2.0.3",
|
|
50
|
+
"@synerise/ds-form-field": "^2.0.11",
|
|
51
|
+
"@synerise/ds-icon": "^2.2.3",
|
|
52
|
+
"@synerise/ds-information-card": "^2.0.14",
|
|
53
|
+
"@synerise/ds-inline-alert": "^2.0.8",
|
|
54
|
+
"@synerise/ds-list-item": "^2.2.4",
|
|
55
|
+
"@synerise/ds-loader": "^2.0.3",
|
|
56
|
+
"@synerise/ds-popconfirm": "^2.0.11",
|
|
57
|
+
"@synerise/ds-result": "^2.0.11",
|
|
58
|
+
"@synerise/ds-scrollbar": "^2.0.9",
|
|
59
|
+
"@synerise/ds-search": "^2.0.11",
|
|
60
|
+
"@synerise/ds-search-bar": "^2.0.12",
|
|
61
|
+
"@synerise/ds-short-cuts": "^2.0.11",
|
|
62
|
+
"@synerise/ds-skeleton": "^2.0.11",
|
|
63
|
+
"@synerise/ds-tooltip": "^2.0.11",
|
|
64
|
+
"@synerise/ds-typography": "^2.0.11",
|
|
65
|
+
"@synerise/ds-utils": "^2.2.2",
|
|
66
66
|
"lodash.debounce": "^4.0.8",
|
|
67
|
-
"react-window": "^1.8.11"
|
|
68
|
-
"uuid": "^8.3.2"
|
|
67
|
+
"react-window": "^1.8.11"
|
|
69
68
|
},
|
|
70
69
|
"devDependencies": {
|
|
71
|
-
"@types/lodash.debounce": "^4.0.9"
|
|
70
|
+
"@types/lodash.debounce": "^4.0.9",
|
|
71
|
+
"vitest": "4"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
74
|
"@synerise/ds-core": "*",
|
|
75
75
|
"react": ">=16.9.0 <= 18.3.1",
|
|
76
76
|
"react-intl": ">=3.12.0 <= 6.8",
|
|
77
|
-
"styled-components": "^5.3.3"
|
|
78
|
-
"vitest": "4"
|
|
77
|
+
"styled-components": "^5.3.3"
|
|
79
78
|
},
|
|
80
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "c356039703d8826bbbdb6dadcb18bb008fea8bc5"
|
|
81
80
|
}
|