@@ -67,6 +67,8 @@ export type SimplePosition = "above" | "below" | "left" | "right";
67
67
*
68
68
* If this is set to `"equal"` or `"min"` and the horizontal anchor is not set
69
69
* to `"center"`, an error will be thrown.
70
+ *
71
+ * @defaultValue `"auto"`
70
72
*/
71
73
export type PositionWidth = "auto" | "equal" | "min" ;
72
74
@@ -88,54 +90,55 @@ export interface InitialCoords {
88
90
initialY ?: number ;
89
91
}
90
92
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 {
102
95
/**
103
96
* The configuration to anchor the fixed element to the container element.
97
+ *
98
+ * @defaultValue `BELOW_CENTER_ANCHOR`
104
99
*/
105
- anchor ?: Partial < PositionAnchor > ;
100
+ anchor ?: PositionAnchor ;
106
101
107
102
/**
108
103
* The viewwidth margin to apply so that the element doesn't need to be
109
104
* directly on the screen edge.
105
+ *
106
+ * @defaultValue `16`
110
107
*/
111
108
vwMargin ?: number ;
112
109
113
110
/**
114
111
* The viewwidth margin to apply so that the element doesn't need to be
115
112
* directly on the screen edge.
113
+ *
114
+ * @defaultValue `16`
116
115
*/
117
116
vhMargin ?: number ;
118
117
119
118
/**
120
119
* The container width margin to apply so that the element doesn't need to be
121
120
* directly on the container's edge.
121
+ *
122
+ * @defaultValue `0`
122
123
*/
123
124
xMargin ?: number ;
124
125
125
126
/**
126
127
* The container height margin to apply so that the element doesn't need to be
127
128
* directly on the container's edge
129
+ *
130
+ * @defaultValue `0`
128
131
*/
129
132
yMargin ?: number ;
130
133
131
- /**
132
- * @see PositionWidth
133
- */
134
+ /** {@inheritDoc PositionWidth } */
134
135
width ?: PositionWidth ;
135
136
136
137
/**
137
138
* Boolean if the style object should include the `transformOrigin` value
138
139
* based on the x and y positions.
140
+ *
141
+ * @defaultValue `false`
139
142
*/
140
143
transformOrigin ?: boolean ;
141
144
@@ -144,24 +147,42 @@ export interface FixedPositionOptions extends InitialCoords {
144
147
* container element. This is useful for autocomplete menus or other
145
148
* components that retain focus on the container element while the fixed
146
149
* element becomes visible.
150
+ *
151
+ * @defaultValue `false`
147
152
*/
148
153
preventOverlap ?: boolean ;
149
154
150
155
/**
151
156
* Boolean if the auto-swapping behavior should be disabled. It's normally
152
157
* recommended to not disable this since it'll allow elements to appear off
153
158
* screen.
159
+ *
160
+ * @defaultValue `false`
154
161
*/
155
162
disableSwapping ?: boolean ;
156
163
157
164
/**
158
165
* Boolean if the fixed positioning should no longer prevent the fixed element
159
166
* to be positioned within the viewport. This is nice if you want to allow for
160
167
* full page scrolling instead and manually set a max-height on your element.
168
+ *
169
+ * @defaultValue `false`
161
170
*/
162
171
disableVHBounds ?: boolean ;
163
172
}
164
173
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
+
165
186
/**
166
187
* This is more of a private interface that is used to help show how fixed
167
188
* elements are placed within the viewport. Most of the time the `top` and
@@ -182,6 +203,30 @@ export interface Coords {
182
203
minWidth ?: number ;
183
204
}
184
205
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
+
185
230
/**
186
231
* Since the position can be "swapped" to help fit the fixed element within the
187
232
* viewport, this interface is used to contain the calculated positions as well
@@ -201,17 +246,6 @@ export interface FixedPosition {
201
246
* applied.
202
247
*/
203
248
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 ;
217
251
}
0 commit comments