calcite-radio-button-group.entry.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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, c as createEvent, h, H as Host, g as getElement } from './index-1f9b54dc.js';
  7. import { c as createObserver } from './observers-9f44e9b3.js';
  8. const radioButtonGroupCss = "@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{display:flex;max-inline-size:100vw}:host([layout=horizontal]){flex-direction:row;flex-wrap:wrap}:host([layout=horizontal][scale=s]){gap:1rem}:host([layout=horizontal][scale=m]){gap:1.25rem}:host([layout=horizontal][scale=l]){gap:1.5rem}:host([layout=vertical]){flex-direction:column}";
  9. const RadioButtonGroup = class {
  10. constructor(hostRef) {
  11. registerInstance(this, hostRef);
  12. this.calciteRadioButtonGroupChange = createEvent(this, "calciteRadioButtonGroupChange", 6);
  13. //--------------------------------------------------------------------------
  14. //
  15. // Properties
  16. //
  17. //--------------------------------------------------------------------------
  18. /** When `true`, interaction is prevented and the component is displayed with lower opacity. */
  19. this.disabled = false;
  20. /** When `true`, the component is not displayed and its `calcite-radio-button`s are not focusable or checkable. */
  21. this.hidden = false;
  22. /** Defines the layout of the component. */
  23. this.layout = "horizontal";
  24. /** When `true`, the component must have a value in order for the form to submit. */
  25. this.required = false;
  26. /** Specifies the size of the component. */
  27. this.scale = "m";
  28. // --------------------------------------------------------------------------
  29. //
  30. // Private Properties
  31. //
  32. // --------------------------------------------------------------------------
  33. this.mutationObserver = createObserver("mutation", () => this.passPropsToRadioButtons());
  34. //--------------------------------------------------------------------------
  35. //
  36. // Private Methods
  37. //
  38. //--------------------------------------------------------------------------
  39. this.passPropsToRadioButtons = () => {
  40. const radioButtons = this.el.querySelectorAll("calcite-radio-button");
  41. if (radioButtons.length > 0) {
  42. radioButtons.forEach((radioButton) => {
  43. radioButton.disabled = this.disabled || radioButton.disabled;
  44. radioButton.hidden = this.hidden;
  45. radioButton.name = this.name;
  46. radioButton.required = this.required;
  47. radioButton.scale = this.scale;
  48. });
  49. }
  50. };
  51. }
  52. onDisabledChange() {
  53. this.passPropsToRadioButtons();
  54. }
  55. onHiddenChange() {
  56. this.passPropsToRadioButtons();
  57. }
  58. onLayoutChange() {
  59. this.passPropsToRadioButtons();
  60. }
  61. onScaleChange() {
  62. this.passPropsToRadioButtons();
  63. }
  64. //--------------------------------------------------------------------------
  65. //
  66. // Lifecycle
  67. //
  68. //--------------------------------------------------------------------------
  69. connectedCallback() {
  70. var _a;
  71. this.passPropsToRadioButtons();
  72. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
  73. }
  74. disconnectedCallback() {
  75. var _a;
  76. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
  77. }
  78. //--------------------------------------------------------------------------
  79. //
  80. // Event Listeners
  81. //
  82. //--------------------------------------------------------------------------
  83. radioButtonChangeHandler(event) {
  84. this.calciteRadioButtonGroupChange.emit(event.target.value);
  85. }
  86. // --------------------------------------------------------------------------
  87. //
  88. // Render Methods
  89. //
  90. // --------------------------------------------------------------------------
  91. render() {
  92. return (h(Host, { role: "radiogroup" }, h("slot", null)));
  93. }
  94. get el() { return getElement(this); }
  95. static get watchers() { return {
  96. "disabled": ["onDisabledChange"],
  97. "hidden": ["onHiddenChange"],
  98. "layout": ["onLayoutChange"],
  99. "scale": ["onScaleChange"]
  100. }; }
  101. };
  102. RadioButtonGroup.style = radioButtonGroupCss;
  103. export { RadioButtonGroup as calcite_radio_button_group };