@justeattakeaway/pie-modal 0.44.0 → 0.46.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.
@@ -87,7 +87,7 @@
87
87
  "type": {
88
88
  "text": "DefaultProps"
89
89
  },
90
- "default": "{\n hasBackButton: false,\n hasStackedActions: false,\n headingLevel: 'h2',\n isOpen: false,\n isDismissible: false,\n isFooterPinned: true,\n isFullWidthBelowMid: false,\n isLoading: false,\n leadingActionVariant: 'primary',\n position: 'center',\n size: 'medium',\n supportingActionVariant: 'ghost',\n}"
90
+ "default": "{\n hasBackButton: false,\n hasStackedActions: false,\n headingLevel: 'h2',\n isOpen: false,\n isDismissible: false,\n isFooterPinned: true,\n isFullWidthBelowMid: false,\n isLoading: false,\n position: 'center',\n size: 'medium',\n}"
91
91
  }
92
92
  ],
93
93
  "exports": [
@@ -244,18 +244,12 @@
244
244
  },
245
245
  {
246
246
  "kind": "field",
247
- "name": "leadingActionText",
247
+ "name": "leadingAction",
248
248
  "type": {
249
- "text": "ModalProps['leadingActionText']"
249
+ "text": "ModalProps['leadingAction']"
250
250
  },
251
251
  "privacy": "public",
252
- "attribute": "leadingActionText"
253
- },
254
- {
255
- "kind": "field",
256
- "name": "leadingActionVariant",
257
- "privacy": "public",
258
- "attribute": "leadingActionVariant"
252
+ "attribute": "leadingAction"
259
253
  },
260
254
  {
261
255
  "kind": "field",
@@ -267,7 +261,7 @@
267
261
  "kind": "field",
268
262
  "name": "returnFocusAfterCloseSelector",
269
263
  "type": {
270
- "text": "ModalProps['returnFocusAfterCloseSelector'] | undefined"
264
+ "text": "ModalProps['returnFocusAfterCloseSelector']"
271
265
  },
272
266
  "privacy": "public",
273
267
  "attribute": "returnFocusAfterCloseSelector"
@@ -280,18 +274,12 @@
280
274
  },
281
275
  {
282
276
  "kind": "field",
283
- "name": "supportingActionText",
277
+ "name": "supportingAction",
284
278
  "type": {
285
- "text": "ModalProps['supportingActionText']"
279
+ "text": "ModalProps['supportingAction']"
286
280
  },
287
281
  "privacy": "public",
288
- "attribute": "supportingActionText"
289
- },
290
- {
291
- "kind": "field",
292
- "name": "supportingActionVariant",
293
- "privacy": "public",
294
- "attribute": "supportingActionVariant"
282
+ "attribute": "supportingAction"
295
283
  },
296
284
  {
297
285
  "kind": "field",
@@ -459,7 +447,7 @@
459
447
  "text": "TemplateResult | typeof nothing"
460
448
  }
461
449
  },
462
- "description": "Renders the \"leadingAction\" button if the text is provided.\n\nIf `leadingActionText` is not provided, the button is not rendered.\nIf `leadingActionVariant` is not provided, the default value is used.\nThe (optional) aria-label is read from the `aria` prop's `leadingActionLabel` property."
450
+ "description": "Renders the \"leadingAction\" button if the text is provided.\n\nIf `leadingAction.text` is not provided, the button is not rendered.\nIf `leadingAction.variant` is not provided, the default value of \"primary\" is used.\nThe (optional) aria-label is read from `leadingAction.ariaLabel`."
463
451
  },
464
452
  {
465
453
  "kind": "method",
@@ -470,7 +458,29 @@
470
458
  "text": "TemplateResult | typeof nothing"
471
459
  }
472
460
  },
