@prosekit/lit 0.1.3 → 0.1.5

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.
@@ -1,20 +1,20 @@
1
1
  import {
2
- commandPopoverContext
3
- } from "./chunk-66YTZIW6.js";
4
- import "./chunk-M6MY5WGM.js";
5
- import "./chunk-6P3YKUWI.js";
2
+ autocompletePopoverContext
3
+ } from "./chunk-WWRKI6AU.js";
4
+ import "./chunk-MLUELLVA.js";
5
+ import "./chunk-5CI65R73.js";
6
6
  import {
7
- Popover
8
- } from "./chunk-7WLKD2U6.js";
9
- import "./chunk-IDDQA3VV.js";
7
+ Popover,
8
+ boundary
9
+ } from "./chunk-I2VPMW75.js";
10
+ import "./chunk-GZRUCYLP.js";
10
11
  import {
11
- __decorateClass
12
- } from "./chunk-O5JP3B34.js";
12
+ defineCustomElement
13
+ } from "./chunk-S32IZIQF.js";
13
14
 
14
15
  // src/components/autocomplete-popover/index.ts
15
- import { provide } from "@lit/context";
16
+ import { ContextProvider } from "@lit/context";
16
17
  import "@prosekit/core";
17
- import { customElement, property, state } from "lit/decorators.js";
18
18
 
19
19
  // src/components/autocomplete-list/helpers.ts
