@synerise/ds-select 1.3.34 → 1.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 CHANGED
@@ -3,6 +3,27 @@
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.0](https://github.com/synerise/synerise-design/compare/@synerise/ds-select@1.3.34...@synerise/ds-select@1.4.0) (2026-07-24)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **select:** add onKeyDown, maxLength, dropdownAlign, popupClassName, maxTagPlaceholder ([1cf5f39](https://github.com/synerise/synerise-design/commit/1cf5f394055c10caee8b2bef81c83d04e19dcd6e))
11
+ - **select:** add suffixIcon, tabIndex, option style/children parity shims ([10c0bbc](https://github.com/synerise/synerise-design/commit/10c0bbc584534f7950bd5093764d9363a526149b))
12
+ - **select:** color clear/remove icons via currentColor, not svg fill ([0573124](https://github.com/synerise/synerise-design/commit/05731249ebc2d6d291879f0cb0f7443d8966a2b6))
13
+ - **select:** fire onFocus/onBlur and split render into sub-components ([44f73ec](https://github.com/synerise/synerise-design/commit/44f73ec0dc705c920950048acfa61ea108ec8072))
14
+ - **select:** forward data-_ and aria-_ attributes to the select root ([49294a8](https://github.com/synerise/synerise-design/commit/49294a8b1ab2b17967fc9d8ce9879eb48c5844cb))
15
+ - **select:** mark the current option selected via ListItem selected prop ([b5cb80a](https://github.com/synerise/synerise-design/commit/b5cb80a9d6e8a0411752a58fb0e66770f5c19408))
16
+ - **select:** move onClick off the dropdown trigger; focus inputs in interaction tests ([ed1a79c](https://github.com/synerise/synerise-design/commit/ed1a79c45bf056304a11e959ceb086dc1258b55e))
17
+ - **select:** multiple chip keeps its label-defined width; X squeezes label on hover ([5c9908d](https://github.com/synerise/synerise-design/commit/5c9908d8ff86119aa3948a1f366497827598bd3d))
18
+ - **select:** overlay search input and blur it on selection ([f312354](https://github.com/synerise/synerise-design/commit/f31235487542b29f31b2435c2b9951716803d20c))
19
+ - **select:** restore antd-parity props for consumer back-compat ([ceac672](https://github.com/synerise/synerise-design/commit/ceac6729c4c4815ee918a927a98aa17de0407e8d))
20
+
21
+ ### Features
22
+
23
+ - **select:** forward per-option data-_/aria-_ to the rendered option row ([1a8162d](https://github.com/synerise/synerise-design/commit/1a8162d9dae98a5cf96b0f35f70f9148eb025e88))
24
+ - **select:** implement maxTagCount/maxTagTextLength/maxTagPlaceholder + onPopupScroll ([060d2c6](https://github.com/synerise/synerise-design/commit/060d2c6b74118c065d928786dad67aa1b88500c7))
25
+ - **select:** keyboard-arrow option navigation + combobox/listbox ARIA ([74e5466](https://github.com/synerise/synerise-design/commit/74e5466b23dc2d062c0bd734cc84334f55b99ab8))
26
+
6
27
  ## [1.3.34](https://github.com/synerise/synerise-design/compare/@synerise/ds-select@1.3.33...@synerise/ds-select@1.3.34) (2026-07-23)
7
28
 
8
29
  **Note:** Version bump only for package @synerise/ds-select
package/CLAUDE.md CHANGED
@@ -1,140 +1,175 @@
1
1
  # Select (`@synerise/ds-select`)
2
2
 
3
- > A DS-styled select dropdown wrapping Ant Design's Select with FormField integration, prefix/suffix addon support, `readOnly` mode, and a `raw` render variant.
3
+ > A DS-native select dropdown (no Ant Design): a selector trigger + floating options dropdown built
4
+ > on `@synerise/ds-dropdown` (floating-ui) and `@synerise/ds-list-item`, wrapped in `FormField`.
5
+ > Supports single-select, `multiple` (chips), `tags` (free-text) and in-selector search, with full
6
+ > keyboard navigation, combobox/listbox ARIA, prefix/suffix addons, `readOnly`, and a `raw` variant.
4
7
 
5
8
  ## Package structure
6
9
 
7
10
  ```
8
11
  src/
9
- Select.tsx — main component (forwardRef, compound with .Option and .OptGroup)
10
- Select.types.ts — Props type (extends Antd SelectProps + FormFieldCommonProps)
11
- Select.styles.ts — styled-components: SelectContainer, AntdSelect, SelectWrapper, PrefixWrapper, SuffixWrapper
12
- index.tsdefault export, SelectProps type, SelectStyles namespace
12
+ Select.tsx — main component (forwardRef, compound with .Option); composes the sub-components below
13
+ Select.types.ts — SelectProps, SelectValue, SelectOption, SelectMode, SelectHandler, RawValueType, FilterOptionFn
14
+ Select.styles.ts — styled-components (Selector = the .ds-select box, SelectWrapper, chips, dropdown, …)
15
+ Option.tsxdeclarative <Select.Option> marker (renders null) + OptionProps
16
+ index.ts — default export + types + SelectStyles namespace + getOptionsFromChildren/findOption
17
+ Select.figma.tsx — Figma Code Connect mapping
13
18
  modules.d.ts — imports @testing-library/jest-dom
14
- style/
15
- index.lessimports antd select LESS + ds-core variables + select.mixin.less
16
- select.mixin.less — DS overrides for all antd select class variants (dropdown, items, states)
19
+ hooks/
20
+ useSelectOptions.tsresolve options (prop children), client filtering, tags create-row
21
+ components/
22
+ OptionList.tsx — dropdown overlay: loading / empty / scrollable listbox of options
23
+ SelectorContent.tsx — selector inner content: chips / selected label / placeholder + search input
24
+ utils/
25
+ getOptionsFromChildren.ts — read <Select.Option> children into SelectOption[]; findOption()
26
+ helpers.ts — cx(), toArray(), defaultFilter(), DEFAULT_LIST_HEIGHT
17
27
  __specs__/
18
- Select.spec.tsx — Vitest + React Testing Library tests
28
+ Select.spec.tsx — Vitest + React Testing Library tests
19
29
  ```
20
30
 
31
+ > No `style/` dir and no `antd` peerDep — the component is styled purely with styled-components. The
32
+ > old antd-era LESS (`select.mixin.less`, `.ant-select-*` overrides) was relocated to `ds-table`
33
+ > (`table/src/style/`), the only consumer that still renders antd selects.
34
+
21
35
  ## Public exports
22
36
 
23
37
  ```ts
24
- export default SelectWithComponents; // compound: Select + .Option + .OptGroup
25
- export type { Props as SelectProps } from './Select.types';
38
+ export { default } from './Select'; // compound: Select + .Option
39
+ export { Option, type OptionProps } from './Option';
40
+ export type {
41
+ Props, SelectProps, SelectValue, SelectOption, SelectMode,
42
+ SelectHandler, RawValueType, FilterOptionFn,
43
+ } from './Select.types';
26
44
  export * as SelectStyles from './Select.styles';
45
+ export { getOptionsFromChildren, findOption } from './utils/getOptionsFromChildren';
27
46
  ```
28
47
 
29
48
  ### `Select` (default)
30
49
 
31
- The default export is a compound component. Sub-components come from Antd directly:
32
- - `Select.Option` `AntdSelect.Option`
33
- - `Select.OptGroup` `AntdSelect.OptGroup`
50
+ `forwardRef<HTMLDivElement, SelectProps>`, augmented into a compound component with a single
51
+ sub-component: **`Select.Option`** (the DS `Option` marker). `Select.OptGroup` is intentionally
52
+ **not** reimplemented (zero real usage).
34
53
 
35
- The component is wrapped in `forwardRef<HTMLDivElement, Props>`.
54
+ `SelectValue = string | number | (string | number)[] | undefined` — antd-free (no `LabeledValue`).
36
55
 
37
56
  #### DS-specific props
38
57
 
39
58
  | Prop | Type | Default | Description |
40
59
  |------|------|---------|-------------|
41
- | `label` | `ReactNode` | `undefined` | Label above the field (via `FormField`). |
42
- | `tooltip` | `ReactNode` | `undefined` | Info tooltip next to the label (renders InfoFillS icon trigger). |
43
- | `tooltipConfig` | `TooltipProps` | `undefined` | Extra config merged into the label Tooltip. |
44
- | `description` | `ReactNode` | `undefined` | Helper text below the field. |
45
- | `errorText` | `ReactNode` | `undefined` | Error message below the field; also activates error visual state. |
46
- | `error` | `boolean` | `undefined` | Activates error visual state without showing a message. |
47
- | `clearTooltip` | `string` | `undefined` | Tooltip text shown on hover of the clear (×) button. |
48
- | `prefixel` | `ReactNode` | `undefined` | Addon element attached to the left of the selector (shares border). |
49
- | `suffixel` | `ReactNode` | `undefined` | Addon element attached to the right of the selector (shares border). |
50
- | `grey` | `boolean` | `undefined` | Gives the selector a `grey-050` background when not in error state. |
51
- | `asFormElement` | `boolean` | `undefined` | Forces a 16 px bottom margin even when `errorText` and `description` are absent. |
52
- | `raw` | `boolean` | `undefined` | Skips the `FormField` wrapper entirely renders only the selector. `forwardedRef` attaches to `SelectWrapper` instead of `SelectContainer`. |
53
- | `readOnly` | `boolean` | `undefined` | Disables the antd select while styling it as readable (white bg, `default` cursor, `grey-600` text) instead of the standard disabled look. |
54
- | `disabled` | `boolean` | `undefined` | Standard disabled state; merged with `readOnly` — either flag disables the underlying Antd select. |
55
- | `listHeight` | `ReactText` | `256` (Antd default) | Max height of the dropdown list in px. Type is widened to `ReactText` (string or number), overriding Antd's `number`-only constraint. |
56
- | `selectorStyle` | `CSSObject` | `undefined` | Inline styled-components `css` applied to `.ant-select-selector`. Useful for custom widths or padding. |
57
- | `style` | `React.CSSProperties` | `undefined` | Applied to `SelectWrapper` (the flex row containing selector + addons). |
58
- | `className` | `string` | `undefined` | Added to `SelectWrapper`. |
59
- | `getPopupContainer` | `(triggerNode) => HTMLElement` | `defaultGetPopupContainer` from `@synerise/ds-utils` | Where the dropdown is rendered. |
60
-
61
- All Antd `SelectProps<T>` are also accepted and forwarded (mode, value, defaultValue, onChange, onSearch, filterOption, showSearch, allowClear, open, etc.).
60
+ | `label` / `description` / `tooltip` / `tooltipConfig` | `ReactNode` / `TooltipProps` | `undefined` | `FormField` chrome (from `FormFieldCommonProps`). |
61
+ | `errorText` | `ReactNode` | `undefined` | Error message below the field; also activates the error visual state. |
62
+ | `error` | `boolean` | `undefined` | Error visual state without a message. |
63
+ | `clearTooltip` | `string` | `undefined` | Tooltip on hover of the clear (×) control. |
64
+ | `prefixel` / `suffixel` | `ReactNode` | `undefined` | Addon nodes attached left/right of the selector (shared border). |
65
+ | `grey` | `boolean` | `undefined` | `grey-050` selector background when not in error state. |
66
+ | `asFormElement` | `boolean` | `undefined` | Forces a 16 px bottom margin even without `errorText`/`description`. |
67
+ | `raw` | `boolean` | `undefined` | Skips the `FormField` wrapper renders only the selector; `ref` attaches to `SelectWrapper`. |
68
+ | `readOnly` | `boolean` | `undefined` | Non-interactive with readable styling (white bg, `default` cursor, `grey-600` text). |
69
+ | `disabled` | `boolean` | `undefined` | Standard disabled state; ORed with `readOnly` to block interaction. |
70
+ | `selectorStyle` | `CSSObject` | `undefined` | Inline style object applied to the `Selector` box. |
71
+ | `listHeight` | `number \| string` | `256` | Max dropdown list height (px). |
72
+ | `style` | `CSSProperties` | `undefined` | Applied to `SelectWrapper` (the flex row: selector + addons). |
73
+ | `className` | `string` | `undefined` | Added to the outer `SelectContainer`. |
74
+ | `getPopupContainer` | `(node) => HTMLElement \| ParentNode \| null` | `defaultGetPopupContainer` (`@synerise/ds-utils`) | Container the dropdown mounts into. |
75
+ | `size` | `'default' \| 'middle' \| 'large'` | `'default'` | Selector height (`middle` maps to `default`). |
76
+
77
+ Native `data-*` / `aria-*` attributes are forwarded onto the select root (`.ds-select-wrapper`).
78
+
79
+ #### antd-parity props (additive back-compat)
80
+
81
+ Kept so antd-era consumers need no change: `searchValue`, `onClear`, `onClick`, `onInputKeyDown`,
82
+ `onKeyDown`, `suffixIcon`, `clearIcon`, `maxLength`, `maxTagCount`, `maxTagTextLength`,
83
+ `maxTagPlaceholder`, `onPopupScroll`, `popupClassName` (alias of `dropdownClassName`),
84
+ `dropdownMatchSelectWidth` (`boolean | number`), `dropdownRender`, `showArrow`,
85
+ `autoFocus`, `tabIndex`, `rowKey`, plus the standard
86
+ `mode`/`options`/`showSearch`/`filterOption`/`allowClear`/`open`/`onChange`/`onSearch`/… surface.
87
+ `SelectHandler` type and the `SelectStyles.Selector` styled export are re-exported for parity.
88
+
89
+ `maxTagCount` (collapse extra chips into a `+N` overflow chip), `maxTagTextLength` (truncate chip
90
+ labels) and `onPopupScroll` are fully implemented. `listItemHeight`, `dropdownAlign` and
91
+ `defaultActiveFirstOption` are accepted for compatibility but have **no runtime effect**.
62
92
 
63
93
  ## Usage patterns
64
94
 
65
95
  ```tsx
66
96
  import Select from '@synerise/ds-select';
67
97
 
68
- const { Option, OptGroup } = Select;
69
-
70
- // Basic with FormField label / description
71
- <Select label="Platform" description="Choose your platform" defaultValue="insta">
72
- <OptGroup label="Social">
73
- <Option value="insta">Instagram</Option>
74
- <Option value="fb">Facebook</Option>
75
- </OptGroup>
76
- </Select>
77
-
78
- // Multiple mode
79
- <Select mode="multiple" placeholder="Select tags" allowClear>
80
- <Option value="a">Alpha</Option>
81
- <Option value="b">Beta</Option>
82
- </Select>
98
+ const { Option } = Select;
83
99
 
84
- // Error state with message
85
- <Select errorText="This field is required" value={undefined} />
100
+ // Options as data (preferred)
101
+ <Select label="Platform" options={[{ value: 'insta', label: 'Instagram' }]} defaultValue="insta" />
86
102
 
87
- // Error state without message (e.g. inline in a form row)
88
- <Select error />
103
+ // Declarative children (read only when `options` is absent)
104
+ <Select label="Platform"><Option value="insta">Instagram</Option></Select>
89
105
 
90
- // readOnly (looks like a regular input, not grayed out)
91
- <Select readOnly value="locked-value" />
106
+ // Multiple (removable chips) / tags (free-text) / search
107
+ <Select mode="multiple" placeholder="Select tags" allowClear options={opts} />
108
+ <Select mode="tags" tokenSeparators={[',']} />
109
+ <Select showSearch filterOption optionFilterProp="label" options={opts} />
92
110
 
93
- // Grey background variant
94
- <Select grey placeholder="Search.." showSearch />
111
+ // Remote search: filter server-side, feed options from onSearch
112
+ <Select showSearch filterOption={false} onSearch={fetchOptions} options={opts} />
95
113
 
96
- // Raw (no FormField wrapper, ref goes to SelectWrapper)
114
+ // readOnly / raw / prefix-suffix
115
+ <Select readOnly value="locked" />
97
116
  <Select raw ref={myRef} placeholder="Compact" />
98
-
99
- // Prefix / suffix addons
100
117
  <Select prefixel={<span>$</span>} suffixel={<span>USD</span>} />
101
-
102
- // Clear button tooltip
103
- <Select allowClear clearTooltip="Clear selection" />
104
118
  ```
105
119
 
106
120
  ## Styling
107
121
 
108
- Two-layer styling approach:
109
-
110
- 1. **LESS** (`style/index.less` + `style/select.mixin.less`) — overrides all Antd `.ant-select-*` class rules: dropdown shadows, item hover colors, selected-item checkmark (base64 SVG), arrow icon (base64 SVG), tag/multiple chip styles, focus ring (`blue-600` inset shadow, `blue-050` bg), disabled state.
111
-
112
- 2. **styled-components** (`Select.styles.ts`) — handles DS-specific structural and state variants:
113
- - `SelectContainer` `flex-direction: column`; adds `16px` bottom margin when `hasBottomMargin` is true.
114
- - `SelectWrapper` `display: flex` row; applies `grey-050` background via `grey` prop (only when not in error state).
115
- - `AntdSelect` — extends Antd Select; handles `large` size height/line-height overrides, `withPrefixel`/`withSuffixel` border-radius removal, error border/shadow/background (`red-600`/`red-050`), and `readOnly` vs `disabled` visual differentiation.
116
- - `PrefixWrapper` / `SuffixWrapper` `grey-050` background, `grey-300` inset box-shadow, rounded outer corners only; negative margin/padding creates flush border join with selector.
117
-
118
- The dropdown offset is hard-coded to `[0, 8]` px via `dropdownAlign` (STOR-588).
119
-
120
- The search icon in the selector is replaced with an inline SVG data-URL using the theme's `grey-400` color.
122
+ **styled-components (`Select.styles.ts`) is the source of truth.** Key styled parts:
123
+ - `SelectContainer` — column flex; adds a 16 px bottom margin when `hasBottomMargin`.
124
+ - `SelectWrapper` (`.ds-select-wrapper`) — the flex row (selector + addons); carries the root
125
+ `onFocus`/`onBlur`/`onClick` and `data-*`/`aria-*` passthrough.
126
+ - `Selector` (`.ds-select`) — the trigger box; `large` height, `withPrefixel`/`withSuffixel`
127
+ border-radius removal, open/focus ring (`blue-600`/`blue-050`), error (`red-600`/`red-050`),
128
+ `readOnly` vs `disabled` differentiation, and the `selectorStyle` interpolation.
129
+ - `PrefixWrapper` / `SuffixWrapper` `grey-050` addons with flush border join.
130
+ - Dropdown / options: `DropdownWrapper`, `ScrollList`, `Inner` (`role="listbox"`), `OptionItem`
131
+ (styled `ds-list-item`), `NotFound`, `Loading`. Selector content: `SelectionItem`, `Placeholder`,
132
+ `MultiValueArea`, `Chip`/`ChipLabel`/`ChipRemove`, `Arrow`, `ClearWrapper`, `SearchInputEl`.
133
+
134
+ Class hooks are `ds-select-*` (`.ds-select`, `.ds-select-selection-item`, `.ds-select-dropdown`,
135
+ `.ds-select-arrow`, `.ds-select-clear`, `.ds-select-search`, …).
121
136
 
122
137
  ## Key dependencies
123
138
 
124
- - `antd/lib/select` — base Select, Option, OptGroup
125
- - `@synerise/ds-form-field` — wraps label / description / error layout (skipped when `raw` is true)
126
- - `@synerise/ds-icon` `Close3M` for clear button, `CloseS` for tag remove icon
127
- - `@synerise/ds-tooltip` — wraps the clear button icon to show `clearTooltip`
128
- - `@synerise/ds-utils` — `getPopupContainer` default (renders dropdown in nearest scroll parent)
129
- - `@synerise/ds-core` — theme tokens used in styled-components; LESS variables imported in Less styles
139
+ - `@synerise/ds-dropdown` — floating-ui popover positioning + overlay (the `Selector` is the `asChild` trigger).
140
+ - `@synerise/ds-list-item` — the option row (`OptionItem`) and list wrapper (`ScrollList`).
141
+ - `@synerise/ds-scrollbar` / `@synerise/ds-loader` dropdown scroll container / loading spinner.
142
+ - `@synerise/ds-form-field` — label / description / error layout (skipped when `raw`).
143
+ - `@synerise/ds-icon` — `AngleDownS` (arrow), `Close3M` (clear), `CloseS` (chip remove).
144
+ - `@synerise/ds-tooltip` — wraps the clear control for `clearTooltip`.
145
+ - `@synerise/ds-utils` — default `getPopupContainer`.
146
+ - `@synerise/ds-core` — theme tokens (peerDep). **No `antd` peerDep** — the component imports zero
147
+ antd; the LESS that pulled `~antd/lib/select/style` was relocated to `ds-table` (see below).
130
148
 
131
149
  ## Implementation notes
132
150
 
133
- - **`readOnly` is implemented via `disabled`** both `readOnly` and `disabled` flags are ORed before passing to Antd's `disabled` prop. The visual distinction is achieved only through styled-components CSS on the `readOnly` transient prop.
134
- - **`it.only` in tests** — the `'should be empty'` test case uses `it.only`, which means the other tests in the file are skipped when running in isolation. This is likely unintentional.
135
- - **`listHeight` type widening** Antd types `listHeight` as `number`, but DS overrides it to `ReactText` (`string | number`) to allow string values like `"auto"`.
136
- - **`selectorStyle` is not in README** — the prop exists in `Select.types.ts` and is wired in `AntdSelect` styled component but is not documented in the README.
137
- - **`clearIcon` is always overridden** — even if `clearIcon` is passed via `antdProps`, it is re-set internally. Any consumer-provided `clearIcon` will be ignored.
138
- - **`removeIcon` is always overridden** — same as `clearIcon`; custom `removeIcon` from consumer props is ignored.
139
- - **Compound component typing** — `SelectWithComponents` is typed as `SelectCompoundComponent = typeof Select & { Option, OptGroup }` using `Object.assign`, so `.Option` and `.OptGroup` are fully typed.
140
- - **Uses Vitest** `package.json` has `"test": "jest"`.
151
+ - **Option resolution** — `useSelectOptions` returns `resolvedOptions` (from `options` prop, else
152
+ `getOptionsFromChildren(children)`) and `displayedOptions` (after client filtering and, in `tags`
153
+ mode, a create-row prepended for the typed text). `filterOption={false}` disables local filtering.
154
+ - **`Option.value` is optional** — falls back to the element's React `key` (antd parity); callbacks
155
+ expose `option.key`.
156
+ - **Keyboard nav is hand-rolled (not ds-dropdown's)** — Select is a *combobox*: focus stays on the
157
+ input/selector via `aria-activedescendant`, whereas ds-dropdown uses roving DOM focus. `activeIndex`
158
+ + `moveActive` + three effects drive highlight; `handleKeyDown` handles Arrow/Home/End/Enter/Escape/
159
+ Space and Backspace (drop last chip).
160
+ - **Focus / blur** — `onFocus`/`onBlur` fire on the root only when focus truly enters/leaves the
161
+ select (relatedTarget guard ignores selector↔input moves). `autoFocus` focuses the `Selector` in
162
+ select-only mode (no search input to receive it). The dropdown `onMouseDown` prevents focus loss so
163
+ selecting an option / scrolling isn't treated as a blur (needed by `subtle-form`'s revert-on-blur).
164
+ - **`readOnly` is implemented via `disabled`** — both flags are ORed into `isDisabled`; the visual
165
+ distinction comes from the `$readOnly` transient prop on `Selector`.
166
+ - **Controlled/uncontrolled** — `value`/`open`/`searchValue` are controlled when defined, else backed
167
+ by internal state; `onSearch` still fires when `searchValue` is controlled.
168
+ - **antd-free; no LESS** — styling is entirely styled-components. The old antd-era LESS
169
+ (`style/index.less` + `select.mixin.less`, `.ant-select-*` overrides for antd selects) was
170
+ **relocated to `ds-table`** (`table/src/style/select.mixin.less` + a direct
171
+ `@import '~antd/lib/select/style'`), since `ds-table` (out of scope, stays on antd) was the only
172
+ remaining consumer. ds-select ships no `dist/style` and no longer declares an `antd` peerDep.
173
+ - **Tests** — Vitest + React Testing Library (`src/__specs__/Select.spec.tsx`): render/parity,
174
+ keyboard + ARIA, and focus/blur (autofocus, onBlur on leave / not on internal move, onFocus).
175
+ ```