@synerise/ds-collector 1.4.49 → 1.4.51
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 +8 -0
- package/CLAUDE.md +130 -0
- package/package.json +11 -10
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
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
|
+
## [1.4.51](https://github.com/Synerise/synerise-design/compare/@synerise/ds-collector@1.4.50...@synerise/ds-collector@1.4.51) (2026-07-23)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-collector
|
|
9
|
+
|
|
10
|
+
## [1.4.50](https://github.com/Synerise/synerise-design/compare/@synerise/ds-collector@1.4.49...@synerise/ds-collector@1.4.50) (2026-07-16)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @synerise/ds-collector
|
|
13
|
+
|
|
6
14
|
## [1.4.49](https://github.com/Synerise/synerise-design/compare/@synerise/ds-collector@1.4.48...@synerise/ds-collector@1.4.49) (2026-07-09)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @synerise/ds-collector
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# Collector (`@synerise/ds-collector`)
|
|
2
|
+
|
|
3
|
+
> Tag-input / multi-value picker with a filterable suggestions dropdown, paste-splitting, keyboard navigation, confirm/cancel buttons, and an optional item counter — all in a single focusable field.
|
|
4
|
+
|
|
5
|
+
## Package structure
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
src/
|
|
9
|
+
Collector.tsx — main component; attaches sub-components as static props
|
|
10
|
+
Collector.types.ts — CollectorProps, CollectorValue, CollectorTexts, LookupConfig, CollectorValuesSeparator
|
|
11
|
+
Collector.styles.ts — styled components (Container, CollectorInput, MainContent, etc.)
|
|
12
|
+
utils.ts — filterValueSuggestions, isOverflown, scrollWithHorizontalArrow, filterOut* helpers
|
|
13
|
+
index.ts — public exports
|
|
14
|
+
hooks/
|
|
15
|
+
useTranslations.tsx — merges default i18n strings with consumer-provided texts
|
|
16
|
+
Elements/
|
|
17
|
+
ButtonPanel/ — add/cancel button row (right side of input)
|
|
18
|
+
OptionsDropdown/ — floating dropdown with filtered suggestions
|
|
19
|
+
NavigationHint/ — keyboard navigation tip rendered at bottom of dropdown
|
|
20
|
+
Values/ — list of selected tag chips inside the input
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Public exports
|
|
24
|
+
|
|
25
|
+
### `Collector` (default)
|
|
26
|
+
|
|
27
|
+
| Prop | Type | Default | Description |
|
|
28
|
+
|------|------|---------|-------------|
|
|
29
|
+
| `selected` | `CollectorValue[]` | _(required)_ | Currently selected items shown as chips. |
|
|
30
|
+
| `suggestions` | `CollectorValue[]` | _(required)_ | Full list of available options shown in the dropdown. |
|
|
31
|
+
| `onItemSelect` | `(item: CollectorValue) => void` | _(required)_ | Called when user selects an item from the dropdown. |
|
|
32
|
+
| `onItemAdd` | `(itemName: string \| number) => CollectorValue` | `undefined` | Factory for creating a new `CollectorValue` from a typed string. Required for `allowCustomValue` and `allowMultipleValues` to work. |
|
|
33
|
+
| `onConfirm` | `(values: CollectorValue[]) => void` | `undefined` | Called when user clicks Add or presses Enter with selected values. |
|
|
34
|
+
| `onCancel` | `() => void` | `undefined` | Called when user clicks Cancel. |
|
|
35
|
+
| `onItemDeselect` | `(item: CollectorValue) => void` | `undefined` | Called when a chip is removed. |
|
|
36
|
+
| `onMultipleItemsSelect` | `(items: CollectorValue[]) => void` | `undefined` | Called after a paste that produces multiple items. |
|
|
37
|
+
| `onSearchValueChange` | `(value: string) => void` | `undefined` | Called on every input keystroke (for controlled search). |
|
|
38
|
+
| `allowMultipleValues` | `boolean` | `undefined` | Enables multi-chip mode (chips shown, `selected` array managed externally). |
|
|
39
|
+
| `allowCustomValue` | `boolean` | `undefined` | Allows typing values not in `suggestions`. |
|
|
40
|
+
| `allowPaste` | `boolean` | `undefined` | Enables paste-splitting: pasted text containing the separator is auto-split into multiple items. |
|
|
41
|
+
| `valuesSeparator` | `CollectorValuesSeparator` | `';'` | Delimiter for paste-splitting. One of `';'` / `','` / `'|'`. |
|
|
42
|
+
| `valuesEscapeOpenTag` | `string` | `'```'` | Opening escape tag — text wrapped in open+close tags is treated as a literal value (separator inside is ignored). |
|
|
43
|
+
| `valuesEscapeCloseTag` | `string` | `'```'` | Closing escape tag. |
|
|
44
|
+
| `searchValue` | `string` | `undefined` | Controlled input value. |
|
|
45
|
+
| `texts` | `Partial<CollectorTexts>` | `undefined` | Override i18n strings. |
|
|
46
|
+
| `label` | `ReactNode` | `undefined` | Label rendered above the input. |
|
|
47
|
+
| `description` | `ReactNode` | `undefined` | Helper text rendered below the input. |
|
|
48
|
+
| `error` | `boolean` | `undefined` | Puts the input in error state (red border) without a message. |
|
|
49
|
+
| `errorText` | `ReactNode` | `undefined` | Error message; also activates error state. |
|
|
50
|
+
| `disabled` | `boolean` | `undefined` | Disables the entire component. |
|
|
51
|
+
| `disableSearch` | `boolean` | `undefined` | Hides the text input (values/chips still work). |
|
|
52
|
+
| `disableButtonPanel` | `boolean` | `undefined` | Hides the Add/Cancel button row on the right side. |
|
|
53
|
+
| `fixedHeight` | `boolean` | `undefined` | Input area stays a fixed height with horizontal scroll instead of growing. |
|
|
54
|
+
| `showCount` | `boolean` | `undefined` | Displays "N Item(s)" counter above the input. |
|
|
55
|
+
| `showNavigationHints` | `boolean` | `undefined` | Shows keyboard navigation hint (↑↓ / Enter) at the bottom of the dropdown. |
|
|
56
|
+
| `keepSearchQueryOnSelect` | `boolean` | `undefined` | Preserves the typed query after an item is selected from the dropdown. |
|
|
57
|
+
| `enableCustomFilteringSuggestions` | `boolean` | `undefined` | Disables internal suggestion filtering — consumer must update `suggestions` externally in response to `onSearchValueChange`. |
|
|
58
|
+
| `lookupConfig` | `LookupConfig` | `{ filter: 'text', display: 'text' }` | Keys to use for filtering (`filter`) and display (`display`) on `CollectorValue` objects. |
|
|
59
|
+
| `addButtonProps` | `Partial<ButtonProps & DataAttributes>` | `undefined` | Extra props merged onto the Add button (e.g. `data-*` attributes). `disabled` is auto-managed. |
|
|
60
|
+
| `cancelButtonProps` | `Partial<ButtonProps & DataAttributes>` | `undefined` | Extra props merged onto the Cancel button. |
|
|
61
|
+
| `buttonPanelPrefix` | `ReactNode` | `undefined` | Content rendered to the left of the Add/Cancel buttons. |
|
|
62
|
+
| `dropdownContent` | `ReactNode` | `undefined` | Replaces the default suggestion list with custom content. |
|
|
63
|
+
| `dropdownItemHeight` | `'large'` | `undefined` | Increases the height of dropdown list items. |
|
|
64
|
+
| `renderItem` | `(value: CollectorValue) => JSX.Element` | `undefined` | Custom renderer for each suggestion item. |
|
|
65
|
+
| `listHeader` | `ReactNode` | `undefined` | Content rendered at the top of the dropdown list. |
|
|
66
|
+
| `hideDropdownOnClickOutside` | `boolean` | `true` | Closes the dropdown when user clicks outside the component. |
|
|
67
|
+
| `className` | `string` | `undefined` | Extra class on the inner `CollectorInput` element (always includes `ds-collector`). |
|
|
68
|
+
| `scrollbarProps` | `ScrollbarAdditionalProps` | `undefined` | Defined in types but currently not passed to any rendered element. |
|
|
69
|
+
|
|
70
|
+
### Static sub-components
|
|
71
|
+
|
|
72
|
+
`Collector.Values`, `Collector.ButtonPanel`, `Collector.OptionsDropdown`, `Collector.NavigationHint` are attached to the default export. These are internal elements exposed for advanced composition — not intended for standalone use outside a `Collector`.
|
|
73
|
+
|
|
74
|
+
### Types (exported)
|
|
75
|
+
|
|
76
|
+
| Export | Description |
|
|
77
|
+
|--------|-------------|
|
|
78
|
+
| `CollectorProps` | Full props interface |
|
|
79
|
+
| `CollectorValue` | `{ [key: string]: any }` — arbitrary object used as item data |
|
|
80
|
+
| `CollectorTexts` | Shape of the `texts` override object |
|
|
81
|
+
| `CollectorValuesSeparator` | `';' \| ',' \| '\|'` |
|
|
82
|
+
|
|
83
|
+
## Custom hooks
|
|
84
|
+
|
|
85
|
+
### `useTranslations`
|
|
86
|
+
|
|
87
|
+
Merges consumer-provided `Partial<CollectorTexts>` with `react-intl` defaults. Returns a complete `CollectorTexts` object. Calls `useIntl()` unconditionally — `IntlProvider` must be present in the tree.
|
|
88
|
+
|
|
89
|
+
i18n defaults: `add` = "Add", `cancel` = "Cancel", `placeholder` = "Type value", `toNavigate` = "to navigate", `toSelect` = "to select".
|
|
90
|
+
|
|
91
|
+
## Usage patterns
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
import Collector, { type CollectorValue } from '@synerise/ds-collector';
|
|
95
|
+
|
|
96
|
+
const [selected, setSelected] = useState<CollectorValue[]>([]);
|
|
97
|
+
|
|
98
|
+
<Collector
|
|
99
|
+
selected={selected}
|
|
100
|
+
suggestions={[{ text: 'Option A' }, { text: 'Option B' }]}
|
|
101
|
+
onItemSelect={(item) => setSelected(prev => [...prev, item])}
|
|
102
|
+
onItemDeselect={(item) => setSelected(prev => prev.filter(v => v !== item))}
|
|
103
|
+
onItemAdd={(name) => ({ text: name })}
|
|
104
|
+
onConfirm={(values) => console.log(values)}
|
|
105
|
+
allowMultipleValues
|
|
106
|
+
allowCustomValue
|
|
107
|
+
texts={{ add: 'Add', cancel: 'Cancel', placeholder: 'Type to search…' }}
|
|
108
|
+
/>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Key dependencies
|
|
112
|
+
|
|
113
|
+
- `copy-to-clipboard` — not used here; see `@synerise/ds-copy-icon`
|
|
114
|
+
- `@synerise/ds-utils` `useOnClickOutside`, `focusWithArrowKeys`, `useDelimiterEscape` — click-outside dismissal, arrow-key focus, separator escape logic
|
|
115
|
+
- `@synerise/ds-scrollbar` — wraps the values area in non-fixed-height mode
|
|
116
|
+
- `lodash.isequal` — deep comparison when filtering already-selected items from suggestions
|
|
117
|
+
- `react-intl` (peer dep) — default tooltip/label strings via `useTranslations`
|
|
118
|
+
|
|
119
|
+
## Implementation notes
|
|
120
|
+
|
|
121
|
+
- **`selected`, `suggestions`, `onItemSelect` are required** (no `?` in types) — TypeScript will error if omitted.
|
|
122
|
+
- **`useIntl()` is called unconditionally** in `useTranslations` — an `IntlProvider` must exist in the tree even when `texts` fully overrides all strings.
|
|
123
|
+
- **Separator auto-split on keyUp** — when the typed value contains `valuesSeparator` (and is not wrapped in escape tags), `handleKeyUp` splits the input into multiple items automatically. Pressing `;` (default) mid-word commits the preceding token.
|
|
124
|
+
- **Paste splitting** requires both `allowMultipleValues` and `allowPaste` to be true — paste events containing the separator are split and passed to `onMultipleItemsSelect`.
|
|
125
|
+
- **Escape tag** — wrapping a value in `` ``` … ``` `` (defaults) prevents separator-based splitting. The open tag prefix is stripped before the item is created.
|
|
126
|
+
- **`enableCustomFilteringSuggestions`** — when `true`, internal filtering is disabled. The consumer is responsible for updating `suggestions` via `onSearchValueChange`. When `false` (default), the component filters `suggestions` by the typed value internally.
|
|
127
|
+
- **`lookupConfig` defaults** — if not provided, the component uses `'text'` for both filter and display keys. `CollectorValue` objects must have a `text` field for default behaviour to work.
|
|
128
|
+
- **`scrollbarProps` is a no-op** — it is declared in `CollectorProps` but never destructured or passed to any element in the current implementation.
|
|
129
|
+
- **`isAddActive`** — the Add button is enabled only when `selected.length > 0` or `canCreateItemFromValue()` returns `true`. `canCreateItemFromValue` checks `allowCustomValue || suggestionsIncludesItem(value)`.
|
|
130
|
+
- **Backspace removes last chip** — in `allowMultipleValues` mode with an empty input and at least one selected item, Backspace calls `onItemDeselect` on the last element of the `selected` array (via direct `.pop()` mutation — a side effect on the consumer's array).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-collector",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.51",
|
|
4
4
|
"description": "Collector UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"files": [
|
|
18
18
|
"/dist",
|
|
19
19
|
"CHANGELOG.md",
|
|
20
|
+
"CLAUDE.md",
|
|
20
21
|
"README.md",
|
|
21
22
|
"package.json",
|
|
22
23
|
"LICENSE.md"
|
|
@@ -41,14 +42,14 @@
|
|
|
41
42
|
],
|
|
42
43
|
"types": "dist/index.d.ts",
|
|
43
44
|
"dependencies": {
|
|
44
|
-
"@synerise/ds-button": "^1.5.
|
|
45
|
-
"@synerise/ds-divider": "^1.3.
|
|
46
|
-
"@synerise/ds-icon": "^1.18.
|
|
47
|
-
"@synerise/ds-input": "^1.7.
|
|
48
|
-
"@synerise/ds-list-item": "^1.6.
|
|
49
|
-
"@synerise/ds-scrollbar": "^1.5.
|
|
50
|
-
"@synerise/ds-search": "^1.5.
|
|
51
|
-
"@synerise/ds-utils": "^1.10.
|
|
45
|
+
"@synerise/ds-button": "^1.5.35",
|
|
46
|
+
"@synerise/ds-divider": "^1.3.16",
|
|
47
|
+
"@synerise/ds-icon": "^1.18.5",
|
|
48
|
+
"@synerise/ds-input": "^1.7.13",
|
|
49
|
+
"@synerise/ds-list-item": "^1.6.2",
|
|
50
|
+
"@synerise/ds-scrollbar": "^1.5.2",
|
|
51
|
+
"@synerise/ds-search": "^1.5.34",
|
|
52
|
+
"@synerise/ds-utils": "^1.10.2",
|
|
52
53
|
"classnames": "^2.5.1",
|
|
53
54
|
"lodash.isequal": "^4.5.0"
|
|
54
55
|
},
|
|
@@ -63,5 +64,5 @@
|
|
|
63
64
|
"@types/lodash.isequal": "^4.5.8",
|
|
64
65
|
"vitest": "4"
|
|
65
66
|
},
|
|
66
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "d0a43cc43d8528a36f105aceea52ab470edb71d9"
|
|
67
68
|
}
|