@workday/canvas-kit-popup-stack 6.1.3 → 6.2.1
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/README.md +41 -0
- package/dist/commonjs/lib/PopupStack.d.ts +83 -10
- package/dist/commonjs/lib/PopupStack.d.ts.map +1 -1
- package/dist/commonjs/lib/PopupStack.js +129 -15
- package/dist/es6/lib/PopupStack.d.ts +83 -10
- package/dist/es6/lib/PopupStack.d.ts.map +1 -1
- package/dist/es6/lib/PopupStack.js +126 -15
- package/lib/PopupStack.ts +141 -16
- package/package.json +6 -3
- package/ts3.5/dist/commonjs/lib/PopupStack.d.ts +83 -10
- package/ts3.5/dist/es6/lib/PopupStack.d.ts +83 -10
|
@@ -32,6 +32,16 @@ export interface PopupStackItem {
|
|
|
32
32
|
* popups.
|
|
33
33
|
*/
|
|
34
34
|
export declare function getValue(index: number, length: number): number;
|
|
35
|
+
interface Stack {
|
|
36
|
+
items: PopupStackItem[];
|
|
37
|
+
container?: () => HTMLElement;
|
|
38
|
+
zIndex: {
|
|
39
|
+
min: number;
|
|
40
|
+
max: number;
|
|
41
|
+
getValue: typeof getValue;
|
|
42
|
+
};
|
|
43
|
+
_adapter: Partial<typeof PopupStack>;
|
|
44
|
+
}
|
|
35
45
|
export declare const PopupStack: {
|
|
36
46
|
/**
|
|
37
47
|
* Create a HTMLElement as the container for the popup stack item. The returned element reference
|
|
@@ -48,10 +58,11 @@ export declare const PopupStack: {
|
|
|
48
58
|
*/
|
|
49
59
|
add(item: PopupStackItem): void;
|
|
50
60
|
/**
|
|
51
|
-
* Removes an item from
|
|
52
|
-
*
|
|
53
|
-
* cleanup.
|
|
54
|
-
* reset z-index values of the
|
|
61
|
+
* Removes an item from a stack by its `HTMLElement` reference. This should be called when a popup
|
|
62
|
+
* is "closed" or when the element is removed from the page entirely to ensure proper memory
|
|
63
|
+
* cleanup. A popup will be removed from the stack it is a part of. This will not automatically be
|
|
64
|
+
* called when the element is removed from the DOM. This method will reset z-index values of the
|
|
65
|
+
* stack.
|
|
55
66
|
*/
|
|
56
67
|
remove(element: HTMLElement): void;
|
|
57
68
|
/**
|
|
@@ -65,7 +76,7 @@ export declare const PopupStack: {
|
|
|
65
76
|
* elements in the order of lowest z-index to highest z-index. Some popup behaviors will need to
|
|
66
77
|
* make decisions based on z-index order.
|
|
67
78
|
*/
|
|
68
|
-
getElements(): HTMLElement[];
|
|
79
|
+
getElements(stackOverride?: Stack | undefined): HTMLElement[];
|
|
69
80
|
/**
|
|
70
81
|
* Bring the element to the top of the stack. This is useful for persistent popups to place them
|
|
71
82
|
* on top of the stack when clicked. If an `owner` was provided to an item when it was added and
|
|
@@ -91,6 +102,36 @@ export declare const PopupStack: {
|
|
|
91
102
|
* is not inside `element`).
|
|
92
103
|
*/
|
|
93
104
|
contains(element: HTMLElement, eventTarget: HTMLElement): boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Add a new stack context for popups. This method could be called with the same element multiple
|
|
107
|
+
* times, but should only push a new stack context once. The most common use-case for calling
|
|
108
|
+
* `pushStackContext` is when entering fullscreen, but multiple fullscreen listeners could be
|
|
109
|
+
* pushing the same element which is very difficult to ensure only one stack is used. To mitigate,
|
|
110
|
+
* this method filters out multiple calls to push the same element as a new stack context.
|
|
111
|
+
*/
|
|
112
|
+
pushStackContext(container: HTMLElement): void;
|
|
113
|
+
/**
|
|
114
|
+
* Remove the topmost stack context. The stack context will only be removed if the top stack
|
|
115
|
+
* context container element matches to guard against accidental remove of other stack contexts
|
|
116
|
+
* you don't own.
|
|
117
|
+
*/
|
|
118
|
+
popStackContext(container: HTMLElement): void;
|
|
119
|
+
/**
|
|
120
|
+
* Transfer the popup stack item into the current popup stack context.
|
|
121
|
+
*
|
|
122
|
+
* An example might be a popup
|
|
123
|
+
* that is opened and an element goes into fullscreen. The default popup stack context is
|
|
124
|
+
* `document.body`, but the [Fullscreen
|
|
125
|
+
* API](https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API) will only render elements
|
|
126
|
+
* that are children of the fullscreen element. If the popup isn't transferred to the current
|
|
127
|
+
* popup stack context, the popup will remain open, but will no longer be rendered. This method
|
|
128
|
+
* will transfer that popup to the fullscreen element so that it will render. Popups created while
|
|
129
|
+
* in a fullscreen context that need to be transferred back when fullscreen is exited should also
|
|
130
|
+
* call this method. While popups may still render when fullscreen is exited, popups will be
|
|
131
|
+
* members of different popup stack contexts which will cause unspecified results (like the escape
|
|
132
|
+
* key will choose the wrong popup as the "topmost").
|
|
133
|
+
*/
|
|
134
|
+
transferToCurrentContext(item: PopupStackItem): void;
|
|
94
135
|
};
|
|
95
136
|
/**
|
|
96
137
|
* Reset all the items in the stack. This should only be used for testing or if the page doesn't
|
|
@@ -117,10 +158,11 @@ export declare const createAdapter: (adapter: Partial<{
|
|
|
117
158
|
*/
|
|
118
159
|
add(item: PopupStackItem): void;
|
|
119
160
|
/**
|
|
120
|
-
* Removes an item from
|
|
121
|
-
*
|
|
122
|
-
* cleanup.
|
|
123
|
-
* reset z-index values of the
|
|
161
|
+
* Removes an item from a stack by its `HTMLElement` reference. This should be called when a popup
|
|
162
|
+
* is "closed" or when the element is removed from the page entirely to ensure proper memory
|
|
163
|
+
* cleanup. A popup will be removed from the stack it is a part of. This will not automatically be
|
|
164
|
+
* called when the element is removed from the DOM. This method will reset z-index values of the
|
|
165
|
+
* stack.
|
|
124
166
|
*/
|
|
125
167
|
remove(element: HTMLElement): void;
|
|
126
168
|
/**
|
|
@@ -134,7 +176,7 @@ export declare const createAdapter: (adapter: Partial<{
|
|
|
134
176
|
* elements in the order of lowest z-index to highest z-index. Some popup behaviors will need to
|
|
135
177
|
* make decisions based on z-index order.
|
|
136
178
|
*/
|
|
137
|
-
getElements(): HTMLElement[];
|
|
179
|
+
getElements(stackOverride?: Stack | undefined): HTMLElement[];
|
|
138
180
|
/**
|
|
139
181
|
* Bring the element to the top of the stack. This is useful for persistent popups to place them
|
|
140
182
|
* on top of the stack when clicked. If an `owner` was provided to an item when it was added and
|
|
@@ -160,5 +202,36 @@ export declare const createAdapter: (adapter: Partial<{
|
|
|
160
202
|
* is not inside `element`).
|
|
161
203
|
*/
|
|
162
204
|
contains(element: HTMLElement, eventTarget: HTMLElement): boolean;
|
|
205
|
+
/**
|
|
206
|
+
* Add a new stack context for popups. This method could be called with the same element multiple
|
|
207
|
+
* times, but should only push a new stack context once. The most common use-case for calling
|
|
208
|
+
* `pushStackContext` is when entering fullscreen, but multiple fullscreen listeners could be
|
|
209
|
+
* pushing the same element which is very difficult to ensure only one stack is used. To mitigate,
|
|
210
|
+
* this method filters out multiple calls to push the same element as a new stack context.
|
|
211
|
+
*/
|
|
212
|
+
pushStackContext(container: HTMLElement): void;
|
|
213
|
+
/**
|
|
214
|
+
* Remove the topmost stack context. The stack context will only be removed if the top stack
|
|
215
|
+
* context container element matches to guard against accidental remove of other stack contexts
|
|
216
|
+
* you don't own.
|
|
217
|
+
*/
|
|
218
|
+
popStackContext(container: HTMLElement): void;
|
|
219
|
+
/**
|
|
220
|
+
* Transfer the popup stack item into the current popup stack context.
|
|
221
|
+
*
|
|
222
|
+
* An example might be a popup
|
|
223
|
+
* that is opened and an element goes into fullscreen. The default popup stack context is
|
|
224
|
+
* `document.body`, but the [Fullscreen
|
|
225
|
+
* API](https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API) will only render elements
|
|
226
|
+
* that are children of the fullscreen element. If the popup isn't transferred to the current
|
|
227
|
+
* popup stack context, the popup will remain open, but will no longer be rendered. This method
|
|
228
|
+
* will transfer that popup to the fullscreen element so that it will render. Popups created while
|
|
229
|
+
* in a fullscreen context that need to be transferred back when fullscreen is exited should also
|
|
230
|
+
* call this method. While popups may still render when fullscreen is exited, popups will be
|
|
231
|
+
* members of different popup stack contexts which will cause unspecified results (like the escape
|
|
232
|
+
* key will choose the wrong popup as the "topmost").
|
|
233
|
+
*/
|
|
234
|
+
transferToCurrentContext(item: PopupStackItem): void;
|
|
163
235
|
}>) => void;
|
|
236
|
+
export {};
|
|
164
237
|
//# sourceMappingURL=PopupStack.d.ts.map
|