@magicx-eng/ai-autocomplete-vanilla 0.58.1 → 0.60.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 CHANGED
@@ -341,7 +341,7 @@ unsub();
341
341
  > **Custom (rich-text) editors:** the wiring above assumes `myInput` is a `<textarea>`/`<input>`, whose caret the library reads directly. If you're driving a contentEditable or rich-text editor instead, also call `ac.handleCaretMove(offset)` on selection changes (with the caret as a plain-text offset) so arrow keys can move from the input into the dropdown.
342
342
 
343
343
 
344
- > **Datepicker in a custom UI.** For a date parameter, `state.activeFormatType` is `"date"` and `state.filteredOptions` 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 — `selectOption(cell)` behaves exactly as it does for an option. To draw an actual calendar, read `state.dateView` for the month on show, `cellDay(cell)` for the number to paint, and call `showPreviousMonth()` / `showNextMonth()` to page. Cells that pad the start and end of the month have `is_tappable: false`. For a **range** parameter `activeFormatType` is `"date-range"` and the same `selectOption(cell)` is called twice: the first records the start (`state.dateRangeStart` holds it, and nothing is committed yet), the second commits the span. `dateCellMarks` and `visibleDateRange` are exported to paint the two ends and the band between them the way the built-in calendars do.
344
+ > **Datepicker in a custom UI.** For a date parameter, `state.activeFormatType` is `"date"` and `state.filteredOptions` 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 — `selectOption(cell)` behaves exactly as it does for an option. To draw an actual calendar, read `state.dateView` for the month on show, `cellDay(cell)` for the number to paint, and call `showPreviousMonth()` / `showNextMonth()` to page. Cells that pad the start and end of the month have `is_tappable: false`. For a **range** parameter `activeFormatType` is `"date-range"` and the same `selectOption(cell)` is called twice: the first records the start (`state.dateRangeStart` holds it, and nothing is committed yet), the second commits the span. `dateCellMarks` and `visibleDateRange` are exported to paint the two ends and the band between them the way the built-in calendars do. A `"date"` question can also ask the end of a range whose start is already known. Then `state.dateFloor` holds that start: mark it, dim the days before it (`isDimmedDay` and `dateFloorFor` are exported for this), and note that picking one of them does nothing.
345
345
 
346
346
  > **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.
347
347
 
@@ -361,6 +361,7 @@ unsub();
361
361
  | `activeFormatType` | `"options" \| "date" \| "date-range"` | How the active parameter is answered: pick an option, pick a date, or pick a span of dates. Both date formats show a calendar instead of the option list; `"date-range"` takes two clicks, a start and an end. Typing does not filter it — the text is treated as a new query. |
362
362
  | `dateView` | `DateMonthView \| null` | The month the calendar is showing (`{ year, month }`, 0-based month). Null unless `activeFormatType` is a calendar one. |
363
363
  | `dateRangeStart` | `string \| null` | While a range is half-picked, the start already chosen, as `YYYY-MM-DD`. Null at every other moment, including for every non-range parameter. |
364
+ | `dateFloor` | `string \| null` | The earliest day the active date question takes, as `YYYY-MM-DD`. Set while a single-date question asks the end of a date range whose start is already known: the built-in calendar marks that start, dims the days before it, and no earlier day can be picked. Null at every other moment. |
364
365
  | `segments` | `Segment[]` | Input text split into typed text vs completed params — completed segments render as bold `<strong>` runs inside the editor |
365
366
  | `placeholderText` | `string` | Placeholder text from server suggestions (joined `placeholder`-type suggestion texts) |
366
367
  | `activeDropdownIndex` | `number` | Highlighted option index (-1 = none) |
