@justeattakeaway/pie-modal 0.11.0 → 0.13.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.
- package/.turbo/turbo-build.log +6 -6
- package/CHANGELOG.md +27 -0
- package/README.md +2 -0
- package/dist/index.js +221 -164
- package/dist/react.js +131 -124
- package/dist/types/packages/components/pie-modal/src/defs.d.ts +16 -1
- package/dist/types/packages/components/pie-modal/src/defs.d.ts.map +1 -1
- package/dist/types/packages/components/pie-modal/src/index.d.ts +25 -11
- package/dist/types/packages/components/pie-modal/src/index.d.ts.map +1 -1
- package/dist/types/packages/components/pie-modal/src/react.d.ts +6 -1
- package/dist/types/packages/components/pie-modal/src/react.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/defs.ts +20 -1
- package/src/index.ts +110 -41
- package/src/modal.scss +183 -19
- package/test/component/pie-modal.spec.ts +236 -56
- package/test/visual/pie-modal.spec.ts +50 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { RTLComponentProps } from '@justeattakeaway/pie-webc-core';
|
|
1
2
|
export declare const headingLevels: readonly ["h1", "h2", "h3", "h4", "h5", "h6"];
|
|
2
3
|
export declare const sizes: readonly ["small", "medium", "large"];
|
|
3
|
-
export interface ModalProps {
|
|
4
|
+
export interface ModalProps extends RTLComponentProps {
|
|
4
5
|
/**
|
|
5
6
|
* The text to display in the modal's heading.
|
|
6
7
|
*/
|
|
@@ -25,6 +26,14 @@ export interface ModalProps {
|
|
|
25
26
|
*
|
|
26
27
|
*/
|
|
27
28
|
isDismissible: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* When true, displays a loading spinner in the modal.
|
|
31
|
+
*/
|
|
32
|
+
isLoading: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* When true, the modal will have a back button. This currently behaves the same as the close button.
|
|
35
|
+
*/
|
|
36
|
+
hasBackButton: boolean;
|
|
28
37
|
/**
|
|
29
38
|
* This controls whether a *medium-sized* modal will cover the full width of the page when below the mid breakpoint.
|
|
30
39
|
*/
|
|
@@ -50,4 +59,10 @@ export declare const ON_MODAL_CLOSE_EVENT = "pie-modal-close";
|
|
|
50
59
|
* @constant
|
|
51
60
|
*/
|
|
52
61
|
export declare const ON_MODAL_OPEN_EVENT = "pie-modal-open";
|
|
62
|
+
/**
|
|
63
|
+
* Event name for when the modal back button is clicked.
|
|
64
|
+
*
|
|
65
|
+
* @constant
|
|
66
|
+
*/
|
|
67
|
+
export declare const ON_MODAL_BACK_EVENT = "pie-modal-back";
|
|
53
68
|
//# sourceMappingURL=defs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defs.d.ts","sourceRoot":"","sources":["../../../src/defs.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,+CAAgD,CAAC;AAC3E,eAAO,MAAM,KAAK,uCAAwC,CAAC;AAE3D,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"defs.d.ts","sourceRoot":"","sources":["../../../src/defs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAEnE,eAAO,MAAM,aAAa,+CAAgD,CAAC;AAC3E,eAAO,MAAM,KAAK,uCAAwC,CAAC;AAE3D,MAAM,WAAW,UAAW,SAAQ,iBAAiB;IACjD;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,YAAY,EAAE,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC;IAE3C;;OAEG;IACH,MAAM,EAAE,OAAO,CAAC;IAEhB;;;;;;;;;;OAUG;IACH,aAAa,EAAE,OAAO,CAAC;IAEvB;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,aAAa,EAAE,OAAO,CAAC;IAEvB;;OAEG;IACH,mBAAmB,EAAE,OAAO,CAAC;IAE7B;;OAEG;IACH,6BAA6B,CAAC,EAAE,MAAM,CAAC;IAEvC;;OAEG;IACH,IAAI,EAAE,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC;CAC9B;AAED;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,oBAAoB,CAAC;AAEtD;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,mBAAmB,CAAC;AAEpD;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,mBAAmB,CAAC"}
|
|
@@ -4,18 +4,27 @@ import { ModalProps, headingLevels, sizes } from './defs';
|
|
|
4
4
|
export { type ModalProps, headingLevels, sizes };
|
|
5
5
|
declare const componentSelector = "pie-modal";
|
|
6
6
|
declare const PieModal_base: (new (...args: any[]) => {
|
|
7
|
-
dir:
|
|
7
|
+
dir: "ltr" | "rtl" | "auto";
|
|
8
8
|
isRTL: boolean;
|
|
9
9
|
}) & typeof LitElement;
|
|
10
|
+
/**
|
|
11
|
+
* @event {CustomEvent} pie-modal-open - when the modal is opened.
|
|
12
|
+
* @event {CustomEvent} pie-modal-close - when the modal is closed.
|
|
13
|
+
* @event {CustomEvent} pie-modal-back - when the modal back button is clicked.
|
|
14
|
+
*/
|
|
10
15
|
export declare class PieModal extends PieModal_base implements ModalProps {
|
|
11
16
|
heading: string;
|
|
12
17
|
headingLevel: ModalProps['headingLevel'];
|
|
13
18
|
isDismissible: boolean;
|
|
19
|
+
hasBackButton: boolean;
|
|
14
20
|
isFullWidthBelowMid: boolean;
|
|
15
21
|
isOpen: boolean;
|
|
22
|
+
isLoading: boolean;
|
|
16
23
|
returnFocusAfterCloseSelector?: string;
|
|
17
24
|
size: ModalProps['size'];
|
|
18
|
-
_dialog
|
|
25
|
+
private _dialog?;
|
|
26
|
+
private _backButtonClicked;
|
|
27
|
+
static styles: import("lit").CSSResult;
|
|
19
28
|
constructor();
|
|
20
29
|
connectedCallback(): void;
|
|
21
30
|
disconnectedCallback(): void;
|
|
@@ -41,9 +50,22 @@ export declare class PieModal extends PieModal_base implements ModalProps {
|
|
|
41
50
|
/**
|
|
42
51
|
* Return focus to the specified element, providing the selector is valid
|
|
43
52
|
* and the chosen element can be found.
|
|
44
|
-
* Fails silently.
|
|
45
53
|
*/
|
|
46
54
|
private _returnFocus;
|
|
55
|
+
/**
|
|
56
|
+
* Template for the close button element. Called within the
|
|
57
|
+
* main render function.
|
|
58
|
+
*
|
|
59
|
+
* @private
|
|
60
|
+
*/
|
|
61
|
+
private renderCloseButton;
|
|
62
|
+
/**
|
|
63
|
+
* Template for the back button element. Called within the
|
|
64
|
+
* main render function.
|
|
65
|
+
*
|
|
66
|
+
* @private
|
|
67
|
+
*/
|
|
68
|
+
private renderBackButton;
|
|
47
69
|
render(): TemplateResult;
|
|
48
70
|
/**
|
|
49
71
|
* Dismisses the modal on backdrop click if `isDismissible` is `true`.
|
|
@@ -62,14 +84,6 @@ export declare class PieModal extends PieModal_base implements ModalProps {
|
|
|
62
84
|
* @param {string} eventType
|
|
63
85
|
*/
|
|
64
86
|
private _dispatchModalCustomEvent;
|
|
65
|
-
/**
|
|
66
|
-
* Template for the close button element. Called within the
|
|
67
|
-
* main render function.
|
|
68
|
-
*
|
|
69
|
-
* @private
|
|
70
|
-
*/
|
|
71
|
-
private renderCloseButton;
|
|
72
|
-
static styles: import("lit").CSSResult;
|
|
73
87
|
}
|
|
74
88
|
declare global {
|
|
75
89
|
interface HTMLElementTagNameMap {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,UAAU,EAAW,cAAc,EACtC,MAAM,KAAK,CAAC;AAMb,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAEnE,OAAO,iDAAiD,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,UAAU,EAAW,cAAc,EACtC,MAAM,KAAK,CAAC;AAMb,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAEnE,OAAO,iDAAiD,CAAC;AACzD,OAAO,uDAAuD,CAAC;AAC/D,OAAO,wDAAwD,CAAC;AAGhE,OAAO,EACH,UAAU,EACV,aAAa,EAIb,KAAK,EACR,MAAM,QAAQ,CAAC;AAGhB,OAAO,EAAE,KAAK,UAAU,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;AAEjD,QAAA,MAAM,iBAAiB,cAAc,CAAC;;;;;AAEtC;;;;GAIG;AACH,qBAAa,QAAS,SAAQ,aAAqB,YAAW,UAAU;IAG7D,OAAO,EAAG,MAAM,CAAC;IAIjB,YAAY,EAAE,UAAU,CAAC,cAAc,CAAC,CAAQ;IAGhD,aAAa,UAAS;IAGtB,aAAa,UAAS;IAGtB,mBAAmB,UAAS;IAG5B,MAAM,UAAS;IAGf,SAAS,UAAS;IAGlB,6BAA6B,CAAC,EAAE,MAAM,CAAC;IAIvC,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,CAAY;IAG3C,OAAO,CAAC,OAAO,CAAC,CAAoB;IAEpC,OAAO,CAAC,kBAAkB,CAAS;IAGnC,MAAM,CAAC,MAAM,0BAAqB;;IAOlC,iBAAiB,IAAM,IAAI;IAO3B,oBAAoB,IAAM,IAAI;IAO9B,YAAY,CAAE,iBAAiB,EAAE,YAAY,CAAC,UAAU,CAAC,GAAI,IAAI;IASjE,OAAO,CAAE,iBAAiB,EAAE,YAAY,CAAC,UAAU,CAAC,GAAI,IAAI;IAI5D;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAS1B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAM1B;;;;;OAKG;IACH,OAAO,CAAC,wBAAwB,CAI9B;IAGF,OAAO,CAAC,kCAAkC;IAU1C,OAAO,CAAC,4BAA4B;IAkBpC;;;OAGG;IACH,OAAO,CAAC,YAAY;IAQpB;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;IAUzB;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;IAYjB,MAAM;IAsDb;;;OAGG;IACH,OAAO,CAAC,yBAAyB,CAyB/B;IAEF;;;;;;;;;;OAUG;IACH,OAAO,CAAC,yBAAyB,CAO/B;CACL;AAID,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,CAAC,iBAAiB,CAAC,EAAE,QAAQ,CAAC;KACjC;CACJ"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { EventName } from '@lit-labs/react';
|
|
1
2
|
import { PieModal as PieModalReact } from './index';
|
|
2
|
-
export declare const PieModal: import("@lit-labs/react").ReactWebComponent<PieModalReact, {
|
|
3
|
+
export declare const PieModal: import("@lit-labs/react").ReactWebComponent<PieModalReact, {
|
|
4
|
+
onPieModalOpen: EventName<CustomEvent<any>>;
|
|
5
|
+
onPieModalClose: EventName<CustomEvent<any>>;
|
|
6
|
+
onPieModalBack: EventName<CustomEvent<any>>;
|
|
7
|
+
}>;
|
|
3
8
|
//# sourceMappingURL=react.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../../src/react.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../../src/react.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmB,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AAEpD,eAAO,MAAM,QAAQ;;;;EAUnB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justeattakeaway/pie-modal",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "PIE design system modal built using web components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"author": "JustEatTakeaway - Design System Web Team",
|
|
22
22
|
"license": "Apache-2.0",
|
|
23
23
|
"devDependencies": {
|
|
24
|
+
"@justeattakeaway/pie-button": "workspace:*",
|
|
24
25
|
"@justeattakeaway/pie-components-config": "workspace:*",
|
|
25
26
|
"@justeattakeaway/pie-icon-button": "workspace:*",
|
|
26
27
|
"@justeattakeaway/pie-icons-webc": "workspace:*",
|
package/src/defs.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { RTLComponentProps } from '@justeattakeaway/pie-webc-core';
|
|
2
|
+
|
|
1
3
|
export const headingLevels = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'] as const;
|
|
2
4
|
export const sizes = ['small', 'medium', 'large'] as const;
|
|
3
5
|
|
|
4
|
-
export interface ModalProps {
|
|
6
|
+
export interface ModalProps extends RTLComponentProps {
|
|
5
7
|
/**
|
|
6
8
|
* The text to display in the modal's heading.
|
|
7
9
|
*/
|
|
@@ -30,6 +32,16 @@ export interface ModalProps {
|
|
|
30
32
|
*/
|
|
31
33
|
isDismissible: boolean;
|
|
32
34
|
|
|
35
|
+
/**
|
|
36
|
+
* When true, displays a loading spinner in the modal.
|
|
37
|
+
*/
|
|
38
|
+
isLoading: boolean;
|
|
39
|
+
|
|
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
|
+
|
|
33
45
|
/**
|
|
34
46
|
* This controls whether a *medium-sized* modal will cover the full width of the page when below the mid breakpoint.
|
|
35
47
|
*/
|
|
@@ -59,3 +71,10 @@ export const ON_MODAL_CLOSE_EVENT = 'pie-modal-close';
|
|
|
59
71
|
* @constant
|
|
60
72
|
*/
|
|
61
73
|
export const ON_MODAL_OPEN_EVENT = 'pie-modal-open';
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Event name for when the modal back button is clicked.
|
|
77
|
+
*
|
|
78
|
+
* @constant
|
|
79
|
+
*/
|
|
80
|
+
export const ON_MODAL_BACK_EVENT = 'pie-modal-back';
|
package/src/index.ts
CHANGED
|
@@ -9,12 +9,16 @@ import {
|
|
|
9
9
|
import type { DependentMap } from '@justeattakeaway/pie-webc-core';
|
|
10
10
|
import { disableBodyScroll, enableBodyScroll } from 'body-scroll-lock';
|
|
11
11
|
import '@justeattakeaway/pie-icons-webc/icons/IconClose';
|
|
12
|
+
import '@justeattakeaway/pie-icons-webc/icons/IconChevronLeft';
|
|
13
|
+
import '@justeattakeaway/pie-icons-webc/icons/IconChevronRight';
|
|
14
|
+
|
|
12
15
|
import styles from './modal.scss?inline';
|
|
13
16
|
import {
|
|
14
17
|
ModalProps,
|
|
15
18
|
headingLevels,
|
|
16
19
|
ON_MODAL_CLOSE_EVENT,
|
|
17
20
|
ON_MODAL_OPEN_EVENT,
|
|
21
|
+
ON_MODAL_BACK_EVENT,
|
|
18
22
|
sizes,
|
|
19
23
|
} from './defs';
|
|
20
24
|
|
|
@@ -23,6 +27,11 @@ export { type ModalProps, headingLevels, sizes };
|
|
|
23
27
|
|
|
24
28
|
const componentSelector = 'pie-modal';
|
|
25
29
|
|
|
30
|
+
/**
|
|
31
|
+
* @event {CustomEvent} pie-modal-open - when the modal is opened.
|
|
32
|
+
* @event {CustomEvent} pie-modal-close - when the modal is closed.
|
|
33
|
+
* @event {CustomEvent} pie-modal-back - when the modal back button is clicked.
|
|
34
|
+
*/
|
|
26
35
|
export class PieModal extends RtlMixin(LitElement) implements ModalProps {
|
|
27
36
|
@property({ type: String })
|
|
28
37
|
@requiredProperty(componentSelector)
|
|
@@ -35,12 +44,18 @@ export class PieModal extends RtlMixin(LitElement) implements ModalProps {
|
|
|
35
44
|
@property({ type: Boolean, reflect: true })
|
|
36
45
|
public isDismissible = false;
|
|
37
46
|
|
|
47
|
+
@property({ type: Boolean })
|
|
48
|
+
public hasBackButton = false;
|
|
49
|
+
|
|
38
50
|
@property({ type: Boolean })
|
|
39
51
|
public isFullWidthBelowMid = false;
|
|
40
52
|
|
|
41
53
|
@property({ type: Boolean })
|
|
42
54
|
public isOpen = false;
|
|
43
55
|
|
|
56
|
+
@property({ type: Boolean, reflect: true })
|
|
57
|
+
public isLoading = false;
|
|
58
|
+
|
|
44
59
|
@property()
|
|
45
60
|
public returnFocusAfterCloseSelector?: string;
|
|
46
61
|
|
|
@@ -49,7 +64,12 @@ export class PieModal extends RtlMixin(LitElement) implements ModalProps {
|
|
|
49
64
|
public size: ModalProps['size'] = 'medium';
|
|
50
65
|
|
|
51
66
|
@query('dialog')
|
|
52
|
-
|
|
67
|
+
private _dialog?: HTMLDialogElement;
|
|
68
|
+
|
|
69
|
+
private _backButtonClicked = false;
|
|
70
|
+
|
|
71
|
+
// Renders a `CSSResult` generated from SCSS by Vite
|
|
72
|
+
static styles = unsafeCSS(styles);
|
|
53
73
|
|
|
54
74
|
constructor () {
|
|
55
75
|
super();
|
|
@@ -60,11 +80,13 @@ export class PieModal extends RtlMixin(LitElement) implements ModalProps {
|
|
|
60
80
|
super.connectedCallback();
|
|
61
81
|
document.addEventListener(ON_MODAL_OPEN_EVENT, this._handleModalOpened.bind(this));
|
|
62
82
|
document.addEventListener(ON_MODAL_CLOSE_EVENT, this._handleModalClosed.bind(this));
|
|
83
|
+
document.addEventListener(ON_MODAL_BACK_EVENT, this._handleModalClosed.bind(this));
|
|
63
84
|
}
|
|
64
85
|
|
|
65
86
|
disconnectedCallback () : void {
|
|
66
87
|
document.removeEventListener(ON_MODAL_OPEN_EVENT, this._handleModalOpened.bind(this));
|
|
67
88
|
document.removeEventListener(ON_MODAL_CLOSE_EVENT, this._handleModalClosed.bind(this));
|
|
89
|
+
document.removeEventListener(ON_MODAL_BACK_EVENT, this._handleModalClosed.bind(this));
|
|
68
90
|
super.disconnectedCallback();
|
|
69
91
|
}
|
|
70
92
|
|
|
@@ -126,11 +148,17 @@ export class PieModal extends RtlMixin(LitElement) implements ModalProps {
|
|
|
126
148
|
|
|
127
149
|
// Handles changes to the modal isOpen property by dispatching any appropriate events
|
|
128
150
|
private _handleModalOpenStateChanged (changedProperties: DependentMap<ModalProps>) : void {
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
if (
|
|
132
|
-
if (
|
|
133
|
-
this.
|
|
151
|
+
const wasPreviouslyOpen = changedProperties.get('isOpen');
|
|
152
|
+
|
|
153
|
+
if (wasPreviouslyOpen !== undefined) {
|
|
154
|
+
if (wasPreviouslyOpen) {
|
|
155
|
+
if (this._backButtonClicked) {
|
|
156
|
+
// Reset the flag
|
|
157
|
+
this._backButtonClicked = false;
|
|
158
|
+
this._dispatchModalCustomEvent(ON_MODAL_BACK_EVENT);
|
|
159
|
+
} else {
|
|
160
|
+
this._dispatchModalCustomEvent(ON_MODAL_CLOSE_EVENT);
|
|
161
|
+
}
|
|
134
162
|
} else {
|
|
135
163
|
this._dispatchModalCustomEvent(ON_MODAL_OPEN_EVENT);
|
|
136
164
|
}
|
|
@@ -140,7 +168,6 @@ export class PieModal extends RtlMixin(LitElement) implements ModalProps {
|
|
|
140
168
|
/**
|
|
141
169
|
* Return focus to the specified element, providing the selector is valid
|
|
142
170
|
* and the chosen element can be found.
|
|
143
|
-
* Fails silently.
|
|
144
171
|
*/
|
|
145
172
|
private _returnFocus () : void {
|
|
146
173
|
const selector = this.returnFocusAfterCloseSelector?.trim();
|
|
@@ -150,31 +177,92 @@ export class PieModal extends RtlMixin(LitElement) implements ModalProps {
|
|
|
150
177
|
}
|
|
151
178
|
}
|
|
152
179
|
|
|
153
|
-
|
|
180
|
+
/**
|
|
181
|
+
* Template for the close button element. Called within the
|
|
182
|
+
* main render function.
|
|
183
|
+
*
|
|
184
|
+
* @private
|
|
185
|
+
*/
|
|
186
|
+
private renderCloseButton (): TemplateResult {
|
|
187
|
+
return html`
|
|
188
|
+
<pie-icon-button
|
|
189
|
+
@click="${() => { this.isOpen = false; }}"
|
|
190
|
+
variant="ghost-secondary"
|
|
191
|
+
class="c-modal-closeBtn"
|
|
192
|
+
data-test-id="modal-close-button"><icon-close /></pie-icon-button>
|
|
193
|
+
`;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Template for the back button element. Called within the
|
|
198
|
+
* main render function.
|
|
199
|
+
*
|
|
200
|
+
* @private
|
|
201
|
+
*/
|
|
202
|
+
private renderBackButton () : TemplateResult {
|
|
203
|
+
return html`
|
|
204
|
+
<pie-icon-button
|
|
205
|
+
@click="${() => { this._backButtonClicked = true; this.isOpen = false; }}"
|
|
206
|
+
variant="ghost-secondary"
|
|
207
|
+
class="c-modal-backBtn"
|
|
208
|
+
data-test-id="modal-back-button">
|
|
209
|
+
${this.isRTL ? html`<icon-chevron-right />` : html`<icon-chevron-left />`}
|
|
210
|
+
</pie-icon-button>
|
|
211
|
+
`;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
public render () {
|
|
154
215
|
const {
|
|
216
|
+
hasBackButton,
|
|
155
217
|
heading,
|
|
156
218
|
headingLevel = 'h2',
|
|
157
|
-
|
|
219
|
+
isDismissible,
|
|
158
220
|
isFullWidthBelowMid,
|
|
221
|
+
isLoading,
|
|
222
|
+
size,
|
|
159
223
|
} = this;
|
|
160
224
|
|
|
161
225
|
const headingTag = unsafeStatic(headingLevel);
|
|
162
226
|
|
|
163
227
|
return html`
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
228
|
+
<dialog
|
|
229
|
+
id="dialog"
|
|
230
|
+
class="c-modal"
|
|
231
|
+
size="${size}"
|
|
232
|
+
?hasBackButton=${hasBackButton}
|
|
233
|
+
?isDismissible=${isDismissible}
|
|
234
|
+
?isFullWidthBelowMid=${isFullWidthBelowMid}
|
|
235
|
+
?isLoading=${isLoading}
|
|
236
|
+
data-test-id="pie-modal">
|
|
237
|
+
<header class="c-modal-header">
|
|
238
|
+
${hasBackButton ? this.renderBackButton() : nothing}
|
|
239
|
+
<${headingTag} class="c-modal-heading">
|
|
240
|
+
${heading}
|
|
241
|
+
</${headingTag}>
|
|
242
|
+
${isDismissible ? this.renderCloseButton() : nothing}
|
|
243
|
+
</header>
|
|
244
|
+
<article class="c-modal-content c-modal-content--scrollable">
|
|
245
|
+
<div class="c-modal-contentInner">
|
|
174
246
|
<slot></slot>
|
|
175
|
-
</
|
|
176
|
-
</
|
|
177
|
-
|
|
247
|
+
</div>
|
|
248
|
+
</article>
|
|
249
|
+
<footer class="c-modal-footer">
|
|
250
|
+
<pie-button
|
|
251
|
+
variant="primary"
|
|
252
|
+
type="submit"
|
|
253
|
+
@click="${() => this._dialog?.close('leading')}"
|
|
254
|
+
data-test-id="modal-leading-action">
|
|
255
|
+
Confirm
|
|
256
|
+
</pie-button>
|
|
257
|
+
<pie-button
|
|
258
|
+
variant="ghost"
|
|
259
|
+
type="reset"
|
|
260
|
+
@click="${() => this._dialog?.close('supporting')}"
|
|
261
|
+
data-test-id="modal-supporting-action">
|
|
262
|
+
Cancel
|
|
263
|
+
</pie-button>
|
|
264
|
+
</footer>
|
|
265
|
+
</dialog>`;
|
|
178
266
|
}
|
|
179
267
|
|
|
180
268
|
/**
|
|
@@ -227,25 +315,6 @@ export class PieModal extends RtlMixin(LitElement) implements ModalProps {
|
|
|
227
315
|
|
|
228
316
|
this.dispatchEvent(event);
|
|
229
317
|
};
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Template for the close button element. Called within the
|
|
233
|
-
* main render function.
|
|
234
|
-
*
|
|
235
|
-
* @private
|
|
236
|
-
*/
|
|
237
|
-
private renderCloseButton (): TemplateResult {
|
|
238
|
-
return html`
|
|
239
|
-
<pie-icon-button
|
|
240
|
-
@click="${() => { this.isOpen = false; }}"
|
|
241
|
-
variant="ghost-secondary"
|
|
242
|
-
class="c-modal-closeBtn"
|
|
243
|
-
data-test-id="modal-close-button"><icon-close /></pie-icon-button>
|
|
244
|
-
`;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
// Renders a `CSSResult` generated from SCSS by Vite
|
|
248
|
-
static styles = unsafeCSS(styles);
|
|
249
318
|
}
|
|
250
319
|
|
|
251
320
|
customElements.define(componentSelector, PieModal);
|