/*! * All material copyright ESRI, All Rights Reserved, unless otherwise specified. * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details. * v1.0.0-beta.82 */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); const index = require('./index-5c65e149.js'); const guid = require('./guid-8b6d6cb4.js'); const interactive = require('./interactive-e294111f.js'); const CSS = { checked: "checked", description: "description", descriptionOnly: "description-only", disabled: "disabled", heading: "heading", headingOnly: "heading-only", icon: "icon", iconOnly: "icon-only", inputAlignmentEnd: "input-alignment-end", inputAlignmentStart: "input-alignment-start", inputEnabled: "input-enabled", largeVisual: "large-visual", widthAuto: "width-auto", widthFull: "width-full" }; 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}"; const TileSelect = class { constructor(hostRef) { index.registerInstance(this, hostRef); this.calciteTileSelectChange = index.createEvent(this, "calciteTileSelectChange", 7); //-------------------------------------------------------------------------- // // Properties // //-------------------------------------------------------------------------- /** The checked state of the tile select. */ this.checked = false; /** The disabled state of the tile select. */ this.disabled = false; /** The hidden state of the tile select. */ this.hidden = false; /** Display an interactive radio or checkbox. */ this.inputEnabled = false; /** The side of the tile that the radio or checkbox appears on when inputEnabled is true. */ this.inputAlignment = "start"; /** The selection mode of the tile select: radio (single) or checkbox (multiple). */ this.type = "radio"; /** specify the width of the tile, defaults to auto */ this.width = "auto"; this.guid = `calcite-tile-select-${guid.guid()}`; //-------------------------------------------------------------------------- // // State // //-------------------------------------------------------------------------- /** The focused state of the tile-select. */ this.focused = false; } checkedChanged(newChecked) { this.input.checked = newChecked; } nameChanged(newName) { this.input.name = newName; } //-------------------------------------------------------------------------- // // Public Methods // //-------------------------------------------------------------------------- /** Sets focus on the component. */ async setFocus() { this.input.setFocus(); } //-------------------------------------------------------------------------- // // Event Listeners // //-------------------------------------------------------------------------- checkboxChangeHandler(event) { const checkbox = event.target; if (checkbox === this.input) { this.checked = checkbox.checked; } event.stopPropagation(); this.calciteTileSelectChange.emit(); } checkboxFocusBlurHandler(event) { const checkbox = event.target; if (checkbox === this.input) { this.focused = event.detail; } event.stopPropagation(); } radioButtonChangeHandler(event) { const radioButton = event.target; if (radioButton === this.input) { this.checked = radioButton.checked; } event.stopPropagation(); this.calciteTileSelectChange.emit(); } radioButtonCheckedChangeHandler(event) { const radioButton = event.target; if (radioButton === this.input) { this.checked = radioButton.checked; } event.stopPropagation(); } radioButtonFocusBlurHandler(event) { const radioButton = event.target; if (radioButton === this.input) { this.focused = radioButton.focused; } event.stopPropagation(); } click(event) { const target = event.target; const targets = ["calcite-tile", "calcite-tile-select"]; if (targets.includes(target.localName)) { this.input.click(); } } mouseenter() { if (this.input.localName === "calcite-radio-button") { this.input.hovered = true; } if (this.input.localName === "calcite-checkbox") { this.input.hovered = true; } } mouseleave() { if (this.input.localName === "calcite-radio-button") { this.input.hovered = false; } if (this.input.localName === "calcite-checkbox") { this.input.hovered = false; } } //-------------------------------------------------------------------------- // // Lifecycle // //-------------------------------------------------------------------------- connectedCallback() { this.renderInput(); } disconnectedCallback() { this.input.parentNode.removeChild(this.input); } componentDidRender() { interactive.updateHostInteraction(this); } // -------------------------------------------------------------------------- // // Render Methods // // -------------------------------------------------------------------------- renderInput() { this.input = document.createElement(this.type === "radio" ? "calcite-radio-button" : "calcite-checkbox"); this.input.checked = this.checked; this.input.disabled = this.disabled; this.input.hidden = this.hidden; this.input.id = this.guid; this.input.label = this.heading || this.name || ""; if (this.name) { this.input.name = this.name; } if (this.value) { this.input.value = this.value != null ? this.value.toString() : ""; } this.el.insertAdjacentElement("beforeend", this.input); } render() { const { checked, description, disabled, focused, heading, icon, inputAlignment, inputEnabled, width } = this; return (index.h("div", { class: { checked, container: true, [CSS.description]: Boolean(description), [CSS.descriptionOnly]: Boolean(!heading && !icon && description), disabled, focused, [CSS.heading]: Boolean(heading), [CSS.headingOnly]: heading && !icon && !description, [CSS.icon]: Boolean(icon), [CSS.iconOnly]: !heading && icon && !description, [CSS.inputAlignmentEnd]: inputAlignment === "end", [CSS.inputAlignmentStart]: inputAlignment === "start", [CSS.inputEnabled]: inputEnabled, [CSS.largeVisual]: heading && icon && !description, [CSS.widthAuto]: width === "auto", [CSS.widthFull]: width === "full" } }, index.h("calcite-tile", { active: checked, description: description, embed: true, heading: heading, icon: icon }), index.h("slot", null))); } get el() { return index.getElement(this); } static get watchers() { return { "checked": ["checkedChanged"], "name": ["nameChanged"] }; } }; TileSelect.style = tileSelectCss; 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}"; const TileSelectGroup = class { constructor(hostRef) { index.registerInstance(this, hostRef); //-------------------------------------------------------------------------- // // Properties // //-------------------------------------------------------------------------- /** The disabled state of the tile select. */ this.disabled = false; /** Tiles by default move horizontally, stacking with each row, vertical allows single-column layouts */ this.layout = "horizontal"; } //-------------------------------------------------------------------------- // // Lifecycle // //-------------------------------------------------------------------------- componentDidRender() { interactive.updateHostInteraction(this); } render() { return index.h("slot", null); } get el() { return index.getElement(this); } }; TileSelectGroup.style = tileSelectGroupCss; exports.calcite_tile_select = TileSelect; exports.calcite_tile_select_group = TileSelectGroup;