calcite-tile-select_2.entry.js 17 KB

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