@prosekit/solid 0.7.0-beta.1 → 0.7.0-beta.3

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 (119) hide show
  1. package/dist/prosekit-solid-autocomplete.d.ts +225 -19
  2. package/dist/prosekit-solid-autocomplete.d.ts.map +1 -1
  3. package/dist/prosekit-solid-autocomplete.js +204 -9
  4. package/dist/prosekit-solid-autocomplete.js.map +1 -1
  5. package/dist/prosekit-solid-block-handle.d.ts +209 -15
  6. package/dist/prosekit-solid-block-handle.d.ts.map +1 -1
  7. package/dist/prosekit-solid-block-handle.js +160 -7
  8. package/dist/prosekit-solid-block-handle.js.map +1 -1
  9. package/dist/prosekit-solid-drop-indicator.d.ts +26 -7
  10. package/dist/prosekit-solid-drop-indicator.d.ts.map +1 -1
  11. package/dist/prosekit-solid-drop-indicator.js +29 -3
  12. package/dist/prosekit-solid-drop-indicator.js.map +1 -1
  13. package/dist/prosekit-solid-inline-popover.d.ts +203 -9
  14. package/dist/prosekit-solid-inline-popover.d.ts.map +1 -1
  15. package/dist/prosekit-solid-inline-popover.js +128 -5
  16. package/dist/prosekit-solid-inline-popover.js.map +1 -1
  17. package/dist/prosekit-solid-menu.d.ts +287 -0
  18. package/dist/prosekit-solid-menu.d.ts.map +1 -0
  19. package/dist/prosekit-solid-menu.js +241 -0
  20. package/dist/prosekit-solid-menu.js.map +1 -0
  21. package/dist/prosekit-solid-popover.d.ts +226 -15
  22. package/dist/prosekit-solid-popover.d.ts.map +1 -1
  23. package/dist/prosekit-solid-popover.js +165 -7
  24. package/dist/prosekit-solid-popover.js.map +1 -1
  25. package/dist/prosekit-solid-resizable.d.ts +55 -13
  26. package/dist/prosekit-solid-resizable.d.ts.map +1 -1
  27. package/dist/prosekit-solid-resizable.js +69 -7
  28. package/dist/prosekit-solid-resizable.js.map +1 -1
  29. package/dist/prosekit-solid-table-handle.d.ts +446 -39
  30. package/dist/prosekit-solid-table-handle.d.ts.map +1 -1
  31. package/dist/prosekit-solid-table-handle.js +334 -19
  32. package/dist/prosekit-solid-table-handle.js.map +1 -1
  33. package/dist/prosekit-solid-tooltip.d.ts +210 -15
  34. package/dist/prosekit-solid-tooltip.d.ts.map +1 -1
  35. package/dist/prosekit-solid-tooltip.js +149 -7
  36. package/dist/prosekit-solid-tooltip.js.map +1 -1
  37. package/dist/prosekit-solid.d.ts +23 -2
  38. package/dist/prosekit-solid.d.ts.map +1 -1
  39. package/package.json +23 -15
  40. package/src/components/autocomplete/autocomplete-empty.gen.ts +22 -24
  41. package/src/components/autocomplete/autocomplete-item.gen.ts +82 -26
  42. package/src/components/autocomplete/autocomplete-popup.gen.ts +78 -0
  43. package/src/components/autocomplete/autocomplete-positioner.gen.ts +167 -0
  44. package/src/components/autocomplete/autocomplete-root.gen.ts +110 -0
  45. package/src/components/autocomplete/index.gen.ts +12 -4
  46. package/src/components/autocomplete/index.ts +27 -0
  47. package/src/components/block-handle/block-handle-add.gen.ts +54 -26
  48. package/src/components/block-handle/block-handle-draggable.gen.ts +54 -26
  49. package/src/components/block-handle/block-handle-popup.gen.ts +27 -0
  50. package/src/components/block-handle/block-handle-positioner.gen.ts +185 -0
  51. package/src/components/block-handle/block-handle-root.gen.ts +82 -0
  52. package/src/components/block-handle/index.gen.ts +13 -3
  53. package/src/components/block-handle/index.ts +27 -0
  54. package/src/components/drop-indicator/drop-indicator.gen.ts +60 -26
  55. package/src/components/drop-indicator/index.gen.ts +5 -1
  56. package/src/components/drop-indicator/index.ts +14 -0
  57. package/src/components/inline-popover/index.gen.ts +11 -1
  58. package/src/components/inline-popover/index.ts +22 -0
  59. package/src/components/inline-popover/inline-popover-popup.gen.ts +27 -0
  60. package/src/components/inline-popover/inline-popover-positioner.gen.ts +191 -0
  61. package/src/components/inline-popover/inline-popover-root.gen.ts +106 -0
  62. package/src/components/menu/index.gen.ts +19 -0
  63. package/src/components/menu/index.ts +37 -0
  64. package/src/components/menu/menu-item.gen.ts +89 -0
  65. package/src/components/menu/menu-popup.gen.ts +53 -0
  66. package/src/components/menu/menu-positioner.gen.ts +192 -0
  67. package/src/components/menu/menu-root.gen.ts +86 -0
  68. package/src/components/menu/menu-submenu-root.gen.ts +27 -0
  69. package/src/components/menu/menu-submenu-trigger.gen.ts +27 -0
  70. package/src/components/menu/menu-trigger.gen.ts +77 -0
  71. package/src/components/popover/index.gen.ts +11 -3
  72. package/src/components/popover/index.ts +24 -0
  73. package/src/components/popover/popover-popup.gen.ts +27 -0
  74. package/src/components/popover/popover-positioner.gen.ts +192 -0
  75. package/src/components/popover/popover-root.gen.ts +90 -26
  76. package/src/components/popover/popover-trigger.gen.ts +90 -26
  77. package/src/components/resizable/index.gen.ts +8 -2
  78. package/src/components/resizable/index.ts +20 -0
  79. package/src/components/resizable/resizable-handle.gen.ts +49 -26
  80. package/src/components/resizable/resizable-root.gen.ts +89 -26
  81. package/src/components/table-handle/index.gen.ts +17 -9
  82. package/src/components/table-handle/index.ts +58 -0
  83. package/src/components/table-handle/table-handle-column-menu-root.gen.ts +61 -0
  84. package/src/components/table-handle/table-handle-column-menu-trigger.gen.ts +55 -0
  85. package/src/components/table-handle/table-handle-column-popup.gen.ts +27 -0
  86. package/src/components/table-handle/table-handle-column-positioner.gen.ts +196 -0
  87. package/src/components/table-handle/table-handle-drag-preview.gen.ts +52 -26
  88. package/src/components/table-handle/table-handle-drop-indicator.gen.ts +52 -26
  89. package/src/components/table-handle/table-handle-root.gen.ts +54 -26
  90. package/src/components/table-handle/table-handle-row-menu-root.gen.ts +61 -0
  91. package/src/components/table-handle/table-handle-row-menu-trigger.gen.ts +55 -0
  92. package/src/components/table-handle/table-handle-row-popup.gen.ts +27 -0
  93. package/src/components/table-handle/table-handle-row-positioner.gen.ts +196 -0
  94. package/src/components/tooltip/index.gen.ts +11 -3
  95. package/src/components/tooltip/index.ts +24 -0
  96. package/src/components/tooltip/tooltip-popup.gen.ts +27 -0
  97. package/src/components/tooltip/tooltip-positioner.gen.ts +192 -0
  98. package/src/components/tooltip/tooltip-root.gen.ts +83 -26
  99. package/src/components/tooltip/tooltip-trigger.gen.ts +58 -26
  100. package/dist/create-component.js +0 -41
  101. package/dist/create-component.js.map +0 -1
  102. package/dist/create-props.d.ts +0 -6
  103. package/dist/create-props.d.ts.map +0 -1
  104. package/dist/types.d.ts +0 -26
  105. package/dist/types.d.ts.map +0 -1
  106. package/src/components/autocomplete/autocomplete-list.gen.ts +0 -29
  107. package/src/components/autocomplete/autocomplete-popover.gen.ts +0 -29
  108. package/src/components/block-handle/block-handle-popover.gen.ts +0 -29
  109. package/src/components/create-component.ts +0 -60
  110. package/src/components/create-props.ts +0 -13
  111. package/src/components/inline-popover/inline-popover.gen.ts +0 -29
  112. package/src/components/popover/popover-content.gen.ts +0 -29
  113. package/src/components/table-handle/table-handle-column-root.gen.ts +0 -29
  114. package/src/components/table-handle/table-handle-column-trigger.gen.ts +0 -29
  115. package/src/components/table-handle/table-handle-popover-content.gen.ts +0 -29
  116. package/src/components/table-handle/table-handle-popover-item.gen.ts +0 -29
  117. package/src/components/table-handle/table-handle-row-root.gen.ts +0 -29
  118. package/src/components/table-handle/table-handle-row-trigger.gen.ts +0 -29
  119. package/src/components/tooltip/tooltip-content.gen.ts +0 -29
