rich-input 1.2.2 → 1.4.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 +127 -98
- package/assets/rich-input-parts.svg +92 -61
- package/components/rich-input.js +614 -54
- package/index.js +7 -1
- package/package.json +5 -2
- package/utils/highlights.js +75 -0
- package/utils/query-parser.js +379 -52
package/README.md
CHANGED
|
@@ -5,18 +5,20 @@
|
|
|
5
5
|
[](LICENSE)
|
|
6
6
|
[](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements)
|
|
7
7
|
|
|
8
|
-
The `<rich-input>` component is a rich input field that acts like a standard `<input type="text">` so users can type ordinary text or search terms, but enhances it with contextual autocomplete and in-input highlighting for structured `keyword:value`
|
|
8
|
+
The `<rich-input>` component is a rich input field that acts like a standard `<input type="text">` so users can type ordinary text or search terms, but enhances it with contextual autocomplete and in-input highlighting for structured queries with `keyword:value` filters, prefix `operators` (e.g. `-`), boolean `combinators` (e.g. `AND`, `OR`), and grouping `delimiters` (e.g. `()`), such as `(label:"We Play House Recordings" OR year:2026) AND -style:"Acid House"`.
|
|
9
9
|
|
|
10
10
|
---
|
|
11
11
|
|
|
12
12
|
## Features
|
|
13
13
|
|
|
14
14
|
- **Standard Input Ergonomics**: Acts and feels like a regular `<input type="text">` with standard value access, selection ranges, and events.
|
|
15
|
-
- **
|
|
16
|
-
- **Keywords**: Typing at the start of a token (e.g. typing `a`) suggests configured keywords like `artist:` and
|
|
15
|
+
- **Contextual Autocomplete**:
|
|
16
|
+
- **Keywords**: Typing at the start of a token or after an operator/delimiter (e.g. typing `a` or `-s`) suggests configured keywords like `artist:` and `-style:`.
|
|
17
|
+
- **Combinators**: Typing a configured boolean combinator (e.g. `A` or `O` when `combinators="AND OR"` is set) suggests `AND` and `OR`.
|
|
17
18
|
- **Values**: Typing within a keyword value (e.g. `label:"K` or `label:K`) suggests matching options like `"Keinemusik"` and `"Kranky"`.
|
|
19
|
+
- **Configurable Operators, Combinators & Delimiters**: Configure prefix operators (`operators="- ~ +"`), boolean combinators (`combinators="AND OR NOT"`), and grouping delimiter pairs (`delimiters="() [] {}"`) per instance via HTML attributes / JS properties, or globally via static properties on `RichInput`.
|
|
18
20
|
- **Range-Based Positioning via OpaqueRange**: Positions autocomplete dropdown popovers anchored to the start of the active `OpaqueRange` (e.g. at the opening quotation mark of a value) using `range.getBoundingClientRect()`, rather than shifting with the cursor (with a hidden mirror-div fallback in unsupported browsers).
|
|
19
|
-
- **Native In-Input Highlighting via CSS Custom Highlight API**: Highlights keyword values inside the `<input>` control using standard CSS rules like `::highlight(label)
|
|
21
|
+
- **Native In-Input Highlighting via CSS Custom Highlight API**: Highlights keyword values, operators, combinators, delimiters, and invalid tokens inside the `<input>` control using standard CSS rules like `::highlight(label)`, `::highlight(rich-input-operator)`, `::highlight(rich-input-combinator)`, and `::highlight(rich-input-delimiter)` without brittle mirror-div overlays.
|
|
20
22
|
- **Declarative Configuration via `<datalist>`**: Configure keywords and options purely in HTML by nesting standard `<datalist>` elements with `<option>` tags inside `<rich-input>`.
|
|
21
23
|
- **Rich Option Markup**: Embed custom HTML markup (such as logos, images, icons, and avatars) directly inside `<option>` elements for rich, visual suggestion popovers.
|
|
22
24
|
- **Form Associated**: Implements `static formAssociated = true` and `ElementInternals` to participate seamlessly in `<form>` submission, `FormData`, and form reset lifecycles.
|
|
@@ -36,8 +38,11 @@ The visual below illustrates the internal Shadow DOM elements, exposed CSS Shado
|
|
|
36
38
|
|
|
37
39
|
- `<rich-input>`: The host custom element wrapping the control, datalists, and suggestions popover.
|
|
38
40
|
- `::part(control)`: The outer input container enclosing the icon, input, and clear button.
|
|
39
|
-
- `::part(icon)`: The
|
|
41
|
+
- `::part(icon)`: The leading icon element (defaults to a search magnifying glass, customizable via CSS `content` or `background`).
|
|
40
42
|
- `::highlight(<keyword>)`: Target pseudo-element for styling keyword values via the CSS Custom Highlight API (e.g. `::highlight(label)`, `::highlight(year)`).
|
|
43
|
+
- `::highlight(rich-input-operator)`: Target pseudo-element for styling keyword operators (e.g. `-` in `-style:"Acid House"`).
|
|
44
|
+
- `::highlight(rich-input-combinator)`: Target pseudo-element for styling query combinators (e.g. `OR` in `artist:"Aphex Twin" OR label:"Defected"`).
|
|
45
|
+
- `::highlight(rich-input-delimiter)`: Target pseudo-element for styling grouping delimiters (e.g. `(` and `)` in `(artist:"Aphex Twin" OR label:"Defected")`).
|
|
41
46
|
- `::highlight(rich-input-keyword)`: Target pseudo-element for styling keyword prefixes (e.g. `label:`, `year:`).
|
|
42
47
|
- `::highlight(rich-input-invalid)`: Target pseudo-element for marking unrecognized keywords or invalid keyword values (not in datalist) with a squiggly underline.
|
|
43
48
|
- `::part(clear-button)`: The clear button (visible when text is present).
|
|
@@ -45,9 +50,11 @@ The visual below illustrates the internal Shadow DOM elements, exposed CSS Shado
|
|
|
45
50
|
- `::part(suggestions-header)`: The header bar at the top of the suggestions popover.
|
|
46
51
|
- `::part(suggestions-list)`: The `<ul>` container holding autocomplete suggestion items.
|
|
47
52
|
- `::part(suggestion-item)`: Each suggestion `<li>` row.
|
|
48
|
-
- `::part(suggestion-item-active)`: The currently
|
|
53
|
+
- `::part(suggestion-item-active)`: The currently focused / hovered suggestion row.
|
|
54
|
+
- `::part(suggestion-item-selected)`: The suggestion row matching the value currently echoed in the input.
|
|
49
55
|
- `::part(suggestion-image)`: The circular logo, icon, or avatar image prepended to rich suggestions.
|
|
50
56
|
- `::part(suggestion-keyword)`: The keyword label text inside a keyword suggestion.
|
|
57
|
+
- `::part(suggestion-combinator)`: The combinator label text inside a combinator suggestion.
|
|
51
58
|
- `::part(suggestion-value)`: The value label text inside a value suggestion.
|
|
52
59
|
|
|
53
60
|
---
|
|
@@ -76,12 +83,18 @@ Or via CDN:
|
|
|
76
83
|
|
|
77
84
|
### 2. Basic Usage
|
|
78
85
|
|
|
79
|
-
Nest `<datalist>` elements inside `<rich-input>` to configure keywords and autocomplete suggestions
|
|
86
|
+
Nest `<datalist>` elements inside `<rich-input>` to configure keywords and autocomplete suggestions, and optionally configure `operators`, `combinators`, and `delimiters`:
|
|
80
87
|
|
|
81
88
|
```html
|
|
82
|
-
<rich-input
|
|
89
|
+
<rich-input
|
|
90
|
+
operators="-"
|
|
91
|
+
combinators="AND OR"
|
|
92
|
+
delimiters="()"
|
|
93
|
+
placeholder="Search music catalog..."
|
|
94
|
+
>
|
|
83
95
|
<datalist id="label" label="Record Label">
|
|
84
96
|
<option value="Defected"></option>
|
|
97
|
+
<option value="House"></option>
|
|
85
98
|
<option value="Keinemusik"></option>
|
|
86
99
|
<option value="Kranky"></option>
|
|
87
100
|
<option value="Madhouse Records"></option>
|
|
@@ -97,21 +110,25 @@ Nest `<datalist>` elements inside `<rich-input>` to configure keywords and autoc
|
|
|
97
110
|
<option value="2024"></option>
|
|
98
111
|
</datalist>
|
|
99
112
|
|
|
100
|
-
<datalist id="
|
|
101
|
-
<option value="
|
|
102
|
-
<option value="
|
|
113
|
+
<datalist id="style" label="Style">
|
|
114
|
+
<option value="Acid House"></option>
|
|
115
|
+
<option value="Deep House"></option>
|
|
116
|
+
<option value="Dub Techno"></option>
|
|
103
117
|
</datalist>
|
|
104
118
|
</rich-input>
|
|
105
119
|
```
|
|
106
120
|
|
|
107
121
|
---
|
|
108
122
|
|
|
109
|
-
## Datalist Configuration
|
|
123
|
+
## Datalist & Syntax Configuration
|
|
110
124
|
|
|
111
|
-
Configuration is defined by standard HTML `<datalist>` elements placed inside the `<rich-input>` element:
|
|
125
|
+
Configuration is defined by attributes on `<rich-input>` and standard HTML `<datalist>` elements placed inside the `<rich-input>` element:
|
|
112
126
|
|
|
113
127
|
| Element / Attribute | Type | Description |
|
|
114
128
|
|---|---|---|
|
|
129
|
+
| `<rich-input operators="...">` | `string` | Optional space-separated list of single-character prefix operators (e.g. `operators="- ~ +"`). Defaults to `"-"` (negative filter). Set `operators=""` to disable operators. |
|
|
130
|
+
| `<rich-input combinators="...">` | `string` | Optional space-separated list of boolean query combinators (e.g. `combinators="AND OR NOT"`). Defaults to `""` (empty array). |
|
|
131
|
+
| `<rich-input delimiters="...">` | `string` | Optional space-separated list of two-character opening/closing delimiter pairs (e.g. `delimiters="() [] {}"`). Defaults to `"()"` (parentheses). Set `delimiters=""` to disable delimiters. |
|
|
115
132
|
| `<datalist id="...">` | `string` | **Required.** The keyword identifier used in queries (e.g. `id="artist"` produces `artist:`). Case-insensitive. |
|
|
116
133
|
| `<datalist label="...">` | `string` | Human-readable label displayed in suggestion headers. Defaults to capitalized `id`. |
|
|
117
134
|
| `<datalist data-type="...">` | `string` | Optional data type (`"string"` or `"number"`). |
|
|
@@ -119,59 +136,55 @@ Configuration is defined by standard HTML `<datalist>` elements placed inside th
|
|
|
119
136
|
| `<option label="...">` | `string` | Optional descriptive label shown alongside the value. |
|
|
120
137
|
| `<option>` children | `Node` | Optional image (`<img>`) prepended to the suggested value. |
|
|
121
138
|
|
|
122
|
-
Datalists can be added, updated, or removed dynamically at runtime; `<rich-input>` observes changes via `
|
|
139
|
+
Datalists and syntax attributes can be added, updated, or removed dynamically at runtime; `<rich-input>` observes changes via `attributeChangedCallback` and `MutationObserver`.
|
|
140
|
+
|
|
141
|
+
### Configuring Operators, Combinators & Delimiters via JavaScript
|
|
142
|
+
|
|
143
|
+
In addition to HTML attributes, you can configure `operators`, `combinators`, and `delimiters` per instance or globally on the `RichInput` class (which sets the default for newly created instances that do not specify a local override):
|
|
144
|
+
|
|
145
|
+
```javascript
|
|
146
|
+
import { RichInput } from '@bramus/rich-input';
|
|
147
|
+
|
|
148
|
+
// Set global defaults for newly created <rich-input> elements
|
|
149
|
+
RichInput.operators = ['-', '+'];
|
|
150
|
+
RichInput.combinators = ['AND', 'OR', 'NOT'];
|
|
151
|
+
RichInput.delimiters = ['()', '[]'];
|
|
152
|
+
|
|
153
|
+
// Or configure an individual instance via properties or methods
|
|
154
|
+
const input = document.querySelector('rich-input');
|
|
155
|
+
input.operators = ['-'];
|
|
156
|
+
input.combinators = ['AND', 'OR'];
|
|
157
|
+
input.delimiters = ['()'];
|
|
158
|
+
|
|
159
|
+
// Reset an instance or global setting back to defaults by assigning null
|
|
160
|
+
input.operators = null;
|
|
161
|
+
```
|
|
123
162
|
|
|
124
163
|
---
|
|
125
164
|
|
|
126
|
-
## Rich Option Markup
|
|
165
|
+
## Rich Option Markup (`<img>` Support)
|
|
127
166
|
|
|
128
|
-
`<
|
|
167
|
+
Options inside a `<datalist>` can include an `<img>` element to display thumbnails, avatars, or record label logos in the autocomplete suggestions popover:
|
|
129
168
|
|
|
130
169
|
```html
|
|
131
|
-
<
|
|
132
|
-
<
|
|
133
|
-
<
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
<
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
<option value="Kranky">
|
|
142
|
-
<img src="assets/kranky.jpg" height="50" width="50" alt="Kranky Logo">
|
|
143
|
-
Kranky
|
|
144
|
-
</option>
|
|
145
|
-
<option value="Madhouse Records">
|
|
146
|
-
<img src="assets/madhouse-records.jpg" height="50" width="50" alt="Madhouse Records Logo">
|
|
147
|
-
Madhouse Records
|
|
148
|
-
</option>
|
|
149
|
-
<option value="Ninja Tune">
|
|
150
|
-
<img src="assets/ninja-tune.jpg" height="50" width="50" alt="Ninja Tune Logo">
|
|
151
|
-
Ninja Tune
|
|
152
|
-
</option>
|
|
153
|
-
<option value="Warp Records">
|
|
154
|
-
<img src="assets/warp-records.png" height="50" width="50" alt="Warp Records Logo">
|
|
155
|
-
Warp Records
|
|
156
|
-
</option>
|
|
157
|
-
<option value="We Play House Recordings">
|
|
158
|
-
<img src="assets/we-play-house-recordings.jpg" height="50" width="50" alt="We Play House Recordings Logo">
|
|
159
|
-
We Play House Recordings
|
|
160
|
-
</option>
|
|
161
|
-
<option value="XL Recordings">
|
|
162
|
-
<img src="assets/xl-recordings.jpg" height="50" width="50" alt="XL Recordings Logo">
|
|
163
|
-
XL Recordings
|
|
164
|
-
</option>
|
|
165
|
-
</datalist>
|
|
166
|
-
</rich-input>
|
|
170
|
+
<datalist id="label" label="Record Label">
|
|
171
|
+
<option value="We Play House Recordings">
|
|
172
|
+
<img src="assets/we-play-house-recordings.jpg" height="50" width="50" alt="WPH">
|
|
173
|
+
We Play House Recordings
|
|
174
|
+
</option>
|
|
175
|
+
<option value="Defected">
|
|
176
|
+
<img src="assets/defected.jpg" height="50" width="50" alt="Defected">
|
|
177
|
+
Defected
|
|
178
|
+
</option>
|
|
179
|
+
</datalist>
|
|
167
180
|
```
|
|
168
181
|
|
|
169
|
-
When
|
|
182
|
+
When `<rich-input>` parses a `<datalist>`, it clones any `<img>` found inside `<option>` and renders it inside the corresponding suggestion row with `part="suggestion-image"`. You can style these images from your stylesheet using `::part(suggestion-image)`:
|
|
170
183
|
|
|
171
184
|
```css
|
|
172
185
|
rich-input::part(suggestion-image) {
|
|
173
|
-
width:
|
|
174
|
-
height:
|
|
186
|
+
width: 2.5em;
|
|
187
|
+
height: 2.5em;
|
|
175
188
|
border-radius: 50%;
|
|
176
189
|
object-fit: cover;
|
|
177
190
|
}
|
|
@@ -179,43 +192,22 @@ rich-input::part(suggestion-image) {
|
|
|
179
192
|
|
|
180
193
|
---
|
|
181
194
|
|
|
182
|
-
##
|
|
195
|
+
## Customizing the Leading Icon via `::part(icon)`
|
|
183
196
|
|
|
184
|
-
`<rich-input>`
|
|
197
|
+
By default, `<rich-input>` renders a leading search magnifying glass icon exposed as `::part(icon)`. You can customize or replace this icon using either the CSS `content` property (for example, to display an emoji) or the CSS `background` property (to display a custom SVG or image):
|
|
185
198
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
Provide your own SVG or image with `slot="leading"`:
|
|
199
|
+
```css
|
|
200
|
+
/* Option 1: Show an emoji or text via the CSS content property */
|
|
201
|
+
rich-input::part(icon) {
|
|
202
|
+
content: "🎵";
|
|
203
|
+
}
|
|
192
204
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
<path d="M9 18V5l12-2v13"></path>
|
|
198
|
-
<circle cx="6" cy="18" r="3"></circle>
|
|
199
|
-
<circle cx="18" cy="16" r="3"></circle>
|
|
200
|
-
</svg>
|
|
201
|
-
|
|
202
|
-
<datalist id="genre" label="Genre">
|
|
203
|
-
<option value="House"></option>
|
|
204
|
-
<option value="Techno"></option>
|
|
205
|
-
</datalist>
|
|
206
|
-
</rich-input>
|
|
205
|
+
/* Option 2: Show a custom SVG/image via the CSS background property */
|
|
206
|
+
rich-input::part(icon) {
|
|
207
|
+
background: url("music-note.svg") no-repeat center / contain;
|
|
208
|
+
}
|
|
207
209
|
```
|
|
208
210
|
|
|
209
|
-
When an element with `slot="leading"` is supplied, the default search magnifying glass icon is automatically suppressed. If no slotted element is provided, the default magnifying glass icon renders as fallback.
|
|
210
|
-
|
|
211
|
-
### Available Slots
|
|
212
|
-
|
|
213
|
-
| Slot Name | Description |
|
|
214
|
-
|---|---|
|
|
215
|
-
| `leading` | Custom leading icon or content. Defaults to the search magnifying glass icon (`::part(icon)`). |
|
|
216
|
-
| `trailing` | Custom content rendered after the clear button. |
|
|
217
|
-
| *(default)* | Unnamed slot where `<datalist>` configuration elements are placed (visually hidden). |
|
|
218
|
-
|
|
219
211
|
---
|
|
220
212
|
|
|
221
213
|
## The OpaqueRange API
|
|
@@ -269,6 +261,24 @@ Values corresponding to configured keywords are registered into the global `CSS.
|
|
|
269
261
|
color: oklch(0.32 0.14 320);
|
|
270
262
|
}
|
|
271
263
|
|
|
264
|
+
/* Generic prefix highlight for operators (e.g. "-" in "-style:Acid") */
|
|
265
|
+
::highlight(rich-input-operator) {
|
|
266
|
+
color: #e11d48;
|
|
267
|
+
text-shadow: 0 0 1px rgba(225, 29, 72, 0.2);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/* Generic highlight for combinators (e.g. "OR" in "artist:Aphex OR label:Defected") */
|
|
271
|
+
::highlight(rich-input-combinator) {
|
|
272
|
+
color: #7c3aed;
|
|
273
|
+
text-shadow: 0 0 1px rgba(124, 58, 237, 0.2);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/* Generic highlight for delimiters (e.g. "(" and ")") */
|
|
277
|
+
::highlight(rich-input-delimiter) {
|
|
278
|
+
color: #0284c7;
|
|
279
|
+
text-shadow: 0 0 1px rgba(2, 132, 199, 0.25);
|
|
280
|
+
}
|
|
281
|
+
|
|
272
282
|
/* Generic prefix highlight for keyword labels (e.g. "label:", "year:") */
|
|
273
283
|
::highlight(rich-input-keyword) {
|
|
274
284
|
color: #64748b;
|
|
@@ -339,14 +349,16 @@ rich-input::part(suggestion-item-active) {
|
|
|
339
349
|
|---|---|
|
|
340
350
|
| `::part(control)` | The wrapper container enclosing the search icon, input, and clear button |
|
|
341
351
|
| `::part(input)` | The internal native `<input type="text">` |
|
|
342
|
-
| `::part(icon)` | The
|
|
352
|
+
| `::part(icon)` | The leading icon element (defaults to a search magnifying glass, customizable via CSS `content` or `background`) |
|
|
343
353
|
| `::part(clear-button)` | The clear button (visible when text is present) |
|
|
344
354
|
| `::part(popover)` | The autocomplete popover container |
|
|
345
355
|
| `::part(suggestions-header)` | The header bar at the top of the popover |
|
|
346
356
|
| `::part(suggestions-list)` | The `<ul>` list element |
|
|
347
357
|
| `::part(suggestion-item)` | Each suggestion `<li>` item |
|
|
348
|
-
| `::part(suggestion-item-active)` | The currently
|
|
358
|
+
| `::part(suggestion-item-active)` | The currently focused / hovered suggestion item |
|
|
359
|
+
| `::part(suggestion-item-selected)` | The suggestion item matching the value currently echoed in the input |
|
|
349
360
|
| `::part(suggestion-keyword)` | Keyword name element in suggestion items |
|
|
361
|
+
| `::part(suggestion-combinator)` | Combinator name element in suggestion items |
|
|
350
362
|
| `::part(suggestion-value)` | Value element in suggestion items |
|
|
351
363
|
| `::part(suggestion-content)` | The content container inside each suggestion item |
|
|
352
364
|
| `::part(suggestion-image)` | Image or icon element rendered inside rich suggestion items |
|
|
@@ -358,6 +370,12 @@ rich-input::part(suggestion-item-active) {
|
|
|
358
370
|
### Properties
|
|
359
371
|
|
|
360
372
|
- `value` (`string`): Gets or sets the search input value. Updates highlights and form value automatically.
|
|
373
|
+
- `operators` (`string[] | string`): Gets or sets the prefix operators (e.g. `['-', '~', '+']` or `'- ~ +'`) for this instance. Defaults to `RichInput.operators` (`['-']`). Setting to `null` clears the instance override and falls back to the global configuration.
|
|
374
|
+
- `RichInput.operators` (`string[] | string`): Static getter and setter to configure global default operators for all instances without a local override.
|
|
375
|
+
- `combinators` (`string[] | string`): Gets or sets the query combinators (e.g. `['AND', 'OR', 'NOT']` or `'AND OR NOT'`) for this instance. Defaults to `RichInput.combinators` (`[]`). Setting to `null` clears the instance override and falls back to the global configuration.
|
|
376
|
+
- `RichInput.combinators` (`string[] | string`): Static getter and setter to configure global default combinators for all instances without a local override.
|
|
377
|
+
- `delimiters` (`string[] | string`): Gets or sets the delimiter pairs (e.g. `['()', '{}', '[]']` or `'{} () []'`) for this instance. Defaults to `RichInput.delimiters` (`['()']`). Setting to `null` clears the instance override and falls back to the global configuration.
|
|
378
|
+
- `RichInput.delimiters` (`string[] | string`): Static getter and setter to configure global default delimiter pairs for all instances without a local override.
|
|
361
379
|
- `placeholder` (`string`): Gets or sets the input placeholder text.
|
|
362
380
|
- `disabled` (`boolean`): Disables or enables the input control.
|
|
363
381
|
- `name` (`string`): Form field name when submitted inside a `<form>`.
|
|
@@ -365,19 +383,30 @@ rich-input::part(suggestion-item-active) {
|
|
|
365
383
|
|
|
366
384
|
### Methods
|
|
367
385
|
|
|
368
|
-
- `getParsedQuery()`: Returns a parsed object
|
|
386
|
+
- `getParsedQuery()`: Returns a parsed object containing the `raw` query string and an ordered `tokens` array (`keyword`, `combinator`, `delimiter`, `text`, and `whitespace` tokens):
|
|
369
387
|
```json
|
|
370
388
|
{
|
|
371
|
-
"raw": "
|
|
372
|
-
"
|
|
373
|
-
|
|
374
|
-
"
|
|
375
|
-
"
|
|
376
|
-
|
|
377
|
-
|
|
389
|
+
"raw": "(artist:\"Aphex Twin\" OR year:2026) AND -style:\"Acid House\"",
|
|
390
|
+
"tokens": [
|
|
391
|
+
{ "type": "delimiter", "raw": "(", "delimiter": "(", "pair": "()", "role": "open", "start": 0, "end": 1 },
|
|
392
|
+
{ "type": "keyword", "operator": null, "keyword": "artist", "innerValue": "Aphex Twin", "start": 1, "end": 20 },
|
|
393
|
+
{ "type": "whitespace", "raw": " ", "start": 20, "end": 21 },
|
|
394
|
+
{ "type": "combinator", "raw": "OR", "combinator": "OR", "start": 21, "end": 23 },
|
|
395
|
+
{ "type": "whitespace", "raw": " ", "start": 23, "end": 24 },
|
|
396
|
+
{ "type": "keyword", "operator": null, "keyword": "year", "innerValue": "2026", "start": 24, "end": 33 },
|
|
397
|
+
{ "type": "delimiter", "raw": ")", "delimiter": ")", "pair": "()", "role": "close", "start": 33, "end": 34 },
|
|
398
|
+
{ "type": "whitespace", "raw": " ", "start": 34, "end": 35 },
|
|
399
|
+
{ "type": "combinator", "raw": "AND", "combinator": "AND", "start": 35, "end": 38 },
|
|
400
|
+
{ "type": "whitespace", "raw": " ", "start": 38, "end": 39 },
|
|
401
|
+
{ "type": "keyword", "operator": "-", "keyword": "style", "innerValue": "Acid House", "start": 39, "end": 58 }
|
|
402
|
+
]
|
|
378
403
|
}
|
|
379
404
|
```
|
|
380
405
|
- `getKeywords()`: Returns an array of configured keyword definitions from the datalists.
|
|
406
|
+
- `getOperators()` / `setOperators(operators)`: Gets or sets the operators for this instance (or globally via `RichInput.getOperators()` / `RichInput.setOperators(operators)`).
|
|
407
|
+
- `getCombinators()` / `setCombinators(combinators)`: Gets or sets the combinators for this instance (or globally via `RichInput.getCombinators()` / `RichInput.setCombinators(combinators)`).
|
|
408
|
+
- `getDelimiters()` / `setDelimiters(delimiters)`: Gets or sets the delimiters for this instance (or globally via `RichInput.getDelimiters()` / `RichInput.setDelimiters(delimiters)`).
|
|
409
|
+
- `getActiveValueRanges()` / `getActiveKeywordRanges()` / `getActiveOperatorRanges()` / `getActiveCombinatorRanges()` / `getActiveDelimiterRanges()` / `getActiveInvalidRanges()`: Returns the active highlight range descriptors for each token category.
|
|
381
410
|
- `focus(options)`: Focuses the internal input.
|
|
382
411
|
- `blur()`: Removes focus from the internal input.
|
|
383
412
|
- `select()`: Selects all text inside the input.
|
|
@@ -389,7 +418,7 @@ rich-input::part(suggestion-item-active) {
|
|
|
389
418
|
- `change`: Dispatched on blur or when a search change is committed.
|
|
390
419
|
- `search`: Dispatched when the user presses `Enter` with suggestions closed.
|
|
391
420
|
- `rich-input-select`: Dispatched when an autocomplete suggestion is selected.
|
|
392
|
-
- `event.detail`: `{ type, keyword, value, label, query }`
|
|
421
|
+
- `event.detail`: `{ type, operator, keyword, value, label, query }`
|
|
393
422
|
|
|
394
423
|
---
|
|
395
424
|
|