@abgov/react-components 4.0.0-alpha.26 → 4.0.0-alpha.29

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/react-components",
3
- "version": "4.0.0-alpha.26",
3
+ "version": "4.0.0-alpha.29",
4
4
  "description": "Government of Alberta - UI components for React",
5
5
  "bugs": {
6
6
  "url": "https://github.com/GovAlta/ui-components/issues"
@@ -2594,7 +2594,7 @@ function instance$u($$self, $$props, $$invalidate) {
2594
2594
  type
2595
2595
  } = $$props;
2596
2596
  let {
2597
- heading
2597
+ heading = ""
2598
2598
  } = $$props;
2599
2599
  let {
2600
2600
  testid = ""
@@ -3850,7 +3850,7 @@ function instance$q($$self, $$props, $$invalidate) {
3850
3850
  class Chip extends SvelteElement {
3851
3851
  constructor(options) {
3852
3852
  super();
3853
- this.shadowRoot.innerHTML = `<style>.leading-icon{margin-left:-0.25rem}.chip{vertical-align:middle;align-items:center;background-color:var(--color-white);border-radius:99px;border:1px solid #949494;box-sizing:border-box;color:var(--goa-color-text);display:inline-flex;flex-direction:row;font-size:var(--chip-font-size);font-weight:var(--fw-regular);gap:0.25rem;height:2rem;justify-content:center;margin:0.25rem;padding:0 0.75rem}.text{padding-bottom:var(--font-valign-fix)}.chip:focus{outline:2px solid var(--goa-color-interactive--focus);background-color:var(--color-white)}.chip:hover{background-color:var(--color-gray-200)}.deletable{cursor:pointer}.delete-icon{margin-right:-0.25rem}.error,.error:hover{background-color:var(--goa-color-status-emergency-light)}</style>`;
3853
+ this.shadowRoot.innerHTML = `<style>.leading-icon{margin-left:-0.25rem}.chip{vertical-align:middle;align-items:center;background-color:var(--color-white);border-radius:99px;border:1px solid #949494;box-sizing:border-box;color:var(--goa-color-text);display:inline-flex;flex-direction:row;font-size:var(--chip-font-size);font-weight:var(--fw-regular);gap:0.25rem;height:2rem;justify-content:center;margin:0.25rem;padding:0 0.75rem;cursor:default}.text{padding-bottom:var(--font-valign-fix)}.chip:focus{outline:2px solid var(--goa-color-interactive--focus);background-color:var(--color-white)}.chip:hover{background-color:var(--color-gray-200)}.deletable{cursor:pointer}.delete-icon{margin-right:-0.25rem}.error,.error:hover{background-color:var(--goa-color-status-emergency-light)}</style>`;
3854
3854
  init(this, {
3855
3855
  target: this.shadowRoot,
3856
3856
  props: attribute_to_object(this.attributes),
@@ -7664,7 +7664,7 @@ function create_if_block$9(ctx) {
7664
7664
  ctx[2] && `--width: ${
7665
7665
  /*width*/
7666
7666
  ctx[2]};`) + ";");
7667
- set_custom_element_data(goa_focus_trap, "open",
7667
+ set_custom_element_data(goa_focus_trap, "active",
7668
7668
  /*open*/
7669
7669
  ctx[1]);
7670
7670
  },
@@ -7765,7 +7765,7 @@ function create_if_block$9(ctx) {
7765
7765
  if (!current || dirty &
7766
7766
  /*open*/
7767
7767
  2) {
7768
- set_custom_element_data(goa_focus_trap, "open",
7768
+ set_custom_element_data(goa_focus_trap, "active",
7769
7769
  /*open*/
7770
7770
  ctx[1]);
7771
7771
  }
@@ -11812,7 +11812,7 @@ function instance$7($$self, $$props, $$invalidate) {
11812
11812
  class TextArea extends SvelteElement {
11813
11813
  constructor(options) {
11814
11814
  super();
11815
- this.shadowRoot.innerHTML = `<style>:host{box-sizing:border-box;font-family:var(--font-family)}.container{position:relative;width:100%}@media(min-width: 640px){.container{max-width:var(--width)}}.goa-textarea{display:block;width:100%;box-sizing:border-box;outline:none;transition:box-shadow 0.1s ease-in;border:1px solid var(--color-gray-600);border-radius:3px;background:var(--color-white);color:var(--color-black, #ccc);padding:var(--input-padding, 0.5rem);font-size:var(--input-font-size);font-family:var(--font-family);min-width:100%}@media(min-width: 640px){.goa-textarea{min-width:0;width:var(--width)}}.goa-textarea[readonly]{cursor:pointer}.goa-textarea:hover{border-color:var(--goa-color-interactive--hover)}.goa-textarea:active,.goa-textarea:focus,.goa-textarea:focus-within{box-shadow:0 0 0 3px var(--goa-color-interactive--focus)}.goa-textarea:disabled{border-color:var(--color-gray-200)}.goa-textarea:disabled:hover{border-color:var(--color-gray-200)}.goa-textarea:disabled:focus,.goa-textarea:disabled:active{box-shadow:none}.counter{position:absolute;right:0;padding-top:0.25rem;font-size:var(--fs-sm)}.counter-error{color:var(--goa-color-interactive--error)
11815
+ this.shadowRoot.innerHTML = `<style>:host{box-sizing:border-box;font-family:var(--font-family)}.container{position:relative;width:100%}@media(min-width: 640px){.container{max-width:var(--width)}}.goa-textarea{display:block;width:100%;box-sizing:border-box;outline:none;transition:box-shadow 0.1s ease-in;border:1px solid var(--color-gray-600);border-radius:3px;background:var(--color-white);color:var(--color-black, #ccc);padding:var(--textarea-padding-vertical, 0.5rem) var(--textarea-padding-horizontal, 0.5rem);font-size:var(--input-font-size);font-family:var(--font-family);min-width:100%}@media(min-width: 640px){.goa-textarea{min-width:0;width:var(--width)}}.goa-textarea[readonly]{cursor:pointer}.goa-textarea:hover{border-color:var(--goa-color-interactive--hover)}.goa-textarea:active,.goa-textarea:focus,.goa-textarea:focus-within{box-shadow:0 0 0 3px var(--goa-color-interactive--focus)}.goa-textarea:disabled{border-color:var(--color-gray-200)}.goa-textarea:disabled:hover{border-color:var(--color-gray-200)}.goa-textarea:disabled:focus,.goa-textarea:disabled:active{box-shadow:none}.counter{position:absolute;right:0;padding-top:0.25rem;font-size:var(--fs-sm)}.counter-error{color:var(--goa-color-interactive--error)
11816
11816
  }.error:hover,.error:focus,.error{border:2px solid var(--goa-color-interactive--error)}</style>`;
11817
11817
  init(this, {
11818
11818
  target: this.shadowRoot,
@@ -11989,7 +11989,7 @@ function create_fragment$7(ctx) {
11989
11989
  insert(target, div, anchor);
11990
11990
  /*div_binding*/
11991
11991
 
11992
- ctx[3](div);
11992
+ ctx[4](div);
11993
11993
  },
11994
11994
 
11995
11995
  p: noop,
@@ -12000,20 +12000,16 @@ function create_fragment$7(ctx) {
12000
12000
  if (detaching) detach(div);
12001
12001
  /*div_binding*/
12002
12002
 
12003
- ctx[3](null);
12003
+ ctx[4](null);
12004
12004
  }
12005
12005
 
12006
12006
  };
12007
12007
  }
12008
12008
 
12009
12009
  function isFocusable(element) {
12010
- if (element.tabIndex > 0 || element.tabIndex === 0 && element.getAttribute('tabIndex') !== null) {
12011
- return true;
12012
- }
12013
-
12014
- if (element.disabled) {
12015
- return false;
12016
- }
12010
+ const isTabbable = element.tabIndex > 0 || element.tabIndex === 0 && element.getAttribute('tabIndex') !== null;
12011
+ if (isTabbable) return true;
12012
+ if (element.disabled) return false;
12017
12013
 
12018
12014
  switch (element.nodeName) {
12019
12015
  case 'A':
@@ -12033,13 +12029,14 @@ function isFocusable(element) {
12033
12029
  }
12034
12030
 
12035
12031
  function instance$6($$self, $$props, $$invalidate) {
12036
- let isOpen;
12032
+ let isActive;
12033
+ let {
12034
+ active
12035
+ } = $$props;
12037
12036
  let ignoreFocusChanges = false;
12038
12037
  let lastFocus;
12039
12038
  let element;
12040
- let {
12041
- open
12042
- } = $$props;
12039
+ let hasListeners = false;
12043
12040
 
12044
12041
  function removeListeners() {
12045
12042
  document.removeEventListener('focus', trapFocus, true);
@@ -12047,15 +12044,18 @@ function instance$6($$self, $$props, $$invalidate) {
12047
12044
 
12048
12045
  function addListeners() {
12049
12046
  document.addEventListener('focus', trapFocus, true);
12050
- }
12047
+ } // ====
12048
+ // First Node
12049
+ // ====
12051
12050
 
12052
- function attemptFocusOnFirstDescendant(descendants) {
12053
- if (!descendants) return false;
12054
12051
 
12055
- for (let i = 0; i < descendants.length; i++) {
12056
- let descendant = descendants[i];
12052
+ function focusOnFirstNode(nodes) {
12053
+ if (!nodes) return false;
12057
12054
 
12058
- if (attemptFocus(descendant) || attemptFocusOnFirstDescendant(descendant.childNodes) || attemptFocusOnFirstDescendantOfSlotElement(descendant) || attemptFocusOnFirstDescendantOfShadowDOM(descendant)) {
12055
+ for (const node of nodes) {
12056
+ const isFocusable = focus(node) || focusOnFirstNode(node.childNodes) || focusOnFirstNodeOfSlot(node) || focusOnFirstNodeOfShadowDOM(node);
12057
+
12058
+ if (isFocusable) {
12059
12059
  return true;
12060
12060
  }
12061
12061
  }
@@ -12063,37 +12063,34 @@ function instance$6($$self, $$props, $$invalidate) {
12063
12063
  return false;
12064
12064
  }
12065
12065
 
12066
- function attemptFocusOnFirstDescendantOfSlotElement(node) {
12067
- var _a;
12068
-
12069
- if (node instanceof HTMLSlotElement) {
12070
- let assingedNodesOfSlotElement = (_a = node) === null || _a === void 0 ? void 0 : _a.assignedNodes();
12066
+ function focusOnFirstNodeOfSlot(node) {
12067
+ if (!(node instanceof HTMLSlotElement)) return false;
12071
12068
 
12072
- if (attemptFocusOnFirstDescendant(assingedNodesOfSlotElement)) {
12073
- return true;
12074
- }
12069
+ if (focusOnFirstNode(node.assignedNodes())) {
12070
+ return true;
12075
12071
  }
12076
12072
  }
12077
12073
 
12078
- function attemptFocusOnFirstDescendantOfShadowDOM(node) {
12079
- var _a, _b;
12074
+ function focusOnFirstNodeOfShadowDOM(node) {
12075
+ var _a;
12080
12076
 
12081
- if (node instanceof HTMLElement) {
12082
- let childNodesOfShadowRoot = (_b = (_a = node) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.childNodes;
12077
+ if (!(node instanceof HTMLElement)) return false;
12083
12078
 
12084
- if (attemptFocusOnFirstDescendant(childNodesOfShadowRoot)) {
12085
- return true;
12086
- }
12079
+ if (focusOnFirstNode((_a = node.shadowRoot) === null || _a === void 0 ? void 0 : _a.childNodes)) {
12080
+ return true;
12087
12081
  }
12088
- }
12082
+ } // ====
12083
+ // Last Node
12084
+ // ====
12089
12085
 
12090
- function attemptFocusOnLastDescendant(descendants) {
12091
- if (!descendants) return false;
12092
12086
 
12093
- for (let i = descendants.length - 1; i >= 0; i--) {
12094
- let descendant = descendants[i];
12087
+ function focusOnLastNode(nodes) {
12088
+ if (!nodes) return false;
12095
12089
 
12096
- if (attemptFocus(descendant) || attemptFocusOnLastDescendant(descendant.childNodes) || attemptFocusOnLastDescendantOfSlotElement(descendant) || attemptFocusOnLastDescendantOfShadowDOM(descendant)) {
12090
+ for (let i = nodes.length - 1; i >= 0; i--) {
12091
+ let node = nodes[i];
12092
+
12093
+ if (focus(node) || focusOnLastNode(node.childNodes) || focusOnLastNodeOfSlot(node) || focusOnLastNodeOfShadowDOM(node)) {
12097
12094
  return true;
12098
12095
  }
12099
12096
  }
@@ -12101,67 +12098,57 @@ function instance$6($$self, $$props, $$invalidate) {
12101
12098
  return false;
12102
12099
  }
12103
12100
 
12104
- function attemptFocusOnLastDescendantOfSlotElement(node) {
12105
- var _a;
12106
-
12107
- if (node instanceof HTMLSlotElement) {
12108
- let assingedNodesOfSlotElement = (_a = node) === null || _a === void 0 ? void 0 : _a.assignedNodes();
12101
+ function focusOnLastNodeOfSlot(node) {
12102
+ if (!(node instanceof HTMLSlotElement)) return false;
12109
12103
 
12110
- if (attemptFocusOnLastDescendant(assingedNodesOfSlotElement)) {
12111
- return true;
12112
- }
12104
+ if (focusOnLastNode(node.assignedNodes())) {
12105
+ return true;
12113
12106
  }
12114
12107
  }
12115
12108
 
12116
- function attemptFocusOnLastDescendantOfShadowDOM(node) {
12117
- var _a, _b;
12109
+ function focusOnLastNodeOfShadowDOM(node) {
12110
+ var _a;
12118
12111
 
12119
- if (node instanceof HTMLElement) {
12120
- let childNodesOfShadowRoot = (_b = (_a = node) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.childNodes;
12112
+ if (!(node instanceof HTMLElement)) return false;
12121
12113
 
12122
- if (attemptFocusOnLastDescendant(childNodesOfShadowRoot)) {
12123
- return true;
12124
- }
12114
+ if (focusOnLastNode((_a = node.shadowRoot) === null || _a === void 0 ? void 0 : _a.childNodes)) {
12115
+ return true;
12125
12116
  }
12126
12117
  }
12127
12118
 
12128
- function attemptFocus(element) {
12129
- if (!isFocusable(element)) {
12130
- return false;
12131
- }
12132
-
12133
- ignoreFocusChanges = true;
12119
+ function focus(element) {
12120
+ if (!isFocusable(element)) return false;
12134
12121
 
12135
12122
  try {
12123
+ ignoreFocusChanges = true;
12136
12124
  element.focus();
12137
- } catch (e) {}
12125
+ } catch (e) {} finally {
12126
+ ignoreFocusChanges = false;
12127
+ }
12138
12128
 
12139
- ignoreFocusChanges = false;
12140
12129
  return document.activeElement === element;
12141
12130
  }
12142
12131
 
12143
12132
  function trapFocus(event) {
12144
12133
  var _a;
12145
12134
 
12146
- if (ignoreFocusChanges) {
12147
- return;
12148
- }
12149
-
12135
+ if (ignoreFocusChanges) return;
12150
12136
  const slotElements = (_a = element.firstChild) === null || _a === void 0 ? void 0 : _a.assignedElements();
12151
12137
  if (!(slotElements === null || slotElements === void 0 ? void 0 : slotElements.length)) return;
12152
12138
  const contentRootElement = slotElements[0];
12153
12139
 
12154
12140
  if (event.composedPath().includes(contentRootElement)) {
12155
12141
  lastFocus = event.target;
12156
- } else {
12157
- attemptFocusOnFirstDescendant(contentRootElement.childNodes);
12142
+ return;
12143
+ }
12158
12144
 
12159
- if (lastFocus == document.activeElement) {
12160
- attemptFocusOnLastDescendant(contentRootElement.childNodes);
12161
- }
12145
+ focusOnFirstNode(contentRootElement.childNodes);
12162
12146
 
12163
- lastFocus = document.activeElement;
12147
+ if (lastFocus == document.activeElement) {
12148
+ focusOnLastNode(contentRootElement.childNodes);
12164
12149
  }
12150
+
12151
+ lastFocus = document.activeElement;
12165
12152
  }
12166
12153
 
12167
12154
  function div_binding($$value) {
@@ -12172,30 +12159,34 @@ function instance$6($$self, $$props, $$invalidate) {
12172
12159
  }
12173
12160
 
12174
12161
  $$self.$$set = $$props => {
12175
- if ('open' in $$props) $$invalidate(1, open = $$props.open);
12162
+ if ('active' in $$props) $$invalidate(1, active = $$props.active);
12176
12163
  };
12177
12164
 
12178
12165
  $$self.$$.update = () => {
12179
12166
  if ($$self.$$.dirty &
12180
- /*open*/
12167
+ /*active*/
12181
12168
  2) {
12182
- $$invalidate(2, isOpen = toBoolean(open));
12169
+ $$invalidate(3, isActive = toBoolean(active));
12183
12170
  }
12184
12171
 
12185
12172
  if ($$self.$$.dirty &
12186
- /*isOpen*/
12187
- 4) {
12173
+ /*isActive, hasListeners*/
12174
+ 12) {
12188
12175
  {
12189
- if (isOpen) {
12176
+ if (isActive && !hasListeners) {
12190
12177
  addListeners();
12191
- } else {
12178
+ $$invalidate(2, hasListeners = true);
12179
+ }
12180
+
12181
+ if (!isActive && hasListeners) {
12192
12182
  removeListeners();
12183
+ $$invalidate(2, hasListeners = false);
12193
12184
  }
12194
12185
  }
12195
12186
  }
12196
12187
  };
12197
12188
 
12198
- return [element, open, isOpen, div_binding];
12189
+ return [element, active, hasListeners, isActive, div_binding];
12199
12190
  }
12200
12191
 
12201
12192
  class FocusTrap extends SvelteElement {
@@ -12206,7 +12197,7 @@ class FocusTrap extends SvelteElement {
12206
12197
  props: attribute_to_object(this.attributes),
12207
12198
  customElement: true
12208
12199
  }, instance$6, create_fragment$7, safe_not_equal, {
12209
- open: 1
12200
+ active: 1
12210
12201
  }, null);
12211
12202
 
12212
12203
  if (options) {
@@ -12222,16 +12213,16 @@ class FocusTrap extends SvelteElement {
12222
12213
  }
12223
12214
 
12224
12215
  static get observedAttributes() {
12225
- return ["open"];
12216
+ return ["active"];
12226
12217
  }
12227
12218
 
12228
- get open() {
12219
+ get active() {
12229
12220
  return this.$$.ctx[1];
12230
12221
  }
12231
12222
 
12232
- set open(open) {
12223
+ set active(active) {
12233
12224
  this.$$set({
12234
- open
12225
+ active
12235
12226
  });
12236
12227
  flush();
12237
12228
  }
@@ -2650,7 +2650,7 @@
2650
2650
  type
2651
2651
  } = $$props;
2652
2652
  let {
2653
- heading
2653
+ heading = ""
2654
2654
  } = $$props;
2655
2655
  let {
2656
2656
  testid = ""
@@ -3906,7 +3906,7 @@
3906
3906
  class Chip extends SvelteElement {
3907
3907
  constructor(options) {
3908
3908
  super();
3909
- this.shadowRoot.innerHTML = `<style>.leading-icon{margin-left:-0.25rem}.chip{vertical-align:middle;align-items:center;background-color:var(--color-white);border-radius:99px;border:1px solid #949494;box-sizing:border-box;color:var(--goa-color-text);display:inline-flex;flex-direction:row;font-size:var(--chip-font-size);font-weight:var(--fw-regular);gap:0.25rem;height:2rem;justify-content:center;margin:0.25rem;padding:0 0.75rem}.text{padding-bottom:var(--font-valign-fix)}.chip:focus{outline:2px solid var(--goa-color-interactive--focus);background-color:var(--color-white)}.chip:hover{background-color:var(--color-gray-200)}.deletable{cursor:pointer}.delete-icon{margin-right:-0.25rem}.error,.error:hover{background-color:var(--goa-color-status-emergency-light)}</style>`;
3909
+ this.shadowRoot.innerHTML = `<style>.leading-icon{margin-left:-0.25rem}.chip{vertical-align:middle;align-items:center;background-color:var(--color-white);border-radius:99px;border:1px solid #949494;box-sizing:border-box;color:var(--goa-color-text);display:inline-flex;flex-direction:row;font-size:var(--chip-font-size);font-weight:var(--fw-regular);gap:0.25rem;height:2rem;justify-content:center;margin:0.25rem;padding:0 0.75rem;cursor:default}.text{padding-bottom:var(--font-valign-fix)}.chip:focus{outline:2px solid var(--goa-color-interactive--focus);background-color:var(--color-white)}.chip:hover{background-color:var(--color-gray-200)}.deletable{cursor:pointer}.delete-icon{margin-right:-0.25rem}.error,.error:hover{background-color:var(--goa-color-status-emergency-light)}</style>`;
3910
3910
  init(this, {
3911
3911
  target: this.shadowRoot,
3912
3912
  props: attribute_to_object(this.attributes),
@@ -7707,7 +7707,7 @@
7707
7707
  ctx[2] && `--width: ${
7708
7708
  /*width*/
7709
7709
  ctx[2]};`) + ";");
7710
- set_custom_element_data(goa_focus_trap, "open",
7710
+ set_custom_element_data(goa_focus_trap, "active",
7711
7711
  /*open*/
7712
7712
  ctx[1]);
7713
7713
  },
@@ -7808,7 +7808,7 @@
7808
7808
  if (!current || dirty &
7809
7809
  /*open*/
7810
7810
  2) {
7811
- set_custom_element_data(goa_focus_trap, "open",
7811
+ set_custom_element_data(goa_focus_trap, "active",
7812
7812
  /*open*/
7813
7813
  ctx[1]);
7814
7814
  }
@@ -11858,7 +11858,7 @@
11858
11858
  class TextArea extends SvelteElement {
11859
11859
  constructor(options) {
11860
11860
  super();
11861
- this.shadowRoot.innerHTML = `<style>:host{box-sizing:border-box;font-family:var(--font-family)}.container{position:relative;width:100%}@media(min-width: 640px){.container{max-width:var(--width)}}.goa-textarea{display:block;width:100%;box-sizing:border-box;outline:none;transition:box-shadow 0.1s ease-in;border:1px solid var(--color-gray-600);border-radius:3px;background:var(--color-white);color:var(--color-black, #ccc);padding:var(--input-padding, 0.5rem);font-size:var(--input-font-size);font-family:var(--font-family);min-width:100%}@media(min-width: 640px){.goa-textarea{min-width:0;width:var(--width)}}.goa-textarea[readonly]{cursor:pointer}.goa-textarea:hover{border-color:var(--goa-color-interactive--hover)}.goa-textarea:active,.goa-textarea:focus,.goa-textarea:focus-within{box-shadow:0 0 0 3px var(--goa-color-interactive--focus)}.goa-textarea:disabled{border-color:var(--color-gray-200)}.goa-textarea:disabled:hover{border-color:var(--color-gray-200)}.goa-textarea:disabled:focus,.goa-textarea:disabled:active{box-shadow:none}.counter{position:absolute;right:0;padding-top:0.25rem;font-size:var(--fs-sm)}.counter-error{color:var(--goa-color-interactive--error)
11861
+ this.shadowRoot.innerHTML = `<style>:host{box-sizing:border-box;font-family:var(--font-family)}.container{position:relative;width:100%}@media(min-width: 640px){.container{max-width:var(--width)}}.goa-textarea{display:block;width:100%;box-sizing:border-box;outline:none;transition:box-shadow 0.1s ease-in;border:1px solid var(--color-gray-600);border-radius:3px;background:var(--color-white);color:var(--color-black, #ccc);padding:var(--textarea-padding-vertical, 0.5rem) var(--textarea-padding-horizontal, 0.5rem);font-size:var(--input-font-size);font-family:var(--font-family);min-width:100%}@media(min-width: 640px){.goa-textarea{min-width:0;width:var(--width)}}.goa-textarea[readonly]{cursor:pointer}.goa-textarea:hover{border-color:var(--goa-color-interactive--hover)}.goa-textarea:active,.goa-textarea:focus,.goa-textarea:focus-within{box-shadow:0 0 0 3px var(--goa-color-interactive--focus)}.goa-textarea:disabled{border-color:var(--color-gray-200)}.goa-textarea:disabled:hover{border-color:var(--color-gray-200)}.goa-textarea:disabled:focus,.goa-textarea:disabled:active{box-shadow:none}.counter{position:absolute;right:0;padding-top:0.25rem;font-size:var(--fs-sm)}.counter-error{color:var(--goa-color-interactive--error)
11862
11862
  }.error:hover,.error:focus,.error{border:2px solid var(--goa-color-interactive--error)}</style>`;
11863
11863
  init(this, {
11864
11864
  target: this.shadowRoot,
@@ -12035,7 +12035,7 @@
12035
12035
  insert(target, div, anchor);
12036
12036
  /*div_binding*/
12037
12037
 
12038
- ctx[3](div);
12038
+ ctx[4](div);
12039
12039
  },
12040
12040
 
12041
12041
  p: noop,
@@ -12046,20 +12046,16 @@
12046
12046
  if (detaching) detach(div);
12047
12047
  /*div_binding*/
12048
12048
 
12049
- ctx[3](null);
12049
+ ctx[4](null);
12050
12050
  }
12051
12051
 
12052
12052
  };
12053
12053
  }
12054
12054
 
12055
12055
  function isFocusable(element) {
12056
- if (element.tabIndex > 0 || element.tabIndex === 0 && element.getAttribute('tabIndex') !== null) {
12057
- return true;
12058
- }
12059
-
12060
- if (element.disabled) {
12061
- return false;
12062
- }
12056
+ const isTabbable = element.tabIndex > 0 || element.tabIndex === 0 && element.getAttribute('tabIndex') !== null;
12057
+ if (isTabbable) return true;
12058
+ if (element.disabled) return false;
12063
12059
 
12064
12060
  switch (element.nodeName) {
12065
12061
  case 'A':
@@ -12079,13 +12075,14 @@
12079
12075
  }
12080
12076
 
12081
12077
  function instance$6($$self, $$props, $$invalidate) {
12082
- let isOpen;
12078
+ let isActive;
12079
+ let {
12080
+ active
12081
+ } = $$props;
12083
12082
  let ignoreFocusChanges = false;
12084
12083
  let lastFocus;
12085
12084
  let element;
12086
- let {
12087
- open
12088
- } = $$props;
12085
+ let hasListeners = false;
12089
12086
 
12090
12087
  function removeListeners() {
12091
12088
  document.removeEventListener('focus', trapFocus, true);
@@ -12093,15 +12090,18 @@
12093
12090
 
12094
12091
  function addListeners() {
12095
12092
  document.addEventListener('focus', trapFocus, true);
12096
- }
12093
+ } // ====
12094
+ // First Node
12095
+ // ====
12097
12096
 
12098
- function attemptFocusOnFirstDescendant(descendants) {
12099
- if (!descendants) return false;
12100
12097
 
12101
- for (let i = 0; i < descendants.length; i++) {
12102
- let descendant = descendants[i];
12098
+ function focusOnFirstNode(nodes) {
12099
+ if (!nodes) return false;
12103
12100
 
12104
- if (attemptFocus(descendant) || attemptFocusOnFirstDescendant(descendant.childNodes) || attemptFocusOnFirstDescendantOfSlotElement(descendant) || attemptFocusOnFirstDescendantOfShadowDOM(descendant)) {
12101
+ for (const node of nodes) {
12102
+ const isFocusable = focus(node) || focusOnFirstNode(node.childNodes) || focusOnFirstNodeOfSlot(node) || focusOnFirstNodeOfShadowDOM(node);
12103
+
12104
+ if (isFocusable) {
12105
12105
  return true;
12106
12106
  }
12107
12107
  }
@@ -12109,37 +12109,34 @@
12109
12109
  return false;
12110
12110
  }
12111
12111
 
12112
- function attemptFocusOnFirstDescendantOfSlotElement(node) {
12113
- var _a;
12114
-
12115
- if (node instanceof HTMLSlotElement) {
12116
- let assingedNodesOfSlotElement = (_a = node) === null || _a === void 0 ? void 0 : _a.assignedNodes();
12112
+ function focusOnFirstNodeOfSlot(node) {
12113
+ if (!(node instanceof HTMLSlotElement)) return false;
12117
12114
 
12118
- if (attemptFocusOnFirstDescendant(assingedNodesOfSlotElement)) {
12119
- return true;
12120
- }
12115
+ if (focusOnFirstNode(node.assignedNodes())) {
12116
+ return true;
12121
12117
  }
12122
12118
  }
12123
12119
 
12124
- function attemptFocusOnFirstDescendantOfShadowDOM(node) {
12125
- var _a, _b;
12120
+ function focusOnFirstNodeOfShadowDOM(node) {
12121
+ var _a;
12126
12122
 
12127
- if (node instanceof HTMLElement) {
12128
- let childNodesOfShadowRoot = (_b = (_a = node) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.childNodes;
12123
+ if (!(node instanceof HTMLElement)) return false;
12129
12124
 
12130
- if (attemptFocusOnFirstDescendant(childNodesOfShadowRoot)) {
12131
- return true;
12132
- }
12125
+ if (focusOnFirstNode((_a = node.shadowRoot) === null || _a === void 0 ? void 0 : _a.childNodes)) {
12126
+ return true;
12133
12127
  }
12134
- }
12128
+ } // ====
12129
+ // Last Node
12130
+ // ====
12135
12131
 
12136
- function attemptFocusOnLastDescendant(descendants) {
12137
- if (!descendants) return false;
12138
12132
 
12139
- for (let i = descendants.length - 1; i >= 0; i--) {
12140
- let descendant = descendants[i];
12133
+ function focusOnLastNode(nodes) {
12134
+ if (!nodes) return false;
12141
12135
 
12142
- if (attemptFocus(descendant) || attemptFocusOnLastDescendant(descendant.childNodes) || attemptFocusOnLastDescendantOfSlotElement(descendant) || attemptFocusOnLastDescendantOfShadowDOM(descendant)) {
12136
+ for (let i = nodes.length - 1; i >= 0; i--) {
12137
+ let node = nodes[i];
12138
+
12139
+ if (focus(node) || focusOnLastNode(node.childNodes) || focusOnLastNodeOfSlot(node) || focusOnLastNodeOfShadowDOM(node)) {
12143
12140
  return true;
12144
12141
  }
12145
12142
  }
@@ -12147,67 +12144,57 @@
12147
12144
  return false;
12148
12145
  }
12149
12146
 
12150
- function attemptFocusOnLastDescendantOfSlotElement(node) {
12151
- var _a;
12152
-
12153
- if (node instanceof HTMLSlotElement) {
12154
- let assingedNodesOfSlotElement = (_a = node) === null || _a === void 0 ? void 0 : _a.assignedNodes();
12147
+ function focusOnLastNodeOfSlot(node) {
12148
+ if (!(node instanceof HTMLSlotElement)) return false;
12155
12149
 
12156
- if (attemptFocusOnLastDescendant(assingedNodesOfSlotElement)) {
12157
- return true;
12158
- }
12150
+ if (focusOnLastNode(node.assignedNodes())) {
12151
+ return true;
12159
12152
  }
12160
12153
  }
12161
12154
 
12162
- function attemptFocusOnLastDescendantOfShadowDOM(node) {
12163
- var _a, _b;
12155
+ function focusOnLastNodeOfShadowDOM(node) {
12156
+ var _a;
12164
12157
 
12165
- if (node instanceof HTMLElement) {
12166
- let childNodesOfShadowRoot = (_b = (_a = node) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.childNodes;
12158
+ if (!(node instanceof HTMLElement)) return false;
12167
12159
 
12168
- if (attemptFocusOnLastDescendant(childNodesOfShadowRoot)) {
12169
- return true;
12170
- }
12160
+ if (focusOnLastNode((_a = node.shadowRoot) === null || _a === void 0 ? void 0 : _a.childNodes)) {
12161
+ return true;
12171
12162
  }
12172
12163
  }
12173
12164
 
12174
- function attemptFocus(element) {
12175
- if (!isFocusable(element)) {
12176
- return false;
12177
- }
12178
-
12179
- ignoreFocusChanges = true;
12165
+ function focus(element) {
12166
+ if (!isFocusable(element)) return false;
12180
12167
 
12181
12168
  try {
12169
+ ignoreFocusChanges = true;
12182
12170
  element.focus();
12183
- } catch (e) {}
12171
+ } catch (e) {} finally {
12172
+ ignoreFocusChanges = false;
12173
+ }
12184
12174
 
12185
- ignoreFocusChanges = false;
12186
12175
  return document.activeElement === element;
12187
12176
  }
12188
12177
 
12189
12178
  function trapFocus(event) {
12190
12179
  var _a;
12191
12180
 
12192
- if (ignoreFocusChanges) {
12193
- return;
12194
- }
12195
-
12181
+ if (ignoreFocusChanges) return;
12196
12182
  const slotElements = (_a = element.firstChild) === null || _a === void 0 ? void 0 : _a.assignedElements();
12197
12183
  if (!(slotElements === null || slotElements === void 0 ? void 0 : slotElements.length)) return;
12198
12184
  const contentRootElement = slotElements[0];
12199
12185
 
12200
12186
  if (event.composedPath().includes(contentRootElement)) {
12201
12187
  lastFocus = event.target;
12202
- } else {
12203
- attemptFocusOnFirstDescendant(contentRootElement.childNodes);
12188
+ return;
12189
+ }
12204
12190
 
12205
- if (lastFocus == document.activeElement) {
12206
- attemptFocusOnLastDescendant(contentRootElement.childNodes);
12207
- }
12191
+ focusOnFirstNode(contentRootElement.childNodes);
12208
12192
 
12209
- lastFocus = document.activeElement;
12193
+ if (lastFocus == document.activeElement) {
12194
+ focusOnLastNode(contentRootElement.childNodes);
12210
12195
  }
12196
+
12197
+ lastFocus = document.activeElement;
12211
12198
  }
12212
12199
 
12213
12200
  function div_binding($$value) {
@@ -12218,30 +12205,34 @@
12218
12205
  }
12219
12206
 
12220
12207
  $$self.$$set = $$props => {
12221
- if ('open' in $$props) $$invalidate(1, open = $$props.open);
12208
+ if ('active' in $$props) $$invalidate(1, active = $$props.active);
12222
12209
  };
12223
12210
 
12224
12211
  $$self.$$.update = () => {
12225
12212
  if ($$self.$$.dirty &
12226
- /*open*/
12213
+ /*active*/
12227
12214
  2) {
12228
- $$invalidate(2, isOpen = toBoolean(open));
12215
+ $$invalidate(3, isActive = toBoolean(active));
12229
12216
  }
12230
12217
 
12231
12218
  if ($$self.$$.dirty &
12232
- /*isOpen*/
12233
- 4) {
12219
+ /*isActive, hasListeners*/
12220
+ 12) {
12234
12221
  {
12235
- if (isOpen) {
12222
+ if (isActive && !hasListeners) {
12236
12223
  addListeners();
12237
- } else {
12224
+ $$invalidate(2, hasListeners = true);
12225
+ }
12226
+
12227
+ if (!isActive && hasListeners) {
12238
12228
  removeListeners();
12229
+ $$invalidate(2, hasListeners = false);
12239
12230
  }
12240
12231
  }
12241
12232
  }
12242
12233
  };
12243
12234
 
12244
- return [element, open, isOpen, div_binding];
12235
+ return [element, active, hasListeners, isActive, div_binding];
12245
12236
  }
12246
12237
 
12247
12238
  class FocusTrap extends SvelteElement {
@@ -12252,7 +12243,7 @@
12252
12243
  props: attribute_to_object(this.attributes),
12253
12244
  customElement: true
12254
12245
  }, instance$6, create_fragment$7, safe_not_equal, {
12255
- open: 1
12246
+ active: 1
12256
12247
  }, null);
12257
12248
 
12258
12249
  if (options) {
@@ -12268,16 +12259,16 @@
12268
12259
  }
12269
12260
 
12270
12261
  static get observedAttributes() {
12271
- return ["open"];
12262
+ return ["active"];
12272
12263
  }
12273
12264
 
12274
- get open() {
12265
+ get active() {
12275
12266
  return this.$$.ctx[1];
12276
12267
  }
12277
12268
 
12278
- set open(open) {
12269
+ set active(active) {
12279
12270
  this.$$set({
12280
- open
12271
+ active
12281
12272
  });
12282
12273
  flush();
12283
12274
  }