@magicx-eng/ai-autocomplete-vanilla 0.26.1 → 0.27.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 +5 -0
- package/dist/index.d.mts +92 -1
- package/dist/index.d.ts +92 -1
- package/dist/index.js +128 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +128 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -91,6 +91,9 @@ const ac = new AIAutocomplete(container, {
|
|
|
91
91
|
showSkipButton: true, // false = hide the pill bar's trailing "skip" button
|
|
92
92
|
showOptionIcons: true, // false = render option rows as text only (no icons)
|
|
93
93
|
showChipIcons: true, // false = render completed chips as text only (no icons)
|
|
94
|
+
showChipImages: true, // false = never draw an option's picture on its completed chip
|
|
95
|
+
showOptionImages: true, // false = never draw an option's image_url thumbnail
|
|
96
|
+
showOptionCounts: true, // false = never show an option's item_count
|
|
94
97
|
|
|
95
98
|
// Focus
|
|
96
99
|
autoFocus: true, // focus the input on mount (Tier 1 only)
|
|
@@ -546,6 +549,8 @@ unsub();
|
|
|
546
549
|
|
|
547
550
|
> **Option icons.** An option may carry an icon: `icon_svg` is inline SVG markup and `icon` its name. The built-in dropdown draws the SVG before the option's text, in the text color, and hides it while the row shows its loading skeleton. When rendering options yourself, pass `icon_svg` through the exported `sanitizeOptionIconSvg` before inserting it — it reduces the markup to plain vector drawing and returns `null` for anything else — and use `optionLabel(option)` for the text — it is the option's `text` alone; `icon` is the icon's name and is never shown as text, even when `icon_svg` is missing or fails to draw. A picked option's `icon` / `icon_svg` are copied onto its completed parameter, and the chip in the input draws the glyph before its text. Both surfaces can be switched off: `showOptionIcons: false` renders option rows as text only and `showChipIcons: false` renders chips as text only; either way the icon element is omitted rather than hidden.
|
|
548
551
|
|
|
552
|
+
> **Option pictures and counts.** An option may also carry `image_url` — a picture of the best-matching catalog item offering it — and `item_count`, how many items offer it (each is present only when the server includes it; when it includes counts, the options also arrive ordered by them, most items first; a starting state carries pictures but no counts). The built-in dropdown draws the picture as a square thumbnail before the option's text (in place of its `icon_svg`, so a row never leads with two visuals) and the count as a muted label at the row's trailing edge (`"12 items"`); a skeleton row keeps the tile's placeholder fill and hides the count. The unit word after the number is a token: set `--aia-option-count-unit: "sneakers"` to name what is being counted, `--aia-option-count-unit-one: "sneaker"` for a count of 1 (it falls back to the plural token), or `--aia-option-count-unit: ""` for the number alone. When rendering options yourself, pass `image_url` through the exported `optionImageSrc` before using it as an `<img src>` — it returns the URL only when it is `http(s)` and `null` otherwise — and `formatOptionCount(option.item_count)` gives the number the built-in rows print (`null` when there is no count); `optionCountLabel(count, unit?)` appends a unit for a dropdown that prints the word itself (`"item"` / `"items"` by default; one word, a `{ one, other }` pair, or `""` for none). Both surfaces can be switched off: `showOptionImages: false` renders rows without pictures (an option's icon then draws instead) and `showOptionCounts: false` hides the counts. A picked option's `image_url` is copied onto its completed parameter too, and the chip in the input draws it as a small rounded tile before its text, in place of the icon; `showChipImages: false` renders chips without pictures (the icon then draws instead). The tile is sized by `--aia-option-image-size` (40px), rounded by `--aia-option-image-radius` (12px), spaced by `--aia-option-image-gap` (12px) and filled by `--aia-option-image-bg` while its picture loads; the count reads `--aia-option-count-font-size` (12px), `--aia-option-count-color` and `--aia-option-count-opacity` (0.6); the chip's tile reads `--aia-chip-image-size` (1.25em of the chip's font), `--aia-chip-image-radius` (4px) and `--aia-chip-image-bg`.
|
|
553
|
+
|
|
549
554
|
### State shape (`CoreState`)
|
|
550
555
|
|
|
551
556
|
| Field | Type | Description |
|
package/dist/index.d.mts
CHANGED
|
@@ -7,6 +7,16 @@ interface CompletedParam {
|
|
|
7
7
|
}
|
|
8
8
|
interface SuggestionOption {
|
|
9
9
|
text: string;
|
|
10
|
+
/**
|
|
11
|
+
* The option's real, matchable value — present when the option has a
|
|
12
|
+
* separate matchable value from its display `text` (e.g. a hierarchical
|
|
13
|
+
* option's `text` is its last path segment, "Probiotics", while `value` is
|
|
14
|
+
* the full path `text` was shortened from). Sent to the server on tap
|
|
15
|
+
* instead of `text` (see `toWireParam`), so grounding still matches the
|
|
16
|
+
* full, collision-safe value while the row shows a short label. Falls
|
|
17
|
+
* back to `text` when absent.
|
|
18
|
+
*/
|
|
19
|
+
value?: string;
|
|
10
20
|
/**
|
|
11
21
|
* The icon's name — an identifier such as `"apple"`, exposed on the row as
|
|
12
22
|
* `data-aia-icon` when its `icon_svg` draws. Never rendered as text: a row
|
|
@@ -19,6 +29,22 @@ interface SuggestionOption {
|
|
|
19
29
|
* touches the DOM; markup that fails it renders no icon.
|
|
20
30
|
*/
|
|
21
31
|
icon_svg?: string;
|
|
32
|
+
/**
|
|
33
|
+
* URL of a picture for the option — the image of the best-matching catalog
|
|
34
|
+
* item offering it. Present only when the server includes pictures for the
|
|
35
|
+
* catalog being searched; absent otherwise. The built-in dropdown draws it
|
|
36
|
+
* as a square thumbnail before the text (see `optionImageSrc` for which
|
|
37
|
+
* URLs load).
|
|
38
|
+
*/
|
|
39
|
+
image_url?: string;
|
|
40
|
+
/**
|
|
41
|
+
* How many catalog items offer this option. Present only when the server
|
|
42
|
+
* includes counts, in which case the options also arrive ordered by it,
|
|
43
|
+
* most items first; absent otherwise (a starting state carries pictures but
|
|
44
|
+
* no counts). The built-in dropdown shows it at the row's trailing edge
|
|
45
|
+
* (see `optionCountLabel`).
|
|
46
|
+
*/
|
|
47
|
+
item_count?: number;
|
|
22
48
|
tag?: string;
|
|
23
49
|
is_tappable: boolean;
|
|
24
50
|
kind: TaskKind | null;
|
|
@@ -171,6 +197,8 @@ interface CustomFieldsReport {
|
|
|
171
197
|
interface CompletedParamState extends CompletedParam {
|
|
172
198
|
id: string;
|
|
173
199
|
text: string;
|
|
200
|
+
/** The originating option's `value` (see {@link SuggestionOption.value}), carried over so `toWireParam` can send it instead of the shortened `text`. */
|
|
201
|
+
value?: string;
|
|
174
202
|
/** Source suggestion's `type` — used by re-edit mode to render the dropdown pill. */
|
|
175
203
|
suggestionType: string;
|
|
176
204
|
/** Source suggestion's `text` — used by re-edit mode to render the dropdown pill. */
|
|
@@ -185,6 +213,12 @@ interface CompletedParamState extends CompletedParam {
|
|
|
185
213
|
*/
|
|
186
214
|
icon?: string;
|
|
187
215
|
icon_svg?: string;
|
|
216
|
+
/**
|
|
217
|
+
* The picked option's `image_url`, carried over so the completed chip draws
|
|
218
|
+
* the same picture its option row did, in place of the icon. Absent when
|
|
219
|
+
* the option carried none.
|
|
220
|
+
*/
|
|
221
|
+
image_url?: string;
|
|
188
222
|
}
|
|
189
223
|
/**
|
|
190
224
|
* A suggestion the user dismissed with the skip key (→) instead of filling.
|
|
@@ -809,6 +843,12 @@ interface CoreOptions {
|
|
|
809
843
|
showOptionIcons?: boolean;
|
|
810
844
|
/** When true (default), a completed chip in the input draws the icon of the option that answered it. Set to false to render chips as text only. */
|
|
811
845
|
showChipIcons?: boolean;
|
|
846
|
+
/** When true (default), a completed chip in the input draws the picture (`image_url`) of the option that answered it, in place of its icon. Set to false to render chips without pictures. */
|
|
847
|
+
showChipImages?: boolean;
|
|
848
|
+
/** When true (default), an option that carries an `image_url` draws it as a square thumbnail before its text in the dropdown (in place of its `icon_svg`). Set to false to render option rows without pictures. */
|
|
849
|
+
showOptionImages?: boolean;
|
|
850
|
+
/** When true (default), an option that carries an `item_count` shows it as a muted label at the row's trailing edge ("12 items"). Set to false to hide the counts. */
|
|
851
|
+
showOptionCounts?: boolean;
|
|
812
852
|
/**
|
|
813
853
|
* When true (default), the dropdown's pill bar ends in a small "skip" button
|
|
814
854
|
* that dismisses the active pill — same action as pressing → at the end of
|
|
@@ -1662,6 +1702,55 @@ declare function attachProductRowWheel(row: HTMLElement): () => void;
|
|
|
1662
1702
|
*/
|
|
1663
1703
|
declare function scrollCaretIntoView(root: HTMLElement): void;
|
|
1664
1704
|
|
|
1705
|
+
/**
|
|
1706
|
+
* The picture an option may carry (`image_url`) and the number of catalog
|
|
1707
|
+
* items behind it (`item_count`). Both are optional on the wire — present
|
|
1708
|
+
* only when the server includes them for the catalog being searched — and
|
|
1709
|
+
* both are drawn by the built-in dropdown: the picture as a square thumbnail
|
|
1710
|
+
* before the text, the count as a muted label at the row's trailing edge.
|
|
1711
|
+
* These helpers are what the three packages' rows share, and are exported
|
|
1712
|
+
* for a custom dropdown that renders options itself.
|
|
1713
|
+
*/
|
|
1714
|
+
/**
|
|
1715
|
+
* The `src` to draw an option's `image_url` with, or `null` when the URL must
|
|
1716
|
+
* not be loaded. Only an `http(s)` URL is accepted — resolved against the
|
|
1717
|
+
* page, so a root-relative path from a same-origin catalog still works —
|
|
1718
|
+
* which keeps `javascript:`, `data:` and `blob:` sources out of an `<img>`
|
|
1719
|
+
* the server populates.
|
|
1720
|
+
*/
|
|
1721
|
+
declare function optionImageSrc(url: string | undefined): string | null;
|
|
1722
|
+
/**
|
|
1723
|
+
* An option's `item_count` as the built-in rows print it: the number alone,
|
|
1724
|
+
* grouped the way the page's locale groups numbers (`"1,200"`). The unit word
|
|
1725
|
+
* after it is the stylesheet's — `--aia-option-count-unit` (default
|
|
1726
|
+
* `"items"`, `--aia-option-count-unit-one` for a count of 1) — so a consumer
|
|
1727
|
+
* names what is being counted, or blanks it, without a render option. `null`
|
|
1728
|
+
* for an absent, negative or non-integer count: a count the server did not
|
|
1729
|
+
* send is not a count of zero.
|
|
1730
|
+
*/
|
|
1731
|
+
declare function formatOptionCount(count: number | undefined): string | null;
|
|
1732
|
+
/** The unit `optionCountLabel` appends when given none: `"1 item"`, `"12 items"`. */
|
|
1733
|
+
declare const DEFAULT_OPTION_COUNT_UNIT: {
|
|
1734
|
+
readonly one: "item";
|
|
1735
|
+
readonly other: "items";
|
|
1736
|
+
};
|
|
1737
|
+
/**
|
|
1738
|
+
* A full label for an option's `item_count`, for a custom dropdown that
|
|
1739
|
+
* prints the unit itself: `formatOptionCount` followed by the unit — one
|
|
1740
|
+
* word for every count, or a singular/plural pair — or the number alone for
|
|
1741
|
+
* an empty unit. `null` when there is no count.
|
|
1742
|
+
*/
|
|
1743
|
+
declare function optionCountLabel(count: number | undefined, unit?: string | {
|
|
1744
|
+
one: string;
|
|
1745
|
+
other: string;
|
|
1746
|
+
}): string | null;
|
|
1747
|
+
/**
|
|
1748
|
+
* Whether `option` carries a picture the built-in dropdown would draw: an
|
|
1749
|
+
* `image_url` that `optionImageSrc` accepts. (The dropdown still skips it
|
|
1750
|
+
* when its images are switched off.)
|
|
1751
|
+
*/
|
|
1752
|
+
declare function optionHasImage(option: SuggestionOption): boolean;
|
|
1753
|
+
|
|
1665
1754
|
/**
|
|
1666
1755
|
* Reduces an option's `icon_svg` markup to plain vector drawing before it is
|
|
1667
1756
|
* inserted into the dropdown. The icons come from the server's own curated
|
|
@@ -1728,6 +1817,8 @@ interface RenderEditableArgs {
|
|
|
1728
1817
|
isFocused: boolean;
|
|
1729
1818
|
/** Whether completed chips draw the icon of the option that answered them. Default: true. */
|
|
1730
1819
|
showChipIcons?: boolean;
|
|
1820
|
+
/** Whether completed chips draw the picture of the option that answered them, in place of the icon. Default: true. */
|
|
1821
|
+
showChipImages?: boolean;
|
|
1731
1822
|
}
|
|
1732
1823
|
/**
|
|
1733
1824
|
* Renders text segments into the contentEditable input. Completed params are
|
|
@@ -1998,4 +2089,4 @@ interface SubmitResultExtras {
|
|
|
1998
2089
|
*/
|
|
1999
2090
|
declare function buildSubmitResult(text: string, completedParams: CompletedParamState[], skippedParams?: SkippedParamState[], extras?: SubmitResultExtras): AutocompleteResult;
|
|
2000
2091
|
|
|
2001
|
-
export { AIAutocomplete, type APIConfig, type APIKeyConfig, ATTRIBUTION_URL, type AccessTokenConfig, type AccessTokenResult, type AppearanceMode, type AutocompleteRequest, type AutocompleteResponse, type AutocompleteResult, type CompletedParam, type CompletedParamState, type CoreOptions, type CoreState, type CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, type DateMonthView, type DateRange, type DateSelection, type ExpressedFilter, type FilterOp, type FormatType, type IdentifiedParam, type IdentifiedParamState, type InputItem, type LooseDateOptions, type MatchedItem, type MatchedItems, ModeController, OPTIONS_GRID_MOBILE_QUERY, OPTION_ENTER_DELAY_VAR, OPTION_ENTER_FADE_MS, OPTION_ENTER_RISE_MS, OPTION_ENTER_RISE_PX, OPTION_ENTER_STAGGER_MS, type OptionOverride, type OptionOverrides, type OptionsGridLayout, type OptionsGridPlan, PLACEHOLDER_FADE_OUT_MS, PLACEHOLDER_LEAVING_ATTR, PLACEHOLDER_SWAP_GAP_MS, PLACEHOLDER_TYPE_MS, PLACEHOLDER_WORD_PAUSE_MS, PRODUCT_PATH_PREFIX, PRODUCT_ROW_PX_PER_LINE, type Product, type ProductRowMetrics, type ProductRowWheel, type ProductsConfig, type ProductsLayout, RANGE_SEPARATOR, type RecentlySuggested, type RenderMode, SCROLL_ARROW_ATTR, SCROLL_ARROW_BOTTOM_VAR, SCROLL_ARROW_CLASS, SCROLL_ARROW_FADE_MS, SCROLL_ARROW_LABEL, SCROLL_ARROW_SCROLL_IDLE_MS, SCROLL_ARROW_VISIBLE_ATTR, SKIPPED_PARAM_TEXT, type ScrollArrowArgs, type ScrollArrowController, type Segment, type SkippedParamState, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type TaskKind, WEEKDAY_LABELS, addMonths, attachProductRowWheel, attachScrollArrow, buildAttributionUrl, buildDateOptions, buildQuery, buildSubmitResult, cellDay, cellIso, computeOptionsGridLayout, createStore, cursorIsAtEnd, dateCellMarks, dateSelectionFor, extractPlainText, formatAbsoluteDate, formatDate, formatDateRange, getCursorOffset, getFooterHint, identifiedParamLabel, isCalendarFormat, isOptionsGridMobileViewport, isoDate, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, optionEnterDelayMs, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, parseDate, parseLooseDate, parseLooseDateRange, plainTextLength, planOptionsGrid, previousGraphemeBoundary, productFromMatchedItem, productRowWheelTarget, productsFromCustomFields, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, toWireIdentifiedParams, visibleDateRange, withSkippedParams };
|
|
2092
|
+
export { AIAutocomplete, type APIConfig, type APIKeyConfig, ATTRIBUTION_URL, type AccessTokenConfig, type AccessTokenResult, type AppearanceMode, type AutocompleteRequest, type AutocompleteResponse, type AutocompleteResult, type CompletedParam, type CompletedParamState, type CoreOptions, type CoreState, type CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, type DateMonthView, type DateRange, type DateSelection, type ExpressedFilter, type FilterOp, type FormatType, type IdentifiedParam, type IdentifiedParamState, type InputItem, type LooseDateOptions, type MatchedItem, type MatchedItems, ModeController, OPTIONS_GRID_MOBILE_QUERY, OPTION_ENTER_DELAY_VAR, OPTION_ENTER_FADE_MS, OPTION_ENTER_RISE_MS, OPTION_ENTER_RISE_PX, OPTION_ENTER_STAGGER_MS, type OptionOverride, type OptionOverrides, type OptionsGridLayout, type OptionsGridPlan, PLACEHOLDER_FADE_OUT_MS, PLACEHOLDER_LEAVING_ATTR, PLACEHOLDER_SWAP_GAP_MS, PLACEHOLDER_TYPE_MS, PLACEHOLDER_WORD_PAUSE_MS, PRODUCT_PATH_PREFIX, PRODUCT_ROW_PX_PER_LINE, type Product, type ProductRowMetrics, type ProductRowWheel, type ProductsConfig, type ProductsLayout, RANGE_SEPARATOR, type RecentlySuggested, type RenderMode, SCROLL_ARROW_ATTR, SCROLL_ARROW_BOTTOM_VAR, SCROLL_ARROW_CLASS, SCROLL_ARROW_FADE_MS, SCROLL_ARROW_LABEL, SCROLL_ARROW_SCROLL_IDLE_MS, SCROLL_ARROW_VISIBLE_ATTR, SKIPPED_PARAM_TEXT, type ScrollArrowArgs, type ScrollArrowController, type Segment, type SkippedParamState, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type TaskKind, WEEKDAY_LABELS, addMonths, attachProductRowWheel, attachScrollArrow, buildAttributionUrl, buildDateOptions, buildQuery, buildSubmitResult, cellDay, cellIso, computeOptionsGridLayout, createStore, cursorIsAtEnd, dateCellMarks, dateSelectionFor, extractPlainText, formatAbsoluteDate, formatDate, formatDateRange, formatOptionCount, getCursorOffset, getFooterHint, identifiedParamLabel, isCalendarFormat, isOptionsGridMobileViewport, isoDate, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, optionCountLabel, optionEnterDelayMs, optionHasImage, optionImageSrc, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, parseDate, parseLooseDate, parseLooseDateRange, plainTextLength, planOptionsGrid, previousGraphemeBoundary, productFromMatchedItem, productRowWheelTarget, productsFromCustomFields, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, toWireIdentifiedParams, visibleDateRange, withSkippedParams };
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,16 @@ interface CompletedParam {
|
|
|
7
7
|
}
|
|
8
8
|
interface SuggestionOption {
|
|
9
9
|
text: string;
|
|
10
|
+
/**
|
|
11
|
+
* The option's real, matchable value — present when the option has a
|
|
12
|
+
* separate matchable value from its display `text` (e.g. a hierarchical
|
|
13
|
+
* option's `text` is its last path segment, "Probiotics", while `value` is
|
|
14
|
+
* the full path `text` was shortened from). Sent to the server on tap
|
|
15
|
+
* instead of `text` (see `toWireParam`), so grounding still matches the
|
|
16
|
+
* full, collision-safe value while the row shows a short label. Falls
|
|
17
|
+
* back to `text` when absent.
|
|
18
|
+
*/
|
|
19
|
+
value?: string;
|
|
10
20
|
/**
|
|
11
21
|
* The icon's name — an identifier such as `"apple"`, exposed on the row as
|
|
12
22
|
* `data-aia-icon` when its `icon_svg` draws. Never rendered as text: a row
|
|
@@ -19,6 +29,22 @@ interface SuggestionOption {
|
|
|
19
29
|
* touches the DOM; markup that fails it renders no icon.
|
|
20
30
|
*/
|
|
21
31
|
icon_svg?: string;
|
|
32
|
+
/**
|
|
33
|
+
* URL of a picture for the option — the image of the best-matching catalog
|
|
34
|
+
* item offering it. Present only when the server includes pictures for the
|
|
35
|
+
* catalog being searched; absent otherwise. The built-in dropdown draws it
|
|
36
|
+
* as a square thumbnail before the text (see `optionImageSrc` for which
|
|
37
|
+
* URLs load).
|
|
38
|
+
*/
|
|
39
|
+
image_url?: string;
|
|
40
|
+
/**
|
|
41
|
+
* How many catalog items offer this option. Present only when the server
|
|
42
|
+
* includes counts, in which case the options also arrive ordered by it,
|
|
43
|
+
* most items first; absent otherwise (a starting state carries pictures but
|
|
44
|
+
* no counts). The built-in dropdown shows it at the row's trailing edge
|
|
45
|
+
* (see `optionCountLabel`).
|
|
46
|
+
*/
|
|
47
|
+
item_count?: number;
|
|
22
48
|
tag?: string;
|
|
23
49
|
is_tappable: boolean;
|
|
24
50
|
kind: TaskKind | null;
|
|
@@ -171,6 +197,8 @@ interface CustomFieldsReport {
|
|
|
171
197
|
interface CompletedParamState extends CompletedParam {
|
|
172
198
|
id: string;
|
|
173
199
|
text: string;
|
|
200
|
+
/** The originating option's `value` (see {@link SuggestionOption.value}), carried over so `toWireParam` can send it instead of the shortened `text`. */
|
|
201
|
+
value?: string;
|
|
174
202
|
/** Source suggestion's `type` — used by re-edit mode to render the dropdown pill. */
|
|
175
203
|
suggestionType: string;
|
|
176
204
|
/** Source suggestion's `text` — used by re-edit mode to render the dropdown pill. */
|
|
@@ -185,6 +213,12 @@ interface CompletedParamState extends CompletedParam {
|
|
|
185
213
|
*/
|
|
186
214
|
icon?: string;
|
|
187
215
|
icon_svg?: string;
|
|
216
|
+
/**
|
|
217
|
+
* The picked option's `image_url`, carried over so the completed chip draws
|
|
218
|
+
* the same picture its option row did, in place of the icon. Absent when
|
|
219
|
+
* the option carried none.
|
|
220
|
+
*/
|
|
221
|
+
image_url?: string;
|
|
188
222
|
}
|
|
189
223
|
/**
|
|
190
224
|
* A suggestion the user dismissed with the skip key (→) instead of filling.
|
|
@@ -809,6 +843,12 @@ interface CoreOptions {
|
|
|
809
843
|
showOptionIcons?: boolean;
|
|
810
844
|
/** When true (default), a completed chip in the input draws the icon of the option that answered it. Set to false to render chips as text only. */
|
|
811
845
|
showChipIcons?: boolean;
|
|
846
|
+
/** When true (default), a completed chip in the input draws the picture (`image_url`) of the option that answered it, in place of its icon. Set to false to render chips without pictures. */
|
|
847
|
+
showChipImages?: boolean;
|
|
848
|
+
/** When true (default), an option that carries an `image_url` draws it as a square thumbnail before its text in the dropdown (in place of its `icon_svg`). Set to false to render option rows without pictures. */
|
|
849
|
+
showOptionImages?: boolean;
|
|
850
|
+
/** When true (default), an option that carries an `item_count` shows it as a muted label at the row's trailing edge ("12 items"). Set to false to hide the counts. */
|
|
851
|
+
showOptionCounts?: boolean;
|
|
812
852
|
/**
|
|
813
853
|
* When true (default), the dropdown's pill bar ends in a small "skip" button
|
|
814
854
|
* that dismisses the active pill — same action as pressing → at the end of
|
|
@@ -1662,6 +1702,55 @@ declare function attachProductRowWheel(row: HTMLElement): () => void;
|
|
|
1662
1702
|
*/
|
|
1663
1703
|
declare function scrollCaretIntoView(root: HTMLElement): void;
|
|
1664
1704
|
|
|
1705
|
+
/**
|
|
1706
|
+
* The picture an option may carry (`image_url`) and the number of catalog
|
|
1707
|
+
* items behind it (`item_count`). Both are optional on the wire — present
|
|
1708
|
+
* only when the server includes them for the catalog being searched — and
|
|
1709
|
+
* both are drawn by the built-in dropdown: the picture as a square thumbnail
|
|
1710
|
+
* before the text, the count as a muted label at the row's trailing edge.
|
|
1711
|
+
* These helpers are what the three packages' rows share, and are exported
|
|
1712
|
+
* for a custom dropdown that renders options itself.
|
|
1713
|
+
*/
|
|
1714
|
+
/**
|
|
1715
|
+
* The `src` to draw an option's `image_url` with, or `null` when the URL must
|
|
1716
|
+
* not be loaded. Only an `http(s)` URL is accepted — resolved against the
|
|
1717
|
+
* page, so a root-relative path from a same-origin catalog still works —
|
|
1718
|
+
* which keeps `javascript:`, `data:` and `blob:` sources out of an `<img>`
|
|
1719
|
+
* the server populates.
|
|
1720
|
+
*/
|
|
1721
|
+
declare function optionImageSrc(url: string | undefined): string | null;
|
|
1722
|
+
/**
|
|
1723
|
+
* An option's `item_count` as the built-in rows print it: the number alone,
|
|
1724
|
+
* grouped the way the page's locale groups numbers (`"1,200"`). The unit word
|
|
1725
|
+
* after it is the stylesheet's — `--aia-option-count-unit` (default
|
|
1726
|
+
* `"items"`, `--aia-option-count-unit-one` for a count of 1) — so a consumer
|
|
1727
|
+
* names what is being counted, or blanks it, without a render option. `null`
|
|
1728
|
+
* for an absent, negative or non-integer count: a count the server did not
|
|
1729
|
+
* send is not a count of zero.
|
|
1730
|
+
*/
|
|
1731
|
+
declare function formatOptionCount(count: number | undefined): string | null;
|
|
1732
|
+
/** The unit `optionCountLabel` appends when given none: `"1 item"`, `"12 items"`. */
|
|
1733
|
+
declare const DEFAULT_OPTION_COUNT_UNIT: {
|
|
1734
|
+
readonly one: "item";
|
|
1735
|
+
readonly other: "items";
|
|
1736
|
+
};
|
|
1737
|
+
/**
|
|
1738
|
+
* A full label for an option's `item_count`, for a custom dropdown that
|
|
1739
|
+
* prints the unit itself: `formatOptionCount` followed by the unit — one
|
|
1740
|
+
* word for every count, or a singular/plural pair — or the number alone for
|
|
1741
|
+
* an empty unit. `null` when there is no count.
|
|
1742
|
+
*/
|
|
1743
|
+
declare function optionCountLabel(count: number | undefined, unit?: string | {
|
|
1744
|
+
one: string;
|
|
1745
|
+
other: string;
|
|
1746
|
+
}): string | null;
|
|
1747
|
+
/**
|
|
1748
|
+
* Whether `option` carries a picture the built-in dropdown would draw: an
|
|
1749
|
+
* `image_url` that `optionImageSrc` accepts. (The dropdown still skips it
|
|
1750
|
+
* when its images are switched off.)
|
|
1751
|
+
*/
|
|
1752
|
+
declare function optionHasImage(option: SuggestionOption): boolean;
|
|
1753
|
+
|
|
1665
1754
|
/**
|
|
1666
1755
|
* Reduces an option's `icon_svg` markup to plain vector drawing before it is
|
|
1667
1756
|
* inserted into the dropdown. The icons come from the server's own curated
|
|
@@ -1728,6 +1817,8 @@ interface RenderEditableArgs {
|
|
|
1728
1817
|
isFocused: boolean;
|
|
1729
1818
|
/** Whether completed chips draw the icon of the option that answered them. Default: true. */
|
|
1730
1819
|
showChipIcons?: boolean;
|
|
1820
|
+
/** Whether completed chips draw the picture of the option that answered them, in place of the icon. Default: true. */
|
|
1821
|
+
showChipImages?: boolean;
|
|
1731
1822
|
}
|
|
1732
1823
|
/**
|
|
1733
1824
|
* Renders text segments into the contentEditable input. Completed params are
|
|
@@ -1998,4 +2089,4 @@ interface SubmitResultExtras {
|
|
|
1998
2089
|
*/
|
|
1999
2090
|
declare function buildSubmitResult(text: string, completedParams: CompletedParamState[], skippedParams?: SkippedParamState[], extras?: SubmitResultExtras): AutocompleteResult;
|
|
2000
2091
|
|
|
2001
|
-
export { AIAutocomplete, type APIConfig, type APIKeyConfig, ATTRIBUTION_URL, type AccessTokenConfig, type AccessTokenResult, type AppearanceMode, type AutocompleteRequest, type AutocompleteResponse, type AutocompleteResult, type CompletedParam, type CompletedParamState, type CoreOptions, type CoreState, type CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, type DateMonthView, type DateRange, type DateSelection, type ExpressedFilter, type FilterOp, type FormatType, type IdentifiedParam, type IdentifiedParamState, type InputItem, type LooseDateOptions, type MatchedItem, type MatchedItems, ModeController, OPTIONS_GRID_MOBILE_QUERY, OPTION_ENTER_DELAY_VAR, OPTION_ENTER_FADE_MS, OPTION_ENTER_RISE_MS, OPTION_ENTER_RISE_PX, OPTION_ENTER_STAGGER_MS, type OptionOverride, type OptionOverrides, type OptionsGridLayout, type OptionsGridPlan, PLACEHOLDER_FADE_OUT_MS, PLACEHOLDER_LEAVING_ATTR, PLACEHOLDER_SWAP_GAP_MS, PLACEHOLDER_TYPE_MS, PLACEHOLDER_WORD_PAUSE_MS, PRODUCT_PATH_PREFIX, PRODUCT_ROW_PX_PER_LINE, type Product, type ProductRowMetrics, type ProductRowWheel, type ProductsConfig, type ProductsLayout, RANGE_SEPARATOR, type RecentlySuggested, type RenderMode, SCROLL_ARROW_ATTR, SCROLL_ARROW_BOTTOM_VAR, SCROLL_ARROW_CLASS, SCROLL_ARROW_FADE_MS, SCROLL_ARROW_LABEL, SCROLL_ARROW_SCROLL_IDLE_MS, SCROLL_ARROW_VISIBLE_ATTR, SKIPPED_PARAM_TEXT, type ScrollArrowArgs, type ScrollArrowController, type Segment, type SkippedParamState, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type TaskKind, WEEKDAY_LABELS, addMonths, attachProductRowWheel, attachScrollArrow, buildAttributionUrl, buildDateOptions, buildQuery, buildSubmitResult, cellDay, cellIso, computeOptionsGridLayout, createStore, cursorIsAtEnd, dateCellMarks, dateSelectionFor, extractPlainText, formatAbsoluteDate, formatDate, formatDateRange, getCursorOffset, getFooterHint, identifiedParamLabel, isCalendarFormat, isOptionsGridMobileViewport, isoDate, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, optionEnterDelayMs, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, parseDate, parseLooseDate, parseLooseDateRange, plainTextLength, planOptionsGrid, previousGraphemeBoundary, productFromMatchedItem, productRowWheelTarget, productsFromCustomFields, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, toWireIdentifiedParams, visibleDateRange, withSkippedParams };
|
|
2092
|
+
export { AIAutocomplete, type APIConfig, type APIKeyConfig, ATTRIBUTION_URL, type AccessTokenConfig, type AccessTokenResult, type AppearanceMode, type AutocompleteRequest, type AutocompleteResponse, type AutocompleteResult, type CompletedParam, type CompletedParamState, type CoreOptions, type CoreState, type CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, type DateMonthView, type DateRange, type DateSelection, type ExpressedFilter, type FilterOp, type FormatType, type IdentifiedParam, type IdentifiedParamState, type InputItem, type LooseDateOptions, type MatchedItem, type MatchedItems, ModeController, OPTIONS_GRID_MOBILE_QUERY, OPTION_ENTER_DELAY_VAR, OPTION_ENTER_FADE_MS, OPTION_ENTER_RISE_MS, OPTION_ENTER_RISE_PX, OPTION_ENTER_STAGGER_MS, type OptionOverride, type OptionOverrides, type OptionsGridLayout, type OptionsGridPlan, PLACEHOLDER_FADE_OUT_MS, PLACEHOLDER_LEAVING_ATTR, PLACEHOLDER_SWAP_GAP_MS, PLACEHOLDER_TYPE_MS, PLACEHOLDER_WORD_PAUSE_MS, PRODUCT_PATH_PREFIX, PRODUCT_ROW_PX_PER_LINE, type Product, type ProductRowMetrics, type ProductRowWheel, type ProductsConfig, type ProductsLayout, RANGE_SEPARATOR, type RecentlySuggested, type RenderMode, SCROLL_ARROW_ATTR, SCROLL_ARROW_BOTTOM_VAR, SCROLL_ARROW_CLASS, SCROLL_ARROW_FADE_MS, SCROLL_ARROW_LABEL, SCROLL_ARROW_SCROLL_IDLE_MS, SCROLL_ARROW_VISIBLE_ATTR, SKIPPED_PARAM_TEXT, type ScrollArrowArgs, type ScrollArrowController, type Segment, type SkippedParamState, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type TaskKind, WEEKDAY_LABELS, addMonths, attachProductRowWheel, attachScrollArrow, buildAttributionUrl, buildDateOptions, buildQuery, buildSubmitResult, cellDay, cellIso, computeOptionsGridLayout, createStore, cursorIsAtEnd, dateCellMarks, dateSelectionFor, extractPlainText, formatAbsoluteDate, formatDate, formatDateRange, formatOptionCount, getCursorOffset, getFooterHint, identifiedParamLabel, isCalendarFormat, isOptionsGridMobileViewport, isoDate, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, optionCountLabel, optionEnterDelayMs, optionHasImage, optionImageSrc, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, parseDate, parseLooseDate, parseLooseDateRange, plainTextLength, planOptionsGrid, previousGraphemeBoundary, productFromMatchedItem, productRowWheelTarget, productsFromCustomFields, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, toWireIdentifiedParams, visibleDateRange, withSkippedParams };
|