calcite-fab.entry.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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.97
  5. */
  6. import { r as registerInstance, h, g as getElement } from './index-1f9b54dc.js';
  7. import { f as focusElement } from './dom-8f0a9ff2.js';
  8. import { u as updateHostInteraction } from './interactive-5db230e8.js';
  9. import './resources-9c476cb6.js';
  10. import './guid-9f15e57a.js';
  11. const CSS = {
  12. button: "button"
  13. };
  14. const ICONS = {
  15. plus: "plus"
  16. };
  17. const fabCss = "@keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in-down{0%{opacity:0;transform:translate3D(0, -5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;transform:translate3D(0, 5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-scale{0%{opacity:0;transform:scale3D(0.95, 0.95, 1)}100%{opacity: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;animation-fill-mode:both;animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{animation-name:in}.calcite-animate__in-down{animation-name:in-down}.calcite-animate__in-up{animation-name:in-up}.calcite-animate__in-scale{animation-name:in-scale}@media (prefers-reduced-motion: reduce){:root{--calcite-internal-duration-factor:0.01}}:root{--calcite-floating-ui-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host{display:flex;background-color:transparent}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}calcite-button{--tw-shadow:0 6px 20px -4px rgba(0, 0, 0, 0.1), 0 4px 12px -2px rgba(0, 0, 0, 0.08);--tw-shadow-colored:0 6px 20px -4px var(--tw-shadow-color), 0 4px 12px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}calcite-button:hover{--tw-shadow:0 12px 32px -2px rgba(0, 0, 0, 0.1), 0 4px 20px 0 rgba(0, 0, 0, 0.08);--tw-shadow-colored:0 12px 32px -2px var(--tw-shadow-color), 0 4px 20px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}calcite-button:active{--tw-shadow:0 2px 12px -4px rgba(0, 0, 0, 0.2), 0 2px 4px -2px rgba(0, 0, 0, 0.16);--tw-shadow-colored:0 2px 12px -4px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}";
  18. const Fab = class {
  19. constructor(hostRef) {
  20. registerInstance(this, hostRef);
  21. // --------------------------------------------------------------------------
  22. //
  23. // Properties
  24. //
  25. // --------------------------------------------------------------------------
  26. /**
  27. * Used to set the button's appearance. Default is outline.
  28. */
  29. this.appearance = "outline";
  30. /**
  31. * Used to set the button's color. Default is light.
  32. */
  33. this.color = "neutral";
  34. /**
  35. * When true, disabled prevents interaction. This state shows items with lower opacity/grayed.
  36. */
  37. this.disabled = false;
  38. /**
  39. * Specifies an icon to display.
  40. *
  41. * @default "plus"
  42. */
  43. this.icon = ICONS.plus;
  44. /**
  45. * When true, content is waiting to be loaded. This state shows a busy indicator.
  46. */
  47. this.loading = false;
  48. /**
  49. * Specifies the size of the fab.
  50. */
  51. this.scale = "m";
  52. /**
  53. * Indicates whether the text is displayed.
  54. */
  55. this.textEnabled = false;
  56. }
  57. //--------------------------------------------------------------------------
  58. //
  59. // Lifecycle
  60. //
  61. //--------------------------------------------------------------------------
  62. componentDidRender() {
  63. updateHostInteraction(this);
  64. }
  65. // --------------------------------------------------------------------------
  66. //
  67. // Methods
  68. //
  69. // --------------------------------------------------------------------------
  70. /** Sets focus on the component. */
  71. async setFocus() {
  72. focusElement(this.buttonEl);
  73. }
  74. // --------------------------------------------------------------------------
  75. //
  76. // Render Methods
  77. //
  78. // --------------------------------------------------------------------------
  79. render() {
  80. const { appearance, color, disabled, loading, scale, textEnabled, icon, label, text } = this;
  81. const title = !textEnabled ? label || text || null : null;
  82. return (h("calcite-button", { appearance: appearance === "solid" ? "solid" : "outline", class: CSS.button, color: color, disabled: disabled, iconStart: icon, label: label, loading: loading, ref: (buttonEl) => {
  83. this.buttonEl = buttonEl;
  84. }, round: true, scale: scale, title: title, type: "button", width: "auto" }, this.textEnabled ? this.text : null));
  85. }
  86. get el() { return getElement(this); }
  87. };
  88. Fab.style = fabCss;
  89. export { Fab as calcite_fab };