@oicl/openbridge-webcomponents-full-bundle 2.0.0-next.172 → 2.0.0-next.174
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/bundle/openbridge-webcomponents.bundle.js +182 -35
- package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
- package/custom-elements.json +45 -5
- package/dist/components/accordion-card/accordion-card.css.js +61 -19
- package/dist/components/accordion-card/accordion-card.css.js.map +1 -1
- package/dist/components/accordion-card/accordion-card.d.ts +12 -3
- package/dist/components/accordion-card/accordion-card.d.ts.map +1 -1
- package/dist/components/accordion-card/accordion-card.js +23 -5
- package/dist/components/accordion-card/accordion-card.js.map +1 -1
- package/dist/components/accordion-item/accordion-item.css.js +40 -9
- package/dist/components/accordion-item/accordion-item.css.js.map +1 -1
- package/dist/components/accordion-item/accordion-item.d.ts +14 -5
- package/dist/components/accordion-item/accordion-item.d.ts.map +1 -1
- package/dist/components/accordion-item/accordion-item.js +23 -3
- package/dist/components/accordion-item/accordion-item.js.map +1 -1
- package/dist/internal/focus.d.ts +23 -0
- package/dist/internal/focus.d.ts.map +1 -1
- package/dist/internal/focus.js +38 -1
- package/dist/internal/focus.js.map +1 -1
- package/docs/GettingStarted.mdx +8 -3
- package/docs/MigrationGuide.mdx +18 -4
- package/docs/migration-guide/api-ar.md +9 -7
- package/docs/migration-guide/api-automation.md +0 -1
- package/docs/migration-guide/deprecated-members.md +9 -8
- package/package.json +1 -1
- package/src/components/accordion-card/accordion-card.css +57 -15
- package/src/components/accordion-card/accordion-card.spec.ts +171 -0
- package/src/components/accordion-card/accordion-card.ts +32 -12
- package/src/components/accordion-item/accordion-item.css +40 -9
- package/src/components/accordion-item/accordion-item.spec.ts +161 -0
- package/src/components/accordion-item/accordion-item.ts +34 -9
- package/src/internal/_test-utils.ts +3 -12
- package/src/internal/focus.ts +45 -0
package/src/internal/focus.ts
CHANGED
|
@@ -19,6 +19,51 @@ export function deepActiveElement(): Element | null {
|
|
|
19
19
|
return active;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Whether `node` sits inside `root` in the composed tree.
|
|
24
|
+
*
|
|
25
|
+
* `Node.contains()` walks the DOM tree, where slotted light-DOM content is a
|
|
26
|
+
* child of the host and not of the slot — so it answers no for exactly the
|
|
27
|
+
* content a component projects into itself. This follows `assignedSlot` and
|
|
28
|
+
* shadow hosts as well.
|
|
29
|
+
*/
|
|
30
|
+
export function composedContains(root: Node, node: Node | null): boolean {
|
|
31
|
+
let current: Node | null = node;
|
|
32
|
+
while (current) {
|
|
33
|
+
if (current === root) return true;
|
|
34
|
+
current =
|
|
35
|
+
(current as Element).assignedSlot ??
|
|
36
|
+
current.parentNode ??
|
|
37
|
+
(current instanceof ShadowRoot ? current.host : null);
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Moves focus out of `hidden`, to the first fallback that will take it.
|
|
44
|
+
*
|
|
45
|
+
* Call it just before a region becomes `inert` or is taken out of the page.
|
|
46
|
+
* The browser blurs whatever it hides, and focus lands on `<body>` a frame or
|
|
47
|
+
* two later, so the next Tab press starts from the top of the document instead
|
|
48
|
+
* of where the user was.
|
|
49
|
+
*
|
|
50
|
+
* Each candidate is tried and then checked, rather than inspected first: a
|
|
51
|
+
* `disabled` button, a hidden one and an element with no tabindex all refuse
|
|
52
|
+
* focus for different reasons, and the only reliable question is whether focus
|
|
53
|
+
* actually left.
|
|
54
|
+
*/
|
|
55
|
+
export function releaseFocusBefore(
|
|
56
|
+
hidden: Node,
|
|
57
|
+
...fallbacks: (HTMLElement | null | undefined)[]
|
|
58
|
+
): void {
|
|
59
|
+
if (!composedContains(hidden, deepActiveElement())) return;
|
|
60
|
+
for (const candidate of fallbacks) {
|
|
61
|
+
if (!candidate) continue;
|
|
62
|
+
candidate.focus();
|
|
63
|
+
if (!composedContains(hidden, deepActiveElement())) return;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
22
67
|
function isTabbable(element: Element): element is HTMLElement {
|
|
23
68
|
if (!element.matches(TABBABLE_SELECTOR)) return false;
|
|
24
69
|
if ((element as HTMLElement).tabIndex < 0) return false;
|