@magicx-eng/ai-autocomplete-vanilla 0.22.0 → 0.23.1

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
@@ -531,7 +531,7 @@ unsub();
531
531
 
532
532
  > **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.
533
533
 
534
- > **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, which keeps an `icon` that has no `icon_svg` as a legacy text prefix. 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.
534
+ > **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.
535
535
 
536
536
  ### State shape (`CoreState`)
537
537
 
@@ -734,6 +734,10 @@ Constructor callbacks (`onSubmit`, `onChange`, etc.) are registered once at cons
734
734
 
735
735
  Styles are auto-injected at runtime (Tier 1 and Tier 2). No CSS import needed. The component ships built-in light and dark defaults.
736
736
 
737
+ Every class name the core emits is namespaced — `magicx-aia-*` (plus the bare `magicx-aia` root) and `aia-*` for the layout primitives — so nothing it renders can match a `.container`, `.pill` or `.dropdown` rule in your own stylesheet, and none of its rules can reach your elements.
738
+
739
+ **Page CSS stops at the widget's edge.** Everything inside the input wrapper (`[data-aia-input-wrapper]`) and the dropdown (`[data-aia-dropdown]`) is reset to browser defaults before the SDK's own styles apply, so element and universal rules in your stylesheet — `button { … }`, `a { … }`, `* { … }`, a CSS reset, a framework's preflight — never reach it, and inherited typography adjustments from the page (line-height, letter-spacing, text-transform, text-align, …) are pinned at those two roots. Font family, size, weight and text colour still inherit from your page; a submit button you provide is left to your own stylesheet; and nothing the SDK ships styles elements outside its own subtree. The reset sits at specificity (0,0,5), below any rule that names a class, attribute or id — your overrides on the `data-aia-*` hooks work exactly as before, and so does a page rule like `.sidebar button { … }`, which names a class: scope rules like that to your own markup. For complete isolation, including rules like that, mount the widget in a shadow root — see [Shadow DOM](#shadow-dom).
740
+
737
741
  ### Shadow DOM
738
742
 
739
743
  Mount the container inside a shadow root and the widget works there — the stylesheet is injected into that root rather than `document.head`, and the caret is read from the root that owns the editor:
@@ -755,7 +759,7 @@ This is the way to embed the widget in a page whose CSS you don't control. In th
755
759
 
756
760
  ### CSS Variables
757
761
 
758
- Override these on the container element. All built-in defaults use `:where()` (zero specificity) your overrides always win without `!important`.
762
+ Override these on the container element. The variables are declared with `:where()` (zero specificity), so a value you set on the container always wins without `!important`.
759
763
 
760
764
  | Variable | Default (light) | Default (dark) | Description |
761
765
  |---|---|---|---|
@@ -837,6 +841,7 @@ For styling beyond the CSS variables, target these stable `data-aia-*` attribute
837
841
 
838
842
  | Attribute | Element |
839
843
  |---|---|
844
+ | `[data-aia-input-wrapper]` | Wrapper around the editor area and the submit button — one of the two roots the SDK isolates from page CSS (the dropdown is the other) |
840
845
  | `[data-aia-editor]` | Editor area wrapping the contentEditable + inline pill list |
841
846
  | `[data-aia-input]` | The contentEditable `<div>` that owns typed text and bold completed params. Replaces the previous `[data-aia-textarea]` selector. |
842
847
  | `[data-aia-pill-list-container]` | Inline sibling of the editor that holds unfilled-suggestion pills |
@@ -858,7 +863,7 @@ For styling beyond the CSS variables, target these stable `data-aia-*` attribute
858
863
  | `[data-aia-product]` | Each product card |
859
864
  | `[data-aia-product-placeholder]` | Media tile of a card whose product has no image |
860
865
 
