@synerise/ds-item-picker 2.2.2 → 2.3.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 +23 -0
- package/CLAUDE.md +7 -6
- package/dist/components/ItemPickerDropdown/ItemPickerDropdown.style.js +2 -4
- package/dist/components/ItemPickerList/ItemPickerList.js +1 -3
- package/dist/components/ItemPickerList/ItemPickerList.styles.js +3 -3
- package/dist/components/ItemPickerList/components/ErrorMessage.js +2 -3
- package/dist/components/ItemPickerList/components/ListSearchInput.js +1 -3
- package/dist/components/ItemPickerList/hooks/useItemsInSections.d.ts +1 -1
- package/dist/components/ItemPickerList/hooks/useItemsInSections.js +3 -1
- package/dist/components/ItemPickerNew/ItemPickerNew.js +1 -0
- package/dist/components/ItemPickerNew/ItemPickerNew.types.d.ts +1 -1
- package/dist/components/ItemPickerTrigger/Trigger.js +4 -5
- package/dist/components/ItemPickerTrigger/Trigger.styles.js +16 -16
- package/package.json +22 -22
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,29 @@
|
|
|
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.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
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* integrate Token Studio design tokens across the design system ([aabb447](https://github.com/Synerise/synerise-design/commit/aabb447edfb2d0c85e3de1f07e809ef84083453b))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [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)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **item-picker:** tolerate undefined items while the consumer loads ([35cb3c8](https://github.com/Synerise/synerise-design/commit/35cb3c8c6727796ed7f1ab01768f8e8bdb16ee97))
|
|
23
|
+
* keep the information card closed while its picker is open ([4fbed93](https://github.com/Synerise/synerise-design/commit/4fbed93dc688f1f26633378ecc5246c10869bcf4))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
6
29
|
## [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)
|
|
7
30
|
|
|
8
31
|
|
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 |
|
|
@@ -112,7 +112,7 @@ Current API. Generic over `ItemType extends BaseItemType` and `SectionType exten
|
|
|
112
112
|
| `tooltip?` | `ReactNode` | — | `FormField` tooltip |
|
|
113
113
|
| `tooltipConfig?` | `FormFieldCommonProps['tooltipConfig']` | — | `FormField` tooltip config |
|
|
114
114
|
| `error?` | `boolean` | — | Error state on trigger and FormField |
|
|
115
|
-
| `isObjectDeleted?` | `boolean` | — | Marks the selected item as deleted; renders its value text in
|
|
115
|
+
| `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
116
|
| `errorText?` | `FormFieldCommonProps['errorText']` | — | Preferred error message |
|
|
117
117
|
| `errorMessage?` | `FormFieldCommonProps['errorText']` | — | **@deprecated** — use `errorText` |
|
|
118
118
|
| `disabled?` | `boolean` | — | Disables trigger and dropdown |
|
|
@@ -167,7 +167,7 @@ Use `ItemPicker` (default) with `isNewVersion` instead.
|
|
|
167
167
|
| `clearConfirmTitle?` | `string` | `'Please confirm'` | Popconfirm title |
|
|
168
168
|
| `yesText?` / `noText?` | `string` | `'Yes'` / `'No'` | Popconfirm buttons |
|
|
169
169
|
| `error?` | `boolean` | — | Error state |
|
|
170
|
-
| `isObjectDeleted?` | `boolean` | — | Marks the selected item as deleted; renders its value text in
|
|
170
|
+
| `isObjectDeleted?` | `boolean` | — | Marks the selected item as deleted; renders its value text in `--ds-form-error-text-color` |
|
|
171
171
|
| `errorMessage?` | `ReactNode` | — | Error text |
|
|
172
172
|
| `disabled?` | `boolean` | — | Disabled state |
|
|
173
173
|
| `hideSearchBar?` | `boolean` | — | Hide search bar |
|
|
@@ -283,7 +283,7 @@ import { ItemPickerList } from '@synerise/ds-item-picker';
|
|
|
283
283
|
|
|
284
284
|
## Styling
|
|
285
285
|
|
|
286
|
-
- All styled-components; no hardcoded colours — uses
|
|
286
|
+
- All styled-components; no hardcoded colours — uses `var(--ds-*)` tokens.
|
|
287
287
|
- The outer wrapper is `S.ItemPickerWrapper` (just `position: relative`).
|
|
288
288
|
- List layout driven by `useListHeight`; default height 420 px, drops to 350 px below 800 px viewport threshold.
|
|
289
289
|
- `containerHeight` prop accepts `'fitContent'` (shrinks to content), `'fillSpace'` (100%), or an explicit `HeightConfig` object.
|
|
@@ -310,6 +310,7 @@ import { ItemPickerList } from '@synerise/ds-item-picker';
|
|
|
310
310
|
## Implementation notes
|
|
311
311
|
|
|
312
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`.
|
|
313
314
|
- **Async loading race prevention**: `useItemsInSections` tracks a `requestIdRef` UUID and discards stale responses.
|
|
314
315
|
- **AbortController**: each `loadItems` call gets a fresh `AbortController`; the previous one is aborted on re-trigger (section change, search, refresh).
|
|
315
316
|
- **Search action trigger**: typing `/` into the search bar activates the global actions list (`listActions = searchQuery === '/'`).
|
|
@@ -322,7 +323,7 @@ import { ItemPickerList } from '@synerise/ds-item-picker';
|
|
|
322
323
|
- `LIST_FOLDERS_IN_SECTIONS` — folder tiles (no items loaded yet)
|
|
323
324
|
- **`ItemPickerLegacy` is marked `@deprecated`** in source with a JSDoc comment on the component itself.
|
|
324
325
|
- **`errorMessage` prop** on `ItemPickerNew` is marked `@deprecated`; prefer `errorText` (from `FormFieldCommonProps`).
|
|
325
|
-
- **`isObjectDeleted` prop** (on `ItemPickerNew`, `ItemPickerLegacy`, and the shared `Trigger`) flags a selected item that no longer exists. When `true`, `Trigger.styles` renders `ValueText` in
|
|
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 `--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.
|
|
326
327
|
- **Several `ItemPickerTriggerProps` fields are `@deprecated`**: `clear`, `changeButtonLabel`, `clearConfirmTitle`, `yesText`, `noText` — move to `texts` object.
|
|
327
328
|
- **`Props` alias** in `Trigger.types.ts` is marked `@deprecated`; use `ItemPickerTriggerProps`.
|
|
328
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.
|
|
@@ -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";
|
|
@@ -50,7 +49,6 @@ const ItemPickerListInner = ({
|
|
|
50
49
|
noResultsComponent,
|
|
51
50
|
...htmlAttributes
|
|
52
51
|
}, forwardedRef) => {
|
|
53
|
-
const theme = useTheme();
|
|
54
52
|
const [searchQuery, setSearchQuery] = useState("");
|
|
55
53
|
const scrollBarRef = useRef(null);
|
|
56
54
|
const containerRef = useRef(null);
|
|
@@ -227,7 +225,7 @@ const ItemPickerListInner = ({
|
|
|
227
225
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
228
226
|
isSection && /* @__PURE__ */ jsx(Dropdown.BackAction, { tooltipProps: {
|
|
229
227
|
title: allTexts.backTooltip,
|
|
230
|
-
shortCuts: ["⌘", /* @__PURE__ */ jsx(Icon, { size: 18,
|
|
228
|
+
shortCuts: ["⌘", /* @__PURE__ */ jsx(Icon, { size: 18, component: /* @__PURE__ */ jsx(ArrowLeftM, {}) }, "hint-arrow-left")]
|
|
231
229
|
}, label: getSectionLabel(), onClick: goBack }),
|
|
232
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 }) }) }) })
|
|
233
231
|
] });
|
|
@@ -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"
|
|
@@ -63,7 +63,7 @@ const SkeletonWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
|
63
63
|
const Title = /* @__PURE__ */ styled.div.withConfig({
|
|
64
64
|
displayName: "ItemPickerListstyles__Title",
|
|
65
65
|
componentId: "sc-1r33ill-13"
|
|
66
|
-
})(["font-size:10px;line-height:1.6;font-weight:500;text-transform:uppercase;color:
|
|
66
|
+
})(["font-size:10px;line-height:1.6;font-weight:500;text-transform:uppercase;color:var(--ds-divider-header-text-color);padding:8px 12px;"]);
|
|
67
67
|
const TitleWithTooltip = /* @__PURE__ */ styled.div.withConfig({
|
|
68
68
|
displayName: "ItemPickerListstyles__TitleWithTooltip",
|
|
69
69
|
componentId: "sc-1r33ill-14"
|
|
@@ -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
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useState, useCallback, useEffect } from "react";
|
|
3
|
-
import { useTheme } from "@synerise/ds-core";
|
|
4
3
|
import Dropdown from "@synerise/ds-dropdown";
|
|
5
4
|
import Icon, { SearchM } from "@synerise/ds-icon";
|
|
6
5
|
import { SearchWrapper } from "../ItemPickerList.styles.js";
|
|
@@ -18,7 +17,6 @@ const ListSearchInput = ({
|
|
|
18
17
|
inputRef,
|
|
19
18
|
canPerformListActions
|
|
20
19
|
}) => {
|
|
21
|
-
const theme = useTheme();
|
|
22
20
|
const [localSearchQuery, setLocalSearchQuery] = useState("");
|
|
23
21
|
const handleSearchChange = useCallback((value) => {
|
|
24
22
|
setLocalSearchQuery(value);
|
|
@@ -44,7 +42,7 @@ const ListSearchInput = ({
|
|
|
44
42
|
const ref = changeLocalSearchQueryRef;
|
|
45
43
|
ref.current = setLocalSearchQuery;
|
|
46
44
|
}, [changeLocalSearchQueryRef]);
|
|
47
|
-
return /* @__PURE__ */ jsx(SearchWrapper, { "data-testid": "search-wrapper", children: /* @__PURE__ */ jsx(Dropdown.SearchInput, { iconLeft: /* @__PURE__ */ jsx(Icon, { component: searchByParamConfig?.icon || /* @__PURE__ */ jsx(SearchM, {})
|
|
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 }) });
|
|
48
46
|
};
|
|
49
47
|
export {
|
|
50
48
|
ListSearchInput
|
|
@@ -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;
|
|
@@ -9,13 +9,14 @@ import { getSearchByActionItems } from "../utils/getSearchByActionItems.js";
|
|
|
9
9
|
import { resolveSectionId } from "../utils/resolveSectionId.js";
|
|
10
10
|
import { useFlattenFolders } from "./useFlattenFolders.js";
|
|
11
11
|
import { matchesSearchQuery, getRecentItems, getFolderItems, getItems } from "./useItemsInSections.utils.js";
|
|
12
|
+
const EMPTY_ITEMS = [];
|
|
12
13
|
const getSectionHeight = (itemsCount, withTitle) => {
|
|
13
14
|
const itemsHeight = itemsCount * ITEM_SIZE[itemSizes.DEFAULT];
|
|
14
15
|
const titleHeight = withTitle && itemsCount ? ITEM_SIZE.title : 0;
|
|
15
16
|
return itemsHeight + titleHeight;
|
|
16
17
|
};
|
|
17
18
|
const useItemsInSections = ({
|
|
18
|
-
items,
|
|
19
|
+
items: itemsProp,
|
|
19
20
|
texts,
|
|
20
21
|
selectedItem,
|
|
21
22
|
sections,
|
|
@@ -29,6 +30,7 @@ const useItemsInSections = ({
|
|
|
29
30
|
changeSearchQuery,
|
|
30
31
|
onLoadedData
|
|
31
32
|
}) => {
|
|
33
|
+
const items = itemsProp ?? EMPTY_ITEMS;
|
|
32
34
|
const [currentSection, setCurrentSection] = useState();
|
|
33
35
|
const [previousSection, setPreviousSection] = useState();
|
|
34
36
|
const [searchByAction, setSearchByAction] = useState();
|
|
@@ -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'];
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useCallback, useMemo } from "react";
|
|
3
3
|
import Button from "@synerise/ds-button";
|
|
4
|
-
import { theme } from "@synerise/ds-core";
|
|
5
4
|
import Icon, { Close3S, WarningFillM, AngleDownS, EditM } from "@synerise/ds-icon";
|
|
6
5
|
import { InformationCardTooltip } from "@synerise/ds-information-card";
|
|
7
6
|
import Popconfirm from "@synerise/ds-popconfirm";
|
|
@@ -44,19 +43,19 @@ const Trigger = forwardRef(({
|
|
|
44
43
|
onClear && onClear();
|
|
45
44
|
}, [onClear, closeDropdown]);
|
|
46
45
|
const renderClear = useMemo(() => {
|
|
47
|
-
const tooltip = /* @__PURE__ */ jsx(Tooltip, { title: allTexts.clear, children: /* @__PURE__ */ jsx(ClearIconWrapper, { onClick: (event) => withClearConfirmation && event.stopPropagation(), children: /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(Close3S, {}), color:
|
|
46
|
+
const tooltip = /* @__PURE__ */ jsx(Tooltip, { title: allTexts.clear, children: /* @__PURE__ */ jsx(ClearIconWrapper, { onClick: (event) => withClearConfirmation && event.stopPropagation(), children: /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(Close3S, {}), color: "var(--ds-form-clear-icon)" }) }) });
|
|
48
47
|
if (selected) {
|
|
49
48
|
if (withClearConfirmation) {
|
|
50
49
|
return /* @__PURE__ */ jsx(Popconfirm, { title: allTexts.clearConfirmTitle, okButtonProps: {
|
|
51
50
|
onClick: handleClear
|
|
52
|
-
}, okText: allTexts.yes, cancelText: allTexts.no, icon: /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(WarningFillM, {}), color:
|
|
51
|
+
}, okText: allTexts.yes, cancelText: allTexts.no, icon: /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(WarningFillM, {}), color: "var(--ds-color-icon-warning-default)" }), children: tooltip });
|
|
53
52
|
}
|
|
54
53
|
return /* @__PURE__ */ jsx(ClearWrapper, { onClick: handleClear, "data-testid": "clear-icon", children: tooltip });
|
|
55
54
|
}
|
|
56
55
|
return null;
|
|
57
56
|
}, [allTexts.clear, allTexts.clearConfirmTitle, allTexts.yes, allTexts.no, selected, withClearConfirmation, handleClear]);
|
|
58
57
|
const renderAngleIcon = useMemo(() => {
|
|
59
|
-
return size === "small" && /* @__PURE__ */ jsx(AngleIconWrapper, { children: /* @__PURE__ */ jsx(Icon, { "data-testid": "angle-icon", component: /* @__PURE__ */ jsx(AngleDownS, {}), color:
|
|
58
|
+
return size === "small" && /* @__PURE__ */ jsx(AngleIconWrapper, { children: /* @__PURE__ */ jsx(Icon, { "data-testid": "angle-icon", component: /* @__PURE__ */ jsx(AngleDownS, {}), color: "var(--ds-form-icon-color-default)" }) });
|
|
60
59
|
}, [size]);
|
|
61
60
|
const handleChangeButtonClick = useCallback((event) => {
|
|
62
61
|
event.stopPropagation();
|
|
@@ -86,7 +85,7 @@ const Trigger = forwardRef(({
|
|
|
86
85
|
renderAngleIcon
|
|
87
86
|
] })
|
|
88
87
|
] }), [disabled, error, handleOpen, informationCardTooltipProps, onClear, opened, placeholder, placeholderIcon, ref, renderAngleIcon, renderChangeButton, renderClear, selected, size]);
|
|
89
|
-
return informationCardTooltipProps ? /* @__PURE__ */ jsx(InformationCardTriggerWrapper, { children: /* @__PURE__ */ jsx(InformationCardTooltip, { ref, ...informationCardTooltipProps, children: renderedTrigger }) }) : renderedTrigger;
|
|
88
|
+
return informationCardTooltipProps ? /* @__PURE__ */ jsx(InformationCardTriggerWrapper, { children: /* @__PURE__ */ jsx(InformationCardTooltip, { ref, ...informationCardTooltipProps, disabled: opened || informationCardTooltipProps.disabled, children: renderedTrigger }) }) : renderedTrigger;
|
|
90
89
|
});
|
|
91
90
|
export {
|
|
92
91
|
Trigger as default
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
2
|
const getDefaultStyles = (props) => {
|
|
3
3
|
if (props.size === "small") {
|
|
4
|
-
return `box-shadow: inset 0 0 0 1px
|
|
4
|
+
return `box-shadow: inset 0 0 0 1px var(--ds-form-field-border-default);`;
|
|
5
5
|
}
|
|
6
|
-
return `border: 1px dashed
|
|
6
|
+
return `border: 1px dashed var(--ds-form-field-border-default);`;
|
|
7
7
|
};
|
|
8
8
|
const getHoverStyles = (props) => {
|
|
9
9
|
if (props.size === "small") {
|
|
10
|
-
return `box-shadow: inset 0 0 0 1px
|
|
10
|
+
return `box-shadow: inset 0 0 0 1px var(--ds-form-field-border-hover);`;
|
|
11
11
|
}
|
|
12
|
-
return `border: 1px dashed
|
|
12
|
+
return `border: 1px dashed var(--ds-form-field-border-hover);`;
|
|
13
13
|
};
|
|
14
14
|
const getErrorStyles = (props) => {
|
|
15
15
|
if (props.size === "small") {
|
|
16
|
-
return `box-shadow: inset 0 0 0
|
|
16
|
+
return `box-shadow: inset 0 0 0 2px var(--ds-form-field-border-validated);`;
|
|
17
17
|
}
|
|
18
|
-
return `border: 1px dashed
|
|
18
|
+
return `border: 1px dashed var(--ds-form-field-border-validated);`;
|
|
19
19
|
};
|
|
20
20
|
const getFocusStyles = (props) => {
|
|
21
21
|
if (props.size === "small") {
|
|
22
|
-
return `box-shadow: inset 0 0 0 2px
|
|
22
|
+
return `box-shadow: inset 0 0 0 2px var(--ds-form-field-border-focus);`;
|
|
23
23
|
}
|
|
24
|
-
return `border: 1px dashed
|
|
24
|
+
return `border: 1px dashed var(--ds-form-field-border-focus);`;
|
|
25
25
|
};
|
|
26
26
|
const ClearIconWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
27
27
|
displayName: "Triggerstyles__ClearIconWrapper",
|
|
@@ -46,11 +46,11 @@ const Prefix = /* @__PURE__ */ styled.div.withConfig({
|
|
|
46
46
|
const Placeholder = /* @__PURE__ */ styled.div.withConfig({
|
|
47
47
|
displayName: "Triggerstyles__Placeholder",
|
|
48
48
|
componentId: "sc-1t1uce7-5"
|
|
49
|
-
})(["display:flex;flex-direction:row;align-items:center;justify-content:flex-start;flex:1;color:
|
|
49
|
+
})(["display:flex;flex-direction:row;align-items:center;justify-content:flex-start;flex:1;color:var(--ds-form-field-text-placeholder);padding:0 0 0 4px;", "{color:var(--ds-color-icon-base-subtle);}&:hover{color:", ";", "{color:var(--ds-form-icon-color-default);}}"], Prefix, (props) => props.size === "large" ? "var(--ds-color-text-base-muted)" : "var(--ds-form-field-text-placeholder)", Prefix);
|
|
50
50
|
const Value = /* @__PURE__ */ styled.div.withConfig({
|
|
51
51
|
displayName: "Triggerstyles__Value",
|
|
52
52
|
componentId: "sc-1t1uce7-6"
|
|
53
|
-
})(["display:flex;flex-direction:row;align-items:center;justify-content:flex-start;flex:1;color:
|
|
53
|
+
})(["display:flex;flex-direction:row;align-items:center;justify-content:flex-start;flex:1;color:var(--ds-form-field-text-value);max-width:100%;overflow:hidden;padding:0 0 0 4px;", ""], (props) => !props.isObjectDeleted && css(["", "{color:var(--ds-form-icon-color-default);}"], Prefix));
|
|
54
54
|
const Trigger = /* @__PURE__ */ styled.div.withConfig({
|
|
55
55
|
displayName: "Triggerstyles__Trigger",
|
|
56
56
|
componentId: "sc-1t1uce7-7"
|
|
@@ -62,7 +62,7 @@ const InformationCardTriggerWrapper = /* @__PURE__ */ styled.span.withConfig({
|
|
|
62
62
|
const TriggerWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
63
63
|
displayName: "Triggerstyles__TriggerWrapper",
|
|
64
64
|
componentId: "sc-1t1uce7-9"
|
|
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:
|
|
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:var(--ds-form-field-bg-focus);", ";}&&{", ";", " ", ";", ";}"], (props) => {
|
|
66
66
|
if (props.disabled) {
|
|
67
67
|
return "not-allowed";
|
|
68
68
|
}
|
|
@@ -72,15 +72,15 @@ const TriggerWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
|
72
72
|
return "pointer";
|
|
73
73
|
}, (props) => props.disabled ? "none" : "all", (props) => props.size === "small" ? "0 8px" : "0 12px", (props) => {
|
|
74
74
|
if (props.disabled) {
|
|
75
|
-
return
|
|
75
|
+
return "var(--ds-form-field-bg-disabled)";
|
|
76
76
|
}
|
|
77
77
|
if (props.error) {
|
|
78
|
-
return
|
|
78
|
+
return "var(--ds-form-field-bg-validated)";
|
|
79
79
|
}
|
|
80
80
|
if (props.size === "large") {
|
|
81
81
|
return "transparent";
|
|
82
82
|
}
|
|
83
|
-
return
|
|
83
|
+
return "var(--ds-form-field-bg-default)";
|
|
84
84
|
}, (props) => getDefaultStyles(props), (props) => props.clearable && props.size === "small" && `
|
|
85
85
|
${AngleIconWrapper} {
|
|
86
86
|
display: block;
|
|
@@ -95,7 +95,7 @@ const TriggerWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
|
95
95
|
${ClearIconWrapper} {
|
|
96
96
|
display: block;
|
|
97
97
|
}
|
|
98
|
-
`, (props) =>
|
|
98
|
+
`, (props) => getFocusStyles(props), (props) => props.selected && props.size === "large" && css(["border:1px solid var(--ds-form-field-border-default);&:hover{border:1px solid var(--ds-form-field-border-hover);}"]), (props) => props.opened && !props.error && css(["background-color:var(--ds-form-field-bg-focus);", ";"], getFocusStyles(props)), (props) => Boolean(props.error) && css(["background-color:var(--ds-form-field-bg-validated);", ""], getErrorStyles(props)), (props) => Boolean(props.disabled) && css(["", "{opacity:var(--ds-opacity-disabled);}"], IconWrapper));
|
|
99
99
|
const ChangeButtonWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
100
100
|
displayName: "Triggerstyles__ChangeButtonWrapper",
|
|
101
101
|
componentId: "sc-1t1uce7-10"
|
|
@@ -103,7 +103,7 @@ const ChangeButtonWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
|
103
103
|
const ValueText = /* @__PURE__ */ styled.span.withConfig({
|
|
104
104
|
displayName: "Triggerstyles__ValueText",
|
|
105
105
|
componentId: "sc-1t1uce7-11"
|
|
106
|
-
})(["text-overflow:ellipsis;overflow:hidden;white-space:nowrap;", ""], (props) => props.isObjectDeleted && css(["color:
|
|
106
|
+
})(["text-overflow:ellipsis;overflow:hidden;white-space:nowrap;", ""], (props) => props.isObjectDeleted && css(["color:var(--ds-form-error-text-color);"]));
|
|
107
107
|
export {
|
|
108
108
|
AngleIconWrapper,
|
|
109
109
|
ChangeButtonWrapper,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-item-picker",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "ItemPicker UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -42,27 +42,27 @@
|
|
|
42
42
|
],
|
|
43
43
|
"types": "dist/index.d.ts",
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@synerise/ds-avatar": "^2.0
|
|
46
|
-
"@synerise/ds-button": "^2.
|
|
47
|
-
"@synerise/ds-dropdown": "^2.
|
|
48
|
-
"@synerise/ds-empty-states": "^2.0
|
|
45
|
+
"@synerise/ds-avatar": "^2.1.0",
|
|
46
|
+
"@synerise/ds-button": "^2.2.0",
|
|
47
|
+
"@synerise/ds-dropdown": "^2.2.0",
|
|
48
|
+
"@synerise/ds-empty-states": "^2.1.0",
|
|
49
49
|
"@synerise/ds-flag": "^2.0.3",
|
|
50
|
-
"@synerise/ds-form-field": "^2.0
|
|
51
|
-
"@synerise/ds-icon": "^2.
|
|
52
|
-
"@synerise/ds-information-card": "^2.0
|
|
53
|
-
"@synerise/ds-inline-alert": "^2.0
|
|
54
|
-
"@synerise/ds-list-item": "^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.
|
|
50
|
+
"@synerise/ds-form-field": "^2.1.0",
|
|
51
|
+
"@synerise/ds-icon": "^2.3.0",
|
|
52
|
+
"@synerise/ds-information-card": "^2.1.0",
|
|
53
|
+
"@synerise/ds-inline-alert": "^2.1.0",
|
|
54
|
+
"@synerise/ds-list-item": "^2.3.0",
|
|
55
|
+
"@synerise/ds-loader": "^2.1.0",
|
|
56
|
+
"@synerise/ds-popconfirm": "^2.1.0",
|
|
57
|
+
"@synerise/ds-result": "^2.1.0",
|
|
58
|
+
"@synerise/ds-scrollbar": "^2.1.0",
|
|
59
|
+
"@synerise/ds-search": "^2.1.0",
|
|
60
|
+
"@synerise/ds-search-bar": "^2.1.0",
|
|
61
|
+
"@synerise/ds-short-cuts": "^2.1.0",
|
|
62
|
+
"@synerise/ds-skeleton": "^2.1.0",
|
|
63
|
+
"@synerise/ds-tooltip": "^2.1.0",
|
|
64
|
+
"@synerise/ds-typography": "^2.1.0",
|
|
65
|
+
"@synerise/ds-utils": "^2.3.0",
|
|
66
66
|
"lodash.debounce": "^4.0.8",
|
|
67
67
|
"react-window": "^1.8.11"
|
|
68
68
|
},
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"react-intl": ">=3.12.0 <= 6.8",
|
|
77
77
|
"styled-components": "^5.3.3"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "5c3d61e30289486d14c7d6becb682e2d4a08ce41"
|
|
80
80
|
}
|