@iabbb/bds-react 0.40.0-beta.9 → 0.40.0

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/index.mjs CHANGED
@@ -1,89 +1,5 @@
1
1
  import * as React from 'react';
2
2
 
3
- function _iterableToArrayLimit(r, l) {
4
- var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
5
- if (null != t) {
6
- var e,
7
- n,
8
- i,
9
- u,
10
- a = [],
11
- f = !0,
12
- o = !1;
13
- try {
14
- if (i = (t = t.call(r)).next, 0 === l) {
15
- if (Object(t) !== t) return;
16
- f = !1;
17
- } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
18
- } catch (r) {
19
- o = !0, n = r;
20
- } finally {
21
- try {
22
- if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
23
- } finally {
24
- if (o) throw n;
25
- }
26
- }
27
- return a;
28
- }
29
- }
30
- function ownKeys(e, r) {
31
- var t = Object.keys(e);
32
- if (Object.getOwnPropertySymbols) {
33
- var o = Object.getOwnPropertySymbols(e);
34
- r && (o = o.filter(function (r) {
35
- return Object.getOwnPropertyDescriptor(e, r).enumerable;
36
- })), t.push.apply(t, o);
37
- }
38
- return t;
39
- }
40
- function _objectSpread2(e) {
41
- for (var r = 1; r < arguments.length; r++) {
42
- var t = null != arguments[r] ? arguments[r] : {};
43
- r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
44
- _defineProperty(e, r, t[r]);
45
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
46
- Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
47
- });
48
- }
49
- return e;
50
- }
51
- function _classCallCheck(instance, Constructor) {
52
- if (!(instance instanceof Constructor)) {
53
- throw new TypeError("Cannot call a class as a function");
54
- }
55
- }
56
- function _defineProperties(target, props) {
57
- for (var i = 0; i < props.length; i++) {
58
- var descriptor = props[i];
59
- descriptor.enumerable = descriptor.enumerable || false;
60
- descriptor.configurable = true;
61
- if ("value" in descriptor) descriptor.writable = true;
62
- Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
63
- }
64
- }
65
- function _createClass(Constructor, protoProps, staticProps) {
66
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
67
- if (staticProps) _defineProperties(Constructor, staticProps);
68
- Object.defineProperty(Constructor, "prototype", {
69
- writable: false
70
- });
71
- return Constructor;
72
- }
73
- function _defineProperty(obj, key, value) {
74
- key = _toPropertyKey(key);
75
- if (key in obj) {
76
- Object.defineProperty(obj, key, {
77
- value: value,
78
- enumerable: true,
79
- configurable: true,
80
- writable: true
81
- });
82
- } else {
83
- obj[key] = value;
84
- }
85
- return obj;
86
- }
87
3
  function _extends() {
88
4
  _extends = Object.assign ? Object.assign.bind() : function (target) {
89
5
  for (var i = 1; i < arguments.length; i++) {
@@ -98,90 +14,6 @@ function _extends() {
98
14
  };
99
15
  return _extends.apply(this, arguments);
100
16
  }
101
- function _inherits(subClass, superClass) {
102
- if (typeof superClass !== "function" && superClass !== null) {
103
- throw new TypeError("Super expression must either be null or a function");
104
- }
105
- subClass.prototype = Object.create(superClass && superClass.prototype, {
106
- constructor: {
107
- value: subClass,
108
- writable: true,
109
- configurable: true
110
- }
111
- });
112
- Object.defineProperty(subClass, "prototype", {
113
- writable: false
114
- });
115
- if (superClass) _setPrototypeOf(subClass, superClass);
116
- }
117
- function _getPrototypeOf(o) {
118
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
119
- return o.__proto__ || Object.getPrototypeOf(o);
120
- };
121
- return _getPrototypeOf(o);
122
- }
123
- function _setPrototypeOf(o, p) {
124
- _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
125
- o.__proto__ = p;
126
- return o;
127
- };
128
- return _setPrototypeOf(o, p);
129
- }
130
- function _isNativeReflectConstruct() {
131
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
132
- if (Reflect.construct.sham) return false;
133
- if (typeof Proxy === "function") return true;
134
- try {
135
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
136
- return true;
137
- } catch (e) {
138
- return false;
139
- }
140
- }
141
- function _construct(Parent, args, Class) {
142
- if (_isNativeReflectConstruct()) {
143
- _construct = Reflect.construct.bind();
144
- } else {
145
- _construct = function _construct(Parent, args, Class) {
146
- var a = [null];
147
- a.push.apply(a, args);
148
- var Constructor = Function.bind.apply(Parent, a);
149
- var instance = new Constructor();
150
- if (Class) _setPrototypeOf(instance, Class.prototype);
151
- return instance;
152
- };
153
- }
154
- return _construct.apply(null, arguments);
155
- }
156
- function _isNativeFunction(fn) {
157
- return Function.toString.call(fn).indexOf("[native code]") !== -1;
158
- }
159
- function _wrapNativeSuper(Class) {
160
- var _cache = typeof Map === "function" ? new Map() : undefined;
161
- _wrapNativeSuper = function _wrapNativeSuper(Class) {
162
- if (Class === null || !_isNativeFunction(Class)) return Class;
163
- if (typeof Class !== "function") {
164
- throw new TypeError("Super expression must either be null or a function");
165
- }
166
- if (typeof _cache !== "undefined") {
167
- if (_cache.has(Class)) return _cache.get(Class);
168
- _cache.set(Class, Wrapper);
169
- }
170
- function Wrapper() {
171
- return _construct(Class, arguments, _getPrototypeOf(this).constructor);
172
- }
173
- Wrapper.prototype = Object.create(Class.prototype, {
174
- constructor: {
175
- value: Wrapper,
176
- enumerable: false,
177
- writable: true,
178
- configurable: true
179
- }
180
- });
181
- return _setPrototypeOf(Wrapper, Class);
182
- };
183
- return _wrapNativeSuper(Class);
184
- }
185
17
  function _objectWithoutPropertiesLoose(source, excluded) {
186
18
  if (source == null) return {};
187
19
  var target = {};
@@ -209,46 +41,12 @@ function _objectWithoutProperties(source, excluded) {
209
41
  }
210
42
  return target;
211
43
  }
