@govtechsg/sgds-web-component 1.3.0 → 1.4.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.
@@ -67,6 +67,8 @@ class SgdsModal extends sgdsElement["default"] {
67
67
  this.centeredAlignVariant = false;
68
68
  /** Removes the default animation when opening and closing of modal */
69
69
  this.noAnimation = false;
70
+ /** Removes the close button from modal header */
71
+ this.noCloseButton = false;
70
72
  }
71
73
  connectedCallback() {
72
74
  super.connectedCallback();
@@ -223,16 +225,18 @@ class SgdsModal extends sgdsElement["default"] {
223
225
  >
224
226
  ${this.titleIcon ? withLabelIcon : ""} ${this.title}
225
227
  </h3>
226
- <button
227
- class=${classMap_js.classMap({
228
- "modal-close": true,
229
- "btn-sm": true,
230
- "btn-close": true,
231
- centered: this.centeredAlignVariant
232
- })}
233
- @click="${() => this.requestClose("close-button")}"
234
- aria-label="close modal"
235
- ></button>
228
+ ${this.noCloseButton
229
+ ? lit.nothing
230
+ : lit.html `<button
231
+ class=${classMap_js.classMap({
232
+ "modal-close": true,
233
+ "btn-sm": true,
234
+ "btn-close": true,
235
+ centered: this.centeredAlignVariant
236
+ })}
237
+ @click="${() => this.requestClose("close-button")}"
238
+ aria-label="close modal"
239
+ ></button>`}
236
240
  </div>
237
241
  `
238
242
  : ""}
@@ -295,6 +299,9 @@ tslib.__decorate([
295
299
  tslib.__decorate([
296
300
  decorators_js.property({ type: Boolean, reflect: true })
297
301
  ], SgdsModal.prototype, "noAnimation", void 0);
302
+ tslib.__decorate([
303
+ decorators_js.property({ type: Boolean, reflect: true })
304
+ ], SgdsModal.prototype, "noCloseButton", void 0);
298
305
  tslib.__decorate([
299
306
  watch.watch("open", { waitUntilFirstUpdate: true })
300
307
  ], SgdsModal.prototype, "handleOpenChange", null);
@@ -1 +1 @@
1
- {"version":3,"file":"sgds-modal.cjs.js","sources":["../../../src/components/Modal/sgds-modal.ts"],"sourcesContent":["import { html } from \"lit\";\nimport { property, query } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\nimport { unsafeSVG } from \"lit/directives/unsafe-svg.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport { animateTo, stopAnimations } from \"../../utils/animate\";\nimport { getAnimation, setDefaultAnimation } from \"../../utils/animation-registry\";\nimport { waitForEvent } from \"../../utils/event\";\nimport Modal from \"../../utils/modal\";\nimport { lockBodyScrolling, unlockBodyScrolling } from \"../../utils/scroll\";\nimport { HasSlotController } from \"../../utils/slot\";\nimport { watch } from \"../../utils/watch\";\nimport styles from \"./sgds-modal.scss\";\n\n/**\n * @summary The modal component inform users about a specific task and may contain critical information which users then have to make a decision.\n *\n * @slot default - The content of the Modal's body.\n * @slot footer - The content of the Modal's footer, typically used to pass in buttons for call to action.\n *\n * @event sgds-close - Emitted when the modal is called to close via mouseclick of close button, overlay or via keyboard esc key\n * @event sgds-show - Emitted when the modal opens\n * @event sgds-hide - Emitted when the modal closes\n * @event sgds-after-show - Emitted after modal opens and the animations has completed\n * @event sgds-after-hide - Emitted after modal closes and the animations has completed\n *\n * @csspart base - The component's base wrapper\n * @csspart overlay - The overlay that covers the screen behind the dialog\n * @csspart panel - The modal's dialog panel\n * @csspart header - The modal's header that wraps the title, titleIcon and close button\n * @csspart title - The h3 element wrapping title and titleIcon\n * @csspart body - The modal's body where the content lies\n * @csspart footers - The modal's footer\n *\n * @cssproperty --modal-padding - The general modal padding of modal component. Applied to body, footer and header.\n * @cssproperty --modal-panel-z-index - The z-index of modal panel\n * @cssproperty --modal-panel-width - The width of modal panel.\n * @cssproperty --modal-panel-height - The height of modal panel.\n * @cssproperty --modal-panel-background-color - The background color of modal panel\n * @cssproperty --modal-panel-border-radius - The border radius of modal panel\n * @cssproperty --modal-header-bottom-border-line-width - The line width of header's bottom border\n * @cssproperty --modal-overlay-background-color - The overlay's background color\n */\nexport class SgdsModal extends SgdsElement {\n static styles = [SgdsElement.styles, styles];\n\n /**@internal */\n @query(\".modal\") dialog: HTMLElement;\n /**@internal */\n @query(\".modal-panel\") panel: HTMLElement;\n /**@internal */\n @query(\".modal-overlay\") overlay: HTMLElement;\n /**@internal */\n @query(\".modal-title\") heading: HTMLElement;\n /**@internal */\n private readonly hasSlotController = new HasSlotController(this, \"footer\");\n /**@internal */\n private modal: Modal;\n /**@internal */\n private originalTrigger: HTMLElement | null;\n\n /**Indicates whether or not the modal is open. You can use this in lieu of the show/hide methods. */\n @property({ type: Boolean, reflect: true }) open = false;\n // @property({ type: Boolean, reflect: true }) centeredAlignVariant = false;\n /**The modal's title as displayed in the header */\n @property({ reflect: true }) title = \"\";\n /**The modal's icon as displayed in the header. Pass in SVG format icons as string directly */\n @property({ reflect: true }) titleIcon = \"\";\n /** Disables the header. This will also remove the default close button */\n @property({ type: Boolean, reflect: true }) noHeader = false;\n /** Centers the modal vertically in page */\n @property({ type: Boolean, reflect: true }) centered = false;\n /** Centers the contents inside the modal */\n @property({ type: Boolean, reflect: true }) centeredAlignVariant = false;\n /** Removes the default animation when opening and closing of modal */\n @property({ type: Boolean, reflect: true }) noAnimation = false;\n\n connectedCallback() {\n super.connectedCallback();\n this.handleDocumentKeyDown = this.handleDocumentKeyDown.bind(this);\n this.modal = new Modal(this);\n }\n\n firstUpdated() {\n this.dialog.hidden = !this.open;\n\n if (this.open) {\n this.addOpenListeners();\n this.modal.activate();\n lockBodyScrolling(this);\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n unlockBodyScrolling(this);\n }\n\n /** Shows the dialog. */\n public async show() {\n if (this.open) {\n return undefined;\n }\n\n this.open = true;\n return waitForEvent(this, \"sgds-after-show\");\n }\n\n /** Hides the dialog */\n public async hide() {\n if (!this.open) {\n return undefined;\n }\n\n this.open = false;\n return waitForEvent(this, \"sgds-after-hide\");\n }\n\n private requestClose(source: \"close-button\" | \"keyboard\" | \"overlay\") {\n const sgdsRequestClose = this.emit(\"sgds-close\", {\n cancelable: true,\n detail: { source }\n });\n\n if (sgdsRequestClose.defaultPrevented) {\n const animation = getAnimation(this, \"modal.denyClose\");\n animateTo(this.panel, animation.keyframes);\n return;\n }\n\n this.hide();\n }\n\n addOpenListeners() {\n document.addEventListener(\"keydown\", this.handleDocumentKeyDown);\n }\n\n removeOpenListeners() {\n document.removeEventListener(\"keydown\", this.handleDocumentKeyDown);\n }\n\n handleDocumentKeyDown(event: KeyboardEvent) {\n if (this.open && event.key === \"Escape\") {\n event.stopPropagation();\n this.requestClose(\"keyboard\");\n }\n }\n\n @watch(\"open\", { waitUntilFirstUpdate: true })\n async handleOpenChange() {\n if (this.open) {\n // Show\n this.emit(\"sgds-show\");\n this.addOpenListeners();\n this.originalTrigger = document.activeElement as HTMLElement;\n this.modal.activate();\n\n lockBodyScrolling(this);\n\n await Promise.all([stopAnimations(this.dialog), stopAnimations(this.overlay)]);\n this.dialog.hidden = false;\n\n const panelAnimation = getAnimation(this, \"modal.show\");\n const overlayAnimation = getAnimation(this, \"modal.overlay.show\");\n !this.noAnimation &&\n (await Promise.all([\n animateTo(this.panel, panelAnimation.keyframes, panelAnimation.options),\n animateTo(this.overlay, overlayAnimation.keyframes, overlayAnimation.options)\n ]));\n\n this.emit(\"sgds-after-show\");\n\n // Add focus on modal heading after opening it\n this.heading.focus();\n } else {\n // Hide\n this.emit(\"sgds-hide\");\n this.removeOpenListeners();\n this.modal.deactivate();\n\n await Promise.all([stopAnimations(this.dialog), stopAnimations(this.overlay)]);\n const panelAnimation = getAnimation(this, \"modal.hide\");\n const overlayAnimation = getAnimation(this, \"modal.overlay.hide\");\n\n // Animate the overlay and the panel at the same time. Because animation durations might be different, we need to\n // hide each one individually when the animation finishes, otherwise the first one that finishes will reappear\n // unexpectedly. We'll unhide them after all animations have completed.\n !this.noAnimation &&\n (await Promise.all([\n animateTo(this.overlay, overlayAnimation.keyframes, overlayAnimation.options).then(() => {\n this.overlay.hidden = true;\n }),\n animateTo(this.panel, panelAnimation.keyframes, panelAnimation.options).then(() => {\n this.panel.hidden = true;\n })\n ]));\n\n this.dialog.hidden = true;\n\n // Now that the dialog is hidden, restore the overlay and panel for next time\n this.overlay.hidden = false;\n this.panel.hidden = false;\n\n unlockBodyScrolling(this);\n\n // Restore focus to the original trigger\n const trigger = this.originalTrigger;\n if (typeof trigger?.focus === \"function\") {\n setTimeout(() => trigger.focus());\n }\n\n this.emit(\"sgds-after-hide\");\n }\n }\n\n render() {\n const withLabelIcon = html`${unsafeSVG(this.titleIcon)}`;\n return html`\n <div\n part=\"base\"\n class=${classMap({\n modal: true,\n \"modal--open\": this.open,\n \"modal--has-footer\": this.hasSlotController.test(\"footer\"),\n centered: this.centered\n })}\n >\n <div part=\"overlay\" class=\"modal-overlay\" @click=${() => this.requestClose(\"overlay\")}></div>\n\n <div\n part=\"panel\"\n class=\"modal-panel\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-hidden=${this.open ? \"false\" : \"true\"}\n aria-label=${ifDefined(this.noHeader ? this.title : undefined)}\n aria-labelledby=${ifDefined(!this.noHeader ? \"title\" : undefined)}\n tabindex=\"-1\"\n >\n ${!this.noHeader\n ? html`\n <div\n part=\"header\"\n class=${classMap({\n \"modal-header\": true,\n centered: this.centeredAlignVariant\n })}\n >\n <h3\n part=\"title\"\n class=${classMap({\n \"modal-title\": true,\n centered: this.centeredAlignVariant\n })}\n id=\"title\"\n tabindex=\"-1\"\n >\n ${this.titleIcon ? withLabelIcon : \"\"} ${this.title}\n </h3>\n <button\n class=${classMap({\n \"modal-close\": true,\n \"btn-sm\": true,\n \"btn-close\": true,\n centered: this.centeredAlignVariant\n })}\n @click=\"${() => this.requestClose(\"close-button\")}\"\n aria-label=\"close modal\"\n ></button>\n </div>\n `\n : \"\"}\n\n <div\n part=\"body\"\n class=${classMap({\n \"modal-body\": true,\n centered: this.centeredAlignVariant\n })}\n >\n <slot></slot>\n </div>\n\n <footer\n part=\"footer\"\n class=${classMap({\n \"modal-footer\": true,\n centered: this.centeredAlignVariant\n })}\n >\n <slot name=\"footer\"></slot>\n </footer>\n </div>\n </div>\n `;\n }\n}\n\nsetDefaultAnimation(\"modal.show\", {\n keyframes: [\n { opacity: 0, transform: \"scale(1) translate(0, -100%)\" },\n { opacity: 1, transform: \"scale(1) translate(0, 0%)\" }\n ],\n options: { duration: 400, easing: \"ease\" }\n});\n\nsetDefaultAnimation(\"modal.hide\", {\n keyframes: [\n { opacity: 1, transform: \"scale(1) translate(0, 0)\" },\n { opacity: 0, transform: \"scale(1) translate(0, -100%)\" }\n ],\n options: { duration: 400, easing: \"ease\" }\n});\n\nsetDefaultAnimation(\"modal.denyClose\", {\n keyframes: [{ transform: \"scale(1)\" }, { transform: \"scale(1.02)\" }, { transform: \"scale(1)\" }],\n options: { duration: 400 }\n});\n\nsetDefaultAnimation(\"modal.overlay.show\", {\n keyframes: [{ opacity: 0 }, { opacity: 1 }],\n options: { duration: 400 }\n});\n\nsetDefaultAnimation(\"modal.overlay.hide\", {\n keyframes: [{ opacity: 1 }, { opacity: 0 }],\n options: { duration: 400 }\n});\n\nexport default SgdsModal;\n"],"names":["SgdsElement","HasSlotController","Modal","lockBodyScrolling","unlockBodyScrolling","waitForEvent","getAnimation","animateTo","stopAnimations","html","unsafeSVG","classMap","ifDefined","styles","__decorate","query","property","watch","setDefaultAnimation"],"mappings":";;;;;;;;;;;;;;;;;;;;AAeA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BG;AACG,MAAO,SAAU,SAAQA,sBAAW,CAAA;AAA1C,IAAA,WAAA,GAAA;;;QAYmB,IAAiB,CAAA,iBAAA,GAAG,IAAIC,sBAAiB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;;QAO/B,IAAI,CAAA,IAAA,GAAG,KAAK,CAAC;;;QAG5B,IAAK,CAAA,KAAA,GAAG,EAAE,CAAC;;QAEX,IAAS,CAAA,SAAA,GAAG,EAAE,CAAC;;QAEA,IAAQ,CAAA,QAAA,GAAG,KAAK,CAAC;;QAEjB,IAAQ,CAAA,QAAA,GAAG,KAAK,CAAC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IACD,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE;AAC3C,CAAA,CAAC,CAAC;AAEHA,qCAAmB,CAAC,YAAY,EAAE;AAChC,IAAA,SAAS,EAAE;AACT,QAAA,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,0BAA0B,EAAE;AACrD,QAAA,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,8BAA8B,EAAE;AAC1D,KAAA;IACD,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE;AAC3C,CAAA,CAAC,CAAC;AAEHA,qCAAmB,CAAC,iBAAiB,EAAE;AACrC,IAAA,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,EAAE,EAAE,SAAS,EAAE,aAAa,EAAE,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;AAC/F,IAAA,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE;AAC3B,CAAA,CAAC,CAAC;AAEHA,qCAAmB,CAAC,oBAAoB,EAAE;AACxC,IAAA,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;AAC3C,IAAA,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE;AAC3B,CAAA,CAAC,CAAC;AAEHA,qCAAmB,CAAC,oBAAoB,EAAE;AACxC,IAAA,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;AAC3C,IAAA,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE;AAC3B,CAAA,CAAC;;;;;"}
1
+ {"version":3,"file":"sgds-modal.cjs.js","sources":["../../../src/components/Modal/sgds-modal.ts"],"sourcesContent":["import { html, nothing } from \"lit\";\nimport { property, query } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\nimport { unsafeSVG } from \"lit/directives/unsafe-svg.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport { animateTo, stopAnimations } from \"../../utils/animate\";\nimport { getAnimation, setDefaultAnimation } from \"../../utils/animation-registry\";\nimport { waitForEvent } from \"../../utils/event\";\nimport Modal from \"../../utils/modal\";\nimport { lockBodyScrolling, unlockBodyScrolling } from \"../../utils/scroll\";\nimport { HasSlotController } from \"../../utils/slot\";\nimport { watch } from \"../../utils/watch\";\nimport styles from \"./sgds-modal.scss\";\n\n/**\n * @summary The modal component inform users about a specific task and may contain critical information which users then have to make a decision.\n *\n * @slot default - The content of the Modal's body.\n * @slot footer - The content of the Modal's footer, typically used to pass in buttons for call to action.\n *\n * @event sgds-close - Emitted when the modal is called to close via mouseclick of close button, overlay or via keyboard esc key\n * @event sgds-show - Emitted when the modal opens\n * @event sgds-hide - Emitted when the modal closes\n * @event sgds-after-show - Emitted after modal opens and the animations has completed\n * @event sgds-after-hide - Emitted after modal closes and the animations has completed\n *\n * @csspart base - The component's base wrapper\n * @csspart overlay - The overlay that covers the screen behind the dialog\n * @csspart panel - The modal's dialog panel\n * @csspart header - The modal's header that wraps the title, titleIcon and close button\n * @csspart title - The h3 element wrapping title and titleIcon\n * @csspart body - The modal's body where the content lies\n * @csspart footers - The modal's footer\n *\n * @cssproperty --modal-padding - The general modal padding of modal component. Applied to body, footer and header.\n * @cssproperty --modal-panel-z-index - The z-index of modal panel\n * @cssproperty --modal-panel-width - The width of modal panel.\n * @cssproperty --modal-panel-height - The height of modal panel.\n * @cssproperty --modal-panel-background-color - The background color of modal panel\n * @cssproperty --modal-panel-border-radius - The border radius of modal panel\n * @cssproperty --modal-header-bottom-border-line-width - The line width of header's bottom border\n * @cssproperty --modal-overlay-background-color - The overlay's background color\n */\nexport class SgdsModal extends SgdsElement {\n static styles = [SgdsElement.styles, styles];\n\n /**@internal */\n @query(\".modal\") dialog: HTMLElement;\n /**@internal */\n @query(\".modal-panel\") panel: HTMLElement;\n /**@internal */\n @query(\".modal-overlay\") overlay: HTMLElement;\n /**@internal */\n @query(\".modal-title\") heading: HTMLElement;\n /**@internal */\n private readonly hasSlotController = new HasSlotController(this, \"footer\");\n /**@internal */\n private modal: Modal;\n /**@internal */\n private originalTrigger: HTMLElement | null;\n\n /**Indicates whether or not the modal is open. You can use this in lieu of the show/hide methods. */\n @property({ type: Boolean, reflect: true }) open = false;\n // @property({ type: Boolean, reflect: true }) centeredAlignVariant = false;\n /**The modal's title as displayed in the header */\n @property({ reflect: true }) title = \"\";\n /**The modal's icon as displayed in the header. Pass in SVG format icons as string directly */\n @property({ reflect: true }) titleIcon = \"\";\n /** Disables the header. This will also remove the default close button */\n @property({ type: Boolean, reflect: true }) noHeader = false;\n /** Centers the modal vertically in page */\n @property({ type: Boolean, reflect: true }) centered = false;\n /** Centers the contents inside the modal */\n @property({ type: Boolean, reflect: true }) centeredAlignVariant = false;\n /** Removes the default animation when opening and closing of modal */\n @property({ type: Boolean, reflect: true }) noAnimation = false;\n /** Removes the close button from modal header */\n @property({ type: Boolean, reflect: true }) noCloseButton = false;\n\n connectedCallback() {\n super.connectedCallback();\n this.handleDocumentKeyDown = this.handleDocumentKeyDown.bind(this);\n this.modal = new Modal(this);\n }\n\n firstUpdated() {\n this.dialog.hidden = !this.open;\n\n if (this.open) {\n this.addOpenListeners();\n this.modal.activate();\n lockBodyScrolling(this);\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n unlockBodyScrolling(this);\n }\n\n /** Shows the dialog. */\n public async show() {\n if (this.open) {\n return undefined;\n }\n\n this.open = true;\n return waitForEvent(this, \"sgds-after-show\");\n }\n\n /** Hides the dialog */\n public async hide() {\n if (!this.open) {\n return undefined;\n }\n\n this.open = false;\n return waitForEvent(this, \"sgds-after-hide\");\n }\n\n private requestClose(source: \"close-button\" | \"keyboard\" | \"overlay\") {\n const sgdsRequestClose = this.emit(\"sgds-close\", {\n cancelable: true,\n detail: { source }\n });\n\n if (sgdsRequestClose.defaultPrevented) {\n const animation = getAnimation(this, \"modal.denyClose\");\n animateTo(this.panel, animation.keyframes);\n return;\n }\n\n this.hide();\n }\n\n addOpenListeners() {\n document.addEventListener(\"keydown\", this.handleDocumentKeyDown);\n }\n\n removeOpenListeners() {\n document.removeEventListener(\"keydown\", this.handleDocumentKeyDown);\n }\n\n handleDocumentKeyDown(event: KeyboardEvent) {\n if (this.open && event.key === \"Escape\") {\n event.stopPropagation();\n this.requestClose(\"keyboard\");\n }\n }\n\n @watch(\"open\", { waitUntilFirstUpdate: true })\n async handleOpenChange() {\n if (this.open) {\n // Show\n this.emit(\"sgds-show\");\n this.addOpenListeners();\n this.originalTrigger = document.activeElement as HTMLElement;\n this.modal.activate();\n\n lockBodyScrolling(this);\n\n await Promise.all([stopAnimations(this.dialog), stopAnimations(this.overlay)]);\n this.dialog.hidden = false;\n\n const panelAnimation = getAnimation(this, \"modal.show\");\n const overlayAnimation = getAnimation(this, \"modal.overlay.show\");\n !this.noAnimation &&\n (await Promise.all([\n animateTo(this.panel, panelAnimation.keyframes, panelAnimation.options),\n animateTo(this.overlay, overlayAnimation.keyframes, overlayAnimation.options)\n ]));\n\n this.emit(\"sgds-after-show\");\n\n // Add focus on modal heading after opening it\n this.heading.focus();\n } else {\n // Hide\n this.emit(\"sgds-hide\");\n this.removeOpenListeners();\n this.modal.deactivate();\n\n await Promise.all([stopAnimations(this.dialog), stopAnimations(this.overlay)]);\n const panelAnimation = getAnimation(this, \"modal.hide\");\n const overlayAnimation = getAnimation(this, \"modal.overlay.hide\");\n\n // Animate the overlay and the panel at the same time. Because animation durations might be different, we need to\n // hide each one individually when the animation finishes, otherwise the first one that finishes will reappear\n // unexpectedly. We'll unhide them after all animations have completed.\n !this.noAnimation &&\n (await Promise.all([\n animateTo(this.overlay, overlayAnimation.keyframes, overlayAnimation.options).then(() => {\n this.overlay.hidden = true;\n }),\n animateTo(this.panel, panelAnimation.keyframes, panelAnimation.options).then(() => {\n this.panel.hidden = true;\n })\n ]));\n\n this.dialog.hidden = true;\n\n // Now that the dialog is hidden, restore the overlay and panel for next time\n this.overlay.hidden = false;\n this.panel.hidden = false;\n\n unlockBodyScrolling(this);\n\n // Restore focus to the original trigger\n const trigger = this.originalTrigger;\n if (typeof trigger?.focus === \"function\") {\n setTimeout(() => trigger.focus());\n }\n\n this.emit(\"sgds-after-hide\");\n }\n }\n\n render() {\n const withLabelIcon = html`${unsafeSVG(this.titleIcon)}`;\n return html`\n <div\n part=\"base\"\n class=${classMap({\n modal: true,\n \"modal--open\": this.open,\n \"modal--has-footer\": this.hasSlotController.test(\"footer\"),\n centered: this.centered\n })}\n >\n <div part=\"overlay\" class=\"modal-overlay\" @click=${() => this.requestClose(\"overlay\")}></div>\n\n <div\n part=\"panel\"\n class=\"modal-panel\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-hidden=${this.open ? \"false\" : \"true\"}\n aria-label=${ifDefined(this.noHeader ? this.title : undefined)}\n aria-labelledby=${ifDefined(!this.noHeader ? \"title\" : undefined)}\n tabindex=\"-1\"\n >\n ${!this.noHeader\n ? html`\n <div\n part=\"header\"\n class=${classMap({\n \"modal-header\": true,\n centered: this.centeredAlignVariant\n })}\n >\n <h3\n part=\"title\"\n class=${classMap({\n \"modal-title\": true,\n centered: this.centeredAlignVariant\n })}\n id=\"title\"\n tabindex=\"-1\"\n >\n ${this.titleIcon ? withLabelIcon : \"\"} ${this.title}\n </h3>\n ${this.noCloseButton\n ? nothing\n : html`<button\n class=${classMap({\n \"modal-close\": true,\n \"btn-sm\": true,\n \"btn-close\": true,\n centered: this.centeredAlignVariant\n })}\n @click=\"${() => this.requestClose(\"close-button\")}\"\n aria-label=\"close modal\"\n ></button>`}\n </div>\n `\n : \"\"}\n\n <div\n part=\"body\"\n class=${classMap({\n \"modal-body\": true,\n centered: this.centeredAlignVariant\n })}\n >\n <slot></slot>\n </div>\n\n <footer\n part=\"footer\"\n class=${classMap({\n \"modal-footer\": true,\n centered: this.centeredAlignVariant\n })}\n >\n <slot name=\"footer\"></slot>\n </footer>\n </div>\n </div>\n `;\n }\n}\n\nsetDefaultAnimation(\"modal.show\", {\n keyframes: [\n { opacity: 0, transform: \"scale(1) translate(0, -100%)\" },\n { opacity: 1, transform: \"scale(1) translate(0, 0%)\" }\n ],\n options: { duration: 400, easing: \"ease\" }\n});\n\nsetDefaultAnimation(\"modal.hide\", {\n keyframes: [\n { opacity: 1, transform: \"scale(1) translate(0, 0)\" },\n { opacity: 0, transform: \"scale(1) translate(0, -100%)\" }\n ],\n options: { duration: 400, easing: \"ease\" }\n});\n\nsetDefaultAnimation(\"modal.denyClose\", {\n keyframes: [{ transform: \"scale(1)\" }, { transform: \"scale(1.02)\" }, { transform: \"scale(1)\" }],\n options: { duration: 400 }\n});\n\nsetDefaultAnimation(\"modal.overlay.show\", {\n keyframes: [{ opacity: 0 }, { opacity: 1 }],\n options: { duration: 400 }\n});\n\nsetDefaultAnimation(\"modal.overlay.hide\", {\n keyframes: [{ opacity: 1 }, { opacity: 0 }],\n options: { duration: 400 }\n});\n\nexport default SgdsModal;\n"],"names":["SgdsElement","HasSlotController","Modal","lockBodyScrolling","unlockBodyScrolling","waitForEvent","getAnimation","animateTo","stopAnimations","html","unsafeSVG","classMap","ifDefined","nothing","styles","__decorate","query","property","watch","setDefaultAnimation"],"mappings":";;;;;;;;;;;;;;;;;;;;AAeA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BG;AACG,MAAO,SAAU,SAAQA,sBAAW,CAAA;AAA1C,IAAA,WAAA,GAAA;;;QAYmB,IAAiB,CAAA,iBAAA,GAAG,IAAIC,sBAAiB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;;QAO/B,IAAI,CAAA,IAAA,GAAG,KAAK,CAAC;;;QAG5B,IAAK,CAAA,KAAA,GAAG,EAAE,CAAC;;QAEX,IAAS,CAAA,SAAA,GAAG,EAAE,CAAC;;QAEA,IAAQ,CAAA,QAAA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,EAAE,GAAG,EAAE;AAC3B,CAAA,CAAC,CAAC;AAEHA,qCAAmB,CAAC,oBAAoB,EAAE;AACxC,IAAA,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;AAC3C,IAAA,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE;AAC3B,CAAA,CAAC;;;;;"}
@@ -58,6 +58,8 @@ export declare class SgdsModal extends SgdsElement {
58
58
  centeredAlignVariant: boolean;
59
59
  /** Removes the default animation when opening and closing of modal */
60
60
  noAnimation: boolean;
61
+ /** Removes the close button from modal header */
62
+ noCloseButton: boolean;
61
63
  connectedCallback(): void;
62
64
  firstUpdated(): void;
63
65
  disconnectedCallback(): void;
@@ -1,5 +1,5 @@
1
1
  import { __decorate } from 'tslib';
2
- import { html } from 'lit';
2
+ import { html, nothing } from 'lit';
3
3
  import { query, property } from 'lit/decorators.js';
4
4
  import { classMap } from 'lit/directives/class-map.js';
5
5
  import { ifDefined } from 'lit/directives/if-defined.js';
@@ -63,6 +63,8 @@ class SgdsModal extends SgdsElement {
63
63
  this.centeredAlignVariant = false;
64
64
  /** Removes the default animation when opening and closing of modal */
65
65
  this.noAnimation = false;
66
+ /** Removes the close button from modal header */
67
+ this.noCloseButton = false;
66
68
  }
67
69
  connectedCallback() {
68
70
  super.connectedCallback();
@@ -219,16 +221,18 @@ class SgdsModal extends SgdsElement {
219
221
  >
220
222
  ${this.titleIcon ? withLabelIcon : ""} ${this.title}
221
223
  </h3>
222
- <button
223
- class=${classMap({
224
- "modal-close": true,
225
- "btn-sm": true,
226
- "btn-close": true,
227
- centered: this.centeredAlignVariant
228
- })}
229
- @click="${() => this.requestClose("close-button")}"
230
- aria-label="close modal"
231
- ></button>
224
+ ${this.noCloseButton
225
+ ? nothing
226
+ : html `<button
227
+ class=${classMap({
228
+ "modal-close": true,
229
+ "btn-sm": true,
230
+ "btn-close": true,
231
+ centered: this.centeredAlignVariant
232
+ })}
233
+ @click="${() => this.requestClose("close-button")}"
234
+ aria-label="close modal"
235
+ ></button>`}
232
236
  </div>
233
237
  `
234
238
  : ""}
@@ -291,6 +295,9 @@ __decorate([
291
295
  __decorate([
292
296
  property({ type: Boolean, reflect: true })
293
297
  ], SgdsModal.prototype, "noAnimation", void 0);
298
+ __decorate([
299
+ property({ type: Boolean, reflect: true })
300
+ ], SgdsModal.prototype, "noCloseButton", void 0);
294
301
  __decorate([
295
302
  watch("open", { waitUntilFirstUpdate: true })
296
303
  ], SgdsModal.prototype, "handleOpenChange", null);
@@ -1 +1 @@
1
- {"version":3,"file":"sgds-modal.js","sources":["../../../src/components/Modal/sgds-modal.ts"],"sourcesContent":["import { html } from \"lit\";\nimport { property, query } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\nimport { unsafeSVG } from \"lit/directives/unsafe-svg.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport { animateTo, stopAnimations } from \"../../utils/animate\";\nimport { getAnimation, setDefaultAnimation } from \"../../utils/animation-registry\";\nimport { waitForEvent } from \"../../utils/event\";\nimport Modal from \"../../utils/modal\";\nimport { lockBodyScrolling, unlockBodyScrolling } from \"../../utils/scroll\";\nimport { HasSlotController } from \"../../utils/slot\";\nimport { watch } from \"../../utils/watch\";\nimport styles from \"./sgds-modal.scss\";\n\n/**\n * @summary The modal component inform users about a specific task and may contain critical information which users then have to make a decision.\n *\n * @slot default - The content of the Modal's body.\n * @slot footer - The content of the Modal's footer, typically used to pass in buttons for call to action.\n *\n * @event sgds-close - Emitted when the modal is called to close via mouseclick of close button, overlay or via keyboard esc key\n * @event sgds-show - Emitted when the modal opens\n * @event sgds-hide - Emitted when the modal closes\n * @event sgds-after-show - Emitted after modal opens and the animations has completed\n * @event sgds-after-hide - Emitted after modal closes and the animations has completed\n *\n * @csspart base - The component's base wrapper\n * @csspart overlay - The overlay that covers the screen behind the dialog\n * @csspart panel - The modal's dialog panel\n * @csspart header - The modal's header that wraps the title, titleIcon and close button\n * @csspart title - The h3 element wrapping title and titleIcon\n * @csspart body - The modal's body where the content lies\n * @csspart footers - The modal's footer\n *\n * @cssproperty --modal-padding - The general modal padding of modal component. Applied to body, footer and header.\n * @cssproperty --modal-panel-z-index - The z-index of modal panel\n * @cssproperty --modal-panel-width - The width of modal panel.\n * @cssproperty --modal-panel-height - The height of modal panel.\n * @cssproperty --modal-panel-background-color - The background color of modal panel\n * @cssproperty --modal-panel-border-radius - The border radius of modal panel\n * @cssproperty --modal-header-bottom-border-line-width - The line width of header's bottom border\n * @cssproperty --modal-overlay-background-color - The overlay's background color\n */\nexport class SgdsModal extends SgdsElement {\n static styles = [SgdsElement.styles, styles];\n\n /**@internal */\n @query(\".modal\") dialog: HTMLElement;\n /**@internal */\n @query(\".modal-panel\") panel: HTMLElement;\n /**@internal */\n @query(\".modal-overlay\") overlay: HTMLElement;\n /**@internal */\n @query(\".modal-title\") heading: HTMLElement;\n /**@internal */\n private readonly hasSlotController = new HasSlotController(this, \"footer\");\n /**@internal */\n private modal: Modal;\n /**@internal */\n private originalTrigger: HTMLElement | null;\n\n /**Indicates whether or not the modal is open. You can use this in lieu of the show/hide methods. */\n @property({ type: Boolean, reflect: true }) open = false;\n // @property({ type: Boolean, reflect: true }) centeredAlignVariant = false;\n /**The modal's title as displayed in the header */\n @property({ reflect: true }) title = \"\";\n /**The modal's icon as displayed in the header. Pass in SVG format icons as string directly */\n @property({ reflect: true }) titleIcon = \"\";\n /** Disables the header. This will also remove the default close button */\n @property({ type: Boolean, reflect: true }) noHeader = false;\n /** Centers the modal vertically in page */\n @property({ type: Boolean, reflect: true }) centered = false;\n /** Centers the contents inside the modal */\n @property({ type: Boolean, reflect: true }) centeredAlignVariant = false;\n /** Removes the default animation when opening and closing of modal */\n @property({ type: Boolean, reflect: true }) noAnimation = false;\n\n connectedCallback() {\n super.connectedCallback();\n this.handleDocumentKeyDown = this.handleDocumentKeyDown.bind(this);\n this.modal = new Modal(this);\n }\n\n firstUpdated() {\n this.dialog.hidden = !this.open;\n\n if (this.open) {\n this.addOpenListeners();\n this.modal.activate();\n lockBodyScrolling(this);\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n unlockBodyScrolling(this);\n }\n\n /** Shows the dialog. */\n public async show() {\n if (this.open) {\n return undefined;\n }\n\n this.open = true;\n return waitForEvent(this, \"sgds-after-show\");\n }\n\n /** Hides the dialog */\n public async hide() {\n if (!this.open) {\n return undefined;\n }\n\n this.open = false;\n return waitForEvent(this, \"sgds-after-hide\");\n }\n\n private requestClose(source: \"close-button\" | \"keyboard\" | \"overlay\") {\n const sgdsRequestClose = this.emit(\"sgds-close\", {\n cancelable: true,\n detail: { source }\n });\n\n if (sgdsRequestClose.defaultPrevented) {\n const animation = getAnimation(this, \"modal.denyClose\");\n animateTo(this.panel, animation.keyframes);\n return;\n }\n\n this.hide();\n }\n\n addOpenListeners() {\n document.addEventListener(\"keydown\", this.handleDocumentKeyDown);\n }\n\n removeOpenListeners() {\n document.removeEventListener(\"keydown\", this.handleDocumentKeyDown);\n }\n\n handleDocumentKeyDown(event: KeyboardEvent) {\n if (this.open && event.key === \"Escape\") {\n event.stopPropagation();\n this.requestClose(\"keyboard\");\n }\n }\n\n @watch(\"open\", { waitUntilFirstUpdate: true })\n async handleOpenChange() {\n if (this.open) {\n // Show\n this.emit(\"sgds-show\");\n this.addOpenListeners();\n this.originalTrigger = document.activeElement as HTMLElement;\n this.modal.activate();\n\n lockBodyScrolling(this);\n\n await Promise.all([stopAnimations(this.dialog), stopAnimations(this.overlay)]);\n this.dialog.hidden = false;\n\n const panelAnimation = getAnimation(this, \"modal.show\");\n const overlayAnimation = getAnimation(this, \"modal.overlay.show\");\n !this.noAnimation &&\n (await Promise.all([\n animateTo(this.panel, panelAnimation.keyframes, panelAnimation.options),\n animateTo(this.overlay, overlayAnimation.keyframes, overlayAnimation.options)\n ]));\n\n this.emit(\"sgds-after-show\");\n\n // Add focus on modal heading after opening it\n this.heading.focus();\n } else {\n // Hide\n this.emit(\"sgds-hide\");\n this.removeOpenListeners();\n this.modal.deactivate();\n\n await Promise.all([stopAnimations(this.dialog), stopAnimations(this.overlay)]);\n const panelAnimation = getAnimation(this, \"modal.hide\");\n const overlayAnimation = getAnimation(this, \"modal.overlay.hide\");\n\n // Animate the overlay and the panel at the same time. Because animation durations might be different, we need to\n // hide each one individually when the animation finishes, otherwise the first one that finishes will reappear\n // unexpectedly. We'll unhide them after all animations have completed.\n !this.noAnimation &&\n (await Promise.all([\n animateTo(this.overlay, overlayAnimation.keyframes, overlayAnimation.options).then(() => {\n this.overlay.hidden = true;\n }),\n animateTo(this.panel, panelAnimation.keyframes, panelAnimation.options).then(() => {\n this.panel.hidden = true;\n })\n ]));\n\n this.dialog.hidden = true;\n\n // Now that the dialog is hidden, restore the overlay and panel for next time\n this.overlay.hidden = false;\n this.panel.hidden = false;\n\n unlockBodyScrolling(this);\n\n // Restore focus to the original trigger\n const trigger = this.originalTrigger;\n if (typeof trigger?.focus === \"function\") {\n setTimeout(() => trigger.focus());\n }\n\n this.emit(\"sgds-after-hide\");\n }\n }\n\n render() {\n const withLabelIcon = html`${unsafeSVG(this.titleIcon)}`;\n return html`\n <div\n part=\"base\"\n class=${classMap({\n modal: true,\n \"modal--open\": this.open,\n \"modal--has-footer\": this.hasSlotController.test(\"footer\"),\n centered: this.centered\n })}\n >\n <div part=\"overlay\" class=\"modal-overlay\" @click=${() => this.requestClose(\"overlay\")}></div>\n\n <div\n part=\"panel\"\n class=\"modal-panel\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-hidden=${this.open ? \"false\" : \"true\"}\n aria-label=${ifDefined(this.noHeader ? this.title : undefined)}\n aria-labelledby=${ifDefined(!this.noHeader ? \"title\" : undefined)}\n tabindex=\"-1\"\n >\n ${!this.noHeader\n ? html`\n <div\n part=\"header\"\n class=${classMap({\n \"modal-header\": true,\n centered: this.centeredAlignVariant\n })}\n >\n <h3\n part=\"title\"\n class=${classMap({\n \"modal-title\": true,\n centered: this.centeredAlignVariant\n })}\n id=\"title\"\n tabindex=\"-1\"\n >\n ${this.titleIcon ? withLabelIcon : \"\"} ${this.title}\n </h3>\n <button\n class=${classMap({\n \"modal-close\": true,\n \"btn-sm\": true,\n \"btn-close\": true,\n centered: this.centeredAlignVariant\n })}\n @click=\"${() => this.requestClose(\"close-button\")}\"\n aria-label=\"close modal\"\n ></button>\n </div>\n `\n : \"\"}\n\n <div\n part=\"body\"\n class=${classMap({\n \"modal-body\": true,\n centered: this.centeredAlignVariant\n })}\n >\n <slot></slot>\n </div>\n\n <footer\n part=\"footer\"\n class=${classMap({\n \"modal-footer\": true,\n centered: this.centeredAlignVariant\n })}\n >\n <slot name=\"footer\"></slot>\n </footer>\n </div>\n </div>\n `;\n }\n}\n\nsetDefaultAnimation(\"modal.show\", {\n keyframes: [\n { opacity: 0, transform: \"scale(1) translate(0, -100%)\" },\n { opacity: 1, transform: \"scale(1) translate(0, 0%)\" }\n ],\n options: { duration: 400, easing: \"ease\" }\n});\n\nsetDefaultAnimation(\"modal.hide\", {\n keyframes: [\n { opacity: 1, transform: \"scale(1) translate(0, 0)\" },\n { opacity: 0, transform: \"scale(1) translate(0, -100%)\" }\n ],\n options: { duration: 400, easing: \"ease\" }\n});\n\nsetDefaultAnimation(\"modal.denyClose\", {\n keyframes: [{ transform: \"scale(1)\" }, { transform: \"scale(1.02)\" }, { transform: \"scale(1)\" }],\n options: { duration: 400 }\n});\n\nsetDefaultAnimation(\"modal.overlay.show\", {\n keyframes: [{ opacity: 0 }, { opacity: 1 }],\n options: { duration: 400 }\n});\n\nsetDefaultAnimation(\"modal.overlay.hide\", {\n keyframes: [{ opacity: 1 }, { opacity: 0 }],\n options: { duration: 400 }\n});\n\nexport default SgdsModal;\n"],"names":["styles"],"mappings":";;;;;;;;;;;;;;;;AAeA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BG;AACG,MAAO,SAAU,SAAQ,WAAW,C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AAA,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE;AAC3B,CAAA,CAAC;;;;"}
1
+ {"version":3,"file":"sgds-modal.js","sources":["../../../src/components/Modal/sgds-modal.ts"],"sourcesContent":["import { html, nothing } from \"lit\";\nimport { property, query } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\nimport { unsafeSVG } from \"lit/directives/unsafe-svg.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport { animateTo, stopAnimations } from \"../../utils/animate\";\nimport { getAnimation, setDefaultAnimation } from \"../../utils/animation-registry\";\nimport { waitForEvent } from \"../../utils/event\";\nimport Modal from \"../../utils/modal\";\nimport { lockBodyScrolling, unlockBodyScrolling } from \"../../utils/scroll\";\nimport { HasSlotController } from \"../../utils/slot\";\nimport { watch } from \"../../utils/watch\";\nimport styles from \"./sgds-modal.scss\";\n\n/**\n * @summary The modal component inform users about a specific task and may contain critical information which users then have to make a decision.\n *\n * @slot default - The content of the Modal's body.\n * @slot footer - The content of the Modal's footer, typically used to pass in buttons for call to action.\n *\n * @event sgds-close - Emitted when the modal is called to close via mouseclick of close button, overlay or via keyboard esc key\n * @event sgds-show - Emitted when the modal opens\n * @event sgds-hide - Emitted when the modal closes\n * @event sgds-after-show - Emitted after modal opens and the animations has completed\n * @event sgds-after-hide - Emitted after modal closes and the animations has completed\n *\n * @csspart base - The component's base wrapper\n * @csspart overlay - The overlay that covers the screen behind the dialog\n * @csspart panel - The modal's dialog panel\n * @csspart header - The modal's header that wraps the title, titleIcon and close button\n * @csspart title - The h3 element wrapping title and titleIcon\n * @csspart body - The modal's body where the content lies\n * @csspart footers - The modal's footer\n *\n * @cssproperty --modal-padding - The general modal padding of modal component. Applied to body, footer and header.\n * @cssproperty --modal-panel-z-index - The z-index of modal panel\n * @cssproperty --modal-panel-width - The width of modal panel.\n * @cssproperty --modal-panel-height - The height of modal panel.\n * @cssproperty --modal-panel-background-color - The background color of modal panel\n * @cssproperty --modal-panel-border-radius - The border radius of modal panel\n * @cssproperty --modal-header-bottom-border-line-width - The line width of header's bottom border\n * @cssproperty --modal-overlay-background-color - The overlay's background color\n */\nexport class SgdsModal extends SgdsElement {\n static styles = [SgdsElement.styles, styles];\n\n /**@internal */\n @query(\".modal\") dialog: HTMLElement;\n /**@internal */\n @query(\".modal-panel\") panel: HTMLElement;\n /**@internal */\n @query(\".modal-overlay\") overlay: HTMLElement;\n /**@internal */\n @query(\".modal-title\") heading: HTMLElement;\n /**@internal */\n private readonly hasSlotController = new HasSlotController(this, \"footer\");\n /**@internal */\n private modal: Modal;\n /**@internal */\n private originalTrigger: HTMLElement | null;\n\n /**Indicates whether or not the modal is open. You can use this in lieu of the show/hide methods. */\n @property({ type: Boolean, reflect: true }) open = false;\n // @property({ type: Boolean, reflect: true }) centeredAlignVariant = false;\n /**The modal's title as displayed in the header */\n @property({ reflect: true }) title = \"\";\n /**The modal's icon as displayed in the header. Pass in SVG format icons as string directly */\n @property({ reflect: true }) titleIcon = \"\";\n /** Disables the header. This will also remove the default close button */\n @property({ type: Boolean, reflect: true }) noHeader = false;\n /** Centers the modal vertically in page */\n @property({ type: Boolean, reflect: true }) centered = false;\n /** Centers the contents inside the modal */\n @property({ type: Boolean, reflect: true }) centeredAlignVariant = false;\n /** Removes the default animation when opening and closing of modal */\n @property({ type: Boolean, reflect: true }) noAnimation = false;\n /** Removes the close button from modal header */\n @property({ type: Boolean, reflect: true }) noCloseButton = false;\n\n connectedCallback() {\n super.connectedCallback();\n this.handleDocumentKeyDown = this.handleDocumentKeyDown.bind(this);\n this.modal = new Modal(this);\n }\n\n firstUpdated() {\n this.dialog.hidden = !this.open;\n\n if (this.open) {\n this.addOpenListeners();\n this.modal.activate();\n lockBodyScrolling(this);\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n unlockBodyScrolling(this);\n }\n\n /** Shows the dialog. */\n public async show() {\n if (this.open) {\n return undefined;\n }\n\n this.open = true;\n return waitForEvent(this, \"sgds-after-show\");\n }\n\n /** Hides the dialog */\n public async hide() {\n if (!this.open) {\n return undefined;\n }\n\n this.open = false;\n return waitForEvent(this, \"sgds-after-hide\");\n }\n\n private requestClose(source: \"close-button\" | \"keyboard\" | \"overlay\") {\n const sgdsRequestClose = this.emit(\"sgds-close\", {\n cancelable: true,\n detail: { source }\n });\n\n if (sgdsRequestClose.defaultPrevented) {\n const animation = getAnimation(this, \"modal.denyClose\");\n animateTo(this.panel, animation.keyframes);\n return;\n }\n\n this.hide();\n }\n\n addOpenListeners() {\n document.addEventListener(\"keydown\", this.handleDocumentKeyDown);\n }\n\n removeOpenListeners() {\n document.removeEventListener(\"keydown\", this.handleDocumentKeyDown);\n }\n\n handleDocumentKeyDown(event: KeyboardEvent) {\n if (this.open && event.key === \"Escape\") {\n event.stopPropagation();\n this.requestClose(\"keyboard\");\n }\n }\n\n @watch(\"open\", { waitUntilFirstUpdate: true })\n async handleOpenChange() {\n if (this.open) {\n // Show\n this.emit(\"sgds-show\");\n this.addOpenListeners();\n this.originalTrigger = document.activeElement as HTMLElement;\n this.modal.activate();\n\n lockBodyScrolling(this);\n\n await Promise.all([stopAnimations(this.dialog), stopAnimations(this.overlay)]);\n this.dialog.hidden = false;\n\n const panelAnimation = getAnimation(this, \"modal.show\");\n const overlayAnimation = getAnimation(this, \"modal.overlay.show\");\n !this.noAnimation &&\n (await Promise.all([\n animateTo(this.panel, panelAnimation.keyframes, panelAnimation.options),\n animateTo(this.overlay, overlayAnimation.keyframes, overlayAnimation.options)\n ]));\n\n this.emit(\"sgds-after-show\");\n\n // Add focus on modal heading after opening it\n this.heading.focus();\n } else {\n // Hide\n this.emit(\"sgds-hide\");\n this.removeOpenListeners();\n this.modal.deactivate();\n\n await Promise.all([stopAnimations(this.dialog), stopAnimations(this.overlay)]);\n const panelAnimation = getAnimation(this, \"modal.hide\");\n const overlayAnimation = getAnimation(this, \"modal.overlay.hide\");\n\n // Animate the overlay and the panel at the same time. Because animation durations might be different, we need to\n // hide each one individually when the animation finishes, otherwise the first one that finishes will reappear\n // unexpectedly. We'll unhide them after all animations have completed.\n !this.noAnimation &&\n (await Promise.all([\n animateTo(this.overlay, overlayAnimation.keyframes, overlayAnimation.options).then(() => {\n this.overlay.hidden = true;\n }),\n animateTo(this.panel, panelAnimation.keyframes, panelAnimation.options).then(() => {\n this.panel.hidden = true;\n })\n ]));\n\n this.dialog.hidden = true;\n\n // Now that the dialog is hidden, restore the overlay and panel for next time\n this.overlay.hidden = false;\n this.panel.hidden = false;\n\n unlockBodyScrolling(this);\n\n // Restore focus to the original trigger\n const trigger = this.originalTrigger;\n if (typeof trigger?.focus === \"function\") {\n setTimeout(() => trigger.focus());\n }\n\n this.emit(\"sgds-after-hide\");\n }\n }\n\n render() {\n const withLabelIcon = html`${unsafeSVG(this.titleIcon)}`;\n return html`\n <div\n part=\"base\"\n class=${classMap({\n modal: true,\n \"modal--open\": this.open,\n \"modal--has-footer\": this.hasSlotController.test(\"footer\"),\n centered: this.centered\n })}\n >\n <div part=\"overlay\" class=\"modal-overlay\" @click=${() => this.requestClose(\"overlay\")}></div>\n\n <div\n part=\"panel\"\n class=\"modal-panel\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-hidden=${this.open ? \"false\" : \"true\"}\n aria-label=${ifDefined(this.noHeader ? this.title : undefined)}\n aria-labelledby=${ifDefined(!this.noHeader ? \"title\" : undefined)}\n tabindex=\"-1\"\n >\n ${!this.noHeader\n ? html`\n <div\n part=\"header\"\n class=${classMap({\n \"modal-header\": true,\n centered: this.centeredAlignVariant\n })}\n >\n <h3\n part=\"title\"\n class=${classMap({\n \"modal-title\": true,\n centered: this.centeredAlignVariant\n })}\n id=\"title\"\n tabindex=\"-1\"\n >\n ${this.titleIcon ? withLabelIcon : \"\"} ${this.title}\n </h3>\n ${this.noCloseButton\n ? nothing\n : html`<button\n class=${classMap({\n \"modal-close\": true,\n \"btn-sm\": true,\n \"btn-close\": true,\n centered: this.centeredAlignVariant\n })}\n @click=\"${() => this.requestClose(\"close-button\")}\"\n aria-label=\"close modal\"\n ></button>`}\n </div>\n `\n : \"\"}\n\n <div\n part=\"body\"\n class=${classMap({\n \"modal-body\": true,\n centered: this.centeredAlignVariant\n })}\n >\n <slot></slot>\n </div>\n\n <footer\n part=\"footer\"\n class=${classMap({\n \"modal-footer\": true,\n centered: this.centeredAlignVariant\n })}\n >\n <slot name=\"footer\"></slot>\n </footer>\n </div>\n </div>\n `;\n }\n}\n\nsetDefaultAnimation(\"modal.show\", {\n keyframes: [\n { opacity: 0, transform: \"scale(1) translate(0, -100%)\" },\n { opacity: 1, transform: \"scale(1) translate(0, 0%)\" }\n ],\n options: { duration: 400, easing: \"ease\" }\n});\n\nsetDefaultAnimation(\"modal.hide\", {\n keyframes: [\n { opacity: 1, transform: \"scale(1) translate(0, 0)\" },\n { opacity: 0, transform: \"scale(1) translate(0, -100%)\" }\n ],\n options: { duration: 400, easing: \"ease\" }\n});\n\nsetDefaultAnimation(\"modal.denyClose\", {\n keyframes: [{ transform: \"scale(1)\" }, { transform: \"scale(1.02)\" }, { transform: \"scale(1)\" }],\n options: { duration: 400 }\n});\n\nsetDefaultAnimation(\"modal.overlay.show\", {\n keyframes: [{ opacity: 0 }, { opacity: 1 }],\n options: { duration: 400 }\n});\n\nsetDefaultAnimation(\"modal.overlay.hide\", {\n keyframes: [{ opacity: 1 }, { opacity: 0 }],\n options: { duration: 400 }\n});\n\nexport default SgdsModal;\n"],"names":["styles"],"mappings":";;;;;;;;;;;;;;;;AAeA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BG;AACG,MAAO,SAAU,SAAQ,WAAW,CAAA;AAA1C,IAAA,WAAA,GAAA;;;QAYmB,IAAiB,CAAA,iBAAA,GAAG,IAAI,iBAAiB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;;QAO/B,IAAI,CAAA,IAAA,GAAG,KAAK,CAAC;;;QAG5B,IAAK,CAAA,KAAA,GAAG,EAAE,CAAC;;QAEX,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;AACxC,IAAA,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;AAC3C,IAAA,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE;AAC3B,CAAA,CAAC;;;;"}
@@ -3310,6 +3310,7 @@
3310
3310
 
3311
3311
  var css_248z$E = css`:host{--accordion-active-color:var(--sgds-primary)}`;
3312
3312
 
3313
+ const VALID_KEYS = ["Enter", "ArrowUp", "ArrowLeft", "ArrowDown", "ArrowRight"];
3313
3314
  /**
3314
3315
  * @summary A dropdown mechanism that allow users to either show or hide related content. `SgdsAccordion` is a wrapper to manage the behaviour for multiple `SgdsAccordionItems`
3315
3316
  * @slot default - slot for accordion-item
@@ -3344,10 +3345,8 @@
3344
3345
  }
3345
3346
  });
3346
3347
  }
3347
- async onToggle(event) {
3348
- // Let the event pass through the DOM so that it can be
3349
- // prevented from the outside if a user so desires.
3350
- if (this.allowMultiple || event.defaultPrevented) {
3348
+ async _onToggle(event) {
3349
+ if (this.allowMultiple) {
3351
3350
  // No toggling when `allowMultiple` or the user prevents it.
3352
3351
  return;
3353
3352
  }
@@ -3364,6 +3363,11 @@
3364
3363
  }
3365
3364
  });
3366
3365
  }
3366
+ async _onKeyboardToggle(event) {
3367
+ if (!VALID_KEYS.includes(event.key))
3368
+ return;
3369
+ return this._onToggle(event);
3370
+ }
3367
3371
  render() {
3368
3372
  return html$1 `
3369
3373
  <div
@@ -3372,7 +3376,7 @@
3372
3376
  [`${this.accordionClasses}`]: this.accordionClasses
3373
3377
  })}
3374
3378
  >
3375
- <slot @click=${this.onToggle}></slot>
3379
+ <slot @click=${this._onToggle} @keydown=${this._onKeyboardToggle}></slot>
3376
3380
  </div>
3377
3381
  `;
3378
3382
  }
@@ -3517,7 +3521,7 @@
3517
3521
  };
3518
3522
  }
3519
3523
 
3520
- var css_248z$D = css`:host{--accordion-item-padding-y:1rem;--accordion-item-padding-x:1.5rem;--accordion-item-border-radius:0.25rem;--accordion-item-font-weight:700;--accordion-item-line-height:2rem}.accordion-body{line-height:var(--accordion-item-line-height);overflow:hidden;padding:0}.accordion-content{display:block;padding:0 var(--accordion-item-padding-x) var(--accordion-item-padding-y)}.accordion-button{line-height:var(--accordion-item-line-height)}.accordion-button:not(.collapsed){box-shadow:none;color:var(--accordion-active-color);font-weight:var(--accordion-item-font-weight)}:host([first-of-type]) .accordion-item{border-radius:var(--accordion-item-border-radius) var(--accordion-item-border-radius) 0 0}:host([nth-of-type]) .accordion-item{border-radius:0;border-top:0}:host([last-of-type]) .accordion-item{border-radius:0 0 var(--accordion-item-border-radius) var(--accordion-item-border-radius);border-top:0}`;
3524
+ var css_248z$D = css`:host{--accordion-item-padding-y:1rem;--accordion-item-padding-x:1.5rem;--accordion-item-border-radius:0.25rem;--accordion-item-font-weight:700;--accordion-item-line-height:2rem}.accordion-body{line-height:var(--accordion-item-line-height);overflow:hidden;padding:0}.accordion-content{display:block;padding:0 var(--accordion-item-padding-x) var(--accordion-item-padding-y)}.accordion-button{line-height:var(--accordion-item-line-height)}.accordion-button:not(.collapsed){color:var(--accordion-active-color,var(--sgds-primary))}.accordion-button svg.bi-chevron-down{height:1.3rem;margin-left:auto;transition:transform .2s ease-in-out;width:1.3rem}.accordion-button:not(.collapsed){box-shadow:none;font-weight:var(--accordion-item-font-weight)}.accordion-button:not(.collapsed) svg.bi-chevron-down{transform:rotate(-180deg)}.accordion-button:after{content:unset}:host([first-of-type]) .accordion-item{border-radius:var(--accordion-item-border-radius) var(--accordion-item-border-radius) 0 0}:host([nth-of-type]) .accordion-item{border-radius:0;border-top:0}:host([last-of-type]) .accordion-item{border-radius:0 0 var(--accordion-item-border-radius) var(--accordion-item-border-radius);border-top:0}.hidden{display:none}`;
3521
3525
 
3522
3526
  /**
3523
3527
  *
@@ -3546,8 +3550,8 @@
3546
3550
  this.open = false;
3547
3551
  }
3548
3552
  firstUpdated() {
3549
- this.body.hidden = !this.open;
3550
- this.body.style.height = this.open ? "auto" : "0";
3553
+ if (!this.open)
3554
+ this.body.classList.add("hidden");
3551
3555
  }
3552
3556
  handleSummaryClick() {
3553
3557
  if (this.open) {
@@ -3586,10 +3590,9 @@
3586
3590
  return;
3587
3591
  }
3588
3592
  await stopAnimations(this.body);
3589
- this.body.hidden = false;
3593
+ this.body.classList.remove("hidden");
3590
3594
  const { keyframes, options } = getAnimation(this, "accordion.show");
3591
3595
  await animateTo(this.body, shimKeyframesHeightAuto(keyframes, this.body.scrollHeight), options);
3592
- this.body.style.height = "auto";
3593
3596
  this.emit("sgds-after-show");
3594
3597
  }
3595
3598
  else {
@@ -3601,9 +3604,13 @@
3601
3604
  }
3602
3605
  await stopAnimations(this.body);
3603
3606
  const { keyframes, options } = getAnimation(this, "accordion.hide");
3607
+ const animationDuration = options.duration;
3608
+ // Workaround to fix GSIB delay after animateTo.
3609
+ //Setting a timeout of duration slightly less than animation's duraton to prevent case where animation runs faster than .hidden class is added
3610
+ setTimeout(() => {
3611
+ this.body.classList.add("hidden");
3612
+ }, animationDuration - 20);
3604
3613
  await animateTo(this.body, shimKeyframesHeightAuto(keyframes, this.body.scrollHeight), options);
3605
- this.body.hidden = true;
3606
- this.body.style.height = "auto";
3607
3614
  this.emit("sgds-after-hide");
3608
3615
  }
3609
3616
  }
@@ -3629,7 +3636,8 @@
3629
3636
  part="base"
3630
3637
  class=${classMap({
3631
3638
  "sgds accordion-item": true,
3632
- [`${this.accordionItemClasses}`]: this.accordionItemClasses
3639
+ [`${this.accordionItemClasses}`]: this.accordionItemClasses,
3640
+ show: this.open
3633
3641
  })}
3634
3642
  >
3635
3643
  <button
@@ -3646,8 +3654,25 @@
3646
3654
  @keydown=${this.handleSummaryKeyDown}
3647
3655
  >
3648
3656
  <slot name="accordion-header"></slot>
3657
+ <svg
3658
+ xmlns="http://www.w3.org/2000/svg"
3659
+ width="16"
3660
+ height="16"
3661
+ fill="currentColor"
3662
+ class="bi bi-chevron-down"
3663
+ viewBox="0 0 16 16"
3664
+ >
3665
+ <path
3666
+ fill-rule="evenodd"
3667
+ d="M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z"
3668
+ />
3669
+ </svg>
3649
3670
  </button>
3650
- <div class="accordion-body">
3671
+ <div
3672
+ class=${classMap({
3673
+ "accordion-body": true
3674
+ })}
3675
+ >
3651
3676
  <slot name="accordion-content" class="accordion-content" role="region" aria-labelledby="header"></slot>
3652
3677
  </div>
3653
3678
  </div>
@@ -3678,14 +3703,14 @@
3678
3703
  { height: "0", opacity: "0" },
3679
3704
  { height: "auto", opacity: "1" }
3680
3705
  ],
3681
- options: { duration: 200, easing: "ease-in-out" }
3706
+ options: { duration: 350, easing: "ease-in-out" }
3682
3707
  });
3683
3708
  setDefaultAnimation("accordion.hide", {
3684
3709
  keyframes: [
3685
3710
  { height: "auto", opacity: "1" },
3686
3711
  { height: "0", opacity: "0" }
3687
3712
  ],
3688
- options: { duration: 200, easing: "ease-in-out" }
3713
+ options: { duration: 350, easing: "ease-in-out" }
3689
3714
  });
3690
3715
 
3691
3716
  const appliedClassMixins = new WeakMap();
@@ -21675,6 +21700,8 @@
21675
21700
  this.centeredAlignVariant = false;
21676
21701
  /** Removes the default animation when opening and closing of modal */
21677
21702
  this.noAnimation = false;
21703
+ /** Removes the close button from modal header */
21704
+ this.noCloseButton = false;
21678
21705
  }
