@react-fabric/form 1.0.0-beta.17 → 1.0.0-beta.19
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/dist/cjs/select/List.js +41 -20
- package/dist/esm/select/List.js +42 -21
- package/dist/types/select/List.d.ts +1 -1
- package/package.json +4 -4
- package/src/select/List.tsx +34 -7
package/dist/cjs/select/List.js
CHANGED
|
@@ -13,26 +13,27 @@ var Options = require('./Options.js');
|
|
|
13
13
|
var useSelect = require('./useSelect.js');
|
|
14
14
|
var jsxRuntime = require('react/jsx-runtime');
|
|
15
15
|
|
|
16
|
-
var _excluded = ["ref", "name", "value", "readOnly", "disabled", "required", "placeholder", "autoFocus", "options", "height", "groupProperty", "labelProperty", "valueProperty", "multiple", "allowCreate", "createOption", "matcher", "renderer", "onQuery", "onChange", "onSelect", "onEnterPressed", "invalid", "error", "allowClear", "decorateStart", "decorateEnd", "data-inner", "data-hide-selected"];
|
|
16
|
+
var _excluded = ["ref", "name", "value", "readOnly", "disabled", "required", "placeholder", "autoFocus", "options", "height", "groupProperty", "labelProperty", "valueProperty", "multiple", "allowCreate", "searchable", "createOption", "matcher", "renderer", "onQuery", "onChange", "onSelect", "onEnterPressed", "invalid", "error", "allowClear", "decorateStart", "decorateEnd", "data-inner", "data-hide-selected"];
|
|
17
17
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
18
18
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
19
19
|
var List = function List(_ref) {
|
|
20
20
|
var _state$query;
|
|
21
|
-
_ref.ref
|
|
22
|
-
|
|
21
|
+
var ref = _ref.ref,
|
|
22
|
+
name = _ref.name,
|
|
23
23
|
value = _ref.value,
|
|
24
24
|
readOnly = _ref.readOnly,
|
|
25
25
|
disabled = _ref.disabled,
|
|
26
26
|
required = _ref.required,
|
|
27
|
-
placeholder = _ref.placeholder
|
|
28
|
-
_ref.autoFocus
|
|
29
|
-
|
|
27
|
+
placeholder = _ref.placeholder,
|
|
28
|
+
autoFocus = _ref.autoFocus,
|
|
29
|
+
options = _ref.options,
|
|
30
30
|
height = _ref.height,
|
|
31
31
|
groupProperty = _ref.groupProperty,
|
|
32
32
|
labelProperty = _ref.labelProperty,
|
|
33
33
|
valueProperty = _ref.valueProperty,
|
|
34
34
|
multiple = _ref.multiple,
|
|
35
35
|
allowCreate = _ref.allowCreate,
|
|
36
|
+
searchable = _ref.searchable,
|
|
36
37
|
createOption = _ref.createOption,
|
|
37
38
|
matcher = _ref.matcher,
|
|
38
39
|
renderer = _ref.renderer,
|
|
@@ -138,9 +139,10 @@ var List = function List(_ref) {
|
|
|
138
139
|
}
|
|
139
140
|
} else if (evt.key === "Backspace") {
|
|
140
141
|
!state.query && handleRemove();
|
|
141
|
-
} else if (["ArrowUp", "ArrowDown"].includes(evt.key)) {
|
|
142
|
-
if (state.activeIndex === null) {
|
|
143
|
-
|
|
142
|
+
} else if (!searchable || ["ArrowUp", "ArrowDown"].includes(evt.key)) {
|
|
143
|
+
if (["ArrowUp", "ArrowDown"].includes(evt.key) && state.activeIndex === null) {
|
|
144
|
+
var _state$selectedIndex;
|
|
145
|
+
setActiveIndex((_state$selectedIndex = state.selectedIndex) !== null && _state$selectedIndex !== void 0 ? _state$selectedIndex : 0);
|
|
144
146
|
}
|
|
145
147
|
setTimeout(function () {
|
|
146
148
|
var _props$onKeyDown;
|
|
@@ -185,6 +187,14 @@ var List = function List(_ref) {
|
|
|
185
187
|
});
|
|
186
188
|
}
|
|
187
189
|
}, [state.value, state.query, placeholder, renderer]);
|
|
190
|
+
react.useLayoutEffect(function () {
|
|
191
|
+
setTimeout(function () {
|
|
192
|
+
var _listRef$current$stat;
|
|
193
|
+
state.selectedIndex && ((_listRef$current$stat = listRef.current[state.selectedIndex]) === null || _listRef$current$stat === void 0 ? void 0 : _listRef$current$stat.scrollIntoView({
|
|
194
|
+
block: "center"
|
|
195
|
+
}));
|
|
196
|
+
}, 100);
|
|
197
|
+
}, [state.selectedIndex]);
|
|
188
198
|
return /*#__PURE__*/jsxRuntime.jsxs(Wrapper, _objectSpread(_objectSpread({}, wrapperProps), {}, {
|
|
189
199
|
children: [/*#__PURE__*/jsxRuntime.jsx(InputWrapper.InputWrapper, {
|
|
190
200
|
showClear: !utilities.isEmpty(state.value),
|
|
@@ -197,23 +207,32 @@ var List = function List(_ref) {
|
|
|
197
207
|
className: "z-1 rounded-b-none",
|
|
198
208
|
"data-inner": true,
|
|
199
209
|
wrapperRef: refs.setReference,
|
|
200
|
-
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
210
|
+
children: /*#__PURE__*/jsxRuntime.jsxs("div", _objectSpread(_objectSpread({
|
|
211
|
+
role: "none",
|
|
201
212
|
"data-select-display": "true",
|
|
202
|
-
className: "group flex-1 py-1 px-2 truncate text-start flex gap-1 flex-wrap"
|
|
203
|
-
|
|
213
|
+
className: classNames("group flex-1 py-1 px-2 truncate text-start flex gap-1 relative min-h-5 justify-start", multiple ? "flex-wrap" : "flex-nowrap overflow-hidden")
|
|
214
|
+
}, referenceProps), {}, {
|
|
215
|
+
onMouseUp: function onMouseUp(e) {
|
|
216
|
+
var _e$currentTarget$quer;
|
|
217
|
+
return (_e$currentTarget$quer = e.currentTarget.querySelector("input")) === null || _e$currentTarget$quer === void 0 ? void 0 : _e$currentTarget$quer.focus();
|
|
218
|
+
},
|
|
219
|
+
children: [!hideSelected && displayValue, /*#__PURE__*/jsxRuntime.jsx("input", {
|
|
220
|
+
readOnly: !searchable || readOnly,
|
|
204
221
|
disabled: disabled,
|
|
205
222
|
value: (_state$query = state.query) !== null && _state$query !== void 0 ? _state$query : "",
|
|
206
223
|
"aria-invalid": invalid,
|
|
207
224
|
"data-testid": name,
|
|
208
225
|
name: name,
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
226
|
+
size: 1,
|
|
227
|
+
ref: ref,
|
|
228
|
+
autoFocus: autoFocus,
|
|
229
|
+
className: classNames("appearance-none bg-transparent outline-none border-none ring-0 flex-1 min-w-24", disabled && "cursor-not-allowed pointer-events-none", multiple && "min-w-24"),
|
|
230
|
+
placeholder: utilities.isEmpty(state.value) ? placeholder : "",
|
|
212
231
|
onChange: function onChange(evt) {
|
|
213
232
|
return handleQuery(evt.target.value);
|
|
214
233
|
}
|
|
215
|
-
})
|
|
216
|
-
})
|
|
234
|
+
})]
|
|
235
|
+
}))
|
|
217
236
|
}), /*#__PURE__*/jsxRuntime.jsx(react$1.FloatingFocusManager, {
|
|
218
237
|
context: context,
|
|
219
238
|
initialFocus: -1,
|
|
@@ -227,11 +246,13 @@ var List = function List(_ref) {
|
|
|
227
246
|
}, floatingProps), {}, {
|
|
228
247
|
items: state.items,
|
|
229
248
|
active: state.activeIndex,
|
|
249
|
+
valueProperty: valueProperty,
|
|
250
|
+
labelProperty: labelProperty,
|
|
230
251
|
itemRef: setItemRef,
|
|
231
252
|
itemProps: makeItemProps,
|
|
232
|
-
children: function children(item) {
|
|
233
|
-
var
|
|
234
|
-
return (
|
|
253
|
+
children: function children(item, label) {
|
|
254
|
+
var _renderer3;
|
|
255
|
+
return (_renderer3 = renderer === null || renderer === void 0 ? void 0 : renderer(item)) !== null && _renderer3 !== void 0 ? _renderer3 : label;
|
|
235
256
|
}
|
|
236
257
|
}))
|
|
237
258
|
})]
|
package/dist/esm/select/List.js
CHANGED
|
@@ -6,33 +6,34 @@ import { useFloating, autoUpdate, useListNavigation, useTypeahead, useInteractio
|
|
|
6
6
|
import { Chip } from '@react-fabric/core';
|
|
7
7
|
import { isArray, isEmpty } from '@react-fabric/utilities';
|
|
8
8
|
import classNames from 'classnames';
|
|
9
|
-
import { useMemo, Fragment, useId, useCallback } from 'react';
|
|
9
|
+
import { useMemo, Fragment, useId, useCallback, useLayoutEffect } from 'react';
|
|
10
10
|
import { FieldWrapper } from '../internal/FieldWrapper.js';
|
|
11
11
|
import { InputWrapper } from '../internal/InputWrapper.js';
|
|
12
12
|
import { Options } from './Options.js';
|
|
13
13
|
import { useSelect } from './useSelect.js';
|
|
14
14
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
15
15
|
|
|
16
|
-
var _excluded = ["ref", "name", "value", "readOnly", "disabled", "required", "placeholder", "autoFocus", "options", "height", "groupProperty", "labelProperty", "valueProperty", "multiple", "allowCreate", "createOption", "matcher", "renderer", "onQuery", "onChange", "onSelect", "onEnterPressed", "invalid", "error", "allowClear", "decorateStart", "decorateEnd", "data-inner", "data-hide-selected"];
|
|
16
|
+
var _excluded = ["ref", "name", "value", "readOnly", "disabled", "required", "placeholder", "autoFocus", "options", "height", "groupProperty", "labelProperty", "valueProperty", "multiple", "allowCreate", "searchable", "createOption", "matcher", "renderer", "onQuery", "onChange", "onSelect", "onEnterPressed", "invalid", "error", "allowClear", "decorateStart", "decorateEnd", "data-inner", "data-hide-selected"];
|
|
17
17
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
18
18
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
19
19
|
var List = function List(_ref) {
|
|
20
20
|
var _state$query;
|
|
21
|
-
_ref.ref
|
|
22
|
-
|
|
21
|
+
var ref = _ref.ref,
|
|
22
|
+
name = _ref.name,
|
|
23
23
|
value = _ref.value,
|
|
24
24
|
readOnly = _ref.readOnly,
|
|
25
25
|
disabled = _ref.disabled,
|
|
26
26
|
required = _ref.required,
|
|
27
|
-
placeholder = _ref.placeholder
|
|
28
|
-
_ref.autoFocus
|
|
29
|
-
|
|
27
|
+
placeholder = _ref.placeholder,
|
|
28
|
+
autoFocus = _ref.autoFocus,
|
|
29
|
+
options = _ref.options,
|
|
30
30
|
height = _ref.height,
|
|
31
31
|
groupProperty = _ref.groupProperty,
|
|
32
32
|
labelProperty = _ref.labelProperty,
|
|
33
33
|
valueProperty = _ref.valueProperty,
|
|
34
34
|
multiple = _ref.multiple,
|
|
35
35
|
allowCreate = _ref.allowCreate,
|
|
36
|
+
searchable = _ref.searchable,
|
|
36
37
|
createOption = _ref.createOption,
|
|
37
38
|
matcher = _ref.matcher,
|
|
38
39
|
renderer = _ref.renderer,
|
|
@@ -138,9 +139,10 @@ var List = function List(_ref) {
|
|
|
138
139
|
}
|
|
139
140
|
} else if (evt.key === "Backspace") {
|
|
140
141
|
!state.query && handleRemove();
|
|
141
|
-
} else if (["ArrowUp", "ArrowDown"].includes(evt.key)) {
|
|
142
|
-
if (state.activeIndex === null) {
|
|
143
|
-
|
|
142
|
+
} else if (!searchable || ["ArrowUp", "ArrowDown"].includes(evt.key)) {
|
|
143
|
+
if (["ArrowUp", "ArrowDown"].includes(evt.key) && state.activeIndex === null) {
|
|
144
|
+
var _state$selectedIndex;
|
|
145
|
+
setActiveIndex((_state$selectedIndex = state.selectedIndex) !== null && _state$selectedIndex !== void 0 ? _state$selectedIndex : 0);
|
|
144
146
|
}
|
|
145
147
|
setTimeout(function () {
|
|
146
148
|
var _props$onKeyDown;
|
|
@@ -185,6 +187,14 @@ var List = function List(_ref) {
|
|
|
185
187
|
});
|
|
186
188
|
}
|
|
187
189
|
}, [state.value, state.query, placeholder, renderer]);
|
|
190
|
+
useLayoutEffect(function () {
|
|
191
|
+
setTimeout(function () {
|
|
192
|
+
var _listRef$current$stat;
|
|
193
|
+
state.selectedIndex && ((_listRef$current$stat = listRef.current[state.selectedIndex]) === null || _listRef$current$stat === void 0 ? void 0 : _listRef$current$stat.scrollIntoView({
|
|
194
|
+
block: "center"
|
|
195
|
+
}));
|
|
196
|
+
}, 100);
|
|
197
|
+
}, [state.selectedIndex]);
|
|
188
198
|
return /*#__PURE__*/jsxs(Wrapper, _objectSpread(_objectSpread({}, wrapperProps), {}, {
|
|
189
199
|
children: [/*#__PURE__*/jsx(InputWrapper, {
|
|
190
200
|
showClear: !isEmpty(state.value),
|
|
@@ -197,23 +207,32 @@ var List = function List(_ref) {
|
|
|
197
207
|
className: "z-1 rounded-b-none",
|
|
198
208
|
"data-inner": true,
|
|
199
209
|
wrapperRef: refs.setReference,
|
|
200
|
-
children: /*#__PURE__*/jsxs("div", {
|
|
210
|
+
children: /*#__PURE__*/jsxs("div", _objectSpread(_objectSpread({
|
|
211
|
+
role: "none",
|
|
201
212
|
"data-select-display": "true",
|
|
202
|
-
className: "group flex-1 py-1 px-2 truncate text-start flex gap-1 flex-wrap"
|
|
203
|
-
|
|
213
|
+
className: classNames("group flex-1 py-1 px-2 truncate text-start flex gap-1 relative min-h-5 justify-start", multiple ? "flex-wrap" : "flex-nowrap overflow-hidden")
|
|
214
|
+
}, referenceProps), {}, {
|
|
215
|
+
onMouseUp: function onMouseUp(e) {
|
|
216
|
+
var _e$currentTarget$quer;
|
|
217
|
+
return (_e$currentTarget$quer = e.currentTarget.querySelector("input")) === null || _e$currentTarget$quer === void 0 ? void 0 : _e$currentTarget$quer.focus();
|
|
218
|
+
},
|
|
219
|
+
children: [!hideSelected && displayValue, /*#__PURE__*/jsx("input", {
|
|
220
|
+
readOnly: !searchable || readOnly,
|
|
204
221
|
disabled: disabled,
|
|
205
222
|
value: (_state$query = state.query) !== null && _state$query !== void 0 ? _state$query : "",
|
|
206
223
|
"aria-invalid": invalid,
|
|
207
224
|
"data-testid": name,
|
|
208
225
|
name: name,
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
226
|
+
size: 1,
|
|
227
|
+
ref: ref,
|
|
228
|
+
autoFocus: autoFocus,
|
|
229
|
+
className: classNames("appearance-none bg-transparent outline-none border-none ring-0 flex-1 min-w-24", disabled && "cursor-not-allowed pointer-events-none", multiple && "min-w-24"),
|
|
230
|
+
placeholder: isEmpty(state.value) ? placeholder : "",
|
|
212
231
|
onChange: function onChange(evt) {
|
|
213
232
|
return handleQuery(evt.target.value);
|
|
214
233
|
}
|
|
215
|
-
})
|
|
216
|
-
})
|
|
234
|
+
})]
|
|
235
|
+
}))
|
|
217
236
|
}), /*#__PURE__*/jsx(FloatingFocusManager, {
|
|
218
237
|
context: context,
|
|
219
238
|
initialFocus: -1,
|
|
@@ -227,11 +246,13 @@ var List = function List(_ref) {
|
|
|
227
246
|
}, floatingProps), {}, {
|
|
228
247
|
items: state.items,
|
|
229
248
|
active: state.activeIndex,
|
|
249
|
+
valueProperty: valueProperty,
|
|
250
|
+
labelProperty: labelProperty,
|
|
230
251
|
itemRef: setItemRef,
|
|
231
252
|
itemProps: makeItemProps,
|
|
232
|
-
children: function children(item) {
|
|
233
|
-
var
|
|
234
|
-
return (
|
|
253
|
+
children: function children(item, label) {
|
|
254
|
+
var _renderer3;
|
|
255
|
+
return (_renderer3 = renderer === null || renderer === void 0 ? void 0 : renderer(item)) !== null && _renderer3 !== void 0 ? _renderer3 : label;
|
|
235
256
|
}
|
|
236
257
|
}))
|
|
237
258
|
})]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type SelectProps } from "../types";
|
|
2
|
-
export declare const List: <T extends unknown = string>({ ref, name, value, readOnly, disabled, required, placeholder, autoFocus, options, height, groupProperty, labelProperty, valueProperty, multiple, allowCreate, createOption, matcher, renderer, onQuery, onChange, onSelect, onEnterPressed, invalid, error, allowClear, decorateStart, decorateEnd, "data-inner": isInner, "data-hide-selected": hideSelected, ...rest }: SelectProps<T> & {
|
|
2
|
+
export declare const List: <T extends unknown = string>({ ref, name, value, readOnly, disabled, required, placeholder, autoFocus, options, height, groupProperty, labelProperty, valueProperty, multiple, allowCreate, searchable, createOption, matcher, renderer, onQuery, onChange, onSelect, onEnterPressed, invalid, error, allowClear, decorateStart, decorateEnd, "data-inner": isInner, "data-hide-selected": hideSelected, ...rest }: SelectProps<T> & {
|
|
3
3
|
height?: string | number;
|
|
4
4
|
}) => import("react/jsx-runtime").JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-fabric/form",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.19",
|
|
4
4
|
"description": "RUF: Form package",
|
|
5
5
|
"author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"@dnd-kit/utilities": "^3.2.2",
|
|
40
40
|
"@floating-ui/react": "^0.26.24",
|
|
41
41
|
"@hookform/resolvers": "^3.9.0",
|
|
42
|
-
"@react-fabric/core": "^1.0.0-beta.
|
|
43
|
-
"@react-fabric/utilities": "^1.0.0-beta.
|
|
42
|
+
"@react-fabric/core": "^1.0.0-beta.19",
|
|
43
|
+
"@react-fabric/utilities": "^1.0.0-beta.19",
|
|
44
44
|
"classnames": "^2.5.1",
|
|
45
45
|
"color": "^4.2.3",
|
|
46
46
|
"react-color": "^2.19.3",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"node": ">=18.12.0",
|
|
61
61
|
"npm": ">=8.19.0"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "1757660f7f30590d1bf5c7f2bd3526f6052dccd5"
|
|
64
64
|
}
|
package/src/select/List.tsx
CHANGED
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
import { Chip } from "@react-fabric/core";
|
|
33
33
|
import { isArray, isEmpty } from "@react-fabric/utilities";
|
|
34
34
|
import classNames from "classnames";
|
|
35
|
-
import { Fragment, useCallback, useId, useMemo } from "react";
|
|
35
|
+
import { Fragment, useCallback, useId, useLayoutEffect, useMemo } from "react";
|
|
36
36
|
import { FieldWrapper } from "../internal/FieldWrapper";
|
|
37
37
|
import { InputWrapper } from "../internal/InputWrapper";
|
|
38
38
|
import { type SelectProps } from "../types";
|
|
@@ -55,6 +55,7 @@ export const List = <T extends AnyObject = string>({
|
|
|
55
55
|
valueProperty,
|
|
56
56
|
multiple,
|
|
57
57
|
allowCreate,
|
|
58
|
+
searchable,
|
|
58
59
|
createOption,
|
|
59
60
|
matcher,
|
|
60
61
|
renderer,
|
|
@@ -166,9 +167,12 @@ export const List = <T extends AnyObject = string>({
|
|
|
166
167
|
}
|
|
167
168
|
} else if (evt.key === "Backspace") {
|
|
168
169
|
!state.query && handleRemove();
|
|
169
|
-
} else if (["ArrowUp", "ArrowDown"].includes(evt.key)) {
|
|
170
|
-
if (
|
|
171
|
-
|
|
170
|
+
} else if (!searchable || ["ArrowUp", "ArrowDown"].includes(evt.key)) {
|
|
171
|
+
if (
|
|
172
|
+
["ArrowUp", "ArrowDown"].includes(evt.key) &&
|
|
173
|
+
state.activeIndex === null
|
|
174
|
+
) {
|
|
175
|
+
setActiveIndex(state.selectedIndex ?? 0);
|
|
172
176
|
}
|
|
173
177
|
setTimeout(() => {
|
|
174
178
|
props.onKeyDown?.(evt);
|
|
@@ -225,6 +229,15 @@ export const List = <T extends AnyObject = string>({
|
|
|
225
229
|
}
|
|
226
230
|
}, [state.value, state.query, placeholder, renderer]);
|
|
227
231
|
|
|
232
|
+
useLayoutEffect(() => {
|
|
233
|
+
setTimeout(() => {
|
|
234
|
+
state.selectedIndex &&
|
|
235
|
+
listRef.current[state.selectedIndex]?.scrollIntoView({
|
|
236
|
+
block: "center",
|
|
237
|
+
});
|
|
238
|
+
}, 100);
|
|
239
|
+
}, [state.selectedIndex]);
|
|
240
|
+
|
|
228
241
|
return (
|
|
229
242
|
<Wrapper {...wrapperProps}>
|
|
230
243
|
<InputWrapper
|
|
@@ -240,22 +253,34 @@ export const List = <T extends AnyObject = string>({
|
|
|
240
253
|
wrapperRef={refs.setReference}
|
|
241
254
|
>
|
|
242
255
|
<div
|
|
256
|
+
role="none"
|
|
243
257
|
data-select-display="true"
|
|
244
|
-
className=
|
|
258
|
+
className={classNames(
|
|
259
|
+
"group flex-1 py-1 px-2 truncate text-start flex gap-1 relative min-h-5 justify-start",
|
|
260
|
+
multiple ? "flex-wrap" : "flex-nowrap overflow-hidden",
|
|
261
|
+
)}
|
|
262
|
+
{...referenceProps}
|
|
263
|
+
onMouseUp={(e) =>
|
|
264
|
+
e.currentTarget.querySelector<HTMLElement>("input")?.focus()
|
|
265
|
+
}
|
|
245
266
|
>
|
|
246
267
|
{!hideSelected && displayValue}
|
|
247
268
|
<input
|
|
269
|
+
readOnly={!searchable || readOnly}
|
|
248
270
|
disabled={disabled}
|
|
249
271
|
value={state.query ?? ""}
|
|
250
272
|
aria-invalid={invalid}
|
|
251
273
|
data-testid={name}
|
|
252
274
|
name={name}
|
|
275
|
+
size={1}
|
|
276
|
+
ref={ref}
|
|
277
|
+
autoFocus={autoFocus}
|
|
253
278
|
className={classNames(
|
|
254
279
|
"appearance-none bg-transparent outline-none border-none ring-0 flex-1 min-w-24",
|
|
255
280
|
disabled && "cursor-not-allowed pointer-events-none",
|
|
281
|
+
multiple && "min-w-24",
|
|
256
282
|
)}
|
|
257
283
|
placeholder={isEmpty(state.value) ? placeholder : ""}
|
|
258
|
-
{...referenceProps}
|
|
259
284
|
onChange={(evt) => handleQuery(evt.target.value)}
|
|
260
285
|
/>
|
|
261
286
|
</div>
|
|
@@ -277,10 +302,12 @@ export const List = <T extends AnyObject = string>({
|
|
|
277
302
|
{...floatingProps}
|
|
278
303
|
items={state.items}
|
|
279
304
|
active={state.activeIndex}
|
|
305
|
+
valueProperty={valueProperty}
|
|
306
|
+
labelProperty={labelProperty}
|
|
280
307
|
itemRef={setItemRef}
|
|
281
308
|
itemProps={makeItemProps}
|
|
282
309
|
>
|
|
283
|
-
{(item) => renderer?.(item) ??
|
|
310
|
+
{(item, label) => renderer?.(item) ?? label}
|
|
284
311
|
</Options>
|
|
285
312
|
</FloatingFocusManager>
|
|
286
313
|
</Wrapper>
|