473
- "description": "Renders the \"supportingAction\" button if the text is provided.\nYou cannot have a supporting action without a leading action.\n\nIf `supportingActionText` or `leadingActionText` are not provided, the button is not rendered.\nIf `supportingActionVariant` is not provided, the default value is used."
461
+ "description": "Renders the \"supportingAction\" button if the text is provided.\nYou cannot have a supporting action without a leading action.\n\nIf either `supportingAction.text` or `leadingAction.text` are not provided, the button is not rendered.\nIf `supportingAction.variant` is not provided, the default value of \"ghost\" is used.\nThe (optional) aria-label is read from `supportingAction.ariaLabel`."
462
+ },
463
+ {
464
+ "kind": "method",
465
+ "name": "renderModalFooter",
466
+ "privacy": "private",
467
+ "return": {
468
+ "type": {
469
+ "text": "TemplateResult | typeof nothing"
470
+ }
471
+ },
472
+ "description": "Renders the modal footer if a leading action is provided.\nAdditionally renders the supporting action if it is provided."
473
+ },
474
+ {
475
+ "kind": "method",
476
+ "name": "renderLoadingSpinner",
477
+ "privacy": "private",
478
+ "return": {
479
+ "type": {
480
+ "text": "TemplateResult | typeof nothing"
481
+ }
482
+ },
483
+ "description": "Renders the loading spinner if `isLoading` is true."
474
484
  },
475
485
  {
476
486
  "kind": "method",
@@ -584,15 +594,11 @@
584
594
  "fieldName": "isOpen"
585
595
  },
586
596
  {
587
- "name": "leadingActionText",
597
+ "name": "leadingAction",
588
598
  "type": {
589
- "text": "ModalProps['leadingActionText']"
599
+ "text": "ModalProps['leadingAction']"
590
600
  },
591
- "fieldName": "leadingActionText"
592
- },
593
- {
594
- "name": "leadingActionVariant",
595
- "fieldName": "leadingActionVariant"
601
+ "fieldName": "leadingAction"
596
602
  },
597
603
  {
598
604
  "name": "position",
@@ -601,7 +607,7 @@
601
607
  {
602
608
  "name": "returnFocusAfterCloseSelector",
603
609
  "type": {
604
- "text": "ModalProps['returnFocusAfterCloseSelector'] | undefined"
610
+ "text": "ModalProps['returnFocusAfterCloseSelector']"
605
611
  },
606
612
  "fieldName": "returnFocusAfterCloseSelector"
607
613
  },
@@ -610,15 +616,11 @@
610
616
  "fieldName": "size"
611
617
  },
612
618
  {
613
- "name": "supportingActionText",
619
+ "name": "supportingAction",
614
620
  "type": {
615
- "text": "ModalProps['supportingActionText']"
621
+ "text": "ModalProps['supportingAction']"
616
622
  },
617
- "fieldName": "supportingActionText"
618
- },
619
- {
620
- "name": "supportingActionVariant",
621
- "fieldName": "supportingActionVariant"
623
+ "fieldName": "supportingAction"
622
624
  }
623
625
  ],
