UNPKG

@esri/calcite-components

Version:

Web Components for Esri's Calcite Design System.

77 lines (72 loc) 5.09 kB
import { r as registerInstance, h, H as Host, g as getElement } from './index-8fd57462.js'; import { f as focusElement, g as getElementDir } from './dom-d9ba1da4.js'; const CSS = { button: "button" }; const ICONS = { plus: "plus" }; const calciteFabCss = "@-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)}}:host{-webkit-box-sizing:border-box;box-sizing:border-box;background-color:var(--calcite-ui-foreground-1);color:var(--calcite-ui-text-2);font-size:var(--calcite-font-size--1)}:host *{-webkit-box-sizing:border-box;box-sizing:border-box}:host{--calcite-icon-size:1rem;--calcite-spacing-quarter:0.25rem;--calcite-spacing-half:0.5rem;--calcite-spacing-three-quarters:0.75rem;--calcite-spacing:1rem;--calcite-spacing-plus-quarter:1.25rem;--calcite-spacing-plus-half:1.5rem;--calcite-spacing-double:2rem;--calcite-menu-min-width:10rem;--calcite-header-min-height:3rem;--calcite-footer-min-height:3rem}:root{--calcite-popper-transition:150ms ease-in-out}:host([hidden]){display:none}:host{background-color:transparent}calcite-button{-webkit-box-shadow:0 6px 20px -4px rgba(0, 0, 0, 0.1), 0 4px 12px -2px rgba(0, 0, 0, 0.08);box-shadow:0 6px 20px -4px rgba(0, 0, 0, 0.1), 0 4px 12px -2px rgba(0, 0, 0, 0.08)}calcite-button:hover{-webkit-box-shadow:0 12px 32px -2px rgba(0, 0, 0, 0.1), 0 4px 20px 0 rgba(0, 0, 0, 0.08);box-shadow:0 12px 32px -2px rgba(0, 0, 0, 0.1), 0 4px 20px 0 rgba(0, 0, 0, 0.08)}calcite-button:active{-webkit-box-shadow:0 2px 12px -4px rgba(0, 0, 0, 0.2), 0 2px 4px -2px rgba(0, 0, 0, 0.16);box-shadow:0 2px 12px -4px rgba(0, 0, 0, 0.2), 0 2px 4px -2px rgba(0, 0, 0, 0.16)}"; const CalciteFab = class { constructor(hostRef) { registerInstance(this, hostRef); // -------------------------------------------------------------------------- // // Properties // // -------------------------------------------------------------------------- /** * Used to set the button's appearance. Default is outline. */ this.appearance = "outline"; /** * Used to set the button's color. Default is light. */ this.color = "light"; /** * When true, disabled prevents interaction. This state shows items with lower opacity/grayed. */ this.disabled = false; /** * The name of the icon to display. The value of this property must match the icon name from https://esri.github.io/calcite-ui-icons/. */ this.icon = ICONS.plus; /** * When true, content is waiting to be loaded. This state shows a busy indicator. */ this.loading = false; /** * Specifies the size of the fab. */ this.scale = "m"; /** * Indicates whether the text is displayed. */ this.textEnabled = false; } // -------------------------------------------------------------------------- // // Methods // // -------------------------------------------------------------------------- async setFocus() { focusElement(this.buttonEl); } // -------------------------------------------------------------------------- // // Render Methods // // -------------------------------------------------------------------------- render() { const { appearance, color, disabled, el, loading, scale, theme, textEnabled, icon, label, text } = this; const titleText = !textEnabled && text; const title = label || titleText; const dir = getElementDir(el); return (h(Host, null, h("calcite-button", { appearance: appearance, "aria-label": label, class: CSS.button, color: color, dir: dir, disabled: disabled, iconStart: icon, loading: loading, ref: (buttonEl) => { this.buttonEl = buttonEl; }, round: true, scale: scale, theme: theme, title: title, width: "auto" }, this.textEnabled ? this.text : null))); } get el() { return getElement(this); } }; CalciteFab.style = calciteFabCss; export { CalciteFab as calcite_fab };