@sanity/ui 2.15.17 → 2.16.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.
@@ -537,6 +537,16 @@ declare interface PopoverProps
537
537
  overflow?: BoxOverflow
538
538
  padding?: number | number[]
539
539
  placement?: Placement
540
+ /**
541
+ * When 'flip' (default), the placement is determined from the initial placement and the
542
+ * fallback placements in order. Whichever fits in the viewport first.
543
+ *
544
+ * When 'autoPlacement', the initial placement and all fallback placements are evaluated
545
+ * and the placement with the most viewport space available.
546
+ *
547
+ * Option is only relevant if either `constrainSize` or `preventOverflow` is `true`
548
+ */
549
+ placementStrategy?: 'flip' | 'autoPlacement'
540
550
  /** Whether or not to render the popover in a portal element. */
541
551
  portal?: boolean | string
542
552
  preventOverflow?: boolean
@@ -537,6 +537,16 @@ declare interface PopoverProps
537
537
  overflow?: BoxOverflow
538
538
  padding?: number | number[]
539
539
  placement?: Placement
540
+ /**
541
+ * When 'flip' (default), the placement is determined from the initial placement and the
542
+ * fallback placements in order. Whichever fits in the viewport first.
543
+ *
544
+ * When 'autoPlacement', the initial placement and all fallback placements are evaluated
545
+ * and the placement with the most viewport space available.
546
+ *
547
+ * Option is only relevant if either `constrainSize` or `preventOverflow` is `true`
548
+ */
549
+ placementStrategy?: 'flip' | 'autoPlacement'
540
550
  /** Whether or not to render the popover in a portal element. */
541
551
  portal?: boolean | string
542
552
  preventOverflow?: boolean
package/dist/index.d.mts CHANGED
@@ -1596,6 +1596,16 @@ export declare interface PopoverProps
1596
1596
  overflow?: BoxOverflow
1597
1597
  padding?: number | number[]
1598
1598
  placement?: Placement
1599
+ /**
1600
+ * When 'flip' (default), the placement is determined from the initial placement and the
1601
+ * fallback placements in order. Whichever fits in the viewport first.
1602
+ *
1603
+ * When 'autoPlacement', the initial placement and all fallback placements are evaluated
1604
+ * and the placement with the most viewport space available.
1605
+ *
1606
+ * Option is only relevant if either `constrainSize` or `preventOverflow` is `true`
1607
+ */
1608
+ placementStrategy?: 'flip' | 'autoPlacement'
1599
1609
  /** Whether or not to render the popover in a portal element. */
1600
1610
  portal?: boolean | string
1601
1611
  preventOverflow?: boolean
package/dist/index.d.ts CHANGED
@@ -1596,6 +1596,16 @@ export declare interface PopoverProps
1596
1596
  overflow?: BoxOverflow
1597
1597
  padding?: number | number[]
1598
1598
  placement?: Placement
1599
+ /**
1600
+ * When 'flip' (default), the placement is determined from the initial placement and the
1601
+ * fallback placements in order. Whichever fits in the viewport first.
1602
+ *
1603
+ * When 'autoPlacement', the initial placement and all fallback placements are evaluated
1604
+ * and the placement with the most viewport space available.
1605
+ *
1606
+ * Option is only relevant if either `constrainSize` or `preventOverflow` is `true`
1607
+ */
1608
+ placementStrategy?: 'flip' | 'autoPlacement'
1599
1609
  /** Whether or not to render the popover in a portal element. */
1600
1610
  portal?: boolean | string
1601
1611
  preventOverflow?: boolean
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/ui",
3
- "version": "2.15.17",
3
+ "version": "2.16.0",
4
4
  "keywords": [
5
5
  "sanity",
6
6
  "ui",
@@ -120,7 +120,7 @@
120
120
  "@sanity/icons": "^3.7.0",
121
121
  "csstype": "^3.1.3",
122
122
  "framer-motion": "^12.9.7",
123
- "react-compiler-runtime": "19.1.0-rc.1",
123
+ "react-compiler-runtime": "19.1.0-rc.2",
124
124
  "react-refractor": "^2.2.0",
125
125
  "use-effect-event": "^1.0.2"
126
126
  },
