@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
@@ -1,20 +1,19 @@
1
1
  import {
2
2
  Popover
3
- } from "./chunk-7WLKD2U6.js";
3
+ } from "./chunk-Z3PEQ6MW.js";
4
4
  import {
5
5
  ListManager
6
- } from "./chunk-PCXKL6TA.js";
7
- import "./chunk-55G7TJI3.js";
6
+ } from "./chunk-PW3MTUZM.js";
7
+ import "./chunk-L6FOAZFL.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,48 +1,4 @@
1
- export { propNames } from './_tsup-dts-rollup';
2
- export { AutocompleteEmptyProps } from './_tsup-dts-rollup';
3
- export { AutocompleteEmpty } from './_tsup-dts-rollup';
4
- export { AutocompleteItemProps } from './_tsup-dts-rollup';
5
- export { AutocompleteItem } from './_tsup-dts-rollup';
6
- export { isAutocompleteItem } from './_tsup-dts-rollup';
7
- export { queryClosestAutocompleteItem } from './_tsup-dts-rollup';
8
- export { AutocompleteListProps } from './_tsup-dts-rollup';
9
- export { AutocompleteList } from './_tsup-dts-rollup';
10
- export { AutocompleteListContext } from './_tsup-dts-rollup';
11
- export { commandListContext } from './_tsup-dts-rollup';
12
- export { AutocompleteListController } from './_tsup-dts-rollup';
13
- export { isAutocompleteList } from './_tsup-dts-rollup';
14
- export { AutocompletePopoverContext } from './_tsup-dts-rollup';
15
- export { commandPopoverContext } from './_tsup-dts-rollup';
16
- export { AutocompletePopoverController } from './_tsup-dts-rollup';
17
- export { defaultPopoverOptions } from './_tsup-dts-rollup';
18
- export { defaultQueryBuilder } from './_tsup-dts-rollup';
19
- export { PopoverOptions } from './_tsup-dts-rollup';
20
- export { AutocompletePopoverProps } from './_tsup-dts-rollup';
21
- export { AutocompletePopover } from './_tsup-dts-rollup';
22
- export { LightElement } from './_tsup-dts-rollup';
23
- export { ComboBoxContext } from './_tsup-dts-rollup';
24
- export { comboBoxContext } from './_tsup-dts-rollup';
25
- export { ComboBoxProps } from './_tsup-dts-rollup';
26
- export { ComboBox } from './_tsup-dts-rollup';
27
- export { ComboBoxInputProps } from './_tsup-dts-rollup';
28
- export { ComboBoxInput } from './_tsup-dts-rollup';
29
- export { ComboBoxItemProps } from './_tsup-dts-rollup';
30
- export { ComboBoxItem } from './_tsup-dts-rollup';
31
- export { isComboBoxItem } from './_tsup-dts-rollup';
32
- export { queryClosestComboBoxItem } from './_tsup-dts-rollup';
33
- export { ComboBoxListProps } from './_tsup-dts-rollup';
34
- export { ComboBoxList } from './_tsup-dts-rollup';
35
- export { isComboBoxList } from './_tsup-dts-rollup';
36
- export { InlinePopoverController } from './_tsup-dts-rollup';
37
- export { getVirtualSelectionElement } from './_tsup-dts-rollup';
1
+ export { PopoverOptions_alias_1 as PopoverOptions } from './_tsup-dts-rollup';
2
+ export { propNames_alias_12 as propNames } from './_tsup-dts-rollup';
38
3
  export { InlinePopoverProps } from './_tsup-dts-rollup';
39
4
  export { InlinePopover } from './_tsup-dts-rollup';
