@prosekit/web 0.1.1 → 0.1.2

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.
@@ -94,7 +94,6 @@ var defaultAutocompleteListProps = {
94
94
  import {
95
95
  assignProps,
96
96
  createSignal,
97
- mapSignals,
98
97
  useEffect as useEffect2
99
98
  } from "@aria-ui/core";
100
99
  import { useListbox } from "@aria-ui/listbox";
@@ -104,24 +103,27 @@ import {
104
103
  withPriority
105
104
  } from "@prosekit/core";
106
105
  function useAutocompleteList(element, props) {
107
- const state = mapSignals(assignProps(defaultAutocompleteListProps, props));
106
+ const fullProps = assignProps(defaultAutocompleteListProps, props);
107
+ const editor = createSignal(fullProps.editor);
108
108
  const open = openContext.consume(element);
109
109
  const query = queryContext.consume(element);
110
110
  const onSubmit = onSubmitContext.consume(element);
111
- const onKeydownHandlerAdd = useKeyboardHandler(element, open, state.editor);
111
+ const onKeydownHandlerAdd = useKeyboardHandler(element, open, editor);
112
+ const onValueChange = (value) => {
113
+ var _a;
114
+ if (value) {
115
+ (_a = onSubmit.peek()) == null ? void 0 : _a();
116
+ }
117
+ };
112
118
  const {
113
119
  query: listboxQuery,
114
120
  value: listboxValue,
121
+ filter,
115
122
  autoFocus
116
123
  } = useListbox(element, {
117
124
  onKeydownHandlerAdd,
118
- // This function will be called before `onSubmit()`.
119
- onValueChange: (value) => {
120
- var _a;
121
- if (value) {
122
- (_a = onSubmit.value) == null ? void 0 : _a.call(onSubmit);
123
- }
124
- }
125
+ onValueChange,
126
+ filter: fullProps.filter
125
127
  });
126
128
  useEffect2(element, () => {
127
129
  listboxQuery.value = query.value;
@@ -152,7 +154,7 @@ function useAutocompleteList(element, props) {
152
154
  };
153
155
  }
154
156
  });
155
- return state;
157
+ return { editor, filter };
156
158
  }
157
159
  function useKeyboardHandler(element, open, editor) {
158
160
  const keydownHandler = createSignal(
@@ -226,7 +228,7 @@ import {
226
228
  assignProps as assignProps2,
227
229
  createComputed,
228
230
  createSignal as createSignal2,
229
- mapSignals as mapSignals2,
231
+ mapSignals,
230
232
  useEffect as useEffect3
231
233
  } from "@aria-ui/core";
232
234
  import { useOverlayPositionerState } from "@aria-ui/overlay";
@@ -243,7 +245,7 @@ function defaultQueryBuilder(match) {
243
245
 
244
246
  // src/components/autocomplete/autocomplete-popover/state.ts
245
247
  function useAutocompletePopover(host, props) {
246
- const state = mapSignals2(assignProps2(defaultAutocompletePopoverProps, props));
248
+ const state = mapSignals(assignProps2(defaultAutocompletePopoverProps, props));
247
249
  useAutocompletePopoverState(host, state);
248
250
  return state;
249
251
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/web",
3
3
  "type": "module",
4
- "version": "0.1.1",
4
+ "version": "0.1.2",
5
5
  "private": false,
6
6
  "author": {
7
7
  "name": "ocavue",