calcite-tile-select_2.cjs.entry.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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. 'use strict';
  7. Object.defineProperty(exports, '__esModule', { value: true });
  8. const index = require('./index-5c65e149.js');
  9. const guid = require('./guid-8b6d6cb4.js');
  10. const interactive = require('./interactive-e294111f.js');
  11. const CSS = {
  12. checked: "checked",
  13. description: "description",
  14. descriptionOnly: "description-only",
  15. disabled: "disabled",
  16. heading: "heading",
  17. headingOnly: "heading-only",
  18. icon: "icon",
  19. iconOnly: "icon-only",
  20. inputAlignmentEnd: "input-alignment-end",
  21. inputAlignmentStart: "input-alignment-start",
  22. inputEnabled: "input-enabled",
  23. largeVisual: "large-visual",
  24. widthAuto: "width-auto",
  25. widthFull: "width-full"
  26. };
  27. const tileSelectCss = "@-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{display:block}:host .container{background-color:var(--calcite-ui-foreground-1);-webkit-box-shadow:0 0 0 1px var(--calcite-ui-border-2);box-shadow:0 0 0 1px var(--calcite-ui-border-2);-webkit-box-sizing:border-box;box-sizing:border-box;cursor:pointer;display:inline-block;height:100%;max-width:300px;padding:0.75rem;position:relative;-webkit-transition:var(--calcite-animation-timing);transition:var(--calcite-animation-timing);vertical-align:top;z-index:10}:host .container.checked{z-index:30;-webkit-box-shadow:0 0 0 1px var(--calcite-ui-brand);box-shadow:0 0 0 1px var(--calcite-ui-brand)}:host .container.heading-only{-ms-flex-align:center;align-items:center}:host .container:not(.input-enabled) ::slotted(calcite-checkbox),:host .container:not(.input-enabled) ::slotted(calcite-radio-button){position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0}:host .container.focused:not(.disabled){z-index:30}:host .container.focused:not(.disabled):not(.input-enabled){-webkit-box-shadow:0 0 0 1px var(--calcite-ui-brand), inset 0 0 0 2px var(--calcite-ui-foreground-1), inset 0 0 0 5px var(--calcite-ui-brand);box-shadow:0 0 0 1px var(--calcite-ui-brand), inset 0 0 0 2px var(--calcite-ui-foreground-1), inset 0 0 0 5px var(--calcite-ui-brand)}:host .container.input-enabled.input-alignment-start.width-auto.heading-only,:host .container.input-enabled.input-alignment-start.width-auto.icon-only,:host .container.input-enabled.input-alignment-start.width-auto.description-only,:host .container.input-enabled.input-alignment-start.width-auto.heading.description,:host .container.input-enabled.input-alignment-start.width-auto.icon.description,:host .container.input-enabled.input-alignment-start.width-auto.heading.icon.description{display:inline-grid;grid-template-columns:-webkit-max-content 1fr;grid-template-columns:max-content 1fr}:host .container.input-enabled.input-alignment-start.heading-only,:host .container.input-enabled.input-alignment-start.icon-only,:host .container.input-enabled.input-alignment-start.description-only,:host .container.input-enabled.input-alignment-start.heading.description,:host .container.input-enabled.input-alignment-start.icon.description,:host .container.input-enabled.input-alignment-start.heading.icon.description{gap:0.75rem}:host .container.input-enabled.input-alignment-start calcite-tile{-ms-flex-order:1;order:1}:host .container.input-enabled.input-alignment-start.large-visual ::slotted(calcite-checkbox),:host .container.input-enabled.input-alignment-start.large-visual ::slotted(calcite-radio-button){position:absolute;inset-block-start:0.75rem;inset-inline-start:0.75rem}:host .container.input-enabled.input-alignment-end.width-auto.heading-only,:host .container.input-enabled.input-alignment-end.width-auto.icon-only{display:inline-grid;grid-gap:0.75rem;grid-template-columns:-webkit-max-content 1fr;grid-template-columns:max-content 1fr}:host .container.input-enabled.input-alignment-end.heading-only,:host .container.input-enabled.input-alignment-end.icon-only{gap:0.75rem}:host .container.input-enabled.input-alignment-end.description-only ::slotted(calcite-checkbox),:host .container.input-enabled.input-alignment-end.description-only ::slotted(calcite-radio-button),:host .container.input-enabled.input-alignment-end.heading.description ::slotted(calcite-checkbox),:host .container.input-enabled.input-alignment-end.heading.description ::slotted(calcite-radio-button),:host .container.input-enabled.input-alignment-end.icon.description ::slotted(calcite-checkbox),:host .container.input-enabled.input-alignment-end.icon.description ::slotted(calcite-radio-button),:host .container.input-enabled.input-alignment-end.heading.icon.description ::slotted(calcite-checkbox),:host .container.input-enabled.input-alignment-end.heading.icon.description ::slotted(calcite-radio-button){position:absolute;inset-block-start:0.75rem;inset-inline-end:0.75rem}:host .container.input-enabled.input-alignment-end.large-visual ::slotted(calcite-checkbox),:host .container.input-enabled.input-alignment-end.large-visual ::slotted(calcite-radio-button){position:absolute;inset-block-start:0.75rem;inset-inline-end:0.75rem}:host .container.width-full{display:-ms-flexbox;display:flex;max-width:none}:host .container.width-full calcite-tile{-ms-flex:1 1 auto;flex:1 1 auto}:host(:hover) .container{z-index:20}:host(:hover) .container:not(.input-enabled){-webkit-box-shadow:0 0 0 1px var(--calcite-ui-brand);box-shadow:0 0 0 1px var(--calcite-ui-brand)}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}";
  28. const TileSelect = class {
  29. constructor(hostRef) {
  30. index.registerInstance(this, hostRef);
  31. this.calciteTileSelectChange = index.createEvent(this, "calciteTileSelectChange", 7);
  32. //--------------------------------------------------------------------------
  33. //
  34. // Properties
  35. //
  36. //--------------------------------------------------------------------------
  37. /** The checked state of the tile select. */
  38. this.checked = false;
  39. /** The disabled state of the tile select. */
  40. this.disabled = false;
  41. /** The hidden state of the tile select. */
  42. this.hidden = false;
  43. /** Display an interactive radio or checkbox. */
  44. this.inputEnabled = false;
  45. /** The side of the tile that the radio or checkbox appears on when inputEnabled is true. */
  46. this.inputAlignment = "start";
  47. /** The selection mode of the tile select: radio (single) or checkbox (multiple). */
  48. this.type = "radio";
  49. /** specify the width of the tile, defaults to auto */
  50. this.width = "auto";
  51. this.guid = `calcite-tile-select-${guid.guid()}`;
  52. //--------------------------------------------------------------------------
  53. //
  54. // State
  55. //
  56. //--------------------------------------------------------------------------
  57. /** The focused state of the tile-select. */
  58. this.focused = false;
  59. }
  60. checkedChanged(newChecked) {
  61. this.input.checked = newChecked;
  62. }
  63. nameChanged(newName) {
  64. this.input.name = newName;
  65. }
  66. //--------------------------------------------------------------------------
  67. //
  68. // Public Methods
  69. //
  70. //--------------------------------------------------------------------------
  71. /** Sets focus on the component. */
  72. async setFocus() {
  73. this.input.setFocus();
  74. }
  75. //--------------------------------------------------------------------------
  76. //
  77. // Event Listeners
  78. //
  79. //--------------------------------------------------------------------------
  80. checkboxChangeHandler(event) {
  81. const checkbox = event.target;
  82. if (checkbox === this.input) {
  83. this.checked = checkbox.checked;
  84. }
  85. event.stopPropagation();
  86. this.calciteTileSelectChange.emit();
  87. }
  88. checkboxFocusBlurHandler(event) {
  89. const checkbox = event.target;
  90. if (checkbox === this.input) {
  91. this.focused = event.detail;
  92. }
  93. event.stopPropagation();
  94. }
  95. radioButtonChangeHandler(event) {
  96. const radioButton = event.target;
  97. if (radioButton === this.input) {
  98. this.checked = radioButton.checked;
  99. }
  100. event.stopPropagation();
  101. this.calciteTileSelectChange.emit();
  102. }
  103. radioButtonCheckedChangeHandler(event) {
  104. const radioButton = event.target;
  105. if (radioButton === this.input) {
  106. this.checked = radioButton.checked;
  107. }
  108. event.stopPropagation();
  109. }
  110. radioButtonFocusBlurHandler(event) {
  111. const radioButton = event.target;
  112. if (radioButton === this.input) {
  113. this.focused = radioButton.focused;
  114. }
  115. event.stopPropagation();
  116. }
  117. click(event) {
  118. const target = event.target;
  119. const targets = ["calcite-tile", "calcite-tile-select"];
  120. if (targets.includes(target.localName)) {
  121. this.input.click();
  122. }
  123. }
  124. mouseenter() {
  125. if (this.input.localName === "calcite-radio-button") {
  126. this.input.hovered = true;
  127. }
  128. if (this.input.localName === "calcite-checkbox") {
  129. this.input.hovered = true;
  130. }
  131. }
  132. mouseleave() {
  133. if (this.input.localName === "calcite-radio-button") {
  134. this.input.hovered = false;
  135. }
  136. if (this.input.localName === "calcite-checkbox") {
  137. this.input.hovered = false;
  138. }
  139. }
  140. //--------------------------------------------------------------------------
  141. //
  142. // Lifecycle
  143. //
  144. //--------------------------------------------------------------------------
  145. connectedCallback() {
  146. this.renderInput();
  147. }
  148. disconnectedCallback() {
  149. this.input.parentNode.removeChild(this.input);
  150. }
  151. componentDidRender() {
  152. interactive.updateHostInteraction(this);
  153. }
  154. // --------------------------------------------------------------------------
  155. //
  156. // Render Methods
  157. //
  158. // --------------------------------------------------------------------------
  159. renderInput() {
  160. this.input = document.createElement(this.type === "radio" ? "calcite-radio-button" : "calcite-checkbox");
  161. this.input.checked = this.checked;
  162. this.input.disabled = this.disabled;
  163. this.input.hidden = this.hidden;
  164. this.input.id = this.guid;
  165. this.input.label = this.heading || this.name || "";
  166. if (this.name) {
  167. this.input.name = this.name;
  168. }
  169. if (this.value) {
  170. this.input.value = this.value != null ? this.value.toString() : "";
  171. }
  172. this.el.insertAdjacentElement("beforeend", this.input);
  173. }
  174. render() {
  175. const { checked, description, disabled, focused, heading, icon, inputAlignment, inputEnabled, width } = this;
  176. return (index.h("div", { class: {
  177. checked,
  178. container: true,
  179. [CSS.description]: Boolean(description),
  180. [CSS.descriptionOnly]: Boolean(!heading && !icon && description),
  181. disabled,
  182. focused,
  183. [CSS.heading]: Boolean(heading),
  184. [CSS.headingOnly]: heading && !icon && !description,
  185. [CSS.icon]: Boolean(icon),
  186. [CSS.iconOnly]: !heading && icon && !description,
  187. [CSS.inputAlignmentEnd]: inputAlignment === "end",
  188. [CSS.inputAlignmentStart]: inputAlignment === "start",
  189. [CSS.inputEnabled]: inputEnabled,
  190. [CSS.largeVisual]: heading && icon && !description,
  191. [CSS.widthAuto]: width === "auto",
  192. [CSS.widthFull]: width === "full"
  193. } }, index.h("calcite-tile", { active: checked, description: description, embed: true, heading: heading, icon: icon }), index.h("slot", null)));
  194. }
  195. get el() { return index.getElement(this); }
  196. static get watchers() { return {
  197. "checked": ["checkedChanged"],
  198. "name": ["nameChanged"]
  199. }; }
  200. };
  201. TileSelect.style = tileSelectCss;
  202. const tileSelectGroupCss = "@-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{display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap}:host ::slotted(calcite-tile-select){margin-right:1px;margin-bottom:1px}:host([layout=vertical]){-ms-flex-direction:column;flex-direction:column}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}";
  203. const TileSelectGroup = class {
  204. constructor(hostRef) {
  205. index.registerInstance(this, hostRef);
  206. //--------------------------------------------------------------------------
  207. //
  208. // Properties
  209. //
  210. //--------------------------------------------------------------------------
  211. /** The disabled state of the tile select. */
  212. this.disabled = false;
  213. /** Tiles by default move horizontally, stacking with each row, vertical allows single-column layouts */
  214. this.layout = "horizontal";
  215. }
  216. //--------------------------------------------------------------------------
  217. //
  218. // Lifecycle
  219. //
  220. //--------------------------------------------------------------------------
  221. componentDidRender() {
  222. interactive.updateHostInteraction(this);
  223. }
  224. render() {
  225. return index.h("slot", null);
  226. }
  227. get el() { return index.getElement(this); }
  228. };
  229. TileSelectGroup.style = tileSelectGroupCss;
  230. exports.calcite_tile_select = TileSelect;
  231. exports.calcite_tile_select_group = TileSelectGroup;