40
- export { AutoUpdateOptions } from './_tsup-dts-rollup';
41
- export { PopoverProps } from './_tsup-dts-rollup';
42
- export { Popover } from './_tsup-dts-rollup';
43
- export { ListManager } from './_tsup-dts-rollup';
44
- export { blockComponentStyles } from './_tsup-dts-rollup';
45
- export { componentStyles } from './_tsup-dts-rollup';
46
- export { commandScore } from './_tsup-dts-rollup';
47
- export { roundByDPR } from './_tsup-dts-rollup';
48
- export { default_alias as default } from './_tsup-dts-rollup';
@@ -1,13 +1,12 @@
1
1
  import {
2
2
  Popover
3
- } from "./chunk-7WLKD2U6.js";
3
+ } from "./chunk-Z3PEQ6MW.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,48 +1,5 @@
1
- export { propNames } from './_tsup-dts-rollup';
2
- export { AutocompleteEmptyProps } from './_tsup-dts-rollup';
3
- export { AutocompleteEmpty } from './_tsup-dts-rollup';
4
- export { AutocompleteItemProps } from './_tsup-dts-rollup';
5
- export { AutocompleteItem } from './_tsup-dts-rollup';
6
- export { isAutocompleteItem } from './_tsup-dts-rollup';
7
- export { queryClosestAutocompleteItem } from './_tsup-dts-rollup';
8
- export { AutocompleteListProps } from './_tsup-dts-rollup';
9
- export { AutocompleteList } from './_tsup-dts-rollup';
10
- export { AutocompleteListContext } from './_tsup-dts-rollup';
11
- export { commandListContext } from './_tsup-dts-rollup';
12
- export { AutocompleteListController } from './_tsup-dts-rollup';
13
- export { isAutocompleteList } from './_tsup-dts-rollup';
14
- export { AutocompletePopoverContext } from './_tsup-dts-rollup';
15
- export { commandPopoverContext } from './_tsup-dts-rollup';
16
- export { AutocompletePopoverController } from './_tsup-dts-rollup';
17
- export { defaultPopoverOptions } from './_tsup-dts-rollup';
18
- export { defaultQueryBuilder } from './_tsup-dts-rollup';
19
- export { PopoverOptions } from './_tsup-dts-rollup';
20
- export { AutocompletePopoverProps } from './_tsup-dts-rollup';
21
- export { AutocompletePopover } from './_tsup-dts-rollup';
22
- export { LightElement } from './_tsup-dts-rollup';
23
- export { ComboBoxContext } from './_tsup-dts-rollup';
24
- export { comboBoxContext } from './_tsup-dts-rollup';
25
- export { ComboBoxProps } from './_tsup-dts-rollup';
26
- export { ComboBox } from './_tsup-dts-rollup';
27
- export { ComboBoxInputProps } from './_tsup-dts-rollup';
28
- export { ComboBoxInput } from './_tsup-dts-rollup';
29
- export { ComboBoxItemProps } from './_tsup-dts-rollup';
30
- export { ComboBoxItem } from './_tsup-dts-rollup';
31
- export { isComboBoxItem } from './_tsup-dts-rollup';
32
- export { queryClosestComboBoxItem } from './_tsup-dts-rollup';
33
- export { ComboBoxListProps } from './_tsup-dts-rollup';
34
- export { ComboBoxList } from './_tsup-dts-rollup';
35
- export { isComboBoxList } from './_tsup-dts-rollup';
36
- export { InlinePopoverController } from './_tsup-dts-rollup';
37
- export { getVirtualSelectionElement } from './_tsup-dts-rollup';
38
- export { InlinePopoverProps } from './_tsup-dts-rollup';
39
- export { InlinePopover } from './_tsup-dts-rollup';
40
1
  export { AutoUpdateOptions } from './_tsup-dts-rollup';
2
+ export { PopoverOptions_alias_2 as PopoverOptions } from './_tsup-dts-rollup';
3
+ export { propNames_alias_13 as propNames } from './_tsup-dts-rollup';
41
4
  export { PopoverProps } from './_tsup-dts-rollup';
42
5
  export { Popover } from './_tsup-dts-rollup';