20
20
  function isAutocompleteList(element) {
@@ -114,8 +114,8 @@ import {
114
114
  size
115
115
  } from "@floating-ui/dom";
116
116
  var defaultDetectOverflowOptions = {
117
- // Make sure the popover is always at least 8px away from the boundary
118
- padding: 8
117
+ padding: 8,
118
+ boundary
119
119
  };
120
120
  var defaultPopoverOptions = {
121
121
  // The main axis is the y axis, and we place the popover at the bottom of the
@@ -127,10 +127,10 @@ var defaultPopoverOptions = {
127
127
  middleware: [
128
128
  // Use the text caret as the reference point
129
129
  inline(),
130
- offset(() => ({
130
+ offset({
131
131
  // Move down the popover by 4px
132
132
  mainAxis: 4
133
- })),
133
+ }),
134
134
  // Flip the popover to the top if it's overflowing the viewport
135
135
  //
136
136
  // When `flipAlignment` is true, which is the default, ensure `flip() `is
@@ -170,40 +170,49 @@ var propNames = ["editor", "regex", "popoverOptions"];
170
170
  var AutocompletePopover = class extends Popover {
171
171
  constructor() {
172
172
  super(...arguments);
173
- /** @hidden */
173
+ /**
174
+ * @hidden
175
+ */
174
176
  this.controller = new AutocompletePopoverController(
175
177
  this,
176
178
  this.updateContext.bind(this)
177
179
  );
178
180
  this.popoverOptions = defaultPopoverOptions;
179
- this.context = {
180
- active: false,
181
- query: "",
182
- handleDismiss: () => {
183
- var _a, _b;
184
- return (_b = (_a = this.controller).handleDismiss) == null ? void 0 : _b.call(_a);
185
- },
186
- handleSubmit: () => {
187
- var _a, _b;
188
- return (_b = (_a = this.controller).handleSubmit) == null ? void 0 : _b.call(_a);
181
+ this.context = new ContextProvider(this, {
182
+ context: autocompletePopoverContext,
183
+ initialValue: {
184
+ active: false,
185
+ query: "",
186
+ handleDismiss: () => {
187
+ var _a, _b;
188
+ return (_b = (_a = this.controller).handleDismiss) == null ? void 0 : _b.call(_a);
189
+ },
190
+ handleSubmit: () => {
191
+ var _a, _b;
192
+ return (_b = (_a = this.controller).handleSubmit) == null ? void 0 : _b.call(_a);
193
+ }
189
194
  }
190
- };
195
+ });
191
196
  }
192
197
  get list() {
193
198
  const element = this.querySelector("prosekit-autocomplete-list");
194
199
  return isAutocompleteList(element) ? element : null;
195
200
  }
196
201
  updateContext(query, active) {
197
- if (this.context.query === query && this.context.active === active) {
202
+ const context = this.context.value;
203
+ if (context.query === query && context.active === active) {
198
204
  return;
199
205
  }
200
- this.context = { ...this.context, query, active };
206
+ this.context.setValue({ ...context, query, active });
207
+ this.requestUpdate();
201
208
  requestAnimationFrame(() => {
202
209
  var _a;
203
210
  (_a = this.list) == null ? void 0 : _a.selectFirstItem();
204
211
  });
205
212
  }
206
- /** @hidden */
213
+ /**
214
+ * @hidden
215
+ */
207
216
  willUpdate(changedProperties) {
208
217
  var _a, _b;
209
218
  super.willUpdate(changedProperties);
@@ -217,7 +226,9 @@ var AutocompletePopover = class extends Popover {
217
226
  this.reference = (_b = this.controller.reference) != null ? _b : void 0;
218
227
  this.options = this.popoverOptions;
219
228
  }
220
- /** @hidden */
229
+ /**
230
+ * @hidden
231
+ */
221
232
  hide() {
222
233
  var _a;
223
234
  super.hide();
@@ -227,25 +238,17 @@ var AutocompletePopover = class extends Popover {
227
238
  }
228
239
  }
229
240
  };
230
- __decorateClass([
231
- property({ attribute: false })
232
- ], AutocompletePopover.prototype, "editor", 2);
233
- __decorateClass([
234
- property({ attribute: false })
235
- ], AutocompletePopover.prototype, "regex", 2);
236
- __decorateClass([
237
- property({ attribute: false })
238
- ], AutocompletePopover.prototype, "popoverOptions", 2);
239
- __decorateClass([
240
- provide({ context: commandPopoverContext }),
241
- state()
242
- ], AutocompletePopover.prototype, "context", 2);
243
- __decorateClass([
244
- property({ attribute: false })
245
- ], AutocompletePopover.prototype, "onSelect", 2);
246
- AutocompletePopover = __decorateClass([
247
- customElement("prosekit-autocomplete-popover")
248
- ], AutocompletePopover);
241
+ /**
242
+ * @hidden
243
+ */
244
+ AutocompletePopover.properties = {
245
+ ...Popover.properties,
246
+ editor: { attribute: false },
247
+ regex: { attribute: false },
248
+ popoverOptions: { attribute: false },
249
+ onSelect: { attribute: false }
250
+ };
251
+ defineCustomElement("prosekit-autocomplete-popover", AutocompletePopover);
249
252
  export {
250
253
  AutocompletePopover,
251
254
  propNames
@@ -3,38 +3,52 @@ import {
3
3
  } from "./chunk-C4MW43I4.js";
4
4
  import {
5
5
  LightElement,
6
- __decorateClass
7
- } from "./chunk-O5JP3B34.js";
6
+ defineCustomElement
7
+ } from "./chunk-S32IZIQF.js";
8
8
 
9
9
  // src/components/combo-box-input/index.ts
10
- import { consume } from "@lit/context";
10
+ import { ContextConsumer } from "@lit/context";
11
11
  import { html } from "lit";
12
- import { customElement, property, state } from "lit/decorators.js";
13
12
  var propNames = ["placeholder"];
14
13
  var ComboBoxInput = class extends LightElement {
15
14
  constructor() {
16
15
  super(...arguments);
17
16
  this.placeholder = "";
18
- this.comboBoxContext = null;
17
+ this.comboBoxContext = new ContextConsumer(this, {
18
+ context: comboBoxContext,
19
+ subscribe: true
20
+ });
19
21
  this.visible = false;
20
22
  }
21
23
  handleKeydown(event) {
22
24
  var _a, _b, _c, _d, _e, _f, _g, _h;
23
- if (event.code === "ArrowUp") {
24
- (_b = (_a = this.comboBoxContext) == null ? void 0 : _a.listManager) == null ? void 0 : _b.handleArrowUp();
25
- } else if (event.code === "ArrowDown") {
26
- (_d = (_c = this.comboBoxContext) == null ? void 0 : _c.listManager) == null ? void 0 : _d.handleArrowDown();
27
- } else if (event.code === "Escape") {
28
- (_f = (_e = this.comboBoxContext) == null ? void 0 : _e.listManager) == null ? void 0 : _f.handleEscape();
29
- } else if (event.code === "Enter") {
30
- (_h = (_g = this.comboBoxContext) == null ? void 0 : _g.listManager) == null ? void 0 : _h.handleEnter();
25
+ switch (event.code) {
26
+ case "ArrowUp":
27
+ (_b = (_a = this.comboBoxContext.value) == null ? void 0 : _a.listManager) == null ? void 0 : _b.handleArrowUp();
28
+ event.preventDefault();
29
+ return;
30
+ case "ArrowDown":
31
+ (_d = (_c = this.comboBoxContext.value) == null ? void 0 : _c.listManager) == null ? void 0 : _d.handleArrowDown();
32
+ event.preventDefault();
33
+ return;
34
+ case "Escape":
35
+ (_f = (_e = this.comboBoxContext.value) == null ? void 0 : _e.listManager) == null ? void 0 : _f.handleEscape();
36
+ event.preventDefault();
37
+ return;
38
+ case "Enter":
39
+ (_h = (_g = this.comboBoxContext.value) == null ? void 0 : _g.listManager) == null ? void 0 : _h.handleEnter();
40
+ event.preventDefault();
41
+ return;
31
42
  }
32
43
  }
33
44
  handleInput(event) {
34
45
  var _a, _b, _c;
35
46
  const value = (_b = (_a = event == null ? void 0 : event.target) == null ? void 0 : _a.value) != null ? _b : "";
36
- (_c = this.comboBoxContext) == null ? void 0 : _c.setInputValue(value);
47
+ (_c = this.comboBoxContext.value) == null ? void 0 : _c.setInputValue(value);
37
48
  }
49
+ /**
50
+ * @hidden
51
+ */
38
52
  firstUpdated() {
39
53
  const resizeObserver = new ResizeObserver((entries) => {
40
54
  const visible = entries.some(
@@ -50,22 +64,21 @@ var ComboBoxInput = class extends LightElement {
50
64
  });
51
65
  resizeObserver.observe(this);
52
66
  }
53
- /** @hidden */
67
+ /**
68
+ * @hidden
69
+ */
54
70
  render() {
55
71
  var _a, _b;
56
- 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 : ""}">`;
72
+ return html`<input placeholder="${this.placeholder}" @keydown="${(event) => this.handleKeydown(event)}" @input="${(event) => this.handleInput(event)}" .value="${(_b = (_a = this.comboBoxContext.value) == null ? void 0 : _a.inputValue) != null ? _b : ""}">`;
57
73
  }
58
74
  };
59
- __decorateClass([
60
- property({ attribute: true })
61
- ], ComboBoxInput.prototype, "placeholder", 2);
62
- __decorateClass([
63
- consume({ context: comboBoxContext, subscribe: true }),
64
- state()
65
- ], ComboBoxInput.prototype, "comboBoxContext", 2);
66
- ComboBoxInput = __decorateClass([
67
- customElement("prosekit-combo-box-input")
68
- ], ComboBoxInput);
75
+ /**
76
+ * @hidden
77
+ */
78
+ ComboBoxInput.properties = {
79
+ placeholder: { attribute: true }
80
+ };
81
+ defineCustomElement("prosekit-combo-box-input", ComboBoxInput);
69
82
  export {
70
83
  ComboBoxInput,
71
84
  propNames
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  ComboBoxItem,
3
3
  propNames
4
- } from "./chunk-55G7TJI3.js";
4
+ } from "./chunk-7RGGPFFK.js";
5
5
  import "./chunk-C4MW43I4.js";
6
- import "./chunk-O5JP3B34.js";
6
+ import "./chunk-S32IZIQF.js";
7
7
  export {
8
8
  ComboBoxItem,
9
9
  propNames
@@ -3,45 +3,41 @@ import {
3
3
  } from "./chunk-C4MW43I4.js";
4
4
  import {
5
5
  LightElement,
6
- __decorateClass
7
- } from "./chunk-O5JP3B34.js";
6
+ defineCustomElement
7
+ } from "./chunk-S32IZIQF.js";
8
8
 
9
9
  // src/components/combo-box-list/component.ts
10
- import { consume } from "@lit/context";
11
- import { customElement, state } from "lit/decorators.js";
10
+ import { ContextConsumer } from "@lit/context";
12
11
  var propNames = [];
13
12
  var ComboBoxList = class extends LightElement {
14
13
  constructor() {
15
14
  super(...arguments);
16
- this.comboBoxContext = null;
15
+ this.comboBoxContext = new ContextConsumer(this, {
16
+ context: comboBoxContext,
17
+ subscribe: true
18
+ });
17
19
  }
18
20
  connectedCallback() {
19
21
  super.connectedCallback();
20
22
  this.addEventListener("mousemove", (event) => {
21
23
  var _a;
22
- (_a = this.comboBoxContext) == null ? void 0 : _a.listManager.handleMouseMove(event);
24
+ (_a = this.comboBoxContext.value) == null ? void 0 : _a.listManager.handleMouseMove(event);
23
25
  });
24
26
  this.addEventListener("mouseover", (event) => {
25
27
  var _a;
26
- (_a = this.comboBoxContext) == null ? void 0 : _a.listManager.handleMouseOver(event);
28
+ (_a = this.comboBoxContext.value) == null ? void 0 : _a.listManager.handleMouseOver(event);
27
29
  });
28
30
  this.addEventListener("mousedown", (event) => {
29
31
  var _a;
30
- (_a = this.comboBoxContext) == null ? void 0 : _a.listManager.handleMouseDown(event);
32
+ (_a = this.comboBoxContext.value) == null ? void 0 : _a.listManager.handleMouseDown(event);
31
33
  });
32
34
  this.addEventListener("click", (event) => {
33
35
  var _a;
34
- (_a = this.comboBoxContext) == null ? void 0 : _a.listManager.handleClick(event);
36
+ (_a = this.comboBoxContext.value) == null ? void 0 : _a.listManager.handleClick(event);
35
37
  });
36
38
  }
37
39
  };
38
- __decorateClass([
39
- consume({ context: comboBoxContext, subscribe: true }),
40
- state()
41
- ], ComboBoxList.prototype, "comboBoxContext", 2);
42
- ComboBoxList = __decorateClass([
43
- customElement("prosekit-combo-box-list")
44
- ], ComboBoxList);
40
+ defineCustomElement("prosekit-combo-box-list", ComboBoxList);
45
41
  export {
46
42
  ComboBoxList,
47
43
  propNames
@@ -1,20 +1,19 @@
1
1
  import {
2
2
  Popover
3
- } from "./chunk-7WLKD2U6.js";
3
+ } from "./chunk-I2VPMW75.js";
4
4
  import {
5
5
  ListManager
6
- } from "./chunk-IDDQA3VV.js";
7
- import "./chunk-55G7TJI3.js";
6
+ } from "./chunk-GZRUCYLP.js";
7
+ import "./chunk-7RGGPFFK.js";
8
8
  import {
9
9
  comboBoxContext
10
10
  } from "./chunk-C4MW43I4.js";
11
11
  import {
12
- __decorateClass
13
- } from "./chunk-O5JP3B34.js";
12
+ defineCustomElement
13
+ } from "./chunk-S32IZIQF.js";
14
14
 
15
15
  // src/components/combo-box/index.ts
16
- import { provide } from "@lit/context";
17
- import { customElement, property, state } from "lit/decorators.js";
16
+ import { ContextProvider } from "@lit/context";
18
17
 
19
18
  // src/components/combo-box-item/helpers.ts
20
19
  function isComboBoxItem(element) {
@@ -46,10 +45,10 @@ var ComboBox = class extends Popover {
46
45
  },
47
46
  getSelectedValue: () => {
48
47
  var _a;
49
- return ((_a = this.context.selectedValue) != null ? _a : "").trim();
48
+ return ((_a = this.getContext().selectedValue) != null ? _a : "").trim();
50
49
  },
51
- setSelectedValue: (value) => {
52
- return this.context.setSelectedValue(value);
50
+ setSelectedValue: (value, reason) => {
51
+ return this.setSelectedValue(value, reason);
53
52
  },
54
53
  getItemValue: (item) => {
55
54
  var _a;
@@ -60,50 +59,67 @@ var ComboBox = class extends Popover {
60
59
  return true;
61
60
  },
62
61
  onDismiss: () => {
63
- var _a;
64
- (_a = this.onDismiss) == null ? void 0 : _a.call(this);
62
+ this.hide();
65
63
  },
66
64
  onSelect: (item) => {
67
- var _a, _b;
68
- this.context.setSelectedValue("");
69
- this.context.setInputValue("");
65
+ var _a;
66
+ this.setSelectedValue("", "keyboard");
70
67
  (_a = item == null ? void 0 : item.onSelect) == null ? void 0 : _a.call(item);
71
- (_b = this.onDismiss) == null ? void 0 : _b.call(this);
68
+ this.hide();
69
+ }
70
+ });
71
+ this.context = new ContextProvider(this, {
72
+ context: comboBoxContext,
73
+ initialValue: {
74
+ inputValue: "",
75
+ setInputValue: (inputValue) => {
76
+ this.setInputValue(inputValue);
77
+ },
78
+ selectedValue: "",
79
+ selectedReason: "keyboard",
80
+ listManager: this.listManager
72
81
  }
73
82
  });
74
- this.context = {
75
- inputValue: "",
76
- setInputValue: (inputValue) => {
77
- if (this.context.inputValue === inputValue) {
78
- return;
79
- }
80
- this.context = { ...this.context, inputValue };
81
- },
82
- selectedValue: "",
83
- setSelectedValue: (selectedValue) => {
84
- if (this.context.selectedValue === selectedValue) {
85
- return;
86
- }
87
- this.context = { ...this.context, selectedValue };
88
- },
89
- listManager: this.listManager
90
- };
83
+ }
84
+ /**
85
+ * @hidden
86
+ */
87
+ hide() {
88
+ var _a;
89
+ super.hide();
90
+ this.setInputValue("");
91
+ (_a = this.onDismiss) == null ? void 0 : _a.call(this);
92
+ }
93
+ getContext() {
94
+ return this.context.value;
95
+ }
96
+ setInputValue(inputValue) {
97
+ const context = this.context.value;
98
+ if (context.inputValue === inputValue) {
99
+ return;
100
+ }
101
+ this.context.setValue({ ...context, inputValue });
102
+ }
103
+ setSelectedValue(selectedValue, selectedReason) {
104
+ const context = this.context.value;
105
+ if (context.selectedValue === selectedValue) {
106
+ return;
107
+ }
108
+ this.context.setValue({ ...context, selectedValue, selectedReason });
91
109
  }
92
110
  get items() {
93
- const items = this.querySelectorAll("\u220Fprosekit-combo-box-item");
111
+ const items = this.querySelectorAll("prosekit-combo-box-item");
94
112
  return Array.from(items).filter(isComboBoxItem);
95
113
  }
96
114
  };
97
- __decorateClass([
98
- property({ attribute: false })
99
- ], ComboBox.prototype, "onDismiss", 2);
100
- __decorateClass([
101
- provide({ context: comboBoxContext }),
102
- state()
103
- ], ComboBox.prototype, "context", 2);
104
- ComboBox = __decorateClass([
105
- customElement("prosekit-combo-box")
106
- ], ComboBox);
115
+ /**
116
+ * @hidden
117
+ */
118
+ ComboBox.properties = {
119
+ ...Popover.properties,
120
+ onDismiss: { attribute: false }
121
+ };
122
+ defineCustomElement("prosekit-combo-box", ComboBox);
107
123
  export {
108
124
  ComboBox,
109
125
  propNames
@@ -1,13 +1,12 @@
1
1
  import {
2
2
  Popover
3
- } from "./chunk-7WLKD2U6.js";
3
+ } from "./chunk-I2VPMW75.js";
4
4
  import {
5
- __decorateClass
6
- } from "./chunk-O5JP3B34.js";
5
+ defineCustomElement
6
+ } from "./chunk-S32IZIQF.js";
7
7
 
8
8
  // src/components/inline-popover/index.ts
9
9
  import "@prosekit/core";
10
- import { customElement, property } from "lit/decorators.js";
11
10
 
12
11
  // src/components/inline-popover/controller.ts
13
12
  import { defineUpdateHandler } from "@prosekit/core";
@@ -113,13 +112,17 @@ var defaultPopoverOptions = {
113
112
  var propNames = ["editor", "popoverOptions"];
114
113
  var InlinePopover = class extends Popover {
115
114
  constructor() {
116
- super();
117
- /** @hidden */
118
- this.controller = new InlinePopoverController(this);
115
+ super(...arguments);
119
116
  this.popoverOptions = defaultPopoverOptions;
120
117
  this.dismiss = "escape";
118
+ /**
119
+ * @hidden
120
+ */
121
+ this.controller = new InlinePopoverController(this);
121
122
  }
122
- /** @hidden */
123
+ /**
124
+ * @hidden
125
+ */
123
126
  willUpdate() {
124
127
  var _a, _b;
125
128
  if (this.editor) {
@@ -129,7 +132,9 @@ var InlinePopover = class extends Popover {
129
132
  this.reference = (_b = this.controller.reference) != null ? _b : void 0;
130
133
  this.options = this.popoverOptions;
131
134
  }
132
- /** @hidden */
135
+ /**
136
+ * @hidden
137
+ */
133
138
  hide() {
134
139
  var _a;
135
140
  super.hide();
@@ -139,15 +144,15 @@ var InlinePopover = class extends Popover {
139
144
  }
140
145
  }
141
146
  };
142
- __decorateClass([
143
- property({ attribute: false })
144
- ], InlinePopover.prototype, "editor", 2);
145
- __decorateClass([
146
- property({ attribute: false })
147
- ], InlinePopover.prototype, "popoverOptions", 2);
148
- InlinePopover = __decorateClass([
149
- customElement("prosekit-inline-popover")
150
- ], InlinePopover);
147
+ /**
148
+ * @hidden
149
+ */
150
+ InlinePopover.properties = {
151
+ ...Popover.properties,
152
+ editor: { attribute: false },
153
+ popoverOptions: { attribute: false }
154
+ };
155
+ defineCustomElement("prosekit-inline-popover", InlinePopover);
151
156
  export {
152
157
  InlinePopover,
153
158
  propNames
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  Popover,
3
3
  propNames
4
- } from "./chunk-7WLKD2U6.js";
5
- import "./chunk-O5JP3B34.js";
4
+ } from "./chunk-I2VPMW75.js";
5
+ import "./chunk-S32IZIQF.js";
6
6
  export {
7
7
  Popover,
8
8
  propNames
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/lit",
3
3
  "type": "module",
4
- "version": "0.1.3",
4
+ "version": "0.1.5",
5
5
  "private": false,
6
6
  "author": {
7
7
  "name": "ocavue",
@@ -87,19 +87,19 @@
87
87
  "dependencies": {
88
88
  "@floating-ui/dom": "^1.5.3",
89
89
  "@lit/context": "^1.1.0",
90
- "@prosekit/core": "^0.1.0",
91
- "@prosekit/extensions": "^0.1.0",
92
- "@prosekit/pm": "^0.1.0",
90
+ "@prosekit/core": "^0.1.9",
91
+ "@prosekit/extensions": "^0.1.6",
92
+ "@prosekit/pm": "^0.1.1",
93
93
  "@superhuman/command-score": "^0.5.0",
94
94
  "lit": "^3.1.0"
95
95
  },
96
96
  "devDependencies": {
97
97
  "@prosekit/dev": "*",
98
- "minify-literals": "^1.0.7",
98
+ "minify-literals": "^1.0.8",
99
99
  "tsup": "^8.0.1",
100
- "typescript": "^5.3.2",
101
- "vitest": "^0.34.6",
102
- "vue": "^3.3.9"
100
+ "typescript": "^5.3.3",
101
+ "vitest": "^1.0.4",
102
+ "vue": "^3.3.12"
103
103
  },
104
104
  "scripts": {
105
105
  "build:tsup": "tsup",
@@ -1,48 +0,0 @@
1
- import {
2
- comboBoxContext
3
- } from "./chunk-C4MW43I4.js";
4
- import {
5
- LightElement,
6
- __decorateClass
7
- } from "./chunk-O5JP3B34.js";
8
-
9
- // src/components/combo-box-item/component.ts
10
- import { consume } from "@lit/context";
11
- import { customElement, property, state } from "lit/decorators.js";
12
- var propNames = [];
13
- var ComboBoxItem = class extends LightElement {
14
- constructor() {
15
- super(...arguments);
16
- this.selected = false;
17
- }
18
- updated() {
19
- var _a, _b, _c, _d;
20
- const content = ((_a = this.textContent) != null ? _a : "").trim();
21
- const query = ((_c = (_b = this.comboBoxContext) == null ? void 0 : _b.inputValue) != null ? _c : "").trim();
22
- const match = content.toLowerCase().includes(query.toLowerCase());
23
- this.selected = match && content === ((_d = this.comboBoxContext) == null ? void 0 : _d.selectedValue);
24
- this.ariaSelected = String(this.selected);
25
- this.setHidden(!match);
26
- }
27
- };
28
- __decorateClass([
29
- property({ attribute: false })
30
- ], ComboBoxItem.prototype, "editor", 2);
31
- __decorateClass([
32
- property({ type: Boolean, reflect: true, attribute: "data-selected" })
33
- ], ComboBoxItem.prototype, "selected", 2);
34
- __decorateClass([
35
- consume({ context: comboBoxContext, subscribe: true }),
36
- state({})
37
- ], ComboBoxItem.prototype, "comboBoxContext", 2);
38
- __decorateClass([
39
- property({ attribute: false })
40
- ], ComboBoxItem.prototype, "onSelect", 2);
41
- ComboBoxItem = __decorateClass([
42
- customElement("prosekit-combo-box-item")
43
- ], ComboBoxItem);
44
-
45
- export {
46
- propNames,
47
- ComboBoxItem
48
- };