@magicx-eng/ai-autocomplete-vanilla 0.24.0 → 0.25.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/dist/index.d.mts CHANGED
@@ -1550,6 +1550,64 @@ declare function cursorIsAtEnd(root: HTMLElement): boolean;
1550
1550
  */
1551
1551
  declare function previousGraphemeBoundary(text: string, offset: number): number;
1552
1552
 
1553
+ /**
1554
+ * A mouse wheel over the product strip scrolls it sideways.
1555
+ *
1556
+ * The strip is one row scrolling on the x axis with its scrollbar hidden
1557
+ * (styles.css), so a mouse — whose wheel is vertical — had no way to reach the
1558
+ * cards past the panel's edge. Trackpads and touch already scroll the row
1559
+ * natively; this hands mouse users the same reach by turning a vertical wheel
1560
+ * over the row into horizontal travel and keeping the page still.
1561
+ *
1562
+ * Shared by all three packages: vanilla binds it in `renderProductStrip`, and
1563
+ * the React and Angular strips bind it on their own row element.
1564
+ */
1565
+ /** The scroll metrics a wheel decision reads; a subset of `HTMLElement`. */
1566
+ interface ProductRowMetrics {
1567
+ scrollLeft: number;
1568
+ scrollWidth: number;
1569
+ clientWidth: number;
1570
+ }
1571
+ /** The wheel fields a decision reads; a subset of `WheelEvent`. */
1572
+ interface ProductRowWheel {
1573
+ deltaX: number;
1574
+ deltaY: number;
1575
+ deltaMode: number;
1576
+ ctrlKey: boolean;
1577
+ }
1578
+ /**
1579
+ * Pixels per line for a `deltaMode` of `DOM_DELTA_LINE`. Firefox reports about
1580
+ * three lines a notch, so one notch lands near Chrome's 100px.
1581
+ */
1582
+ declare const PRODUCT_ROW_PX_PER_LINE = 32;
1583
+ /**
1584
+ * The row's next `scrollLeft` for a wheel turn over it, or `null` to leave the
1585
+ * event to the browser, which already does the right thing when:
1586
+ *
1587
+ * - the gesture is sideways, or a diagonal whose horizontal part is at least
1588
+ * as large as its vertical one — a trackpad's horizontal delta scrolls the
1589
+ * row natively, and shift+wheel arrives as horizontal delta the same way. A
1590
+ * diagonal that is mostly vertical is still a wheel turn;
1591
+ * - ctrl is held — that is a pinch zoom, not a scroll;
1592
+ * - the row has nothing to scroll;
1593
+ * - the turn is past either end. A row parked on its last card must not pin
1594
+ * the page under a resting pointer, so the turn falls through and the page
1595
+ * scrolls as it would anywhere else. `overscroll-behavior-x: contain` on the
1596
+ * row still stops a native horizontal fling from chaining out mid-row.
1597
+ *
1598
+ * Pure over the row's metrics so it can be tested without layout.
1599
+ */
1600
+ declare function productRowWheelTarget(row: ProductRowMetrics, e: ProductRowWheel): number | null;
1601
+ /**
1602
+ * Bind the wheel-to-sideways behaviour on a strip's row. Returns the detach.
1603
+ *
1604
+ * Registered non-passive on purpose: a wheel listener that cannot call
1605
+ * `preventDefault` leaves the page scrolling under the row. React's `onWheel`
1606
+ * prop is passive by default, which is why the React strip binds through a
1607
+ * ref rather than the prop.
1608
+ */
1609
+ declare function attachProductRowWheel(row: HTMLElement): () => void;
1610
+
1553
1611
  /**
1554
1612
  * Scroll-to-caret for the editor's own scroll container.
1555
1613
  *
@@ -1917,4 +1975,4 @@ interface SubmitResultExtras {
1917
1975
  */
1918
1976
  declare function buildSubmitResult(text: string, completedParams: CompletedParamState[], skippedParams?: SkippedParamState[], extras?: SubmitResultExtras): AutocompleteResult;
1919
1977
 
