@fluentui/react-positioning 9.21.0 → 9.22.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,21 @@
1
1
  # Change Log - @fluentui/react-positioning
2
2
 
3
- This log was last generated on Wed, 25 Feb 2026 13:28:19 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 03 Mar 2026 09:41:32 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.22.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.22.0)
8
+
9
+ Tue, 03 Mar 2026 09:41:32 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.21.0..@fluentui/react-positioning_v9.22.0)
11
+
12
+ ### Minor changes
13
+
14
+ - refactor: deprecate createSlideStyles ([PR #35763](https://github.com/microsoft/fluentui/pull/35763) by robertpenner@microsoft.com)
15
+
7
16
  ## [9.21.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.21.0)
8
17
 
9
- Wed, 25 Feb 2026 13:28:19 GMT
18
+ Wed, 25 Feb 2026 13:32:24 GMT
10
19
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.20.12..@fluentui/react-positioning_v9.21.0)
11
20
 
12
21
  ### Minor changes
package/dist/index.d.ts CHANGED
@@ -82,6 +82,9 @@ export declare type CreateArrowStylesOptions = {
82
82
  * Creates animation styles so that positioned elements slide in from the main axis
83
83
  * @param mainAxis - distance than the element sides for
84
84
  * @returns Griffel styles to spread to a slot
85
+ *
86
+ * @deprecated The popover-related components now use the Slide motion component,
87
+ * which they inject using the `surfaceMotion` slot.
85
88
  */
86
89
  export declare function createSlideStyles(mainAxis: number): GriffelStyle;
87
90
 
@@ -140,6 +143,15 @@ declare type OnPositioningEndEventDetail = {
140
143
 
141
144
  export declare type Position = 'above' | 'below' | 'before' | 'after';
142
145
 
146
+ /**
147
+ * CSS custom properties used to encode the slide direction for positioning-aware enter animations.
148
+ * Set at runtime by `usePositioningSlideDirection` and registered via the CSS
149
+ * `registerProperty()` API so browsers can interpolate them as `<length>` values.
150
+ */
151
+ export declare const POSITIONING_SLIDE_DIRECTION_VAR_X = "--fui-positioning-slide-direction-x";
152
+
153
+ export declare const POSITIONING_SLIDE_DIRECTION_VAR_Y = "--fui-positioning-slide-direction-y";
154
+
143
155
  export declare type PositioningBoundary = PositioningRect | HTMLElement | Array<HTMLElement> | 'clippingParents' | 'scrollParent' | 'window';
144
156
 
145
157
  export declare type PositioningConfigurationFn = (params: {
@@ -350,6 +362,24 @@ declare interface UsePositioningReturn {
350
362
  arrowRef: React_2.MutableRefObject<any>;
351
363
  }
352
364
 
365
+ /**
366
+ * A hook that manages CSS custom properties for slide direction based on positioning placement.
367
+ *
368
+ * It wraps the `onPositioningEnd` callback to set `--fui-positioning-slide-direction-x` and
369
+ * `--fui-positioning-slide-direction-y` CSS custom properties on the positioned element,
370
+ * and registers them via `CSS.registerProperty` to avoid properties propagation down to a DOM tree.
371
+ *
372
+ * @returns The wrapped `onPositioningEnd` handler to pass to the positioning config.
373
+ */
374
+ export declare function usePositioningSlideDirection(options: UsePositioningSlideDirectionOptions): NonNullable<PositioningProps['onPositioningEnd']>;
375
+
376
+ declare type UsePositioningSlideDirectionOptions = {
377
+ /** The target document for CSS.registerProperty. */
378
+ targetDocument: Document | undefined;
379
+ /** The user's original onPositioningEnd callback, if any. */
380
+ onPositioningEnd?: PositioningProps['onPositioningEnd'];
381
+ };
382
+
353
383
  export declare function useSafeZoneArea({ debug, disabled, onSafeZoneEnter, onSafeZoneMove, onSafeZoneLeave, onSafeZoneTimeout, timeout, }?: UseSafeZoneOptions): {
354
384
  containerRef: RefObjectFunction<HTMLElement>;
355
385
  targetRef: RefObjectFunction<HTMLElement>;
package/lib/constants.js CHANGED
@@ -3,3 +3,9 @@ export const DATA_POSITIONING_ESCAPED = 'data-popper-escaped';
3
3
  export const DATA_POSITIONING_HIDDEN = 'data-popper-reference-hidden';
4
4
  export const DATA_POSITIONING_PLACEMENT = 'data-popper-placement';
5
5
  export const POSITIONING_END_EVENT = 'fui-positioningend';
6
+ /**
7
+ * CSS custom properties used to encode the slide direction for positioning-aware enter animations.
8
+ * Set at runtime by `usePositioningSlideDirection` and registered via the CSS
9
+ * `registerProperty()` API so browsers can interpolate them as `<length>` values.
10
+ */ export const POSITIONING_SLIDE_DIRECTION_VAR_X = '--fui-positioning-slide-direction-x';
11
+ export const POSITIONING_SLIDE_DIRECTION_VAR_Y = '--fui-positioning-slide-direction-y';
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/constants.ts"],"sourcesContent":["export const DATA_POSITIONING_INTERSECTING = 'data-popper-is-intersecting';\nexport const DATA_POSITIONING_ESCAPED = 'data-popper-escaped';\nexport const DATA_POSITIONING_HIDDEN = 'data-popper-reference-hidden';\nexport const DATA_POSITIONING_PLACEMENT = 'data-popper-placement';\nexport const POSITIONING_END_EVENT = 'fui-positioningend';\n"],"names":["DATA_POSITIONING_INTERSECTING","DATA_POSITIONING_ESCAPED","DATA_POSITIONING_HIDDEN","DATA_POSITIONING_PLACEMENT","POSITIONING_END_EVENT"],"mappings":"AAAA,OAAO,MAAMA,gCAAgC,8BAA8B;AAC3E,OAAO,MAAMC,2BAA2B,sBAAsB;AAC9D,OAAO,MAAMC,0BAA0B,+BAA+B;AACtE,OAAO,MAAMC,6BAA6B,wBAAwB;AAClE,OAAO,MAAMC,wBAAwB,qBAAqB"}
1
+ {"version":3,"sources":["../src/constants.ts"],"sourcesContent":["export const DATA_POSITIONING_INTERSECTING = 'data-popper-is-intersecting';\nexport const DATA_POSITIONING_ESCAPED = 'data-popper-escaped';\nexport const DATA_POSITIONING_HIDDEN = 'data-popper-reference-hidden';\nexport const DATA_POSITIONING_PLACEMENT = 'data-popper-placement';\nexport const POSITIONING_END_EVENT = 'fui-positioningend';\n\n/**\n * CSS custom properties used to encode the slide direction for positioning-aware enter animations.\n * Set at runtime by `usePositioningSlideDirection` and registered via the CSS\n * `registerProperty()` API so browsers can interpolate them as `<length>` values.\n */\nexport const POSITIONING_SLIDE_DIRECTION_VAR_X = '--fui-positioning-slide-direction-x';\nexport const POSITIONING_SLIDE_DIRECTION_VAR_Y = '--fui-positioning-slide-direction-y';\n"],"names":["DATA_POSITIONING_INTERSECTING","DATA_POSITIONING_ESCAPED","DATA_POSITIONING_HIDDEN","DATA_POSITIONING_PLACEMENT","POSITIONING_END_EVENT","POSITIONING_SLIDE_DIRECTION_VAR_X","POSITIONING_SLIDE_DIRECTION_VAR_Y"],"mappings":"AAAA,OAAO,MAAMA,gCAAgC,8BAA8B;AAC3E,OAAO,MAAMC,2BAA2B,sBAAsB;AAC9D,OAAO,MAAMC,0BAA0B,+BAA+B;AACtE,OAAO,MAAMC,6BAA6B,wBAAwB;AAClE,OAAO,MAAMC,wBAAwB,qBAAqB;AAE1D;;;;CAIC,GACD,OAAO,MAAMC,oCAAoC,sCAAsC;AACvF,OAAO,MAAMC,oCAAoC,sCAAsC"}
@@ -4,6 +4,9 @@ import { DATA_POSITIONING_PLACEMENT } from './constants';
4
4
  * Creates animation styles so that positioned elements slide in from the main axis
5
5
  * @param mainAxis - distance than the element sides for
6
6
  * @returns Griffel styles to spread to a slot
7
+ *
8
+ * @deprecated The popover-related components now use the Slide motion component,
9
+ * which they inject using the `surfaceMotion` slot.
7
10
  */ export function createSlideStyles(mainAxis) {
8
11
  // With 'accumulate' animation composition, these opacity keyframes are added onto the default opacity of 1.
9
12
  const fadeIn = {
@@ -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 // 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"],"mappings":"AAAA,SAASA,MAA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;QACF;QAEA,uBAAuB;QACvB,qDAAqD;YACnD,CAAC,CAAC,EAAE,EAAEH,2BAA2B,CAAC,CAAC,CAAC,EAAE;gBACpCc,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 *\n * @deprecated The popover-related components now use the Slide motion component,\n * which they inject using the `surfaceMotion` 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"],"mappings":"AAAA,SAASA,MAAM,QAAQ,wBAAwB;AAE/C,SAASC,0BAA0B,QAAQ,cAAc;AAEzD;;;;;;;CAOC,GACD,OAAO,SAASC,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,mBAAmBX,OAAOY,cAAc;QACxCC,yBAAyBb,OAAOc,kBAAkB;QAClD,CAACN,kBAAkB,EAAE,CAAC,GAAG,CAAC;QAC1B,CAACC,kBAAkB,EAAE,GAAGN,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,GAAGL,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;gBACpCU,mBAAmB;gBACnBI,eAAeX;YACjB;QACF;QAEA,uBAAuB;QACvB,qDAAqD;YACnD,CAAC,CAAC,EAAE,EAAEH,2BAA2B,CAAC,CAAC,CAAC,EAAE;gBACpCc,eAAeX;YACjB;QACF;IACF;AACF"}
package/lib/index.js CHANGED
@@ -1,5 +1,8 @@
1
1
  export { createVirtualElementFromClick } from './createVirtualElementFromClick';
2
+ export { usePositioningSlideDirection } from './usePositioningSlideDirection';
3
+ export { POSITIONING_SLIDE_DIRECTION_VAR_X, POSITIONING_SLIDE_DIRECTION_VAR_Y } from './constants';
2
4
  export { createArrowHeightStyles, createArrowStyles } from './createArrowStyles';
5
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
3
6
  export { createSlideStyles } from './createSlideStyles';
4
7
  export { PositioningConfigurationProvider } from './PositioningConfigurationContext';
5
8
  export { usePositioning } from './usePositioning';
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';\n\nexport { PositioningConfigurationProvider } from './PositioningConfigurationContext';\n\nexport { usePositioning } from './usePositioning';\nexport { usePositioningMouseTarget } from './usePositioningMouseTarget';\nexport { useSafeZoneArea } from './hooks/useSafeZoneArea/useSafeZoneArea';\nexport type { UseSafeZoneOptions } from './hooks/useSafeZoneArea/useSafeZoneArea';\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","useSafeZoneArea","resolvePositioningShorthand","mergeArrowOffset"],"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,eAAe,QAAQ,0CAA0C;AAE1E,SAASC,2BAA2B,EAAEC,gBAAgB,QAAQ,gBAAgB"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { createVirtualElementFromClick } from './createVirtualElementFromClick';\nexport { usePositioningSlideDirection } from './usePositioningSlideDirection';\nexport { POSITIONING_SLIDE_DIRECTION_VAR_X, POSITIONING_SLIDE_DIRECTION_VAR_Y } from './constants';\nexport { createArrowHeightStyles, createArrowStyles } from './createArrowStyles';\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport { createSlideStyles } from './createSlideStyles';\nexport type { CreateArrowStylesOptions } from './createArrowStyles';\n\nexport { PositioningConfigurationProvider } from './PositioningConfigurationContext';\n\nexport { usePositioning } from './usePositioning';\nexport { usePositioningMouseTarget } from './usePositioningMouseTarget';\nexport { useSafeZoneArea } from './hooks/useSafeZoneArea/useSafeZoneArea';\nexport type { UseSafeZoneOptions } from './hooks/useSafeZoneArea/useSafeZoneArea';\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","usePositioningSlideDirection","POSITIONING_SLIDE_DIRECTION_VAR_X","POSITIONING_SLIDE_DIRECTION_VAR_Y","createArrowHeightStyles","createArrowStyles","createSlideStyles","PositioningConfigurationProvider","usePositioning","usePositioningMouseTarget","useSafeZoneArea","resolvePositioningShorthand","mergeArrowOffset"],"mappings":"AAAA,SAASA,6BAA6B,QAAQ,kCAAkC;AAChF,SAASC,4BAA4B,QAAQ,iCAAiC;AAC9E,SAASC,iCAAiC,EAAEC,iCAAiC,QAAQ,cAAc;AACnG,SAASC,uBAAuB,EAAEC,iBAAiB,QAAQ,sBAAsB;AACjF,4DAA4D;AAC5D,SAASC,iBAAiB,QAAQ,sBAAsB;AAGxD,SAASC,gCAAgC,QAAQ,oCAAoC;AAErF,SAASC,cAAc,QAAQ,mBAAmB;AAClD,SAASC,yBAAyB,QAAQ,8BAA8B;AACxE,SAASC,eAAe,QAAQ,0CAA0C;AAE1E,SAASC,2BAA2B,EAAEC,gBAAgB,QAAQ,gBAAgB"}
@@ -0,0 +1,78 @@
1
+ 'use client';
2
+ import * as React from 'react';
3
+ import { useEventCallback, isHTMLElement } from '@fluentui/react-utilities';
4
+ import { POSITIONING_SLIDE_DIRECTION_VAR_X, POSITIONING_SLIDE_DIRECTION_VAR_Y } from './constants';
5
+ /**
6
+ * Returns the slide direction unit vectors for a given Floating UI placement.
7
+ * Values are -1, 0, or 1, representing the direction the element slides in from.
8
+ */ export function getPlacementSlideDirections(placement) {
9
+ const side = placement.split('-')[0];
10
+ // Default to sliding down from the top side
11
+ let x = 0;
12
+ let y = 1;
13
+ if (side === 'right') {
14
+ x = -1;
15
+ y = 0;
16
+ } else if (side === 'bottom') {
17
+ x = 0;
18
+ y = -1;
19
+ } else if (side === 'left') {
20
+ x = 1;
21
+ y = 0;
22
+ }
23
+ return {
24
+ x,
25
+ y
26
+ };
27
+ }
28
+ /**
29
+ * A hook that manages CSS custom properties for slide direction based on positioning placement.
30
+ *
31
+ * It wraps the `onPositioningEnd` callback to set `--fui-positioning-slide-direction-x` and
32
+ * `--fui-positioning-slide-direction-y` CSS custom properties on the positioned element,
33
+ * and registers them via `CSS.registerProperty` to avoid properties propagation down to a DOM tree.
34
+ *
35
+ * @returns The wrapped `onPositioningEnd` handler to pass to the positioning config.
36
+ */ export function usePositioningSlideDirection(options) {
37
+ const { targetDocument, onPositioningEnd } = options;
38
+ const handlePositionEnd = useEventCallback((e)=>{
39
+ onPositioningEnd === null || onPositioningEnd === void 0 ? void 0 : onPositioningEnd(e);
40
+ const element = e.target;
41
+ const placement = e.detail.placement;
42
+ if (!isHTMLElement(element)) {
43
+ return;
44
+ }
45
+ const { x, y } = getPlacementSlideDirections(placement);
46
+ element.style.setProperty(POSITIONING_SLIDE_DIRECTION_VAR_X, `${x}px`);
47
+ element.style.setProperty(POSITIONING_SLIDE_DIRECTION_VAR_Y, `${y}px`);
48
+ });
49
+ // Register the CSS custom properties so they can be interpolated during animations.
50
+ // CSS.registerProperty is idempotent — the try/catch handles the case where
51
+ // properties are already registered.
52
+ React.useEffect(()=>{
53
+ var _targetDocument_defaultView_CSS, _targetDocument_defaultView;
54
+ var _targetDocument_defaultView_CSS_registerProperty;
55
+ const registerProperty = (_targetDocument_defaultView_CSS_registerProperty = targetDocument === null || targetDocument === void 0 ? void 0 : (_targetDocument_defaultView = targetDocument.defaultView) === null || _targetDocument_defaultView === void 0 ? void 0 : (_targetDocument_defaultView_CSS = _targetDocument_defaultView.CSS) === null || _targetDocument_defaultView_CSS === void 0 ? void 0 : _targetDocument_defaultView_CSS.registerProperty) !== null && _targetDocument_defaultView_CSS_registerProperty !== void 0 ? _targetDocument_defaultView_CSS_registerProperty : ()=>{
56
+ // No-op if registerProperty is not supported
57
+ };
58
+ try {
59
+ registerProperty({
60
+ name: POSITIONING_SLIDE_DIRECTION_VAR_X,
61
+ syntax: '<length>',
62
+ inherits: false,
63
+ initialValue: '0px'
64
+ });
65
+ registerProperty({
66
+ name: POSITIONING_SLIDE_DIRECTION_VAR_Y,
67
+ syntax: '<length>',
68
+ inherits: false,
69
+ initialValue: '0px'
70
+ });
71
+ } catch (e) {
72
+ // Ignore errors from registerProperty, which can occur if the properties are already registered
73
+ }
74
+ }, [
75
+ targetDocument
76
+ ]);
77
+ return handlePositionEnd;
78
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/usePositioningSlideDirection.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useEventCallback, isHTMLElement } from '@fluentui/react-utilities';\nimport type { PositioningProps } from './types';\nimport { POSITIONING_SLIDE_DIRECTION_VAR_X, POSITIONING_SLIDE_DIRECTION_VAR_Y } from './constants';\n\n/**\n * Returns the slide direction unit vectors for a given Floating UI placement.\n * Values are -1, 0, or 1, representing the direction the element slides in from.\n */\nexport function getPlacementSlideDirections(placement: string): { x: number; y: number } {\n const side = placement.split('-')[0];\n // Default to sliding down from the top side\n let x = 0;\n let y = 1;\n\n if (side === 'right') {\n x = -1;\n y = 0;\n } else if (side === 'bottom') {\n x = 0;\n y = -1;\n } else if (side === 'left') {\n x = 1;\n y = 0;\n }\n\n return { x, y };\n}\n\ntype UsePositioningSlideDirectionOptions = {\n /** The target document for CSS.registerProperty. */\n targetDocument: Document | undefined;\n /** The user's original onPositioningEnd callback, if any. */\n onPositioningEnd?: PositioningProps['onPositioningEnd'];\n};\n\n/**\n * A hook that manages CSS custom properties for slide direction based on positioning placement.\n *\n * It wraps the `onPositioningEnd` callback to set `--fui-positioning-slide-direction-x` and\n * `--fui-positioning-slide-direction-y` CSS custom properties on the positioned element,\n * and registers them via `CSS.registerProperty` to avoid properties propagation down to a DOM tree.\n *\n * @returns The wrapped `onPositioningEnd` handler to pass to the positioning config.\n */\nexport function usePositioningSlideDirection(\n options: UsePositioningSlideDirectionOptions,\n): NonNullable<PositioningProps['onPositioningEnd']> {\n const { targetDocument, onPositioningEnd } = options;\n\n const handlePositionEnd: NonNullable<PositioningProps['onPositioningEnd']> = useEventCallback(e => {\n onPositioningEnd?.(e);\n\n const element = e.target;\n const placement = e.detail.placement;\n\n if (!isHTMLElement(element)) {\n return;\n }\n\n const { x, y } = getPlacementSlideDirections(placement);\n\n element.style.setProperty(POSITIONING_SLIDE_DIRECTION_VAR_X, `${x}px`);\n element.style.setProperty(POSITIONING_SLIDE_DIRECTION_VAR_Y, `${y}px`);\n });\n\n // Register the CSS custom properties so they can be interpolated during animations.\n // CSS.registerProperty is idempotent — the try/catch handles the case where\n // properties are already registered.\n React.useEffect(() => {\n const registerProperty =\n targetDocument?.defaultView?.CSS?.registerProperty ??\n (() => {\n // No-op if registerProperty is not supported\n });\n\n try {\n registerProperty({\n name: POSITIONING_SLIDE_DIRECTION_VAR_X,\n syntax: '<length>',\n inherits: false,\n initialValue: '0px',\n });\n registerProperty({\n name: POSITIONING_SLIDE_DIRECTION_VAR_Y,\n syntax: '<length>',\n inherits: false,\n initialValue: '0px',\n });\n } catch (e) {\n // Ignore errors from registerProperty, which can occur if the properties are already registered\n }\n }, [targetDocument]);\n\n return handlePositionEnd;\n}\n"],"names":["React","useEventCallback","isHTMLElement","POSITIONING_SLIDE_DIRECTION_VAR_X","POSITIONING_SLIDE_DIRECTION_VAR_Y","getPlacementSlideDirections","placement","side","split","x","y","usePositioningSlideDirection","options","targetDocument","onPositioningEnd","handlePositionEnd","e","element","target","detail","style","setProperty","useEffect","registerProperty","defaultView","CSS","name","syntax","inherits","initialValue"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,gBAAgB,EAAEC,aAAa,QAAQ,4BAA4B;AAE5E,SAASC,iCAAiC,EAAEC,iCAAiC,QAAQ,cAAc;AAEnG;;;CAGC,GACD,OAAO,SAASC,4BAA4BC,SAAiB;IAC3D,MAAMC,OAAOD,UAAUE,KAAK,CAAC,IAAI,CAAC,EAAE;IACpC,4CAA4C;IAC5C,IAAIC,IAAI;IACR,IAAIC,IAAI;IAER,IAAIH,SAAS,SAAS;QACpBE,IAAI,CAAC;QACLC,IAAI;IACN,OAAO,IAAIH,SAAS,UAAU;QAC5BE,IAAI;QACJC,IAAI,CAAC;IACP,OAAO,IAAIH,SAAS,QAAQ;QAC1BE,IAAI;QACJC,IAAI;IACN;IAEA,OAAO;QAAED;QAAGC;IAAE;AAChB;AASA;;;;;;;;CAQC,GACD,OAAO,SAASC,6BACdC,OAA4C;IAE5C,MAAM,EAAEC,cAAc,EAAEC,gBAAgB,EAAE,GAAGF;IAE7C,MAAMG,oBAAuEd,iBAAiBe,CAAAA;QAC5FF,6BAAAA,uCAAAA,iBAAmBE;QAEnB,MAAMC,UAAUD,EAAEE,MAAM;QACxB,MAAMZ,YAAYU,EAAEG,MAAM,CAACb,SAAS;QAEpC,IAAI,CAACJ,cAAce,UAAU;YAC3B;QACF;QAEA,MAAM,EAAER,CAAC,EAAEC,CAAC,EAAE,GAAGL,4BAA4BC;QAE7CW,QAAQG,KAAK,CAACC,WAAW,CAAClB,mCAAmC,GAAGM,EAAE,EAAE,CAAC;QACrEQ,QAAQG,KAAK,CAACC,WAAW,CAACjB,mCAAmC,GAAGM,EAAE,EAAE,CAAC;IACvE;IAEA,oFAAoF;IACpF,4EAA4E;IAC5E,qCAAqC;IACrCV,MAAMsB,SAAS,CAAC;YAEZT,iCAAAA;YAAAA;QADF,MAAMU,mBACJV,CAAAA,mDAAAA,2BAAAA,sCAAAA,8BAAAA,eAAgBW,WAAW,cAA3BX,mDAAAA,kCAAAA,4BAA6BY,GAAG,cAAhCZ,sDAAAA,gCAAkCU,gBAAgB,cAAlDV,8DAAAA,mDACC;QACC,6CAA6C;QAC/C;QAEF,IAAI;YACFU,iBAAiB;gBACfG,MAAMvB;gBACNwB,QAAQ;gBACRC,UAAU;gBACVC,cAAc;YAChB;YACAN,iBAAiB;gBACfG,MAAMtB;gBACNuB,QAAQ;gBACRC,UAAU;gBACVC,cAAc;YAChB;QACF,EAAE,OAAOb,GAAG;QACV,gGAAgG;QAClG;IACF,GAAG;QAACH;KAAe;IAEnB,OAAOE;AACT"}
@@ -23,6 +23,12 @@ _export(exports, {
23
23
  },
24
24
  POSITIONING_END_EVENT: function() {
25
25
  return POSITIONING_END_EVENT;
26
+ },
27
+ POSITIONING_SLIDE_DIRECTION_VAR_X: function() {
28
+ return POSITIONING_SLIDE_DIRECTION_VAR_X;
29
+ },
30
+ POSITIONING_SLIDE_DIRECTION_VAR_Y: function() {
31
+ return POSITIONING_SLIDE_DIRECTION_VAR_Y;
26
32
  }
27
33
  });
28
34
  const DATA_POSITIONING_INTERSECTING = 'data-popper-is-intersecting';
@@ -30,3 +36,5 @@ const DATA_POSITIONING_ESCAPED = 'data-popper-escaped';
30
36
  const DATA_POSITIONING_HIDDEN = 'data-popper-reference-hidden';
31
37
  const DATA_POSITIONING_PLACEMENT = 'data-popper-placement';
32
38
  const POSITIONING_END_EVENT = 'fui-positioningend';
39
+ const POSITIONING_SLIDE_DIRECTION_VAR_X = '--fui-positioning-slide-direction-x';
40
+ const POSITIONING_SLIDE_DIRECTION_VAR_Y = '--fui-positioning-slide-direction-y';
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/constants.ts"],"sourcesContent":["export const DATA_POSITIONING_INTERSECTING = 'data-popper-is-intersecting';\nexport const DATA_POSITIONING_ESCAPED = 'data-popper-escaped';\nexport const DATA_POSITIONING_HIDDEN = 'data-popper-reference-hidden';\nexport const DATA_POSITIONING_PLACEMENT = 'data-popper-placement';\nexport const POSITIONING_END_EVENT = 'fui-positioningend';\n"],"names":["DATA_POSITIONING_INTERSECTING","DATA_POSITIONING_ESCAPED","DATA_POSITIONING_HIDDEN","DATA_POSITIONING_PLACEMENT","POSITIONING_END_EVENT"],"mappings":";;;;;;;;;;;4BACaC;;;2BACAC;;;iCAFAF;;;8BAGAG;;;yBACAC;;;;AAJN,MAAMJ,gCAAgC,8BAA8B;AACpE,MAAMC,2BAA2B,sBAAsB;AACvD,MAAMC,0BAA0B,+BAA+B;AAC/D,MAAMC,6BAA6B,wBAAwB;AAC3D,MAAMC,wBAAwB,qBAAqB"}
1
+ {"version":3,"sources":["../src/constants.ts"],"sourcesContent":["export const DATA_POSITIONING_INTERSECTING = 'data-popper-is-intersecting';\nexport const DATA_POSITIONING_ESCAPED = 'data-popper-escaped';\nexport const DATA_POSITIONING_HIDDEN = 'data-popper-reference-hidden';\nexport const DATA_POSITIONING_PLACEMENT = 'data-popper-placement';\nexport const POSITIONING_END_EVENT = 'fui-positioningend';\n\n/**\n * CSS custom properties used to encode the slide direction for positioning-aware enter animations.\n * Set at runtime by `usePositioningSlideDirection` and registered via the CSS\n * `registerProperty()` API so browsers can interpolate them as `<length>` values.\n */\nexport const POSITIONING_SLIDE_DIRECTION_VAR_X = '--fui-positioning-slide-direction-x';\nexport const POSITIONING_SLIDE_DIRECTION_VAR_Y = '--fui-positioning-slide-direction-y';\n"],"names":["DATA_POSITIONING_INTERSECTING","DATA_POSITIONING_ESCAPED","DATA_POSITIONING_HIDDEN","DATA_POSITIONING_PLACEMENT","POSITIONING_END_EVENT","POSITIONING_SLIDE_DIRECTION_VAR_X","POSITIONING_SLIDE_DIRECTION_VAR_Y"],"mappings":";;;;;;;;;;;IACaC,wBAAAA;;;2BACAC;;;iCAFAF;;;8BAGAG;;;yBACAC;;;qCAOAC;;;qCACAC;;;;AAZN,MAAMN,gCAAgC,8BAA8B;AACpE,iCAAiC,sBAAsB;AACvD,MAAME,0BAA0B,+BAA+B;AAC/D,MAAMC,6BAA6B,wBAAwB;AAC3D,MAAMC,wBAAwB,qBAAqB;AAOnD,MAAMC,oCAAoC,sCAAsC;AAChF,MAAMC,oCAAoC,sCAAsC"}
@@ -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 // 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"],"mappings":";;;;+BASgBE;;;;;;4BATO,wBAAwB;2BAEJ,cAAc;AAOlD,2BAA2BC,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,mBAAmBX,kBAAAA,CAAOY,cAAc;QACxCC,yBAAyBb,kBAAAA,CAAOc,kBAAkB;QAClD,CAACN,kBAAkB,EAAE,CAAC,GAAG,CAAC;QAC1B,CAACC,kBAAkB,EAAE,GAAGN,SAAS,EAAE,CAAC;QACpC,CAAC,CAAC,EAAE,EAAEF,qCAAAA,CAA2B,QAAQ,CAAC,CAAC,EAAE;YAC3C,CAACO,kBAAkB,EAAE,CAAC,CAAC,EAAEL,SAAS,EAAE,CAAC;YACrC,CAACM,kBAAkB,EAAE;QACvB;QAEA,CAAC,CAAC,EAAE,EAAER,qCAAAA,CAA2B,SAAS,CAAC,CAAC,EAAE;YAC5C,CAACO,kBAAkB,EAAE;YACrB,CAACC,kBAAkB,EAAE,CAAC,CAAC,EAAEN,SAAS,EAAE,CAAC;QACvC;QAEA,CAAC,CAAC,EAAE,EAAEF,qCAAAA,CAA2B,OAAO,CAAC,CAAC,EAAE;YAC1C,CAACO,kBAAkB,EAAE,GAAGL,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,qCAAAA,CAA2B,CAAC,CAAC,CAAC,EAAE;gBACpCU,mBAAmB;gBACnBI,eAAeX;YACjB;QACF;QAEA,uBAAuB;QACvB,qDAAqD;YACnD,CAAC,CAAC,EAAE,EAAEH,qCAAAA,CAA2B,CAAC,CAAC,CAAC,EAAE;gBACpCc,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 *\n * @deprecated The popover-related components now use the Slide motion component,\n * which they inject using the `surfaceMotion` 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"],"mappings":";;;;+BAYgBE;;;;;;4BAZO,wBAAwB;2BAEJ,cAAc;AAUlD,2BAA2BC,QAAgB;IAChD,4GAA4G;IAC5G,MAAMC,SAAS;QACbC,MAAM;YACJC,SAAS,CAAC;QACZ;QACAC,IAAI;YACFD,SAAS;QACX;IACF;IAEA,MAAME,oBAAoB;IAC1B,MAAMC,oBAAoB;I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
12
+ POSITIONING_SLIDE_DIRECTION_VAR_X: function() {
13
+ return _constants.POSITIONING_SLIDE_DIRECTION_VAR_X;
14
+ },
15
+ POSITIONING_SLIDE_DIRECTION_VAR_Y: function() {
16
+ return _constants.POSITIONING_SLIDE_DIRECTION_VAR_Y;
17
+ },
12
18
  PositioningConfigurationProvider: function() {
13
19
  return _PositioningConfigurationContext.PositioningConfigurationProvider;
14
20
  },
@@ -36,11 +42,16 @@ _export(exports, {
36
42
  usePositioningMouseTarget: function() {
37
43
  return _usePositioningMouseTarget.usePositioningMouseTarget;
38
44
  },
45
+ usePositioningSlideDirection: function() {
46
+ return _usePositioningSlideDirection.usePositioningSlideDirection;
47
+ },
39
48
  useSafeZoneArea: function() {
40
49
  return _useSafeZoneArea.useSafeZoneArea;
41
50
  }
42
51
  });
43
52
  const _createVirtualElementFromClick = require("./createVirtualElementFromClick");
53
+ const _usePositioningSlideDirection = require("./usePositioningSlideDirection");
54
+ const _constants = require("./constants");
44
55
  const _createArrowStyles = require("./createArrowStyles");
45
56
  const _createSlideStyles = require("./createSlideStyles");
46
57
  const _PositioningConfigurationContext = require("./PositioningConfigurationContext");
@@ -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';\n\nexport { PositioningConfigurationProvider } from './PositioningConfigurationContext';\n\nexport { usePositioning } from './usePositioning';\nexport { usePositioningMouseTarget } from './usePositioningMouseTarget';\nexport { useSafeZoneArea } from './hooks/useSafeZoneArea/useSafeZoneArea';\nexport type { UseSafeZoneOptions } from './hooks/useSafeZoneArea/useSafeZoneArea';\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","useSafeZoneArea","resolvePositioningShorthand","mergeArrowOffset"],"mappings":";;;;;;;;;;;;eAKSI,iEAAgC;;;eAJhCH,0CAAuB;;;eAAEC,oCAAiB;;;eAC1CC,oCAAiB;;;eAFjBH,4DAA6B;;IAWAS;sCAAgB;;;eAA7CD,kCAA2B;;;eAJ3BH,8BAAc;;;eACdC,oDAAyB;;;eACzBC,gCAAe;;;+CATsB,kCAAkC;mCACrB,sBAAsB;mCAC/C,sBAAsB;iDAGP,oCAAoC;gCAEtD,mBAAmB;2CACR,8BAA8B;iCACxC,0CAA0C;uBAEZ,gBAAgB"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { createVirtualElementFromClick } from './createVirtualElementFromClick';\nexport { usePositioningSlideDirection } from './usePositioningSlideDirection';\nexport { POSITIONING_SLIDE_DIRECTION_VAR_X, POSITIONING_SLIDE_DIRECTION_VAR_Y } from './constants';\nexport { createArrowHeightStyles, createArrowStyles } from './createArrowStyles';\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport { createSlideStyles } from './createSlideStyles';\nexport type { CreateArrowStylesOptions } from './createArrowStyles';\n\nexport { PositioningConfigurationProvider } from './PositioningConfigurationContext';\n\nexport { usePositioning } from './usePositioning';\nexport { usePositioningMouseTarget } from './usePositioningMouseTarget';\nexport { useSafeZoneArea } from './hooks/useSafeZoneArea/useSafeZoneArea';\nexport type { UseSafeZoneOptions } from './hooks/useSafeZoneArea/useSafeZoneArea';\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","usePositioningSlideDirection","POSITIONING_SLIDE_DIRECTION_VAR_X","POSITIONING_SLIDE_DIRECTION_VAR_Y","createArrowHeightStyles","createArrowStyles","createSlideStyles","PositioningConfigurationProvider","usePositioning","usePositioningMouseTarget","useSafeZoneArea","resolvePositioningShorthand","mergeArrowOffset"],"mappings":";;;;;;;;;;;IAESE,iCAAiC;;;;eAAEC,4CAAiC;;;eAMpEI,iEAAgC;;IALhCH;yDAAuB;;;eAAEC,oCAAiB;;;eAE1CC,oCAAiB;;iCALY;eAA7BN;;;eAc6BY,uBAAgB;;+BAAlB;eAA3BD;;;eAJAH,8BAAc;;IACdC;mEAAyB;;;eAVzBR,0DAA4B;;;eAW5BS,gCAAe;;;+CAZsB,kCAAkC;8CACnC,iCAAiC;2BACO,cAAc;mCACxC,sBAAsB;mCAE/C,sBAAsB;iDAGP,oCAAoC;gCAEtD,mBAAmB;2CACR,8BAA8B;iCACxC,0CAA0C;uBAEZ,gBAAgB"}
@@ -0,0 +1,86 @@
1
+ 'use client';
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ function _export(target, all) {
7
+ for(var name in all)Object.defineProperty(target, name, {
8
+ enumerable: true,
9
+ get: all[name]
10
+ });
11
+ }
12
+ _export(exports, {
13
+ getPlacementSlideDirections: function() {
14
+ return getPlacementSlideDirections;
15
+ },
16
+ usePositioningSlideDirection: function() {
17
+ return usePositioningSlideDirection;
18
+ }
19
+ });
20
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
21
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
22
+ const _reactutilities = require("@fluentui/react-utilities");
23
+ const _constants = require("./constants");
24
+ function getPlacementSlideDirections(placement) {
25
+ const side = placement.split('-')[0];
26
+ // Default to sliding down from the top side
27
+ let x = 0;
28
+ let y = 1;
29
+ if (side === 'right') {
30
+ x = -1;
31
+ y = 0;
32
+ } else if (side === 'bottom') {
33
+ x = 0;
34
+ y = -1;
35
+ } else if (side === 'left') {
36
+ x = 1;
37
+ y = 0;
38
+ }
39
+ return {
40
+ x,
41
+ y
42
+ };
43
+ }
44
+ function usePositioningSlideDirection(options) {
45
+ const { targetDocument, onPositioningEnd } = options;
46
+ const handlePositionEnd = (0, _reactutilities.useEventCallback)((e)=>{
47
+ onPositioningEnd === null || onPositioningEnd === void 0 ? void 0 : onPositioningEnd(e);
48
+ const element = e.target;
49
+ const placement = e.detail.placement;
50
+ if (!(0, _reactutilities.isHTMLElement)(element)) {
51
+ return;
52
+ }
53
+ const { x, y } = getPlacementSlideDirections(placement);
54
+ element.style.setProperty(_constants.POSITIONING_SLIDE_DIRECTION_VAR_X, `${x}px`);
55
+ element.style.setProperty(_constants.POSITIONING_SLIDE_DIRECTION_VAR_Y, `${y}px`);
56
+ });
57
+ // Register the CSS custom properties so they can be interpolated during animations.
58
+ // CSS.registerProperty is idempotent — the try/catch handles the case where
59
+ // properties are already registered.
60
+ _react.useEffect(()=>{
61
+ var _targetDocument_defaultView_CSS, _targetDocument_defaultView;
62
+ var _targetDocument_defaultView_CSS_registerProperty;
63
+ const registerProperty = (_targetDocument_defaultView_CSS_registerProperty = targetDocument === null || targetDocument === void 0 ? void 0 : (_targetDocument_defaultView = targetDocument.defaultView) === null || _targetDocument_defaultView === void 0 ? void 0 : (_targetDocument_defaultView_CSS = _targetDocument_defaultView.CSS) === null || _targetDocument_defaultView_CSS === void 0 ? void 0 : _targetDocument_defaultView_CSS.registerProperty) !== null && _targetDocument_defaultView_CSS_registerProperty !== void 0 ? _targetDocument_defaultView_CSS_registerProperty : ()=>{
64
+ // No-op if registerProperty is not supported
65
+ };
66
+ try {
67
+ registerProperty({
68
+ name: _constants.POSITIONING_SLIDE_DIRECTION_VAR_X,
69
+ syntax: '<length>',
70
+ inherits: false,
71
+ initialValue: '0px'
72
+ });
73
+ registerProperty({
74
+ name: _constants.POSITIONING_SLIDE_DIRECTION_VAR_Y,
75
+ syntax: '<length>',
76
+ inherits: false,
77
+ initialValue: '0px'
78
+ });
79
+ } catch (e) {
80
+ // Ignore errors from registerProperty, which can occur if the properties are already registered
81
+ }
82
+ }, [
83
+ targetDocument
84
+ ]);
85
+ return handlePositionEnd;
86
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/usePositioningSlideDirection.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useEventCallback, isHTMLElement } from '@fluentui/react-utilities';\nimport type { PositioningProps } from './types';\nimport { POSITIONING_SLIDE_DIRECTION_VAR_X, POSITIONING_SLIDE_DIRECTION_VAR_Y } from './constants';\n\n/**\n * Returns the slide direction unit vectors for a given Floating UI placement.\n * Values are -1, 0, or 1, representing the direction the element slides in from.\n */\nexport function getPlacementSlideDirections(placement: string): { x: number; y: number } {\n const side = placement.split('-')[0];\n // Default to sliding down from the top side\n let x = 0;\n let y = 1;\n\n if (side === 'right') {\n x = -1;\n y = 0;\n } else if (side === 'bottom') {\n x = 0;\n y = -1;\n } else if (side === 'left') {\n x = 1;\n y = 0;\n }\n\n return { x, y };\n}\n\ntype UsePositioningSlideDirectionOptions = {\n /** The target document for CSS.registerProperty. */\n targetDocument: Document | undefined;\n /** The user's original onPositioningEnd callback, if any. */\n onPositioningEnd?: PositioningProps['onPositioningEnd'];\n};\n\n/**\n * A hook that manages CSS custom properties for slide direction based on positioning placement.\n *\n * It wraps the `onPositioningEnd` callback to set `--fui-positioning-slide-direction-x` and\n * `--fui-positioning-slide-direction-y` CSS custom properties on the positioned element,\n * and registers them via `CSS.registerProperty` to avoid properties propagation down to a DOM tree.\n *\n * @returns The wrapped `onPositioningEnd` handler to pass to the positioning config.\n */\nexport function usePositioningSlideDirection(\n options: UsePositioningSlideDirectionOptions,\n): NonNullable<PositioningProps['onPositioningEnd']> {\n const { targetDocument, onPositioningEnd } = options;\n\n const handlePositionEnd: NonNullable<PositioningProps['onPositioningEnd']> = useEventCallback(e => {\n onPositioningEnd?.(e);\n\n const element = e.target;\n const placement = e.detail.placement;\n\n if (!isHTMLElement(element)) {\n return;\n }\n\n const { x, y } = getPlacementSlideDirections(placement);\n\n element.style.setProperty(POSITIONING_SLIDE_DIRECTION_VAR_X, `${x}px`);\n element.style.setProperty(POSITIONING_SLIDE_DIRECTION_VAR_Y, `${y}px`);\n });\n\n // Register the CSS custom properties so they can be interpolated during animations.\n // CSS.registerProperty is idempotent — the try/catch handles the case where\n // properties are already registered.\n React.useEffect(() => {\n const registerProperty =\n targetDocument?.defaultView?.CSS?.registerProperty ??\n (() => {\n // No-op if registerProperty is not supported\n });\n\n try {\n registerProperty({\n name: POSITIONING_SLIDE_DIRECTION_VAR_X,\n syntax: '<length>',\n inherits: false,\n initialValue: '0px',\n });\n registerProperty({\n name: POSITIONING_SLIDE_DIRECTION_VAR_Y,\n syntax: '<length>',\n inherits: false,\n initialValue: '0px',\n });\n } catch (e) {\n // Ignore errors from registerProperty, which can occur if the properties are already registered\n }\n }, [targetDocument]);\n\n return handlePositionEnd;\n}\n"],"names":["React","useEventCallback","isHTMLElement","POSITIONING_SLIDE_DIRECTION_VAR_X","POSITIONING_SLIDE_DIRECTION_VAR_Y","getPlacementSlideDirections","placement","side","split","x","y","usePositioningSlideDirection","options","targetDocument","onPositioningEnd","handlePositionEnd","e","element","target","detail","style","setProperty","useEffect","registerProperty","defaultView","CSS","name","syntax","inherits","initialValue"],"mappings":"AAAA;;;;;;;;;;;;IAWgBK,2BAAAA;;;IAoCAM,4BAAAA;;;;;iEA7CO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BAA6BY,GAAAA,AAAG,MAAA,QAAhCZ,oCAAAA,KAAAA,IAAAA,KAAAA,IAAAA,gCAAkCU,gBAAAA,AAAgB,MAAA,QAAlDV,qDAAAA,KAAAA,IAAAA,mDACC;QACC,6CAA6C;QAC/C;QAEF,IAAI;YACFU,iBAAiB;gBACfG,MAAMvB,4CAAAA;gBACNwB,QAAQ;gBACRC,UAAU;gBACVC,cAAc;YAChB;YACAN,iBAAiB;gBACfG,MAAMtB,4CAAAA;gBACNuB,QAAQ;gBACRC,UAAU;gBACVC,cAAc;YAChB;QACF,EAAE,OAAOb,GAAG;QACV,gGAAgG;QAClG;IACF,GAAG;QAACH;KAAe;IAEnB,OAAOE;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-positioning",
3
- "version": "9.21.0",
3
+ "version": "9.22.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",