@descope/web-components-ui 1.0.185 → 1.0.187

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.esm.js CHANGED
@@ -709,6 +709,813 @@ const createProxy = ({
709
709
  return ProxyClass;
710
710
  };
711
711
 
712
+ (function () {
713
+
714
+ const refMap = new WeakMap();
715
+ const validityMap = new WeakMap();
716
+ const hiddenInputMap = new WeakMap();
717
+ const internalsMap = new WeakMap();
718
+ const validationMessageMap = new WeakMap();
719
+ const formsMap = new WeakMap();
720
+ const shadowHostsMap = new WeakMap();
721
+ const formElementsMap = new WeakMap();
722
+ const refValueMap = new WeakMap();
723
+ const upgradeMap = new WeakMap();
724
+ const shadowRootMap = new WeakMap();
725
+ const validationAnchorMap = new WeakMap();
726
+ const documentFragmentMap = new WeakMap();
727
+ const connectedCallbackMap = new WeakMap();
728
+ const validityUpgradeMap = new WeakMap();
729
+
730
+ const aom = {
731
+ ariaAtomic: 'aria-atomic',
732
+ ariaAutoComplete: 'aria-autocomplete',
733
+ ariaBusy: 'aria-busy',
734
+ ariaChecked: 'aria-checked',
735
+ ariaColCount: 'aria-colcount',
736
+ ariaColIndex: 'aria-colindex',
737
+ ariaColIndexText: 'aria-colindextext',
738
+ ariaColSpan: 'aria-colspan',
739
+ ariaCurrent: 'aria-current',
740
+ ariaDisabled: 'aria-disabled',
741
+ ariaExpanded: 'aria-expanded',
742
+ ariaHasPopup: 'aria-haspopup',
743
+ ariaHidden: 'aria-hidden',
744
+ ariaInvalid: 'aria-invalid',
745
+ ariaKeyShortcuts: 'aria-keyshortcuts',
746
+ ariaLabel: 'aria-label',
747
+ ariaLevel: 'aria-level',
748
+ ariaLive: 'aria-live',
749
+ ariaModal: 'aria-modal',
750
+ ariaMultiLine: 'aria-multiline',
751
+ ariaMultiSelectable: 'aria-multiselectable',
752
+ ariaOrientation: 'aria-orientation',
753
+ ariaPlaceholder: 'aria-placeholder',
754
+ ariaPosInSet: 'aria-posinset',
755
+ ariaPressed: 'aria-pressed',
756
+ ariaReadOnly: 'aria-readonly',
757
+ ariaRelevant: 'aria-relevant',
758
+ ariaRequired: 'aria-required',
759
+ ariaRoleDescription: 'aria-roledescription',
760
+ ariaRowCount: 'aria-rowcount',
761
+ ariaRowIndex: 'aria-rowindex',
762
+ ariaRowIndexText: 'aria-rowindextext',
763
+ ariaRowSpan: 'aria-rowspan',
764
+ ariaSelected: 'aria-selected',
765
+ ariaSetSize: 'aria-setsize',
766
+ ariaSort: 'aria-sort',
767
+ ariaValueMax: 'aria-valuemax',
768
+ ariaValueMin: 'aria-valuemin',
769
+ ariaValueNow: 'aria-valuenow',
770
+ ariaValueText: 'aria-valuetext',
771
+ role: 'role'
772
+ };
773
+ const initAom = (ref, internals) => {
774
+ for (let key in aom) {
775
+ internals[key] = null;
776
+ let closureValue = null;
777
+ const attributeName = aom[key];
778
+ Object.defineProperty(internals, key, {
779
+ get() {
780
+ return closureValue;
781
+ },
782
+ set(value) {
783
+ closureValue = value;
784
+ if (ref.isConnected) {
785
+ ref.setAttribute(attributeName, value);
786
+ }
787
+ else {
788
+ upgradeMap.set(ref, internals);
789
+ }
790
+ }
791
+ });
792
+ }
793
+ };
794
+
795
+ function initNode(node) {
796
+ const internals = internalsMap.get(node);
797
+ const { form } = internals;
798
+ initForm(node, form, internals);
799
+ initLabels(node, internals.labels);
800
+ }
801
+ const walkFieldset = (node, firstRender = false) => {
802
+ const walker = document.createTreeWalker(node, NodeFilter.SHOW_ELEMENT, {
803
+ acceptNode(node) {
804
+ return internalsMap.has(node) ?
805
+ NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
806
+ }
807
+ });
808
+ let current = walker.nextNode();
809
+ const isCallNecessary = (!firstRender || node.disabled);
810
+ while (current) {
811
+ if (current.formDisabledCallback && isCallNecessary) {
812
+ setDisabled(current, node.disabled);
813
+ }
814
+ current = walker.nextNode();
815
+ }
816
+ };
817
+ const disabledOrNameObserverConfig = { attributes: true, attributeFilter: ['disabled', 'name'] };
818
+ const disabledOrNameObserver = mutationObserverExists() ? new MutationObserver((mutationsList) => {
819
+ for (const mutation of mutationsList) {
820
+ const target = mutation.target;
821
+ if (mutation.attributeName === 'disabled') {
822
+ if (target.constructor['formAssociated']) {
823
+ setDisabled(target, target.hasAttribute('disabled'));
824
+ }
825
+ else if (target.localName === 'fieldset') {
826
+ walkFieldset(target);
827
+ }
828
+ }
829
+ if (mutation.attributeName === 'name') {
830
+ if (target.constructor['formAssociated']) {
831
+ const internals = internalsMap.get(target);
832
+ const value = refValueMap.get(target);
833
+ internals.setFormValue(value);
834
+ }
835
+ }
836
+ }
837
+ }) : {};
838
+ function observerCallback(mutationList) {
839
+ mutationList.forEach(mutationRecord => {
840
+ const { addedNodes, removedNodes } = mutationRecord;
841
+ const added = Array.from(addedNodes);
842
+ const removed = Array.from(removedNodes);
843
+ added.forEach(node => {
844
+ if (internalsMap.has(node) && node.constructor['formAssociated']) {
845
+ initNode(node);
846
+ }
847
+ if (upgradeMap.has(node)) {
848
+ const internals = upgradeMap.get(node);
849
+ const aomKeys = Object.keys(aom);
850
+ aomKeys
851
+ .filter(key => internals[key] !== null)
852
+ .forEach(key => {
853
+ node.setAttribute(aom[key], internals[key]);
854
+ });
855
+ upgradeMap.delete(node);
856
+ }
857
+ if (validityUpgradeMap.has(node)) {
858
+ const internals = validityUpgradeMap.get(node);
859
+ node.setAttribute('internals-valid', internals.validity.valid.toString());
860
+ node.setAttribute('internals-invalid', (!internals.validity.valid).toString());
861
+ node.setAttribute('aria-invalid', (!internals.validity.valid).toString());
862
+ validityUpgradeMap.delete(node);
863
+ }
864
+ if (node.localName === 'form') {
865
+ const formElements = formElementsMap.get(node);
866
+ const walker = document.createTreeWalker(node, NodeFilter.SHOW_ELEMENT, {
867
+ acceptNode(node) {
868
+ return (internalsMap.has(node) && node.constructor['formAssociated'] && !(formElements && formElements.has(node))) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
869
+ }
870
+ });
871
+ let current = walker.nextNode();
872
+ while (current) {
873
+ initNode(current);
874
+ current = walker.nextNode();
875
+ }
876
+ }
877
+ if (node.localName === 'fieldset') {
878
+ disabledOrNameObserver.observe?.(node, disabledOrNameObserverConfig);
879
+ walkFieldset(node, true);
880
+ }
881
+ });
882
+ removed.forEach(node => {
883
+ const internals = internalsMap.get(node);
884
+ if (internals && hiddenInputMap.get(internals)) {
885
+ removeHiddenInputs(internals);
886
+ }
887
+ if (shadowHostsMap.has(node)) {
888
+ const observer = shadowHostsMap.get(node);
889
+ observer.disconnect();
890
+ }
891
+ });
892
+ });
893
+ }
894
+ function fragmentObserverCallback(mutationList) {
895
+ mutationList.forEach(mutation => {
896
+ const { removedNodes } = mutation;
897
+ removedNodes.forEach(node => {
898
+ const observer = documentFragmentMap.get(mutation.target);
899
+ if (internalsMap.has(node)) {
900
+ upgradeInternals(node);
901
+ }
902
+ observer.disconnect();
903
+ });
904
+ });
905
+ }
906
+ const deferUpgrade = (fragment) => {
907
+ const observer = new MutationObserver(fragmentObserverCallback);
908
+ observer.observe?.(fragment, { childList: true });
909
+ documentFragmentMap.set(fragment, observer);
910
+ };
911
+ mutationObserverExists() ? new MutationObserver(observerCallback) : {};
912
+ const observerConfig = {
913
+ childList: true,
914
+ subtree: true
915
+ };
916
+
917
+ const setDisabled = (ref, disabled) => {
918
+ ref.toggleAttribute('internals-disabled', disabled);
919
+ if (disabled) {
920
+ ref.setAttribute('aria-disabled', 'true');
921
+ }
922
+ else {
923
+ ref.removeAttribute('aria-disabled');
924
+ }
925
+ if (ref.formDisabledCallback) {
926
+ ref.formDisabledCallback.apply(ref, [disabled]);
927
+ }
928
+ };
929
+ const removeHiddenInputs = (internals) => {
930
+ const hiddenInputs = hiddenInputMap.get(internals);
931
+ hiddenInputs.forEach(hiddenInput => {
932
+ hiddenInput.remove();
933
+ });
934
+ hiddenInputMap.set(internals, []);
935
+ };
936
+ const createHiddenInput = (ref, internals) => {
937
+ const input = document.createElement('input');
938
+ input.type = 'hidden';
939
+ input.name = ref.getAttribute('name');
940
+ ref.after(input);
941
+ hiddenInputMap.get(internals).push(input);
942
+ return input;
943
+ };
944
+ const initRef = (ref, internals) => {
945
+ hiddenInputMap.set(internals, []);
946
+ disabledOrNameObserver.observe?.(ref, disabledOrNameObserverConfig);
947
+ };
948
+ const initLabels = (ref, labels) => {
949
+ if (labels.length) {
950
+ Array.from(labels).forEach(label => label.addEventListener('click', ref.click.bind(ref)));
951
+ let firstLabelId = labels[0].id;
952
+ if (!labels[0].id) {
953
+ firstLabelId = `${labels[0].htmlFor}_Label`;
954
+ labels[0].id = firstLabelId;
955
+ }
956
+ ref.setAttribute('aria-labelledby', firstLabelId);
957
+ }
958
+ };
959
+ const setFormValidity = (form) => {
960
+ const nativeControlValidity = Array.from(form.elements)
961
+ .filter((element) => !element.tagName.includes('-') && element.validity)
962
+ .map((element) => element.validity.valid);
963
+ const polyfilledElements = formElementsMap.get(form) || [];
964
+ const polyfilledValidity = Array.from(polyfilledElements)
965
+ .filter(control => control.isConnected)
966
+ .map((control) => internalsMap.get(control).validity.valid);
967
+ const hasInvalid = [...nativeControlValidity, ...polyfilledValidity].includes(false);
968
+ form.toggleAttribute('internals-invalid', hasInvalid);
969
+ form.toggleAttribute('internals-valid', !hasInvalid);
970
+ };
971
+ const formInputCallback = (event) => {
972
+ setFormValidity(findParentForm(event.target));
973
+ };
974
+ const formChangeCallback = (event) => {
975
+ setFormValidity(findParentForm(event.target));
976
+ };
977
+ const wireSubmitLogic = (form) => {
978
+ const submitButtonSelector = ['button[type=submit]', 'input[type=submit]', 'button:not([type])']
979
+ .map(sel => `${sel}:not([disabled])`)
980
+ .map(sel => `${sel}:not([form])${form.id ? `,${sel}[form='${form.id}']` : ''}`)
981
+ .join(',');
982
+ form.addEventListener('click', event => {
983
+ const target = event.target;
984
+ if (target.closest(submitButtonSelector)) {
985
+ const elements = formElementsMap.get(form);
986
+ if (form.noValidate) {
987
+ return;
988
+ }
989
+ if (elements.size) {
990
+ const nodes = Array.from(elements);
991
+ const validityList = nodes
992
+ .reverse()
993
+ .map(node => {
994
+ const internals = internalsMap.get(node);
995
+ return internals.reportValidity();
996
+ });
997
+ if (validityList.includes(false)) {
998
+ event.preventDefault();
999
+ }
1000
+ }
1001
+ }
1002
+ });
1003
+ };
1004
+ const formResetCallback = (event) => {
1005
+ const elements = formElementsMap.get(event.target);
1006
+ if (elements && elements.size) {
1007
+ elements.forEach(element => {
1008
+ if (element.constructor.formAssociated && element.formResetCallback) {
1009
+ element.formResetCallback.apply(element);
1010
+ }
1011
+ });
1012
+ }
1013
+ };
1014
+ const initForm = (ref, form, internals) => {
1015
+ if (form) {
1016
+ const formElements = formElementsMap.get(form);
1017
+ if (formElements) {
1018
+ formElements.add(ref);
1019
+ }
1020
+ else {
1021
+ const initSet = new Set();
1022
+ initSet.add(ref);
1023
+ formElementsMap.set(form, initSet);
1024
+ wireSubmitLogic(form);
1025
+ form.addEventListener('reset', formResetCallback);
1026
+ form.addEventListener('input', formInputCallback);
1027
+ form.addEventListener('change', formChangeCallback);
1028
+ }
1029
+ formsMap.set(form, { ref, internals });
1030
+ if (ref.constructor['formAssociated'] && ref.formAssociatedCallback) {
1031
+ setTimeout(() => {
1032
+ ref.formAssociatedCallback.apply(ref, [form]);
1033
+ }, 0);
1034
+ }
1035
+ setFormValidity(form);
1036
+ }
1037
+ };
1038
+ const findParentForm = (elem) => {
1039
+ let parent = elem.parentNode;
1040
+ if (parent && parent.tagName !== 'FORM') {
1041
+ parent = findParentForm(parent);
1042
+ }
1043
+ return parent;
1044
+ };
1045
+ const throwIfNotFormAssociated = (ref, message, ErrorType = DOMException) => {
1046
+ if (!ref.constructor['formAssociated']) {
1047
+ throw new ErrorType(message);
1048
+ }
1049
+ };
1050
+ const overrideFormMethod = (form, returnValue, method) => {
1051
+ const elements = formElementsMap.get(form);
1052
+ if (elements && elements.size) {
1053
+ elements.forEach(element => {
1054
+ const internals = internalsMap.get(element);
1055
+ const valid = internals[method]();
1056
+ if (!valid) {
1057
+ returnValue = false;
1058
+ }
1059
+ });
1060
+ }
1061
+ return returnValue;
1062
+ };
1063
+ const upgradeInternals = (ref) => {
1064
+ if (ref.constructor['formAssociated']) {
1065
+ const internals = internalsMap.get(ref);
1066
+ const { labels, form } = internals;
1067
+ initLabels(ref, labels);
1068
+ initForm(ref, form, internals);
1069
+ }
1070
+ };
1071
+ function mutationObserverExists() {
1072
+ return typeof MutationObserver !== 'undefined';
1073
+ }
1074
+
1075
+ class ValidityState {
1076
+ constructor() {
1077
+ this.badInput = false;
1078
+ this.customError = false;
1079
+ this.patternMismatch = false;
1080
+ this.rangeOverflow = false;
1081
+ this.rangeUnderflow = false;
1082
+ this.stepMismatch = false;
1083
+ this.tooLong = false;
1084
+ this.tooShort = false;
1085
+ this.typeMismatch = false;
1086
+ this.valid = true;
1087
+ this.valueMissing = false;
1088
+ Object.seal(this);
1089
+ }
1090
+ }
1091
+ const setValid = (validityObject) => {
1092
+ validityObject.badInput = false;
1093
+ validityObject.customError = false;
1094
+ validityObject.patternMismatch = false;
1095
+ validityObject.rangeOverflow = false;
1096
+ validityObject.rangeUnderflow = false;
1097
+ validityObject.stepMismatch = false;
1098
+ validityObject.tooLong = false;
1099
+ validityObject.tooShort = false;
1100
+ validityObject.typeMismatch = false;
1101
+ validityObject.valid = true;
1102
+ validityObject.valueMissing = false;
1103
+ return validityObject;
1104
+ };
1105
+ const reconcileValidity = (validityObject, newState, form) => {
1106
+ validityObject.valid = isValid(newState);
1107
+ Object.keys(newState).forEach(key => validityObject[key] = newState[key]);
1108
+ if (form) {
1109
+ setFormValidity(form);
1110
+ }
1111
+ return validityObject;
1112
+ };
1113
+ const isValid = (validityState) => {
1114
+ let valid = true;
1115
+ for (let key in validityState) {
1116
+ if (key !== 'valid' && validityState[key] !== false) {
1117
+ valid = false;
1118
+ }
1119
+ }
1120
+ return valid;
1121
+ };
1122
+
1123
+ const customStateMap = new WeakMap();
1124
+ function addState(ref, stateName) {
1125
+ ref.toggleAttribute(stateName, true);
1126
+ if (ref.part) {
1127
+ ref.part.add(stateName);
1128
+ }
1129
+ }
1130
+ class CustomStateSet extends Set {
1131
+ static get isPolyfilled() {
1132
+ return true;
1133
+ }
1134
+ constructor(ref) {
1135
+ super();
1136
+ if (!ref || !ref.tagName || ref.tagName.indexOf('-') === -1) {
1137
+ throw new TypeError('Illegal constructor');
1138
+ }
1139
+ customStateMap.set(this, ref);
1140
+ }
1141
+ add(state) {
1142
+ if (!/^--/.test(state) || typeof state !== 'string') {
1143
+ throw new DOMException(`Failed to execute 'add' on 'CustomStateSet': The specified value ${state} must start with '--'.`);
1144
+ }
1145
+ const result = super.add(state);
1146
+ const ref = customStateMap.get(this);
1147
+ const stateName = `state${state}`;
1148
+ if (ref.isConnected) {
1149
+ addState(ref, stateName);
1150
+ }
1151
+ else {
1152
+ setTimeout(() => {
1153
+ addState(ref, stateName);
1154
+ });
1155
+ }
1156
+ return result;
1157
+ }
1158
+ clear() {
1159
+ for (let [entry] of this.entries()) {
1160
+ this.delete(entry);
1161
+ }
1162
+ super.clear();
1163
+ }
1164
+ delete(state) {
1165
+ const result = super.delete(state);
1166
+ const ref = customStateMap.get(this);
1167
+ if (ref.isConnected) {
1168
+ ref.toggleAttribute(`state${state}`, false);
1169
+ if (ref.part) {
1170
+ ref.part.remove(`state${state}`);
1171
+ }
1172
+ }
1173
+ else {
1174
+ setTimeout(() => {
1175
+ ref.toggleAttribute(`state${state}`, false);
1176
+ if (ref.part) {
1177
+ ref.part.remove(`state${state}`);
1178
+ }
1179
+ });
1180
+ }
1181
+ return result;
1182
+ }
1183
+ }
1184
+
1185
+ function __classPrivateFieldGet(receiver, state, kind, f) {
1186
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
1187
+ 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");
1188
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
1189
+ }
1190
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
1191
+ if (kind === "m") throw new TypeError("Private method is not writable");
1192
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
1193
+ 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");
1194
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
1195
+ }
1196
+
1197
+ var _HTMLFormControlsCollection_elements;
1198
+ class HTMLFormControlsCollection {
1199
+ constructor(elements) {
1200
+ _HTMLFormControlsCollection_elements.set(this, void 0);
1201
+ __classPrivateFieldSet(this, _HTMLFormControlsCollection_elements, elements, "f");
1202
+ for (let i = 0; i < elements.length; i++) {
1203
+ let element = elements[i];
1204
+ this[i] = element;
1205
+ if (element.hasAttribute('name')) {
1206
+ this[element.getAttribute('name')] = element;
1207
+ }
1208
+ }
1209
+ Object.freeze(this);
1210
+ }
1211
+ get length() {
1212
+ return __classPrivateFieldGet(this, _HTMLFormControlsCollection_elements, "f").length;
1213
+ }
1214
+ [(_HTMLFormControlsCollection_elements = new WeakMap(), Symbol.iterator)]() {
1215
+ return __classPrivateFieldGet(this, _HTMLFormControlsCollection_elements, "f")[Symbol.iterator]();
1216
+ }
1217
+ item(i) {
1218
+ return this[i] == null ? null : this[i];
1219
+ }
1220
+ namedItem(name) {
1221
+ return this[name] == null ? null : this[name];
1222
+ }
1223
+ }
1224
+
1225
+ function patchFormPrototype() {
1226
+ const checkValidity = HTMLFormElement.prototype.checkValidity;
1227
+ HTMLFormElement.prototype.checkValidity = checkValidityOverride;
1228
+ const reportValidity = HTMLFormElement.prototype.reportValidity;
1229
+ HTMLFormElement.prototype.reportValidity = reportValidityOverride;
1230
+ function checkValidityOverride(...args) {
1231
+ let returnValue = checkValidity.apply(this, args);
1232
+ return overrideFormMethod(this, returnValue, 'checkValidity');
1233
+ }
1234
+ function reportValidityOverride(...args) {
1235
+ let returnValue = reportValidity.apply(this, args);
1236
+ return overrideFormMethod(this, returnValue, 'reportValidity');
1237
+ }
1238
+ const { get } = Object.getOwnPropertyDescriptor(HTMLFormElement.prototype, 'elements');
1239
+ Object.defineProperty(HTMLFormElement.prototype, 'elements', {
1240
+ get(...args) {
1241
+ const elements = get.call(this, ...args);
1242
+ const polyfilledElements = Array.from(formElementsMap.get(this) || []);
1243
+ if (polyfilledElements.length === 0) {
1244
+ return elements;
1245
+ }
1246
+ const orderedElements = Array.from(elements).concat(polyfilledElements).sort((a, b) => {
1247
+ if (a.compareDocumentPosition) {
1248
+ return a.compareDocumentPosition(b) & 2 ? 1 : -1;
1249
+ }
1250
+ return 0;
1251
+ });
1252
+ return new HTMLFormControlsCollection(orderedElements);
1253
+ },
1254
+ });
1255
+ }
1256
+
1257
+ class ElementInternals {
1258
+ static get isPolyfilled() {
1259
+ return true;
1260
+ }
1261
+ constructor(ref) {
1262
+ if (!ref || !ref.tagName || ref.tagName.indexOf('-') === -1) {
1263
+ throw new TypeError('Illegal constructor');
1264
+ }
1265
+ const rootNode = ref.getRootNode();
1266
+ const validity = new ValidityState();
1267
+ this.states = new CustomStateSet(ref);
1268
+ refMap.set(this, ref);
1269
+ validityMap.set(this, validity);
1270
+ internalsMap.set(ref, this);
1271
+ initAom(ref, this);
1272
+ initRef(ref, this);
1273
+ Object.seal(this);
1274
+ if (rootNode instanceof DocumentFragment) {
1275
+ deferUpgrade(rootNode);
1276
+ }
1277
+ }
1278
+ checkValidity() {
1279
+ const ref = refMap.get(this);
1280
+ throwIfNotFormAssociated(ref, `Failed to execute 'checkValidity' on 'ElementInternals': The target element is not a form-associated custom element.`);
1281
+ if (!this.willValidate) {
1282
+ return true;
1283
+ }
1284
+ const validity = validityMap.get(this);
1285
+ if (!validity.valid) {
1286
+ const validityEvent = new Event('invalid', {
1287
+ bubbles: false,
1288
+ cancelable: true,
1289
+ composed: false
1290
+ });
1291
+ ref.dispatchEvent(validityEvent);
1292
+ }
1293
+ return validity.valid;
1294
+ }
1295
+ get form() {
1296
+ const ref = refMap.get(this);
1297
+ throwIfNotFormAssociated(ref, `Failed to read the 'form' property from 'ElementInternals': The target element is not a form-associated custom element.`);
1298
+ let form;
1299
+ if (ref.constructor['formAssociated'] === true) {
1300
+ form = findParentForm(ref);
1301
+ }
1302
+ return form;
1303
+ }
1304
+ get labels() {
1305
+ const ref = refMap.get(this);
1306
+ throwIfNotFormAssociated(ref, `Failed to read the 'labels' property from 'ElementInternals': The target element is not a form-associated custom element.`);
1307
+ const id = ref.getAttribute('id');
1308
+ const hostRoot = ref.getRootNode();
1309
+ if (hostRoot && id) {
1310
+ return hostRoot.querySelectorAll(`[for="${id}"]`);
1311
+ }
1312
+ return [];
1313
+ }
1314
+ reportValidity() {
1315
+ const ref = refMap.get(this);
1316
+ throwIfNotFormAssociated(ref, `Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element.`);
1317
+ if (!this.willValidate) {
1318
+ return true;
1319
+ }
1320
+ const valid = this.checkValidity();
1321
+ const anchor = validationAnchorMap.get(this);
1322
+ if (anchor && !ref.constructor['formAssociated']) {
1323
+ throw new DOMException(`Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element.`);
1324
+ }
1325
+ if (!valid && anchor) {
1326
+ ref.focus();
1327
+ anchor.focus();
1328
+ }
1329
+ return valid;
1330
+ }
1331
+ setFormValue(value) {
1332
+ const ref = refMap.get(this);
1333
+ throwIfNotFormAssociated(ref, `Failed to execute 'setFormValue' on 'ElementInternals': The target element is not a form-associated custom element.`);
1334
+ removeHiddenInputs(this);
1335
+ if (value != null && !(value instanceof FormData)) {
1336
+ if (ref.getAttribute('name')) {
1337
+ const hiddenInput = createHiddenInput(ref, this);
1338
+ hiddenInput.value = value;
1339
+ }
1340
+ }
1341
+ else if (value != null && value instanceof FormData) {
1342
+ Array.from(value).reverse().forEach(([formDataKey, formDataValue]) => {
1343
+ if (typeof formDataValue === 'string') {
1344
+ const hiddenInput = createHiddenInput(ref, this);
1345
+ hiddenInput.name = formDataKey;
1346
+ hiddenInput.value = formDataValue;
1347
+ }
1348
+ });
1349
+ }
1350
+ refValueMap.set(ref, value);
1351
+ }
1352
+ setValidity(validityChanges, validationMessage, anchor) {
1353
+ const ref = refMap.get(this);
1354
+ throwIfNotFormAssociated(ref, `Failed to execute 'setValidity' on 'ElementInternals': The target element is not a form-associated custom element.`);
1355
+ if (!validityChanges) {
1356
+ throw new TypeError('Failed to execute \'setValidity\' on \'ElementInternals\': 1 argument required, but only 0 present.');
1357
+ }
1358
+ validationAnchorMap.set(this, anchor);
1359
+ const validity = validityMap.get(this);
1360
+ const validityChangesObj = {};
1361
+ for (const key in validityChanges) {
1362
+ validityChangesObj[key] = validityChanges[key];
1363
+ }
1364
+ if (Object.keys(validityChangesObj).length === 0) {
1365
+ setValid(validity);
1366
+ }
1367
+ const check = { ...validity, ...validityChangesObj };
1368
+ delete check.valid;
1369
+ const { valid } = reconcileValidity(validity, check, this.form);
1370
+ if (!valid && !validationMessage) {
1371
+ 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.`);
1372
+ }
1373
+ validationMessageMap.set(this, valid ? '' : validationMessage);
1374
+ if (ref.isConnected) {
1375
+ ref.toggleAttribute('internals-invalid', !valid);
1376
+ ref.toggleAttribute('internals-valid', valid);
1377
+ ref.setAttribute('aria-invalid', `${!valid}`);
1378
+ }
1379
+ else {
1380
+ validityUpgradeMap.set(ref, this);
1381
+ }
1382
+ }
1383
+ get shadowRoot() {
1384
+ const ref = refMap.get(this);
1385
+ const shadowRoot = shadowRootMap.get(ref);
1386
+ if (shadowRoot) {
1387
+ return shadowRoot;
1388
+ }
1389
+ return null;
1390
+ }
1391
+ get validationMessage() {
1392
+ const ref = refMap.get(this);
1393
+ throwIfNotFormAssociated(ref, `Failed to read the 'validationMessage' property from 'ElementInternals': The target element is not a form-associated custom element.`);
1394
+ return validationMessageMap.get(this);
1395
+ }
1396
+ get validity() {
1397
+ const ref = refMap.get(this);
1398
+ throwIfNotFormAssociated(ref, `Failed to read the 'validity' property from 'ElementInternals': The target element is not a form-associated custom element.`);
1399
+ const validity = validityMap.get(this);
1400
+ return validity;
1401
+ }
1402
+ get willValidate() {
1403
+ const ref = refMap.get(this);
1404
+ throwIfNotFormAssociated(ref, `Failed to read the 'willValidate' property from 'ElementInternals': The target element is not a form-associated custom element.`);
1405
+ if ((ref.disabled || ref.hasAttribute('disabled')) ||
1406
+ ref.hasAttribute('readonly')) {
1407
+ return false;
1408
+ }
1409
+ return true;
1410
+ }
1411
+ }
1412
+ function isElementInternalsSupported() {
1413
+ if (typeof window === 'undefined' || !window.ElementInternals || !HTMLElement.prototype.attachInternals) {
1414
+ return false;
1415
+ }
1416
+ class ElementInternalsFeatureDetection extends HTMLElement {
1417
+ constructor() {
1418
+ super();
1419
+ this.internals = this.attachInternals();
1420
+ }
1421
+ }
1422
+ const randomName = `element-internals-feature-detection-${Math.random().toString(36).replace(/[^a-z]+/g, '')}`;
1423
+ customElements.define(randomName, ElementInternalsFeatureDetection);
1424
+ const featureDetectionElement = new ElementInternalsFeatureDetection();
1425
+ return [
1426
+ 'shadowRoot',
1427
+ 'form',
1428
+ 'willValidate',
1429
+ 'validity',
1430
+ 'validationMessage',
1431
+ 'labels',
1432
+ 'setFormValue',
1433
+ 'setValidity',
1434
+ 'checkValidity',
1435
+ 'reportValidity'
1436
+ ].every(prop => prop in featureDetectionElement.internals);
1437
+ }
1438
+ if (!isElementInternalsSupported()) {
1439
+ if (typeof window !== 'undefined') {
1440
+ window.ElementInternals = ElementInternals;
1441
+ }
1442
+ if (typeof CustomElementRegistry !== 'undefined') {
1443
+ const define = CustomElementRegistry.prototype.define;
1444
+ CustomElementRegistry.prototype.define = function (name, constructor, options) {
1445
+ if (constructor.formAssociated) {
1446
+ const connectedCallback = constructor.prototype.connectedCallback;
1447
+ constructor.prototype.connectedCallback = function () {
1448
+ if (!connectedCallbackMap.has(this)) {
1449
+ connectedCallbackMap.set(this, true);
1450
+ if (this.hasAttribute('disabled')) {
1451
+ setDisabled(this, true);
1452
+ }
1453
+ }
1454
+ if (connectedCallback != null) {
1455
+ connectedCallback.apply(this);
1456
+ }
1457
+ upgradeInternals(this);
1458
+ };
1459
+ }
1460
+ define.call(this, name, constructor, options);
1461
+ };
1462
+ }
1463
+ if (typeof HTMLElement !== 'undefined') {
1464
+ HTMLElement.prototype.attachInternals = function () {
1465
+ if (!this.tagName) {
1466
+ return {};
1467
+ }
1468
+ else if (this.tagName.indexOf('-') === -1) {
1469
+ throw new Error(`Failed to execute 'attachInternals' on 'HTMLElement': Unable to attach ElementInternals to non-custom elements.`);
1470
+ }
1471
+ if (internalsMap.has(this)) {
1472
+ throw new DOMException(`DOMException: Failed to execute 'attachInternals' on 'HTMLElement': ElementInternals for the specified element was already attached.`);
1473
+ }
1474
+ return new ElementInternals(this);
1475
+ };
1476
+ }
1477
+ if (typeof Element !== 'undefined') {
1478
+ function attachShadowObserver(...args) {
1479
+ const shadowRoot = attachShadow.apply(this, args);
1480
+ shadowRootMap.set(this, shadowRoot);
1481
+ if (mutationObserverExists()) {
1482
+ const observer = new MutationObserver(observerCallback);
1483
+ if (window.ShadyDOM) {
1484
+ observer.observe(this, observerConfig);
1485
+ }
1486
+ else {
1487
+ observer.observe(shadowRoot, observerConfig);
1488
+ }
1489
+ shadowHostsMap.set(this, observer);
1490
+ }
1491
+ return shadowRoot;
1492
+ }
1493
+ const attachShadow = Element.prototype.attachShadow;
1494
+ Element.prototype.attachShadow = attachShadowObserver;
1495
+ }
1496
+ if (mutationObserverExists() && typeof document !== 'undefined') {
1497
+ const documentObserver = new MutationObserver(observerCallback);
1498
+ documentObserver.observe(document.documentElement, observerConfig);
1499
+ }
1500
+ if (typeof HTMLFormElement !== 'undefined') {
1501
+ patchFormPrototype();
1502
+ }
1503
+ if (typeof window !== 'undefined' && !window.CustomStateSet) {
1504
+ window.CustomStateSet = CustomStateSet;
1505
+ }
1506
+ }
1507
+ else if (typeof window !== 'undefined' && !window.CustomStateSet) {
1508
+ window.CustomStateSet = CustomStateSet;
1509
+ const attachInternals = HTMLElement.prototype.attachInternals;
1510
+ HTMLElement.prototype.attachInternals = function (...args) {
1511
+ const internals = attachInternals.call(this, args);
1512
+ internals.states = new CustomStateSet(this);
1513
+ return internals;
1514
+ };
1515
+ }
1516
+
1517
+ })();
1518
+
712
1519
  const observedAttributes$6 = ['required', 'pattern'];
713
1520
 
714
1521
  const errorAttributes = {
@@ -5619,7 +6426,7 @@ customElements.define(componentName$6, NewPasswordClass);
5619
6426
 
5620
6427
  const componentName$5 = getComponentName('recaptcha');
5621
6428
 
5622
- const observedAttributes$1 = ['disabled', 'site-key', 'action', 'enterprise'];
6429
+ const observedAttributes$1 = ['enabled', 'site-key', 'action', 'enterprise'];
5623
6430
 
5624
6431
  const BaseClass = createBaseClass({
5625
6432
  componentName: componentName$5,
@@ -5632,18 +6439,18 @@ class RawRecaptcha extends BaseClass {
5632
6439
 
5633
6440
  attributeChangedCallback(attrName, oldValue, newValue) {
5634
6441
  super.attributeChangedCallback?.(attrName, oldValue, newValue);
5635
- if (attrName === 'disabled') {
6442
+ if (attrName === 'enabled') {
5636
6443
  this.#toggleRecaptcha(newValue === 'true');
5637
6444
  }
5638
6445
  }
5639
6446
 
5640
- renderRecaptcha(disabled) {
5641
- if (disabled) {
5642
- this.recaptchaEle.style.display = 'none';
5643
- this.mockRecaptchaEle.style.display = '';
5644
- } else {
6447
+ renderRecaptcha(enabled) {
6448
+ if (enabled) {
5645
6449
  this.recaptchaEle.style.display = '';
5646
6450
  this.mockRecaptchaEle.style.display = 'none';
6451
+ } else {
6452
+ this.recaptchaEle.style.display = 'none';
6453
+ this.mockRecaptchaEle.style.display = '';
5647
6454
  }
5648
6455
  }
5649
6456
 
@@ -5652,16 +6459,19 @@ class RawRecaptcha extends BaseClass {
5652
6459
 
5653
6460
  this.attachShadow({ mode: 'open' }).innerHTML = `
5654
6461
  <style>
5655
- :host #recaptcha {
6462
+ :host {
6463
+ display: inline-flex;
6464
+ }
6465
+ :host > div {
6466
+ display: flex;
6467
+ }
6468
+ :host #recaptcha {
5656
6469
  width: 100%;
5657
- height: 100%
6470
+ height: 100%;
5658
6471
  }
5659
6472
  :host img {
5660
6473
  width: 256px;
5661
6474
  }
5662
- :host {
5663
- display: inline-flex;
5664
- }
5665
6475
  </style>
5666
6476
  <div>
5667
6477
  <span id="recaptcha"></span>
@@ -5685,8 +6495,8 @@ class RawRecaptcha extends BaseClass {
5685
6495
  return this.getAttribute('action') || 'load';
5686
6496
  }
5687
6497
 
5688
- get disabled() {
5689
- return this.getAttribute('disabled') === 'true';
6498
+ get enabled() {
6499
+ return this.getAttribute('enabled') === 'true';
5690
6500
  }
5691
6501
 
5692
6502
  get scriptURL() {
@@ -5697,9 +6507,9 @@ class RawRecaptcha extends BaseClass {
5697
6507
  return url.toString();
5698
6508
  }
5699
6509
 
5700
- #toggleRecaptcha(disabled) {
5701
- this.renderRecaptcha(disabled);
5702
- if (!disabled) {
6510
+ #toggleRecaptcha(enabled) {
6511
+ this.renderRecaptcha(enabled);
6512
+ if (enabled) {
5703
6513
  this.#loadRecaptchaScript();
5704
6514
  this.#createOnLoadScript();
5705
6515
  }
@@ -5765,8 +6575,7 @@ class RawRecaptcha extends BaseClass {
5765
6575
 
5766
6576
  connectedCallback() {
5767
6577
  super.connectedCallback?.();
5768
-
5769
- this.#toggleRecaptcha(this.disabled);
6578
+ this.#toggleRecaptcha(this.enabled);
5770
6579
  }
5771
6580
  }
5772
6581