calcite-shell_3.entry.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. /*!
  2. * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
  4. * v1.0.0-beta.97
  5. */
  6. import { r as registerInstance, h, F as Fragment, g as getElement, c as createEvent, f as forceUpdate } from './index-1f9b54dc.js';
  7. import { g as getSlotted, a as getElementDir, i as isPrimaryPointerButton } from './dom-8f0a9ff2.js';
  8. import { c as connectConditionalSlotComponent, d as disconnectConditionalSlotComponent } from './conditionalSlot-a3e8c63a.js';
  9. import { c as clamp } from './math-dd4df0b5.js';
  10. import './resources-9c476cb6.js';
  11. import './guid-9f15e57a.js';
  12. import './observers-9f44e9b3.js';
  13. const CSS$2 = {
  14. main: "main",
  15. mainReversed: "main--reversed",
  16. content: "content",
  17. contentBehind: "content--behind",
  18. footer: "footer"
  19. };
  20. const SLOTS$2 = {
  21. centerRow: "center-row",
  22. primaryPanel: "primary-panel",
  23. contextualPanel: "contextual-panel",
  24. panelStart: "panel-start",
  25. panelEnd: "panel-end",
  26. header: "header",
  27. footer: "footer"
  28. };
  29. 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)}";
  30. const Shell = class {
  31. constructor(hostRef) {
  32. registerInstance(this, hostRef);
  33. // --------------------------------------------------------------------------
  34. //
  35. // Properties
  36. //
  37. // --------------------------------------------------------------------------
  38. /**
  39. * Positions the center content behind any `calcite-shell-panel`s.
  40. */
  41. this.contentBehind = false;
  42. }
  43. // --------------------------------------------------------------------------
  44. //
  45. // Lifecycle
  46. //
  47. // --------------------------------------------------------------------------
  48. connectedCallback() {
  49. connectConditionalSlotComponent(this);
  50. }
  51. disconnectedCallback() {
  52. disconnectConditionalSlotComponent(this);
  53. }
  54. // --------------------------------------------------------------------------
  55. //
  56. // Render Methods
  57. //
  58. // --------------------------------------------------------------------------
  59. renderHeader() {
  60. const hasHeader = !!getSlotted(this.el, SLOTS$2.header);
  61. return hasHeader ? h("slot", { key: "header", name: SLOTS$2.header }) : null;
  62. }
  63. renderContent() {
  64. const defaultSlotNode = h("slot", { key: "default-slot" });
  65. const centerRowSlotNode = h("slot", { key: "center-row-slot", name: SLOTS$2.centerRow });
  66. const contentContainerKey = "content-container";
  67. const content = !!this.contentBehind
  68. ? [
  69. h("div", { class: {
  70. [CSS$2.content]: true,
  71. [CSS$2.contentBehind]: true
  72. }, key: contentContainerKey }, defaultSlotNode),
  73. centerRowSlotNode
  74. ]
  75. : [
  76. h("div", { class: CSS$2.content, key: contentContainerKey }, defaultSlotNode, centerRowSlotNode)
  77. ];
  78. return content;
  79. }
  80. renderFooter() {
  81. const hasFooter = !!getSlotted(this.el, SLOTS$2.footer);
  82. return hasFooter ? (h("div", { class: CSS$2.footer, key: "footer" }, h("slot", { name: SLOTS$2.footer }))) : null;
  83. }
  84. renderMain() {
  85. const primaryPanel = getSlotted(this.el, SLOTS$2.primaryPanel);
  86. const mainClasses = {
  87. [CSS$2.main]: true,
  88. [CSS$2.mainReversed]: (primaryPanel === null || primaryPanel === void 0 ? void 0 : primaryPanel.position) === "end"
  89. };
  90. return (h("div", { class: mainClasses }, h("slot", { name: SLOTS$2.primaryPanel }), h("slot", { name: SLOTS$2.panelStart }), this.renderContent(), h("slot", { name: SLOTS$2.panelEnd }), h("slot", { name: SLOTS$2.contextualPanel })));
  91. }
  92. render() {
  93. return (h(Fragment, null, this.renderHeader(), this.renderMain(), this.renderFooter()));
  94. }
  95. get el() { return getElement(this); }
  96. };
  97. Shell.style = shellCss;
  98. const CSS$1 = {
  99. actionBarContainer: "action-bar-container",
  100. content: "content"
  101. };
  102. const SLOTS$1 = {
  103. actionBar: "action-bar"
  104. };
  105. 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)}";
  106. const ShellCenterRow = class {
  107. constructor(hostRef) {
  108. registerInstance(this, hostRef);
  109. // --------------------------------------------------------------------------
  110. //
  111. // Properties
  112. //
  113. // --------------------------------------------------------------------------
  114. /**
  115. * When `true`, the content area displays like a floating panel.
  116. */
  117. this.detached = false;
  118. /**
  119. * Specifies the maximum height of the component.
  120. */
  121. this.heightScale = "s";
  122. /**
  123. * Specifies the component's position. Will be flipped when the element direction is right-to-left (`"rtl"`).
  124. */
  125. this.position = "end";
  126. }
  127. // --------------------------------------------------------------------------
  128. //
  129. // Lifecycle
  130. //
  131. // --------------------------------------------------------------------------
  132. connectedCallback() {
  133. connectConditionalSlotComponent(this);
  134. }
  135. disconnectedCallback() {
  136. disconnectConditionalSlotComponent(this);
  137. }
  138. // --------------------------------------------------------------------------
  139. //
  140. // Render Methods
  141. //
  142. // --------------------------------------------------------------------------
  143. render() {
  144. const { el } = this;
  145. const contentNode = (h("div", { class: CSS$1.content }, h("slot", null)));
  146. const actionBar = getSlotted(el, SLOTS$1.actionBar);
  147. const actionBarNode = actionBar ? (h("div", { class: CSS$1.actionBarContainer, key: "action-bar" }, h("slot", { name: SLOTS$1.actionBar }))) : null;
  148. const children = [actionBarNode, contentNode];
  149. if ((actionBar === null || actionBar === void 0 ? void 0 : actionBar.position) === "end") {
  150. children.reverse();
  151. }
  152. return h(Fragment, null, children);
  153. }
  154. get el() { return getElement(this); }
  155. };
  156. ShellCenterRow.style = shellCenterRowCss;
  157. const CSS = {
  158. container: "container",
  159. content: "content",
  160. contentHeader: "content__header",
  161. contentBody: "content__body",
  162. contentDetached: "content--detached",
  163. separator: "separator"
  164. };
  165. const SLOTS = {
  166. actionBar: "action-bar",
  167. header: "header"
  168. };
  169. const TEXT = {
  170. resize: "Resize"
  171. };
  172. 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}";
  173. const ShellPanel = class {
  174. constructor(hostRef) {
  175. registerInstance(this, hostRef);
  176. this.calciteShellPanelToggle = createEvent(this, "calciteShellPanelToggle", 6);
  177. // --------------------------------------------------------------------------
  178. //
  179. // Properties
  180. //
  181. // --------------------------------------------------------------------------
  182. /**
  183. * When `true`, hides the component's content area.
  184. */
  185. this.collapsed = false;
  186. /**
  187. * When `true`, the content area displays like a floating panel.
  188. */
  189. this.detached = false;
  190. /**
  191. * When `detached`, specifies the maximum height of the component.
  192. */
  193. this.detachedHeightScale = "l";
  194. /**
  195. * Specifies the width of the component's content area.
  196. */
  197. this.widthScale = "m";
  198. /**
  199. * Accessible name for the resize separator.
  200. *
  201. * @default "Resize"
  202. */
  203. this.intlResize = TEXT.resize;
  204. /**
  205. * When `true` and not `detached`, the component's content area is resizable.
  206. */
  207. this.resizable = false;
  208. this.contentWidth = null;
  209. this.initialContentWidth = null;
  210. this.initialClientX = null;
  211. this.contentWidthMax = null;
  212. this.contentWidthMin = null;
  213. this.step = 1;
  214. this.stepMultiplier = 10;
  215. this.storeContentEl = (contentEl) => {
  216. this.contentEl = contentEl;
  217. };
  218. this.getKeyAdjustedWidth = (event) => {
  219. const { key } = event;
  220. const { el, step, stepMultiplier, contentWidthMin, contentWidthMax, initialContentWidth, position } = this;
  221. const multipliedStep = step * stepMultiplier;
  222. const MOVEMENT_KEYS = [
  223. "ArrowUp",
  224. "ArrowDown",
  225. "ArrowLeft",
  226. "ArrowRight",
  227. "Home",
  228. "End",
  229. "PageUp",
  230. "PageDown"
  231. ];
  232. if (MOVEMENT_KEYS.indexOf(key) > -1) {
  233. event.preventDefault();
  234. }
  235. const dir = getElementDir(el);
  236. const directionKeys = ["ArrowLeft", "ArrowRight"];
  237. const directionFactor = dir === "rtl" && directionKeys.includes(key) ? -1 : 1;
  238. const increaseKeys = key === "ArrowUp" ||
  239. (position === "end" ? key === directionKeys[0] : key === directionKeys[1]);
  240. if (increaseKeys) {
  241. const stepValue = event.shiftKey ? multipliedStep : step;
  242. return initialContentWidth + directionFactor * stepValue;
  243. }
  244. const decreaseKeys = key === "ArrowDown" ||
  245. (position === "end" ? key === directionKeys[1] : key === directionKeys[0]);
  246. if (decreaseKeys) {
  247. const stepValue = event.shiftKey ? multipliedStep : step;
  248. return initialContentWidth - directionFactor * stepValue;
  249. }
  250. if (typeof contentWidthMin === "number" && key === "Home") {
  251. return contentWidthMin;
  252. }
  253. if (typeof contentWidthMax === "number" && key === "End") {
  254. return contentWidthMax;
  255. }
  256. if (key === "PageDown") {
  257. return initialContentWidth - multipliedStep;
  258. }
  259. if (key === "PageUp") {
  260. return initialContentWidth + multipliedStep;
  261. }
  262. return null;
  263. };
  264. this.separatorKeyDown = (event) => {
  265. this.setInitialContentWidth();
  266. const width = this.getKeyAdjustedWidth(event);
  267. if (typeof width === "number") {
  268. this.setContentWidth(width);
  269. }
  270. };
  271. this.separatorPointerMove = (event) => {
  272. event.preventDefault();
  273. const { el, initialContentWidth, position, initialClientX } = this;
  274. const offset = event.clientX - initialClientX;
  275. const dir = getElementDir(el);
  276. const adjustmentDirection = dir === "rtl" ? -1 : 1;
  277. const adjustedOffset = position === "end" ? -adjustmentDirection * offset : adjustmentDirection * offset;
  278. const width = initialContentWidth + adjustedOffset;
  279. this.setContentWidth(width);
  280. };
  281. this.separatorPointerUp = (event) => {
  282. if (!isPrimaryPointerButton(event)) {
  283. return;
  284. }
  285. event.preventDefault();
  286. document.removeEventListener("pointerup", this.separatorPointerUp);
  287. document.removeEventListener("pointermove", this.separatorPointerMove);
  288. };
  289. this.setInitialContentWidth = () => {
  290. var _a;
  291. this.initialContentWidth = (_a = this.contentEl) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().width;
  292. };
  293. this.separatorPointerDown = (event) => {
  294. if (!isPrimaryPointerButton(event)) {
  295. return;
  296. }
  297. event.preventDefault();
  298. const { separatorEl } = this;
  299. separatorEl && document.activeElement !== separatorEl && separatorEl.focus();
  300. this.setInitialContentWidth();
  301. this.initialClientX = event.clientX;
  302. document.addEventListener("pointerup", this.separatorPointerUp);
  303. document.addEventListener("pointermove", this.separatorPointerMove);
  304. };
  305. this.connectSeparator = (separatorEl) => {
  306. this.disconnectSeparator();
  307. this.separatorEl = separatorEl;
  308. separatorEl.addEventListener("pointerdown", this.separatorPointerDown);
  309. };
  310. this.disconnectSeparator = () => {
  311. var _a;
  312. (_a = this.separatorEl) === null || _a === void 0 ? void 0 : _a.removeEventListener("pointerdown", this.separatorPointerDown);
  313. };
  314. }
  315. watchHandler() {
  316. this.calciteShellPanelToggle.emit();
  317. }
  318. //--------------------------------------------------------------------------
  319. //
  320. // Lifecycle
  321. //
  322. //--------------------------------------------------------------------------
  323. connectedCallback() {
  324. connectConditionalSlotComponent(this);
  325. }
  326. disconnectedCallback() {
  327. disconnectConditionalSlotComponent(this);
  328. this.disconnectSeparator();
  329. }
  330. componentDidLoad() {
  331. this.updateAriaValues();
  332. }
  333. // --------------------------------------------------------------------------
  334. //
  335. // Render Methods
  336. //
  337. // --------------------------------------------------------------------------
  338. renderHeader() {
  339. const { el } = this;
  340. const hasHeader = getSlotted(el, SLOTS.header);
  341. return hasHeader ? (h("div", { class: CSS.contentHeader, key: "header" }, h("slot", { name: SLOTS.header }))) : null;
  342. }
  343. render() {
  344. const { collapsed, detached, position, initialContentWidth, contentWidth, contentWidthMax, contentWidthMin, intlResize, resizable } = this;
  345. const allowResizing = !detached && resizable;
  346. const contentNode = (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(), h("div", { class: CSS.contentBody }, h("slot", null))));
  347. const separatorNode = allowResizing ? (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;
  348. const actionBarNode = h("slot", { key: "action-bar", name: SLOTS.actionBar });
  349. const mainNodes = [actionBarNode, contentNode, separatorNode];
  350. if (position === "end") {
  351. mainNodes.reverse();
  352. }
  353. return h("div", { class: { [CSS.container]: true } }, mainNodes);
  354. }
  355. // --------------------------------------------------------------------------
  356. //
  357. // private Methods
  358. //
  359. // --------------------------------------------------------------------------
  360. setContentWidth(width) {
  361. const { contentWidthMax, contentWidthMin } = this;
  362. const roundedWidth = Math.round(width);
  363. this.contentWidth =
  364. typeof contentWidthMax === "number" && typeof contentWidthMin === "number"
  365. ? clamp(roundedWidth, contentWidthMin, contentWidthMax)
  366. : roundedWidth;
  367. }
  368. updateAriaValues() {
  369. const { contentEl } = this;
  370. const computedStyle = contentEl && getComputedStyle(contentEl);
  371. if (!computedStyle) {
  372. return;
  373. }
  374. const max = parseInt(computedStyle.getPropertyValue("max-width"), 10);
  375. const min = parseInt(computedStyle.getPropertyValue("min-width"), 10);
  376. const valueNow = parseInt(computedStyle.getPropertyValue("width"), 10);
  377. if (typeof valueNow === "number" && !isNaN(valueNow)) {
  378. this.initialContentWidth = valueNow;
  379. }
  380. if (typeof max === "number" && !isNaN(max)) {
  381. this.contentWidthMax = max;
  382. }
  383. if (typeof min === "number" && !isNaN(min)) {
  384. this.contentWidthMin = min;
  385. }
  386. forceUpdate(this);
  387. }
  388. get el() { return getElement(this); }
  389. static get watchers() { return {
  390. "collapsed": ["watchHandler"]
  391. }; }
  392. };
  393. ShellPanel.style = shellPanelCss;
  394. export { Shell as calcite_shell, ShellCenterRow as calcite_shell_center_row, ShellPanel as calcite_shell_panel };