21679
21706
  connectedCallback() {
21680
21707
  super.connectedCallback();
@@ -21831,16 +21858,18 @@
21831
21858
  >
21832
21859
  ${this.titleIcon ? withLabelIcon : ""} ${this.title}
21833
21860
  </h3>
21834
- <button
21835
- class=${classMap({
21836
- "modal-close": true,
21837
- "btn-sm": true,
21838
- "btn-close": true,
21839
- centered: this.centeredAlignVariant
21840
- })}
21841
- @click="${() => this.requestClose("close-button")}"
21842
- aria-label="close modal"
21843
- ></button>
21861
+ ${this.noCloseButton
21862
+ ? nothing
21863
+ : html$1 `<button
21864
+ class=${classMap({
21865
+ "modal-close": true,
21866
+ "btn-sm": true,
21867
+ "btn-close": true,
21868
+ centered: this.centeredAlignVariant
21869
+ })}
21870
+ @click="${() => this.requestClose("close-button")}"
21871
+ aria-label="close modal"
21872
+ ></button>`}
21844
21873
  </div>
21845
21874
  `
21846
21875
  : ""}
@@ -21903,6 +21932,9 @@
21903
21932
  __decorate([
21904
21933
  property({ type: Boolean, reflect: true })
21905
21934
  ], SgdsModal.prototype, "noAnimation", void 0);
21935
+ __decorate([
21936
+ property({ type: Boolean, reflect: true })
21937
+ ], SgdsModal.prototype, "noCloseButton", void 0);
21906
21938
  __decorate([
21907
21939
  watch("open", { waitUntilFirstUpdate: true })
21908
21940
  ], SgdsModal.prototype, "handleOpenChange", null);