@@ -1,29 +1,85 @@
1
- import {
2
- type AutocompleteItemElement,
3
- type AutocompleteItemProps as Props,
4
- type AutocompleteItemEvents as Events,
5
- autocompleteItemProps,
6
- autocompleteItemEvents,
7
- } from '@prosekit/web/autocomplete'
8
- import type { Component } from 'solid-js'
9
-
10
- import type { PropsWithElement } from '../../types.ts'
11
- import { createComponent } from '../create-component.ts'
12
- import type { CreateProps } from '../create-props.ts'
1
+ /**
2
+ * This file is auto-generated by the "@aria-ui/cli" tool. Do not edit this file directly.
3
+ */
4
+
5
+ import { registerAutocompleteItemElement, type AutocompleteItemElement, type AutocompleteItemEvents, type AutocompleteItemProps as AutocompleteItemElementProps } from '@prosekit/web/autocomplete';
6
+ import { createEffect, createSignal, mergeProps, splitProps } from 'solid-js';
7
+ import type { Component, JSX } from 'solid-js';
8
+ import h from 'solid-js/h';
9
+
10
+ /**
11
+ * Props for the {@link AutocompleteItem} Solid component.
12
+ *
13
+ * @public
14
+ */
15
+ export interface AutocompleteItemProps extends JSX.HTMLAttributes<AutocompleteItemElement> {
16
+ /**
17
+ * The value of the item, which will be matched against the query.
18
+ *
19
+ * If not provided, the value is the item's text content.
20
+ *
21
+ * @default ""
22
+ */
23
+ value?: AutocompleteItemElementProps['value'];
24
+ /**
25
+ * Whether this option is disabled.
26
+ *
27
+ * @default false
28
+ */
29
+ disabled?: AutocompleteItemElementProps['disabled'];
30
+ /** Emitted when the the item is selected. */
31
+ onSelect?: (event: AutocompleteItemEvents['select']) => void;
32
+ }
13
33
 
