@prosekit/lit 0.0.9 → 0.0.10

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 (30) hide show
  1. package/dist/{chunk-J73E7P6J.js → chunk-3UDA5JEW.js} +2 -9
  2. package/dist/{chunk-37EPOFI5.js → chunk-AWQAU2JR.js} +5 -3
  3. package/dist/chunk-BMDOOASL.js +57 -0
  4. package/dist/chunk-DYEHERSG.js +9 -0
  5. package/dist/chunk-G5KPDHDH.js +120 -0
  6. package/dist/chunk-HMV7TD6T.js +9 -0
  7. package/dist/{chunk-HPMQEYGA.js → chunk-KGZID7N7.js} +61 -92
  8. package/dist/chunk-PCXKL6TA.js +109 -0
  9. package/dist/chunk-TRZW33VF.js +35 -0
  10. package/dist/index-2645d161.d.ts +10 -0
  11. package/dist/index-c461623f.d.ts +67 -0
  12. package/dist/index-f7e15683.d.ts +66 -0
  13. package/dist/options-7235df55.d.ts +14 -0
  14. package/dist/prosekit-lit-components-autocomplete-empty.js +5 -3
  15. package/dist/prosekit-lit-components-autocomplete-item.js +3 -2
  16. package/dist/prosekit-lit-components-autocomplete-list.d.ts +2 -10
  17. package/dist/prosekit-lit-components-autocomplete-list.js +5 -3
  18. package/dist/prosekit-lit-components-autocomplete-popover.d.ts +2 -12
  19. package/dist/prosekit-lit-components-autocomplete-popover.js +23 -139
  20. package/dist/prosekit-lit-components-code-block-popover.d.ts +19 -0
  21. package/dist/prosekit-lit-components-code-block-popover.js +141 -0
  22. package/dist/prosekit-lit-components-combo-box-input.d.ts +22 -0
  23. package/dist/prosekit-lit-components-combo-box-input.js +74 -0
  24. package/dist/prosekit-lit-components-combo-box-item.d.ts +4 -0
  25. package/dist/prosekit-lit-components-combo-box-item.js +11 -0
  26. package/dist/prosekit-lit-components-combo-box-list.d.ts +13 -0
  27. package/dist/prosekit-lit-components-combo-box-list.js +50 -0
  28. package/dist/prosekit-lit-components-combo-box.d.ts +20 -0
  29. package/dist/prosekit-lit-components-combo-box.js +111 -0
  30. package/package.json +42 -2
