calcite-popover_2.entry.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  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 { r as registerInstance, c as createEvent, f as forceUpdate, h, H as Host, g as getElement } from './index-1f9b54dc.js';
  7. import { b as defaultOffsetDistance, f as filterComputedPlacements, c as connectFloatingUI, u as updateAfterClose, a as disconnectFloatingUI, r as reposition, F as FloatingCSS } from './floating-ui-5c49748f.js';
  8. import { g as guid } from './guid-9f15e57a.js';
  9. import { i as isPrimaryPointerButton, t as toAriaBoolean, q as queryElementRoots } from './dom-8f0a9ff2.js';
  10. import { c as connectOpenCloseComponent, d as disconnectOpenCloseComponent } from './openCloseComponent-ba7d452b.js';
  11. import { H as Heading } from './Heading-e0abf8a2.js';
  12. import { i as isActivationKey } from './key-acc755b7.js';
  13. import { c as createObserver } from './observers-9f44e9b3.js';
  14. import './debounce-d85a6654.js';
  15. import './resources-9c476cb6.js';
  16. const CSS = {
  17. container: "container",
  18. arrow: "arrow",
  19. imageContainer: "image-container",
  20. closeButtonContainer: "close-button-container",
  21. closeButton: "close-button",
  22. content: "content",
  23. hasHeader: "has-header",
  24. header: "header",
  25. headerContent: "header-content",
  26. heading: "heading"
  27. };
  28. const TEXT = {
  29. close: "Close"
  30. };
  31. const defaultPopoverPlacement = "auto";
  32. const ARIA_CONTROLS = "aria-controls";
  33. const ARIA_EXPANDED = "aria-expanded";
  34. const HEADING_LEVEL = 2;
  35. class PopoverManager$1 {
  36. constructor() {
  37. // --------------------------------------------------------------------------
  38. //
  39. // Private Properties
  40. //
  41. // --------------------------------------------------------------------------
  42. this.registeredElements = new Map();
  43. this.registeredElementCount = 0;
  44. // --------------------------------------------------------------------------
  45. //
  46. // Private Methods
  47. //
  48. // --------------------------------------------------------------------------
  49. this.queryPopover = (composedPath) => {
  50. const { registeredElements } = this;
  51. const registeredElement = composedPath.find((pathEl) => registeredElements.has(pathEl));
  52. return registeredElements.get(registeredElement);
  53. };
  54. this.togglePopovers = (event) => {
  55. const composedPath = event.composedPath();
  56. const togglePopover = this.queryPopover(composedPath);
  57. if (togglePopover && !togglePopover.triggerDisabled) {
  58. togglePopover.toggle();
  59. }
  60. Array.from(this.registeredElements.values())
  61. .filter((popover) => popover !== togglePopover && popover.autoClose && popover.open && !composedPath.includes(popover))
  62. .forEach((popover) => popover.toggle(false));
  63. };
  64. this.keyHandler = (event) => {
  65. if (event.defaultPrevented || !isActivationKey(event.key)) {
  66. return;
  67. }
  68. this.togglePopovers(event);
  69. };
  70. this.clickHandler = (event) => {
  71. if (isPrimaryPointerButton(event)) {
  72. this.togglePopovers(event);
  73. }
  74. };
  75. }
  76. // --------------------------------------------------------------------------
  77. //
  78. // Public Methods
  79. //
  80. // --------------------------------------------------------------------------
  81. registerElement(referenceEl, popover) {
  82. this.registeredElementCount++;
  83. this.registeredElements.set(referenceEl, popover);
  84. if (this.registeredElementCount === 1) {
  85. this.addListeners();
  86. }
  87. }
  88. unregisterElement(referenceEl) {
  89. if (this.registeredElements.delete(referenceEl)) {
  90. this.registeredElementCount--;
  91. }
  92. if (this.registeredElementCount === 0) {
  93. this.removeListeners();
  94. }
  95. }
  96. addListeners() {
  97. document.addEventListener("pointerdown", this.clickHandler, { capture: true });
  98. document.addEventListener("keydown", this.keyHandler, { capture: true });
  99. }
  100. removeListeners() {
  101. document.removeEventListener("pointerdown", this.clickHandler, { capture: true });
  102. document.removeEventListener("keydown", this.keyHandler, { capture: true });
  103. }
  104. }
  105. const popoverCss = "@keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in-down{0%{opacity:0;transform:translate3D(0, -5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;transform:translate3D(0, 5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-scale{0%{opacity:0;transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;animation-fill-mode:both;animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{animation-name:in}.calcite-animate__in-down{animation-name:in-down}.calcite-animate__in-up{animation-name:in-up}.calcite-animate__in-scale{animation-name:in-scale}@media (prefers-reduced-motion: reduce){:root{--calcite-internal-duration-factor:0.01}}:root{--calcite-floating-ui-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:block;position:absolute;z-index:900}.calcite-floating-ui-anim{position:relative;transition:var(--calcite-floating-ui-transition);visibility:hidden;transition-property:transform, visibility, opacity;opacity:0;box-shadow:0 0 16px 0 rgba(0, 0, 0, 0.16);z-index:1;border-radius:0.25rem}:host([data-placement^=bottom]) .calcite-floating-ui-anim{transform:translateY(-5px)}:host([data-placement^=top]) .calcite-floating-ui-anim{transform:translateY(5px)}:host([data-placement^=left]) .calcite-floating-ui-anim{transform:translateX(5px)}:host([data-placement^=right]) .calcite-floating-ui-anim{transform:translateX(-5px)}:host([data-placement]) .calcite-floating-ui-anim--active{opacity:1;visibility:visible;transform:translate(0)}:host([calcite-hydrated-hidden]){visibility:hidden !important;pointer-events:none}.arrow,.arrow::before{position:absolute;inline-size:8px;block-size:8px;z-index:-1}.arrow::before{content:\"\";--tw-shadow:0 4px 8px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);--tw-shadow-colored:0 4px 8px -1px var(--tw-shadow-color), 0 2px 4px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);transform:rotate(45deg);background:var(--calcite-ui-foreground-1)}:host([data-placement^=top]) .arrow{inset-block-end:-4px}:host([data-placement^=bottom]) .arrow{inset-block-start:-4px}:host([data-placement^=left]) .arrow{direction:ltr;inset-inline-end:-4px}:host([data-placement^=right]) .arrow{direction:ltr;inset-inline-start:-4px}:host{pointer-events:none}:host([open]){pointer-events:initial}.calcite-floating-ui-anim{border-radius:0.25rem;border-width:1px;border-style:solid;border-color:var(--calcite-ui-border-3);background-color:var(--calcite-ui-foreground-1)}.arrow::before{outline:1px solid var(--calcite-ui-border-3)}.header{display:flex;flex:1 1 auto;align-items:stretch;justify-content:flex-start;border-width:0px;border-block-end-width:1px;border-style:solid;background-color:var(--calcite-ui-foreground-1);border-block-end-color:var(--calcite-ui-border-3)}.heading{margin:0px;display:block;flex:1 1 auto;align-self:center;white-space:normal;padding-inline:1rem;padding-block:0.75rem;font-size:var(--calcite-font-size-0);line-height:1.375;font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-1);word-wrap:break-word;word-break:break-word}.container{position:relative;display:flex;block-size:100%;flex-direction:row;flex-wrap:nowrap;border-radius:0.25rem;background-color:var(--calcite-ui-foreground-1);color:var(--calcite-ui-text-1)}.container.has-header{flex-direction:column}.content{display:flex;block-size:100%;inline-size:100%;flex-direction:column;flex-wrap:nowrap;align-self:center;word-wrap:break-word;word-break:break-word}.close-button-container{display:flex;overflow:hidden;flex:0 0 auto;border-start-end-radius:0.25rem;border-end-end-radius:0.25rem}::slotted(calcite-panel),::slotted(calcite-flow){block-size:100%}";
  106. const manager = new PopoverManager$1();
  107. const Popover = class {
  108. constructor(hostRef) {
  109. registerInstance(this, hostRef);
  110. this.calcitePopoverBeforeClose = createEvent(this, "calcitePopoverBeforeClose", 6);
  111. this.calcitePopoverClose = createEvent(this, "calcitePopoverClose", 6);
  112. this.calcitePopoverBeforeOpen = createEvent(this, "calcitePopoverBeforeOpen", 6);
  113. this.calcitePopoverOpen = createEvent(this, "calcitePopoverOpen", 6);
  114. // --------------------------------------------------------------------------
  115. //
  116. // Properties
  117. //
  118. // --------------------------------------------------------------------------
  119. /**
  120. * When `true`, clicking outside of the component automatically closes open `calcite-popover`s.
  121. */
  122. this.autoClose = false;
  123. /**
  124. * When `true`, a close button is added to the component.
  125. *
  126. * @deprecated use dismissible instead.
  127. */
  128. this.closeButton = false;
  129. /**
  130. * When `true`, a close button is added to the component.
  131. *
  132. * @deprecated use `closable` instead.
  133. */
  134. this.dismissible = false;
  135. /** When `true`, display a close button within the component. */
  136. this.closable = false;
  137. /**
  138. * When `true`, prevents flipping the component's placement when overlapping its `referenceElement`.
  139. */
  140. this.disableFlip = false;
  141. /**
  142. * When `true`, removes the caret pointer.
  143. */
  144. this.disablePointer = false;
  145. /**
  146. * Offsets the position of the component away from the `referenceElement`.
  147. *
  148. * @default 6
  149. */
  150. this.offsetDistance = defaultOffsetDistance;
  151. /**
  152. * Offsets the position of the component along the `referenceElement`.
  153. */
  154. this.offsetSkidding = 0;
  155. /**
  156. * When `true`, displays and positions the component.
  157. */
  158. this.open = false;
  159. /**
  160. * Determines the type of positioning to use for the overlaid content.
  161. *
  162. * Using `"absolute"` will work for most cases. The component will be positioned inside of overflowing parent containers and will affect the container's layout.
  163. *
  164. * `"fixed"` value should be used to escape an overflowing parent container, or when the reference element's `position` CSS property is `"fixed"`.
  165. *
  166. */
  167. this.overlayPositioning = "absolute";
  168. /**
  169. * Determines where the component will be positioned relative to the `referenceElement`.
  170. *
  171. * @see [LogicalPlacement](https://github.com/Esri/calcite-components/blob/master/src/utils/floating-ui.ts#L25)
  172. */
  173. this.placement = defaultPopoverPlacement;
  174. /**
  175. * When `true`, disables automatically toggling the component when its `referenceElement` has been triggered.
  176. *
  177. * This property can be set to `true` to manage when the component is open.
  178. */
  179. this.triggerDisabled = false;
  180. /**
  181. * Accessible name for the component's close button.
  182. *
  183. * @default "Close"
  184. */
  185. this.intlClose = TEXT.close;
  186. this.guid = `calcite-popover-${guid()}`;
  187. this.openTransitionProp = "opacity";
  188. this.hasLoaded = false;
  189. // --------------------------------------------------------------------------
  190. //
  191. // Private Methods
  192. //
  193. // --------------------------------------------------------------------------
  194. this.setTransitionEl = (el) => {
  195. this.transitionEl = el;
  196. connectOpenCloseComponent(this);
  197. };
  198. this.setFilteredPlacements = () => {
  199. const { el, flipPlacements } = this;
  200. this.filteredFlipPlacements = flipPlacements
  201. ? filterComputedPlacements(flipPlacements, el)
  202. : null;
  203. };
  204. this.setUpReferenceElement = (warn = true) => {
  205. this.removeReferences();
  206. this.effectiveReferenceElement = this.getReferenceElement();
  207. connectFloatingUI(this, this.effectiveReferenceElement, this.el);
  208. const { el, referenceElement, effectiveReferenceElement } = this;
  209. if (warn && referenceElement && !effectiveReferenceElement) {
  210. console.warn(`${el.tagName}: reference-element id "${referenceElement}" was not found.`, {
  211. el
  212. });
  213. }
  214. this.addReferences();
  215. };
  216. this.getId = () => {
  217. return this.el.id || this.guid;
  218. };
  219. this.setExpandedAttr = () => {
  220. const { effectiveReferenceElement, open } = this;
  221. if (!effectiveReferenceElement) {
  222. return;
  223. }
  224. if ("setAttribute" in effectiveReferenceElement) {
  225. effectiveReferenceElement.setAttribute(ARIA_EXPANDED, toAriaBoolean(open));
  226. }
  227. };
  228. this.addReferences = () => {
  229. const { effectiveReferenceElement } = this;
  230. if (!effectiveReferenceElement) {
  231. return;
  232. }
  233. const id = this.getId();
  234. if ("setAttribute" in effectiveReferenceElement) {
  235. effectiveReferenceElement.setAttribute(ARIA_CONTROLS, id);
  236. }
  237. manager.registerElement(effectiveReferenceElement, this.el);
  238. this.setExpandedAttr();
  239. };
  240. this.removeReferences = () => {
  241. const { effectiveReferenceElement } = this;
  242. if (!effectiveReferenceElement) {
  243. return;
  244. }
  245. if ("removeAttribute" in effectiveReferenceElement) {
  246. effectiveReferenceElement.removeAttribute(ARIA_CONTROLS);
  247. effectiveReferenceElement.removeAttribute(ARIA_EXPANDED);
  248. }
  249. manager.unregisterElement(effectiveReferenceElement);
  250. };
  251. this.hide = () => {
  252. this.open = false;
  253. };
  254. this.storeArrowEl = (el) => {
  255. this.arrowEl = el;
  256. this.reposition(true);
  257. };
  258. }
  259. handleDismissible(value) {
  260. this.closable = value;
  261. }
  262. handleClosable(value) {
  263. this.dismissible = value;
  264. }
  265. flipPlacementsHandler() {
  266. this.setFilteredPlacements();
  267. this.reposition(true);
  268. }
  269. offsetDistanceOffsetHandler() {
  270. this.reposition(true);
  271. }
  272. offsetSkiddingHandler() {
  273. this.reposition(true);
  274. }
  275. openHandler(value) {
  276. if (value) {
  277. this.reposition(true);
  278. }
  279. else {
  280. updateAfterClose(this.el);
  281. }
  282. this.setExpandedAttr();
  283. }
  284. overlayPositioningHandler() {
  285. this.reposition(true);
  286. }
  287. placementHandler() {
  288. this.reposition(true);
  289. }
  290. referenceElementHandler() {
  291. this.setUpReferenceElement();
  292. this.reposition(true);
  293. }
  294. // --------------------------------------------------------------------------
  295. //
  296. // Lifecycle
  297. //
  298. // --------------------------------------------------------------------------
  299. connectedCallback() {
  300. this.setFilteredPlacements();
  301. connectOpenCloseComponent(this);
  302. const closable = this.closable || this.dismissible;
  303. if (closable) {
  304. this.handleDismissible(closable);
  305. }
  306. if (closable) {
  307. this.handleClosable(closable);
  308. }
  309. this.setUpReferenceElement(this.hasLoaded);
  310. }
  311. componentDidLoad() {
  312. if (this.referenceElement && !this.effectiveReferenceElement) {
  313. this.setUpReferenceElement();
  314. }
  315. this.reposition();
  316. this.hasLoaded = true;
  317. }
  318. disconnectedCallback() {
  319. this.removeReferences();
  320. disconnectFloatingUI(this, this.effectiveReferenceElement, this.el);
  321. disconnectOpenCloseComponent(this);
  322. }
  323. // --------------------------------------------------------------------------
  324. //
  325. // Public Methods
  326. //
  327. // --------------------------------------------------------------------------
  328. /**
  329. * Updates the position of the component.
  330. *
  331. * @param delayed
  332. */
  333. async reposition(delayed = false) {
  334. const { el, effectiveReferenceElement, placement, overlayPositioning, disableFlip, filteredFlipPlacements, offsetDistance, offsetSkidding, arrowEl } = this;
  335. return reposition(this, {
  336. floatingEl: el,
  337. referenceEl: effectiveReferenceElement,
  338. overlayPositioning,
  339. placement,
  340. disableFlip,
  341. flipPlacements: filteredFlipPlacements,
  342. offsetDistance,
  343. offsetSkidding,
  344. includeArrow: !this.disablePointer,
  345. arrowEl,
  346. type: "popover"
  347. }, delayed);
  348. }
  349. /**
  350. * Sets focus on the component.
  351. *
  352. * @param focusId
  353. */
  354. async setFocus(focusId) {
  355. var _a;
  356. const { closeButtonEl } = this;
  357. if (focusId === "close-button" && closeButtonEl) {
  358. forceUpdate(closeButtonEl);
  359. closeButtonEl.setFocus();
  360. return;
  361. }
  362. (_a = this.el) === null || _a === void 0 ? void 0 : _a.focus();
  363. }
  364. /**
  365. * Toggles the component's open property.
  366. *
  367. * @param value
  368. */
  369. async toggle(value = !this.open) {
  370. this.open = value;
  371. }
  372. getReferenceElement() {
  373. const { referenceElement, el } = this;
  374. return ((typeof referenceElement === "string"
  375. ? queryElementRoots(el, { id: referenceElement })
  376. : referenceElement) || null);
  377. }
  378. onBeforeOpen() {
  379. this.calcitePopoverBeforeOpen.emit();
  380. }
  381. onOpen() {
  382. this.calcitePopoverOpen.emit();
  383. }
  384. onBeforeClose() {
  385. this.calcitePopoverBeforeClose.emit();
  386. }
  387. onClose() {
  388. this.calcitePopoverClose.emit();
  389. }
  390. // --------------------------------------------------------------------------
  391. //
  392. // Render Methods
  393. //
  394. // --------------------------------------------------------------------------
  395. renderCloseButton() {
  396. const { closeButton, intlClose, heading, closable } = this;
  397. return closable || closeButton ? (h("div", { class: CSS.closeButtonContainer }, h("calcite-action", { class: CSS.closeButton, onClick: this.hide, ref: (closeButtonEl) => (this.closeButtonEl = closeButtonEl), scale: heading ? "s" : "m", text: intlClose }, h("calcite-icon", { icon: "x", scale: heading ? "s" : "m" })))) : null;
  398. }
  399. renderHeader() {
  400. const { heading, headingLevel } = this;
  401. const headingNode = heading ? (h(Heading, { class: CSS.heading, level: headingLevel || HEADING_LEVEL }, heading)) : null;
  402. return headingNode ? (h("div", { class: CSS.header }, headingNode, this.renderCloseButton())) : null;
  403. }
  404. render() {
  405. const { effectiveReferenceElement, heading, label, open, disablePointer } = this;
  406. const displayed = effectiveReferenceElement && open;
  407. const hidden = !displayed;
  408. const arrowNode = !disablePointer ? h("div", { class: CSS.arrow, ref: this.storeArrowEl }) : null;
  409. return (h(Host, { "aria-hidden": toAriaBoolean(hidden), "aria-label": label, "aria-live": "polite", "calcite-hydrated-hidden": hidden, id: this.getId(), role: "dialog" }, h("div", { class: {
  410. [FloatingCSS.animation]: true,
  411. [FloatingCSS.animationActive]: displayed
  412. }, ref: this.setTransitionEl }, arrowNode, h("div", { class: {
  413. [CSS.hasHeader]: !!heading,
  414. [CSS.container]: true
  415. } }, this.renderHeader(), h("div", { class: CSS.content }, h("slot", null)), !heading ? this.renderCloseButton() : null))));
  416. }
  417. get el() { return getElement(this); }
  418. static get watchers() { return {
  419. "dismissible": ["handleDismissible"],
  420. "closable": ["handleClosable"],
  421. "flipPlacements": ["flipPlacementsHandler"],
  422. "offsetDistance": ["offsetDistanceOffsetHandler"],
  423. "offsetSkidding": ["offsetSkiddingHandler"],
  424. "open": ["openHandler"],
  425. "overlayPositioning": ["overlayPositioningHandler"],
  426. "placement": ["placementHandler"],
  427. "referenceElement": ["referenceElementHandler"]
  428. }; }
  429. };
  430. Popover.style = popoverCss;
  431. const popoverManagerCss = "@keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in-down{0%{opacity:0;transform:translate3D(0, -5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;transform:translate3D(0, 5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-scale{0%{opacity:0;transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;animation-fill-mode:both;animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{animation-name:in}.calcite-animate__in-down{animation-name:in-down}.calcite-animate__in-up{animation-name:in-up}.calcite-animate__in-scale{animation-name:in-scale}@media (prefers-reduced-motion: reduce){:root{--calcite-internal-duration-factor:0.01}}:root{--calcite-floating-ui-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{position:relative;display:block}";
  432. const PopoverManager = class {
  433. constructor(hostRef) {
  434. registerInstance(this, hostRef);
  435. this.mutationObserver = createObserver("mutation", () => this.setAutoClose());
  436. // --------------------------------------------------------------------------
  437. //
  438. // Properties
  439. //
  440. // --------------------------------------------------------------------------
  441. /**
  442. * CSS Selector to match reference elements for popovers. Reference elements will be identified by this selector in order to open their associated popover.
  443. *
  444. * @default `[data-calcite-popover-reference]`
  445. */
  446. this.selector = "[data-calcite-popover-reference]";
  447. /**
  448. * Automatically closes any currently open popovers when clicking outside of a popover.
  449. */
  450. this.autoClose = false;
  451. }
  452. autoCloseHandler() {
  453. this.setAutoClose();
  454. }
  455. // --------------------------------------------------------------------------
  456. //
  457. // Lifecycle
  458. //
  459. // --------------------------------------------------------------------------
  460. connectedCallback() {
  461. var _a;
  462. this.setAutoClose();
  463. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
  464. }
  465. disconnectedCallback() {
  466. var _a;
  467. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
  468. }
  469. // --------------------------------------------------------------------------
  470. //
  471. // Render Methods
  472. //
  473. // --------------------------------------------------------------------------
  474. render() {
  475. return h("slot", null);
  476. }
  477. // --------------------------------------------------------------------------
  478. //
  479. // Private Methods
  480. //
  481. // --------------------------------------------------------------------------
  482. setAutoClose() {
  483. const { autoClose, el } = this;
  484. el.querySelectorAll("calcite-popover").forEach((popover) => (popover.autoClose = autoClose));
  485. }
  486. get el() { return getElement(this); }
  487. static get watchers() { return {
  488. "autoClose": ["autoCloseHandler"]
  489. }; }
  490. };
  491. PopoverManager.style = popoverManagerCss;
  492. export { Popover as calcite_popover, PopoverManager as calcite_popover_manager };