@prosekit/lit 0.1.2 → 0.1.4

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.
Files changed (33) hide show
  1. package/dist/_tsup-dts-rollup.d.ts +307 -60
  2. package/dist/{chunk-6P3YKUWI.js → chunk-5CI65R73.js} +2 -2
  3. package/dist/chunk-L6FOAZFL.js +51 -0
  4. package/dist/chunk-MLUELLVA.js +60 -0
  5. package/dist/{chunk-PCXKL6TA.js → chunk-PW3MTUZM.js} +7 -6
  6. package/dist/chunk-S32IZIQF.js +33 -0
  7. package/dist/{chunk-XBNMYITV.js → chunk-TGJAVLMZ.js} +48 -41
  8. package/dist/{chunk-7WLKD2U6.js → chunk-Z3PEQ6MW.js} +81 -41
  9. package/dist/prosekit-lit-autocomplete-empty.d.ts +0 -45
  10. package/dist/prosekit-lit-autocomplete-empty.js +14 -14
  11. package/dist/prosekit-lit-autocomplete-item.d.ts +3 -48
  12. package/dist/prosekit-lit-autocomplete-item.js +3 -3
  13. package/dist/prosekit-lit-autocomplete-list.d.ts +3 -48
  14. package/dist/prosekit-lit-autocomplete-list.js +5 -5
  15. package/dist/prosekit-lit-autocomplete-popover.d.ts +1 -45
  16. package/dist/prosekit-lit-autocomplete-popover.js +53 -50
  17. package/dist/prosekit-lit-combo-box-input.d.ts +1 -46
  18. package/dist/prosekit-lit-combo-box-input.js +39 -26
  19. package/dist/prosekit-lit-combo-box-item.d.ts +3 -48
  20. package/dist/prosekit-lit-combo-box-item.js +2 -2
  21. package/dist/prosekit-lit-combo-box-list.d.ts +3 -48
  22. package/dist/prosekit-lit-combo-box-list.js +12 -16
  23. package/dist/prosekit-lit-combo-box.d.ts +1 -46
  24. package/dist/prosekit-lit-combo-box.js +60 -44
  25. package/dist/prosekit-lit-inline-popover.d.ts +2 -46
  26. package/dist/prosekit-lit-inline-popover.js +23 -18
  27. package/dist/prosekit-lit-popover.d.ts +2 -45
  28. package/dist/prosekit-lit-popover.js +2 -2
  29. package/dist/prosekit-lit.d.ts +1 -48
  30. package/package.json +6 -6
  31. package/dist/chunk-55G7TJI3.js +0 -48
  32. package/dist/chunk-GWGDLLFN.js +0 -61
  33. package/dist/chunk-O5JP3B34.js +0 -31
@@ -10,11 +10,10 @@ import { PropertyValues } from 'lit';
10
10
  import { ReactiveController } from 'lit';
11
11
  import { ReactiveControllerHost } from 'lit';
12
12
  import { TemplateResult } from 'lit';
13
- import { UserProjectConfigExport } from 'vitest/dist/config.js';
14
13
  import { VirtualElement } from '@floating-ui/dom';
15
14
 
16
15
  export declare class AutocompleteEmpty extends LightElement implements AutocompleteEmptyProps {
17
- listContext?: AutocompleteListContext;
16
+ private listContext;
18
17
  connectedCallback(): void;
19
18
  protected willUpdate(_changedProperties: PropertyValues<this>): void;
20
19
  }
