Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: remove floating-ui from bundle by vendoring resolvePositioningShorthand",
"packageName": "@fluentui/react-headless-components-preview",
"email": "vgenaev@gmail.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import type { PositioningProps as PositioningProps_2 } from '@fluentui/react-pos
import { PositioningShorthand } from '@fluentui/react-positioning';
import { PositioningShorthandValue } from '@fluentui/react-positioning';
import type * as React_2 from 'react';
import { resolvePositioningShorthand } from '@fluentui/react-positioning';

export { Alignment }

Expand Down Expand Up @@ -50,7 +49,8 @@ export const POSITIONS: {
readonly after: "after";
};

export { resolvePositioningShorthand }
// @public (undocumented)
export function resolvePositioningShorthand(shorthand: PositioningShorthand | undefined | null): Readonly<PositioningProps_2>;

// @public (undocumented)
export function usePositioning(options: PositioningProps): PositioningReturn;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { resolvePositioningShorthand } from '@fluentui/react-positioning';
export { resolvePositioningShorthand } from './utils';
export { usePositioning } from './usePositioning';
export { getPlacementString } from './utils';
export { POSITIONS, ALIGNMENTS } from './constants';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export { debounce } from './debounce';
export { applyOffset, resolveOffset } from './offset';
export { getCoverSelfAlignment, getPlacementString, shorthandToPositionArea } from './placement';
export { resolveElementRef } from './resolveElementRef';
export { resolvePositioningShorthand } from './resolvePositioningShorthand';
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { resolvePositioningShorthand } from '@fluentui/react-positioning';
import type { Alignment, Position, PositioningShorthandValue } from '@fluentui/react-positioning';
import type { LogicalAlignment } from '../types';
import { ALIGNMENTS, POSITIONS, POSITION_AREA_MAP } from '../constants';
import { resolvePositioningShorthand } from './resolvePositioningShorthand';

const ALIGN_ALIASES: Record<string, LogicalAlignment> = {
top: ALIGNMENTS.start,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import type { PositioningProps, PositioningShorthand, PositioningShorthandValue } from '@fluentui/react-positioning';

const shorthandLookup: Record<PositioningShorthandValue, Pick<PositioningProps, 'position' | 'align'>> = {
above: { position: 'above', align: 'center' },
'above-start': { position: 'above', align: 'start' },
'above-end': { position: 'above', align: 'end' },
below: { position: 'below', align: 'center' },
'below-start': { position: 'below', align: 'start' },
'below-end': { position: 'below', align: 'end' },
before: { position: 'before', align: 'center' },
'before-top': { position: 'before', align: 'top' },
'before-bottom': { position: 'before', align: 'bottom' },
after: { position: 'after', align: 'center' },
'after-top': { position: 'after', align: 'top' },
'after-bottom': { position: 'after', align: 'bottom' },
};

export function resolvePositioningShorthand(
shorthand: PositioningShorthand | undefined | null,
): Readonly<PositioningProps> {
if (shorthand === undefined || shorthand === null) {
return {};
}

if (typeof shorthand === 'string') {
return shorthandLookup[shorthand];
}

return shorthand as Readonly<PositioningProps>;
}
Loading