@justeattakeaway/pie-modal 0.17.0 → 0.19.0

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.
@@ -0,0 +1,260 @@
1
+ import type { CSSResult } from 'lit';
2
+ import type { DependentMap } from '@justeattakeaway/pie-webc-core';
3
+ import type { LitElement } from 'lit';
4
+ import { RTLComponentProps } from '@justeattakeaway/pie-webc-core';
5
+ import type { TemplateResult } from 'lit';
6
+ import { Variant } from '@justeattakeaway/pie-button/src/defs.ts';
7
+
8
+ export declare type ActionProps = {
9
+ /**
10
+ * The text to display inside the button.
11
+ */
12
+ text: string;
13
+ /**
14
+ * The button variant.
15
+ */
16
+ variant?: Variant;
17
+ /**
18
+ * The ARIA label for the button.
19
+ */
20
+ ariaLabel?: string;
21
+ };
22
+
23
+ export declare type AriaProps = {
24
+ close?: string;
25
+ back?: string;
26
+ loading?: string;
27
+ };
28
+
29
+ export declare const headingLevels: readonly ["h1", "h2", "h3", "h4", "h5", "h6"];
30
+
31
+ export declare type ModalActionType = 'leading' | 'supporting';
32
+
33
+ export declare type ModalProps = RTLComponentProps & {
34
+ /**
35
+ * The ARIA labels used for the modal close and back buttons, as well as loading state.
36
+ */
37
+ aria?: AriaProps;
38
+ /**
39
+ * When true, the modal will have a back button. This currently behaves the same as the close button.
40
+ */
41
+ hasBackButton: boolean;
42
+ /**
43
+ * When true, the modal will have a back button. This currently behaves the same as the close button.
44
+ */
45
+ hasStackedActions: boolean;
46
+ /**
47
+ * The text to display in the modal's heading.
48
+ */
49
+ heading: string;
50
+ /**
51
+ * The HTML heading tag to use for the modal's heading. Can be h1-h6.
52
+ */
53
+ headingLevel: typeof headingLevels[number];
54
+ /**
55
+ * When true, the modal will be open.
56
+ */
57
+ isOpen: boolean;
58
+ /**
59
+ * When set to `true`:
60
+ * 1. The close button within the modal will be visible.
61
+ * 2. The user can dismiss the modal via the ESCAPE key, clicking the backdrop
62
+ * or via a close button.
63
+ *
64
+ * When set to `false`:
65
+ * 1. The close button within the modal will be hidden.
66
+ * 2. The user can NOT dismiss the modal via the ESCAPE key or clicking the backdrop.
67
+ *
68
+ */
69
+ isDismissible: boolean;
70
+ /**
71
+ * When false, the modal footer will scroll with the content inside the modal body.
72
+ */
73
+ isFooterPinned: boolean;
74
+ /**
75
+ * This controls whether a *medium-sized* modal will cover the full width of the page when below the mid breakpoint.
76
+ */
77
+ isFullWidthBelowMid: boolean;
78
+ /**
79
+ * When true, displays a loading spinner in the modal.
80
+ */
81
+ isLoading: boolean;
82
+ /**
83
+ * The leading action configuration for the modal.
84
+ */
85
+ leadingAction: ActionProps;
86
+ position: typeof positions[number];
87
+ /**
88
+ * The selector for the element that you would like focus to be returned to when the modal is closed, e.g., #skipToMain
89
+ */
90
+ returnFocusAfterCloseSelector?: string;
91
+ /**
92
+ * The size of the modal; this controls how wide it will appear on the page.
93
+ */
94
+ size: typeof sizes[number];
95
+ /**
96
+ * The supporting action configuration for the modal.
97
+ */
98
+ supportingAction: ActionProps;
99
+ };
100
+
101
+ /**
102
+ * Event name for when the modal back button is clicked.
103
+ *
104
+ * @constant
105
+ */
106
+ export declare const ON_MODAL_BACK_EVENT = "pie-modal-back";
107
+
108
+ /**
109
+ * Event name for when the modal is closed.
110
+ *
111
+ * @constant
112
+ */
113
+ export declare const ON_MODAL_CLOSE_EVENT = "pie-modal-close";
114
+
115
+ /**
116
+ * Event name for when the modal leading action is clicked.
117
+ *
118
+ * @constant
119
+ */
120
+ export declare const ON_MODAL_LEADING_ACTION_CLICK = "pie-modal-leading-action-click";
121
+
122
+ /**
123
+ * Event name for when the modal is opened.
124
+ *
125
+ * @constant
126
+ */
127
+ export declare const ON_MODAL_OPEN_EVENT = "pie-modal-open";
128
+
129
+ /**
130
+ * Event name for when the modal supporting action is clicked.
131
+ *
132
+ * @constant
133
+ */
134
+ export declare const ON_MODAL_SUPPORTING_ACTION_CLICK = "pie-modal-supporting-action-click";
135
+
136
+ /**
137
+ * @event {CustomEvent} pie-modal-open - when the modal is opened.
138
+ * @event {CustomEvent} pie-modal-close - when the modal is closed.
139
+ * @event {CustomEvent} pie-modal-back - when the modal back button is clicked.
140
+ * @event {CustomEvent} pie-modal-leading-action-click - when the modal leading action is clicked.
141
+ * @event {CustomEvent} pie-modal-supporting-action-click - when the modal supporting action is clicked.
142
+ */
143
+ export declare class PieModal extends PieModal_base implements ModalProps {
144
+ aria: AriaProps;
145
+ heading: string;
146
+ headingLevel: ModalProps['headingLevel'];
147
+ hasBackButton: boolean;
148
+ hasStackedActions: boolean;
149
+ isDismissible: boolean;
150
+ isFooterPinned: boolean;
151
+ isFullWidthBelowMid: boolean;
152
+ isLoading: boolean;
153
+ isOpen: boolean;
154
+ leadingAction: ActionProps;
155
+ position: ModalProps['position'];
156
+ returnFocusAfterCloseSelector?: string;
157
+ size: ModalProps['size'];
158
+ supportingAction: ActionProps;
159
+ private _dialog?;
160
+ private _backButtonClicked;
161
+ static styles: CSSResult;
162
+ constructor();
163
+ connectedCallback(): void;
164
+ disconnectedCallback(): void;
165
+ firstUpdated(changedProperties: DependentMap<ModalProps>): void;
166
+ updated(changedProperties: DependentMap<ModalProps>): void;
167
+ /**
168
+ * Opens the dialog element and disables page scrolling
169
+ */
170
+ private _handleModalOpened;
171
+ /**
172
+ * Closes the dialog element and re-enables page scrolling
173
+ */
174
+ private _handleModalClosed;
175
+ /**
176
+ * Prevents the user from dismissing the dialog via the `cancel`
177
+ * event (ESC key) when `isDismissible` is set to false.
178
+ *
179
+ * @param {Event} event - The event object.
180
+ */
181
+ private _handleDialogCancelEvent;
182
+ private _handleModalOpenStateOnFirstRender;
183
+ private _handleModalOpenStateChanged;
184
+ private _handleActionClick;
185
+ /**
186
+ * Return focus to the specified element, providing the selector is valid
187
+ * and the chosen element can be found.
188
+ */
189
+ private _returnFocus;
190
+ /**
191
+ * Template for the close button element. Called within the
192
+ * main render function.
193
+ *
194
+ * @private
195
+ */
196
+ private renderCloseButton;
197
+ /**
198
+ * Template for the back button element. Called within the
199
+ * main render function.
200
+ *
201
+ * @private
202
+ */
203
+ private renderBackButton;
204
+ /**
205
+ * Render leadingAction button depending on prop availability.
206
+ *
207
+ * 1. If the prop `leadingAction` is not provided, the button is not rendered.
208
+ * 2. If the prop `leadingAction` is provided but any of the optional properties
209
+ * are not provided, they fall back to their default values.
210
+ *
211
+ * @private
212
+ */
213
+ private renderLeadingAction;
214
+ /**
215
+ * Render supportingAction button depending on prop availability.
216
+ *
217
+ * 1. If the prop `supportingAction` is not provided, the button is not rendered.
218
+ * 2. If the prop `supportingAction` is provided but any of the optional properties
219
+ * are not provided, they fall back to their default values.
220
+ * 3. If `supportingAction` is provided but not `leadingAction`, log a warning and do
221
+ * not render `supportingAction`.
222
+ *
223
+ * @private
224
+ */
225
+ private renderSupportingAction;
226
+ /**
227
+ * Renders the modal inner content and footer of the modal.
228
+ * @private
229
+ */
230
+ private renderModalContentAndFooter;
231
+ render(): TemplateResult;
232
+ /**
233
+ * Dismisses the modal on backdrop click if `isDismissible` is `true`.
234
+ * @param {MouseEvent} event - the click event targetting the modal/backdrop
235
+ */
236
+ private _handleDialogLightDismiss;
237
+ /**
238
+ * Note: We should aim to have a shareable event helper system to allow
239
+ * us to share this across components in-future.
240
+ *
241
+ * Dispatch a custom event.
242
+ *
243
+ * To be used whenever we have behavioural events we want to
244
+ * bubble up through the modal.
245
+ *
246
+ * @param {string} eventType
247
+ */
248
+ private _dispatchModalCustomEvent;
249
+ }
250
+
251
+ declare const PieModal_base: (new (...args: any[]) => {
252
+ dir: "ltr" | "rtl" | "auto";
253
+ isRTL: boolean;
254
+ }) & typeof LitElement;
255
+
256
+ export declare const positions: readonly ["top", "center"];
257
+
258
+ export declare const sizes: readonly ["small", "medium", "large"];
259
+
260
+ export { }