@@ -162,7 +162,7 @@
162
162
  "@types/react-is": "^19.0.0",
163
163
  "@types/refractor": "^3.4.1",
164
164
  "@vitejs/plugin-react": "^4.4.1",
165
- "babel-plugin-react-compiler": "19.1.0-rc.1",
165
+ "babel-plugin-react-compiler": "19.1.0-rc.2",
166
166
  "babel-plugin-styled-components": "^2.1.4",
167
167
  "commitizen": "^4.3.1",
168
168
  "cypress": "^13.17.0",
@@ -175,7 +175,7 @@
175
175
  "eslint-plugin-import": "^2.31.0",
176
176
  "eslint-plugin-jsx-a11y": "^6.10.2",
177
177
  "eslint-plugin-react": "^7.37.5",
178
- "eslint-plugin-react-hooks": "0.0.0-experimental-7a2c7045-20250506",
178
+ "eslint-plugin-react-hooks": "0.0.0-experimental-4448b187-20250515",
179
179
  "eslint-plugin-react-refresh": "^0.4.20",
180
180
  "eslint-plugin-simple-import-sort": "^12.1.1",
181
181
  "eslint-plugin-storybook": "^0.12.0",
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  arrow,
3
+ autoPlacement,
3
4
  autoUpdate,
4
5
  flip,
5
6
  hide,
@@ -96,6 +97,16 @@ export interface PopoverProps
96
97
  overflow?: BoxOverflow
97
98
  padding?: number | number[]
98
99
  placement?: Placement
100
+ /**
101
+ * When 'flip' (default), the placement is determined from the initial placement and the
102
+ * fallback placements in order. Whichever fits in the viewport first.
103
+ *
104
+ * When 'autoPlacement', the initial placement and all fallback placements are evaluated
105
+ * and the placement with the most viewport space available.
106
+ *
107
+ * Option is only relevant if either `constrainSize` or `preventOverflow` is `true`
108
+ */
109
+ placementStrategy?: 'flip' | 'autoPlacement'
99
110
  /** Whether or not to render the popover in a portal element. */
100
111
  portal?: boolean | string
101
112
  preventOverflow?: boolean
@@ -154,6 +165,7 @@ export const Popover = memo(
154
165
  overflow = 'hidden',
155
166
  padding: paddingProp,
156
167
  placement: placementProp = 'bottom',
168
+ placementStrategy = 'flip',
157
169
  portal,
158
170
  preventOverflow = true,
159
171
  radius: radiusProp = 3,
@@ -240,14 +252,22 @@ export const Popover = memo(
240
252
 
241
253
  // Flip the floating element when leaving the boundary box
242
254
  if (constrainSize || preventOverflow) {
243
- ret.push(
244
- flip({
245
- boundary: floatingBoundary || undefined,
246
- fallbackPlacements,
247
- padding: DEFAULT_POPOVER_PADDING,
248
- rootBoundary,
249
- }),
250
- )
255
+ if (placementStrategy === 'autoPlacement') {
256
+ ret.push(
257
+ autoPlacement({
258
+ allowedPlacements: [placementProp].concat(fallbackPlacements),
259
+ }),
260
+ )
261
+ } else {
262
+ ret.push(
263
+ flip({
264
+ boundary: floatingBoundary || undefined,
265
+ fallbackPlacements,
266
+ padding: DEFAULT_POPOVER_PADDING,
267
+ rootBoundary,
268
+ }),
269
+ )
270
+ }
251
271
  }
252
272
 
253
273
  // Define distance between reference and floating element
@@ -330,6 +350,8 @@ export const Popover = memo(
330
350
  arrowProp,
331
351
  constrainSize,
332
352
  fallbackPlacements,
353
+ placementProp,
354
+ placementStrategy,
333
355
  floatingBoundary,
334
356
  margins,
335
357
  matchReferenceWidth,