@magicx-eng/ai-autocomplete-react 0.12.1 → 0.14.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/README.md +121 -6
- package/dist/index.d.mts +31 -4
- package/dist/index.d.ts +31 -4
- package/dist/index.js +340 -268
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +340 -268
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -16,13 +16,14 @@ A React/TypeScript SDK that provides a guided AI-powered autocomplete experience
|
|
|
16
16
|
- **Keyboard navigation** — arrow keys, enter to submit, tab to autocomplete, backspace to un-bold the last completed param
|
|
17
17
|
- **IME-safe** — composition events are buffered so input text is committed once, after composition ends
|
|
18
18
|
- **Client-side filtering** — instant substring filtering on every keystroke
|
|
19
|
+
- **Datepicker** — date parameters are answered with a calendar instead of an option list. Click a day or navigate with the arrow keys; the date is committed the way it would be written — `Tuesday` for a date inside the next week, `March 23` for one later this year, `March 23 2027` for another year. Tapping a committed date re-opens the calendar on the month that text names now — for a weekday name, that is the next such day, not the one originally picked.
|
|
19
20
|
- **Option overrides** — inject or dynamically generate client-side options per suggestion type
|
|
20
21
|
- **Product strip (opt-in)** — plug in any platform's product search and the dropdown renders a horizontal row of product cards below the options; the SDK owns the UI, your integration owns only `fetch` and `transform`
|
|
21
22
|
- **Controlled & uncontrolled** — works out of the box or integrates with external state
|
|
22
23
|
- **Ref forwarding** — imperative `focus()`, `blur()`, `reset()`, and `setMode()` via ref
|
|
23
24
|
- **Accessible** — ARIA combobox 1.2 pattern with `role="listbox"`, `aria-activedescendant`
|
|
24
|
-
- **Animations** — option
|
|
25
|
-
- **Loading skeleton** — while a fetch is in flight, the dropdown and inline pills keep the previous layout (same count and widths) with their text masked and a shimmer pulse. The skeleton is held back until the
|
|
25
|
+
- **Animations** — option press (the picked option compresses while the rest step back), text shimmer on newly added params
|
|
26
|
+
- **Loading skeleton** — while a fetch is in flight, the dropdown and inline pills keep the previous layout (same count and widths) with their text masked and a shimmer pulse. The skeleton is held back until the option-press animation finishes, so taps don't visually "stutter" into loading.
|
|
26
27
|
- **Lightweight** — styles auto-injected at runtime
|
|
27
28
|
- **TypeScript first** — full type definitions shipped with the package
|
|
28
29
|
|
|
@@ -131,6 +132,87 @@ After a completed param is added (by any means — option click, exact-match typ
|
|
|
131
132
|
|
|
132
133
|
---
|
|
133
134
|
|
|
135
|
+
### Datepicker
|
|
136
|
+
|
|
137
|
+
When the next parameter is a date, the dropdown shows a calendar instead of a
|
|
138
|
+
list of options. A parameter counts as a date when its name says so, or when at
|
|
139
|
+
least three of the options it offers are themselves written as dates — so a
|
|
140
|
+
parameter called `when` or `arrival` still gets a calendar. Options written as
|
|
141
|
+
relative phrases (`today`, `next week`) are not read as dates; a parameter
|
|
142
|
+
offering those needs a name that says date.
|
|
143
|
+
|
|
144
|
+
Nothing is required to switch it on — a date parameter renders this way
|
|
145
|
+
automatically, and every other parameter is unaffected. Tier 1 and Tier 2
|
|
146
|
+
render the calendar for you; in Tier 3 the same data reaches `dropdownProps` so
|
|
147
|
+
you can render your own (see [Tier 3](#tier-3-headless)).
|
|
148
|
+
|
|
149
|
+
**What the user can do**
|
|
150
|
+
|
|
151
|
+
| Input | Result |
|
|
152
|
+
|---|---|
|
|
153
|
+
| Click a day | Commits that date |
|
|
154
|
+
| <kbd>↓</kbd> | Moves into the calendar, starting on today |
|
|
155
|
+
| <kbd>←</kbd> / <kbd>→</kbd> | Previous / next day, crossing week boundaries |
|
|
156
|
+
| <kbd>↑</kbd> / <kbd>↓</kbd> | Previous / next week. Past either end of the month, focus returns to the input |
|
|
157
|
+
| <kbd>Enter</kbd> | Commits the highlighted day |
|
|
158
|
+
| Month arrows | Page the calendar. Paging never commits anything |
|
|
159
|
+
| <kbd>→</kbd> at the end of the input | Skips the parameter, same as any other pill |
|
|
160
|
+
|
|
161
|
+
**The committed value** is written the way a person would write it, always in
|
|
162
|
+
English regardless of the visitor's locale, so the value you receive has one
|
|
163
|
+
vocabulary everywhere:
|
|
164
|
+
|
|
165
|
+
- a date inside the next week (today included) commits as its weekday name —
|
|
166
|
+
`Tuesday`. Like the sentence it sits in, that name is relative: read later,
|
|
167
|
+
it means the next such day;
|
|
168
|
+
- one further out in the current year as `MONTH DAY` — `March 23`;
|
|
169
|
+
- one in another year as `MONTH DAY YEAR` — `March 23 2027`.
|
|
170
|
+
|
|
171
|
+
It arrives as an ordinary completed parameter: bold in the input,
|
|
172
|
+
and present in `completed_params` on submit like any other answer.
|
|
173
|
+
|
|
174
|
+
**Re-editing** a committed date re-opens the calendar on the month the committed
|
|
175
|
+
text names, with that day marked, so changing an answer takes one click. For a
|
|
176
|
+
weekday name that reading is relative, so once the day it named has gone by,
|
|
177
|
+
re-editing marks the next such day rather than the one originally picked — the
|
|
178
|
+
calendar shows what the sentence says today, which is also what gets submitted.
|
|
179
|
+
|
|
180
|
+
**Reading the value back.** The date arrives as text, so if you need a `Date`
|
|
181
|
+
object, `parseDate` is exported for it:
|
|
182
|
+
|
|
183
|
+
```ts
|
|
184
|
+
import { parseDate } from "@magicx-eng/ai-autocomplete-react";
|
|
185
|
+
|
|
186
|
+
// Reads all three committed shapes: a weekday name is the one date it can
|
|
187
|
+
// mean in the next seven days, and a yearless month-day is the current year.
|
|
188
|
+
const due = parseDate("March 23"); // Date, or null if the text isn't one of ours
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
`parseLooseDate` is exported too, for the looser shapes a person types into a
|
|
192
|
+
query — it reads `september 5th`, `5th September`, `Sept 5` and `2026-09-05`,
|
|
193
|
+
and answers `null` for anything ambiguous rather than guessing.
|
|
194
|
+
|
|
195
|
+
**Dates the user writes themselves.** When someone types a date into their query
|
|
196
|
+
— "fly to vegas on september 5th" — the parameter it answers is recognised in
|
|
197
|
+
place and the date becomes tappable. Tapping it opens the calendar on that
|
|
198
|
+
month with the day already marked, so confirming or changing it takes one tap,
|
|
199
|
+
and the picked date replaces their words with the canonical form.
|
|
200
|
+
|
|
201
|
+
The written date is read where it can be: `september 5th`, `5th September`,
|
|
202
|
+
`Sept 5`, `September 5, 2026` and `2026-09-05` all resolve, in any of those
|
|
203
|
+
orders and with or without the year (a date with no year means its next
|
|
204
|
+
occurrence). Two cases deliberately don't pre-select — a numeric date like
|
|
205
|
+
`09/05`, which is September 5th in the US and May 9th elsewhere with nothing to
|
|
206
|
+
say which, and phrases like `next friday`. Those still open the calendar, just
|
|
207
|
+
on the current month with nothing marked, so the user picks rather than being
|
|
208
|
+
shown a guess that might be wrong.
|
|
209
|
+
|
|
210
|
+
**Typing** while the calendar is open does not filter it. The text is treated as
|
|
211
|
+
a new query, so suggestions refresh as the user types — useful when someone
|
|
212
|
+
would rather describe what they want than pick a day.
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
134
216
|
## Tier 2: Hook + Dropdown
|
|
135
217
|
|
|
136
218
|
Use the hook to drive state and render our dropdown; you own the input element and layout:
|
|
@@ -182,6 +264,8 @@ function App() {
|
|
|
182
264
|
|
|
183
265
|
Skip `<AIAutocompleteDropdown />` and render the suggestions UI yourself. `dropdownProps` carries the data + actions — the active suggestion's options, the highlighted index, `isOpen`, and `onSelect` / `onHighlight`:
|
|
184
266
|
|
|
267
|
+
> **Datepicker in a custom UI.** For a date parameter, `dropdownProps.formatType` is `"date"` and `suggestions[0].options` holds that month's day cells. Each cell's `text` is the date it commits (`"March 23"`, or `"Tuesday"` inside the next week), so rendering them as a plain list already works — `onSelect` behaves exactly as it does for an option. To draw an actual calendar, read `dateView` for the month on show, `cellDay(option)` for the number to paint, and call `onPreviousMonth` / `onNextMonth` to page. Cells that pad the start and end of the month have `is_tappable: false`.
|
|
268
|
+
|
|
185
269
|
```tsx
|
|
186
270
|
import { useAIAutocomplete } from "@magicx-eng/ai-autocomplete-react";
|
|
187
271
|
|
|
@@ -237,7 +321,7 @@ function App() {
|
|
|
237
321
|
| `pillPlacement?` | `"inline" \| "dropdown" \| "hidden"` | `"dropdown"` | Where to render unfilled pills. `"hidden"` hides pills entirely. |
|
|
238
322
|
| `mode?` | `"light" \| "dark" \| "auto"` | `"auto"` | Color mode. `"auto"` follows `prefers-color-scheme`. |
|
|
239
323
|
| `optionsPosition?` | `"above" \| "below"` | `"below"` | Where the dropdown opens relative to the input. |
|
|
240
|
-
| `animations?` | `boolean` | `true` | Enable/disable all SDK animations (
|
|
324
|
+
| `animations?` | `boolean` | `true` | Enable/disable all SDK animations (press + shimmer, the typed-in starting-state placeholder, the option rows' staggered entrance, and the "more below" arrow's slide). `prefers-reduced-motion` also switches the last three off. |
|
|
241
325
|
| `dropdownTrigger?` | `"auto" \| "manual" \| "hidden"` | `"auto"` | When the dropdown appears. `"auto"` = when options available. `"manual"` = only on pill tap, closes after selection. `"hidden"` = never shows. |
|
|
242
326
|
| `closeDropdownOnBlur?` | `boolean` | `true` | When `true`, the dropdown closes if the input loses focus. Set to `false` to keep it open whenever options are available, regardless of focus. |
|
|
243
327
|
| `showNonTappableOptions?` | `boolean` | `true` | When `true`, non-tappable options are rendered alongside tappable ones in the dropdown. Set to `false` to hide non-tappable options entirely. |
|
|
@@ -539,13 +623,17 @@ Override on the container (via `className`). All defaults use `:where()` (zero s
|
|
|
539
623
|
| `--aia-footer-chip-bg` | `--aia-surface` at 65% | `--aia-surface` at 65% | Fill behind the footer's keyboard hint and AI-Autocomplete badge. The option list scrolls under the footer, so this keeps both legible over the row passing behind them. `transparent` on the glass surface. |
|
|
540
624
|
| `--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. |
|
|
541
625
|
| `--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). |
|
|
542
|
-
| `--aia-streak-rgb` | `99, 102, 241` | `255, 255, 255` | Comma-separated RGB triplet
|
|
543
|
-
| `--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. |
|
|
626
|
+
| `--aia-streak-rgb` | `99, 102, 241` | `255, 255, 255` | Comma-separated RGB triplet tinting the datepicker's pressed cell, and its selected cell when `--aia-date-selected-bg` is unset. The today ring uses `--aia-date-today-ring`, not this. |
|
|
544
627
|
| `--aia-product-card-width` | `116px` | `116px` | Width of a product card in the strip. The media tile is square, so this also sets its height. |
|
|
545
628
|
| `--aia-product-gap` | `8px` | `8px` | Gap between product cards. |
|
|
546
629
|
| `--aia-product-bg` | `transparent` | `transparent` | Product card background. |
|
|
547
630
|
| `--aia-product-bg-active` | `--aia-option-bg` | `--aia-option-bg` | Product card background on hover. |
|
|
548
631
|
| `--aia-product-media-bg` | `--aia-skeleton-bg` | `--aia-skeleton-bg` | Fill behind the product image, and of the placeholder tile when a product has no image. |
|
|
632
|
+
| `--aia-scroll-arrow-bg` | `--aia-surface` | `--aia-surface` | Fill of the "more below" arrow — the round button that rises at the bottom of the option list while there is more to scroll to. |
|
|
633
|
+
| `--aia-scroll-arrow-color` | `--aia-option-color` | `--aia-option-color` | Chevron color of the arrow (`--aia-scroll-arrow-color-hover` on hover). |
|
|
634
|
+
| `--aia-scroll-arrow-border` | `--aia-dropdown-border` | `--aia-dropdown-border` | Hairline around the arrow. |
|
|
635
|
+
| `--aia-scroll-arrow-shadow` | `0 2px 8px rgba(0,0,0,0.12)` | `0 2px 8px rgba(0,0,0,0.12)` | Elevation of the arrow. |
|
|
636
|
+
| `--aia-placeholder-fade` | `120ms` | `120ms` | Fade-out of the outgoing placeholder phrase when the starting-state placeholder changes (the incoming one types itself in). |
|
|
549
637
|
| `--aia-product-placeholder-color` | `--aia-option-color` | `--aia-option-color` | Glyph color of the no-image placeholder tile. |
|
|
550
638
|
| `--aia-product-title-color` | `--aia-option-color-selected` | `--aia-option-color-selected` | Product title text. Follows the option colors by default, so theming the panel moves suggestions and products together. |
|
|
551
639
|
| `--aia-product-price-color` | `--aia-option-color-selected` | `--aia-option-color-selected` | Product price text. |
|
|
@@ -556,6 +644,14 @@ Override on the container (via `className`). All defaults use `:where()` (zero s
|
|
|
556
644
|
| `--aia-product-price-font-size` | `11px` | `11px` | Product price font size. |
|
|
557
645
|
| `--aia-product-vendor-font-size` | `10px` | `10px` | Product vendor font size. |
|
|
558
646
|
| `--aia-products-label-font-size` | `11px` | `11px` | Section label font size. |
|
|
647
|
+
| `--aia-date-panel-width` | `312px` | `312px` | Max width of the whole dropdown panel while the calendar is up — the panel narrows to calendar size. |
|
|
648
|
+
| `--aia-date-cell-size` | `26px` | `26px` | Size of a day's square — the box that carries the highlight, the today ring and the selected fill. |
|
|
649
|
+
| `--aia-date-row-height` | `28px` | `28px` | Height of one week row. Lower it to fit a 6-week month in a shorter dropdown. |
|
|
650
|
+
| `--aia-date-cell-font-size` | `13px` | `13px` | Day-number font size. |
|
|
651
|
+
| `--aia-date-month-font-size` | `14px` | `14px` | Font size of the "March 2026" header. |
|
|
652
|
+
| `--aia-date-weekday-font-size` | `11px` | `11px` | Font size of the S/M/T/W/T/F/S column letters. |
|
|
653
|
+
| `--aia-date-today-ring` | `--aia-option-color` | `--aia-option-color` | Outline drawn around today's date. |
|
|
654
|
+
| `--aia-date-selected-bg` | white at 12% | white at 12% | Fill behind the date a re-edited parameter already holds. |
|
|
559
655
|
| `--aia-skeleton-bg` | `rgba(189, 189, 189, 0.25)` | `#1a1b1d` | Fill color for the loading skeleton bars and the masked text in cached pills/options. |
|
|
560
656
|
|
|
561
657
|
Legacy `--aia-color-*` variables are still supported as fallbacks.
|
|
@@ -586,7 +682,13 @@ For styling beyond the CSS variables, target these stable `data-aia-*` attribute
|
|
|
586
682
|
| `[data-aia-pill-scroll]` | Scrollable pill region inside the bar — carries the horizontal scroll and right-edge fade mask |
|
|
587
683
|
| `[data-aia-skip]` | The pill bar's trailing "skip" button. Tune via `--aia-skip-font-size` / `--aia-skip-color` / `--aia-skip-color-hover` / `--aia-skip-hover-bg` |
|
|
588
684
|
| `[data-aia-option]` | Each suggestion option |
|
|
685
|
+
| `[data-aia-scroll-arrow]` | The "more below" arrow on the dropdown — carries `data-aia-visible` while shown |
|
|
589
686
|
| `[data-aia-dropdown]` | The dropdown root (listbox). Carries `data-aia-has-products` while the product strip has cards. |
|
|
687
|
+
| `[data-aia-datepicker]` | The calendar, rendered in place of the option list for a date parameter |
|
|
688
|
+
| `[data-aia-date-month]` | The "March 2026" header label |
|
|
689
|
+
| `[data-aia-date-prev]` / `[data-aia-date-next]` | The month arrows |
|
|
690
|
+
| `[data-aia-date-grid]` | The 7-column grid of day cells |
|
|
691
|
+
| `[data-aia-date-cell]` | Each day cell. Also carries `[data-aia-option]`, so option-level styling applies to both bodies |
|
|
590
692
|
| `[data-aia-products]` | Product strip section (label + row) |
|
|
591
693
|
| `[data-aia-products-row]` | The horizontally scrolling row of cards |
|
|
592
694
|
| `[data-aia-product]` | Each product card |
|
|
@@ -611,11 +713,24 @@ Every `/api/suggest` request carries a `meta.session_id` UUID. A session runs fr
|
|
|
611
713
|
|
|
612
714
|
The contract is simple: **after the user submits the query, call `reset()`**. That clears the input and rotates `session_id` so the next session begins clean.
|
|
613
715
|
|
|
614
|
-
> **Why it matters:**
|
|
716
|
+
> **Why it matters:** suggestions get sharper as a query develops. Each one
|
|
717
|
+
> takes account of what the user has already answered, so the parameters offered
|
|
718
|
+
> late in a query are shaped by the choices made early in it — that is what makes
|
|
719
|
+
> the experience feel guided rather than like a static list. `session_id` is what
|
|
720
|
+
> ties those requests together into one query.
|
|
721
|
+
>
|
|
722
|
+
> So `reset()` is not bookkeeping: it is how you say "that query is finished".
|
|
723
|
+
> Skip it and the next query is treated as a continuation of the last one, and
|
|
724
|
+
> its suggestions keep being shaped by answers the user has already moved on
|
|
725
|
+
> from — the failure is quiet, and shows up as steadily less relevant options
|
|
726
|
+
> rather than as an error.
|
|
615
727
|
|
|
616
728
|
- **Tier 1 `<AIAutocomplete />`** does this automatically — it calls `reset()` for you after `onSubmit` returns, for both Enter-key and built-in-button submits.
|
|
617
729
|
- **Tier 2 & 3 `useAIAutocomplete()`** — you own the submit flow, so call `reset()` from your `onSubmit` handler (see the example above) or from your custom button after firing `onSubmit`.
|
|
618
730
|
|
|
731
|
+
The id is a plain UUID. Log it next to your own request logs if you want to
|
|
732
|
+
correlate a user's report with the query that produced it.
|
|
733
|
+
|
|
619
734
|
## Option Overrides
|
|
620
735
|
|
|
621
736
|
```tsx
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AutocompleteResult, OptionOverrides, APIConfig, AppearanceMode, CompletedParamState, ProductsConfig, Product, Suggestion, SuggestionOption, SkippedParamState, Segment } from '@magicx-eng/ai-autocomplete-vanilla';
|
|
2
|
-
export { APIConfig, APIKeyConfig, AccessTokenConfig, AccessTokenResult, AppearanceMode, AutocompleteResult, CompletedParam, CompletedParamState, OptionOverrides, Product, ProductsConfig, Segment, SkippedParamState, Suggestion, SuggestionOption, TaskKind, buildSubmitResult, withSkippedParams } from '@magicx-eng/ai-autocomplete-vanilla';
|
|
1
|
+
import { AutocompleteResult, OptionOverrides, APIConfig, AppearanceMode, CompletedParamState, ProductsConfig, Product, Suggestion, SuggestionOption, FormatType, DateMonthView, SkippedParamState, Segment } from '@magicx-eng/ai-autocomplete-vanilla';
|
|
2
|
+
export { APIConfig, APIKeyConfig, AccessTokenConfig, AccessTokenResult, AppearanceMode, AutocompleteResult, CompletedParam, CompletedParamState, DateMonthView, FormatType, OptionOverrides, Product, ProductsConfig, Segment, SkippedParamState, Suggestion, SuggestionOption, TaskKind, WEEKDAY_LABELS, buildSubmitResult, cellDay, cellIso, formatDate, isoDate, monthLabel, parseDate, parseLooseDate, withSkippedParams } from '@magicx-eng/ai-autocomplete-vanilla';
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
import { ReactNode, KeyboardEvent, ChangeEvent } from 'react';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
@@ -38,7 +38,7 @@ interface AIAutocompleteProps {
|
|
|
38
38
|
mode?: AppearanceMode;
|
|
39
39
|
/** Where the dropdown opens relative to the input. Default: "below" */
|
|
40
40
|
optionsPosition?: "above" | "below";
|
|
41
|
-
/** Enable all SDK animations (
|
|
41
|
+
/** Enable all SDK animations (press + shimmer). Default: true */
|
|
42
42
|
animations?: boolean;
|
|
43
43
|
/** When the dropdown appears. "auto" (default) = shows when options available. "manual" = only on pill tap, closes after selection. "hidden" = never shows. */
|
|
44
44
|
dropdownTrigger?: "auto" | "manual" | "hidden";
|
|
@@ -239,6 +239,17 @@ interface UseAIAutocompleteReturn {
|
|
|
239
239
|
setFocused: (focused: boolean) => void;
|
|
240
240
|
/** Tier 1 re-edit: snapshot of the bold param currently being re-edited (null when not editing). */
|
|
241
241
|
editingParam: CompletedParamState | null;
|
|
242
|
+
/**
|
|
243
|
+
* Set while the user is picking a date for a span the server identified as
|
|
244
|
+
* one — "september 5th" in "fly to vegas on september 5th". Null otherwise.
|
|
245
|
+
*/
|
|
246
|
+
editingIdentified: {
|
|
247
|
+
id: string;
|
|
248
|
+
type: string;
|
|
249
|
+
anchor: number;
|
|
250
|
+
tail: number;
|
|
251
|
+
iso: string | null;
|
|
252
|
+
} | null;
|
|
242
253
|
/** Tier 1 re-edit: plain-text offset where the editing region starts (null when not editing). */
|
|
243
254
|
editingAnchor: number | null;
|
|
244
255
|
/** Tier 1 helper: latest known caret offset within the editor. Promote paths stamp this with the position the caret should land after a completion. */
|
|
@@ -329,6 +340,22 @@ interface AIAutocompleteDropdownProps {
|
|
|
329
340
|
* Default: `"below"`.
|
|
330
341
|
*/
|
|
331
342
|
optionsPosition?: "above" | "below";
|
|
343
|
+
/**
|
|
344
|
+
* How the active pill is answered. `"date"` renders a calendar in place of
|
|
345
|
+
* the options grid, and `suggestions[0].options` then carries that month's
|
|
346
|
+
* cells rather than the parameter's own options — the core swaps them before
|
|
347
|
+
* they reach here. Provided by `dropdownProps` from the hook.
|
|
348
|
+
* Default: `"options"`.
|
|
349
|
+
*/
|
|
350
|
+
formatType?: FormatType;
|
|
351
|
+
/** The month the calendar shows. Null unless `formatType` is `"date"`. Provided by `dropdownProps` from the hook. */
|
|
352
|
+
dateView?: DateMonthView | null;
|
|
353
|
+
/** `YYYY-MM-DD` already held by the param being re-edited, so its cell reads as the current answer. Provided by `dropdownProps` from the hook. */
|
|
354
|
+
selectedDateIso?: string | null;
|
|
355
|
+
/** Page the calendar back a month. Provided by `dropdownProps` from the hook. */
|
|
356
|
+
onPreviousMonth?: () => void;
|
|
357
|
+
/** Page the calendar forward a month. Provided by `dropdownProps` from the hook. */
|
|
358
|
+
onNextMonth?: () => void;
|
|
332
359
|
/**
|
|
333
360
|
* Color mode for a **standalone** dropdown. When set, the dropdown scopes the
|
|
334
361
|
* SDK's design tokens to its own root (adds the `magicx-aia` class +
|
|
@@ -344,7 +371,7 @@ interface AIAutocompleteDropdownProps {
|
|
|
344
371
|
|
|
345
372
|
declare const AIAutocomplete: react.ForwardRefExoticComponent<AIAutocompleteProps & react.RefAttributes<AIAutocompleteHandle>>;
|
|
346
373
|
|
|
347
|
-
declare function AIAutocompleteDropdown({ suggestions, activeIndex, onSelect, onHighlight, isOpen, id, className, pills, onPillClick, showPills, onSkip, showSkipButton, skipDisabled, activeSelected, isLoading, isInputEmpty, products, onProductSelect, onProductFocusChange, optionsPosition, mode, }: AIAutocompleteDropdownProps): react_jsx_runtime.JSX.Element;
|
|
374
|
+
declare function AIAutocompleteDropdown({ suggestions, activeIndex, onSelect, onHighlight, isOpen, id, className, pills, onPillClick, showPills, onSkip, showSkipButton, skipDisabled, activeSelected, isLoading, isInputEmpty, products, onProductSelect, onProductFocusChange, formatType, dateView, selectedDateIso, onPreviousMonth, onNextMonth, optionsPosition, mode, }: AIAutocompleteDropdownProps): react_jsx_runtime.JSX.Element;
|
|
348
375
|
|
|
349
376
|
declare function useAIAutocomplete({ onSubmit, onError, optionOverrides, maskCompletedText, apiConfig, additionalContext, columns, dropdownTrigger, optionsPosition, closeDropdownOnBlur, showNonTappableOptions, showSkipButton, onFocus, onBlur, value: controlledValue, completedParams: controlledParams, onChange: onChangeProp, onParamsChange, products, onProductSelect, source, setCursor, }: UseAIAutocompleteOptions): UseAIAutocompleteReturn;
|
|
350
377
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AutocompleteResult, OptionOverrides, APIConfig, AppearanceMode, CompletedParamState, ProductsConfig, Product, Suggestion, SuggestionOption, SkippedParamState, Segment } from '@magicx-eng/ai-autocomplete-vanilla';
|
|
2
|
-
export { APIConfig, APIKeyConfig, AccessTokenConfig, AccessTokenResult, AppearanceMode, AutocompleteResult, CompletedParam, CompletedParamState, OptionOverrides, Product, ProductsConfig, Segment, SkippedParamState, Suggestion, SuggestionOption, TaskKind, buildSubmitResult, withSkippedParams } from '@magicx-eng/ai-autocomplete-vanilla';
|
|
1
|
+
import { AutocompleteResult, OptionOverrides, APIConfig, AppearanceMode, CompletedParamState, ProductsConfig, Product, Suggestion, SuggestionOption, FormatType, DateMonthView, SkippedParamState, Segment } from '@magicx-eng/ai-autocomplete-vanilla';
|
|
2
|
+
export { APIConfig, APIKeyConfig, AccessTokenConfig, AccessTokenResult, AppearanceMode, AutocompleteResult, CompletedParam, CompletedParamState, DateMonthView, FormatType, OptionOverrides, Product, ProductsConfig, Segment, SkippedParamState, Suggestion, SuggestionOption, TaskKind, WEEKDAY_LABELS, buildSubmitResult, cellDay, cellIso, formatDate, isoDate, monthLabel, parseDate, parseLooseDate, withSkippedParams } from '@magicx-eng/ai-autocomplete-vanilla';
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
import { ReactNode, KeyboardEvent, ChangeEvent } from 'react';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
@@ -38,7 +38,7 @@ interface AIAutocompleteProps {
|
|
|
38
38
|
mode?: AppearanceMode;
|
|
39
39
|
/** Where the dropdown opens relative to the input. Default: "below" */
|
|
40
40
|
optionsPosition?: "above" | "below";
|
|
41
|
-
/** Enable all SDK animations (
|
|
41
|
+
/** Enable all SDK animations (press + shimmer). Default: true */
|
|
42
42
|
animations?: boolean;
|
|
43
43
|
/** When the dropdown appears. "auto" (default) = shows when options available. "manual" = only on pill tap, closes after selection. "hidden" = never shows. */
|
|
44
44
|
dropdownTrigger?: "auto" | "manual" | "hidden";
|
|
@@ -239,6 +239,17 @@ interface UseAIAutocompleteReturn {
|
|
|
239
239
|
setFocused: (focused: boolean) => void;
|
|
240
240
|
/** Tier 1 re-edit: snapshot of the bold param currently being re-edited (null when not editing). */
|
|
241
241
|
editingParam: CompletedParamState | null;
|
|
242
|
+
/**
|
|
243
|
+
* Set while the user is picking a date for a span the server identified as
|
|
244
|
+
* one — "september 5th" in "fly to vegas on september 5th". Null otherwise.
|
|
245
|
+
*/
|
|
246
|
+
editingIdentified: {
|
|
247
|
+
id: string;
|
|
248
|
+
type: string;
|
|
249
|
+
anchor: number;
|
|
250
|
+
tail: number;
|
|
251
|
+
iso: string | null;
|
|
252
|
+
} | null;
|
|
242
253
|
/** Tier 1 re-edit: plain-text offset where the editing region starts (null when not editing). */
|
|
243
254
|
editingAnchor: number | null;
|
|
244
255
|
/** Tier 1 helper: latest known caret offset within the editor. Promote paths stamp this with the position the caret should land after a completion. */
|
|
@@ -329,6 +340,22 @@ interface AIAutocompleteDropdownProps {
|
|
|
329
340
|
* Default: `"below"`.
|
|
330
341
|
*/
|
|
331
342
|
optionsPosition?: "above" | "below";
|
|
343
|
+
/**
|
|
344
|
+
* How the active pill is answered. `"date"` renders a calendar in place of
|
|
345
|
+
* the options grid, and `suggestions[0].options` then carries that month's
|
|
346
|
+
* cells rather than the parameter's own options — the core swaps them before
|
|
347
|
+
* they reach here. Provided by `dropdownProps` from the hook.
|
|
348
|
+
* Default: `"options"`.
|
|
349
|
+
*/
|
|
350
|
+
formatType?: FormatType;
|
|
351
|
+
/** The month the calendar shows. Null unless `formatType` is `"date"`. Provided by `dropdownProps` from the hook. */
|
|
352
|
+
dateView?: DateMonthView | null;
|
|
353
|
+
/** `YYYY-MM-DD` already held by the param being re-edited, so its cell reads as the current answer. Provided by `dropdownProps` from the hook. */
|
|
354
|
+
selectedDateIso?: string | null;
|
|
355
|
+
/** Page the calendar back a month. Provided by `dropdownProps` from the hook. */
|
|
356
|
+
onPreviousMonth?: () => void;
|
|
357
|
+
/** Page the calendar forward a month. Provided by `dropdownProps` from the hook. */
|
|
358
|
+
onNextMonth?: () => void;
|
|
332
359
|
/**
|
|
333
360
|
* Color mode for a **standalone** dropdown. When set, the dropdown scopes the
|
|
334
361
|
* SDK's design tokens to its own root (adds the `magicx-aia` class +
|
|
@@ -344,7 +371,7 @@ interface AIAutocompleteDropdownProps {
|
|
|
344
371
|
|
|
345
372
|
declare const AIAutocomplete: react.ForwardRefExoticComponent<AIAutocompleteProps & react.RefAttributes<AIAutocompleteHandle>>;
|
|
346
373
|
|
|
347
|
-
declare function AIAutocompleteDropdown({ suggestions, activeIndex, onSelect, onHighlight, isOpen, id, className, pills, onPillClick, showPills, onSkip, showSkipButton, skipDisabled, activeSelected, isLoading, isInputEmpty, products, onProductSelect, onProductFocusChange, optionsPosition, mode, }: AIAutocompleteDropdownProps): react_jsx_runtime.JSX.Element;
|
|
374
|
+
declare function AIAutocompleteDropdown({ suggestions, activeIndex, onSelect, onHighlight, isOpen, id, className, pills, onPillClick, showPills, onSkip, showSkipButton, skipDisabled, activeSelected, isLoading, isInputEmpty, products, onProductSelect, onProductFocusChange, formatType, dateView, selectedDateIso, onPreviousMonth, onNextMonth, optionsPosition, mode, }: AIAutocompleteDropdownProps): react_jsx_runtime.JSX.Element;
|
|
348
375
|
|
|
349
376
|
declare function useAIAutocomplete({ onSubmit, onError, optionOverrides, maskCompletedText, apiConfig, additionalContext, columns, dropdownTrigger, optionsPosition, closeDropdownOnBlur, showNonTappableOptions, showSkipButton, onFocus, onBlur, value: controlledValue, completedParams: controlledParams, onChange: onChangeProp, onParamsChange, products, onProductSelect, source, setCursor, }: UseAIAutocompleteOptions): UseAIAutocompleteReturn;
|
|
350
377
|
|