@@ -67,6 +67,8 @@ export type SimplePosition = "above" | "below" | "left" | "right";
6767 *
6868 * If this is set to `"equal"` or `"min"` and the horizontal anchor is not set
6969 * to `"center"`, an error will be thrown.
70+ *
71+ * @defaultValue `"auto"`
7072 */
7173export type PositionWidth = "auto" | "equal" | "min" ;
7274
@@ -88,54 +90,55 @@ export interface InitialCoords {
8890 initialY ?: number ;
8991}
9092
91- export interface FixedPositionOptions extends InitialCoords {
92- /**
93- * The container element that the `element` should be fixed to.
94- */
95- container : HTMLElement | null ;
96-
97- /**
98- * The element that is fixed to a `container` element.
99- */
100- element : HTMLElement | null ;
101-
93+ /** @remarks \@since 4.0.0 */
94+ export interface CalculateFixedPositionOptions extends InitialCoords {
10295 /**
10396 * The configuration to anchor the fixed element to the container element.
97+ *
98+ * @defaultValue `BELOW_CENTER_ANCHOR`
10499 */
105- anchor ?: Partial < PositionAnchor > ;
100+ anchor ?: PositionAnchor ;
106101
107102 /**
108103 * The viewwidth margin to apply so that the element doesn't need to be
109104 * directly on the screen edge.
105+ *
106+ * @defaultValue `16`
110107 */
111108 vwMargin ?: number ;
112109
113110 /**
114111 * The viewwidth margin to apply so that the element doesn't need to be
115112 * directly on the screen edge.
113+ *
114+ * @defaultValue `16`
116115 */
117116 vhMargin ?: number ;
118117
119118 /**
120119 * The container width margin to apply so that the element doesn't need to be
121120 * directly on the container's edge.
121+ *
122+ * @defaultValue `0`
122123 */
123124 xMargin ?: number ;
124125
125126 /**
126127 * The container height margin to apply so that the element doesn't need to be
127128 * directly on the container's edge
129+ *
130+ * @defaultValue `0`
128131 */
129132 yMargin ?: number ;
130133
131- /**
132- * @see PositionWidth
133- */
134+ /** {@inheritDoc PositionWidth } */
134135 width ?: PositionWidth ;
135136
136137 /**
137138 * Boolean if the style object should include the `transformOrigin` value
138139 * based on the x and y positions.
140+ *
141+ * @defaultValue `false`
139142 */
140143 transformOrigin ?: boolean ;
141144
@@ -144,24 +147,42 @@ export interface FixedPositionOptions extends InitialCoords {
144147 * container element. This is useful for autocomplete menus or other
145148 * components that retain focus on the container element while the fixed
146149 * element becomes visible.
150+ *
151+ * @defaultValue `false`
147152 */
148153 preventOverlap ?: boolean ;
149154
150155 /**
151156 * Boolean if the auto-swapping behavior should be disabled. It's normally
152157 * recommended to not disable this since it'll allow elements to appear off
153158 * screen.
159+ *
160+ * @defaultValue `false`
154161 */
155162 disableSwapping ?: boolean ;
156163
157164 /**
158165 * Boolean if the fixed positioning should no longer prevent the fixed element
159166 * to be positioned within the viewport. This is nice if you want to allow for
160167 * full page scrolling instead and manually set a max-height on your element.
168+ *
169+ * @defaultValue `false`
161170 */
162171 disableVHBounds ?: boolean ;
163172}
164173
174+ export interface FixedPositionOptions extends CalculateFixedPositionOptions {
175+ /**
176+ * The container element that the `element` should be fixed to.
177+ */
178+ container : HTMLElement | null ;
179+
180+ /**
181+ * The element that is fixed to a `container` element.
182+ */
183+ element : HTMLElement | null ;
184+ }
185+
165186/**
166187 * This is more of a private interface that is used to help show how fixed
167188 * elements are placed within the viewport. Most of the time the `top` and
@@ -182,6 +203,30 @@ export interface Coords {
182203 minWidth ?: number ;
183204}
184205
206+ /**
207+ * The style object that should be applied to the fixed element so it will be
208+ * fixed to the container element. This will be `undefined` if the container
209+ * element doesn't exist within the DOM.
210+ *
211+ * Note: The fixed element styles **will not** contain styles for `z-index` or
212+ * `background-color` so you'll need to add that manually.
213+ *
214+ * @remarks \@since 4.0.0
215+ */
216+ export interface FixedPositionStyle extends Coords {
217+ /**
218+ * This will be `"fixed"` unless
219+ * {@link CalculateFixedPositionOptions.disableVHBounds} is set to `true`.
220+ */
221+ position : "fixed" | "absolute" ;
222+
223+ /**
224+ * This will be `undefined` unless
225+ * {@link CalculateFixedPositionOptions.transformOrigin} is set to `true`
226+ */
227+ transformOrigin ?: string ;
228+ }
229+
185230/**
186231 * Since the position can be "swapped" to help fit the fixed element within the
187232 * viewport, this interface is used to contain the calculated positions as well
@@ -201,17 +246,6 @@ export interface FixedPosition {
201246 * applied.
202247 */
203248 actualY : VerticalPosition ;
204-
205- /**
206- * The style object that should be applied to the fixed element so it will be
207- * fixed to the container element. This will be `undefined` if the container
208- * element doesn't exist within the DOM.
209- *
210- * Note: The fixed element styles **will not** contain styles for `z-index` or
211- * `background-color` so you'll need to add that manually.
212- */
213- style ?: Coords & {
214- position : "fixed" | "absolute" ;
215- transformOrigin ?: string ;
216- } ;
249+ /** {@inheritDoc FixedPositionStyle } */
250+ style ?: FixedPositionStyle ;
217251}
0 commit comments