@esri/calcite-components
Version:
Web Components for Esri's Calcite Design System.
6 lines • 1.48 kB
JavaScript
/*!
* All material copyright ESRI, All Rights Reserved, unless otherwise specified.
* See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
* v1.5.0-next.4
*/
import{g as n}from"./p-7fb6664e.js";const t=/firefox/i.test(n()),i=t?new WeakMap:null;function e(){const{disabled:n}=this;n||HTMLElement.prototype.click.call(this)}function o(n){const e=n.target;if(t&&!i.get(e))return;const{disabled:o}=e;o&&n.preventDefault()}const c=["mousedown","mouseup","click"];function u(n){if(t&&!i.get(n.target))return;const{disabled:e}=n.target;e&&(n.stopImmediatePropagation(),n.preventDefault())}const a={capture:!0};function d(n,t=!1){if(n.disabled)return n.el.setAttribute("tabindex","-1"),n.el.setAttribute("aria-disabled","true"),n.el.contains(document.activeElement)&&document.activeElement.blur(),void s(n);f(n),"function"==typeof t?n.el.setAttribute("tabindex",t.call(n)?"0":"-1"):!0===t?n.el.setAttribute("tabindex","0"):!1===t&&n.el.removeAttribute("tabindex"),n.el.removeAttribute("aria-disabled")}function s(n){var i;n.el.click=e,(i=t?r(n):n.el)&&(i.addEventListener("pointerdown",o,a),c.forEach((n=>i.addEventListener(n,u,a))))}function r(n){return i.get(n.el)}function f(n){var i;delete n.el.click,(i=t?r(n):n.el)&&(i.removeEventListener("pointerdown",o,a),c.forEach((n=>i.removeEventListener(n,u,a))))}function b(n){n.disabled&&t&&(i.set(n.el,n.el.parentElement||n.el),s(n))}function l(n){t&&(i.delete(n.el),f(n))}export{b as c,l as d,d as u}