14
34
  /**
15
- * Props for the {@link AutocompleteItem} component.
35
+ * A Solid component that renders an `prosekit-autocomplete-item` custom element.
36
+ *
37
+ * @public
16
38
  */
17
- export interface AutocompleteItemProps extends Partial<CreateProps<Props, Events>> {}
18
-
19
- export const AutocompleteItem: Component<PropsWithElement<
20
- AutocompleteItemProps,
21
- AutocompleteItemElement
22
- >> = createComponent<
23
- AutocompleteItemProps,
24
- AutocompleteItemElement
25
- >(
26
- 'prosekit-autocomplete-item',
27
- Object.keys(autocompleteItemProps),
28
- Object.keys(autocompleteItemEvents),
29
- )
39
+ export const AutocompleteItem: Component<AutocompleteItemProps> = (props): any => {
40
+ registerAutocompleteItemElement();
41
+
42
+ const [getElement, setElement] = createSignal<AutocompleteItemElement | null>(null);
43
+ const handlers: Array<((event: any) => void) | undefined> = [];
44
+
45
+ const [elementProps, eventHandlers, restProps] = splitProps(props, ['disabled', 'value'], ['onSelect']);
46
+
47
+ createEffect(() => {
48
+ const element = getElement();
49
+ if (!element) return;
50
+
51
+ Object.assign(element, { disabled: elementProps.disabled, value: elementProps.value });
52
+
53
+ handlers.length = 0;
54
+ handlers.push(eventHandlers.onSelect);
55
+ });
56
+
57
+ createEffect(() => {
58
+ const element = getElement();
59
+ if (!element) return;
60
+
61
+ const ac = new AbortController();
62
+ for (const [index, eventName] of ['select'].entries()) {
63
+ element.addEventListener(
64
+ eventName,
65
+ (event) => {
66
+ handlers[index]?.(event);
67
+ },
68
+ { signal: ac.signal },
69
+ );
70
+ }
71
+ return () => ac.abort();
72
+ });
73
+
74
+ return () =>
75
+ h(
76
+ 'prosekit-autocomplete-item',
77
+ mergeProps(restProps, {
78
+ ref: (el: AutocompleteItemElement | null) => {
79
+ setElement(el);
80
+ },
81
+ }),
82
+ );
83
+ };
84
+
85
+ export type { AutocompleteItemEvents };
@@ -0,0 +1,78 @@
1
+ /**
2
+ * This file is auto-generated by the "@aria-ui/cli" tool. Do not edit this file directly.
3
+ */
4
+
5
+ import { registerAutocompletePopupElement, type AutocompletePopupElement, type AutocompletePopupEvents } from '@prosekit/web/autocomplete';
6
+ import { createEffect, createSignal, mergeProps, splitProps } from 'solid-js';
7
+ import type { Component, JSX } from 'solid-js';
8
+ import h from 'solid-js/h';
9
+
10
+ /**
11
+ * Props for the {@link AutocompletePopup} Solid component.
12
+ *
13
+ * @public
14
+ */
15
+ export interface AutocompletePopupProps extends JSX.HTMLAttributes<AutocompletePopupElement> {
16
+ /**
17
+ * Emitted when the selected value changes. Only available when multiple is
18
+ * false.
19
+ */
20
+ onValueChange?: (event: AutocompletePopupEvents['valueChange']) => void;
21
+ /**
22
+ * Emitted when the selected values change. Only available when multiple is
23
+ * true.
24
+ */
25
+ onValuesChange?: (event: AutocompletePopupEvents['valuesChange']) => void;
26
+ }
27
+
28
+ /**
29
+ * A Solid component that renders an `prosekit-autocomplete-popup` custom element.
30
+ *
31
+ * @public
32
+ */
33
+ export const AutocompletePopup: Component<AutocompletePopupProps> = (props): any => {
34
+ registerAutocompletePopupElement();
35
+
36
+ const [getElement, setElement] = createSignal<AutocompletePopupElement | null>(null);
37
+ const handlers: Array<((event: any) => void) | undefined> = [];
38
+
39
+ const [eventHandlers, restProps] = splitProps(props, ['onValueChange', 'onValuesChange']);
40
+
41
+ createEffect(() => {
42
+ const element = getElement();
43
+ if (!element) return;
44
+
45
+ handlers.length = 0;
46
+ handlers.push(eventHandlers.onValueChange);
47
+ handlers.push(eventHandlers.onValuesChange);
48
+ });
49
+
50
+ createEffect(() => {
51
+ const element = getElement();
52
+ if (!element) return;
53
+
54
+ const ac = new AbortController();
55
+ for (const [index, eventName] of ['valueChange', 'valuesChange'].entries()) {
56
+ element.addEventListener(
57
+ eventName,
58
+ (event) => {
59
+ handlers[index]?.(event);
60
+ },
61
+ { signal: ac.signal },
62
+ );
63
+ }
64
+ return () => ac.abort();
65
+ });
66
+
67
+ return () =>
68
+ h(
69
+ 'prosekit-autocomplete-popup',
70
+ mergeProps(restProps, {
71
+ ref: (el: AutocompletePopupElement | null) => {
72
+ setElement(el);
73
+ },
74
+ }),
75
+ );
76
+ };
77
+
78
+ export type { AutocompletePopupEvents };
@@ -0,0 +1,167 @@
1
+ /**
2
+ * This file is auto-generated by the "@aria-ui/cli" tool. Do not edit this file directly.
3
+ */
4
+
5
+ import { registerAutocompletePositionerElement, type AutocompletePositionerElement, type AutocompletePositionerProps as AutocompletePositionerElementProps } from '@prosekit/web/autocomplete';
6
+ import { createEffect, createSignal, mergeProps, splitProps } from 'solid-js';
7
+ import type { Component, JSX } from 'solid-js';
8
+ import h from 'solid-js/h';
9
+
10
+ /**
11
+ * Props for the {@link AutocompletePositioner} Solid component.
12
+ *
13
+ * @public
14
+ */
15
+ export interface AutocompletePositionerProps extends JSX.HTMLAttributes<AutocompletePositionerElement> {
16
+ /**
17
+ * The placement of the popover, relative to the text cursor.
18
+ *
19
+ * @default "bottom-start"
20
+ */
21
+ placement?: AutocompletePositionerElementProps['placement'];
22
+ /**
23
+ * The distance between the popover and the hovered block.
24
+ *
25
+ * @default 4
26
+ */
27
+ offset?: AutocompletePositionerElementProps['offset'];
28
+ /** @default true */
29
+ inline?: AutocompletePositionerElementProps['inline'];
30
+ /** @default true */
31
+ hoist?: AutocompletePositionerElementProps['hoist'];
32
+ /** @default true */
33
+ fitViewport?: AutocompletePositionerElementProps['fitViewport'];
34
+ /** @default "The body element" */
35
+ boundary?: AutocompletePositionerElementProps['boundary'];
36
+ /** @default 8 */
37
+ overflowPadding?: AutocompletePositionerElementProps['overflowPadding'];
38
+ /**
39
+ * The strategy to use for positioning
40
+ *
41
+ * @default "absolute"
42
+ */
43
+ strategy?: AutocompletePositionerElementProps['strategy'];
44
+ /**
45
+ * Options to activate auto-update listeners
46
+ *
47
+ * @see https://floating-ui.com/docs/autoUpdate
48
+ *
49
+ * @default true
50
+ */
51
+ autoUpdate?: AutocompletePositionerElementProps['autoUpdate'];
52
+ /**
53
+ * Whether to flip the `placement` in order to keep it in view when the
54
+ * preferred placement(s) will overflow the clipping boundary. You can also
55
+ * provide an array of placements to try sequentially if the preferred
56
+ * `placement` does not fit.
57
+ *
58
+ * @default true
59
+ */
60
+ flip?: AutocompletePositionerElementProps['flip'];
61
+ /**
62
+ * Whether the floating element should shift to keep it in view.
63
+ *
64
+ * @default true
65
+ */
66
+ shift?: AutocompletePositionerElementProps['shift'];
67
+ /**
68
+ * Whether the floating element can overlap the reference element to keep it
69
+ * in view.
70
+ *
71
+ * @default false
72
+ */
73
+ overlap?: AutocompletePositionerElementProps['overlap'];
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?: AutocompletePositionerElementProps['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?: AutocompletePositionerElementProps['sameHeight'];
88
+ /**
89
+ * Whether to hide the floating element when the reference element or the
90
+ * floating element is fully clipped.
91
+ *
92
+ * @default false
93
+ */
94
+ hide?: AutocompletePositionerElementProps['hide'];
95
+ /**
96
+ * Describes the root boundary that the element will be checked for overflow relative to.
97
+ * Please see https://floating-ui.com/docs/detectoverflow#rootboundary for more information.
98
+ *
99
+ * @default 'viewport'
100
+ */
101
+ rootBoundary?: AutocompletePositionerElementProps['rootBoundary'];
102
+ /**
103
+ * The element that will be used to check for overflow. Please see
104
+ * https://floating-ui.com/docs/detectoverflow#elementcontext for more
105
+ * information.
106
+ *
107
+ * @default 'floating'
108
+ */
109
+ elementContext?: AutocompletePositionerElementProps['elementContext'];
110
+ /**
111
+ * Whether to check the alternate elementContext's boundary. Please see
112
+ * https://floating-ui.com/docs/detectoverflow#altboundary for more
113
+ * information.
114
+ *
115
+ * @default false
116
+ */
117
+ altBoundary?: AutocompletePositionerElementProps['altBoundary'];
118
+ }
119
+
120
+ /**
121
+ * A Solid component that renders an `prosekit-autocomplete-positioner` custom element.
122
+ *
123
+ * @public
124
+ */
125
+ export const AutocompletePositioner: Component<AutocompletePositionerProps> = (props): any => {
126
+ registerAutocompletePositionerElement();
127
+
128
+ const [getElement, setElement] = createSignal<AutocompletePositionerElement | null>(null);
129
+
130
+ const [elementProps, restProps] = splitProps(props, ['altBoundary', 'autoUpdate', 'boundary', 'elementContext', 'fitViewport', 'flip', 'hide', 'hoist', 'inline', 'offset', 'overflowPadding', 'overlap', 'placement', 'rootBoundary', 'sameHeight', 'sameWidth', 'shift', 'strategy']);
131
+
132
+ createEffect(() => {
133
+ const element = getElement();
134
+ if (!element) return;
135
+
136
+ Object.assign(element, {
137
+ altBoundary: elementProps.altBoundary,
138
+ autoUpdate: elementProps.autoUpdate,
139
+ boundary: elementProps.boundary,
140
+ elementContext: elementProps.elementContext,
141
+ fitViewport: elementProps.fitViewport,
142
+ flip: elementProps.flip,
143
+ hide: elementProps.hide,
144
+ hoist: elementProps.hoist,
145
+ inline: elementProps.inline,
146
+ offset: elementProps.offset,
147
+ overflowPadding: elementProps.overflowPadding,
148
+ overlap: elementProps.overlap,
149
+ placement: elementProps.placement,
150
+ rootBoundary: elementProps.rootBoundary,
151
+ sameHeight: elementProps.sameHeight,
152
+ sameWidth: elementProps.sameWidth,
153
+ shift: elementProps.shift,
154
+ strategy: elementProps.strategy,
155
+ });
156
+ });
157
+
158
+ return () =>
159
+ h(
160
+ 'prosekit-autocomplete-positioner',
161
+ mergeProps(restProps, {
162
+ ref: (el: AutocompletePositionerElement | null) => {
163
+ setElement(el);
164
+ },
165
+ }),
166
+ );
167
+ };
@@ -0,0 +1,110 @@
1
+ /**
2
+ * This file is auto-generated by the "@aria-ui/cli" tool. Do not edit this file directly.
3
+ */
4
+
5
+ import { registerAutocompleteRootElement, type AutocompleteRootElement, type AutocompleteRootEvents, type AutocompleteRootProps as AutocompleteRootElementProps } from '@prosekit/web/autocomplete';
6
+ import { createEffect, createSignal, mergeProps, splitProps } from 'solid-js';
7
+ import type { Component, JSX } from 'solid-js';
8
+ import h from 'solid-js/h';
9
+
10
+ import { useEditorContext } from '../../contexts/editor-context.ts';
11
+
12
+ /**
13
+ * Props for the {@link AutocompleteRoot} Solid component.
14
+ *
15
+ * @public
16
+ */
17
+ export interface AutocompleteRootProps extends JSX.HTMLAttributes<AutocompleteRootElement> {
18
+ /**
19
+ * The ProseKit editor instance.
20
+ *
21
+ * @default null
22
+ * @hidden
23
+ */
24
+ editor?: AutocompleteRootElementProps['editor'];
25
+ /**
26
+ * The regular expression to match the query text to autocomplete.
27
+ *
28
+ * @default null
29
+ */
30
+ regex?: AutocompleteRootElementProps['regex'];
31
+ /**
32
+ * The filter function to determine if an item should be shown in the
33
+ * listbox.
34
+ *
35
+ * @default defaultItemFilter
36
+ */
37
+ filter?: AutocompleteRootElementProps['filter'];
38
+ /** Fired when the open state changes. */
39
+ onOpenChange?: (event: AutocompleteRootEvents['openChange']) => void;
40
+ /** Fired when the query changes. */
41
+ onQueryChange?: (event: AutocompleteRootEvents['queryChange']) => void;
42
+ /**
43
+ * Emitted when the selected value changes. Only available when multiple is
44
+ * false.
45
+ */
46
+ onValueChange?: (event: AutocompleteRootEvents['valueChange']) => void;
47
+ /**
48
+ * Emitted when the selected values change. Only available when multiple is
49
+ * true.
50
+ */
51
+ onValuesChange?: (event: AutocompleteRootEvents['valuesChange']) => void;
52
+ }
53
+
54
+ /**
55
+ * A Solid component that renders an `prosekit-autocomplete-root` custom element.
56
+ *
57
+ * @public
58
+ */
59
+ export const AutocompleteRoot: Component<AutocompleteRootProps> = (props): any => {
60
+ registerAutocompleteRootElement();
61
+
62
+ const [getElement, setElement] = createSignal<AutocompleteRootElement | null>(null);
63
+ const handlers: Array<((event: any) => void) | undefined> = [];
64
+
65
+ const [elementProps, eventHandlers, restProps] = splitProps(props, ['editor', 'filter', 'regex'], ['onOpenChange', 'onQueryChange', 'onValueChange', 'onValuesChange']);
66
+
67
+ const p0Fallback = useEditorContext();
68
+
69
+ createEffect(() => {
70
+ const element = getElement();
71
+ if (!element) return;
72
+
73
+ Object.assign(element, { editor: elementProps.editor ?? p0Fallback, filter: elementProps.filter, regex: elementProps.regex });
74
+
75
+ handlers.length = 0;
76
+ handlers.push(eventHandlers.onOpenChange);
77
+ handlers.push(eventHandlers.onQueryChange);
78
+ handlers.push(eventHandlers.onValueChange);
79
+ handlers.push(eventHandlers.onValuesChange);
80
+ });
81
+
82
+ createEffect(() => {
83
+ const element = getElement();
84
+ if (!element) return;
85
+
86
+ const ac = new AbortController();
87
+ for (const [index, eventName] of ['openChange', 'queryChange', 'valueChange', 'valuesChange'].entries()) {
88
+ element.addEventListener(
89
+ eventName,
90
+ (event) => {
91
+ handlers[index]?.(event);
92
+ },
93
+ { signal: ac.signal },
94
+ );
95
+ }
96
+ return () => ac.abort();
97
+ });
98
+
99
+ return () =>
100
+ h(
101
+ 'prosekit-autocomplete-root',
102
+ mergeProps(restProps, {
103
+ ref: (el: AutocompleteRootElement | null) => {
104
+ setElement(el);
105
+ },
106
+ }),
107
+ );
108
+ };
109
+
110
+ export type { AutocompleteRootEvents };
@@ -1,7 +1,15 @@
1
- export { AutocompleteEmpty, type AutocompleteEmptyProps } from './autocomplete-empty.gen.ts'
1
+ /**
2
+ * This file is auto-generated by the "@aria-ui/cli" tool. Do not edit this file directly.
3
+ */
2
4
 
3
- export { AutocompleteItem, type AutocompleteItemProps } from './autocomplete-item.gen.ts'
5
+ export { AutocompleteEmpty, type AutocompleteEmptyProps } from './autocomplete-empty.gen.ts';
4
6
 
5
- export { AutocompleteList, type AutocompleteListProps } from './autocomplete-list.gen.ts'
7
+ export { AutocompleteItem, type AutocompleteItemProps, type AutocompleteItemEvents } from './autocomplete-item.gen.ts';
6
8
 
7
- export { AutocompletePopover, type AutocompletePopoverProps } from './autocomplete-popover.gen.ts'
9
+ export { AutocompletePopup, type AutocompletePopupProps, type AutocompletePopupEvents } from './autocomplete-popup.gen.ts';
10
+
11
+ export { AutocompletePositioner, type AutocompletePositionerProps } from './autocomplete-positioner.gen.ts';
12
+
13
+ export { AutocompleteRoot, type AutocompleteRootProps, type AutocompleteRootEvents } from './autocomplete-root.gen.ts';
14
+
15
+ export { OpenChangeEvent, QueryChangeEvent, SelectEvent, ValueChangeEvent, ValuesChangeEvent } from '@prosekit/web/autocomplete';
@@ -0,0 +1,27 @@
1
+ /**
2
+
3
+ @module
4
+
5
+ ## Anatomy
6
+
7
+ ```jsx
8
+ import {
9
+ AutocompleteEmpty,
10
+ AutocompleteItem,
11
+ AutocompletePopup,
12
+ AutocompletePositioner,
13
+ AutocompleteRoot,
14
+ } from 'prosekit/solid/autocomplete'
15
+
16
+ <AutocompleteRoot>
17
+ <AutocompletePositioner>
18
+ <AutocompletePopup>
19
+ <AutocompleteItem>...</AutocompleteItem>
20
+ <AutocompleteEmpty>...</AutocompleteEmpty>
21
+ </AutocompletePopup>
22
+ </AutocompletePositioner>
23
+ </AutocompleteRoot>
24
+ ```
25
+ */
26
+
27
+ export * from './index.gen.ts'
@@ -1,29 +1,57 @@
1
- import {
2
- type BlockHandleAddElement,
3
- type BlockHandleAddProps as Props,
4
- type BlockHandleAddEvents as Events,
5
- blockHandleAddProps,
6
- blockHandleAddEvents,
7
- } from '@prosekit/web/block-handle'
8
- import type { Component } from 'solid-js'
9
-
10
- import type { PropsWithElement } from '../../types.ts'
11
- import { createComponent } from '../create-component.ts'
12
- import type { CreateProps } from '../create-props.ts'
1
+ /**
2
+ * This file is auto-generated by the "@aria-ui/cli" tool. Do not edit this file directly.
3
+ */
4
+
5
+ import { registerBlockHandleAddElement, type BlockHandleAddElement, type BlockHandleAddProps as BlockHandleAddElementProps } from '@prosekit/web/block-handle';
6
+ import { createEffect, createSignal, mergeProps, splitProps } from 'solid-js';
7
+ import type { Component, JSX } from 'solid-js';
8
+ import h from 'solid-js/h';
9
+
10
+ import { useEditorContext } from '../../contexts/editor-context.ts';
11
+
12
+ /**
13
+ * Props for the {@link BlockHandleAdd} Solid component.
14
+ *
15
+ * @public
16
+ */
17
+ export interface BlockHandleAddProps extends JSX.HTMLAttributes<BlockHandleAddElement> {
18
+ /**
19
+ * The ProseKit editor instance.
20
+ *
21
+ * @default null
22
+ * @hidden
23
+ */
24
+ editor?: BlockHandleAddElementProps['editor'];
25
+ }
13
26
 
14
27
  /**
15
- * Props for the {@link BlockHandleAdd} component.
28
+ * A Solid component that renders an `prosekit-block-handle-add` custom element.
29
+ *
30
+ * @public
16
31
  */
17
- export interface BlockHandleAddProps extends Partial<CreateProps<Props, Events>> {}
18
-
19
- export const BlockHandleAdd: Component<PropsWithElement<
20
- BlockHandleAddProps,
21
- BlockHandleAddElement
22
- >> = createComponent<
23
- BlockHandleAddProps,
24
- BlockHandleAddElement
25
- >(
26
- 'prosekit-block-handle-add',
27
- Object.keys(blockHandleAddProps),
28
- Object.keys(blockHandleAddEvents),
29
- )
32
+ export const BlockHandleAdd: Component<BlockHandleAddProps> = (props): any => {
33
+ registerBlockHandleAddElement();
34
+
35
+ const [getElement, setElement] = createSignal<BlockHandleAddElement | null>(null);
36
+
37
+ const [elementProps, restProps] = splitProps(props, ['editor']);
38
+
39
+ const p0Fallback = useEditorContext();
40
+
41
+ createEffect(() => {
42
+ const element = getElement();
43
+ if (!element) return;
44
+
45
+ Object.assign(element, { editor: elementProps.editor ?? p0Fallback });
46
+ });
47
+
48
+ return () =>
49
+ h(
50
+ 'prosekit-block-handle-add',
51
+ mergeProps(restProps, {
52
+ ref: (el: BlockHandleAddElement | null) => {
53
+ setElement(el);
54
+ },
55
+ }),
56
+ );
57
+ };
@@ -1,29 +1,57 @@
1
- import {
2
- type BlockHandleDraggableElement,
3
- type BlockHandleDraggableProps as Props,
4
- type BlockHandleDraggableEvents as Events,
5
- blockHandleDraggableProps,
6
- blockHandleDraggableEvents,
7
- } from '@prosekit/web/block-handle'
8
- import type { Component } from 'solid-js'
9
-
10
- import type { PropsWithElement } from '../../types.ts'
11
- import { createComponent } from '../create-component.ts'
12
- import type { CreateProps } from '../create-props.ts'
1
+ /**
2
+ * This file is auto-generated by the "@aria-ui/cli" tool. Do not edit this file directly.
3
+ */
4
+
5
+ import { registerBlockHandleDraggableElement, type BlockHandleDraggableElement, type BlockHandleDraggableProps as BlockHandleDraggableElementProps } from '@prosekit/web/block-handle';
6
+ import { createEffect, createSignal, mergeProps, splitProps } from 'solid-js';
7
+ import type { Component, JSX } from 'solid-js';
8
+ import h from 'solid-js/h';
9
+
10
+ import { useEditorContext } from '../../contexts/editor-context.ts';
11
+
12
+ /**
13
+ * Props for the {@link BlockHandleDraggable} Solid component.
14
+ *
15
+ * @public
16
+ */
17
+ export interface BlockHandleDraggableProps extends JSX.HTMLAttributes<BlockHandleDraggableElement> {
18
+ /**
19
+ * The ProseKit editor instance.
20
+ *
21
+ * @default null
22
+ * @hidden
23
+ */
24
+ editor?: BlockHandleDraggableElementProps['editor'];
25
+ }
13
26
 
14
27
  /**
15
- * Props for the {@link BlockHandleDraggable} component.
28
+ * A Solid component that renders an `prosekit-block-handle-draggable` custom element.
29
+ *
30
+ * @public
16
31
  */
17
- export interface BlockHandleDraggableProps extends Partial<CreateProps<Props, Events>> {}
18
-
19
- export const BlockHandleDraggable: Component<PropsWithElement<
20
- BlockHandleDraggableProps,
21
- BlockHandleDraggableElement
22
- >> = createComponent<
23
- BlockHandleDraggableProps,
24
- BlockHandleDraggableElement
25
- >(
26
- 'prosekit-block-handle-draggable',
27
- Object.keys(blockHandleDraggableProps),
28
- Object.keys(blockHandleDraggableEvents),
29
- )
32
+ export const BlockHandleDraggable: Component<BlockHandleDraggableProps> = (props): any => {
33
+ registerBlockHandleDraggableElement();
34
+
35
+ const [getElement, setElement] = createSignal<BlockHandleDraggableElement | null>(null);
36
+
37
+ const [elementProps, restProps] = splitProps(props, ['editor']);
38
+
39
+ const p0Fallback = useEditorContext();
40
+
41
+ createEffect(() => {
42
+ const element = getElement();
43
+ if (!element) return;
44
+
45
+ Object.assign(element, { editor: elementProps.editor ?? p0Fallback });
46
+ });
47
+
48
+ return () =>
49
+ h(
50
+ 'prosekit-block-handle-draggable',
51
+ mergeProps(restProps, {
52
+ ref: (el: BlockHandleDraggableElement | null) => {
53
+ setElement(el);
54
+ },
55
+ }),
56
+ );
57
+ };