@prosekit/lit 0.2.7 → 0.3.0

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 (46) hide show
  1. package/dist/_tsup-dts-rollup.d.ts +27 -1088
  2. package/dist/prosekit-lit-autocomplete.d.ts +4 -0
  3. package/dist/prosekit-lit-autocomplete.js +11 -0
  4. package/dist/prosekit-lit-block-handle.d.ts +2 -0
  5. package/dist/prosekit-lit-block-handle.js +7 -0
  6. package/dist/prosekit-lit-inline-popover.d.ts +0 -3
  7. package/dist/prosekit-lit-inline-popover.js +2 -190
  8. package/dist/prosekit-lit-popover.d.ts +3 -6
  9. package/dist/prosekit-lit-popover.js +7 -8
  10. package/dist/prosekit-lit-resizable.d.ts +2 -3
  11. package/dist/prosekit-lit-resizable.js +5 -108
  12. package/dist/prosekit-lit-tooltip.d.ts +3 -0
  13. package/dist/prosekit-lit-tooltip.js +9 -0
  14. package/package.json +24 -95
  15. package/dist/chunk-3AZDRLDR.js +0 -39
  16. package/dist/chunk-3TPE2GKD.js +0 -51
  17. package/dist/chunk-5CI65R73.js +0 -9
  18. package/dist/chunk-C4MW43I4.js +0 -9
  19. package/dist/chunk-CPC45JQ7.js +0 -202
  20. package/dist/chunk-I5EMQRE4.js +0 -60
  21. package/dist/chunk-MZAHIYA5.js +0 -114
  22. package/dist/chunk-S72UTR5M.js +0 -9
  23. package/dist/chunk-WEUGKLVB.js +0 -9
  24. package/dist/chunk-XHBZNZ2L.js +0 -369
  25. package/dist/prosekit-lit-autocomplete-empty.d.ts +0 -3
  26. package/dist/prosekit-lit-autocomplete-empty.js +0 -44
  27. package/dist/prosekit-lit-autocomplete-item.d.ts +0 -3
  28. package/dist/prosekit-lit-autocomplete-item.js +0 -10
  29. package/dist/prosekit-lit-autocomplete-list.d.ts +0 -3
  30. package/dist/prosekit-lit-autocomplete-list.js +0 -12
  31. package/dist/prosekit-lit-autocomplete-popover.d.ts +0 -4
  32. package/dist/prosekit-lit-autocomplete-popover.js +0 -199
  33. package/dist/prosekit-lit-block-popover.d.ts +0 -3
  34. package/dist/prosekit-lit-block-popover.js +0 -169
  35. package/dist/prosekit-lit-combo-box-input.d.ts +0 -3
  36. package/dist/prosekit-lit-combo-box-input.js +0 -92
  37. package/dist/prosekit-lit-combo-box-item.d.ts +0 -3
  38. package/dist/prosekit-lit-combo-box-item.js +0 -10
  39. package/dist/prosekit-lit-combo-box-list.d.ts +0 -3
  40. package/dist/prosekit-lit-combo-box-list.js +0 -44
  41. package/dist/prosekit-lit-combo-box.d.ts +0 -3
  42. package/dist/prosekit-lit-combo-box.js +0 -130
  43. package/dist/prosekit-lit-drag-handle.d.ts +0 -3
  44. package/dist/prosekit-lit-drag-handle.js +0 -94
  45. package/dist/prosekit-lit-resizable-handle.d.ts +0 -3
  46. package/dist/prosekit-lit-resizable-handle.js +0 -159
