/*! * 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 */ import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client'; import { g as guid } from './guid.js'; import { u as updateHostInteraction } from './interactive.js'; import { d as defineCustomElement$4 } from './icon.js'; import { d as defineCustomElement$3 } from './link.js'; import { d as defineCustomElement$2 } from './tile.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 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement { constructor() { super(); this.__registerHost(); this.__attachShadow(); this.calciteTileSelectChange = 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()}`; //-------------------------------------------------------------------------- // // 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() { 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 (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" } }, h("calcite-tile", { active: checked, description: description, embed: true, heading: heading, icon: icon }), h("slot", null))); } get el() { return this; } static get watchers() { return { "checked": ["checkedChanged"], "name": ["nameChanged"] }; } static get style() { return tileSelectCss; } }, [1, "calcite-tile-select", { "checked": [1540], "description": [513], "disabled": [516], "heading": [513], "hidden": [516], "icon": [513], "name": [520], "inputEnabled": [516, "input-enabled"], "inputAlignment": [513, "input-alignment"], "type": [513], "value": [8], "width": [513], "focused": [32], "setFocus": [64] }, [[0, "calciteCheckboxChange", "checkboxChangeHandler"], [0, "calciteInternalCheckboxFocus", "checkboxFocusBlurHandler"], [0, "calciteInternalCheckboxBlur", "checkboxFocusBlurHandler"], [0, "calciteRadioButtonChange", "radioButtonChangeHandler"], [0, "calciteInternalRadioButtonCheckedChange", "radioButtonCheckedChangeHandler"], [0, "calciteInternalRadioButtonFocus", "radioButtonFocusBlurHandler"], [0, "calciteInternalRadioButtonBlur", "radioButtonFocusBlurHandler"], [0, "click", "click"], [1, "mouseenter", "mouseenter"], [1, "mouseleave", "mouseleave"]]]); function defineCustomElement$1() { if (typeof customElements === "undefined") { return; } const components = ["calcite-tile-select", "calcite-icon", "calcite-link", "calcite-tile"]; components.forEach(tagName => { switch (tagName) { case "calcite-tile-select": if (!customElements.get(tagName)) { customElements.define(tagName, TileSelect); } break; case "calcite-icon": if (!customElements.get(tagName)) { defineCustomElement$4(); } break; case "calcite-link": if (!customElements.get(tagName)) { defineCustomElement$3(); } break; case "calcite-tile": if (!customElements.get(tagName)) { defineCustomElement$2(); } break; } }); } defineCustomElement$1(); const CalciteTileSelect = TileSelect; const defineCustomElement = defineCustomElement$1; export { CalciteTileSelect, defineCustomElement };