43
- export { ListManager } from './_tsup-dts-rollup';
44
- export { blockComponentStyles } from './_tsup-dts-rollup';
45
- export { componentStyles } from './_tsup-dts-rollup';
46
- export { commandScore } from './_tsup-dts-rollup';
47
- export { roundByDPR } from './_tsup-dts-rollup';
48
- export { default_alias as default } from './_tsup-dts-rollup';
@@ -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-Z3PEQ6MW.js";
5
+ import "./chunk-S32IZIQF.js";
6
6
  export {
7
7
  Popover,
8
8
  propNames
@@ -1,48 +1 @@
1
- export { propNames } from './_tsup-dts-rollup';
2
- export { AutocompleteEmptyProps } from './_tsup-dts-rollup';
3
- export { AutocompleteEmpty } from './_tsup-dts-rollup';
4
- export { AutocompleteItemProps } from './_tsup-dts-rollup';
5
- export { AutocompleteItem } from './_tsup-dts-rollup';
6
- export { isAutocompleteItem } from './_tsup-dts-rollup';
7
- export { queryClosestAutocompleteItem } from './_tsup-dts-rollup';
8
- export { AutocompleteListProps } from './_tsup-dts-rollup';
9
- export { AutocompleteList } from './_tsup-dts-rollup';
10
- export { AutocompleteListContext } from './_tsup-dts-rollup';
11
- export { commandListContext } from './_tsup-dts-rollup';
12
- export { AutocompleteListController } from './_tsup-dts-rollup';
13
- export { isAutocompleteList } from './_tsup-dts-rollup';
14
- export { AutocompletePopoverContext } from './_tsup-dts-rollup';
15
- export { commandPopoverContext } from './_tsup-dts-rollup';
16
- export { AutocompletePopoverController } from './_tsup-dts-rollup';
17
- export { defaultPopoverOptions } from './_tsup-dts-rollup';
18
- export { defaultQueryBuilder } from './_tsup-dts-rollup';
19
- export { PopoverOptions } from './_tsup-dts-rollup';
20
- export { AutocompletePopoverProps } from './_tsup-dts-rollup';
21
- export { AutocompletePopover } from './_tsup-dts-rollup';
22
- export { LightElement } from './_tsup-dts-rollup';
23
- export { ComboBoxContext } from './_tsup-dts-rollup';
24
- export { comboBoxContext } from './_tsup-dts-rollup';
25
- export { ComboBoxProps } from './_tsup-dts-rollup';
26
- export { ComboBox } from './_tsup-dts-rollup';
27
- export { ComboBoxInputProps } from './_tsup-dts-rollup';
28
- export { ComboBoxInput } from './_tsup-dts-rollup';
29
- export { ComboBoxItemProps } from './_tsup-dts-rollup';
30
- export { ComboBoxItem } from './_tsup-dts-rollup';
31
- export { isComboBoxItem } from './_tsup-dts-rollup';
32
- export { queryClosestComboBoxItem } from './_tsup-dts-rollup';
33
- export { ComboBoxListProps } from './_tsup-dts-rollup';
34
- export { ComboBoxList } from './_tsup-dts-rollup';
35
- export { isComboBoxList } from './_tsup-dts-rollup';
36
- export { InlinePopoverController } from './_tsup-dts-rollup';
37
- export { getVirtualSelectionElement } from './_tsup-dts-rollup';
38
- export { InlinePopoverProps } from './_tsup-dts-rollup';
39
- export { InlinePopover } from './_tsup-dts-rollup';
40
- export { AutoUpdateOptions } from './_tsup-dts-rollup';
41
- export { PopoverProps } from './_tsup-dts-rollup';
42
- export { Popover } from './_tsup-dts-rollup';
43
- export { ListManager } from './_tsup-dts-rollup';
44
- export { blockComponentStyles } from './_tsup-dts-rollup';
45
- export { componentStyles } from './_tsup-dts-rollup';
46
- export { commandScore } from './_tsup-dts-rollup';
47
- export { roundByDPR } from './_tsup-dts-rollup';
48
- export { default_alias as default } from './_tsup-dts-rollup';
1
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/lit",
3
3
  "type": "module",
4
- "version": "0.1.2",
4
+ "version": "0.1.4",
5
5
  "private": false,
6
6
  "author": {
7
7
  "name": "ocavue",
@@ -95,11 +95,11 @@
95
95
  },
96
96
  "devDependencies": {
97
97
  "@prosekit/dev": "*",
98
- "minify-literals": "^1.0.7",
99
- "tsup": "^7.3.0",
100
- "typescript": "^5.2.2",
101
- "vitest": "^0.34.6",
102
- "vue": "^3.3.8"
98
+ "minify-literals": "^1.0.8",
99
+ "tsup": "^8.0.1",
100
+ "typescript": "^5.3.3",
101
+ "vitest": "^1.0.2",
102
+ "vue": "^3.3.11"
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
- };
@@ -1,61 +0,0 @@
1
- import {
2
- commandListContext
3
- } from "./chunk-6P3YKUWI.js";
4
- import {
5
- LightElement,
6
- __decorateClass
7
- } from "./chunk-O5JP3B34.js";
8
-
9
- // src/components/autocomplete-item/component.ts
10
- import { consume } from "@lit/context";
11
- import "lit";
12
- import { customElement, property, state } from "lit/decorators.js";
13
- var propNames = ["value", "onSelect"];
14
- var AutocompleteItem = class extends LightElement {
15
- constructor() {
16
- super(...arguments);
17
- this.value = "";
18
- this.selected = false;
19
- }
20
- get content() {
21
- const text = this.value || this.textContent || "";
22
- return text.trim().toLowerCase();
23
- }
24
- connectedCallback() {
25
- super.connectedCallback();
26
- this.role = "option";
27
- }
28
- willUpdate() {
29
- var _a, _b;
30
- const content = this.content;
31
- this.selected = content === ((_a = this.listContext) == null ? void 0 : _a.selectedValue);
32
- const score = ((_b = this.listContext) == null ? void 0 : _b.scores.get(content)) || 0;
33
- this.setHidden(score <= 0);
34
- }
35
- updated(changedProperties) {
36
- if (this.selected && changedProperties.has("selected") && !changedProperties.get("selected")) {
37
- this.scrollIntoView({ block: "nearest" });
38
- }
39
- }
40
- };
41
- __decorateClass([
42
- property({ type: String, reflect: true, attribute: "data-value" })
43
- ], AutocompleteItem.prototype, "value", 2);
44
- __decorateClass([
45
- property({ type: Boolean, reflect: true, attribute: "data-selected" })
46
- ], AutocompleteItem.prototype, "selected", 2);
47
- __decorateClass([
48
- property({ attribute: false })
49
- ], AutocompleteItem.prototype, "onSelect", 2);
50
- __decorateClass([
51
- consume({ context: commandListContext, subscribe: true }),
52
- state({})
53
- ], AutocompleteItem.prototype, "listContext", 2);
54
- AutocompleteItem = __decorateClass([
55
- customElement("prosekit-autocomplete-item")
56
- ], AutocompleteItem);
57
-
58
- export {
59
- propNames,
60
- AutocompleteItem
61
- };
@@ -1,31 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __decorateClass = (decorators, target, key, kind) => {
4
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
- if (decorator = decorators[i])
7
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result)
9
- __defProp(target, key, result);
10
- return result;
11
- };
12
-
13
- // src/components/block-element/index.ts
14
- import { LitElement } from "lit";
15
- var LightElement = class extends LitElement {
16
- createRenderRoot() {
17
- return this;
18
- }
19
- setHidden(hidden) {
20
- if (this.hidden !== hidden) {
21
- this.hidden = hidden;
22
- const display = this.style.display;
23
- this.style.display = hidden ? "none" : display === "none" ? "" : display;
24
- }
25
- }
26
- };
27
-
28
- export {
29
- __decorateClass,
30
- LightElement
31
- };