@yamada-ui/autocomplete 0.0.0-dev-20231125112239 → 0.0.0-dev-20231125140816
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/autocomplete-create.mjs +1 -1
- package/dist/autocomplete-empty.mjs +1 -1
- package/dist/autocomplete-icon.mjs +1 -1
- package/dist/autocomplete-list.mjs +1 -1
- package/dist/autocomplete-option-group.d.mts +1 -1
- package/dist/autocomplete-option-group.d.ts +1 -1
- package/dist/autocomplete-option-group.mjs +1 -1
- package/dist/autocomplete-option.d.mts +1 -1
- package/dist/autocomplete-option.d.ts +1 -1
- package/dist/autocomplete-option.mjs +1 -1
- package/dist/autocomplete.d.mts +1 -1
- package/dist/autocomplete.d.ts +1 -1
- package/dist/autocomplete.js +57 -16
- package/dist/autocomplete.mjs +1 -1
- package/dist/{chunk-FUKAI7NL.mjs → chunk-TZHEVPHW.mjs} +86 -37
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +86 -37
- package/dist/index.mjs +1 -1
- package/dist/multi-autocomplete.d.mts +1 -1
- package/dist/multi-autocomplete.d.ts +1 -1
- package/dist/multi-autocomplete.js +70 -29
- package/dist/multi-autocomplete.mjs +1 -1
- package/dist/{use-autocomplete-67b1aea6.d.ts → use-autocomplete-72ef1a50.d.ts} +6 -1
- package/dist/use-autocomplete.d.mts +1 -1
- package/dist/use-autocomplete.d.ts +1 -1
- package/dist/use-autocomplete.js +41 -8
- package/dist/use-autocomplete.mjs +1 -1
- package/package.json +10 -10
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _yamada_ui_core from '@yamada-ui/core';
|
|
2
2
|
import { HTMLUIProps } from '@yamada-ui/core';
|
|
3
|
-
import { U as UseAutocompleteOptionGroupProps } from './use-autocomplete-
|
|
3
|
+
import { U as UseAutocompleteOptionGroupProps } from './use-autocomplete-72ef1a50.js';
|
|
4
4
|
import 'react/jsx-runtime';
|
|
5
5
|
import 'react';
|
|
6
6
|
import '@yamada-ui/form-control';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _yamada_ui_core from '@yamada-ui/core';
|
|
2
2
|
import { HTMLUIProps } from '@yamada-ui/core';
|
|
3
|
-
import { U as UseAutocompleteOptionGroupProps } from './use-autocomplete-
|
|
3
|
+
import { U as UseAutocompleteOptionGroupProps } from './use-autocomplete-72ef1a50.js';
|
|
4
4
|
import 'react/jsx-runtime';
|
|
5
5
|
import 'react';
|
|
6
6
|
import '@yamada-ui/form-control';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import '@yamada-ui/core';
|
|
2
2
|
import 'react';
|
|
3
|
-
export { A as AutocompleteOption, a as AutocompleteOptionProps } from './use-autocomplete-
|
|
3
|
+
export { A as AutocompleteOption, a as AutocompleteOptionProps } from './use-autocomplete-72ef1a50.js';
|
|
4
4
|
import 'react/jsx-runtime';
|
|
5
5
|
import '@yamada-ui/form-control';
|
|
6
6
|
import '@yamada-ui/popover';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import '@yamada-ui/core';
|
|
2
2
|
import 'react';
|
|
3
|
-
export { A as AutocompleteOption, a as AutocompleteOptionProps } from './use-autocomplete-
|
|
3
|
+
export { A as AutocompleteOption, a as AutocompleteOptionProps } from './use-autocomplete-72ef1a50.js';
|
|
4
4
|
import 'react/jsx-runtime';
|
|
5
5
|
import '@yamada-ui/form-control';
|
|
6
6
|
import '@yamada-ui/popover';
|
package/dist/autocomplete.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import * as _yamada_ui_core from '@yamada-ui/core';
|
|
|
2
2
|
import { ThemeProps, HTMLUIProps } from '@yamada-ui/core';
|
|
3
3
|
import { AutocompleteIconProps } from './autocomplete-icon.mjs';
|
|
4
4
|
import { AutocompleteListProps } from './autocomplete-list.mjs';
|
|
5
|
-
import { c as UseAutocompleteProps } from './use-autocomplete-
|
|
5
|
+
import { c as UseAutocompleteProps } from './use-autocomplete-72ef1a50.js';
|
|
6
6
|
import 'react';
|
|
7
7
|
import 'react/jsx-runtime';
|
|
8
8
|
import '@yamada-ui/form-control';
|
package/dist/autocomplete.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as _yamada_ui_core from '@yamada-ui/core';
|
|
|
2
2
|
import { ThemeProps, HTMLUIProps } from '@yamada-ui/core';
|
|
3
3
|
import { AutocompleteIconProps } from './autocomplete-icon.js';
|
|
4
4
|
import { AutocompleteListProps } from './autocomplete-list.js';
|
|
5
|
-
import { c as UseAutocompleteProps } from './use-autocomplete-
|
|
5
|
+
import { c as UseAutocompleteProps } from './use-autocomplete-72ef1a50.js';
|
|
6
6
|
import 'react';
|
|
7
7
|
import 'react/jsx-runtime';
|
|
8
8
|
import '@yamada-ui/form-control';
|
package/dist/autocomplete.js
CHANGED
|
@@ -389,6 +389,7 @@ var useAutocomplete = ({
|
|
|
389
389
|
closeOnBlur = true,
|
|
390
390
|
closeOnEsc = true,
|
|
391
391
|
allowCreate = false,
|
|
392
|
+
allowFree = false,
|
|
392
393
|
insertPositionItem = "first",
|
|
393
394
|
emptyMessage = "No results found",
|
|
394
395
|
format = defaultFormat,
|
|
@@ -676,6 +677,10 @@ var useAutocomplete = ({
|
|
|
676
677
|
var _a;
|
|
677
678
|
return (_a = node.textContent) != null ? _a : "";
|
|
678
679
|
});
|
|
680
|
+
if (allowFree && selectedValues2.length === 0) {
|
|
681
|
+
selectedValues2.push(newValue);
|
|
682
|
+
setInputValue("");
|
|
683
|
+
}
|
|
679
684
|
setDisplayValue((prev) => {
|
|
680
685
|
if (!isMulti) {
|
|
681
686
|
return selectedValues2[0];
|
|
@@ -692,7 +697,7 @@ var useAutocomplete = ({
|
|
|
692
697
|
}
|
|
693
698
|
});
|
|
694
699
|
},
|
|
695
|
-
[descendants, isMulti]
|
|
700
|
+
[descendants, isMulti, allowFree]
|
|
696
701
|
);
|
|
697
702
|
const onChange = (0, import_react.useCallback)(
|
|
698
703
|
(newValue) => {
|
|
@@ -708,11 +713,26 @@ var useAutocomplete = ({
|
|
|
708
713
|
}
|
|
709
714
|
}
|
|
710
715
|
});
|
|
716
|
+
const isHit2 = descendants.values().filter(
|
|
717
|
+
({ node }) => {
|
|
718
|
+
var _a;
|
|
719
|
+
return format((_a = node.textContent) != null ? _a : "").includes(newValue);
|
|
720
|
+
}
|
|
721
|
+
).length > 0;
|
|
711
722
|
onChangeDisplayValue(newValue);
|
|
712
|
-
|
|
723
|
+
if (!allowFree || isHit2) {
|
|
724
|
+
setInputValue("");
|
|
725
|
+
}
|
|
713
726
|
rebirthOptions(false);
|
|
714
727
|
},
|
|
715
|
-
[
|
|
728
|
+
[
|
|
729
|
+
allowFree,
|
|
730
|
+
onChangeDisplayValue,
|
|
731
|
+
rebirthOptions,
|
|
732
|
+
setValue,
|
|
733
|
+
descendants,
|
|
734
|
+
format
|
|
735
|
+
]
|
|
716
736
|
);
|
|
717
737
|
const onSelect = (0, import_react.useCallback)(() => {
|
|
718
738
|
var _a, _b;
|
|
@@ -846,11 +866,15 @@ var useAutocomplete = ({
|
|
|
846
866
|
return;
|
|
847
867
|
if (!closeOnBlur && isHit)
|
|
848
868
|
return;
|
|
849
|
-
|
|
869
|
+
if (allowFree && !!inputValue) {
|
|
870
|
+
onChange(inputValue);
|
|
871
|
+
} else {
|
|
872
|
+
setInputValue("");
|
|
873
|
+
}
|
|
850
874
|
if (isOpen)
|
|
851
875
|
onClose();
|
|
852
876
|
},
|
|
853
|
-
[closeOnBlur, isHit, isOpen, onClose]
|
|
877
|
+
[closeOnBlur, isHit, isOpen, inputValue, allowFree, onClose, onChange]
|
|
854
878
|
);
|
|
855
879
|
const onKeyDown = (0, import_react.useCallback)(
|
|
856
880
|
(ev) => {
|
|
@@ -865,7 +889,11 @@ var useAutocomplete = ({
|
|
|
865
889
|
ArrowDown: isFocused ? () => onFocusNext() : !isOpen ? (0, import_utils6.funcAll)(onOpen, onFocusFirstOrSelected) : void 0,
|
|
866
890
|
ArrowUp: isFocused ? () => onFocusPrev() : !isOpen ? (0, import_utils6.funcAll)(onOpen, onFocusLastOrSelected) : void 0,
|
|
867
891
|
Space: isCreate ? onCreate : isFocused ? onSelect : !isOpen ? (0, import_utils6.funcAll)(onOpen, onFocusFirstOrSelected) : void 0,
|
|
868
|
-
Enter: isCreate ? onCreate : isFocused ? onSelect : !isOpen ? (0, import_utils6.funcAll)(onOpen, onFocusFirstOrSelected) :
|
|
892
|
+
Enter: isCreate ? onCreate : isFocused ? onSelect : !isOpen ? (0, import_utils6.funcAll)(onOpen, onFocusFirstOrSelected) : allowFree && isMulti ? () => {
|
|
893
|
+
if (inputValue)
|
|
894
|
+
onChange(inputValue);
|
|
895
|
+
setFocusedIndex(0);
|
|
896
|
+
} : void 0,
|
|
869
897
|
Home: isOpen ? onFocusFirst : void 0,
|
|
870
898
|
End: isOpen ? onFocusLast : void 0,
|
|
871
899
|
Escape: closeOnEsc ? onClose : void 0,
|
|
@@ -879,11 +907,13 @@ var useAutocomplete = ({
|
|
|
879
907
|
action(ev);
|
|
880
908
|
},
|
|
881
909
|
[
|
|
910
|
+
allowFree,
|
|
882
911
|
formControlProps,
|
|
883
912
|
displayValue,
|
|
884
913
|
inputValue,
|
|
885
914
|
onOpen,
|
|
886
915
|
isFocused,
|
|
916
|
+
isMulti,
|
|
887
917
|
onFocusFirstOrSelected,
|
|
888
918
|
onFocusNext,
|
|
889
919
|
onFocusLastOrSelected,
|
|
@@ -897,7 +927,8 @@ var useAutocomplete = ({
|
|
|
897
927
|
closeOnEsc,
|
|
898
928
|
onClose,
|
|
899
929
|
isEmptyValue,
|
|
900
|
-
onDelete
|
|
930
|
+
onDelete,
|
|
931
|
+
onChange
|
|
901
932
|
]
|
|
902
933
|
);
|
|
903
934
|
(0, import_react.useEffect)(() => {
|
|
@@ -922,7 +953,7 @@ var useAutocomplete = ({
|
|
|
922
953
|
maxSelectedValues
|
|
923
954
|
]);
|
|
924
955
|
(0, import_utils6.useUpdateEffect)(() => {
|
|
925
|
-
if (isOpen)
|
|
956
|
+
if (isOpen || allowFree)
|
|
926
957
|
return;
|
|
927
958
|
setFocusedIndex(-1);
|
|
928
959
|
setInputValue("");
|
|
@@ -942,6 +973,7 @@ var useAutocomplete = ({
|
|
|
942
973
|
});
|
|
943
974
|
const getPopoverProps = (0, import_react.useCallback)(
|
|
944
975
|
(props) => ({
|
|
976
|
+
matchWidth: true,
|
|
945
977
|
...rest,
|
|
946
978
|
...props,
|
|
947
979
|
isOpen,
|
|
@@ -992,6 +1024,7 @@ var useAutocomplete = ({
|
|
|
992
1024
|
omitSelectedValues,
|
|
993
1025
|
closeOnSelect,
|
|
994
1026
|
allowCreate,
|
|
1027
|
+
allowFree,
|
|
995
1028
|
emptyMessage,
|
|
996
1029
|
isOpen,
|
|
997
1030
|
isAllSelected,
|
|
@@ -1479,7 +1512,6 @@ var Autocomplete = (0, import_core8.forwardRef)(
|
|
|
1479
1512
|
h != null ? h : h = height;
|
|
1480
1513
|
minH != null ? minH : minH = minHeight;
|
|
1481
1514
|
const css = {
|
|
1482
|
-
position: "relative",
|
|
1483
1515
|
w: "100%",
|
|
1484
1516
|
h: "fit-content",
|
|
1485
1517
|
color,
|
|
@@ -1503,16 +1535,25 @@ var Autocomplete = (0, import_core8.forwardRef)(
|
|
|
1503
1535
|
__css: css,
|
|
1504
1536
|
...getContainerProps(containerProps),
|
|
1505
1537
|
children: [
|
|
1506
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.
|
|
1507
|
-
|
|
1538
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1539
|
+
import_core8.ui.div,
|
|
1508
1540
|
{
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1541
|
+
className: "ui-autocomplete__inner",
|
|
1542
|
+
__css: { position: "relative", ...styles.inner },
|
|
1543
|
+
children: [
|
|
1544
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1545
|
+
AutocompleteField,
|
|
1546
|
+
{
|
|
1547
|
+
h,
|
|
1548
|
+
minH,
|
|
1549
|
+
inputProps,
|
|
1550
|
+
...getFieldProps({}, ref)
|
|
1551
|
+
}
|
|
1552
|
+
),
|
|
1553
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteIcon, { ...iconProps, ...formControlProps })
|
|
1554
|
+
]
|
|
1513
1555
|
}
|
|
1514
1556
|
),
|
|
1515
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteIcon, { ...iconProps, ...formControlProps }),
|
|
1516
1557
|
!isEmpty ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(AutocompleteList, { ...listProps, children: [
|
|
1517
1558
|
allowCreate ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteCreate, {}) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteEmpty, {}),
|
|
1518
1559
|
children != null ? children : computedChildren
|
package/dist/autocomplete.mjs
CHANGED
|
@@ -171,7 +171,6 @@ var Autocomplete = forwardRef2(
|
|
|
171
171
|
h != null ? h : h = height;
|
|
172
172
|
minH != null ? minH : minH = minHeight;
|
|
173
173
|
const css = {
|
|
174
|
-
position: "relative",
|
|
175
174
|
w: "100%",
|
|
176
175
|
h: "fit-content",
|
|
177
176
|
color,
|
|
@@ -195,16 +194,25 @@ var Autocomplete = forwardRef2(
|
|
|
195
194
|
__css: css,
|
|
196
195
|
...getContainerProps(containerProps),
|
|
197
196
|
children: [
|
|
198
|
-
/* @__PURE__ */
|
|
199
|
-
|
|
197
|
+
/* @__PURE__ */ jsxs(
|
|
198
|
+
ui2.div,
|
|
200
199
|
{
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
200
|
+
className: "ui-autocomplete__inner",
|
|
201
|
+
__css: { position: "relative", ...styles.inner },
|
|
202
|
+
children: [
|
|
203
|
+
/* @__PURE__ */ jsx2(
|
|
204
|
+
AutocompleteField,
|
|
205
|
+
{
|
|
206
|
+
h,
|
|
207
|
+
minH,
|
|
208
|
+
inputProps,
|
|
209
|
+
...getFieldProps({}, ref)
|
|
210
|
+
}
|
|
211
|
+
),
|
|
212
|
+
/* @__PURE__ */ jsx2(AutocompleteIcon, { ...iconProps, ...formControlProps })
|
|
213
|
+
]
|
|
205
214
|
}
|
|
206
215
|
),
|
|
207
|
-
/* @__PURE__ */ jsx2(AutocompleteIcon, { ...iconProps, ...formControlProps }),
|
|
208
216
|
!isEmpty ? /* @__PURE__ */ jsxs(AutocompleteList, { ...listProps, children: [
|
|
209
217
|
allowCreate ? /* @__PURE__ */ jsx2(AutocompleteCreate, {}) : /* @__PURE__ */ jsx2(AutocompleteEmpty, {}),
|
|
210
218
|
children != null ? children : computedChildren
|
|
@@ -491,7 +499,6 @@ var MultiAutocomplete = forwardRef7(
|
|
|
491
499
|
h != null ? h : h = height;
|
|
492
500
|
minH != null ? minH : minH = minHeight;
|
|
493
501
|
const css = {
|
|
494
|
-
position: "relative",
|
|
495
502
|
w: "100%",
|
|
496
503
|
h: "fit-content",
|
|
497
504
|
color,
|
|
@@ -512,30 +519,39 @@ var MultiAutocomplete = forwardRef7(
|
|
|
512
519
|
children: /* @__PURE__ */ jsx7(Popover2, { ...getPopoverProps(), children: /* @__PURE__ */ jsxs6(
|
|
513
520
|
ui7.div,
|
|
514
521
|
{
|
|
515
|
-
className: cx7("ui-autocomplete", className),
|
|
522
|
+
className: cx7("ui-multi-autocomplete", className),
|
|
516
523
|
__css: css,
|
|
517
524
|
...getContainerProps(containerProps),
|
|
518
525
|
children: [
|
|
519
|
-
/* @__PURE__ */
|
|
520
|
-
|
|
526
|
+
/* @__PURE__ */ jsxs6(
|
|
527
|
+
ui7.div,
|
|
521
528
|
{
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
+
className: "ui-multi-autocomplete__inner",
|
|
530
|
+
__css: { position: "relative", ...styles.inner },
|
|
531
|
+
children: [
|
|
532
|
+
/* @__PURE__ */ jsx7(
|
|
533
|
+
MultiAutocompleteField,
|
|
534
|
+
{
|
|
535
|
+
component,
|
|
536
|
+
separator,
|
|
537
|
+
keepPlaceholder,
|
|
538
|
+
h,
|
|
539
|
+
minH,
|
|
540
|
+
inputProps,
|
|
541
|
+
...getFieldProps({}, ref)
|
|
542
|
+
}
|
|
543
|
+
),
|
|
544
|
+
isClearable && value.length ? /* @__PURE__ */ jsx7(
|
|
545
|
+
AutocompleteClearIcon,
|
|
546
|
+
{
|
|
547
|
+
...clearIconProps,
|
|
548
|
+
onClick: handlerAll(clearIconProps == null ? void 0 : clearIconProps.onClick, onClear),
|
|
549
|
+
...formControlProps
|
|
550
|
+
}
|
|
551
|
+
) : /* @__PURE__ */ jsx7(AutocompleteIcon, { ...iconProps, ...formControlProps })
|
|
552
|
+
]
|
|
529
553
|
}
|
|
530
554
|
),
|
|
531
|
-
isClearable && value.length ? /* @__PURE__ */ jsx7(
|
|
532
|
-
AutocompleteClearIcon,
|
|
533
|
-
{
|
|
534
|
-
...clearIconProps,
|
|
535
|
-
onClick: handlerAll(clearIconProps == null ? void 0 : clearIconProps.onClick, onClear),
|
|
536
|
-
...formControlProps
|
|
537
|
-
}
|
|
538
|
-
) : /* @__PURE__ */ jsx7(AutocompleteIcon, { ...iconProps, ...formControlProps }),
|
|
539
555
|
!isEmpty ? /* @__PURE__ */ jsxs6(AutocompleteList, { ...listProps, children: [
|
|
540
556
|
allowCreate ? /* @__PURE__ */ jsx7(AutocompleteCreate, {}) : /* @__PURE__ */ jsx7(AutocompleteEmpty, {}),
|
|
541
557
|
children != null ? children : computedChildren
|
|
@@ -617,7 +633,7 @@ var MultiAutocompleteField = forwardRef7(
|
|
|
617
633
|
return /* @__PURE__ */ jsx7(PopoverTrigger2, { children: /* @__PURE__ */ jsxs6(
|
|
618
634
|
ui7.div,
|
|
619
635
|
{
|
|
620
|
-
className: cx7("ui-autocomplete__field", className),
|
|
636
|
+
className: cx7("ui-multi-autocomplete__field", className),
|
|
621
637
|
__css: css,
|
|
622
638
|
py: (displayValue == null ? void 0 : displayValue.length) && component ? "0.125rem" : void 0,
|
|
623
639
|
...rest,
|
|
@@ -626,7 +642,7 @@ var MultiAutocompleteField = forwardRef7(
|
|
|
626
642
|
/* @__PURE__ */ jsx7(
|
|
627
643
|
ui7.input,
|
|
628
644
|
{
|
|
629
|
-
className:
|
|
645
|
+
className: "ui-multi-autocomplete__field__input",
|
|
630
646
|
display: "inline-block",
|
|
631
647
|
flex: "1",
|
|
632
648
|
overflow: "hidden",
|
|
@@ -782,6 +798,7 @@ var useAutocomplete = ({
|
|
|
782
798
|
closeOnBlur = true,
|
|
783
799
|
closeOnEsc = true,
|
|
784
800
|
allowCreate = false,
|
|
801
|
+
allowFree = false,
|
|
785
802
|
insertPositionItem = "first",
|
|
786
803
|
emptyMessage = "No results found",
|
|
787
804
|
format = defaultFormat,
|
|
@@ -1069,6 +1086,10 @@ var useAutocomplete = ({
|
|
|
1069
1086
|
var _a;
|
|
1070
1087
|
return (_a = node.textContent) != null ? _a : "";
|
|
1071
1088
|
});
|
|
1089
|
+
if (allowFree && selectedValues2.length === 0) {
|
|
1090
|
+
selectedValues2.push(newValue);
|
|
1091
|
+
setInputValue("");
|
|
1092
|
+
}
|
|
1072
1093
|
setDisplayValue((prev) => {
|
|
1073
1094
|
if (!isMulti) {
|
|
1074
1095
|
return selectedValues2[0];
|
|
@@ -1085,7 +1106,7 @@ var useAutocomplete = ({
|
|
|
1085
1106
|
}
|
|
1086
1107
|
});
|
|
1087
1108
|
},
|
|
1088
|
-
[descendants, isMulti]
|
|
1109
|
+
[descendants, isMulti, allowFree]
|
|
1089
1110
|
);
|
|
1090
1111
|
const onChange = useCallback(
|
|
1091
1112
|
(newValue) => {
|
|
@@ -1101,11 +1122,26 @@ var useAutocomplete = ({
|
|
|
1101
1122
|
}
|
|
1102
1123
|
}
|
|
1103
1124
|
});
|
|
1125
|
+
const isHit2 = descendants.values().filter(
|
|
1126
|
+
({ node }) => {
|
|
1127
|
+
var _a;
|
|
1128
|
+
return format((_a = node.textContent) != null ? _a : "").includes(newValue);
|
|
1129
|
+
}
|
|
1130
|
+
).length > 0;
|
|
1104
1131
|
onChangeDisplayValue(newValue);
|
|
1105
|
-
|
|
1132
|
+
if (!allowFree || isHit2) {
|
|
1133
|
+
setInputValue("");
|
|
1134
|
+
}
|
|
1106
1135
|
rebirthOptions(false);
|
|
1107
1136
|
},
|
|
1108
|
-
[
|
|
1137
|
+
[
|
|
1138
|
+
allowFree,
|
|
1139
|
+
onChangeDisplayValue,
|
|
1140
|
+
rebirthOptions,
|
|
1141
|
+
setValue,
|
|
1142
|
+
descendants,
|
|
1143
|
+
format
|
|
1144
|
+
]
|
|
1109
1145
|
);
|
|
1110
1146
|
const onSelect = useCallback(() => {
|
|
1111
1147
|
var _a, _b;
|
|
@@ -1239,11 +1275,15 @@ var useAutocomplete = ({
|
|
|
1239
1275
|
return;
|
|
1240
1276
|
if (!closeOnBlur && isHit)
|
|
1241
1277
|
return;
|
|
1242
|
-
|
|
1278
|
+
if (allowFree && !!inputValue) {
|
|
1279
|
+
onChange(inputValue);
|
|
1280
|
+
} else {
|
|
1281
|
+
setInputValue("");
|
|
1282
|
+
}
|
|
1243
1283
|
if (isOpen)
|
|
1244
1284
|
onClose();
|
|
1245
1285
|
},
|
|
1246
|
-
[closeOnBlur, isHit, isOpen, onClose]
|
|
1286
|
+
[closeOnBlur, isHit, isOpen, inputValue, allowFree, onClose, onChange]
|
|
1247
1287
|
);
|
|
1248
1288
|
const onKeyDown = useCallback(
|
|
1249
1289
|
(ev) => {
|
|
@@ -1258,7 +1298,11 @@ var useAutocomplete = ({
|
|
|
1258
1298
|
ArrowDown: isFocused ? () => onFocusNext() : !isOpen ? funcAll(onOpen, onFocusFirstOrSelected) : void 0,
|
|
1259
1299
|
ArrowUp: isFocused ? () => onFocusPrev() : !isOpen ? funcAll(onOpen, onFocusLastOrSelected) : void 0,
|
|
1260
1300
|
Space: isCreate ? onCreate : isFocused ? onSelect : !isOpen ? funcAll(onOpen, onFocusFirstOrSelected) : void 0,
|
|
1261
|
-
Enter: isCreate ? onCreate : isFocused ? onSelect : !isOpen ? funcAll(onOpen, onFocusFirstOrSelected) :
|
|
1301
|
+
Enter: isCreate ? onCreate : isFocused ? onSelect : !isOpen ? funcAll(onOpen, onFocusFirstOrSelected) : allowFree && isMulti ? () => {
|
|
1302
|
+
if (inputValue)
|
|
1303
|
+
onChange(inputValue);
|
|
1304
|
+
setFocusedIndex(0);
|
|
1305
|
+
} : void 0,
|
|
1262
1306
|
Home: isOpen ? onFocusFirst : void 0,
|
|
1263
1307
|
End: isOpen ? onFocusLast : void 0,
|
|
1264
1308
|
Escape: closeOnEsc ? onClose : void 0,
|
|
@@ -1272,11 +1316,13 @@ var useAutocomplete = ({
|
|
|
1272
1316
|
action(ev);
|
|
1273
1317
|
},
|
|
1274
1318
|
[
|
|
1319
|
+
allowFree,
|
|
1275
1320
|
formControlProps,
|
|
1276
1321
|
displayValue,
|
|
1277
1322
|
inputValue,
|
|
1278
1323
|
onOpen,
|
|
1279
1324
|
isFocused,
|
|
1325
|
+
isMulti,
|
|
1280
1326
|
onFocusFirstOrSelected,
|
|
1281
1327
|
onFocusNext,
|
|
1282
1328
|
onFocusLastOrSelected,
|
|
@@ -1290,7 +1336,8 @@ var useAutocomplete = ({
|
|
|
1290
1336
|
closeOnEsc,
|
|
1291
1337
|
onClose,
|
|
1292
1338
|
isEmptyValue,
|
|
1293
|
-
onDelete
|
|
1339
|
+
onDelete,
|
|
1340
|
+
onChange
|
|
1294
1341
|
]
|
|
1295
1342
|
);
|
|
1296
1343
|
useEffect(() => {
|
|
@@ -1315,7 +1362,7 @@ var useAutocomplete = ({
|
|
|
1315
1362
|
maxSelectedValues
|
|
1316
1363
|
]);
|
|
1317
1364
|
useUpdateEffect(() => {
|
|
1318
|
-
if (isOpen)
|
|
1365
|
+
if (isOpen || allowFree)
|
|
1319
1366
|
return;
|
|
1320
1367
|
setFocusedIndex(-1);
|
|
1321
1368
|
setInputValue("");
|
|
@@ -1335,6 +1382,7 @@ var useAutocomplete = ({
|
|
|
1335
1382
|
});
|
|
1336
1383
|
const getPopoverProps = useCallback(
|
|
1337
1384
|
(props) => ({
|
|
1385
|
+
matchWidth: true,
|
|
1338
1386
|
...rest,
|
|
1339
1387
|
...props,
|
|
1340
1388
|
isOpen,
|
|
@@ -1385,6 +1433,7 @@ var useAutocomplete = ({
|
|
|
1385
1433
|
omitSelectedValues,
|
|
1386
1434
|
closeOnSelect,
|
|
1387
1435
|
allowCreate,
|
|
1436
|
+
allowFree,
|
|
1388
1437
|
emptyMessage,
|
|
1389
1438
|
isOpen,
|
|
1390
1439
|
isAllSelected,
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { Autocomplete, AutocompleteProps } from './autocomplete.mjs';
|
|
2
2
|
export { AutocompleteOptionGroup, AutocompleteOptionGroupProps } from './autocomplete-option-group.mjs';
|
|
3
|
-
export { b as AutocompleteItem, A as AutocompleteOption, a as AutocompleteOptionProps } from './use-autocomplete-
|
|
3
|
+
export { b as AutocompleteItem, A as AutocompleteOption, a as AutocompleteOptionProps } from './use-autocomplete-72ef1a50.js';
|
|
4
4
|
export { AutocompleteCreate, AutocompleteCreateProps } from './autocomplete-create.mjs';
|
|
5
5
|
export { AutocompleteEmpty, AutocompleteEmptyProps } from './autocomplete-empty.mjs';
|
|
6
6
|
export { MultiAutocomplete, MultiAutocompleteProps } from './multi-autocomplete.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { Autocomplete, AutocompleteProps } from './autocomplete.js';
|
|
2
2
|
export { AutocompleteOptionGroup, AutocompleteOptionGroupProps } from './autocomplete-option-group.js';
|
|
3
|
-
export { b as AutocompleteItem, A as AutocompleteOption, a as AutocompleteOptionProps } from './use-autocomplete-
|
|
3
|
+
export { b as AutocompleteItem, A as AutocompleteOption, a as AutocompleteOptionProps } from './use-autocomplete-72ef1a50.js';
|
|
4
4
|
export { AutocompleteCreate, AutocompleteCreateProps } from './autocomplete-create.js';
|
|
5
5
|
export { AutocompleteEmpty, AutocompleteEmptyProps } from './autocomplete-empty.js';
|
|
6
6
|
export { MultiAutocomplete, MultiAutocompleteProps } from './multi-autocomplete.js';
|