@yamada-ui/autocomplete 0.2.10 → 0.2.12
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.js +24 -17
- package/dist/autocomplete-create.mjs +1 -1
- package/dist/autocomplete-empty.js +24 -17
- package/dist/autocomplete-empty.mjs +1 -1
- package/dist/autocomplete-icon.js +30 -23
- package/dist/autocomplete-icon.mjs +1 -1
- package/dist/autocomplete-list.js +4 -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.js +10 -5
- 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.js +33 -22
- 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 +226 -120
- package/dist/autocomplete.mjs +1 -1
- package/dist/{chunk-5O3XEEJE.mjs → chunk-ZVZP7IWT.mjs} +352 -229
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +345 -229
- 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 +245 -149
- package/dist/multi-autocomplete.mjs +1 -1
- package/dist/{use-autocomplete-cbe9b443.d.ts → use-autocomplete-2422c1c8.d.ts} +25 -5
- package/dist/use-autocomplete.d.mts +1 -1
- package/dist/use-autocomplete.d.ts +1 -1
- package/dist/use-autocomplete.js +131 -45
- package/dist/use-autocomplete.mjs +1 -1
- package/package.json +11 -11
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
// src/autocomplete-list.tsx
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
forwardRef as forwardRef8
|
|
4
|
+
} from "@yamada-ui/core";
|
|
3
5
|
import { PopoverContent } from "@yamada-ui/popover";
|
|
4
6
|
import { cx as cx8 } from "@yamada-ui/utils";
|
|
5
7
|
|
|
6
8
|
// src/use-autocomplete.tsx
|
|
7
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
layoutStylesProperties
|
|
11
|
+
} from "@yamada-ui/core";
|
|
8
12
|
import {
|
|
9
13
|
formControlProperties,
|
|
10
14
|
useFormControlProps
|
|
@@ -83,7 +87,16 @@ var AutocompleteIcon = forwardRef(
|
|
|
83
87
|
}
|
|
84
88
|
})
|
|
85
89
|
);
|
|
86
|
-
return /* @__PURE__ */ jsx(
|
|
90
|
+
return /* @__PURE__ */ jsx(
|
|
91
|
+
ui.div,
|
|
92
|
+
{
|
|
93
|
+
ref,
|
|
94
|
+
className: cx("ui-autocomplete-icon", className),
|
|
95
|
+
__css: css,
|
|
96
|
+
...rest,
|
|
97
|
+
children: isValidElement(children) ? cloneChildren : /* @__PURE__ */ jsx(ChevronIcon, {})
|
|
98
|
+
}
|
|
99
|
+
);
|
|
87
100
|
}
|
|
88
101
|
);
|
|
89
102
|
var AutocompleteClearIcon = ({
|
|
@@ -109,100 +122,107 @@ var AutocompleteClearIcon = ({
|
|
|
109
122
|
}
|
|
110
123
|
);
|
|
111
124
|
};
|
|
112
|
-
var AutocompleteItemIcon = forwardRef(
|
|
113
|
-
|
|
114
|
-
|
|
125
|
+
var AutocompleteItemIcon = forwardRef(({ className, ...rest }, ref) => {
|
|
126
|
+
const { styles } = useAutocompleteContext();
|
|
127
|
+
const css = {
|
|
128
|
+
flexShrink: 0,
|
|
129
|
+
display: "inline-flex",
|
|
130
|
+
justifyContent: "center",
|
|
131
|
+
alignItems: "center",
|
|
132
|
+
fontSize: "0.85em",
|
|
133
|
+
...styles.itemIcon
|
|
134
|
+
};
|
|
135
|
+
return /* @__PURE__ */ jsx(
|
|
136
|
+
ui.span,
|
|
137
|
+
{
|
|
138
|
+
ref,
|
|
139
|
+
className: cx("ui-autocomplete-item-icon", className),
|
|
140
|
+
__css: css,
|
|
141
|
+
...rest
|
|
142
|
+
}
|
|
143
|
+
);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// src/autocomplete.tsx
|
|
147
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
148
|
+
var Autocomplete = forwardRef2(
|
|
149
|
+
(props, ref) => {
|
|
150
|
+
const [styles, mergedProps] = useMultiComponentStyle("Select", props);
|
|
151
|
+
let {
|
|
152
|
+
className,
|
|
153
|
+
defaultValue = "",
|
|
154
|
+
color,
|
|
155
|
+
h,
|
|
156
|
+
height,
|
|
157
|
+
minH,
|
|
158
|
+
minHeight,
|
|
159
|
+
containerProps,
|
|
160
|
+
listProps,
|
|
161
|
+
inputProps,
|
|
162
|
+
iconProps,
|
|
163
|
+
children,
|
|
164
|
+
...computedProps
|
|
165
|
+
} = omitThemeProps(mergedProps);
|
|
166
|
+
const {
|
|
167
|
+
descendants,
|
|
168
|
+
formControlProps,
|
|
169
|
+
getPopoverProps,
|
|
170
|
+
getContainerProps,
|
|
171
|
+
getFieldProps,
|
|
172
|
+
createOption,
|
|
173
|
+
isEmpty,
|
|
174
|
+
inputValue,
|
|
175
|
+
computedChildren,
|
|
176
|
+
...rest
|
|
177
|
+
} = useAutocomplete({ ...computedProps, defaultValue, children });
|
|
178
|
+
h = h != null ? h : height;
|
|
179
|
+
minH = minH != null ? minH : minHeight;
|
|
115
180
|
const css = {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
...styles.itemIcon
|
|
181
|
+
position: "relative",
|
|
182
|
+
w: "100%",
|
|
183
|
+
h: "fit-content",
|
|
184
|
+
color,
|
|
185
|
+
...styles.container
|
|
122
186
|
};
|
|
123
|
-
return /* @__PURE__ */
|
|
124
|
-
|
|
187
|
+
return /* @__PURE__ */ jsx2(AutocompleteDescendantsContextProvider, { value: descendants, children: /* @__PURE__ */ jsx2(
|
|
188
|
+
AutocompleteProvider,
|
|
125
189
|
{
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
190
|
+
value: {
|
|
191
|
+
...rest,
|
|
192
|
+
formControlProps,
|
|
193
|
+
inputValue,
|
|
194
|
+
createOption,
|
|
195
|
+
isEmpty,
|
|
196
|
+
styles
|
|
197
|
+
},
|
|
198
|
+
children: /* @__PURE__ */ jsx2(Popover, { ...getPopoverProps(), children: /* @__PURE__ */ jsxs(
|
|
199
|
+
ui2.div,
|
|
200
|
+
{
|
|
201
|
+
className: cx2("ui-autocomplete", className),
|
|
202
|
+
__css: css,
|
|
203
|
+
...getContainerProps(containerProps),
|
|
204
|
+
children: [
|
|
205
|
+
/* @__PURE__ */ jsx2(
|
|
206
|
+
AutocompleteField,
|
|
207
|
+
{
|
|
208
|
+
h,
|
|
209
|
+
minH,
|
|
210
|
+
inputProps,
|
|
211
|
+
...getFieldProps({}, ref)
|
|
212
|
+
}
|
|
213
|
+
),
|
|
214
|
+
/* @__PURE__ */ jsx2(AutocompleteIcon, { ...iconProps, ...formControlProps }),
|
|
215
|
+
!isEmpty ? /* @__PURE__ */ jsxs(AutocompleteList, { ...listProps, children: [
|
|
216
|
+
createOption ? /* @__PURE__ */ jsx2(AutocompleteCreate, {}) : /* @__PURE__ */ jsx2(AutocompleteEmpty, {}),
|
|
217
|
+
children != null ? children : computedChildren
|
|
218
|
+
] }) : /* @__PURE__ */ jsx2(AutocompleteList, { ...listProps, children: createOption && inputValue ? /* @__PURE__ */ jsx2(AutocompleteCreate, {}) : /* @__PURE__ */ jsx2(AutocompleteEmpty, {}) })
|
|
219
|
+
]
|
|
220
|
+
}
|
|
221
|
+
) })
|
|
130
222
|
}
|
|
131
|
-
);
|
|
223
|
+
) });
|
|
132
224
|
}
|
|
133
225
|
);
|
|
134
|
-
|
|
135
|
-
// src/autocomplete.tsx
|
|
136
|
-
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
137
|
-
var Autocomplete = forwardRef2((props, ref) => {
|
|
138
|
-
const [styles, mergedProps] = useMultiComponentStyle("Select", props);
|
|
139
|
-
let {
|
|
140
|
-
className,
|
|
141
|
-
defaultValue = "",
|
|
142
|
-
color,
|
|
143
|
-
h,
|
|
144
|
-
height,
|
|
145
|
-
minH,
|
|
146
|
-
minHeight,
|
|
147
|
-
containerProps,
|
|
148
|
-
listProps,
|
|
149
|
-
inputProps,
|
|
150
|
-
iconProps,
|
|
151
|
-
children,
|
|
152
|
-
...computedProps
|
|
153
|
-
} = omitThemeProps(mergedProps);
|
|
154
|
-
const {
|
|
155
|
-
descendants,
|
|
156
|
-
formControlProps,
|
|
157
|
-
getPopoverProps,
|
|
158
|
-
getContainerProps,
|
|
159
|
-
getFieldProps,
|
|
160
|
-
createOption,
|
|
161
|
-
isEmpty,
|
|
162
|
-
inputValue,
|
|
163
|
-
computedChildren,
|
|
164
|
-
...rest
|
|
165
|
-
} = useAutocomplete({ ...computedProps, defaultValue, children });
|
|
166
|
-
h = h != null ? h : height;
|
|
167
|
-
minH = minH != null ? minH : minHeight;
|
|
168
|
-
const css = {
|
|
169
|
-
position: "relative",
|
|
170
|
-
w: "100%",
|
|
171
|
-
h: "fit-content",
|
|
172
|
-
color,
|
|
173
|
-
...styles.container
|
|
174
|
-
};
|
|
175
|
-
return /* @__PURE__ */ jsx2(AutocompleteDescendantsContextProvider, { value: descendants, children: /* @__PURE__ */ jsx2(
|
|
176
|
-
AutocompleteProvider,
|
|
177
|
-
{
|
|
178
|
-
value: { ...rest, formControlProps, inputValue, createOption, isEmpty, styles },
|
|
179
|
-
children: /* @__PURE__ */ jsx2(Popover, { ...getPopoverProps(), children: /* @__PURE__ */ jsxs(
|
|
180
|
-
ui2.div,
|
|
181
|
-
{
|
|
182
|
-
className: cx2("ui-autocomplete", className),
|
|
183
|
-
__css: css,
|
|
184
|
-
...getContainerProps(containerProps),
|
|
185
|
-
children: [
|
|
186
|
-
/* @__PURE__ */ jsx2(
|
|
187
|
-
AutocompleteField,
|
|
188
|
-
{
|
|
189
|
-
h,
|
|
190
|
-
minH,
|
|
191
|
-
inputProps,
|
|
192
|
-
...getFieldProps({}, ref)
|
|
193
|
-
}
|
|
194
|
-
),
|
|
195
|
-
/* @__PURE__ */ jsx2(AutocompleteIcon, { ...iconProps, ...formControlProps }),
|
|
196
|
-
!isEmpty ? /* @__PURE__ */ jsxs(AutocompleteList, { ...listProps, children: [
|
|
197
|
-
createOption ? /* @__PURE__ */ jsx2(AutocompleteCreate, {}) : /* @__PURE__ */ jsx2(AutocompleteEmpty, {}),
|
|
198
|
-
children != null ? children : computedChildren
|
|
199
|
-
] }) : /* @__PURE__ */ jsx2(AutocompleteList, { ...listProps, children: createOption && inputValue ? /* @__PURE__ */ jsx2(AutocompleteCreate, {}) : /* @__PURE__ */ jsx2(AutocompleteEmpty, {}) })
|
|
200
|
-
]
|
|
201
|
-
}
|
|
202
|
-
) })
|
|
203
|
-
}
|
|
204
|
-
) });
|
|
205
|
-
});
|
|
206
226
|
var AutocompleteField = forwardRef2(
|
|
207
227
|
({ className, h, minH, placeholder, inputProps, ...rest }, ref) => {
|
|
208
228
|
const { displayValue, inputValue, styles } = useAutocompleteContext();
|
|
@@ -216,16 +236,27 @@ var AutocompleteField = forwardRef2(
|
|
|
216
236
|
...styles.field,
|
|
217
237
|
cursor: "text"
|
|
218
238
|
};
|
|
219
|
-
return /* @__PURE__ */ jsx2(PopoverTrigger, { children: /* @__PURE__ */ jsx2(
|
|
220
|
-
ui2.
|
|
239
|
+
return /* @__PURE__ */ jsx2(PopoverTrigger, { children: /* @__PURE__ */ jsx2(
|
|
240
|
+
ui2.div,
|
|
221
241
|
{
|
|
222
|
-
className: "ui-autocomplete-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
242
|
+
className: cx2("ui-autocomplete-field", className),
|
|
243
|
+
__css: css,
|
|
244
|
+
...rest,
|
|
245
|
+
children: /* @__PURE__ */ jsx2(
|
|
246
|
+
ui2.input,
|
|
247
|
+
{
|
|
248
|
+
className: "ui-autocomplete-input",
|
|
249
|
+
display: "inline-block",
|
|
250
|
+
w: "full",
|
|
251
|
+
placeholder,
|
|
252
|
+
...getInputProps(
|
|
253
|
+
{ ...inputProps, value: inputValue || displayValue || "" },
|
|
254
|
+
ref
|
|
255
|
+
)
|
|
256
|
+
}
|
|
257
|
+
)
|
|
227
258
|
}
|
|
228
|
-
) })
|
|
259
|
+
) });
|
|
229
260
|
}
|
|
230
261
|
);
|
|
231
262
|
|
|
@@ -412,108 +443,113 @@ import {
|
|
|
412
443
|
} from "@yamada-ui/core";
|
|
413
444
|
import { Popover as Popover2, PopoverTrigger as PopoverTrigger2 } from "@yamada-ui/popover";
|
|
414
445
|
import { cx as cx7, handlerAll } from "@yamada-ui/utils";
|
|
415
|
-
import {
|
|
446
|
+
import {
|
|
447
|
+
cloneElement as cloneElement2,
|
|
448
|
+
useMemo
|
|
449
|
+
} from "react";
|
|
416
450
|
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
417
|
-
var MultiAutocomplete = forwardRef7(
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
});
|
|
451
|
+
var MultiAutocomplete = forwardRef7(
|
|
452
|
+
(props, ref) => {
|
|
453
|
+
const [styles, mergedProps] = useMultiComponentStyle2("Select", props);
|
|
454
|
+
let {
|
|
455
|
+
className,
|
|
456
|
+
defaultValue = [],
|
|
457
|
+
component,
|
|
458
|
+
separator,
|
|
459
|
+
isClearable = true,
|
|
460
|
+
color,
|
|
461
|
+
h,
|
|
462
|
+
height,
|
|
463
|
+
minH,
|
|
464
|
+
minHeight,
|
|
465
|
+
closeOnSelect = false,
|
|
466
|
+
keepPlaceholder = false,
|
|
467
|
+
containerProps,
|
|
468
|
+
listProps,
|
|
469
|
+
inputProps,
|
|
470
|
+
iconProps,
|
|
471
|
+
clearIconProps,
|
|
472
|
+
children,
|
|
473
|
+
...computedProps
|
|
474
|
+
} = omitThemeProps2(mergedProps);
|
|
475
|
+
const {
|
|
476
|
+
value,
|
|
477
|
+
descendants,
|
|
478
|
+
formControlProps,
|
|
479
|
+
getPopoverProps,
|
|
480
|
+
getContainerProps,
|
|
481
|
+
getFieldProps,
|
|
482
|
+
createOption,
|
|
483
|
+
isEmpty,
|
|
484
|
+
inputValue,
|
|
485
|
+
computedChildren,
|
|
486
|
+
onClear,
|
|
487
|
+
...rest
|
|
488
|
+
} = useAutocomplete({
|
|
489
|
+
...computedProps,
|
|
490
|
+
defaultValue,
|
|
491
|
+
closeOnSelect,
|
|
492
|
+
children
|
|
493
|
+
});
|
|
494
|
+
h = h != null ? h : height;
|
|
495
|
+
minH = minH != null ? minH : minHeight;
|
|
496
|
+
const css = {
|
|
497
|
+
position: "relative",
|
|
498
|
+
w: "100%",
|
|
499
|
+
h: "fit-content",
|
|
500
|
+
color,
|
|
501
|
+
...styles.container
|
|
502
|
+
};
|
|
503
|
+
return /* @__PURE__ */ jsx7(AutocompleteDescendantsContextProvider, { value: descendants, children: /* @__PURE__ */ jsx7(
|
|
504
|
+
AutocompleteProvider,
|
|
505
|
+
{
|
|
506
|
+
value: {
|
|
507
|
+
...rest,
|
|
508
|
+
value,
|
|
509
|
+
formControlProps,
|
|
510
|
+
inputValue,
|
|
511
|
+
createOption,
|
|
512
|
+
isEmpty,
|
|
513
|
+
styles
|
|
514
|
+
},
|
|
515
|
+
children: /* @__PURE__ */ jsx7(Popover2, { ...getPopoverProps(), children: /* @__PURE__ */ jsxs6(
|
|
516
|
+
ui7.div,
|
|
517
|
+
{
|
|
518
|
+
className: cx7("ui-autocomplete", className),
|
|
519
|
+
__css: css,
|
|
520
|
+
...getContainerProps(containerProps),
|
|
521
|
+
children: [
|
|
522
|
+
/* @__PURE__ */ jsx7(
|
|
523
|
+
MultiAutocompleteField,
|
|
524
|
+
{
|
|
525
|
+
component,
|
|
526
|
+
separator,
|
|
527
|
+
keepPlaceholder,
|
|
528
|
+
h,
|
|
529
|
+
minH,
|
|
530
|
+
inputProps,
|
|
531
|
+
...getFieldProps({}, ref)
|
|
532
|
+
}
|
|
533
|
+
),
|
|
534
|
+
isClearable && value.length ? /* @__PURE__ */ jsx7(
|
|
535
|
+
AutocompleteClearIcon,
|
|
536
|
+
{
|
|
537
|
+
...clearIconProps,
|
|
538
|
+
onClick: handlerAll(clearIconProps == null ? void 0 : clearIconProps.onClick, onClear),
|
|
539
|
+
...formControlProps
|
|
540
|
+
}
|
|
541
|
+
) : /* @__PURE__ */ jsx7(AutocompleteIcon, { ...iconProps, ...formControlProps }),
|
|
542
|
+
!isEmpty ? /* @__PURE__ */ jsxs6(AutocompleteList, { ...listProps, children: [
|
|
543
|
+
createOption ? /* @__PURE__ */ jsx7(AutocompleteCreate, {}) : /* @__PURE__ */ jsx7(AutocompleteEmpty, {}),
|
|
544
|
+
children != null ? children : computedChildren
|
|
545
|
+
] }) : /* @__PURE__ */ jsx7(AutocompleteList, { ...listProps, children: createOption && inputValue ? /* @__PURE__ */ jsx7(AutocompleteCreate, {}) : /* @__PURE__ */ jsx7(AutocompleteEmpty, {}) })
|
|
546
|
+
]
|
|
547
|
+
}
|
|
548
|
+
) })
|
|
549
|
+
}
|
|
550
|
+
) });
|
|
551
|
+
}
|
|
552
|
+
);
|
|
517
553
|
var MultiAutocompleteField = forwardRef7(
|
|
518
554
|
({
|
|
519
555
|
className,
|
|
@@ -526,7 +562,15 @@ var MultiAutocompleteField = forwardRef7(
|
|
|
526
562
|
inputProps,
|
|
527
563
|
...rest
|
|
528
564
|
}, ref) => {
|
|
529
|
-
const {
|
|
565
|
+
const {
|
|
566
|
+
value,
|
|
567
|
+
displayValue,
|
|
568
|
+
inputValue,
|
|
569
|
+
onChange,
|
|
570
|
+
isOpen,
|
|
571
|
+
inputRef,
|
|
572
|
+
styles
|
|
573
|
+
} = useAutocompleteContext();
|
|
530
574
|
const { getInputProps } = useAutocompleteInput();
|
|
531
575
|
const cloneChildren = useMemo(() => {
|
|
532
576
|
if (!(displayValue == null ? void 0 : displayValue.length))
|
|
@@ -695,7 +739,10 @@ var kanaMap = {
|
|
|
695
739
|
"\uFF65": "\u30FB"
|
|
696
740
|
};
|
|
697
741
|
var defaultFormat = (value) => {
|
|
698
|
-
value = value.replace(
|
|
742
|
+
value = value.replace(
|
|
743
|
+
/[!-~]/g,
|
|
744
|
+
(v) => String.fromCharCode(v.charCodeAt(0) - 65248)
|
|
745
|
+
);
|
|
699
746
|
const reg = new RegExp("(" + Object.keys(kanaMap).join("|") + ")", "g");
|
|
700
747
|
value = value.replace(reg, (v) => kanaMap[v]).replace(/゙/g, "\u309B").replace(/゚/g, "\u309C");
|
|
701
748
|
value = value.toUpperCase();
|
|
@@ -752,7 +799,14 @@ var useAutocomplete = ({
|
|
|
752
799
|
const { id } = rest;
|
|
753
800
|
const formControlProps = pickObject(rest, formControlProperties);
|
|
754
801
|
const [containerProps, inputProps] = splitObject(
|
|
755
|
-
omitObject(rest, [
|
|
802
|
+
omitObject(rest, [
|
|
803
|
+
"id",
|
|
804
|
+
"value",
|
|
805
|
+
"defaultValue",
|
|
806
|
+
"onChange",
|
|
807
|
+
"month",
|
|
808
|
+
"onChangeMonth"
|
|
809
|
+
]),
|
|
756
810
|
layoutStylesProperties
|
|
757
811
|
);
|
|
758
812
|
const descendants = useAutocompleteDescendants();
|
|
@@ -804,9 +858,17 @@ var useAutocomplete = ({
|
|
|
804
858
|
if (!isArray(value2)) {
|
|
805
859
|
return /* @__PURE__ */ jsx8(AutocompleteOption, { value: value2, ...props, children: label }, i);
|
|
806
860
|
} else {
|
|
807
|
-
return /* @__PURE__ */ jsx8(
|
|
808
|
-
|
|
809
|
-
|
|
861
|
+
return /* @__PURE__ */ jsx8(
|
|
862
|
+
AutocompleteOptionGroup,
|
|
863
|
+
{
|
|
864
|
+
label,
|
|
865
|
+
...props,
|
|
866
|
+
children: value2.map(
|
|
867
|
+
({ label: label2, value: value3, ...props2 }, i2) => !isArray(value3) ? /* @__PURE__ */ jsx8(AutocompleteOption, { value: value3, ...props2, children: label2 }, i2) : null
|
|
868
|
+
)
|
|
869
|
+
},
|
|
870
|
+
i
|
|
871
|
+
);
|
|
810
872
|
}
|
|
811
873
|
});
|
|
812
874
|
const isEmpty = !validChildren.length && !(computedChildren == null ? void 0 : computedChildren.length);
|
|
@@ -830,7 +892,9 @@ var useAutocomplete = ({
|
|
|
830
892
|
const id2 = setTimeout(() => {
|
|
831
893
|
if (isEmpty || isAllSelected)
|
|
832
894
|
return;
|
|
833
|
-
const first = descendants.enabledfirstValue(
|
|
895
|
+
const first = descendants.enabledfirstValue(
|
|
896
|
+
({ node }) => "target" in node.dataset
|
|
897
|
+
);
|
|
834
898
|
if (!first)
|
|
835
899
|
return;
|
|
836
900
|
if (!isMulti || !omitSelectedValues) {
|
|
@@ -858,7 +922,9 @@ var useAutocomplete = ({
|
|
|
858
922
|
const id2 = setTimeout(() => {
|
|
859
923
|
if (isEmpty || isAllSelected)
|
|
860
924
|
return;
|
|
861
|
-
const last = descendants.enabledlastValue(
|
|
925
|
+
const last = descendants.enabledlastValue(
|
|
926
|
+
({ node }) => "target" in node.dataset
|
|
927
|
+
);
|
|
862
928
|
if (!last)
|
|
863
929
|
return;
|
|
864
930
|
if (!isMulti || !omitSelectedValues) {
|
|
@@ -900,7 +966,10 @@ var useAutocomplete = ({
|
|
|
900
966
|
(index = focusedIndex) => {
|
|
901
967
|
const id2 = setTimeout(() => {
|
|
902
968
|
var _a;
|
|
903
|
-
const next = descendants.enabledNextValue(
|
|
969
|
+
const next = descendants.enabledNextValue(
|
|
970
|
+
index,
|
|
971
|
+
({ node }) => "target" in node.dataset
|
|
972
|
+
);
|
|
904
973
|
if (!next)
|
|
905
974
|
return;
|
|
906
975
|
if (!isMulti || !omitSelectedValues) {
|
|
@@ -916,13 +985,23 @@ var useAutocomplete = ({
|
|
|
916
985
|
});
|
|
917
986
|
timeoutIds.current.add(id2);
|
|
918
987
|
},
|
|
919
|
-
[
|
|
988
|
+
[
|
|
989
|
+
descendants,
|
|
990
|
+
enabledValues,
|
|
991
|
+
focusedIndex,
|
|
992
|
+
isMulti,
|
|
993
|
+
omitSelectedValues,
|
|
994
|
+
selectedIndexes
|
|
995
|
+
]
|
|
920
996
|
);
|
|
921
997
|
const onFocusPrev = useCallback(
|
|
922
998
|
(index = focusedIndex) => {
|
|
923
999
|
const id2 = setTimeout(() => {
|
|
924
1000
|
var _a;
|
|
925
|
-
const prev = descendants.enabledPrevValue(
|
|
1001
|
+
const prev = descendants.enabledPrevValue(
|
|
1002
|
+
index,
|
|
1003
|
+
({ node }) => "target" in node.dataset
|
|
1004
|
+
);
|
|
926
1005
|
if (!prev)
|
|
927
1006
|
return;
|
|
928
1007
|
if (!isMulti || !omitSelectedValues) {
|
|
@@ -938,7 +1017,14 @@ var useAutocomplete = ({
|
|
|
938
1017
|
});
|
|
939
1018
|
timeoutIds.current.add(id2);
|
|
940
1019
|
},
|
|
941
|
-
[
|
|
1020
|
+
[
|
|
1021
|
+
descendants,
|
|
1022
|
+
enabledValues,
|
|
1023
|
+
focusedIndex,
|
|
1024
|
+
isMulti,
|
|
1025
|
+
omitSelectedValues,
|
|
1026
|
+
selectedIndexes
|
|
1027
|
+
]
|
|
942
1028
|
);
|
|
943
1029
|
const onFocusFirstOrSelected = isEmptyValue || omitSelectedValues ? onFocusFirst : onFocusSelected;
|
|
944
1030
|
const onFocusLastOrSelected = isEmptyValue || omitSelectedValues ? onFocusLast : onFocusSelected;
|
|
@@ -1035,7 +1121,15 @@ var useAutocomplete = ({
|
|
|
1035
1121
|
onClose();
|
|
1036
1122
|
if (omitSelectedValues)
|
|
1037
1123
|
onFocusNext();
|
|
1038
|
-
}, [
|
|
1124
|
+
}, [
|
|
1125
|
+
closeOnSelect,
|
|
1126
|
+
descendants,
|
|
1127
|
+
focusedIndex,
|
|
1128
|
+
omitSelectedValues,
|
|
1129
|
+
onChange,
|
|
1130
|
+
onClose,
|
|
1131
|
+
onFocusNext
|
|
1132
|
+
]);
|
|
1039
1133
|
const onSearch = useCallback(
|
|
1040
1134
|
(ev) => {
|
|
1041
1135
|
var _a;
|
|
@@ -1072,12 +1166,20 @@ var useAutocomplete = ({
|
|
|
1072
1166
|
} else if (firstInsertPositionOnCreate === "last") {
|
|
1073
1167
|
newOptions = [...newOptions, newOption];
|
|
1074
1168
|
} else {
|
|
1075
|
-
const i = newOptions.findIndex(
|
|
1169
|
+
const i = newOptions.findIndex(
|
|
1170
|
+
({ label }) => label === firstInsertPositionOnCreate
|
|
1171
|
+
);
|
|
1076
1172
|
if (i !== -1 && isArray(newOptions[i].value)) {
|
|
1077
1173
|
if (secondInsertPositionOnCreate === "first") {
|
|
1078
|
-
newOptions[i].value = [
|
|
1174
|
+
newOptions[i].value = [
|
|
1175
|
+
newOption,
|
|
1176
|
+
...newOptions[i].value
|
|
1177
|
+
];
|
|
1079
1178
|
} else {
|
|
1080
|
-
newOptions[i].value = [
|
|
1179
|
+
newOptions[i].value = [
|
|
1180
|
+
...newOptions[i].value,
|
|
1181
|
+
newOption
|
|
1182
|
+
];
|
|
1081
1183
|
}
|
|
1082
1184
|
} else {
|
|
1083
1185
|
console.warn(
|
|
@@ -1088,7 +1190,9 @@ var useAutocomplete = ({
|
|
|
1088
1190
|
setOptions(newOptions);
|
|
1089
1191
|
onChange(inputValue);
|
|
1090
1192
|
rebirthOptions(false);
|
|
1091
|
-
const index = flattenOptions(newOptions).findIndex(
|
|
1193
|
+
const index = flattenOptions(newOptions).findIndex(
|
|
1194
|
+
({ value: value2 }) => value2 === inputValue
|
|
1195
|
+
);
|
|
1092
1196
|
setFocusedIndex(index);
|
|
1093
1197
|
(_a = rest.onCreate) == null ? void 0 : _a.call(rest, newOption, newOptions);
|
|
1094
1198
|
}, [
|
|
@@ -1207,7 +1311,14 @@ var useAutocomplete = ({
|
|
|
1207
1311
|
} else {
|
|
1208
1312
|
setIsAllSelected(false);
|
|
1209
1313
|
}
|
|
1210
|
-
}, [
|
|
1314
|
+
}, [
|
|
1315
|
+
omitSelectedValues,
|
|
1316
|
+
value,
|
|
1317
|
+
descendants,
|
|
1318
|
+
isMulti,
|
|
1319
|
+
onClose,
|
|
1320
|
+
maxSelectedValues
|
|
1321
|
+
]);
|
|
1211
1322
|
useUpdateEffect(() => {
|
|
1212
1323
|
if (isOpen)
|
|
1213
1324
|
return;
|
|
@@ -1409,7 +1520,10 @@ var useAutocompleteList = () => {
|
|
|
1409
1520
|
role: "select",
|
|
1410
1521
|
tabIndex: -1,
|
|
1411
1522
|
...props,
|
|
1412
|
-
onAnimationComplete: handlerAll2(
|
|
1523
|
+
onAnimationComplete: handlerAll2(
|
|
1524
|
+
props.onAnimationComplete,
|
|
1525
|
+
onAnimationComplete
|
|
1526
|
+
)
|
|
1413
1527
|
}),
|
|
1414
1528
|
[listRef, onAnimationComplete]
|
|
1415
1529
|
);
|
|
@@ -1417,15 +1531,20 @@ var useAutocompleteList = () => {
|
|
|
1417
1531
|
getListProps
|
|
1418
1532
|
};
|
|
1419
1533
|
};
|
|
1420
|
-
var useAutocompleteOptionGroup = ({
|
|
1534
|
+
var useAutocompleteOptionGroup = ({
|
|
1535
|
+
label,
|
|
1536
|
+
...rest
|
|
1537
|
+
}) => {
|
|
1421
1538
|
const { value, omitSelectedValues } = useAutocompleteContext();
|
|
1422
1539
|
const isMulti = isArray(value);
|
|
1423
1540
|
const descendants = useAutocompleteDescendantsContext();
|
|
1424
1541
|
const values = descendants.values();
|
|
1425
|
-
const selectedValues = isMulti && omitSelectedValues ? descendants.values(
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1542
|
+
const selectedValues = isMulti && omitSelectedValues ? descendants.values(
|
|
1543
|
+
({ node }) => {
|
|
1544
|
+
var _a;
|
|
1545
|
+
return value.includes((_a = node.dataset.value) != null ? _a : "");
|
|
1546
|
+
}
|
|
1547
|
+
) : [];
|
|
1429
1548
|
const selectedIndexes = selectedValues.map(({ index }) => index);
|
|
1430
1549
|
const childValues = values.filter(
|
|
1431
1550
|
({ node, index }) => {
|
|
@@ -1500,14 +1619,18 @@ var useAutocompleteOption = (props) => {
|
|
|
1500
1619
|
} = { ...optionProps, ...props };
|
|
1501
1620
|
const trulyDisabled = !!isDisabled && !isFocusable;
|
|
1502
1621
|
const itemRef = useRef2(null);
|
|
1503
|
-
const { index, register, descendants } = useAutocompleteDescendant({
|
|
1622
|
+
const { index, register, descendants } = useAutocompleteDescendant({
|
|
1623
|
+
disabled: trulyDisabled
|
|
1624
|
+
});
|
|
1504
1625
|
const values = descendants.values();
|
|
1505
1626
|
const frontValues = values.slice(0, index);
|
|
1506
1627
|
const isMulti = isArray(value);
|
|
1507
|
-
const isDuplicated = !isMulti ? frontValues.some(
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1628
|
+
const isDuplicated = !isMulti ? frontValues.some(
|
|
1629
|
+
({ node }) => {
|
|
1630
|
+
var _a2;
|
|
1631
|
+
return node.dataset.value === ((_a2 = computedProps.value) != null ? _a2 : "");
|
|
1632
|
+
}
|
|
1633
|
+
) : false;
|
|
1511
1634
|
const isSelected = !isDuplicated && (!isMulti ? ((_a = computedProps.value) != null ? _a : "") === value : value.includes((_b = computedProps.value) != null ? _b : ""));
|
|
1512
1635
|
const isTarget = "target" in ((_d = (_c = itemRef.current) == null ? void 0 : _c.dataset) != null ? _d : {});
|
|
1513
1636
|
const isFocused = index === focusedIndex;
|