1920
- 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, type Product, type ProductsConfig, 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, 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, productsFromCustomFields, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, toWireIdentifiedParams, visibleDateRange, withSkippedParams };
1978
+ 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, 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 };
package/dist/index.d.ts CHANGED
@@ -1550,6 +1550,64 @@ declare function cursorIsAtEnd(root: HTMLElement): boolean;
1550
1550
  */
1551
1551
  declare function previousGraphemeBoundary(text: string, offset: number): number;
1552
1552
 
1553
+ /**
1554
+ * A mouse wheel over the product strip scrolls it sideways.
1555
+ *
1556
+ * The strip is one row scrolling on the x axis with its scrollbar hidden
1557
+ * (styles.css), so a mouse — whose wheel is vertical — had no way to reach the
1558
+ * cards past the panel's edge. Trackpads and touch already scroll the row
1559
+ * natively; this hands mouse users the same reach by turning a vertical wheel
1560
+ * over the row into horizontal travel and keeping the page still.
1561
+ *
1562
+ * Shared by all three packages: vanilla binds it in `renderProductStrip`, and
1563
+ * the React and Angular strips bind it on their own row element.
1564
+ */
1565
+ /** The scroll metrics a wheel decision reads; a subset of `HTMLElement`. */
1566
+ interface ProductRowMetrics {
1567
+ scrollLeft: number;
1568
+ scrollWidth: number;
1569
+ clientWidth: number;
1570
+ }
1571
+ /** The wheel fields a decision reads; a subset of `WheelEvent`. */
1572
+ interface ProductRowWheel {
1573
+ deltaX: number;
1574
+ deltaY: number;
1575
+ deltaMode: number;
1576
+ ctrlKey: boolean;
1577
+ }
1578
+ /**
1579
+ * Pixels per line for a `deltaMode` of `DOM_DELTA_LINE`. Firefox reports about
1580
+ * three lines a notch, so one notch lands near Chrome's 100px.
1581
+ */
1582
+ declare const PRODUCT_ROW_PX_PER_LINE = 32;
1583
+ /**
1584
+ * The row's next `scrollLeft` for a wheel turn over it, or `null` to leave the
1585
+ * event to the browser, which already does the right thing when:
1586
+ *
1587
+ * - the gesture is sideways, or a diagonal whose horizontal part is at least
1588
+ * as large as its vertical one — a trackpad's horizontal delta scrolls the
1589
+ * row natively, and shift+wheel arrives as horizontal delta the same way. A
1590
+ * diagonal that is mostly vertical is still a wheel turn;
1591
+ * - ctrl is held — that is a pinch zoom, not a scroll;
1592
+ * - the row has nothing to scroll;
1593
+ * - the turn is past either end. A row parked on its last card must not pin
1594
+ * the page under a resting pointer, so the turn falls through and the page
1595
+ * scrolls as it would anywhere else. `overscroll-behavior-x: contain` on the
1596
+ * row still stops a native horizontal fling from chaining out mid-row.
1597
+ *
1598
+ * Pure over the row's metrics so it can be tested without layout.
1599
+ */
1600
+ declare function productRowWheelTarget(row: ProductRowMetrics, e: ProductRowWheel): number | null;
1601
+ /**
1602
+ * Bind the wheel-to-sideways behaviour on a strip's row. Returns the detach.
1603
+ *
1604
+ * Registered non-passive on purpose: a wheel listener that cannot call
1605
+ * `preventDefault` leaves the page scrolling under the row. React's `onWheel`
1606
+ * prop is passive by default, which is why the React strip binds through a
1607
+ * ref rather than the prop.
1608
+ */
1609
+ declare function attachProductRowWheel(row: HTMLElement): () => void;
1610
+
1553
1611
  /**
1554
1612
  * Scroll-to-caret for the editor's own scroll container.
1555
1613
  *
@@ -1917,4 +1975,4 @@ interface SubmitResultExtras {
1917
1975
  */
1918
1976
  declare function buildSubmitResult(text: string, completedParams: CompletedParamState[], skippedParams?: SkippedParamState[], extras?: SubmitResultExtras): AutocompleteResult;
1919
1977
 
1920
- 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, type Product, type ProductsConfig, 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, 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, productsFromCustomFields, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, toWireIdentifiedParams, visibleDateRange, withSkippedParams };
1978
+ 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, 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 };