@abgov/web-components 1.0.0-alpha.83 → 1.0.0-alpha.84
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/package.json +1 -1
- package/web-components.es.js +78 -97
- package/web-components.umd.js +29 -29
package/package.json
CHANGED
package/web-components.es.js
CHANGED
|
@@ -2147,7 +2147,7 @@ function create_fragment$z(ctx) {
|
|
|
2147
2147
|
function instance$u($$self, $$props, $$invalidate) {
|
|
2148
2148
|
let iconType;
|
|
2149
2149
|
let { type } = $$props;
|
|
2150
|
-
let { heading } = $$props;
|
|
2150
|
+
let { heading = "" } = $$props;
|
|
2151
2151
|
let { testid = "" } = $$props;
|
|
2152
2152
|
|
|
2153
2153
|
$$self.$$set = $$props => {
|
|
@@ -6338,7 +6338,7 @@ function create_if_block$9(ctx) {
|
|
|
6338
6338
|
attr(div4, "data-testid", "modal");
|
|
6339
6339
|
attr(div4, "class", "modal");
|
|
6340
6340
|
attr(div4, "style", div4_style_value = "--scroll-offset: " + /*scrollOffset*/ ctx[4] + "px; " + (/*width*/ ctx[2] && `--width: ${/*width*/ ctx[2]};`) + ";");
|
|
6341
|
-
set_custom_element_data(goa_focus_trap, "
|
|
6341
|
+
set_custom_element_data(goa_focus_trap, "active", /*open*/ ctx[1]);
|
|
6342
6342
|
},
|
|
6343
6343
|
m(target, anchor) {
|
|
6344
6344
|
insert(target, goa_focus_trap, anchor);
|
|
@@ -6413,7 +6413,7 @@ function create_if_block$9(ctx) {
|
|
|
6413
6413
|
if (noscroll_action && is_function(noscroll_action.update) && dirty & /*isOpen*/ 8) noscroll_action.update.call(null, { enable: /*isOpen*/ ctx[3] });
|
|
6414
6414
|
|
|
6415
6415
|
if (!current || dirty & /*open*/ 2) {
|
|
6416
|
-
set_custom_element_data(goa_focus_trap, "
|
|
6416
|
+
set_custom_element_data(goa_focus_trap, "active", /*open*/ ctx[1]);
|
|
6417
6417
|
}
|
|
6418
6418
|
},
|
|
6419
6419
|
i(local) {
|
|
@@ -9887,26 +9887,22 @@ function create_fragment$7(ctx) {
|
|
|
9887
9887
|
},
|
|
9888
9888
|
m(target, anchor) {
|
|
9889
9889
|
insert(target, div, anchor);
|
|
9890
|
-
/*div_binding*/ ctx[
|
|
9890
|
+
/*div_binding*/ ctx[4](div);
|
|
9891
9891
|
},
|
|
9892
9892
|
p: noop,
|
|
9893
9893
|
i: noop,
|
|
9894
9894
|
o: noop,
|
|
9895
9895
|
d(detaching) {
|
|
9896
9896
|
if (detaching) detach(div);
|
|
9897
|
-
/*div_binding*/ ctx[
|
|
9897
|
+
/*div_binding*/ ctx[4](null);
|
|
9898
9898
|
}
|
|
9899
9899
|
};
|
|
9900
9900
|
}
|
|
9901
9901
|
|
|
9902
9902
|
function isFocusable(element) {
|
|
9903
|
-
|
|
9904
|
-
|
|
9905
|
-
|
|
9906
|
-
|
|
9907
|
-
if (element.disabled) {
|
|
9908
|
-
return false;
|
|
9909
|
-
}
|
|
9903
|
+
const isTabbable = element.tabIndex > 0 || element.tabIndex === 0 && element.getAttribute('tabIndex') !== null;
|
|
9904
|
+
if (isTabbable) return true;
|
|
9905
|
+
if (element.disabled) return false;
|
|
9910
9906
|
|
|
9911
9907
|
switch (element.nodeName) {
|
|
9912
9908
|
case 'A':
|
|
@@ -9923,11 +9919,12 @@ function isFocusable(element) {
|
|
|
9923
9919
|
}
|
|
9924
9920
|
|
|
9925
9921
|
function instance$6($$self, $$props, $$invalidate) {
|
|
9926
|
-
let
|
|
9922
|
+
let isActive;
|
|
9923
|
+
let { active } = $$props;
|
|
9927
9924
|
let ignoreFocusChanges = false;
|
|
9928
9925
|
let lastFocus;
|
|
9929
9926
|
let element;
|
|
9930
|
-
let
|
|
9927
|
+
let hasListeners = false;
|
|
9931
9928
|
|
|
9932
9929
|
function removeListeners() {
|
|
9933
9930
|
document.removeEventListener('focus', trapFocus, true);
|
|
@@ -9937,13 +9934,16 @@ function instance$6($$self, $$props, $$invalidate) {
|
|
|
9937
9934
|
document.addEventListener('focus', trapFocus, true);
|
|
9938
9935
|
}
|
|
9939
9936
|
|
|
9940
|
-
|
|
9941
|
-
|
|
9937
|
+
// ====
|
|
9938
|
+
// First Node
|
|
9939
|
+
// ====
|
|
9940
|
+
function focusOnFirstNode(nodes) {
|
|
9941
|
+
if (!nodes) return false;
|
|
9942
9942
|
|
|
9943
|
-
for (
|
|
9944
|
-
|
|
9943
|
+
for (const node of nodes) {
|
|
9944
|
+
const isFocusable = focus(node) || focusOnFirstNode(node.childNodes) || focusOnFirstNodeOfSlot(node) || focusOnFirstNodeOfShadowDOM(node);
|
|
9945
9945
|
|
|
9946
|
-
if (
|
|
9946
|
+
if (isFocusable) {
|
|
9947
9947
|
return true;
|
|
9948
9948
|
}
|
|
9949
9949
|
}
|
|
@@ -9951,43 +9951,35 @@ function instance$6($$self, $$props, $$invalidate) {
|
|
|
9951
9951
|
return false;
|
|
9952
9952
|
}
|
|
9953
9953
|
|
|
9954
|
-
function
|
|
9955
|
-
|
|
9956
|
-
|
|
9957
|
-
if (node instanceof HTMLSlotElement) {
|
|
9958
|
-
let assingedNodesOfSlotElement = (_a = node) === null || _a === void 0
|
|
9959
|
-
? void 0
|
|
9960
|
-
: _a.assignedNodes();
|
|
9954
|
+
function focusOnFirstNodeOfSlot(node) {
|
|
9955
|
+
if (!(node instanceof HTMLSlotElement)) return false;
|
|
9961
9956
|
|
|
9962
|
-
|
|
9963
|
-
|
|
9964
|
-
}
|
|
9957
|
+
if (focusOnFirstNode(node.assignedNodes())) {
|
|
9958
|
+
return true;
|
|
9965
9959
|
}
|
|
9966
9960
|
}
|
|
9967
9961
|
|
|
9968
|
-
function
|
|
9969
|
-
var _a
|
|
9970
|
-
|
|
9971
|
-
if (node instanceof HTMLElement) {
|
|
9972
|
-
let childNodesOfShadowRoot = (_b = (_a = node) === null || _a === void 0
|
|
9973
|
-
? void 0
|
|
9974
|
-
: _a.shadowRoot) === null || _b === void 0
|
|
9975
|
-
? void 0
|
|
9976
|
-
: _b.childNodes;
|
|
9962
|
+
function focusOnFirstNodeOfShadowDOM(node) {
|
|
9963
|
+
var _a;
|
|
9964
|
+
if (!(node instanceof HTMLElement)) return false;
|
|
9977
9965
|
|
|
9978
|
-
|
|
9979
|
-
|
|
9980
|
-
|
|
9966
|
+
if (focusOnFirstNode((_a = node.shadowRoot) === null || _a === void 0
|
|
9967
|
+
? void 0
|
|
9968
|
+
: _a.childNodes)) {
|
|
9969
|
+
return true;
|
|
9981
9970
|
}
|
|
9982
9971
|
}
|
|
9983
9972
|
|
|
9984
|
-
|
|
9985
|
-
|
|
9973
|
+
// ====
|
|
9974
|
+
// Last Node
|
|
9975
|
+
// ====
|
|
9976
|
+
function focusOnLastNode(nodes) {
|
|
9977
|
+
if (!nodes) return false;
|
|
9986
9978
|
|
|
9987
|
-
for (let i =
|
|
9988
|
-
let
|
|
9979
|
+
for (let i = nodes.length - 1; i >= 0; i--) {
|
|
9980
|
+
let node = nodes[i];
|
|
9989
9981
|
|
|
9990
|
-
if (
|
|
9982
|
+
if (focus(node) || focusOnLastNode(node.childNodes) || focusOnLastNodeOfSlot(node) || focusOnLastNodeOfShadowDOM(node)) {
|
|
9991
9983
|
return true;
|
|
9992
9984
|
}
|
|
9993
9985
|
}
|
|
@@ -9995,59 +9987,43 @@ function instance$6($$self, $$props, $$invalidate) {
|
|
|
9995
9987
|
return false;
|
|
9996
9988
|
}
|
|
9997
9989
|
|
|
9998
|
-
function
|
|
9999
|
-
|
|
10000
|
-
|
|
10001
|
-
if (node instanceof HTMLSlotElement) {
|
|
10002
|
-
let assingedNodesOfSlotElement = (_a = node) === null || _a === void 0
|
|
10003
|
-
? void 0
|
|
10004
|
-
: _a.assignedNodes();
|
|
9990
|
+
function focusOnLastNodeOfSlot(node) {
|
|
9991
|
+
if (!(node instanceof HTMLSlotElement)) return false;
|
|
10005
9992
|
|
|
10006
|
-
|
|
10007
|
-
|
|
10008
|
-
}
|
|
9993
|
+
if (focusOnLastNode(node.assignedNodes())) {
|
|
9994
|
+
return true;
|
|
10009
9995
|
}
|
|
10010
9996
|
}
|
|
10011
9997
|
|
|
10012
|
-
function
|
|
10013
|
-
var _a
|
|
10014
|
-
|
|
10015
|
-
if (node instanceof HTMLElement) {
|
|
10016
|
-
let childNodesOfShadowRoot = (_b = (_a = node) === null || _a === void 0
|
|
10017
|
-
? void 0
|
|
10018
|
-
: _a.shadowRoot) === null || _b === void 0
|
|
10019
|
-
? void 0
|
|
10020
|
-
: _b.childNodes;
|
|
9998
|
+
function focusOnLastNodeOfShadowDOM(node) {
|
|
9999
|
+
var _a;
|
|
10000
|
+
if (!(node instanceof HTMLElement)) return false;
|
|
10021
10001
|
|
|
10022
|
-
|
|
10023
|
-
|
|
10024
|
-
|
|
10002
|
+
if (focusOnLastNode((_a = node.shadowRoot) === null || _a === void 0
|
|
10003
|
+
? void 0
|
|
10004
|
+
: _a.childNodes)) {
|
|
10005
|
+
return true;
|
|
10025
10006
|
}
|
|
10026
10007
|
}
|
|
10027
10008
|
|
|
10028
|
-
function
|
|
10029
|
-
if (!isFocusable(element))
|
|
10030
|
-
return false;
|
|
10031
|
-
}
|
|
10032
|
-
|
|
10033
|
-
ignoreFocusChanges = true;
|
|
10009
|
+
function focus(element) {
|
|
10010
|
+
if (!isFocusable(element)) return false;
|
|
10034
10011
|
|
|
10035
10012
|
try {
|
|
10013
|
+
ignoreFocusChanges = true;
|
|
10036
10014
|
element.focus();
|
|
10037
10015
|
} catch(e) {
|
|
10038
10016
|
|
|
10017
|
+
} finally {
|
|
10018
|
+
ignoreFocusChanges = false;
|
|
10039
10019
|
}
|
|
10040
10020
|
|
|
10041
|
-
ignoreFocusChanges = false;
|
|
10042
10021
|
return document.activeElement === element;
|
|
10043
10022
|
}
|
|
10044
10023
|
|
|
10045
10024
|
function trapFocus(event) {
|
|
10046
10025
|
var _a;
|
|
10047
|
-
|
|
10048
|
-
if (ignoreFocusChanges) {
|
|
10049
|
-
return;
|
|
10050
|
-
}
|
|
10026
|
+
if (ignoreFocusChanges) return;
|
|
10051
10027
|
|
|
10052
10028
|
const slotElements = (_a = element.firstChild) === null || _a === void 0
|
|
10053
10029
|
? void 0
|
|
@@ -10061,15 +10037,16 @@ function instance$6($$self, $$props, $$invalidate) {
|
|
|
10061
10037
|
|
|
10062
10038
|
if (event.composedPath().includes(contentRootElement)) {
|
|
10063
10039
|
lastFocus = event.target;
|
|
10064
|
-
|
|
10065
|
-
|
|
10040
|
+
return;
|
|
10041
|
+
}
|
|
10066
10042
|
|
|
10067
|
-
|
|
10068
|
-
attemptFocusOnLastDescendant(contentRootElement.childNodes);
|
|
10069
|
-
}
|
|
10043
|
+
focusOnFirstNode(contentRootElement.childNodes);
|
|
10070
10044
|
|
|
10071
|
-
|
|
10045
|
+
if (lastFocus == document.activeElement) {
|
|
10046
|
+
focusOnLastNode(contentRootElement.childNodes);
|
|
10072
10047
|
}
|
|
10048
|
+
|
|
10049
|
+
lastFocus = document.activeElement;
|
|
10073
10050
|
}
|
|
10074
10051
|
|
|
10075
10052
|
function div_binding($$value) {
|
|
@@ -10080,26 +10057,30 @@ function instance$6($$self, $$props, $$invalidate) {
|
|
|
10080
10057
|
}
|
|
10081
10058
|
|
|
10082
10059
|
$$self.$$set = $$props => {
|
|
10083
|
-
if ('
|
|
10060
|
+
if ('active' in $$props) $$invalidate(1, active = $$props.active);
|
|
10084
10061
|
};
|
|
10085
10062
|
|
|
10086
10063
|
$$self.$$.update = () => {
|
|
10087
|
-
if ($$self.$$.dirty & /*
|
|
10088
|
-
$$invalidate(
|
|
10064
|
+
if ($$self.$$.dirty & /*active*/ 2) {
|
|
10065
|
+
$$invalidate(3, isActive = toBoolean(active));
|
|
10089
10066
|
}
|
|
10090
10067
|
|
|
10091
|
-
if ($$self.$$.dirty & /*
|
|
10068
|
+
if ($$self.$$.dirty & /*isActive, hasListeners*/ 12) {
|
|
10092
10069
|
{
|
|
10093
|
-
if (
|
|
10070
|
+
if (isActive && !hasListeners) {
|
|
10094
10071
|
addListeners();
|
|
10095
|
-
|
|
10072
|
+
$$invalidate(2, hasListeners = true);
|
|
10073
|
+
}
|
|
10074
|
+
|
|
10075
|
+
if (!isActive && hasListeners) {
|
|
10096
10076
|
removeListeners();
|
|
10077
|
+
$$invalidate(2, hasListeners = false);
|
|
10097
10078
|
}
|
|
10098
10079
|
}
|
|
10099
10080
|
}
|
|
10100
10081
|
};
|
|
10101
10082
|
|
|
10102
|
-
return [element,
|
|
10083
|
+
return [element, active, hasListeners, isActive, div_binding];
|
|
10103
10084
|
}
|
|
10104
10085
|
|
|
10105
10086
|
class FocusTrap extends SvelteElement {
|
|
@@ -10116,7 +10097,7 @@ class FocusTrap extends SvelteElement {
|
|
|
10116
10097
|
instance$6,
|
|
10117
10098
|
create_fragment$7,
|
|
10118
10099
|
safe_not_equal,
|
|
10119
|
-
{
|
|
10100
|
+
{ active: 1 },
|
|
10120
10101
|
null
|
|
10121
10102
|
);
|
|
10122
10103
|
|
|
@@ -10133,15 +10114,15 @@ class FocusTrap extends SvelteElement {
|
|
|
10133
10114
|
}
|
|
10134
10115
|
|
|
10135
10116
|
static get observedAttributes() {
|
|
10136
|
-
return ["
|
|
10117
|
+
return ["active"];
|
|
10137
10118
|
}
|
|
10138
10119
|
|
|
10139
|
-
get
|
|
10120
|
+
get active() {
|
|
10140
10121
|
return this.$$.ctx[1];
|
|
10141
10122
|
}
|
|
10142
10123
|
|
|
10143
|
-
set
|
|
10144
|
-
this.$$set({
|
|
10124
|
+
set active(active) {
|
|
10125
|
+
this.$$set({ active });
|
|
10145
10126
|
flush();
|
|
10146
10127
|
}
|
|
10147
10128
|
}
|