@yamada-ui/autocomplete 0.7.4 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +9 -1
- package/dist/autocomplete.d.ts +9 -1
- package/dist/autocomplete.js +41 -29
- package/dist/autocomplete.mjs +1 -1
- package/dist/{chunk-CIFWQ6SD.mjs → chunk-DZE2TDMF.mjs} +45 -31
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +45 -31
- package/dist/index.mjs +1 -1
- package/dist/multi-autocomplete.d.mts +9 -1
- package/dist/multi-autocomplete.d.ts +9 -1
- package/dist/multi-autocomplete.js +41 -29
- package/dist/multi-autocomplete.mjs +1 -1
- package/dist/{use-autocomplete-292DXnK-.d.mts → use-autocomplete-PdT_PKFf.d.mts} +2 -2
- package/dist/{use-autocomplete-292DXnK-.d.ts → use-autocomplete-PdT_PKFf.d.ts} +2 -2
- package/dist/use-autocomplete.d.mts +1 -1
- package/dist/use-autocomplete.d.ts +1 -1
- package/dist/use-autocomplete.js +37 -27
- package/dist/use-autocomplete.mjs +1 -1
- package/package.json +8 -7
|
@@ -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-PdT_PKFf.mjs';
|
|
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-PdT_PKFf.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-PdT_PKFf.mjs';
|
|
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-PdT_PKFf.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
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as _yamada_ui_core from '@yamada-ui/core';
|
|
2
2
|
import { ThemeProps, HTMLUIProps } from '@yamada-ui/core';
|
|
3
|
+
import { PortalProps } from '@yamada-ui/portal';
|
|
3
4
|
import { AutocompleteIconProps } from './autocomplete-icon.mjs';
|
|
4
5
|
import { AutocompleteListProps } from './autocomplete-list.mjs';
|
|
5
|
-
import { c as UseAutocompleteProps } from './use-autocomplete-
|
|
6
|
+
import { c as UseAutocompleteProps } from './use-autocomplete-PdT_PKFf.mjs';
|
|
6
7
|
import 'react';
|
|
7
8
|
import 'react/jsx-runtime';
|
|
8
9
|
import '@yamada-ui/form-control';
|
|
@@ -34,6 +35,13 @@ type AutocompleteOptions = {
|
|
|
34
35
|
* Props for autocomplete icon element.
|
|
35
36
|
*/
|
|
36
37
|
iconProps?: AutocompleteIconProps;
|
|
38
|
+
/**
|
|
39
|
+
* Props to be forwarded to the portal component.
|
|
40
|
+
*
|
|
41
|
+
* @default '{ isDisabled: true }'
|
|
42
|
+
*
|
|
43
|
+
*/
|
|
44
|
+
portalProps?: Omit<PortalProps, "children">;
|
|
37
45
|
};
|
|
38
46
|
type AutocompleteProps = ThemeProps<"Select"> & Omit<UseAutocompleteProps<string>, "maxSelectedValues" | "omitSelectedValues"> & AutocompleteOptions;
|
|
39
47
|
declare const Autocomplete: _yamada_ui_core.Component<"input", AutocompleteProps>;
|
package/dist/autocomplete.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as _yamada_ui_core from '@yamada-ui/core';
|
|
2
2
|
import { ThemeProps, HTMLUIProps } from '@yamada-ui/core';
|
|
3
|
+
import { PortalProps } from '@yamada-ui/portal';
|
|
3
4
|
import { AutocompleteIconProps } from './autocomplete-icon.js';
|
|
4
5
|
import { AutocompleteListProps } from './autocomplete-list.js';
|
|
5
|
-
import { c as UseAutocompleteProps } from './use-autocomplete-
|
|
6
|
+
import { c as UseAutocompleteProps } from './use-autocomplete-PdT_PKFf.js';
|
|
6
7
|
import 'react';
|
|
7
8
|
import 'react/jsx-runtime';
|
|
8
9
|
import '@yamada-ui/form-control';
|
|
@@ -34,6 +35,13 @@ type AutocompleteOptions = {
|
|
|
34
35
|
* Props for autocomplete icon element.
|
|
35
36
|
*/
|
|
36
37
|
iconProps?: AutocompleteIconProps;
|
|
38
|
+
/**
|
|
39
|
+
* Props to be forwarded to the portal component.
|
|
40
|
+
*
|
|
41
|
+
* @default '{ isDisabled: true }'
|
|
42
|
+
*
|
|
43
|
+
*/
|
|
44
|
+
portalProps?: Omit<PortalProps, "children">;
|
|
37
45
|
};
|
|
38
46
|
type AutocompleteProps = ThemeProps<"Select"> & Omit<UseAutocompleteProps<string>, "maxSelectedValues" | "omitSelectedValues"> & AutocompleteOptions;
|
|
39
47
|
declare const Autocomplete: _yamada_ui_core.Component<"input", AutocompleteProps>;
|
package/dist/autocomplete.js
CHANGED
|
@@ -26,6 +26,7 @@ __export(autocomplete_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(autocomplete_exports);
|
|
27
27
|
var import_core8 = require("@yamada-ui/core");
|
|
28
28
|
var import_popover3 = require("@yamada-ui/popover");
|
|
29
|
+
var import_portal = require("@yamada-ui/portal");
|
|
29
30
|
var import_utils8 = require("@yamada-ui/utils");
|
|
30
31
|
|
|
31
32
|
// src/autocomplete-icon.tsx
|
|
@@ -700,7 +701,7 @@ var useAutocomplete = ({
|
|
|
700
701
|
[descendants, isMulti, allowFree]
|
|
701
702
|
);
|
|
702
703
|
const onChange = (0, import_react.useCallback)(
|
|
703
|
-
(newValue) => {
|
|
704
|
+
(newValue, runRebirth = true) => {
|
|
704
705
|
setValue((prev) => {
|
|
705
706
|
if (!(0, import_utils6.isArray)(prev)) {
|
|
706
707
|
return newValue;
|
|
@@ -720,12 +721,20 @@ var useAutocomplete = ({
|
|
|
720
721
|
}
|
|
721
722
|
).length > 0;
|
|
722
723
|
onChangeLabel(newValue);
|
|
723
|
-
if (!allowFree || isHit2)
|
|
724
|
+
if (!allowFree || isHit2)
|
|
724
725
|
setInputValue("");
|
|
725
|
-
|
|
726
|
-
|
|
726
|
+
if (isMulti && runRebirth)
|
|
727
|
+
rebirthOptions(false);
|
|
727
728
|
},
|
|
728
|
-
[
|
|
729
|
+
[
|
|
730
|
+
allowFree,
|
|
731
|
+
isMulti,
|
|
732
|
+
onChangeLabel,
|
|
733
|
+
rebirthOptions,
|
|
734
|
+
setValue,
|
|
735
|
+
descendants,
|
|
736
|
+
format
|
|
737
|
+
]
|
|
729
738
|
);
|
|
730
739
|
const onSelect = (0, import_react.useCallback)(() => {
|
|
731
740
|
var _a, _b;
|
|
@@ -820,23 +829,6 @@ var useAutocomplete = ({
|
|
|
820
829
|
secondInsertPositionItem,
|
|
821
830
|
isMulti
|
|
822
831
|
]);
|
|
823
|
-
const onDelete = (0, import_react.useCallback)(() => {
|
|
824
|
-
if (!isMulti) {
|
|
825
|
-
onChange("");
|
|
826
|
-
} else {
|
|
827
|
-
onChange(value[value.length - 1]);
|
|
828
|
-
}
|
|
829
|
-
}, [isMulti, onChange, value]);
|
|
830
|
-
const onClear = (0, import_react.useCallback)(
|
|
831
|
-
(ev) => {
|
|
832
|
-
ev.stopPropagation();
|
|
833
|
-
setValue([]);
|
|
834
|
-
setLabel(void 0);
|
|
835
|
-
setInputValue("");
|
|
836
|
-
rebirthOptions();
|
|
837
|
-
},
|
|
838
|
-
[setLabel, setInputValue, setValue, rebirthOptions]
|
|
839
|
-
);
|
|
840
832
|
const onClick = (0, import_react.useCallback)(() => {
|
|
841
833
|
if (isOpen) {
|
|
842
834
|
if (inputRef.current)
|
|
@@ -859,16 +851,35 @@ var useAutocomplete = ({
|
|
|
859
851
|
return;
|
|
860
852
|
if (!closeOnBlur && isHit)
|
|
861
853
|
return;
|
|
862
|
-
if (allowFree && !!inputValue)
|
|
863
|
-
onChange(inputValue);
|
|
864
|
-
|
|
865
|
-
setInputValue("");
|
|
866
|
-
}
|
|
854
|
+
if (allowFree && !!inputValue)
|
|
855
|
+
onChange(inputValue, false);
|
|
856
|
+
setInputValue("");
|
|
867
857
|
if (isOpen)
|
|
868
858
|
onClose();
|
|
869
859
|
},
|
|
870
860
|
[closeOnBlur, isHit, isOpen, inputValue, allowFree, onClose, onChange]
|
|
871
861
|
);
|
|
862
|
+
const onDelete = (0, import_react.useCallback)(() => {
|
|
863
|
+
if (!isMulti) {
|
|
864
|
+
onChange("");
|
|
865
|
+
} else {
|
|
866
|
+
onChange(value[value.length - 1]);
|
|
867
|
+
}
|
|
868
|
+
if (!isOpen)
|
|
869
|
+
onFocus();
|
|
870
|
+
}, [isMulti, isOpen, onChange, onFocus, value]);
|
|
871
|
+
const onClear = (0, import_react.useCallback)(
|
|
872
|
+
(ev) => {
|
|
873
|
+
ev.stopPropagation();
|
|
874
|
+
setValue([]);
|
|
875
|
+
setLabel(void 0);
|
|
876
|
+
setInputValue("");
|
|
877
|
+
rebirthOptions();
|
|
878
|
+
if (isOpen && inputRef.current)
|
|
879
|
+
inputRef.current.focus();
|
|
880
|
+
},
|
|
881
|
+
[isOpen, setLabel, setInputValue, setValue, rebirthOptions]
|
|
882
|
+
);
|
|
872
883
|
const onKeyDown = (0, import_react.useCallback)(
|
|
873
884
|
(ev) => {
|
|
874
885
|
if (ev.key === " ")
|
|
@@ -1487,6 +1498,7 @@ var Autocomplete = (0, import_core8.forwardRef)(
|
|
|
1487
1498
|
listProps,
|
|
1488
1499
|
inputProps,
|
|
1489
1500
|
iconProps,
|
|
1501
|
+
portalProps = { isDisabled: false },
|
|
1490
1502
|
children,
|
|
1491
1503
|
...computedProps
|
|
1492
1504
|
} = (0, import_core8.omitThemeProps)(mergedProps);
|
|
@@ -1547,10 +1559,10 @@ var Autocomplete = (0, import_core8.forwardRef)(
|
|
|
1547
1559
|
]
|
|
1548
1560
|
}
|
|
1549
1561
|
),
|
|
1550
|
-
!isEmpty ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(AutocompleteList, { ...listProps, children: [
|
|
1562
|
+
!isEmpty ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_portal.Portal, { ...portalProps, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(AutocompleteList, { ...listProps, children: [
|
|
1551
1563
|
allowCreate ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteCreate, {}) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteEmpty, {}),
|
|
1552
1564
|
children != null ? children : computedChildren
|
|
1553
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteList, { ...listProps, children: allowCreate && inputValue ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteCreate, {}) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteEmpty, {}) })
|
|
1565
|
+
] }) }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_portal.Portal, { ...portalProps, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteList, { ...listProps, children: allowCreate && inputValue ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteCreate, {}) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteEmpty, {}) }) })
|
|
1554
1566
|
]
|
|
1555
1567
|
}
|
|
1556
1568
|
) })
|
package/dist/autocomplete.mjs
CHANGED
|
@@ -44,6 +44,7 @@ import {
|
|
|
44
44
|
omitThemeProps
|
|
45
45
|
} from "@yamada-ui/core";
|
|
46
46
|
import { Popover, PopoverTrigger } from "@yamada-ui/popover";
|
|
47
|
+
import { Portal } from "@yamada-ui/portal";
|
|
47
48
|
import { cx as cx2 } from "@yamada-ui/utils";
|
|
48
49
|
|
|
49
50
|
// src/autocomplete-icon.tsx
|
|
@@ -153,6 +154,7 @@ var Autocomplete = forwardRef2(
|
|
|
153
154
|
listProps,
|
|
154
155
|
inputProps,
|
|
155
156
|
iconProps,
|
|
157
|
+
portalProps = { isDisabled: false },
|
|
156
158
|
children,
|
|
157
159
|
...computedProps
|
|
158
160
|
} = omitThemeProps(mergedProps);
|
|
@@ -213,10 +215,10 @@ var Autocomplete = forwardRef2(
|
|
|
213
215
|
]
|
|
214
216
|
}
|
|
215
217
|
),
|
|
216
|
-
!isEmpty ? /* @__PURE__ */ jsxs(AutocompleteList, { ...listProps, children: [
|
|
218
|
+
!isEmpty ? /* @__PURE__ */ jsx2(Portal, { ...portalProps, children: /* @__PURE__ */ jsxs(AutocompleteList, { ...listProps, children: [
|
|
217
219
|
allowCreate ? /* @__PURE__ */ jsx2(AutocompleteCreate, {}) : /* @__PURE__ */ jsx2(AutocompleteEmpty, {}),
|
|
218
220
|
children != null ? children : computedChildren
|
|
219
|
-
] }) : /* @__PURE__ */ jsx2(AutocompleteList, { ...listProps, children: allowCreate && inputValue ? /* @__PURE__ */ jsx2(AutocompleteCreate, {}) : /* @__PURE__ */ jsx2(AutocompleteEmpty, {}) })
|
|
221
|
+
] }) }) : /* @__PURE__ */ jsx2(Portal, { ...portalProps, children: /* @__PURE__ */ jsx2(AutocompleteList, { ...listProps, children: allowCreate && inputValue ? /* @__PURE__ */ jsx2(AutocompleteCreate, {}) : /* @__PURE__ */ jsx2(AutocompleteEmpty, {}) }) })
|
|
220
222
|
]
|
|
221
223
|
}
|
|
222
224
|
) })
|
|
@@ -447,6 +449,7 @@ import {
|
|
|
447
449
|
omitThemeProps as omitThemeProps2
|
|
448
450
|
} from "@yamada-ui/core";
|
|
449
451
|
import { Popover as Popover2, PopoverTrigger as PopoverTrigger2 } from "@yamada-ui/popover";
|
|
452
|
+
import { Portal as Portal2 } from "@yamada-ui/portal";
|
|
450
453
|
import { cx as cx7, handlerAll } from "@yamada-ui/utils";
|
|
451
454
|
import { cloneElement as cloneElement2, useMemo } from "react";
|
|
452
455
|
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
@@ -474,6 +477,7 @@ var MultiAutocomplete = forwardRef7(
|
|
|
474
477
|
inputProps,
|
|
475
478
|
iconProps,
|
|
476
479
|
clearIconProps,
|
|
480
|
+
portalProps = { isDisabled: false },
|
|
477
481
|
children,
|
|
478
482
|
...computedProps
|
|
479
483
|
} = omitThemeProps2(mergedProps);
|
|
@@ -552,10 +556,10 @@ var MultiAutocomplete = forwardRef7(
|
|
|
552
556
|
]
|
|
553
557
|
}
|
|
554
558
|
),
|
|
555
|
-
!isEmpty ? /* @__PURE__ */ jsxs6(AutocompleteList, { ...listProps, children: [
|
|
559
|
+
!isEmpty ? /* @__PURE__ */ jsx7(Portal2, { ...portalProps, children: /* @__PURE__ */ jsxs6(AutocompleteList, { ...listProps, children: [
|
|
556
560
|
allowCreate ? /* @__PURE__ */ jsx7(AutocompleteCreate, {}) : /* @__PURE__ */ jsx7(AutocompleteEmpty, {}),
|
|
557
561
|
children != null ? children : computedChildren
|
|
558
|
-
] }) : /* @__PURE__ */ jsx7(AutocompleteList, { ...listProps, children: allowCreate && inputValue ? /* @__PURE__ */ jsx7(AutocompleteCreate, {}) : /* @__PURE__ */ jsx7(AutocompleteEmpty, {}) })
|
|
562
|
+
] }) }) : /* @__PURE__ */ jsx7(Portal2, { ...portalProps, children: /* @__PURE__ */ jsx7(AutocompleteList, { ...listProps, children: allowCreate && inputValue ? /* @__PURE__ */ jsx7(AutocompleteCreate, {}) : /* @__PURE__ */ jsx7(AutocompleteEmpty, {}) }) })
|
|
559
563
|
]
|
|
560
564
|
}
|
|
561
565
|
) })
|
|
@@ -1101,7 +1105,7 @@ var useAutocomplete = ({
|
|
|
1101
1105
|
[descendants, isMulti, allowFree]
|
|
1102
1106
|
);
|
|
1103
1107
|
const onChange = useCallback(
|
|
1104
|
-
(newValue) => {
|
|
1108
|
+
(newValue, runRebirth = true) => {
|
|
1105
1109
|
setValue((prev) => {
|
|
1106
1110
|
if (!isArray(prev)) {
|
|
1107
1111
|
return newValue;
|
|
@@ -1121,12 +1125,20 @@ var useAutocomplete = ({
|
|
|
1121
1125
|
}
|
|
1122
1126
|
).length > 0;
|
|
1123
1127
|
onChangeLabel(newValue);
|
|
1124
|
-
if (!allowFree || isHit2)
|
|
1128
|
+
if (!allowFree || isHit2)
|
|
1125
1129
|
setInputValue("");
|
|
1126
|
-
|
|
1127
|
-
|
|
1130
|
+
if (isMulti && runRebirth)
|
|
1131
|
+
rebirthOptions(false);
|
|
1128
1132
|
},
|
|
1129
|
-
[
|
|
1133
|
+
[
|
|
1134
|
+
allowFree,
|
|
1135
|
+
isMulti,
|
|
1136
|
+
onChangeLabel,
|
|
1137
|
+
rebirthOptions,
|
|
1138
|
+
setValue,
|
|
1139
|
+
descendants,
|
|
1140
|
+
format
|
|
1141
|
+
]
|
|
1130
1142
|
);
|
|
1131
1143
|
const onSelect = useCallback(() => {
|
|
1132
1144
|
var _a, _b;
|
|
@@ -1221,23 +1233,6 @@ var useAutocomplete = ({
|
|
|
1221
1233
|
secondInsertPositionItem,
|
|
1222
1234
|
isMulti
|
|
1223
1235
|
]);
|
|
1224
|
-
const onDelete = useCallback(() => {
|
|
1225
|
-
if (!isMulti) {
|
|
1226
|
-
onChange("");
|
|
1227
|
-
} else {
|
|
1228
|
-
onChange(value[value.length - 1]);
|
|
1229
|
-
}
|
|
1230
|
-
}, [isMulti, onChange, value]);
|
|
1231
|
-
const onClear = useCallback(
|
|
1232
|
-
(ev) => {
|
|
1233
|
-
ev.stopPropagation();
|
|
1234
|
-
setValue([]);
|
|
1235
|
-
setLabel(void 0);
|
|
1236
|
-
setInputValue("");
|
|
1237
|
-
rebirthOptions();
|
|
1238
|
-
},
|
|
1239
|
-
[setLabel, setInputValue, setValue, rebirthOptions]
|
|
1240
|
-
);
|
|
1241
1236
|
const onClick = useCallback(() => {
|
|
1242
1237
|
if (isOpen) {
|
|
1243
1238
|
if (inputRef.current)
|
|
@@ -1260,16 +1255,35 @@ var useAutocomplete = ({
|
|
|
1260
1255
|
return;
|
|
1261
1256
|
if (!closeOnBlur && isHit)
|
|
1262
1257
|
return;
|
|
1263
|
-
if (allowFree && !!inputValue)
|
|
1264
|
-
onChange(inputValue);
|
|
1265
|
-
|
|
1266
|
-
setInputValue("");
|
|
1267
|
-
}
|
|
1258
|
+
if (allowFree && !!inputValue)
|
|
1259
|
+
onChange(inputValue, false);
|
|
1260
|
+
setInputValue("");
|
|
1268
1261
|
if (isOpen)
|
|
1269
1262
|
onClose();
|
|
1270
1263
|
},
|
|
1271
1264
|
[closeOnBlur, isHit, isOpen, inputValue, allowFree, onClose, onChange]
|
|
1272
1265
|
);
|
|
1266
|
+
const onDelete = useCallback(() => {
|
|
1267
|
+
if (!isMulti) {
|
|
1268
|
+
onChange("");
|
|
1269
|
+
} else {
|
|
1270
|
+
onChange(value[value.length - 1]);
|
|
1271
|
+
}
|
|
1272
|
+
if (!isOpen)
|
|
1273
|
+
onFocus();
|
|
1274
|
+
}, [isMulti, isOpen, onChange, onFocus, value]);
|
|
1275
|
+
const onClear = useCallback(
|
|
1276
|
+
(ev) => {
|
|
1277
|
+
ev.stopPropagation();
|
|
1278
|
+
setValue([]);
|
|
1279
|
+
setLabel(void 0);
|
|
1280
|
+
setInputValue("");
|
|
1281
|
+
rebirthOptions();
|
|
1282
|
+
if (isOpen && inputRef.current)
|
|
1283
|
+
inputRef.current.focus();
|
|
1284
|
+
},
|
|
1285
|
+
[isOpen, setLabel, setInputValue, setValue, rebirthOptions]
|
|
1286
|
+
);
|
|
1273
1287
|
const onKeyDown = useCallback(
|
|
1274
1288
|
(ev) => {
|
|
1275
1289
|
if (ev.key === " ")
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
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-PdT_PKFf.mjs';
|
|
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';
|
|
7
7
|
import '@yamada-ui/core';
|
|
8
|
+
import '@yamada-ui/portal';
|
|
8
9
|
import './autocomplete-icon.mjs';
|
|
9
10
|
import 'react';
|
|
10
11
|
import './autocomplete-list.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
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-PdT_PKFf.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';
|
|
7
7
|
import '@yamada-ui/core';
|
|
8
|
+
import '@yamada-ui/portal';
|
|
8
9
|
import './autocomplete-icon.js';
|
|
9
10
|
import 'react';
|
|
10
11
|
import './autocomplete-list.js';
|
package/dist/index.js
CHANGED
|
@@ -33,6 +33,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
33
33
|
// src/autocomplete.tsx
|
|
34
34
|
var import_core4 = require("@yamada-ui/core");
|
|
35
35
|
var import_popover3 = require("@yamada-ui/popover");
|
|
36
|
+
var import_portal = require("@yamada-ui/portal");
|
|
36
37
|
var import_utils4 = require("@yamada-ui/utils");
|
|
37
38
|
|
|
38
39
|
// src/autocomplete-icon.tsx
|
|
@@ -501,7 +502,7 @@ var useAutocomplete = ({
|
|
|
501
502
|
[descendants, isMulti, allowFree]
|
|
502
503
|
);
|
|
503
504
|
const onChange = (0, import_react.useCallback)(
|
|
504
|
-
(newValue) => {
|
|
505
|
+
(newValue, runRebirth = true) => {
|
|
505
506
|
setValue((prev) => {
|
|
506
507
|
if (!(0, import_utils.isArray)(prev)) {
|
|
507
508
|
return newValue;
|
|
@@ -521,12 +522,20 @@ var useAutocomplete = ({
|
|
|
521
522
|
}
|
|
522
523
|
).length > 0;
|
|
523
524
|
onChangeLabel(newValue);
|
|
524
|
-
if (!allowFree || isHit2)
|
|
525
|
+
if (!allowFree || isHit2)
|
|
525
526
|
setInputValue("");
|
|
526
|
-
|
|
527
|
-
|
|
527
|
+
if (isMulti && runRebirth)
|
|
528
|
+
rebirthOptions(false);
|
|
528
529
|
},
|
|
529
|
-
[
|
|
530
|
+
[
|
|
531
|
+
allowFree,
|
|
532
|
+
isMulti,
|
|
533
|
+
onChangeLabel,
|
|
534
|
+
rebirthOptions,
|
|
535
|
+
setValue,
|
|
536
|
+
descendants,
|
|
537
|
+
format
|
|
538
|
+
]
|
|
530
539
|
);
|
|
531
540
|
const onSelect = (0, import_react.useCallback)(() => {
|
|
532
541
|
var _a, _b;
|
|
@@ -621,23 +630,6 @@ var useAutocomplete = ({
|
|
|
621
630
|
secondInsertPositionItem,
|
|
622
631
|
isMulti
|
|
623
632
|
]);
|
|
624
|
-
const onDelete = (0, import_react.useCallback)(() => {
|
|
625
|
-
if (!isMulti) {
|
|
626
|
-
onChange("");
|
|
627
|
-
} else {
|
|
628
|
-
onChange(value[value.length - 1]);
|
|
629
|
-
}
|
|
630
|
-
}, [isMulti, onChange, value]);
|
|
631
|
-
const onClear = (0, import_react.useCallback)(
|
|
632
|
-
(ev) => {
|
|
633
|
-
ev.stopPropagation();
|
|
634
|
-
setValue([]);
|
|
635
|
-
setLabel(void 0);
|
|
636
|
-
setInputValue("");
|
|
637
|
-
rebirthOptions();
|
|
638
|
-
},
|
|
639
|
-
[setLabel, setInputValue, setValue, rebirthOptions]
|
|
640
|
-
);
|
|
641
633
|
const onClick = (0, import_react.useCallback)(() => {
|
|
642
634
|
if (isOpen) {
|
|
643
635
|
if (inputRef.current)
|
|
@@ -660,16 +652,35 @@ var useAutocomplete = ({
|
|
|
660
652
|
return;
|
|
661
653
|
if (!closeOnBlur && isHit)
|
|
662
654
|
return;
|
|
663
|
-
if (allowFree && !!inputValue)
|
|
664
|
-
onChange(inputValue);
|
|
665
|
-
|
|
666
|
-
setInputValue("");
|
|
667
|
-
}
|
|
655
|
+
if (allowFree && !!inputValue)
|
|
656
|
+
onChange(inputValue, false);
|
|
657
|
+
setInputValue("");
|
|
668
658
|
if (isOpen)
|
|
669
659
|
onClose();
|
|
670
660
|
},
|
|
671
661
|
[closeOnBlur, isHit, isOpen, inputValue, allowFree, onClose, onChange]
|
|
672
662
|
);
|
|
663
|
+
const onDelete = (0, import_react.useCallback)(() => {
|
|
664
|
+
if (!isMulti) {
|
|
665
|
+
onChange("");
|
|
666
|
+
} else {
|
|
667
|
+
onChange(value[value.length - 1]);
|
|
668
|
+
}
|
|
669
|
+
if (!isOpen)
|
|
670
|
+
onFocus();
|
|
671
|
+
}, [isMulti, isOpen, onChange, onFocus, value]);
|
|
672
|
+
const onClear = (0, import_react.useCallback)(
|
|
673
|
+
(ev) => {
|
|
674
|
+
ev.stopPropagation();
|
|
675
|
+
setValue([]);
|
|
676
|
+
setLabel(void 0);
|
|
677
|
+
setInputValue("");
|
|
678
|
+
rebirthOptions();
|
|
679
|
+
if (isOpen && inputRef.current)
|
|
680
|
+
inputRef.current.focus();
|
|
681
|
+
},
|
|
682
|
+
[isOpen, setLabel, setInputValue, setValue, rebirthOptions]
|
|
683
|
+
);
|
|
673
684
|
const onKeyDown = (0, import_react.useCallback)(
|
|
674
685
|
(ev) => {
|
|
675
686
|
if (ev.key === " ")
|
|
@@ -1337,6 +1348,7 @@ var Autocomplete = (0, import_core4.forwardRef)(
|
|
|
1337
1348
|
listProps,
|
|
1338
1349
|
inputProps,
|
|
1339
1350
|
iconProps,
|
|
1351
|
+
portalProps = { isDisabled: false },
|
|
1340
1352
|
children,
|
|
1341
1353
|
...computedProps
|
|
1342
1354
|
} = (0, import_core4.omitThemeProps)(mergedProps);
|
|
@@ -1397,10 +1409,10 @@ var Autocomplete = (0, import_core4.forwardRef)(
|
|
|
1397
1409
|
]
|
|
1398
1410
|
}
|
|
1399
1411
|
),
|
|
1400
|
-
!isEmpty ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(AutocompleteList, { ...listProps, children: [
|
|
1412
|
+
!isEmpty ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_portal.Portal, { ...portalProps, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(AutocompleteList, { ...listProps, children: [
|
|
1401
1413
|
allowCreate ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AutocompleteCreate, {}) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AutocompleteEmpty, {}),
|
|
1402
1414
|
children != null ? children : computedChildren
|
|
1403
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AutocompleteList, { ...listProps, children: allowCreate && inputValue ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AutocompleteCreate, {}) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AutocompleteEmpty, {}) })
|
|
1415
|
+
] }) }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_portal.Portal, { ...portalProps, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AutocompleteList, { ...listProps, children: allowCreate && inputValue ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AutocompleteCreate, {}) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AutocompleteEmpty, {}) }) })
|
|
1404
1416
|
]
|
|
1405
1417
|
}
|
|
1406
1418
|
) })
|
|
@@ -1626,6 +1638,7 @@ var MinusIcon = () => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("svg", { view
|
|
|
1626
1638
|
// src/multi-autocomplete.tsx
|
|
1627
1639
|
var import_core9 = require("@yamada-ui/core");
|
|
1628
1640
|
var import_popover4 = require("@yamada-ui/popover");
|
|
1641
|
+
var import_portal2 = require("@yamada-ui/portal");
|
|
1629
1642
|
var import_utils9 = require("@yamada-ui/utils");
|
|
1630
1643
|
var import_react3 = require("react");
|
|
1631
1644
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
@@ -1653,6 +1666,7 @@ var MultiAutocomplete = (0, import_core9.forwardRef)(
|
|
|
1653
1666
|
inputProps,
|
|
1654
1667
|
iconProps,
|
|
1655
1668
|
clearIconProps,
|
|
1669
|
+
portalProps = { isDisabled: false },
|
|
1656
1670
|
children,
|
|
1657
1671
|
...computedProps
|
|
1658
1672
|
} = (0, import_core9.omitThemeProps)(mergedProps);
|
|
@@ -1731,10 +1745,10 @@ var MultiAutocomplete = (0, import_core9.forwardRef)(
|
|
|
1731
1745
|
]
|
|
1732
1746
|
}
|
|
1733
1747
|
),
|
|
1734
|
-
!isEmpty ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(AutocompleteList, { ...listProps, children: [
|
|
1748
|
+
!isEmpty ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_portal2.Portal, { ...portalProps, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(AutocompleteList, { ...listProps, children: [
|
|
1735
1749
|
allowCreate ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AutocompleteCreate, {}) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AutocompleteEmpty, {}),
|
|
1736
1750
|
children != null ? children : computedChildren
|
|
1737
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AutocompleteList, { ...listProps, children: allowCreate && inputValue ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AutocompleteCreate, {}) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AutocompleteEmpty, {}) })
|
|
1751
|
+
] }) }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_portal2.Portal, { ...portalProps, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AutocompleteList, { ...listProps, children: allowCreate && inputValue ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AutocompleteCreate, {}) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AutocompleteEmpty, {}) }) })
|
|
1738
1752
|
]
|
|
1739
1753
|
}
|
|
1740
1754
|
) })
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as _yamada_ui_core from '@yamada-ui/core';
|
|
2
2
|
import { ThemeProps, HTMLUIProps } from '@yamada-ui/core';
|
|
3
|
+
import { PortalProps } from '@yamada-ui/portal';
|
|
3
4
|
import { FC, MouseEventHandler } from 'react';
|
|
4
5
|
import { AutocompleteIconProps } from './autocomplete-icon.mjs';
|
|
5
6
|
import { AutocompleteListProps } from './autocomplete-list.mjs';
|
|
6
|
-
import { c as UseAutocompleteProps } from './use-autocomplete-
|
|
7
|
+
import { c as UseAutocompleteProps } from './use-autocomplete-PdT_PKFf.mjs';
|
|
7
8
|
import 'react/jsx-runtime';
|
|
8
9
|
import '@yamada-ui/form-control';
|
|
9
10
|
import '@yamada-ui/popover';
|
|
@@ -65,6 +66,13 @@ type MultiAutocompleteOptions = {
|
|
|
65
66
|
* Props for multi autocomplete clear icon element.
|
|
66
67
|
*/
|
|
67
68
|
clearIconProps?: AutocompleteIconProps;
|
|
69
|
+
/**
|
|
70
|
+
* Props to be forwarded to the portal component.
|
|
71
|
+
*
|
|
72
|
+
* @default '{ isDisabled: true }'
|
|
73
|
+
*
|
|
74
|
+
*/
|
|
75
|
+
portalProps?: Omit<PortalProps, "children">;
|
|
68
76
|
};
|
|
69
77
|
type MultiAutocompleteProps = ThemeProps<"Select"> & UseAutocompleteProps<string[]> & MultiAutocompleteOptions;
|
|
70
78
|
declare const MultiAutocomplete: _yamada_ui_core.Component<"div", MultiAutocompleteProps>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as _yamada_ui_core from '@yamada-ui/core';
|
|
2
2
|
import { ThemeProps, HTMLUIProps } from '@yamada-ui/core';
|
|
3
|
+
import { PortalProps } from '@yamada-ui/portal';
|
|
3
4
|
import { FC, MouseEventHandler } from 'react';
|
|
4
5
|
import { AutocompleteIconProps } from './autocomplete-icon.js';
|
|
5
6
|
import { AutocompleteListProps } from './autocomplete-list.js';
|
|
6
|
-
import { c as UseAutocompleteProps } from './use-autocomplete-
|
|
7
|
+
import { c as UseAutocompleteProps } from './use-autocomplete-PdT_PKFf.js';
|
|
7
8
|
import 'react/jsx-runtime';
|
|
8
9
|
import '@yamada-ui/form-control';
|
|
9
10
|
import '@yamada-ui/popover';
|
|
@@ -65,6 +66,13 @@ type MultiAutocompleteOptions = {
|
|
|
65
66
|
* Props for multi autocomplete clear icon element.
|
|
66
67
|
*/
|
|
67
68
|
clearIconProps?: AutocompleteIconProps;
|
|
69
|
+
/**
|
|
70
|
+
* Props to be forwarded to the portal component.
|
|
71
|
+
*
|
|
72
|
+
* @default '{ isDisabled: true }'
|
|
73
|
+
*
|
|
74
|
+
*/
|
|
75
|
+
portalProps?: Omit<PortalProps, "children">;
|
|
68
76
|
};
|
|
69
77
|
type MultiAutocompleteProps = ThemeProps<"Select"> & UseAutocompleteProps<string[]> & MultiAutocompleteOptions;
|
|
70
78
|
declare const MultiAutocomplete: _yamada_ui_core.Component<"div", MultiAutocompleteProps>;
|
|
@@ -26,6 +26,7 @@ __export(multi_autocomplete_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(multi_autocomplete_exports);
|
|
27
27
|
var import_core8 = require("@yamada-ui/core");
|
|
28
28
|
var import_popover3 = require("@yamada-ui/popover");
|
|
29
|
+
var import_portal = require("@yamada-ui/portal");
|
|
29
30
|
var import_utils8 = require("@yamada-ui/utils");
|
|
30
31
|
var import_react3 = require("react");
|
|
31
32
|
|
|
@@ -701,7 +702,7 @@ var useAutocomplete = ({
|
|
|
701
702
|
[descendants, isMulti, allowFree]
|
|
702
703
|
);
|
|
703
704
|
const onChange = (0, import_react.useCallback)(
|
|
704
|
-
(newValue) => {
|
|
705
|
+
(newValue, runRebirth = true) => {
|
|
705
706
|
setValue((prev) => {
|
|
706
707
|
if (!(0, import_utils6.isArray)(prev)) {
|
|
707
708
|
return newValue;
|
|
@@ -721,12 +722,20 @@ var useAutocomplete = ({
|
|
|
721
722
|
}
|
|
722
723
|
).length > 0;
|
|
723
724
|
onChangeLabel(newValue);
|
|
724
|
-
if (!allowFree || isHit2)
|
|
725
|
+
if (!allowFree || isHit2)
|
|
725
726
|
setInputValue("");
|
|
726
|
-
|
|
727
|
-
|
|
727
|
+
if (isMulti && runRebirth)
|
|
728
|
+
rebirthOptions(false);
|
|
728
729
|
},
|
|
729
|
-
[
|
|
730
|
+
[
|
|
731
|
+
allowFree,
|
|
732
|
+
isMulti,
|
|
733
|
+
onChangeLabel,
|
|
734
|
+
rebirthOptions,
|
|
735
|
+
setValue,
|
|
736
|
+
descendants,
|
|
737
|
+
format
|
|
738
|
+
]
|
|
730
739
|
);
|
|
731
740
|
const onSelect = (0, import_react.useCallback)(() => {
|
|
732
741
|
var _a, _b;
|
|
@@ -821,23 +830,6 @@ var useAutocomplete = ({
|
|
|
821
830
|
secondInsertPositionItem,
|
|
822
831
|
isMulti
|
|
823
832
|
]);
|
|
824
|
-
const onDelete = (0, import_react.useCallback)(() => {
|
|
825
|
-
if (!isMulti) {
|
|
826
|
-
onChange("");
|
|
827
|
-
} else {
|
|
828
|
-
onChange(value[value.length - 1]);
|
|
829
|
-
}
|
|
830
|
-
}, [isMulti, onChange, value]);
|
|
831
|
-
const onClear = (0, import_react.useCallback)(
|
|
832
|
-
(ev) => {
|
|
833
|
-
ev.stopPropagation();
|
|
834
|
-
setValue([]);
|
|
835
|
-
setLabel(void 0);
|
|
836
|
-
setInputValue("");
|
|
837
|
-
rebirthOptions();
|
|
838
|
-
},
|
|
839
|
-
[setLabel, setInputValue, setValue, rebirthOptions]
|
|
840
|
-
);
|
|
841
833
|
const onClick = (0, import_react.useCallback)(() => {
|
|
842
834
|
if (isOpen) {
|
|
843
835
|
if (inputRef.current)
|
|
@@ -860,16 +852,35 @@ var useAutocomplete = ({
|
|
|
860
852
|
return;
|
|
861
853
|
if (!closeOnBlur && isHit)
|
|
862
854
|
return;
|
|
863
|
-
if (allowFree && !!inputValue)
|
|
864
|
-
onChange(inputValue);
|
|
865
|
-
|
|
866
|
-
setInputValue("");
|
|
867
|
-
}
|
|
855
|
+
if (allowFree && !!inputValue)
|
|
856
|
+
onChange(inputValue, false);
|
|
857
|
+
setInputValue("");
|
|
868
858
|
if (isOpen)
|
|
869
859
|
onClose();
|
|
870
860
|
},
|
|
871
861
|
[closeOnBlur, isHit, isOpen, inputValue, allowFree, onClose, onChange]
|
|
872
862
|
);
|
|
863
|
+
const onDelete = (0, import_react.useCallback)(() => {
|
|
864
|
+
if (!isMulti) {
|
|
865
|
+
onChange("");
|
|
866
|
+
} else {
|
|
867
|
+
onChange(value[value.length - 1]);
|
|
868
|
+
}
|
|
869
|
+
if (!isOpen)
|
|
870
|
+
onFocus();
|
|
871
|
+
}, [isMulti, isOpen, onChange, onFocus, value]);
|
|
872
|
+
const onClear = (0, import_react.useCallback)(
|
|
873
|
+
(ev) => {
|
|
874
|
+
ev.stopPropagation();
|
|
875
|
+
setValue([]);
|
|
876
|
+
setLabel(void 0);
|
|
877
|
+
setInputValue("");
|
|
878
|
+
rebirthOptions();
|
|
879
|
+
if (isOpen && inputRef.current)
|
|
880
|
+
inputRef.current.focus();
|
|
881
|
+
},
|
|
882
|
+
[isOpen, setLabel, setInputValue, setValue, rebirthOptions]
|
|
883
|
+
);
|
|
873
884
|
const onKeyDown = (0, import_react.useCallback)(
|
|
874
885
|
(ev) => {
|
|
875
886
|
if (ev.key === " ")
|
|
@@ -1520,6 +1531,7 @@ var MultiAutocomplete = (0, import_core8.forwardRef)(
|
|
|
1520
1531
|
inputProps,
|
|
1521
1532
|
iconProps,
|
|
1522
1533
|
clearIconProps,
|
|
1534
|
+
portalProps = { isDisabled: false },
|
|
1523
1535
|
children,
|
|
1524
1536
|
...computedProps
|
|
1525
1537
|
} = (0, import_core8.omitThemeProps)(mergedProps);
|
|
@@ -1598,10 +1610,10 @@ var MultiAutocomplete = (0, import_core8.forwardRef)(
|
|
|
1598
1610
|
]
|
|
1599
1611
|
}
|
|
1600
1612
|
),
|
|
1601
|
-
!isEmpty ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(AutocompleteList, { ...listProps, children: [
|
|
1613
|
+
!isEmpty ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_portal.Portal, { ...portalProps, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(AutocompleteList, { ...listProps, children: [
|
|
1602
1614
|
allowCreate ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteCreate, {}) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteEmpty, {}),
|
|
1603
1615
|
children != null ? children : computedChildren
|
|
1604
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteList, { ...listProps, children: allowCreate && inputValue ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteCreate, {}) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteEmpty, {}) })
|
|
1616
|
+
] }) }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_portal.Portal, { ...portalProps, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteList, { ...listProps, children: allowCreate && inputValue ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteCreate, {}) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteEmpty, {}) }) })
|
|
1605
1617
|
]
|
|
1606
1618
|
}
|
|
1607
1619
|
) })
|
|
@@ -3376,7 +3376,7 @@ type UseAutocompleteBaseProps<T extends string | string[] = string> = Omit<Popov
|
|
|
3376
3376
|
*/
|
|
3377
3377
|
onSearch?: (ev: ChangeEvent<HTMLInputElement>) => void;
|
|
3378
3378
|
/**
|
|
3379
|
-
* The callback invoked when
|
|
3379
|
+
* The callback invoked when autocomplete option created.
|
|
3380
3380
|
*/
|
|
3381
3381
|
onCreate?: (newItem: AutocompleteItem, newItems: AutocompleteItem[]) => void;
|
|
3382
3382
|
/**
|
|
@@ -4052,7 +4052,7 @@ declare const useAutocomplete: <T extends string | string[] = string>({ defaultI
|
|
|
4052
4052
|
};
|
|
4053
4053
|
setFocusedIndex: Dispatch<SetStateAction<number>>;
|
|
4054
4054
|
onChangeLabel: (newValue: string, runOmit?: boolean) => void;
|
|
4055
|
-
onChange: (newValue: string) => void;
|
|
4055
|
+
onChange: (newValue: string, runRebirth?: boolean) => void;
|
|
4056
4056
|
onSearch: (ev: ChangeEvent<HTMLInputElement>) => void;
|
|
4057
4057
|
onCreate: () => void;
|
|
4058
4058
|
onClear: (ev: MouseEvent<HTMLDivElement>) => void;
|
|
@@ -3376,7 +3376,7 @@ type UseAutocompleteBaseProps<T extends string | string[] = string> = Omit<Popov
|
|
|
3376
3376
|
*/
|
|
3377
3377
|
onSearch?: (ev: ChangeEvent<HTMLInputElement>) => void;
|
|
3378
3378
|
/**
|
|
3379
|
-
* The callback invoked when
|
|
3379
|
+
* The callback invoked when autocomplete option created.
|
|
3380
3380
|
*/
|
|
3381
3381
|
onCreate?: (newItem: AutocompleteItem, newItems: AutocompleteItem[]) => void;
|
|
3382
3382
|
/**
|
|
@@ -4052,7 +4052,7 @@ declare const useAutocomplete: <T extends string | string[] = string>({ defaultI
|
|
|
4052
4052
|
};
|
|
4053
4053
|
setFocusedIndex: Dispatch<SetStateAction<number>>;
|
|
4054
4054
|
onChangeLabel: (newValue: string, runOmit?: boolean) => void;
|
|
4055
|
-
onChange: (newValue: string) => void;
|
|
4055
|
+
onChange: (newValue: string, runRebirth?: boolean) => void;
|
|
4056
4056
|
onSearch: (ev: ChangeEvent<HTMLInputElement>) => void;
|
|
4057
4057
|
onCreate: () => void;
|
|
4058
4058
|
onClear: (ev: MouseEvent<HTMLDivElement>) => void;
|
|
@@ -4,4 +4,4 @@ import '@yamada-ui/core';
|
|
|
4
4
|
import '@yamada-ui/form-control';
|
|
5
5
|
import '@yamada-ui/popover';
|
|
6
6
|
import '@yamada-ui/utils';
|
|
7
|
-
export { d as AutocompleteDescendantsContextProvider, b as AutocompleteItem, g as AutocompleteProvider, t as UseAutocompleteCreateReturn, w as UseAutocompleteEmptyReturn, l as UseAutocompleteInputReturn, U as UseAutocompleteOptionGroupProps, o as UseAutocompleteOptionGroupReturn, p as UseAutocompleteOptionProps, r as UseAutocompleteOptionReturn, c as UseAutocompleteProps, j as UseAutocompleteReturn, i as useAutocomplete, h as useAutocompleteContext, s as useAutocompleteCreate, f as useAutocompleteDescendant, e as useAutocompleteDescendants, u as useAutocompleteDescendantsContext, v as useAutocompleteEmpty, k as useAutocompleteInput, m as useAutocompleteList, q as useAutocompleteOption, n as useAutocompleteOptionGroup } from './use-autocomplete-
|
|
7
|
+
export { d as AutocompleteDescendantsContextProvider, b as AutocompleteItem, g as AutocompleteProvider, t as UseAutocompleteCreateReturn, w as UseAutocompleteEmptyReturn, l as UseAutocompleteInputReturn, U as UseAutocompleteOptionGroupProps, o as UseAutocompleteOptionGroupReturn, p as UseAutocompleteOptionProps, r as UseAutocompleteOptionReturn, c as UseAutocompleteProps, j as UseAutocompleteReturn, i as useAutocomplete, h as useAutocompleteContext, s as useAutocompleteCreate, f as useAutocompleteDescendant, e as useAutocompleteDescendants, u as useAutocompleteDescendantsContext, v as useAutocompleteEmpty, k as useAutocompleteInput, m as useAutocompleteList, q as useAutocompleteOption, n as useAutocompleteOptionGroup } from './use-autocomplete-PdT_PKFf.mjs';
|
|
@@ -4,4 +4,4 @@ import '@yamada-ui/core';
|
|
|
4
4
|
import '@yamada-ui/form-control';
|
|
5
5
|
import '@yamada-ui/popover';
|
|
6
6
|
import '@yamada-ui/utils';
|
|
7
|
-
export { d as AutocompleteDescendantsContextProvider, b as AutocompleteItem, g as AutocompleteProvider, t as UseAutocompleteCreateReturn, w as UseAutocompleteEmptyReturn, l as UseAutocompleteInputReturn, U as UseAutocompleteOptionGroupProps, o as UseAutocompleteOptionGroupReturn, p as UseAutocompleteOptionProps, r as UseAutocompleteOptionReturn, c as UseAutocompleteProps, j as UseAutocompleteReturn, i as useAutocomplete, h as useAutocompleteContext, s as useAutocompleteCreate, f as useAutocompleteDescendant, e as useAutocompleteDescendants, u as useAutocompleteDescendantsContext, v as useAutocompleteEmpty, k as useAutocompleteInput, m as useAutocompleteList, q as useAutocompleteOption, n as useAutocompleteOptionGroup } from './use-autocomplete-
|
|
7
|
+
export { d as AutocompleteDescendantsContextProvider, b as AutocompleteItem, g as AutocompleteProvider, t as UseAutocompleteCreateReturn, w as UseAutocompleteEmptyReturn, l as UseAutocompleteInputReturn, U as UseAutocompleteOptionGroupProps, o as UseAutocompleteOptionGroupReturn, p as UseAutocompleteOptionProps, r as UseAutocompleteOptionReturn, c as UseAutocompleteProps, j as UseAutocompleteReturn, i as useAutocomplete, h as useAutocompleteContext, s as useAutocompleteCreate, f as useAutocompleteDescendant, e as useAutocompleteDescendants, u as useAutocompleteDescendantsContext, v as useAutocompleteEmpty, k as useAutocompleteInput, m as useAutocompleteList, q as useAutocompleteOption, n as useAutocompleteOptionGroup } from './use-autocomplete-PdT_PKFf.js';
|
package/dist/use-autocomplete.js
CHANGED
|
@@ -652,7 +652,7 @@ var useAutocomplete = ({
|
|
|
652
652
|
[descendants, isMulti, allowFree]
|
|
653
653
|
);
|
|
654
654
|
const onChange = (0, import_react2.useCallback)(
|
|
655
|
-
(newValue) => {
|
|
655
|
+
(newValue, runRebirth = true) => {
|
|
656
656
|
setValue((prev) => {
|
|
657
657
|
if (!(0, import_utils4.isArray)(prev)) {
|
|
658
658
|
return newValue;
|
|
@@ -672,12 +672,20 @@ var useAutocomplete = ({
|
|
|
672
672
|
}
|
|
673
673
|
).length > 0;
|
|
674
674
|
onChangeLabel(newValue);
|
|
675
|
-
if (!allowFree || isHit2)
|
|
675
|
+
if (!allowFree || isHit2)
|
|
676
676
|
setInputValue("");
|
|
677
|
-
|
|
678
|
-
|
|
677
|
+
if (isMulti && runRebirth)
|
|
678
|
+
rebirthOptions(false);
|
|
679
679
|
},
|
|
680
|
-
[
|
|
680
|
+
[
|
|
681
|
+
allowFree,
|
|
682
|
+
isMulti,
|
|
683
|
+
onChangeLabel,
|
|
684
|
+
rebirthOptions,
|
|
685
|
+
setValue,
|
|
686
|
+
descendants,
|
|
687
|
+
format
|
|
688
|
+
]
|
|
681
689
|
);
|
|
682
690
|
const onSelect = (0, import_react2.useCallback)(() => {
|
|
683
691
|
var _a, _b;
|
|
@@ -772,23 +780,6 @@ var useAutocomplete = ({
|
|
|
772
780
|
secondInsertPositionItem,
|
|
773
781
|
isMulti
|
|
774
782
|
]);
|
|
775
|
-
const onDelete = (0, import_react2.useCallback)(() => {
|
|
776
|
-
if (!isMulti) {
|
|
777
|
-
onChange("");
|
|
778
|
-
} else {
|
|
779
|
-
onChange(value[value.length - 1]);
|
|
780
|
-
}
|
|
781
|
-
}, [isMulti, onChange, value]);
|
|
782
|
-
const onClear = (0, import_react2.useCallback)(
|
|
783
|
-
(ev) => {
|
|
784
|
-
ev.stopPropagation();
|
|
785
|
-
setValue([]);
|
|
786
|
-
setLabel(void 0);
|
|
787
|
-
setInputValue("");
|
|
788
|
-
rebirthOptions();
|
|
789
|
-
},
|
|
790
|
-
[setLabel, setInputValue, setValue, rebirthOptions]
|
|
791
|
-
);
|
|
792
783
|
const onClick = (0, import_react2.useCallback)(() => {
|
|
793
784
|
if (isOpen) {
|
|
794
785
|
if (inputRef.current)
|
|
@@ -811,16 +802,35 @@ var useAutocomplete = ({
|
|
|
811
802
|
return;
|
|
812
803
|
if (!closeOnBlur && isHit)
|
|
813
804
|
return;
|
|
814
|
-
if (allowFree && !!inputValue)
|
|
815
|
-
onChange(inputValue);
|
|
816
|
-
|
|
817
|
-
setInputValue("");
|
|
818
|
-
}
|
|
805
|
+
if (allowFree && !!inputValue)
|
|
806
|
+
onChange(inputValue, false);
|
|
807
|
+
setInputValue("");
|
|
819
808
|
if (isOpen)
|
|
820
809
|
onClose();
|
|
821
810
|
},
|
|
822
811
|
[closeOnBlur, isHit, isOpen, inputValue, allowFree, onClose, onChange]
|
|
823
812
|
);
|
|
813
|
+
const onDelete = (0, import_react2.useCallback)(() => {
|
|
814
|
+
if (!isMulti) {
|
|
815
|
+
onChange("");
|
|
816
|
+
} else {
|
|
817
|
+
onChange(value[value.length - 1]);
|
|
818
|
+
}
|
|
819
|
+
if (!isOpen)
|
|
820
|
+
onFocus();
|
|
821
|
+
}, [isMulti, isOpen, onChange, onFocus, value]);
|
|
822
|
+
const onClear = (0, import_react2.useCallback)(
|
|
823
|
+
(ev) => {
|
|
824
|
+
ev.stopPropagation();
|
|
825
|
+
setValue([]);
|
|
826
|
+
setLabel(void 0);
|
|
827
|
+
setInputValue("");
|
|
828
|
+
rebirthOptions();
|
|
829
|
+
if (isOpen && inputRef.current)
|
|
830
|
+
inputRef.current.focus();
|
|
831
|
+
},
|
|
832
|
+
[isOpen, setLabel, setInputValue, setValue, rebirthOptions]
|
|
833
|
+
);
|
|
824
834
|
const onKeyDown = (0, import_react2.useCallback)(
|
|
825
835
|
(ev) => {
|
|
826
836
|
if (ev.key === " ")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yamada-ui/autocomplete",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Yamada UI autocomplete component",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"yamada",
|
|
@@ -36,16 +36,17 @@
|
|
|
36
36
|
"url": "https://github.com/hirotomoyamada/yamada-ui/issues"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@yamada-ui/core": "0.
|
|
39
|
+
"@yamada-ui/core": "0.14.0",
|
|
40
40
|
"@yamada-ui/utils": "0.4.1",
|
|
41
|
-
"@yamada-ui/icon": "0.3.
|
|
42
|
-
"@yamada-ui/select": "0.
|
|
43
|
-
"@yamada-ui/form-control": "0.3.
|
|
44
|
-
"@yamada-ui/popover": "0.3.
|
|
41
|
+
"@yamada-ui/icon": "0.3.22",
|
|
42
|
+
"@yamada-ui/select": "0.6.0",
|
|
43
|
+
"@yamada-ui/form-control": "0.3.25",
|
|
44
|
+
"@yamada-ui/popover": "0.3.29",
|
|
45
45
|
"@yamada-ui/use-descendant": "0.2.9",
|
|
46
46
|
"@yamada-ui/use-clickable": "0.3.8",
|
|
47
47
|
"@yamada-ui/use-outside-click": "0.2.8",
|
|
48
|
-
"@yamada-ui/use-controllable-state": "0.4.2"
|
|
48
|
+
"@yamada-ui/use-controllable-state": "0.4.2",
|
|
49
|
+
"@yamada-ui/portal": "0.3.9"
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|
|
51
52
|
"react": "^18.0.0",
|