@@ -0,0 +1,66 @@
1
+ import { VirtualElement, AutoUpdateOptions } from '@floating-ui/dom';
2
+ import { CSSResultGroup } from 'lit';
3
+ import { L as LightBlockElement } from './index-2645d161.js';
4
+ import { P as PopoverOptions } from './options-7235df55.js';
5
+
6
+ interface PopoverProps {
7
+ active: boolean;
8
+ reference?: Element | VirtualElement;
9
+ options?: PopoverOptions;
10
+ autoUpdate?: boolean;
11
+ autoUpdateOptions?: AutoUpdateOptions;
12
+ }
13
+ /**
14
+ * A custom element that displays a popover anchored to a reference element.
15
+ */
16
+ declare class Popover extends LightBlockElement implements Partial<PopoverProps> {
17
+ /** @hidden */
18
+ constructor();
19
+ /** @hidden */
20
+ static styles: CSSResultGroup;
21
+ /**
22
+ * Controls the visibility of the popover element. When set to `true`, the popover is displayed and positioned
23
+ * relative to its reference element. When set to `false`, the popover is hidden and its positioning logic is
24
+ * deactivated.
25
+ */
26
+ active: boolean;
27
+ /**
28
+ * The element that the popover is anchored to. This can be either a DOM element or an object that implements the
29
+ * virtual element interface from Floating UI.
30
+ */
31
+ reference?: Element | VirtualElement;
32
+ /**
33
+ * The options that are passed to the `computePosition` function from Floating UI. These options are used to
34
+ * configure the positioning of the popover element relative to its reference element. For more information on the
35
+ * available options, please refer to the Floating UI documentation.
36
+ */
37
+ options?: PopoverOptions;
38
+ /**
39
+ * Controls whether the popover position is automatically updated when the reference element changes position. When
40
+ * set to `true`, the popover position is updated automatically. When set to `false`, the popover position is only
41
+ * updated when the given properties are changed.
42
+ *
43
+ * @default false
44
+ */
45
+ autoUpdate: boolean;
46
+ /**
47
+ * The options that are passed to the `autoUpdate` function from Floating UI. These options are used to configure the
48
+ * automatic update behavior of the popover position. For more information on the available options, please refer to
49
+ * the Floating UI documentation. This property is only used when the `autoUpdate` property is set to `true`.
50
+ */
51
+ autoUpdateOptions?: AutoUpdateOptions;
52
+ /** @hidden */
53
+ private cleanupAutoUpdate?;
54
+ /** @hidden */
55
+ disconnectedCallback(): void;
56
+ /** @hidden */
57
+ protected updated(): void;
58
+ /** @hidden */
59
+ private start;
60
+ /** @hidden */
61
+ private compute;
62
+ /** @hidden */
63
+ private cleanup;
64
+ }
65
+
66
+ export { Popover as P };
@@ -0,0 +1,14 @@
1
+ import { ComputePositionConfig } from '@floating-ui/dom';
2
+
3
+ /**
4
+ * The `PopoverOptions` interface defines the options that can be passed to the
5
+ * `computePosition` function from Floating UI. These options are used to
6
+ * configure the positioning of the popover element relative to its reference
7
+ * element. For more information on the available options, please refer to the
8
+ * Floating UI documentation.
9
+ *
10
+ * https://floating-ui.com/docs/computeposition#options
11
+ */
12
+ type PopoverOptions = ComputePositionConfig;
13
+
14
+ export { PopoverOptions as P };
@@ -1,8 +1,10 @@
1
1
  import {
2
- __decorateClass,
3
- blockComponentStyles,
4
2
  commandListContext
5
- } from "./chunk-J73E7P6J.js";
3
+ } from "./chunk-DYEHERSG.js";
4
+ import {
5
+ __decorateClass,
6
+ blockComponentStyles
7
+ } from "./chunk-3UDA5JEW.js";
6
8
 
7
9
  // src/components/autocomplete-empty/index.ts
8
10
  import { consume } from "@lit-labs/context";
@@ -1,8 +1,9 @@
1
1
  import {
2
2
  AutocompleteItem,
3
3
  propNames
4
- } from "./chunk-37EPOFI5.js";
5
- import "./chunk-J73E7P6J.js";
4
+ } from "./chunk-AWQAU2JR.js";
5
+ import "./chunk-DYEHERSG.js";
6
+ import "./chunk-3UDA5JEW.js";
6
7
  export {
7
8
  AutocompleteItem,
8
9
  propNames
@@ -12,17 +12,15 @@ declare class AutocompleteList extends LitElement implements Partial<Autocomplet
12
12
  /** @hidden */
13
13
  static styles: CSSResultGroup;
14
14
  /** @hidden */
15
+ private listManager;
16
+ /** @hidden */
15
17
  private controller;
16
18
  private get active();
17
- private lastMouseMoveTime;
18
19
  editor?: Editor;
19
20
  popoverContext: AutocompletePopoverContext | null;
20
21
  context: AutocompleteListContext;
21
22
  protected firstUpdated(): void;
22
23
  private get items();
23
- private get availableItems();
24
- private get firstItem();
25
- private get selectedItem();
26
24
  selectFirstItem(): void;
27
25
  private updateValue;
28
26
  private registerValue;
@@ -30,12 +28,6 @@ declare class AutocompleteList extends LitElement implements Partial<Autocomplet
30
28
  defaultSlot?: HTMLSlotElement;
31
29
  /** @hidden */
32
30
  willUpdate(changedProperties: PropertyValues<this>): void;
33
- private updateSelectedByChange;
34
- private handleMouseMove;
35
- private handleMouseOver;
36
- private handleClick;
37
- private handleMouseDown;
38
- private handleSelect;
39
31
  /** @hidden */
40
32
  render(): lit.TemplateResult<1>;
41
33
  }