212
- function _assertThisInitialized(self) {
213
- if (self === void 0) {
214
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
215
- }
216
- return self;
217
- }
218
- function _possibleConstructorReturn(self, call) {
219
- if (call && (typeof call === "object" || typeof call === "function")) {
220
- return call;
221
- } else if (call !== void 0) {
222
- throw new TypeError("Derived constructors may only return object or undefined");
223
- }
224
- return _assertThisInitialized(self);
225
- }
226
- function _createSuper(Derived) {
227
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
228
- return function _createSuperInternal() {
229
- var Super = _getPrototypeOf(Derived),
230
- result;
231
- if (hasNativeReflectConstruct) {
232
- var NewTarget = _getPrototypeOf(this).constructor;
233
- result = Reflect.construct(Super, arguments, NewTarget);
234
- } else {
235
- result = Super.apply(this, arguments);
236
- }
237
- return _possibleConstructorReturn(this, result);
238
- };
239
- }
240
- function _slicedToArray(arr, i) {
241
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
242
- }
243
44
  function _toConsumableArray(arr) {
244
45
  return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
245
46
  }
246
47
  function _arrayWithoutHoles(arr) {
247
48
  if (Array.isArray(arr)) return _arrayLikeToArray(arr);
248
49
  }
249
- function _arrayWithHoles(arr) {
250
- if (Array.isArray(arr)) return arr;
251
- }
252
50
  function _iterableToArray(iter) {
253
51
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
254
52
  }
