calcite-popover_2.cjs.entry.js 23 KB

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