calcite-tip_3.entry.js 24 KB

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