@prosekit/lit 0.0.0-next-20230709090937 → 0.0.0-next-20231120040948
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 +456 -0
- package/dist/chunk-55G7TJI3.js +48 -0
- package/dist/chunk-6P3YKUWI.js +9 -0
- package/dist/chunk-7WLKD2U6.js +184 -0
- package/dist/chunk-C4MW43I4.js +9 -0
- package/dist/chunk-GWGDLLFN.js +61 -0
- package/dist/{chunk-43BFWKM2.js → chunk-O5JP3B34.js} +15 -10
- package/dist/chunk-PCXKL6TA.js +109 -0
- package/dist/chunk-XBNMYITV.js +191 -0
- package/dist/prosekit-lit-autocomplete-empty.d.ts +3 -0
- package/dist/prosekit-lit-autocomplete-empty.js +44 -0
- package/dist/prosekit-lit-autocomplete-item.d.ts +3 -0
- package/dist/prosekit-lit-autocomplete-item.js +10 -0
- package/dist/prosekit-lit-autocomplete-list.d.ts +3 -0
- package/dist/prosekit-lit-autocomplete-list.js +12 -0
- package/dist/prosekit-lit-autocomplete-popover.d.ts +4 -0
- package/dist/prosekit-lit-autocomplete-popover.js +252 -0
- package/dist/prosekit-lit-combo-box-input.d.ts +3 -0
- package/dist/prosekit-lit-combo-box-input.js +72 -0
- package/dist/prosekit-lit-combo-box-item.d.ts +3 -0
- package/dist/prosekit-lit-combo-box-item.js +10 -0
- package/dist/prosekit-lit-combo-box-list.d.ts +3 -0
- package/dist/prosekit-lit-combo-box-list.js +48 -0
- package/dist/prosekit-lit-combo-box.d.ts +3 -0
- package/dist/prosekit-lit-combo-box.js +110 -0
- package/dist/prosekit-lit-inline-popover.d.ts +4 -0
- package/dist/prosekit-lit-inline-popover.js +154 -0
- package/dist/prosekit-lit-popover.d.ts +5 -0
- package/dist/prosekit-lit-popover.js +9 -0
- package/dist/prosekit-lit.d.ts +1 -2
- package/package.json +85 -38
- package/src/index.ts +0 -4
- package/dist/chunk-6FOWUXQ2.js +0 -26
- package/dist/chunk-7C2I5DWH.js +0 -122
- package/dist/chunk-WHIPWT4H.js +0 -122
- package/dist/options-7235df55.d.ts +0 -14
- package/dist/prosekit-lit-elements-menu-item.d.ts +0 -16
- package/dist/prosekit-lit-elements-menu-item.js +0 -37
- package/dist/prosekit-lit-elements-menu.d.ts +0 -50
- package/dist/prosekit-lit-elements-menu.js +0 -169
- package/dist/prosekit-lit-elements-popover-suggestion.d.ts +0 -59
- package/dist/prosekit-lit-elements-popover-suggestion.js +0 -218
- package/dist/prosekit-lit-elements-popover.d.ts +0 -65
- package/dist/prosekit-lit-elements-popover.js +0 -7
@@ -0,0 +1,456 @@
|
|
1
|
+
import { AutoUpdateOptions } from '@floating-ui/dom';
|
2
|
+
import { ComputePositionConfig } from '@floating-ui/dom';
|
3
|
+
import { CSSResult } from 'lit';
|
4
|
+
import { Editor } from '@prosekit/core';
|
5
|
+
import type { EditorView } from '@prosekit/pm/view';
|
6
|
+
import { Keymap } from '@prosekit/core';
|
7
|
+
import { LitElement } from 'lit';
|
8
|
+
import { Options } from 'tsup';
|
9
|
+
import { PropertyValues } from 'lit';
|
10
|
+
import { ReactiveController } from 'lit';
|
11
|
+
import { ReactiveControllerHost } from 'lit';
|
12
|
+
import { TemplateResult } from 'lit';
|
13
|
+
import { UserProjectConfigExport } from 'vitest/dist/config.js';
|
14
|
+
import { VirtualElement } from '@floating-ui/dom';
|
15
|
+
|
16
|
+
export declare class AutocompleteEmpty extends LightElement implements AutocompleteEmptyProps {
|
17
|
+
listContext?: AutocompleteListContext;
|
18
|
+
connectedCallback(): void;
|
19
|
+
protected willUpdate(_changedProperties: PropertyValues<this>): void;
|
20
|
+
}
|
21
|
+
|
22
|
+
export declare interface AutocompleteEmptyProps {
|
23
|
+
}
|
24
|
+
|
25
|
+
/**
|
26
|
+
* Command menu item. Becomes active on pointer enter or through keyboard
|
27
|
+
* navigation. Preferably pass a `value`, otherwise the value will be inferred
|
28
|
+
* from the rendered item's `textContent`.
|
29
|
+
*/
|
30
|
+
declare class AutocompleteItem extends LightElement implements Partial<AutocompleteItemProps> {
|
31
|
+
value: string;
|
32
|
+
selected: boolean;
|
33
|
+
/** @hidden */
|
34
|
+
onSelect?: VoidFunction;
|
35
|
+
listContext?: AutocompleteListContext;
|
36
|
+
get content(): string;
|
37
|
+
connectedCallback(): void;
|
38
|
+
protected willUpdate(): void;
|
39
|
+
protected updated(changedProperties: PropertyValues<this>): void;
|
40
|
+
}
|
41
|
+
export { AutocompleteItem }
|
42
|
+
export { AutocompleteItem as AutocompleteItem_alias_1 }
|
43
|
+
|
44
|
+
declare interface AutocompleteItemProps {
|
45
|
+
value?: string;
|
46
|
+
onSelect: VoidFunction;
|
47
|
+
}
|
48
|
+
export { AutocompleteItemProps }
|
49
|
+
export { AutocompleteItemProps as AutocompleteItemProps_alias_1 }
|
50
|
+
|
51
|
+
declare class AutocompleteList extends LightElement implements Partial<AutocompleteListProps> {
|
52
|
+
/** @hidden */
|
53
|
+
private listManager;
|
54
|
+
/** @hidden */
|
55
|
+
private controller;
|
56
|
+
private get active();
|
57
|
+
editor?: Editor;
|
58
|
+
popoverContext: AutocompletePopoverContext | null;
|
59
|
+
context: AutocompleteListContext;
|
60
|
+
connectedCallback(): void;
|
61
|
+
private get items();
|
62
|
+
selectFirstItem(): void;
|
63
|
+
private updateValue;
|
64
|
+
/** @hidden */
|
65
|
+
willUpdate(changedProperties: PropertyValues<this>): void;
|
66
|
+
}
|
67
|
+
export { AutocompleteList }
|
68
|
+
export { AutocompleteList as AutocompleteList_alias_1 }
|
69
|
+
|
70
|
+
export declare interface AutocompleteListContext {
|
71
|
+
scores: Map<string, number>;
|
72
|
+
selectedValue: string;
|
73
|
+
}
|
74
|
+
|
75
|
+
export declare class AutocompleteListController implements ReactiveController {
|
76
|
+
private host;
|
77
|
+
private keymap;
|
78
|
+
private editor;
|
79
|
+
private cleanup;
|
80
|
+
constructor(host: ReactiveControllerHost, keymap: Keymap);
|
81
|
+
setEditor(editor: Editor): void;
|
82
|
+
hostDisconnected(): void;
|
83
|
+
private defineExtension;
|
84
|
+
}
|
85
|
+
|
86
|
+
declare interface AutocompleteListProps {
|
87
|
+
editor: Editor;
|
88
|
+
}
|
89
|
+
export { AutocompleteListProps }
|
90
|
+
export { AutocompleteListProps as AutocompleteListProps_alias_1 }
|
91
|
+
|
92
|
+
export declare class AutocompletePopover extends Popover implements Partial<AutocompletePopoverProps> {
|
93
|
+
/** @hidden */
|
94
|
+
private controller;
|
95
|
+
editor?: Editor;
|
96
|
+
regex?: RegExp;
|
97
|
+
popoverOptions: PopoverOptions;
|
98
|
+
context: AutocompletePopoverContext;
|
99
|
+
/** @hidden */
|
100
|
+
onSelect?: VoidFunction;
|
101
|
+
private get list();
|
102
|
+
private updateContext;
|
103
|
+
/** @hidden */
|
104
|
+
willUpdate(changedProperties: PropertyValues<this>): void;
|
105
|
+
/** @hidden */
|
106
|
+
hide(): void;
|
107
|
+
}
|
108
|
+
|
109
|
+
export declare interface AutocompletePopoverContext {
|
110
|
+
active: boolean;
|
111
|
+
query: string;
|
112
|
+
handleDismiss: VoidFunction;
|
113
|
+
handleSubmit: VoidFunction;
|
114
|
+
}
|
115
|
+
|
116
|
+
export declare class AutocompletePopoverController implements ReactiveController {
|
117
|
+
private host;
|
118
|
+
private onChange;
|
119
|
+
reference: Element | null;
|
120
|
+
private editor;
|
121
|
+
private regex;
|
122
|
+
private cleanup;
|
123
|
+
handleDismiss: VoidFunction | null;
|
124
|
+
handleSubmit: VoidFunction | null;
|
125
|
+
constructor(host: ReactiveControllerHost, onChange: (query: string, active: boolean) => void);
|
126
|
+
setEditor(editor: Editor): void;
|
127
|
+
setRegex(regex: RegExp): void;
|
128
|
+
private defineExtension;
|
129
|
+
hostDisconnected(): void;
|
130
|
+
}
|
131
|
+
|
132
|
+
export declare interface AutocompletePopoverProps {
|
133
|
+
editor: Editor;
|
134
|
+
regex: RegExp;
|
135
|
+
popoverOptions?: PopoverOptions;
|
136
|
+
}
|
137
|
+
|
138
|
+
export { AutoUpdateOptions }
|
139
|
+
|
140
|
+
export declare const blockComponentStyles: CSSResult;
|
141
|
+
|
142
|
+
export declare class ComboBox extends Popover {
|
143
|
+
onDismiss?: VoidFunction;
|
144
|
+
private listManager;
|
145
|
+
context: ComboBoxContext;
|
146
|
+
get items(): ComboBoxItem[];
|
147
|
+
}
|
148
|
+
|
149
|
+
export declare interface ComboBoxContext {
|
150
|
+
inputValue: string;
|
151
|
+
setInputValue: (val: string) => void;
|
152
|
+
selectedValue: string;
|
153
|
+
setSelectedValue: (val: string) => void;
|
154
|
+
listManager: ListManager<ComboBoxItem>;
|
155
|
+
}
|
156
|
+
|
157
|
+
export declare const comboBoxContext: {
|
158
|
+
__context__: ComboBoxContext;
|
159
|
+
};
|
160
|
+
|
161
|
+
export declare class ComboBoxInput extends LightElement {
|
162
|
+
placeholder: string;
|
163
|
+
comboBoxContext: ComboBoxContext | null;
|
164
|
+
private visible;
|
165
|
+
private handleKeydown;
|
166
|
+
private handleInput;
|
167
|
+
protected firstUpdated(): void;
|
168
|
+
/** @hidden */
|
169
|
+
render(): TemplateResult<1>;
|
170
|
+
}
|
171
|
+
|
172
|
+
export declare interface ComboBoxInputProps {
|
173
|
+
placeholder?: string;
|
174
|
+
}
|
175
|
+
|
176
|
+
declare class ComboBoxItem extends LightElement {
|
177
|
+
editor?: Editor;
|
178
|
+
selected: boolean;
|
179
|
+
comboBoxContext?: ComboBoxContext;
|
180
|
+
/** @hidden */
|
181
|
+
onSelect?: VoidFunction;
|
182
|
+
protected updated(): void;
|
183
|
+
}
|
184
|
+
export { ComboBoxItem }
|
185
|
+
export { ComboBoxItem as ComboBoxItem_alias_1 }
|
186
|
+
|
187
|
+
declare type ComboBoxItemProps = {
|
188
|
+
onSelect?: VoidFunction;
|
189
|
+
};
|
190
|
+
export { ComboBoxItemProps }
|
191
|
+
export { ComboBoxItemProps as ComboBoxItemProps_alias_1 }
|
192
|
+
|
193
|
+
declare class ComboBoxList extends LightElement {
|
194
|
+
comboBoxContext: ComboBoxContext | null;
|
195
|
+
connectedCallback(): void;
|
196
|
+
}
|
197
|
+
export { ComboBoxList }
|
198
|
+
export { ComboBoxList as ComboBoxList_alias_1 }
|
199
|
+
|
200
|
+
declare type ComboBoxListProps = {
|
201
|
+
lang?: string;
|
202
|
+
};
|
203
|
+
export { ComboBoxListProps }
|
204
|
+
export { ComboBoxListProps as ComboBoxListProps_alias_1 }
|
205
|
+
|
206
|
+
export declare interface ComboBoxProps extends PopoverProps {
|
207
|
+
onDismiss?: VoidFunction;
|
208
|
+
}
|
209
|
+
|
210
|
+
export declare const commandListContext: {
|
211
|
+
__context__: AutocompleteListContext;
|
212
|
+
};
|
213
|
+
|
214
|
+
export declare const commandPopoverContext: {
|
215
|
+
__context__: AutocompletePopoverContext;
|
216
|
+
};
|
217
|
+
|
218
|
+
declare type CommandScore = (item: string, query: string) => number;
|
219
|
+
|
220
|
+
export declare const commandScore: CommandScore;
|
221
|
+
|
222
|
+
export declare const componentStyles: CSSResult;
|
223
|
+
|
224
|
+
export declare const default_alias: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
|
225
|
+
|
226
|
+
export declare const default_alias_1: UserProjectConfigExport;
|
227
|
+
|
228
|
+
/**
|
229
|
+
* Default popover options.
|
230
|
+
*/
|
231
|
+
export declare const defaultPopoverOptions: PopoverOptions;
|
232
|
+
|
233
|
+
/**
|
234
|
+
* Default popover options.
|
235
|
+
*/
|
236
|
+
export declare const defaultPopoverOptions_alias_1: PopoverOptions;
|
237
|
+
|
238
|
+
export declare const defaultPopoverOptions_alias_2: PopoverOptions;
|
239
|
+
|
240
|
+
export declare function defaultQueryBuilder(match: RegExpExecArray): string;
|
241
|
+
|
242
|
+
export declare function getVirtualSelectionElement(view: EditorView): Range | undefined;
|
243
|
+
|
244
|
+
export declare class InlinePopover extends Popover implements Partial<InlinePopoverProps> {
|
245
|
+
/** @hidden */
|
246
|
+
private controller;
|
247
|
+
editor?: Editor;
|
248
|
+
popoverOptions: PopoverOptions;
|
249
|
+
constructor();
|
250
|
+
/** @hidden */
|
251
|
+
willUpdate(): void;
|
252
|
+
/** @hidden */
|
253
|
+
hide(): void;
|
254
|
+
}
|
255
|
+
|
256
|
+
export declare class InlinePopoverController implements ReactiveController {
|
257
|
+
private host;
|
258
|
+
reference?: VirtualElement;
|
259
|
+
private editor?;
|
260
|
+
private cleanupExtension?;
|
261
|
+
private cleanupEventListener?;
|
262
|
+
private mouseHovering;
|
263
|
+
constructor(host: ReactiveControllerHost);
|
264
|
+
setEditor(editor: Editor): void;
|
265
|
+
hostConnected(): void;
|
266
|
+
hostDisconnected(): void;
|
267
|
+
private update;
|
268
|
+
private defineExtension;
|
269
|
+
}
|
270
|
+
|
271
|
+
export declare interface InlinePopoverProps {
|
272
|
+
editor: Editor;
|
273
|
+
popoverOptions?: PopoverOptions;
|
274
|
+
}
|
275
|
+
|
276
|
+
export declare function isAutocompleteItem(element?: Element | null): element is AutocompleteItem;
|
277
|
+
|
278
|
+
export declare function isAutocompleteList(element?: Element | null): element is AutocompleteList;
|
279
|
+
|
280
|
+
export declare function isComboBoxItem(element?: Element | null): element is ComboBoxItem;
|
281
|
+
|
282
|
+
export declare function isComboBoxList(element?: Element | null): element is ComboBoxList;
|
283
|
+
|
284
|
+
export declare class LightElement extends LitElement {
|
285
|
+
createRenderRoot(): this;
|
286
|
+
setHidden(hidden: boolean): void;
|
287
|
+
}
|
288
|
+
|
289
|
+
export declare class ListManager<Item extends {
|
290
|
+
hidden: boolean;
|
291
|
+
} & HTMLElement> {
|
292
|
+
private lastMouseMoveTime;
|
293
|
+
private getItems;
|
294
|
+
private getSelectedValue;
|
295
|
+
private setSelectedValue;
|
296
|
+
private getItemValue;
|
297
|
+
private queryClosestItem;
|
298
|
+
private getActive;
|
299
|
+
private onDismiss;
|
300
|
+
private onSelect;
|
301
|
+
constructor(options: {
|
302
|
+
getItems: () => Item[];
|
303
|
+
getSelectedValue: () => string;
|
304
|
+
setSelectedValue: (value: string) => void;
|
305
|
+
getItemValue: (item: Item) => string;
|
306
|
+
queryClosestItem: (element: HTMLElement) => Item | null;
|
307
|
+
getActive: () => boolean;
|
308
|
+
onDismiss: () => void;
|
309
|
+
onSelect: (item?: Item | null) => void;
|
310
|
+
});
|
311
|
+
get items(): Item[];
|
312
|
+
get availableItems(): Item[];
|
313
|
+
get firstItem(): Item | null;
|
314
|
+
get selectedItem(): Item | null;
|
315
|
+
private updateSelectedByChange;
|
316
|
+
private handleSelect;
|
317
|
+
selectFirstItem(): void;
|
318
|
+
handleMouseMove(_event: MouseEvent): void;
|
319
|
+
handleMouseOver(event: MouseEvent): void;
|
320
|
+
handleMouseDown(event: MouseEvent): void;
|
321
|
+
handleClick(event: MouseEvent): void;
|
322
|
+
handleArrowUp(): boolean;
|
323
|
+
handleArrowDown(): boolean;
|
324
|
+
handleEscape(): boolean;
|
325
|
+
handleEnter(): boolean;
|
326
|
+
}
|
327
|
+
|
328
|
+
/**
|
329
|
+
* A custom element that displays a popover anchored to a reference element.
|
330
|
+
*/
|
331
|
+
export declare class Popover extends LightElement implements Partial<PopoverProps> {
|
332
|
+
/** @hidden */
|
333
|
+
constructor();
|
334
|
+
/**
|
335
|
+
* Controls the visibility of the popover element. When set to `true`, the popover is displayed and positioned
|
336
|
+
* relative to its reference element. When set to `false`, the popover is hidden and its positioning logic is
|
337
|
+
* deactivated.
|
338
|
+
*/
|
339
|
+
active: boolean;
|
340
|
+
/**
|
341
|
+
* The element that the popover is anchored to. This can be either a DOM element or an object that implements the
|
342
|
+
* virtual element interface from Floating UI.
|
343
|
+
*/
|
344
|
+
reference?: Element | VirtualElement;
|
345
|
+
/**
|
346
|
+
* The options that are passed to the `computePosition` function from Floating UI. These options are used to
|
347
|
+
* configure the positioning of the popover element relative to its reference element. For more information on the
|
348
|
+
* available options, please refer to the Floating UI documentation.
|
349
|
+
*/
|
350
|
+
options?: PopoverOptions;
|
351
|
+
/**
|
352
|
+
* Controls whether the popover position is automatically updated when the reference element changes position. When
|
353
|
+
* set to `true`, the popover position is updated automatically. When set to `false`, the popover position is only
|
354
|
+
* updated when the given properties are changed.
|
355
|
+
*
|
356
|
+
* @default false
|
357
|
+
*/
|
358
|
+
autoUpdate: boolean;
|
359
|
+
/**
|
360
|
+
* The options that are passed to the `autoUpdate` function from Floating UI. These options are used to configure the
|
361
|
+
* automatic update behavior of the popover position. For more information on the available options, please refer to
|
362
|
+
* the Floating UI documentation. This property is only used when the `autoUpdate` property is set to `true`.
|
363
|
+
*/
|
364
|
+
autoUpdateOptions?: AutoUpdateOptions;
|
365
|
+
/**
|
366
|
+
* Controls whether the popover should be dismissed based on user interaction.
|
367
|
+
*
|
368
|
+
* Available options:
|
369
|
+
*
|
370
|
+
* - "off": The popover is not dismissed.
|
371
|
+
* - "on": The popover is dismissed when the user clicks outside of the popover or presses the escape key.
|
372
|
+
* - "click": The popover is dismissed when the user clicks outside of the popover.
|
373
|
+
* - "escape": The popover is dismissed when the user presses the escape key.
|
374
|
+
*
|
375
|
+
* @default "on"
|
376
|
+
*/
|
377
|
+
dismiss: string;
|
378
|
+
/** @hidden */
|
379
|
+
private disposeAutoUpdate?;
|
380
|
+
/** @hidden */
|
381
|
+
private disposeEventListeners?;
|
382
|
+
/** @hidden */
|
383
|
+
connectedCallback(): void;
|
384
|
+
/** @hidden */
|
385
|
+
disconnectedCallback(): void;
|
386
|
+
/** @hidden */
|
387
|
+
protected updated(changedProperties: PropertyValues<this>): void;
|
388
|
+
/** @hidden */
|
389
|
+
private start;
|
390
|
+
/** @hidden */
|
391
|
+
private compute;
|
392
|
+
/** @hidden */
|
393
|
+
hide(): void;
|
394
|
+
private handleDocumentMouseDown;
|
395
|
+
private handleDocumentKeyDown;
|
396
|
+
}
|
397
|
+
|
398
|
+
/**
|
399
|
+
* The `PopoverOptions` interface defines the options that can be passed to the
|
400
|
+
* `computePosition` function from Floating UI. These options are used to
|
401
|
+
* configure the positioning of the popover element relative to its reference
|
402
|
+
* element. For more information on the available options, please refer to the
|
403
|
+
* Floating UI documentation.
|
404
|
+
*
|
405
|
+
* https://floating-ui.com/docs/computeposition#options
|
406
|
+
*/
|
407
|
+
declare type PopoverOptions = ComputePositionConfig;
|
408
|
+
export { PopoverOptions }
|
409
|
+
export { PopoverOptions as PopoverOptions_alias_1 }
|
410
|
+
export { PopoverOptions as PopoverOptions_alias_2 }
|
411
|
+
export { PopoverOptions as PopoverOptions_alias_3 }
|
412
|
+
|
413
|
+
export declare interface PopoverProps {
|
414
|
+
active: boolean;
|
415
|
+
reference?: Element | VirtualElement;
|
416
|
+
options?: PopoverOptions;
|
417
|
+
autoUpdate?: boolean;
|
418
|
+
autoUpdateOptions?: AutoUpdateOptions;
|
419
|
+
}
|
420
|
+
|
421
|
+
export declare const propNames: readonly [];
|
422
|
+
|
423
|
+
declare const propNames_2: readonly ["value", "onSelect"];
|
424
|
+
export { propNames_2 as propNames_alias_1 }
|
425
|
+
export { propNames_2 as propNames_alias_2 }
|
426
|
+
|
427
|
+
declare const propNames_3: readonly ["editor"];
|
428
|
+
export { propNames_3 as propNames_alias_3 }
|
429
|
+
export { propNames_3 as propNames_alias_4 }
|
430
|
+
|
431
|
+
declare const propNames_4: never[];
|
432
|
+
export { propNames_4 as propNames_alias_8 }
|
433
|
+
export { propNames_4 as propNames_alias_9 }
|
434
|
+
|
435
|
+
declare const propNames_5: never[];
|
436
|
+
export { propNames_5 as propNames_alias_10 }
|
437
|
+
export { propNames_5 as propNames_alias_11 }
|
438
|
+
|
439
|
+
export declare const propNames_alias_12: readonly ["editor", "popoverOptions"];
|
440
|
+
|
441
|
+
export declare const propNames_alias_13: readonly ["active", "reference", "options", "autoUpdate", "autoUpdateOptions"];
|
442
|
+
|
443
|
+
export declare const propNames_alias_5: readonly ["editor", "regex", "popoverOptions"];
|
444
|
+
|
445
|
+
export declare const propNames_alias_6: readonly ["onDismiss"];
|
446
|
+
|
447
|
+
export declare const propNames_alias_7: readonly ["placeholder"];
|
448
|
+
|
449
|
+
export declare function queryClosestAutocompleteItem(element?: Element | null): AutocompleteItem | null;
|
450
|
+
|
451
|
+
export declare function queryClosestComboBoxItem(element?: Element | null): ComboBoxItem | null;
|
452
|
+
|
453
|
+
/** Rounds a value to the nearest device pixel ratio. */
|
454
|
+
export declare function roundByDPR(value: number): number;
|
455
|
+
|
456
|
+
export { }
|
@@ -0,0 +1,48 @@
|
|
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
|
+
};
|
@@ -0,0 +1,184 @@
|
|
1
|
+
import {
|
2
|
+
LightElement,
|
3
|
+
__decorateClass
|
4
|
+
} from "./chunk-O5JP3B34.js";
|
5
|
+
|
6
|
+
// src/components/popover/index.ts
|
7
|
+
import {
|
8
|
+
autoUpdate,
|
9
|
+
computePosition
|
10
|
+
} from "@floating-ui/dom";
|
11
|
+
import { customElement, property } from "lit/decorators.js";
|
12
|
+
|
13
|
+
// src/utils/round-by-dpr.ts
|
14
|
+
function roundByDPR(value) {
|
15
|
+
const dpr = window.devicePixelRatio || 1;
|
16
|
+
return Math.round(value * dpr) / dpr;
|
17
|
+
}
|
18
|
+
|
19
|
+
// src/components/popover/default-popover-options.ts
|
20
|
+
import { offset, shift, size } from "@floating-ui/dom";
|
21
|
+
|
22
|
+
// src/components/popover/options.ts
|
23
|
+
import "@floating-ui/dom";
|
24
|
+
|
25
|
+
// src/components/popover/default-popover-options.ts
|
26
|
+
var defaultPopoverOptions = {
|
27
|
+
placement: "bottom",
|
28
|
+
middleware: [
|
29
|
+
offset({ mainAxis: 8, crossAxis: 8 }),
|
30
|
+
shift({ padding: 8 }),
|
31
|
+
size({
|
32
|
+
apply: ({ availableWidth, availableHeight, elements }) => {
|
33
|
+
elements.floating.style.setProperty(
|
34
|
+
"max-width",
|
35
|
+
`${Math.floor(availableWidth)}px`
|
36
|
+
);
|
37
|
+
elements.floating.style.setProperty(
|
38
|
+
"max-height",
|
39
|
+
`${Math.floor(availableHeight)}px`
|
40
|
+
);
|
41
|
+
},
|
42
|
+
padding: 8
|
43
|
+
})
|
44
|
+
]
|
45
|
+
};
|
46
|
+
|
47
|
+
// src/components/popover/index.ts
|
48
|
+
var propNames = [
|
49
|
+
"active",
|
50
|
+
"reference",
|
51
|
+
"options",
|
52
|
+
"autoUpdate",
|
53
|
+
"autoUpdateOptions"
|
54
|
+
];
|
55
|
+
var Popover = class extends LightElement {
|
56
|
+
/** @hidden */
|
57
|
+
constructor() {
|
58
|
+
super();
|
59
|
+
this.active = false;
|
60
|
+
this.autoUpdate = false;
|
61
|
+
this.dismiss = "on";
|
62
|
+
this.handleDocumentMouseDown = (event) => {
|
63
|
+
const path = event.composedPath();
|
64
|
+
if (!path.includes(this)) {
|
65
|
+
this.hide();
|
66
|
+
}
|
67
|
+
};
|
68
|
+
this.handleDocumentKeyDown = (event) => {
|
69
|
+
if (event.key === "Escape" && this.active) {
|
70
|
+
event.stopPropagation();
|
71
|
+
this.hide();
|
72
|
+
return;
|
73
|
+
}
|
74
|
+
};
|
75
|
+
}
|
76
|
+
/** @hidden */
|
77
|
+
connectedCallback() {
|
78
|
+
super.connectedCallback();
|
79
|
+
const clickEnabled = this.dismiss === "on" || this.dismiss === "click";
|
80
|
+
const escapeEnabled = this.dismiss === "on" || this.dismiss === "escape";
|
81
|
+
const handleMouseDown = clickEnabled ? this.handleDocumentMouseDown.bind(this) : null;
|
82
|
+
const handleKeyDown = escapeEnabled ? this.handleDocumentKeyDown.bind(this) : null;
|
83
|
+
handleMouseDown && document.addEventListener("mousedown", handleMouseDown);
|
84
|
+
handleKeyDown && document.addEventListener("keydown", handleKeyDown);
|
85
|
+
this.disposeEventListeners = () => {
|
86
|
+
handleMouseDown && document.removeEventListener("mousedown", handleMouseDown);
|
87
|
+
handleKeyDown && document.removeEventListener("keydown", handleKeyDown);
|
88
|
+
};
|
89
|
+
}
|
90
|
+
/** @hidden */
|
91
|
+
disconnectedCallback() {
|
92
|
+
var _a, _b;
|
93
|
+
super.disconnectedCallback();
|
94
|
+
(_a = this.disposeAutoUpdate) == null ? void 0 : _a.call(this);
|
95
|
+
this.disposeAutoUpdate = void 0;
|
96
|
+
(_b = this.disposeEventListeners) == null ? void 0 : _b.call(this);
|
97
|
+
this.disposeEventListeners = void 0;
|
98
|
+
}
|
99
|
+
/** @hidden */
|
100
|
+
updated(changedProperties) {
|
101
|
+
super.updated(changedProperties);
|
102
|
+
this.start();
|
103
|
+
this.setHidden(!this.active);
|
104
|
+
}
|
105
|
+
/** @hidden */
|
106
|
+
start() {
|
107
|
+
var _a;
|
108
|
+
(_a = this.disposeAutoUpdate) == null ? void 0 : _a.call(this);
|
109
|
+
this.disposeAutoUpdate = void 0;
|
110
|
+
const reference = this.reference;
|
111
|
+
if (!reference)
|
112
|
+
return;
|
113
|
+
if (!this.active)
|
114
|
+
return;
|
115
|
+
if (this.autoUpdate) {
|
116
|
+
this.disposeAutoUpdate = autoUpdate(
|
117
|
+
reference,
|
118
|
+
this,
|
119
|
+
() => void this.compute(),
|
120
|
+
this.autoUpdateOptions
|
121
|
+
);
|
122
|
+
} else {
|
123
|
+
void this.compute();
|
124
|
+
}
|
125
|
+
}
|
126
|
+
/** @hidden */
|
127
|
+
async compute() {
|
128
|
+
var _a, _b, _c;
|
129
|
+
const reference = this.reference;
|
130
|
+
if (!reference)
|
131
|
+
return;
|
132
|
+
if (!this.active)
|
133
|
+
return;
|
134
|
+
this.setHidden(false);
|
135
|
+
this.style.setProperty("top", "0");
|
136
|
+
this.style.setProperty("left", "0");
|
137
|
+
this.style.setProperty("position", (_b = (_a = this.options) == null ? void 0 : _a.strategy) != null ? _b : "absolute");
|
138
|
+
const options = (_c = this.options) != null ? _c : defaultPopoverOptions;
|
139
|
+
const computed = await computePosition(reference, this, options);
|
140
|
+
const { x, y, strategy } = computed != null ? computed : { x: 0, y: 0, strategy: "absolute" };
|
141
|
+
this.style.setProperty("opacity", "1");
|
142
|
+
this.style.setProperty("position", strategy);
|
143
|
+
this.style.setProperty(
|
144
|
+
"transform",
|
145
|
+
`translate(${roundByDPR(x)}px,${roundByDPR(y)}px)`
|
146
|
+
);
|
147
|
+
}
|
148
|
+
/** @hidden */
|
149
|
+
hide() {
|
150
|
+
this.active = false;
|
151
|
+
}
|
152
|
+
};
|
153
|
+
__decorateClass([
|
154
|
+
property({ type: Boolean, reflect: true })
|
155
|
+
], Popover.prototype, "active", 2);
|
156
|
+
__decorateClass([
|
157
|
+
property({ attribute: false })
|
158
|
+
], Popover.prototype, "reference", 2);
|
159
|
+
__decorateClass([
|
160
|
+
property({ attribute: false })
|
161
|
+
], Popover.prototype, "options", 2);
|
162
|
+
__decorateClass([
|
163
|
+
property({
|
164
|
+
type: Boolean,
|
165
|
+
reflect: true
|
166
|
+
})
|
167
|
+
], Popover.prototype, "autoUpdate", 2);
|
168
|
+
__decorateClass([
|
169
|
+
property({ type: Object })
|
170
|
+
], Popover.prototype, "autoUpdateOptions", 2);
|
171
|
+
__decorateClass([
|
172
|
+
property({
|
173
|
+
type: String,
|
174
|
+
reflect: true
|
175
|
+
})
|
176
|
+
], Popover.prototype, "dismiss", 2);
|
177
|
+
Popover = __decorateClass([
|
178
|
+
customElement("prosekit-popover")
|
179
|
+
], Popover);
|
180
|
+
|
181
|
+
export {
|
182
|
+
propNames,
|
183
|
+
Popover
|
184
|
+
};
|