shell-center-row.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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 { 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 `calcite-shell-panel`.
  12. * @slot action-bar - A slot for adding a `calcite-action-bar` to the `calcite-shell-panel`.
  13. */
  14. export class ShellCenterRow {
  15. constructor() {
  16. // --------------------------------------------------------------------------
  17. //
  18. // Properties
  19. //
  20. // --------------------------------------------------------------------------
  21. /**
  22. * When `true`, the content area displays like a floating panel.
  23. */
  24. this.detached = false;
  25. /**
  26. * Specifies the maximum height of the component.
  27. */
  28. this.heightScale = "s";
  29. /**
  30. * Specifies the component's position. Will be flipped when the element direction is right-to-left (`"rtl"`).
  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 }, h("slot", null)));
  53. const actionBar = getSlotted(el, SLOTS.actionBar);
  54. const actionBarNode = actionBar ? (h("div", { class: CSS.actionBarContainer, key: "action-bar" }, h("slot", { name: SLOTS.actionBar }))) : null;
  55. const children = [actionBarNode, contentNode];
  56. if ((actionBar === null || actionBar === void 0 ? void 0 : actionBar.position) === "end") {
  57. children.reverse();
  58. }
  59. return h(Fragment, null, children);
  60. }
  61. static get is() { return "calcite-shell-center-row"; }
  62. static get encapsulation() { return "shadow"; }
  63. static get originalStyleUrls() {
  64. return {
  65. "$": ["shell-center-row.scss"]
  66. };
  67. }
  68. static get styleUrls() {
  69. return {
  70. "$": ["shell-center-row.css"]
  71. };
  72. }
  73. static get properties() {
  74. return {
  75. "detached": {
  76. "type": "boolean",
  77. "mutable": false,
  78. "complexType": {
  79. "original": "boolean",
  80. "resolved": "boolean",
  81. "references": {}
  82. },
  83. "required": false,
  84. "optional": false,
  85. "docs": {
  86. "tags": [],
  87. "text": "When `true`, the content area displays like a floating panel."
  88. },
  89. "attribute": "detached",
  90. "reflect": true,
  91. "defaultValue": "false"
  92. },
  93. "heightScale": {
  94. "type": "string",
  95. "mutable": false,
  96. "complexType": {
  97. "original": "Scale",
  98. "resolved": "\"l\" | \"m\" | \"s\"",
  99. "references": {
  100. "Scale": {
  101. "location": "import",
  102. "path": "../interfaces"
  103. }
  104. }
  105. },
  106. "required": false,
  107. "optional": false,
  108. "docs": {
  109. "tags": [],
  110. "text": "Specifies the maximum height of the component."
  111. },
  112. "attribute": "height-scale",
  113. "reflect": true,
  114. "defaultValue": "\"s\""
  115. },
  116. "position": {
  117. "type": "string",
  118. "mutable": false,
  119. "complexType": {
  120. "original": "Position",
  121. "resolved": "\"end\" | \"start\"",
  122. "references": {
  123. "Position": {
  124. "location": "import",
  125. "path": "../interfaces"
  126. }
  127. }
  128. },
  129. "required": false,
  130. "optional": false,
  131. "docs": {
  132. "tags": [],
  133. "text": "Specifies the component's position. Will be flipped when the element direction is right-to-left (`\"rtl\"`)."
  134. },
  135. "attribute": "position",
  136. "reflect": true,
  137. "defaultValue": "\"end\""
  138. }
  139. };
  140. }
  141. static get elementRef() { return "el"; }
  142. }