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