@uipath/apollo-wind 2.77.0 → 2.79.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/components/ui/index.cjs +10 -10
- package/dist/components/ui/input.cjs +1 -1
- package/dist/components/ui/input.d.ts +2 -1
- package/dist/components/ui/input.js +1 -1
- package/dist/components/ui/search.cjs +38 -13
- package/dist/components/ui/search.d.ts +17 -2
- package/dist/components/ui/search.js +41 -16
- package/dist/styles.css +3 -0
- package/package.json +1 -1
|
@@ -33,7 +33,7 @@ var __webpack_modules__ = {
|
|
|
33
33
|
"./button-group" (module) {
|
|
34
34
|
module.exports = require("./button-group.cjs");
|
|
35
35
|
},
|
|
36
|
-
"
|
|
36
|
+
"./button" (module) {
|
|
37
37
|
module.exports = require("./button.cjs");
|
|
38
38
|
},
|
|
39
39
|
"@/components/ui/calendar" (module) {
|
|
@@ -81,7 +81,7 @@ var __webpack_modules__ = {
|
|
|
81
81
|
"./datetime-picker" (module) {
|
|
82
82
|
module.exports = require("./datetime-picker.cjs");
|
|
83
83
|
},
|
|
84
|
-
"
|
|
84
|
+
"@/components/ui/dialog" (module) {
|
|
85
85
|
module.exports = require("./dialog.cjs");
|
|
86
86
|
},
|
|
87
87
|
"./disclosure-tree" (module) {
|
|
@@ -117,7 +117,7 @@ var __webpack_modules__ = {
|
|
|
117
117
|
"./form-field" (module) {
|
|
118
118
|
module.exports = require("./form-field.cjs");
|
|
119
119
|
},
|
|
120
|
-
"
|
|
120
|
+
"./hover-card" (module) {
|
|
121
121
|
module.exports = require("./hover-card.cjs");
|
|
122
122
|
},
|
|
123
123
|
"./info-tooltip" (module) {
|
|
@@ -249,7 +249,7 @@ var __webpack_modules__ = {
|
|
|
249
249
|
"./switch" (module) {
|
|
250
250
|
module.exports = require("./switch.cjs");
|
|
251
251
|
},
|
|
252
|
-
"
|
|
252
|
+
"@/components/ui/table" (module) {
|
|
253
253
|
module.exports = require("./table.cjs");
|
|
254
254
|
},
|
|
255
255
|
"./tabs" (module) {
|
|
@@ -270,7 +270,7 @@ var __webpack_modules__ = {
|
|
|
270
270
|
"./tool-call" (module) {
|
|
271
271
|
module.exports = require("./tool-call.cjs");
|
|
272
272
|
},
|
|
273
|
-
"
|
|
273
|
+
"./tooltip" (module) {
|
|
274
274
|
module.exports = require("./tooltip.cjs");
|
|
275
275
|
},
|
|
276
276
|
"./tree-view" (module) {
|
|
@@ -432,7 +432,7 @@ var __webpack_exports__ = {};
|
|
|
432
432
|
"ReferenceChip"
|
|
433
433
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_bubble__rspack_import_9[__rspack_import_key];
|
|
434
434
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
435
|
-
var _button__rspack_import_10 = __webpack_require__("
|
|
435
|
+
var _button__rspack_import_10 = __webpack_require__("./button");
|
|
436
436
|
var __rspack_reexport = {};
|
|
437
437
|
for(const __rspack_import_key in _button__rspack_import_10)if ([
|
|
438
438
|
"getReferenceChipColors",
|
|
@@ -602,7 +602,7 @@ var __webpack_exports__ = {};
|
|
|
602
602
|
"ReferenceChip"
|
|
603
603
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_datetime_picker__rspack_import_26[__rspack_import_key];
|
|
604
604
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
605
|
-
var _dialog__rspack_import_27 = __webpack_require__("
|
|
605
|
+
var _dialog__rspack_import_27 = __webpack_require__("@/components/ui/dialog");
|
|
606
606
|
var __rspack_reexport = {};
|
|
607
607
|
for(const __rspack_import_key in _dialog__rspack_import_27)if ([
|
|
608
608
|
"getReferenceChipColors",
|
|
@@ -722,7 +722,7 @@ var __webpack_exports__ = {};
|
|
|
722
722
|
"ReferenceChip"
|
|
723
723
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_form_field__rspack_import_38[__rspack_import_key];
|
|
724
724
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
725
|
-
var _hover_card__rspack_import_39 = __webpack_require__("
|
|
725
|
+
var _hover_card__rspack_import_39 = __webpack_require__("./hover-card");
|
|
726
726
|
var __rspack_reexport = {};
|
|
727
727
|
for(const __rspack_import_key in _hover_card__rspack_import_39)if ([
|
|
728
728
|
"getReferenceChipColors",
|
|
@@ -1144,7 +1144,7 @@ var __webpack_exports__ = {};
|
|
|
1144
1144
|
"ReferenceChip"
|
|
1145
1145
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_switch__rspack_import_82[__rspack_import_key];
|
|
1146
1146
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
1147
|
-
var _table__rspack_import_83 = __webpack_require__("
|
|
1147
|
+
var _table__rspack_import_83 = __webpack_require__("@/components/ui/table");
|
|
1148
1148
|
var __rspack_reexport = {};
|
|
1149
1149
|
for(const __rspack_import_key in _table__rspack_import_83)if ([
|
|
1150
1150
|
"getReferenceChipColors",
|
|
@@ -1214,7 +1214,7 @@ var __webpack_exports__ = {};
|
|
|
1214
1214
|
"ReferenceChip"
|
|
1215
1215
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_tool_call__rspack_import_89[__rspack_import_key];
|
|
1216
1216
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
1217
|
-
var _tooltip__rspack_import_90 = __webpack_require__("
|
|
1217
|
+
var _tooltip__rspack_import_90 = __webpack_require__("./tooltip");
|
|
1218
1218
|
var __rspack_reexport = {};
|
|
1219
1219
|
for(const __rspack_import_key in _tooltip__rspack_import_90)if ([
|
|
1220
1220
|
"getReferenceChipColors",
|
|
@@ -52,7 +52,7 @@ const Input = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ 'aria-d
|
|
|
52
52
|
...props,
|
|
53
53
|
...validation.aria,
|
|
54
54
|
disabled: props.disabled || group.disabled,
|
|
55
|
-
className: (0, utils_cjs_namespaceObject.cn)('flex w-full transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring read-only:cursor-default disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-error aria-invalid:focus-visible:ring-error', 'future:focus-visible:ring-primary future:aria-invalid:focus-visible:ring-error', 'default' === size && 'h-9 rounded-md px-3 py-1 text-base placeholder:text-muted-foreground md:text-sm', 'xs' === size && 'h-6 rounded px-2 text-xs placeholder:text-muted-foreground', 'default' === variant && 'border border-input bg-transparent', 'ghost' === variant && 'border-0 bg-surface-overlay', 'default' === variant && 'default' === size && 'future:h-10 future:rounded-xl future:border-0 future:bg-surface-overlay future:py-2 future:text-sm future:placeholder:text-foreground-muted future:placeholder:font-normal future:focus-visible:ring-offset-2 future:focus-visible:ring-offset-background future:aria-invalid:ring-1 future:aria-invalid:ring-error/40', group.inGroup && IN_GROUP_CLASS, className),
|
|
55
|
+
className: (0, utils_cjs_namespaceObject.cn)('flex w-full transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring read-only:cursor-default disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-error aria-invalid:focus-visible:ring-error', 'future:focus-visible:ring-primary future:aria-invalid:focus-visible:ring-error', 'default' === size && 'h-9 rounded-md px-3 py-1 text-base placeholder:text-muted-foreground md:text-sm', 'xs' === size && 'h-6 rounded px-2 text-xs placeholder:text-muted-foreground', 'default' === variant && 'border border-input bg-transparent', 'ghost' === variant && 'border-0 bg-surface-overlay', 'none' === variant && 'border-0 bg-transparent shadow-none', 'default' === variant && 'default' === size && 'future:h-10 future:rounded-xl future:border-0 future:bg-surface-overlay future:py-2 future:text-sm future:placeholder:text-foreground-muted future:placeholder:font-normal future:focus-visible:ring-offset-2 future:focus-visible:ring-offset-background future:aria-invalid:ring-1 future:aria-invalid:ring-error/40', group.inGroup && IN_GROUP_CLASS, className),
|
|
56
56
|
ref: ref
|
|
57
57
|
});
|
|
58
58
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size'> {
|
|
3
|
-
|
|
3
|
+
/** `none` paints no box in any theme, for a caller whose `className` draws its own. */
|
|
4
|
+
variant?: 'default' | 'ghost' | 'none';
|
|
4
5
|
size?: 'default' | 'xs';
|
|
5
6
|
/**
|
|
6
7
|
* Field-specific feedback rendered immediately below the input.
|
|
@@ -24,7 +24,7 @@ const Input = /*#__PURE__*/ forwardRef(({ 'aria-describedby': ariaDescribedBy, '
|
|
|
24
24
|
...props,
|
|
25
25
|
...validation.aria,
|
|
26
26
|
disabled: props.disabled || group.disabled,
|
|
27
|
-
className: cn('flex w-full transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring read-only:cursor-default disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-error aria-invalid:focus-visible:ring-error', 'future:focus-visible:ring-primary future:aria-invalid:focus-visible:ring-error', 'default' === size && 'h-9 rounded-md px-3 py-1 text-base placeholder:text-muted-foreground md:text-sm', 'xs' === size && 'h-6 rounded px-2 text-xs placeholder:text-muted-foreground', 'default' === variant && 'border border-input bg-transparent', 'ghost' === variant && 'border-0 bg-surface-overlay', 'default' === variant && 'default' === size && 'future:h-10 future:rounded-xl future:border-0 future:bg-surface-overlay future:py-2 future:text-sm future:placeholder:text-foreground-muted future:placeholder:font-normal future:focus-visible:ring-offset-2 future:focus-visible:ring-offset-background future:aria-invalid:ring-1 future:aria-invalid:ring-error/40', group.inGroup && IN_GROUP_CLASS, className),
|
|
27
|
+
className: cn('flex w-full transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring read-only:cursor-default disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-error aria-invalid:focus-visible:ring-error', 'future:focus-visible:ring-primary future:aria-invalid:focus-visible:ring-error', 'default' === size && 'h-9 rounded-md px-3 py-1 text-base placeholder:text-muted-foreground md:text-sm', 'xs' === size && 'h-6 rounded px-2 text-xs placeholder:text-muted-foreground', 'default' === variant && 'border border-input bg-transparent', 'ghost' === variant && 'border-0 bg-surface-overlay', 'none' === variant && 'border-0 bg-transparent shadow-none', 'default' === variant && 'default' === size && 'future:h-10 future:rounded-xl future:border-0 future:bg-surface-overlay future:py-2 future:text-sm future:placeholder:text-foreground-muted future:placeholder:font-normal future:focus-visible:ring-offset-2 future:focus-visible:ring-offset-background future:aria-invalid:ring-1 future:aria-invalid:ring-error/40', group.inGroup && IN_GROUP_CLASS, className),
|
|
28
28
|
ref: ref
|
|
29
29
|
});
|
|
30
30
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
@@ -38,13 +38,30 @@ const index_cjs_namespaceObject = require("../../lib/index.cjs");
|
|
|
38
38
|
const DEFAULT_SEARCH_STRINGS = {
|
|
39
39
|
clear: 'Clear'
|
|
40
40
|
};
|
|
41
|
-
const Search = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ className, value, onChange, onClear, showClearButton = true, variant, size, error, errorId, strings, ...props }, ref)=>{
|
|
41
|
+
const Search = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ className, value, onChange, onValueChange, onClear, showClearButton = true, variant, size, error, errorId, strings, ...props }, ref)=>{
|
|
42
42
|
const text = {
|
|
43
43
|
...DEFAULT_SEARCH_STRINGS,
|
|
44
44
|
...strings
|
|
45
45
|
};
|
|
46
|
+
const inputRef = external_react_namespaceObject.useRef(null);
|
|
47
|
+
const setRef = external_react_namespaceObject.useMemo(()=>(0, index_cjs_namespaceObject.composeRefs)(ref, inputRef), [
|
|
48
|
+
ref
|
|
49
|
+
]);
|
|
50
|
+
const handleChange = (e)=>{
|
|
51
|
+
if (onValueChange) {
|
|
52
|
+
onChange?.(e);
|
|
53
|
+
onValueChange(e.target.value);
|
|
54
|
+
} else onChange?.(e.target.value);
|
|
55
|
+
};
|
|
46
56
|
const handleClear = ()=>{
|
|
47
|
-
|
|
57
|
+
const input = inputRef.current;
|
|
58
|
+
if (input) {
|
|
59
|
+
Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set?.call(input, '');
|
|
60
|
+
input.dispatchEvent(new Event('input', {
|
|
61
|
+
bubbles: true
|
|
62
|
+
}));
|
|
63
|
+
input.focus();
|
|
64
|
+
}
|
|
48
65
|
onClear?.();
|
|
49
66
|
};
|
|
50
67
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_input_group_cjs_namespaceObject.InputGroup, {
|
|
@@ -61,11 +78,11 @@ const Search = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ classN
|
|
|
61
78
|
})
|
|
62
79
|
}),
|
|
63
80
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupInput, {
|
|
64
|
-
ref:
|
|
81
|
+
ref: setRef,
|
|
65
82
|
type: "search",
|
|
66
83
|
className: (0, index_cjs_namespaceObject.cn)('[&::-webkit-search-cancel-button]:appearance-none [&::-webkit-search-decoration]:appearance-none', className),
|
|
67
84
|
value: value,
|
|
68
|
-
onChange:
|
|
85
|
+
onChange: handleChange,
|
|
69
86
|
...props
|
|
70
87
|
}),
|
|
71
88
|
showClearButton && value && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupAddon, {
|
|
@@ -84,6 +101,8 @@ const Search = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ classN
|
|
|
84
101
|
Search.displayName = 'Search';
|
|
85
102
|
const SearchWithSuggestions = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ value, onChange, placeholder = 'Search...', suggestions = [], onSelect, emptyMessage = 'No results found.', className, strings }, ref)=>{
|
|
86
103
|
const [open, setOpen] = external_react_namespaceObject.useState(false);
|
|
104
|
+
const anchorRef = external_react_namespaceObject.useRef(null);
|
|
105
|
+
const popupId = external_react_namespaceObject.useId();
|
|
87
106
|
const [searchValue, setSearchValue] = external_react_namespaceObject.useState(value || '');
|
|
88
107
|
external_react_namespaceObject.useEffect(()=>{
|
|
89
108
|
if (void 0 !== value) setSearchValue(value);
|
|
@@ -102,33 +121,39 @@ const SearchWithSuggestions = /*#__PURE__*/ external_react_namespaceObject.forwa
|
|
|
102
121
|
onChange?.(newValue);
|
|
103
122
|
setOpen(newValue.length > 0);
|
|
104
123
|
};
|
|
124
|
+
const isOpen = open && filteredSuggestions.length > 0;
|
|
105
125
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
106
126
|
ref: ref,
|
|
107
127
|
"data-slot": "search-with-suggestions",
|
|
108
128
|
className: (0, index_cjs_namespaceObject.cn)('relative', className),
|
|
109
129
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_popover_cjs_namespaceObject.Popover, {
|
|
110
|
-
open:
|
|
130
|
+
open: isOpen,
|
|
111
131
|
onOpenChange: setOpen,
|
|
112
132
|
children: [
|
|
113
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.
|
|
133
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverAnchor, {
|
|
114
134
|
asChild: true,
|
|
115
135
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
136
|
+
ref: anchorRef,
|
|
116
137
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Search, {
|
|
117
138
|
value: searchValue,
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
setSearchValue('');
|
|
121
|
-
onChange?.('');
|
|
122
|
-
setOpen(false);
|
|
123
|
-
},
|
|
139
|
+
onValueChange: handleInputChange,
|
|
140
|
+
onClick: ()=>setOpen(true),
|
|
124
141
|
placeholder: placeholder,
|
|
125
|
-
strings: strings
|
|
142
|
+
strings: strings,
|
|
143
|
+
"aria-haspopup": "dialog",
|
|
144
|
+
"aria-expanded": isOpen,
|
|
145
|
+
"aria-controls": isOpen ? popupId : void 0
|
|
126
146
|
})
|
|
127
147
|
})
|
|
128
148
|
}),
|
|
129
149
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverContent, {
|
|
150
|
+
id: popupId,
|
|
130
151
|
className: "w-[--radix-popover-trigger-width] p-0",
|
|
131
152
|
align: "start",
|
|
153
|
+
onOpenAutoFocus: (e)=>e.preventDefault(),
|
|
154
|
+
onInteractOutside: (e)=>{
|
|
155
|
+
if (anchorRef.current?.contains(e.target)) e.preventDefault();
|
|
156
|
+
},
|
|
132
157
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_command_cjs_namespaceObject.Command, {
|
|
133
158
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_command_cjs_namespaceObject.CommandList, {
|
|
134
159
|
children: 0 === filteredSuggestions.length ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_command_cjs_namespaceObject.CommandEmpty, {
|
|
@@ -5,9 +5,8 @@ export interface SearchStrings {
|
|
|
5
5
|
clear: string;
|
|
6
6
|
}
|
|
7
7
|
export declare const DEFAULT_SEARCH_STRINGS: SearchStrings;
|
|
8
|
-
|
|
8
|
+
interface SearchBaseProps extends Omit<InputGroupInputProps, 'onChange'> {
|
|
9
9
|
value?: string;
|
|
10
|
-
onChange?: (value: string) => void;
|
|
11
10
|
onClear?: () => void;
|
|
12
11
|
showClearButton?: boolean;
|
|
13
12
|
variant?: InputGroupProps['variant'];
|
|
@@ -19,6 +18,22 @@ export interface SearchProps extends Omit<InputGroupInputProps, 'onChange'> {
|
|
|
19
18
|
/** Overrides for any subset of the built-in labels. */
|
|
20
19
|
strings?: Partial<SearchStrings>;
|
|
21
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Two modes:
|
|
23
|
+
* - Standard (new integrations; required with `asChild` wrappers like
|
|
24
|
+
* cmdk `Command.Input` or Radix Slot): pass `onValueChange` for the
|
|
25
|
+
* string value; `onChange` receives the native event.
|
|
26
|
+
* - Legacy (existing consumers): omit `onValueChange`;
|
|
27
|
+
* `onChange` receives the string value.
|
|
28
|
+
*/
|
|
29
|
+
export type SearchProps = SearchBaseProps & ({
|
|
30
|
+
onValueChange: (value: string) => void;
|
|
31
|
+
onChange?: React.ChangeEventHandler<HTMLInputElement>;
|
|
32
|
+
} | {
|
|
33
|
+
onValueChange?: undefined;
|
|
34
|
+
/** @deprecated Pass `onValueChange` instead; `onChange` will receive the native event. */
|
|
35
|
+
onChange?: (value: string) => void;
|
|
36
|
+
});
|
|
22
37
|
declare const Search: React.ForwardRefExoticComponent<SearchProps & React.RefAttributes<HTMLInputElement>>;
|
|
23
38
|
export interface SearchWithSuggestionsProps {
|
|
24
39
|
value?: string;
|
|
@@ -1,20 +1,37 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Search, X } from "lucide-react";
|
|
3
|
-
import { forwardRef, useEffect, useState } from "react";
|
|
3
|
+
import { forwardRef, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
4
4
|
import { Command, CommandEmpty, CommandGroup, CommandItem, CommandList } from "./command.js";
|
|
5
5
|
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from "./input-group.js";
|
|
6
|
-
import { Popover,
|
|
7
|
-
import { cn } from "../../lib/index.js";
|
|
6
|
+
import { Popover, PopoverAnchor, PopoverContent } from "./popover.js";
|
|
7
|
+
import { cn, composeRefs } from "../../lib/index.js";
|
|
8
8
|
const DEFAULT_SEARCH_STRINGS = {
|
|
9
9
|
clear: 'Clear'
|
|
10
10
|
};
|
|
11
|
-
const search_Search = /*#__PURE__*/ forwardRef(({ className, value, onChange, onClear, showClearButton = true, variant, size, error, errorId, strings, ...props }, ref)=>{
|
|
11
|
+
const search_Search = /*#__PURE__*/ forwardRef(({ className, value, onChange, onValueChange, onClear, showClearButton = true, variant, size, error, errorId, strings, ...props }, ref)=>{
|
|
12
12
|
const text = {
|
|
13
13
|
...DEFAULT_SEARCH_STRINGS,
|
|
14
14
|
...strings
|
|
15
15
|
};
|
|
16
|
+
const inputRef = useRef(null);
|
|
17
|
+
const setRef = useMemo(()=>composeRefs(ref, inputRef), [
|
|
18
|
+
ref
|
|
19
|
+
]);
|
|
20
|
+
const handleChange = (e)=>{
|
|
21
|
+
if (onValueChange) {
|
|
22
|
+
onChange?.(e);
|
|
23
|
+
onValueChange(e.target.value);
|
|
24
|
+
} else onChange?.(e.target.value);
|
|
25
|
+
};
|
|
16
26
|
const handleClear = ()=>{
|
|
17
|
-
|
|
27
|
+
const input = inputRef.current;
|
|
28
|
+
if (input) {
|
|
29
|
+
Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set?.call(input, '');
|
|
30
|
+
input.dispatchEvent(new Event('input', {
|
|
31
|
+
bubbles: true
|
|
32
|
+
}));
|
|
33
|
+
input.focus();
|
|
34
|
+
}
|
|
18
35
|
onClear?.();
|
|
19
36
|
};
|
|
20
37
|
return /*#__PURE__*/ jsxs(InputGroup, {
|
|
@@ -31,11 +48,11 @@ const search_Search = /*#__PURE__*/ forwardRef(({ className, value, onChange, on
|
|
|
31
48
|
})
|
|
32
49
|
}),
|
|
33
50
|
/*#__PURE__*/ jsx(InputGroupInput, {
|
|
34
|
-
ref:
|
|
51
|
+
ref: setRef,
|
|
35
52
|
type: "search",
|
|
36
53
|
className: cn('[&::-webkit-search-cancel-button]:appearance-none [&::-webkit-search-decoration]:appearance-none', className),
|
|
37
54
|
value: value,
|
|
38
|
-
onChange:
|
|
55
|
+
onChange: handleChange,
|
|
39
56
|
...props
|
|
40
57
|
}),
|
|
41
58
|
showClearButton && value && /*#__PURE__*/ jsx(InputGroupAddon, {
|
|
@@ -54,6 +71,8 @@ const search_Search = /*#__PURE__*/ forwardRef(({ className, value, onChange, on
|
|
|
54
71
|
search_Search.displayName = 'Search';
|
|
55
72
|
const SearchWithSuggestions = /*#__PURE__*/ forwardRef(({ value, onChange, placeholder = 'Search...', suggestions = [], onSelect, emptyMessage = 'No results found.', className, strings }, ref)=>{
|
|
56
73
|
const [open, setOpen] = useState(false);
|
|
74
|
+
const anchorRef = useRef(null);
|
|
75
|
+
const popupId = useId();
|
|
57
76
|
const [searchValue, setSearchValue] = useState(value || '');
|
|
58
77
|
useEffect(()=>{
|
|
59
78
|
if (void 0 !== value) setSearchValue(value);
|
|
@@ -72,33 +91,39 @@ const SearchWithSuggestions = /*#__PURE__*/ forwardRef(({ value, onChange, place
|
|
|
72
91
|
onChange?.(newValue);
|
|
73
92
|
setOpen(newValue.length > 0);
|
|
74
93
|
};
|
|
94
|
+
const isOpen = open && filteredSuggestions.length > 0;
|
|
75
95
|
return /*#__PURE__*/ jsx("div", {
|
|
76
96
|
ref: ref,
|
|
77
97
|
"data-slot": "search-with-suggestions",
|
|
78
98
|
className: cn('relative', className),
|
|
79
99
|
children: /*#__PURE__*/ jsxs(Popover, {
|
|
80
|
-
open:
|
|
100
|
+
open: isOpen,
|
|
81
101
|
onOpenChange: setOpen,
|
|
82
102
|
children: [
|
|
83
|
-
/*#__PURE__*/ jsx(
|
|
103
|
+
/*#__PURE__*/ jsx(PopoverAnchor, {
|
|
84
104
|
asChild: true,
|
|
85
105
|
children: /*#__PURE__*/ jsx("div", {
|
|
106
|
+
ref: anchorRef,
|
|
86
107
|
children: /*#__PURE__*/ jsx(search_Search, {
|
|
87
108
|
value: searchValue,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
setSearchValue('');
|
|
91
|
-
onChange?.('');
|
|
92
|
-
setOpen(false);
|
|
93
|
-
},
|
|
109
|
+
onValueChange: handleInputChange,
|
|
110
|
+
onClick: ()=>setOpen(true),
|
|
94
111
|
placeholder: placeholder,
|
|
95
|
-
strings: strings
|
|
112
|
+
strings: strings,
|
|
113
|
+
"aria-haspopup": "dialog",
|
|
114
|
+
"aria-expanded": isOpen,
|
|
115
|
+
"aria-controls": isOpen ? popupId : void 0
|
|
96
116
|
})
|
|
97
117
|
})
|
|
98
118
|
}),
|
|
99
119
|
/*#__PURE__*/ jsx(PopoverContent, {
|
|
120
|
+
id: popupId,
|
|
100
121
|
className: "w-[--radix-popover-trigger-width] p-0",
|
|
101
122
|
align: "start",
|
|
123
|
+
onOpenAutoFocus: (e)=>e.preventDefault(),
|
|
124
|
+
onInteractOutside: (e)=>{
|
|
125
|
+
if (anchorRef.current?.contains(e.target)) e.preventDefault();
|
|
126
|
+
},
|
|
102
127
|
children: /*#__PURE__*/ jsx(Command, {
|
|
103
128
|
children: /*#__PURE__*/ jsx(CommandList, {
|
|
104
129
|
children: 0 === filteredSuggestions.length ? /*#__PURE__*/ jsx(CommandEmpty, {
|
package/dist/styles.css
CHANGED