@@ -268,38 +66,6 @@ function _arrayLikeToArray(arr, len) {
268
66
  function _nonIterableSpread() {
269
67
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
270
68
  }
271
- function _nonIterableRest() {
272
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
273
- }
274
- function _toPrimitive(input, hint) {
275
- if (typeof input !== "object" || input === null) return input;
276
- var prim = input[Symbol.toPrimitive];
277
- if (prim !== undefined) {
278
- var res = prim.call(input, hint || "default");
279
- if (typeof res !== "object") return res;
280
- throw new TypeError("@@toPrimitive must return a primitive value.");
281
- }
282
- return (hint === "string" ? String : Number)(input);
283
- }
284
- function _toPropertyKey(arg) {
285
- var key = _toPrimitive(arg, "string");
286
- return typeof key === "symbol" ? key : String(key);
287
- }
288
- function _classPrivateMethodGet(receiver, privateSet, fn) {
289
- if (!privateSet.has(receiver)) {
290
- throw new TypeError("attempted to get private field on non-instance");
291
- }
292
- return fn;
293
- }
294
- function _checkPrivateRedeclaration(obj, privateCollection) {
295
- if (privateCollection.has(obj)) {
296
- throw new TypeError("Cannot initialize the same private elements twice on an object");
297
- }
298
- }
299
- function _classPrivateMethodInitSpec(obj, privateSet) {
300
- _checkPrivateRedeclaration(obj, privateSet);
301
- privateSet.add(obj);
302
- }
303
69
 
304
70
  var _excluded$5 = ["children", "className", "onClick", "preventDoubleClick", "variant"];
305
71
  var DEBOUNCE_TIMEOUT_IN_SECONDS = 1;
@@ -365,354 +131,46 @@ var CallToAction = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
365
131
  }, props), children);
366
132
  });
367
133
 