@@ -28,11 +27,28 @@ export declare interface AutocompleteEmptyProps {
28
27
  * from the rendered item's `textContent`.
29
28
  */
30
29
  declare class AutocompleteItem extends LightElement implements Partial<AutocompleteItemProps> {
30
+ private listContext;
31
+ /**
32
+ * @hidden
33
+ */
34
+ static properties: {
35
+ value: {
36
+ type: StringConstructor;
37
+ reflect: true;
38
+ attribute: string;
39
+ };
40
+ selected: {
41
+ type: BooleanConstructor;
42
+ reflect: true;
43
+ attribute: string;
44
+ };
45
+ onSelect: {
46
+ attribute: false;
47
+ };
48
+ };
31
49
  value: string;
32
50
  selected: boolean;
33
- /** @hidden */
34
51
  onSelect?: VoidFunction;
35
- listContext?: AutocompleteListContext;
36
52
  get content(): string;
37
53
  connectedCallback(): void;
38
54
  protected willUpdate(): void;
@@ -49,19 +65,33 @@ export { AutocompleteItemProps }
49
65
  export { AutocompleteItemProps as AutocompleteItemProps_alias_1 }
50
66
 
51
67
  declare class AutocompleteList extends LightElement implements Partial<AutocompleteListProps> {
52
- /** @hidden */
68
+ /**
69
+ * @hidden
70
+ */
53
71
  private listManager;
54
- /** @hidden */
72
+ /**
73
+ * @hidden
74
+ */
55
75
  private controller;
76
+ private popoverContext;
56
77
  private get active();
78
+ /**
79
+ * @hidden
80
+ */
81
+ static properties: {
82
+ editor: {
83
+ attribute: false;
84
+ };
85
+ };
57
86
  editor?: Editor;
58
- popoverContext: AutocompletePopoverContext | null;
59
- context: AutocompleteListContext;
87
+ private context;
60
88
  connectedCallback(): void;
61
89
  private get items();
62
90
  selectFirstItem(): void;
63
91
  private updateValue;
64
- /** @hidden */
92
+ /**
93
+ * @hidden
94
+ */
65
95
  willUpdate(changedProperties: PropertyValues<this>): void;
66
96
  }
67
97
  export { AutocompleteList }
@@ -70,8 +100,13 @@ export { AutocompleteList as AutocompleteList_alias_1 }
70
100
  export declare interface AutocompleteListContext {
71
101
  scores: Map<string, number>;
72
102
  selectedValue: string;
103
+ selectedReason: 'mouse' | 'keyboard';
73
104
  }
74
105
 
106
+ export declare const autocompleteListContext: {
107
+ __context__: AutocompleteListContext;
108
+ };
109
+
75
110
  export declare class AutocompleteListController implements ReactiveController {
76
111
  private host;
77
112
  private keymap;
@@ -90,19 +125,62 @@ export { AutocompleteListProps }
90
125
  export { AutocompleteListProps as AutocompleteListProps_alias_1 }
91
126
 
92
127
  export declare class AutocompletePopover extends Popover implements Partial<AutocompletePopoverProps> {
93
- /** @hidden */
128
+ /**
129
+ * @hidden
130
+ */
94
131
  private controller;
132
+ /**
133
+ * @hidden
134
+ */
135
+ static properties: {
136
+ editor: {
137
+ attribute: false;
138
+ };
139
+ regex: {
140
+ attribute: false;
141
+ };
142
+ popoverOptions: {
143
+ attribute: false;
144
+ };
145
+ onSelect: {
146
+ attribute: false;
147
+ };
148
+ active: {
149
+ type: BooleanConstructor;
150
+ reflect: true;
151
+ };
152
+ reference: {
153
+ attribute: false;
154
+ };
155
+ options: {
156
+ attribute: false;
157
+ };
158
+ autoUpdate: {
159
+ type: BooleanConstructor;
160
+ reflect: true;
161
+ };
162
+ autoUpdateOptions: {
163
+ type: ObjectConstructor;
164
+ };
165
+ dismiss: {
166
+ type: StringConstructor;
167
+ reflect: true;
168
+ };
169
+ };
95
170
  editor?: Editor;
96
171
  regex?: RegExp;
97
172
  popoverOptions: PopoverOptions;
98
- context: AutocompletePopoverContext;
99
- /** @hidden */
100
173
  onSelect?: VoidFunction;
174
+ private context;
101
175
  private get list();
102
176
  private updateContext;
103
- /** @hidden */
177
+ /**
178
+ * @hidden
179
+ */
104
180
  willUpdate(changedProperties: PropertyValues<this>): void;
105
- /** @hidden */
181
+ /**
182
+ * @hidden
183
+ */
106
184
  hide(): void;
107
185
  }
108
186
 
@@ -113,6 +191,10 @@ export declare interface AutocompletePopoverContext {
113
191
  handleSubmit: VoidFunction;
114
192
  }
115
193
 
194
+ export declare const autocompletePopoverContext: {
195
+ __context__: AutocompletePopoverContext;
196
+ };
197
+
116
198
  export declare class AutocompletePopoverController implements ReactiveController {
117
199
  private host;
118
200
  private onChange;
@@ -139,10 +221,53 @@ export { AutoUpdateOptions }
139
221
 
140
222
  export declare const blockComponentStyles: CSSResult;
141
223
 
224
+ /**
225
+ * If the browser supports the Popover API, we use the body as the boundary
226
+ * since we don't need to worry about the popover overflowing the parent
227
+ * element.
228
+ */
229
+ export declare const boundary: HTMLElement | undefined;
230
+
142
231
  export declare class ComboBox extends Popover {
232
+ /**
233
+ * @hidden
234
+ */
235
+ static properties: {
236
+ onDismiss: {
237
+ attribute: false;
238
+ };
239
+ active: {
240
+ type: BooleanConstructor;
241
+ reflect: true;
242
+ };
243
+ reference: {
244
+ attribute: false;
245
+ };
246
+ options: {
247
+ attribute: false;
248
+ };
249
+ autoUpdate: {
250
+ type: BooleanConstructor;
251
+ reflect: true;
252
+ };
253
+ autoUpdateOptions: {
254
+ type: ObjectConstructor;
255
+ };
256
+ dismiss: {
257
+ type: StringConstructor;
258
+ reflect: true;
259
+ };
260
+ };
143
261
  onDismiss?: VoidFunction;
144
262
  private listManager;
145
- context: ComboBoxContext;
263
+ /**
264
+ * @hidden
265
+ */
266
+ hide(): void;
267
+ private context;
268
+ private getContext;
269
+ private setInputValue;
270
+ private setSelectedValue;
146
271
  get items(): ComboBoxItem[];
147
272
  }
148
273
 
@@ -150,7 +275,7 @@ export declare interface ComboBoxContext {
150
275
  inputValue: string;
151
276
  setInputValue: (val: string) => void;
152
277
  selectedValue: string;
153
- setSelectedValue: (val: string) => void;
278
+ selectedReason: 'mouse' | 'keyboard';
154
279
  listManager: ListManager<ComboBoxItem>;
155
280
  }
156
281
 
@@ -159,13 +284,26 @@ export declare const comboBoxContext: {
159
284
  };
160
285
 
161
286
  export declare class ComboBoxInput extends LightElement {
287
+ /**
288
+ * @hidden
289
+ */
290
+ static properties: {
291
+ placeholder: {
292
+ attribute: true;
293
+ };
294
+ };
162
295
  placeholder: string;
163
- comboBoxContext: ComboBoxContext | null;
296
+ private comboBoxContext;
164
297
  private visible;
165
298
  private handleKeydown;
166
299
  private handleInput;
300
+ /**
301
+ * @hidden
302
+ */
167
303
  protected firstUpdated(): void;
168
- /** @hidden */
304
+ /**
305
+ * @hidden
306
+ */
169
307
  render(): TemplateResult<1>;
170
308
  }
171
309
 
@@ -174,12 +312,30 @@ export declare interface ComboBoxInputProps {
174
312
  }
175
313
 
176
314
  declare class ComboBoxItem extends LightElement {
315
+ /**
316
+ * @hidden
317
+ */
318
+ static properties: {
319
+ editor: {
320
+ attribute: false;
321
+ };
322
+ selected: {
323
+ type: BooleanConstructor;
324
+ reflect: true;
325
+ attribute: string;
326
+ };
327
+ onSelect: {
328
+ attribute: false;
329
+ };
330
+ };
177
331
  editor?: Editor;
178
332
  selected: boolean;
179
- comboBoxContext?: ComboBoxContext;
180
- /** @hidden */
181
333
  onSelect?: VoidFunction;
182
- protected updated(): void;
334
+ private comboBoxContext;
335
+ /**
336
+ * @hidden
337
+ */
338
+ protected updated(changedProperties: PropertyValues<this>): void;
183
339
  }
184
340
  export { ComboBoxItem }
185
341
  export { ComboBoxItem as ComboBoxItem_alias_1 }
@@ -191,7 +347,7 @@ export { ComboBoxItemProps }
191
347
  export { ComboBoxItemProps as ComboBoxItemProps_alias_1 }
192
348
 
193
349
  declare class ComboBoxList extends LightElement {
194
- comboBoxContext: ComboBoxContext | null;
350
+ private comboBoxContext;
195
351
  connectedCallback(): void;
196
352
  }
197
353
  export { ComboBoxList }
@@ -207,14 +363,6 @@ export declare interface ComboBoxProps extends PopoverProps {
207
363
  onDismiss?: VoidFunction;
208
364
  }
209
365
 
210
- export declare const commandListContext: {
211
- __context__: AutocompleteListContext;
212
- };
213
-
214
- export declare const commandPopoverContext: {
215
- __context__: AutocompletePopoverContext;
216
- };
217
-
218
366
  declare type CommandScore = (item: string, query: string) => number;
219
367
 
220
368
  export declare const commandScore: CommandScore;
@@ -223,7 +371,11 @@ export declare const componentStyles: CSSResult;
223
371
 
224
372
  export declare const default_alias: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
225
373
 
226
- export declare const default_alias_1: UserProjectConfigExport;
374
+ export declare const default_alias_1: {
375
+ test: {
376
+ environment: "jsdom";
377
+ };
378
+ };
227
379
 
228
380
  /**
229
381
  * Default popover options.
@@ -239,17 +391,57 @@ export declare const defaultPopoverOptions_alias_2: PopoverOptions;
239
391
 
240
392
  export declare function defaultQueryBuilder(match: RegExpExecArray): string;
241
393
 
394
+ export declare function defineCustomElement(name: string, constructor: CustomElementConstructor, options?: ElementDefinitionOptions): void;
395
+
242
396
  export declare function getVirtualSelectionElement(view: EditorView): Range | undefined;
243
397
 
244
398
  export declare class InlinePopover extends Popover implements Partial<InlinePopoverProps> {
245
- /** @hidden */
246
- private controller;
399
+ /**
400
+ * @hidden
401
+ */
402
+ static properties: {
403
+ editor: {
404
+ attribute: false;
405
+ };
406
+ popoverOptions: {
407
+ attribute: false;
408
+ };
409
+ active: {
410
+ type: BooleanConstructor;
411
+ reflect: true;
412
+ };
413
+ reference: {
414
+ attribute: false;
415
+ };
416
+ options: {
417
+ attribute: false;
418
+ };
419
+ autoUpdate: {
420
+ type: BooleanConstructor;
421
+ reflect: true;
422
+ };
423
+ autoUpdateOptions: {
424
+ type: ObjectConstructor;
425
+ };
426
+ dismiss: {
427
+ type: StringConstructor;
428
+ reflect: true;
429
+ };
430
+ };
247
431
  editor?: Editor;
248
432
  popoverOptions: PopoverOptions;
249
- constructor();
250
- /** @hidden */
433
+ dismiss: "escape";
434
+ /**
435
+ * @hidden
436
+ */
437
+ private controller;
438
+ /**
439
+ * @hidden
440
+ */
251
441
  willUpdate(): void;
252
- /** @hidden */
442
+ /**
443
+ * @hidden
444
+ */
253
445
  hide(): void;
254
446
  }
255
447
 
@@ -282,6 +474,10 @@ export declare function isComboBoxItem(element?: Element | null): element is Com
282
474
  export declare function isComboBoxList(element?: Element | null): element is ComboBoxList;
283
475
 
284
476
  export declare class LightElement extends LitElement {
477
+ /**
478
+ * @hidden
479
+ */
480
+ constructor();
285
481
  createRenderRoot(): this;
286
482
  setHidden(hidden: boolean): void;
287
483
  }
@@ -301,7 +497,7 @@ export declare class ListManager<Item extends {
301
497
  constructor(options: {
302
498
  getItems: () => Item[];
303
499
  getSelectedValue: () => string;
304
- setSelectedValue: (value: string) => void;
500
+ setSelectedValue: (value: string, reason: 'mouse' | 'keyboard') => void;
305
501
  getItemValue: (item: Item) => string;
306
502
  queryClosestItem: (element: HTMLElement) => Item | null;
307
503
  getActive: () => boolean;
@@ -329,37 +525,67 @@ export declare class ListManager<Item extends {
329
525
  * A custom element that displays a popover anchored to a reference element.
330
526
  */
331
527
  export declare class Popover extends LightElement implements Partial<PopoverProps> {
332
- /** @hidden */
333
- constructor();
334
528
  /**
335
- * Controls the visibility of the popover element. When set to `true`, the popover is displayed and positioned
336
- * relative to its reference element. When set to `false`, the popover is hidden and its positioning logic is
529
+ * @hidden
530
+ */
531
+ static properties: {
532
+ active: {
533
+ type: BooleanConstructor;
534
+ reflect: true;
535
+ };
536
+ reference: {
537
+ attribute: false;
538
+ };
539
+ options: {
540
+ attribute: false;
541
+ };
542
+ autoUpdate: {
543
+ type: BooleanConstructor;
544
+ reflect: true;
545
+ };
546
+ autoUpdateOptions: {
547
+ type: ObjectConstructor;
548
+ };
549
+ dismiss: {
550
+ type: StringConstructor;
551
+ reflect: true;
552
+ };
553
+ };
554
+ /**
555
+ * Controls the visibility of the popover element. When set to `true`, the
556
+ * popover is displayed and positioned relative to its reference element. When
557
+ * set to `false`, the popover is hidden and its positioning logic is
337
558
  * deactivated.
338
559
  */
339
560
  active: boolean;
340
561
  /**
341
- * The element that the popover is anchored to. This can be either a DOM element or an object that implements the
342
- * virtual element interface from Floating UI.
562
+ * The element that the popover is anchored to. This can be either a DOM
563
+ * element or an object that implements the virtual element interface from
564
+ * Floating UI.
343
565
  */
344
566
  reference?: Element | VirtualElement;
345
567
  /**
346
- * The options that are passed to the `computePosition` function from Floating UI. These options are used to
347
- * configure the positioning of the popover element relative to its reference element. For more information on the
568
+ * The options that are passed to the `computePosition` function from Floating
569
+ * UI. These options are used to configure the positioning of the popover
570
+ * element relative to its reference element. For more information on the
348
571
  * available options, please refer to the Floating UI documentation.
349
572
  */
350
573
  options?: PopoverOptions;
351
574
  /**
352
- * Controls whether the popover position is automatically updated when the reference element changes position. When
353
- * set to `true`, the popover position is updated automatically. When set to `false`, the popover position is only
354
- * updated when the given properties are changed.
575
+ * Controls whether the popover position is automatically updated when the
576
+ * reference element changes position. When set to `true`, the popover
577
+ * position is updated automatically. When set to `false`, the popover
578
+ * position is only updated when the given properties are changed.
355
579
  *
356
580
  * @default false
357
581
  */
358
582
  autoUpdate: boolean;
359
583
  /**
360
- * The options that are passed to the `autoUpdate` function from Floating UI. These options are used to configure the
361
- * automatic update behavior of the popover position. For more information on the available options, please refer to
362
- * the Floating UI documentation. This property is only used when the `autoUpdate` property is set to `true`.
584
+ * The options that are passed to the `autoUpdate` function from Floating UI.
585
+ * These options are used to configure the automatic update behavior of the
586
+ * popover position. For more information on the available options, please
587
+ * refer to the Floating UI documentation. This property is only used when the
588
+ * `autoUpdate` property is set to `true`.
363
589
  */
364
590
  autoUpdateOptions?: AutoUpdateOptions;
365
591
  /**
@@ -374,27 +600,48 @@ export declare class Popover extends LightElement implements Partial<PopoverProp
374
600
  *
375
601
  * @default "on"
376
602
  */
377
- dismiss: string;
378
- /** @hidden */
603
+ dismiss: 'off' | 'on' | 'click' | 'escape';
604
+ /**
605
+ * @hidden
606
+ */
379
607
  private disposeAutoUpdate?;
380
- /** @hidden */
608
+ /**
609
+ * @hidden
610
+ */
381
611
  private disposeEventListeners?;
382
- /** @hidden */
612
+ /**
613
+ * @hidden
614
+ */
383
615
  connectedCallback(): void;
384
- /** @hidden */
616
+ /**
617
+ * @hidden
618
+ */
385
619
  disconnectedCallback(): void;
386
- /** @hidden */
620
+ /**
621
+ * @hidden
622
+ */
387
623
  protected updated(changedProperties: PropertyValues<this>): void;
388
- /** @hidden */
624
+ /**
625
+ * @hidden
626
+ */
389
627
  private start;
390
- /** @hidden */
628
+ /**
629
+ * @hidden
630
+ */
391
631
  private compute;
392
- /** @hidden */
632
+ /**
633
+ * @hidden
634
+ */
393
635
  hide(): void;
394
636
  private handleDocumentMouseDown;
395
637
  private handleDocumentKeyDown;
396
638
  }
397
639
 
640
+ /**
641
+ * Whether the browser supports the [Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API).
642
+ */
643
+ export declare const popoverAvailable: boolean;
644
+
398
645
  /**
399
646
  * The `PopoverOptions` interface defines the options that can be passed to the
400
647
  * `computePosition` function from Floating UI. These options are used to
@@ -1,9 +1,9 @@
1
1
  // src/components/autocomplete-list/context.ts
2
2
  import { createContext } from "@lit/context";
3
- var commandListContext = createContext(
3
+ var autocompleteListContext = createContext(
4
4
  "prosekit-autocomplete-list-context"
5
5
  );
6
6
 
7
7
  export {
8
- commandListContext
8
+ autocompleteListContext
9
9
  };
@@ -0,0 +1,51 @@
1
+ import {
2
+ comboBoxContext
3
+ } from "./chunk-C4MW43I4.js";
4
+ import {
5
+ LightElement,
6
+ defineCustomElement
7
+ } from "./chunk-S32IZIQF.js";
8
+
9
+ // src/components/combo-box-item/component.ts
10
+ import { ContextConsumer } from "@lit/context";
11
+ var propNames = [];
12
+ var ComboBoxItem = class extends LightElement {
13
+ constructor() {
14
+ super(...arguments);
15
+ this.selected = false;
16
+ this.comboBoxContext = new ContextConsumer(this, {
17
+ context: comboBoxContext,
18
+ subscribe: true
19
+ });
20
+ }
21
+ /**
22
+ * @hidden
23
+ */
24
+ updated(changedProperties) {
25
+ var _a, _b, _c, _d, _e;
26
+ super.updated(changedProperties);
27
+ const content = ((_a = this.textContent) != null ? _a : "").trim();
28
+ const query = ((_c = (_b = this.comboBoxContext.value) == null ? void 0 : _b.inputValue) != null ? _c : "").trim();
29
+ const match = content.toLowerCase().includes(query.toLowerCase());
30
+ this.selected = match && content === ((_d = this.comboBoxContext.value) == null ? void 0 : _d.selectedValue);
31
+ this.ariaSelected = String(this.selected);
32
+ this.setHidden(!match);
33
+ if (this.selected && changedProperties.has("selected") && !changedProperties.get("selected") && ((_e = this.comboBoxContext.value) == null ? void 0 : _e.selectedReason) === "keyboard") {
34
+ this.scrollIntoView({ block: "nearest" });
35
+ }
36
+ }
37
+ };
38
+ /**
39
+ * @hidden
40
+ */
41
+ ComboBoxItem.properties = {
42
+ editor: { attribute: false },
43
+ selected: { type: Boolean, reflect: true, attribute: "data-selected" },
44
+ onSelect: { attribute: false }
45
+ };
46
+ defineCustomElement("prosekit-combo-box-item", ComboBoxItem);
47
+
48
+ export {
49
+ propNames,
50
+ ComboBoxItem
51
+ };
@@ -0,0 +1,60 @@
1
+ import {
2
+ autocompleteListContext
3
+ } from "./chunk-5CI65R73.js";
4
+ import {
5
+ LightElement,
6
+ defineCustomElement
7
+ } from "./chunk-S32IZIQF.js";
8
+
9
+ // src/components/autocomplete-item/component.ts
10
+ import { ContextConsumer } from "@lit/context";
11
+ import "lit";
12
+ var propNames = ["value", "onSelect"];
13
+ var AutocompleteItem = class extends LightElement {
14
+ constructor() {
15
+ super(...arguments);
16
+ this.listContext = new ContextConsumer(this, {
17
+ context: autocompleteListContext,
18
+ subscribe: true
19
+ });
20
+ this.value = "";
21
+ this.selected = false;
22
+ }
23
+ get content() {
24
+ const text = this.value || this.textContent || "";
25
+ return text.trim().toLowerCase();
26
+ }
27
+ connectedCallback() {
28
+ super.connectedCallback();
29
+ this.role = "option";
30
+ }
31
+ willUpdate() {
32
+ var _a, _b;
33
+ const content = this.content;
34
+ const score = ((_a = this.listContext.value) == null ? void 0 : _a.scores.get(content)) || 0;
35
+ const hidden = score <= 0;
36
+ this.selected = !hidden && content === ((_b = this.listContext.value) == null ? void 0 : _b.selectedValue);
37
+ this.setHidden(hidden);
38
+ }
39
+ updated(changedProperties) {
40
+ var _a;
41
+ this.ariaSelected = String(this.selected);
42
+ if (this.selected && changedProperties.has("selected") && !changedProperties.get("selected") && ((_a = this.listContext.value) == null ? void 0 : _a.selectedReason) === "keyboard") {
43
+ this.scrollIntoView({ block: "nearest" });
44
+ }
45
+ }
46
+ };
47
+ /**
48
+ * @hidden
49
+ */
50
+ AutocompleteItem.properties = {
51
+ value: { type: String, reflect: true, attribute: "data-value" },
52
+ selected: { type: Boolean, reflect: true, attribute: "data-selected" },
53
+ onSelect: { attribute: false }
54
+ };
55
+ defineCustomElement("prosekit-autocomplete-item", AutocompleteItem);
56
+
57
+ export {
58
+ propNames,
59
+ AutocompleteItem
60
+ };