@magicx-eng/ai-autocomplete-vanilla 0.69.0 → 0.70.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
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";
@@ -1618,6 +1618,8 @@ declare class AIAutocomplete {
1618
1618
  private locationAbort;
1619
1619
  /** One provider session per location pill: every search for it, then the pick. */
1620
1620
  private locationSession;
1621
+ /** Where a space-picked place left the caret, until the editor reports its own. */
1622
+ private spacePickCaret;
1621
1623
  private readonly emitSubmit;
1622
1624
  private readonly emitError;
1623
1625
  constructor(container: HTMLElement, opts?: CoreOptions);
@@ -1828,6 +1830,18 @@ declare class AIAutocomplete {
1828
1830
  * `selectOption` like a tapped option — see `buildLocationOption`.
1829
1831
  */
1830
1832
  commitLocation(index?: number): void;
1833
+ /**
1834
+ * A space typed in the input right after words that name the top location
1835
+ * result exactly (its name, or what its brackets hold) picks that place,
1836
+ * as tapping its row would. Only once the search for those words has
1837
+ * answered, so a space while it loads keeps typing, and only while the field
1838
+ * is on screen, so a space never commits a place the user cannot see. The
1839
+ * exact match outranks the field's highlight: it is the top place the typed
1840
+ * words name, whichever row the arrows last rested on.
1841
+ */
1842
+ private spacePicksTopPlace;
1843
+ /** The place query the words after the last chip make, as the field mirrors it. */
1844
+ private typedLocationQuery;
1831
1845
  private runLocationSearch;
1832
1846
  private cancelLocationSearch;
1833
1847
  /**
@@ -2050,6 +2064,8 @@ interface LooseDateOptions {
2050
2064
  * Handles, in order: ISO; a month name with a day either side of it, with or
2051
2065
  * without an ordinal suffix or a year; and a numeric pair where only one
2052
2066
  * reading is possible (`13/05` can only be day-first, since 13 is not a month).
2067
+ * A day written alone with its ordinal suffix ("the 1st") resolves to the next
2068
+ * date on or after today that falls on that day.
2053
2069
  *
2054
2070
  * Deliberately NOT handled:
2055
2071
  * - A numeric pair where both numbers are 12 or under. `09/05` is September
@@ -2109,9 +2125,10 @@ declare const DATE_RANGE_META_END = "aiaDateRangeEnd";
2109
2125
  * - A backwards span ("October 13 - September 11"). Nothing here can tell a
2110
2126
  * typo from a year boundary the writer left implicit, and silently swapping
2111
2127
  * 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.
2128
+ * - A shared-month shorthand with a bare number ("September 11 - 13"). The
2129
+ * right half alone is not a date: a bare number is as likely a count.
2130
+ * With its ordinal suffix ("September 11 - 13th") the right half is a day
2131
+ * and resolves to its next date on or after the start, September 13.
2115
2132
  * - Anything where two different splits both read as a range — the text is
2116
2133
  * then genuinely ambiguous about where its own separator is.
2117
2134
  *
@@ -2710,6 +2727,10 @@ declare function syncPanelHug(dropdown: HTMLElement): void;
2710
2727
  * old content stays on top as a ghost that fades to transparent with a 2px
2711
2728
  * blur over 280ms, while the new content dissolves in (opacity 0 and a 2px
2712
2729
  * blur to clear, 320ms after a 40ms beat) on the same soft ease.
2730
+ * - While a request loads, the old content has already been fading out in
2731
+ * place (`data-aia-loading`, 160ms). The ghost then starts from the opacity
2732
+ * that fade had reached, never back at full, and when the fade has finished
2733
+ * there is no ghost at all: the new content just dissolves in.
2713
2734
  *
2714
2735
  * Opening and closing are CSS (the `--visible` transition). This module only
2715
2736
  * runs between two open renders. All three packages call `settlePanelMorph`
@@ -3153,7 +3174,7 @@ declare function buildQuery(text: string, completedParams: CompletedParamState[]
3153
3174
  /**
3154
3175
  * The dropdown footer's keyboard hint has three states, in priority order:
3155
3176
  * 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
3177
+ * 2. otherwise, the input is empty → "tab to select" (Tab picks the first
3157
3178
  * option). This is the ONLY state that shows "tab to select";
3158
3179
  * 3. otherwise (the input has text) → "→ to skip" — the right arrow skips the
3159
3180
  * 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";
@@ -1618,6 +1618,8 @@ declare class AIAutocomplete {
1618
1618
  private locationAbort;
1619
1619
  /** One provider session per location pill: every search for it, then the pick. */
1620
1620
  private locationSession;
1621
+ /** Where a space-picked place left the caret, until the editor reports its own. */
1622
+ private spacePickCaret;
1621
1623
  private readonly emitSubmit;
1622
1624
  private readonly emitError;
1623
1625
  constructor(container: HTMLElement, opts?: CoreOptions);
@@ -1828,6 +1830,18 @@ declare class AIAutocomplete {
1828
1830
  * `selectOption` like a tapped option — see `buildLocationOption`.
1829
1831
  */
1830
1832
  commitLocation(index?: number): void;
1833
+ /**
1834
+ * A space typed in the input right after words that name the top location
1835
+ * result exactly (its name, or what its brackets hold) picks that place,
1836
+ * as tapping its row would. Only once the search for those words has
1837
+ * answered, so a space while it loads keeps typing, and only while the field
1838
+ * is on screen, so a space never commits a place the user cannot see. The
1839
+ * exact match outranks the field's highlight: it is the top place the typed
1840
+ * words name, whichever row the arrows last rested on.
1841
+ */
1842
+ private spacePicksTopPlace;
1843
+ /** The place query the words after the last chip make, as the field mirrors it. */
1844
+ private typedLocationQuery;
1831
1845
  private runLocationSearch;
1832
1846
  private cancelLocationSearch;
1833
1847
  /**
@@ -2050,6 +2064,8 @@ interface LooseDateOptions {
2050
2064
  * Handles, in order: ISO; a month name with a day either side of it, with or
2051
2065
  * without an ordinal suffix or a year; and a numeric pair where only one
2052
2066
  * reading is possible (`13/05` can only be day-first, since 13 is not a month).
2067
+ * A day written alone with its ordinal suffix ("the 1st") resolves to the next
2068
+ * date on or after today that falls on that day.
2053
2069
  *
2054
2070
  * Deliberately NOT handled:
2055
2071
  * - A numeric pair where both numbers are 12 or under. `09/05` is September
@@ -2109,9 +2125,10 @@ declare const DATE_RANGE_META_END = "aiaDateRangeEnd";
2109
2125
  * - A backwards span ("October 13 - September 11"). Nothing here can tell a
2110
2126
  * typo from a year boundary the writer left implicit, and silently swapping
2111
2127
  * 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.
2128
+ * - A shared-month shorthand with a bare number ("September 11 - 13"). The
2129
+ * right half alone is not a date: a bare number is as likely a count.
2130
+ * With its ordinal suffix ("September 11 - 13th") the right half is a day
2131
+ * and resolves to its next date on or after the start, September 13.
2115
2132
  * - Anything where two different splits both read as a range — the text is
2116
2133
  * then genuinely ambiguous about where its own separator is.
2117
2134
  *
@@ -2710,6 +2727,10 @@ declare function syncPanelHug(dropdown: HTMLElement): void;
2710
2727
  * old content stays on top as a ghost that fades to transparent with a 2px
2711
2728
  * blur over 280ms, while the new content dissolves in (opacity 0 and a 2px
2712
2729
  * blur to clear, 320ms after a 40ms beat) on the same soft ease.
2730
+ * - While a request loads, the old content has already been fading out in
2731
+ * place (`data-aia-loading`, 160ms). The ghost then starts from the opacity
2732
+ * that fade had reached, never back at full, and when the fade has finished
2733
+ * there is no ghost at all: the new content just dissolves in.
2713
2734
  *
2714
2735
  * Opening and closing are CSS (the `--visible` transition). This module only
2715
2736
  * runs between two open renders. All three packages call `settlePanelMorph`
@@ -3153,7 +3174,7 @@ declare function buildQuery(text: string, completedParams: CompletedParamState[]
3153
3174
  /**
3154
3175
  * The dropdown footer's keyboard hint has three states, in priority order:
3155
3176
  * 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
3177
+ * 2. otherwise, the input is empty → "tab to select" (Tab picks the first
3157
3178
  * option). This is the ONLY state that shows "tab to select";
3158
3179
  * 3. otherwise (the input has text) → "→ to skip" — the right arrow skips the
3159
3180
  * active pill.