@fluentui/react-positioning 9.16.6 → 9.17.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.
package/CHANGELOG.md CHANGED
@@ -1,12 +1,31 @@
1
1
  # Change Log - @fluentui/react-positioning
2
2
 
3
- This log was last generated on Thu, 27 Mar 2025 21:08:38 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 14 May 2025 18:45:47 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.17.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.17.0)
8
+
9
+ Wed, 14 May 2025 18:45:47 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.16.7..@fluentui/react-positioning_v9.17.0)
11
+
12
+ ### Minor changes
13
+
14
+ - feat: implement shared positioning config ([PR #34300](https://github.com/microsoft/fluentui/pull/34300) by olfedias@microsoft.com)
15
+
16
+ ## [9.16.7](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.16.7)
17
+
18
+ Wed, 16 Apr 2025 19:42:03 GMT
19
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.16.6..@fluentui/react-positioning_v9.16.7)
20
+
21
+ ### Patches
22
+
23
+ - fix(Popover): revert to a single composition mode for slide animations ([PR #34160](https://github.com/microsoft/fluentui/pull/34160) by robertpenner@microsoft.com)
24
+ - Bump @fluentui/react-utilities to v9.19.0 ([PR #34166](https://github.com/microsoft/fluentui/pull/34166) by beachball)
25
+
7
26
  ## [9.16.6](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.16.6)
8
27
 
9
- Thu, 27 Mar 2025 21:08:38 GMT
28
+ Thu, 27 Mar 2025 21:12:51 GMT
10
29
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.16.5..@fluentui/react-positioning_v9.16.6)
11
30
 
12
31
  ### Patches
package/dist/index.d.ts CHANGED
@@ -122,6 +122,21 @@ export declare type Position = 'above' | 'below' | 'before' | 'after';
122
122
 
123
123
  export declare type PositioningBoundary = PositioningRect | HTMLElement | Array<HTMLElement> | 'clippingParents' | 'scrollParent' | 'window';
124
124
 
125
+ export declare type PositioningConfigurationFn = (params: {
126
+ container: HTMLElement;
127
+ arrow: HTMLElement | null;
128
+ options: PositioningConfigurationFnOptions;
129
+ }) => PositioningConfigurationFnOptions;
130
+
131
+ export declare type PositioningConfigurationFnOptions = Omit<PositioningOptions, 'enabled' | 'onPositioningEnd' | 'positionFixed'>;
132
+
133
+ /**
134
+ * A context provider for the positioning configuration.
135
+ *
136
+ * Accepts a function that takes the positioning options and returns them modified.
137
+ */
138
+ export declare const PositioningConfigurationProvider: React_2.Provider<PositioningConfigurationFn | undefined>;
139
+
125
140
  export declare type PositioningImperativeRef = {
126
141
  /**
127
142
  * Updates the position imperatively.
@@ -0,0 +1,16 @@
1
+ import * as React from 'react';
2
+ // ---
3
+ const DEFAULT_CONFIGURATION = ({ options })=>{
4
+ return options;
5
+ };
6
+ // ---
7
+ const PositioningConfigurationContext = React.createContext(undefined);
8
+ /**
9
+ * A context provider for the positioning configuration.
10
+ *
11
+ * Accepts a function that takes the positioning options and returns them modified.
12
+ */ export const PositioningConfigurationProvider = PositioningConfigurationContext.Provider;
13
+ export const usePositioningConfiguration = ()=>{
14
+ var _React_useContext;
15
+ return (_React_useContext = React.useContext(PositioningConfigurationContext)) !== null && _React_useContext !== void 0 ? _React_useContext : DEFAULT_CONFIGURATION;
16
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/PositioningConfigurationContext.ts"],"sourcesContent":["import * as React from 'react';\nimport type { PositioningConfigurationFn } from './types';\n\n// ---\n\nconst DEFAULT_CONFIGURATION: PositioningConfigurationFn = ({ options }) => {\n return options;\n};\n\n// ---\n\nconst PositioningConfigurationContext = React.createContext<PositioningConfigurationFn | undefined>(undefined);\n\n/**\n * A context provider for the positioning configuration.\n *\n * Accepts a function that takes the positioning options and returns them modified.\n */\nexport const PositioningConfigurationProvider = PositioningConfigurationContext.Provider;\n\nexport const usePositioningConfiguration = (): PositioningConfigurationFn => {\n return React.useContext(PositioningConfigurationContext) ?? DEFAULT_CONFIGURATION;\n};\n"],"names":["React","DEFAULT_CONFIGURATION","options","PositioningConfigurationContext","createContext","undefined","PositioningConfigurationProvider","Provider","usePositioningConfiguration","useContext"],"rangeMappings":";;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAG/B,MAAM;AAEN,MAAMC,wBAAoD,CAAC,EAAEC,OAAO,EAAE;IACpE,OAAOA;AACT;AAEA,MAAM;AAEN,MAAMC,kCAAkCH,MAAMI,aAAa,CAAyCC;AAEpG;;;;CAIC,GACD,OAAO,MAAMC,mCAAmCH,gCAAgCI,QAAQ,CAAC;AAEzF,OAAO,MAAMC,8BAA8B;QAClCR;IAAP,OAAOA,CAAAA,oBAAAA,MAAMS,UAAU,CAACN,8CAAjBH,+BAAAA,oBAAqDC;AAC9D,EAAE"}
@@ -5,19 +5,22 @@ import { DATA_POSITIONING_PLACEMENT } from './constants';
5
5
  * @param mainAxis - distance than the element sides for
6
6
  * @returns Griffel styles to spread to a slot
7
7
  */ export function createSlideStyles(mainAxis) {
8
+ // With 'accumulate' animation composition, these opacity keyframes are added onto the default opacity of 1.
8
9
  const fadeIn = {
9
10
  from: {
10
- opacity: 0
11
+ opacity: -1
11
12
  },
12
13
  to: {
13
- opacity: 1
14
+ opacity: 0
14
15
  }
15
16
  };
16
17
  const slideDistanceVarX = '--fui-positioning-slide-distance-x';
17
18
  const slideDistanceVarY = '--fui-positioning-slide-distance-y';
18
19
  return {
19
- // The fade has absolute values, whereas the slide amount is relative.
20
- animationComposition: 'replace, accumulate',
20
+ // NOTE: there was a previous attempt to give fadeIn a separate composition mode:
21
+ // animationComposition: 'replace, accumulate',
22
+ // but somehow this was linked to a performance regression observed in Teams (bug #4255933)
23
+ animationComposition: 'accumulate',
21
24
  animationDuration: tokens.durationSlower,
22
25
  animationTimingFunction: tokens.curveDecelerateMid,
23
26
  [slideDistanceVarX]: `0px`,
@@ -46,7 +49,6 @@ import { DATA_POSITIONING_PLACEMENT } from './constants';
46
49
  // Note: at-rules have more specificity in Griffel
47
50
  '@media(prefers-reduced-motion)': {
48
51
  [`&[${DATA_POSITIONING_PLACEMENT}]`]: {
49
- animationComposition: 'replace',
50
52
  animationDuration: '1ms',
51
53
  animationName: fadeIn
52
54
  }
@@ -54,7 +56,6 @@ import { DATA_POSITIONING_PLACEMENT } from './constants';
54
56
  // Tested in Firefox 79
55
57
  '@supports not (animation-composition: accumulate)': {
56
58
  [`&[${DATA_POSITIONING_PLACEMENT}]`]: {
57
- animationComposition: 'replace',
58
59
  animationName: fadeIn
59
60
  }
60
61
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/createSlideStyles.ts"],"sourcesContent":["import { tokens } from '@fluentui/react-theme';\nimport type { GriffelStyle } from '@griffel/react';\nimport { DATA_POSITIONING_PLACEMENT } from './constants';\n\n/**\n * Creates animation styles so that positioned elements slide in from the main axis\n * @param mainAxis - distance than the element sides for\n * @returns Griffel styles to spread to a slot\n */\nexport function createSlideStyles(mainAxis: number): GriffelStyle {\n const fadeIn = {\n from: {\n opacity: 0,\n },\n to: {\n opacity: 1,\n },\n };\n\n const slideDistanceVarX = '--fui-positioning-slide-distance-x';\n const slideDistanceVarY = '--fui-positioning-slide-distance-y';\n\n return {\n // The fade has absolute values, whereas the slide amount is relative.\n animationComposition: 'replace, accumulate',\n animationDuration: tokens.durationSlower,\n animationTimingFunction: tokens.curveDecelerateMid,\n [slideDistanceVarX]: `0px`,\n [slideDistanceVarY]: `${mainAxis}px`,\n [`&[${DATA_POSITIONING_PLACEMENT}^=right]`]: {\n [slideDistanceVarX]: `-${mainAxis}px`,\n [slideDistanceVarY]: '0px',\n },\n\n [`&[${DATA_POSITIONING_PLACEMENT}^=bottom]`]: {\n [slideDistanceVarX]: '0px',\n [slideDistanceVarY]: `-${mainAxis}px`,\n },\n\n [`&[${DATA_POSITIONING_PLACEMENT}^=left]`]: {\n [slideDistanceVarX]: `${mainAxis}px`,\n [slideDistanceVarY]: '0px',\n },\n\n animationName: [\n fadeIn,\n {\n from: {\n transform: `translate(var(${slideDistanceVarX}), var(${slideDistanceVarY}))`,\n },\n to: {},\n },\n ],\n\n // Note: at-rules have more specificity in Griffel\n '@media(prefers-reduced-motion)': {\n [`&[${DATA_POSITIONING_PLACEMENT}]`]: {\n animationComposition: 'replace',\n animationDuration: '1ms',\n animationName: fadeIn,\n },\n },\n\n // Tested in Firefox 79\n '@supports not (animation-composition: accumulate)': {\n [`&[${DATA_POSITIONING_PLACEMENT}]`]: {\n animationComposition: 'replace',\n animationName: fadeIn,\n },\n },\n };\n}\n"],"names":["tokens","DATA_POSITIONING_PLACEMENT","createSlideStyles","mainAxis","fadeIn","from","opacity","to","slideDistanceVarX","slideDistanceVarY","animationComposition","animationDuration","durationSlower","animationTimingFunction","curveDecelerateMid","animationName","transform"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,MAAM,QAAQ,wBAAwB;AAE/C,SAASC,0BAA0B,QAAQ,cAAc;AAEzD;;;;CAIC,GACD,OAAO,SAASC,kBAAkBC,QAAgB;IAChD,MAAMC,SAAS;QACbC,MAAM;YACJC,SAAS;QACX;QACAC,IAAI;YACFD,SAAS;QACX;IACF;IAEA,MAAME,oBAAoB;IAC1B,MAAMC,oBAAoB;IAE1B,OAAO;QACL,sEAAsE;QACtEC,sBAAsB;QACtBC,mBAAmBX,OAAOY,cAAc;QACxCC,yBAAyBb,OAAOc,kBAAkB;QAClD,CAACN,kBAAkB,EAAE,CAAC,GAAG,CAAC;QAC1B,CAACC,kBAAkB,EAAE,CAAC,EAAEN,SAAS,EAAE,CAAC;QACpC,CAAC,CAAC,EAAE,EAAEF,2BAA2B,QAAQ,CAAC,CAAC,EAAE;YAC3C,CAACO,kBAAkB,EAAE,CAAC,CAAC,EAAEL,SAAS,EAAE,CAAC;YACrC,CAACM,kBAAkB,EAAE;QACvB;QAEA,CAAC,CAAC,EAAE,EAAER,2BAA2B,SAAS,CAAC,CAAC,EAAE;YAC5C,CAACO,kBAAkB,EAAE;YACrB,CAACC,kBAAkB,EAAE,CAAC,CAAC,EAAEN,SAAS,EAAE,CAAC;QACvC;QAEA,CAAC,CAAC,EAAE,EAAEF,2BAA2B,OAAO,CAAC,CAAC,EAAE;YAC1C,CAACO,kBAAkB,EAAE,CAAC,EAAEL,SAAS,EAAE,CAAC;YACpC,CAACM,kBAAkB,EAAE;QACvB;QAEAM,eAAe;YACbX;YACA;gBACEC,MAAM;oBACJW,WAAW,CAAC,cAAc,EAAER,kBAAkB,OAAO,EAAEC,kBAAkB,EAAE,CAAC;gBAC9E;gBACAF,IAAI,CAAC;YACP;SACD;QAED,kDAAkD;QAClD,kCAAkC;YAChC,CAAC,CAAC,EAAE,EAAEN,2BAA2B,CAAC,CAAC,CAAC,EAAE;gBACpCS,sBAAsB;gBACtBC,mBAAmB;gBACnBI,eAAeX;YACjB;QACF;QAEA,uBAAuB;QACvB,qDAAqD;YACnD,CAAC,CAAC,EAAE,EAAEH,2BAA2B,CAAC,CAAC,CAAC,EAAE;gBACpCS,sBAAsB;gBACtBK,eAAeX;YACjB;QACF;IACF;AACF"}
1
+ {"version":3,"sources":["../src/createSlideStyles.ts"],"sourcesContent":["import { tokens } from '@fluentui/react-theme';\nimport type { GriffelStyle } from '@griffel/react';\nimport { DATA_POSITIONING_PLACEMENT } from './constants';\n\n/**\n * Creates animation styles so that positioned elements slide in from the main axis\n * @param mainAxis - distance than the element sides for\n * @returns Griffel styles to spread to a slot\n */\nexport function createSlideStyles(mainAxis: number): GriffelStyle {\n // With 'accumulate' animation composition, these opacity keyframes are added onto the default opacity of 1.\n const fadeIn = {\n from: {\n opacity: -1, // becomes opacity: 0\n },\n to: {\n opacity: 0, // becomes opacity: 1\n },\n };\n\n const slideDistanceVarX = '--fui-positioning-slide-distance-x';\n const slideDistanceVarY = '--fui-positioning-slide-distance-y';\n\n return {\n // NOTE: there was a previous attempt to give fadeIn a separate composition mode:\n // animationComposition: 'replace, accumulate',\n // but somehow this was linked to a performance regression observed in Teams (bug #4255933)\n animationComposition: 'accumulate',\n animationDuration: tokens.durationSlower,\n animationTimingFunction: tokens.curveDecelerateMid,\n [slideDistanceVarX]: `0px`,\n [slideDistanceVarY]: `${mainAxis}px`,\n [`&[${DATA_POSITIONING_PLACEMENT}^=right]`]: {\n [slideDistanceVarX]: `-${mainAxis}px`,\n [slideDistanceVarY]: '0px',\n },\n\n [`&[${DATA_POSITIONING_PLACEMENT}^=bottom]`]: {\n [slideDistanceVarX]: '0px',\n [slideDistanceVarY]: `-${mainAxis}px`,\n },\n\n [`&[${DATA_POSITIONING_PLACEMENT}^=left]`]: {\n [slideDistanceVarX]: `${mainAxis}px`,\n [slideDistanceVarY]: '0px',\n },\n\n animationName: [\n fadeIn,\n {\n from: {\n transform: `translate(var(${slideDistanceVarX}), var(${slideDistanceVarY}))`,\n },\n to: {},\n },\n ],\n\n // Note: at-rules have more specificity in Griffel\n '@media(prefers-reduced-motion)': {\n [`&[${DATA_POSITIONING_PLACEMENT}]`]: {\n animationDuration: '1ms',\n animationName: fadeIn,\n },\n },\n\n // Tested in Firefox 79\n '@supports not (animation-composition: accumulate)': {\n [`&[${DATA_POSITIONING_PLACEMENT}]`]: {\n animationName: fadeIn,\n },\n },\n };\n}\n"],"names":["tokens","DATA_POSITIONING_PLACEMENT","createSlideStyles","mainAxis","fadeIn","from","opacity","to","slideDistanceVarX","slideDistanceVarY","animationComposition","animationDuration","durationSlower","animationTimingFunction","curveDecelerateMid","animationName","transform"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,MAAM,QAAQ,wBAAwB;AAE/C,SAASC,0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QACvB,qDAAqD;YACnD,CAAC,CAAC,EAAE,EAAEH,2BAA2B,CAAC,CAAC,CAAC,EAAE;gBACpCc,eAAeX;YACjB;QACF;IACF;AACF"}
package/lib/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export { createVirtualElementFromClick } from './createVirtualElementFromClick';
2
2
  export { createArrowHeightStyles, createArrowStyles } from './createArrowStyles';
3
3
  export { createSlideStyles } from './createSlideStyles';
4
+ export { PositioningConfigurationProvider } from './PositioningConfigurationContext';
4
5
  export { usePositioning } from './usePositioning';
5
6
  export { usePositioningMouseTarget } from './usePositioningMouseTarget';
6
7
  export { resolvePositioningShorthand, mergeArrowOffset } from './utils/index';
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { createVirtualElementFromClick } from './createVirtualElementFromClick';\nexport { createArrowHeightStyles, createArrowStyles } from './createArrowStyles';\nexport { createSlideStyles } from './createSlideStyles';\nexport type { CreateArrowStylesOptions } from './createArrowStyles';\nexport { usePositioning } from './usePositioning';\nexport { usePositioningMouseTarget } from './usePositioningMouseTarget';\nexport { resolvePositioningShorthand, mergeArrowOffset } from './utils/index';\nexport type {\n Alignment,\n AutoSize,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n Boundary,\n Offset,\n OffsetFunction,\n OffsetFunctionParam,\n OffsetObject,\n OffsetShorthand,\n Position,\n PositioningBoundary,\n PositioningImperativeRef,\n PositioningProps,\n PositioningRect,\n PositioningShorthand,\n PositioningShorthandValue,\n PositioningVirtualElement,\n SetVirtualMouseTarget,\n} from './types';\n"],"names":["createVirtualElementFromClick","createArrowHeightStyles","createArrowStyles","createSlideStyles","usePositioning","usePositioningMouseTarget","resolvePositioningShorthand","mergeArrowOffset"],"rangeMappings":";;;;;","mappings":"AAAA,SAASA,6BAA6B,QAAQ,kCAAkC;AAChF,SAASC,uBAAuB,EAAEC,iBAAiB,QAAQ,sBAAsB;AACjF,SAASC,iBAAiB,QAAQ,sBAAsB;AAExD,SAASC,cAAc,QAAQ,mBAAmB;AAClD,SAASC,yBAAyB,QAAQ,8BAA8B;AACxE,SAASC,2BAA2B,EAAEC,gBAAgB,QAAQ,gBAAgB"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { createVirtualElementFromClick } from './createVirtualElementFromClick';\nexport { createArrowHeightStyles, createArrowStyles } from './createArrowStyles';\nexport { createSlideStyles } from './createSlideStyles';\nexport type { CreateArrowStylesOptions } from './createArrowStyles';\n\nexport { PositioningConfigurationProvider } from './PositioningConfigurationContext';\n\nexport { usePositioning } from './usePositioning';\nexport { usePositioningMouseTarget } from './usePositioningMouseTarget';\nexport { resolvePositioningShorthand, mergeArrowOffset } from './utils/index';\n\nexport type {\n Alignment,\n AutoSize,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n Boundary,\n Offset,\n OffsetFunction,\n OffsetFunctionParam,\n OffsetObject,\n OffsetShorthand,\n Position,\n PositioningBoundary,\n PositioningImperativeRef,\n PositioningProps,\n PositioningRect,\n PositioningShorthand,\n PositioningShorthandValue,\n PositioningVirtualElement,\n SetVirtualMouseTarget,\n PositioningConfigurationFn,\n PositioningConfigurationFnOptions,\n} from './types';\n"],"names":["createVirtualElementFromClick","createArrowHeightStyles","createArrowStyles","createSlideStyles","PositioningConfigurationProvider","usePositioning","usePositioningMouseTarget","resolvePositioningShorthand","mergeArrowOffset"],"rangeMappings":";;;;;;","mappings":"AAAA,SAASA,6BAA6B,QAAQ,kCAAkC;AAChF,SAASC,uBAAuB,EAAEC,iBAAiB,QAAQ,sBAAsB;AACjF,SAASC,iBAAiB,QAAQ,sBAAsB;AAGxD,SAASC,gCAAgC,QAAQ,oCAAoC;AAErF,SAASC,cAAc,QAAQ,mBAAmB;AAClD,SAASC,yBAAyB,QAAQ,8BAA8B;AACxE,SAASC,2BAA2B,EAAEC,gBAAgB,QAAQ,gBAAgB"}
@@ -1,7 +1,7 @@
1
1
  import { offset as baseOffset } from '@floating-ui/dom';
2
2
  import { getFloatingUIOffset } from '../utils/getFloatingUIOffset';
3
3
  /**
4
- * Wraps floating UI offset middleware to to transform offset value
4
+ * Wraps floating UI offset middleware to transform offset value.
5
5
  */ export function offset(offsetValue) {
6
6
  const floatingUIOffset = getFloatingUIOffset(offsetValue);
7
7
  return baseOffset(floatingUIOffset);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/middleware/offset.ts"],"sourcesContent":["import { offset as baseOffset } from '@floating-ui/dom';\nimport type { PositioningOptions } from '../types';\nimport { getFloatingUIOffset } from '../utils/getFloatingUIOffset';\n\n/**\n * Wraps floating UI offset middleware to to transform offset value\n */\nexport function offset(offsetValue: PositioningOptions['offset']) {\n const floatingUIOffset = getFloatingUIOffset(offsetValue);\n return baseOffset(floatingUIOffset);\n}\n"],"names":["offset","baseOffset","getFloatingUIOffset","offsetValue","floatingUIOffset"],"rangeMappings":";;;;;;;","mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,mBAAmB;AAExD,SAASC,mBAAmB,QAAQ,+BAA+B;AAEnE;;CAEC,GACD,OAAO,SAASF,OAAOG,WAAyC;IAC9D,MAAMC,mBAAmBF,oBAAoBC;IAC7C,OAAOF,WAAWG;AACpB"}
1
+ {"version":3,"sources":["../src/middleware/offset.ts"],"sourcesContent":["import { offset as baseOffset } from '@floating-ui/dom';\nimport type { PositioningOptions } from '../types';\nimport { getFloatingUIOffset } from '../utils/getFloatingUIOffset';\n\n/**\n * Wraps floating UI offset middleware to transform offset value.\n */\nexport function offset(offsetValue: PositioningOptions['offset']) {\n const floatingUIOffset = getFloatingUIOffset(offsetValue);\n return baseOffset(floatingUIOffset);\n}\n"],"names":["offset","baseOffset","getFloatingUIOffset","offsetValue","floatingUIOffset"],"rangeMappings":";;;;;;;","mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,mBAAmB;AAExD,SAASC,mBAAmB,QAAQ,+BAA+B;AAEnE;;CAEC,GACD,OAAO,SAASF,OAAOG,WAAyC;IAC9D,MAAMC,mBAAmBF,oBAAoBC;IAC7C,OAAOF,WAAWG;AACpB"}
package/lib/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import * as React from 'react';\n\nexport type PositioningRect = {\n width: number;\n height: number;\n x: number;\n y: number;\n};\n\nexport type OffsetFunctionParam = {\n positionedRect: PositioningRect;\n targetRect: PositioningRect;\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 PositioningBoundary =\n | PositioningRect\n | HTMLElement\n | Array<HTMLElement>\n | 'clippingParents'\n | 'scrollParent'\n | 'window';\n/**\n * @deprecated use PositioningBoundary instead\n */\nexport type Boundary = PositioningBoundary;\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 | null) => 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?: PositioningBoundary | null;\n\n /** The element which will define the boundaries of the positioned element for the overflow behavior. */\n overflowBoundary?: PositioningBoundary | 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 * When set, the positioned element matches the chosen dimension(s) of the target element\n */\n matchTargetSize?: 'width';\n\n /**\n * Called when a position update has finished. Multiple position updates can happen in a single render,\n * since positioning happens outside of the React lifecycle.\n *\n * It's also possible to listen to the custom DOM event `fui-positioningend`\n */\n onPositioningEnd?: () => void;\n\n /**\n * Disables the resize observer that updates position on target or dimension change\n */\n disableUpdateOnResize?: boolean;\n\n /**\n * When true, the positioned element will shift to cover the target element when there's not enough space.\n * @default false\n */\n shiftToCoverTarget?: 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 | 'fallbackPositions'\n | 'flipBoundary'\n | 'offset'\n | 'overflowBoundary'\n | 'overflowBoundaryPadding'\n | 'pinned'\n | 'position'\n | 'strategy'\n | 'useTransform'\n | 'matchTargetSize'\n | 'onPositioningEnd'\n | 'disableUpdateOnResize'\n | 'shiftToCoverTarget'\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"],"rangeMappings":"","mappings":"AAAA,YAAYA,WAAW,QAAQ"}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import * as React from 'react';\n\nexport type PositioningRect = {\n width: number;\n height: number;\n x: number;\n y: number;\n};\n\nexport type OffsetFunctionParam = {\n positionedRect: PositioningRect;\n targetRect: PositioningRect;\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 PositioningBoundary =\n | PositioningRect\n | HTMLElement\n | Array<HTMLElement>\n | 'clippingParents'\n | 'scrollParent'\n | 'window';\n/**\n * @deprecated use PositioningBoundary instead\n */\nexport type Boundary = PositioningBoundary;\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 | null) => 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?: PositioningBoundary | null;\n\n /** The element which will define the boundaries of the positioned element for the overflow behavior. */\n overflowBoundary?: PositioningBoundary | 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 * When set, the positioned element matches the chosen dimension(s) of the target element\n */\n matchTargetSize?: 'width';\n\n /**\n * Called when a position update has finished. Multiple position updates can happen in a single render,\n * since positioning happens outside of the React lifecycle.\n *\n * It's also possible to listen to the custom DOM event `fui-positioningend`\n */\n onPositioningEnd?: () => void;\n\n /**\n * Disables the resize observer that updates position on target or dimension change\n */\n disableUpdateOnResize?: boolean;\n\n /**\n * When true, the positioned element will shift to cover the target element when there's not enough space.\n * @default false\n */\n shiftToCoverTarget?: 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 | 'fallbackPositions'\n | 'flipBoundary'\n | 'offset'\n | 'overflowBoundary'\n | 'overflowBoundaryPadding'\n | 'pinned'\n | 'position'\n | 'strategy'\n | 'useTransform'\n | 'matchTargetSize'\n | 'onPositioningEnd'\n | 'disableUpdateOnResize'\n | 'shiftToCoverTarget'\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\n// ---\n\nexport type PositioningConfigurationFnOptions = Omit<\n PositioningOptions,\n // Excluded as the function will never be called if disabled\n | 'enabled'\n // Callback is not subscribed from options\n | 'onPositioningEnd'\n // Is deprecated, no need to bloat the interface\n | 'positionFixed'\n>;\nexport type PositioningConfigurationFn = (params: {\n container: HTMLElement;\n arrow: HTMLElement | null;\n options: PositioningConfigurationFnOptions;\n}) => PositioningConfigurationFnOptions;\n"],"names":["React"],"rangeMappings":"","mappings":"AAAA,YAAYA,WAAW,QAAQ"}
@@ -1,13 +1,9 @@
1
- import { hide as hideMiddleware, arrow as arrowMiddleware } from '@floating-ui/dom';
2
- import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';
3
1
  import { canUseDOM, useEventCallback, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';
4
2
  import * as React from 'react';
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, matchTargetSize as matchTargetSizeMiddleware } from './middleware';
7
- import { createPositionManager } from './createPositionManager';
8
- import { devtools } from '@floating-ui/devtools';
9
- import { devtoolsCallback } from './utils/devtools';
10
3
  import { POSITIONING_END_EVENT } from './constants';
4
+ import { createPositionManager } from './createPositionManager';
5
+ import { usePositioningOptions } from './usePositioningOptions';
6
+ import { useCallbackRef, hasAutofocusFilter } from './utils';
11
7
  /**
12
8
  * @internal
13
9
  */ export function usePositioning(options) {
@@ -86,10 +82,10 @@ import { POSITIONING_END_EVENT } from './constants';
86
82
  while(treeWalker.nextNode()){
87
83
  const node = treeWalker.currentNode;
88
84
  // eslint-disable-next-line no-console
89
- console.warn('<Popper>:', node);
85
+ console.warn('usePositioning():', node);
90
86
  // eslint-disable-next-line no-console
91
87
  console.warn([
92
- '<Popper>: ^ this node contains "autoFocus" prop on a React element. This can break the initial',
88
+ 'usePositioning(): ^ this node contains "autoFocus" prop on a React element. This can break the initial',
93
89
  'positioning of an element and cause a window jump effect. This issue occurs because React polyfills',
94
90
  '"autoFocus" behavior to solve inconsistencies between different browsers:',
95
91
  'https://github.com/facebook/react/issues/11851#issuecomment-351787078',
@@ -143,84 +139,3 @@ import { POSITIONING_END_EVENT } from './constants';
143
139
  arrowRef: setArrow
144
140
  };
145
141
  }
146
- function usePositioningOptions(options) {
147
- 'use no memo';
148
- const { align, arrowPadding, autoSize: rawAutoSize, coverTarget, flipBoundary, offset, overflowBoundary, pinned, position, unstable_disableTether: disableTether, // eslint-disable-next-line @typescript-eslint/no-deprecated
149
- positionFixed, strategy, overflowBoundaryPadding, fallbackPositions, useTransform, matchTargetSize, disableUpdateOnResize = false, shiftToCoverTarget } = options;
150
- const { dir, targetDocument } = useFluent();
151
- const isRtl = dir === 'rtl';
152
- const positionStrategy = (strategy !== null && strategy !== void 0 ? strategy : positionFixed) ? 'fixed' : 'absolute';
153
- const autoSize = normalizeAutoSize(rawAutoSize);
154
- return React.useCallback((container, arrow)=>{
155
- const hasScrollableElement = hasScrollParent(container);
156
- const middleware = [
157
- autoSize && resetMaxSizeMiddleware(autoSize),
158
- matchTargetSize && matchTargetSizeMiddleware(),
159
- offset && offsetMiddleware(offset),
160
- coverTarget && coverTargetMiddleware(),
161
- !pinned && flipMiddleware({
162
- container,
163
- flipBoundary,
164
- hasScrollableElement,
165
- isRtl,
166
- fallbackPositions
167
- }),
168
- shiftMiddleware({
169
- container,
170
- hasScrollableElement,
171
- overflowBoundary,
172
- disableTether,
173
- overflowBoundaryPadding,
174
- isRtl,
175
- shiftToCoverTarget
176
- }),
177
- autoSize && maxSizeMiddleware(autoSize, {
178
- container,
179
- overflowBoundary,
180
- overflowBoundaryPadding,
181
- isRtl
182
- }),
183
- intersectingMiddleware(),
184
- arrow && arrowMiddleware({
185
- element: arrow,
186
- padding: arrowPadding
187
- }),
188
- hideMiddleware({
189
- strategy: 'referenceHidden'
190
- }),
191
- hideMiddleware({
192
- strategy: 'escaped'
193
- }),
194
- process.env.NODE_ENV !== 'production' && targetDocument && devtools(targetDocument, devtoolsCallback(options))
195
- ].filter(Boolean);
196
- const placement = toFloatingUIPlacement(align, position, isRtl);
197
- return {
198
- placement,
199
- middleware,
200
- strategy: positionStrategy,
201
- useTransform,
202
- disableUpdateOnResize
203
- };
204
- }, // Options is missing here, but it's not required
205
- // eslint-disable-next-line react-hooks/exhaustive-deps
206
- [
207
- align,
208
- arrowPadding,
209
- autoSize,
210
- coverTarget,
211
- disableTether,
212
- flipBoundary,
213
- isRtl,
214
- offset,
215
- overflowBoundary,
216
- pinned,
217
- position,
218
- positionStrategy,
219
- overflowBoundaryPadding,
220
- fallbackPositions,
221
- useTransform,
222
- matchTargetSize,
223
- targetDocument,
224
- disableUpdateOnResize
225
- ]);
226
- }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/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 matchTargetSize as matchTargetSizeMiddleware,\n} from './middleware';\nimport { createPositionManager } from './createPositionManager';\nimport { devtools } from '@floating-ui/devtools';\nimport { devtoolsCallback } from './utils/devtools';\nimport { POSITIONING_END_EVENT } from './constants';\n\n/**\n * @internal\n */\nexport function usePositioning(options: PositioningProps & PositioningOptions): UsePositioningReturn {\n 'use no memo';\n\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 | null) => {\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 }, []);\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 onPositioningEnd = useEventCallback(() => options.onPositioningEnd?.());\n const setContainer = useCallbackRef<HTMLElement | null>(null, container => {\n if (containerRef.current !== container) {\n containerRef.current?.removeEventListener(POSITIONING_END_EVENT, onPositioningEnd);\n container?.addEventListener(POSITIONING_END_EVENT, onPositioningEnd);\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 'use no memo';\n\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 @typescript-eslint/no-deprecated\n positionFixed,\n strategy,\n overflowBoundaryPadding,\n fallbackPositions,\n useTransform,\n matchTargetSize,\n disableUpdateOnResize = false,\n shiftToCoverTarget,\n } = options;\n\n const { dir, targetDocument } = 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 matchTargetSize && matchTargetSizeMiddleware(),\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 shiftToCoverTarget,\n }),\n autoSize && maxSizeMiddleware(autoSize, { container, overflowBoundary, overflowBoundaryPadding, isRtl }),\n intersectingMiddleware(),\n arrow && arrowMiddleware({ element: arrow, padding: arrowPadding }),\n hideMiddleware({ strategy: 'referenceHidden' }),\n hideMiddleware({ strategy: 'escaped' }),\n process.env.NODE_ENV !== 'production' && targetDocument && devtools(targetDocument, devtoolsCallback(options)),\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 disableUpdateOnResize,\n };\n },\n // Options is missing here, but it's not required\n // eslint-disable-next-line react-hooks/exhaustive-deps\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 matchTargetSize,\n targetDocument,\n disableUpdateOnResize,\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","matchTargetSize","matchTargetSizeMiddleware","createPositionManager","devtools","devtoolsCallback","POSITIONING_END_EVENT","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","onPositioningEnd","setContainer","removeEventListener","addEventListener","setArrow","align","arrowPadding","autoSize","rawAutoSize","flipBoundary","overflowBoundary","pinned","position","unstable_disableTether","disableTether","positionFixed","strategy","overflowBoundaryPadding","fallbackPositions","useTransform","disableUpdateOnResize","shiftToCoverTarget","dir","targetDocument","isRtl","positionStrategy","hasScrollableElement","middleware","element","padding","filter","Boolean","placement"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","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,EAAEC,iBAAiB,QAAQ,UAAU;AACxH,SACEC,SAASC,eAAe,EACxBC,QAAQC,cAAc,EACtBC,eAAeC,qBAAqB,EACpCC,WAAWC,iBAAiB,EAC5BC,gBAAgBC,sBAAsB,EACtCC,UAAUC,gBAAgB,EAC1BC,gBAAgBC,sBAAsB,EACtCC,mBAAmBC,yBAAyB,QACvC,eAAe;AACtB,SAASC,qBAAqB,QAAQ,0BAA0B;AAChE,SAASC,QAAQ,QAAQ,wBAAwB;AACjD,SAASC,gBAAgB,QAAQ,mBAAmB;AACpD,SAASC,qBAAqB,QAAQ,cAAc;AAEpD;;CAEC,GACD,OAAO,SAASC,eAAeC,OAA8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,iBAAiBD;YAC3BN,eAAeC;YACf,CAACoE,UAAUtE,eAAe;gBAAEiC;gBAAWmC;gBAAciB;gBAAsBF;gBAAON;YAAkB;YACpG/E,gBAAgB;gBACdmC;gBACAoD;gBACAhB;gBACAI;gBACAG;gBACAO;gBACAH;YACF;YACAd,YAAY9D,kBAAkB8D,UAAU;gBAAEjC;gBAAWoC;gBAAkBO;gBAAyBO;YAAM;YACtGzE;YACA1B,SAASC,gBAAgB;gBAAEsG,SAASvG;gBAAOwG,SAASvB;YAAa;YACjElF,eAAe;gBAAE4F,UAAU;YAAkB;YAC7C5F,eAAe;gBAAE4F,UAAU;YAAU;YACrCpC,QAAQC,GAAG,CAACC,QAAQ,KAAK,gBAAgByC,kBAAkBpE,SAASoE,gBAAgBnE,iBAAiBG;SACtG,CAACuE,MAAM,CAACC;QAET,MAAMC,YAAYlG,sBAAsBuE,OAAOO,UAAUY;QAEzD,OAAO;YACLQ;YACAL;YACAX,UAAUS;YACVN;YACAC;QACF;IACF,GACA,iDAAiD;IACjD,uDAAuD;IACvD;QACEf;QACAC;QACAC;QACAjE;QACAwE;QACAL;QACAe;QACA5E;QACA8D;QACAC;QACAC;QACAa;QACAR;QACAC;QACAC;QACAnE;QACAuE;QACAH;KACD;AAEL"}
1
+ {"version":3,"sources":["../src/usePositioning.ts"],"sourcesContent":["import { canUseDOM, useEventCallback, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport { POSITIONING_END_EVENT } from './constants';\nimport { createPositionManager } from './createPositionManager';\nimport type {\n PositioningOptions,\n PositioningProps,\n PositionManager,\n TargetElement,\n UsePositioningReturn,\n} from './types';\nimport { usePositioningOptions } from './usePositioningOptions';\nimport { useCallbackRef, hasAutofocusFilter } from './utils';\n\n/**\n * @internal\n */\nexport function usePositioning(options: PositioningProps & PositioningOptions): UsePositioningReturn {\n 'use no memo';\n\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 | null) => {\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('usePositioning():', node);\n // eslint-disable-next-line no-console\n console.warn(\n [\n 'usePositioning(): ^ 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 }, []);\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 onPositioningEnd = useEventCallback(() => options.onPositioningEnd?.());\n const setContainer = useCallbackRef<HTMLElement | null>(null, container => {\n if (containerRef.current !== container) {\n containerRef.current?.removeEventListener(POSITIONING_END_EVENT, onPositioningEnd);\n container?.addEventListener(POSITIONING_END_EVENT, onPositioningEnd);\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"],"names":["canUseDOM","useEventCallback","useIsomorphicLayoutEffect","React","POSITIONING_END_EVENT","createPositionManager","usePositioningOptions","useCallbackRef","hasAutofocusFilter","usePositioning","options","managerRef","useRef","targetRef","overrideTargetRef","containerRef","arrowRef","enabled","resolvePositioningOptions","updatePositionManager","useCallback","current","dispose","target","container","arrow","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","onPositioningEnd","setContainer","removeEventListener","addEventListener","setArrow"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,SAAS,EAAEC,gBAAgB,EAAEC,yBAAyB,QAAQ,4BAA4B;AACnG,YAAYC,WAAW,QAAQ;AAE/B,SAASC,qBAAqB,QAAQ,cAAc;AACpD,SAASC,qBAAqB,QAAQ,0BAA0B;AAQhE,SAASC,qBAAqB,QAAQ,0BAA0B;AAChE,SAASC,cAAc,EAAEC,kBAAkB,QAAQ,UAAU;AAE7D;;CAEC,GACD,OAAO,SAASC,eAAeC,OAA8C;IAC3E;IAEA,MAAMC,aAAaR,MAAMS,MAAM,CAAyB;IACxD,MAAMC,YAAYV,MAAMS,MAAM,CAAuB;IACrD,MAAME,oBAAoBX,MAAMS,MAAM,CAAuB;IAC7D,MAAMG,eAAeZ,MAAMS,MAAM,CAAqB;IACtD,MAAMI,WAAWb,MAAMS,MAAM,CAAqB;IAElD,MAAM,EAAEK,UAAU,IAAI,EAAE,GAAGP;IAC3B,MAAMQ,4BAA4BZ,sBAAsBI;IACxD,MAAMS,wBAAwBhB,MAAMiB,WAAW,CAAC;QAC9C,IAAIT,WAAWU,OAAO,EAAE;YACtBV,WAAWU,OAAO,CAACC,OAAO;QAC5B;QACAX,WAAWU,OAAO,GAAG;YAENP;QAAf,MAAMS,SAAST,CAAAA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AAcqC;QAAcpC,UAAUuC;IAAS;AAChF"}
@@ -0,0 +1,131 @@
1
+ import { devtools } from '@floating-ui/devtools';
2
+ import { hide as hideMiddleware, arrow as arrowMiddleware } from '@floating-ui/dom';
3
+ import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';
4
+ import * as React from 'react';
5
+ import { shift as shiftMiddleware, flip as flipMiddleware, coverTarget as coverTargetMiddleware, maxSize as maxSizeMiddleware, resetMaxSize as resetMaxSizeMiddleware, offset as offsetMiddleware, intersecting as intersectingMiddleware, matchTargetSize as matchTargetSizeMiddleware } from './middleware';
6
+ import { toFloatingUIPlacement, hasScrollParent, normalizeAutoSize } from './utils';
7
+ import { devtoolsCallback } from './utils/devtools';
8
+ import { usePositioningConfiguration } from './PositioningConfigurationContext';
9
+ /**
10
+ * @internal
11
+ *
12
+ * This is redundant and exists only to manage React dependencies properly & avoid leaking individual options to the
13
+ * scope of `usePositioningOptions`.
14
+ */ function usePositioningConfigFn(configFn, options) {
15
+ const { align, arrowPadding, autoSize, coverTarget, disableUpdateOnResize, flipBoundary, offset, overflowBoundary, pinned, position, // eslint-disable-next-line @typescript-eslint/naming-convention
16
+ unstable_disableTether, strategy, overflowBoundaryPadding, fallbackPositions, useTransform, matchTargetSize, shiftToCoverTarget } = options;
17
+ return React.useCallback((container, arrow)=>{
18
+ return configFn({
19
+ container,
20
+ arrow,
21
+ options: {
22
+ autoSize,
23
+ disableUpdateOnResize,
24
+ matchTargetSize,
25
+ offset,
26
+ strategy,
27
+ coverTarget,
28
+ flipBoundary,
29
+ overflowBoundary,
30
+ useTransform,
31
+ overflowBoundaryPadding,
32
+ pinned,
33
+ arrowPadding,
34
+ align,
35
+ fallbackPositions,
36
+ shiftToCoverTarget,
37
+ position,
38
+ // eslint-disable-next-line @typescript-eslint/naming-convention
39
+ unstable_disableTether
40
+ }
41
+ });
42
+ }, [
43
+ autoSize,
44
+ disableUpdateOnResize,
45
+ matchTargetSize,
46
+ offset,
47
+ strategy,
48
+ coverTarget,
49
+ flipBoundary,
50
+ overflowBoundary,
51
+ useTransform,
52
+ overflowBoundaryPadding,
53
+ pinned,
54
+ arrowPadding,
55
+ align,
56
+ fallbackPositions,
57
+ shiftToCoverTarget,
58
+ position,
59
+ unstable_disableTether,
60
+ configFn
61
+ ]);
62
+ }
63
+ /**
64
+ * @internal
65
+ */ export function usePositioningOptions(options) {
66
+ const { dir, targetDocument } = useFluent();
67
+ const isRtl = dir === 'rtl';
68
+ const configFn = usePositioningConfigFn(usePositioningConfiguration(), options);
69
+ const { // eslint-disable-next-line @typescript-eslint/no-deprecated
70
+ positionFixed } = options;
71
+ return React.useCallback((container, arrow)=>{
72
+ const hasScrollableElement = hasScrollParent(container);
73
+ const optionsAfterEnhancement = configFn(container, arrow);
74
+ const { autoSize, disableUpdateOnResize, matchTargetSize, offset, coverTarget, flipBoundary, overflowBoundary, useTransform, overflowBoundaryPadding, pinned, position, arrowPadding, strategy, align, fallbackPositions, shiftToCoverTarget, // eslint-disable-next-line @typescript-eslint/naming-convention
75
+ unstable_disableTether } = optionsAfterEnhancement;
76
+ const normalizedAutoSize = normalizeAutoSize(autoSize);
77
+ const middleware = [
78
+ normalizedAutoSize && resetMaxSizeMiddleware(normalizedAutoSize),
79
+ matchTargetSize && matchTargetSizeMiddleware(),
80
+ offset && offsetMiddleware(offset),
81
+ coverTarget && coverTargetMiddleware(),
82
+ !pinned && flipMiddleware({
83
+ container,
84
+ flipBoundary,
85
+ hasScrollableElement,
86
+ isRtl,
87
+ fallbackPositions
88
+ }),
89
+ shiftMiddleware({
90
+ container,
91
+ hasScrollableElement,
92
+ overflowBoundary,
93
+ disableTether: unstable_disableTether,
94
+ overflowBoundaryPadding,
95
+ isRtl,
96
+ shiftToCoverTarget
97
+ }),
98
+ normalizedAutoSize && maxSizeMiddleware(normalizedAutoSize, {
99
+ container,
100
+ overflowBoundary,
101
+ overflowBoundaryPadding,
102
+ isRtl
103
+ }),
104
+ intersectingMiddleware(),
105
+ arrow && arrowMiddleware({
106
+ element: arrow,
107
+ padding: arrowPadding
108
+ }),
109
+ hideMiddleware({
110
+ strategy: 'referenceHidden'
111
+ }),
112
+ hideMiddleware({
113
+ strategy: 'escaped'
114
+ }),
115
+ process.env.NODE_ENV !== 'production' && targetDocument && devtools(targetDocument, devtoolsCallback(optionsAfterEnhancement))
116
+ ].filter(Boolean);
117
+ const placement = toFloatingUIPlacement(align, position, isRtl);
118
+ return {
119
+ placement,
120
+ middleware,
121
+ strategy: (strategy !== null && strategy !== void 0 ? strategy : positionFixed) ? 'fixed' : 'absolute',
122
+ disableUpdateOnResize,
123
+ useTransform
124
+ };
125
+ }, [
126
+ configFn,
127
+ isRtl,
128
+ targetDocument,
129
+ positionFixed
130
+ ]);
131
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/usePositioningOptions.ts"],"sourcesContent":["import { devtools } from '@floating-ui/devtools';\nimport { hide as hideMiddleware, arrow as arrowMiddleware } from '@floating-ui/dom';\nimport type { Middleware } from '@floating-ui/dom';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport * as React from 'react';\n\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 matchTargetSize as matchTargetSizeMiddleware,\n} from './middleware';\nimport type { PositioningConfigurationFn, PositioningConfigurationFnOptions, PositioningOptions } from './types';\nimport { toFloatingUIPlacement, hasScrollParent, normalizeAutoSize } from './utils';\nimport { devtoolsCallback } from './utils/devtools';\nimport { usePositioningConfiguration } from './PositioningConfigurationContext';\n\n/**\n * @internal\n *\n * This is redundant and exists only to manage React dependencies properly & avoid leaking individual options to the\n * scope of `usePositioningOptions`.\n */\nfunction usePositioningConfigFn(\n configFn: PositioningConfigurationFn,\n options: PositioningOptions,\n): (container: HTMLElement, arrow: HTMLElement | null) => PositioningConfigurationFnOptions {\n const {\n align,\n arrowPadding,\n autoSize,\n coverTarget,\n disableUpdateOnResize,\n flipBoundary,\n offset,\n overflowBoundary,\n pinned,\n position,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n unstable_disableTether,\n strategy,\n overflowBoundaryPadding,\n fallbackPositions,\n useTransform,\n matchTargetSize,\n shiftToCoverTarget,\n } = options;\n\n return React.useCallback(\n (container: HTMLElement, arrow: HTMLElement | null) => {\n return configFn({\n container,\n arrow,\n options: {\n autoSize,\n disableUpdateOnResize,\n matchTargetSize,\n offset,\n strategy,\n coverTarget,\n flipBoundary,\n overflowBoundary,\n useTransform,\n overflowBoundaryPadding,\n pinned,\n arrowPadding,\n align,\n fallbackPositions,\n shiftToCoverTarget,\n position,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n unstable_disableTether,\n },\n });\n },\n [\n autoSize,\n disableUpdateOnResize,\n matchTargetSize,\n offset,\n strategy,\n coverTarget,\n flipBoundary,\n overflowBoundary,\n useTransform,\n overflowBoundaryPadding,\n pinned,\n arrowPadding,\n align,\n fallbackPositions,\n shiftToCoverTarget,\n position,\n unstable_disableTether,\n configFn,\n ],\n );\n}\n\n/**\n * @internal\n */\nexport function usePositioningOptions(options: PositioningOptions) {\n const { dir, targetDocument } = useFluent();\n const isRtl = dir === 'rtl';\n\n const configFn = usePositioningConfigFn(usePositioningConfiguration(), options);\n const {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n positionFixed,\n } = options;\n\n return React.useCallback(\n (container: HTMLElement, arrow: HTMLElement | null) => {\n const hasScrollableElement = hasScrollParent(container);\n\n const optionsAfterEnhancement = configFn(container, arrow);\n const {\n autoSize,\n disableUpdateOnResize,\n matchTargetSize,\n offset,\n coverTarget,\n flipBoundary,\n overflowBoundary,\n useTransform,\n overflowBoundaryPadding,\n pinned,\n position,\n arrowPadding,\n strategy,\n align,\n fallbackPositions,\n shiftToCoverTarget,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n unstable_disableTether,\n } = optionsAfterEnhancement;\n const normalizedAutoSize = normalizeAutoSize(autoSize);\n\n const middleware = [\n normalizedAutoSize && resetMaxSizeMiddleware(normalizedAutoSize),\n matchTargetSize && matchTargetSizeMiddleware(),\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: unstable_disableTether,\n overflowBoundaryPadding,\n isRtl,\n shiftToCoverTarget,\n }),\n normalizedAutoSize &&\n maxSizeMiddleware(normalizedAutoSize, { container, overflowBoundary, overflowBoundaryPadding, isRtl }),\n intersectingMiddleware(),\n arrow && arrowMiddleware({ element: arrow, padding: arrowPadding }),\n hideMiddleware({ strategy: 'referenceHidden' }),\n hideMiddleware({ strategy: 'escaped' }),\n process.env.NODE_ENV !== 'production' &&\n targetDocument &&\n devtools(targetDocument, devtoolsCallback(optionsAfterEnhancement)),\n ].filter(Boolean) as Middleware[];\n\n const placement = toFloatingUIPlacement(align, position, isRtl);\n\n return {\n placement,\n middleware,\n strategy: strategy ?? positionFixed ? ('fixed' as const) : ('absolute' as const),\n\n disableUpdateOnResize,\n useTransform,\n };\n },\n [configFn, isRtl, targetDocument, positionFixed],\n );\n}\n"],"names":["devtools","hide","hideMiddleware","arrow","arrowMiddleware","useFluent_unstable","useFluent","React","shift","shiftMiddleware","flip","flipMiddleware","coverTarget","coverTargetMiddleware","maxSize","maxSizeMiddleware","resetMaxSize","resetMaxSizeMiddleware","offset","offsetMiddleware","intersecting","intersectingMiddleware","matchTargetSize","matchTargetSizeMiddleware","toFloatingUIPlacement","hasScrollParent","normalizeAutoSize","devtoolsCallback","usePositioningConfiguration","usePositioningConfigFn","configFn","options","align","arrowPadding","autoSize","disableUpdateOnResize","flipBoundary","overflowBoundary","pinned","position","unstable_disableTether","strategy","overflowBoundaryPadding","fallbackPositions","useTransform","shiftToCoverTarget","useCallback","container","usePositioningOptions","dir","targetDocument","isRtl","positionFixed","hasScrollableElement","optionsAfterEnhancement","normalizedAutoSize","middleware","disableTether","element","padding","process","env","NODE_ENV","filter","Boolean","placement"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,QAAQ,QAAQ,wBAAwB;AACjD,SAASC,QAAQC,cAAc,EAAEC,SAASC,eAAe,QAAQ,mBAAmB;AAEpF,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAClF,YAAYC,WAAW,QAAQ;AAE/B,SACEC,SAASC,eAAe,EACxBC,QAAQC,cAAc,EACtBC,eAAeC,qBAAqB,EACpCC,WAAWC,iBAAiB,EAC5BC,gBAAgBC,sBAAsB,EACtCC,UAAUC,gBAAgB,EAC1BC,gBAAgBC,sBAAsB,EACtCC,mBAAmBC,yBAAyB,QACvC,eAAe;AAEtB,SAASC,qBAAqB,EAAEC,eAAe,EAAEC,iBAAiB,QAAQ,UAAU;AACpF,SAASC,gBAAgB,QAAQ,mBAAmB;AACpD,SAASC,2BAA2B,QAAQ,oCAAoC;AAEhF;;;;;CAKC,GACD,SAASC,uBACPC,QAAoC,EACpCC,OAA2B;IAE3B,MAAM,EACJC,KAAK,EACLC,YAAY,EACZC,QAAQ,EACRtB,WAAW,EACXuB,qBAAqB,EACrBC,YAAY,EACZlB,MAAM,EACNmB,gBAAgB,EAChBC,MAAM,EACNC,QAAQ,EACR,gEAAgE;IAChEC,sBAAsB,EACtBC,QAAQ,EACRC,uBAAuB,EACvBC,iBAAiB,EACjBC,YAAY,EACZtB,eAAe,EACfuB,kBAAkB,EACnB,GAAGd;IAEJ,OAAOxB,MAAMuC,WAAW,CACtB,CAACC,WAAwB5C;QACvB,OAAO2B,SAAS;YACdiB;YACA5C;YACA4B,SAAS;gBACPG;gBACAC;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AkBwC,oBAAoB;gBAAER;gBAAWV;gBAAkBK;gBAAyBS;YAAM;YACtG9B;YACAlB,SAASC,gBAAgB;gBAAEsD,SAASvD;gBAAOwD,SAAS1B;YAAa;YACjE/B,eAAe;gBAAEuC,UAAU;YAAkB;YAC7CvC,eAAe;gBAAEuC,UAAU;YAAU;YACrCmB,QAAQC,GAAG,CAACC,QAAQ,KAAK,gBACvBZ,kBACAlD,SAASkD,gBAAgBvB,iBAAiB2B;SAC7C,CAACS,MAAM,CAACC;QAET,MAAMC,YAAYzC,sBAAsBQ,OAAOO,UAAUY;QAEzD,OAAO;YACLc;YACAT;YACAf,UAAUA,CAAAA,qBAAAA,sBAAAA,WAAYW,aAAY,IAAK,UAAqB;YAE5DjB;YACAS;QACF;IACF,GACA;QAACd;QAAUqB;QAAOD;QAAgBE;KAAc;AAEpD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils/devtools.ts"],"sourcesContent":["import type { MiddlewareState } from '@floating-ui/dom';\nimport type { PositioningOptions } from '../types';\nimport { isHTMLElement } from '@fluentui/react-utilities';\nimport { listScrollParents } from './listScrollParents';\nimport { fromFloatingUIPlacement } from './fromFloatingUIPlacement';\n\nexport const devtoolsCallback = (options: PositioningOptions) => (middlewareState: MiddlewareState) => {\n const {\n elements: { floating, reference },\n } = middlewareState;\n const scrollParentsSet = new Set<HTMLElement>();\n if (isHTMLElement(reference)) {\n listScrollParents(reference).forEach(scrollParent => scrollParentsSet.add(scrollParent));\n }\n listScrollParents(floating).forEach(scrollParent => scrollParentsSet.add(scrollParent));\n const flipBoundaries: HTMLElement[] = Array.isArray(options.flipBoundary)\n ? options.flipBoundary\n : isHTMLElement(options.flipBoundary)\n ? [options.flipBoundary]\n : [];\n const overflowBoundaries: HTMLElement[] = Array.isArray(options.overflowBoundary)\n ? options.overflowBoundary\n : isHTMLElement(options.overflowBoundary)\n ? [options.overflowBoundary]\n : [];\n return {\n type: 'FluentUIMiddleware',\n middlewareState,\n options,\n initialPlacement: fromFloatingUIPlacement(middlewareState.initialPlacement),\n placement: fromFloatingUIPlacement(middlewareState.placement),\n flipBoundaries,\n overflowBoundaries,\n scrollParents: Array.from(scrollParentsSet),\n } as const;\n};\n"],"names":["isHTMLElement","listScrollParents","fromFloatingUIPlacement","devtoolsCallback","options","middlewareState","elements","floating","reference","scrollParentsSet","Set","forEach","scrollParent","add","flipBoundaries","Array","isArray","flipBoundary","overflowBoundaries","overflowBoundary","type","initialPlacement","placement","scrollParents","from"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,aAAa,QAAQ,4BAA4B;AAC1D,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SAASC,uBAAuB,QAAQ,4BAA4B;AAEpE,OAAO,MAAMC,mBAAmB,CAACC,UAAgC,CAACC;QAChE,MAAM,EACJC,UAAU,EAAEC,QAAQ,EAAEC,SAAS,EAAE,EAClC,GAAGH;QACJ,MAAMI,mBAAmB,IAAIC;QAC7B,IAAIV,cAAcQ,YAAY;YAC5BP,kBAAkBO,WAAWG,OAAO,CAACC,CAAAA,eAAgBH,iBAAiBI,GAAG,CAACD;QAC5E;QACAX,kBAAkBM,UAAUI,OAAO,CAACC,CAAAA,eAAgBH,iBAAiBI,GAAG,CAACD;QACzE,MAAME,iBAAgCC,MAAMC,OAAO,CAACZ,QAAQa,YAAY,IACpEb,QAAQa,YAAY,GACpBjB,cAAcI,QAAQa,YAAY,IAClC;YAACb,QAAQa,YAAY;SAAC,GACtB,EAAE;QACN,MAAMC,qBAAoCH,MAAMC,OAAO,CAACZ,QAAQe,gBAAgB,IAC5Ef,QAAQe,gBAAgB,GACxBnB,cAAcI,QAAQe,gBAAgB,IACtC;YAACf,QAAQe,gBAAgB;SAAC,GAC1B,EAAE;QACN,OAAO;YACLC,MAAM;YACNf;YACAD;YACAiB,kBAAkBnB,wBAAwBG,gBAAgBgB,gBAAgB;YAC1EC,WAAWpB,wBAAwBG,gBAAgBiB,SAAS;YAC5DR;YACAI;YACAK,eAAeR,MAAMS,IAAI,CAACf;QAC5B;IACF,EAAE"}
1
+ {"version":3,"sources":["../src/utils/devtools.ts"],"sourcesContent":["import type { MiddlewareState } from '@floating-ui/dom';\nimport type { PositioningOptions } from '../types';\nimport { isHTMLElement } from '@fluentui/react-utilities';\nimport { listScrollParents } from './listScrollParents';\nimport { fromFloatingUIPlacement } from './fromFloatingUIPlacement';\n\nexport const devtoolsCallback =\n (options: Pick<PositioningOptions, 'flipBoundary' | 'overflowBoundary'>) => (middlewareState: MiddlewareState) => {\n const {\n elements: { floating, reference },\n } = middlewareState;\n const scrollParentsSet = new Set<HTMLElement>();\n if (isHTMLElement(reference)) {\n listScrollParents(reference).forEach(scrollParent => scrollParentsSet.add(scrollParent));\n }\n listScrollParents(floating).forEach(scrollParent => scrollParentsSet.add(scrollParent));\n const flipBoundaries: HTMLElement[] = Array.isArray(options.flipBoundary)\n ? options.flipBoundary\n : isHTMLElement(options.flipBoundary)\n ? [options.flipBoundary]\n : [];\n const overflowBoundaries: HTMLElement[] = Array.isArray(options.overflowBoundary)\n ? options.overflowBoundary\n : isHTMLElement(options.overflowBoundary)\n ? [options.overflowBoundary]\n : [];\n return {\n type: 'FluentUIMiddleware',\n middlewareState,\n options,\n initialPlacement: fromFloatingUIPlacement(middlewareState.initialPlacement),\n placement: fromFloatingUIPlacement(middlewareState.placement),\n flipBoundaries,\n overflowBoundaries,\n scrollParents: Array.from(scrollParentsSet),\n } as const;\n };\n"],"names":["isHTMLElement","listScrollParents","fromFloatingUIPlacement","devtoolsCallback","options","middlewareState","elements","floating","reference","scrollParentsSet","Set","forEach","scrollParent","add","flipBoundaries","Array","isArray","flipBoundary","overflowBoundaries","overflowBoundary","type","initialPlacement","placement","scrollParents","from"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,aAAa,QAAQ,4BAA4B;AAC1D,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SAASC,uBAAuB,QAAQ,4BAA4B;AAEpE,OAAO,MAAMC,mBACX,CAACC,UAA2E,CAACC;QAC3E,MAAM,EACJC,UAAU,EAAEC,QAAQ,EAAEC,SAAS,EAAE,EAClC,GAAGH;QACJ,MAAMI,mBAAmB,IAAIC;QAC7B,IAAIV,cAAcQ,YAAY;YAC5BP,kBAAkBO,WAAWG,OAAO,CAACC,CAAAA,eAAgBH,iBAAiBI,GAAG,CAACD;QAC5E;QACAX,kBAAkBM,UAAUI,OAAO,CAACC,CAAAA,eAAgBH,iBAAiBI,GAAG,CAACD;QACzE,MAAME,iBAAgCC,MAAMC,OAAO,CAACZ,QAAQa,YAAY,IACpEb,QAAQa,YAAY,GACpBjB,cAAcI,QAAQa,YAAY,IAClC;YAACb,QAAQa,YAAY;SAAC,GACtB,EAAE;QACN,MAAMC,qBAAoCH,MAAMC,OAAO,CAACZ,QAAQe,gBAAgB,IAC5Ef,QAAQe,gBAAgB,GACxBnB,cAAcI,QAAQe,gBAAgB,IACtC;YAACf,QAAQe,gBAAgB;SAAC,GAC1B,EAAE;QACN,OAAO;YACLC,MAAM;YACNf;YACAD;YACAiB,kBAAkBnB,wBAAwBG,gBAAgBgB,gBAAgB;YAC1EC,WAAWpB,wBAAwBG,gBAAgBiB,SAAS;YAC5DR;YACAI;YACAK,eAAeR,MAAMS,IAAI,CAACf;QAC5B;IACF,EAAE"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
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
+ PositioningConfigurationProvider: function() {
13
+ return PositioningConfigurationProvider;
14
+ },
15
+ usePositioningConfiguration: function() {
16
+ return usePositioningConfiguration;
17
+ }
18
+ });
19
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
20
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
21
+ // ---
22
+ const DEFAULT_CONFIGURATION = ({ options })=>{
23
+ return options;
24
+ };
25
+ // ---
26
+ const PositioningConfigurationContext = _react.createContext(undefined);
27
+ const PositioningConfigurationProvider = PositioningConfigurationContext.Provider;
28
+ const usePositioningConfiguration = ()=>{
29
+ var _React_useContext;
30
+ return (_React_useContext = _react.useContext(PositioningConfigurationContext)) !== null && _React_useContext !== void 0 ? _React_useContext : DEFAULT_CONFIGURATION;
31
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/PositioningConfigurationContext.ts"],"sourcesContent":["import * as React from 'react';\nimport type { PositioningConfigurationFn } from './types';\n\n// ---\n\nconst DEFAULT_CONFIGURATION: PositioningConfigurationFn = ({ options }) => {\n return options;\n};\n\n// ---\n\nconst PositioningConfigurationContext = React.createContext<PositioningConfigurationFn | undefined>(undefined);\n\n/**\n * A context provider for the positioning configuration.\n *\n * Accepts a function that takes the positioning options and returns them modified.\n */\nexport const PositioningConfigurationProvider = PositioningConfigurationContext.Provider;\n\nexport const usePositioningConfiguration = (): PositioningConfigurationFn => {\n return React.useContext(PositioningConfigurationContext) ?? DEFAULT_CONFIGURATION;\n};\n"],"names":["PositioningConfigurationProvider","usePositioningConfiguration","DEFAULT_CONFIGURATION","options","PositioningConfigurationContext","React","createContext","undefined","Provider","useContext"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAkBaA,gCAAgC;eAAhCA;;IAEAC,2BAA2B;eAA3BA;;;;iEApBU;AAGvB,MAAM;AAEN,MAAMC,wBAAoD,CAAC,EAAEC,OAAO,EAAE;IACpE,OAAOA;AACT;AAEA,MAAM;AAEN,MAAMC,kCAAkCC,OAAMC,aAAa,CAAyCC;AAO7F,MAAMP,mCAAmCI,gCAAgCI,QAAQ;AAEjF,MAAMP,8BAA8B;QAClCI;IAAP,OAAOA,CAAAA,oBAAAA,OAAMI,UAAU,CAACL,8CAAjBC,+BAAAA,oBAAqDH;AAC9D"}
@@ -11,19 +11,22 @@ Object.defineProperty(exports, "createSlideStyles", {
11
11
  const _reacttheme = require("@fluentui/react-theme");
12
12
  const _constants = require("./constants");
13
13
  function createSlideStyles(mainAxis) {
14
+ // With 'accumulate' animation composition, these opacity keyframes are added onto the default opacity of 1.
14
15
  const fadeIn = {
15
16
  from: {
16
- opacity: 0
17
+ opacity: -1
17
18
  },
18
19
  to: {
19
- opacity: 1
20
+ opacity: 0
20
21
  }
21
22
  };
22
23
  const slideDistanceVarX = '--fui-positioning-slide-distance-x';
23
24
  const slideDistanceVarY = '--fui-positioning-slide-distance-y';
24
25
  return {
25
- // The fade has absolute values, whereas the slide amount is relative.
26
- animationComposition: 'replace, accumulate',
26
+ // NOTE: there was a previous attempt to give fadeIn a separate composition mode:
27
+ // animationComposition: 'replace, accumulate',
28
+ // but somehow this was linked to a performance regression observed in Teams (bug #4255933)
29
+ animationComposition: 'accumulate',
27
30
  animationDuration: _reacttheme.tokens.durationSlower,
28
31
  animationTimingFunction: _reacttheme.tokens.curveDecelerateMid,
29
32
  [slideDistanceVarX]: `0px`,
@@ -52,7 +55,6 @@ function createSlideStyles(mainAxis) {
52
55
  // Note: at-rules have more specificity in Griffel
53
56
  '@media(prefers-reduced-motion)': {
54
57
  [`&[${_constants.DATA_POSITIONING_PLACEMENT}]`]: {
55
- animationComposition: 'replace',
56
58
  animationDuration: '1ms',
57
59
  animationName: fadeIn
58
60
  }
@@ -60,7 +62,6 @@ function createSlideStyles(mainAxis) {
60
62
  // Tested in Firefox 79
61
63
  '@supports not (animation-composition: accumulate)': {
62
64
  [`&[${_constants.DATA_POSITIONING_PLACEMENT}]`]: {
63
- animationComposition: 'replace',
64
65
  animationName: fadeIn
65
66
  }
66
67
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/createSlideStyles.ts"],"sourcesContent":["import { tokens } from '@fluentui/react-theme';\nimport type { GriffelStyle } from '@griffel/react';\nimport { DATA_POSITIONING_PLACEMENT } from './constants';\n\n/**\n * Creates animation styles so that positioned elements slide in from the main axis\n * @param mainAxis - distance than the element sides for\n * @returns Griffel styles to spread to a slot\n */\nexport function createSlideStyles(mainAxis: number): GriffelStyle {\n const fadeIn = {\n from: {\n opacity: 0,\n },\n to: {\n opacity: 1,\n },\n };\n\n const slideDistanceVarX = '--fui-positioning-slide-distance-x';\n const slideDistanceVarY = '--fui-positioning-slide-distance-y';\n\n return {\n // The fade has absolute values, whereas the slide amount is relative.\n animationComposition: 'replace, accumulate',\n animationDuration: tokens.durationSlower,\n animationTimingFunction: tokens.curveDecelerateMid,\n [slideDistanceVarX]: `0px`,\n [slideDistanceVarY]: `${mainAxis}px`,\n [`&[${DATA_POSITIONING_PLACEMENT}^=right]`]: {\n [slideDistanceVarX]: `-${mainAxis}px`,\n [slideDistanceVarY]: '0px',\n },\n\n [`&[${DATA_POSITIONING_PLACEMENT}^=bottom]`]: {\n [slideDistanceVarX]: '0px',\n [slideDistanceVarY]: `-${mainAxis}px`,\n },\n\n [`&[${DATA_POSITIONING_PLACEMENT}^=left]`]: {\n [slideDistanceVarX]: `${mainAxis}px`,\n [slideDistanceVarY]: '0px',\n },\n\n animationName: [\n fadeIn,\n {\n from: {\n transform: `translate(var(${slideDistanceVarX}), var(${slideDistanceVarY}))`,\n },\n to: {},\n },\n ],\n\n // Note: at-rules have more specificity in Griffel\n '@media(prefers-reduced-motion)': {\n [`&[${DATA_POSITIONING_PLACEMENT}]`]: {\n animationComposition: 'replace',\n animationDuration: '1ms',\n animationName: fadeIn,\n },\n },\n\n // Tested in Firefox 79\n '@supports not (animation-composition: accumulate)': {\n [`&[${DATA_POSITIONING_PLACEMENT}]`]: {\n animationComposition: 'replace',\n animationName: fadeIn,\n },\n },\n };\n}\n"],"names":["createSlideStyles","mainAxis","fadeIn","from","opacity","to","slideDistanceVarX","slideDistanceVarY","animationComposition","animationDuration","tokens","durationSlower","animationTimingFunction","curveDecelerateMid","DATA_POSITIONING_PLACEMENT","animationName","transform"],"rangeMappings":";;;;;;;;;;;;;;;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CN,sBAAsB;gBACtBC,mBAAmB;gBACnBM,eAAeb;YACjB;QACF;QAEA,uBAAuB;QACvB,qDAAqD;YACnD,CAAC,CAAC,EAAE,EAAEY,qCAA0B,CAAC,CAAC,CAAC,CAAC,EAAE;gBACpCN,sBAAsB;gBACtBO,eAAeb;YACjB;QACF;IACF;AACF"}
1
+ {"version":3,"sources":["../src/createSlideStyles.ts"],"sourcesContent":["import { tokens } from '@fluentui/react-theme';\nimport type { GriffelStyle } from '@griffel/react';\nimport { DATA_POSITIONING_PLACEMENT } from './constants';\n\n/**\n * Creates animation styles so that positioned elements slide in from the main axis\n * @param mainAxis - distance than the element sides for\n * @returns Griffel styles to spread to a slot\n */\nexport function createSlideStyles(mainAxis: number): GriffelStyle {\n // With 'accumulate' animation composition, these opacity keyframes are added onto the default opacity of 1.\n const fadeIn = {\n from: {\n opacity: -1, // becomes opacity: 0\n },\n to: {\n opacity: 0, // becomes opacity: 1\n },\n };\n\n const slideDistanceVarX = '--fui-positioning-slide-distance-x';\n const slideDistanceVarY = '--fui-positioning-slide-distance-y';\n\n return {\n // NOTE: there was a previous attempt to give fadeIn a separate composition mode:\n // animationComposition: 'replace, accumulate',\n // but somehow this was linked to a performance regression observed in Teams (bug #4255933)\n animationComposition: 'accumulate',\n animationDuration: tokens.durationSlower,\n animationTimingFunction: tokens.curveDecelerateMid,\n [slideDistanceVarX]: `0px`,\n [slideDistanceVarY]: `${mainAxis}px`,\n [`&[${DATA_POSITIONING_PLACEMENT}^=right]`]: {\n [slideDistanceVarX]: `-${mainAxis}px`,\n [slideDistanceVarY]: '0px',\n },\n\n [`&[${DATA_POSITIONING_PLACEMENT}^=bottom]`]: {\n [slideDistanceVarX]: '0px',\n [slideDistanceVarY]: `-${mainAxis}px`,\n },\n\n [`&[${DATA_POSITIONING_PLACEMENT}^=left]`]: {\n [slideDistanceVarX]: `${mainAxis}px`,\n [slideDistanceVarY]: '0px',\n },\n\n animationName: [\n fadeIn,\n {\n from: {\n transform: `translate(var(${slideDistanceVarX}), var(${slideDistanceVarY}))`,\n },\n to: {},\n },\n ],\n\n // Note: at-rules have more specificity in Griffel\n '@media(prefers-reduced-motion)': {\n [`&[${DATA_POSITIONING_PLACEMENT}]`]: {\n animationDuration: '1ms',\n animationName: fadeIn,\n },\n },\n\n // Tested in Firefox 79\n '@supports not (animation-composition: accumulate)': {\n [`&[${DATA_POSITIONING_PLACEMENT}]`]: {\n animationName: fadeIn,\n },\n },\n };\n}\n"],"names":["createSlideStyles","mainAxis","fadeIn","from","opacity","to","slideDistanceVarX","slideDistanceVarY","animationComposition","animationDuration","tokens","durationSlower","animationTimingFunction","curveDecelerateMid","DATA_POSITIONING_PLACEMENT","animationName","transform"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BASgBA;;;eAAAA;;;4BATO;2BAEoB;AAOpC,SAASA,kBAAkBC,QAAgB;IAChD,4GAA4G;IAC5G,MAAMC,SAAS;QACbC,MAAM;YACJC,SAAS,CAAC;QACZ;QACAC,IAAI;YACFD,SAAS;QACX;IACF;IAEA,MAAME,oBAAoB;IAC1B,MAAMC,oBAAoB;IAE1B,OAAO;QACL,iFAAiF;QACjF,iDAAiD;QACjD,2FAA2F;QAC3FC,sBAAsB;QACtBC,mBAAmBC,kBAAM,CAACC,cAAc;QACxCC,yBAAyBF,kBAAM,CAACG,kBAAkB;QAClD,CAACP,kBAAkB,EAAE,CAAC,GAAG,CAAC;QAC1B,CAACC,kBAAkB,EAAE,CAAC,EAAEN,SAAS,EAAE,CAAC;QACpC,CAAC,CAAC,EAAE,EAAEa,qCAA0B,CAAC,QAAQ,CAAC,CAAC,EAAE;YAC3C,CAACR,kBAAkB,EAAE,CAAC,CAAC,EAAEL,SAAS,EAAE,CAAC;YACrC,CAACM,kBAAkB,EAAE;QACvB;QAEA,CAAC,CAAC,EAAE,EAAEO,qCAA0B,CAAC,SAAS,CAAC,CAAC,EAAE;YAC5C,CAACR,kBAAkB,EAAE;YACrB,CAACC,kBAAkB,EAAE,CAAC,CAAC,EAAEN,SAAS,EAAE,CAAC;QACvC;QAEA,CAAC,CAAC,EAAE,EAAEa,qCAA0B,CAAC,OAAO,CAAC,CAAC,EAAE;YAC1C,CAACR,kBAAkB,EAAE,CAAC,EAAEL,SAAS,EAAE,CAAC;YACpC,CAACM,kBAAkB,EAAE;QACvB;QAEAQ,eAAe;YACbb;YACA;gBACEC,MAAM;oBACJa,WAAW,CAAC,cAAc,EAAEV,kBAAkB,OAAO,EAAEC,kBAAkB,EAAE,CAAC;gBAC9E;gBACAF,IAAI,CAAC;YACP;SACD;QAED,kDAAkD;QAClD,kCAAkC;YAChC,CAAC,CAAC,EAAE,EAAES,qCAA0B,CAAC,CAAC,CAAC,CAAC,EAAE;gBACpCL,mBAAmB;gBACnBM,eAAeb;YACjB;QACF;QAEA,uBAAuB;QACvB,qDAAqD;YACnD,CAAC,CAAC,EAAE,EAAEY,qCAA0B,CAAC,CAAC,CAAC,CAAC,EAAE;gBACpCC,eAAeb;YACjB;QACF;IACF;AACF"}
@@ -9,6 +9,9 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
+ PositioningConfigurationProvider: function() {
13
+ return _PositioningConfigurationContext.PositioningConfigurationProvider;
14
+ },
12
15
  createArrowHeightStyles: function() {
13
16
  return _createArrowStyles.createArrowHeightStyles;
14
17
  },
@@ -37,6 +40,7 @@ _export(exports, {
37
40
  const _createVirtualElementFromClick = require("./createVirtualElementFromClick");
38
41
  const _createArrowStyles = require("./createArrowStyles");
39
42
  const _createSlideStyles = require("./createSlideStyles");
43
+ const _PositioningConfigurationContext = require("./PositioningConfigurationContext");
40
44
  const _usePositioning = require("./usePositioning");
41
45
  const _usePositioningMouseTarget = require("./usePositioningMouseTarget");
42
46
  const _index = require("./utils/index");
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { createVirtualElementFromClick } from './createVirtualElementFromClick';\nexport { createArrowHeightStyles, createArrowStyles } from './createArrowStyles';\nexport { createSlideStyles } from './createSlideStyles';\nexport type { CreateArrowStylesOptions } from './createArrowStyles';\nexport { usePositioning } from './usePositioning';\nexport { usePositioningMouseTarget } from './usePositioningMouseTarget';\nexport { resolvePositioningShorthand, mergeArrowOffset } from './utils/index';\nexport type {\n Alignment,\n AutoSize,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n Boundary,\n Offset,\n OffsetFunction,\n OffsetFunctionParam,\n OffsetObject,\n OffsetShorthand,\n Position,\n PositioningBoundary,\n PositioningImperativeRef,\n PositioningProps,\n PositioningRect,\n PositioningShorthand,\n PositioningShorthandValue,\n PositioningVirtualElement,\n SetVirtualMouseTarget,\n} from './types';\n"],"names":["createArrowHeightStyles","createArrowStyles","createSlideStyles","createVirtualElementFromClick","mergeArrowOffset","resolvePositioningShorthand","usePositioning","usePositioningMouseTarget"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IACSA,uBAAuB;eAAvBA,0CAAuB;;IAAEC,iBAAiB;eAAjBA,oCAAiB;;IAC1CC,iBAAiB;eAAjBA,oCAAiB;;IAFjBC,6BAA6B;eAA7BA,4DAA6B;;IAMAC,gBAAgB;eAAhBA,uBAAgB;;IAA7CC,2BAA2B;eAA3BA,kCAA2B;;IAF3BC,cAAc;eAAdA,8BAAc;;IACdC,yBAAyB;eAAzBA,oDAAyB;;;+CALY;mCACa;mCACzB;gCAEH;2CACW;uBACoB"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { createVirtualElementFromClick } from './createVirtualElementFromClick';\nexport { createArrowHeightStyles, createArrowStyles } from './createArrowStyles';\nexport { createSlideStyles } from './createSlideStyles';\nexport type { CreateArrowStylesOptions } from './createArrowStyles';\n\nexport { PositioningConfigurationProvider } from './PositioningConfigurationContext';\n\nexport { usePositioning } from './usePositioning';\nexport { usePositioningMouseTarget } from './usePositioningMouseTarget';\nexport { resolvePositioningShorthand, mergeArrowOffset } from './utils/index';\n\nexport type {\n Alignment,\n AutoSize,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n Boundary,\n Offset,\n OffsetFunction,\n OffsetFunctionParam,\n OffsetObject,\n OffsetShorthand,\n Position,\n PositioningBoundary,\n PositioningImperativeRef,\n PositioningProps,\n PositioningRect,\n PositioningShorthand,\n PositioningShorthandValue,\n PositioningVirtualElement,\n SetVirtualMouseTarget,\n PositioningConfigurationFn,\n PositioningConfigurationFnOptions,\n} from './types';\n"],"names":["PositioningConfigurationProvider","createArrowHeightStyles","createArrowStyles","createSlideStyles","createVirtualElementFromClick","mergeArrowOffset","resolvePositioningShorthand","usePositioning","usePositioningMouseTarget"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAKSA,gCAAgC;eAAhCA,iEAAgC;;IAJhCC,uBAAuB;eAAvBA,0CAAuB;;IAAEC,iBAAiB;eAAjBA,oCAAiB;;IAC1CC,iBAAiB;eAAjBA,oCAAiB;;IAFjBC,6BAA6B;eAA7BA,4DAA6B;;IASAC,gBAAgB;eAAhBA,uBAAgB;;IAA7CC,2BAA2B;eAA3BA,kCAA2B;;IAF3BC,cAAc;eAAdA,8BAAc;;IACdC,yBAAyB;eAAzBA,oDAAyB;;;+CARY;mCACa;mCACzB;iDAGe;gCAElB;2CACW;uBACoB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/middleware/offset.ts"],"sourcesContent":["import { offset as baseOffset } from '@floating-ui/dom';\nimport type { PositioningOptions } from '../types';\nimport { getFloatingUIOffset } from '../utils/getFloatingUIOffset';\n\n/**\n * Wraps floating UI offset middleware to to transform offset value\n */\nexport function offset(offsetValue: PositioningOptions['offset']) {\n const floatingUIOffset = getFloatingUIOffset(offsetValue);\n return baseOffset(floatingUIOffset);\n}\n"],"names":["offset","offsetValue","floatingUIOffset","getFloatingUIOffset","baseOffset"],"rangeMappings":";;;;;;;;;;;;;;;","mappings":";;;;+BAOgBA;;;eAAAA;;;qBAPqB;qCAED;AAK7B,SAASA,OAAOC,WAAyC;IAC9D,MAAMC,mBAAmBC,IAAAA,wCAAmB,EAACF;IAC7C,OAAOG,IAAAA,WAAU,EAACF;AACpB"}
1
+ {"version":3,"sources":["../src/middleware/offset.ts"],"sourcesContent":["import { offset as baseOffset } from '@floating-ui/dom';\nimport type { PositioningOptions } from '../types';\nimport { getFloatingUIOffset } from '../utils/getFloatingUIOffset';\n\n/**\n * Wraps floating UI offset middleware to transform offset value.\n */\nexport function offset(offsetValue: PositioningOptions['offset']) {\n const floatingUIOffset = getFloatingUIOffset(offsetValue);\n return baseOffset(floatingUIOffset);\n}\n"],"names":["offset","offsetValue","floatingUIOffset","getFloatingUIOffset","baseOffset"],"rangeMappings":";;;;;;;;;;;;;;;","mappings":";;;;+BAOgBA;;;eAAAA;;;qBAPqB;qCAED;AAK7B,SAASA,OAAOC,WAAyC;IAC9D,MAAMC,mBAAmBC,IAAAA,wCAAmB,EAACF;IAC7C,OAAOG,IAAAA,WAAU,EAACF;AACpB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import * as React from 'react';\n\nexport type PositioningRect = {\n width: number;\n height: number;\n x: number;\n y: number;\n};\n\nexport type OffsetFunctionParam = {\n positionedRect: PositioningRect;\n targetRect: PositioningRect;\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 PositioningBoundary =\n | PositioningRect\n | HTMLElement\n | Array<HTMLElement>\n | 'clippingParents'\n | 'scrollParent'\n | 'window';\n/**\n * @deprecated use PositioningBoundary instead\n */\nexport type Boundary = PositioningBoundary;\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 | null) => 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?: PositioningBoundary | null;\n\n /** The element which will define the boundaries of the positioned element for the overflow behavior. */\n overflowBoundary?: PositioningBoundary | 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 * When set, the positioned element matches the chosen dimension(s) of the target element\n */\n matchTargetSize?: 'width';\n\n /**\n * Called when a position update has finished. Multiple position updates can happen in a single render,\n * since positioning happens outside of the React lifecycle.\n *\n * It's also possible to listen to the custom DOM event `fui-positioningend`\n */\n onPositioningEnd?: () => void;\n\n /**\n * Disables the resize observer that updates position on target or dimension change\n */\n disableUpdateOnResize?: boolean;\n\n /**\n * When true, the positioned element will shift to cover the target element when there's not enough space.\n * @default false\n */\n shiftToCoverTarget?: 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 | 'fallbackPositions'\n | 'flipBoundary'\n | 'offset'\n | 'overflowBoundary'\n | 'overflowBoundaryPadding'\n | 'pinned'\n | 'position'\n | 'strategy'\n | 'useTransform'\n | 'matchTargetSize'\n | 'onPositioningEnd'\n | 'disableUpdateOnResize'\n | 'shiftToCoverTarget'\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":[],"rangeMappings":";;;;;","mappings":";;;;;iEAAuB"}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import * as React from 'react';\n\nexport type PositioningRect = {\n width: number;\n height: number;\n x: number;\n y: number;\n};\n\nexport type OffsetFunctionParam = {\n positionedRect: PositioningRect;\n targetRect: PositioningRect;\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 PositioningBoundary =\n | PositioningRect\n | HTMLElement\n | Array<HTMLElement>\n | 'clippingParents'\n | 'scrollParent'\n | 'window';\n/**\n * @deprecated use PositioningBoundary instead\n */\nexport type Boundary = PositioningBoundary;\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 | null) => 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?: PositioningBoundary | null;\n\n /** The element which will define the boundaries of the positioned element for the overflow behavior. */\n overflowBoundary?: PositioningBoundary | 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 * When set, the positioned element matches the chosen dimension(s) of the target element\n */\n matchTargetSize?: 'width';\n\n /**\n * Called when a position update has finished. Multiple position updates can happen in a single render,\n * since positioning happens outside of the React lifecycle.\n *\n * It's also possible to listen to the custom DOM event `fui-positioningend`\n */\n onPositioningEnd?: () => void;\n\n /**\n * Disables the resize observer that updates position on target or dimension change\n */\n disableUpdateOnResize?: boolean;\n\n /**\n * When true, the positioned element will shift to cover the target element when there's not enough space.\n * @default false\n */\n shiftToCoverTarget?: 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 | 'fallbackPositions'\n | 'flipBoundary'\n | 'offset'\n | 'overflowBoundary'\n | 'overflowBoundaryPadding'\n | 'pinned'\n | 'position'\n | 'strategy'\n | 'useTransform'\n | 'matchTargetSize'\n | 'onPositioningEnd'\n | 'disableUpdateOnResize'\n | 'shiftToCoverTarget'\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\n// ---\n\nexport type PositioningConfigurationFnOptions = Omit<\n PositioningOptions,\n // Excluded as the function will never be called if disabled\n | 'enabled'\n // Callback is not subscribed from options\n | 'onPositioningEnd'\n // Is deprecated, no need to bloat the interface\n | 'positionFixed'\n>;\nexport type PositioningConfigurationFn = (params: {\n container: HTMLElement;\n arrow: HTMLElement | null;\n options: PositioningConfigurationFnOptions;\n}) => PositioningConfigurationFnOptions;\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;iEAAuB"}
@@ -9,16 +9,12 @@ Object.defineProperty(exports, "usePositioning", {
9
9
  }
10
10
  });
11
11
  const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
- const _dom = require("@floating-ui/dom");
13
- const _reactsharedcontexts = require("@fluentui/react-shared-contexts");
14
12
  const _reactutilities = require("@fluentui/react-utilities");
15
13
  const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
16
- const _utils = require("./utils");
17
- const _middleware = require("./middleware");
18
- const _createPositionManager = require("./createPositionManager");
19
- const _devtools = require("@floating-ui/devtools");
20
- const _devtools1 = require("./utils/devtools");
21
14
  const _constants = require("./constants");
15
+ const _createPositionManager = require("./createPositionManager");
16
+ const _usePositioningOptions = require("./usePositioningOptions");
17
+ const _utils = require("./utils");
22
18
  function usePositioning(options) {
23
19
  'use no memo';
24
20
  const managerRef = _react.useRef(null);
@@ -27,7 +23,7 @@ function usePositioning(options) {
27
23
  const containerRef = _react.useRef(null);
28
24
  const arrowRef = _react.useRef(null);
29
25
  const { enabled = true } = options;
30
- const resolvePositioningOptions = usePositioningOptions(options);
26
+ const resolvePositioningOptions = (0, _usePositioningOptions.usePositioningOptions)(options);
31
27
  const updatePositionManager = _react.useCallback(()=>{
32
28
  if (managerRef.current) {
33
29
  managerRef.current.dispose();
@@ -95,10 +91,10 @@ function usePositioning(options) {
95
91
  while(treeWalker.nextNode()){
96
92
  const node = treeWalker.currentNode;
97
93
  // eslint-disable-next-line no-console
98
- console.warn('<Popper>:', node);
94
+ console.warn('usePositioning():', node);
99
95
  // eslint-disable-next-line no-console
100
96
  console.warn([
101
- '<Popper>: ^ this node contains "autoFocus" prop on a React element. This can break the initial',
97
+ 'usePositioning(): ^ this node contains "autoFocus" prop on a React element. This can break the initial',
102
98
  'positioning of an element and cause a window jump effect. This issue occurs because React polyfills',
103
99
  '"autoFocus" behavior to solve inconsistencies between different browsers:',
104
100
  'https://github.com/facebook/react/issues/11851#issuecomment-351787078',
@@ -152,84 +148,3 @@ function usePositioning(options) {
152
148
  arrowRef: setArrow
153
149
  };
154
150
  }
155
- function usePositioningOptions(options) {
156
- 'use no memo';
157
- const { align, arrowPadding, autoSize: rawAutoSize, coverTarget, flipBoundary, offset, overflowBoundary, pinned, position, unstable_disableTether: disableTether, // eslint-disable-next-line @typescript-eslint/no-deprecated
158
- positionFixed, strategy, overflowBoundaryPadding, fallbackPositions, useTransform, matchTargetSize, disableUpdateOnResize = false, shiftToCoverTarget } = options;
159
- const { dir, targetDocument } = (0, _reactsharedcontexts.useFluent_unstable)();
160
- const isRtl = dir === 'rtl';
161
- const positionStrategy = (strategy !== null && strategy !== void 0 ? strategy : positionFixed) ? 'fixed' : 'absolute';
162
- const autoSize = (0, _utils.normalizeAutoSize)(rawAutoSize);
163
- return _react.useCallback((container, arrow)=>{
164
- const hasScrollableElement = (0, _utils.hasScrollParent)(container);
165
- const middleware = [
166
- autoSize && (0, _middleware.resetMaxSize)(autoSize),
167
- matchTargetSize && (0, _middleware.matchTargetSize)(),
168
- offset && (0, _middleware.offset)(offset),
169
- coverTarget && (0, _middleware.coverTarget)(),
170
- !pinned && (0, _middleware.flip)({
171
- container,
172
- flipBoundary,
173
- hasScrollableElement,
174
- isRtl,
175
- fallbackPositions
176
- }),
177
- (0, _middleware.shift)({
178
- container,
179
- hasScrollableElement,
180
- overflowBoundary,
181
- disableTether,
182
- overflowBoundaryPadding,
183
- isRtl,
184
- shiftToCoverTarget
185
- }),
186
- autoSize && (0, _middleware.maxSize)(autoSize, {
187
- container,
188
- overflowBoundary,
189
- overflowBoundaryPadding,
190
- isRtl
191
- }),
192
- (0, _middleware.intersecting)(),
193
- arrow && (0, _dom.arrow)({
194
- element: arrow,
195
- padding: arrowPadding
196
- }),
197
- (0, _dom.hide)({
198
- strategy: 'referenceHidden'
199
- }),
200
- (0, _dom.hide)({
201
- strategy: 'escaped'
202
- }),
203
- process.env.NODE_ENV !== 'production' && targetDocument && (0, _devtools.devtools)(targetDocument, (0, _devtools1.devtoolsCallback)(options))
204
- ].filter(Boolean);
205
- const placement = (0, _utils.toFloatingUIPlacement)(align, position, isRtl);
206
- return {
207
- placement,
208
- middleware,
209
- strategy: positionStrategy,
210
- useTransform,
211
- disableUpdateOnResize
212
- };
213
- }, // Options is missing here, but it's not required
214
- // eslint-disable-next-line react-hooks/exhaustive-deps
215
- [
216
- align,
217
- arrowPadding,
218
- autoSize,
219
- coverTarget,
220
- disableTether,
221
- flipBoundary,
222
- isRtl,
223
- offset,
224
- overflowBoundary,
225
- pinned,
226
- position,
227
- positionStrategy,
228
- overflowBoundaryPadding,
229
- fallbackPositions,
230
- useTransform,
231
- matchTargetSize,
232
- targetDocument,
233
- disableUpdateOnResize
234
- ]);
235
- }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/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 matchTargetSize as matchTargetSizeMiddleware,\n} from './middleware';\nimport { createPositionManager } from './createPositionManager';\nimport { devtools } from '@floating-ui/devtools';\nimport { devtoolsCallback } from './utils/devtools';\nimport { POSITIONING_END_EVENT } from './constants';\n\n/**\n * @internal\n */\nexport function usePositioning(options: PositioningProps & PositioningOptions): UsePositioningReturn {\n 'use no memo';\n\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 | null) => {\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 }, []);\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 onPositioningEnd = useEventCallback(() => options.onPositioningEnd?.());\n const setContainer = useCallbackRef<HTMLElement | null>(null, container => {\n if (containerRef.current !== container) {\n containerRef.current?.removeEventListener(POSITIONING_END_EVENT, onPositioningEnd);\n container?.addEventListener(POSITIONING_END_EVENT, onPositioningEnd);\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 'use no memo';\n\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 @typescript-eslint/no-deprecated\n positionFixed,\n strategy,\n overflowBoundaryPadding,\n fallbackPositions,\n useTransform,\n matchTargetSize,\n disableUpdateOnResize = false,\n shiftToCoverTarget,\n } = options;\n\n const { dir, targetDocument } = 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 matchTargetSize && matchTargetSizeMiddleware(),\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 shiftToCoverTarget,\n }),\n autoSize && maxSizeMiddleware(autoSize, { container, overflowBoundary, overflowBoundaryPadding, isRtl }),\n intersectingMiddleware(),\n arrow && arrowMiddleware({ element: arrow, padding: arrowPadding }),\n hideMiddleware({ strategy: 'referenceHidden' }),\n hideMiddleware({ strategy: 'escaped' }),\n process.env.NODE_ENV !== 'production' && targetDocument && devtools(targetDocument, devtoolsCallback(options)),\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 disableUpdateOnResize,\n };\n },\n // Options is missing here, but it's not required\n // eslint-disable-next-line react-hooks/exhaustive-deps\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 matchTargetSize,\n targetDocument,\n disableUpdateOnResize,\n ],\n );\n}\n"],"names":["usePositioning","options","managerRef","React","useRef","targetRef","overrideTargetRef","containerRef","arrowRef","enabled","resolvePositioningOptions","usePositioningOptions","updatePositionManager","useCallback","current","dispose","target","canUseDOM","createPositionManager","container","arrow","setOverrideTarget","useEventCallback","useImperativeHandle","positioningRef","updatePosition","setTarget","process","env","NODE_ENV","err","Error","console","warn","stack","useIsomorphicLayoutEffect","useEffect","contentNode","treeWalker","ownerDocument","createTreeWalker","NodeFilter","SHOW_ELEMENT","acceptNode","hasAutofocusFilter","nextNode","node","currentNode","join","useCallbackRef","onPositioningEnd","setContainer","removeEventListener","POSITIONING_END_EVENT","addEventListener","setArrow","align","arrowPadding","autoSize","rawAutoSize","coverTarget","flipBoundary","offset","overflowBoundary","pinned","position","unstable_disableTether","disableTether","positionFixed","strategy","overflowBoundaryPadding","fallbackPositions","useTransform","matchTargetSize","disableUpdateOnResize","shiftToCoverTarget","dir","targetDocument","useFluent","isRtl","positionStrategy","normalizeAutoSize","hasScrollableElement","hasScrollParent","middleware","resetMaxSizeMiddleware","matchTargetSizeMiddleware","offsetMiddleware","coverTargetMiddleware","flipMiddleware","shiftMiddleware","maxSizeMiddleware","intersectingMiddleware","arrowMiddleware","element","padding","hideMiddleware","devtools","devtoolsCallback","filter","Boolean","placement","toFloatingUIPlacement"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;QACElB;QACAC;QACAC;QACAE;QACAO;QACAN;QACAkB;QACAjB;QACAC;QACAC;QACAC;QACAe;QACAV;QACAC;QACAC;QACAC;QACAI;QACAH;KACD;AAEL"}
1
+ {"version":3,"sources":["../src/usePositioning.ts"],"sourcesContent":["import { canUseDOM, useEventCallback, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport { POSITIONING_END_EVENT } from './constants';\nimport { createPositionManager } from './createPositionManager';\nimport type {\n PositioningOptions,\n PositioningProps,\n PositionManager,\n TargetElement,\n UsePositioningReturn,\n} from './types';\nimport { usePositioningOptions } from './usePositioningOptions';\nimport { useCallbackRef, hasAutofocusFilter } from './utils';\n\n/**\n * @internal\n */\nexport function usePositioning(options: PositioningProps & PositioningOptions): UsePositioningReturn {\n 'use no memo';\n\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 | null) => {\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('usePositioning():', node);\n // eslint-disable-next-line no-console\n console.warn(\n [\n 'usePositioning(): ^ 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 }, []);\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 onPositioningEnd = useEventCallback(() => options.onPositioningEnd?.());\n const setContainer = useCallbackRef<HTMLElement | null>(null, container => {\n if (containerRef.current !== container) {\n containerRef.current?.removeEventListener(POSITIONING_END_EVENT, onPositioningEnd);\n container?.addEventListener(POSITIONING_END_EVENT, onPositioningEnd);\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"],"names":["usePositioning","options","managerRef","React","useRef","targetRef","overrideTargetRef","containerRef","arrowRef","enabled","resolvePositioningOptions","usePositioningOptions","updatePositionManager","useCallback","current","dispose","target","canUseDOM","createPositionManager","container","arrow","setOverrideTarget","useEventCallback","useImperativeHandle","positioningRef","updatePosition","setTarget","process","env","NODE_ENV","err","Error","console","warn","stack","useIsomorphicLayoutEffect","useEffect","contentNode","treeWalker","ownerDocument","createTreeWalker","NodeFilter","SHOW_ELEMENT","acceptNode","hasAutofocusFilter","nextNode","node","currentNode","join","useCallbackRef","onPositioningEnd","setContainer","removeEventListener","POSITIONING_END_EVENT","addEventListener","setArrow"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAkBgBA;;;eAAAA;;;;gCAlBuD;iEAChD;2BAEe;uCACA;uCAQA;uBACa;AAK5C,SAASA,eAAeC,OAA8C;IAC3E;IAEA,MAAMC,aAAaC,OAAMC,MAAM,CAAyB;IACxD,MAAMC,YAAYF,OAAMC,MAA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cAAxBjD,gDAAAA,+BAAAA;;IAChD,MAAMkD,eAAeF,IAAAA,qBAAc,EAAqB,MAAM9B,CAAAA;QAC5D,IAAIZ,aAAaO,OAAO,KAAKK,WAAW;gBACtCZ;aAAAA,wBAAAA,aAAaO,OAAO,cAApBP,4CAAAA,sBAAsB6C,mBAAmB,CAACC,gCAAqB,EAAEH;YACjE/B,sBAAAA,gCAAAA,UAAWmC,gBAAgB,CAACD,gCAAqB,EAAEH;YACnD3C,aAAaO,OAAO,GAAGK;YACvBP;QACF;IACF;IAEA,MAAM2C,WAAWN,IAAAA,qBAAc,EAAqB,MAAM7B,CAAAA;QACxD,IAAIZ,SAASM,OAAO,KAAKM,OAAO;YAC9BZ,SAASM,OAAO,GAAGM;YACnBR;QACF;IACF;IAEA,kEAAkE;IAClE,OAAO;QAAEP,WAAWqB;QAAWnB,cAAc4C;QAAc3C,UAAU+C;IAAS;AAChF"}
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "usePositioningOptions", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return usePositioningOptions;
9
+ }
10
+ });
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _devtools = require("@floating-ui/devtools");
13
+ const _dom = require("@floating-ui/dom");
14
+ const _reactsharedcontexts = require("@fluentui/react-shared-contexts");
15
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
16
+ const _middleware = require("./middleware");
17
+ const _utils = require("./utils");
18
+ const _devtools1 = require("./utils/devtools");
19
+ const _PositioningConfigurationContext = require("./PositioningConfigurationContext");
20
+ /**
21
+ * @internal
22
+ *
23
+ * This is redundant and exists only to manage React dependencies properly & avoid leaking individual options to the
24
+ * scope of `usePositioningOptions`.
25
+ */ function usePositioningConfigFn(configFn, options) {
26
+ const { align, arrowPadding, autoSize, coverTarget, disableUpdateOnResize, flipBoundary, offset, overflowBoundary, pinned, position, // eslint-disable-next-line @typescript-eslint/naming-convention
27
+ unstable_disableTether, strategy, overflowBoundaryPadding, fallbackPositions, useTransform, matchTargetSize, shiftToCoverTarget } = options;
28
+ return _react.useCallback((container, arrow)=>{
29
+ return configFn({
30
+ container,
31
+ arrow,
32
+ options: {
33
+ autoSize,
34
+ disableUpdateOnResize,
35
+ matchTargetSize,
36
+ offset,
37
+ strategy,
38
+ coverTarget,
39
+ flipBoundary,
40
+ overflowBoundary,
41
+ useTransform,
42
+ overflowBoundaryPadding,
43
+ pinned,
44
+ arrowPadding,
45
+ align,
46
+ fallbackPositions,
47
+ shiftToCoverTarget,
48
+ position,
49
+ // eslint-disable-next-line @typescript-eslint/naming-convention
50
+ unstable_disableTether
51
+ }
52
+ });
53
+ }, [
54
+ autoSize,
55
+ disableUpdateOnResize,
56
+ matchTargetSize,
57
+ offset,
58
+ strategy,
59
+ coverTarget,
60
+ flipBoundary,
61
+ overflowBoundary,
62
+ useTransform,
63
+ overflowBoundaryPadding,
64
+ pinned,
65
+ arrowPadding,
66
+ align,
67
+ fallbackPositions,
68
+ shiftToCoverTarget,
69
+ position,
70
+ unstable_disableTether,
71
+ configFn
72
+ ]);
73
+ }
74
+ function usePositioningOptions(options) {
75
+ const { dir, targetDocument } = (0, _reactsharedcontexts.useFluent_unstable)();
76
+ const isRtl = dir === 'rtl';
77
+ const configFn = usePositioningConfigFn((0, _PositioningConfigurationContext.usePositioningConfiguration)(), options);
78
+ const { // eslint-disable-next-line @typescript-eslint/no-deprecated
79
+ positionFixed } = options;
80
+ return _react.useCallback((container, arrow)=>{
81
+ const hasScrollableElement = (0, _utils.hasScrollParent)(container);
82
+ const optionsAfterEnhancement = configFn(container, arrow);
83
+ const { autoSize, disableUpdateOnResize, matchTargetSize, offset, coverTarget, flipBoundary, overflowBoundary, useTransform, overflowBoundaryPadding, pinned, position, arrowPadding, strategy, align, fallbackPositions, shiftToCoverTarget, // eslint-disable-next-line @typescript-eslint/naming-convention
84
+ unstable_disableTether } = optionsAfterEnhancement;
85
+ const normalizedAutoSize = (0, _utils.normalizeAutoSize)(autoSize);
86
+ const middleware = [
87
+ normalizedAutoSize && (0, _middleware.resetMaxSize)(normalizedAutoSize),
88
+ matchTargetSize && (0, _middleware.matchTargetSize)(),
89
+ offset && (0, _middleware.offset)(offset),
90
+ coverTarget && (0, _middleware.coverTarget)(),
91
+ !pinned && (0, _middleware.flip)({
92
+ container,
93
+ flipBoundary,
94
+ hasScrollableElement,
95
+ isRtl,
96
+ fallbackPositions
97
+ }),
98
+ (0, _middleware.shift)({
99
+ container,
100
+ hasScrollableElement,
101
+ overflowBoundary,
102
+ disableTether: unstable_disableTether,
103
+ overflowBoundaryPadding,
104
+ isRtl,
105
+ shiftToCoverTarget
106
+ }),
107
+ normalizedAutoSize && (0, _middleware.maxSize)(normalizedAutoSize, {
108
+ container,
109
+ overflowBoundary,
110
+ overflowBoundaryPadding,
111
+ isRtl
112
+ }),
113
+ (0, _middleware.intersecting)(),
114
+ arrow && (0, _dom.arrow)({
115
+ element: arrow,
116
+ padding: arrowPadding
117
+ }),
118
+ (0, _dom.hide)({
119
+ strategy: 'referenceHidden'
120
+ }),
121
+ (0, _dom.hide)({
122
+ strategy: 'escaped'
123
+ }),
124
+ process.env.NODE_ENV !== 'production' && targetDocument && (0, _devtools.devtools)(targetDocument, (0, _devtools1.devtoolsCallback)(optionsAfterEnhancement))
125
+ ].filter(Boolean);
126
+ const placement = (0, _utils.toFloatingUIPlacement)(align, position, isRtl);
127
+ return {
128
+ placement,
129
+ middleware,
130
+ strategy: (strategy !== null && strategy !== void 0 ? strategy : positionFixed) ? 'fixed' : 'absolute',
131
+ disableUpdateOnResize,
132
+ useTransform
133
+ };
134
+ }, [
135
+ configFn,
136
+ isRtl,
137
+ targetDocument,
138
+ positionFixed
139
+ ]);
140
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/usePositioningOptions.ts"],"sourcesContent":["import { devtools } from '@floating-ui/devtools';\nimport { hide as hideMiddleware, arrow as arrowMiddleware } from '@floating-ui/dom';\nimport type { Middleware } from '@floating-ui/dom';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport * as React from 'react';\n\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 matchTargetSize as matchTargetSizeMiddleware,\n} from './middleware';\nimport type { PositioningConfigurationFn, PositioningConfigurationFnOptions, PositioningOptions } from './types';\nimport { toFloatingUIPlacement, hasScrollParent, normalizeAutoSize } from './utils';\nimport { devtoolsCallback } from './utils/devtools';\nimport { usePositioningConfiguration } from './PositioningConfigurationContext';\n\n/**\n * @internal\n *\n * This is redundant and exists only to manage React dependencies properly & avoid leaking individual options to the\n * scope of `usePositioningOptions`.\n */\nfunction usePositioningConfigFn(\n configFn: PositioningConfigurationFn,\n options: PositioningOptions,\n): (container: HTMLElement, arrow: HTMLElement | null) => PositioningConfigurationFnOptions {\n const {\n align,\n arrowPadding,\n autoSize,\n coverTarget,\n disableUpdateOnResize,\n flipBoundary,\n offset,\n overflowBoundary,\n pinned,\n position,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n unstable_disableTether,\n strategy,\n overflowBoundaryPadding,\n fallbackPositions,\n useTransform,\n matchTargetSize,\n shiftToCoverTarget,\n } = options;\n\n return React.useCallback(\n (container: HTMLElement, arrow: HTMLElement | null) => {\n return configFn({\n container,\n arrow,\n options: {\n autoSize,\n disableUpdateOnResize,\n matchTargetSize,\n offset,\n strategy,\n coverTarget,\n flipBoundary,\n overflowBoundary,\n useTransform,\n overflowBoundaryPadding,\n pinned,\n arrowPadding,\n align,\n fallbackPositions,\n shiftToCoverTarget,\n position,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n unstable_disableTether,\n },\n });\n },\n [\n autoSize,\n disableUpdateOnResize,\n matchTargetSize,\n offset,\n strategy,\n coverTarget,\n flipBoundary,\n overflowBoundary,\n useTransform,\n overflowBoundaryPadding,\n pinned,\n arrowPadding,\n align,\n fallbackPositions,\n shiftToCoverTarget,\n position,\n unstable_disableTether,\n configFn,\n ],\n );\n}\n\n/**\n * @internal\n */\nexport function usePositioningOptions(options: PositioningOptions) {\n const { dir, targetDocument } = useFluent();\n const isRtl = dir === 'rtl';\n\n const configFn = usePositioningConfigFn(usePositioningConfiguration(), options);\n const {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n positionFixed,\n } = options;\n\n return React.useCallback(\n (container: HTMLElement, arrow: HTMLElement | null) => {\n const hasScrollableElement = hasScrollParent(container);\n\n const optionsAfterEnhancement = configFn(container, arrow);\n const {\n autoSize,\n disableUpdateOnResize,\n matchTargetSize,\n offset,\n coverTarget,\n flipBoundary,\n overflowBoundary,\n useTransform,\n overflowBoundaryPadding,\n pinned,\n position,\n arrowPadding,\n strategy,\n align,\n fallbackPositions,\n shiftToCoverTarget,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n unstable_disableTether,\n } = optionsAfterEnhancement;\n const normalizedAutoSize = normalizeAutoSize(autoSize);\n\n const middleware = [\n normalizedAutoSize && resetMaxSizeMiddleware(normalizedAutoSize),\n matchTargetSize && matchTargetSizeMiddleware(),\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: unstable_disableTether,\n overflowBoundaryPadding,\n isRtl,\n shiftToCoverTarget,\n }),\n normalizedAutoSize &&\n maxSizeMiddleware(normalizedAutoSize, { container, overflowBoundary, overflowBoundaryPadding, isRtl }),\n intersectingMiddleware(),\n arrow && arrowMiddleware({ element: arrow, padding: arrowPadding }),\n hideMiddleware({ strategy: 'referenceHidden' }),\n hideMiddleware({ strategy: 'escaped' }),\n process.env.NODE_ENV !== 'production' &&\n targetDocument &&\n devtools(targetDocument, devtoolsCallback(optionsAfterEnhancement)),\n ].filter(Boolean) as Middleware[];\n\n const placement = toFloatingUIPlacement(align, position, isRtl);\n\n return {\n placement,\n middleware,\n strategy: strategy ?? positionFixed ? ('fixed' as const) : ('absolute' as const),\n\n disableUpdateOnResize,\n useTransform,\n };\n },\n [configFn, isRtl, targetDocument, positionFixed],\n );\n}\n"],"names":["usePositioningOptions","usePositioningConfigFn","configFn","options","align","arrowPadding","autoSize","coverTarget","disableUpdateOnResize","flipBoundary","offset","overflowBoundary","pinned","position","unstable_disableTether","strategy","overflowBoundaryPadding","fallbackPositions","useTransform","matchTargetSize","shiftToCoverTarget","React","useCallback","container","arrow","dir","targetDocument","useFluent","isRtl","usePositioningConfiguration","positionFixed","hasScrollableElement","hasScrollParent","optionsAfterEnhancement","normalizedAutoSize","normalizeAutoSize","middleware","resetMaxSizeMiddleware","matchTargetSizeMiddleware","offsetMiddleware","coverTargetMiddleware","flipMiddleware","shiftMiddleware","disableTether","maxSizeMiddleware","intersectingMiddleware","arrowMiddleware","element","padding","hideMiddleware","process","env","NODE_ENV","devtools","devtoolsCallback","filter","Boolean","placement","toFloatingUIPlacement"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAyGgBA;;;eAAAA;;;;0BAzGS;qBACwC;qCAEjB;iEACzB;4BAWhB;uBAEmE;2BACzC;iDACW;AAE5C;;;;;CAKC,GACD,SAASC,uBACPC,QAAoC,EACpCC,OAA2B;IAE3B,MAAM,EACJC,KAAK,EACLC,YAAY,EACZC,QAAQ,EACRC,WAAW,EACXC,qBAAqB,EACrBC,YAAY,EACZC,MAAM,EACNC,gBAAgB,EAChBC,MAAM,EACNC,QAAQ,EACR,gEAAgE;IAChEC,sBAAsB,EACtB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mBmB,IAAAA,2BAAyB;YAC5C5B,UAAU6B,IAAAA,kBAAgB,EAAC7B;YAC3BH,eAAeiC,IAAAA,uBAAqB;YACpC,CAAC5B,UAAU6B,IAAAA,gBAAc,EAAC;gBAAElB;gBAAWd;gBAAcsB;gBAAsBH;gBAAOX;YAAkB;YACpGyB,IAAAA,iBAAe,EAAC;gBACdnB;gBACAQ;gBACApB;gBACAgC,eAAe7B;gBACfE;gBACAY;gBACAR;YACF;YACAc,sBACEU,IAAAA,mBAAiB,EAACV,oBAAoB;gBAAEX;gBAAWZ;gBAAkBK;gBAAyBY;YAAM;YACtGiB,IAAAA,wBAAsB;YACtBrB,SAASsB,IAAAA,UAAe,EAAC;gBAAEC,SAASvB;gBAAOwB,SAAS3C;YAAa;YACjE4C,IAAAA,SAAc,EAAC;gBAAElC,UAAU;YAAkB;YAC7CkC,IAAAA,SAAc,EAAC;gBAAElC,UAAU;YAAU;YACrCmC,QAAQC,GAAG,CAACC,QAAQ,KAAK,gBACvB1B,kBACA2B,IAAAA,kBAAQ,EAAC3B,gBAAgB4B,IAAAA,2BAAgB,EAACrB;SAC7C,CAACsB,MAAM,CAACC;QAET,MAAMC,YAAYC,IAAAA,4BAAqB,EAACtD,OAAOS,UAAUe;QAEzD,OAAO;YACL6B;YACArB;YACArB,UAAUA,CAAAA,qBAAAA,sBAAAA,WAAYe,aAAY,IAAK,UAAqB;YAE5DtB;YACAU;QACF;IACF,GACA;QAAChB;QAAU0B;QAAOF;QAAgBI;KAAc;AAEpD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils/devtools.ts"],"sourcesContent":["import type { MiddlewareState } from '@floating-ui/dom';\nimport type { PositioningOptions } from '../types';\nimport { isHTMLElement } from '@fluentui/react-utilities';\nimport { listScrollParents } from './listScrollParents';\nimport { fromFloatingUIPlacement } from './fromFloatingUIPlacement';\n\nexport const devtoolsCallback = (options: PositioningOptions) => (middlewareState: MiddlewareState) => {\n const {\n elements: { floating, reference },\n } = middlewareState;\n const scrollParentsSet = new Set<HTMLElement>();\n if (isHTMLElement(reference)) {\n listScrollParents(reference).forEach(scrollParent => scrollParentsSet.add(scrollParent));\n }\n listScrollParents(floating).forEach(scrollParent => scrollParentsSet.add(scrollParent));\n const flipBoundaries: HTMLElement[] = Array.isArray(options.flipBoundary)\n ? options.flipBoundary\n : isHTMLElement(options.flipBoundary)\n ? [options.flipBoundary]\n : [];\n const overflowBoundaries: HTMLElement[] = Array.isArray(options.overflowBoundary)\n ? options.overflowBoundary\n : isHTMLElement(options.overflowBoundary)\n ? [options.overflowBoundary]\n : [];\n return {\n type: 'FluentUIMiddleware',\n middlewareState,\n options,\n initialPlacement: fromFloatingUIPlacement(middlewareState.initialPlacement),\n placement: fromFloatingUIPlacement(middlewareState.placement),\n flipBoundaries,\n overflowBoundaries,\n scrollParents: Array.from(scrollParentsSet),\n } as const;\n};\n"],"names":["devtoolsCallback","options","middlewareState","elements","floating","reference","scrollParentsSet","Set","isHTMLElement","listScrollParents","forEach","scrollParent","add","flipBoundaries","Array","isArray","flipBoundary","overflowBoundaries","overflowBoundary","type","initialPlacement","fromFloatingUIPlacement","placement","scrollParents","from"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAMaA;;;eAAAA;;;gCAJiB;mCACI;yCACM;AAEjC,MAAMA,mBAAmB,CAACC,UAAgC,CAACC;QAChE,MAAM,EACJC,UAAU,EAAEC,QAAQ,EAAEC,SAAS,EAAE,EAClC,GAAGH;QACJ,MAAMI,mBAAmB,IAAIC;QAC7B,IAAIC,IAAAA,6BAAa,EAACH,YAAY;YAC5BI,IAAAA,oCAAiB,EAACJ,WAAWK,OAAO,CAACC,CAAAA,eAAgBL,iBAAiBM,GAAG,CAACD;QAC5E;QACAF,IAAAA,oCAAiB,EAACL,UAAUM,OAAO,CAACC,CAAAA,eAAgBL,iBAAiBM,GAAG,CAACD;QACzE,MAAME,iBAAgCC,MAAMC,OAAO,CAACd,QAAQe,YAAY,IACpEf,QAAQe,YAAY,GACpBR,IAAAA,6BAAa,EAACP,QAAQe,YAAY,IAClC;YAACf,QAAQe,YAAY;SAAC,GACtB,EAAE;QACN,MAAMC,qBAAoCH,MAAMC,OAAO,CAACd,QAAQiB,gBAAgB,IAC5EjB,QAAQiB,gBAAgB,GACxBV,IAAAA,6BAAa,EAACP,QAAQiB,gBAAgB,IACtC;YAACjB,QAAQiB,gBAAgB;SAAC,GAC1B,EAAE;QACN,OAAO;YACLC,MAAM;YACNjB;YACAD;YACAmB,kBAAkBC,IAAAA,gDAAuB,EAACnB,gBAAgBkB,gBAAgB;YAC1EE,WAAWD,IAAAA,gDAAuB,EAACnB,gBAAgBoB,SAAS;YAC5DT;YACAI;YACAM,eAAeT,MAAMU,IAAI,CAAClB;QAC5B;IACF"}
1
+ {"version":3,"sources":["../src/utils/devtools.ts"],"sourcesContent":["import type { MiddlewareState } from '@floating-ui/dom';\nimport type { PositioningOptions } from '../types';\nimport { isHTMLElement } from '@fluentui/react-utilities';\nimport { listScrollParents } from './listScrollParents';\nimport { fromFloatingUIPlacement } from './fromFloatingUIPlacement';\n\nexport const devtoolsCallback =\n (options: Pick<PositioningOptions, 'flipBoundary' | 'overflowBoundary'>) => (middlewareState: MiddlewareState) => {\n const {\n elements: { floating, reference },\n } = middlewareState;\n const scrollParentsSet = new Set<HTMLElement>();\n if (isHTMLElement(reference)) {\n listScrollParents(reference).forEach(scrollParent => scrollParentsSet.add(scrollParent));\n }\n listScrollParents(floating).forEach(scrollParent => scrollParentsSet.add(scrollParent));\n const flipBoundaries: HTMLElement[] = Array.isArray(options.flipBoundary)\n ? options.flipBoundary\n : isHTMLElement(options.flipBoundary)\n ? [options.flipBoundary]\n : [];\n const overflowBoundaries: HTMLElement[] = Array.isArray(options.overflowBoundary)\n ? options.overflowBoundary\n : isHTMLElement(options.overflowBoundary)\n ? [options.overflowBoundary]\n : [];\n return {\n type: 'FluentUIMiddleware',\n middlewareState,\n options,\n initialPlacement: fromFloatingUIPlacement(middlewareState.initialPlacement),\n placement: fromFloatingUIPlacement(middlewareState.placement),\n flipBoundaries,\n overflowBoundaries,\n scrollParents: Array.from(scrollParentsSet),\n } as const;\n };\n"],"names":["devtoolsCallback","options","middlewareState","elements","floating","reference","scrollParentsSet","Set","isHTMLElement","listScrollParents","forEach","scrollParent","add","flipBoundaries","Array","isArray","flipBoundary","overflowBoundaries","overflowBoundary","type","initialPlacement","fromFloatingUIPlacement","placement","scrollParents","from"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAMaA;;;eAAAA;;;gCAJiB;mCACI;yCACM;AAEjC,MAAMA,mBACX,CAACC,UAA2E,CAACC;QAC3E,MAAM,EACJC,UAAU,EAAEC,QAAQ,EAAEC,SAAS,EAAE,EAClC,GAAGH;QACJ,MAAMI,mBAAmB,IAAIC;QAC7B,IAAIC,IAAAA,6BAAa,EAACH,YAAY;YAC5BI,IAAAA,oCAAiB,EAACJ,WAAWK,OAAO,CAACC,CAAAA,eAAgBL,iBAAiBM,GAAG,CAACD;QAC5E;QACAF,IAAAA,oCAAiB,EAACL,UAAUM,OAAO,CAACC,CAAAA,eAAgBL,iBAAiBM,GAAG,CAACD;QACzE,MAAME,iBAAgCC,MAAMC,OAAO,CAACd,QAAQe,YAAY,IACpEf,QAAQe,YAAY,GACpBR,IAAAA,6BAAa,EAACP,QAAQe,YAAY,IAClC;YAACf,QAAQe,YAAY;SAAC,GACtB,EAAE;QACN,MAAMC,qBAAoCH,MAAMC,OAAO,CAACd,QAAQiB,gBAAgB,IAC5EjB,QAAQiB,gBAAgB,GACxBV,IAAAA,6BAAa,EAACP,QAAQiB,gBAAgB,IACtC;YAACjB,QAAQiB,gBAAgB;SAAC,GAC1B,EAAE;QACN,OAAO;YACLC,MAAM;YACNjB;YACAD;YACAmB,kBAAkBC,IAAAA,gDAAuB,EAACnB,gBAAgBkB,gBAAgB;YAC1EE,WAAWD,IAAAA,gDAAuB,EAACnB,gBAAgBoB,SAAS;YAC5DT;YACAI;YACAM,eAAeT,MAAMU,IAAI,CAAClB;QAC5B;IACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-positioning",
3
- "version": "9.16.6",
3
+ "version": "9.17.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",
@@ -20,7 +20,7 @@
20
20
  "@floating-ui/devtools": "0.2.1",
21
21
  "@fluentui/react-shared-contexts": "^9.23.1",
22
22
  "@fluentui/react-theme": "^9.1.24",
23
- "@fluentui/react-utilities": "^9.18.23",
23
+ "@fluentui/react-utilities": "^9.19.0",
24
24
  "@griffel/react": "^1.5.22",
25
25
  "@swc/helpers": "^0.5.1"
26
26
  },