-
-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
251 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,102 @@ | ||
import * as C from "@/content/constants.js"; | ||
import { enums, union } from "./helpers.js"; | ||
import { enums, seeFloating, union } from "./helpers.js"; | ||
|
||
export const floatingPositioning = { | ||
side: { | ||
type: { | ||
type: C.ENUM, | ||
definition: enums("top", "right", "bottom", "left") | ||
}, | ||
description: | ||
"The preferred side of the anchor to render against when open. Will be reversed when collisions occur." | ||
description: seeFloating( | ||
"The preferred side of the anchor to render against when open. Will be reversed when collisions occur.", | ||
"https://floating-ui.com/docs/computePosition#placement" | ||
) | ||
}, | ||
sideOffset: { | ||
type: C.NUMBER, | ||
default: "0", | ||
description: "The amount of offset to apply to the menu's position on the x-axis." | ||
description: seeFloating( | ||
"The amount of offset to apply to the menu's position on the x-axis.", | ||
"https://floating-ui.com/docs/offset#options" | ||
) | ||
}, | ||
align: { | ||
type: { | ||
type: C.ENUM, | ||
definition: enums("start", "center", "end") | ||
}, | ||
description: "The preferred alignment of the anchor to render against when open." | ||
description: seeFloating( | ||
"The preferred alignment of the anchor to render against when open.", | ||
"https://floating-ui.com/docs/computePosition#placement" | ||
) | ||
}, | ||
alignOffset: { | ||
type: C.NUMBER, | ||
default: "0", | ||
description: "An offset in pixels from the 'start' or 'end' alignment options." | ||
description: seeFloating( | ||
"An offset in pixels from the 'start' or 'end' alignment options.", | ||
"https://floating-ui.com/docs/offset#options" | ||
) | ||
}, | ||
avoidCollisions: { | ||
type: C.BOOLEAN, | ||
default: C.TRUE, | ||
description: | ||
"When `true`, overrides the `side` and `align` options to prevent collisions with the boundary edges." | ||
description: seeFloating( | ||
"When `true`, overrides the `side` and `align` options to prevent collisions with the boundary edges.", | ||
"https://floating-ui.com/docs/flip" | ||
) | ||
}, | ||
collisionBoundary: { | ||
type: { | ||
type: C.UNION, | ||
definition: union("'clippingAncestors'", "Element", "Array<Element>", "Rect") | ||
}, | ||
description: "A boundary element or array of elements to check for collisions against." | ||
description: seeFloating( | ||
"A boundary element or array of elements to check for collisions against.", | ||
"https://floating-ui.com/docs/detectoverflow#boundary" | ||
) | ||
}, | ||
collisionPadding: { | ||
type: C.NUMBER, | ||
default: "0", | ||
description: | ||
"The amount in pixels of virtual padding around the viewport edges to check for overflow which will cause a collision." | ||
description: seeFloating( | ||
"The amount in pixels of virtual padding around the viewport edges to check for overflow which will cause a collision.", | ||
"https://floating-ui.com/docs/detectOverflow#padding" | ||
) | ||
}, | ||
fitViewport: { | ||
type: C.BOOLEAN, | ||
default: C.FALSE, | ||
description: "Whether the floating element should be constrained to the viewport." | ||
description: seeFloating( | ||
"Whether the floating element should be constrained to the viewport.", | ||
"https://floating-ui.com/docs/size" | ||
) | ||
}, | ||
sameWidth: { | ||
type: C.BOOLEAN, | ||
default: C.FALSE, | ||
description: "Whether the content should be the same width as the trigger." | ||
description: seeFloating( | ||
"Whether the content should be the same width as the trigger.", | ||
"https://floating-ui.com/docs/size" | ||
) | ||
}, | ||
strategy: { | ||
type: { | ||
type: C.ENUM, | ||
definition: enums("absolute", "fixed") | ||
}, | ||
default: "absolute", | ||
description: seeFloating( | ||
"The positioning strategy to use for the floating element.", | ||
"https://floating-ui.com/docs/computeposition#strategy" | ||
) | ||
}, | ||
overlap: { | ||
type: C.BOOLEAN, | ||
default: C.FALSE, | ||
description: seeFloating( | ||
"Whether the floating element can overlap the reference element.", | ||
"https://floating-ui.com/docs/shift#options" | ||
) | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,10 @@ | ||
import type { AsChild, Transition, TransitionProps } from "$lib/internal/index.js"; | ||
import type { Boundary } from "../floating/_types"; | ||
import type { FloatingProps } from "$lib/bits/floating/_types.js"; | ||
|
||
type ContextFloatingProps = Omit<FloatingProps, "sameWidth" | "side" | "sideOffset" | "align">; | ||
|
||
export type ContentProps< | ||
T extends Transition = Transition, | ||
In extends Transition = Transition, | ||
Out extends Transition = Transition | ||
> = Expand< | ||
{ | ||
/** | ||
* An offset in pixels from the "start" or "end" alignment options. | ||
*/ | ||
alignOffset?: number; | ||
|
||
/** | ||
* When `true`, overrides the `side` and `align` options to prevent collisions | ||
* with the boundary edges. | ||
* | ||
* @defaultValue `true` | ||
*/ | ||
avoidCollisions?: boolean; | ||
|
||
/** | ||
* The amount in pixels of virtual padding around the viewport edges to check | ||
* for overflow which will cause a collision. | ||
*/ | ||
collisionPadding?: number; | ||
|
||
/** | ||
* A boundary element or array of elements to check for collisions against. | ||
*/ | ||
collisionBoundary?: Boundary; | ||
|
||
/** | ||
* Whether the floating element should be constrained to the viewport. | ||
* | ||
* @defaultValue `false` | ||
*/ | ||
fitViewport?: boolean; | ||
} & TransitionProps<T, In, Out> & | ||
AsChild | ||
>; | ||
> = Expand<ContextFloatingProps & TransitionProps<T, In, Out> & AsChild>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.