@magicx-eng/ai-autocomplete-react 0.1.24 → 0.1.26
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/README.md +28 -2
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +134 -40
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +134 -40
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/index.css +0 -2
- package/dist/index.css.map +0 -1
package/README.md
CHANGED
|
@@ -58,7 +58,6 @@ function App() {
|
|
|
58
58
|
console.log(result.raw_query); // "Create a {{TASK_1}}"
|
|
59
59
|
console.log(result.completed_params); // [{ placeholder: "{{TASK_1}}", type: "task", ... }]
|
|
60
60
|
}}
|
|
61
|
-
placeholder="Create a"
|
|
62
61
|
className="my-autocomplete"
|
|
63
62
|
/>
|
|
64
63
|
);
|
|
@@ -140,7 +139,6 @@ function App() {
|
|
|
140
139
|
| `apiConfig?` | `APIConfig` | — | Runtime API configuration (see below). |
|
|
141
140
|
| `optionOverrides?` | `Record<string, (query: string) => SuggestionOption[]>` | — | Override options per suggestion type. |
|
|
142
141
|
| `maskCompletedText?` | `boolean` | `false` | When `true`, omits completed params' literal text from API requests (for masking PII/sensitive values from the server). |
|
|
143
|
-
| `placeholder?` | `string` | — | Fallback placeholder when the server doesn't return one. |
|
|
144
142
|
| `className?` | `string` | — | CSS class applied to the container. |
|
|
145
143
|
| `columns?` | `number` | `2` | Number of columns in the dropdown grid. |
|
|
146
144
|
| `pillPlacement?` | `"inline" \| "dropdown" \| "hidden"` | `"inline"` | Where to render unfilled pills. `"hidden"` hides pills entirely. |
|
|
@@ -282,8 +280,13 @@ Override on the container (via `className`). All defaults use `:where()` (zero s
|
|
|
282
280
|
| `--aia-option-font-size` | `19px` | `19px` | Option font size |
|
|
283
281
|
| `--aia-written-text-color` | `#000000` | `#ffffff` | Input text |
|
|
284
282
|
| `--aia-written-text-font-size` | `19px` | `19px` | Input text font size |
|
|
283
|
+
| `--aia-caret-color` | `--aia-written-text-color` | `--aia-written-text-color` | Textarea caret color. Override independently of input text color. |
|
|
284
|
+
| `--aia-submit-bg` | `#000000` | `#ffffff` | Submit button background |
|
|
285
|
+
| `--aia-submit-color` | `#ffffff` | `#000000` | Submit button icon color |
|
|
285
286
|
| `--aia-dropdown-bg` | — | — | Optional bg color the dropdown's "glass" rim shadow tints toward. Set this to the page background behind the dropdown so the bottom-corner glow blends seamlessly. |
|
|
286
287
|
| `--aia-scrollbar-thumb` | `rgba(0, 0, 0, 0.3)` | `rgba(0, 0, 0, 0.3)` | Color of the option list's scrollbar thumb (Firefox + WebKit). |
|
|
288
|
+
| `--aia-streak-rgb` | `99, 102, 241` | `255, 255, 255` | Comma-separated RGB triplet used to tint the option-selection streak animation (consumed via `rgba(var(--aia-streak-rgb), …)`). |
|
|
289
|
+
| `--aia-streak-glass-bg` | `rgba(99, 102, 241, 0.1)` | `rgba(255, 255, 255, 0.1)` | Background fill for the streak's glass-pill effect. |
|
|
287
290
|
|
|
288
291
|
Legacy `--aia-color-*` variables are still supported as fallbacks.
|
|
289
292
|
|
|
@@ -298,6 +301,29 @@ Legacy `--aia-color-*` variables are still supported as fallbacks.
|
|
|
298
301
|
}
|
|
299
302
|
```
|
|
300
303
|
|
|
304
|
+
### Selector Hooks
|
|
305
|
+
|
|
306
|
+
For styling beyond the CSS variables, target these stable `data-aia-*` attributes (CSS-module class hashes are not part of the public API):
|
|
307
|
+
|
|
308
|
+
| Attribute | Element |
|
|
309
|
+
|---|---|
|
|
310
|
+
| `[data-aia-editor]` | Editor area wrapping the textarea + overlay |
|
|
311
|
+
| `[data-aia-textarea]` | The `<textarea>` |
|
|
312
|
+
| `[data-aia-submit]` | Submit button |
|
|
313
|
+
| `[data-aia-pill]` | Each unfilled-suggestion pill |
|
|
314
|
+
| `[data-aia-pillbar]` | Pill bar container inside the dropdown |
|
|
315
|
+
| `[data-aia-option]` | Each suggestion option |
|
|
316
|
+
| `[data-aia-dropdown]` | The dropdown root (listbox) |
|
|
317
|
+
|
|
318
|
+
```css
|
|
319
|
+
/* Solid (non-glass) dropdown */
|
|
320
|
+
.my-autocomplete [data-aia-dropdown] {
|
|
321
|
+
background: #fff;
|
|
322
|
+
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
|
|
323
|
+
backdrop-filter: none;
|
|
324
|
+
}
|
|
325
|
+
```
|
|
326
|
+
|
|
301
327
|
---
|
|
302
328
|
|
|
303
329
|
## Option Overrides
|
package/dist/index.d.mts
CHANGED
|
@@ -72,7 +72,6 @@ interface AIAutocompleteProps {
|
|
|
72
72
|
onError?: (error: Error) => void;
|
|
73
73
|
optionOverrides?: OptionOverrides;
|
|
74
74
|
maskCompletedText?: boolean;
|
|
75
|
-
placeholder?: string;
|
|
76
75
|
className?: string;
|
|
77
76
|
apiConfig?: APIConfig;
|
|
78
77
|
columns?: number;
|
|
@@ -101,7 +100,6 @@ interface UseAIAutocompleteOptions {
|
|
|
101
100
|
onError?: (error: Error) => void;
|
|
102
101
|
optionOverrides?: OptionOverrides;
|
|
103
102
|
maskCompletedText?: boolean;
|
|
104
|
-
placeholder?: string;
|
|
105
103
|
apiConfig?: APIConfig;
|
|
106
104
|
columns?: number;
|
|
107
105
|
/** When the dropdown appears. Default: "auto". */
|
|
@@ -130,6 +128,8 @@ interface UseAIAutocompleteReturn {
|
|
|
130
128
|
placeholder: string | undefined;
|
|
131
129
|
onChange: (e: ChangeEvent<HTMLTextAreaElement>) => void;
|
|
132
130
|
onKeyDown: (e: KeyboardEvent<HTMLTextAreaElement>) => void;
|
|
131
|
+
onFocus: () => void;
|
|
132
|
+
onBlur: () => void;
|
|
133
133
|
role: "combobox";
|
|
134
134
|
"aria-expanded": boolean;
|
|
135
135
|
"aria-activedescendant": string | undefined;
|
|
@@ -158,6 +158,6 @@ declare const AIAutocomplete: react.ForwardRefExoticComponent<AIAutocompleteProp
|
|
|
158
158
|
|
|
159
159
|
declare function AIAutocompleteDropdown({ suggestions, activeIndex, onSelect, onHighlight, isOpen, id, className, pills, onPillClick, showPills, }: AIAutocompleteDropdownProps): react_jsx_runtime.JSX.Element;
|
|
160
160
|
|
|
161
|
-
declare function useAIAutocomplete({ onSubmit, onError, optionOverrides, maskCompletedText,
|
|
161
|
+
declare function useAIAutocomplete({ onSubmit, onError, optionOverrides, maskCompletedText, apiConfig, columns, dropdownTrigger, value: controlledValue, completedParams: controlledParams, onChange: onChangeProp, onParamsChange, }: UseAIAutocompleteOptions): UseAIAutocompleteReturn;
|
|
162
162
|
|
|
163
163
|
export { AIAutocomplete, AIAutocompleteDropdown, type AIAutocompleteDropdownProps, type AIAutocompleteHandle, type AIAutocompleteProps, type APIConfig, type APIKeyConfig, type AccessTokenConfig, type AccessTokenResult, type AppearanceMode, type AutocompleteResult, type CompletedParam, type CompletedParamState, type OptionOverrides, type Segment, type Suggestion, type SuggestionOption, type TaskKind, type UseAIAutocompleteOptions, type UseAIAutocompleteReturn, useAIAutocomplete };
|
package/dist/index.d.ts
CHANGED
|
@@ -72,7 +72,6 @@ interface AIAutocompleteProps {
|
|
|
72
72
|
onError?: (error: Error) => void;
|
|
73
73
|
optionOverrides?: OptionOverrides;
|
|
74
74
|
maskCompletedText?: boolean;
|
|
75
|
-
placeholder?: string;
|
|
76
75
|
className?: string;
|
|
77
76
|
apiConfig?: APIConfig;
|
|
78
77
|
columns?: number;
|
|
@@ -101,7 +100,6 @@ interface UseAIAutocompleteOptions {
|
|
|
101
100
|
onError?: (error: Error) => void;
|
|
102
101
|
optionOverrides?: OptionOverrides;
|
|
103
102
|
maskCompletedText?: boolean;
|
|
104
|
-
placeholder?: string;
|
|
105
103
|
apiConfig?: APIConfig;
|
|
106
104
|
columns?: number;
|
|
107
105
|
/** When the dropdown appears. Default: "auto". */
|
|
@@ -130,6 +128,8 @@ interface UseAIAutocompleteReturn {
|
|
|
130
128
|
placeholder: string | undefined;
|
|
131
129
|
onChange: (e: ChangeEvent<HTMLTextAreaElement>) => void;
|
|
132
130
|
onKeyDown: (e: KeyboardEvent<HTMLTextAreaElement>) => void;
|
|
131
|
+
onFocus: () => void;
|
|
132
|
+
onBlur: () => void;
|
|
133
133
|
role: "combobox";
|
|
134
134
|
"aria-expanded": boolean;
|
|
135
135
|
"aria-activedescendant": string | undefined;
|
|
@@ -158,6 +158,6 @@ declare const AIAutocomplete: react.ForwardRefExoticComponent<AIAutocompleteProp
|
|
|
158
158
|
|
|
159
159
|
declare function AIAutocompleteDropdown({ suggestions, activeIndex, onSelect, onHighlight, isOpen, id, className, pills, onPillClick, showPills, }: AIAutocompleteDropdownProps): react_jsx_runtime.JSX.Element;
|
|
160
160
|
|
|
161
|
-
declare function useAIAutocomplete({ onSubmit, onError, optionOverrides, maskCompletedText,
|
|
161
|
+
declare function useAIAutocomplete({ onSubmit, onError, optionOverrides, maskCompletedText, apiConfig, columns, dropdownTrigger, value: controlledValue, completedParams: controlledParams, onChange: onChangeProp, onParamsChange, }: UseAIAutocompleteOptions): UseAIAutocompleteReturn;
|
|
162
162
|
|
|
163
163
|
export { AIAutocomplete, AIAutocompleteDropdown, type AIAutocompleteDropdownProps, type AIAutocompleteHandle, type AIAutocompleteProps, type APIConfig, type APIKeyConfig, type AccessTokenConfig, type AccessTokenResult, type AppearanceMode, type AutocompleteResult, type CompletedParam, type CompletedParamState, type OptionOverrides, type Segment, type Suggestion, type SuggestionOption, type TaskKind, type UseAIAutocompleteOptions, type UseAIAutocompleteReturn, useAIAutocomplete };
|