@fvc/select 0.0.0-stage → 1.0.0-next-a7af07acb04fc221bf3a07dc032665ffac019af4
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/README.md +422 -2
- package/dist/lib/index.js +1 -0
- package/dist/lib/select/src/Select.d.ts +3 -0
- package/dist/lib/select/src/components/SelectError.d.ts +3 -0
- package/dist/lib/select/src/components/SelectLabel.d.ts +3 -0
- package/dist/lib/select/src/constants/index.d.ts +9 -0
- package/dist/lib/select/src/helpers/renderOption.d.ts +9 -0
- package/dist/lib/select/src/helpers/renderSuffixIcon.d.ts +3 -0
- package/dist/lib/select/src/helpers/renderTag.d.ts +3 -0
- package/dist/lib/select/src/index.d.ts +1 -0
- package/dist/lib/select/src/types/Select.types.d.ts +33 -0
- package/dist/lib/select/src/types/index.d.ts +1 -0
- package/package.json +47 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# @fvc/select
|
|
2
|
+
|
|
3
|
+
## 1.0.0-next-a7af07acb04fc221bf3a07dc032665ffac019af4
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 5be7367: Add `@fvc/select`, a select field built on antd's `Select` and styled to the AVIS UI kit Select frame.
|
|
8
|
+
|
|
9
|
+
- One `Select` for a single value, `multiple` and `tags`; selected values render as `@fvc/chip` chips.
|
|
10
|
+
- `label`, `withAsterisk`, `error` (a string also prints the message), `icon`, `allowClear`, an `icon` on each option, and `testId`.
|
|
11
|
+
- The dropdown sits flush with the field and caps the list at 500px. A loading field spins the loading icon before the arrow, and an empty list shows `@fvc/empty` with `Nəticə tapılmadı.`
|
|
12
|
+
- Every colour, size and radius is a `--select-*` CSS custom property, so a wrapper can restyle the select inside it; the dropdown tokens reach the dropdown when `getPopupContainer` renders it inside the wrapper.
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [b9ca7ea]
|
|
17
|
+
- Updated dependencies [102beef]
|
|
18
|
+
- Updated dependencies [6081bb3]
|
|
19
|
+
- Updated dependencies [a74cbe8]
|
|
20
|
+
- Updated dependencies [be53c82]
|
|
21
|
+
- Updated dependencies [011f10c]
|
|
22
|
+
- Updated dependencies [4901f0a]
|
|
23
|
+
- @fvc/chip@1.1.1-next-a7af07acb04fc221bf3a07dc032665ffac019af4
|
|
24
|
+
- @fvc/empty@1.1.4-next-a7af07acb04fc221bf3a07dc032665ffac019af4
|
|
25
|
+
- @fvc/icons@1.1.8-next-a7af07acb04fc221bf3a07dc032665ffac019af4
|
package/README.md
CHANGED
|
@@ -1,3 +1,423 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @fvc/select
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@fvc/select` is Ant Design's `Select` restyled to the AVIS UI kit [Select frame](https://www.figma.com/design/mIoVgiLS8kZgKfqfUoL9Pa/AVIS-UI-kit-new?node-id=25807-15027). It adds the FE-VIS label, required marker and error message, draws selected values as `@fvc/chip` chips and adds an optional field icon and per-option icons. Search, multiple selection, virtual scrolling, keyboard navigation and ARIA stay antd's.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun add @fvc/select
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Peer Dependencies
|
|
12
|
+
|
|
13
|
+
The package expects these dependencies to be available in the consuming application:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
bun add react antd @fvc/icons @fvc/chip @fvc/empty
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Render the application inside `@fvc/provider`'s `ConfigProvider`, which loads the palette and typography tokens the select reads.
|
|
20
|
+
|
|
21
|
+
## Import
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { Select } from '@fvc/select';
|
|
25
|
+
import type { SelectOption, SelectProps, SelectRef } from '@fvc/select/types';
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Quick Start
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
import React, { useState } from 'react';
|
|
32
|
+
import { Select } from '@fvc/select';
|
|
33
|
+
import type { SelectOption } from '@fvc/select/types';
|
|
34
|
+
|
|
35
|
+
const cities: SelectOption[] = [
|
|
36
|
+
{ value: 'baku', label: 'Bakı' },
|
|
37
|
+
{ value: 'ganja', label: 'Gəncə' },
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
export function CityField() {
|
|
41
|
+
const [city, setCity] = useState<string | undefined>('baku');
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Select<string | undefined>
|
|
45
|
+
label="Şəhər"
|
|
46
|
+
value={city}
|
|
47
|
+
onChange={setCity}
|
|
48
|
+
placeholder="Seçin"
|
|
49
|
+
options={cities}
|
|
50
|
+
/>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Common Usage
|
|
56
|
+
|
|
57
|
+
### Label and Required Marker
|
|
58
|
+
|
|
59
|
+
`label` renders a `<label>` above the field, linked to it through `id` (generated when you pass none), so clicking the label focuses the field. `withAsterisk` adds the red required marker.
|
|
60
|
+
|
|
61
|
+
```tsx
|
|
62
|
+
<Select label="Şəhər" withAsterisk placeholder="Seçin" options={cities} />
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Error State
|
|
66
|
+
|
|
67
|
+
`error` can be a string or a boolean.
|
|
68
|
+
|
|
69
|
+
| Value | Behavior |
|
|
70
|
+
| ---------------------------- | ---------------------------------------------------------------- |
|
|
71
|
+
| `string` | Applies the error style and renders the message under the field. |
|
|
72
|
+
| `true` | Applies the error style without a message. |
|
|
73
|
+
| `false`, `''` or `undefined` | Uses the default state. |
|
|
74
|
+
|
|
75
|
+
An error sets `aria-invalid` on the field. The message is linked to the field through `aria-describedby`, after any description you pass, so a screen reader reads it with the field.
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
<Select error="Şəhəri seçin" placeholder="Şəhər" options={cities} />
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Field Icon
|
|
82
|
+
|
|
83
|
+
`icon` draws an icon before the arrow, inside the field. The select sizes any SVG inside it to `--select-icon-size`.
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
import { Suspense } from 'react';
|
|
87
|
+
import { Icon } from '@fvc/icons';
|
|
88
|
+
|
|
89
|
+
<Select
|
|
90
|
+
icon={
|
|
91
|
+
<Suspense fallback={null}>
|
|
92
|
+
<Icon.Event color="currentColor" />
|
|
93
|
+
</Suspense>
|
|
94
|
+
}
|
|
95
|
+
placeholder="Dövr"
|
|
96
|
+
options={periods}
|
|
97
|
+
/>;
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
While `loading` is set, the FE-VIS loading icon spins in place of the field icon, before the arrow. An empty list stays closed until the options arrive, so the dropdown never opens on an empty state while they load.
|
|
101
|
+
|
|
102
|
+
### Option Icons
|
|
103
|
+
|
|
104
|
+
An option's `icon` is drawn after its label. A `disabled` option is greyed out and cannot be picked.
|
|
105
|
+
|
|
106
|
+
```tsx
|
|
107
|
+
const documents: SelectOption[] = [
|
|
108
|
+
{ value: 'invoice', label: 'E-qaimə', icon: editIcon },
|
|
109
|
+
{ value: 'act', label: 'Akt', icon: deleteIcon },
|
|
110
|
+
{ value: 'archive', label: 'Arxiv', disabled: true },
|
|
111
|
+
];
|
|
112
|
+
|
|
113
|
+
<Select placeholder="Sənəd" options={documents} />;
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Multiple Selection
|
|
117
|
+
|
|
118
|
+
`mode="multiple"` shows each value as a small `@fvc/chip`. A chip's close icon removes that value and leaves the list closed; **Backspace** in the empty search removes the last chip. The field grows as chips wrap.
|
|
119
|
+
|
|
120
|
+
```tsx
|
|
121
|
+
<Select
|
|
122
|
+
mode="multiple"
|
|
123
|
+
label="Regionlar"
|
|
124
|
+
placeholder="Hamısı"
|
|
125
|
+
options={regions}
|
|
126
|
+
/>
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Tags
|
|
130
|
+
|
|
131
|
+
`mode="tags"` also turns the typed text into a new value. The typed text is listed first, under a divider, above the options that match it, and **Enter** adds it.
|
|
132
|
+
|
|
133
|
+
```tsx
|
|
134
|
+
<Select
|
|
135
|
+
mode="tags"
|
|
136
|
+
optionFilterProp="label"
|
|
137
|
+
placeholder="Etiketlər"
|
|
138
|
+
options={labels}
|
|
139
|
+
/>
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Search
|
|
143
|
+
|
|
144
|
+
antd's search is unchanged. Filter by the label with `optionFilterProp="label"`:
|
|
145
|
+
|
|
146
|
+
```tsx
|
|
147
|
+
<Select
|
|
148
|
+
showSearch
|
|
149
|
+
optionFilterProp="label"
|
|
150
|
+
placeholder="Şəhər"
|
|
151
|
+
options={cities}
|
|
152
|
+
/>
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Clear Button
|
|
156
|
+
|
|
157
|
+
`allowClear` shows the FE-VIS close icon before the arrow while the pointer is over a field with a value; it takes the field icon's place. It takes a boolean only. A `multiple` or `tags` field shows no clear icon, because each chip has its own close icon.
|
|
158
|
+
|
|
159
|
+
```tsx
|
|
160
|
+
<Select allowClear defaultValue="baku" options={cities} />
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Controlled and Uncontrolled
|
|
164
|
+
|
|
165
|
+
Use `value` and `onChange` when the parent owns the value, and `defaultValue` when it does not. `onChange` receives the value and the selected option (or options).
|
|
166
|
+
|
|
167
|
+
```tsx
|
|
168
|
+
<Select<string | undefined> value={city} onChange={setCity} options={cities} />
|
|
169
|
+
<Select defaultValue="baku" options={cities} />
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Empty List
|
|
173
|
+
|
|
174
|
+
With no option to list, the dropdown shows `@fvc/empty` with a search icon and `Nəticə tapılmadı.`, the frame's no-result state. `notFoundContent` replaces it.
|
|
175
|
+
|
|
176
|
+
```tsx
|
|
177
|
+
<Select showSearch notFoundContent="Şəhər tapılmadı" options={cities} />
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Disabled
|
|
181
|
+
|
|
182
|
+
`disabled` locks the field, and its chips lose their close icon and take `@fvc/chip`'s disabled look.
|
|
183
|
+
|
|
184
|
+
```tsx
|
|
185
|
+
<Select disabled mode="multiple" defaultValue={['baku']} options={cities} />
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Long Lists
|
|
189
|
+
|
|
190
|
+
antd's virtual list renders only the rows in view, so the cost of opening and filtering does not grow with `options`. The frame caps the open list at 500px, so `listHeight` defaults to `492`: the list without the dropdown padding. `virtual={false}` turns virtualisation off.
|
|
191
|
+
|
|
192
|
+
Measured on a production build in Chromium (median of 5 runs): the open list renders 15 option rows at 1 000, 5 000 and 10 000 options, in single and multiple mode; opening takes 28–37 ms and filtering on `99` takes 39–60 ms at every size.
|
|
193
|
+
|
|
194
|
+
```tsx
|
|
195
|
+
<Select
|
|
196
|
+
showSearch
|
|
197
|
+
optionFilterProp="label"
|
|
198
|
+
placeholder="VÖEN və ya ad"
|
|
199
|
+
options={taxpayers}
|
|
200
|
+
/>
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Props
|
|
204
|
+
|
|
205
|
+
`Select` accepts every antd `Select` prop except the ones the design owns, plus these:
|
|
206
|
+
|
|
207
|
+
| Prop | Type | Default | Description |
|
|
208
|
+
| ----------------- | ------------------- | -------------------- | -------------------------------------------------------------------- |
|
|
209
|
+
| `label` | `ReactNode` | — | Label above the field. |
|
|
210
|
+
| `withAsterisk` | `boolean` | `false` | Adds the required marker after the label. |
|
|
211
|
+
| `error` | `string \| boolean` | — | Error style; a string also renders the message. |
|
|
212
|
+
| `icon` | `ReactNode` | — | Icon before the arrow, inside the field. |
|
|
213
|
+
| `allowClear` | `boolean` | `false` | Shows the clear icon on a single-value field with a value. |
|
|
214
|
+
| `loading` | `boolean` | `false` | Spins the loading icon before the arrow; an empty list stays closed. |
|
|
215
|
+
| `variant` | `'outlined'` | `'outlined'` | The only variant in the frame. |
|
|
216
|
+
| `notFoundContent` | `ReactNode` | `@fvc/empty` | Shown when there is no option to list. |
|
|
217
|
+
| `listHeight` | `number` | `492` | Height of the option list; the dropdown is 500px. |
|
|
218
|
+
| `dropdownAlign` | `AlignType` | `{ offset: [0, 0] }` | Dropdown position; the frame draws it flush with the field. |
|
|
219
|
+
| `testId` | `string` | — | `data-testid` on the `.fvc-select-field` element. |
|
|
220
|
+
|
|
221
|
+
`className` and `style` go to antd's root, `.fvc-select-field`; to space the whole component, label and error message included, wrap it.
|
|
222
|
+
|
|
223
|
+
`options` items are `SelectOption`: `value` and `label`, an optional `icon`, and antd's `disabled`, `title` and `className`. The frame has no option groups, so an option takes no `options` or `children`.
|
|
224
|
+
|
|
225
|
+
These antd props are not accepted because the design fixes them: `size` (one size), `status` (use `error`), `bordered` and `variant` values other than `outlined`, `prefixCls`, `suffixIcon` (use `icon`), `clearIcon` and the object form of `allowClear`, `menuItemSelectedIcon`, `removeIcon`, `tagRender` (chips), `optionRender` (label and option icon), `fieldNames` (options use the `SelectOption` shape) and `children` (pass `options`).
|
|
226
|
+
|
|
227
|
+
## TypeScript Types
|
|
228
|
+
|
|
229
|
+
```ts
|
|
230
|
+
import type { SelectOption, SelectProps, SelectRef } from '@fvc/select/types';
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
| Type | Description |
|
|
234
|
+
| ------------------------ | --------------------------------------------------------------------------------------- |
|
|
235
|
+
| `SelectProps<ValueType>` | The props above; `ValueType` is the type of `value` and of `onChange`'s first argument. |
|
|
236
|
+
| `SelectOption` | An option: `value`, `label`, `icon`, and antd's `disabled`, `title` and `className`. |
|
|
237
|
+
| `SelectRef` | antd's select ref: `focus()`, `blur()`, `scrollTo()`. |
|
|
238
|
+
|
|
239
|
+
## Storybook
|
|
240
|
+
|
|
241
|
+
Every scenario above has a runnable story whose **Show code** is the complete demo file:
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
bun run storybook
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Then open **Components → Select**. Each story is one consumer scenario: Default, Open list, Disabled, With label, Error, With icon, Option icons, Multiple, Multiple open list, Tags, Search, Allow clear, Controlled, Loading, Long list, Empty list, Customisation and Playground. Where a story shows a Figma state, its description names it. Playground follows its Controls in the Canvas view. The docs page ends with every CSS variable and its description.
|
|
248
|
+
|
|
249
|
+
## Testing
|
|
250
|
+
|
|
251
|
+
- `testId` lands on the antd root, `.fvc-select-field`; the label and error message sit next to it inside `.fvc-select-field-root`.
|
|
252
|
+
- In `happy-dom`, pass `virtual={false}` so every option renders; options are then reachable with `screen.getByRole('option', { name, selected })`.
|
|
253
|
+
- The dropdown renders in `document.body`, outside the `testId` element; render it in place with `getPopupContainer` if a test needs it there.
|
|
254
|
+
- rc-select reads `event.which` for **Enter**, **Esc** and the arrow keys. `user-event` leaves it at `0` under `happy-dom`, so fire those keys with `fireEvent.keyDown(combobox, { key, keyCode, which })`.
|
|
255
|
+
|
|
256
|
+
## CSS Classes
|
|
257
|
+
|
|
258
|
+
The component renders antd's classes under its own prefix, `fvc-select-field`, so its rules never reach a plain antd `Select` (`.fvc-select`), such as `@fvc/pagination`'s page-size changer.
|
|
259
|
+
|
|
260
|
+
| Class | Element |
|
|
261
|
+
| ------------------------------------------------------ | ----------------------------------------------------------------------------------- |
|
|
262
|
+
| `fvc-select-field-root` | Wrapper of the label, field and error message. |
|
|
263
|
+
| `fvc-select-field-label` | The label. |
|
|
264
|
+
| `fvc-select-field-label-asterisk` | The required marker. |
|
|
265
|
+
| `fvc-select-field-error-text` | The error message row. |
|
|
266
|
+
| `fvc-select-field` | antd's root, with the modifiers below. |
|
|
267
|
+
| `fvc-select-field-outlined` | The outlined variant. |
|
|
268
|
+
| `fvc-select-field-error` | The error state. |
|
|
269
|
+
| `fvc-select-field-open` | The dropdown is open. |
|
|
270
|
+
| `fvc-select-field-focused` | The field has focus. |
|
|
271
|
+
| `fvc-select-field-disabled` | The field is disabled. |
|
|
272
|
+
| `fvc-select-field-single`, `fvc-select-field-multiple` | Single or multiple (`multiple`, `tags`) mode. |
|
|
273
|
+
| `fvc-select-field-suffix` | The field icon or the loading icon, and the arrow, when `icon` or `loading` is set. |
|
|
274
|
+
| `fvc-select-field-loading-icon` | The spinning loading icon. |
|
|
275
|
+
| `fvc-select-field-clear` | The clear icon. |
|
|
276
|
+
| `fvc-select-field-dropdown` | The dropdown. |
|
|
277
|
+
| `fvc-select-field-item-option` | An option row, with `-active`, `-selected` and `-disabled` modifiers. |
|
|
278
|
+
| `fvc-select-field-option-label` | An option's label. |
|
|
279
|
+
| `fvc-select-field-option-icon` | An option's icon. |
|
|
280
|
+
| `fvc-select-field-option-created` | In `tags` mode, the label of a value that is not one of `options`. |
|
|
281
|
+
| `fvc-select-field-empty` | The empty state, with `-empty-image` and `-empty-description`. |
|
|
282
|
+
|
|
283
|
+
## CSS Custom Properties
|
|
284
|
+
|
|
285
|
+
Every value the select draws is a CSS custom property declared on `:root` in `src/styles/variables.scss`. Colours point at `@fvc/utils` palette tokens. Override them globally, or on an ancestor to restyle only the selects inside it:
|
|
286
|
+
|
|
287
|
+
```tsx
|
|
288
|
+
type CustomProperties = React.CSSProperties & Record<`--${string}`, string>;
|
|
289
|
+
|
|
290
|
+
const theme: CustomProperties = {
|
|
291
|
+
'--select-middle-size-border-radius': '4px',
|
|
292
|
+
'--select-dropdown-border-radius': '4px',
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
<div style={theme}>
|
|
296
|
+
<Select
|
|
297
|
+
options={cities}
|
|
298
|
+
getPopupContainer={(trigger) => trigger.parentElement || document.body}
|
|
299
|
+
/>
|
|
300
|
+
</div>;
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
The dropdown renders in `document.body`, outside the ancestor, so pass `getPopupContainer` when the override includes dropdown or option tokens.
|
|
304
|
+
|
|
305
|
+
### Field
|
|
306
|
+
|
|
307
|
+
| Variable | Default | Description |
|
|
308
|
+
| --------------------------- | ---------------------------------- | ------------------------------------------------------------------------------------- |
|
|
309
|
+
| `--select-font-family` | `var(--fvc-font-body, sans-serif)` | Font family of the field, its options, label and error message. |
|
|
310
|
+
| `--select-width` | `100%` | Width of the component: label, field and error message. |
|
|
311
|
+
| `--select-border-width` | `1px` | Border width of the field and the dropdown. |
|
|
312
|
+
| `--select-icon-size` | `16px` | Size of the arrow, clear, check, field and error icons. |
|
|
313
|
+
| `--select-icon-gap` | `4px` | Gap between the field icon and the arrow, and between an option’s label and its icon. |
|
|
314
|
+
| `--select-loading-duration` | `1s` | Time the loading icon takes to turn once. |
|
|
315
|
+
|
|
316
|
+
### Label and error message
|
|
317
|
+
|
|
318
|
+
| Variable | Default | Description |
|
|
319
|
+
| ---------------------------------- | ---------------- | ---------------------------------------------- |
|
|
320
|
+
| `--select-label-fw` | `700` | Label font weight. |
|
|
321
|
+
| `--select-label-spacing` | `6px` | Space between the label and the field. |
|
|
322
|
+
| `--select-asterisk-color` | `var(--red-800)` | Colour of the required asterisk. |
|
|
323
|
+
| `--select-asterisk-spacing` | `2px` | Space between the label text and the asterisk. |
|
|
324
|
+
| `--select-description-spacing` | `4px` | Space above the error message. |
|
|
325
|
+
| `--select-description-gap` | `4px` | Space between the error icon and its text. |
|
|
326
|
+
| `--select-description-fw` | `400` | Error message font weight. |
|
|
327
|
+
| `--select-description-error-color` | `var(--red-800)` | Colour of the error message and its icon. |
|
|
328
|
+
|
|
329
|
+
### Middle size
|
|
330
|
+
|
|
331
|
+
| Variable | Default | Description |
|
|
332
|
+
| -------------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
333
|
+
| `--select-middle-size-height` | `32px` | Height of a single-value field. |
|
|
334
|
+
| `--select-middle-size-border-radius` | `20px` | Corner radius of the field. |
|
|
335
|
+
| `--select-middle-size-padding-y` | `7px` | Padding above and below the chips of a `multiple` or `tags` field. A single-value field centres its text in `--select-middle-size-height`. |
|
|
336
|
+
| `--select-middle-size-padding-start` | `11px` | Field padding before the value. |
|
|
337
|
+
| `--select-middle-size-padding-end` | `7px` | Field padding after the icons. |
|
|
338
|
+
| `--select-middle-size-fz` | `14px` | Font size of the value, placeholder, label and error message. |
|
|
339
|
+
| `--select-middle-size-fw` | `700` | Font weight of the selected value and placeholder. |
|
|
340
|
+
| `--select-middle-size-lh` | `16px` | Line height of the label, the error message and the chip row. A single-value field centres its text in `--select-middle-size-height`. |
|
|
341
|
+
| `--select-middle-size-multiple-height` | `40px` | Minimum height of a `multiple` or `tags` field. |
|
|
342
|
+
| `--select-middle-size-multiple-fw` | `400` | Font weight of the search text in a `multiple` or `tags` field. |
|
|
343
|
+
| `--select-middle-size-tag-gap` | `8px` | Gap between the chips of a `multiple` or `tags` field. |
|
|
344
|
+
|
|
345
|
+
### Dropdown
|
|
346
|
+
|
|
347
|
+
| Variable | Default | Description |
|
|
348
|
+
| ----------------------------------- | ------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
|
|
349
|
+
| `--select-dropdown-bg-color` | `var(--neutral-0)` | Dropdown background. |
|
|
350
|
+
| `--select-dropdown-border-color` | `var(--neutral-0)` | Dropdown border colour. |
|
|
351
|
+
| `--select-dropdown-border-radius` | `8px` | Dropdown corner radius. |
|
|
352
|
+
| `--select-dropdown-padding` | `4px` | Space between the dropdown edge and its options. |
|
|
353
|
+
| `--select-dropdown-gap` | `4px` | Space between two options, and on each side of the divider in `tags` mode. |
|
|
354
|
+
| `--select-dropdown-shadow` | `0 5px 15px 0 color-mix(in srgb, var(--body-text-color-1000) 30%, transparent)` | Dropdown shadow: the UI kit’s Dropdown-menu shadow tokens. |
|
|
355
|
+
| `--select-option-padding` | `8px` | Option padding. |
|
|
356
|
+
| `--select-option-border-radius` | `8px` | Option corner radius. |
|
|
357
|
+
| `--select-option-fz` | `14px` | Option font size. |
|
|
358
|
+
| `--select-option-fw` | `400` | Option font weight. |
|
|
359
|
+
| `--select-option-selected-fw` | `700` | Font weight of the selected option. |
|
|
360
|
+
| `--select-option-lh` | `16px` | Option line height. |
|
|
361
|
+
| `--select-option-text-color` | `var(--neutral-1000)` | Option text and check colour. |
|
|
362
|
+
| `--select-option-hover-bg-color` | `var(--blue-150)` | Background of the option under the pointer or keyboard focus. |
|
|
363
|
+
| `--select-option-selected-bg-color` | `var(--blue-20)` | Background of a selected option. |
|
|
364
|
+
| `--select-option-disabled-color` | `var(--gray-600)` | Text colour of a disabled option. |
|
|
365
|
+
| `--select-empty-padding-y` | `38px` | Space above and below the empty state; the empty dropdown is 120px high. |
|
|
366
|
+
| `--select-empty-gap` | `4px` | Space between the empty-state icon and its text. |
|
|
367
|
+
| `--select-empty-icon-color` | `var(--gray-300)` | Empty-state icon colour. |
|
|
368
|
+
| `--select-empty-text-color` | `var(--blue-gray-600)` | Empty-state text colour. |
|
|
369
|
+
| `--select-divider-width` | `1px` | Width of the line under the typed value in `tags` mode. |
|
|
370
|
+
| `--select-divider-color` | `var(--blue-gray-200)` | Colour of the line under the typed value in `tags` mode. |
|
|
371
|
+
|
|
372
|
+
### Outlined variant
|
|
373
|
+
|
|
374
|
+
| Variable | Default | Description |
|
|
375
|
+
| ----------------------------------------- | ---------------------- | ------------------------------------------------------- |
|
|
376
|
+
| `--select-outlined-text-color` | `var(--black-1000)` | Value text colour. |
|
|
377
|
+
| `--select-outlined-placeholder-color` | `var(--blue-gray-400)` | Placeholder colour. |
|
|
378
|
+
| `--select-outlined-bg-color` | `var(--neutral-0)` | Field background. |
|
|
379
|
+
| `--select-outlined-border-color` | `var(--gray-400)` | Field border colour. |
|
|
380
|
+
| `--select-outlined-icon-color` | `var(--black-1000)` | Arrow and clear icon colour. |
|
|
381
|
+
| `--select-outlined-hover-text-color` | `var(--blue-500)` | Value and placeholder colour on hover. |
|
|
382
|
+
| `--select-outlined-hover-border-color` | `var(--gray-400)` | Field border colour on hover. |
|
|
383
|
+
| `--select-outlined-focus-border-color` | `var(--blue-400)` | Field border colour while focused or open. |
|
|
384
|
+
| `--select-outlined-focus-shadow` | `none` | Shadow of the focused or open field. |
|
|
385
|
+
| `--select-outlined-disabled-bg-color` | `var(--gray-50)` | Background of a disabled field. |
|
|
386
|
+
| `--select-outlined-disabled-border-color` | `var(--gray-400)` | Border colour of a disabled field. |
|
|
387
|
+
| `--select-outlined-disabled-text-color` | `var(--blue-gray-600)` | Value, placeholder and icon colour of a disabled field. |
|
|
388
|
+
| `--select-outlined-label-color` | `var(--black-1000)` | Label colour. |
|
|
389
|
+
|
|
390
|
+
### Error state
|
|
391
|
+
|
|
392
|
+
| Variable | Default | Description |
|
|
393
|
+
| -------------------------------------- | ---------------------- | ---------------------------------------------------------------------------------------------- |
|
|
394
|
+
| `--select-error-text-color` | `var(--black-1000)` | Value text colour. |
|
|
395
|
+
| `--select-error-placeholder-color` | `var(--blue-gray-400)` | Placeholder colour. |
|
|
396
|
+
| `--select-error-bg-color` | `var(--red-100)` | Field background. |
|
|
397
|
+
| `--select-error-border-color` | `var(--red-800)` | Field border colour. |
|
|
398
|
+
| `--select-error-icon-color` | `var(--black-1000)` | Arrow and clear icon colour. |
|
|
399
|
+
| `--select-error-hover-text-color` | `var(--blue-500)` | Value and placeholder colour on hover. |
|
|
400
|
+
| `--select-error-hover-border-color` | `var(--red-800)` | Field border colour on hover. |
|
|
401
|
+
| `--select-error-focus-border-color` | `var(--red-800)` | Field border colour while focused or open. |
|
|
402
|
+
| `--select-error-focus-shadow` | `none` | Shadow of the focused or open field. |
|
|
403
|
+
| `--select-error-disabled-bg-color` | `var(--gray-50)` | Background of a disabled field; it looks like any disabled field, and the error message stays. |
|
|
404
|
+
| `--select-error-disabled-border-color` | `var(--gray-400)` | Border colour of a disabled field. |
|
|
405
|
+
| `--select-error-disabled-text-color` | `var(--blue-gray-600)` | Value, placeholder and icon colour of a disabled field. |
|
|
406
|
+
| `--select-error-label-color` | `var(--black-1000)` | Label colour. |
|
|
407
|
+
|
|
408
|
+
## Design Reference
|
|
409
|
+
|
|
410
|
+
- [Figma — Select](https://www.figma.com/design/mIoVgiLS8kZgKfqfUoL9Pa/AVIS-UI-kit-new?node-id=25807-15027): the field, the dropdown, Multiselect and every state.
|
|
411
|
+
- [Ant Design — Select](https://5x.ant.design/components/select): the props this package passes through.
|
|
412
|
+
|
|
413
|
+
## Development
|
|
414
|
+
|
|
415
|
+
From `packages/select`:
|
|
416
|
+
|
|
417
|
+
```bash
|
|
418
|
+
bun run test
|
|
419
|
+
bun run type-check
|
|
420
|
+
bun run build
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
Run `bun run lint` and `bun run storybook` from the repository root.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ConfigProvider as e,Select as l}from"antd";import t from"classnames";import c,{Suspense as o,memo as i,forwardRef as n,useId as r,useMemo as s}from"react";import{Empty as d}from"@fvc/empty";import{Icon as f}from"@fvc/icons";import{Chip as a}from"@fvc/chip";"function"==typeof SuppressedError&&SuppressedError;const v="fvc-select-field",p=`${v}-root`,m={offset:[0,0]},u=492,b=({id:e,error:l})=>c.createElement("div",{id:e,className:`${v}-error-text`},c.createElement(o,{fallback:null},c.createElement(f.Info,{color:"var(--select-description-error-color)"})),l),g=`${v}-label`,h=({htmlFor:e,label:l,withAsterisk:t=!1})=>c.createElement("label",{className:g,htmlFor:e},l,t&&c.createElement("span",{className:`${g}-asterisk`},"*")),w=e=>({data:l},{index:o})=>{const i=t(`${v}-option-label`,{[`${v}-option-created`]:e&&0===o&&!e.has(l)});return c.createElement(c.Fragment,null,c.createElement("span",{className:i},l.label),l.icon&&c.createElement("span",{className:`${v}-option-icon`},l.icon))},y=w(),x=c.createElement(o,{fallback:null},c.createElement(f.ArrowDropDown,{color:"currentColor"})),z=c.createElement(o,{fallback:null},c.createElement(f.Loading,{color:"currentColor",className:`${v}-loading-icon`})),k=(e,l)=>{const t=l?z:e;return t?c.createElement("span",{className:`${v}-suffix`},t,x):x},E=e=>{e.target instanceof Element&&e.target.closest("button")&&(e.preventDefault(),e.stopPropagation())},C=e=>{e.stopPropagation()},N=({label:e,closable:l,disabled:t,isMaxTag:o,onClose:i})=>c.createElement(a,{size:"small",closable:l,disabled:t||!(l||o),onClose:e=>{e.preventDefault(),i(e)},onMouseDown:E,onKeyDown:C},e),$=e=>N(Object.assign(Object.assign({},e),{disabled:!0}));!function(e,l){void 0===l&&(l={});var t=l.insertAt;if("undefined"!=typeof document){var c=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===t&&c.firstChild?c.insertBefore(o,c.firstChild):c.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}('@charset "UTF-8";\n:root {\n /* ── Field ──────────────────────────────────────────────────────────────── */\n --select-font-family: var(--fvc-font-body, sans-serif);\n --select-width: 100%;\n --select-border-width: 1px;\n --select-icon-size: 16px;\n --select-icon-gap: 4px;\n --select-loading-duration: 1s;\n /* ── Label and error message ────────────────────────────────────────────── */\n --select-label-fw: 700;\n --select-label-spacing: 6px;\n --select-asterisk-color: var(--red-800);\n --select-asterisk-spacing: 2px;\n --select-description-spacing: 4px;\n --select-description-gap: 4px;\n --select-description-fw: 400;\n --select-description-error-color: var(--red-800);\n /* ── Middle size ────────────────────────────────────────────────────────────\n The padding sits inside the 1px border: Figma’s 8 / 8 / 8 / 12 minus the\n stroke. */\n --select-middle-size-height: 32px;\n --select-middle-size-border-radius: 20px;\n --select-middle-size-padding-y: 7px;\n --select-middle-size-padding-start: 11px;\n --select-middle-size-padding-end: 7px;\n --select-middle-size-fz: 14px;\n --select-middle-size-fw: 700;\n --select-middle-size-lh: 16px;\n --select-middle-size-multiple-height: 40px;\n --select-middle-size-multiple-fw: 400;\n --select-middle-size-tag-gap: 8px;\n /* ── Dropdown ───────────────────────────────────────────────────────────── */\n --select-dropdown-bg-color: var(--neutral-0);\n --select-dropdown-border-color: var(--neutral-0);\n --select-dropdown-border-radius: 8px;\n --select-dropdown-padding: 4px;\n --select-dropdown-gap: 4px;\n --select-dropdown-shadow: 0 5px 15px 0\n color-mix(in srgb, var(--body-text-color-1000) 30%, transparent);\n --select-option-padding: 8px;\n --select-option-border-radius: 8px;\n --select-option-fz: 14px;\n --select-option-fw: 400;\n --select-option-selected-fw: 700;\n --select-option-lh: 16px;\n --select-option-text-color: var(--neutral-1000);\n --select-option-hover-bg-color: var(--blue-150);\n --select-option-selected-bg-color: var(--blue-20);\n --select-option-disabled-color: var(--gray-600);\n --select-empty-padding-y: 38px;\n --select-empty-gap: 4px;\n --select-empty-icon-color: var(--gray-300);\n --select-empty-text-color: var(--blue-gray-600);\n --select-divider-width: 1px;\n --select-divider-color: var(--blue-gray-200);\n /* ── Outlined variant ───────────────────────────────────────────────────── */\n --select-outlined-text-color: var(--black-1000);\n --select-outlined-placeholder-color: var(--blue-gray-400);\n --select-outlined-bg-color: var(--neutral-0);\n --select-outlined-border-color: var(--gray-400);\n --select-outlined-icon-color: var(--black-1000);\n --select-outlined-hover-text-color: var(--blue-500);\n --select-outlined-hover-border-color: var(--gray-400);\n --select-outlined-focus-border-color: var(--blue-400);\n --select-outlined-focus-shadow: none;\n --select-outlined-disabled-bg-color: var(--gray-50);\n --select-outlined-disabled-border-color: var(--gray-400);\n --select-outlined-disabled-text-color: var(--blue-gray-600);\n --select-outlined-label-color: var(--black-1000);\n /* ── Error state ────────────────────────────────────────────────────────── */\n --select-error-text-color: var(--black-1000);\n --select-error-placeholder-color: var(--blue-gray-400);\n --select-error-bg-color: var(--red-100);\n --select-error-border-color: var(--red-800);\n --select-error-icon-color: var(--black-1000);\n --select-error-hover-text-color: var(--blue-500);\n --select-error-hover-border-color: var(--red-800);\n --select-error-focus-border-color: var(--red-800);\n --select-error-focus-shadow: none;\n --select-error-disabled-bg-color: var(--gray-50);\n --select-error-disabled-border-color: var(--gray-400);\n --select-error-disabled-text-color: var(--blue-gray-600);\n --select-error-label-color: var(--black-1000);\n}\n.fvc-select-field {\n width: 100%;\n}\n.fvc-select-field:not(.fvc-select-field-customize-input) .fvc-select-field-selector {\n min-height: var(--select-middle-size-height);\n padding-top: var(--select-middle-size-padding-y);\n padding-right: calc(var(--select-middle-size-padding-end) + var(--select-icon-size) + var(--select-icon-gap));\n padding-bottom: var(--select-middle-size-padding-y);\n padding-left: var(--select-middle-size-padding-start);\n border-radius: var(--select-middle-size-border-radius);\n font-size: var(--select-middle-size-fz);\n line-height: var(--select-middle-size-lh);\n}\n.fvc-select-field:is(:has(.fvc-select-field-suffix), .fvc-select-field-allow-clear):not(.fvc-select-field-customize-input) .fvc-select-field-selector {\n padding-right: calc(var(--select-middle-size-padding-end) + (var(--select-icon-size) + var(--select-icon-gap)) * 2);\n}\n.fvc-select-field.fvc-select-field-single:not(.fvc-select-field-customize-input) .fvc-select-field-selector {\n height: var(--select-middle-size-height);\n padding-top: 0;\n padding-bottom: 0;\n}\n.fvc-select-field.fvc-select-field-single.fvc-select-field-show-arrow .fvc-select-field-selection-item,\n.fvc-select-field.fvc-select-field-single.fvc-select-field-show-arrow .fvc-select-field-selection-search,\n.fvc-select-field.fvc-select-field-single.fvc-select-field-show-arrow .fvc-select-field-selection-placeholder {\n padding-right: 0;\n}\n.fvc-select-field .fvc-select-field-selection-item,\n.fvc-select-field .fvc-select-field-selection-placeholder {\n font-weight: var(--select-middle-size-fw);\n line-height: var(--select-middle-size-lh);\n}\n.fvc-select-field.fvc-select-field-multiple .fvc-select-field-selector {\n min-height: var(--select-middle-size-multiple-height);\n}\n.fvc-select-field.fvc-select-field-multiple .fvc-select-field-selection-overflow {\n gap: var(--select-middle-size-tag-gap);\n}\n.fvc-select-field.fvc-select-field-multiple .fvc-select-field-selector::after,\n.fvc-select-field.fvc-select-field-multiple .fvc-select-field-selection-wrap::after,\n.fvc-select-field.fvc-select-field-multiple .fvc-select-field-selection-overflow-item-suffix {\n margin-top: 0;\n margin-bottom: 0;\n}\n.fvc-select-field.fvc-select-field-multiple .fvc-select-field-selection-placeholder {\n left: 0;\n}\n.fvc-select-field .fvc-select-field-selection-search {\n display: flex;\n align-items: center;\n}\n.fvc-select-field.fvc-select-field-multiple .fvc-select-field-selection-search {\n margin-left: 0;\n}\n.fvc-select-field.fvc-select-field-multiple :is(.fvc-select-field-selection-search-input,\n.fvc-select-field-selection-search-mirror) {\n font-weight: var(--select-middle-size-multiple-fw);\n line-height: var(--select-middle-size-lh);\n}\n.fvc-select-field-root .fvc-select-field:not(.fvc-select-field-customize-input) .fvc-select-field-selector .fvc-select-field-selection-search-input {\n height: var(--select-middle-size-lh);\n}\n.fvc-select-field .fvc-select-field-arrow,\n.fvc-select-field .fvc-select-field-clear {\n right: calc(var(--select-middle-size-padding-end) + var(--select-border-width));\n width: auto;\n height: var(--select-icon-size);\n margin-top: calc(var(--select-icon-size) / -2);\n font-size: var(--select-icon-size);\n}\n.fvc-select-field .fvc-select-field-clear {\n right: calc(var(--select-middle-size-padding-end) + var(--select-border-width) + var(--select-icon-size) + var(--select-icon-gap));\n}\n.fvc-select-field .fvc-select-field-suffix {\n display: inline-flex;\n align-items: center;\n gap: var(--select-icon-gap);\n}\n.fvc-select-field .fvc-select-field-arrow svg,\n.fvc-select-field .fvc-select-field-clear svg,\n.fvc-select-field .fvc-select-field-suffix svg {\n flex: none;\n width: var(--select-icon-size);\n height: var(--select-icon-size);\n}\n.fvc-select-field.fvc-select-field-open .fvc-select-field-arrow > svg, .fvc-select-field.fvc-select-field-open .fvc-select-field-suffix > :last-child {\n transform: scaleY(-1);\n}\n.fvc-select-field .fvc-select-field-loading-icon {\n animation: fvc-select-spin var(--select-loading-duration) linear infinite;\n}\n.fvc-select-field-root .fvc-select-field:hover .fvc-select-field-clear, .fvc-select-field-root .fvc-select-field .fvc-select-field-clear {\n background: transparent;\n}\n.fvc-select-field:hover:has(.fvc-select-field-clear) .fvc-select-field-suffix > :not(:last-child) {\n visibility: hidden;\n}\n@media (hover: none) {\n .fvc-select-field:has(.fvc-select-field-clear) .fvc-select-field-suffix > :not(:last-child) {\n visibility: hidden;\n }\n}\n.fvc-select-field-outlined .fvc-select-field-selection-item, .fvc-select-field-outlined.fvc-select-field-open .fvc-select-field-selection-item {\n font-family: var(--select-font-family);\n color: var(--select-outlined-text-color);\n}\n.fvc-select-field-root .fvc-select-field-outlined:not(.fvc-select-field-customize-input) .fvc-select-field-selector :is(.fvc-select-field-selection-search-input,\n.fvc-select-field-selection-search-mirror) {\n font-family: var(--select-font-family);\n color: var(--select-outlined-text-color);\n}\n.fvc-select-field-outlined .fvc-select-field-selection-placeholder {\n font-family: var(--select-font-family);\n color: var(--select-outlined-placeholder-color);\n}\n.fvc-select-field-outlined .fvc-select-field-arrow,\n.fvc-select-field-outlined .fvc-select-field-clear {\n color: var(--select-outlined-icon-color);\n}\n.fvc-select-field-root .fvc-select-field-outlined .fvc-select-field-clear:hover {\n color: var(--select-outlined-icon-color);\n}\n.fvc-select-field-outlined:not(.fvc-select-field-customize-input) .fvc-select-field-selector {\n background: var(--select-outlined-bg-color);\n border: var(--select-border-width) solid var(--select-outlined-border-color);\n}\n.fvc-select-field-root .fvc-select-field-outlined:not(.fvc-select-field-disabled):not(.fvc-select-field-customize-input):hover .fvc-select-field-selector {\n border-color: var(--select-outlined-hover-border-color);\n}\n.fvc-select-field-root .fvc-select-field-outlined:not(.fvc-select-field-disabled):not(.fvc-select-field-customize-input):hover .fvc-select-field-selection-item, .fvc-select-field-root .fvc-select-field-outlined:not(.fvc-select-field-disabled):not(.fvc-select-field-customize-input):hover .fvc-select-field-selection-placeholder {\n color: var(--select-outlined-hover-text-color);\n}\n.fvc-select-field-root .fvc-select-field-outlined:not(.fvc-select-field-disabled):not(.fvc-select-field-customize-input).fvc-select-field-focused .fvc-select-field-selector {\n border-color: var(--select-outlined-focus-border-color);\n box-shadow: var(--select-outlined-focus-shadow);\n outline: 0;\n}\n.fvc-select-field-root .fvc-select-field-outlined:not(.fvc-select-field-disabled):not(.fvc-select-field-customize-input).fvc-select-field-open .fvc-select-field-selector {\n border-color: var(--select-outlined-focus-border-color);\n box-shadow: var(--select-outlined-focus-shadow);\n}\n.fvc-select-field-outlined.fvc-select-field-disabled:not(.fvc-select-field-customize-input) .fvc-select-field-selector {\n background: var(--select-outlined-disabled-bg-color);\n border-color: var(--select-outlined-disabled-border-color);\n}\n.fvc-select-field-outlined.fvc-select-field-disabled .fvc-select-field-selection-item, .fvc-select-field-outlined.fvc-select-field-disabled.fvc-select-field-open .fvc-select-field-selection-item {\n font-family: var(--select-font-family);\n color: var(--select-outlined-disabled-text-color);\n}\n.fvc-select-field-root .fvc-select-field-outlined.fvc-select-field-disabled:not(.fvc-select-field-customize-input) .fvc-select-field-selector :is(.fvc-select-field-selection-search-input,\n.fvc-select-field-selection-search-mirror) {\n font-family: var(--select-font-family);\n color: var(--select-outlined-disabled-text-color);\n}\n.fvc-select-field-outlined.fvc-select-field-disabled .fvc-select-field-selection-placeholder {\n font-family: var(--select-font-family);\n color: var(--select-outlined-disabled-text-color);\n}\n.fvc-select-field-outlined.fvc-select-field-disabled .fvc-select-field-arrow,\n.fvc-select-field-outlined.fvc-select-field-disabled .fvc-select-field-clear {\n color: var(--select-outlined-disabled-text-color);\n}\n.fvc-select-field-root .fvc-select-field-outlined.fvc-select-field-disabled .fvc-select-field-clear:hover {\n color: var(--select-outlined-disabled-text-color);\n}\n.fvc-select-field-outlined.fvc-select-field-error .fvc-select-field-selection-item, .fvc-select-field-outlined.fvc-select-field-error.fvc-select-field-open .fvc-select-field-selection-item {\n font-family: var(--select-font-family);\n color: var(--select-error-text-color);\n}\n.fvc-select-field-root .fvc-select-field-outlined.fvc-select-field-error:not(.fvc-select-field-customize-input) .fvc-select-field-selector :is(.fvc-select-field-selection-search-input,\n.fvc-select-field-selection-search-mirror) {\n font-family: var(--select-font-family);\n color: var(--select-error-text-color);\n}\n.fvc-select-field-outlined.fvc-select-field-error .fvc-select-field-selection-placeholder {\n font-family: var(--select-font-family);\n color: var(--select-error-placeholder-color);\n}\n.fvc-select-field-outlined.fvc-select-field-error .fvc-select-field-arrow,\n.fvc-select-field-outlined.fvc-select-field-error .fvc-select-field-clear {\n color: var(--select-error-icon-color);\n}\n.fvc-select-field-root .fvc-select-field-outlined.fvc-select-field-error .fvc-select-field-clear:hover {\n color: var(--select-error-icon-color);\n}\n.fvc-select-field-outlined.fvc-select-field-error:not(.fvc-select-field-customize-input) .fvc-select-field-selector {\n background: var(--select-error-bg-color);\n border: var(--select-border-width) solid var(--select-error-border-color);\n}\n.fvc-select-field-root .fvc-select-field-outlined.fvc-select-field-error:not(.fvc-select-field-disabled):not(.fvc-select-field-customize-input):hover .fvc-select-field-selector {\n border-color: var(--select-error-hover-border-color);\n}\n.fvc-select-field-root .fvc-select-field-outlined.fvc-select-field-error:not(.fvc-select-field-disabled):not(.fvc-select-field-customize-input):hover .fvc-select-field-selection-item, .fvc-select-field-root .fvc-select-field-outlined.fvc-select-field-error:not(.fvc-select-field-disabled):not(.fvc-select-field-customize-input):hover .fvc-select-field-selection-placeholder {\n color: var(--select-error-hover-text-color);\n}\n.fvc-select-field-root .fvc-select-field-outlined.fvc-select-field-error:not(.fvc-select-field-disabled):not(.fvc-select-field-customize-input).fvc-select-field-focused .fvc-select-field-selector {\n border-color: var(--select-error-focus-border-color);\n box-shadow: var(--select-error-focus-shadow);\n outline: 0;\n}\n.fvc-select-field-root .fvc-select-field-outlined.fvc-select-field-error:not(.fvc-select-field-disabled):not(.fvc-select-field-customize-input).fvc-select-field-open .fvc-select-field-selector {\n border-color: var(--select-error-focus-border-color);\n box-shadow: var(--select-error-focus-shadow);\n}\n.fvc-select-field-outlined.fvc-select-field-error.fvc-select-field-disabled:not(.fvc-select-field-customize-input) .fvc-select-field-selector {\n background: var(--select-error-disabled-bg-color);\n border-color: var(--select-error-disabled-border-color);\n}\n.fvc-select-field-outlined.fvc-select-field-error.fvc-select-field-disabled .fvc-select-field-selection-item, .fvc-select-field-outlined.fvc-select-field-error.fvc-select-field-disabled.fvc-select-field-open .fvc-select-field-selection-item {\n font-family: var(--select-font-family);\n color: var(--select-error-disabled-text-color);\n}\n.fvc-select-field-root .fvc-select-field-outlined.fvc-select-field-error.fvc-select-field-disabled:not(.fvc-select-field-customize-input) .fvc-select-field-selector :is(.fvc-select-field-selection-search-input,\n.fvc-select-field-selection-search-mirror) {\n font-family: var(--select-font-family);\n color: var(--select-error-disabled-text-color);\n}\n.fvc-select-field-outlined.fvc-select-field-error.fvc-select-field-disabled .fvc-select-field-selection-placeholder {\n font-family: var(--select-font-family);\n color: var(--select-error-disabled-text-color);\n}\n.fvc-select-field-outlined.fvc-select-field-error.fvc-select-field-disabled .fvc-select-field-arrow,\n.fvc-select-field-outlined.fvc-select-field-error.fvc-select-field-disabled .fvc-select-field-clear {\n color: var(--select-error-disabled-text-color);\n}\n.fvc-select-field-root .fvc-select-field-outlined.fvc-select-field-error.fvc-select-field-disabled .fvc-select-field-clear:hover {\n color: var(--select-error-disabled-text-color);\n}\n.fvc-select-field-dropdown {\n padding: calc(var(--select-dropdown-padding) - var(--select-border-width));\n background: var(--select-dropdown-bg-color);\n border: var(--select-border-width) solid var(--select-dropdown-border-color);\n border-radius: var(--select-dropdown-border-radius);\n box-shadow: var(--select-dropdown-shadow);\n font-family: var(--select-font-family);\n}\n.fvc-select-field-dropdown .fvc-select-field-item-empty {\n padding: 0;\n}\n.fvc-select-field-dropdown .fvc-select-field-empty {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: var(--select-empty-gap);\n margin: 0;\n padding-top: var(--select-empty-padding-y);\n padding-bottom: var(--select-empty-padding-y);\n font-family: var(--select-font-family);\n font-size: var(--select-option-fz);\n line-height: var(--select-option-lh);\n}\n.fvc-select-field-dropdown .fvc-select-field-empty .fvc-select-field-empty-image {\n display: inline-flex;\n height: auto;\n margin: 0;\n color: var(--select-empty-icon-color);\n}\n.fvc-select-field-dropdown .fvc-select-field-empty .fvc-select-field-empty-image svg {\n width: var(--select-icon-size);\n height: var(--select-icon-size);\n}\n.fvc-select-field-dropdown .fvc-select-field-empty .fvc-select-field-empty-description {\n color: var(--select-empty-text-color);\n}\n.fvc-select-field-dropdown .fvc-select-field-item-option {\n display: flex;\n align-items: center;\n gap: var(--select-icon-gap);\n min-height: auto;\n margin-bottom: var(--select-dropdown-gap);\n padding: var(--select-option-padding);\n border-radius: var(--select-option-border-radius);\n font-family: var(--select-font-family);\n font-size: var(--select-option-fz);\n font-weight: var(--select-option-fw);\n line-height: var(--select-option-lh);\n color: var(--select-option-text-color);\n}\n.fvc-select-field-dropdown .fvc-select-field-item-option:last-child {\n margin-bottom: 0;\n}\n.fvc-select-field-dropdown .fvc-select-field-item-option-content,\n.fvc-select-field-dropdown .fvc-select-field-option-label {\n font-family: inherit;\n font-size: inherit;\n}\n.fvc-select-field-dropdown .fvc-select-field-item-option-content {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--select-icon-gap);\n}\n.fvc-select-field-dropdown .fvc-select-field-option-label {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.fvc-select-field-dropdown .fvc-select-field-option-icon {\n display: inline-flex;\n flex: none;\n width: var(--select-icon-size);\n height: var(--select-icon-size);\n}\n.fvc-select-field-dropdown .fvc-select-field-option-icon svg,\n.fvc-select-field-dropdown .fvc-select-field-item-option-state svg {\n width: var(--select-icon-size);\n height: var(--select-icon-size);\n}\n.fvc-select-field-dropdown .fvc-select-field-item-option-state {\n order: -1;\n display: inline-flex;\n color: var(--select-option-text-color);\n}\n.fvc-select-field-dropdown .fvc-select-field-item-option-active:not(.fvc-select-field-item-option-disabled) {\n background: var(--select-option-hover-bg-color);\n}\n.fvc-select-field-dropdown .fvc-select-field-item-option-selected:not(.fvc-select-field-item-option-disabled) {\n background: var(--select-option-selected-bg-color);\n font-weight: var(--select-option-selected-fw);\n color: var(--select-option-text-color);\n}\n.fvc-select-field-dropdown .fvc-select-field-item-option-selected:not(.fvc-select-field-item-option-disabled) .fvc-select-field-item-option-state {\n color: var(--select-option-text-color);\n}\n.fvc-select-field-dropdown .fvc-select-field-item-option-disabled {\n color: var(--select-option-disabled-color);\n}\n.fvc-select-field-dropdown .fvc-select-field-item-option:not(.fvc-select-field-item-option-selected):not(:last-child):has(.fvc-select-field-option-created) {\n position: relative;\n overflow: visible;\n margin-bottom: calc(var(--select-dropdown-gap) * 2);\n}\n.fvc-select-field-dropdown .fvc-select-field-item-option:not(.fvc-select-field-item-option-selected):not(:last-child):has(.fvc-select-field-option-created)::after {\n content: "";\n position: absolute;\n right: 0;\n left: 0;\n bottom: calc(var(--select-dropdown-gap) * -1);\n border-bottom: var(--select-divider-width) solid var(--select-divider-color);\n}\n.fvc-select-field-label {\n display: flex;\n gap: var(--select-asterisk-spacing);\n margin-bottom: var(--select-label-spacing);\n font-family: var(--select-font-family);\n font-size: var(--select-middle-size-fz);\n font-weight: var(--select-label-fw);\n line-height: var(--select-middle-size-lh);\n color: var(--select-outlined-label-color);\n}\n.fvc-select-field-root:has(.fvc-select-field-error) .fvc-select-field-label {\n color: var(--select-error-label-color);\n}\n.fvc-select-field-label-asterisk {\n font-family: inherit;\n font-size: inherit;\n color: var(--select-asterisk-color);\n}\n.fvc-select-field-error-text {\n display: flex;\n align-items: center;\n gap: var(--select-description-gap);\n margin-top: var(--select-description-spacing);\n font-family: var(--select-font-family);\n font-size: var(--select-middle-size-fz);\n font-weight: var(--select-description-fw);\n line-height: var(--select-middle-size-lh);\n color: var(--select-description-error-color);\n}\n.fvc-select-field-error-text svg {\n flex: none;\n width: var(--select-icon-size);\n height: var(--select-icon-size);\n}\n.fvc-select-field-root {\n display: flex;\n flex-direction: column;\n width: var(--select-width);\n}\n@keyframes fvc-select-spin {\n to {\n transform: rotate(360deg);\n }\n}');const O=c.createElement(o,{fallback:null},c.createElement(f.Check,{color:"currentColor"})),S={clearIcon:c.createElement(o,{fallback:null},c.createElement(f.Close,{color:"currentColor"}))},F=c.createElement(d,{classNames:{root:`${v}-empty`,image:`${v}-empty-image`,description:`${v}-empty-description`},image:c.createElement(o,{fallback:null},c.createElement(f.Search,{color:"currentColor"})),description:"Nəticə tapılmadı."}),j=i(n((o,i)=>{var{"aria-describedby":n,allowClear:d=!1,className:f,disabled:a,dropdownAlign:g=m,error:x,icon:z,id:E,label:C,listHeight:j=u,loading:A,mode:D,notFoundContent:I,options:T,testId:P,variant:B="outlined",withAsterisk:H=!1}=o,M=function(e,l){var t={};for(var c in e)Object.prototype.hasOwnProperty.call(e,c)&&l.indexOf(c)<0&&(t[c]=e[c]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(c=Object.getOwnPropertySymbols(e);o<c.length;o++)l.indexOf(c[o])<0&&Object.prototype.propertyIsEnumerable.call(e,c[o])&&(t[c[o]]=e[c[o]])}return t}(o,["aria-describedby","allowClear","className","disabled","dropdownAlign","error","icon","id","label","listHeight","loading","mode","notFoundContent","options","testId","variant","withAsterisk"]);const L=r(),{componentDisabled:R}=e.useConfig(),K=null!=a?a:R,U=E||L,Y=`${U}-error`,q=x&&"string"==typeof x?x:void 0,G=[n,q&&Y].filter(Boolean).join(" ")||void 0,J=t(f,{[`${v}-error`]:!!x}),Q=void 0!==I?I:!A&&F,V=d&&!D&&S,W=s(()=>((e,l)=>"tags"===e?w(new Set(l)):y)(D,T),[D,T]);return c.createElement("div",{className:p},C&&c.createElement(h,{htmlFor:U,label:C,withAsterisk:H}),c.createElement(l,Object.assign({"aria-invalid":!!x||void 0},M,{"aria-describedby":G,ref:i,id:U,prefixCls:v,className:J,variant:B,disabled:a,dropdownAlign:g,listHeight:j,mode:D,options:T,loading:A,notFoundContent:Q,suffixIcon:k(z,A),menuItemSelectedIcon:O,allowClear:V,tagRender:K?$:N,optionRender:W,"data-testid":P})),q&&c.createElement(b,{id:Y,error:q}))}));j.displayName="Select";export{j as Select};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const prefixCls = "fvc-select-field";
|
|
2
|
+
export declare const rootCls = "fvc-select-field-root";
|
|
3
|
+
export declare const defaultDropdownAlign: {
|
|
4
|
+
offset: number[];
|
|
5
|
+
};
|
|
6
|
+
export declare const defaultListHeight = 492;
|
|
7
|
+
export declare const az: {
|
|
8
|
+
emptyText: string;
|
|
9
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { SelectOption, SelectOptionRender, SelectProps } from '../types';
|
|
3
|
+
export declare const createOptionRender: (knownOptions?: ReadonlySet<SelectOption>) => SelectOptionRender;
|
|
4
|
+
export declare const renderOption: (oriOption: import("rc-select/lib/interface").FlattenOptionData<SelectOption>, info: {
|
|
5
|
+
index: number;
|
|
6
|
+
}) => React.ReactNode;
|
|
7
|
+
export declare const getOptionRender: (mode: SelectProps["mode"], options: SelectProps["options"]) => (oriOption: import("rc-select/lib/interface").FlattenOptionData<SelectOption>, info: {
|
|
8
|
+
index: number;
|
|
9
|
+
}) => React.ReactNode;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Select } from './Select';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Select as DefaultSelect, GetRef, SelectProps as DefaultSelectProps } from 'antd';
|
|
2
|
+
import type { ReactElement, ReactNode, RefAttributes } from 'react';
|
|
3
|
+
export type SelectRef = GetRef<typeof DefaultSelect>;
|
|
4
|
+
type DefaultSelectOption = NonNullable<DefaultSelectProps['options']>[number];
|
|
5
|
+
export interface SelectOption extends Pick<DefaultSelectOption, 'className' | 'disabled' | 'title'> {
|
|
6
|
+
value: NonNullable<DefaultSelectOption['value']>;
|
|
7
|
+
label: NonNullable<DefaultSelectOption['label']>;
|
|
8
|
+
icon?: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
export type SelectProps<ValueType = unknown> = Omit<DefaultSelectProps<ValueType, SelectOption>, 'allowClear' | 'bordered' | 'children' | 'clearIcon' | 'fieldNames' | 'menuItemSelectedIcon' | 'optionRender' | 'prefixCls' | 'removeIcon' | 'size' | 'status' | 'suffixIcon' | 'tagRender' | 'variant'> & {
|
|
11
|
+
allowClear?: boolean;
|
|
12
|
+
error?: string | boolean;
|
|
13
|
+
icon?: ReactNode;
|
|
14
|
+
label?: ReactNode;
|
|
15
|
+
testId?: string;
|
|
16
|
+
variant?: 'outlined';
|
|
17
|
+
withAsterisk?: boolean;
|
|
18
|
+
};
|
|
19
|
+
export type SelectComponent = (<ValueType = unknown>(props: SelectProps<ValueType> & RefAttributes<SelectRef>) => ReactElement) & {
|
|
20
|
+
displayName?: string;
|
|
21
|
+
};
|
|
22
|
+
export type SelectTagRender = NonNullable<DefaultSelectProps['tagRender']>;
|
|
23
|
+
export type SelectOptionRender = NonNullable<DefaultSelectProps<unknown, SelectOption>['optionRender']>;
|
|
24
|
+
export interface SelectErrorProps {
|
|
25
|
+
id: string;
|
|
26
|
+
error: string;
|
|
27
|
+
}
|
|
28
|
+
export interface SelectLabelProps {
|
|
29
|
+
htmlFor: string;
|
|
30
|
+
label: SelectProps['label'];
|
|
31
|
+
withAsterisk?: SelectProps['withAsterisk'];
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type * from './Select.types';
|
package/package.json
CHANGED
|
@@ -1,6 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fvc/select",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0-next-a7af07acb04fc221bf3a07dc032665ffac019af4",
|
|
4
|
+
"main": "./dist/lib/index.js",
|
|
5
|
+
"types": "./dist/lib/select/src/index.d.ts",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist/lib/index.js",
|
|
8
|
+
"dist/lib/select",
|
|
9
|
+
"package.json",
|
|
10
|
+
"CHANGELOG.md",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"import": "./dist/lib/index.js",
|
|
16
|
+
"types": "./dist/lib/select/src/index.d.ts"
|
|
17
|
+
},
|
|
18
|
+
"./types": {
|
|
19
|
+
"types": "./dist/lib/select/src/types/index.d.ts"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "rollup -c ./rollup.config.mjs",
|
|
24
|
+
"clean": "rm -rf dist && rm -rf .rollup.cache && rm -rf .turbo",
|
|
25
|
+
"format": "prettier --write \"src/**/*.{ts,tsx}\"",
|
|
26
|
+
"type-check": "tsc --noEmit",
|
|
27
|
+
"test": "bun test --preload ../../tests/happydom.ts --preload ../../tests/testing-library.tsx"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"react",
|
|
31
|
+
"react-component",
|
|
32
|
+
"fvc",
|
|
33
|
+
"fe-vis-core",
|
|
34
|
+
"ui",
|
|
35
|
+
"select",
|
|
36
|
+
"design-system",
|
|
37
|
+
"antd"
|
|
38
|
+
],
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"classnames": "^2.5.1"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"@fvc/chip": "1.1.1-next-a7af07acb04fc221bf3a07dc032665ffac019af4",
|
|
44
|
+
"@fvc/empty": "1.1.4-next-a7af07acb04fc221bf3a07dc032665ffac019af4",
|
|
45
|
+
"@fvc/icons": "1.1.8-next-a7af07acb04fc221bf3a07dc032665ffac019af4",
|
|
46
|
+
"antd": "^5.28.0",
|
|
47
|
+
"react": "^18.0.0"
|
|
48
|
+
}
|
|
49
|
+
}
|