368
- // Shim the global element internals object
369
- // Methods should be fine as noops and properties can generally
370
- // be while on the server.
371
- var ElementInternalsShim = /*#__PURE__*/function () {
372
- function ElementInternals(_host) {
373
- _classCallCheck(this, ElementInternals);
374
- this.ariaAtomic = '';
375
- this.ariaAutoComplete = '';
376
- this.ariaBraileLabel = '';
377
- this.ariaBraileRoleDescription = '';
378
- this.ariaBusy = '';
379
- this.ariaChecked = '';
380
- this.ariaColCount = '';
381
- this.ariaColIndex = '';
382
- this.ariaColSpan = '';
383
- this.ariaCurrent = '';
384
- this.ariaDescription = '';
385
- this.ariaDisabled = '';
386
- this.ariaExpanded = '';
387
- this.ariaHasPopup = '';
388
- this.ariaHidden = '';
389
- this.ariaInvalid = '';
390
- this.ariaKeyShortcuts = '';
391
- this.ariaLabel = '';
392
- this.ariaLevel = '';
393
- this.ariaLive = '';
394
- this.ariaModal = '';
395
- this.ariaMultiLine = '';
396
- this.ariaMultiSelectable = '';
397
- this.ariaOrientation = '';
398
- this.ariaPlaceholder = '';
399
- this.ariaPosInSet = '';
400
- this.ariaPressed = '';
401
- this.ariaReadOnly = '';
402
- this.ariaRequired = '';
403
- this.ariaRoleDescription = '';
404
- this.ariaRowCount = '';
405
- this.ariaRowIndex = '';
406
- this.ariaRowSpan = '';
407
- this.ariaSelected = '';
408
- this.ariaSetSize = '';
409
- this.ariaSort = '';
410
- this.ariaValueMax = '';
411
- this.ariaValueMin = '';
412
- this.ariaValueNow = '';
413
- this.ariaValueText = '';
414
- this.role = '';
415
- this.form = null;
416
- this.labels = [];
417
- this.states = new Set();
418
- this.validationMessage = '';
419
- this.validity = {};
420
- this.willValidate = true;
421
- this.__host = _host;
422
- }
423
- _createClass(ElementInternals, [{
424
- key: "shadowRoot",
425
- get: function get() {
426
- // Grab the shadow root instance from the Element shim
427
- // to ensure that the shadow root is always available
428
- // to the internals instance even if the mode is 'closed'
429
- return this.__host.__shadowRoot;
430
- }
431
- }, {
432
- key: "checkValidity",
433
- value: function checkValidity() {
434
- // TODO(augustjk) Consider actually implementing logic.
435
- // See https://github.com/lit/lit/issues/3740
436
- console.warn('`ElementInternals.checkValidity()` was called on the server.' + 'This method always returns true.');
437
- return true;
438
- }
439
- }, {
440
- key: "reportValidity",
441
- value: function reportValidity() {
442
- return true;
443
- }
444
- }, {
445
- key: "setFormValue",
446
- value: function setFormValue() {}
447
- }, {
448
- key: "setValidity",
449
- value: function setValidity() {}
450
- }]);
451
- return ElementInternals;
452
- }();
134
+ function getFragmentFromUrl(url) {
135
+ return url.includes('#') ? url.split('#').pop() : undefined;
136
+ }
137
+ function getAssociatedLegendOrLabel(input) {
138
+ var _document$querySelect;
139
+ var fieldset = input.closest('fieldset');
140
+ if (fieldset) {
141
+ var legends = fieldset.getElementsByTagName('legend');
142
+ if (legends.length) {
143
+ var candidateLegend = legends[0];
453
144
 
454
- var attributes = new WeakMap();
455
- var attributesForElement = function attributesForElement(element) {
456
- var attrs = attributes.get(element);
457
- if (attrs === undefined) {
458
- attributes.set(element, attrs = new Map());
459
- }
460
- return attrs;
461
- };
462
- // The typings around the exports below are a little funky:
463
- //
464
- // 1. We want the `name` of the shim classes to match the real ones at runtime,
465
- // hence e.g. `class Element`.
466
- // 2. We can't shadow the global types with a simple class declaration, because
467
- // then we can't reference the global types for casting, hence e.g.
468
- // `const ElementShim = class Element`.
469
- // 3. We want to export the classes typed as the real ones, hence e.g.
470
- // `const ElementShimWithRealType = ElementShim as object as typeof Element;`.
471
- // 4. We want the exported names to match the real ones, hence e.g.
472
- // `export {ElementShimWithRealType as Element}`.
473
- var ElementShim = /*#__PURE__*/function () {
474
- function Element() {
475
- _classCallCheck(this, Element);
476
- this.__shadowRootMode = null;
477
- this.__shadowRoot = null;
478
- this.__internals = null;
479
- }
480
- _createClass(Element, [{
481
- key: "attributes",
482
- get: function get() {
483
- return Array.from(attributesForElement(this)).map(function (_ref) {
484
- var _ref2 = _slicedToArray(_ref, 2),
485
- name = _ref2[0],
486
- value = _ref2[1];
487
- return {
488
- name: name,
489
- value: value
490
- };
491
- });
492
- }
493
- }, {
494
- key: "shadowRoot",
495
- get: function get() {
496
- if (this.__shadowRootMode === 'closed') {
497
- return null;
145
+ // If the input type is radio or checkbox, always use the legend if there
146
+ // is one.
147
+ if (input instanceof HTMLInputElement && (input.type === 'checkbox' || input.type === 'radio')) {
148
+ return candidateLegend;
498
149
  }
499
- return this.__shadowRoot;
500
- }
501
- }, {
502
- key: "setAttribute",
503
- value: function setAttribute(name, value) {
504
- // Emulate browser behavior that silently casts all values to string. E.g.
505
- // `42` becomes `"42"` and `{}` becomes `"[object Object]""`.
506
- attributesForElement(this).set(name, String(value));
507
- }
508
- }, {
509
- key: "removeAttribute",
510
- value: function removeAttribute(name) {
511
- attributesForElement(this)["delete"](name);
512
- }
513
- }, {
514
- key: "hasAttribute",
515
- value: function hasAttribute(name) {
516
- return attributesForElement(this).has(name);
517
- }
518
- }, {
519
- key: "attachShadow",
520
- value: function attachShadow(init) {
521
- var shadowRoot = {
522
- host: this
523
- };
524
- this.__shadowRootMode = init.mode;
525
- if (init && init.mode === 'open') {
526
- this.__shadowRoot = shadowRoot;
527
- }
528
- return shadowRoot;
529
- }
530
- }, {
531
- key: "attachInternals",
532
- value: function attachInternals() {
533
- if (this.__internals !== null) {
534
- throw new Error("Failed to execute 'attachInternals' on 'HTMLElement': " + "ElementInternals for the specified element was already attached.");
535
- }
536
- var internals = new ElementInternalsShim(this);
537
- this.__internals = internals;
538
- return internals;
539
- }
540
- }, {
541
- key: "getAttribute",
542
- value: function getAttribute(name) {
543
- var value = attributesForElement(this).get(name);
544
- return value !== null && value !== void 0 ? value : null;
545
- }
546
- }]);
547
- return Element;
548
- }();
549
- var HTMLElementShim = /*#__PURE__*/function (_ElementShim) {
550
- _inherits(HTMLElement, _ElementShim);
551
- var _super = _createSuper(HTMLElement);
552
- function HTMLElement() {
553
- _classCallCheck(this, HTMLElement);
554
- return _super.apply(this, arguments);
555
- }
556
- return _createClass(HTMLElement);
557
- }(ElementShim);
558
- var HTMLElementShimWithRealType = HTMLElementShim;
559
- var CustomElementRegistryShim = /*#__PURE__*/function () {
560
- function CustomElementRegistry() {
561
- _classCallCheck(this, CustomElementRegistry);
562
- this.__definitions = new Map();
563
- }
564
- _createClass(CustomElementRegistry, [{
565
- key: "define",
566
- value: function define(name, ctor) {
567
- var _ctor$observedAttribu;
568
- if (this.__definitions.has(name)) {
569
- if (process.env.NODE_ENV === 'development') {
570
- console.warn("'CustomElementRegistry' already has \"".concat(name, "\" defined. ") + "This may have been caused by live reload or hot module " + "replacement in which case it can be safely ignored.\n" + "Make sure to test your application with a production build as " + "repeat registrations will throw in production.");
571
- } else {
572
- throw new Error("Failed to execute 'define' on 'CustomElementRegistry': " + "the name \"".concat(name, "\" has already been used with this registry"));
573
- }
574
- }
575
- this.__definitions.set(name, {
576
- ctor: ctor,
577
- // Note it's important we read `observedAttributes` in case it is a getter
578
- // with side-effects, as is the case in Lit, where it triggers class
579
- // finalization.
580
- //
581
- // TODO(aomarks) To be spec compliant, we should also capture the
582
- // registration-time lifecycle methods like `connectedCallback`. For them
583
- // to be actually accessible to e.g. the Lit SSR element renderer, though,
584
- // we'd need to introduce a new API for accessing them (since `get` only
585
- // returns the constructor).
586
- observedAttributes: (_ctor$observedAttribu = ctor.observedAttributes) !== null && _ctor$observedAttribu !== void 0 ? _ctor$observedAttribu : []
587
- });
588
- }
589
- }, {
590
- key: "get",
591
- value: function get(name) {
592
- var definition = this.__definitions.get(name);
593
- return definition === null || definition === void 0 ? void 0 : definition.ctor;
594
- }
595
- }]);
596
- return CustomElementRegistry;
597
- }();
598
- var CustomElementRegistryShimWithRealType = CustomElementRegistryShim;
599
- var customElements$1 = new CustomElementRegistryShimWithRealType();
600
150
 
601
- // Avoid installing the DOM shim if one already exists
602
- if (globalThis.window === undefined) {
603
- var window$1 = {
604
- customElements: customElements$1,
605
- HTMLElement: HTMLElementShimWithRealType
606
- };
607
- // Copy initial window globals to node global
608
- Object.assign(globalThis, window$1);
609
- }
151
+ // For other input types, only scroll to the fieldset’s legend (instead of
152
+ // the label associated with the input) if the input would end up in the
153
+ // top half of the screen.
154
+ //
155
+ // This should avoid situations where the input either ends up off the
156
+ // screen, or obscured by a software keyboard.
157
+ var legendTop = candidateLegend.getBoundingClientRect().top;
158
+ var inputRect = input.getBoundingClientRect();
610
159
 
611
- var _e = /*#__PURE__*/new WeakSet();
612
- var _t = /*#__PURE__*/new WeakSet();
613
- var e$1 = /*#__PURE__*/function (_HTMLElement) {
614
- _inherits(e, _HTMLElement);
615
- var _super = _createSuper(e);
616
- function e() {
617
- var _this;
618
- _classCallCheck(this, e);
619
- (_this = _super.call(this), _classPrivateMethodInitSpec(_assertThisInitialized(_this), _t), _classPrivateMethodInitSpec(_assertThisInitialized(_this), _e)), _this.addEventListener("click", function (_e5) {
620
- var t = _e5.target.closest("a");
621
- if (!t) return;
622
- var n = _classPrivateMethodGet(_assertThisInitialized(_this), _e, _e2).call(_assertThisInitialized(_this), t.href);
623
- if (!n) return;
624
- var r = document.getElementById(n);
625
- if (!r) return;
626
- var o = _classPrivateMethodGet(_assertThisInitialized(_this), _t, _t2).call(_assertThisInitialized(_this), r);
627
- o && (_e5.preventDefault(), o.scrollIntoView(), r.focus({
628
- preventScroll: !0
629
- }));
630
- });
631
- return _this;
632
- }
633
- return _createClass(e);
634
- }( /*#__PURE__*/_wrapNativeSuper(HTMLElement));
635
- function _e2(_e3) {
636
- return _e3.includes("#") ? _e3.split("#").pop() : void 0;
637
- }
638
- function _t2(_e4) {
639
- var _document$querySelect;
640
- var t = _e4.closest("fieldset");
641
- if (t) {
642
- var n = t.getElementsByTagName("legend");
643
- if (n.length) {
644
- var _t3 = n[0];
645
- if (_e4 instanceof HTMLInputElement && ("checkbox" === _e4.type || "radio" === _e4.type)) return _t3;
646
- var r = _t3.getBoundingClientRect().top,
647
- o = _e4.getBoundingClientRect();
648
- if (o.height && window.innerHeight) {
649
- if (o.top + o.height - r < window.innerHeight / 2) return _t3;
160
+ // If the browser doesn't support Element.getBoundingClientRect().height
161
+ // or window.innerHeight (like IE8), bail and just link to the label.
162
+ if (inputRect.height && window.innerHeight) {
163
+ var inputBottom = inputRect.top + inputRect.height;
164
+ if (inputBottom - legendTop < window.innerHeight / 2) {
165
+ return candidateLegend;
166
+ }
650
167
  }
651
168
  }
652
169
  }
653
- return (_document$querySelect = document.querySelector("label[for='".concat(_e4.getAttribute("id"), "']"))) !== null && _document$querySelect !== void 0 ? _document$querySelect : _e4.closest("label");
170
+ return (_document$querySelect = document.querySelector("label[for='".concat(input.getAttribute('id'), "']"))) !== null && _document$querySelect !== void 0 ? _document$querySelect : input.closest('label');
654
171
  }
655
- "customElements" in window && customElements.define("bds-error-summary", e$1);
656
-
657
- /**
658
- * @license
659
- * Copyright 2018 Google LLC
660
- * SPDX-License-Identifier: BSD-3-Clause
661
- */
662
- var e = new Set(["children", "localName", "ref", "style", "className"]),
663
- n = new WeakMap(),
664
- l = function l(e, _l, t, o, a) {
665
- var i = null == a ? void 0 : a[_l];
666
- void 0 === i || t === o ? (e[_l] = t, null == t && _l in HTMLElement.prototype && e.removeAttribute(_l)) : function (e, l, t) {
667
- var o = n.get(e);
668
- void 0 === o && n.set(e, o = new Map());
669
- var a = o.get(l);
670
- void 0 !== t ? void 0 === a ? (o.set(l, a = {
671
- handleEvent: t
672
- }), e.addEventListener(l, a)) : a.handleEvent = t : void 0 !== a && (o["delete"](l), e.removeEventListener(l, a));
673
- }(e, i, t);
674
- },
675
- t = function t(_ref) {
676
- var n = _ref.react,
677
- t = _ref.tagName,
678
- o = _ref.elementClass,
679
- a = _ref.events,
680
- i = _ref.displayName;
681
- var s = new Set(Object.keys(null != a ? a : {})),
682
- c = n.forwardRef(function (i, c) {
683
- var r = n.useRef(null),
684
- d = n.useRef(null),
685
- u = {},
686
- v = {};
687
- for (var _i = 0, _Object$entries = Object.entries(i); _i < _Object$entries.length; _i++) {
688
- var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
689
- _n = _Object$entries$_i[0],
690
- _l2 = _Object$entries$_i[1];
691
- e.has(_n) ? u["className" === _n ? "class" : _n] = _l2 : s.has(_n) || _n in o.prototype ? v[_n] = _l2 : u[_n] = _l2;
692
- }
693
- return n.useLayoutEffect(function () {
694
- if (null !== d.current) {
695
- for (var _e in v) l(d.current, _e, i[_e], r.current ? r.current[_e] : void 0, a);
696
- r.current = i;
697
- }
698
- }), n.useLayoutEffect(function () {
699
- var e;
700
- null === (e = d.current) || void 0 === e || e.removeAttribute("defer-hydration");
701
- }, []), u.suppressHydrationWarning = !0, n.createElement(t, _objectSpread2(_objectSpread2({}, u), {}, {
702
- ref: function ref(e) {
703
- d.current = e, "function" == typeof c ? c(e) : null !== c && (c.current = e);
704
- }
705
- }));
706
- });
707
- return c.displayName = null != i ? i : o.name, c;
708
- };
709
172
 
710
173
  var _excluded$3 = ["className", "errors", "mapNameToId"];
711
- var ReactErrorSummary = t({
712
- tagName: 'bds-error-summary',
713
- elementClass: e$1,
714
- react: React
715
- });
716
174
  var FormErrorKey = '_form';
717
175
  var FINAL_FORM_ERROR = 'FINAL_FORM/form-error';
718
176
  function BdsErrorSummary(_ref) {
@@ -731,7 +189,26 @@ function BdsErrorSummary(_ref) {
731
189
  groupRef.current.focus();
732
190
  }, [errors]);
733
191
  if (!errors || Object.keys(errors).length === 0) return null;
734
- return /*#__PURE__*/React.createElement(ReactErrorSummary, _extends({
192
+ var handleLinkClick = function handleLinkClick(e) {
193
+ var inputId = getFragmentFromUrl(e.currentTarget.href);
194
+ if (!inputId) {
195
+ return;
196
+ }
197
+ var input = document.getElementById(inputId);
198
+ if (!input) {
199
+ return;
200
+ }
201
+ var legendOrLabel = getAssociatedLegendOrLabel(input);
202
+ if (!legendOrLabel) {
203
+ return;
204
+ }
205
+ e.preventDefault();
206
+ legendOrLabel.scrollIntoView();
207
+ input.focus({
208
+ preventScroll: true
209
+ });
210
+ };
211
+ return /*#__PURE__*/React.createElement("bds-error-summary", _extends({
735
212
  className: ['stack', className].filter(function (x) {
736
213
  return x;
737
214
  }).join(' '),
@@ -771,7 +248,8 @@ function BdsErrorSummary(_ref) {
771
248
  return /*#__PURE__*/React.createElement("li", {
772
249
  key: inputId
773
250
  }, /*#__PURE__*/React.createElement("a", {
774
- href: "#".concat(inputId)
251
+ href: "#".concat(inputId),
252
+ onClick: handleLinkClick
775
253
  }, fieldMessage, messages.length > 1 ? " (".concat(index + 1, " of ").concat(messages.length, ")") : undefined));
776
254
  }));
777
255
  })));