@magicx-eng/ai-autocomplete-vanilla 0.69.0 → 0.71.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/REFERENCE.md CHANGED
@@ -490,19 +490,20 @@ other option list (a store's branches, say), and the search never runs.
490
490
  | Tapping a place already chosen | Re-opens the field focused, its answer selected |
491
491
  | Typing in the field | Searches after a short pause (2 characters or more) |
492
492
  | <kbd>↓</kbd> / <kbd>↑</kbd> | Moves through the places found |
493
+ | A space in the input right after words that exactly name the top place found (its whole name, or what its brackets hold: "sfo" for "San Francisco International Airport (SFO)") | Commits that place, as a tap would. Only once the search for those words has answered, and not while the field itself has focus |
493
494
  | <kbd>Enter</kbd> or a tap on a place | Commits it. With nothing found, Enter commits the typed text as written. So does Enter pressed before the search answers (within the 250ms pause): nothing is highlighted yet |
494
495
  | <kbd>Esc</kbd>, or <kbd>Backspace</kbd> in an empty field | Back to the input, the pill left open |
495
496
  | <kbd>Tab</kbd> / <kbd>Shift</kbd>+<kbd>Tab</kbd> | On to the next control / back to the input, as for any field |
496
497
 
497
498
  **The committed value** reads as the place and its region (`Seattle, WA`), with
498
499
  the server's lead-in before it when there is one (`in Seattle, WA`). A picked
499
- place also records the provider's place ID on the parameter's `metadata` under
500
+ place also records the provider's place ID and the place's name on the parameter's `metadata` under
500
501
  `LOCATION_META_KEY` (`aiaPlace`); typed text records none:
501
502
 
502
503
  ```ts
503
504
  import { LOCATION_META_KEY } from "@magicx-eng/ai-autocomplete-vanilla";
504
505
 
505
- const place = param.metadata?.[LOCATION_META_KEY]; // { id: "ChIJ…" } | undefined
506
+ const place = param.metadata?.[LOCATION_META_KEY]; // { id: "ChIJ…", name: "Seattle" } | undefined
506
507
  ```
507
508
 
508
509
  **Re-editing** a committed place re-opens the field on it, selected, so typing
@@ -593,6 +594,7 @@ The full input also accepts `--aia-input-radius` and `--aia-written-text-font-we
593
594
  | `--aia-date-today-ring` | `--aia-option-color` | `--aia-option-color` | Outline drawn around today's date. |
594
595
  | `--aia-date-selected-bg` | white at 12% | white at 12% | Fill behind the date a re-edited parameter already holds. |
595
596
  | `--aia-date-range-bg` | white at 6% | white at 6% | Band across the days between the two ends of a picked date range. The ends themselves use `--aia-date-selected-bg`. |
597
+ | `--aia-date-reference-bg` | white at 7% | white at 7% | Soft fill behind a day another answer already holds (the pickup date while the return date is asked), shown for reference; the day stays pickable. |
596
598
  | `--aia-time-panel-width` | `240px` | `240px` | Max width of the whole dropdown panel while the time wheel is up. |
597
599
  | `--aia-time-font-size` | `15px` | `15px` | The time wheel's numbers and its `:` separator. |
598
600
  | `--aia-time-band-bg` | white at 8% | white at 8% | The band behind the wheels' top rows — the chosen time. |
package/dist/index.d.mts CHANGED
@@ -774,7 +774,7 @@ declare function resolveFormatType(source: {
774
774
 
775
775
  /**
776
776
  * Metadata key that carries the provider's place ID on an answer picked from
777
- * the location search, as `{ id }`. A typed answer (Enter with no result
777
+ * the location search, as `{ id, name }`. A typed answer (Enter with no result
778
778
  * highlighted) carries none: it names no place the provider knows.
779
779
  */
780
780
  declare const LOCATION_META_KEY = "aiaPlace";
@@ -1193,6 +1193,13 @@ interface CoreDerivedState {
1193
1193
  * mark that start, dim the days before it, and no earlier day can be picked.
1194
1194
  */
1195
1195
  dateFloor: string | null;
1196
+ /**
1197
+ * The days other date answers in the request already hold, as sorted
1198
+ * `YYYY-MM-DD` (the pickup day while the return day is asked). The calendars
1199
+ * box them for reference; they stay pickable. Empty unless
1200
+ * `activeFormatType` is a calendar one.
1201
+ */
1202
+ dateReferences: string[];
1196
1203
  /**
1197
1204
  * What the time wheel shows. Null unless `activeFormatType` is `"time"`.
1198
1205
  * `touched` is false while it still shows its suggested starting time.
@@ -1605,6 +1612,8 @@ declare class AIAutocomplete {
1605
1612
  private openWordText;
1606
1613
  /** The input text the location field last mirrored while on screen. */
1607
1614
  private locationMirrorText;
1615
+ /** The search the input last put in the location field, so deleting those words clears it again. */
1616
+ private locationMirrored;
1608
1617
  /** Identified params held back until the word they end ends. */
1609
1618
  private heldIdentified;
1610
1619
  /** Values waiting for confirmation. Only a submit of the same text admits them. */
@@ -1618,6 +1627,8 @@ declare class AIAutocomplete {
1618
1627
  private locationAbort;
1619
1628
  /** One provider session per location pill: every search for it, then the pick. */
1620
1629
  private locationSession;
1630
+ /** Where a space-picked place left the caret, until the editor reports its own. */
1631
+ private spacePickCaret;
1621
1632
  private readonly emitSubmit;
1622
1633
  private readonly emitError;
1623
1634
  constructor(container: HTMLElement, opts?: CoreOptions);
@@ -1828,6 +1839,27 @@ declare class AIAutocomplete {
1828
1839
  * `selectOption` like a tapped option — see `buildLocationOption`.
1829
1840
  */
1830
1841
  commitLocation(index?: number): void;
1842
+ /**
1843
+ * A space typed in the input right after words that name the top location
1844
+ * result exactly (its name, or what its brackets hold) picks that place,
1845
+ * as tapping its row would. Only once the search for those words has
1846
+ * answered, so a space while it loads keeps typing, and only while the field
1847
+ * is on screen, so a space never commits a place the user cannot see. The
1848
+ * exact match outranks the field's highlight: it is the top place the typed
1849
+ * words name, whichever row the arrows last rested on.
1850
+ */
1851
+ private spacePicksTopPlace;
1852
+ /**
1853
+ * The place query the words after the last chip make, as the field mirrors
1854
+ * it. Words the server recognized as another parameter ("27th" in "on the
1855
+ * 27th") count as a chip too, so only the text after the last of them is
1856
+ * searched; a span recognized as the location being asked is the place
1857
+ * itself and stays.
1858
+ */
1859
+ private typedLocationQuery;
1860
+ private isReEditing;
1861
+ /** The words typed for the place: after the last chip and any span recognized as another parameter. */
1862
+ private typedLocationPhrase;
1831
1863
  private runLocationSearch;
1832
1864
  private cancelLocationSearch;
1833
1865
  /**
@@ -1966,8 +1998,9 @@ declare class AIAutocomplete {
1966
1998
  * before the server asked for it ("going to paris", then the destination
1967
1999
  * question) is searched right away.
1968
2000
  *
1969
- * The phrase is `livePhraseOf` (the text after the last chip), not
1970
- * `optionQuery`, which reads "" mid-word once a /suggest response lands.
2001
+ * The phrase is `typedLocationQuery` (the text after the last chip and
2002
+ * after any span recognized as another parameter), not `optionQuery`,
2003
+ * which reads "" mid-word once a /suggest response lands.
1971
2004
  */
1972
2005
  private mirrorTypedIntoLocationSearch;
1973
2006
  /** True while commitOnWordEnd is on and the user still types the last word. */
@@ -2050,6 +2083,8 @@ interface LooseDateOptions {
2050
2083
  * Handles, in order: ISO; a month name with a day either side of it, with or
2051
2084
  * without an ordinal suffix or a year; and a numeric pair where only one
2052
2085
  * reading is possible (`13/05` can only be day-first, since 13 is not a month).
2086
+ * A day written alone with its ordinal suffix ("the 1st") resolves to the next
2087
+ * date on or after today that falls on that day.
2053
2088
  *
2054
2089
  * Deliberately NOT handled:
2055
2090
  * - A numeric pair where both numbers are 12 or under. `09/05` is September
@@ -2109,9 +2144,10 @@ declare const DATE_RANGE_META_END = "aiaDateRangeEnd";
2109
2144
  * - A backwards span ("October 13 - September 11"). Nothing here can tell a
2110
2145
  * typo from a year boundary the writer left implicit, and silently swapping
2111
2146
  * the ends would answer a question the user didn't ask.
2112
- * - A shared-month shorthand ("September 11 - 13"). The right half alone is
2113
- * not a date, and inferring the month from the left half is the kind of
2114
- * guess this file exists not to make.
2147
+ * - A shared-month shorthand with a bare number ("September 11 - 13"). The
2148
+ * right half alone is not a date: a bare number is as likely a count.
2149
+ * With its ordinal suffix ("September 11 - 13th") the right half is a day
2150
+ * and resolves to its next date on or after the start, September 13.
2115
2151
  * - Anything where two different splits both read as a range — the text is
2116
2152
  * then genuinely ambiguous about where its own separator is.
2117
2153
  *
@@ -2172,6 +2208,12 @@ interface DateSelection {
2172
2208
  * it are dimmed and, unlike a day gone by, cannot be picked.
2173
2209
  */
2174
2210
  floor?: string | null;
2211
+ /**
2212
+ * Days other date answers already hold (the pickup day while the return day
2213
+ * is asked), boxed for reference. They mark nothing as answered and stay
2214
+ * pickable.
2215
+ */
2216
+ references?: readonly string[];
2175
2217
  }
2176
2218
  /**
2177
2219
  * The calendar's selection, read off core state.
@@ -2194,6 +2236,7 @@ declare function dateSelectionFor(state: {
2194
2236
  } | null;
2195
2237
  dateRangeStart: string | null;
2196
2238
  dateFloor?: string | null;
2239
+ dateReferences?: readonly string[];
2197
2240
  }): DateSelection;
2198
2241
  /**
2199
2242
  * The span the calendar should paint right now.
@@ -2212,7 +2255,8 @@ declare function visibleDateRange(args: {
2212
2255
  }): DateRange | null;
2213
2256
  /**
2214
2257
  * How one cell renders against the current selection: filled at either end of
2215
- * the span, banded in between.
2258
+ * the span, banded in between, boxed for reference when another answer holds
2259
+ * the day and it is neither.
2216
2260
  *
2217
2261
  * Shared by all three packages' calendars so a range can't be painted three
2218
2262
  * subtly different ways. `selectedIso` is the single-date answer, which is
@@ -2222,9 +2266,11 @@ declare function visibleDateRange(args: {
2222
2266
  declare function dateCellMarks(iso: string | null, args: {
2223
2267
  selectedIso: string | null;
2224
2268
  range: DateRange | null;
2269
+ references?: readonly string[];
2225
2270
  }): {
2226
2271
  selected: boolean;
2227
2272
  inRange: boolean;
2273
+ reference: boolean;
2228
2274
  };
2229
2275
  /**
2230
2276
  * Whether a day is dimmed: one already gone by, or one before the earliest day
@@ -2710,6 +2756,10 @@ declare function syncPanelHug(dropdown: HTMLElement): void;
2710
2756
  * old content stays on top as a ghost that fades to transparent with a 2px
2711
2757
  * blur over 280ms, while the new content dissolves in (opacity 0 and a 2px
2712
2758
  * blur to clear, 320ms after a 40ms beat) on the same soft ease.
2759
+ * - While a request loads, the old content has already been fading out in
2760
+ * place (`data-aia-loading`, 160ms). The ghost then starts from the opacity
2761
+ * that fade had reached, never back at full, and when the fade has finished
2762
+ * there is no ghost at all: the new content just dissolves in.
2713
2763
  *
2714
2764
  * Opening and closing are CSS (the `--visible` transition). This module only
2715
2765
  * runs between two open renders. All three packages call `settlePanelMorph`
@@ -3153,7 +3203,7 @@ declare function buildQuery(text: string, completedParams: CompletedParamState[]
3153
3203
  /**
3154
3204
  * The dropdown footer's keyboard hint has three states, in priority order:
3155
3205
  * 1. an option is highlighted → "enter to proceed" (Enter commits it);
3156
- * 2. otherwise, the input is empty → "tab to select" (Tab highlights the first
3206
+ * 2. otherwise, the input is empty → "tab to select" (Tab picks the first
3157
3207
  * option). This is the ONLY state that shows "tab to select";
3158
3208
  * 3. otherwise (the input has text) → "→ to skip" — the right arrow skips the
3159
3209
  * active pill.
package/dist/index.d.ts CHANGED
@@ -774,7 +774,7 @@ declare function resolveFormatType(source: {
774
774
 
775
775
  /**
776
776
  * Metadata key that carries the provider's place ID on an answer picked from
777
- * the location search, as `{ id }`. A typed answer (Enter with no result
777
+ * the location search, as `{ id, name }`. A typed answer (Enter with no result
778
778
  * highlighted) carries none: it names no place the provider knows.
779
779
  */
780
780
  declare const LOCATION_META_KEY = "aiaPlace";
@@ -1193,6 +1193,13 @@ interface CoreDerivedState {
1193
1193
  * mark that start, dim the days before it, and no earlier day can be picked.
1194
1194
  */
1195
1195
  dateFloor: string | null;
1196
+ /**
1197
+ * The days other date answers in the request already hold, as sorted
1198
+ * `YYYY-MM-DD` (the pickup day while the return day is asked). The calendars
1199
+ * box them for reference; they stay pickable. Empty unless
1200
+ * `activeFormatType` is a calendar one.
1201
+ */
1202
+ dateReferences: string[];
1196
1203
  /**
1197
1204
  * What the time wheel shows. Null unless `activeFormatType` is `"time"`.
1198
1205
  * `touched` is false while it still shows its suggested starting time.
@@ -1605,6 +1612,8 @@ declare class AIAutocomplete {
1605
1612
  private openWordText;
1606
1613
  /** The input text the location field last mirrored while on screen. */
1607
1614
  private locationMirrorText;
1615
+ /** The search the input last put in the location field, so deleting those words clears it again. */
1616
+ private locationMirrored;
1608
1617
  /** Identified params held back until the word they end ends. */
1609
1618
  private heldIdentified;
1610
1619
  /** Values waiting for confirmation. Only a submit of the same text admits them. */
@@ -1618,6 +1627,8 @@ declare class AIAutocomplete {
1618
1627
  private locationAbort;
1619
1628
  /** One provider session per location pill: every search for it, then the pick. */
1620
1629
  private locationSession;
1630
+ /** Where a space-picked place left the caret, until the editor reports its own. */
1631
+ private spacePickCaret;
1621
1632
  private readonly emitSubmit;
1622
1633
  private readonly emitError;
1623
1634
  constructor(container: HTMLElement, opts?: CoreOptions);
@@ -1828,6 +1839,27 @@ declare class AIAutocomplete {
1828
1839
  * `selectOption` like a tapped option — see `buildLocationOption`.
1829
1840
  */
1830
1841
  commitLocation(index?: number): void;
1842
+ /**
1843
+ * A space typed in the input right after words that name the top location
1844
+ * result exactly (its name, or what its brackets hold) picks that place,
1845
+ * as tapping its row would. Only once the search for those words has
1846
+ * answered, so a space while it loads keeps typing, and only while the field
1847
+ * is on screen, so a space never commits a place the user cannot see. The
1848
+ * exact match outranks the field's highlight: it is the top place the typed
1849
+ * words name, whichever row the arrows last rested on.
1850
+ */
1851
+ private spacePicksTopPlace;
1852
+ /**
1853
+ * The place query the words after the last chip make, as the field mirrors
1854
+ * it. Words the server recognized as another parameter ("27th" in "on the
1855
+ * 27th") count as a chip too, so only the text after the last of them is
1856
+ * searched; a span recognized as the location being asked is the place
1857
+ * itself and stays.
1858
+ */
1859
+ private typedLocationQuery;
1860
+ private isReEditing;
1861
+ /** The words typed for the place: after the last chip and any span recognized as another parameter. */
1862
+ private typedLocationPhrase;
1831
1863
  private runLocationSearch;
1832
1864
  private cancelLocationSearch;
1833
1865
  /**
@@ -1966,8 +1998,9 @@ declare class AIAutocomplete {
1966
1998
  * before the server asked for it ("going to paris", then the destination
1967
1999
  * question) is searched right away.
1968
2000
  *
1969
- * The phrase is `livePhraseOf` (the text after the last chip), not
1970
- * `optionQuery`, which reads "" mid-word once a /suggest response lands.
2001
+ * The phrase is `typedLocationQuery` (the text after the last chip and
2002
+ * after any span recognized as another parameter), not `optionQuery`,
2003
+ * which reads "" mid-word once a /suggest response lands.
1971
2004
  */
1972
2005
  private mirrorTypedIntoLocationSearch;
1973
2006
  /** True while commitOnWordEnd is on and the user still types the last word. */
@@ -2050,6 +2083,8 @@ interface LooseDateOptions {
2050
2083
  * Handles, in order: ISO; a month name with a day either side of it, with or
2051
2084
  * without an ordinal suffix or a year; and a numeric pair where only one
2052
2085
  * reading is possible (`13/05` can only be day-first, since 13 is not a month).
2086
+ * A day written alone with its ordinal suffix ("the 1st") resolves to the next
2087
+ * date on or after today that falls on that day.
2053
2088
  *
2054
2089
  * Deliberately NOT handled:
2055
2090
  * - A numeric pair where both numbers are 12 or under. `09/05` is September
@@ -2109,9 +2144,10 @@ declare const DATE_RANGE_META_END = "aiaDateRangeEnd";
2109
2144
  * - A backwards span ("October 13 - September 11"). Nothing here can tell a
2110
2145
  * typo from a year boundary the writer left implicit, and silently swapping
2111
2146
  * the ends would answer a question the user didn't ask.
2112
- * - A shared-month shorthand ("September 11 - 13"). The right half alone is
2113
- * not a date, and inferring the month from the left half is the kind of
2114
- * guess this file exists not to make.
2147
+ * - A shared-month shorthand with a bare number ("September 11 - 13"). The
2148
+ * right half alone is not a date: a bare number is as likely a count.
2149
+ * With its ordinal suffix ("September 11 - 13th") the right half is a day
2150
+ * and resolves to its next date on or after the start, September 13.
2115
2151
  * - Anything where two different splits both read as a range — the text is
2116
2152
  * then genuinely ambiguous about where its own separator is.
2117
2153
  *
@@ -2172,6 +2208,12 @@ interface DateSelection {
2172
2208
  * it are dimmed and, unlike a day gone by, cannot be picked.
2173
2209
  */
2174
2210
  floor?: string | null;
2211
+ /**
2212
+ * Days other date answers already hold (the pickup day while the return day
2213
+ * is asked), boxed for reference. They mark nothing as answered and stay
2214
+ * pickable.
2215
+ */
2216
+ references?: readonly string[];
2175
2217
  }
2176
2218
  /**
2177
2219
  * The calendar's selection, read off core state.
@@ -2194,6 +2236,7 @@ declare function dateSelectionFor(state: {
2194
2236
  } | null;
2195
2237
  dateRangeStart: string | null;
2196
2238
  dateFloor?: string | null;
2239
+ dateReferences?: readonly string[];
2197
2240
  }): DateSelection;
2198
2241
  /**
2199
2242
  * The span the calendar should paint right now.
@@ -2212,7 +2255,8 @@ declare function visibleDateRange(args: {
2212
2255
  }): DateRange | null;
2213
2256
  /**
2214
2257
  * How one cell renders against the current selection: filled at either end of
2215
- * the span, banded in between.
2258
+ * the span, banded in between, boxed for reference when another answer holds
2259
+ * the day and it is neither.
2216
2260
  *
2217
2261
  * Shared by all three packages' calendars so a range can't be painted three
2218
2262
  * subtly different ways. `selectedIso` is the single-date answer, which is
@@ -2222,9 +2266,11 @@ declare function visibleDateRange(args: {
2222
2266
  declare function dateCellMarks(iso: string | null, args: {
2223
2267
  selectedIso: string | null;
2224
2268
  range: DateRange | null;
2269
+ references?: readonly string[];
2225
2270
  }): {
2226
2271
  selected: boolean;
2227
2272
  inRange: boolean;
2273
+ reference: boolean;
2228
2274
  };
2229
2275
  /**
2230
2276
  * Whether a day is dimmed: one already gone by, or one before the earliest day
@@ -2710,6 +2756,10 @@ declare function syncPanelHug(dropdown: HTMLElement): void;
2710
2756
  * old content stays on top as a ghost that fades to transparent with a 2px
2711
2757
  * blur over 280ms, while the new content dissolves in (opacity 0 and a 2px
2712
2758
  * blur to clear, 320ms after a 40ms beat) on the same soft ease.
2759
+ * - While a request loads, the old content has already been fading out in
2760
+ * place (`data-aia-loading`, 160ms). The ghost then starts from the opacity
2761
+ * that fade had reached, never back at full, and when the fade has finished
2762
+ * there is no ghost at all: the new content just dissolves in.
2713
2763
  *
2714
2764
  * Opening and closing are CSS (the `--visible` transition). This module only
2715
2765
  * runs between two open renders. All three packages call `settlePanelMorph`
@@ -3153,7 +3203,7 @@ declare function buildQuery(text: string, completedParams: CompletedParamState[]
3153
3203
  /**
3154
3204
  * The dropdown footer's keyboard hint has three states, in priority order:
3155
3205
  * 1. an option is highlighted → "enter to proceed" (Enter commits it);
3156
- * 2. otherwise, the input is empty → "tab to select" (Tab highlights the first
3206
+ * 2. otherwise, the input is empty → "tab to select" (Tab picks the first
3157
3207
  * option). This is the ONLY state that shows "tab to select";
3158
3208
  * 3. otherwise (the input has text) → "→ to skip" — the right arrow skips the
3159
3209
  * active pill.