@prosekit/preact 0.6.8 → 0.7.0-beta.1
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/prosekit-preact-autocomplete.d.ts +226 -18
- package/dist/prosekit-preact-autocomplete.d.ts.map +1 -1
- package/dist/prosekit-preact-autocomplete.js +218 -9
- package/dist/prosekit-preact-autocomplete.js.map +1 -1
- package/dist/prosekit-preact-block-handle.d.ts +210 -14
- package/dist/prosekit-preact-block-handle.d.ts.map +1 -1
- package/dist/prosekit-preact-block-handle.js +184 -7
- package/dist/prosekit-preact-block-handle.js.map +1 -1
- package/dist/prosekit-preact-drop-indicator.d.ts +27 -6
- package/dist/prosekit-preact-drop-indicator.d.ts.map +1 -1
- package/dist/prosekit-preact-drop-indicator.js +38 -3
- package/dist/prosekit-preact-drop-indicator.js.map +1 -1
- package/dist/prosekit-preact-inline-popover.d.ts +204 -8
- package/dist/prosekit-preact-inline-popover.d.ts.map +1 -1
- package/dist/prosekit-preact-inline-popover.js +130 -5
- package/dist/prosekit-preact-inline-popover.js.map +1 -1
- package/dist/prosekit-preact-menu.d.ts +288 -0
- package/dist/prosekit-preact-menu.d.ts.map +1 -0
- package/dist/prosekit-preact-menu.js +274 -0
- package/dist/prosekit-preact-menu.js.map +1 -0
- package/dist/prosekit-preact-popover.d.ts +227 -14
- package/dist/prosekit-preact-popover.d.ts.map +1 -1
- package/dist/prosekit-preact-popover.js +170 -7
- package/dist/prosekit-preact-popover.js.map +1 -1
- package/dist/prosekit-preact-resizable.d.ts +56 -12
- package/dist/prosekit-preact-resizable.d.ts.map +1 -1
- package/dist/prosekit-preact-resizable.js +80 -7
- package/dist/prosekit-preact-resizable.js.map +1 -1
- package/dist/prosekit-preact-table-handle.d.ts +447 -38
- package/dist/prosekit-preact-table-handle.d.ts.map +1 -1
- package/dist/prosekit-preact-table-handle.js +381 -19
- package/dist/prosekit-preact-table-handle.js.map +1 -1
- package/dist/prosekit-preact-tooltip.d.ts +211 -14
- package/dist/prosekit-preact-tooltip.d.ts.map +1 -1
- package/dist/prosekit-preact-tooltip.js +157 -7
- package/dist/prosekit-preact-tooltip.js.map +1 -1
- package/package.json +27 -16
- package/src/components/autocomplete/autocomplete-empty.gen.ts +41 -31
- package/src/components/autocomplete/autocomplete-item.gen.ts +84 -31
- package/src/components/autocomplete/autocomplete-popup.gen.ts +80 -0
- package/src/components/autocomplete/autocomplete-positioner.gen.ts +153 -0
- package/src/components/autocomplete/autocomplete-root.gen.ts +109 -0
- package/src/components/autocomplete/index.gen.ts +12 -4
- package/src/components/autocomplete/index.ts +27 -0
- package/src/components/block-handle/block-handle-add.gen.ts +59 -31
- package/src/components/block-handle/block-handle-draggable.gen.ts +59 -31
- package/src/components/block-handle/block-handle-popup.gen.ts +44 -0
- package/src/components/block-handle/block-handle-positioner.gen.ts +171 -0
- package/src/components/block-handle/block-handle-root.gen.ts +84 -0
- package/src/components/block-handle/index.gen.ts +13 -3
- package/src/components/block-handle/index.ts +27 -0
- package/src/components/drop-indicator/drop-indicator.gen.ts +65 -31
- package/src/components/drop-indicator/index.gen.ts +5 -1
- package/src/components/drop-indicator/index.ts +14 -0
- package/src/components/inline-popover/index.gen.ts +11 -1
- package/src/components/inline-popover/index.ts +22 -0
- package/src/components/inline-popover/inline-popover-popup.gen.ts +44 -0
- package/src/components/inline-popover/inline-popover-positioner.gen.ts +177 -0
- package/src/components/inline-popover/inline-popover-root.gen.ts +108 -0
- package/src/components/menu/index.gen.ts +19 -0
- package/src/components/menu/index.ts +37 -0
- package/src/components/menu/menu-item.gen.ts +91 -0
- package/src/components/menu/menu-popup.gen.ts +58 -0
- package/src/components/menu/menu-positioner.gen.ts +178 -0
- package/src/components/menu/menu-root.gen.ts +88 -0
- package/src/components/menu/menu-submenu-root.gen.ts +44 -0
- package/src/components/menu/menu-submenu-trigger.gen.ts +44 -0
- package/src/components/menu/menu-trigger.gen.ts +79 -0
- package/src/components/popover/index.gen.ts +11 -3
- package/src/components/popover/index.ts +24 -0
- package/src/components/popover/popover-popup.gen.ts +44 -0
- package/src/components/popover/popover-positioner.gen.ts +178 -0
- package/src/components/popover/popover-root.gen.ts +92 -31
- package/src/components/popover/popover-trigger.gen.ts +92 -31
- package/src/components/resizable/index.gen.ts +8 -2
- package/src/components/resizable/index.ts +20 -0
- package/src/components/resizable/resizable-handle.gen.ts +54 -31
- package/src/components/resizable/resizable-root.gen.ts +90 -31
- package/src/components/table-handle/index.gen.ts +17 -9
- package/src/components/table-handle/index.ts +58 -0
- package/src/components/table-handle/table-handle-column-menu-root.gen.ts +66 -0
- package/src/components/table-handle/table-handle-column-menu-trigger.gen.ts +60 -0
- package/src/components/table-handle/table-handle-column-popup.gen.ts +44 -0
- package/src/components/table-handle/table-handle-column-positioner.gen.ts +201 -0
- package/src/components/table-handle/table-handle-drag-preview.gen.ts +57 -31
- package/src/components/table-handle/table-handle-drop-indicator.gen.ts +57 -31
- package/src/components/table-handle/table-handle-root.gen.ts +59 -31
- package/src/components/table-handle/table-handle-row-menu-root.gen.ts +66 -0
- package/src/components/table-handle/table-handle-row-menu-trigger.gen.ts +60 -0
- package/src/components/table-handle/table-handle-row-popup.gen.ts +44 -0
- package/src/components/table-handle/table-handle-row-positioner.gen.ts +201 -0
- package/src/components/tooltip/index.gen.ts +11 -3
- package/src/components/tooltip/index.ts +24 -0
- package/src/components/tooltip/tooltip-popup.gen.ts +44 -0
- package/src/components/tooltip/tooltip-positioner.gen.ts +178 -0
- package/src/components/tooltip/tooltip-root.gen.ts +85 -31
- package/src/components/tooltip/tooltip-trigger.gen.ts +63 -31
- package/src/extensions/preact-node-view.spec.ts +151 -0
- package/dist/create-component.js +0 -95
- package/dist/create-component.js.map +0 -1
- package/dist/create-props.d.ts +0 -6
- package/dist/create-props.d.ts.map +0 -1
- package/src/components/autocomplete/autocomplete-list.gen.ts +0 -34
- package/src/components/autocomplete/autocomplete-popover.gen.ts +0 -34
- package/src/components/block-handle/block-handle-popover.gen.ts +0 -34
- package/src/components/create-component.ts +0 -123
- package/src/components/create-props.ts +0 -13
- package/src/components/inline-popover/inline-popover.gen.ts +0 -34
- package/src/components/merge-refs.ts +0 -35
- package/src/components/popover/popover-content.gen.ts +0 -34
- package/src/components/table-handle/table-handle-column-root.gen.ts +0 -34
- package/src/components/table-handle/table-handle-column-trigger.gen.ts +0 -34
- package/src/components/table-handle/table-handle-popover-content.gen.ts +0 -34
- package/src/components/table-handle/table-handle-popover-item.gen.ts +0 -34
- package/src/components/table-handle/table-handle-row-root.gen.ts +0 -34
- package/src/components/table-handle/table-handle-row-trigger.gen.ts +0 -34
- package/src/components/tooltip/tooltip-content.gen.ts +0 -34
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is auto-generated by the "@aria-ui/cli" tool. Do not edit this file directly.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { registerTableHandleRowPositionerElement, type TableHandleRowPositionerElement, type TableHandleRowPositionerProps as TableHandleRowPositionerElementProps } from '@prosekit/web/table-handle';
|
|
6
|
+
import { createElement, type HTMLAttributes, type Ref } from 'preact';
|
|
7
|
+
import { forwardRef, type ForwardRefExoticComponent, type RefAttributes } from 'preact/compat';
|
|
8
|
+
import { useCallback, useRef, useLayoutEffect } from 'preact/hooks';
|
|
9
|
+
|
|
10
|
+
import { useEditorContext } from '../../contexts/editor-context.ts';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Props for the {@link TableHandleRowPositioner} Preact component.
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export interface TableHandleRowPositionerProps extends HTMLAttributes<TableHandleRowPositionerElement> {
|
|
18
|
+
/**
|
|
19
|
+
* The placement of the popover, relative to the hovered table cell.
|
|
20
|
+
*
|
|
21
|
+
* @default "left"
|
|
22
|
+
*/
|
|
23
|
+
placement?: TableHandleRowPositionerElementProps['placement'];
|
|
24
|
+
/**
|
|
25
|
+
* The strategy to use for positioning
|
|
26
|
+
*
|
|
27
|
+
* @default "absolute"
|
|
28
|
+
*/
|
|
29
|
+
strategy?: TableHandleRowPositionerElementProps['strategy'];
|
|
30
|
+
/**
|
|
31
|
+
* Options to activate auto-update listeners
|
|
32
|
+
*
|
|
33
|
+
* @see https://floating-ui.com/docs/autoUpdate
|
|
34
|
+
*
|
|
35
|
+
* @default true
|
|
36
|
+
*/
|
|
37
|
+
autoUpdate?: TableHandleRowPositionerElementProps['autoUpdate'];
|
|
38
|
+
/**
|
|
39
|
+
* Whether to use the browser [Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API)
|
|
40
|
+
* to place the floating element on top of other page content.
|
|
41
|
+
*
|
|
42
|
+
* @default false
|
|
43
|
+
*/
|
|
44
|
+
hoist?: TableHandleRowPositionerElementProps['hoist'];
|
|
45
|
+
/**
|
|
46
|
+
* @default 0
|
|
47
|
+
* @hidden
|
|
48
|
+
*/
|
|
49
|
+
offset?: TableHandleRowPositionerElementProps['offset'];
|
|
50
|
+
/**
|
|
51
|
+
* @default false
|
|
52
|
+
* @hidden
|
|
53
|
+
*/
|
|
54
|
+
flip?: TableHandleRowPositionerElementProps['flip'];
|
|
55
|
+
/**
|
|
56
|
+
* @default false
|
|
57
|
+
* @hidden
|
|
58
|
+
*/
|
|
59
|
+
shift?: TableHandleRowPositionerElementProps['shift'];
|
|
60
|
+
/**
|
|
61
|
+
* Whether the floating element can overlap the reference element to keep it
|
|
62
|
+
* in view.
|
|
63
|
+
*
|
|
64
|
+
* @default false
|
|
65
|
+
*/
|
|
66
|
+
overlap?: TableHandleRowPositionerElementProps['overlap'];
|
|
67
|
+
/**
|
|
68
|
+
* Whether to constrain the floating element's width and height to not exceed
|
|
69
|
+
* the viewport.
|
|
70
|
+
*
|
|
71
|
+
* @default false
|
|
72
|
+
*/
|
|
73
|
+
fitViewport?: TableHandleRowPositionerElementProps['fitViewport'];
|
|
74
|
+
/**
|
|
75
|
+
* Whether to constrain the floating element's width so that it matches the
|
|
76
|
+
* reference element.
|
|
77
|
+
*
|
|
78
|
+
* @default false
|
|
79
|
+
*/
|
|
80
|
+
sameWidth?: TableHandleRowPositionerElementProps['sameWidth'];
|
|
81
|
+
/**
|
|
82
|
+
* Whether to constrain the floating element's height so that it matches the
|
|
83
|
+
* reference element.
|
|
84
|
+
*
|
|
85
|
+
* @default false
|
|
86
|
+
*/
|
|
87
|
+
sameHeight?: TableHandleRowPositionerElementProps['sameHeight'];
|
|
88
|
+
/**
|
|
89
|
+
* Whether to improve positioning for inline reference elements that span over
|
|
90
|
+
* multiple lines.
|
|
91
|
+
*
|
|
92
|
+
* @default false
|
|
93
|
+
*/
|
|
94
|
+
inline?: TableHandleRowPositionerElementProps['inline'];
|
|
95
|
+
/**
|
|
96
|
+
* @default true
|
|
97
|
+
* @hidden
|
|
98
|
+
*/
|
|
99
|
+
hide?: TableHandleRowPositionerElementProps['hide'];
|
|
100
|
+
/**
|
|
101
|
+
* Describes the clipping element(s) or area that overflow will be checked relative to.
|
|
102
|
+
* Please see https://floating-ui.com/docs/detectoverflow#boundary for more information.
|
|
103
|
+
*
|
|
104
|
+
* @default 'clippingAncestors'
|
|
105
|
+
*/
|
|
106
|
+
boundary?: TableHandleRowPositionerElementProps['boundary'];
|
|
107
|
+
/**
|
|
108
|
+
* Describes the root boundary that the element will be checked for overflow relative to.
|
|
109
|
+
* Please see https://floating-ui.com/docs/detectoverflow#rootboundary for more information.
|
|
110
|
+
*
|
|
111
|
+
* @default 'viewport'
|
|
112
|
+
*/
|
|
113
|
+
rootBoundary?: TableHandleRowPositionerElementProps['rootBoundary'];
|
|
114
|
+
/**
|
|
115
|
+
* Describes the virtual padding around the boundary to check for overflow.
|
|
116
|
+
* Please see https://floating-ui.com/docs/detectoverflow#padding for more information.
|
|
117
|
+
*
|
|
118
|
+
* @default 4
|
|
119
|
+
*/
|
|
120
|
+
overflowPadding?: TableHandleRowPositionerElementProps['overflowPadding'];
|
|
121
|
+
/**
|
|
122
|
+
* The element that will be used to check for overflow. Please see
|
|
123
|
+
* https://floating-ui.com/docs/detectoverflow#elementcontext for more
|
|
124
|
+
* information.
|
|
125
|
+
*
|
|
126
|
+
* @default 'floating'
|
|
127
|
+
*/
|
|
128
|
+
elementContext?: TableHandleRowPositionerElementProps['elementContext'];
|
|
129
|
+
/**
|
|
130
|
+
* Whether to check the alternate elementContext's boundary. Please see
|
|
131
|
+
* https://floating-ui.com/docs/detectoverflow#altboundary for more
|
|
132
|
+
* information.
|
|
133
|
+
*
|
|
134
|
+
* @default false
|
|
135
|
+
*/
|
|
136
|
+
altBoundary?: TableHandleRowPositionerElementProps['altBoundary'];
|
|
137
|
+
/**
|
|
138
|
+
* The ProseKit editor instance.
|
|
139
|
+
*
|
|
140
|
+
* @default null
|
|
141
|
+
* @hidden
|
|
142
|
+
*/
|
|
143
|
+
editor?: TableHandleRowPositionerElementProps['editor'];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function TableHandleRowPositionerComponent(props: TableHandleRowPositionerProps, forwardedRef: Ref<TableHandleRowPositionerElement>) {
|
|
147
|
+
registerTableHandleRowPositionerElement();
|
|
148
|
+
|
|
149
|
+
const elementRef = useRef<TableHandleRowPositionerElement>(null);
|
|
150
|
+
|
|
151
|
+
const p3Fallback = useEditorContext();
|
|
152
|
+
|
|
153
|
+
const { altBoundary: p0, autoUpdate: p1, boundary: p2, editor: p3, elementContext: p4, fitViewport: p5, flip: p6, hide: p7, hoist: p8, inline: p9, offset: p10, overflowPadding: p11, overlap: p12, placement: p13, rootBoundary: p14, sameHeight: p15, sameWidth: p16, shift: p17, strategy: p18, ...restProps } = props;
|
|
154
|
+
|
|
155
|
+
useLayoutEffect(() => {
|
|
156
|
+
const element = elementRef.current as Record<string, unknown> | null;
|
|
157
|
+
if (!element) return;
|
|
158
|
+
Object.assign(element, {
|
|
159
|
+
altBoundary: p0,
|
|
160
|
+
autoUpdate: p1,
|
|
161
|
+
boundary: p2,
|
|
162
|
+
editor: p3 ?? p3Fallback,
|
|
163
|
+
elementContext: p4,
|
|
164
|
+
fitViewport: p5,
|
|
165
|
+
flip: p6,
|
|
166
|
+
hide: p7,
|
|
167
|
+
hoist: p8,
|
|
168
|
+
inline: p9,
|
|
169
|
+
offset: p10,
|
|
170
|
+
overflowPadding: p11,
|
|
171
|
+
overlap: p12,
|
|
172
|
+
placement: p13,
|
|
173
|
+
rootBoundary: p14,
|
|
174
|
+
sameHeight: p15,
|
|
175
|
+
sameWidth: p16,
|
|
176
|
+
shift: p17,
|
|
177
|
+
strategy: p18,
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
const mergedRef = useCallback(
|
|
182
|
+
(element: TableHandleRowPositionerElement | null) => {
|
|
183
|
+
elementRef.current = element;
|
|
184
|
+
if (typeof forwardedRef === 'function') {
|
|
185
|
+
forwardedRef(element);
|
|
186
|
+
} else if (forwardedRef) {
|
|
187
|
+
forwardedRef.current = element;
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
[forwardedRef],
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
return createElement('prosekit-table-handle-row-positioner', { ...restProps, ref: mergedRef, suppressHydrationWarning: true });
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* A Preact component that renders an `prosekit-table-handle-row-positioner` custom element.
|
|
198
|
+
*
|
|
199
|
+
* @public
|
|
200
|
+
*/
|
|
201
|
+
export const TableHandleRowPositioner: ForwardRefExoticComponent<TableHandleRowPositionerProps & RefAttributes<TableHandleRowPositionerElement>> = /* @__PURE__ */ forwardRef(TableHandleRowPositionerComponent);
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* This file is auto-generated by the "@aria-ui/cli" tool. Do not edit this file directly.
|
|
3
|
+
*/
|
|
2
4
|
|
|
3
|
-
export {
|
|
5
|
+
export { TooltipPopup, type TooltipPopupProps } from './tooltip-popup.gen.ts';
|
|
4
6
|
|
|
5
|
-
export {
|
|
7
|
+
export { TooltipPositioner, type TooltipPositionerProps } from './tooltip-positioner.gen.ts';
|
|
8
|
+
|
|
9
|
+
export { TooltipRoot, type TooltipRootProps, type TooltipRootEvents } from './tooltip-root.gen.ts';
|
|
10
|
+
|
|
11
|
+
export { TooltipTrigger, type TooltipTriggerProps } from './tooltip-trigger.gen.ts';
|
|
12
|
+
|
|
13
|
+
export { OpenChangeEvent } from '@prosekit/web/tooltip';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
|
|
3
|
+
@module
|
|
4
|
+
|
|
5
|
+
## Anatomy
|
|
6
|
+
|
|
7
|
+
```jsx
|
|
8
|
+
import {
|
|
9
|
+
TooltipPopup,
|
|
10
|
+
TooltipPositioner,
|
|
11
|
+
TooltipRoot,
|
|
12
|
+
TooltipTrigger,
|
|
13
|
+
} from 'prosekit/preact/tooltip'
|
|
14
|
+
|
|
15
|
+
<TooltipRoot>
|
|
16
|
+
<TooltipTrigger>...</TooltipTrigger>
|
|
17
|
+
<TooltipPositioner>
|
|
18
|
+
<TooltipPopup>...</TooltipPopup>
|
|
19
|
+
</TooltipPositioner>
|
|
20
|
+
</TooltipRoot>
|
|
21
|
+
```
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
export * from './index.gen.ts'
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is auto-generated by the "@aria-ui/cli" tool. Do not edit this file directly.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { registerTooltipPopupElement, type TooltipPopupElement } from '@prosekit/web/tooltip';
|
|
6
|
+
import { createElement, type HTMLAttributes, type Ref } from 'preact';
|
|
7
|
+
import { forwardRef, type ForwardRefExoticComponent, type RefAttributes } from 'preact/compat';
|
|
8
|
+
import { useCallback, useRef } from 'preact/hooks';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Props for the {@link TooltipPopup} Preact component.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export interface TooltipPopupProps extends HTMLAttributes<TooltipPopupElement> {}
|
|
16
|
+
|
|
17
|
+
function TooltipPopupComponent(props: TooltipPopupProps, forwardedRef: Ref<TooltipPopupElement>) {
|
|
18
|
+
registerTooltipPopupElement();
|
|
19
|
+
|
|
20
|
+
const elementRef = useRef<TooltipPopupElement>(null);
|
|
21
|
+
|
|
22
|
+
const { ...restProps } = props;
|
|
23
|
+
|
|
24
|
+
const mergedRef = useCallback(
|
|
25
|
+
(element: TooltipPopupElement | null) => {
|
|
26
|
+
elementRef.current = element;
|
|
27
|
+
if (typeof forwardedRef === 'function') {
|
|
28
|
+
forwardedRef(element);
|
|
29
|
+
} else if (forwardedRef) {
|
|
30
|
+
forwardedRef.current = element;
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
[forwardedRef],
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
return createElement('prosekit-tooltip-popup', { ...restProps, ref: mergedRef, suppressHydrationWarning: true });
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* A Preact component that renders an `prosekit-tooltip-popup` custom element.
|
|
41
|
+
*
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
export const TooltipPopup: ForwardRefExoticComponent<TooltipPopupProps & RefAttributes<TooltipPopupElement>> = /* @__PURE__ */ forwardRef(TooltipPopupComponent);
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is auto-generated by the "@aria-ui/cli" tool. Do not edit this file directly.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { registerTooltipPositionerElement, type TooltipPositionerElement, type TooltipPositionerProps as TooltipPositionerElementProps } from '@prosekit/web/tooltip';
|
|
6
|
+
import { createElement, type HTMLAttributes, type Ref } from 'preact';
|
|
7
|
+
import { forwardRef, type ForwardRefExoticComponent, type RefAttributes } from 'preact/compat';
|
|
8
|
+
import { useCallback, useRef, useLayoutEffect } from 'preact/hooks';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Props for the {@link TooltipPositioner} Preact component.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export interface TooltipPositionerProps extends HTMLAttributes<TooltipPositionerElement> {
|
|
16
|
+
/**
|
|
17
|
+
* The strategy to use for positioning
|
|
18
|
+
*
|
|
19
|
+
* @default "absolute"
|
|
20
|
+
*/
|
|
21
|
+
strategy?: TooltipPositionerElementProps['strategy'];
|
|
22
|
+
/**
|
|
23
|
+
* The initial placement of the floating element
|
|
24
|
+
*
|
|
25
|
+
* @default "top"
|
|
26
|
+
*/
|
|
27
|
+
placement?: TooltipPositionerElementProps['placement'];
|
|
28
|
+
/**
|
|
29
|
+
* Options to activate auto-update listeners
|
|
30
|
+
*
|
|
31
|
+
* @see https://floating-ui.com/docs/autoUpdate
|
|
32
|
+
*
|
|
33
|
+
* @default true
|
|
34
|
+
*/
|
|
35
|
+
autoUpdate?: TooltipPositionerElementProps['autoUpdate'];
|
|
36
|
+
/**
|
|
37
|
+
* Whether to use the browser Popover API to place the floating element on
|
|
38
|
+
* top of other page content.
|
|
39
|
+
*
|
|
40
|
+
* @default true
|
|
41
|
+
*/
|
|
42
|
+
hoist?: TooltipPositionerElementProps['hoist'];
|
|
43
|
+
/**
|
|
44
|
+
* The distance between the reference and floating element.
|
|
45
|
+
*
|
|
46
|
+
* @default 6
|
|
47
|
+
*/
|
|
48
|
+
offset?: TooltipPositionerElementProps['offset'];
|
|
49
|
+
/**
|
|
50
|
+
* Whether to flip the `placement` in order to keep it in view when the
|
|
51
|
+
* preferred placement(s) will overflow the clipping boundary. You can also
|
|
52
|
+
* provide an array of placements to try sequentially if the preferred
|
|
53
|
+
* `placement` does not fit.
|
|
54
|
+
*
|
|
55
|
+
* @default true
|
|
56
|
+
*/
|
|
57
|
+
flip?: TooltipPositionerElementProps['flip'];
|
|
58
|
+
/**
|
|
59
|
+
* Whether the floating element should shift to keep it in view.
|
|
60
|
+
*
|
|
61
|
+
* @default true
|
|
62
|
+
*/
|
|
63
|
+
shift?: TooltipPositionerElementProps['shift'];
|
|
64
|
+
/**
|
|
65
|
+
* Whether the floating element can overlap the reference element to keep it
|
|
66
|
+
* in view.
|
|
67
|
+
*
|
|
68
|
+
* @default false
|
|
69
|
+
*/
|
|
70
|
+
overlap?: TooltipPositionerElementProps['overlap'];
|
|
71
|
+
/**
|
|
72
|
+
* Whether to constrain the floating element's width and height to not exceed
|
|
73
|
+
* the viewport.
|
|
74
|
+
*
|
|
75
|
+
* @default false
|
|
76
|
+
*/
|
|
77
|
+
fitViewport?: TooltipPositionerElementProps['fitViewport'];
|
|
78
|
+
/**
|
|
79
|
+
* Whether to constrain the floating element's width so that it matches the
|
|
80
|
+
* reference element.
|
|
81
|
+
*
|
|
82
|
+
* @default false
|
|
83
|
+
*/
|
|
84
|
+
sameWidth?: TooltipPositionerElementProps['sameWidth'];
|
|
85
|
+
/**
|
|
86
|
+
* Whether to constrain the floating element's height so that it matches the
|
|
87
|
+
* reference element.
|
|
88
|
+
*
|
|
89
|
+
* @default false
|
|
90
|
+
*/
|
|
91
|
+
sameHeight?: TooltipPositionerElementProps['sameHeight'];
|
|
92
|
+
/**
|
|
93
|
+
* Whether to improve positioning for inline reference elements that span over
|
|
94
|
+
* multiple lines.
|
|
95
|
+
*
|
|
96
|
+
* @default false
|
|
97
|
+
*/
|
|
98
|
+
inline?: TooltipPositionerElementProps['inline'];
|
|
99
|
+
/**
|
|
100
|
+
* Whether to hide the floating element when the reference element or the
|
|
101
|
+
* floating element is fully clipped.
|
|
102
|
+
*
|
|
103
|
+
* @default false
|
|
104
|
+
*/
|
|
105
|
+
hide?: TooltipPositionerElementProps['hide'];
|
|
106
|
+
/**
|
|
107
|
+
* Describes the clipping element(s) or area that overflow will be checked relative to.
|
|
108
|
+
* Please see https://floating-ui.com/docs/detectoverflow#boundary for more information.
|
|
109
|
+
*
|
|
110
|
+
* @default 'clippingAncestors'
|
|
111
|
+
*/
|
|
112
|
+
boundary?: TooltipPositionerElementProps['boundary'];
|
|
113
|
+
/**
|
|
114
|
+
* Describes the root boundary that the element will be checked for overflow relative to.
|
|
115
|
+
* Please see https://floating-ui.com/docs/detectoverflow#rootboundary for more information.
|
|
116
|
+
*
|
|
117
|
+
* @default 'viewport'
|
|
118
|
+
*/
|
|
119
|
+
rootBoundary?: TooltipPositionerElementProps['rootBoundary'];
|
|
120
|
+
/**
|
|
121
|
+
* Describes the virtual padding around the boundary to check for overflow.
|
|
122
|
+
* Please see https://floating-ui.com/docs/detectoverflow#padding for more information.
|
|
123
|
+
*
|
|
124
|
+
* @default 4
|
|
125
|
+
*/
|
|
126
|
+
overflowPadding?: TooltipPositionerElementProps['overflowPadding'];
|
|
127
|
+
/**
|
|
128
|
+
* The element that will be used to check for overflow. Please see
|
|
129
|
+
* https://floating-ui.com/docs/detectoverflow#elementcontext for more
|
|
130
|
+
* information.
|
|
131
|
+
*
|
|
132
|
+
* @default 'floating'
|
|
133
|
+
*/
|
|
134
|
+
elementContext?: TooltipPositionerElementProps['elementContext'];
|
|
135
|
+
/**
|
|
136
|
+
* Whether to check the alternate elementContext's boundary. Please see
|
|
137
|
+
* https://floating-ui.com/docs/detectoverflow#altboundary for more
|
|
138
|
+
* information.
|
|
139
|
+
*
|
|
140
|
+
* @default false
|
|
141
|
+
*/
|
|
142
|
+
altBoundary?: TooltipPositionerElementProps['altBoundary'];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function TooltipPositionerComponent(props: TooltipPositionerProps, forwardedRef: Ref<TooltipPositionerElement>) {
|
|
146
|
+
registerTooltipPositionerElement();
|
|
147
|
+
|
|
148
|
+
const elementRef = useRef<TooltipPositionerElement>(null);
|
|
149
|
+
|
|
150
|
+
const { altBoundary: p0, autoUpdate: p1, boundary: p2, elementContext: p3, fitViewport: p4, flip: p5, hide: p6, hoist: p7, inline: p8, offset: p9, overflowPadding: p10, overlap: p11, placement: p12, rootBoundary: p13, sameHeight: p14, sameWidth: p15, shift: p16, strategy: p17, ...restProps } = props;
|
|
151
|
+
|
|
152
|
+
useLayoutEffect(() => {
|
|
153
|
+
const element = elementRef.current as Record<string, unknown> | null;
|
|
154
|
+
if (!element) return;
|
|
155
|
+
Object.assign(element, { altBoundary: p0, autoUpdate: p1, boundary: p2, elementContext: p3, fitViewport: p4, flip: p5, hide: p6, hoist: p7, inline: p8, offset: p9, overflowPadding: p10, overlap: p11, placement: p12, rootBoundary: p13, sameHeight: p14, sameWidth: p15, shift: p16, strategy: p17 });
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
const mergedRef = useCallback(
|
|
159
|
+
(element: TooltipPositionerElement | null) => {
|
|
160
|
+
elementRef.current = element;
|
|
161
|
+
if (typeof forwardedRef === 'function') {
|
|
162
|
+
forwardedRef(element);
|
|
163
|
+
} else if (forwardedRef) {
|
|
164
|
+
forwardedRef.current = element;
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
[forwardedRef],
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
return createElement('prosekit-tooltip-positioner', { ...restProps, ref: mergedRef, suppressHydrationWarning: true });
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* A Preact component that renders an `prosekit-tooltip-positioner` custom element.
|
|
175
|
+
*
|
|
176
|
+
* @public
|
|
177
|
+
*/
|
|
178
|
+
export const TooltipPositioner: ForwardRefExoticComponent<TooltipPositionerProps & RefAttributes<TooltipPositionerElement>> = /* @__PURE__ */ forwardRef(TooltipPositionerComponent);
|
|
@@ -1,34 +1,88 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from '
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
/**
|
|
2
|
+
* This file is auto-generated by the "@aria-ui/cli" tool. Do not edit this file directly.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { registerTooltipRootElement, type TooltipRootElement, type TooltipRootProps as TooltipRootElementProps, type TooltipRootEvents } from '@prosekit/web/tooltip';
|
|
6
|
+
import { createElement, type HTMLAttributes, type Ref } from 'preact';
|
|
7
|
+
import { forwardRef, type ForwardRefExoticComponent, type RefAttributes } from 'preact/compat';
|
|
8
|
+
import { useCallback, useRef, useLayoutEffect } from 'preact/hooks';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Props for the {@link TooltipRoot} Preact component.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export interface TooltipRootProps extends HTMLAttributes<TooltipRootElement> {
|
|
16
|
+
/**
|
|
17
|
+
* Whether the overlay is initially open.
|
|
18
|
+
* @default false
|
|
19
|
+
*/
|
|
20
|
+
defaultOpen?: TooltipRootElementProps['defaultOpen'];
|
|
21
|
+
/**
|
|
22
|
+
* Whether the overlay is currently open.
|
|
23
|
+
* @default null
|
|
24
|
+
*/
|
|
25
|
+
open?: TooltipRootElementProps['open'];
|
|
26
|
+
/**
|
|
27
|
+
* Whether the component should ignore user interaction.
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
disabled?: TooltipRootElementProps['disabled'];
|
|
31
|
+
/** Emitted when the tooltip is opened or closed. */
|
|
32
|
+
onOpenChange?: (event: TooltipRootEvents['openChange']) => void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function TooltipRootComponent(props: TooltipRootProps, forwardedRef: Ref<TooltipRootElement>) {
|
|
36
|
+
registerTooltipRootElement();
|
|
37
|
+
|
|
38
|
+
const elementRef = useRef<TooltipRootElement>(null);
|
|
39
|
+
const handlersRef = useRef<Array<((event: Event) => void) | undefined>>([]);
|
|
40
|
+
|
|
41
|
+
const { defaultOpen: p0, disabled: p1, open: p2, onOpenChange: e0, ...restProps } = props;
|
|
42
|
+
|
|
43
|
+
useLayoutEffect(() => {
|
|
44
|
+
const element = elementRef.current as Record<string, unknown> | null;
|
|
45
|
+
if (!element) return;
|
|
46
|
+
Object.assign(element, { defaultOpen: p0, disabled: p1, open: p2 });
|
|
47
|
+
handlersRef.current = [e0] as Array<((event: Event) => void) | undefined>;
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
useLayoutEffect(() => {
|
|
51
|
+
const element = elementRef.current;
|
|
52
|
+
if (!element) return;
|
|
53
|
+
const ac = new AbortController();
|
|
54
|
+
for (const [index, eventName] of ['openChange'].entries()) {
|
|
55
|
+
element.addEventListener(
|
|
56
|
+
eventName,
|
|
57
|
+
(event: Event) => {
|
|
58
|
+
handlersRef.current[index]?.(event);
|
|
59
|
+
},
|
|
60
|
+
{ signal: ac.signal },
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
return () => ac.abort();
|
|
64
|
+
}, []);
|
|
65
|
+
|
|
66
|
+
const mergedRef = useCallback(
|
|
67
|
+
(element: TooltipRootElement | null) => {
|
|
68
|
+
elementRef.current = element;
|
|
69
|
+
if (typeof forwardedRef === 'function') {
|
|
70
|
+
forwardedRef(element);
|
|
71
|
+
} else if (forwardedRef) {
|
|
72
|
+
forwardedRef.current = element;
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
[forwardedRef],
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
return createElement('prosekit-tooltip-root', { ...restProps, ref: mergedRef, suppressHydrationWarning: true });
|
|
79
|
+
}
|
|
16
80
|
|
|
17
81
|
/**
|
|
18
|
-
*
|
|
82
|
+
* A Preact component that renders an `prosekit-tooltip-root` custom element.
|
|
83
|
+
*
|
|
84
|
+
* @public
|
|
19
85
|
*/
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
export
|
|
23
|
-
Partial<TooltipRootProps> &
|
|
24
|
-
RefAttributes<TooltipRootElement> &
|
|
25
|
-
HTMLAttributes<TooltipRootElement>
|
|
26
|
-
> = createComponent<
|
|
27
|
-
TooltipRootProps,
|
|
28
|
-
TooltipRootElement
|
|
29
|
-
>(
|
|
30
|
-
'prosekit-tooltip-root',
|
|
31
|
-
'TooltipRoot',
|
|
32
|
-
Object.keys(tooltipRootProps),
|
|
33
|
-
Object.keys(tooltipRootEvents),
|
|
34
|
-
)
|
|
86
|
+
export const TooltipRoot: ForwardRefExoticComponent<TooltipRootProps & RefAttributes<TooltipRootElement>> = /* @__PURE__ */ forwardRef(TooltipRootComponent);
|
|
87
|
+
|
|
88
|
+
export type { TooltipRootEvents };
|
|
@@ -1,34 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from '
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
/**
|
|
2
|
+
* This file is auto-generated by the "@aria-ui/cli" tool. Do not edit this file directly.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { registerTooltipTriggerElement, type TooltipTriggerElement, type TooltipTriggerProps as TooltipTriggerElementProps } from '@prosekit/web/tooltip';
|
|
6
|
+
import { createElement, type HTMLAttributes, type Ref } from 'preact';
|
|
7
|
+
import { forwardRef, type ForwardRefExoticComponent, type RefAttributes } from 'preact/compat';
|
|
8
|
+
import { useCallback, useRef, useLayoutEffect } from 'preact/hooks';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Props for the {@link TooltipTrigger} Preact component.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export interface TooltipTriggerProps extends HTMLAttributes<TooltipTriggerElement> {
|
|
16
|
+
/**
|
|
17
|
+
* Whether the component should ignore user interaction.
|
|
18
|
+
* @default false
|
|
19
|
+
*/
|
|
20
|
+
disabled?: TooltipTriggerElementProps['disabled'];
|
|
21
|
+
/**
|
|
22
|
+
* The delay in milliseconds before opening the tooltip on hover.
|
|
23
|
+
* @default 600
|
|
24
|
+
*/
|
|
25
|
+
openDelay?: TooltipTriggerElementProps['openDelay'];
|
|
26
|
+
/**
|
|
27
|
+
* The delay in milliseconds before closing the tooltip when hover/focus ends.
|
|
28
|
+
* @default 0
|
|
29
|
+
*/
|
|
30
|
+
closeDelay?: TooltipTriggerElementProps['closeDelay'];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function TooltipTriggerComponent(props: TooltipTriggerProps, forwardedRef: Ref<TooltipTriggerElement>) {
|
|
34
|
+
registerTooltipTriggerElement();
|
|
35
|
+
|
|
36
|
+
const elementRef = useRef<TooltipTriggerElement>(null);
|
|
37
|
+
|
|
38
|
+
const { closeDelay: p0, disabled: p1, openDelay: p2, ...restProps } = props;
|
|
39
|
+
|
|
40
|
+
useLayoutEffect(() => {
|
|
41
|
+
const element = elementRef.current as Record<string, unknown> | null;
|
|
42
|
+
if (!element) return;
|
|
43
|
+
Object.assign(element, { closeDelay: p0, disabled: p1, openDelay: p2 });
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const mergedRef = useCallback(
|
|
47
|
+
(element: TooltipTriggerElement | null) => {
|
|
48
|
+
elementRef.current = element;
|
|
49
|
+
if (typeof forwardedRef === 'function') {
|
|
50
|
+
forwardedRef(element);
|
|
51
|
+
} else if (forwardedRef) {
|
|
52
|
+
forwardedRef.current = element;
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
[forwardedRef],
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
return createElement('prosekit-tooltip-trigger', { ...restProps, ref: mergedRef, suppressHydrationWarning: true });
|
|
59
|
+
}
|
|
16
60
|
|
|
17
61
|
/**
|
|
18
|
-
*
|
|
62
|
+
* A Preact component that renders an `prosekit-tooltip-trigger` custom element.
|
|
63
|
+
*
|
|
64
|
+
* @public
|
|
19
65
|
*/
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
export const TooltipTrigger: ForwardRefExoticComponent<
|
|
23
|
-
Partial<TooltipTriggerProps> &
|
|
24
|
-
RefAttributes<TooltipTriggerElement> &
|
|
25
|
-
HTMLAttributes<TooltipTriggerElement>
|
|
26
|
-
> = createComponent<
|
|
27
|
-
TooltipTriggerProps,
|
|
28
|
-
TooltipTriggerElement
|
|
29
|
-
>(
|
|
30
|
-
'prosekit-tooltip-trigger',
|
|
31
|
-
'TooltipTrigger',
|
|
32
|
-
Object.keys(tooltipTriggerProps),
|
|
33
|
-
Object.keys(tooltipTriggerEvents),
|
|
34
|
-
)
|
|
66
|
+
export const TooltipTrigger: ForwardRefExoticComponent<TooltipTriggerProps & RefAttributes<TooltipTriggerElement>> = /* @__PURE__ */ forwardRef(TooltipTriggerComponent);
|