@@ -1,9 +1,11 @@
1
1
  import {
2
2
  AutocompleteList,
3
3
  propNames
4
- } from "./chunk-HPMQEYGA.js";
5
- import "./chunk-37EPOFI5.js";
6
- import "./chunk-J73E7P6J.js";
4
+ } from "./chunk-KGZID7N7.js";
5
+ import "./chunk-AWQAU2JR.js";
6
+ import "./chunk-DYEHERSG.js";
7
+ import "./chunk-PCXKL6TA.js";
8
+ import "./chunk-3UDA5JEW.js";
7
9
  export {
8
10
  AutocompleteList,
9
11
  propNames
@@ -1,19 +1,9 @@
1
1
  import * as lit from 'lit';
2
2
  import { LitElement, CSSResultGroup } from 'lit';
3
- import { ComputePositionConfig } from '@floating-ui/dom';
3
+ import { P as PopoverOptions } from './options-7235df55.js';
4
4
  import { Editor } from '@prosekit/core';
5
5
  import { A as AutocompletePopoverContext } from './context-436a56d3.js';
6
-
7
- /**
8
- * The `PopoverOptions` interface defines the options that can be passed to the
9
- * `computePosition` function from Floating UI. These options are used to
10
- * configure the positioning of the popover element relative to its reference
11
- * element. For more information on the available options, please refer to the
12
- * Floating UI documentation.
13
- *
14
- * https://floating-ui.com/docs/computeposition#options
15
- */
16
- type PopoverOptions = ComputePositionConfig;
6
+ import '@floating-ui/dom';
17
7
 
18
8
  declare const propNames: readonly ["editor", "regex", "popoverOptions"];
19
9
  interface AutocompletePopoverProps {
@@ -1,137 +1,21 @@
1
1
  import {
2
2
  commandPopoverContext
3
- } from "./chunk-HPMQEYGA.js";
4
- import "./chunk-37EPOFI5.js";
3
+ } from "./chunk-KGZID7N7.js";
4
+ import "./chunk-AWQAU2JR.js";
5
+ import "./chunk-DYEHERSG.js";
6
+ import "./chunk-PCXKL6TA.js";
7
+ import "./chunk-G5KPDHDH.js";
8
+ import "./chunk-TRZW33VF.js";
5
9
  import {
6
10
  __decorateClass,
7
11
  blockComponentStyles
8
- } from "./chunk-J73E7P6J.js";
9
-
10
- // src/components/popover/index.ts
11
- import {
12
- autoUpdate,
13
- computePosition
14
- } from "@floating-ui/dom";
15
- import {
16
- LitElement,
17
- html
18
- } from "lit";
19
- import { customElement, property, query, state } from "lit/decorators.js";
20
- import { styleMap } from "lit/directives/style-map.js";
21
-
22
- // src/utils/round-by-dpr.ts
23
- function roundByDPR(value) {
24
- const dpr = window.devicePixelRatio || 1;
25
- return Math.round(value * dpr) / dpr;
26
- }
27
-
28
- // src/components/popover/options.ts
29
- import "@floating-ui/dom";
30
-
31
- // src/components/popover/index.ts
32
- var Popover = class extends LitElement {
33
- /** @hidden */
34
- constructor() {
35
- super();
36
- this.active = false;
37
- this.autoUpdate = false;
38
- }
39
- /** @hidden */
40
- disconnectedCallback() {
41
- this.cleanup();
42
- }
43
- /** @hidden */
44
- updated(changed) {
45
- if (!changed.has("computed")) {
46
- this.start();
47
- }
48
- }
49
- /** @hidden */
50
- start() {
51
- this.cleanup();
52
- const reference = this.reference;
53
- const floating = this.floating;
54
- if (!reference)
55
- return;
56
- if (this.autoUpdate) {
57
- this.cleanupAutoUpdate = autoUpdate(
58
- reference,
59
- floating,
60
- () => void this.compute(),
61
- this.autoUpdateOptions
62
- );
63
- } else {
64
- void this.compute();
65
- }
66
- }
67
- /** @hidden */
68
- async compute() {
69
- const reference = this.reference;
70
- const floating = this.floating;
71
- if (!reference)
72
- return;
73
- const options = this.options;
74
- this.computed = await computePosition(reference, floating, options);
75
- }
76
- /** @hidden */
77
- cleanup() {
78
- var _a;
79
- (_a = this.cleanupAutoUpdate) == null ? void 0 : _a.call(this);
80
- this.cleanupAutoUpdate = void 0;
81
- }
82
- /** @hidden */
83
- render() {
84
- var _a;
85
- const { x, y, strategy } = (_a = this.computed) != null ? _a : {
86
- x: 0,
87
- y: 0,
88
- strategy: "absolute"
89
- };
90
- const style = {
91
- top: "0",
92
- left: "0",
93
- position: strategy,
94
- transform: `translate(${roundByDPR(x)}px,${roundByDPR(y)}px)`,
95
- display: this.active ? void 0 : "none"
96
- };
97
- return html`<div class="floating" style="${styleMap(style)}"><slot></slot></div>`;
98
- }
99
- };
100
- /** @hidden */
101
- Popover.styles = blockComponentStyles;
102
- __decorateClass([
103
- property({ type: Boolean, reflect: true })
104
- ], Popover.prototype, "active", 2);
105
- __decorateClass([
106
- query(".floating")
107
- ], Popover.prototype, "floating", 2);
108
- __decorateClass([
109
- property({ attribute: false })
110
- ], Popover.prototype, "reference", 2);
111
- __decorateClass([
112
- property({ attribute: false })
113
- ], Popover.prototype, "options", 2);
114
- __decorateClass([
115
- property({
116
- type: Boolean,
117
- reflect: true
118
- })
119
- ], Popover.prototype, "autoUpdate", 2);
120
- __decorateClass([
121
- property({ type: Object })
122
- ], Popover.prototype, "autoUpdateOptions", 2);
123
- __decorateClass([
124
- state()
125
- ], Popover.prototype, "computed", 2);
126
- Popover = __decorateClass([
127
- customElement("prosekit-popover")
128
- ], Popover);
12
+ } from "./chunk-3UDA5JEW.js";
129
13
 