package/REFERENCE.md CHANGED
@@ -589,9 +589,11 @@ The full input also accepts `--aia-input-radius` and `--aia-written-text-font-we
589
589
  | `--aia-time-panel-width` | `240px` | `240px` | Max width of the whole dropdown panel while the time wheel is up. |
590
590
  | `--aia-time-font-size` | `15px` | `15px` | The time wheel's numbers and its `:` separator. |
591
591
  | `--aia-time-band-bg` | white at 8% | white at 8% | The band behind the wheels' top rows — the chosen time. |
592
- | `--aia-time-done-bg` | white at 10% | white at 10% | The time wheel's Done button. |
593
- | `--aia-time-done-bg-hover` | white at 16% | white at 16% | The Done button on hover. |
594
- | `--aia-time-done-color` | `--aia-option-color-selected` | `--aia-option-color-selected` | The Done button's text. |
592
+ | `--aia-confirm-bg` | `#262626` | `#a6a6a6` | The solid fill shared by the Done buttons (multi-select and time wheel) and a checked multi-select checkbox. |
593
+ | `--aia-confirm-bg-hover` | `#404040` | `#b8b8b8` | The Done buttons on hover. |
594
+ | `--aia-confirm-color` | `#ffffff` | `#000000` | The Done buttons' text and the checkbox's checkmark. |
595
+ | `--aia-multi-done-bg` / `--aia-multi-done-bg-hover` / `--aia-multi-done-color` | `--aia-confirm-*` | `--aia-confirm-*` | Override the multi-select Done button alone. |
596
+ | `--aia-time-done-bg` / `--aia-time-done-bg-hover` / `--aia-time-done-color` | `--aia-confirm-*` | `--aia-confirm-*` | Override the time wheel's Done button alone. |
595
597
  | `--aia-location-field-bg` | `--aia-streak-rgb` at 6% (indigo) | `--aia-streak-rgb` at 6% (white) | The location search field. |
596
598
  | `--aia-location-field-radius` | `10px` | `10px` | Corner radius of the location search field. |
597
599
  | `--aia-location-font-size` | `15px` | `15px` | The location field's text and the place names. |
package/dist/index.d.mts CHANGED
@@ -125,6 +125,14 @@ interface InputItem {
125
125
  * type names a date or date range opens a calendar when tapped.
126
126
  */
127
127
  type?: SuggestionType;
128
+ /**
129
+ * The date an identified date span states, or the start of a date range, as
130
+ * `YYYY-MM-DD` in the user's time zone. A relative phrase such as "this
131
+ * Saturday" carries one. Absent when the span states no date.
132
+ */
133
+ iso_date?: string;
134
+ /** The last day of an identified date range, `YYYY-MM-DD`. Absent while the range has no end. */
135
+ iso_date_end?: string;
128
136
  }
129
137
  /** Wire shape for an LLM-identified param echoed back to the server. */
