modal.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767
  1. /*!
  2. * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
  4. * v1.0.0-beta.97
  5. */
  6. import { h, Host } from "@stencil/core";
  7. import { ensureId, focusElement, getSlotted, isCalciteFocusable } from "../../utils/dom";
  8. import { queryShadowRoot } from "@a11y/focus-trap/shadow";
  9. import { isFocusable, isHidden } from "@a11y/focus-trap/focusable";
  10. import { CSS, ICONS, SLOTS, TEXT } from "./resources";
  11. import { createObserver } from "../../utils/observers";
  12. import { connectConditionalSlotComponent, disconnectConditionalSlotComponent } from "../../utils/conditionalSlot";
  13. import { connectOpenCloseComponent, disconnectOpenCloseComponent } from "../../utils/openCloseComponent";
  14. const isFocusableExtended = (el) => {
  15. return isCalciteFocusable(el) || isFocusable(el);
  16. };
  17. const getFocusableElements = (el) => {
  18. return queryShadowRoot(el, isHidden, isFocusableExtended);
  19. };
  20. /**
  21. * @slot header - A slot for adding header text.
  22. * @slot content - A slot for adding the component's content.
  23. * @slot primary - A slot for adding a primary button.
  24. * @slot secondary - A slot for adding a secondary button.
  25. * @slot back - A slot for adding a back button.
  26. */
  27. export class Modal {
  28. constructor() {
  29. //--------------------------------------------------------------------------
  30. //
  31. // Properties
  32. //
  33. //--------------------------------------------------------------------------
  34. /**
  35. * When `true`, the component is active.
  36. *
  37. * @deprecated use `open` instead.
  38. */
  39. this.active = false;
  40. /** When `true`, displays and positions the component. */
  41. this.open = false;
  42. /** Passes a function to run before the component closes. */
  43. this.beforeClose = () => Promise.resolve();
  44. /** When `true`, disables the component's close button. */
  45. this.disableCloseButton = false;
  46. /** When `true`, disables the closing of the component when clicked outside. */
  47. this.disableOutsideClose = false;
  48. /** Accessible name for the component's close button. */
  49. this.intlClose = TEXT.close;
  50. /** When `true`, disables the default close on escape behavior. */
  51. this.disableEscape = false;
  52. /** Specifies the size of the component. */
  53. this.scale = "m";
  54. /** Specifies the width of the component. Can use scale sizes or pass a number (displays in pixels). */
  55. this.width = "m";
  56. /** Sets the background color of the component's content. */
  57. this.backgroundColor = "white";
  58. /**
  59. * When `true`, disables spacing to the content area slot.
  60. *
  61. * @deprecated Use `--calcite-modal-padding` CSS variable instead.
  62. */
  63. this.noPadding = false;
  64. //--------------------------------------------------------------------------
  65. //
  66. // Variables
  67. //
  68. //--------------------------------------------------------------------------
  69. this.hasFooter = true;
  70. /**
  71. * We use internal variable to make sure initially open modal can transition from closed state when rendered
  72. *
  73. * @private
  74. */
  75. this.isOpen = false;
  76. this.mutationObserver = createObserver("mutation", () => this.updateFooterVisibility());
  77. this.openTransitionProp = "opacity";
  78. //--------------------------------------------------------------------------
  79. //
  80. // Private Methods
  81. //
  82. //--------------------------------------------------------------------------
  83. this.setTransitionEl = (el) => {
  84. this.transitionEl = el;
  85. connectOpenCloseComponent(this);
  86. };
  87. this.openEnd = () => {
  88. this.setFocus();
  89. this.el.removeEventListener("calciteModalOpen", this.openEnd);
  90. };
  91. this.handleOutsideClose = () => {
  92. if (this.disableOutsideClose) {
  93. return;
  94. }
  95. this.close();
  96. };
  97. /** Close the modal, first running the `beforeClose` method */
  98. this.close = () => {
  99. return this.beforeClose(this.el).then(() => {
  100. this.open = false;
  101. this.isOpen = false;
  102. focusElement(this.previousActiveElement);
  103. this.removeOverflowHiddenClass();
  104. });
  105. };
  106. this.focusFirstElement = () => {
  107. focusElement(this.disableCloseButton ? getFocusableElements(this.el)[0] : this.closeButtonEl);
  108. };
  109. this.focusLastElement = () => {
  110. const focusableElements = getFocusableElements(this.el).filter((el) => !el.getAttribute("data-focus-fence"));
  111. if (focusableElements.length > 0) {
  112. focusElement(focusableElements[focusableElements.length - 1]);
  113. }
  114. else {
  115. focusElement(this.closeButtonEl);
  116. }
  117. };
  118. this.updateFooterVisibility = () => {
  119. this.hasFooter = !!getSlotted(this.el, [SLOTS.back, SLOTS.primary, SLOTS.secondary]);
  120. };
  121. }
  122. //--------------------------------------------------------------------------
  123. //
  124. // Lifecycle
  125. //
  126. //--------------------------------------------------------------------------
  127. componentWillLoad() {
  128. // when modal initially renders, if active was set we need to open as watcher doesn't fire
  129. if (this.open) {
  130. requestAnimationFrame(() => this.openModal());
  131. }
  132. }
  133. connectedCallback() {
  134. var _a;
  135. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
  136. this.updateFooterVisibility();
  137. connectConditionalSlotComponent(this);
  138. connectOpenCloseComponent(this);
  139. if (this.open) {
  140. this.active = this.open;
  141. }
  142. if (this.active) {
  143. this.activeHandler(this.active);
  144. }
  145. }
  146. disconnectedCallback() {
  147. var _a;
  148. this.removeOverflowHiddenClass();
  149. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
  150. disconnectConditionalSlotComponent(this);
  151. disconnectOpenCloseComponent(this);
  152. }
  153. render() {
  154. return (h(Host, { "aria-describedby": this.contentId, "aria-labelledby": this.titleId, "aria-modal": "true", role: "dialog" }, h("calcite-scrim", { class: CSS.scrim, onClick: this.handleOutsideClose }), this.renderStyle(), h("div", { class: {
  155. [CSS.modal]: true,
  156. [CSS.modalOpen]: this.isOpen
  157. }, ref: this.setTransitionEl }, h("div", { "data-focus-fence": true, onFocus: this.focusLastElement, tabindex: "0" }), h("div", { class: CSS.header }, this.renderCloseButton(), h("header", { class: CSS.title }, h("slot", { name: CSS.header }))), h("div", { class: {
  158. content: true,
  159. "content--spaced": !this.noPadding,
  160. "content--no-footer": !this.hasFooter
  161. }, ref: (el) => (this.modalContent = el) }, h("slot", { name: SLOTS.content })), this.renderFooter(), h("div", { "data-focus-fence": true, onFocus: this.focusFirstElement, tabindex: "0" }))));
  162. }
  163. renderFooter() {
  164. return this.hasFooter ? (h("div", { class: CSS.footer, key: "footer" }, h("span", { class: CSS.back }, h("slot", { name: SLOTS.back })), h("span", { class: CSS.secondary }, h("slot", { name: SLOTS.secondary })), h("span", { class: CSS.primary }, h("slot", { name: SLOTS.primary })))) : null;
  165. }
  166. renderCloseButton() {
  167. return !this.disableCloseButton ? (h("button", { "aria-label": this.intlClose, class: CSS.close, key: "button", onClick: this.close, ref: (el) => (this.closeButtonEl = el), title: this.intlClose }, h("calcite-icon", { icon: ICONS.close, scale: this.scale === "s" ? "s" : this.scale === "m" ? "m" : this.scale === "l" ? "l" : null }))) : null;
  168. }
  169. renderStyle() {
  170. const hasCustomWidth = !isNaN(parseInt(`${this.width}`));
  171. return hasCustomWidth ? (h("style", null, `
  172. .${CSS.modal} {
  173. max-width: ${this.width}px !important;
  174. }
  175. @media screen and (max-width: ${this.width}px) {
  176. .${CSS.modal} {
  177. height: 100% !important;
  178. max-height: 100% !important;
  179. width: 100% !important;
  180. max-width: 100% !important;
  181. margin: 0 !important;
  182. border-radius: 0 !important;
  183. }
  184. .content {
  185. flex: 1 1 auto !important;
  186. max-height: unset !important;
  187. }
  188. }
  189. `)) : null;
  190. }
  191. //--------------------------------------------------------------------------
  192. //
  193. // Event Listeners
  194. //
  195. //--------------------------------------------------------------------------
  196. handleEscape(event) {
  197. if (this.open && !this.disableEscape && event.key === "Escape" && !event.defaultPrevented) {
  198. this.close();
  199. event.preventDefault();
  200. }
  201. }
  202. //--------------------------------------------------------------------------
  203. //
  204. // Public Methods
  205. //
  206. //--------------------------------------------------------------------------
  207. /**
  208. * Focus the first interactive element.
  209. *
  210. * @param el
  211. * @deprecated use `setFocus` instead.
  212. */
  213. async focusElement(el) {
  214. if (el) {
  215. el.focus();
  216. }
  217. return this.setFocus();
  218. }
  219. /**
  220. * Sets focus on the component.
  221. *
  222. * By default, tries to focus on focusable content. If there is none, it will focus on the close button.
  223. * To focus on the close button, use the `close-button` focus ID.
  224. *
  225. * @param focusId
  226. */
  227. async setFocus(focusId) {
  228. const closeButton = this.closeButtonEl;
  229. return focusElement(focusId === "close-button" ? closeButton : getFocusableElements(this.el)[0] || closeButton);
  230. }
  231. /**
  232. * Sets the scroll top of the component's content.
  233. *
  234. * @param top
  235. * @param left
  236. */
  237. async scrollContent(top = 0, left = 0) {
  238. if (this.modalContent) {
  239. if (this.modalContent.scrollTo) {
  240. this.modalContent.scrollTo({ top, left, behavior: "smooth" });
  241. }
  242. else {
  243. this.modalContent.scrollTop = top;
  244. this.modalContent.scrollLeft = left;
  245. }
  246. }
  247. }
  248. onBeforeOpen() {
  249. this.transitionEl.classList.add(CSS.openingActive);
  250. this.calciteModalBeforeOpen.emit();
  251. }
  252. onOpen() {
  253. this.transitionEl.classList.remove(CSS.openingIdle, CSS.openingActive);
  254. this.calciteModalOpen.emit();
  255. }
  256. onBeforeClose() {
  257. this.transitionEl.classList.add(CSS.closingActive);
  258. this.calciteModalBeforeClose.emit();
  259. }
  260. onClose() {
  261. this.transitionEl.classList.remove(CSS.closingIdle, CSS.closingActive);
  262. this.calciteModalClose.emit();
  263. }
  264. activeHandler(value) {
  265. this.open = value;
  266. }
  267. async toggleModal(value) {
  268. var _a, _b;
  269. this.active = value;
  270. if (value) {
  271. (_a = this.transitionEl) === null || _a === void 0 ? void 0 : _a.classList.add(CSS.openingIdle);
  272. this.openModal();
  273. }
  274. else {
  275. (_b = this.transitionEl) === null || _b === void 0 ? void 0 : _b.classList.add(CSS.closingIdle);
  276. this.close();
  277. }
  278. }
  279. /** Open the modal */
  280. openModal() {
  281. this.previousActiveElement = document.activeElement;
  282. this.el.addEventListener("calciteModalOpen", this.openEnd);
  283. this.open = true;
  284. this.isOpen = true;
  285. const titleEl = getSlotted(this.el, SLOTS.header);
  286. const contentEl = getSlotted(this.el, SLOTS.content);
  287. this.titleId = ensureId(titleEl);
  288. this.contentId = ensureId(contentEl);
  289. document.documentElement.classList.add(CSS.overflowHidden);
  290. }
  291. removeOverflowHiddenClass() {
  292. document.documentElement.classList.remove(CSS.overflowHidden);
  293. }
  294. static get is() { return "calcite-modal"; }
  295. static get encapsulation() { return "shadow"; }
  296. static get originalStyleUrls() {
  297. return {
  298. "$": ["modal.scss"]
  299. };
  300. }
  301. static get styleUrls() {
  302. return {
  303. "$": ["modal.css"]
  304. };
  305. }
  306. static get properties() {
  307. return {
  308. "active": {
  309. "type": "boolean",
  310. "mutable": true,
  311. "complexType": {
  312. "original": "boolean",
  313. "resolved": "boolean",
  314. "references": {}
  315. },
  316. "required": false,
  317. "optional": false,
  318. "docs": {
  319. "tags": [{
  320. "name": "deprecated",
  321. "text": "use `open` instead."
  322. }],
  323. "text": "When `true`, the component is active."
  324. },
  325. "attribute": "active",
  326. "reflect": true,
  327. "defaultValue": "false"
  328. },
  329. "open": {
  330. "type": "boolean",
  331. "mutable": true,
  332. "complexType": {
  333. "original": "boolean",
  334. "resolved": "boolean",
  335. "references": {}
  336. },
  337. "required": false,
  338. "optional": false,
  339. "docs": {
  340. "tags": [],
  341. "text": "When `true`, displays and positions the component."
  342. },
  343. "attribute": "open",
  344. "reflect": true,
  345. "defaultValue": "false"
  346. },
  347. "beforeClose": {
  348. "type": "unknown",
  349. "mutable": false,
  350. "complexType": {
  351. "original": "(el: HTMLElement) => Promise<void>",
  352. "resolved": "(el: HTMLElement) => Promise<void>",
  353. "references": {
  354. "HTMLElement": {
  355. "location": "global"
  356. },
  357. "Promise": {
  358. "location": "global"
  359. }
  360. }
  361. },
  362. "required": false,
  363. "optional": true,
  364. "docs": {
  365. "tags": [],
  366. "text": "Passes a function to run before the component closes."
  367. },
  368. "defaultValue": "() => Promise.resolve()"
  369. },
  370. "disableCloseButton": {
  371. "type": "boolean",
  372. "mutable": false,
  373. "complexType": {
  374. "original": "boolean",
  375. "resolved": "boolean",
  376. "references": {}
  377. },
  378. "required": false,
  379. "optional": false,
  380. "docs": {
  381. "tags": [],
  382. "text": "When `true`, disables the component's close button."
  383. },
  384. "attribute": "disable-close-button",
  385. "reflect": true,
  386. "defaultValue": "false"
  387. },
  388. "disableOutsideClose": {
  389. "type": "boolean",
  390. "mutable": false,
  391. "complexType": {
  392. "original": "boolean",
  393. "resolved": "boolean",
  394. "references": {}
  395. },
  396. "required": false,
  397. "optional": false,
  398. "docs": {
  399. "tags": [],
  400. "text": "When `true`, disables the closing of the component when clicked outside."
  401. },
  402. "attribute": "disable-outside-close",
  403. "reflect": true,
  404. "defaultValue": "false"
  405. },
  406. "intlClose": {
  407. "type": "string",
  408. "mutable": false,
  409. "complexType": {
  410. "original": "string",
  411. "resolved": "string",
  412. "references": {}
  413. },
  414. "required": false,
  415. "optional": false,
  416. "docs": {
  417. "tags": [],
  418. "text": "Accessible name for the component's close button."
  419. },
  420. "attribute": "intl-close",
  421. "reflect": false,
  422. "defaultValue": "TEXT.close"
  423. },
  424. "docked": {
  425. "type": "boolean",
  426. "mutable": false,
  427. "complexType": {
  428. "original": "boolean",
  429. "resolved": "boolean",
  430. "references": {}
  431. },
  432. "required": false,
  433. "optional": false,
  434. "docs": {
  435. "tags": [],
  436. "text": "When `true`, prevents the component from expanding to the entire screen on mobile devices."
  437. },
  438. "attribute": "docked",
  439. "reflect": true
  440. },
  441. "disableEscape": {
  442. "type": "boolean",
  443. "mutable": false,
  444. "complexType": {
  445. "original": "boolean",
  446. "resolved": "boolean",
  447. "references": {}
  448. },
  449. "required": false,
  450. "optional": false,
  451. "docs": {
  452. "tags": [],
  453. "text": "When `true`, disables the default close on escape behavior."
  454. },
  455. "attribute": "disable-escape",
  456. "reflect": true,
  457. "defaultValue": "false"
  458. },
  459. "scale": {
  460. "type": "string",
  461. "mutable": false,
  462. "complexType": {
  463. "original": "Scale",
  464. "resolved": "\"l\" | \"m\" | \"s\"",
  465. "references": {
  466. "Scale": {
  467. "location": "import",
  468. "path": "../interfaces"
  469. }
  470. }
  471. },
  472. "required": false,
  473. "optional": false,
  474. "docs": {
  475. "tags": [],
  476. "text": "Specifies the size of the component."
  477. },
  478. "attribute": "scale",
  479. "reflect": true,
  480. "defaultValue": "\"m\""
  481. },
  482. "width": {
  483. "type": "any",
  484. "mutable": false,
  485. "complexType": {
  486. "original": "Scale | number",
  487. "resolved": "\"l\" | \"m\" | \"s\" | number",
  488. "references": {
  489. "Scale": {
  490. "location": "import",
  491. "path": "../interfaces"
  492. }
  493. }
  494. },
  495. "required": false,
  496. "optional": false,
  497. "docs": {
  498. "tags": [],
  499. "text": "Specifies the width of the component. Can use scale sizes or pass a number (displays in pixels)."
  500. },
  501. "attribute": "width",
  502. "reflect": true,
  503. "defaultValue": "\"m\""
  504. },
  505. "fullscreen": {
  506. "type": "boolean",
  507. "mutable": false,
  508. "complexType": {
  509. "original": "boolean",
  510. "resolved": "boolean",
  511. "references": {}
  512. },
  513. "required": false,
  514. "optional": false,
  515. "docs": {
  516. "tags": [],
  517. "text": "Sets the component to always be fullscreen (overrides `width`)."
  518. },
  519. "attribute": "fullscreen",
  520. "reflect": true
  521. },
  522. "color": {
  523. "type": "string",
  524. "mutable": false,
  525. "complexType": {
  526. "original": "\"red\" | \"blue\"",
  527. "resolved": "\"blue\" | \"red\"",
  528. "references": {}
  529. },
  530. "required": false,
  531. "optional": true,
  532. "docs": {
  533. "tags": [],
  534. "text": "Adds a color bar to the top of component for visual impact.\nUse color to add importance to destructive or workflow dialogs."
  535. },
  536. "attribute": "color",
  537. "reflect": true
  538. },
  539. "backgroundColor": {
  540. "type": "string",
  541. "mutable": false,
  542. "complexType": {
  543. "original": "ModalBackgroundColor",
  544. "resolved": "\"grey\" | \"white\"",
  545. "references": {
  546. "ModalBackgroundColor": {
  547. "location": "import",
  548. "path": "./interfaces"
  549. }
  550. }
  551. },
  552. "required": false,
  553. "optional": false,
  554. "docs": {
  555. "tags": [],
  556. "text": "Sets the background color of the component's content."
  557. },
  558. "attribute": "background-color",
  559. "reflect": true,
  560. "defaultValue": "\"white\""
  561. },
  562. "noPadding": {
  563. "type": "boolean",
  564. "mutable": false,
  565. "complexType": {
  566. "original": "boolean",
  567. "resolved": "boolean",
  568. "references": {}
  569. },
  570. "required": false,
  571. "optional": false,
  572. "docs": {
  573. "tags": [{
  574. "name": "deprecated",
  575. "text": "Use `--calcite-modal-padding` CSS variable instead."
  576. }],
  577. "text": "When `true`, disables spacing to the content area slot."
  578. },
  579. "attribute": "no-padding",
  580. "reflect": true,
  581. "defaultValue": "false"
  582. }
  583. };
  584. }
  585. static get states() {
  586. return {
  587. "hasFooter": {},
  588. "isOpen": {}
  589. };
  590. }
  591. static get events() {
  592. return [{
  593. "method": "calciteModalBeforeClose",
  594. "name": "calciteModalBeforeClose",
  595. "bubbles": true,
  596. "cancelable": false,
  597. "composed": true,
  598. "docs": {
  599. "tags": [],
  600. "text": "Fires when the component is requested to be closed and before the closing transition begins."
  601. },
  602. "complexType": {
  603. "original": "void",
  604. "resolved": "void",
  605. "references": {}
  606. }
  607. }, {
  608. "method": "calciteModalClose",
  609. "name": "calciteModalClose",
  610. "bubbles": true,
  611. "cancelable": false,
  612. "composed": true,
  613. "docs": {
  614. "tags": [],
  615. "text": "Fires when the component is closed and animation is complete."
  616. },
  617. "complexType": {
  618. "original": "void",
  619. "resolved": "void",
  620. "references": {}
  621. }
  622. }, {
  623. "method": "calciteModalBeforeOpen",
  624. "name": "calciteModalBeforeOpen",
  625. "bubbles": true,
  626. "cancelable": false,
  627. "composed": true,
  628. "docs": {
  629. "tags": [],
  630. "text": "Fires when the component is added to the DOM but not rendered, and before the opening transition begins."
  631. },
  632. "complexType": {
  633. "original": "void",
  634. "resolved": "void",
  635. "references": {}
  636. }
  637. }, {
  638. "method": "calciteModalOpen",
  639. "name": "calciteModalOpen",
  640. "bubbles": true,
  641. "cancelable": false,
  642. "composed": true,
  643. "docs": {
  644. "tags": [],
  645. "text": "Fires when the component is open and animation is complete."
  646. },
  647. "complexType": {
  648. "original": "void",
  649. "resolved": "void",
  650. "references": {}
  651. }
  652. }];
  653. }
  654. static get methods() {
  655. return {
  656. "focusElement": {
  657. "complexType": {
  658. "signature": "(el?: HTMLElement) => Promise<void>",
  659. "parameters": [{
  660. "tags": [{
  661. "name": "param",
  662. "text": "el"
  663. }],
  664. "text": ""
  665. }],
  666. "references": {
  667. "Promise": {
  668. "location": "global"
  669. },
  670. "HTMLElement": {
  671. "location": "global"
  672. }
  673. },
  674. "return": "Promise<void>"
  675. },
  676. "docs": {
  677. "text": "Focus the first interactive element.",
  678. "tags": [{
  679. "name": "param",
  680. "text": "el"
  681. }, {
  682. "name": "deprecated",
  683. "text": "use `setFocus` instead."
  684. }]
  685. }
  686. },
  687. "setFocus": {
  688. "complexType": {
  689. "signature": "(focusId?: \"close-button\") => Promise<void>",
  690. "parameters": [{
  691. "tags": [{
  692. "name": "param",
  693. "text": "focusId"
  694. }],
  695. "text": ""
  696. }],
  697. "references": {
  698. "Promise": {
  699. "location": "global"
  700. }
  701. },
  702. "return": "Promise<void>"
  703. },
  704. "docs": {
  705. "text": "Sets focus on the component.\n\nBy default, tries to focus on focusable content. If there is none, it will focus on the close button.\nTo focus on the close button, use the `close-button` focus ID.",
  706. "tags": [{
  707. "name": "param",
  708. "text": "focusId"
  709. }]
  710. }
  711. },
  712. "scrollContent": {
  713. "complexType": {
  714. "signature": "(top?: number, left?: number) => Promise<void>",
  715. "parameters": [{
  716. "tags": [{
  717. "name": "param",
  718. "text": "top"
  719. }],
  720. "text": ""
  721. }, {
  722. "tags": [{
  723. "name": "param",
  724. "text": "left"
  725. }],
  726. "text": ""
  727. }],
  728. "references": {
  729. "Promise": {
  730. "location": "global"
  731. }
  732. },
  733. "return": "Promise<void>"
  734. },
  735. "docs": {
  736. "text": "Sets the scroll top of the component's content.",
  737. "tags": [{
  738. "name": "param",
  739. "text": "top"
  740. }, {
  741. "name": "param",
  742. "text": "left"
  743. }]
  744. }
  745. }
  746. };
  747. }
  748. static get elementRef() { return "el"; }
  749. static get watchers() {
  750. return [{
  751. "propName": "active",
  752. "methodName": "activeHandler"
  753. }, {
  754. "propName": "open",
  755. "methodName": "toggleModal"
  756. }];
  757. }
  758. static get listeners() {
  759. return [{
  760. "name": "keydown",
  761. "method": "handleEscape",
  762. "target": "window",
  763. "capture": false,
  764. "passive": false
  765. }];
  766. }
  767. }