inclusive-elements 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/inclusive-elements.js +11 -8
- package/dist/types/tooltip/tooltip.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Basic interactive UI patterns like popup menus, tooltips, and modals are surpris
|
|
|
8
8
|
|
|
9
9
|
`inclusive-elements` provides those basic behaviors in the form of Custom Elements, without any of the cruft. They are:
|
|
10
10
|
|
|
11
|
-
- **🦮 Accessible.** Designed following the [
|
|
11
|
+
- **🦮 Accessible.** Designed following the [ARIA Authoring Practices Guide](https://www.w3.org/WAI/ARIA/apg/) so everyone can use them.
|
|
12
12
|
- **🌳 Lightweight.** 3kB gzipped with minimal dependencies. Less if you tree-shake only the elements you need.
|
|
13
13
|
- **🎨 Unstyled.** Easily integrate with your design bottom-up without having to fight defaults.
|
|
14
14
|
- **🚀 Easy to use.** Simple API, works with any framework that supports Custom Elements.
|
|
@@ -23,7 +23,9 @@ npm install inclusive-elements --save
|
|
|
23
23
|
|
|
24
24
|
Detailed descriptions and usage instructions are contained within each element:
|
|
25
25
|
|
|
26
|
+
- [Accordion](src/accordion)
|
|
26
27
|
- [Alerts](src/alerts)
|
|
28
|
+
- [Disclosure](src/disclosure)
|
|
27
29
|
- [Menu](src/menu)
|
|
28
30
|
- [Modal](src/modal)
|
|
29
31
|
- [Popup](src/popup)
|
|
@@ -109,7 +109,7 @@ s(b, "duration", 1e4);
|
|
|
109
109
|
function C(o) {
|
|
110
110
|
return o.altKey || o.ctrlKey || o.metaKey || o.shiftKey || o.button !== void 0 && o.button !== 0;
|
|
111
111
|
}
|
|
112
|
-
class
|
|
112
|
+
class P extends HTMLElement {
|
|
113
113
|
constructor() {
|
|
114
114
|
super(...arguments);
|
|
115
115
|
s(this, "onButtonClick", (t) => {
|
|
@@ -272,7 +272,7 @@ s(m, "attention", (t) => t.animate(
|
|
|
272
272
|
],
|
|
273
273
|
300
|
|
274
274
|
));
|
|
275
|
-
class
|
|
275
|
+
class $ extends HTMLElement {
|
|
276
276
|
constructor() {
|
|
277
277
|
super();
|
|
278
278
|
s(this, "cleanup");
|
|
@@ -375,7 +375,7 @@ class P extends HTMLElement {
|
|
|
375
375
|
return this.children[1];
|
|
376
376
|
}
|
|
377
377
|
}
|
|
378
|
-
class
|
|
378
|
+
class U extends HTMLElement {
|
|
379
379
|
constructor() {
|
|
380
380
|
super(...arguments);
|
|
381
381
|
s(this, "onInitialFocus", () => {
|
|
@@ -418,12 +418,15 @@ const l = class extends HTMLElement {
|
|
|
418
418
|
s(this, "onFocus", this.show.bind(this));
|
|
419
419
|
s(this, "onMouseLeave", this.afterDelay.bind(this, this.hide));
|
|
420
420
|
s(this, "onBlur", this.hide.bind(this));
|
|
421
|
+
s(this, "onPointerUp", (t) => {
|
|
422
|
+
t.pointerType === "mouse" && this.hide();
|
|
423
|
+
});
|
|
421
424
|
s(this, "onKeyDown", (t) => {
|
|
422
425
|
t.key === "Escape" && this.hide();
|
|
423
426
|
});
|
|
424
427
|
}
|
|
425
428
|
connectedCallback() {
|
|
426
|
-
this.parent = this.parentNode, this.parent && (this.parent.addEventListener("mouseenter", this.onMouseEnter), this.parent.addEventListener("focus", this.onFocus), this.parent.addEventListener("mouseleave", this.onMouseLeave), this.parent.addEventListener("blur", this.onBlur), this.parent.addEventListener("
|
|
429
|
+
this.parent = this.parentNode, this.parent && (this.parent.addEventListener("mouseenter", this.onMouseEnter), this.parent.addEventListener("focus", this.onFocus), this.parent.addEventListener("touchstart", this.onFocus), this.parent.addEventListener("mouseleave", this.onMouseLeave), this.parent.addEventListener("blur", this.onBlur), this.parent.addEventListener("pointerup", this.onPointerUp), this.observer = new MutationObserver((t) => {
|
|
427
430
|
t.forEach((e) => {
|
|
428
431
|
e.attributeName === "disabled" && this.hide();
|
|
429
432
|
});
|
|
@@ -431,7 +434,7 @@ const l = class extends HTMLElement {
|
|
|
431
434
|
}
|
|
432
435
|
disconnectedCallback() {
|
|
433
436
|
var t;
|
|
434
|
-
this.tooltip && (this.tooltip.remove(), this.tooltip = void 0), this.parent && (this.parent.removeEventListener("mouseenter", this.onMouseEnter), this.parent.removeEventListener("focus", this.onFocus), this.parent.removeEventListener("mouseleave", this.onMouseLeave), this.parent.removeEventListener("blur", this.onBlur), this.parent.removeEventListener("
|
|
437
|
+
this.tooltip && (this.tooltip.remove(), this.tooltip = void 0), this.parent && (this.parent.removeEventListener("mouseenter", this.onMouseEnter), this.parent.removeEventListener("focus", this.onFocus), this.parent.removeEventListener("touchstart", this.onFocus), this.parent.removeEventListener("mouseleave", this.onMouseLeave), this.parent.removeEventListener("blur", this.onBlur), this.parent.removeEventListener("pointerup", this.onPointerUp), this.parent = void 0), document.removeEventListener("keydown", this.onKeyDown), document.removeEventListener("scroll", this.onBlur), (t = this.observer) == null || t.disconnect(), clearTimeout(this.timeout);
|
|
435
438
|
}
|
|
436
439
|
get disabled() {
|
|
437
440
|
return this.hasAttribute("disabled");
|
|
@@ -480,10 +483,10 @@ s(c, "delay", 100), s(c, "placement", "top"), s(c, "tooltipClass", "tooltip");
|
|
|
480
483
|
export {
|
|
481
484
|
I as AccordionElement,
|
|
482
485
|
b as AlertsElement,
|
|
483
|
-
|
|
486
|
+
P as DisclosureElement,
|
|
484
487
|
f as MenuElement,
|
|
485
488
|
m as ModalElement,
|
|
486
|
-
|
|
487
|
-
|
|
489
|
+
$ as PopupElement,
|
|
490
|
+
U as ToolbarElement,
|
|
488
491
|
c as TooltipElement
|
|
489
492
|
};
|