624
626
  "mixins": [
package/dist/index.d.ts CHANGED
@@ -7,15 +7,28 @@ import type { RTLInterface } from '@justeattakeaway/pie-webc-core';
7
7
  import type { TemplateResult } from 'lit';
8
8
  import { Variant } from '@justeattakeaway/pie-button/src/defs.ts';
9
9
 
10
+ 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
+
10
25
  export declare type AriaProps = {
11
26
  close?: string;
12
27
  back?: string;
13
28
  loading?: string;
14
- leadingActionLabel?: string;
15
- supportingActionLabel?: string;
16
29
  };
17
30
 
18
- export declare type DefaultProps = ComponentDefaultProps<ModalProps, keyof Omit<ModalProps, 'aria' | 'heading' | 'leadingActionText' | 'supportingActionText' | 'returnFocusAfterCloseSelector'>>;
31
+ export declare type DefaultProps = ComponentDefaultProps<ModalProps, keyof Omit<ModalProps, 'aria' | 'heading' | 'leadingAction' | 'supportingAction' | 'returnFocusAfterCloseSelector'>>;
19
32
 
20
33
  export declare const defaultProps: DefaultProps;
21
34
 
@@ -29,7 +42,7 @@ export declare interface ModalEventDetail {
29
42
 
30
43
  export declare type ModalProps = {
31
44
  /**
32
- * The ARIA labels used for the modal leading action, supporting action, close and back buttons, as well as for the loading state.
45
+ * The ARIA labels used for the modal close and back buttons, as well as for the loading state.
33
46
  */
34
47
  aria?: AriaProps;
35
48
  /**
@@ -77,21 +90,13 @@ export declare type ModalProps = {
77
90
  */
78
91
  isLoading?: boolean;
79
92
  /**
80
- * The text to display inside the leading action button.
81
- */
82
- leadingActionText?: string;
83
- /**
84
- * The button variant for the leading action button.
93
+ * The leading action configuration for the modal.
85
94
  */
86
- leadingActionVariant?: Variant;
95
+ leadingAction?: ActionProps;
87
96
  /**
88
- * The text to display inside the supporting action button.
97
+ * The supporting action configuration for the modal.
89
98
  */
90
- supportingActionText?: string;
91
- /**
92
- * The button variant for the supporting action button.
93
- */
94
- supportingActionVariant?: Variant;
99
+ supportingAction?: ActionProps;
95
100
  position?: typeof positions[number];
96
101
  /**
97
102
  * The selector for the element that you would like focus to be returned to when the modal is closed, e.g., #skipToMain
@@ -157,13 +162,11 @@ export declare class PieModal extends PieModal_base implements ModalProps {
157
162
  isFullWidthBelowMid: boolean;
158
163
  isLoading: boolean;
159
164
  isOpen: boolean;
160
- leadingActionText: ModalProps['leadingActionText'];
161
- leadingActionVariant: "primary" | "secondary" | "outline" | "outline-inverse" | "ghost" | "inverse" | "ghost-inverse" | "destructive" | "destructive-ghost";
165
+ leadingAction: ModalProps['leadingAction'];
162
166
  position: "top" | "center";
163
- returnFocusAfterCloseSelector?: ModalProps['returnFocusAfterCloseSelector'];
167
+ returnFocusAfterCloseSelector: ModalProps['returnFocusAfterCloseSelector'];
164
168
  size: "medium" | "large" | "small";
165
- supportingActionText: ModalProps['supportingActionText'];
166
- supportingActionVariant: "primary" | "secondary" | "outline" | "outline-inverse" | "ghost" | "inverse" | "ghost-inverse" | "destructive" | "destructive-ghost";
169
+ supportingAction: ModalProps['supportingAction'];
167
170
  private _dialog?;
168
171
  private _backButtonClicked;
169
172
  static styles: CSSResult;
@@ -211,9 +214,9 @@ export declare class PieModal extends PieModal_base implements ModalProps {
211
214
  /**
212
215
  * Renders the "leadingAction" button if the text is provided.
213
216
  *
214
- * If `leadingActionText` is not provided, the button is not rendered.
215
- * If `leadingActionVariant` is not provided, the default value is used.
216
- * The (optional) aria-label is read from the `aria` prop's `leadingActionLabel` property.
217
+ * If `leadingAction.text` is not provided, the button is not rendered.
218
+ * If `leadingAction.variant` is not provided, the default value of "primary" is used.
219
+ * The (optional) aria-label is read from `leadingAction.ariaLabel`.
217
220
  *
218
221
  * @private
219
222
  */
@@ -222,12 +225,25 @@ export declare class PieModal extends PieModal_base implements ModalProps {
222
225
  * Renders the "supportingAction" button if the text is provided.
223
226
  * You cannot have a supporting action without a leading action.
224
227
  *
225
- * If `supportingActionText` or `leadingActionText` are not provided, the button is not rendered.
226
- * If `supportingActionVariant` is not provided, the default value is used.
228
+ * If either `supportingAction.text` or `leadingAction.text` are not provided, the button is not rendered.
229
+ * If `supportingAction.variant` is not provided, the default value of "ghost" is used.
230
+ * The (optional) aria-label is read from `supportingAction.ariaLabel`.
227
231
  *
228
232
  * @private
229
233
  */
230
234
  private renderSupportingAction;
235
+ /**
236
+ * Renders the modal footer if a leading action is provided.
237
+ * Additionally renders the supporting action if it is provided.
238
+ *
239
+ * @private
240
+ */
241
+ private renderModalFooter;
242
+ /**
243
+ * Renders the loading spinner if `isLoading` is true.
244
+ * @private
245
+ */
246
+ private renderLoadingSpinner;
231
247
  /**
232
248
  * Renders the modal inner content and footer of the modal.
233
249
  * @private