861
- Completed params render as inline `<strong>` elements inside the editor. Override their weight with `[data-aia-input] strong { font-weight: 700; }` (the built-in style uses `:where()` so any consumer selector wins without `!important`).
866
+ Completed params render as inline `<strong>` elements inside the editor. Override their weight with `[data-aia-input] strong { font-weight: 700; }` a selector that names the editor wins without `!important`, while a bare `strong { … }` page rule is kept out by the isolation reset.
862
867
 
863
868
  The vanilla core also exposes stable BEM class names (`magicx-aia-*`); both can be used.
864
869
 
package/dist/index.d.mts CHANGED
@@ -8,10 +8,9 @@ interface CompletedParam {
8
8
  interface SuggestionOption {
9
9
  text: string;
10
10
  /**
11
- * Icon for the option. When `icon_svg` is also set this is the icon's name
12
- * (an identifier such as `"apple"`, exposed on the row as `data-aia-icon`)
13
- * and the SVG is what renders. Without `icon_svg` it is legacy display text
14
- * (an emoji, say) drawn as a prefix to `text`.
11
+ * The icon's name an identifier such as `"apple"`, exposed on the row as
12
+ * `data-aia-icon` when its `icon_svg` draws. Never rendered as text: a row
13
+ * without a drawable `icon_svg` shows `text` alone.
15
14
  */
16
15
  icon?: string;
17
16
  /**
@@ -1587,9 +1586,11 @@ declare function scrollCaretIntoView(root: HTMLElement): void;
1587
1586
  */
1588
1587
  declare function sanitizeOptionIconSvg(markup: string): string | null;
1589
1588
  /**
1590
- * The text an option row shows. With `icon_svg` the icon draws as its own
1591
- * element and `icon` is just its name; without it, a legacy `icon` (an emoji
1592
- * from an option override, say) is display text prefixed to the option.
1589
+ * The text an option row shows: its `text`, alone. `icon` is the icon's name
1590
+ * (`"apple"`), an identifier for `data-aia-icon` and consumer CSS, never
1591
+ * display text so it is not prefixed to the option, whether `icon_svg`
1592
+ * came with it, failed to draw, or was switched off. A row whose icon cannot
1593
+ * draw shows the text by itself rather than the icon's name.
1593
1594
  */
1594
1595
  declare function optionLabel(option: {
1595
1596
  text: string;
package/dist/index.d.ts CHANGED
@@ -8,10 +8,9 @@ interface CompletedParam {
8
8
  interface SuggestionOption {
9
9
  text: string;
10
10
  /**
11
- * Icon for the option. When `icon_svg` is also set this is the icon's name
12
- * (an identifier such as `"apple"`, exposed on the row as `data-aia-icon`)
13
- * and the SVG is what renders. Without `icon_svg` it is legacy display text
14
- * (an emoji, say) drawn as a prefix to `text`.
11
+ * The icon's name an identifier such as `"apple"`, exposed on the row as
12
+ * `data-aia-icon` when its `icon_svg` draws. Never rendered as text: a row
13
+ * without a drawable `icon_svg` shows `text` alone.
15
14
  */
16
15
  icon?: string;
17
16
  /**
@@ -1587,9 +1586,11 @@ declare function scrollCaretIntoView(root: HTMLElement): void;
1587
1586
  */
1588
1587
  declare function sanitizeOptionIconSvg(markup: string): string | null;
1589
1588
  /**
1590
- * The text an option row shows. With `icon_svg` the icon draws as its own
1591
- * element and `icon` is just its name; without it, a legacy `icon` (an emoji
1592
- * from an option override, say) is display text prefixed to the option.
1589
+ * The text an option row shows: its `text`, alone. `icon` is the icon's name
1590
+ * (`"apple"`), an identifier for `data-aia-icon` and consumer CSS, never
1591
+ * display text so it is not prefixed to the option, whether `icon_svg`
1592
+ * came with it, failed to draw, or was switched off. A row whose icon cannot
1593
+ * draw shows the text by itself rather than the icon's name.
1593
1594
  */
1594
1595
  declare function optionLabel(option: {
1595
1596
  text: string;