calcite-tip_3.cjs.entry.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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.82
  5. */
  6. 'use strict';
  7. Object.defineProperty(exports, '__esModule', { value: true });
  8. const index = require('./index-5c65e149.js');
  9. const dom = require('./dom-9ac0341c.js');
  10. const Heading = require('./Heading-0cb5902d.js');
  11. const conditionalSlot = require('./conditionalSlot-ba5cd797.js');
  12. const observers = require('./observers-d9fdf006.js');
  13. require('./guid-8b6d6cb4.js');
  14. const CSS$1 = {
  15. header: "header",
  16. heading: "heading",
  17. close: "close",
  18. container: "container",
  19. tipContainer: "tip-container",
  20. tipContainerAdvancing: "tip-container--advancing",
  21. tipContainerRetreating: "tip-container--retreating",
  22. pagination: "pagination",
  23. pagePosition: "page-position",
  24. pageNext: "page-next",
  25. pagePrevious: "page-previous"
  26. };
  27. const ICONS$1 = {
  28. chevronLeft: "chevron-left",
  29. chevronRight: "chevron-right",
  30. close: "x"
  31. };
  32. const TEXT$1 = {
  33. defaultGroupTitle: "Tips",
  34. defaultPaginationLabel: "Tip",
  35. close: "Close",
  36. previous: "Previous",
  37. next: "Next"
  38. };
  39. const HEADING_LEVEL$1 = 2;
  40. const CSS = {
  41. container: "container",
  42. header: "header",
  43. heading: "heading",
  44. close: "close",
  45. imageFrame: "image-frame",
  46. content: "content",
  47. info: "info"
  48. };
  49. const ICONS = {
  50. close: "x"
  51. };
  52. const SLOTS = {
  53. thumbnail: "thumbnail"
  54. };
  55. const TEXT = {
  56. close: "Close"
  57. };
  58. const HEADING_LEVEL = (HEADING_LEVEL$1 + 1);
  59. const tipCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 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;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{position:relative;margin:1rem;-webkit-box-sizing:border-box;box-sizing:border-box;display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;border-width:1px;border-style:solid;border-color:var(--calcite-ui-border-2);background-color:var(--calcite-ui-foreground-1);font-size:var(--calcite-font-size--1);line-height:1rem;color:var(--calcite-ui-text-2)}:host *{-webkit-box-sizing:border-box;box-sizing:border-box}.container{width:100%;padding:1rem}:host([dismissed]),:host([dismissed]) .container{display:none}:host([selected]) .container{margin:0px;border-style:none;padding:0px}.header{margin:0px;display:-ms-flexbox;display:flex;-ms-flex-line-pack:justify;align-content:space-between;-ms-flex-align:center;align-items:center;fill:var(--calcite-ui-text-2);color:var(--calcite-ui-text-2)}.heading{margin:0px;padding:0px;font-weight:var(--calcite-font-weight-medium)}.header .heading{-ms-flex:1 1 auto;flex:1 1 auto;padding:0.5rem}h1.heading{font-size:var(--calcite-font-size-2);line-height:1.5rem}h2.heading{font-size:var(--calcite-font-size-1);line-height:1.5rem}h3.heading{font-size:var(--calcite-font-size-0);line-height:1.25rem}h4.heading,h5.heading{font-size:var(--calcite-font-size--1);line-height:1rem}.header{margin-bottom:0.5rem}.header .heading{padding:0px;color:var(--calcite-ui-text-1)}.container[hidden]{display:none}.content{display:-ms-flexbox;display:flex}.info{padding-top:0px;padding-bottom:0px;padding-left:1rem;padding-right:1rem;width:70%}.info:only-child{width:100%;padding-left:0px;padding-right:0px}::slotted(p){margin-top:0px}::slotted(a){outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;color:var(--calcite-ui-brand)}::slotted(a:focus){outline:2px solid var(--calcite-ui-brand);outline-offset:2px}.image-frame{width:25%}.image-frame img{max-width:100%}::slotted(img){max-width:100%}";
  60. const Tip = class {
  61. constructor(hostRef) {
  62. index.registerInstance(this, hostRef);
  63. this.calciteTipDismiss = index.createEvent(this, "calciteTipDismiss", 7);
  64. // --------------------------------------------------------------------------
  65. //
  66. // Properties
  67. //
  68. // --------------------------------------------------------------------------
  69. /**
  70. * No longer displays the tip.
  71. */
  72. this.dismissed = false;
  73. /**
  74. * Indicates whether the tip can be dismissed.
  75. */
  76. this.nonDismissible = false;
  77. /**
  78. * The selected state of the tip if it is being used inside a `calcite-tip-manager`.
  79. */
  80. this.selected = false;
  81. // --------------------------------------------------------------------------
  82. //
  83. // Private Methods
  84. //
  85. // --------------------------------------------------------------------------
  86. this.hideTip = () => {
  87. this.dismissed = true;
  88. this.calciteTipDismiss.emit();
  89. };
  90. }
  91. // --------------------------------------------------------------------------
  92. //
  93. // Lifecycle
  94. //
  95. // --------------------------------------------------------------------------
  96. connectedCallback() {
  97. conditionalSlot.connectConditionalSlotComponent(this);
  98. }
  99. disconnectedCallback() {
  100. conditionalSlot.disconnectConditionalSlotComponent(this);
  101. }
  102. // --------------------------------------------------------------------------
  103. //
  104. // Render Methods
  105. //
  106. // --------------------------------------------------------------------------
  107. renderHeader() {
  108. var _a;
  109. const { heading, headingLevel, el } = this;
  110. const parentLevel = (_a = el.closest("calcite-tip-manager")) === null || _a === void 0 ? void 0 : _a.headingLevel;
  111. const relativeLevel = parentLevel ? Heading.constrainHeadingLevel(parentLevel + 1) : null;
  112. const level = headingLevel || relativeLevel || HEADING_LEVEL;
  113. return heading ? (index.h("header", { class: CSS.header }, index.h(Heading.Heading, { class: CSS.heading, level: level }, heading))) : null;
  114. }
  115. renderDismissButton() {
  116. const { nonDismissible, hideTip, intlClose } = this;
  117. const text = intlClose || TEXT.close;
  118. return !nonDismissible ? (index.h("calcite-action", { class: CSS.close, icon: ICONS.close, onClick: hideTip, scale: "l", text: text })) : null;
  119. }
  120. renderImageFrame() {
  121. const { el } = this;
  122. return dom.getSlotted(el, SLOTS.thumbnail) ? (index.h("div", { class: CSS.imageFrame, key: "thumbnail" }, index.h("slot", { name: SLOTS.thumbnail }))) : null;
  123. }
  124. renderInfoNode() {
  125. return (index.h("div", { class: CSS.info }, index.h("slot", null)));
  126. }
  127. renderContent() {
  128. return (index.h("div", { class: CSS.content }, this.renderImageFrame(), this.renderInfoNode()));
  129. }
  130. render() {
  131. return (index.h(index.Fragment, null, index.h("article", { class: CSS.container }, this.renderHeader(), this.renderContent()), this.renderDismissButton()));
  132. }
  133. get el() { return index.getElement(this); }
  134. };
  135. Tip.style = tipCss;
  136. const tipGroupCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 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;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{-webkit-box-sizing:border-box;box-sizing:border-box;display:block;background-color:var(--calcite-ui-foreground-1);font-size:var(--calcite-font-size--1);line-height:1rem;color:var(--calcite-ui-text-2)}::slotted(calcite-tip){margin:0px;border-style:none}:host-context(calcite-tip-manager){margin-top:0.75rem;margin-bottom:0.75rem}:host-context(calcite-tip-manager) ::slotted(calcite-tip){padding:1rem}";
  137. const TipGroup = class {
  138. constructor(hostRef) {
  139. index.registerInstance(this, hostRef);
  140. }
  141. render() {
  142. return index.h("slot", null);
  143. }
  144. };
  145. TipGroup.style = tipGroupCss;
  146. const tipManagerCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 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;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{-webkit-box-sizing:border-box;box-sizing:border-box;display:block;background-color:var(--calcite-ui-foreground-1);font-size:var(--calcite-font-size--1);line-height:1rem;color:var(--calcite-ui-text-2);--calcite-tip-manager-height:19vh}:host *{-webkit-box-sizing:border-box;box-sizing:border-box}:host([closed]){display:none}.header{margin:0px;display:-ms-flexbox;display:flex;-ms-flex-line-pack:justify;align-content:space-between;-ms-flex-align:center;align-items:center;fill:var(--calcite-ui-text-2);color:var(--calcite-ui-text-2)}.heading{margin:0px;padding:0px;font-weight:var(--calcite-font-weight-medium)}.header .heading{-ms-flex:1 1 auto;flex:1 1 auto;padding:0.5rem}h1.heading{font-size:var(--calcite-font-size-2);line-height:1.5rem}h2.heading{font-size:var(--calcite-font-size-1);line-height:1.5rem}h3.heading{font-size:var(--calcite-font-size-0);line-height:1.25rem}h4.heading,h5.heading{font-size:var(--calcite-font-size--1);line-height:1rem}.header{border-width:0px;border-bottom-width:1px;border-style:solid;border-color:var(--calcite-ui-border-3);padding-top:0px;padding-bottom:0px;-webkit-padding-end:0px;padding-inline-end:0px;-webkit-padding-start:1rem;padding-inline-start:1rem}.header h2.heading{padding:0px;font-size:var(--calcite-font-size-1);line-height:1.5rem;font-weight:var(--calcite-font-weight-bold);color:var(--calcite-ui-text-1)}.container{position:relative;overflow:hidden;outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;min-height:150px}.container:focus{outline:2px solid var(--calcite-ui-brand);outline-offset:2px}.tip-container{margin-top:1px;display:-ms-flexbox;display:flex;-ms-flex-align:start;align-items:flex-start;-ms-flex-pack:center;justify-content:center;overflow:auto;outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;-webkit-animation-name:none;animation-name:none;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing);height:var(--calcite-tip-manager-height)}.tip-container:focus{outline:2px solid var(--calcite-ui-brand);outline-offset:2px}::slotted(calcite-tip){border-style:none;padding:0.75rem;max-width:var(--calcite-tip-max-width)}.tip-container--advancing{-webkit-animation-name:tip-advance;animation-name:tip-advance}.tip-container--retreating{-webkit-animation-name:tip-retreat;animation-name:tip-retreat}.pagination{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;padding-left:0px;padding-right:0px;padding-top:0.75rem;padding-bottom:0.5rem}.page-position{margin-top:0px;margin-bottom:0px;margin-left:0.5rem;margin-right:0.5rem;font-size:var(--calcite-font-size--2);line-height:1rem}@-webkit-keyframes tip-advance{0%{opacity:0;-webkit-transform:translate3d(50px, 0, 0) scale(0.99);transform:translate3d(50px, 0, 0) scale(0.99)}100%{opacity:1;-webkit-transform:translate3d(0, 0, 0) scale(1);transform:translate3d(0, 0, 0) scale(1)}}@keyframes tip-advance{0%{opacity:0;-webkit-transform:translate3d(50px, 0, 0) scale(0.99);transform:translate3d(50px, 0, 0) scale(0.99)}100%{opacity:1;-webkit-transform:translate3d(0, 0, 0) scale(1);transform:translate3d(0, 0, 0) scale(1)}}@-webkit-keyframes tip-retreat{0%{opacity:0;-webkit-transform:translate3d(-50px, 0, 0) scale(0.99);transform:translate3d(-50px, 0, 0) scale(0.99)}100%{opacity:1;-webkit-transform:translate3d(0, 0, 0) scale(1);transform:translate3d(0, 0, 0) scale(1)}}@keyframes tip-retreat{0%{opacity:0;-webkit-transform:translate3d(-50px, 0, 0) scale(0.99);transform:translate3d(-50px, 0, 0) scale(0.99)}100%{opacity:1;-webkit-transform:translate3d(0, 0, 0) scale(1);transform:translate3d(0, 0, 0) scale(1)}}";
  147. const TipManager = class {
  148. constructor(hostRef) {
  149. index.registerInstance(this, hostRef);
  150. this.calciteTipManagerToggle = index.createEvent(this, "calciteTipManagerToggle", 7);
  151. this.calciteTipManagerClose = index.createEvent(this, "calciteTipManagerClose", 7);
  152. // --------------------------------------------------------------------------
  153. //
  154. // Properties
  155. //
  156. // --------------------------------------------------------------------------
  157. /**
  158. * Closed state of the `calcite-tip-manager`.
  159. */
  160. this.closed = false;
  161. this.mutationObserver = observers.createObserver("mutation", () => this.setUpTips());
  162. this.hideTipManager = () => {
  163. this.closed = true;
  164. this.calciteTipManagerToggle.emit();
  165. this.calciteTipManagerClose.emit();
  166. };
  167. this.previousClicked = () => {
  168. this.previousTip();
  169. };
  170. this.nextClicked = () => {
  171. this.nextTip();
  172. };
  173. this.tipManagerKeyUpHandler = (event) => {
  174. if (event.target !== this.container) {
  175. return;
  176. }
  177. switch (event.key) {
  178. case "ArrowRight":
  179. event.preventDefault();
  180. this.nextTip();
  181. break;
  182. case "ArrowLeft":
  183. event.preventDefault();
  184. this.previousTip();
  185. break;
  186. case "Home":
  187. event.preventDefault();
  188. this.selectedIndex = 0;
  189. break;
  190. case "End":
  191. event.preventDefault();
  192. this.selectedIndex = this.total - 1;
  193. break;
  194. }
  195. };
  196. this.storeContainerRef = (el) => {
  197. this.container = el;
  198. };
  199. }
  200. closedChangeHandler() {
  201. this.direction = null;
  202. this.calciteTipManagerToggle.emit();
  203. }
  204. selectedChangeHandler() {
  205. this.showSelectedTip();
  206. this.updateGroupTitle();
  207. }
  208. // --------------------------------------------------------------------------
  209. //
  210. // Lifecycle
  211. //
  212. // --------------------------------------------------------------------------
  213. connectedCallback() {
  214. var _a;
  215. this.setUpTips();
  216. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
  217. }
  218. disconnectedCallback() {
  219. var _a;
  220. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
  221. }
  222. // --------------------------------------------------------------------------
  223. //
  224. // Public Methods
  225. //
  226. // --------------------------------------------------------------------------
  227. /** Selects the next tip to display */
  228. async nextTip() {
  229. this.direction = "advancing";
  230. const nextIndex = this.selectedIndex + 1;
  231. this.selectedIndex = (nextIndex + this.total) % this.total;
  232. }
  233. /** Selects the previous tip to display */
  234. async previousTip() {
  235. this.direction = "retreating";
  236. const previousIndex = this.selectedIndex - 1;
  237. this.selectedIndex = (previousIndex + this.total) % this.total;
  238. }
  239. // --------------------------------------------------------------------------
  240. //
  241. // Private Methods
  242. //
  243. // --------------------------------------------------------------------------
  244. setUpTips() {
  245. const tips = Array.from(this.el.querySelectorAll("calcite-tip"));
  246. this.total = tips.length;
  247. if (this.total === 0) {
  248. return;
  249. }
  250. const selectedTip = this.el.querySelector("calcite-tip[selected]");
  251. this.tips = tips;
  252. this.selectedIndex = selectedTip ? tips.indexOf(selectedTip) : 0;
  253. tips.forEach((tip) => {
  254. tip.nonDismissible = true;
  255. });
  256. this.showSelectedTip();
  257. this.updateGroupTitle();
  258. }
  259. showSelectedTip() {
  260. this.tips.forEach((tip, index) => {
  261. const isSelected = this.selectedIndex === index;
  262. tip.selected = isSelected;
  263. tip.hidden = !isSelected;
  264. });
  265. }
  266. updateGroupTitle() {
  267. const selectedTip = this.tips[this.selectedIndex];
  268. const tipParent = selectedTip.closest("calcite-tip-group");
  269. this.groupTitle = (tipParent === null || tipParent === void 0 ? void 0 : tipParent.groupTitle) || this.intlDefaultTitle || TEXT$1.defaultGroupTitle;
  270. }
  271. // --------------------------------------------------------------------------
  272. //
  273. // Render Methods
  274. //
  275. // --------------------------------------------------------------------------
  276. renderPagination() {
  277. const dir = dom.getElementDir(this.el);
  278. const { selectedIndex, tips, total, intlNext, intlPrevious, intlPaginationLabel } = this;
  279. const nextLabel = intlNext || TEXT$1.next;
  280. const previousLabel = intlPrevious || TEXT$1.previous;
  281. const paginationLabel = intlPaginationLabel || TEXT$1.defaultPaginationLabel;
  282. return tips.length > 1 ? (index.h("footer", { class: CSS$1.pagination }, index.h("calcite-action", { class: CSS$1.pagePrevious, icon: dir === "ltr" ? ICONS$1.chevronLeft : ICONS$1.chevronRight, onClick: this.previousClicked, scale: "m", text: previousLabel }), index.h("span", { class: CSS$1.pagePosition }, `${paginationLabel} ${selectedIndex + 1}/${total}`), index.h("calcite-action", { class: CSS$1.pageNext, icon: dir === "ltr" ? ICONS$1.chevronRight : ICONS$1.chevronLeft, onClick: this.nextClicked, scale: "m", text: nextLabel }))) : null;
  283. }
  284. render() {
  285. const { closed, direction, headingLevel, groupTitle, selectedIndex, intlClose, total } = this;
  286. const closeLabel = intlClose || TEXT$1.close;
  287. if (total === 0) {
  288. return null;
  289. }
  290. return (index.h("section", { "aria-hidden": dom.toAriaBoolean(closed), class: CSS$1.container, hidden: closed, onKeyUp: this.tipManagerKeyUpHandler, ref: this.storeContainerRef, tabIndex: 0 }, index.h("header", { class: CSS$1.header }, index.h(Heading.Heading, { class: CSS$1.heading, level: headingLevel || HEADING_LEVEL$1 }, groupTitle), index.h("calcite-action", { class: CSS$1.close, onClick: this.hideTipManager, scale: "m", text: closeLabel }, index.h("calcite-icon", { icon: ICONS$1.close, scale: "m" }))), index.h("div", { class: {
  291. [CSS$1.tipContainer]: true,
  292. [CSS$1.tipContainerAdvancing]: !closed && direction === "advancing",
  293. [CSS$1.tipContainerRetreating]: !closed && direction === "retreating"
  294. }, key: selectedIndex, tabIndex: 0 }, index.h("slot", null)), this.renderPagination()));
  295. }
  296. get el() { return index.getElement(this); }
  297. static get watchers() { return {
  298. "closed": ["closedChangeHandler"],
  299. "selectedIndex": ["selectedChangeHandler"]
  300. }; }
  301. };
  302. TipManager.style = tipManagerCss;
  303. exports.calcite_tip = Tip;
  304. exports.calcite_tip_group = TipGroup;
  305. exports.calcite_tip_manager = TipManager;