@rovula/ui 0.1.42 → 0.1.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/bundle.js +1 -1
- package/dist/cjs/bundle.js.map +1 -1
- package/dist/cjs/types/components/AutoComplete/AutoComplete.d.ts +3 -1
- package/dist/cjs/types/components/AutoComplete/AutoComplete.stories.d.ts +2 -1
- package/dist/components/AutoComplete/AutoComplete.js +4 -4
- package/dist/esm/bundle.js +1 -1
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/types/components/AutoComplete/AutoComplete.d.ts +3 -1
- package/dist/esm/types/components/AutoComplete/AutoComplete.stories.d.ts +2 -1
- package/dist/index.d.ts +3 -1
- package/package.json +1 -1
- package/src/components/AutoComplete/AutoComplete.tsx +7 -2
|
@@ -61,13 +61,15 @@ export type AutoCompleteProps<T extends AutoCompleteOption = AutoCompleteOption>
|
|
|
61
61
|
listboxClassName?: string;
|
|
62
62
|
/** Extra inline styles applied to the options list container */
|
|
63
63
|
listboxStyle?: React.CSSProperties;
|
|
64
|
+
/** Extra inline styles applied to the Popover content wrapper (portal mode only) */
|
|
65
|
+
popoverStyle?: React.CSSProperties;
|
|
64
66
|
/** Extra className applied to each option item */
|
|
65
67
|
optionClassName?: string;
|
|
66
68
|
/** Extra inline styles applied to each option item */
|
|
67
69
|
optionStyle?: React.CSSProperties;
|
|
68
70
|
"data-testid"?: string;
|
|
69
71
|
} & Omit<InputProps, OmittedInputProps>;
|
|
70
|
-
declare function AutoCompleteInner<T extends AutoCompleteOption = AutoCompleteOption>({ options, value, onChange, onSelect, onBlur, onSearch, loading, noOptionsText, showNoOptions, renderOption, filterOptions, portal, listboxClassName, listboxStyle, optionClassName, optionStyle, "data-testid": testId, id, label, fullwidth, size, rounded, variant, disabled, ...rest }: AutoCompleteProps<T>, ref: React.ForwardedRef<HTMLInputElement>): import("react/jsx-runtime").JSX.Element;
|
|
72
|
+
declare function AutoCompleteInner<T extends AutoCompleteOption = AutoCompleteOption>({ options, value, onChange, onSelect, onBlur, onSearch, loading, noOptionsText, showNoOptions, renderOption, filterOptions, portal, listboxClassName, listboxStyle, popoverStyle, optionClassName, optionStyle, "data-testid": testId, id, label, fullwidth, size, rounded, variant, disabled, ...rest }: AutoCompleteProps<T>, ref: React.ForwardedRef<HTMLInputElement>): import("react/jsx-runtime").JSX.Element;
|
|
71
73
|
declare const AutoComplete: <T extends AutoCompleteOption = AutoCompleteOption>(props: AutoCompleteProps<T> & {
|
|
72
74
|
ref?: React.ForwardedRef<HTMLInputElement>;
|
|
73
75
|
}) => ReturnType<typeof AutoCompleteInner>;
|
|
@@ -5,7 +5,7 @@ declare const meta: {
|
|
|
5
5
|
title: string;
|
|
6
6
|
component: <T extends AutoCompleteOption = AutoCompleteOption>(props: import("./AutoComplete").AutoCompleteProps<T> & {
|
|
7
7
|
ref?: React.ForwardedRef<HTMLInputElement>;
|
|
8
|
-
}) => ReturnType<(<T_1 extends AutoCompleteOption = AutoCompleteOption>({ options, value, onChange, onSelect, onBlur, onSearch, loading, noOptionsText, showNoOptions, renderOption, filterOptions, portal, listboxClassName, listboxStyle, optionClassName, optionStyle, "data-testid": testId, id, label, fullwidth, size, rounded, variant, disabled, ...rest }: import("./AutoComplete").AutoCompleteProps<T_1>, ref: React.ForwardedRef<HTMLInputElement>) => import("react/jsx-runtime").JSX.Element)>;
|
|
8
|
+
}) => ReturnType<(<T_1 extends AutoCompleteOption = AutoCompleteOption>({ options, value, onChange, onSelect, onBlur, onSearch, loading, noOptionsText, showNoOptions, renderOption, filterOptions, portal, listboxClassName, listboxStyle, popoverStyle, optionClassName, optionStyle, "data-testid": testId, id, label, fullwidth, size, rounded, variant, disabled, ...rest }: import("./AutoComplete").AutoCompleteProps<T_1>, ref: React.ForwardedRef<HTMLInputElement>) => import("react/jsx-runtime").JSX.Element)>;
|
|
9
9
|
tags: string[];
|
|
10
10
|
parameters: {
|
|
11
11
|
layout: string;
|
|
@@ -25,6 +25,7 @@ declare const meta: {
|
|
|
25
25
|
portal?: boolean | undefined;
|
|
26
26
|
listboxClassName?: string | undefined;
|
|
27
27
|
listboxStyle?: React.CSSProperties | undefined;
|
|
28
|
+
popoverStyle?: React.CSSProperties | undefined;
|
|
28
29
|
optionClassName?: string | undefined;
|
|
29
30
|
optionStyle?: React.CSSProperties | undefined;
|
|
30
31
|
"data-testid"?: string | undefined;
|
|
@@ -26,9 +26,9 @@ function AutoCompleteInner(_a, ref) {
|
|
|
26
26
|
var _b;
|
|
27
27
|
var {
|
|
28
28
|
// AutoComplete-specific props
|
|
29
|
-
options, value = "", onChange, onSelect, onBlur, onSearch, loading = false, noOptionsText = "No results", showNoOptions = false, renderOption, filterOptions = (x) => x, portal = true, listboxClassName, listboxStyle, optionClassName, optionStyle, "data-testid": testId,
|
|
29
|
+
options, value = "", onChange, onSelect, onBlur, onSearch, loading = false, noOptionsText = "No results", showNoOptions = false, renderOption, filterOptions = (x) => x, portal = true, listboxClassName, listboxStyle, popoverStyle, optionClassName, optionStyle, "data-testid": testId,
|
|
30
30
|
// InputProps with explicit defaults (rest passes everything else through)
|
|
31
|
-
id, label, fullwidth = true, size = "md", rounded = "normal", variant = "outline", disabled } = _a, rest = __rest(_a, ["options", "value", "onChange", "onSelect", "onBlur", "onSearch", "loading", "noOptionsText", "showNoOptions", "renderOption", "filterOptions", "portal", "listboxClassName", "listboxStyle", "optionClassName", "optionStyle", "data-testid", "id", "label", "fullwidth", "size", "rounded", "variant", "disabled"]);
|
|
31
|
+
id, label, fullwidth = true, size = "md", rounded = "normal", variant = "outline", disabled } = _a, rest = __rest(_a, ["options", "value", "onChange", "onSelect", "onBlur", "onSearch", "loading", "noOptionsText", "showNoOptions", "renderOption", "filterOptions", "portal", "listboxClassName", "listboxStyle", "popoverStyle", "optionClassName", "optionStyle", "data-testid", "id", "label", "fullwidth", "size", "rounded", "variant", "disabled"]);
|
|
32
32
|
const [open, setOpen] = useState(false);
|
|
33
33
|
const [activeIndex, setActiveIndex] = useState(-1);
|
|
34
34
|
const inputRef = useRef(null);
|
|
@@ -85,7 +85,7 @@ function AutoCompleteInner(_a, ref) {
|
|
|
85
85
|
setActiveIndex(-1);
|
|
86
86
|
}
|
|
87
87
|
}, [open, activeIndex, filteredOptions, commitSelection]);
|
|
88
|
-
const listContent = (_jsx("div", { role: "listbox", style: Object.assign({ boxShadow: "var(--dropdown-menu-shadow)" }, listboxStyle), className: cn("rounded-md border border-bg-stroke3
|
|
88
|
+
const listContent = (_jsx("div", { role: "listbox", style: Object.assign({ boxShadow: "var(--dropdown-menu-shadow)" }, listboxStyle), className: cn("max-h-60 overflow-y-auto", "rounded-md border border-bg-stroke3", "bg-modal-dropdown-surface text-text-g-contrast-high", !portal && "absolute top-full left-0 w-full -mt-3 z-[51]", portal && "z-[51]", listboxClassName), "data-testid": testId ? `${testId}-listbox` : undefined, children: loading ? (_jsx("div", { className: "flex items-center justify-center py-6", children: _jsx(Loading, { size: 20 }) })) : filteredOptions.length === 0 ? (_jsx("div", { className: "px-4 py-6 text-center", children: _jsx(Text, { variant: "small1", className: "text-[var(--dropdown-menu-default-text)]", children: noOptionsText }) })) : (filteredOptions.map((option, index) => {
|
|
89
89
|
const isSelected = option.value === value;
|
|
90
90
|
const isActive = index === activeIndex;
|
|
91
91
|
return (_jsxs("button", { id: `autocomplete-option-${option.value}`, type: "button", role: "option", "aria-selected": isSelected, style: optionStyle, className: cn(menuItemBaseStyles, "w-full", isSelected &&
|
|
@@ -95,7 +95,7 @@ function AutoCompleteInner(_a, ref) {
|
|
|
95
95
|
})) }));
|
|
96
96
|
return (_jsxs(PopoverPrimitive.Root, { open: showPopover, children: [_jsx(PopoverPrimitive.Anchor, { asChild: true, children: _jsxs("div", { className: cn("relative", fullwidth && "w-full"), children: [_jsx(TextInput, Object.assign({}, rest, { ref: ref !== null && ref !== void 0 ? ref : inputRef, id: id, label: label, value: value, size: size, rounded: rounded, variant: variant, disabled: disabled, fullwidth: fullwidth, autoComplete: "off", role: "combobox", "aria-expanded": showPopover, "aria-autocomplete": "list", "aria-activedescendant": activeIndex >= 0
|
|
97
97
|
? `autocomplete-option-${(_b = filteredOptions[activeIndex]) === null || _b === void 0 ? void 0 : _b.value}`
|
|
98
|
-
: undefined, hasClearIcon: true, onChange: handleInputChange, onFocus: handleFocus, onBlur: handleBlur, onKeyDown: handleKeyDown, "data-testid": testId })), showPopover && !portal && listContent] }) }), portal && (_jsx(PopoverPrimitive.Portal, { children: _jsx(PopoverPrimitive.Content, { onOpenAutoFocus: (e) => e.preventDefault(), onInteractOutside: (e) => e.preventDefault(), onFocusOutside: (e) => e.preventDefault(), side: "bottom", align: "start", sideOffset: -12, style: { width: "var(--radix-popover-trigger-width)" }, children: listContent }) }))] }));
|
|
98
|
+
: undefined, hasClearIcon: true, onChange: handleInputChange, onFocus: handleFocus, onBlur: handleBlur, onKeyDown: handleKeyDown, "data-testid": testId })), showPopover && !portal && listContent] }) }), portal && (_jsx(PopoverPrimitive.Portal, { children: _jsx(PopoverPrimitive.Content, { onOpenAutoFocus: (e) => e.preventDefault(), onInteractOutside: (e) => e.preventDefault(), onFocusOutside: (e) => e.preventDefault(), side: "bottom", align: "start", sideOffset: -12, style: Object.assign({ width: "var(--radix-popover-trigger-width)", zIndex: 51 }, popoverStyle), children: listContent }) }))] }));
|
|
99
99
|
}
|
|
100
100
|
// forwardRef with generics requires a manual cast
|
|
101
101
|
const AutoComplete = forwardRef(AutoCompleteInner);
|