shell-center-row.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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 { Component, Element, Prop, h, Fragment } from "@stencil/core";
  7. import { CSS, SLOTS } from "./resources";
  8. import { getSlotted } from "../../utils/dom";
  9. import { connectConditionalSlotComponent, disconnectConditionalSlotComponent } from "../../utils/conditionalSlot";
  10. /**
  11. * @slot - A slot for adding content to the shell panel.
  12. * @slot action-bar - A slot for adding a `calcite-action-bar` to the panel.
  13. */
  14. export class ShellCenterRow {
  15. constructor() {
  16. // --------------------------------------------------------------------------
  17. //
  18. // Properties
  19. //
  20. // --------------------------------------------------------------------------
  21. /**
  22. * This property makes the content area appear like a "floating" panel.
  23. */
  24. this.detached = false;
  25. /**
  26. * Specifies the maximum height of the row.
  27. */
  28. this.heightScale = "s";
  29. /**
  30. * Arranges the component depending on the elements 'dir' property.
  31. */
  32. this.position = "end";
  33. }
  34. // --------------------------------------------------------------------------
  35. //
  36. // Lifecycle
  37. //
  38. // --------------------------------------------------------------------------
  39. connectedCallback() {
  40. connectConditionalSlotComponent(this);
  41. }
  42. disconnectedCallback() {
  43. disconnectConditionalSlotComponent(this);
  44. }
  45. // --------------------------------------------------------------------------
  46. //
  47. // Render Methods
  48. //
  49. // --------------------------------------------------------------------------
  50. render() {
  51. const { el } = this;
  52. const contentNode = (h("div", { class: CSS.content },
  53. h("slot", null)));
  54. const actionBar = getSlotted(el, SLOTS.actionBar);
  55. const actionBarNode = actionBar ? (h("div", { class: CSS.actionBarContainer, key: "action-bar" },
  56. h("slot", { name: SLOTS.actionBar }))) : null;
  57. const children = [actionBarNode, contentNode];
  58. if ((actionBar === null || actionBar === void 0 ? void 0 : actionBar.position) === "end") {
  59. children.reverse();
  60. }
  61. return h(Fragment, null, children);
  62. }
  63. static get is() { return "calcite-shell-center-row"; }
  64. static get encapsulation() { return "shadow"; }
  65. static get originalStyleUrls() { return {
  66. "$": ["shell-center-row.scss"]
  67. }; }
  68. static get styleUrls() { return {
  69. "$": ["shell-center-row.css"]
  70. }; }
  71. static get properties() { return {
  72. "detached": {
  73. "type": "boolean",
  74. "mutable": false,
  75. "complexType": {
  76. "original": "boolean",
  77. "resolved": "boolean",
  78. "references": {}
  79. },
  80. "required": false,
  81. "optional": false,
  82. "docs": {
  83. "tags": [],
  84. "text": "This property makes the content area appear like a \"floating\" panel."
  85. },
  86. "attribute": "detached",
  87. "reflect": true,
  88. "defaultValue": "false"
  89. },
  90. "heightScale": {
  91. "type": "string",
  92. "mutable": false,
  93. "complexType": {
  94. "original": "Scale",
  95. "resolved": "\"l\" | \"m\" | \"s\"",
  96. "references": {
  97. "Scale": {
  98. "location": "import",
  99. "path": "../interfaces"
  100. }
  101. }
  102. },
  103. "required": false,
  104. "optional": false,
  105. "docs": {
  106. "tags": [],
  107. "text": "Specifies the maximum height of the row."
  108. },
  109. "attribute": "height-scale",
  110. "reflect": true,
  111. "defaultValue": "\"s\""
  112. },
  113. "position": {
  114. "type": "string",
  115. "mutable": false,
  116. "complexType": {
  117. "original": "Position",
  118. "resolved": "\"end\" | \"start\"",
  119. "references": {
  120. "Position": {
  121. "location": "import",
  122. "path": "../interfaces"
  123. }
  124. }
  125. },
  126. "required": false,
  127. "optional": false,
  128. "docs": {
  129. "tags": [],
  130. "text": "Arranges the component depending on the elements 'dir' property."
  131. },
  132. "attribute": "position",
  133. "reflect": true,
  134. "defaultValue": "\"end\""
  135. }
  136. }; }
  137. static get elementRef() { return "el"; }
  138. }