@descope/web-components-ui 1.0.422 → 1.0.424

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.
@@ -1442,851 +1442,6 @@ const createProxy = ({
1442
1442
  return ProxyClass;
1443
1443
  };
1444
1444
 
1445
- (function (exports) {
1446
-
1447
- const refMap = new WeakMap();
1448
- const validityMap = new WeakMap();
1449
- const hiddenInputMap = new WeakMap();
1450
- const internalsMap = new WeakMap();
1451
- const validationMessageMap = new WeakMap();
1452
- const formsMap = new WeakMap();
1453
- const shadowHostsMap = new WeakMap();
1454
- const formElementsMap = new WeakMap();
1455
- const refValueMap = new WeakMap();
1456
- const upgradeMap = new WeakMap();
1457
- const shadowRootMap = new WeakMap();
1458
- const validationAnchorMap = new WeakMap();
1459
- const documentFragmentMap = new WeakMap();
1460
- const connectedCallbackMap = new WeakMap();
1461
- const validityUpgradeMap = new WeakMap();
1462
-
1463
- const aom = {
1464
- ariaAtomic: 'aria-atomic',
1465
- ariaAutoComplete: 'aria-autocomplete',
1466
- ariaBusy: 'aria-busy',
1467
- ariaChecked: 'aria-checked',
1468
- ariaColCount: 'aria-colcount',
1469
- ariaColIndex: 'aria-colindex',
1470
- ariaColIndexText: 'aria-colindextext',
1471
- ariaColSpan: 'aria-colspan',
1472
- ariaCurrent: 'aria-current',
1473
- ariaDescription: 'aria-description',
1474
- ariaDisabled: 'aria-disabled',
1475
- ariaExpanded: 'aria-expanded',
1476
- ariaHasPopup: 'aria-haspopup',
1477
- ariaHidden: 'aria-hidden',
1478
- ariaInvalid: 'aria-invalid',
1479
- ariaKeyShortcuts: 'aria-keyshortcuts',
1480
- ariaLabel: 'aria-label',
1481
- ariaLevel: 'aria-level',
1482
- ariaLive: 'aria-live',
1483
- ariaModal: 'aria-modal',
1484
- ariaMultiLine: 'aria-multiline',
1485
- ariaMultiSelectable: 'aria-multiselectable',
1486
- ariaOrientation: 'aria-orientation',
1487
- ariaPlaceholder: 'aria-placeholder',
1488
- ariaPosInSet: 'aria-posinset',
1489
- ariaPressed: 'aria-pressed',
1490
- ariaReadOnly: 'aria-readonly',
1491
- ariaRelevant: 'aria-relevant',
1492
- ariaRequired: 'aria-required',
1493
- ariaRoleDescription: 'aria-roledescription',
1494
- ariaRowCount: 'aria-rowcount',
1495
- ariaRowIndex: 'aria-rowindex',
1496
- ariaRowIndexText: 'aria-rowindextext',
1497
- ariaRowSpan: 'aria-rowspan',
1498
- ariaSelected: 'aria-selected',
1499
- ariaSetSize: 'aria-setsize',
1500
- ariaSort: 'aria-sort',
1501
- ariaValueMax: 'aria-valuemax',
1502
- ariaValueMin: 'aria-valuemin',
1503
- ariaValueNow: 'aria-valuenow',
1504
- ariaValueText: 'aria-valuetext',
1505
- role: 'role'
1506
- };
1507
- const initAom = (ref, internals) => {
1508
- for (let key in aom) {
1509
- internals[key] = null;
1510
- let closureValue = null;
1511
- const attributeName = aom[key];
1512
- Object.defineProperty(internals, key, {
1513
- get() {
1514
- return closureValue;
1515
- },
1516
- set(value) {
1517
- closureValue = value;
1518
- if (ref.isConnected) {
1519
- ref.setAttribute(attributeName, value);
1520
- }
1521
- else {
1522
- upgradeMap.set(ref, internals);
1523
- }
1524
- }
1525
- });
1526
- }
1527
- };
1528
-
1529
- function initNode(node) {
1530
- const internals = internalsMap.get(node);
1531
- const { form } = internals;
1532
- initForm(node, form, internals);
1533
- initLabels(node, internals.labels);
1534
- }
1535
- const walkFieldset = (node, firstRender = false) => {
1536
- const walker = document.createTreeWalker(node, NodeFilter.SHOW_ELEMENT, {
1537
- acceptNode(node) {
1538
- return internalsMap.has(node) ?
1539
- NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
1540
- }
1541
- });
1542
- let current = walker.nextNode();
1543
- const isCallNecessary = (!firstRender || node.disabled);
1544
- while (current) {
1545
- if (current.formDisabledCallback && isCallNecessary) {
1546
- setDisabled(current, node.disabled);
1547
- }
1548
- current = walker.nextNode();
1549
- }
1550
- };
1551
- const disabledOrNameObserverConfig = { attributes: true, attributeFilter: ['disabled', 'name'] };
1552
- const disabledOrNameObserver = mutationObserverExists() ? new MutationObserver((mutationsList) => {
1553
- for (const mutation of mutationsList) {
1554
- const target = mutation.target;
1555
- if (mutation.attributeName === 'disabled') {
1556
- if (target.constructor['formAssociated']) {
1557
- setDisabled(target, target.hasAttribute('disabled'));
1558
- }
1559
- else if (target.localName === 'fieldset') {
1560
- walkFieldset(target);
1561
- }
1562
- }
1563
- if (mutation.attributeName === 'name') {
1564
- if (target.constructor['formAssociated']) {
1565
- const internals = internalsMap.get(target);
1566
- const value = refValueMap.get(target);
1567
- internals.setFormValue(value);
1568
- }
1569
- }
1570
- }
1571
- }) : {};
1572
- function observerCallback(mutationList) {
1573
- mutationList.forEach(mutationRecord => {
1574
- const { addedNodes, removedNodes } = mutationRecord;
1575
- const added = Array.from(addedNodes);
1576
- const removed = Array.from(removedNodes);
1577
- added.forEach(node => {
1578
- var _a;
1579
- if (internalsMap.has(node) && node.constructor['formAssociated']) {
1580
- initNode(node);
1581
- }
1582
- if (upgradeMap.has(node)) {
1583
- const internals = upgradeMap.get(node);
1584
- const aomKeys = Object.keys(aom);
1585
- aomKeys
1586
- .filter(key => internals[key] !== null)
1587
- .forEach(key => {
1588
- node.setAttribute(aom[key], internals[key]);
1589
- });
1590
- upgradeMap.delete(node);
1591
- }
1592
- if (validityUpgradeMap.has(node)) {
1593
- const internals = validityUpgradeMap.get(node);
1594
- node.setAttribute('internals-valid', internals.validity.valid.toString());
1595
- node.setAttribute('internals-invalid', (!internals.validity.valid).toString());
1596
- node.setAttribute('aria-invalid', (!internals.validity.valid).toString());
1597
- validityUpgradeMap.delete(node);
1598
- }
1599
- if (node.localName === 'form') {
1600
- const formElements = formElementsMap.get(node);
1601
- const walker = document.createTreeWalker(node, NodeFilter.SHOW_ELEMENT, {
1602
- acceptNode(node) {
1603
- return (internalsMap.has(node) && node.constructor['formAssociated'] && !(formElements && formElements.has(node))) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
1604
- }
1605
- });
1606
- let current = walker.nextNode();
1607
- while (current) {
1608
- initNode(current);
1609
- current = walker.nextNode();
1610
- }
1611
- }
1612
- if (node.localName === 'fieldset') {
1613
- (_a = disabledOrNameObserver.observe) === null || _a === void 0 ? void 0 : _a.call(disabledOrNameObserver, node, disabledOrNameObserverConfig);
1614
- walkFieldset(node, true);
1615
- }
1616
- });
1617
- removed.forEach(node => {
1618
- const internals = internalsMap.get(node);
1619
- if (internals && hiddenInputMap.get(internals)) {
1620
- removeHiddenInputs(internals);
1621
- }
1622
- if (shadowHostsMap.has(node)) {
1623
- const observer = shadowHostsMap.get(node);
1624
- observer.disconnect();
1625
- }
1626
- });
1627
- });
1628
- }
1629
- function fragmentObserverCallback(mutationList) {
1630
- mutationList.forEach(mutation => {
1631
- const { removedNodes } = mutation;
1632
- removedNodes.forEach(node => {
1633
- const observer = documentFragmentMap.get(mutation.target);
1634
- if (internalsMap.has(node)) {
1635
- upgradeInternals(node);
1636
- }
1637
- observer.disconnect();
1638
- });
1639
- });
1640
- }
1641
- const deferUpgrade = (fragment) => {
1642
- var _a, _b;
1643
- const observer = new MutationObserver(fragmentObserverCallback);
1644
- if (((_a = window === null || window === void 0 ? void 0 : window.ShadyDOM) === null || _a === void 0 ? void 0 : _a.inUse) &&
1645
- fragment.mode &&
1646
- fragment.host) {
1647
- fragment = fragment.host;
1648
- }
1649
- (_b = observer.observe) === null || _b === void 0 ? void 0 : _b.call(observer, fragment, { childList: true });
1650
- documentFragmentMap.set(fragment, observer);
1651
- };
1652
- mutationObserverExists() ? new MutationObserver(observerCallback) : {};
1653
- const observerConfig = {
1654
- childList: true,
1655
- subtree: true
1656
- };
1657
-
1658
- const setDisabled = (ref, disabled) => {
1659
- ref.toggleAttribute('internals-disabled', disabled);
1660
- if (disabled) {
1661
- ref.setAttribute('aria-disabled', 'true');
1662
- }
1663
- else {
1664
- ref.removeAttribute('aria-disabled');
1665
- }
1666
- if (ref.formDisabledCallback) {
1667
- ref.formDisabledCallback.apply(ref, [disabled]);
1668
- }
1669
- };
1670
- const removeHiddenInputs = (internals) => {
1671
- const hiddenInputs = hiddenInputMap.get(internals);
1672
- hiddenInputs.forEach(hiddenInput => {
1673
- hiddenInput.remove();
1674
- });
1675
- hiddenInputMap.set(internals, []);
1676
- };
1677
- const createHiddenInput = (ref, internals) => {
1678
- const input = document.createElement('input');
1679
- input.type = 'hidden';
1680
- input.name = ref.getAttribute('name');
1681
- ref.after(input);
1682
- hiddenInputMap.get(internals).push(input);
1683
- return input;
1684
- };
1685
- const initRef = (ref, internals) => {
1686
- var _a;
1687
- hiddenInputMap.set(internals, []);
1688
- (_a = disabledOrNameObserver.observe) === null || _a === void 0 ? void 0 : _a.call(disabledOrNameObserver, ref, disabledOrNameObserverConfig);
1689
- };
1690
- const initLabels = (ref, labels) => {
1691
- if (labels.length) {
1692
- Array.from(labels).forEach(label => label.addEventListener('click', ref.click.bind(ref)));
1693
- let firstLabelId = labels[0].id;
1694
- if (!labels[0].id) {
1695
- firstLabelId = `${labels[0].htmlFor}_Label`;
1696
- labels[0].id = firstLabelId;
1697
- }
1698
- ref.setAttribute('aria-labelledby', firstLabelId);
1699
- }
1700
- };
1701
- const setFormValidity = (form) => {
1702
- const nativeControlValidity = Array.from(form.elements)
1703
- .filter((element) => !element.tagName.includes('-') && element.validity)
1704
- .map((element) => element.validity.valid);
1705
- const polyfilledElements = formElementsMap.get(form) || [];
1706
- const polyfilledValidity = Array.from(polyfilledElements)
1707
- .filter(control => control.isConnected)
1708
- .map((control) => internalsMap.get(control).validity.valid);
1709
- const hasInvalid = [...nativeControlValidity, ...polyfilledValidity].includes(false);
1710
- form.toggleAttribute('internals-invalid', hasInvalid);
1711
- form.toggleAttribute('internals-valid', !hasInvalid);
1712
- };
1713
- const formInputCallback = (event) => {
1714
- setFormValidity(findParentForm(event.target));
1715
- };
1716
- const formChangeCallback = (event) => {
1717
- setFormValidity(findParentForm(event.target));
1718
- };
1719
- const wireSubmitLogic = (form) => {
1720
- const submitButtonSelector = ['button[type=submit]', 'input[type=submit]', 'button:not([type])']
1721
- .map(sel => `${sel}:not([disabled])`)
1722
- .map(sel => `${sel}:not([form])${form.id ? `,${sel}[form='${form.id}']` : ''}`)
1723
- .join(',');
1724
- form.addEventListener('click', event => {
1725
- const target = event.target;
1726
- if (target.closest(submitButtonSelector)) {
1727
- const elements = formElementsMap.get(form);
1728
- if (form.noValidate) {
1729
- return;
1730
- }
1731
- if (elements.size) {
1732
- const nodes = Array.from(elements);
1733
- const validityList = nodes
1734
- .reverse()
1735
- .map(node => {
1736
- const internals = internalsMap.get(node);
1737
- return internals.reportValidity();
1738
- });
1739
- if (validityList.includes(false)) {
1740
- event.preventDefault();
1741
- }
1742
- }
1743
- }
1744
- });
1745
- };
1746
- const formResetCallback = (event) => {
1747
- const elements = formElementsMap.get(event.target);
1748
- if (elements && elements.size) {
1749
- elements.forEach(element => {
1750
- if (element.constructor.formAssociated && element.formResetCallback) {
1751
- element.formResetCallback.apply(element);
1752
- }
1753
- });
1754
- }
1755
- };
1756
- const initForm = (ref, form, internals) => {
1757
- if (form) {
1758
- const formElements = formElementsMap.get(form);
1759
- if (formElements) {
1760
- formElements.add(ref);
1761
- }
1762
- else {
1763
- const initSet = new Set();
1764
- initSet.add(ref);
1765
- formElementsMap.set(form, initSet);
1766
- wireSubmitLogic(form);
1767
- form.addEventListener('reset', formResetCallback);
1768
- form.addEventListener('input', formInputCallback);
1769
- form.addEventListener('change', formChangeCallback);
1770
- }
1771
- formsMap.set(form, { ref, internals });
1772
- if (ref.constructor['formAssociated'] && ref.formAssociatedCallback) {
1773
- setTimeout(() => {
1774
- ref.formAssociatedCallback.apply(ref, [form]);
1775
- }, 0);
1776
- }
1777
- setFormValidity(form);
1778
- }
1779
- };
1780
- const findParentForm = (elem) => {
1781
- let parent = elem.parentNode;
1782
- if (parent && parent.tagName !== 'FORM') {
1783
- parent = findParentForm(parent);
1784
- }
1785
- return parent;
1786
- };
1787
- const throwIfNotFormAssociated = (ref, message, ErrorType = DOMException) => {
1788
- if (!ref.constructor['formAssociated']) {
1789
- throw new ErrorType(message);
1790
- }
1791
- };
1792
- const overrideFormMethod = (form, returnValue, method) => {
1793
- const elements = formElementsMap.get(form);
1794
- if (elements && elements.size) {
1795
- elements.forEach(element => {
1796
- const internals = internalsMap.get(element);
1797
- const valid = internals[method]();
1798
- if (!valid) {
1799
- returnValue = false;
1800
- }
1801
- });
1802
- }
1803
- return returnValue;
1804
- };
1805
- const upgradeInternals = (ref) => {
1806
- if (ref.constructor['formAssociated']) {
1807
- const internals = internalsMap.get(ref);
1808
- const { labels, form } = internals;
1809
- initLabels(ref, labels);
1810
- initForm(ref, form, internals);
1811
- }
1812
- };
1813
- function mutationObserverExists() {
1814
- return typeof MutationObserver !== 'undefined';
1815
- }
1816
-
1817
- class ValidityState {
1818
- constructor() {
1819
- this.badInput = false;
1820
- this.customError = false;
1821
- this.patternMismatch = false;
1822
- this.rangeOverflow = false;
1823
- this.rangeUnderflow = false;
1824
- this.stepMismatch = false;
1825
- this.tooLong = false;
1826
- this.tooShort = false;
1827
- this.typeMismatch = false;
1828
- this.valid = true;
1829
- this.valueMissing = false;
1830
- Object.seal(this);
1831
- }
1832
- }
1833
- const setValid = (validityObject) => {
1834
- validityObject.badInput = false;
1835
- validityObject.customError = false;
1836
- validityObject.patternMismatch = false;
1837
- validityObject.rangeOverflow = false;
1838
- validityObject.rangeUnderflow = false;
1839
- validityObject.stepMismatch = false;
1840
- validityObject.tooLong = false;
1841
- validityObject.tooShort = false;
1842
- validityObject.typeMismatch = false;
1843
- validityObject.valid = true;
1844
- validityObject.valueMissing = false;
1845
- return validityObject;
1846
- };
1847
- const reconcileValidity = (validityObject, newState, form) => {
1848
- validityObject.valid = isValid(newState);
1849
- Object.keys(newState).forEach(key => validityObject[key] = newState[key]);
1850
- if (form) {
1851
- setFormValidity(form);
1852
- }
1853
- return validityObject;
1854
- };
1855
- const isValid = (validityState) => {
1856
- let valid = true;
1857
- for (let key in validityState) {
1858
- if (key !== 'valid' && validityState[key] !== false) {
1859
- valid = false;
1860
- }
1861
- }
1862
- return valid;
1863
- };
1864
-
1865
- const customStateMap = new WeakMap();
1866
- function addState(ref, stateName) {
1867
- ref.toggleAttribute(stateName, true);
1868
- if (ref.part) {
1869
- ref.part.add(stateName);
1870
- }
1871
- }
1872
- class CustomStateSet extends Set {
1873
- static get isPolyfilled() {
1874
- return true;
1875
- }
1876
- constructor(ref) {
1877
- super();
1878
- if (!ref || !ref.tagName || ref.tagName.indexOf('-') === -1) {
1879
- throw new TypeError('Illegal constructor');
1880
- }
1881
- customStateMap.set(this, ref);
1882
- }
1883
- add(state) {
1884
- if (!/^--/.test(state) || typeof state !== 'string') {
1885
- throw new DOMException(`Failed to execute 'add' on 'CustomStateSet': The specified value ${state} must start with '--'.`);
1886
- }
1887
- const result = super.add(state);
1888
- const ref = customStateMap.get(this);
1889
- const stateName = `state${state}`;
1890
- if (ref.isConnected) {
1891
- addState(ref, stateName);
1892
- }
1893
- else {
1894
- setTimeout(() => {
1895
- addState(ref, stateName);
1896
- });
1897
- }
1898
- return result;
1899
- }
1900
- clear() {
1901
- for (let [entry] of this.entries()) {
1902
- this.delete(entry);
1903
- }
1904
- super.clear();
1905
- }
1906
- delete(state) {
1907
- const result = super.delete(state);
1908
- const ref = customStateMap.get(this);
1909
- if (ref.isConnected) {
1910
- ref.toggleAttribute(`state${state}`, false);
1911
- if (ref.part) {
1912
- ref.part.remove(`state${state}`);
1913
- }
1914
- }
1915
- else {
1916
- setTimeout(() => {
1917
- ref.toggleAttribute(`state${state}`, false);
1918
- if (ref.part) {
1919
- ref.part.remove(`state${state}`);
1920
- }
1921
- });
1922
- }
1923
- return result;
1924
- }
1925
- }
1926
-
1927
- function __classPrivateFieldGet(receiver, state, kind, f) {
1928
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
1929
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
1930
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
1931
- }
1932
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
1933
- if (kind === "m") throw new TypeError("Private method is not writable");
1934
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
1935
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
1936
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
1937
- }
1938
-
1939
- var _HTMLFormControlsCollection_elements;
1940
- class HTMLFormControlsCollection {
1941
- constructor(elements) {
1942
- _HTMLFormControlsCollection_elements.set(this, void 0);
1943
- __classPrivateFieldSet(this, _HTMLFormControlsCollection_elements, elements, "f");
1944
- for (let i = 0; i < elements.length; i++) {
1945
- let element = elements[i];
1946
- this[i] = element;
1947
- if (element.hasAttribute('name')) {
1948
- this[element.getAttribute('name')] = element;
1949
- }
1950
- }
1951
- Object.freeze(this);
1952
- }
1953
- get length() {
1954
- return __classPrivateFieldGet(this, _HTMLFormControlsCollection_elements, "f").length;
1955
- }
1956
- [(_HTMLFormControlsCollection_elements = new WeakMap(), Symbol.iterator)]() {
1957
- return __classPrivateFieldGet(this, _HTMLFormControlsCollection_elements, "f")[Symbol.iterator]();
1958
- }
1959
- item(i) {
1960
- return this[i] == null ? null : this[i];
1961
- }
1962
- namedItem(name) {
1963
- return this[name] == null ? null : this[name];
1964
- }
1965
- }
1966
-
1967
- function patchFormPrototype() {
1968
- const checkValidity = HTMLFormElement.prototype.checkValidity;
1969
- HTMLFormElement.prototype.checkValidity = checkValidityOverride;
1970
- const reportValidity = HTMLFormElement.prototype.reportValidity;
1971
- HTMLFormElement.prototype.reportValidity = reportValidityOverride;
1972
- function checkValidityOverride(...args) {
1973
- let returnValue = checkValidity.apply(this, args);
1974
- return overrideFormMethod(this, returnValue, 'checkValidity');
1975
- }
1976
- function reportValidityOverride(...args) {
1977
- let returnValue = reportValidity.apply(this, args);
1978
- return overrideFormMethod(this, returnValue, 'reportValidity');
1979
- }
1980
- const { get } = Object.getOwnPropertyDescriptor(HTMLFormElement.prototype, 'elements');
1981
- Object.defineProperty(HTMLFormElement.prototype, 'elements', {
1982
- get(...args) {
1983
- const elements = get.call(this, ...args);
1984
- const polyfilledElements = Array.from(formElementsMap.get(this) || []);
1985
- if (polyfilledElements.length === 0) {
1986
- return elements;
1987
- }
1988
- const orderedElements = Array.from(elements).concat(polyfilledElements).sort((a, b) => {
1989
- if (a.compareDocumentPosition) {
1990
- return a.compareDocumentPosition(b) & 2 ? 1 : -1;
1991
- }
1992
- return 0;
1993
- });
1994
- return new HTMLFormControlsCollection(orderedElements);
1995
- },
1996
- });
1997
- }
1998
-
1999
- class ElementInternals {
2000
- static get isPolyfilled() {
2001
- return true;
2002
- }
2003
- constructor(ref) {
2004
- if (!ref || !ref.tagName || ref.tagName.indexOf('-') === -1) {
2005
- throw new TypeError('Illegal constructor');
2006
- }
2007
- const rootNode = ref.getRootNode();
2008
- const validity = new ValidityState();
2009
- this.states = new CustomStateSet(ref);
2010
- refMap.set(this, ref);
2011
- validityMap.set(this, validity);
2012
- internalsMap.set(ref, this);
2013
- initAom(ref, this);
2014
- initRef(ref, this);
2015
- Object.seal(this);
2016
- if (rootNode instanceof DocumentFragment) {
2017
- deferUpgrade(rootNode);
2018
- }
2019
- }
2020
- checkValidity() {
2021
- const ref = refMap.get(this);
2022
- throwIfNotFormAssociated(ref, `Failed to execute 'checkValidity' on 'ElementInternals': The target element is not a form-associated custom element.`);
2023
- if (!this.willValidate) {
2024
- return true;
2025
- }
2026
- const validity = validityMap.get(this);
2027
- if (!validity.valid) {
2028
- const validityEvent = new Event('invalid', {
2029
- bubbles: false,
2030
- cancelable: true,
2031
- composed: false
2032
- });
2033
- ref.dispatchEvent(validityEvent);
2034
- }
2035
- return validity.valid;
2036
- }
2037
- get form() {
2038
- const ref = refMap.get(this);
2039
- throwIfNotFormAssociated(ref, `Failed to read the 'form' property from 'ElementInternals': The target element is not a form-associated custom element.`);
2040
- let form;
2041
- if (ref.constructor['formAssociated'] === true) {
2042
- form = findParentForm(ref);
2043
- }
2044
- return form;
2045
- }
2046
- get labels() {
2047
- const ref = refMap.get(this);
2048
- throwIfNotFormAssociated(ref, `Failed to read the 'labels' property from 'ElementInternals': The target element is not a form-associated custom element.`);
2049
- const id = ref.getAttribute('id');
2050
- const hostRoot = ref.getRootNode();
2051
- if (hostRoot && id) {
2052
- return hostRoot.querySelectorAll(`[for="${id}"]`);
2053
- }
2054
- return [];
2055
- }
2056
- reportValidity() {
2057
- const ref = refMap.get(this);
2058
- throwIfNotFormAssociated(ref, `Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element.`);
2059
- if (!this.willValidate) {
2060
- return true;
2061
- }
2062
- const valid = this.checkValidity();
2063
- const anchor = validationAnchorMap.get(this);
2064
- if (anchor && !ref.constructor['formAssociated']) {
2065
- throw new DOMException(`Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element.`);
2066
- }
2067
- if (!valid && anchor) {
2068
- ref.focus();
2069
- anchor.focus();
2070
- }
2071
- return valid;
2072
- }
2073
- setFormValue(value) {
2074
- const ref = refMap.get(this);
2075
- throwIfNotFormAssociated(ref, `Failed to execute 'setFormValue' on 'ElementInternals': The target element is not a form-associated custom element.`);
2076
- removeHiddenInputs(this);
2077
- if (value != null && !(value instanceof FormData)) {
2078
- if (ref.getAttribute('name')) {
2079
- const hiddenInput = createHiddenInput(ref, this);
2080
- hiddenInput.value = value;
2081
- }
2082
- }
2083
- else if (value != null && value instanceof FormData) {
2084
- Array.from(value).reverse().forEach(([formDataKey, formDataValue]) => {
2085
- if (typeof formDataValue === 'string') {
2086
- const hiddenInput = createHiddenInput(ref, this);
2087
- hiddenInput.name = formDataKey;
2088
- hiddenInput.value = formDataValue;
2089
- }
2090
- });
2091
- }
2092
- refValueMap.set(ref, value);
2093
- }
2094
- setValidity(validityChanges, validationMessage, anchor) {
2095
- const ref = refMap.get(this);
2096
- throwIfNotFormAssociated(ref, `Failed to execute 'setValidity' on 'ElementInternals': The target element is not a form-associated custom element.`);
2097
- if (!validityChanges) {
2098
- throw new TypeError('Failed to execute \'setValidity\' on \'ElementInternals\': 1 argument required, but only 0 present.');
2099
- }
2100
- validationAnchorMap.set(this, anchor);
2101
- const validity = validityMap.get(this);
2102
- const validityChangesObj = {};
2103
- for (const key in validityChanges) {
2104
- validityChangesObj[key] = validityChanges[key];
2105
- }
2106
- if (Object.keys(validityChangesObj).length === 0) {
2107
- setValid(validity);
2108
- }
2109
- const check = Object.assign(Object.assign({}, validity), validityChangesObj);
2110
- delete check.valid;
2111
- const { valid } = reconcileValidity(validity, check, this.form);
2112
- if (!valid && !validationMessage) {
2113
- throw new DOMException(`Failed to execute 'setValidity' on 'ElementInternals': The second argument should not be empty if one or more flags in the first argument are true.`);
2114
- }
2115
- validationMessageMap.set(this, valid ? '' : validationMessage);
2116
- if (ref.isConnected) {
2117
- ref.toggleAttribute('internals-invalid', !valid);
2118
- ref.toggleAttribute('internals-valid', valid);
2119
- ref.setAttribute('aria-invalid', `${!valid}`);
2120
- }
2121
- else {
2122
- validityUpgradeMap.set(ref, this);
2123
- }
2124
- }
2125
- get shadowRoot() {
2126
- const ref = refMap.get(this);
2127
- const shadowRoot = shadowRootMap.get(ref);
2128
- if (shadowRoot) {
2129
- return shadowRoot;
2130
- }
2131
- return null;
2132
- }
2133
- get validationMessage() {
2134
- const ref = refMap.get(this);
2135
- throwIfNotFormAssociated(ref, `Failed to read the 'validationMessage' property from 'ElementInternals': The target element is not a form-associated custom element.`);
2136
- return validationMessageMap.get(this);
2137
- }
2138
- get validity() {
2139
- const ref = refMap.get(this);
2140
- throwIfNotFormAssociated(ref, `Failed to read the 'validity' property from 'ElementInternals': The target element is not a form-associated custom element.`);
2141
- const validity = validityMap.get(this);
2142
- return validity;
2143
- }
2144
- get willValidate() {
2145
- const ref = refMap.get(this);
2146
- throwIfNotFormAssociated(ref, `Failed to read the 'willValidate' property from 'ElementInternals': The target element is not a form-associated custom element.`);
2147
- if ((ref.disabled || ref.hasAttribute('disabled')) ||
2148
- ref.hasAttribute('readonly')) {
2149
- return false;
2150
- }
2151
- return true;
2152
- }
2153
- }
2154
- function isElementInternalsSupported() {
2155
- if (typeof window === 'undefined' || !window.ElementInternals || !HTMLElement.prototype.attachInternals) {
2156
- return false;
2157
- }
2158
- class ElementInternalsFeatureDetection extends HTMLElement {
2159
- constructor() {
2160
- super();
2161
- this.internals = this.attachInternals();
2162
- }
2163
- }
2164
- const randomName = `element-internals-feature-detection-${Math.random().toString(36).replace(/[^a-z]+/g, '')}`;
2165
- customElements.define(randomName, ElementInternalsFeatureDetection);
2166
- const featureDetectionElement = new ElementInternalsFeatureDetection();
2167
- return [
2168
- 'shadowRoot',
2169
- 'form',
2170
- 'willValidate',
2171
- 'validity',
2172
- 'validationMessage',
2173
- 'labels',
2174
- 'setFormValue',
2175
- 'setValidity',
2176
- 'checkValidity',
2177
- 'reportValidity'
2178
- ].every(prop => prop in featureDetectionElement.internals);
2179
- }
2180
- let hasElementInternalsPolyfillBeenApplied = false;
2181
- let hasCustomStateSetPolyfillBeenApplied = false;
2182
- function forceCustomStateSetPolyfill(attachInternals) {
2183
- if (hasCustomStateSetPolyfillBeenApplied) {
2184
- return;
2185
- }
2186
- hasCustomStateSetPolyfillBeenApplied = true;
2187
- window.CustomStateSet = CustomStateSet;
2188
- if (attachInternals) {
2189
- HTMLElement.prototype.attachInternals = function (...args) {
2190
- const internals = attachInternals.call(this, args);
2191
- internals.states = new CustomStateSet(this);
2192
- return internals;
2193
- };
2194
- }
2195
- }
2196
- function forceElementInternalsPolyfill(forceCustomStateSet = true) {
2197
- if (hasElementInternalsPolyfillBeenApplied) {
2198
- return;
2199
- }
2200
- hasElementInternalsPolyfillBeenApplied = true;
2201
- if (typeof window !== 'undefined') {
2202
- window.ElementInternals = ElementInternals;
2203
- }
2204
- if (typeof CustomElementRegistry !== 'undefined') {
2205
- const define = CustomElementRegistry.prototype.define;
2206
- CustomElementRegistry.prototype.define = function (name, constructor, options) {
2207
- if (constructor.formAssociated) {
2208
- const connectedCallback = constructor.prototype.connectedCallback;
2209
- constructor.prototype.connectedCallback = function () {
2210
- if (!connectedCallbackMap.has(this)) {
2211
- connectedCallbackMap.set(this, true);
2212
- if (this.hasAttribute('disabled')) {
2213
- setDisabled(this, true);
2214
- }
2215
- }
2216
- if (connectedCallback != null) {
2217
- connectedCallback.apply(this);
2218
- }
2219
- upgradeInternals(this);
2220
- };
2221
- }
2222
- define.call(this, name, constructor, options);
2223
- };
2224
- }
2225
- if (typeof HTMLElement !== 'undefined') {
2226
- HTMLElement.prototype.attachInternals = function () {
2227
- if (!this.tagName) {
2228
- return {};
2229
- }
2230
- else if (this.tagName.indexOf('-') === -1) {
2231
- throw new Error(`Failed to execute 'attachInternals' on 'HTMLElement': Unable to attach ElementInternals to non-custom elements.`);
2232
- }
2233
- if (internalsMap.has(this)) {
2234
- throw new DOMException(`DOMException: Failed to execute 'attachInternals' on 'HTMLElement': ElementInternals for the specified element was already attached.`);
2235
- }
2236
- return new ElementInternals(this);
2237
- };
2238
- }
2239
- if (typeof Element !== 'undefined') {
2240
- function attachShadowObserver(...args) {
2241
- const shadowRoot = attachShadow.apply(this, args);
2242
- shadowRootMap.set(this, shadowRoot);
2243
- if (mutationObserverExists()) {
2244
- const observer = new MutationObserver(observerCallback);
2245
- if (window.ShadyDOM) {
2246
- observer.observe(this, observerConfig);
2247
- }
2248
- else {
2249
- observer.observe(shadowRoot, observerConfig);
2250
- }
2251
- shadowHostsMap.set(this, observer);
2252
- }
2253
- return shadowRoot;
2254
- }
2255
- const attachShadow = Element.prototype.attachShadow;
2256
- Element.prototype.attachShadow = attachShadowObserver;
2257
- }
2258
- if (mutationObserverExists() && typeof document !== 'undefined') {
2259
- const documentObserver = new MutationObserver(observerCallback);
2260
- documentObserver.observe(document.documentElement, observerConfig);
2261
- }
2262
- if (typeof HTMLFormElement !== 'undefined') {
2263
- patchFormPrototype();
2264
- }
2265
- if (forceCustomStateSet ||
2266
- (typeof window !== "undefined" && !window.CustomStateSet)) {
2267
- forceCustomStateSetPolyfill();
2268
- }
2269
- }
2270
-
2271
- const isCePolyfill = !!customElements.polyfillWrapFlushCallback;
2272
- if (!isCePolyfill) {
2273
- if (!isElementInternalsSupported()) {
2274
- forceElementInternalsPolyfill(false);
2275
- }
2276
- else if (typeof window !== "undefined" && !window.CustomStateSet) {
2277
- forceCustomStateSetPolyfill(HTMLElement.prototype.attachInternals);
2278
- }
2279
- }
2280
-
2281
- exports.forceCustomStateSetPolyfill = forceCustomStateSetPolyfill;
2282
- exports.forceElementInternalsPolyfill = forceElementInternalsPolyfill;
2283
-
2284
- Object.defineProperty(exports, '__esModule', { value: true });
2285
-
2286
- return exports;
2287
-
2288
- })({});
2289
-
2290
1445
  const observedAttributes$4 = ['required', 'pattern'];
2291
1446
 
2292
1447
  const errorAttributes = {
@@ -7142,6 +6297,7 @@ const customMixin$9 = (superclass) =>
7142
6297
  name="code"
7143
6298
  tabindex="-1"
7144
6299
  slot="input"
6300
+ role="textbox"
7145
6301
  ><slot></slot></${componentName$K}>
7146
6302
  `;
7147
6303
 
@@ -10565,8 +9721,8 @@ class RawUploadFile extends BaseInputClass$2 {
10565
9721
  </div>
10566
9722
  <div class="description"></div>
10567
9723
  <div class="button-wrapper">
10568
- <input type="file" tabindex="-1" />
10569
- <descope-button></descope-button>
9724
+ <input type="file" tabindex="-1" aria-labelledby="button"/>
9725
+ <descope-button id="button"></descope-button>
10570
9726
  </div>
10571
9727
  </div>
10572
9728
  `;