@fluentui/react-positioning 9.8.0 → 9.9.0

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.json CHANGED
@@ -2,7 +2,43 @@
2
2
  "name": "@fluentui/react-positioning",
3
3
  "entries": [
4
4
  {
5
- "date": "Tue, 11 Jul 2023 18:44:10 GMT",
5
+ "date": "Thu, 27 Jul 2023 10:33:12 GMT",
6
+ "tag": "@fluentui/react-positioning_v9.9.0",
7
+ "version": "9.9.0",
8
+ "comments": {
9
+ "minor": [
10
+ {
11
+ "author": "yuanboxue@microsoft.com",
12
+ "package": "@fluentui/react-positioning",
13
+ "commit": "d2d8068110a9a7f71f417a40ee5f2db0ed1c40b9",
14
+ "comment": "feat: simplify autoSize options to make 'always'/'height-always'/'width-always' equivalent to true/'height'/'width'."
15
+ },
16
+ {
17
+ "author": "yuanboxue@microsoft.com",
18
+ "package": "@fluentui/react-positioning",
19
+ "commit": "e59b4b305eb656c5af005fefbfa2b1f69afcdc43",
20
+ "comment": "feat: update maxSize middleware to apply height/width when overflow"
21
+ }
22
+ ]
23
+ }
24
+ },
25
+ {
26
+ "date": "Thu, 20 Jul 2023 18:27:32 GMT",
27
+ "tag": "@fluentui/react-positioning_v9.8.0",
28
+ "version": "9.8.0",
29
+ "comments": {
30
+ "none": [
31
+ {
32
+ "author": "olfedias@microsoft.com",
33
+ "package": "@fluentui/react-positioning",
34
+ "commit": "5a4b16715e8e929f11d8113f710e578ca73acaa6",
35
+ "comment": "chore: migrate to monosize"
36
+ }
37
+ ]
38
+ }
39
+ },
40
+ {
41
+ "date": "Tue, 11 Jul 2023 18:46:35 GMT",
6
42
  "tag": "@fluentui/react-positioning_v9.8.0",
7
43
  "version": "9.8.0",
8
44
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,22 @@
1
1
  # Change Log - @fluentui/react-positioning
2
2
 
3
- This log was last generated on Tue, 11 Jul 2023 18:44:10 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 27 Jul 2023 10:33:12 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.9.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.9.0)
8
+
9
+ Thu, 27 Jul 2023 10:33:12 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.8.0..@fluentui/react-positioning_v9.9.0)
11
+
12
+ ### Minor changes
13
+
14
+ - feat: simplify autoSize options to make 'always'/'height-always'/'width-always' equivalent to true/'height'/'width'. ([PR #28649](https://github.com/microsoft/fluentui/pull/28649) by yuanboxue@microsoft.com)
15
+ - feat: update maxSize middleware to apply height/width when overflow ([PR #28622](https://github.com/microsoft/fluentui/pull/28622) by yuanboxue@microsoft.com)
16
+
7
17
  ## [9.8.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.8.0)
8
18
 
9
- Tue, 11 Jul 2023 18:44:10 GMT
19
+ Tue, 11 Jul 2023 18:46:35 GMT
10
20
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.7.3..@fluentui/react-positioning_v9.8.0)
11
21
 
12
22
  ### Minor changes
package/dist/index.d.ts CHANGED
@@ -183,11 +183,11 @@ declare interface PositioningOptions {
183
183
  */
184
184
  arrowPadding?: number;
185
185
  /**
186
- * Applies max-height and max-width on the positioned element to fit it within the available space in viewport.
187
- * true enables this for both width and height when overflow happens.
188
- * 'always' applies `max-height`/`max-width` regardless of overflow.
189
- * 'height' applies `max-height` when overflow happens, and 'width' for `max-width`
190
- * `height-always` applies `max-height` regardless of overflow, and 'width-always' for always applying `max-width`
186
+ * Applies styles on the positioned element to fit it within the available space in viewport.
187
+ * - true: set styles for max height/width.
188
+ * - 'height': set styles for max height.
189
+ * - 'width'': set styles for max width.
190
+ * Note that options 'always'/'height-always'/'width-always' are now obsolete, and equivalent to true/'height'/'width'.
191
191
  */
192
192
  autoSize?: AutoSize;
193
193
  /**
@@ -1,5 +1,36 @@
1
1
  import { size } from '@floating-ui/dom';
2
2
  import { getBoundary } from '../utils/getBoundary';
3
+ /**
4
+ * floating-ui `size` middleware uses floating element's height/width to calculate available height/width.
5
+ * This middleware only runs once per lifecycle, resetting styles applied by maxSize from previous lifecycle.
6
+ * Then floating element's original size is restored and `size` middleware can calculate available height/width correctly.
7
+ */ export const resetMaxSize = (autoSize)=>({
8
+ name: 'resetMaxSize',
9
+ fn ({ middlewareData: { maxSizeAlreadyReset } , elements }) {
10
+ if (maxSizeAlreadyReset) {
11
+ return {};
12
+ }
13
+ const { applyMaxWidth , applyMaxHeight } = autoSize;
14
+ if (applyMaxWidth) {
15
+ elements.floating.style.removeProperty('box-sizing');
16
+ elements.floating.style.removeProperty('max-width');
17
+ elements.floating.style.removeProperty('width');
18
+ }
19
+ if (applyMaxHeight) {
20
+ elements.floating.style.removeProperty('box-sizing');
21
+ elements.floating.style.removeProperty('max-height');
22
+ elements.floating.style.removeProperty('height');
23
+ }
24
+ return {
25
+ data: {
26
+ maxSizeAlreadyReset: true
27
+ },
28
+ reset: {
29
+ rects: true
30
+ }
31
+ };
32
+ }
33
+ });
3
34
  export function maxSize(autoSize, options) {
4
35
  const { container , overflowBoundary } = options;
5
36
  return size({
@@ -8,22 +39,23 @@ export function maxSize(autoSize, options) {
8
39
  boundary: getBoundary(container, overflowBoundary)
9
40
  },
10
41
  apply ({ availableHeight , availableWidth , elements , rects }) {
11
- const applyMaxWidth = autoSize === 'always' || autoSize === 'width-always' || rects.floating.width > availableWidth && (autoSize === true || autoSize === 'width');
12
- const applyMaxHeight = autoSize === 'always' || autoSize === 'height-always' || rects.floating.height > availableHeight && (autoSize === true || autoSize === 'height');
13
- if (applyMaxHeight) {
14
- Object.assign(elements.floating.style, {
15
- maxHeight: `${availableHeight}px`,
16
- boxSizing: 'border-box',
17
- overflowY: 'auto'
18
- });
19
- }
20
- if (applyMaxWidth) {
21
- Object.assign(elements.floating.style, {
22
- maxWidth: `${availableWidth}px`,
23
- boxSizing: 'border-box',
24
- overflowX: 'auto'
25
- });
26
- }
42
+ const applyMaxSizeStyles = (apply, dimension, availableSize)=>{
43
+ if (!apply) {
44
+ return;
45
+ }
46
+ elements.floating.style.setProperty('box-sizing', 'border-box');
47
+ elements.floating.style.setProperty(`max-${dimension}`, `${availableSize}px`);
48
+ if (rects.floating[dimension] > availableSize) {
49
+ elements.floating.style.setProperty(dimension, `${availableSize}px`);
50
+ const axis = dimension === 'width' ? 'x' : 'y';
51
+ if (!elements.floating.style.getPropertyValue(`overflow-${axis}`)) {
52
+ elements.floating.style.setProperty(`overflow-${axis}`, 'auto');
53
+ }
54
+ }
55
+ };
56
+ const { applyMaxWidth , applyMaxHeight } = autoSize;
57
+ applyMaxSizeStyles(applyMaxWidth, 'width', availableWidth);
58
+ applyMaxSizeStyles(applyMaxHeight, 'height', availableHeight);
27
59
  }
28
60
  });
29
61
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["maxSize.ts"],"sourcesContent":["import { size } from '@floating-ui/dom';\nimport type { Middleware } from '@floating-ui/dom';\nimport type { PositioningOptions } from '../types';\nimport { getBoundary } from '../utils/getBoundary';\nexport interface MaxSizeMiddlewareOptions extends Pick<PositioningOptions, 'overflowBoundary'> {\n container: HTMLElement | null;\n}\n\nexport function maxSize(autoSize: PositioningOptions['autoSize'], options: MaxSizeMiddlewareOptions): Middleware {\n const { container, overflowBoundary } = options;\n return size({\n ...(overflowBoundary && { altBoundary: true, boundary: getBoundary(container, overflowBoundary) }),\n apply({ availableHeight, availableWidth, elements, rects }) {\n const applyMaxWidth =\n autoSize === 'always' ||\n autoSize === 'width-always' ||\n (rects.floating.width > availableWidth && (autoSize === true || autoSize === 'width'));\n\n const applyMaxHeight =\n autoSize === 'always' ||\n autoSize === 'height-always' ||\n (rects.floating.height > availableHeight && (autoSize === true || autoSize === 'height'));\n\n if (applyMaxHeight) {\n Object.assign<CSSStyleDeclaration, Partial<CSSStyleDeclaration>>(elements.floating.style, {\n maxHeight: `${availableHeight}px`,\n boxSizing: 'border-box',\n overflowY: 'auto',\n });\n }\n\n if (applyMaxWidth) {\n Object.assign<CSSStyleDeclaration, Partial<CSSStyleDeclaration>>(elements.floating.style, {\n maxWidth: `${availableWidth}px`,\n boxSizing: 'border-box',\n overflowX: 'auto',\n });\n }\n },\n });\n}\n"],"names":["size","getBoundary","maxSize","autoSize","options","container","overflowBoundary","altBoundary","boundary","apply","availableHeight","availableWidth","elements","rects","applyMaxWidth","floating","width","applyMaxHeight","height","Object","assign","style","maxHeight","boxSizing","overflowY","maxWidth","overflowX"],"mappings":"AAAA,SAASA,IAAI,QAAQ,mBAAmB;AAGxC,SAASC,WAAW,QAAQ,uBAAuB;AAKnD,OAAO,SAASC,QAAQC,QAAwC,EAAEC,OAAiC,EAAc;IAC/G,MAAM,EAAEC,UAAS,EAAEC,iBAAgB,EAAE,GAAGF;IACxC,OAAOJ,KAAK;QACV,GAAIM,oBAAoB;YAAEC,aAAa,IAAI;YAAEC,UAAUP,YAAYI,WAAWC;QAAkB,CAAC;QACjGG,OAAM,EAAEC,gBAAe,EAAEC,eAAc,EAAEC,SAAQ,EAAEC,MAAK,EAAE,EAAE;YAC1D,MAAMC,gBACJX,aAAa,YACbA,aAAa,kBACZU,MAAME,QAAQ,CAACC,KAAK,GAAGL,kBAAmBR,CAAAA,aAAa,IAAI,IAAIA,aAAa,OAAM;YAErF,MAAMc,iBACJd,aAAa,YACbA,aAAa,mBACZU,MAAME,QAAQ,CAACG,MAAM,GAAGR,mBAAoBP,CAAAA,aAAa,IAAI,IAAIA,aAAa,QAAO;YAExF,IAAIc,gBAAgB;gBAClBE,OAAOC,MAAM,CAAoDR,SAASG,QAAQ,CAACM,KAAK,EAAE;oBACxFC,WAAW,CAAC,EAAEZ,gBAAgB,EAAE,CAAC;oBACjCa,WAAW;oBACXC,WAAW;gBACb;YACF,CAAC;YAED,IAAIV,eAAe;gBACjBK,OAAOC,MAAM,CAAoDR,SAASG,QAAQ,CAACM,KAAK,EAAE;oBACxFI,UAAU,CAAC,EAAEd,eAAe,EAAE,CAAC;oBAC/BY,WAAW;oBACXG,WAAW;gBACb;YACF,CAAC;QACH;IACF;AACF,CAAC"}
1
+ {"version":3,"sources":["maxSize.ts"],"sourcesContent":["import { size } from '@floating-ui/dom';\nimport type { Middleware } from '@floating-ui/dom';\nimport type { NormalizedAutoSize, PositioningOptions } from '../types';\nimport { getBoundary } from '../utils/getBoundary';\nexport interface MaxSizeMiddlewareOptions extends Pick<PositioningOptions, 'overflowBoundary'> {\n container: HTMLElement | null;\n}\n\n/**\n * floating-ui `size` middleware uses floating element's height/width to calculate available height/width.\n * This middleware only runs once per lifecycle, resetting styles applied by maxSize from previous lifecycle.\n * Then floating element's original size is restored and `size` middleware can calculate available height/width correctly.\n */\nexport const resetMaxSize = (autoSize: NormalizedAutoSize): Middleware => ({\n name: 'resetMaxSize',\n fn({ middlewareData: { maxSizeAlreadyReset }, elements }) {\n if (maxSizeAlreadyReset) {\n return {};\n }\n\n const { applyMaxWidth, applyMaxHeight } = autoSize;\n if (applyMaxWidth) {\n elements.floating.style.removeProperty('box-sizing');\n elements.floating.style.removeProperty('max-width');\n elements.floating.style.removeProperty('width');\n }\n if (applyMaxHeight) {\n elements.floating.style.removeProperty('box-sizing');\n elements.floating.style.removeProperty('max-height');\n elements.floating.style.removeProperty('height');\n }\n\n return {\n data: { maxSizeAlreadyReset: true },\n reset: { rects: true },\n };\n },\n});\n\nexport function maxSize(autoSize: NormalizedAutoSize, options: MaxSizeMiddlewareOptions): Middleware {\n const { container, overflowBoundary } = options;\n return size({\n ...(overflowBoundary && { altBoundary: true, boundary: getBoundary(container, overflowBoundary) }),\n apply({ availableHeight, availableWidth, elements, rects }) {\n const applyMaxSizeStyles = (apply: boolean, dimension: 'width' | 'height', availableSize: number) => {\n if (!apply) {\n return;\n }\n\n elements.floating.style.setProperty('box-sizing', 'border-box');\n elements.floating.style.setProperty(`max-${dimension}`, `${availableSize}px`);\n\n if (rects.floating[dimension] > availableSize) {\n elements.floating.style.setProperty(dimension, `${availableSize}px`);\n\n const axis = dimension === 'width' ? 'x' : 'y';\n if (!elements.floating.style.getPropertyValue(`overflow-${axis}`)) {\n elements.floating.style.setProperty(`overflow-${axis}`, 'auto');\n }\n }\n };\n\n const { applyMaxWidth, applyMaxHeight } = autoSize;\n applyMaxSizeStyles(applyMaxWidth, 'width', availableWidth);\n applyMaxSizeStyles(applyMaxHeight, 'height', availableHeight);\n },\n });\n}\n"],"names":["size","getBoundary","resetMaxSize","autoSize","name","fn","middlewareData","maxSizeAlreadyReset","elements","applyMaxWidth","applyMaxHeight","floating","style","removeProperty","data","reset","rects","maxSize","options","container","overflowBoundary","altBoundary","boundary","apply","availableHeight","availableWidth","applyMaxSizeStyles","dimension","availableSize","setProperty","axis","getPropertyValue"],"mappings":"AAAA,SAASA,IAAI,QAAQ,mBAAmB;AAGxC,SAASC,WAAW,QAAQ,uBAAuB;AAKnD;;;;CAIC,GACD,OAAO,MAAMC,eAAe,CAACC,WAA8C,CAAA;QACzEC,MAAM;QACNC,IAAG,EAAEC,gBAAgB,EAAEC,oBAAmB,EAAE,CAAA,EAAEC,SAAQ,EAAE,EAAE;YACxD,IAAID,qBAAqB;gBACvB,OAAO,CAAC;YACV,CAAC;YAED,MAAM,EAAEE,cAAa,EAAEC,eAAc,EAAE,GAAGP;YAC1C,IAAIM,eAAe;gBACjBD,SAASG,QAAQ,CAACC,KAAK,CAACC,cAAc,CAAC;gBACvCL,SAASG,QAAQ,CAACC,KAAK,CAACC,cAAc,CAAC;gBACvCL,SAASG,QAAQ,CAACC,KAAK,CAACC,cAAc,CAAC;YACzC,CAAC;YACD,IAAIH,gBAAgB;gBAClBF,SAASG,QAAQ,CAACC,KAAK,CAACC,cAAc,CAAC;gBACvCL,SAASG,QAAQ,CAACC,KAAK,CAACC,cAAc,CAAC;gBACvCL,SAASG,QAAQ,CAACC,KAAK,CAACC,cAAc,CAAC;YACzC,CAAC;YAED,OAAO;gBACLC,MAAM;oBAAEP,qBAAqB,IAAI;gBAAC;gBAClCQ,OAAO;oBAAEC,O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,"sources":["types.ts"],"sourcesContent":["import * as React from 'react';\n\ntype Rect = {\n width: number;\n height: number;\n x: number;\n y: number;\n};\n\nexport type OffsetFunctionParam = {\n positionedRect: Rect;\n targetRect: Rect;\n position: Position;\n alignment?: Alignment;\n};\n\nexport type TargetElement = HTMLElement | PositioningVirtualElement;\n\n/**\n * @internal\n */\nexport interface PositionManager {\n updatePosition: () => void;\n dispose: () => void;\n}\n\nexport interface UsePositioningReturn {\n // React refs are supposed to be contravariant\n // (allows a more general type to be passed rather than a more specific one)\n // However, Typescript currently can't infer that fact for refs\n // See https://github.com/microsoft/TypeScript/issues/30748 for more information\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n targetRef: React.MutableRefObject<any>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n containerRef: React.MutableRefObject<any>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n arrowRef: React.MutableRefObject<any>;\n}\n\nexport type OffsetObject = { crossAxis?: number; mainAxis: number };\n\nexport type OffsetShorthand = number;\n\nexport type OffsetFunction = (param: OffsetFunctionParam) => OffsetObject | OffsetShorthand;\n\nexport type Offset = OffsetFunction | OffsetObject | OffsetShorthand;\n\nexport type Position = 'above' | 'below' | 'before' | 'after';\nexport type Alignment = 'top' | 'bottom' | 'start' | 'end' | 'center';\n\nexport type AutoSize = 'height' | 'height-always' | 'width' | 'width-always' | 'always' | boolean;\n\nexport type Boundary = HTMLElement | Array<HTMLElement> | 'clippingParents' | 'scrollParent' | 'window';\n\nexport type PositioningImperativeRef = {\n /**\n * Updates the position imperatively.\n * Useful when the position of the target changes from other factors than scrolling of window resize.\n */\n updatePosition: () => void;\n\n /**\n * Sets the target and updates positioning imperatively.\n * Useful for avoiding double renders with the target option.\n */\n setTarget: (target: TargetElement) => void;\n};\n\nexport type PositioningVirtualElement = {\n getBoundingClientRect: () => {\n x: number;\n y: number;\n top: number;\n left: number;\n bottom: number;\n right: number;\n width: number;\n height: number;\n };\n contextElement?: Element;\n};\n\nexport type SetVirtualMouseTarget = (event: React.MouseEvent | MouseEvent | undefined | null) => void;\n\n/**\n * Internal options for positioning\n */\nexport interface PositioningOptions {\n /** Alignment for the component. Only has an effect if used with the @see position option */\n align?: Alignment;\n\n /** The element which will define the boundaries of the positioned element for the flip behavior. */\n flipBoundary?: Boundary | null;\n\n /** The element which will define the boundaries of the positioned element for the overflow behavior. */\n overflowBoundary?: Boundary | null;\n\n /**\n * Applies a padding to the overflow bounadry, so that overflow is detected earlier before the\n * positioned surface hits the overflow boundary.\n */\n overflowBoundaryPadding?: number | Partial<{ top: number; end: number; bottom: number; start: number }>;\n\n /**\n * Position for the component. Position has higher priority than align. If position is vertical ('above' | 'below')\n * and align is also vertical ('top' | 'bottom') or if both position and align are horizontal ('before' | 'after'\n * and 'start' | 'end' respectively),\n * then provided value for 'align' will be ignored and 'center' will be used instead.\n */\n position?: Position;\n\n /**\n * Enables the position element to be positioned with 'fixed' (default value is position: 'absolute')\n * @default false\n * @deprecated use `strategy` instead\n */\n positionFixed?: boolean;\n\n /**\n * Specifies the type of CSS position property to use.\n * @default absolute\n */\n strategy?: 'absolute' | 'fixed';\n\n /**\n * Lets you displace a positioned element from its reference element.\n * This can be useful if you need to apply some margin between them or if you need to fine tune the\n * position according to some custom logic.\n */\n offset?: Offset;\n\n /**\n * Defines padding between the corner of the popup element and the arrow.\n * Use to prevent the arrow from overlapping a rounded corner, for example.\n */\n arrowPadding?: number;\n\n /**\n * Applies max-height and max-width on the positioned element to fit it within the available space in viewport.\n * true enables this for both width and height when overflow happens.\n * 'always' applies `max-height`/`max-width` regardless of overflow.\n * 'height' applies `max-height` when overflow happens, and 'width' for `max-width`\n * `height-always` applies `max-height` regardless of overflow, and 'width-always' for always applying `max-width`\n */\n autoSize?: AutoSize;\n\n /**\n * Modifies position and alignment to cover the target\n */\n coverTarget?: boolean;\n\n /**\n * Disables automatic repositioning of the component; it will always be placed according to the values of `align` and\n * `position` props, regardless of the size of the component, the reference element or the viewport.\n */\n pinned?: boolean;\n\n /**\n * When the reference element or the viewport is outside viewport allows a positioned element to be fully in viewport.\n * \"all\" enables this behavior for all axis.\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n unstable_disableTether?: boolean | 'all';\n\n /**\n * If flip fails to stop the positioned element from overflowing\n * its boundaries, use a specified fallback positions.\n */\n fallbackPositions?: PositioningShorthandValue[];\n\n /**\n * Modifies whether popover is positioned using transform.\n * @default true\n */\n useTransform?: boolean;\n\n /**\n * If false, does not position anything\n */\n enabled?: boolean;\n}\n\n/**\n * Public api that allows components using react-positioning to specify positioning options\n */\nexport interface PositioningProps\n extends Pick<\n PositioningOptions,\n | 'align'\n | 'arrowPadding'\n | 'autoSize'\n | 'coverTarget'\n | 'flipBoundary'\n | 'offset'\n | 'overflowBoundary'\n | 'overflowBoundaryPadding'\n | 'pinned'\n | 'position'\n | 'strategy'\n | 'useTransform'\n > {\n /** An imperative handle to Popper methods. */\n positioningRef?: React.Ref<PositioningImperativeRef>;\n\n /**\n * Manual override for the target element. Useful for scenarios where a component accepts user prop to override target\n */\n target?: TargetElement | null;\n}\n\nexport type PositioningShorthandValue =\n | 'above'\n | 'above-start'\n | 'above-end'\n | 'below'\n | 'below-start'\n | 'below-end'\n | 'before'\n | 'before-top'\n | 'before-bottom'\n | 'after'\n | 'after-top'\n | 'after-bottom';\n\nexport type PositioningShorthand = PositioningProps | PositioningShorthandValue;\n"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
1
+ {"version":3,"sources":["types.ts"],"sourcesContent":["import * as React from 'react';\n\ntype Rect = {\n width: number;\n height: number;\n x: number;\n y: number;\n};\n\nexport type OffsetFunctionParam = {\n positionedRect: Rect;\n targetRect: Rect;\n position: Position;\n alignment?: Alignment;\n};\n\nexport type TargetElement = HTMLElement | PositioningVirtualElement;\n\n/**\n * @internal\n */\nexport interface PositionManager {\n updatePosition: () => void;\n dispose: () => void;\n}\n\nexport interface UsePositioningReturn {\n // React refs are supposed to be contravariant\n // (allows a more general type to be passed rather than a more specific one)\n // However, Typescript currently can't infer that fact for refs\n // See https://github.com/microsoft/TypeScript/issues/30748 for more information\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n targetRef: React.MutableRefObject<any>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n containerRef: React.MutableRefObject<any>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n arrowRef: React.MutableRefObject<any>;\n}\n\nexport type OffsetObject = { crossAxis?: number; mainAxis: number };\n\nexport type OffsetShorthand = number;\n\nexport type OffsetFunction = (param: OffsetFunctionParam) => OffsetObject | OffsetShorthand;\n\nexport type Offset = OffsetFunction | OffsetObject | OffsetShorthand;\n\nexport type Position = 'above' | 'below' | 'before' | 'after';\nexport type Alignment = 'top' | 'bottom' | 'start' | 'end' | 'center';\n\nexport type AutoSize = 'height' | 'height-always' | 'width' | 'width-always' | 'always' | boolean;\nexport type NormalizedAutoSize = { applyMaxWidth: boolean; applyMaxHeight: boolean };\n\nexport type Boundary = HTMLElement | Array<HTMLElement> | 'clippingParents' | 'scrollParent' | 'window';\n\nexport type PositioningImperativeRef = {\n /**\n * Updates the position imperatively.\n * Useful when the position of the target changes from other factors than scrolling of window resize.\n */\n updatePosition: () => void;\n\n /**\n * Sets the target and updates positioning imperatively.\n * Useful for avoiding double renders with the target option.\n */\n setTarget: (target: TargetElement) => void;\n};\n\nexport type PositioningVirtualElement = {\n getBoundingClientRect: () => {\n x: number;\n y: number;\n top: number;\n left: number;\n bottom: number;\n right: number;\n width: number;\n height: number;\n };\n contextElement?: Element;\n};\n\nexport type SetVirtualMouseTarget = (event: React.MouseEvent | MouseEvent | undefined | null) => void;\n\n/**\n * Internal options for positioning\n */\nexport interface PositioningOptions {\n /** Alignment for the component. Only has an effect if used with the @see position option */\n align?: Alignment;\n\n /** The element which will define the boundaries of the positioned element for the flip behavior. */\n flipBoundary?: Boundary | null;\n\n /** The element which will define the boundaries of the positioned element for the overflow behavior. */\n overflowBoundary?: Boundary | null;\n\n /**\n * Applies a padding to the overflow bounadry, so that overflow is detected earlier before the\n * positioned surface hits the overflow boundary.\n */\n overflowBoundaryPadding?: number | Partial<{ top: number; end: number; bottom: number; start: number }>;\n\n /**\n * Position for the component. Position has higher priority than align. If position is vertical ('above' | 'below')\n * and align is also vertical ('top' | 'bottom') or if both position and align are horizontal ('before' | 'after'\n * and 'start' | 'end' respectively),\n * then provided value for 'align' will be ignored and 'center' will be used instead.\n */\n position?: Position;\n\n /**\n * Enables the position element to be positioned with 'fixed' (default value is position: 'absolute')\n * @default false\n * @deprecated use `strategy` instead\n */\n positionFixed?: boolean;\n\n /**\n * Specifies the type of CSS position property to use.\n * @default absolute\n */\n strategy?: 'absolute' | 'fixed';\n\n /**\n * Lets you displace a positioned element from its reference element.\n * This can be useful if you need to apply some margin between them or if you need to fine tune the\n * position according to some custom logic.\n */\n offset?: Offset;\n\n /**\n * Defines padding between the corner of the popup element and the arrow.\n * Use to prevent the arrow from overlapping a rounded corner, for example.\n */\n arrowPadding?: number;\n\n /**\n * Applies styles on the positioned element to fit it within the available space in viewport.\n * - true: set styles for max height/width.\n * - 'height': set styles for max height.\n * - 'width'': set styles for max width.\n * Note that options 'always'/'height-always'/'width-always' are now obsolete, and equivalent to true/'height'/'width'.\n */\n autoSize?: AutoSize;\n\n /**\n * Modifies position and alignment to cover the target\n */\n coverTarget?: boolean;\n\n /**\n * Disables automatic repositioning of the component; it will always be placed according to the values of `align` and\n * `position` props, regardless of the size of the component, the reference element or the viewport.\n */\n pinned?: boolean;\n\n /**\n * When the reference element or the viewport is outside viewport allows a positioned element to be fully in viewport.\n * \"all\" enables this behavior for all axis.\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n unstable_disableTether?: boolean | 'all';\n\n /**\n * If flip fails to stop the positioned element from overflowing\n * its boundaries, use a specified fallback positions.\n */\n fallbackPositions?: PositioningShorthandValue[];\n\n /**\n * Modifies whether popover is positioned using transform.\n * @default true\n */\n useTransform?: boolean;\n\n /**\n * If false, does not position anything\n */\n enabled?: boolean;\n}\n\n/**\n * Public api that allows components using react-positioning to specify positioning options\n */\nexport interface PositioningProps\n extends Pick<\n PositioningOptions,\n | 'align'\n | 'arrowPadding'\n | 'autoSize'\n | 'coverTarget'\n | 'flipBoundary'\n | 'offset'\n | 'overflowBoundary'\n | 'overflowBoundaryPadding'\n | 'pinned'\n | 'position'\n | 'strategy'\n | 'useTransform'\n > {\n /** An imperative handle to Popper methods. */\n positioningRef?: React.Ref<PositioningImperativeRef>;\n\n /**\n * Manual override for the target element. Useful for scenarios where a component accepts user prop to override target\n */\n target?: TargetElement | null;\n}\n\nexport type PositioningShorthandValue =\n | 'above'\n | 'above-start'\n | 'above-end'\n | 'below'\n | 'below-start'\n | 'below-end'\n | 'before'\n | 'before-top'\n | 'before-bottom'\n | 'after'\n | 'after-top'\n | 'after-bottom';\n\nexport type PositioningShorthand = PositioningProps | PositioningShorthandValue;\n"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
@@ -2,8 +2,8 @@ import { hide as hideMiddleware, arrow as arrowMiddleware } from '@floating-ui/d
2
2
  import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';
3
3
  import { canUseDOM, useEventCallback, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';
4
4
  import * as React from 'react';
5
- import { useCallbackRef, toFloatingUIPlacement, hasAutofocusFilter, hasScrollParent } from './utils';
6
- import { shift as shiftMiddleware, flip as flipMiddleware, coverTarget as coverTargetMiddleware, maxSize as maxSizeMiddleware, offset as offsetMiddleware, intersecting as intersectingMiddleware } from './middleware';
5
+ import { useCallbackRef, toFloatingUIPlacement, hasAutofocusFilter, hasScrollParent, normalizeAutoSize } from './utils';
6
+ import { shift as shiftMiddleware, flip as flipMiddleware, coverTarget as coverTargetMiddleware, maxSize as maxSizeMiddleware, resetMaxSize as resetMaxSizeMiddleware, offset as offsetMiddleware, intersecting as intersectingMiddleware } from './middleware';
7
7
  import { createPositionManager } from './createPositionManager';
8
8
  /**
9
9
  * @internal
@@ -136,14 +136,16 @@ import { createPositionManager } from './createPositionManager';
136
136
  };
137
137
  }
138
138
  function usePositioningOptions(options) {
139
- const { align , arrowPadding , autoSize , coverTarget , flipBoundary , offset , overflowBoundary , pinned , position , unstable_disableTether: disableTether , // eslint-disable-next-line deprecation/deprecation
139
+ const { align , arrowPadding , autoSize: rawAutoSize , coverTarget , flipBoundary , offset , overflowBoundary , pinned , position , unstable_disableTether: disableTether , // eslint-disable-next-line deprecation/deprecation
140
140
  positionFixed , strategy , overflowBoundaryPadding , fallbackPositions , useTransform } = options;
141
141
  const { dir } = useFluent();
142
142
  const isRtl = dir === 'rtl';
143
143
  const positionStrategy = (strategy !== null && strategy !== void 0 ? strategy : positionFixed) ? 'fixed' : 'absolute';
144
+ const autoSize = normalizeAutoSize(rawAutoSize);
144
145
  return React.useCallback((container, arrow)=>{
145
146
  const hasScrollableElement = hasScrollParent(container);
146
147
  const middleware = [
148
+ autoSize && resetMaxSizeMiddleware(autoSize),
147
149
  offset && offsetMiddleware(offset),
148
150
  coverTarget && coverTargetMiddleware(),
149
151
  !pinned && flipMiddleware({
@@ -1 +1 @@
1
- {"version":3,"sources":["usePositioning.ts"],"sourcesContent":["import { hide as hideMiddleware, arrow as arrowMiddleware } from '@floating-ui/dom';\nimport type { Middleware, Strategy } from '@floating-ui/dom';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { canUseDOM, useEventCallback, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport type {\n PositioningOptions,\n PositioningProps,\n PositionManager,\n TargetElement,\n UsePositioningReturn,\n} from './types';\nimport { useCallbackRef, toFloatingUIPlacement, hasAutofocusFilter, hasScrollParent } from './utils';\nimport {\n shift as shiftMiddleware,\n flip as flipMiddleware,\n coverTarget as coverTargetMiddleware,\n maxSize as maxSizeMiddleware,\n offset as offsetMiddleware,\n intersecting as intersectingMiddleware,\n} from './middleware';\nimport { createPositionManager } from './createPositionManager';\n\n/**\n * @internal\n */\nexport function usePositioning(options: PositioningProps & PositioningOptions): UsePositioningReturn {\n const managerRef = React.useRef<PositionManager | null>(null);\n const targetRef = React.useRef<TargetElement | null>(null);\n const overrideTargetRef = React.useRef<TargetElement | null>(null);\n const containerRef = React.useRef<HTMLElement | null>(null);\n const arrowRef = React.useRef<HTMLElement | null>(null);\n\n const { enabled = true } = options;\n const resolvePositioningOptions = usePositioningOptions(options);\n const updatePositionManager = React.useCallback(() => {\n if (managerRef.current) {\n managerRef.current.dispose();\n }\n managerRef.current = null;\n\n const target = overrideTargetRef.current ?? targetRef.current;\n\n if (enabled && canUseDOM() && target && containerRef.current) {\n managerRef.current = createPositionManager({\n container: containerRef.current,\n target,\n arrow: arrowRef.current,\n ...resolvePositioningOptions(containerRef.current, arrowRef.current),\n });\n }\n }, [enabled, resolvePositioningOptions]);\n\n const setOverrideTarget = useEventCallback((target: TargetElement | null) => {\n overrideTargetRef.current = target;\n updatePositionManager();\n });\n\n React.useImperativeHandle(\n options.positioningRef,\n () => ({\n updatePosition: () => managerRef.current?.updatePosition(),\n setTarget: (target: TargetElement) => {\n if (options.target && process.env.NODE_ENV !== 'production') {\n const err = new Error();\n // eslint-disable-next-line no-console\n console.warn('Imperative setTarget should not be used at the same time as target option');\n // eslint-disable-next-line no-console\n console.warn(err.stack);\n }\n\n setOverrideTarget(target);\n },\n }),\n [options.target, setOverrideTarget],\n );\n\n useIsomorphicLayoutEffect(() => {\n setOverrideTarget(options.target ?? null);\n }, [options.target, setOverrideTarget]);\n\n useIsomorphicLayoutEffect(() => {\n updatePositionManager();\n }, [updatePositionManager]);\n\n if (process.env.NODE_ENV !== 'production') {\n // This checked should run only in development mode\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(() => {\n if (containerRef.current) {\n const contentNode = containerRef.current;\n const treeWalker = contentNode.ownerDocument?.createTreeWalker(contentNode, NodeFilter.SHOW_ELEMENT, {\n acceptNode: hasAutofocusFilter,\n });\n\n while (treeWalker.nextNode()) {\n const node = treeWalker.currentNode;\n // eslint-disable-next-line no-console\n console.warn('<Popper>:', node);\n // eslint-disable-next-line no-console\n console.warn(\n [\n '<Popper>: ^ this node contains \"autoFocus\" prop on a React element. This can break the initial',\n 'positioning of an element and cause a window jump effect. This issue occurs because React polyfills',\n '\"autoFocus\" behavior to solve inconsistencies between different browsers:',\n 'https://github.com/facebook/react/issues/11851#issuecomment-351787078',\n '\\n',\n 'However, \".focus()\" in this case occurs before any other React effects will be executed',\n '(React.useEffect(), componentDidMount(), etc.) and we can not prevent this behavior. If you really',\n 'want to use \"autoFocus\" please add \"position: fixed\" to styles of the element that is wrapped by',\n '\"Popper\".',\n `In general, it's not recommended to use \"autoFocus\" as it may break accessibility aspects:`,\n 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md',\n '\\n',\n 'We suggest to use the \"trapFocus\" prop on Fluent components or a catch \"ref\" and then use',\n '\"ref.current.focus\" in React.useEffect():',\n 'https://reactjs.org/docs/refs-and-the-dom.html#adding-a-ref-to-a-dom-element',\n ].join(' '),\n );\n }\n }\n // We run this check once, no need to add deps here\n // TODO: Should be rework to handle options.enabled and contentRef updates\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n }\n\n const setTarget = useCallbackRef<TargetElement>(null, target => {\n if (targetRef.current !== target) {\n targetRef.current = target;\n updatePositionManager();\n }\n });\n\n const setContainer = useCallbackRef<HTMLElement | null>(null, container => {\n if (containerRef.current !== container) {\n containerRef.current = container;\n updatePositionManager();\n }\n });\n\n const setArrow = useCallbackRef<HTMLElement | null>(null, arrow => {\n if (arrowRef.current !== arrow) {\n arrowRef.current = arrow;\n updatePositionManager();\n }\n });\n\n // Let users use callback refs so they feel like 'normal' DOM refs\n return { targetRef: setTarget, containerRef: setContainer, arrowRef: setArrow };\n}\n\nfunction usePositioningOptions(options: PositioningOptions) {\n const {\n align,\n arrowPadding,\n autoSize,\n coverTarget,\n flipBoundary,\n offset,\n overflowBoundary,\n pinned,\n position,\n unstable_disableTether: disableTether,\n // eslint-disable-next-line deprecation/deprecation\n positionFixed,\n strategy,\n overflowBoundaryPadding,\n fallbackPositions,\n useTransform,\n } = options;\n\n const { dir } = useFluent();\n const isRtl = dir === 'rtl';\n const positionStrategy: Strategy = strategy ?? positionFixed ? 'fixed' : 'absolute';\n\n return React.useCallback(\n (container: HTMLElement | null, arrow: HTMLElement | null) => {\n const hasScrollableElement = hasScrollParent(container);\n\n const middleware = [\n offset && offsetMiddleware(offset),\n coverTarget && coverTargetMiddleware(),\n !pinned && flipMiddleware({ container, flipBoundary, hasScrollableElement, isRtl, fallbackPositions }),\n shiftMiddleware({\n container,\n hasScrollableElement,\n overflowBoundary,\n disableTether,\n overflowBoundaryPadding,\n isRtl,\n }),\n autoSize && maxSizeMiddleware(autoSize, { container, overflowBoundary }),\n intersectingMiddleware(),\n arrow && arrowMiddleware({ element: arrow, padding: arrowPadding }),\n hideMiddleware({ strategy: 'referenceHidden' }),\n hideMiddleware({ strategy: 'escaped' }),\n ].filter(Boolean) as Middleware[];\n\n const placement = toFloatingUIPlacement(align, position, isRtl);\n\n return {\n placement,\n middleware,\n strategy: positionStrategy,\n useTransform,\n };\n },\n [\n align,\n arrowPadding,\n autoSize,\n coverTarget,\n disableTether,\n flipBoundary,\n isRtl,\n offset,\n overflowBoundary,\n pinned,\n position,\n positionStrategy,\n overflowBoundaryPadding,\n fallbackPositions,\n useTransform,\n ],\n );\n}\n"],"names":["hide","hideMiddleware","arrow","arrowMiddleware","useFluent_unstable","useFluent","canUseDOM","useEventCallback","useIsomorphicLayoutEffect","React","useCallbackRef","toFloatingUIPlacement","hasAutofocusFilter","hasScrollParent","shift","shiftMiddleware","flip","flipMiddleware","coverTarget","coverTargetMiddleware","maxSize","maxSizeMiddleware","offset","offsetMiddleware","intersecting","intersectingMiddleware","createPositionManager","usePositioning","options","managerRef","useRef","targetRef","overrideTargetRef","containerRef","arrowRef","enabled","resolvePositioningOptions","usePositioningOptions","updatePositionManager","useCallback","current","dispose","target","container","setOverrideTarget","useImperativeHandle","positioningRef","updatePosition","setTarget","process","env","NODE_ENV","err","Error","console","warn","stack","useEffect","contentNode","treeWalker","ownerDocument","createTreeWalker","NodeFilter","SHOW_ELEMENT","acceptNode","nextNode","node","currentNode","join","setContainer","setArrow","align","arrowPadding","autoSize","flipBoundary","overflowBoundary","pinned","position","unstable_disableTether","disableTether","positionFixed","strategy","overflowBoundaryPadding","fallbackPositions","useTransform","dir","isRtl","positionStrategy","hasScrollableElement","middleware","element","padding","filter","Boolean","placement"],"mappings":"AAAA,SAASA,QAAQC,cAAc,EAAEC,SAASC,eAAe,QAAQ,mBAAmB;AAEpF,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAClF,SAASC,SAAS,EAAEC,gBAAgB,EAAEC,yBAAyB,QAAQ,4BAA4B;AACnG,YAAYC,WAAW,QAAQ;AAQ/B,SAASC,cAAc,EAAEC,qBAAqB,EAAEC,kBAAkB,EAAEC,eAAe,QAAQ,UAAU;AACrG,SACEC,SAASC,eAAe,EACxBC,QAAQC,cAAc,EACtBC,eAAeC,qBAAqB,EACpCC,WAAWC,iBAAiB,EAC5BC,UAAUC,gBAAgB,EAC1BC,gBAAgBC,sBAAsB,QACjC,eAAe;AACtB,SAASC,qBAAqB,QAAQ,0BAA0B;AAEhE;;CAEC,GACD,OAAO,SAASC,eAAeC,OAA8C,EAAwB;IACnG,MAAMC,aAAapB,MAAMqB,MAAM,CAAyB,IAAI;IAC5D,MAAMC,YAAYtB,MAAMqB,MAAM,CAAuB,IAAI;IACzD,MAAME,oBAAoBvB,MAAMqB,MAAM,CAAuB,IAAI;IACjE,MAAMG,eAAexB,MAAMqB,MAAM,CAAqB,IAAI;IAC1D,MAAMI,WAAWzB,MAAMqB,MAAM,CAAqB,IAAI;IAEtD,MAAM,EAAEK,SAAU,IAAI,CAAA,EAAE,GAAGP;IAC3B,MAAMQ,4BAA4BC,sBAAsBT;IACxD,MAAMU,wBAAwB7B,MAAM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D;QACAL;QACAY;QACAhE;QACAqD;QACAC;QACAC;QACAU;QACAL;QACAC;QACAC;KACD;AAEL"}
1
+ {"version":3,"sources":["usePositioning.ts"],"sourcesContent":["import { hide as hideMiddleware, arrow as arrowMiddleware } from '@floating-ui/dom';\nimport type { Middleware, Strategy } from '@floating-ui/dom';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { canUseDOM, useEventCallback, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport type {\n PositioningOptions,\n PositioningProps,\n PositionManager,\n TargetElement,\n UsePositioningReturn,\n} from './types';\nimport { useCallbackRef, toFloatingUIPlacement, hasAutofocusFilter, hasScrollParent, normalizeAutoSize } from './utils';\nimport {\n shift as shiftMiddleware,\n flip as flipMiddleware,\n coverTarget as coverTargetMiddleware,\n maxSize as maxSizeMiddleware,\n resetMaxSize as resetMaxSizeMiddleware,\n offset as offsetMiddleware,\n intersecting as intersectingMiddleware,\n} from './middleware';\nimport { createPositionManager } from './createPositionManager';\n\n/**\n * @internal\n */\nexport function usePositioning(options: PositioningProps & PositioningOptions): UsePositioningReturn {\n const managerRef = React.useRef<PositionManager | null>(null);\n const targetRef = React.useRef<TargetElement | null>(null);\n const overrideTargetRef = React.useRef<TargetElement | null>(null);\n const containerRef = React.useRef<HTMLElement | null>(null);\n const arrowRef = React.useRef<HTMLElement | null>(null);\n\n const { enabled = true } = options;\n const resolvePositioningOptions = usePositioningOptions(options);\n const updatePositionManager = React.useCallback(() => {\n if (managerRef.current) {\n managerRef.current.dispose();\n }\n managerRef.current = null;\n\n const target = overrideTargetRef.current ?? targetRef.current;\n\n if (enabled && canUseDOM() && target && containerRef.current) {\n managerRef.current = createPositionManager({\n container: containerRef.current,\n target,\n arrow: arrowRef.current,\n ...resolvePositioningOptions(containerRef.current, arrowRef.current),\n });\n }\n }, [enabled, resolvePositioningOptions]);\n\n const setOverrideTarget = useEventCallback((target: TargetElement | null) => {\n overrideTargetRef.current = target;\n updatePositionManager();\n });\n\n React.useImperativeHandle(\n options.positioningRef,\n () => ({\n updatePosition: () => managerRef.current?.updatePosition(),\n setTarget: (target: TargetElement) => {\n if (options.target && process.env.NODE_ENV !== 'production') {\n const err = new Error();\n // eslint-disable-next-line no-console\n console.warn('Imperative setTarget should not be used at the same time as target option');\n // eslint-disable-next-line no-console\n console.warn(err.stack);\n }\n\n setOverrideTarget(target);\n },\n }),\n [options.target, setOverrideTarget],\n );\n\n useIsomorphicLayoutEffect(() => {\n setOverrideTarget(options.target ?? null);\n }, [options.target, setOverrideTarget]);\n\n useIsomorphicLayoutEffect(() => {\n updatePositionManager();\n }, [updatePositionManager]);\n\n if (process.env.NODE_ENV !== 'production') {\n // This checked should run only in development mode\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(() => {\n if (containerRef.current) {\n const contentNode = containerRef.current;\n const treeWalker = contentNode.ownerDocument?.createTreeWalker(contentNode, NodeFilter.SHOW_ELEMENT, {\n acceptNode: hasAutofocusFilter,\n });\n\n while (treeWalker.nextNode()) {\n const node = treeWalker.currentNode;\n // eslint-disable-next-line no-console\n console.warn('<Popper>:', node);\n // eslint-disable-next-line no-console\n console.warn(\n [\n '<Popper>: ^ this node contains \"autoFocus\" prop on a React element. This can break the initial',\n 'positioning of an element and cause a window jump effect. This issue occurs because React polyfills',\n '\"autoFocus\" behavior to solve inconsistencies between different browsers:',\n 'https://github.com/facebook/react/issues/11851#issuecomment-351787078',\n '\\n',\n 'However, \".focus()\" in this case occurs before any other React effects will be executed',\n '(React.useEffect(), componentDidMount(), etc.) and we can not prevent this behavior. If you really',\n 'want to use \"autoFocus\" please add \"position: fixed\" to styles of the element that is wrapped by',\n '\"Popper\".',\n `In general, it's not recommended to use \"autoFocus\" as it may break accessibility aspects:`,\n 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md',\n '\\n',\n 'We suggest to use the \"trapFocus\" prop on Fluent components or a catch \"ref\" and then use',\n '\"ref.current.focus\" in React.useEffect():',\n 'https://reactjs.org/docs/refs-and-the-dom.html#adding-a-ref-to-a-dom-element',\n ].join(' '),\n );\n }\n }\n // We run this check once, no need to add deps here\n // TODO: Should be rework to handle options.enabled and contentRef updates\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n }\n\n const setTarget = useCallbackRef<TargetElement>(null, target => {\n if (targetRef.current !== target) {\n targetRef.current = target;\n updatePositionManager();\n }\n });\n\n const setContainer = useCallbackRef<HTMLElement | null>(null, container => {\n if (containerRef.current !== container) {\n containerRef.current = container;\n updatePositionManager();\n }\n });\n\n const setArrow = useCallbackRef<HTMLElement | null>(null, arrow => {\n if (arrowRef.current !== arrow) {\n arrowRef.current = arrow;\n updatePositionManager();\n }\n });\n\n // Let users use callback refs so they feel like 'normal' DOM refs\n return { targetRef: setTarget, containerRef: setContainer, arrowRef: setArrow };\n}\n\nfunction usePositioningOptions(options: PositioningOptions) {\n const {\n align,\n arrowPadding,\n autoSize: rawAutoSize,\n coverTarget,\n flipBoundary,\n offset,\n overflowBoundary,\n pinned,\n position,\n unstable_disableTether: disableTether,\n // eslint-disable-next-line deprecation/deprecation\n positionFixed,\n strategy,\n overflowBoundaryPadding,\n fallbackPositions,\n useTransform,\n } = options;\n\n const { dir } = useFluent();\n const isRtl = dir === 'rtl';\n const positionStrategy: Strategy = strategy ?? positionFixed ? 'fixed' : 'absolute';\n const autoSize = normalizeAutoSize(rawAutoSize);\n\n return React.useCallback(\n (container: HTMLElement | null, arrow: HTMLElement | null) => {\n const hasScrollableElement = hasScrollParent(container);\n\n const middleware = [\n autoSize && resetMaxSizeMiddleware(autoSize),\n offset && offsetMiddleware(offset),\n coverTarget && coverTargetMiddleware(),\n !pinned && flipMiddleware({ container, flipBoundary, hasScrollableElement, isRtl, fallbackPositions }),\n shiftMiddleware({\n container,\n hasScrollableElement,\n overflowBoundary,\n disableTether,\n overflowBoundaryPadding,\n isRtl,\n }),\n autoSize && maxSizeMiddleware(autoSize, { container, overflowBoundary }),\n intersectingMiddleware(),\n arrow && arrowMiddleware({ element: arrow, padding: arrowPadding }),\n hideMiddleware({ strategy: 'referenceHidden' }),\n hideMiddleware({ strategy: 'escaped' }),\n ].filter(Boolean) as Middleware[];\n\n const placement = toFloatingUIPlacement(align, position, isRtl);\n\n return {\n placement,\n middleware,\n strategy: positionStrategy,\n useTransform,\n };\n },\n [\n align,\n arrowPadding,\n autoSize,\n coverTarget,\n disableTether,\n flipBoundary,\n isRtl,\n offset,\n overflowBoundary,\n pinned,\n position,\n positionStrategy,\n overflowBoundaryPadding,\n fallbackPositions,\n useTransform,\n ],\n );\n}\n"],"names":["hide","hideMiddleware","arrow","arrowMiddleware","useFluent_unstable","useFluent","canUseDOM","useEventCallback","useIsomorphicLayoutEffect","React","useCallbackRef","toFloatingUIPlacement","hasAutofocusFilter","hasScrollParent","normalizeAutoSize","shift","shiftMiddleware","flip","flipMiddleware","coverTarget","coverTargetMiddleware","maxSize","maxSizeMiddleware","resetMaxSize","resetMaxSizeMiddleware","offset","offsetMiddleware","intersecting","intersectingMiddleware","createPositionManager","usePositioning","options","managerRef","useRef","targetRef","overrideTargetRef","containerRef","arrowRef","enabled","resolvePositioningOptions","usePositioningOptions","updatePositionManager","useCallback","current","dispose","target","container","setOverrideTarget","useImperativeHandle","positioningRef","updatePosition","setTarget","process","env","NODE_ENV","err","Error","console","warn","stack","useEffect","contentNode","treeWalker","ownerDocument","createTreeWalker","NodeFilter","SHOW_ELEMENT","acceptNode","nextNode","node","currentNode","join","setContainer","setArrow","align","arrowPadding","autoSize","rawAutoSize","flipBoundary","overflowBoundary","pinned","position","unstable_disableTether","disableTether","positionFixed","strategy","overflowBoundaryPadding","fallbackPositions","useTransform","dir","isRtl","positionStrategy","hasScrollableElement","middleware","element","padding","filter","Boolean","placement"],"mappings":"AAAA,SAASA,QAAQC,cAAc,EAAEC,SAASC,eAAe,QAAQ,mBAAmB;AAEpF,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AACl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EJ,MAAM,EAAE0D,IAAG,EAAE,GAAGpF;IAChB,MAAMqF,QAAQD,QAAQ;IACtB,MAAME,mBAA6BN,CAAAA,qBAAAA,sBAAAA,WAAYD,aAAa,AAAD,IAAI,UAAU,UAAU;IACnF,MAAMR,WAAW9D,kBAAkB+D;IAEnC,OAAOpE,MAAMiC,WAAW,CACtB,CAACI,WAA+B5C,QAA8B;QAC5D,MAAM0F,uBAAuB/E,gBAAgBiC;QAE7C,MAAM+C,aAAa;YACjBjB,YAAYpD,uBAAuBoD;YACnCnD,UAAUC,iBAAiBD;YAC3BN,eAAeC;YACf,CAAC4D,UAAU9D,eAAe;gBAAE4B;gBAAWgC;gBAAcc;gBAAsBF;gBAAOH;YAAkB;YACpGvE,gBAAgB;gBACd8B;gBACA8C;gBACAb;gBACAI;gBACAG;gBACAI;YACF;YACAd,YAAYtD,kBAAkBsD,UAAU;gBAAE9B;gBAAWiC;YAAiB;YACtEnD;YACA1B,SAASC,gBAAgB;gBAAE2F,SAAS5F;gBAAO6F,SAASpB;YAAa;YACjE1E,eAAe;gBAAEoF,UAAU;YAAkB;YAC7CpF,eAAe;gBAAEoF,UAAU;YAAU;SACtC,CAACW,MAAM,CAACC;QAET,MAAMC,YAAYvF,sBAAsB+D,OAAOO,UAAUS;QAEzD,OAAO;YACLQ;YACAL;YACAR,UAAUM;YACVH;QACF;IACF,GACA;QACEd;QACAC;QACAC;QACAzD;QACAgE;QACAL;QACAY;QACAjE;QACAsD;QACAC;QACAC;QACAU;QACAL;QACAC;QACAC;KACD;AAEL"}
@@ -13,3 +13,4 @@ export * from './toggleScrollListener';
13
13
  export * from './hasAutoFocusFilter';
14
14
  export * from './writeArrowUpdates';
15
15
  export * from './writeContainerupdates';
16
+ export * from './normalizeAutoSize';
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"sourcesContent":["export * from './parseFloatingUIPlacement';\nexport * from './getBoundary';\nexport * from './getReactFiberFromNode';\nexport * from './getScrollParent';\nexport * from './mergeArrowOffset';\nexport * from './toFloatingUIPadding';\nexport * from './toFloatingUIPlacement';\nexport * from './fromFloatingUIPlacement';\nexport * from './resolvePositioningShorthand';\nexport * from './useCallbackRef';\nexport * from './debounce';\nexport * from './toggleScrollListener';\nexport * from './hasAutoFocusFilter';\nexport * from './writeArrowUpdates';\nexport * from './writeContainerupdates';\n"],"names":[],"mappings":"AAAA,cAAc,6BAA6B;AAC3C,cAAc,gBAAgB;AAC9B,cAAc,0BAA0B;AACxC,cAAc,oBAAoB;AAClC,cAAc,qBAAqB;AACnC,cAAc,wBAAwB;AACtC,cAAc,0BAA0B;AACxC,cAAc,4BAA4B;AAC1C,cAAc,gCAAgC;AAC9C,cAAc,mBAAmB;AACjC,cAAc,aAAa;AAC3B,cAAc,yBAAyB;AACvC,cAAc,uBAAuB;AACrC,cAAc,sBAAsB;AACpC,cAAc,0BAA0B"}
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export * from './parseFloatingUIPlacement';\nexport * from './getBoundary';\nexport * from './getReactFiberFromNode';\nexport * from './getScrollParent';\nexport * from './mergeArrowOffset';\nexport * from './toFloatingUIPadding';\nexport * from './toFloatingUIPlacement';\nexport * from './fromFloatingUIPlacement';\nexport * from './resolvePositioningShorthand';\nexport * from './useCallbackRef';\nexport * from './debounce';\nexport * from './toggleScrollListener';\nexport * from './hasAutoFocusFilter';\nexport * from './writeArrowUpdates';\nexport * from './writeContainerupdates';\nexport * from './normalizeAutoSize';\n"],"names":[],"mappings":"AAAA,cAAc,6BAA6B;AAC3C,cAAc,gBAAgB;AAC9B,cAAc,0BAA0B;AACxC,cAAc,oBAAoB;AAClC,cAAc,qBAAqB;AACnC,cAAc,wBAAwB;AACtC,cAAc,0BAA0B;AACxC,cAAc,4BAA4B;AAC1C,cAAc,gCAAgC;AAC9C,cAAc,mBAAmB;AACjC,cAAc,aAAa;AAC3B,cAAc,yBAAyB;AACvC,cAAc,uBAAuB;AACrC,cAAc,sBAAsB;AACpC,cAAc,0BAA0B;AACxC,cAAc,sBAAsB"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * AutoSizes contains many options from historic implementation.
3
+ * Now options 'always'/'height-always'/'width-always' are obsolete.
4
+ * This function maps them to true/'height'/'width'
5
+ */ export const normalizeAutoSize = (autoSize)=>{
6
+ switch(autoSize){
7
+ case 'always':
8
+ case true:
9
+ return {
10
+ applyMaxWidth: true,
11
+ applyMaxHeight: true
12
+ };
13
+ case 'width-always':
14
+ case 'width':
15
+ return {
16
+ applyMaxWidth: true,
17
+ applyMaxHeight: false
18
+ };
19
+ case 'height-always':
20
+ case 'height':
21
+ return {
22
+ applyMaxWidth: false,
23
+ applyMaxHeight: true
24
+ };
25
+ default:
26
+ return false;
27
+ }
28
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["normalizeAutoSize.ts"],"sourcesContent":["import type { NormalizedAutoSize, PositioningOptions } from '../types';\n\n/**\n * AutoSizes contains many options from historic implementation.\n * Now options 'always'/'height-always'/'width-always' are obsolete.\n * This function maps them to true/'height'/'width'\n */\nexport const normalizeAutoSize = (autoSize?: PositioningOptions['autoSize']): NormalizedAutoSize | false => {\n switch (autoSize) {\n case 'always':\n case true:\n return {\n applyMaxWidth: true,\n applyMaxHeight: true,\n };\n\n case 'width-always':\n case 'width':\n return {\n applyMaxWidth: true,\n applyMaxHeight: false,\n };\n\n case 'height-always':\n case 'height':\n return {\n applyMaxWidth: false,\n applyMaxHeight: true,\n };\n\n default:\n return false;\n }\n};\n"],"names":["normalizeAutoSize","autoSize","applyMaxWidth","applyMaxHeight"],"mappings":"AAEA;;;;CAIC,GACD,OAAO,MAAMA,oBAAoB,CAACC,WAA0E;IAC1G,OAAQA;QACN,KAAK;QACL,KAAK,IAAI;YACP,OAAO;gBACLC,eAAe,IAAI;gBACnBC,gBAAgB,IAAI;YACtB;QAEF,KAAK;QACL,KAAK;YACH,OAAO;gBACLD,eAAe,IAAI;gBACnBC,gBAAgB,KAAK;YACvB;QAEF,KAAK;QACL,KAAK;YACH,OAAO;gBACLD,eAAe,KAAK;gBACpBC,gBAAgB,IAAI;YACtB;QAEF;YACE,OAAO,KAAK;IAChB;AACF,EAAE"}
@@ -2,12 +2,45 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- Object.defineProperty(exports, "maxSize", {
6
- enumerable: true,
7
- get: ()=>maxSize
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ resetMaxSize: ()=>resetMaxSize,
13
+ maxSize: ()=>maxSize
8
14
  });
9
15
  const _dom = require("@floating-ui/dom");
10
16
  const _getBoundary = require("../utils/getBoundary");
17
+ const resetMaxSize = (autoSize)=>({
18
+ name: 'resetMaxSize',
19
+ fn ({ middlewareData: { maxSizeAlreadyReset } , elements }) {
20
+ if (maxSizeAlreadyReset) {
21
+ return {};
22
+ }
23
+ const { applyMaxWidth , applyMaxHeight } = autoSize;
24
+ if (applyMaxWidth) {
25
+ elements.floating.style.removeProperty('box-sizing');
26
+ elements.floating.style.removeProperty('max-width');
27
+ elements.floating.style.removeProperty('width');
28
+ }
29
+ if (applyMaxHeight) {
30
+ elements.floating.style.removeProperty('box-sizing');
31
+ elements.floating.style.removeProperty('max-height');
32
+ elements.floating.style.removeProperty('height');
33
+ }
34
+ return {
35
+ data: {
36
+ maxSizeAlreadyReset: true
37
+ },
38
+ reset: {
39
+ rects: true
40
+ }
41
+ };
42
+ }
43
+ });
11
44
  function maxSize(autoSize, options) {
12
45
  const { container , overflowBoundary } = options;
13
46
  return (0, _dom.size)({
@@ -16,22 +49,23 @@ function maxSize(autoSize, options) {
16
49
  boundary: (0, _getBoundary.getBoundary)(container, overflowBoundary)
17
50
  },
18
51
  apply ({ availableHeight , availableWidth , elements , rects }) {
19
- const applyMaxWidth = autoSize === 'always' || autoSize === 'width-always' || rects.floating.width > availableWidth && (autoSize === true || autoSize === 'width');
20
- const applyMaxHeight = autoSize === 'always' || autoSize === 'height-always' || rects.floating.height > availableHeight && (autoSize === true || autoSize === 'height');
21
- if (applyMaxHeight) {
22
- Object.assign(elements.floating.style, {
23
- maxHeight: `${availableHeight}px`,
24
- boxSizing: 'border-box',
25
- overflowY: 'auto'
26
- });
27
- }
28
- if (applyMaxWidth) {
29
- Object.assign(elements.floating.style, {
30
- maxWidth: `${availableWidth}px`,
31
- boxSizing: 'border-box',
32
- overflowX: 'auto'
33
- });
34
- }
52
+ const applyMaxSizeStyles = (apply, dimension, availableSize)=>{
53
+ if (!apply) {
54
+ return;
55
+ }
56
+ elements.floating.style.setProperty('box-sizing', 'border-box');
57
+ elements.floating.style.setProperty(`max-${dimension}`, `${availableSize}px`);
58
+ if (rects.floating[dimension] > availableSize) {
59
+ elements.floating.style.setProperty(dimension, `${availableSize}px`);
60
+ const axis = dimension === 'width' ? 'x' : 'y';
61
+ if (!elements.floating.style.getPropertyValue(`overflow-${axis}`)) {
62
+ elements.floating.style.setProperty(`overflow-${axis}`, 'auto');
63
+ }
64
+ }
65
+ };
66
+ const { applyMaxWidth , applyMaxHeight } = autoSize;
67
+ applyMaxSizeStyles(applyMaxWidth, 'width', availableWidth);
68
+ applyMaxSizeStyles(applyMaxHeight, 'height', availableHeight);
35
69
  }
36
70
  });
37
71
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["maxSize.js"],"sourcesContent":["import { size } from '@floating-ui/dom';\nimport { getBoundary } from '../utils/getBoundary';\nexport function maxSize(autoSize, options) {\n const { container , overflowBoundary } = options;\n return size({\n ...overflowBoundary && {\n altBoundary: true,\n boundary: getBoundary(container, overflowBoundary)\n },\n apply ({ availableHeight , availableWidth , elements , rects }) {\n const applyMaxWidth = autoSize === 'always' || autoSize === 'width-always' || rects.floating.width > availableWidth && (autoSize === true || autoSize === 'width');\n const applyMaxHeight = autoSize === 'always' || autoSize === 'height-always' || rects.floating.height > availableHeight && (autoSize === true || autoSize === 'height');\n if (applyMaxHeight) {\n Object.assign(elements.floating.style, {\n maxHeight: `${availableHeight}px`,\n boxSizing: 'border-box',\n overflowY: 'auto'\n });\n }\n if (applyMaxWidth) {\n Object.assign(elements.floating.style, {\n maxWidth: `${availableWidth}px`,\n boxSizing: 'border-box',\n overflowX: 'auto'\n });\n }\n }\n });\n}\n"],"names":["maxSize","autoSize","options","container","overflowBoundary","size","altBoundary","boundary","getBoundary","apply","availableHeight","availableWidth","elements","rects","applyMaxWidth","floating","width","applyMaxHeight","height","Object","assign","style","maxHeight","boxSizing","overflowY","maxWidth","overflowX"],"mappings":";;;;+BAEgBA;;aAAAA;;qBAFK;6BACO;AACrB,SAASA,QAAQC,QAAQ,EAAEC,OAAO,EAAE;IACvC,MAAM,EAAEC,UAAS,EAAGC,iBAAgB,EAAG,GAAGF;IAC1C,OAAOG,IAAAA,SAAI,EAAC;QACR,GAAGD,oBAAoB;YACnBE,aAAa,IAAI;YACjBC,UAAUC,IAAAA,wBAAW,EAACL,WAAWC;QACrC,CAAC;QACDK,OAAO,EAAEC,gBAAe,EAAGC,eAAc,EAAGC,SAAQ,EAAGC,MAAK,EAAG,EAAE;YAC7D,MAAMC,gBAAgBb,aAAa,YAAYA,aAAa,kBAAkBY,MAAME,QAAQ,CAACC,KAAK,GAAGL,kBAAmBV,CAAAA,aAAa,IAAI,IAAIA,aAAa,OAAM;YAChK,MAAMgB,iBAAiBhB,aAAa,YAAYA,aAAa,mBAAmBY,MAAME,QAAQ,CAACG,MAAM,GAAGR,mBAAoBT,CAAAA,aAAa,IAAI,IAAIA,aAAa,QAAO;YACrK,IAAIgB,gBAAgB;gBAChBE,OAAOC,MAAM,CAACR,SAASG,QAAQ,CAACM,KAAK,EAAE;oBACnCC,WAAW,CAAC,EAAEZ,gBAAgB,EAAE,CAAC;oBACjCa,WAAW;oBACXC,WAAW;gBACf;YACJ,CAAC;YACD,IAAIV,eAAe;gBACfK,OAAOC,MAAM,CAACR,SAASG,QAAQ,CAACM,KAAK,EAAE;oBACnCI,UAAU,CAAC,EAAEd,eAAe,EAAE,CAAC;oBAC/BY,WAAW;oBACXG,WAAW;gBACf;YACJ,CAAC;QACL;IACJ;AACJ"}
1
+ {"version":3,"sources":["maxSize.js"],"sourcesContent":["import { size } from '@floating-ui/dom';\nimport { getBoundary } from '../utils/getBoundary';\n/**\n * floating-ui `size` middleware uses floating element's height/width to calculate available height/width.\n * This middleware only runs once per lifecycle, resetting styles applied by maxSize from previous lifecycle.\n * Then floating element's original size is restored and `size` middleware can calculate available height/width correctly.\n */ export const resetMaxSize = (autoSize)=>({\n name: 'resetMaxSize',\n fn ({ middlewareData: { maxSizeAlreadyReset } , elements }) {\n if (maxSizeAlreadyReset) {\n return {};\n }\n const { applyMaxWidth , applyMaxHeight } = autoSize;\n if (applyMaxWidth) {\n elements.floating.style.removeProperty('box-sizing');\n elements.floating.style.removeProperty('max-width');\n elements.floating.style.removeProperty('width');\n }\n if (applyMaxHeight) {\n elements.floating.style.removeProperty('box-sizing');\n elements.floating.style.removeProperty('max-height');\n elements.floating.style.removeProperty('height');\n }\n return {\n data: {\n maxSizeAlreadyReset: true\n },\n reset: {\n rects: true\n }\n };\n }\n });\nexport function maxSize(autoSize, options) {\n const { container , overflowBoundary } = options;\n return size({\n ...overflowBoundary && {\n altBoundary: true,\n boundary: getBoundary(container, overflowBoundary)\n },\n apply ({ availableHeight , availableWidth , elements , rects }) {\n const applyMaxSizeStyles = (apply, dimension, availableSize)=>{\n if (!apply) {\n return;\n }\n elements.floating.style.setProperty('box-sizing', 'border-box');\n elements.floating.style.setProperty(`max-${dimension}`, `${availableSize}px`);\n if (rects.floating[dimension] > availableSize) {\n elements.floating.style.setProperty(dimension, `${availableSize}px`);\n const axis = dimension === 'width' ? 'x' : 'y';\n if (!elements.floating.style.getPropertyValue(`overflow-${axis}`)) {\n elements.floating.style.setProperty(`overflow-${axis}`, 'auto');\n }\n }\n };\n const { applyMaxWidth , applyMaxHeight } = autoSize;\n applyMaxSizeStyles(applyMaxWidth, 'width', availableWidth);\n applyMaxSizeStyles(applyMaxHeight, 'height', availableHeight);\n }\n });\n}\n"],"names":["resetMaxSize","maxSize","autoSize","name","fn","middlewareData","maxSizeAlreadyReset","elements","applyMaxWidth","applyMaxHeight","floating","style","removeProperty","data","reset","rects","options","container","overflowBoundary","size","altBoundary","boundary","getBoundary","apply","availableHeight","availableWidth","applyMaxSizeStyles","dimension","availableSize","setProperty","axis","getPropertyValue"],"mappings":";;;;;;;;;;;IAMiBA,YAAY,MAAZA;IA2BDC,OAAO,MAAPA;;qBAjCK;6BACO;AAKjB,MAAMD,eAAe,CAACE,WAAY,CAAA;QACrCC,MAAM;QACNC,IAAI,EAAEC,gBAAgB,EAAEC,oBAAmB,EAAG,CAAA,EAAGC,SAAQ,EAAG,EAAE;YAC1D,IAAID,qBAAqB;gBACrB,OAAO,CAAC;YACZ,CAAC;YACD,MAAM,EAAEE,cAAa,EAAGC,eAAc,EAAG,GAAGP;YAC5C,IAAIM,eAAe;gBACfD,SAASG,QAAQ,CAACC,KAAK,CAACC,cAAc,CAAC;gBACvCL,SAASG,QAAQ,CAACC,KAAK,CAACC,cAAc,CAAC;gBACvCL,SAASG,QAAQ,CAACC,KAAK,CAACC,cAAc,CAAC;YAC3C,CAAC;YACD,IAAIH,gBAAgB;gBAChBF,SAASG,QAAQ,CAACC,KAAK,CAACC,cAAc,CAAC;gBACvCL,SAASG,QAAQ,CAACC,KAAK,CAACC,cAAc,CAAC;gBACvCL,SAASG,QAAQ,CAACC,KAAK,CAACC,cAAc,CAAC;YAC3C,CAAC;YACD,OAAO;gBACHC,MAAM;oBACFP,qBAAqB,IAAI;gBAC7B;gBACAQ,OAAO;oBACHC,OAAO,IAAI;gBACf;YACJ;QACJ;IACJ,CAAA;AACG,SAASd,QAAQC,QAAQ,EAAEc,OAAO,EAAE;IACvC,MAAM,EAAEC,UAAS,EAAGC,iBAAgB,EAAG,GAAGF;IAC1C,OAAOG,IAAAA,SAAI,EAAC;QACR,GAAGD,oBAAoB;YACnBE,aAAa,IAAI;YACjBC,UAAUC,IAAAA,wBAAW,EAACL,WAAWC;QACrC,CAAC;QACDK,OAAO,EAAEC,gBAAe,EAAGC,eAAc,EAAGlB,SAAQ,EAAGQ,MAAK,EAAG,EAAE;YAC7D,MAAMW,qBAAqB,CAACH,OAAOI,WAAWC,gBAAgB;gBAC1D,IAAI,CAACL,OAAO;oBACR;gBACJ,CAAC;gBACDhB,SAASG,QAAQ,CAACC,KAAK,CAACkB,WAAW,CAAC,cAAc;gBAClDtB,SAASG,QAAQ,CAACC,KAAK,CAACkB,WAAW,CAAC,CAAC,IAAI,EAAEF,UAAU,CAAC,EAAE,CAAC,EAAEC,cAAc,EAAE,CAAC;gBAC5E,IAAIb,MAAML,QAAQ,CAACiB,UAAU,GAAGC,eAAe;oBAC3CrB,SAASG,QAAQ,CAACC,KAAK,CAACkB,WAAW,CAACF,WAAW,CAAC,EAAEC,cAAc,EAAE,CAAC;oBACnE,MAAME,OAAOH,cAAc,UAAU,MAAM,GAAG;oBAC9C,IAAI,CAACpB,SAASG,QAAQ,CAACC,KAAK,CAACoB,gBAAgB,CAAC,CAAC,SAAS,EAAED,KAAK,CAAC,GAAG;wBAC/DvB,SAASG,QAAQ,CAACC,KAAK,CAACkB,WAAW,CAAC,CAAC,SAAS,EAAEC,KAAK,CAAC,EAAE;oBAC5D,CAAC;gBACL,CAAC;YACL;YACA,MAAM,EAAEtB,cAAa,EAAGC,eAAc,EAAG,GAAGP;YAC5CwB,mBAAmBlB,eAAe,SAASiB;YAC3CC,mBAAmBjB,gBAAgB,UAAUe;QACjD;IACJ;AACJ"}
@@ -143,13 +143,15 @@ function usePositioning(options) {
143
143
  };
144
144
  }
145
145
  function usePositioningOptions(options) {
146
- const { align , arrowPadding , autoSize , coverTarget , flipBoundary , offset , overflowBoundary , pinned , position , unstable_disableTether: disableTether , positionFixed , strategy , overflowBoundaryPadding , fallbackPositions , useTransform } = options;
146
+ const { align , arrowPadding , autoSize: rawAutoSize , coverTarget , flipBoundary , offset , overflowBoundary , pinned , position , unstable_disableTether: disableTether , positionFixed , strategy , overflowBoundaryPadding , fallbackPositions , useTransform } = options;
147
147
  const { dir } = (0, _reactSharedContexts.useFluent_unstable)();
148
148
  const isRtl = dir === 'rtl';
149
149
  const positionStrategy = (strategy !== null && strategy !== void 0 ? strategy : positionFixed) ? 'fixed' : 'absolute';
150
+ const autoSize = (0, _utils.normalizeAutoSize)(rawAutoSize);
150
151
  return _react.useCallback((container, arrow)=>{
151
152
  const hasScrollableElement = (0, _utils.hasScrollParent)(container);
152
153
  const middleware = [
154
+ autoSize && (0, _middleware.resetMaxSize)(autoSize),
153
155
  offset && (0, _middleware.offset)(offset),
154
156
  coverTarget && (0, _middleware.coverTarget)(),
155
157
  !pinned && (0, _middleware.flip)({
@@ -1 +1 @@
1
- {"version":3,"sources":["usePositioning.js"],"sourcesContent":["import { hide as hideMiddleware, arrow as arrowMiddleware } from '@floating-ui/dom';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { canUseDOM, useEventCallback, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport { useCallbackRef, toFloatingUIPlacement, hasAutofocusFilter, hasScrollParent } from './utils';\nimport { shift as shiftMiddleware, flip as flipMiddleware, coverTarget as coverTargetMiddleware, maxSize as maxSizeMiddleware, offset as offsetMiddleware, intersecting as intersectingMiddleware } from './middleware';\nimport { createPositionManager } from './createPositionManager';\n/**\n * @internal\n */ export function usePositioning(options) {\n const managerRef = React.useRef(null);\n const targetRef = React.useRef(null);\n const overrideTargetRef = React.useRef(null);\n const containerRef = React.useRef(null);\n const arrowRef = React.useRef(null);\n const { enabled =true } = options;\n const resolvePositioningOptions = usePositioningOptions(options);\n const updatePositionManager = React.useCallback(()=>{\n if (managerRef.current) {\n managerRef.current.dispose();\n }\n managerRef.current = null;\n var _overrideTargetRef_current;\n const target = (_overrideTargetRef_current = overrideTargetRef.current) !== null && _overrideTargetRef_current !== void 0 ? _overrideTargetRef_current : targetRef.current;\n if (enabled && canUseDOM() && target && containerRef.current) {\n managerRef.current = createPositionManager({\n container: containerRef.current,\n target,\n arrow: arrowRef.current,\n ...resolvePositioningOptions(containerRef.current, arrowRef.current)\n });\n }\n }, [\n enabled,\n resolvePositioningOptions\n ]);\n const setOverrideTarget = useEventCallback((target)=>{\n overrideTargetRef.current = target;\n updatePositionManager();\n });\n React.useImperativeHandle(options.positioningRef, ()=>{\n return {\n updatePosition: ()=>{\n var _managerRef_current;\n return (_managerRef_current = managerRef.current) === null || _managerRef_current === void 0 ? void 0 : _managerRef_current.updatePosition();\n },\n setTarget: (target)=>{\n if (options.target && process.env.NODE_ENV !== 'production') {\n const err = new Error();\n // eslint-disable-next-line no-console\n console.warn('Imperative setTarget should not be used at the same time as target option');\n // eslint-disable-next-line no-console\n console.warn(err.stack);\n }\n setOverrideTarget(target);\n }\n };\n }, [\n options.target,\n setOverrideTarget\n ]);\n useIsomorphicLayoutEffect(()=>{\n var _options_target;\n setOverrideTarget((_options_target = options.target) !== null && _options_target !== void 0 ? _options_target : null);\n }, [\n options.target,\n setOverrideTarget\n ]);\n useIsomorphicLayoutEffect(()=>{\n updatePositionManager();\n }, [\n updatePositionManager\n ]);\n if (process.env.NODE_ENV !== 'production') {\n // This checked should run only in development mode\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(()=>{\n if (containerRef.current) {\n var _contentNode_ownerDocument;\n const contentNode = containerRef.current;\n const treeWalker = (_contentNode_ownerDocument = contentNode.ownerDocument) === null || _contentNode_ownerDocument === void 0 ? void 0 : _contentNode_ownerDocument.createTreeWalker(contentNode, NodeFilter.SHOW_ELEMENT, {\n acceptNode: hasAutofocusFilter\n });\n while(treeWalker.nextNode()){\n const node = treeWalker.currentNode;\n // eslint-disable-next-line no-console\n console.warn('<Popper>:', node);\n // eslint-disable-next-line no-console\n console.warn([\n '<Popper>: ^ this node contains \"autoFocus\" prop on a React element. This can break the initial',\n 'positioning of an element and cause a window jump effect. This issue occurs because React polyfills',\n '\"autoFocus\" behavior to solve inconsistencies between different browsers:',\n 'https://github.com/facebook/react/issues/11851#issuecomment-351787078',\n '\\n',\n 'However, \".focus()\" in this case occurs before any other React effects will be executed',\n '(React.useEffect(), componentDidMount(), etc.) and we can not prevent this behavior. If you really',\n 'want to use \"autoFocus\" please add \"position: fixed\" to styles of the element that is wrapped by',\n '\"Popper\".',\n `In general, it's not recommended to use \"autoFocus\" as it may break accessibility aspects:`,\n 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md',\n '\\n',\n 'We suggest to use the \"trapFocus\" prop on Fluent components or a catch \"ref\" and then use',\n '\"ref.current.focus\" in React.useEffect():',\n 'https://reactjs.org/docs/refs-and-the-dom.html#adding-a-ref-to-a-dom-element'\n ].join(' '));\n }\n }\n // We run this check once, no need to add deps here\n // TODO: Should be rework to handle options.enabled and contentRef updates\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n }\n const setTarget = useCallbackRef(null, (target)=>{\n if (targetRef.current !== target) {\n targetRef.current = target;\n updatePositionManager();\n }\n });\n const setContainer = useCallbackRef(null, (container)=>{\n if (containerRef.current !== container) {\n containerRef.current = container;\n updatePositionManager();\n }\n });\n const setArrow = useCallbackRef(null, (arrow)=>{\n if (arrowRef.current !== arrow) {\n arrowRef.current = arrow;\n updatePositionManager();\n }\n });\n // Let users use callback refs so they feel like 'normal' DOM refs\n return {\n targetRef: setTarget,\n containerRef: setContainer,\n arrowRef: setArrow\n };\n}\nfunction usePositioningOptions(options) {\n const { align , arrowPadding , autoSize , coverTarget , flipBoundary , offset , overflowBoundary , pinned , position , unstable_disableTether: disableTether , // eslint-disable-next-line deprecation/deprecation\n positionFixed , strategy , overflowBoundaryPadding , fallbackPositions , useTransform } = options;\n const { dir } = useFluent();\n const isRtl = dir === 'rtl';\n const positionStrategy = (strategy !== null && strategy !== void 0 ? strategy : positionFixed) ? 'fixed' : 'absolute';\n return React.useCallback((container, arrow)=>{\n const hasScrollableElement = hasScrollParent(container);\n const middleware = [\n offset && offsetMiddleware(offset),\n coverTarget && coverTargetMiddleware(),\n !pinned && flipMiddleware({\n container,\n flipBoundary,\n hasScrollableElement,\n isRtl,\n fallbackPositions\n }),\n shiftMiddleware({\n container,\n hasScrollableElement,\n overflowBoundary,\n disableTether,\n overflowBoundaryPadding,\n isRtl\n }),\n autoSize && maxSizeMiddleware(autoSize, {\n container,\n overflowBoundary\n }),\n intersectingMiddleware(),\n arrow && arrowMiddleware({\n element: arrow,\n padding: arrowPadding\n }),\n hideMiddleware({\n strategy: 'referenceHidden'\n }),\n hideMiddleware({\n strategy: 'escaped'\n })\n ].filter(Boolean);\n const placement = toFloatingUIPlacement(align, position, isRtl);\n return {\n placement,\n middleware,\n strategy: positionStrategy,\n useTransform\n };\n }, [\n align,\n arrowPadding,\n autoSize,\n coverTarget,\n disableTether,\n flipBoundary,\n isRtl,\n offset,\n overflowBoundary,\n pinned,\n position,\n positionStrategy,\n overflowBoundaryPadding,\n fallbackPositions,\n useTransform\n ]);\n}\n"],"names":["usePositioning","options","managerRef","React","useRef","targetRef","overrideTargetRef","containerRef","arrowRef","enabled","resolvePositioningOptions","usePositioningOptions","updatePositionManager","useCallback","current","dispose","_overrideTargetRef_current","target","canUseDOM","createPositionManager","container","arrow","setOverrideTarget","useEventCallback","useImperativeHandle","positioningRef","updatePosition","_managerRef_current","setTarget","process","env","NODE_ENV","err","Error","console","warn","stack","useIsomorphicLayoutEffect","_options_target","useEffect","_contentNode_ownerDocument","contentNode","treeWalker","ownerDocument","createTreeWalker","NodeFilter","SHOW_ELEMENT","acceptNode","hasAutofocusFilter","nextNode","node","currentNode","join","useCallbackRef","setContainer","setArrow","align","arrowPadding","autoSize","coverTarget","flipBoundary","offset","overflowBoundary","pinned","position","unstable_disableTether","disableTether","positionFixed","strategy","overflowBoundaryPadding","fallbackPositions","useTransform","dir","useFluent","isRtl","positionStrategy","hasScrollableElement","hasScrollParent","middleware","offsetMiddleware","coverTargetMiddleware","flipMiddleware","shiftMiddleware","maxSizeMiddleware","intersectingMiddleware","arrowMiddleware","element","padding","hideMiddleware","filter","Boolean","placement","toFloatingUIPlacement"],"mappings":";;;;+BASoBA;;aAAAA;;;qBAT6C;qCACjB;gCACuB;6DAChD;uBACoE;4BAC8G;uCACnK;AAG3B,SAASA,eAAeC,OAAO,EAAE;IACxC,MAAMC,aAAaC,OAAMC,MAAM,CAAC,IAAI;IACpC,MAAMC,YAAYF,OAAMC,MAAM,CAAC,IAAI;IACnC,MAAME,oBAAoBH,OAAMC,MAAM,CAAC,IAAI;IAC3C,MAAMG,eAAeJ,OAAMC,MAAM,CAAC,IAAI;IACtC,MAAMI,WAAWL,OAAMC,MAAM,CAAC,IAAI;IAClC,MAAM,EAAEK,SAAS,IAAI,CAAA,EAAG,GAAGR;IAC3B,MAAMS,4BAA4BC,sBAAsBV;IACxD,MAAMW,wBAAwBT,OAAMU,WAAW,CAAC,IAAI;QAChD,IAAIX,WAAWY,OAAO,EAAE;YACpBZ,WAAWY,OAAO,CAACC,OAAO;QAC9B,CAAC;QACDb,WAAWY,OAAO,GAAG,IAAI;QACzB,IAAIE;QACJ,MAAMC,SAAS,AAACD,CAAAA,6BAA6BV,kBAAkBQ,OAAO,AAAD,MAAO,IAAI,IAAIE,+BAA+B,KAAK,IAAIA,6BAA6BX,UAAUS,OAAO;QAC1K,IAAIL,WAAWS,IAAAA,yBAAS,OAAMD,UAAUV,aAAaO,OAAO,EAAE;YAC1DZ,WAAWY,OAAO,GAAGK,IAAAA,4CAAqB,EAAC;gBACvCC,WAAWb,aAAaO,OAAO;gBAC/BG;gBACAI,OAAOb,SAASM,OAAO;gBACvB,GAAGJ,0BAA0BH,aAAaO,OAAO,EAAEN,SAASM,OAAO,CAAC;YACxE;QACJ,CAAC;IACL,GAAG;QACCL;QACAC;KACH;IACD,MAAMY,oBAAoBC,IAAAA,gCAAgB,EAAC,CAACN,SAAS;QACjDX,kBAAkBQ,OAAO,GAAGG;QAC5BL;IACJ;IACAT,OAAMqB,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F,MAAM,EAAEuE,IAAG,EAAG,GAAGC,IAAAA,uCAAS;IAC1B,MAAMC,QAAQF,QAAQ;IACtB,MAAMG,mBAAmB,AAACP,CAAAA,aAAa,IAAI,IAAIA,aAAa,KAAK,IAAIA,WAAWD,aAAa,AAAD,IAAK,UAAU,UAAU;IACrH,OAAOhE,OAAMU,WAAW,CAAC,CAACO,WAAWC,QAAQ;QACzC,MAAMuD,uBAAuBC,IAAAA,sBAAe,EAACzD;QAC7C,MAAM0D,aAAa;YACfjB,UAAUkB,IAAAA,kBAAgB,EAAClB;YAC3BF,eAAeqB,IAAAA,uBAAqB;YACpC,CAACjB,UAAUkB,IAAAA,gBAAc,EAAC;gBACtB7D;gBACAwC;gBACAgB;gBACAF;gBACAJ;YACJ;YACAY,IAAAA,iBAAe,EAAC;gBACZ9D;gBACAwD;gBACAd;gBACAI;gBACAG;gBACAK;YACJ;YACAhB,YAAYyB,IAAAA,mBAAiB,EAACzB,UAAU;gBACpCtC;gBACA0C;YACJ;YACAsB,IAAAA,wBAAsB;YACtB/D,SAASgE,IAAAA,UAAe,EAAC;gBACrBC,SAASjE;gBACTkE,SAAS9B;YACb;YACA+B,IAAAA,SAAc,EAAC;gBACXpB,UAAU;YACd;YACAoB,IAAAA,SAAc,EAAC;gBACXpB,UAAU;YACd;SACH,CAACqB,MAAM,CAACC;QACT,MAAMC,YAAYC,IAAAA,4BAAqB,EAACpC,OAAOQ,UAAUU;QACzD,OAAO;YACHiB;YACAb;YACAV,UAAUO;YACVJ;QACJ;IACJ,GAAG;QACCf;QACAC;QACAC;QACAC;QACAO;QACAN;QACAc;QACAb;QACAC;QACAC;QACAC;QACAW;QACAN;QACAC;QACAC;KACH;AACL"}
1
+ {"version":3,"sources":["usePositioning.js"],"sourcesContent":["import { hide as hideMiddleware, arrow as arrowMiddleware } from '@floating-ui/dom';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { canUseDOM, useEventCallback, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport { useCallbackRef, toFloatingUIPlacement, hasAutofocusFilter, hasScrollParent, normalizeAutoSize } from './utils';\nimport { shift as shiftMiddleware, flip as flipMiddleware, coverTarget as coverTargetMiddleware, maxSize as maxSizeMiddleware, resetMaxSize as resetMaxSizeMiddleware, offset as offsetMiddleware, intersecting as intersectingMiddleware } from './middleware';\nimport { createPositionManager } from './createPositionManager';\n/**\n * @internal\n */ export function usePositioning(options) {\n const managerRef = React.useRef(null);\n const targetRef = React.useRef(null);\n const overrideTargetRef = React.useRef(null);\n const containerRef = React.useRef(null);\n const arrowRef = React.useRef(null);\n const { enabled =true } = options;\n const resolvePositioningOptions = usePositioningOptions(options);\n const updatePositionManager = React.useCallback(()=>{\n if (managerRef.current) {\n managerRef.current.dispose();\n }\n managerRef.current = null;\n var _overrideTargetRef_current;\n const target = (_overrideTargetRef_current = overrideTargetRef.current) !== null && _overrideTargetRef_current !== void 0 ? _overrideTargetRef_current : targetRef.current;\n if (enabled && canUseDOM() && target && containerRef.current) {\n managerRef.current = createPositionManager({\n container: containerRef.current,\n target,\n arrow: arrowRef.current,\n ...resolvePositioningOptions(containerRef.current, arrowRef.current)\n });\n }\n }, [\n enabled,\n resolvePositioningOptions\n ]);\n const setOverrideTarget = useEventCallback((target)=>{\n overrideTargetRef.current = target;\n updatePositionManager();\n });\n React.useImperativeHandle(options.positioningRef, ()=>{\n return {\n updatePosition: ()=>{\n var _managerRef_current;\n return (_managerRef_current = managerRef.current) === null || _managerRef_current === void 0 ? void 0 : _managerRef_current.updatePosition();\n },\n setTarget: (target)=>{\n if (options.target && process.env.NODE_ENV !== 'production') {\n const err = new Error();\n // eslint-disable-next-line no-console\n console.warn('Imperative setTarget should not be used at the same time as target option');\n // eslint-disable-next-line no-console\n console.warn(err.stack);\n }\n setOverrideTarget(target);\n }\n };\n }, [\n options.target,\n setOverrideTarget\n ]);\n useIsomorphicLayoutEffect(()=>{\n var _options_target;\n setOverrideTarget((_options_target = options.target) !== null && _options_target !== void 0 ? _options_target : null);\n }, [\n options.target,\n setOverrideTarget\n ]);\n useIsomorphicLayoutEffect(()=>{\n updatePositionManager();\n }, [\n updatePositionManager\n ]);\n if (process.env.NODE_ENV !== 'production') {\n // This checked should run only in development mode\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(()=>{\n if (containerRef.current) {\n var _contentNode_ownerDocument;\n const contentNode = containerRef.current;\n const treeWalker = (_contentNode_ownerDocument = contentNode.ownerDocument) === null || _contentNode_ownerDocument === void 0 ? void 0 : _contentNode_ownerDocument.createTreeWalker(contentNode, NodeFilter.SHOW_ELEMENT, {\n acceptNode: hasAutofocusFilter\n });\n while(treeWalker.nextNode()){\n const node = treeWalker.currentNode;\n // eslint-disable-next-line no-console\n console.warn('<Popper>:', node);\n // eslint-disable-next-line no-console\n console.warn([\n '<Popper>: ^ this node contains \"autoFocus\" prop on a React element. This can break the initial',\n 'positioning of an element and cause a window jump effect. This issue occurs because React polyfills',\n '\"autoFocus\" behavior to solve inconsistencies between different browsers:',\n 'https://github.com/facebook/react/issues/11851#issuecomment-351787078',\n '\\n',\n 'However, \".focus()\" in this case occurs before any other React effects will be executed',\n '(React.useEffect(), componentDidMount(), etc.) and we can not prevent this behavior. If you really',\n 'want to use \"autoFocus\" please add \"position: fixed\" to styles of the element that is wrapped by',\n '\"Popper\".',\n `In general, it's not recommended to use \"autoFocus\" as it may break accessibility aspects:`,\n 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md',\n '\\n',\n 'We suggest to use the \"trapFocus\" prop on Fluent components or a catch \"ref\" and then use',\n '\"ref.current.focus\" in React.useEffect():',\n 'https://reactjs.org/docs/refs-and-the-dom.html#adding-a-ref-to-a-dom-element'\n ].join(' '));\n }\n }\n // We run this check once, no need to add deps here\n // TODO: Should be rework to handle options.enabled and contentRef updates\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n }\n const setTarget = useCallbackRef(null, (target)=>{\n if (targetRef.current !== target) {\n targetRef.current = target;\n updatePositionManager();\n }\n });\n const setContainer = useCallbackRef(null, (container)=>{\n if (containerRef.current !== container) {\n containerRef.current = container;\n updatePositionManager();\n }\n });\n const setArrow = useCallbackRef(null, (arrow)=>{\n if (arrowRef.current !== arrow) {\n arrowRef.current = arrow;\n updatePositionManager();\n }\n });\n // Let users use callback refs so they feel like 'normal' DOM refs\n return {\n targetRef: setTarget,\n containerRef: setContainer,\n arrowRef: setArrow\n };\n}\nfunction usePositioningOptions(options) {\n const { align , arrowPadding , autoSize: rawAutoSize , coverTarget , flipBoundary , offset , overflowBoundary , pinned , position , unstable_disableTether: disableTether , // eslint-disable-next-line deprecation/deprecation\n positionFixed , strategy , overflowBoundaryPadding , fallbackPositions , useTransform } = options;\n const { dir } = useFluent();\n const isRtl = dir === 'rtl';\n const positionStrategy = (strategy !== null && strategy !== void 0 ? strategy : positionFixed) ? 'fixed' : 'absolute';\n const autoSize = normalizeAutoSize(rawAutoSize);\n return React.useCallback((container, arrow)=>{\n const hasScrollableElement = hasScrollParent(container);\n const middleware = [\n autoSize && resetMaxSizeMiddleware(autoSize),\n offset && offsetMiddleware(offset),\n coverTarget && coverTargetMiddleware(),\n !pinned && flipMiddleware({\n container,\n flipBoundary,\n hasScrollableElement,\n isRtl,\n fallbackPositions\n }),\n shiftMiddleware({\n container,\n hasScrollableElement,\n overflowBoundary,\n disableTether,\n overflowBoundaryPadding,\n isRtl\n }),\n autoSize && maxSizeMiddleware(autoSize, {\n container,\n overflowBoundary\n }),\n intersectingMiddleware(),\n arrow && arrowMiddleware({\n element: arrow,\n padding: arrowPadding\n }),\n hideMiddleware({\n strategy: 'referenceHidden'\n }),\n hideMiddleware({\n strategy: 'escaped'\n })\n ].filter(Boolean);\n const placement = toFloatingUIPlacement(align, position, isRtl);\n return {\n placement,\n middleware,\n strategy: positionStrategy,\n useTransform\n };\n }, [\n align,\n arrowPadding,\n autoSize,\n coverTarget,\n disableTether,\n flipBoundary,\n isRtl,\n offset,\n overflowBoundary,\n pinned,\n position,\n positionStrategy,\n overflowBoundaryPadding,\n fallbackPositions,\n useTransform\n ]);\n}\n"],"names":["usePositioning","options","managerRef","React","useRef","targetRef","overrideTargetRef","containerRef","arrowRef","enabled","resolvePositioningOptions","usePositioningOptions","updatePositionManager","useCallback","current","dispose","_overrideTargetRef_current","target","canUseDOM","createPositionManager","container","arrow","setOverrideTarget","useEventCallback","useImperativeHandle","positioningRef","updatePosition","_managerRef_current","setTarget","process","env","NODE_ENV","err","Error","console","warn","stack","useIsomorphicLayoutEffect","_options_target","useEffect","_contentNode_ownerDocument","contentNode","treeWalker","ownerDocument","createTreeWalker","NodeFilter","SHOW_ELEMENT","acceptNode","hasAutofocusFilter","nextNode","node","currentNode","join","useCallbackRef","setContainer","setArrow","align","arrowPadding","autoSize","rawAutoSize","coverTarget","flipBoundary","offset","overflowBoundary","pinned","position","unstable_disableTether","disableTether","positionFixed","strategy","overflowBoundaryPadding","fallbackPositions","useTransform","dir","useFluent","isRtl","positionStrategy","normalizeAutoSize","hasScrollableElement","hasScrollParent","middleware","resetMaxSizeMiddleware","offsetMiddleware","coverTargetMiddleware","flipMiddleware","shiftMiddleware","maxSizeMiddleware","intersectingMiddleware","arrowMiddleware","element","padding","hideMiddleware","filter","Boolean","placement","toFloatingUIPlacement"],"mappings":";;;;+BASoBA;;aAAAA;;;qBAT6C;qCACjB;gCACuB;6DAChD;uBACuF;4BACmI;uCAC3M;AAG3B,SAASA,eAAeC,OAAO,EAAE;IACxC,MAAMC,aAAaC,OAAMC,MAAM,CAAC,IAAI;IACpC,MAAMC,YAAYF,OAAMC,MAAM,CAAC,IAAI;IACnC,MAAME,oBAAoBH,OAAMC,MAAM,CAAC,IAAI;IAC3C,MAAMG,eAAeJ,OAAMC,MAAM,CAAC,IAAI;IACtC,MAAMI,WAAWL,OAAMC,MAAM,CAAC,IAAI;IAClC,MAAM,EAAEK,SAAS,IAAI,CAAA,EAAG,GAAGR;IAC3B,MAAMS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gBAAc,EAAC;gBACtBhE;gBACAyC;gBACAiB;gBACAH;gBACAJ;YACJ;YACAc,IAAAA,iBAAe,EAAC;gBACZjE;gBACA0D;gBACAf;gBACAI;gBACAG;gBACAK;YACJ;YACAjB,YAAY4B,IAAAA,mBAAiB,EAAC5B,UAAU;gBACpCtC;gBACA2C;YACJ;YACAwB,IAAAA,wBAAsB;YACtBlE,SAASmE,IAAAA,UAAe,EAAC;gBACrBC,SAASpE;gBACTqE,SAASjC;YACb;YACAkC,IAAAA,SAAc,EAAC;gBACXtB,UAAU;YACd;YACAsB,IAAAA,SAAc,EAAC;gBACXtB,UAAU;YACd;SACH,CAACuB,MAAM,CAACC;QACT,MAAMC,YAAYC,IAAAA,4BAAqB,EAACvC,OAAOS,UAAUU;QACzD,OAAO;YACHmB;YACAd;YACAX,UAAUO;YACVJ;QACJ;IACJ,GAAG;QACChB;QACAC;QACAC;QACAE;QACAO;QACAN;QACAc;QACAb;QACAC;QACAC;QACAC;QACAW;QACAN;QACAC;QACAC;KACH;AACL"}
@@ -18,3 +18,4 @@ _exportStar(require("./toggleScrollListener"), exports);
18
18
  _exportStar(require("./hasAutoFocusFilter"), exports);
19
19
  _exportStar(require("./writeArrowUpdates"), exports);
20
20
  _exportStar(require("./writeContainerupdates"), exports);
21
+ _exportStar(require("./normalizeAutoSize"), exports);
@@ -1 +1 @@
1
- {"version":3,"sources":["index.js"],"sourcesContent":["export * from './parseFloatingUIPlacement';\nexport * from './getBoundary';\nexport * from './getReactFiberFromNode';\nexport * from './getScrollParent';\nexport * from './mergeArrowOffset';\nexport * from './toFloatingUIPadding';\nexport * from './toFloatingUIPlacement';\nexport * from './fromFloatingUIPlacement';\nexport * from './resolvePositioningShorthand';\nexport * from './useCallbackRef';\nexport * from './debounce';\nexport * from './toggleScrollListener';\nexport * from './hasAutoFocusFilter';\nexport * from './writeArrowUpdates';\nexport * from './writeContainerupdates';\n"],"names":[],"mappings":";;;;;oBAAc;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA"}
1
+ {"version":3,"sources":["index.js"],"sourcesContent":["export * from './parseFloatingUIPlacement';\nexport * from './getBoundary';\nexport * from './getReactFiberFromNode';\nexport * from './getScrollParent';\nexport * from './mergeArrowOffset';\nexport * from './toFloatingUIPadding';\nexport * from './toFloatingUIPlacement';\nexport * from './fromFloatingUIPlacement';\nexport * from './resolvePositioningShorthand';\nexport * from './useCallbackRef';\nexport * from './debounce';\nexport * from './toggleScrollListener';\nexport * from './hasAutoFocusFilter';\nexport * from './writeArrowUpdates';\nexport * from './writeContainerupdates';\nexport * from './normalizeAutoSize';\n"],"names":[],"mappings":";;;;;oBAAc;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * AutoSizes contains many options from historic implementation.
3
+ * Now options 'always'/'height-always'/'width-always' are obsolete.
4
+ * This function maps them to true/'height'/'width'
5
+ */ "use strict";
6
+ Object.defineProperty(exports, "__esModule", {
7
+ value: true
8
+ });
9
+ Object.defineProperty(exports, "normalizeAutoSize", {
10
+ enumerable: true,
11
+ get: ()=>normalizeAutoSize
12
+ });
13
+ const normalizeAutoSize = (autoSize)=>{
14
+ switch(autoSize){
15
+ case 'always':
16
+ case true:
17
+ return {
18
+ applyMaxWidth: true,
19
+ applyMaxHeight: true
20
+ };
21
+ case 'width-always':
22
+ case 'width':
23
+ return {
24
+ applyMaxWidth: true,
25
+ applyMaxHeight: false
26
+ };
27
+ case 'height-always':
28
+ case 'height':
29
+ return {
30
+ applyMaxWidth: false,
31
+ applyMaxHeight: true
32
+ };
33
+ default:
34
+ return false;
35
+ }
36
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["normalizeAutoSize.js"],"sourcesContent":["/**\n * AutoSizes contains many options from historic implementation.\n * Now options 'always'/'height-always'/'width-always' are obsolete.\n * This function maps them to true/'height'/'width'\n */ export const normalizeAutoSize = (autoSize)=>{\n switch(autoSize){\n case 'always':\n case true:\n return {\n applyMaxWidth: true,\n applyMaxHeight: true\n };\n case 'width-always':\n case 'width':\n return {\n applyMaxWidth: true,\n applyMaxHeight: false\n };\n case 'height-always':\n case 'height':\n return {\n applyMaxWidth: false,\n applyMaxHeight: true\n };\n default:\n return false;\n }\n};\n"],"names":["normalizeAutoSize","autoSize","applyMaxWidth","applyMaxHeight"],"mappings":"AAAA;;;;CAIC;;;;+BAAgBA;;aAAAA;;AAAN,MAAMA,oBAAoB,CAACC,WAAW;IAC7C,OAAOA;QACH,KAAK;QACL,KAAK,IAAI;YACL,OAAO;gBACHC,eAAe,IAAI;gBACnBC,gBAAgB,IAAI;YACxB;QACJ,KAAK;QACL,KAAK;YACD,OAAO;gBACHD,eAAe,IAAI;gBACnBC,gBAAgB,KAAK;YACzB;QACJ,KAAK;QACL,KAAK;YACD,OAAO;gBACHD,eAAe,KAAK;gBACpBC,gBAAgB,IAAI;YACxB;QACJ;YACI,OAAO,KAAK;IACpB;AACJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-positioning",
3
- "version": "9.8.0",
3
+ "version": "9.9.0",
4
4
  "description": "A react wrapper around Popper.js for Fluent UI",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -13,7 +13,7 @@
13
13
  "license": "MIT",
14
14
  "scripts": {
15
15
  "build": "just-scripts build",
16
- "bundle-size": "bundle-size measure",
16
+ "bundle-size": "monosize measure",
17
17
  "clean": "just-scripts clean",
18
18
  "code-style": "just-scripts code-style",
19
19
  "just": "just-scripts",