130
14
  // src/components/autocomplete-popover/index.ts
131
15
  import { provide } from "@lit-labs/context";
132
16
  import "@prosekit/core";
133
- import { html as html2, LitElement as LitElement2 } from "lit";
134
- import { customElement as customElement2, property as property2, query as query2, state as state2 } from "lit/decorators.js";
17
+ import { html, LitElement } from "lit";
18
+ import { customElement, property, query, state } from "lit/decorators.js";
135
19
 
136
20
  // src/components/autocomplete-list/helpers.ts
137
21
  function isAutocompleteList(element) {
@@ -195,8 +79,8 @@ var AutocompletePopoverController = class {
195
79
  if (span) {
196
80
  this.reference = span;
197
81
  }
198
- const query3 = defaultQueryBuilder(options.match);
199
- this.onChange(query3 != null ? query3 : "", !!this.reference);
82
+ const query2 = defaultQueryBuilder(options.match);
83
+ this.onChange(query2 != null ? query2 : "", !!this.reference);
200
84
  this.handleDismiss = options.ignoreMatch;
201
85
  this.handleSubmit = options.deleteMatch;
202
86
  setTimeout(() => {
@@ -275,7 +159,7 @@ var defaultPopoverOptions = {
275
159
 
276
160
  // src/components/autocomplete-popover/index.ts
277
161
  var propNames = ["editor", "regex", "popoverOptions"];
278
- var AutocompletePopover = class extends LitElement2 {
162
+ var AutocompletePopover = class extends LitElement {
279
163
  constructor() {
280
164
  super(...arguments);
281
165
  /** @hidden */
@@ -301,11 +185,11 @@ var AutocompletePopover = class extends LitElement2 {
301
185
  var _a, _b, _c;
302
186
  return (_c = (_b = (_a = this.defaultSlot) == null ? void 0 : _a.assignedElements({ flatten: true })) == null ? void 0 : _b.find(isAutocompleteList)) != null ? _c : null;
303
187
  }
304
- updateContext(query3, active) {
305
- if (this.context.query === query3 && this.context.active === active) {
188
+ updateContext(query2, active) {
189
+ if (this.context.query === query2 && this.context.active === active) {
306
190
  return;
307
191
  }
308
- this.context = { ...this.context, query: query3, active };
192
+ this.context = { ...this.context, query: query2, active };
309
193
  requestAnimationFrame(() => {
310
194
  var _a;
311
195
  (_a = this.list) == null ? void 0 : _a.selectFirstItem();
@@ -328,32 +212,32 @@ var AutocompletePopover = class extends LitElement2 {
328
212
  /** @hidden */
329
213
  render() {
330
214
  var _a;
331
- return html2`<prosekit-popover .active="${this.active}" .reference="${(_a = this.controller.reference) != null ? _a : void 0}" .options="${this.popoverOptions}"><slot></slot></prosekit-popover>`;
215
+ return html`<prosekit-popover .active="${this.active}" .reference="${(_a = this.controller.reference) != null ? _a : void 0}" .options="${this.popoverOptions}"><slot></slot></prosekit-popover>`;
332
216
  }
333
217
  };
334
218
  /** @hidden */
335
219
  AutocompletePopover.styles = blockComponentStyles;
336
220
  __decorateClass([
337
- property2({ attribute: false })
221
+ property({ attribute: false })
338
222
  ], AutocompletePopover.prototype, "editor", 2);
339
223
  __decorateClass([
340
- property2({ attribute: false })
224
+ property({ attribute: false })
341
225
  ], AutocompletePopover.prototype, "regex", 2);
342
226
  __decorateClass([
343
- property2({ attribute: false })
227
+ property({ attribute: false })
344
228
  ], AutocompletePopover.prototype, "popoverOptions", 2);
345
229
  __decorateClass([
346
230
  provide({ context: commandPopoverContext }),
347
- state2()
231
+ state()
348
232
  ], AutocompletePopover.prototype, "context", 2);
349
233
  __decorateClass([
350
- property2({ attribute: false })
234
+ property({ attribute: false })
351
235
  ], AutocompletePopover.prototype, "onSelect", 2);
352
236
  __decorateClass([
353
- query2("slot")
237
+ query("slot")
354
238
  ], AutocompletePopover.prototype, "defaultSlot", 2);
355
239
  AutocompletePopover = __decorateClass([
356
- customElement2("prosekit-autocomplete-popover")
240
+ customElement("prosekit-autocomplete-popover")
357
241
  ], AutocompletePopover);
358
242
  export {
359
243
  AutocompletePopover,
@@ -0,0 +1,19 @@
1
+ import { Editor } from '@prosekit/core';
2
+ import { P as Popover } from './index-f7e15683.js';
3
+ import '@floating-ui/dom';
4
+ import 'lit';
5
+ import './index-2645d161.js';
6
+ import './options-7235df55.js';
7
+
8
+ declare const propNames: readonly ["editor"];
9
+ interface CodeBlockPopoverProps {
10
+ editor: Editor;
11
+ }
12
+ declare class CodeBlockPopover extends Popover implements Partial<CodeBlockPopoverProps> {
13
+ editor?: Editor;
14
+ /** @hidden */
15
+ private controller;
16
+ protected updated(): void;
17
+ }
18
+
19
+ export { CodeBlockPopover, CodeBlockPopoverProps, propNames };
@@ -0,0 +1,141 @@
1
+ import {
2
+ Popover
3
+ } from "./chunk-G5KPDHDH.js";
4
+ import "./chunk-TRZW33VF.js";
5
+ import {
6
+ __decorateClass
7
+ } from "./chunk-3UDA5JEW.js";
8
+
9
+ // src/components/code-block-popover/index.ts
10
+ import { offset } from "@floating-ui/dom";
11
+ import { customElement, property } from "lit/decorators.js";
12
+
13
+ // src/components/code-block-popover/controller.ts
14
+ import "@prosekit/core";
15
+ import "lit";
16
+
17
+ // src/components/code-block-popover/code-block-select.ts
18
+ import { addPlugin } from "@prosekit/core";
19
+ import { ProseMirrorPlugin } from "@prosekit/pm/state";
20
+ function addCodeBlockSelect(options) {
21
+ let prevState = null;
22
+ const plugin = new ProseMirrorPlugin({
23
+ view: () => {
24
+ return {
25
+ update: (view) => {
26
+ const currState = getState(view);
27
+ if ((prevState == null ? void 0 : prevState.pos) !== (currState == null ? void 0 : currState.pos) || (prevState == null ? void 0 : prevState.dom) !== (currState == null ? void 0 : currState.dom)) {
28
+ if (currState) {
29
+ options.onSelect(currState);
30
+ } else {
31
+ options.onDismiss();
32
+ }
33
+ }
34
+ prevState = currState;
35
+ }
36
+ };
37
+ }
38
+ });
39
+ return addPlugin({ plugins: [plugin] });
40
+ }
41
+ function getState(view) {
42
+ const { $from, $to } = view.state.selection;
43
+ if ($from.sameParent($to)) {
44
+ const node = $from.parent;
45
+ if (isCodeBlock(node)) {
46
+ const pos = $from.before();
47
+ const dom = view.nodeDOM(pos);
48
+ if (dom) {
49
+ return { pos, node, dom };
50
+ }
51
+ }
52
+ }
53
+ return null;
54
+ }
55
+ function isCodeBlock(node) {
56
+ return node.type.spec.code && node.isTextblock;
57
+ }
58
+
59
+ // src/components/code-block-popover/controller.ts
60
+ var CodeBlockPopoverController = class {
61
+ constructor(host) {
62
+ this.host = host;
63
+ this.reference = null;
64
+ this.editor = null;
65
+ this.cleanup = null;
66
+ this.host.addController(this);
67
+ }
68
+ setEditor(editor) {
69
+ if (this.editor !== editor) {
70
+ this.editor = editor;
71
+ this.addExtension();
72
+ this.host.requestUpdate();
73
+ }
74
+ }
75
+ addExtension() {
76
+ var _a;
77
+ const editor = this.editor;
78
+ if (!editor)
79
+ return;
80
+ const extension = addCodeBlockSelect({
81
+ onSelect: ({ dom }) => {
82
+ if (this.reference !== dom) {
83
+ this.reference = dom;
84
+ this.host.requestUpdate();
85
+ }
86
+ },
87
+ onDismiss: () => {
88
+ if (this.reference !== null) {
89
+ this.reference = null;
90
+ this.host.requestUpdate();
91
+ }
92
+ }
93
+ });
94
+ (_a = this.cleanup) == null ? void 0 : _a.call(this);
95
+ this.cleanup = editor.use(extension);
96
+ }
97
+ hostDisconnected() {
98
+ var _a;
99
+ (_a = this.cleanup) == null ? void 0 : _a.call(this);
100
+ this.cleanup = null;
101
+ }
102
+ };
103
+
104
+ // src/components/code-block-popover/index.ts
105
+ var propNames = ["editor"];
106
+ var CodeBlockPopover = class extends Popover {
107
+ constructor() {
108
+ super(...arguments);
109
+ /** @hidden */
110
+ this.controller = new CodeBlockPopoverController(this);
111
+ }
112
+ updated() {
113
+ var _a, _b;
114
+ if (this.editor) {
115
+ this.controller.setEditor(this.editor);
116
+ }
117
+ this.reference = (_b = (_a = this.controller) == null ? void 0 : _a.reference) != null ? _b : void 0;
118
+ this.active = !!this.reference;
119
+ this.options = popoverOptions;
120
+ super.updated();
121
+ }
122
+ };
123
+ __decorateClass([
124
+ property({ attribute: false, type: Object })
125
+ ], CodeBlockPopover.prototype, "editor", 2);
126
+ CodeBlockPopover = __decorateClass([
127
+ customElement("prosekit-code-block-popover")
128
+ ], CodeBlockPopover);
129
+ var popoverOptions = {
130
+ placement: "top-start",
131
+ strategy: "absolute",
132
+ middleware: [
133
+ offset((options) => {
134
+ return -options.rects.floating.height;
135
+ })
136
+ ]
137
+ };
138
+ export {
139
+ CodeBlockPopover,
140
+ propNames
141
+ };
@@ -0,0 +1,22 @@
1
+ import * as lit_html from 'lit-html';
2
+ import { L as LightBlockElement } from './index-2645d161.js';
3
+ import { C as ComboBoxContext } from './index-c461623f.js';
4
+ import 'lit';
5
+ import '@prosekit/core';
6
+
7
+ declare const propNames: readonly ["placeholder"];
8
+ type ComboBoxInputProps = {
9
+ placeholder?: string;
10
+ };
11
+ declare class ComboBoxInput extends LightBlockElement {
12
+ placeholder: string;
13
+ comboBoxContext: ComboBoxContext | null;
14
+ private visible;
15
+ private handleKeydown;
16
+ private handleInput;
17
+ protected firstUpdated(): void;
18
+ /** @hidden */
19
+ render(): lit_html.TemplateResult<1>;
20
+ }
21
+
22
+ export { ComboBoxInput, ComboBoxInputProps, propNames };
@@ -0,0 +1,74 @@
1
+ import {
2
+ comboBoxContext
3
+ } from "./chunk-HMV7TD6T.js";
4
+ import {
5
+ LightBlockElement
6
+ } from "./chunk-TRZW33VF.js";
7
+ import {
8
+ __decorateClass
9
+ } from "./chunk-3UDA5JEW.js";
10
+
11
+ // src/components/combo-box-input/index.ts
12
+ import { consume } from "@lit-labs/context";
13
+ import { customElement, property, state } from "lit/decorators.js";
14
+ import { html } from "lit-html";
15
+ var propNames = ["placeholder"];
16
+ var ComboBoxInput = class extends LightBlockElement {
17
+ constructor() {
18
+ super(...arguments);
19
+ this.placeholder = "";
20
+ this.comboBoxContext = null;
21
+ this.visible = false;
22
+ }
23
+ handleKeydown(event) {
24
+ var _a, _b, _c, _d, _e, _f, _g, _h;
25
+ if (event.code === "ArrowUp") {
26
+ (_b = (_a = this.comboBoxContext) == null ? void 0 : _a.listManager) == null ? void 0 : _b.handleArrowUp();
27
+ } else if (event.code === "ArrowDown") {
28
+ (_d = (_c = this.comboBoxContext) == null ? void 0 : _c.listManager) == null ? void 0 : _d.handleArrowDown();
29
+ } else if (event.code === "Escape") {
30
+ (_f = (_e = this.comboBoxContext) == null ? void 0 : _e.listManager) == null ? void 0 : _f.handleEscape();
31
+ } else if (event.code === "Enter") {
32
+ (_h = (_g = this.comboBoxContext) == null ? void 0 : _g.listManager) == null ? void 0 : _h.handleEnter();
33
+ }
34
+ }
35
+ handleInput(event) {
36
+ var _a, _b, _c;
37
+ const value = (_b = (_a = event == null ? void 0 : event.target) == null ? void 0 : _a.value) != null ? _b : "";
38
+ (_c = this.comboBoxContext) == null ? void 0 : _c.setInputValue(value);
39
+ }
40
+ firstUpdated() {
41
+ const resizeObserver = new ResizeObserver((entries) => {
42
+ const visible = entries.some(
43
+ (entry) => entry.contentRect.width > 0 && entry.contentRect.width > 0
44
+ );
45
+ if (this.visible !== visible && visible) {
46
+ setTimeout(() => {
47
+ var _a;
48
+ return (_a = this.querySelector("input")) == null ? void 0 : _a.focus();
49
+ }, 0);
50
+ }
51
+ this.visible = visible;
52
+ });
53
+ resizeObserver.observe(this);
54
+ }
55
+ /** @hidden */
56
+ render() {
57
+ var _a, _b;
58
+ return html`<input placeholder="${this.placeholder}" @keydown="${(event) => this.handleKeydown(event)}" @input="${(event) => this.handleInput(event)}" value="${(_b = (_a = this.comboBoxContext) == null ? void 0 : _a.inputValue) != null ? _b : ""}">`;
59
+ }
60
+ };
61
+ __decorateClass([
62
+ property({ attribute: true })
63
+ ], ComboBoxInput.prototype, "placeholder", 2);
64
+ __decorateClass([
65
+ consume({ context: comboBoxContext, subscribe: true }),
66
+ state()
67
+ ], ComboBoxInput.prototype, "comboBoxContext", 2);
68
+ ComboBoxInput = __decorateClass([
69
+ customElement("prosekit-combo-box-input")
70
+ ], ComboBoxInput);
71
+ export {
72
+ ComboBoxInput,
73
+ propNames
74
+ };
@@ -0,0 +1,4 @@
1
+ export { a as ComboBoxItem, b as ComboBoxItemProps, p as propNames } from './index-c461623f.js';
2
+ import '@prosekit/core';
3
+ import 'lit';
4
+ import './index-2645d161.js';
@@ -0,0 +1,11 @@
1
+ import {
2
+ ComboBoxItem,
3
+ propNames
4
+ } from "./chunk-BMDOOASL.js";
5
+ import "./chunk-HMV7TD6T.js";
6
+ import "./chunk-TRZW33VF.js";
7
+ import "./chunk-3UDA5JEW.js";
8
+ export {
9
+ ComboBoxItem,
10
+ propNames
11
+ };