calcite-shell_3.cjs.entry.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  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 dom = require('./dom-2ec8c9ed.js');
  10. const conditionalSlot = require('./conditionalSlot-ef852d9d.js');
  11. const math = require('./math-f71ad83a.js');
  12. require('./resources-b5a5f8a7.js');
  13. require('./guid-f4f03a7a.js');
  14. require('./observers-5706326b.js');
  15. const CSS$2 = {
  16. main: "main",
  17. mainReversed: "main--reversed",
  18. content: "content",
  19. contentBehind: "content--behind",
  20. footer: "footer"
  21. };
  22. const SLOTS$2 = {
  23. centerRow: "center-row",
  24. primaryPanel: "primary-panel",
  25. contextualPanel: "contextual-panel",
  26. panelStart: "panel-start",
  27. panelEnd: "panel-end",
  28. header: "header",
  29. footer: "footer"
  30. };
  31. const shellCss = "@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}}:host{box-sizing:border-box;background-color:var(--calcite-ui-foreground-1);color:var(--calcite-ui-text-2);font-size:var(--calcite-font-size--1)}:host *{box-sizing:border-box}:root{--calcite-floating-ui-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{position:absolute;inset:0px;display:flex;block-size:100%;inline-size:100%;flex-direction:column;overflow:hidden;--calcite-shell-tip-spacing:26vw}.main{position:relative;display:flex;block-size:100%;inline-size:100%;flex:1 1 auto;flex-direction:row;justify-content:space-between;overflow:hidden}.main--reversed{flex-direction:row-reverse}.content{display:flex;block-size:100%;inline-size:100%;flex-direction:column;flex-wrap:nowrap;overflow:auto}.content ::slotted(calcite-shell-center-row),.content ::slotted(calcite-panel),.content ::slotted(calcite-flow){flex:1 1 auto;align-self:stretch;max-block-size:unset}.content--behind{position:absolute;inset:0px;border-width:0px;z-index:calc(1 - 1);display:initial}::slotted(calcite-shell-center-row){inline-size:unset}::slotted(.header .heading){font-size:var(--calcite-font-size--2);line-height:1.375;font-weight:var(--calcite-font-weight-normal)}slot[name=panel-end]::slotted(calcite-shell-panel){margin-inline-start:auto}::slotted(calcite-shell-panel),::slotted(calcite-shell-center-row){position:relative;z-index:1}::slotted(calcite-panel),::slotted(calcite-flow){border-width:1px;border-inline-start-width:0px;border-inline-end-width:0px;border-style:solid;border-color:var(--calcite-ui-border-3)}slot[name=center-row]::slotted(calcite-shell-center-row:not([detached])){border-inline-start-width:1px;border-inline-end-width:1px;border-color:var(--calcite-ui-border-3)}::slotted(calcite-tip-manager){position:absolute;z-index:500;box-sizing:border-box}@keyframes in-up{0%{opacity:0;transform:translate3D(0, 5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}::slotted(calcite-tip-manager){animation:in-up var(--calcite-internal-animation-timing-slow) ease-in-out;border-radius:0.25rem;--tw-shadow:0 6px 20px -4px rgba(0, 0, 0, 0.1), 0 4px 12px -2px rgba(0, 0, 0, 0.08);--tw-shadow-colored:0 6px 20px -4px var(--tw-shadow-color), 0 4px 12px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);inset-block-end:0.5rem;inset-inline:var(--calcite-shell-tip-spacing)}";
  32. const Shell = class {
  33. constructor(hostRef) {
  34. index.registerInstance(this, hostRef);
  35. // --------------------------------------------------------------------------
  36. //
  37. // Properties
  38. //
  39. // --------------------------------------------------------------------------
  40. /**
  41. * Positions the center content behind any `calcite-shell-panel`s.
  42. */
  43. this.contentBehind = false;
  44. }
  45. // --------------------------------------------------------------------------
  46. //
  47. // Lifecycle
  48. //
  49. // --------------------------------------------------------------------------
  50. connectedCallback() {
  51. conditionalSlot.connectConditionalSlotComponent(this);
  52. }
  53. disconnectedCallback() {
  54. conditionalSlot.disconnectConditionalSlotComponent(this);
  55. }
  56. // --------------------------------------------------------------------------
  57. //
  58. // Render Methods
  59. //
  60. // --------------------------------------------------------------------------
  61. renderHeader() {
  62. const hasHeader = !!dom.getSlotted(this.el, SLOTS$2.header);
  63. return hasHeader ? index.h("slot", { key: "header", name: SLOTS$2.header }) : null;
  64. }
  65. renderContent() {
  66. const defaultSlotNode = index.h("slot", { key: "default-slot" });
  67. const centerRowSlotNode = index.h("slot", { key: "center-row-slot", name: SLOTS$2.centerRow });
  68. const contentContainerKey = "content-container";
  69. const content = !!this.contentBehind
  70. ? [
  71. index.h("div", { class: {
  72. [CSS$2.content]: true,
  73. [CSS$2.contentBehind]: true
  74. }, key: contentContainerKey }, defaultSlotNode),
  75. centerRowSlotNode
  76. ]
  77. : [
  78. index.h("div", { class: CSS$2.content, key: contentContainerKey }, defaultSlotNode, centerRowSlotNode)
  79. ];
  80. return content;
  81. }
  82. renderFooter() {
  83. const hasFooter = !!dom.getSlotted(this.el, SLOTS$2.footer);
  84. return hasFooter ? (index.h("div", { class: CSS$2.footer, key: "footer" }, index.h("slot", { name: SLOTS$2.footer }))) : null;
  85. }
  86. renderMain() {
  87. const primaryPanel = dom.getSlotted(this.el, SLOTS$2.primaryPanel);
  88. const mainClasses = {
  89. [CSS$2.main]: true,
  90. [CSS$2.mainReversed]: (primaryPanel === null || primaryPanel === void 0 ? void 0 : primaryPanel.position) === "end"
  91. };
  92. return (index.h("div", { class: mainClasses }, index.h("slot", { name: SLOTS$2.primaryPanel }), index.h("slot", { name: SLOTS$2.panelStart }), this.renderContent(), index.h("slot", { name: SLOTS$2.panelEnd }), index.h("slot", { name: SLOTS$2.contextualPanel })));
  93. }
  94. render() {
  95. return (index.h(index.Fragment, null, this.renderHeader(), this.renderMain(), this.renderFooter()));
  96. }
  97. get el() { return index.getElement(this); }
  98. };
  99. Shell.style = shellCss;
  100. const CSS$1 = {
  101. actionBarContainer: "action-bar-container",
  102. content: "content"
  103. };
  104. const SLOTS$1 = {
  105. actionBar: "action-bar"
  106. };
  107. const shellCenterRowCss = "@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}}:host{box-sizing:border-box;background-color:var(--calcite-ui-foreground-1);color:var(--calcite-ui-text-2);font-size:var(--calcite-font-size--1)}:host *{box-sizing:border-box}:root{--calcite-floating-ui-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:flex;flex:1 1 auto;overflow:hidden;background-color:transparent}.content{margin:0px;display:flex;block-size:100%;inline-size:100%;overflow:hidden;flex:1 0 0}.action-bar-container{display:flex}:host([detached]){margin-inline:0.5rem;margin-block:0.5rem 1.5rem}@keyframes in-up{0%{opacity:0;transform:translate3D(0, 5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}:host([detached]){animation:in-up var(--calcite-internal-animation-timing-slow) ease-in-out;border-radius:0.25rem;border-width:0px;--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)}:host([position=end]){align-self:flex-end}:host([position=start]){align-self:flex-start}:host([height-scale=s]){block-size:33.333333%}:host([height-scale=m]){block-size:70%}:host([height-scale=l]){block-size:100%}:host([height-scale=l][detached]){block-size:calc(100% - 2rem)}::slotted(calcite-panel){block-size:100%;inline-size:100%}::slotted(calcite-action-bar),::slotted(calcite-action-bar[position=end]){border-inline-end:1px solid;border-color:var(--calcite-ui-border-3)}";
  108. const ShellCenterRow = class {
  109. constructor(hostRef) {
  110. index.registerInstance(this, hostRef);
  111. // --------------------------------------------------------------------------
  112. //
  113. // Properties
  114. //
  115. // --------------------------------------------------------------------------
  116. /**
  117. * When `true`, the content area displays like a floating panel.
  118. */
  119. this.detached = false;
  120. /**
  121. * Specifies the maximum height of the component.
  122. */
  123. this.heightScale = "s";
  124. /**
  125. * Specifies the component's position. Will be flipped when the element direction is right-to-left (`"rtl"`).
  126. */
  127. this.position = "end";
  128. }
  129. // --------------------------------------------------------------------------
  130. //
  131. // Lifecycle
  132. //
  133. // --------------------------------------------------------------------------
  134. connectedCallback() {
  135. conditionalSlot.connectConditionalSlotComponent(this);
  136. }
  137. disconnectedCallback() {
  138. conditionalSlot.disconnectConditionalSlotComponent(this);
  139. }
  140. // --------------------------------------------------------------------------
  141. //
  142. // Render Methods
  143. //
  144. // --------------------------------------------------------------------------
  145. render() {
  146. const { el } = this;
  147. const contentNode = (index.h("div", { class: CSS$1.content }, index.h("slot", null)));
  148. const actionBar = dom.getSlotted(el, SLOTS$1.actionBar);
  149. const actionBarNode = actionBar ? (index.h("div", { class: CSS$1.actionBarContainer, key: "action-bar" }, index.h("slot", { name: SLOTS$1.actionBar }))) : null;
  150. const children = [actionBarNode, contentNode];
  151. if ((actionBar === null || actionBar === void 0 ? void 0 : actionBar.position) === "end") {
  152. children.reverse();
  153. }
  154. return index.h(index.Fragment, null, children);
  155. }
  156. get el() { return index.getElement(this); }
  157. };
  158. ShellCenterRow.style = shellCenterRowCss;
  159. const CSS = {
  160. container: "container",
  161. content: "content",
  162. contentHeader: "content__header",
  163. contentBody: "content__body",
  164. contentDetached: "content--detached",
  165. separator: "separator"
  166. };
  167. const SLOTS = {
  168. actionBar: "action-bar",
  169. header: "header"
  170. };
  171. const TEXT = {
  172. resize: "Resize"
  173. };
  174. const shellPanelCss = "@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{pointer-events:none;display:flex;flex:0 1 auto;align-items:stretch;--calcite-shell-panel-detached-max-height:unset}.container{pointer-events:none;box-sizing:border-box;display:flex;flex:1 1 auto;align-items:stretch;background-color:transparent;font-size:var(--calcite-font-size--1);color:var(--calcite-ui-text-2)}.container *{box-sizing:border-box}:host(:hover) .separator:not(:hover):not(:focus),:host(:focus-within) .separator:not(:hover):not(:focus){opacity:1;background-color:var(--calcite-ui-border-3)}.separator{pointer-events:auto;position:absolute;inset-block:0px;display:flex;block-size:100%;inline-size:0.125rem;background-color:transparent;opacity:0;transition:all var(--calcite-animation-timing) ease-in-out 0s, outline 0s, outline-offset 0s;cursor:col-resize;outline:none}.separator:hover{opacity:1;background-color:var(--calcite-ui-border-2)}.separator:focus{background-color:var(--calcite-ui-brand);opacity:1}:host([position=start]) .separator{inset-inline-end:-2px}:host([position=end]) .separator{inset-inline-start:-2px}::slotted(calcite-panel),::slotted(calcite-flow){block-size:100%;inline-size:100%;flex:1 1 auto;max-block-size:unset;max-inline-size:unset}::slotted(.calcite-match-height){display:flex;flex:1 1 auto;overflow:hidden}.content{pointer-events:auto;display:flex;flex-direction:column;flex-wrap:nowrap;align-items:stretch;align-self:stretch;background-color:var(--calcite-ui-background);padding:0px;inline-size:var(--calcite-shell-panel-width);max-inline-size:var(--calcite-shell-panel-max-width);min-inline-size:var(--calcite-shell-panel-min-width);transition:max-block-size var(--calcite-animation-timing), max-inline-size var(--calcite-animation-timing)}.content__header{display:flex;flex:0 1 auto;flex-direction:column;flex-wrap:nowrap;align-items:stretch}.content__body{display:flex;flex:1 1 auto;flex-direction:column;overflow:hidden}:host([width-scale=s]) .content{--calcite-shell-panel-width:calc(var(--calcite-panel-width-multiplier) * 12vw);--calcite-shell-panel-max-width:calc(var(--calcite-panel-width-multiplier) * 300px);--calcite-shell-panel-min-width:calc(var(--calcite-panel-width-multiplier) * 150px)}:host([width-scale=m]) .content{--calcite-shell-panel-width:calc(var(--calcite-panel-width-multiplier) * 20vw);--calcite-shell-panel-max-width:calc(var(--calcite-panel-width-multiplier) * 420px);--calcite-shell-panel-min-width:calc(var(--calcite-panel-width-multiplier) * 240px)}:host([width-scale=l]) .content{--calcite-shell-panel-width:calc(var(--calcite-panel-width-multiplier) * 45vw);--calcite-shell-panel-max-width:calc(var(--calcite-panel-width-multiplier) * 680px);--calcite-shell-panel-min-width:calc(var(--calcite-panel-width-multiplier) * 340px)}:host([detached-height-scale=s]) .content--detached{--calcite-shell-panel-detached-max-height:40vh}:host([detached-height-scale=m]) .content--detached{--calcite-shell-panel-detached-max-height:60vh}:host([detached-height-scale=l]) .content--detached{--calcite-shell-panel-detached-max-height:80vh}.content--detached{margin-inline:0.5rem;margin-block:0.5rem auto;block-size:auto;overflow:hidden;border-radius:0.25rem;--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);max-block-size:var(--calcite-shell-panel-detached-max-height)}.content--detached ::slotted(calcite-panel),.content--detached ::slotted(calcite-flow){max-block-size:unset}:host([position=start]) .content--detached ::slotted(calcite-panel),:host([position=start]) .content--detached ::slotted(calcite-flow),:host([position=end]) .content--detached ::slotted(calcite-panel),:host([position=end]) .content--detached ::slotted(calcite-flow){border-style:none}.content[hidden]{display:none}slot[name=action-bar]::slotted(calcite-action-bar),.content ::slotted(calcite-flow),.content ::slotted(calcite-panel:not([dismissed])){border-width:1px;border-style:solid;border-color:var(--calcite-ui-border-3)}:host([position=start]) slot[name=action-bar]::slotted(calcite-action-bar),:host([position=start]) .content ::slotted(calcite-flow),:host([position=start]) .content ::slotted(calcite-panel){border-inline-start:none}:host([position=end]) slot[name=action-bar]::slotted(calcite-action-bar),:host([position=end]) .content ::slotted(calcite-flow),:host([position=end]) .content ::slotted(calcite-panel){border-inline-end:none}";
  175. const ShellPanel = class {
  176. constructor(hostRef) {
  177. index.registerInstance(this, hostRef);
  178. this.calciteShellPanelToggle = index.createEvent(this, "calciteShellPanelToggle", 6);
  179. // --------------------------------------------------------------------------
  180. //
  181. // Properties
  182. //
  183. // --------------------------------------------------------------------------
  184. /**
  185. * When `true`, hides the component's content area.
  186. */
  187. this.collapsed = false;
  188. /**
  189. * When `true`, the content area displays like a floating panel.
  190. */
  191. this.detached = false;
  192. /**
  193. * When `detached`, specifies the maximum height of the component.
  194. */
  195. this.detachedHeightScale = "l";
  196. /**
  197. * Specifies the width of the component's content area.
  198. */
  199. this.widthScale = "m";
  200. /**
  201. * Accessible name for the resize separator.
  202. *
  203. * @default "Resize"
  204. */
  205. this.intlResize = TEXT.resize;
  206. /**
  207. * When `true` and not `detached`, the component's content area is resizable.
  208. */
  209. this.resizable = false;
  210. this.contentWidth = null;
  211. this.initialContentWidth = null;
  212. this.initialClientX = null;
  213. this.contentWidthMax = null;
  214. this.contentWidthMin = null;
  215. this.step = 1;
  216. this.stepMultiplier = 10;
  217. this.storeContentEl = (contentEl) => {
  218. this.contentEl = contentEl;
  219. };
  220. this.getKeyAdjustedWidth = (event) => {
  221. const { key } = event;
  222. const { el, step, stepMultiplier, contentWidthMin, contentWidthMax, initialContentWidth, position } = this;
  223. const multipliedStep = step * stepMultiplier;
  224. const MOVEMENT_KEYS = [
  225. "ArrowUp",
  226. "ArrowDown",
  227. "ArrowLeft",
  228. "ArrowRight",
  229. "Home",
  230. "End",
  231. "PageUp",
  232. "PageDown"
  233. ];
  234. if (MOVEMENT_KEYS.indexOf(key) > -1) {
  235. event.preventDefault();
  236. }
  237. const dir = dom.getElementDir(el);
  238. const directionKeys = ["ArrowLeft", "ArrowRight"];
  239. const directionFactor = dir === "rtl" && directionKeys.includes(key) ? -1 : 1;
  240. const increaseKeys = key === "ArrowUp" ||
  241. (position === "end" ? key === directionKeys[0] : key === directionKeys[1]);
  242. if (increaseKeys) {
  243. const stepValue = event.shiftKey ? multipliedStep : step;
  244. return initialContentWidth + directionFactor * stepValue;
  245. }
  246. const decreaseKeys = key === "ArrowDown" ||
  247. (position === "end" ? key === directionKeys[1] : key === directionKeys[0]);
  248. if (decreaseKeys) {
  249. const stepValue = event.shiftKey ? multipliedStep : step;
  250. return initialContentWidth - directionFactor * stepValue;
  251. }
  252. if (typeof contentWidthMin === "number" && key === "Home") {
  253. return contentWidthMin;
  254. }
  255. if (typeof contentWidthMax === "number" && key === "End") {
  256. return contentWidthMax;
  257. }
  258. if (key === "PageDown") {
  259. return initialContentWidth - multipliedStep;
  260. }
  261. if (key === "PageUp") {
  262. return initialContentWidth + multipliedStep;
  263. }
  264. return null;
  265. };
  266. this.separatorKeyDown = (event) => {
  267. this.setInitialContentWidth();
  268. const width = this.getKeyAdjustedWidth(event);
  269. if (typeof width === "number") {
  270. this.setContentWidth(width);
  271. }
  272. };
  273. this.separatorPointerMove = (event) => {
  274. event.preventDefault();
  275. const { el, initialContentWidth, position, initialClientX } = this;
  276. const offset = event.clientX - initialClientX;
  277. const dir = dom.getElementDir(el);
  278. const adjustmentDirection = dir === "rtl" ? -1 : 1;
  279. const adjustedOffset = position === "end" ? -adjustmentDirection * offset : adjustmentDirection * offset;
  280. const width = initialContentWidth + adjustedOffset;
  281. this.setContentWidth(width);
  282. };
  283. this.separatorPointerUp = (event) => {
  284. if (!dom.isPrimaryPointerButton(event)) {
  285. return;
  286. }
  287. event.preventDefault();
  288. document.removeEventListener("pointerup", this.separatorPointerUp);
  289. document.removeEventListener("pointermove", this.separatorPointerMove);
  290. };
  291. this.setInitialContentWidth = () => {
  292. var _a;
  293. this.initialContentWidth = (_a = this.contentEl) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().width;
  294. };
  295. this.separatorPointerDown = (event) => {
  296. if (!dom.isPrimaryPointerButton(event)) {
  297. return;
  298. }
  299. event.preventDefault();
  300. const { separatorEl } = this;
  301. separatorEl && document.activeElement !== separatorEl && separatorEl.focus();
  302. this.setInitialContentWidth();
  303. this.initialClientX = event.clientX;
  304. document.addEventListener("pointerup", this.separatorPointerUp);
  305. document.addEventListener("pointermove", this.separatorPointerMove);
  306. };
  307. this.connectSeparator = (separatorEl) => {
  308. this.disconnectSeparator();
  309. this.separatorEl = separatorEl;
  310. separatorEl.addEventListener("pointerdown", this.separatorPointerDown);
  311. };
  312. this.disconnectSeparator = () => {
  313. var _a;
  314. (_a = this.separatorEl) === null || _a === void 0 ? void 0 : _a.removeEventListener("pointerdown", this.separatorPointerDown);
  315. };
  316. }
  317. watchHandler() {
  318. this.calciteShellPanelToggle.emit();
  319. }
  320. //--------------------------------------------------------------------------
  321. //
  322. // Lifecycle
  323. //
  324. //--------------------------------------------------------------------------
  325. connectedCallback() {
  326. conditionalSlot.connectConditionalSlotComponent(this);
  327. }
  328. disconnectedCallback() {
  329. conditionalSlot.disconnectConditionalSlotComponent(this);
  330. this.disconnectSeparator();
  331. }
  332. componentDidLoad() {
  333. this.updateAriaValues();
  334. }
  335. // --------------------------------------------------------------------------
  336. //
  337. // Render Methods
  338. //
  339. // --------------------------------------------------------------------------
  340. renderHeader() {
  341. const { el } = this;
  342. const hasHeader = dom.getSlotted(el, SLOTS.header);
  343. return hasHeader ? (index.h("div", { class: CSS.contentHeader, key: "header" }, index.h("slot", { name: SLOTS.header }))) : null;
  344. }
  345. render() {
  346. const { collapsed, detached, position, initialContentWidth, contentWidth, contentWidthMax, contentWidthMin, intlResize, resizable } = this;
  347. const allowResizing = !detached && resizable;
  348. const contentNode = (index.h("div", { class: { [CSS.content]: true, [CSS.contentDetached]: detached }, hidden: collapsed, key: "content", ref: this.storeContentEl, style: allowResizing && contentWidth ? { width: `${contentWidth}px` } : null }, this.renderHeader(), index.h("div", { class: CSS.contentBody }, index.h("slot", null))));
  349. const separatorNode = allowResizing ? (index.h("div", { "aria-label": intlResize, "aria-orientation": "horizontal", "aria-valuemax": contentWidthMax, "aria-valuemin": contentWidthMin, "aria-valuenow": contentWidth !== null && contentWidth !== void 0 ? contentWidth : initialContentWidth, class: CSS.separator, key: "separator", onKeyDown: this.separatorKeyDown, ref: this.connectSeparator, role: "separator", tabIndex: 0, "touch-action": "none" })) : null;
  350. const actionBarNode = index.h("slot", { key: "action-bar", name: SLOTS.actionBar });
  351. const mainNodes = [actionBarNode, contentNode, separatorNode];
  352. if (position === "end") {
  353. mainNodes.reverse();
  354. }
  355. return index.h("div", { class: { [CSS.container]: true } }, mainNodes);
  356. }
  357. // --------------------------------------------------------------------------
  358. //
  359. // private Methods
  360. //
  361. // --------------------------------------------------------------------------
  362. setContentWidth(width) {
  363. const { contentWidthMax, contentWidthMin } = this;
  364. const roundedWidth = Math.round(width);
  365. this.contentWidth =
  366. typeof contentWidthMax === "number" && typeof contentWidthMin === "number"
  367. ? math.clamp(roundedWidth, contentWidthMin, contentWidthMax)
  368. : roundedWidth;
  369. }
  370. updateAriaValues() {
  371. const { contentEl } = this;
  372. const computedStyle = contentEl && getComputedStyle(contentEl);
  373. if (!computedStyle) {
  374. return;
  375. }
  376. const max = parseInt(computedStyle.getPropertyValue("max-width"), 10);
  377. const min = parseInt(computedStyle.getPropertyValue("min-width"), 10);
  378. const valueNow = parseInt(computedStyle.getPropertyValue("width"), 10);
  379. if (typeof valueNow === "number" && !isNaN(valueNow)) {
  380. this.initialContentWidth = valueNow;
  381. }
  382. if (typeof max === "number" && !isNaN(max)) {
  383. this.contentWidthMax = max;
  384. }
  385. if (typeof min === "number" && !isNaN(min)) {
  386. this.contentWidthMin = min;
  387. }
  388. index.forceUpdate(this);
  389. }
  390. get el() { return index.getElement(this); }
  391. static get watchers() { return {
  392. "collapsed": ["watchHandler"]
  393. }; }
  394. };
  395. ShellPanel.style = shellPanelCss;
  396. exports.calcite_shell = Shell;
  397. exports.calcite_shell_center_row = ShellCenterRow;
  398. exports.calcite_shell_panel = ShellPanel;