@roadtrip/components 3.47.0 → 3.47.1

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.
@@ -48,6 +48,10 @@ export class Drawer {
48
48
  * Footer Content state
49
49
  */
50
50
  this.hasFooterContent = false;
51
+ this.onFooterSlotChange = (event) => {
52
+ const slot = event.target;
53
+ this.hasFooterContent = slot.assignedElements().length > 0;
54
+ };
51
55
  /**
52
56
  * Close the dialog when clicking on the cross or layer
53
57
  */
@@ -87,13 +91,15 @@ export class Drawer {
87
91
  * Enable/disable focus trap so it can be overrided by the client in case of something appearing over the drawer like a modal for example
88
92
  */
89
93
  handleFocusTrapProp(value) {
90
- var _a, _b;
91
- if (value) {
92
- (_a = this.focusTrap) === null || _a === void 0 ? void 0 : _a.unpause();
93
- }
94
- else {
95
- (_b = this.focusTrap) === null || _b === void 0 ? void 0 : _b.pause();
96
- }
94
+ setTimeout(() => {
95
+ var _a, _b;
96
+ if (value) {
97
+ (_a = this.focusTrap) === null || _a === void 0 ? void 0 : _a.unpause();
98
+ }
99
+ else {
100
+ (_b = this.focusTrap) === null || _b === void 0 ? void 0 : _b.pause();
101
+ }
102
+ }, 100); // Timeout is used to ensure the drawer has been rendered when client wants to update the property at the same time
97
103
  }
98
104
  // @Watch('isOpen')
99
105
  // handleOpen(openValue: boolean) {
@@ -111,9 +117,14 @@ export class Drawer {
111
117
  this.onOpen.emit();
112
118
  // Focus the first button element after the drawer is opened then focus trap
113
119
  setTimeout(() => {
114
- var _a;
120
+ var _a, _b, _c;
115
121
  this.focusFirstElement();
116
- (_a = this.focusTrap) === null || _a === void 0 ? void 0 : _a.activate();
122
+ if ((_a = this.focusTrap) === null || _a === void 0 ? void 0 : _a.active) {
123
+ (_b = this.focusTrap) === null || _b === void 0 ? void 0 : _b.unpause();
124
+ }
125
+ else {
126
+ (_c = this.focusTrap) === null || _c === void 0 ? void 0 : _c.activate();
127
+ }
117
128
  }, 50); // Add a slight delay to ensure the element is rendered
118
129
  }
119
130
  else {
@@ -164,7 +175,7 @@ export class Drawer {
164
175
  }
165
176
  }
166
177
  render() {
167
- var _a, _b, _c, _d;
178
+ var _a, _b, _c;
168
179
  const drawerIsOpenClass = this.isOpen ? 'drawer-open' : '';
169
180
  const removePaddingClass = this.removePadding ? 'remove-padding' : '';
170
181
  const inverseHeaderClass = this.hasInverseHeader ? 'drawer-header-inverse' : '';
@@ -175,9 +186,7 @@ export class Drawer {
175
186
  const backIconElement = this.hasBackIcon ? (h("button", { type: "button", class: "drawer-action", "aria-label": ariaLabelBack, onClick: this.onClickBack }, h("road-icon", { icon: navigationChevron, rotate: "180" }), this.backText)) : null;
176
187
  const closeIconElement = this.hasCloseIcon ? (h("button", { type: "button", class: "drawer-close", onClick: this.onClick, "aria-label": ariaLabelClose }, h("road-icon", { icon: navigationClose, "aria-hidden": "true" }))) : null;
177
188
  const drawerWidthValue = this.position === 'bottom' ? '100%' : `${this.drawerWidth}px`;
178
- const footerSlotElement = (_d = this.el.shadowRoot) === null || _d === void 0 ? void 0 : _d.querySelector('slot[name="footer"]');
179
- const hasFooterContent = footerSlotElement instanceof HTMLSlotElement && footerSlotElement.assignedNodes().length > 0;
180
- return (h(Host, { key: 'f204c79488e3496f2b5de75bdbaf8af4a7912306', class: `${drawerIsOpenClass} drawer-${this.position}`, tabindex: "0", role: "dialog", "aria-label": ariaLabel }, h("div", { key: 'c75f6462bd7f7451d17784b72fb94ec343fe88f9', class: "road-drawer-wrapper" }, h("div", { key: '2e5df3a95fa7344dfbe103e05714c74646f68c3c', class: "drawer-overlay", onClick: this.onClick, tabindex: "-1" }), h("div", { key: 'dfc325bb20bebcc1cb41902d5acbd28b2b662d01', class: "drawer-dialog", style: { maxWidth: drawerWidthValue }, role: "document" }, h("div", { key: 'efdf2daad76553c2b4d0df35353865abd29a170c', class: "drawer-content" }, h("header", { key: '96cefa87d0a69594d2add43cbffa6cbbd6a491d9', class: `drawer-header ${inverseHeaderClass} ${drawerDelimiterClass}` }, backIconElement, this.drawerTitle ? (h("h2", { class: "drawer-title" }, this.drawerTitle)) : (h("div", { class: "drawer-title" }, h("slot", { name: "title" }))), closeIconElement), h("div", { key: 'd5d13d447d46cd6e1df289a217aa8422e100afa7', class: `drawer-body ${removePaddingClass}` }, h("slot", { key: '5d9aefc4ccbff803e332fd55998fb20b141b272d' })), h("footer", { key: '767203a6ffdf081888a7d43f0e840598513832b6', class: `drawer-footer ${removePaddingClass}`, style: { display: hasFooterContent ? 'block' : 'none' } }, h("slot", { key: '7d67cff86df04ba7c0c694e88d982abc2e08da5b', name: "footer" })))))));
189
+ return (h(Host, { key: '060d4bb015870b3540eb83b2ad932c3d06947c47', class: `${drawerIsOpenClass} drawer-${this.position}`, tabindex: "0", role: "dialog", "aria-label": ariaLabel }, h("div", { key: 'd73080a0b0bcf3caec1eca5cd37da1daff6f827b', class: "road-drawer-wrapper" }, h("div", { key: '01ec8567832bfdd74da79b89cd2d64749d808f4b', class: "drawer-overlay", onClick: this.onClick, tabindex: "-1" }), h("div", { key: 'f5c9999f311cb8840590123e4ac397d380de0098', class: "drawer-dialog", style: { maxWidth: drawerWidthValue }, role: "document" }, h("div", { key: '49b1ab4eeb412cfd97fca92c14a3a0d3fed06ca5', class: "drawer-content" }, h("header", { key: '70942d7f0638042702208a783df6298df4569804', class: `drawer-header ${inverseHeaderClass} ${drawerDelimiterClass}` }, backIconElement, this.drawerTitle ? (h("h2", { class: "drawer-title" }, this.drawerTitle)) : (h("div", { class: "drawer-title" }, h("slot", { name: "title" }))), closeIconElement), h("div", { key: '3bd1a439510a2fdd0e39c7ca3e1c12c224cc119f', class: `drawer-body ${removePaddingClass}` }, h("slot", { key: '9e7931e555265561fb8af8d09bc1a0ddbbfefd81' })), h("footer", { key: '5fb5f98e793fe226f32f17f3d50c493212b6c11a', class: `drawer-footer ${removePaddingClass}`, hidden: !this.hasFooterContent }, h("slot", { key: 'd177f8dacdf71974733c1a911bcd0011856825e1', name: "footer", onSlotchange: this.onFooterSlotChange })))))));
181
190
  }
182
191
  static get is() { return "road-drawer"; }
183
192
  static get encapsulation() { return "shadow"; }
@@ -1 +1 @@
1
- {"version":3,"file":"drawer.js","sourceRoot":"","sources":["../../../src/components/drawer/drawer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACrH,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,eAAe,EAAa,MAAM,YAAY,CAAC;AAExD;;;;;;;;GAQG;AAQH,MAAM,OAAO,MAAM;IALnB;QAYE;;WAEG;QACsB,WAAM,GAAY,KAAK,CAAC;QAEjD;;WAEG;QACsB,kBAAa,GAAY,KAAK,CAAC;QAExD;;WAEG;QACK,aAAQ,GAAW,MAAM,CAAC;QAElC;;WAEG;QACK,gBAAW,GAAW,GAAG,CAAC;QAElC;;WAEG;QACK,qBAAgB,GAAY,KAAK,CAAC;QAE1C;;WAEG;QACK,gBAAW,GAAY,KAAK,CAAC;QA2BrC;;WAEG;QACK,iBAAY,GAAY,IAAI,CAAC;QAErC;;WAEG;QACK,qBAAgB,GAAY,IAAI,CAAC;QAsBzC;;WAEG;QACM,qBAAgB,GAAG,KAAK,CAAC;QAiFlC;;WAEG;QACK,YAAO,GAAG,CAAC,EAAW,EAAE,EAAE;YAChC,EAAE,CAAC,eAAe,EAAE,CAAC;YACrB,EAAE,CAAC,cAAc,EAAE,CAAC;YAEpB,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,CAAC,CAAC;QAEF;;WAEG;QACK,gBAAW,GAAG,CAAC,KAAiB,EAAE,EAAE;YAC1C,KAAK,CAAC,eAAe,EAAE,CAAC;YACxB,KAAK,CAAC,cAAc,EAAE,CAAC;YAEvB,IAAI,CAAC,IAAI,EAAE,CAA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CACP;4BACA,gBAAgB,CACV;wBACT,4DAAK,KAAK,EAAE,eAAe,kBAAkB,EAAE;4BAC7C,8DAAQ,CACJ;wBACN,+DAAQ,KAAK,EAAE,iBAAiB,kBAAkB,EAAE,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE;4BAC3G,6DAAM,IAAI,EAAC,QAAQ,GAAG,CACf,CACL,CACF,CACF,CACD,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAEF","sourcesContent":["import { Component, Element, Event, EventEmitter, Listen, Method, Prop, h, Host, Watch, State } from '@stencil/core';\nimport { navigationClose, navigationChevron } from '../../../icons';\nimport { createFocusTrap, FocusTrap } from 'focus-trap';\n\n/**\n * @slot - Content of the drawer.\n * @slot title - replace the title with a custom title section when `'drawerTitle'` is not set\n * @slot footer - footer of the drawer\n * `<div slot=\"footer\">`\n `<road-button color=\"primary\" outline=\"true\" expand=\"true\">Annuler</road-button>`\n `<road-button color=\"primary\" expand=\"true\" class=\"mb-0\">Valider</road-button>`\n ` </div>`\n */\n\n\n@Component({\n tag: 'road-drawer',\n styleUrl: 'drawer.css',\n shadow: true,\n})\nexport class Drawer {\n\n /**\n * Current reference of the drawer\n */\n @Element() el!: HTMLRoadDrawerElement;\n\n /**\n * Set isOpen property to true to open the drawer\n */\n @Prop({ mutable: true }) isOpen: boolean = false;\n\n /**\n * Set removePadding property to true to remove padding for drawer body\n */\n @Prop({ mutable: true }) removePadding: boolean = false;\n\n /**\n * position of the drawer. e.g. left, right, bottom\n */\n @Prop() position: string = 'left';\n\n /**\n * Width of the drawer\n */\n @Prop() drawerWidth: number = 480;\n\n /**\n * Inverse header colors\n */\n @Prop() hasInverseHeader: boolean = false;\n\n /**\n * Show / hide back icon\n */\n @Prop() hasBackIcon: boolean = false;\n\n /**\n * Show / hide back icon\n */\n @Prop() backText?: string;\n\n /**\n * Title of the drawer in the header bar\n */\n @Prop() drawerTitle?: string;\n\n /**\n * Aria label of the drawer\n */\n @Prop() ariaLabel?: string;\n\n /**\n * Aria label of the drawer\n */\n @Prop() ariaLabelBack?: string;\n\n /**\n * Aria label of the drawer\n */\n @Prop() ariaLabelClose?: string;\n\n /**\n * Show / hide close icon\n */\n @Prop() hasCloseIcon: boolean = true;\n\n /**\n * Override focus trap\n */\n @Prop() enabledFocusTrap: boolean = true;\n\n /**\n * Indicate when opening the drawer\n */\n @Event({ eventName: 'open' }) onOpen!: EventEmitter<void>;\n\n /**\n * Indicate when closing the drawer\n */\n @Event({ eventName: 'close' }) onClose!: EventEmitter<void>;\n\n /**\n * Indicate when return to previous state of the drawer content\n */\n @Event({ eventName: 'back' }) onBack!: EventEmitter<void>;\n\n /**\n * Focus trap state\n */\n @State() focusTrap?: FocusTrap;\n\n /**\n * Footer Content state\n */\n @State() hasFooterContent = false;\n\n /**\n * Open the drawer\n */\n @Method()\n async open() {\n this.isOpen = true;\n }\n\n /**\n * Close the drawer\n */\n @Method()\n async close() {\n this.isOpen = false;\n }\n\n /**\n * Return to previous state of the drawer content\n */\n @Method()\n async back() {\n this.onBack.emit();\n }\n\n /**\n * Enable/disable focus trap so it can be overrided by the client in case of something appearing over the drawer like a modal for example\n */\n @Watch('enabledFocusTrap')\n handleFocusTrapProp(value: boolean) {\n if (value) {\n this.focusTrap?.unpause();\n } else {\n this.focusTrap?.pause();\n }\n }\n\n // @Watch('isOpen')\n // handleOpen(openValue: boolean) {\n // if(openValue === true) {\n // this.onOpen.emit();\n // } else {\n // this.el.addEventListener('transitionend', () => {\n // this.onClose.emit();\n // this.el.shadowRoot && ((this.el.shadowRoot.querySelector('.drawer-body') as HTMLElement).scrollTop = 0);\n // }, { once: true});\n // }\n // }\n\n\n @Watch('isOpen')\n handleOpen(openValue: boolean) {\n if (openValue === true) {\n this.onOpen.emit();\n // Focus the first button element after the drawer is opened then focus trap\n setTimeout(() => {\n this.focusFirstElement();\n this.focusTrap?.activate();\n }, 50); // Add a slight delay to ensure the element is rendered\n } else {\n this.el.addEventListener('transitionend', () => {\n this.focusTrap?.deactivate();\n this.onClose.emit();\n this.el.shadowRoot && ((this.el.shadowRoot.querySelector('.drawer-body') as HTMLElement).scrollTop = 0);\n }, { once: true });\n }\n }\n\n /**\n * Find and focus the first element in the drawer\n */\n private focusFirstElement() {\n const firstElement = this.el.shadowRoot?.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, [contenteditable], [tabindex]:not([tabindex=\"-1\"])')[0] as HTMLElement;\n\n if (firstElement) {\n firstElement.focus();\n }\n }\n\n\n /**\n * Close the dialog when clicking on the cross or layer\n */\n private onClick = (ev: UIEvent) => {\n ev.stopPropagation();\n ev.preventDefault();\n\n this.close();\n };\n\n /**\n * Close the dialog when clicking on the cross or layer\n */\n private onClickBack = (event: MouseEvent) => {\n event.stopPropagation();\n event.preventDefault();\n\n this.back();\n };\n\n /**\n * Close the dialog when press Escape key\n */\n @Listen('keyup', { target: 'document' })\n onEscape(event: KeyboardEvent) {\n if (event.key === 'Escape' || event.key === \"Esc\") {\n this.close();\n }\n }\n\n /**\n * Call close function when clicking an element with data-dismiss=\"modal\" attribute\n */\n componentDidLoad() {\n this.el.querySelectorAll('[data-dismiss=\"modal\"]').forEach(item => {\n item.addEventListener('click', () => this.close());\n });\n\n const drawerContent = this.el.shadowRoot?.querySelector(\".road-drawer-wrapper\");\n this.focusTrap = createFocusTrap(drawerContent as HTMLElement, {\n onActivate: () => drawerContent?.classList.add(\"focus-trapped\"),\n onDeactivate: () => drawerContent?.classList.remove(\"focus-trapped\"),\n tabbableOptions: {\n getShadowRoot: true,\n },\n });\n if (this.isOpen) {\n this.handleOpen(true);\n }\n }\n\n render() {\n const drawerIsOpenClass = this.isOpen ? 'drawer-open' : '';\n const removePaddingClass = this.removePadding ? 'remove-padding' : '';\n const inverseHeaderClass = this.hasInverseHeader ? 'drawer-header-inverse' : '';\n const ariaLabel = this.ariaLabel ?? 'drawer';\n const ariaLabelBack = this.ariaLabelBack ?? 'Back';\n const ariaLabelClose = this.ariaLabelClose ?? 'Close';\n const drawerDelimiterClass = this.drawerTitle && !this.hasInverseHeader ? 'drawer-delimiter' : '';\n const backIconElement = this.hasBackIcon ? (\n <button type=\"button\" class=\"drawer-action\" aria-label={ariaLabelBack} onClick={this.onClickBack}>\n <road-icon icon={navigationChevron} rotate=\"180\"></road-icon>\n {this.backText}\n </button>\n ) : null;\n const closeIconElement = this.hasCloseIcon ? (\n <button type=\"button\" class=\"drawer-close\" onClick={this.onClick} aria-label={ariaLabelClose}>\n <road-icon icon={navigationClose} aria-hidden=\"true\"></road-icon>\n </button>\n ) : null;\n const drawerWidthValue = this.position === 'bottom' ? '100%' : `${this.drawerWidth}px`;\n\n const footerSlotElement = this.el.shadowRoot?.querySelector('slot[name=\"footer\"]');\n const hasFooterContent = footerSlotElement instanceof HTMLSlotElement && footerSlotElement.assignedNodes().length > 0;\n\n return (\n <Host class={`${drawerIsOpenClass} drawer-${this.position}`} tabindex=\"0\" role=\"dialog\" aria-label={ariaLabel}>\n <div class=\"road-drawer-wrapper\">\n <div class=\"drawer-overlay\" onClick={this.onClick} tabindex=\"-1\"></div>\n <div class=\"drawer-dialog\" style={{ maxWidth: drawerWidthValue }} role=\"document\">\n <div class=\"drawer-content\">\n <header class={`drawer-header ${inverseHeaderClass} ${drawerDelimiterClass}`}>\n {backIconElement}\n {this.drawerTitle ? (\n <h2 class=\"drawer-title\">{this.drawerTitle}</h2>\n ) : (\n <div class=\"drawer-title\">\n <slot name=\"title\" />\n </div>\n )}\n {closeIconElement}\n </header>\n <div class={`drawer-body ${removePaddingClass}`}>\n <slot />\n </div>\n <footer class={`drawer-footer ${removePaddingClass}`} style={{ display: hasFooterContent ? 'block' : 'none' }}>\n <slot name=\"footer\" />\n </footer>\n </div>\n </div>\n </div>\n </Host>\n );\n }\n\n}\n"]}
1
+ {"version":3,"file":"drawer.js","sourceRoot":"","sources":["../../../src/components/drawer/drawer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACrH,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,eAAe,EAAa,MAAM,YAAY,CAAC;AAExD;;;;;;;;GAQG;AAQH,MAAM,OAAO,MAAM;IALnB;QAYE;;WAEG;QACsB,WAAM,GAAY,KAAK,CAAC;QAEjD;;WAEG;QACsB,kBAAa,GAAY,KAAK,CAAC;QAExD;;WAEG;QACK,aAAQ,GAAW,MAAM,CAAC;QAElC;;WAEG;QACK,gBAAW,GAAW,GAAG,CAAC;QAElC;;WAEG;QACK,qBAAgB,GAAY,KAAK,CAAC;QAE1C;;WAEG;QACK,gBAAW,GAAY,KAAK,CAAC;QA2BrC;;WAEG;QACK,iBAAY,GAAY,IAAI,CAAC;QAErC;;WAEG;QACK,qBAAgB,GAAY,IAAI,CAAC;QAsBzC;;WAEG;QACM,qBAAgB,GAAG,KAAK,CAAC;QA2E1B,uBAAkB,GAAG,CAAC,KAAY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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAEF","sourcesContent":["import { Component, Element, Event, EventEmitter, Listen, Method, Prop, h, Host, Watch, State } from '@stencil/core';\nimport { navigationClose, navigationChevron } from '../../../icons';\nimport { createFocusTrap, FocusTrap } from 'focus-trap';\n\n/**\n * @slot - Content of the drawer.\n * @slot title - replace the title with a custom title section when `'drawerTitle'` is not set\n * @slot footer - footer of the drawer\n * `<div slot=\"footer\">`\n `<road-button color=\"primary\" outline=\"true\" expand=\"true\">Annuler</road-button>`\n `<road-button color=\"primary\" expand=\"true\" class=\"mb-0\">Valider</road-button>`\n ` </div>`\n */\n\n\n@Component({\n tag: 'road-drawer',\n styleUrl: 'drawer.css',\n shadow: true,\n})\nexport class Drawer {\n\n /**\n * Current reference of the drawer\n */\n @Element() el!: HTMLRoadDrawerElement;\n\n /**\n * Set isOpen property to true to open the drawer\n */\n @Prop({ mutable: true }) isOpen: boolean = false;\n\n /**\n * Set removePadding property to true to remove padding for drawer body\n */\n @Prop({ mutable: true }) removePadding: boolean = false;\n\n /**\n * position of the drawer. e.g. left, right, bottom\n */\n @Prop() position: string = 'left';\n\n /**\n * Width of the drawer\n */\n @Prop() drawerWidth: number = 480;\n\n /**\n * Inverse header colors\n */\n @Prop() hasInverseHeader: boolean = false;\n\n /**\n * Show / hide back icon\n */\n @Prop() hasBackIcon: boolean = false;\n\n /**\n * Show / hide back icon\n */\n @Prop() backText?: string;\n\n /**\n * Title of the drawer in the header bar\n */\n @Prop() drawerTitle?: string;\n\n /**\n * Aria label of the drawer\n */\n @Prop() ariaLabel?: string;\n\n /**\n * Aria label of the drawer\n */\n @Prop() ariaLabelBack?: string;\n\n /**\n * Aria label of the drawer\n */\n @Prop() ariaLabelClose?: string;\n\n /**\n * Show / hide close icon\n */\n @Prop() hasCloseIcon: boolean = true;\n\n /**\n * Override focus trap\n */\n @Prop() enabledFocusTrap: boolean = true;\n\n /**\n * Indicate when opening the drawer\n */\n @Event({ eventName: 'open' }) onOpen!: EventEmitter<void>;\n\n /**\n * Indicate when closing the drawer\n */\n @Event({ eventName: 'close' }) onClose!: EventEmitter<void>;\n\n /**\n * Indicate when return to previous state of the drawer content\n */\n @Event({ eventName: 'back' }) onBack!: EventEmitter<void>;\n\n /**\n * Focus trap state\n */\n @State() focusTrap?: FocusTrap;\n\n /**\n * Footer Content state\n */\n @State() hasFooterContent = false;\n\n /**\n * Open the drawer\n */\n @Method()\n async open() {\n this.isOpen = true;\n }\n\n /**\n * Close the drawer\n */\n @Method()\n async close() {\n this.isOpen = false;\n }\n\n /**\n * Return to previous state of the drawer content\n */\n @Method()\n async back() {\n this.onBack.emit();\n }\n\n /**\n * Enable/disable focus trap so it can be overrided by the client in case of something appearing over the drawer like a modal for example\n */\n @Watch('enabledFocusTrap')\n handleFocusTrapProp(value: boolean) {\n setTimeout(() => {\n if (value) {\n this.focusTrap?.unpause();\n } else {\n this.focusTrap?.pause();\n }\n }, 100); // Timeout is used to ensure the drawer has been rendered when client wants to update the property at the same time\n }\n\n // @Watch('isOpen')\n // handleOpen(openValue: boolean) {\n // if(openValue === true) {\n // this.onOpen.emit();\n // } else {\n // this.el.addEventListener('transitionend', () => {\n // this.onClose.emit();\n // this.el.shadowRoot && ((this.el.shadowRoot.querySelector('.drawer-body') as HTMLElement).scrollTop = 0);\n // }, { once: true});\n // }\n // }\n\n\n @Watch('isOpen')\n handleOpen(openValue: boolean) {\n if (openValue === true) {\n this.onOpen.emit();\n // Focus the first button element after the drawer is opened then focus trap\n setTimeout(() => {\n this.focusFirstElement();\n if (this.focusTrap?.active) {\n this.focusTrap?.unpause();\n } else {\n this.focusTrap?.activate();\n }\n }, 50); // Add a slight delay to ensure the element is rendered\n } else {\n this.el.addEventListener('transitionend', () => {\n this.focusTrap?.deactivate();\n this.onClose.emit();\n this.el.shadowRoot && ((this.el.shadowRoot.querySelector('.drawer-body') as HTMLElement).scrollTop = 0);\n }, { once: true });\n }\n }\n\n private onFooterSlotChange = (event: Event) => {\n const slot = event.target as HTMLSlotElement;\n this.hasFooterContent = slot.assignedElements().length > 0;\n };\n\n /**\n * Find and focus the first element in the drawer\n */\n private focusFirstElement() {\n const firstElement = this.el.shadowRoot?.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, [contenteditable], [tabindex]:not([tabindex=\"-1\"])')[0] as HTMLElement;\n\n if (firstElement) {\n firstElement.focus();\n }\n }\n\n\n /**\n * Close the dialog when clicking on the cross or layer\n */\n private onClick = (ev: UIEvent) => {\n ev.stopPropagation();\n ev.preventDefault();\n\n this.close();\n };\n\n /**\n * Close the dialog when clicking on the cross or layer\n */\n private onClickBack = (event: MouseEvent) => {\n event.stopPropagation();\n event.preventDefault();\n\n this.back();\n };\n\n /**\n * Close the dialog when press Escape key\n */\n @Listen('keyup', { target: 'document' })\n onEscape(event: KeyboardEvent) {\n if (event.key === 'Escape' || event.key === \"Esc\") {\n this.close();\n }\n }\n\n /**\n * Call close function when clicking an element with data-dismiss=\"modal\" attribute\n */\n componentDidLoad() {\n this.el.querySelectorAll('[data-dismiss=\"modal\"]').forEach(item => {\n item.addEventListener('click', () => this.close());\n });\n\n const drawerContent = this.el.shadowRoot?.querySelector(\".road-drawer-wrapper\");\n this.focusTrap = createFocusTrap(drawerContent as HTMLElement, {\n onActivate: () => drawerContent?.classList.add(\"focus-trapped\"),\n onDeactivate: () => drawerContent?.classList.remove(\"focus-trapped\"),\n tabbableOptions: {\n getShadowRoot: true,\n },\n });\n if (this.isOpen) {\n this.handleOpen(true);\n }\n }\n\n render() {\n const drawerIsOpenClass = this.isOpen ? 'drawer-open' : '';\n const removePaddingClass = this.removePadding ? 'remove-padding' : '';\n const inverseHeaderClass = this.hasInverseHeader ? 'drawer-header-inverse' : '';\n const ariaLabel = this.ariaLabel ?? 'drawer';\n const ariaLabelBack = this.ariaLabelBack ?? 'Back';\n const ariaLabelClose = this.ariaLabelClose ?? 'Close';\n const drawerDelimiterClass = this.drawerTitle && !this.hasInverseHeader ? 'drawer-delimiter' : '';\n const backIconElement = this.hasBackIcon ? (\n <button type=\"button\" class=\"drawer-action\" aria-label={ariaLabelBack} onClick={this.onClickBack}>\n <road-icon icon={navigationChevron} rotate=\"180\"></road-icon>\n {this.backText}\n </button>\n ) : null;\n const closeIconElement = this.hasCloseIcon ? (\n <button type=\"button\" class=\"drawer-close\" onClick={this.onClick} aria-label={ariaLabelClose}>\n <road-icon icon={navigationClose} aria-hidden=\"true\"></road-icon>\n </button>\n ) : null;\n const drawerWidthValue = this.position === 'bottom' ? '100%' : `${this.drawerWidth}px`;\n\n return (\n <Host class={`${drawerIsOpenClass} drawer-${this.position}`} tabindex=\"0\" role=\"dialog\" aria-label={ariaLabel}>\n <div class=\"road-drawer-wrapper\">\n <div class=\"drawer-overlay\" onClick={this.onClick} tabindex=\"-1\"></div>\n <div class=\"drawer-dialog\" style={{ maxWidth: drawerWidthValue }} role=\"document\">\n <div class=\"drawer-content\">\n <header class={`drawer-header ${inverseHeaderClass} ${drawerDelimiterClass}`}>\n {backIconElement}\n {this.drawerTitle ? (\n <h2 class=\"drawer-title\">{this.drawerTitle}</h2>\n ) : (\n <div class=\"drawer-title\">\n <slot name=\"title\" />\n </div>\n )}\n {closeIconElement}\n </header>\n <div class={`drawer-body ${removePaddingClass}`}>\n <slot />\n </div>\n <footer\n class={`drawer-footer ${removePaddingClass}`}\n hidden={!this.hasFooterContent}\n >\n <slot name=\"footer\" onSlotchange={this.onFooterSlotChange} />\n </footer>\n </div>\n </div>\n </div>\n </Host>\n );\n }\n\n}\n"]}
@@ -1934,6 +1934,10 @@ const Drawer = class {
1934
1934
  * Footer Content state
1935
1935
  */
1936
1936
  this.hasFooterContent = false;
1937
+ this.onFooterSlotChange = (event) => {
1938
+ const slot = event.target;
1939
+ this.hasFooterContent = slot.assignedElements().length > 0;
1940
+ };
1937
1941
  /**
1938
1942
  * Close the dialog when clicking on the cross or layer
1939
1943
  */
@@ -1973,13 +1977,15 @@ const Drawer = class {
1973
1977
  * Enable/disable focus trap so it can be overrided by the client in case of something appearing over the drawer like a modal for example
1974
1978
  */
1975
1979
  handleFocusTrapProp(value) {
1976
- var _a, _b;
1977
- if (value) {
1978
- (_a = this.focusTrap) === null || _a === void 0 ? void 0 : _a.unpause();
1979
- }
1980
- else {
1981
- (_b = this.focusTrap) === null || _b === void 0 ? void 0 : _b.pause();
1982
- }
1980
+ setTimeout(() => {
1981
+ var _a, _b;
1982
+ if (value) {
1983
+ (_a = this.focusTrap) === null || _a === void 0 ? void 0 : _a.unpause();
1984
+ }
1985
+ else {
1986
+ (_b = this.focusTrap) === null || _b === void 0 ? void 0 : _b.pause();
1987
+ }
1988
+ }, 100); // Timeout is used to ensure the drawer has been rendered when client wants to update the property at the same time
1983
1989
  }
1984
1990
  // @Watch('isOpen')
1985
1991
  // handleOpen(openValue: boolean) {
@@ -1997,9 +2003,14 @@ const Drawer = class {
1997
2003
  this.onOpen.emit();
1998
2004
  // Focus the first button element after the drawer is opened then focus trap
1999
2005
  setTimeout(() => {
2000
- var _a;
2006
+ var _a, _b, _c;
2001
2007
  this.focusFirstElement();
2002
- (_a = this.focusTrap) === null || _a === void 0 ? void 0 : _a.activate();
2008
+ if ((_a = this.focusTrap) === null || _a === void 0 ? void 0 : _a.active) {
2009
+ (_b = this.focusTrap) === null || _b === void 0 ? void 0 : _b.unpause();
2010
+ }
2011
+ else {
2012
+ (_c = this.focusTrap) === null || _c === void 0 ? void 0 : _c.activate();
2013
+ }
2003
2014
  }, 50); // Add a slight delay to ensure the element is rendered
2004
2015
  }
2005
2016
  else {
@@ -2050,7 +2061,7 @@ const Drawer = class {
2050
2061
  }
2051
2062
  }
2052
2063
  render() {
2053
- var _a, _b, _c, _d;
2064
+ var _a, _b, _c;
2054
2065
  const drawerIsOpenClass = this.isOpen ? 'drawer-open' : '';
2055
2066
  const removePaddingClass = this.removePadding ? 'remove-padding' : '';
2056
2067
  const inverseHeaderClass = this.hasInverseHeader ? 'drawer-header-inverse' : '';
@@ -2061,9 +2072,7 @@ const Drawer = class {
2061
2072
  const backIconElement = this.hasBackIcon ? (h("button", { type: "button", class: "drawer-action", "aria-label": ariaLabelBack, onClick: this.onClickBack }, h("road-icon", { icon: navigationChevron, rotate: "180" }), this.backText)) : null;
2062
2073
  const closeIconElement = this.hasCloseIcon ? (h("button", { type: "button", class: "drawer-close", onClick: this.onClick, "aria-label": ariaLabelClose }, h("road-icon", { icon: navigationClose, "aria-hidden": "true" }))) : null;
2063
2074
  const drawerWidthValue = this.position === 'bottom' ? '100%' : `${this.drawerWidth}px`;
2064
- const footerSlotElement = (_d = this.el.shadowRoot) === null || _d === void 0 ? void 0 : _d.querySelector('slot[name="footer"]');
2065
- const hasFooterContent = footerSlotElement instanceof HTMLSlotElement && footerSlotElement.assignedNodes().length > 0;
2066
- return (h(Host, { key: 'f204c79488e3496f2b5de75bdbaf8af4a7912306', class: `${drawerIsOpenClass} drawer-${this.position}`, tabindex: "0", role: "dialog", "aria-label": ariaLabel }, h("div", { key: 'c75f6462bd7f7451d17784b72fb94ec343fe88f9', class: "road-drawer-wrapper" }, h("div", { key: '2e5df3a95fa7344dfbe103e05714c74646f68c3c', class: "drawer-overlay", onClick: this.onClick, tabindex: "-1" }), h("div", { key: 'dfc325bb20bebcc1cb41902d5acbd28b2b662d01', class: "drawer-dialog", style: { maxWidth: drawerWidthValue }, role: "document" }, h("div", { key: 'efdf2daad76553c2b4d0df35353865abd29a170c', class: "drawer-content" }, h("header", { key: '96cefa87d0a69594d2add43cbffa6cbbd6a491d9', class: `drawer-header ${inverseHeaderClass} ${drawerDelimiterClass}` }, backIconElement, this.drawerTitle ? (h("h2", { class: "drawer-title" }, this.drawerTitle)) : (h("div", { class: "drawer-title" }, h("slot", { name: "title" }))), closeIconElement), h("div", { key: 'd5d13d447d46cd6e1df289a217aa8422e100afa7', class: `drawer-body ${removePaddingClass}` }, h("slot", { key: '5d9aefc4ccbff803e332fd55998fb20b141b272d' })), h("footer", { key: '767203a6ffdf081888a7d43f0e840598513832b6', class: `drawer-footer ${removePaddingClass}`, style: { display: hasFooterContent ? 'block' : 'none' } }, h("slot", { key: '7d67cff86df04ba7c0c694e88d982abc2e08da5b', name: "footer" })))))));
2075
+ return (h(Host, { key: '060d4bb015870b3540eb83b2ad932c3d06947c47', class: `${drawerIsOpenClass} drawer-${this.position}`, tabindex: "0", role: "dialog", "aria-label": ariaLabel }, h("div", { key: 'd73080a0b0bcf3caec1eca5cd37da1daff6f827b', class: "road-drawer-wrapper" }, h("div", { key: '01ec8567832bfdd74da79b89cd2d64749d808f4b', class: "drawer-overlay", onClick: this.onClick, tabindex: "-1" }), h("div", { key: 'f5c9999f311cb8840590123e4ac397d380de0098', class: "drawer-dialog", style: { maxWidth: drawerWidthValue }, role: "document" }, h("div", { key: '49b1ab4eeb412cfd97fca92c14a3a0d3fed06ca5', class: "drawer-content" }, h("header", { key: '70942d7f0638042702208a783df6298df4569804', class: `drawer-header ${inverseHeaderClass} ${drawerDelimiterClass}` }, backIconElement, this.drawerTitle ? (h("h2", { class: "drawer-title" }, this.drawerTitle)) : (h("div", { class: "drawer-title" }, h("slot", { name: "title" }))), closeIconElement), h("div", { key: '3bd1a439510a2fdd0e39c7ca3e1c12c224cc119f', class: `drawer-body ${removePaddingClass}` }, h("slot", { key: '9e7931e555265561fb8af8d09bc1a0ddbbfefd81' })), h("footer", { key: '5fb5f98e793fe226f32f17f3d50c493212b6c11a', class: `drawer-footer ${removePaddingClass}`, hidden: !this.hasFooterContent }, h("slot", { key: 'd177f8dacdf71974733c1a911bcd0011856825e1', name: "footer", onSlotchange: this.onFooterSlotChange })))))));
2067
2076
  }
2068
2077
  get el() { return getElement(this); }
2069
2078
  static get watchers() { return {