@@ -1,159 +0,0 @@
1
- import {
2
- resizableContext
3
- } from "./chunk-WEUGKLVB.js";
4
- import {
5
- LightElement,
6
- defineCustomElement
7
- } from "./chunk-3AZDRLDR.js";
8
-
9
- // src/components/resizable-handle/component.ts
10
- import { ContextConsumer } from "@lit/context";
11
-
12
- // src/utils/is-finite-positive-number.ts
13
- function isFinitePositiveNumber(value) {
14
- return typeof value === "number" && Number.isFinite(value) && value > 0;
15
- }
16
-
17
- // src/components/resizable-handle/calc-resize.ts
18
- function calcResize(position, w, h, dx, dy, aspectRatio) {
19
- aspectRatio = aspectRatio ? aspectRatio : w / h;
20
- aspectRatio = isFinitePositiveNumber(aspectRatio) ? aspectRatio : 1;
21
- switch (position) {
22
- case "bottom-right":
23
- return calcBottomRightResize(w, h, dx, dy, aspectRatio);
24
- case "bottom-left":
25
- return calcBottomLeftResize(w, h, dx, dy, aspectRatio);
26
- case "top-right":
27
- return calcTopRightResize(w, h, dx, dy, aspectRatio);
28
- case "top-left":
29
- return calcTopLeftResize(w, h, dx, dy, aspectRatio);
30
- case "top":
31
- return calcTopResize(w, h, dx, dy, aspectRatio);
32
- case "right":
33
- return calcRightResize(w, h, dx, dy, aspectRatio);
34
- case "bottom":
35
- return calcBottomResize(w, h, dx, dy, aspectRatio);
36
- case "left":
37
- return calcLeftResize(w, h, dx, dy, aspectRatio);
38
- default:
39
- throw new RangeError(`Invalid position: ${position}`);
40
- }
41
- }
42
- var calcBottomRightResize = (w, h, dx, dy, r) => {
43
- w += dx;
44
- h += dy;
45
- const sum = w + h;
46
- h = sum / (r + 1);
47
- w = sum - h;
48
- return [w, h];
49
- };
50
- var calcBottomLeftResize = (w, h, dx, dy, r) => {
51
- w -= dx;
52
- h += dy;
53
- const sum = w + h;
54
- h = sum / (r + 1);
55
- w = sum - h;
56
- return [w, h];
57
- };
58
- var calcTopRightResize = (w, h, dx, dy, r) => {
59
- w += dx;
60
- h -= dy;
61
- const sum = w + h;
62
- h = sum / (r + 1);
63
- w = sum - h;
64
- return [w, h];
65
- };
66
- var calcTopLeftResize = (w, h, dx, dy, r) => {
67
- w -= dx;
68
- h -= dy;
69
- const sum = w + h;
70
- h = sum / (r + 1);
71
- w = sum - h;
72
- return [w, h];
73
- };
74
- var calcTopResize = (w, h, dx, dy, r) => {
75
- h -= dy;
76
- w = h * r;
77
- return [w, h];
78
- };
79
- var calcRightResize = (w, h, dx, dy, r) => {
80
- w += dx;
81
- h = w / r;
82
- return [w, h];
83
- };
84
- var calcBottomResize = (w, h, dx, dy, r) => {
85
- h += dy;
86
- w = h * r;
87
- return [w, h];
88
- };
89
- var calcLeftResize = (w, h, dx, dy, r) => {
90
- w -= dx;
91
- h = w / r;
92
- return [w, h];
93
- };
94
-
95
- // src/components/resizable-handle/component.ts
96
- var propNames = [];
97
- var ResizableHandle = class extends LightElement {
98
- constructor() {
99
- super(...arguments);
100
- this.context = new ContextConsumer(this, {
101
- context: resizableContext
102
- });
103
- }
104
- connectedCallback() {
105
- super.connectedCallback();
106
- let startX = 0;
107
- let startY = 0;
108
- let width = 0;
109
- let height = 0;
110
- let aspectRatio = 1;
111
- const handlePointerMove = (event) => {
112
- var _a;
113
- event.preventDefault();
114
- const dx = event.x - startX;
115
- const dy = event.y - startY;
116
- const [w, h] = calcResize(
117
- this.position || "bottom-right",
118
- width,
119
- height,
120
- dx,
121
- dy,
122
- aspectRatio
123
- );
124
- (_a = this.context.value) == null ? void 0 : _a.onResize(w, h);
125
- };
126
- const handlePointerDown = (event) => {
127
- var _a;
128
- event.preventDefault();
129
- startX = event.x;
130
- startY = event.y;
131
- const size = (_a = this.context.value) == null ? void 0 : _a.onResizeStart();
132
- if (size) {
133
- ;
134
- [width, height, aspectRatio] = size;
135
- }
136
- this.ownerDocument.addEventListener("pointermove", handlePointerMove);
137
- this.ownerDocument.addEventListener("pointerup", handlePointerUp);
138
- };
139
- const handlePointerUp = (event) => {
140
- var _a;
141
- event.preventDefault();
142
- (_a = this.context.value) == null ? void 0 : _a.onResizeEnd();
143
- this.ownerDocument.removeEventListener("pointermove", handlePointerMove);
144
- this.ownerDocument.removeEventListener("pointerup", handlePointerUp);
145
- };
146
- this.addEventListener("pointerdown", handlePointerDown);
147
- }
148
- };
149
- /**
150
- * @hidden
151
- */
152
- ResizableHandle.properties = {
153
- position: { attribute: false }
154
- };
155
- defineCustomElement("prosekit-resizable-handle", ResizableHandle);
156
- export {
157
- ResizableHandle,
158
- propNames
159
- };