@spectrum-web-components/overlay 1.0.0 → 1.0.1-color-testing

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/overlay",
3
- "version": "1.0.0",
3
+ "version": "1.0.1-color-testing",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -160,11 +160,11 @@
160
160
  "dependencies": {
161
161
  "@floating-ui/dom": "^1.6.1",
162
162
  "@floating-ui/utils": "^0.2.1",
163
- "@spectrum-web-components/action-button": "^1.0.0",
164
- "@spectrum-web-components/base": "^1.0.0",
165
- "@spectrum-web-components/reactive-controllers": "^1.0.0",
166
- "@spectrum-web-components/shared": "^1.0.0",
167
- "@spectrum-web-components/theme": "^1.0.0"
163
+ "@spectrum-web-components/action-button": "^1.0.1-color-testing",
164
+ "@spectrum-web-components/base": "^1.0.1-color-testing",
165
+ "@spectrum-web-components/reactive-controllers": "^1.0.1-color-testing",
166
+ "@spectrum-web-components/shared": "^1.0.1-color-testing",
167
+ "@spectrum-web-components/theme": "^1.0.1-color-testing"
168
168
  },
169
169
  "types": "./src/index.d.ts",
170
170
  "customElements": "custom-elements.json",
@@ -176,5 +176,5 @@
176
176
  "./stories/overlay-story-components.js",
177
177
  "./**/*.dev.js"
178
178
  ],
179
- "gitHead": "5cf5d34645bf9494ebd20f64c42d1619523d2d84"
179
+ "gitHead": "17e14b4a9fa2c8b15df158ea7d77ce09bf50de82"
180
180
  }
package/src/Overlay.d.ts CHANGED
@@ -8,7 +8,7 @@ import type { ClickController } from './ClickController.js';
8
8
  import type { HoverController } from './HoverController.js';
9
9
  import type { LongpressController } from './LongpressController.js';
10
10
  export { LONGPRESS_INSTRUCTIONS } from './LongpressController.js';
11
- declare let OverlayFeatures: typeof AbstractOverlay & import("./overlay-types.js").Constructor<import("@spectrum-web-components/base").SpectrumElement>;
11
+ declare let ComputedOverlayBase: typeof AbstractOverlay & import("./overlay-types.js").Constructor<import("@spectrum-web-components/base").SpectrumElement>;
12
12
  /**
13
13
  * @element sp-overlay
14
14
  *
@@ -16,57 +16,116 @@ declare let OverlayFeatures: typeof AbstractOverlay & import("./overlay-types.js
16
16
  * @fires sp-closed - announce that an overlay has compelted any exit animations
17
17
  * @fires slottable-request - requests to add or remove slottable content
18
18
  */
