@prosekit/lit 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.
@@ -31,11 +31,11 @@ var defaultPopoverOptions = {
31
31
  size({
32
32
  apply: ({ availableWidth, availableHeight, elements }) => {
33
33
  elements.floating.style.setProperty(
34
- "--prosekit-popover-available-width",
34
+ "max-width",
35
35
  `${Math.floor(availableWidth)}px`
36
36
  );
37
37
  elements.floating.style.setProperty(
38
- "--prosekit-popover-available-height",
38
+ "max-height",
39
39
  `${Math.floor(availableHeight)}px`
40
40
  );
41
41
  },
@@ -5,7 +5,7 @@ import "./chunk-GWGDLLFN.js";
5
5
  import "./chunk-6P3YKUWI.js";
6
6
  import {
7
7
  Popover
8
- } from "./chunk-I6N76F4U.js";
8
+ } from "./chunk-7WLKD2U6.js";
9
9
  import "./chunk-PCXKL6TA.js";
10
10
  import {
11
11
  __decorateClass
@@ -82,9 +82,6 @@ var AutocompletePopoverController = class {
82
82
  this.onChange(query != null ? query : "", !!this.reference);
83
83
  this.handleDismiss = options.ignoreMatch;
84
84
  this.handleSubmit = options.deleteMatch;
85
- setTimeout(() => {
86
- this.host.requestUpdate();
87
- }, 0);
88
85
  };
89
86
  const handleLeave = () => {
90
87
  this.reference = null;
@@ -121,38 +118,49 @@ var defaultDetectOverflowOptions = {
121
118
  padding: 8
122
119
  };
123
120
  var defaultPopoverOptions = {
124
- placement: "bottom-end",
121
+ // The main axis is the y axis, and we place the popover at the bottom of the
122
+ // reference element.
123
+ //
124
+ // The cross axis is the x axis, and we place the popover at the start of the
125
+ // reference element. The reference element and the popover are left-aligned.
126
+ placement: "bottom-start",
125
127
  middleware: [
126
128
  // Use the text caret as the reference point
127
129
  inline(),
128
- offset(({ rects }) => ({
129
- // Put the popover at the bottom right corner
130
- alignmentAxis: -rects.floating.width,
130
+ offset(() => ({
131
131
  // Move down the popover by 4px
132
132
  mainAxis: 4
133
133
  })),
134
134
  // Flip the popover to the top if it's overflowing the viewport
135
+ //
136
+ // When `flipAlignment` is true, which is the default, ensure `flip() `is
137
+ // placed before `shift()` in your middleware array.
138
+ //
139
+ // https://floating-ui.com/docs/flip#flipalignment
135
140
  flip({
136
- fallbackStrategy: "initialPlacement",
137
- fallbackAxisSideDirection: "start",
141
+ // Flip the popover to the top if necessary.
142
+ mainAxis: true,
143
+ // We don't want to flip the popover to the left or right, since `shift()`
144
+ // will handle this.
138
145
  crossAxis: false,
139
146
  ...defaultDetectOverflowOptions
140
147
  }),
148
+ // We need to place `shift()` after `flip()`. See https://floating-ui.com/docs/flip#flipalignment
149
+ shift({
150
+ ...defaultDetectOverflowOptions
151
+ }),
141
152
  size({
142
153
  apply: ({ availableWidth, availableHeight, elements }) => {
143
154
  elements.floating.style.setProperty(
144
- "--prosekit-popover-available-width",
155
+ "max-width",
145
156
  `${Math.floor(availableWidth)}px`
146
157
  );
147
158
  elements.floating.style.setProperty(
148
- "--prosekit-popover-available-height",
159
+ "max-height",
149
160
  `${Math.floor(availableHeight)}px`
150
161
  );
151
162
  },
152
163
  ...defaultDetectOverflowOptions
153
- }),
154
- shift({
155
- ...defaultDetectOverflowOptions
156
164
  })
157
165
  ]
158
166
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Popover
3
- } from "./chunk-I6N76F4U.js";
3
+ } from "./chunk-7WLKD2U6.js";
4
4
  import {
5
5
  ListManager
6
6
  } from "./chunk-PCXKL6TA.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Popover
3
- } from "./chunk-I6N76F4U.js";
3
+ } from "./chunk-7WLKD2U6.js";
4
4
  import {
5
5
  __decorateClass
6
6
  } from "./chunk-O5JP3B34.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Popover,
3
3
  propNames
4
- } from "./chunk-I6N76F4U.js";
4
+ } from "./chunk-7WLKD2U6.js";
5
5
  import "./chunk-O5JP3B34.js";
6
6
  export {
7
7
  Popover,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/lit",
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",