calcite-fab.cjs.entry.js 5.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. 'use strict';
  7. Object.defineProperty(exports, '__esModule', { value: true });
  8. const index = require('./index-a0010f96.js');
  9. const dom = require('./dom-2ec8c9ed.js');
  10. const interactive = require('./interactive-32293bca.js');
  11. require('./resources-b5a5f8a7.js');
  12. require('./guid-f4f03a7a.js');
  13. const CSS = {
  14. button: "button"
  15. };
  16. const ICONS = {
  17. plus: "plus"
  18. };
  19. 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)}";
  20. const Fab = class {
  21. constructor(hostRef) {
  22. index.registerInstance(this, hostRef);
  23. // --------------------------------------------------------------------------
  24. //
  25. // Properties
  26. //
  27. // --------------------------------------------------------------------------
  28. /**
  29. * Used to set the button's appearance. Default is outline.
  30. */
  31. this.appearance = "outline";
  32. /**
  33. * Used to set the button's color. Default is light.
  34. */
  35. this.color = "neutral";
  36. /**
  37. * When true, disabled prevents interaction. This state shows items with lower opacity/grayed.
  38. */
  39. this.disabled = false;
  40. /**
  41. * Specifies an icon to display.
  42. *
  43. * @default "plus"
  44. */
  45. this.icon = ICONS.plus;
  46. /**
  47. * When true, content is waiting to be loaded. This state shows a busy indicator.
  48. */
  49. this.loading = false;
  50. /**
  51. * Specifies the size of the fab.
  52. */
  53. this.scale = "m";
  54. /**
  55. * Indicates whether the text is displayed.
  56. */
  57. this.textEnabled = false;
  58. }
  59. //--------------------------------------------------------------------------
  60. //
  61. // Lifecycle
  62. //
  63. //--------------------------------------------------------------------------
  64. componentDidRender() {
  65. interactive.updateHostInteraction(this);
  66. }
  67. // --------------------------------------------------------------------------
  68. //
  69. // Methods
  70. //
  71. // --------------------------------------------------------------------------
  72. /** Sets focus on the component. */
  73. async setFocus() {
  74. dom.focusElement(this.buttonEl);
  75. }
  76. // --------------------------------------------------------------------------
  77. //
  78. // Render Methods
  79. //
  80. // --------------------------------------------------------------------------
  81. render() {
  82. const { appearance, color, disabled, loading, scale, textEnabled, icon, label, text } = this;
  83. const title = !textEnabled ? label || text || null : null;
  84. return (index.h("calcite-button", { appearance: appearance === "solid" ? "solid" : "outline", class: CSS.button, color: color, disabled: disabled, iconStart: icon, label: label, loading: loading, ref: (buttonEl) => {
  85. this.buttonEl = buttonEl;
  86. }, round: true, scale: scale, title: title, type: "button", width: "auto" }, this.textEnabled ? this.text : null));
  87. }
  88. get el() { return index.getElement(this); }
  89. };
  90. Fab.style = fabCss;
  91. exports.calcite_fab = Fab;