19
- export declare class Overlay extends OverlayFeatures {
19
+ export declare class Overlay extends ComputedOverlayBase {
20
20
  static styles: import("@spectrum-web-components/base").CSSResult[];
21
21
  /**
22
22
  * An Overlay that is `delayed` will wait until a warm-up period of 1000ms
23
- * has completed before opening. Once the warmup period has completed, all
23
+ * has completed before opening. Once the warm-up period has completed, all
24
24
  * subsequent Overlays will open immediately. When no Overlays are opened,
25
- * a cooldown period of 1000ms will begin. Once the cooldown has completed,
25
+ * a cool-down period of 1000ms will begin. Once the cool-down has completed,
26
26
  * the next Overlay to be opened will be subject to the warm-up period if
27
27
  * provided that option.
28
+ *
29
+ * This behavior helps to manage the performance and user experience by
30
+ * preventing multiple overlays from opening simultaneously and ensuring
31
+ * a smooth transition between opening and closing overlays.
32
+ *
33
+ * @type {boolean}
34
+ * @default false
28
35
  */
29
36
  get delayed(): boolean;
30
37
  set delayed(delayed: boolean);
31
38
  private _delayed;
39
+ /**
40
+ * A reference to the dialog element within the overlay.
41
+ * This element is expected to have `showPopover` and `hidePopover` methods.
42
+ */
32
43
  dialogEl: HTMLDialogElement & {
33
44
  showPopover(): void;
34
45
  hidePopover(): void;
35
46
  };
36
47
  /**
37
- * Whether the overlay is currently functional or not
48
+ * Indicates whether the overlay is currently functional or not.
49
+ *
50
+ * When set to `true`, the overlay is disabled, and any active strategy is aborted.
51
+ * The overlay will also close if it is currently open. When set to `false`, the
52
+ * overlay will re-bind events and re-open if it was previously open.
53
+ *
54
+ * @type {boolean}
55
+ * @default false
38
56
  */
39
57
  get disabled(): boolean;
40
58
  set disabled(disabled: boolean);
41
59
  private _disabled;
60
+ /**
61
+ * A query to gather all elements slotted into the default slot, excluding elements
62
+ * with the slot name "longpress-describedby-descriptor".
63
+ */
42
64
  elements: OpenableElement[];
65
+ /**
66
+ * A reference to the parent overlay that should be force-closed, if any.
67
+ */
43
68
  parentOverlayToForceClose?: Overlay;
69
+ /**
70
+ * Determines if the overlay has a non-virtual trigger element.
71
+ *
72
+ * @returns {boolean} `true` if the trigger element is not a virtual trigger, otherwise `false`.
73
+ */
44
74
  private get hasNonVirtualTrigger();
45
75
  /**
46
- * The `offset` property accepts either a single number, to
47
- * define the offset of the Overlay along the main axis from
48
- * the trigger, or 2-tuple, to define the offset along the
49
- * main axis and the cross axis. This option has no effect
50
- * when there is no trigger element.
76
+ * The `offset` property accepts either a single number to define the offset of the
77
+ * Overlay along the main axis from the trigger, or a 2-tuple to define the offset
78
+ * along both the main axis and the cross axis. This option has no effect when there
79
+ * is no trigger element.
80
+ *
81
+ * @type {number | [number, number]}
82
+ * @default 0
51
83
  */
52
84
  offset: number | [number, number];
85
+ /**
86
+ * Provides an instance of the `PlacementController` for managing the positioning
87
+ * of the overlay relative to its trigger element.
88
+ *
89
+ * If the `PlacementController` instance does not already exist, it is created and
90
+ * assigned to the `_placementController` property.
91
+ *
92
+ * @protected
93
+ * @returns {PlacementController} The `PlacementController` instance.
94
+ */
53
95
  protected get placementController(): PlacementController;
54
96
  /**
55
- * Whether the Overlay is projected onto the "top layer" or not.
97
+ * Indicates whether the Overlay is projected onto the "top layer" or not.
98
+ *
99
+ * When set to `true`, the overlay is open and visible. When set to `false`, the overlay is closed and hidden.
100
+ *
101
+ * @type {boolean}
102
+ * @default false
56
103
  */
57
104
  get open(): boolean;
58
105
  set open(open: boolean);
59
106
  private _open;
107
+ /**
108
+ * Tracks the number of overlays that have been opened.
109
+ *
110
+ * This static property is used to manage the stacking context of multiple overlays.
111
+ *
112
+ * @type {number}
113
+ * @default 1
114
+ */
60
115
  static openCount: number;
61
116
  /**
62
- * Instruct the Overlay where to place itself in
63
- * relationship to the trigger element.
117
+ * Instruct the Overlay where to place itself in relationship to the trigger element.
118
+ *
64
119
  * @type {"top" | "top-start" | "top-end" | "right" | "right-start" | "right-end" | "bottom" | "bottom-start" | "bottom-end" | "left" | "left-start" | "left-end"}
65
120
  */
66
121
  placement?: Placement;
67
122
  /**
68
123
  * The state in which the last `request-slottable` event was dispatched.
69
- * Do not allow overlays from dispatching the same state twice in a row.
124
+ *
125
+ * This property ensures that overlays do not dispatch the same state twice in a row.
126
+ *
127
+ * @type {boolean}
128
+ * @default false
70
129
  */
71
130
  private lastRequestSlottableState;
72
131
  /**
@@ -74,61 +133,332 @@ export declare class Overlay extends OverlayFeatures {
74
133
  * to the appropriate value based on the "type" of the overlay
75
134
  * when set to `"auto"`.
76
135
  *
136
+ * @type {'true' | 'false' | 'auto'}
137
+ * @default 'auto'
77
138
  */
78
139
  receivesFocus: 'true' | 'false' | 'auto';
140
+ /**
141
+ * A reference to the slot element within the overlay.
142
+ *
143
+ * This element is used to manage the content slotted into the overlay.
144
+ *
145
+ * @type {HTMLSlotElement}
146
+ */
79
147
  slotEl: HTMLSlotElement;
148
+ /**
149
+ * The current state of the overlay.
150
+ *
151
+ * This property reflects the current state of the overlay, such as 'opened' or 'closed'.
152
+ * When the state changes, it triggers the appropriate actions and updates the component.
153
+ *
154
+ * @type {OverlayState}
155
+ * @default 'closed'
156
+ */
80
157
  get state(): OverlayState;
81
158
  set state(state: OverlayState);
82
159
  _state: OverlayState;
160
+ /**
161
+ * The interaction strategy for opening the overlay.
162
+ * This can be a ClickController, HoverController, or LongpressController.
163
+ */
83
164
  strategy?: ClickController | HoverController | LongpressController;
165
+ /**
166
+ * The padding around the tip of the overlay.
167
+ * This property defines the padding around the tip of the overlay, which can be used to adjust its positioning.
168
+ *
169
+ * @type {number}
170
+ */
84
171
  tipPadding?: number;
85
172
  /**
86
173
  * An optional ID reference for the trigger element combined with the optional
87
- * interaction (click | hover | longpress) by which the overlay shold open
88
- * the overlay with an `@`: e.g. `trigger@click` opens the overlay when an
89
- * element with the ID "trigger" is clicked.
174
+ * interaction (click | hover | longpress) by which the overlay should open.
175
+ * The format is `trigger@interaction`, e.g., `trigger@click` opens the overlay
176
+ * when an element with the ID "trigger" is clicked.
177
+ *
178
+ * @type {string}
90
179
  */
91
180
  trigger?: string;
92
181
  /**
93
182
  * An element reference for the trigger element that the overlay should relate to.
183
+ * This property is not reflected as an attribute.
184
+ *
185
+ * @type {HTMLElement | VirtualTrigger | null}
94
186
  */
95
187
  triggerElement: HTMLElement | VirtualTrigger | null;
96
188
  /**
97
189
  * The specific interaction to listen for on the `triggerElement` to open the overlay.
190
+ * This property is not reflected as an attribute.
191
+ *
192
+ * @type {TriggerInteraction}
98
193
  */
99
194
  triggerInteraction?: TriggerInteraction;
100
195
  /**
101
196
  * Configures the open/close heuristics of the Overlay.
197
+ *
102
198
  * @type {"auto" | "hint" | "manual" | "modal" | "page"}
199
+ * @default "auto"
103
200
  */
104
201
  type: OverlayTypes;
202
+ /**
203
+ * Tracks whether the overlay was previously open.
204
+ * This is used to restore the open state when re-enabling the overlay.
205
+ *
206
+ * @type {boolean}
207
+ * @default false
208
+ */
105
209
  protected wasOpen: boolean;
210
+ /**
211
+ * Provides an instance of the `ElementResolutionController` for managing the element
212
+ * that the overlay should be associated with. If the instance does not already exist,
213
+ * it is created and assigned to the `_elementResolver` property.
214
+ *
215
+ * @protected
216
+ * @returns {ElementResolutionController} The `ElementResolutionController` instance.
217
+ */
106
218
  protected get elementResolver(): ElementResolutionController;
219
+ /**
220
+ * Determines if the overlay uses a dialog.
221
+ * Returns `true` if the overlay type is "modal" or "page".
222
+ *
223
+ * @private
224
+ * @returns {boolean} `true` if the overlay uses a dialog, otherwise `false`.
225
+ */
107
226
  private get usesDialog();
227
+ /**
228
+ * Determines the value for the popover attribute based on the overlay type.
229
+ *
230
+ * @private
231
+ * @returns {'auto' | 'manual' | undefined} The popover value or undefined if not applicable.
232
+ */
108
233
  private get popoverValue();
109
- protected get requiresPosition(): boolean;
234
+ /**
235
+ * Determines if the overlay requires positioning based on its type and state.
236
+ *
237
+ * @protected
238
+ * @returns {boolean} True if the overlay requires positioning, otherwise false.
239
+ */
240
+ protected get requiresPositioning(): boolean;
241
+ /**
242
+ * Manages the positioning of the overlay relative to its trigger element.
243
+ *
244
+ * This method calculates the necessary parameters for positioning the overlay,
245
+ * such as offset, placement, and tip padding, and then delegates the actual
246
+ * positioning to the `PlacementController`.
247
+ *
248
+ * @protected
249
+ * @override
250
+ */
110
251
  protected managePosition(): void;
252
+ /**
253
+ * Manages the process of opening the popover.
254
+ *
255
+ * This method handles the necessary steps to open the popover, including managing delays,
256
+ * ensuring the popover is in the DOM, making transitions, and applying focus.
257
+ *
258
+ * @protected
259
+ * @override
260
+ * @returns {Promise<void>} A promise that resolves when the popover has been fully opened.
261
+ */
111
262
  protected managePopoverOpen(): Promise<void>;
263
+ /**
264
+ * Applies focus to the appropriate element after the popover has been opened.
265
+ *
266
+ * This method handles the focus management for the overlay, ensuring that the correct
267
+ * element receives focus based on the overlay's type and state.
268
+ *
269
+ * @protected
270
+ * @override
271
+ * @param {boolean} targetOpenState - The target open state of the overlay.
272
+ * @param {HTMLElement | null} focusEl - The element to focus after opening the popover.
273
+ * @returns {Promise<void>} A promise that resolves when the focus has been applied.
274
+ */
112
275
  protected applyFocus(targetOpenState: boolean, focusEl: HTMLElement | null): Promise<void>;
276
+ /**
277
+ * Returns focus to the trigger element if the overlay is closed.
278
+ *
279
+ * This method ensures that focus is returned to the trigger element when the overlay is closed,
280
+ * unless the overlay is of type "hint" or the focus is already outside the overlay.
281
+ *
282
+ * @protected
283
+ * @override
284
+ */
113
285
  protected returnFocus(): void;
286
+ /**
287
+ * Handles the focus out event to close the overlay if the focus moves outside of it.
288
+ *
289
+ * This method ensures that the overlay is closed when the focus moves to an element
290
+ * outside of the overlay, unless the focus is moved to a related element.
291
+ *
292
+ * @private
293
+ * @param {FocusEvent} event - The focus out event.
294
+ */
114
295
  private closeOnFocusOut;
296
+ /**
297
+ * Manages the process of opening or closing the overlay.
298
+ *
299
+ * This method handles the necessary steps to open or close the overlay, including updating the state,
300
+ * managing the overlay stack, and handling focus events.
301
+ *
302
+ * @protected
303
+ * @param {boolean} oldOpen - The previous open state of the overlay.
304
+ * @returns {Promise<void>} A promise that resolves when the overlay has been fully managed.
305
+ */
115
306
  protected manageOpen(oldOpen: boolean): Promise<void>;
307
+ /**
308
+ * Binds event handling strategies to the overlay based on the specified trigger interaction.
309
+ *
310
+ * This method sets up the appropriate event handling strategy for the overlay, ensuring that
311
+ * it responds correctly to user interactions such as clicks, hovers, or long presses.
312
+ *
313
+ * @protected
314
+ */
116
315
  protected bindEvents(): void;
316
+ /**
317
+ * Handles the `beforetoggle` event to manage the overlay's state.
318
+ *
319
+ * This method checks the new state of the event and calls `handleBrowserClose`
320
+ * if the new state is not 'open'.
321
+ *
322
+ * @protected
323
+ * @param {Event & { newState: string }} event - The `beforetoggle` event with the new state.
324
+ */
117
325
  protected handleBeforetoggle(event: Event & {
118
326
  newState: string;
119
327
  }): void;
120
- protected handleBrowserClose(): void;
328
+ /**
329
+ * Handles the browser's close event to manage the overlay's state.
330
+ *
331
+ * This method stops the propagation of the event and closes the overlay if it is not
332
+ * actively opening. If the overlay is actively opening, it calls `manuallyKeepOpen`.
333
+ *
334
+ * @protected
335
+ * @param {Event} event - The browser's close event.
336
+ */
337
+ protected handleBrowserClose(event: Event): void;
338
+ /**
339
+ * Manually keeps the overlay open.
340
+ *
341
+ * This method sets the overlay to open, allows placement updates, and manages the open state.
342
+ *
343
+ * @public
344
+ * @override
345
+ */
121
346
  manuallyKeepOpen(): void;
347
+ /**
348
+ * Handles the `slotchange` event to manage the overlay's state.
349
+ *
350
+ * This method checks if there are any elements in the slot. If there are no elements,
351
+ * it releases the description from the strategy. If there are elements and the trigger
352
+ * is non-virtual, it prepares the description for the trigger element.
353
+ *
354
+ * @protected
355
+ */
122
356
  protected handleSlotchange(): void;
357
+ /**
358
+ * Determines whether the overlay should prevent closing.
359
+ *
360
+ * This method checks the `willPreventClose` flag and resets it to `false`.
361
+ * It returns the value of the `willPreventClose` flag.
362
+ *
363
+ * @public
364
+ * @returns {boolean} `true` if the overlay should prevent closing, otherwise `false`.
365
+ */
123
366
  shouldPreventClose(): boolean;
367
+ /**
368
+ * Requests slottable content for the overlay.
369
+ *
370
+ * This method dispatches a `SlottableRequestEvent` to request or remove slottable content
371
+ * based on the current open state of the overlay. It ensures that the same state is not
372
+ * dispatched twice in a row.
373
+ *
374
+ * @protected
375
+ * @override
376
+ */
124
377
  protected requestSlottable(): void;
378
+ /**
379
+ * Lifecycle method called before the component updates.
380
+ *
381
+ * This method handles various tasks before the component updates, such as setting an ID,
382
+ * managing the open state, resolving the trigger element, and binding events.
383
+ *
384
+ * @override
385
+ * @param {PropertyValues} changes - The properties that have changed.
386
+ */
125
387
  willUpdate(changes: PropertyValues): void;
388
+ /**
389
+ * Lifecycle method called after the component updates.
390
+ *
391
+ * This method handles various tasks after the component updates, such as updating the placement
392
+ * attribute, resetting the overlay position, and clearing the overlay position based on the state.
393
+ *
394
+ * @override
395
+ * @param {PropertyValues} changes - The properties that have changed.
396
+ */
126
397
  protected updated(changes: PropertyValues): void;
398
+ /**
399
+ * Renders the content of the overlay.
400
+ *
401
+ * This method returns a template result containing a slot element. The slot element
402
+ * listens for the `slotchange` event to manage the overlay's state.
403
+ *
404
+ * @protected
405
+ * @returns {TemplateResult} The template result containing the slot element.
406
+ */
127
407
  protected renderContent(): TemplateResult;
408
+ /**
409
+ * Generates a style map for the dialog element.
410
+ *
411
+ * This method returns an object containing CSS custom properties for the dialog element.
412
+ * The `--swc-overlay-open-count` custom property is set to the current open count of overlays.
413
+ *
414
+ * @private
415
+ * @returns {StyleInfo} The style map for the dialog element.
416
+ */
128
417
  private get dialogStyleMap();
418
+ /**
419
+ * Renders the dialog element for the overlay.
420
+ *
421
+ * This method returns a template result containing a dialog element. The dialog element
422
+ * includes various attributes and event listeners to manage the overlay's state and behavior.
423
+ *
424
+ * @protected
425
+ * @returns {TemplateResult} The template result containing the dialog element.
426
+ */
129
427
  protected renderDialog(): TemplateResult;
428
+ /**
429
+ * Renders the popover element for the overlay.
430
+ *
431
+ * This method returns a template result containing a div element styled as a popover.
432
+ * The popover element includes various attributes and event listeners to manage the overlay's state and behavior.
433
+ *
434
+ * @protected
435
+ * @returns {TemplateResult} The template result containing the popover element.
436
+ */
130
437
  protected renderPopover(): TemplateResult;
438
+ /**
439
+ * Renders the overlay component.
440
+ *
441
+ * This method returns a template result containing either a dialog or popover element
442
+ * based on the overlay type. It also includes a slot for longpress descriptors.
443
+ *
444
+ * @override
445
+ * @returns {TemplateResult} The template result containing the overlay content.
446
+ */
131
447
  render(): TemplateResult;
448
+ /**
449
+ * Lifecycle method called when the component is added to the DOM.
450
+ *
451
+ * This method sets up event listeners and binds events if the component has already updated.
452
+ *
453
+ * @override
454
+ */
132
455
  connectedCallback(): void;
456
+ /**
457
+ * Lifecycle method called when the component is removed from the DOM.
458
+ *
459
+ * This method releases the description from the strategy and updates the 'open' property.
460
+ *
461
+ * @override
462
+ */
133
463
  disconnectedCallback(): void;
134
464
  }