130
138
  interface IdentifiedParam {
@@ -174,6 +182,8 @@ interface AutocompleteRequest {
174
182
  currency_rate?: number;
175
183
  country?: string;
176
184
  client_version: string;
185
+ /** The browser's IANA time zone ("Asia/Seoul"). Dates the user types are understood in this zone. */
186
+ timezone?: string;
177
187
  session_id: string;
178
188
  source?: "full-sdk" | "headless-sdk";
179
189
  /** The wire format this SDK speaks ({@link SCHEMA_VERSION}). */
@@ -392,6 +402,10 @@ interface IdentifiedParamState {
392
402
  text: string;
393
403
  /** The span's value type, from its `input` item. */
394
404
  type?: SuggestionType;
405
+ /** The date the span states, or a range's start: `YYYY-MM-DD`. */
406
+ isoDate?: string;
407
+ /** The last day of a range the span states: `YYYY-MM-DD`. */
408
+ isoDateEnd?: string;
395
409
  }
396
410
  type Segment = {
397
411
  type: "text";
@@ -1151,6 +1165,13 @@ interface CoreDerivedState {
1151
1165
  * first. The calendars paint the span between it and the highlighted cell.
1152
1166
  */
1153
1167
  dateRangeStart: string | null;
1168
+ /**
1169
+ * The earliest day the active date question takes, as `YYYY-MM-DD`, or null.
1170
+ * Set while a single-date question asks the end of a date range whose start
1171
+ * an identified span already carries ("from this Saturday"): the calendars
1172
+ * mark that start, dim the days before it, and no earlier day can be picked.
1173
+ */
1174
+ dateFloor: string | null;
1154
1175
  /**
1155
1176
  * What the time wheel shows. Null unless `activeFormatType` is `"time"`.
1156
1177
  * `touched` is false while it still shows its suggested starting time.
@@ -1638,10 +1659,11 @@ declare class AIAutocomplete {
1638
1659
  * Returns false for anything else — an identified span whose `type` the
1639
1660
  * server didn't name as a date or date range stays inert.
1640
1661
  *
1641
- * The span's own text is read for a starting month (`parseLooseDate`), but
1642
- * failing to read it is not a failure: the calendar opens either way, and
1643
- * whatever the user picks replaces the span with the SDK's canonical form. So
1644
- * an unparseable "sometime next week" still ends up a clean answer.
1662
+ * The dates carried on the span place the calendar, and the span's own text
1663
+ * is read (`parseLooseDate`) when it carries none. Failing to read it is not
1664
+ * a failure: the calendar opens either way, and whatever the user picks
1665
+ * replaces the span with the SDK's canonical form. So an unparseable
1666
+ * "sometime next week" still ends up a clean answer.
1645
1667
  */
1646
1668
  startEditingIdentified(paramId: string): boolean;
1647
1669
  /** Close the calendar opened for an identified span, leaving its text untouched. */
@@ -1960,13 +1982,11 @@ interface LooseDateOptions {
1960
1982
  */
1961
1983
  declare function parseLooseDate(text: string | undefined | null, opts?: LooseDateOptions): string | null;
1962
1984
  /**
1963
- * The `YYYY-MM-DD` for an identified date param.
1985
+ * The date an identified span states, as `YYYY-MM-DD`.
1964
1986
  *
1965
- * Reads a normalized value off the param first, if one is ever there. The
1966
- * server sends only the user's literal text today, so in practice this always
1967
- * falls through to {@link parseLooseDate} — but normalizing server-side is the
1968
- * real fix for the ambiguous cases the parser refuses, and when it lands this
1969
- * is the one place that has to change.
1987
+ * A date carried on the param (`isoDate`) wins. Otherwise the span's own text
1988
+ * is parsed with {@link parseLooseDate}, which returns null for text it cannot
1989
+ * read, such as a relative phrase.
1970
1990
  */
1971
1991
  declare function resolveIdentifiedDate(param: {
1972
1992
  text: string;
@@ -2062,8 +2082,17 @@ interface DateSelection {
2062
2082
  selectedIso: string | null;
2063
2083
  /** Both ends of a re-edited range param, or null. */
2064
2084
  selectedRange: DateRange | null;
2065
- /** The first end of a range being picked right now, or null. */
2085
+ /**
2086
+ * The first end of a range being picked right now, or the known start of the
2087
+ * range whose end a single-date question asks. Null otherwise.
2088
+ */
2066
2089
  rangeStart: string | null;
2090
+ /**
2091
+ * The earliest day a single-date question takes, or null. Set while the
2092
+ * question asks the end of a range whose start is already known: days before
2093
+ * it are dimmed and, unlike a day gone by, cannot be picked.
2094
+ */
2095
+ floor?: string | null;
2067
2096
  }
2068
2097
  /**
2069
2098
  * The calendar's selection, read off core state.
@@ -2085,6 +2114,7 @@ declare function dateSelectionFor(state: {
2085
2114
  metadata?: Record<string, unknown>;
2086
2115
  } | null;
2087
2116
  dateRangeStart: string | null;
2117
+ dateFloor?: string | null;
2088
2118
  }): DateSelection;
2089
2119
  /**
2090
2120
  * The span the calendar should paint right now.
@@ -2098,6 +2128,8 @@ declare function visibleDateRange(args: {
2098
2128
  pendingStart: string | null;
2099
2129
  highlightedIso: string | null;
2100
2130
  selected: DateRange | null;
2131
+ /** The earliest day the question takes: a highlight before it previews nothing. */
2132
+ floor?: string | null;
2101
2133
  }): DateRange | null;
2102
2134
  /**
2103
2135
  * How one cell renders against the current selection: filled at either end of
@@ -2115,6 +2147,20 @@ declare function dateCellMarks(iso: string | null, args: {
2115
2147
  selected: boolean;
2116
2148
  inRange: boolean;
2117
2149
  };
2150
+ /**
2151
+ * Whether a day is dimmed: one already gone by, or one before the earliest day
2152
+ * the question takes. A day gone by stays pickable. A day before the floor does
2153
+ * not: the core takes no pick of it.
2154
+ */
2155
+ declare function isDimmedDay(iso: string | null, today: string, floor?: string | null): boolean;
2156
+ /**
2157
+ * The earliest day a calendar takes, or null, from the fields a dropdown is
2158
+ * handed. A single-date calendar is given a range start only while it asks that
2159
+ * range's end, so there the start is its floor. Every dropdown passes the
2160
+ * selection on as separate fields and builds it again beside its calendar,
2161
+ * which is why this is derived from those fields.
2162
+ */
2163
+ declare function dateFloorFor(formatType: FormatType | undefined, rangeStart: string | null | undefined): string | null;
2118
2164
 
2119
2165
  /**
2120
2166
  * Entrance choreography for the dropdown's option rows.
@@ -3087,4 +3133,4 @@ declare const SMART_SUGGESTION_SPARKLE_SVG: string;
3087
3133
  /** True when some pill is a question the shopper can decline. */
3088
3134
  declare function hasSkippablePill(suggestions: Suggestion[]): boolean;
3089
3135
 
3090
- 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 CurrencyOptions, type CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, type DateMonthView, type DateRange, type DateSelection, EDITOR_GROW_MS, type ExpressedFilter, type FilterOp, type FormatType, type IdentifiedParam, type IdentifiedParamState, type InputItem, LOCATION_META_KEY, LOCATION_MIN_QUERY, type LocationPlace, type LocationStatus, type LocationView, type LooseDateOptions, MULTI_SELECT_TOGGLE_MIN_PX, MULTI_SELECT_TOGGLE_SLOP_PX, 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, OPTION_IMAGE_WIDTH, 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_IMAGE_WIDTH, PRODUCT_PATH_PREFIX, PRODUCT_ROW_PX_PER_LINE, type PhraseMatch, type Product, type ProductImageFallback, type ProductRowMetrics, type ProductRowWheel, type ProductsConfig, type ProductsLayout, RANGE_SEPARATOR, type RecentlySuggested, type RenderMode, SCHEMA_VERSION, 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, SMART_SUGGESTION_SPARKLE_SVG, type ScrollArrowArgs, type ScrollArrowController, type Segment, type SelectOptionOptions, type SkippedParamState, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type SuggestionType, TIME_META_KEY, TIME_STEP_MINUTES, TIME_WHEEL_COLUMNS, TIME_WHEEL_ROW_HEIGHT, type TaskKind, type TextPart, type TimeParts, type TimePeriod, type TimeView, type TimeWheelColumn, type TimeWheelRow, type UIStrings, VIEWPORT_FIT_ATTR, VIEWPORT_FIT_HEIGHT_VAR, type ViewportFitArgs, type ViewportFitController, WEEKDAY_LABELS, addMonths, attachProductRowWheel, attachScrollArrow, attachViewportFit, buildAttributionUrl, buildDateOptions, buildLocationOption, buildQuery, buildSubmitResult, buildTimeOption, cellDay, cellIso, chipIdFromTap, computeOptionsGridLayout, containScroll, createStore, cursorIsAtEnd, dateCellMarks, dateSelectionFor, extractPlainText, formatAbsoluteDate, formatDate, formatDateRange, formatOptionCount, formatPlace, formatTime, getCursorOffset, getFooterHint, hasSkippablePill, highlightParts, identifiedParamLabel, isCalendarFormat, isMultiSelectToggleTap, isOptionsGridMobileViewport, isPickerFormat, isSmartSuggestion, isTraditionalAutocompleteSuggestion, isoDate, isoTime, keepCaretOnChip, labelTraditionalAutocomplete, locationEndpointFor, matchTypedPhrase, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, optionCountLabel, optionEnterDelayMs, optionHasImage, optionImageSources, optionImageSrc, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, optionsShowLeadingVisuals, parseDate, parseLooseDate, parseLooseDateRange, parseTime, plainTextLength, planOptionsGrid, previousGraphemeBoundary, productFromMatchedItem, productImageSources, productImageSrc, productInitial, productPhotoFill, productRowWheelTarget, productsFromCustomFields, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sameOptionRows, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, shopifyImageSrc, timeWheelIndex, timeWheelIndexFromScroll, timeWheelRows, toWireIdentifiedParams, typedFragment, uiStringsFor, visibleDateRange, watchEditorHeight, withSkippedParams, withTimeWheelIndex, withoutTraditionalAutocomplete };
3136
+ 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 CurrencyOptions, type CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, type DateMonthView, type DateRange, type DateSelection, EDITOR_GROW_MS, type ExpressedFilter, type FilterOp, type FormatType, type IdentifiedParam, type IdentifiedParamState, type InputItem, LOCATION_META_KEY, LOCATION_MIN_QUERY, type LocationPlace, type LocationStatus, type LocationView, type LooseDateOptions, MULTI_SELECT_TOGGLE_MIN_PX, MULTI_SELECT_TOGGLE_SLOP_PX, 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, OPTION_IMAGE_WIDTH, 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_IMAGE_WIDTH, PRODUCT_PATH_PREFIX, PRODUCT_ROW_PX_PER_LINE, type PhraseMatch, type Product, type ProductImageFallback, type ProductRowMetrics, type ProductRowWheel, type ProductsConfig, type ProductsLayout, RANGE_SEPARATOR, type RecentlySuggested, type RenderMode, SCHEMA_VERSION, 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, SMART_SUGGESTION_SPARKLE_SVG, type ScrollArrowArgs, type ScrollArrowController, type Segment, type SelectOptionOptions, type SkippedParamState, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type SuggestionType, TIME_META_KEY, TIME_STEP_MINUTES, TIME_WHEEL_COLUMNS, TIME_WHEEL_ROW_HEIGHT, type TaskKind, type TextPart, type TimeParts, type TimePeriod, type TimeView, type TimeWheelColumn, type TimeWheelRow, type UIStrings, VIEWPORT_FIT_ATTR, VIEWPORT_FIT_HEIGHT_VAR, type ViewportFitArgs, type ViewportFitController, WEEKDAY_LABELS, addMonths, attachProductRowWheel, attachScrollArrow, attachViewportFit, buildAttributionUrl, buildDateOptions, buildLocationOption, buildQuery, buildSubmitResult, buildTimeOption, cellDay, cellIso, chipIdFromTap, computeOptionsGridLayout, containScroll, createStore, cursorIsAtEnd, dateCellMarks, dateFloorFor, dateSelectionFor, extractPlainText, formatAbsoluteDate, formatDate, formatDateRange, formatOptionCount, formatPlace, formatTime, getCursorOffset, getFooterHint, hasSkippablePill, highlightParts, identifiedParamLabel, isCalendarFormat, isDimmedDay, isMultiSelectToggleTap, isOptionsGridMobileViewport, isPickerFormat, isSmartSuggestion, isTraditionalAutocompleteSuggestion, isoDate, isoTime, keepCaretOnChip, labelTraditionalAutocomplete, locationEndpointFor, matchTypedPhrase, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, optionCountLabel, optionEnterDelayMs, optionHasImage, optionImageSources, optionImageSrc, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, optionsShowLeadingVisuals, parseDate, parseLooseDate, parseLooseDateRange, parseTime, plainTextLength, planOptionsGrid, previousGraphemeBoundary, productFromMatchedItem, productImageSources, productImageSrc, productInitial, productPhotoFill, productRowWheelTarget, productsFromCustomFields, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sameOptionRows, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, shopifyImageSrc, timeWheelIndex, timeWheelIndexFromScroll, timeWheelRows, toWireIdentifiedParams, typedFragment, uiStringsFor, visibleDateRange, watchEditorHeight, withSkippedParams, withTimeWheelIndex, withoutTraditionalAutocomplete };
package/dist/index.d.ts CHANGED
@@ -125,6 +125,14 @@ interface InputItem {
125
125
  * type names a date or date range opens a calendar when tapped.
126
126
  */
127
127
  type?: SuggestionType;
128
+ /**
129
+ * The date an identified date span states, or the start of a date range, as
130
+ * `YYYY-MM-DD` in the user's time zone. A relative phrase such as "this
131
+ * Saturday" carries one. Absent when the span states no date.
132
+ */
133
+ iso_date?: string;
134
+ /** The last day of an identified date range, `YYYY-MM-DD`. Absent while the range has no end. */
135
+ iso_date_end?: string;
128
136
  }
129
137
  /** Wire shape for an LLM-identified param echoed back to the server. */
130
138
  interface IdentifiedParam {
@@ -174,6 +182,8 @@ interface AutocompleteRequest {
174
182
  currency_rate?: number;
175
183
  country?: string;
176
184
  client_version: string;
185
+ /** The browser's IANA time zone ("Asia/Seoul"). Dates the user types are understood in this zone. */
186
+ timezone?: string;
177
187
  session_id: string;
178
188
  source?: "full-sdk" | "headless-sdk";
179
189
  /** The wire format this SDK speaks ({@link SCHEMA_VERSION}). */
@@ -392,6 +402,10 @@ interface IdentifiedParamState {
392
402
  text: string;
393
403
  /** The span's value type, from its `input` item. */
394
404
  type?: SuggestionType;
405
+ /** The date the span states, or a range's start: `YYYY-MM-DD`. */
406
+ isoDate?: string;
407
+ /** The last day of a range the span states: `YYYY-MM-DD`. */
408
+ isoDateEnd?: string;
395
409
  }
396
410
  type Segment = {
397
411
  type: "text";
@@ -1151,6 +1165,13 @@ interface CoreDerivedState {
1151
1165
  * first. The calendars paint the span between it and the highlighted cell.
1152
1166
  */
1153
1167
  dateRangeStart: string | null;
1168
+ /**
1169
+ * The earliest day the active date question takes, as `YYYY-MM-DD`, or null.
1170
+ * Set while a single-date question asks the end of a date range whose start
1171
+ * an identified span already carries ("from this Saturday"): the calendars
1172
+ * mark that start, dim the days before it, and no earlier day can be picked.
1173
+ */
1174
+ dateFloor: string | null;
1154
1175
  /**
1155
1176
  * What the time wheel shows. Null unless `activeFormatType` is `"time"`.
1156
1177
  * `touched` is false while it still shows its suggested starting time.
@@ -1638,10 +1659,11 @@ declare class AIAutocomplete {
1638
1659
  * Returns false for anything else — an identified span whose `type` the
1639
1660
  * server didn't name as a date or date range stays inert.
1640
1661
  *
1641
- * The span's own text is read for a starting month (`parseLooseDate`), but
1642
- * failing to read it is not a failure: the calendar opens either way, and
1643
- * whatever the user picks replaces the span with the SDK's canonical form. So
1644
- * an unparseable "sometime next week" still ends up a clean answer.
1662
+ * The dates carried on the span place the calendar, and the span's own text
1663
+ * is read (`parseLooseDate`) when it carries none. Failing to read it is not
1664
+ * a failure: the calendar opens either way, and whatever the user picks
1665
+ * replaces the span with the SDK's canonical form. So an unparseable
1666
+ * "sometime next week" still ends up a clean answer.
1645
1667
  */
1646
1668
  startEditingIdentified(paramId: string): boolean;
1647
1669
  /** Close the calendar opened for an identified span, leaving its text untouched. */
@@ -1960,13 +1982,11 @@ interface LooseDateOptions {
1960
1982
  */
1961
1983
  declare function parseLooseDate(text: string | undefined | null, opts?: LooseDateOptions): string | null;
1962
1984
  /**
1963
- * The `YYYY-MM-DD` for an identified date param.
1985
+ * The date an identified span states, as `YYYY-MM-DD`.
1964
1986
  *
1965
- * Reads a normalized value off the param first, if one is ever there. The
1966
- * server sends only the user's literal text today, so in practice this always
1967
- * falls through to {@link parseLooseDate} — but normalizing server-side is the
1968
- * real fix for the ambiguous cases the parser refuses, and when it lands this
1969
- * is the one place that has to change.
1987
+ * A date carried on the param (`isoDate`) wins. Otherwise the span's own text
1988
+ * is parsed with {@link parseLooseDate}, which returns null for text it cannot
1989
+ * read, such as a relative phrase.
1970
1990
  */
1971
1991
  declare function resolveIdentifiedDate(param: {
1972
1992
  text: string;
@@ -2062,8 +2082,17 @@ interface DateSelection {
2062
2082
  selectedIso: string | null;
2063
2083
  /** Both ends of a re-edited range param, or null. */
2064
2084
  selectedRange: DateRange | null;
2065
- /** The first end of a range being picked right now, or null. */
2085
+ /**
2086
+ * The first end of a range being picked right now, or the known start of the
2087
+ * range whose end a single-date question asks. Null otherwise.
2088
+ */
2066
2089
  rangeStart: string | null;
2090
+ /**
2091
+ * The earliest day a single-date question takes, or null. Set while the
2092
+ * question asks the end of a range whose start is already known: days before
2093
+ * it are dimmed and, unlike a day gone by, cannot be picked.
2094
+ */
2095
+ floor?: string | null;
2067
2096
  }
2068
2097
  /**
2069
2098
  * The calendar's selection, read off core state.
@@ -2085,6 +2114,7 @@ declare function dateSelectionFor(state: {
2085
2114
  metadata?: Record<string, unknown>;
2086
2115
  } | null;
2087
2116
  dateRangeStart: string | null;
2117
+ dateFloor?: string | null;
2088
2118
  }): DateSelection;
2089
2119
  /**
2090
2120
  * The span the calendar should paint right now.
@@ -2098,6 +2128,8 @@ declare function visibleDateRange(args: {
2098
2128
  pendingStart: string | null;
2099
2129
  highlightedIso: string | null;
2100
2130
  selected: DateRange | null;
2131
+ /** The earliest day the question takes: a highlight before it previews nothing. */
2132
+ floor?: string | null;
2101
2133
  }): DateRange | null;
2102
2134
  /**
2103
2135
  * How one cell renders against the current selection: filled at either end of
@@ -2115,6 +2147,20 @@ declare function dateCellMarks(iso: string | null, args: {
2115
2147
  selected: boolean;
2116
2148
  inRange: boolean;
2117
2149
  };
2150
+ /**
2151
+ * Whether a day is dimmed: one already gone by, or one before the earliest day
2152
+ * the question takes. A day gone by stays pickable. A day before the floor does
2153
+ * not: the core takes no pick of it.
2154
+ */
2155
+ declare function isDimmedDay(iso: string | null, today: string, floor?: string | null): boolean;
2156
+ /**
2157
+ * The earliest day a calendar takes, or null, from the fields a dropdown is
2158
+ * handed. A single-date calendar is given a range start only while it asks that
2159
+ * range's end, so there the start is its floor. Every dropdown passes the
2160
+ * selection on as separate fields and builds it again beside its calendar,
2161
+ * which is why this is derived from those fields.
2162
+ */
2163
+ declare function dateFloorFor(formatType: FormatType | undefined, rangeStart: string | null | undefined): string | null;
2118
2164
 
2119
2165
  /**
2120
2166
  * Entrance choreography for the dropdown's option rows.
@@ -3087,4 +3133,4 @@ declare const SMART_SUGGESTION_SPARKLE_SVG: string;
3087
3133
  /** True when some pill is a question the shopper can decline. */
3088
3134
  declare function hasSkippablePill(suggestions: Suggestion[]): boolean;
3089
3135
 
3090
- 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 CurrencyOptions, type CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, type DateMonthView, type DateRange, type DateSelection, EDITOR_GROW_MS, type ExpressedFilter, type FilterOp, type FormatType, type IdentifiedParam, type IdentifiedParamState, type InputItem, LOCATION_META_KEY, LOCATION_MIN_QUERY, type LocationPlace, type LocationStatus, type LocationView, type LooseDateOptions, MULTI_SELECT_TOGGLE_MIN_PX, MULTI_SELECT_TOGGLE_SLOP_PX, 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, OPTION_IMAGE_WIDTH, 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_IMAGE_WIDTH, PRODUCT_PATH_PREFIX, PRODUCT_ROW_PX_PER_LINE, type PhraseMatch, type Product, type ProductImageFallback, type ProductRowMetrics, type ProductRowWheel, type ProductsConfig, type ProductsLayout, RANGE_SEPARATOR, type RecentlySuggested, type RenderMode, SCHEMA_VERSION, 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, SMART_SUGGESTION_SPARKLE_SVG, type ScrollArrowArgs, type ScrollArrowController, type Segment, type SelectOptionOptions, type SkippedParamState, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type SuggestionType, TIME_META_KEY, TIME_STEP_MINUTES, TIME_WHEEL_COLUMNS, TIME_WHEEL_ROW_HEIGHT, type TaskKind, type TextPart, type TimeParts, type TimePeriod, type TimeView, type TimeWheelColumn, type TimeWheelRow, type UIStrings, VIEWPORT_FIT_ATTR, VIEWPORT_FIT_HEIGHT_VAR, type ViewportFitArgs, type ViewportFitController, WEEKDAY_LABELS, addMonths, attachProductRowWheel, attachScrollArrow, attachViewportFit, buildAttributionUrl, buildDateOptions, buildLocationOption, buildQuery, buildSubmitResult, buildTimeOption, cellDay, cellIso, chipIdFromTap, computeOptionsGridLayout, containScroll, createStore, cursorIsAtEnd, dateCellMarks, dateSelectionFor, extractPlainText, formatAbsoluteDate, formatDate, formatDateRange, formatOptionCount, formatPlace, formatTime, getCursorOffset, getFooterHint, hasSkippablePill, highlightParts, identifiedParamLabel, isCalendarFormat, isMultiSelectToggleTap, isOptionsGridMobileViewport, isPickerFormat, isSmartSuggestion, isTraditionalAutocompleteSuggestion, isoDate, isoTime, keepCaretOnChip, labelTraditionalAutocomplete, locationEndpointFor, matchTypedPhrase, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, optionCountLabel, optionEnterDelayMs, optionHasImage, optionImageSources, optionImageSrc, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, optionsShowLeadingVisuals, parseDate, parseLooseDate, parseLooseDateRange, parseTime, plainTextLength, planOptionsGrid, previousGraphemeBoundary, productFromMatchedItem, productImageSources, productImageSrc, productInitial, productPhotoFill, productRowWheelTarget, productsFromCustomFields, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sameOptionRows, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, shopifyImageSrc, timeWheelIndex, timeWheelIndexFromScroll, timeWheelRows, toWireIdentifiedParams, typedFragment, uiStringsFor, visibleDateRange, watchEditorHeight, withSkippedParams, withTimeWheelIndex, withoutTraditionalAutocomplete };
3136
+ 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 CurrencyOptions, type CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, type DateMonthView, type DateRange, type DateSelection, EDITOR_GROW_MS, type ExpressedFilter, type FilterOp, type FormatType, type IdentifiedParam, type IdentifiedParamState, type InputItem, LOCATION_META_KEY, LOCATION_MIN_QUERY, type LocationPlace, type LocationStatus, type LocationView, type LooseDateOptions, MULTI_SELECT_TOGGLE_MIN_PX, MULTI_SELECT_TOGGLE_SLOP_PX, 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, OPTION_IMAGE_WIDTH, 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_IMAGE_WIDTH, PRODUCT_PATH_PREFIX, PRODUCT_ROW_PX_PER_LINE, type PhraseMatch, type Product, type ProductImageFallback, type ProductRowMetrics, type ProductRowWheel, type ProductsConfig, type ProductsLayout, RANGE_SEPARATOR, type RecentlySuggested, type RenderMode, SCHEMA_VERSION, 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, SMART_SUGGESTION_SPARKLE_SVG, type ScrollArrowArgs, type ScrollArrowController, type Segment, type SelectOptionOptions, type SkippedParamState, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type SuggestionType, TIME_META_KEY, TIME_STEP_MINUTES, TIME_WHEEL_COLUMNS, TIME_WHEEL_ROW_HEIGHT, type TaskKind, type TextPart, type TimeParts, type TimePeriod, type TimeView, type TimeWheelColumn, type TimeWheelRow, type UIStrings, VIEWPORT_FIT_ATTR, VIEWPORT_FIT_HEIGHT_VAR, type ViewportFitArgs, type ViewportFitController, WEEKDAY_LABELS, addMonths, attachProductRowWheel, attachScrollArrow, attachViewportFit, buildAttributionUrl, buildDateOptions, buildLocationOption, buildQuery, buildSubmitResult, buildTimeOption, cellDay, cellIso, chipIdFromTap, computeOptionsGridLayout, containScroll, createStore, cursorIsAtEnd, dateCellMarks, dateFloorFor, dateSelectionFor, extractPlainText, formatAbsoluteDate, formatDate, formatDateRange, formatOptionCount, formatPlace, formatTime, getCursorOffset, getFooterHint, hasSkippablePill, highlightParts, identifiedParamLabel, isCalendarFormat, isDimmedDay, isMultiSelectToggleTap, isOptionsGridMobileViewport, isPickerFormat, isSmartSuggestion, isTraditionalAutocompleteSuggestion, isoDate, isoTime, keepCaretOnChip, labelTraditionalAutocomplete, locationEndpointFor, matchTypedPhrase, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, optionCountLabel, optionEnterDelayMs, optionHasImage, optionImageSources, optionImageSrc, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, optionsShowLeadingVisuals, parseDate, parseLooseDate, parseLooseDateRange, parseTime, plainTextLength, planOptionsGrid, previousGraphemeBoundary, productFromMatchedItem, productImageSources, productImageSrc, productInitial, productPhotoFill, productRowWheelTarget, productsFromCustomFields, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sameOptionRows, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, shopifyImageSrc, timeWheelIndex, timeWheelIndexFromScroll, timeWheelRows, toWireIdentifiedParams, typedFragment, uiStringsFor, visibleDateRange, watchEditorHeight, withSkippedParams, withTimeWheelIndex, withoutTraditionalAutocomplete };