@prosekit/lit 0.0.9 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_tsup-dts-rollup.d.ts +469 -0
- package/dist/{chunk-J73E7P6J.js → chunk-3UDA5JEW.js} +2 -9
- package/dist/{chunk-37EPOFI5.js → chunk-AWQAU2JR.js} +5 -3
- package/dist/chunk-BMDOOASL.js +57 -0
- package/dist/chunk-DYEHERSG.js +9 -0
- package/dist/chunk-G5KPDHDH.js +120 -0
- package/dist/chunk-HMV7TD6T.js +9 -0
- package/dist/{chunk-HPMQEYGA.js → chunk-KGZID7N7.js} +61 -92
- package/dist/chunk-PCXKL6TA.js +109 -0
- package/dist/chunk-TRZW33VF.js +35 -0
- package/dist/prosekit-lit-components-autocomplete-empty.d.ts +3 -17
- package/dist/prosekit-lit-components-autocomplete-empty.js +5 -3
- package/dist/prosekit-lit-components-autocomplete-item.d.ts +3 -32
- package/dist/prosekit-lit-components-autocomplete-item.js +3 -2
- package/dist/prosekit-lit-components-autocomplete-list.d.ts +3 -43
- package/dist/prosekit-lit-components-autocomplete-list.js +5 -3
- package/dist/prosekit-lit-components-autocomplete-popover.d.ts +4 -47
- package/dist/prosekit-lit-components-autocomplete-popover.js +23 -139
- package/dist/prosekit-lit-components-code-block-popover.d.ts +3 -0
- package/dist/prosekit-lit-components-code-block-popover.js +141 -0
- package/dist/prosekit-lit-components-combo-box-input.d.ts +3 -0
- package/dist/prosekit-lit-components-combo-box-input.js +74 -0
- package/dist/prosekit-lit-components-combo-box-item.d.ts +3 -0
- package/dist/prosekit-lit-components-combo-box-item.js +11 -0
- package/dist/prosekit-lit-components-combo-box-list.d.ts +3 -0
- package/dist/prosekit-lit-components-combo-box-list.js +50 -0
- package/dist/prosekit-lit-components-combo-box.d.ts +3 -0
- package/dist/prosekit-lit-components-combo-box.js +111 -0
- package/dist/prosekit-lit.d.ts +1 -2
- package/package.json +47 -7
- package/dist/context-19474449.d.ts +0 -7
- package/dist/context-436a56d3.d.ts +0 -8
@@ -1,137 +1,21 @@
|
|
1
1
|
import {
|
2
2
|
commandPopoverContext
|
3
|
-
} from "./chunk-
|
4
|
-
import "./chunk-
|
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-
|
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
|
134
|
-
import { customElement
|
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
|
199
|
-
this.onChange(
|
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
|
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(
|
305
|
-
if (this.context.query ===
|
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:
|
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
|
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
|
-
|
221
|
+
property({ attribute: false })
|
338
222
|
], AutocompletePopover.prototype, "editor", 2);
|
339
223
|
__decorateClass([
|
340
|
-
|
224
|
+
property({ attribute: false })
|
341
225
|
], AutocompletePopover.prototype, "regex", 2);
|
342
226
|
__decorateClass([
|
343
|
-
|
227
|
+
property({ attribute: false })
|
344
228
|
], AutocompletePopover.prototype, "popoverOptions", 2);
|
345
229
|
__decorateClass([
|
346
230
|
provide({ context: commandPopoverContext }),
|
347
|
-
|
231
|
+
state()
|
348
232
|
], AutocompletePopover.prototype, "context", 2);
|
349
233
|
__decorateClass([
|
350
|
-
|
234
|
+
property({ attribute: false })
|
351
235
|
], AutocompletePopover.prototype, "onSelect", 2);
|
352
236
|
__decorateClass([
|
353
|
-
|
237
|
+
query("slot")
|
354
238
|
], AutocompletePopover.prototype, "defaultSlot", 2);
|
355
239
|
AutocompletePopover = __decorateClass([
|
356
|
-
|
240
|
+
customElement("prosekit-autocomplete-popover")
|
357
241
|
], AutocompletePopover);
|
358
242
|
export {
|
359
243
|
AutocompletePopover,
|
@@ -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(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,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,50 @@
|
|
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-list/component.ts
|
12
|
+
import { consume } from "@lit-labs/context";
|
13
|
+
import { customElement, state } from "lit/decorators.js";
|
14
|
+
var propNames = [];
|
15
|
+
var ComboBoxList = class extends LightBlockElement {
|
16
|
+
constructor() {
|
17
|
+
super(...arguments);
|
18
|
+
this.comboBoxContext = null;
|
19
|
+
}
|
20
|
+
connectedCallback() {
|
21
|
+
super.connectedCallback();
|
22
|
+
this.addEventListener("mousemove", (event) => {
|
23
|
+
var _a;
|
24
|
+
(_a = this.comboBoxContext) == null ? void 0 : _a.listManager.handleMouseMove(event);
|
25
|
+
});
|
26
|
+
this.addEventListener("mouseover", (event) => {
|
27
|
+
var _a;
|
28
|
+
(_a = this.comboBoxContext) == null ? void 0 : _a.listManager.handleMouseOver(event);
|
29
|
+
});
|
30
|
+
this.addEventListener("mousedown", (event) => {
|
31
|
+
var _a;
|
32
|
+
(_a = this.comboBoxContext) == null ? void 0 : _a.listManager.handleMouseDown(event);
|
33
|
+
});
|
34
|
+
this.addEventListener("click", (event) => {
|
35
|
+
var _a;
|
36
|
+
(_a = this.comboBoxContext) == null ? void 0 : _a.listManager.handleClick(event);
|
37
|
+
});
|
38
|
+
}
|
39
|
+
};
|
40
|
+
__decorateClass([
|
41
|
+
consume({ context: comboBoxContext, subscribe: true }),
|
42
|
+
state()
|
43
|
+
], ComboBoxList.prototype, "comboBoxContext", 2);
|
44
|
+
ComboBoxList = __decorateClass([
|
45
|
+
customElement("prosekit-combo-box-list")
|
46
|
+
], ComboBoxList);
|
47
|
+
export {
|
48
|
+
ComboBoxList,
|
49
|
+
propNames
|
50
|
+
};
|
@@ -0,0 +1,111 @@
|
|
1
|
+
import "./chunk-BMDOOASL.js";
|
2
|
+
import {
|
3
|
+
ListManager
|
4
|
+
} from "./chunk-PCXKL6TA.js";
|
5
|
+
import {
|
6
|
+
Popover
|
7
|
+
} from "./chunk-G5KPDHDH.js";
|
8
|
+
import {
|
9
|
+
comboBoxContext
|
10
|
+
} from "./chunk-HMV7TD6T.js";
|
11
|
+
import "./chunk-TRZW33VF.js";
|
12
|
+
import {
|
13
|
+
__decorateClass
|
14
|
+
} from "./chunk-3UDA5JEW.js";
|
15
|
+
|
16
|
+
// src/components/combo-box/index.ts
|
17
|
+
import { provide } from "@lit-labs/context";
|
18
|
+
import { customElement, property, state } from "lit/decorators.js";
|
19
|
+
|
20
|
+
// src/components/combo-box-item/helpers.ts
|
21
|
+
function isComboBoxItem(element) {
|
22
|
+
var _a;
|
23
|
+
return ((_a = element == null ? void 0 : element.tagName) == null ? void 0 : _a.toLowerCase()) === "prosekit-combo-box-item";
|
24
|
+
}
|
25
|
+
function queryClosestComboBoxItem(element) {
|
26
|
+
if (!element) {
|
27
|
+
return null;
|
28
|
+
}
|
29
|
+
if (isComboBoxItem(element)) {
|
30
|
+
return element;
|
31
|
+
}
|
32
|
+
const item = element.closest("prosekit-combo-box-item");
|
33
|
+
if (isComboBoxItem(item)) {
|
34
|
+
return item;
|
35
|
+
}
|
36
|
+
return null;
|
37
|
+
}
|
38
|
+
|
39
|
+
// src/components/combo-box/index.ts
|
40
|
+
var propNames = ["onDismiss"];
|
41
|
+
var ComboBox = class extends Popover {
|
42
|
+
constructor() {
|
43
|
+
super(...arguments);
|
44
|
+
this.listManager = new ListManager({
|
45
|
+
getItems: () => {
|
46
|
+
return this.items;
|
47
|
+
},
|
48
|
+
getSelectedValue: () => {
|
49
|
+
var _a;
|
50
|
+
return ((_a = this.context.selectedValue) != null ? _a : "").trim();
|
51
|
+
},
|
52
|
+
setSelectedValue: (value) => {
|
53
|
+
return this.context.setSelectedValue(value);
|
54
|
+
},
|
55
|
+
getItemValue: (item) => {
|
56
|
+
var _a;
|
57
|
+
return ((_a = item.textContent) != null ? _a : "").trim();
|
58
|
+
},
|
59
|
+
queryClosestItem: queryClosestComboBoxItem,
|
60
|
+
getActive: () => {
|
61
|
+
return true;
|
62
|
+
},
|
63
|
+
onDismiss: () => {
|
64
|
+
var _a;
|
65
|
+
(_a = this.onDismiss) == null ? void 0 : _a.call(this);
|
66
|
+
},
|
67
|
+
onSelect: (item) => {
|
68
|
+
var _a, _b;
|
69
|
+
this.context.setSelectedValue("");
|
70
|
+
this.context.setInputValue("");
|
71
|
+
(_a = item == null ? void 0 : item.onSelect) == null ? void 0 : _a.call(item);
|
72
|
+
(_b = this.onDismiss) == null ? void 0 : _b.call(this);
|
73
|
+
}
|
74
|
+
});
|
75
|
+
this.context = {
|
76
|
+
inputValue: "",
|
77
|
+
setInputValue: (inputValue) => {
|
78
|
+
if (this.context.inputValue === inputValue) {
|
79
|
+
return;
|
80
|
+
}
|
81
|
+
this.context = { ...this.context, inputValue };
|
82
|
+
},
|
83
|
+
selectedValue: "",
|
84
|
+
setSelectedValue: (selectedValue) => {
|
85
|
+
if (this.context.selectedValue === selectedValue) {
|
86
|
+
return;
|
87
|
+
}
|
88
|
+
this.context = { ...this.context, selectedValue };
|
89
|
+
},
|
90
|
+
listManager: this.listManager
|
91
|
+
};
|
92
|
+
}
|
93
|
+
get items() {
|
94
|
+
const items = this.querySelectorAll("\u220Fprosekit-combo-box-item");
|
95
|
+
return Array.from(items).filter(isComboBoxItem);
|
96
|
+
}
|
97
|
+
};
|
98
|
+
__decorateClass([
|
99
|
+
property({ attribute: false })
|
100
|
+
], ComboBox.prototype, "onDismiss", 2);
|
101
|
+
__decorateClass([
|
102
|
+
provide({ context: comboBoxContext }),
|
103
|
+
state()
|
104
|
+
], ComboBox.prototype, "context", 2);
|
105
|
+
ComboBox = __decorateClass([
|
106
|
+
customElement("prosekit-combo-box")
|
107
|
+
], ComboBox);
|
108
|
+
export {
|
109
|
+
ComboBox,
|
110
|
+
propNames
|
111
|
+
};
|
package/dist/prosekit-lit.d.ts
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
export { }
|
1
|
+
export {};
|