@mgdis/core-ui-helpers 1.2.2 → 1.3.1

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.
Files changed (149) hide show
  1. package/dist/angular/index.cjs +27 -0
  2. package/dist/angular/index.cjs.map +1 -0
  3. package/dist/angular/index.d.ts +21 -0
  4. package/dist/angular/index.js +25 -0
  5. package/dist/angular/index.js.map +1 -0
  6. package/dist/angular/index.umd.js +33 -0
  7. package/dist/angular/index.umd.js.map +1 -0
  8. package/dist/locale/index.cjs +190 -0
  9. package/dist/locale/index.cjs.map +1 -0
  10. package/dist/locale/index.d.ts +110 -0
  11. package/dist/locale/index.js +181 -0
  12. package/dist/locale/index.js.map +1 -0
  13. package/dist/locale/index.umd.js +196 -0
  14. package/dist/locale/index.umd.js.map +1 -0
  15. package/dist/playwright/index.cjs +137 -0
  16. package/dist/playwright/index.cjs.map +1 -0
  17. package/dist/playwright/index.d.ts +39 -0
  18. package/dist/playwright/index.js +133 -0
  19. package/dist/playwright/index.js.map +1 -0
  20. package/dist/playwright/index.umd.js +143 -0
  21. package/dist/playwright/index.umd.js.map +1 -0
  22. package/dist/stencil/index.cjs +363 -0
  23. package/dist/stencil/index.cjs.map +1 -0
  24. package/dist/stencil/index.d.ts +222 -0
  25. package/dist/stencil/index.js +357 -0
  26. package/dist/stencil/index.js.map +1 -0
  27. package/dist/stencil/index.umd.js +369 -0
  28. package/dist/stencil/index.umd.js.map +1 -0
  29. package/dist/storybook/index.cjs +2335 -0
  30. package/dist/storybook/index.cjs.map +1 -0
  31. package/dist/storybook/index.d.ts +85 -0
  32. package/dist/storybook/index.js +2329 -0
  33. package/dist/storybook/index.js.map +1 -0
  34. package/dist/storybook/index.umd.js +2341 -0
  35. package/dist/storybook/index.umd.js.map +1 -0
  36. package/dist/tests/index.cjs +315 -0
  37. package/dist/tests/index.cjs.map +1 -0
  38. package/dist/tests/index.d.ts +100 -0
  39. package/dist/tests/index.js +309 -0
  40. package/dist/tests/index.js.map +1 -0
  41. package/dist/tests/index.umd.js +321 -0
  42. package/dist/tests/index.umd.js.map +1 -0
  43. package/dist/utils/index.cjs +441 -0
  44. package/dist/utils/index.cjs.map +1 -0
  45. package/dist/utils/index.d.ts +265 -0
  46. package/dist/utils/index.js +417 -0
  47. package/dist/utils/index.js.map +1 -0
  48. package/dist/utils/index.umd.js +447 -0
  49. package/dist/utils/index.umd.js.map +1 -0
  50. package/dist/vue/index.cjs +1935 -0
  51. package/dist/vue/index.cjs.map +1 -0
  52. package/dist/vue/index.d.ts +35 -0
  53. package/dist/vue/index.js +1933 -0
  54. package/dist/vue/index.js.map +1 -0
  55. package/dist/vue/index.umd.js +1941 -0
  56. package/dist/vue/index.umd.js.map +1 -0
  57. package/package.json +14 -11
  58. package/CHANGELOG.md +0 -101
  59. package/json-doc.test.json +0 -264
  60. package/rollup.config.mjs +0 -61
  61. package/src/angular/index.spec.ts +0 -8
  62. package/src/angular/index.ts +0 -1
  63. package/src/angular/mg-angular-logger/index.ts +0 -1
  64. package/src/angular/mg-angular-logger/mg-angular-logger.conf.ts +0 -3
  65. package/src/angular/mg-angular-logger/mg-angular-logger.spec.ts +0 -40
  66. package/src/angular/mg-angular-logger/mg-angular-logger.ts +0 -24
  67. package/src/locale/index.spec.ts +0 -24
  68. package/src/locale/index.ts +0 -1
  69. package/src/locale/locale.spec.ts +0 -291
  70. package/src/locale/locale.ts +0 -201
  71. package/src/playwright/config/index.ts +0 -43
  72. package/src/playwright/index.spec.ts +0 -16
  73. package/src/playwright/index.ts +0 -4
  74. package/src/playwright/utils/__snapshots__/utils.spec.ts.snap +0 -48
  75. package/src/playwright/utils/index.ts +0 -1
  76. package/src/playwright/utils/utils.spec.ts +0 -50
  77. package/src/playwright/utils/utils.ts +0 -77
  78. package/src/stencil/ide/__snapshots__/cem.spec.ts.snap +0 -248
  79. package/src/stencil/ide/__snapshots__/ide.spec.ts.snap +0 -414
  80. package/src/stencil/ide/cem.spec.ts +0 -35
  81. package/src/stencil/ide/cem.ts +0 -96
  82. package/src/stencil/ide/ide.spec.ts +0 -29
  83. package/src/stencil/ide/ide.ts +0 -221
  84. package/src/stencil/ide/index.ts +0 -2
  85. package/src/stencil/index.spec.ts +0 -16
  86. package/src/stencil/index.ts +0 -2
  87. package/src/stencil/normalize-boolean-attributes/index.ts +0 -1
  88. package/src/stencil/normalize-boolean-attributes/normalize-boolean-attributes.spec.ts +0 -63
  89. package/src/stencil/normalize-boolean-attributes/normalize-boolean-attributes.ts +0 -40
  90. package/src/storybook/index.spec.ts +0 -19
  91. package/src/storybook/index.ts +0 -1
  92. package/src/storybook/stencil/__snapshots__/stencil.spec.ts.snap +0 -329
  93. package/src/storybook/stencil/index.ts +0 -1
  94. package/src/storybook/stencil/stencil-shim.d.ts +0 -1
  95. package/src/storybook/stencil/stencil.conf.ts +0 -4
  96. package/src/storybook/stencil/stencil.spec.ts +0 -170
  97. package/src/storybook/stencil/stencil.ts +0 -377
  98. package/src/tests/index.spec.ts +0 -20
  99. package/src/tests/index.ts +0 -1
  100. package/src/tests/unit/__snapshots__/unit.spec.ts.snap +0 -52
  101. package/src/tests/unit/index.ts +0 -1
  102. package/src/tests/unit/unit.conf.ts +0 -16
  103. package/src/tests/unit/unit.spec.ts +0 -206
  104. package/src/tests/unit/unit.ts +0 -333
  105. package/src/utils/attributes/class-list/class-list.spec.ts +0 -36
  106. package/src/utils/attributes/class-list/class-list.ts +0 -51
  107. package/src/utils/attributes/class-list/index.ts +0 -1
  108. package/src/utils/attributes/id/id.spec.ts +0 -54
  109. package/src/utils/attributes/id/id.ts +0 -47
  110. package/src/utils/attributes/id/index.ts +0 -1
  111. package/src/utils/attributes/index.ts +0 -3
  112. package/src/utils/attributes/to-kebab-case/index.ts +0 -1
  113. package/src/utils/attributes/to-kebab-case/to-kebab-case.spec.ts +0 -29
  114. package/src/utils/attributes/to-kebab-case/to-kebab-case.ts +0 -23
  115. package/src/utils/components/__snapshots__/components.spec.ts.snap +0 -313
  116. package/src/utils/components/components.conf.ts +0 -11
  117. package/src/utils/components/components.spec.ts +0 -192
  118. package/src/utils/components/components.ts +0 -152
  119. package/src/utils/components/index.ts +0 -2
  120. package/src/utils/date/date.spec.ts +0 -12
  121. package/src/utils/date/date.ts +0 -20
  122. package/src/utils/date/index.ts +0 -1
  123. package/src/utils/elements/elements.spec.ts +0 -17
  124. package/src/utils/elements/elements.ts +0 -18
  125. package/src/utils/elements/index.ts +0 -1
  126. package/src/utils/index.spec.ts +0 -84
  127. package/src/utils/index.ts +0 -8
  128. package/src/utils/number/index.ts +0 -1
  129. package/src/utils/number/number.spec.ts +0 -14
  130. package/src/utils/number/number.ts +0 -6
  131. package/src/utils/object/index.ts +0 -2
  132. package/src/utils/object/object.conf.ts +0 -4
  133. package/src/utils/object/object.spec.ts +0 -110
  134. package/src/utils/object/object.ts +0 -27
  135. package/src/utils/string/index.ts +0 -1
  136. package/src/utils/string/string.spec.ts +0 -54
  137. package/src/utils/string/string.ts +0 -39
  138. package/src/utils/windows/index.ts +0 -1
  139. package/src/utils/windows/windows.spec.ts +0 -69
  140. package/src/utils/windows/windows.ts +0 -50
  141. package/src/vue/index.spec.ts +0 -8
  142. package/src/vue/index.ts +0 -1
  143. package/src/vue/mg-model/index.ts +0 -1
  144. package/src/vue/mg-model/mg-model.conf.ts +0 -6
  145. package/src/vue/mg-model/mg-model.spec.ts +0 -50
  146. package/src/vue/mg-model/mg-model.ts +0 -55
  147. package/tsconfig.json +0 -17
  148. package/typedoc.json +0 -14
  149. package/vitest.config.mts +0 -13
@@ -0,0 +1,315 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Utility function that mocks the `MutationObserver` API. Recommended to execute inside `beforeEach`.
5
+ * @param mutationObserverMock - Parameter that is sent to the `Object.defineProperty`
6
+ * overwrite method. `jest.fn()` mock functions can be passed here if the goal is to not only
7
+ * mock the mutation observer, but its methods.
8
+ * You can manually fire an intersection entry:
9
+ * @param mutationObserverMock - configuration object
10
+ * @returns Mocked MutationObserver
11
+ * @example
12
+ * ```
13
+ * let fireMo;
14
+ * setupMutationObserverMock({
15
+ * observe: function () {
16
+ * fireMo = this.cb;
17
+ * },
18
+ * });
19
+ * ...
20
+ * fireMo([{ type: 'childList', addedNodes: [AMockElemenet, AnotherMockElemenet], target: yourMockElemenet }]);;
21
+ * ```
22
+ */
23
+ const setupMutationObserverMock = ({ disconnect, observe, takeRecords, }) => {
24
+ class MockMutationObserver {
25
+ /**
26
+ *
27
+ */
28
+ disconnect = disconnect;
29
+ /**
30
+ *
31
+ */
32
+ observe = observe;
33
+ /**
34
+ *
35
+ */
36
+ takeRecords = takeRecords;
37
+ /**
38
+ *
39
+ */
40
+ cb;
41
+ constructor(fn) {
42
+ this.cb = fn;
43
+ }
44
+ }
45
+ [window, global].forEach((element) => {
46
+ Object.defineProperty(element, 'MutationObserver', {
47
+ writable: true,
48
+ configurable: true,
49
+ value: MockMutationObserver,
50
+ });
51
+ });
52
+ return MockMutationObserver;
53
+ };
54
+ /**
55
+ * Utility function that mocks the `ResizeObserver` API. Recommended to execute inside `beforeEach`.
56
+ * @param resizeObserverMock - Parameter that is sent to the `Object.defineProperty`
57
+ * overwrite method. `jest.fn()` mock functions can be passed here if the goal is to not only
58
+ * mock the resize observer, but its methods.
59
+ * You can manually fire an intersection entry:
60
+ * @param resizeObserverMock - configuration object
61
+ * @returns Mocked ResizeObserver
62
+ * @example
63
+ * ```
64
+ * let fireRo;
65
+ * setupResizeObserverMock({
66
+ * observe: function () {
67
+ * fireRo = this.cb;
68
+ * },
69
+ * });
70
+ * ...
71
+ * fireRo([{
72
+ * borderBoxSize: ResizeObserverSize[],
73
+ * contentBoxSize: ResizeObserverSize[],
74
+ * contentRect: DOMRectReadOnly,
75
+ * devicePixelContentBoxSize: ResizeObserverSize[],
76
+ * target: yourMockElemenet
77
+ * }]);;
78
+ * ```
79
+ */
80
+ const setupResizeObserverMock = ({ disconnect, observe, }) => {
81
+ class MockResizeObserver {
82
+ /**
83
+ *
84
+ */
85
+ disconnect = disconnect;
86
+ /**
87
+ *
88
+ */
89
+ observe = observe;
90
+ /**
91
+ *
92
+ */
93
+ unobserve;
94
+ /**
95
+ *
96
+ */
97
+ cb;
98
+ constructor(fn) {
99
+ this.cb = fn;
100
+ }
101
+ }
102
+ [window, global].forEach((element) => {
103
+ Object.defineProperty(element, 'ResizeObserver', {
104
+ writable: true,
105
+ configurable: true,
106
+ value: MockResizeObserver,
107
+ });
108
+ });
109
+ return MockResizeObserver;
110
+ };
111
+ class MockCustomEvent extends Event {
112
+ /**
113
+ *
114
+ */
115
+ detail; // eslint-disable-line @typescript-eslint/no-explicit-any
116
+ }
117
+ /**
118
+ * Utility function that mocks the `SubmitEvent` API. Recommended to execute inside `beforeEach`.
119
+ * @example
120
+ * ```
121
+ * setupSubmitEventMock();
122
+ * ```
123
+ * @returns custom event mock
124
+ */
125
+ const setupSubmitEventMock = () => {
126
+ class SubmitEvent extends MockCustomEvent {
127
+ }
128
+ [window, global].forEach((element) => {
129
+ Object.defineProperty(element, 'SubmitEvent', {
130
+ writable: true,
131
+ configurable: true,
132
+ value: SubmitEvent,
133
+ });
134
+ });
135
+ return SubmitEvent;
136
+ };
137
+ /**
138
+ * Utility function that mocks the `requestAnimationFrame` API. Recommended to execute inside `test`.
139
+ * @example
140
+ * ```
141
+ * setUpRequestAnimationFrameMock(jest.runOnlyPendingTimers);
142
+ * ```
143
+ * @param faketimer - recommended to use jest.runOnlyPendingTimers()
144
+ * @returns custom setUpRequestAnimationFrameMock mock
145
+ */
146
+ const setUpRequestAnimationFrameMock = (faketimer) => {
147
+ const requestAnimationFrame = (callback) => {
148
+ setTimeout(callback, 1);
149
+ faketimer();
150
+ return 0;
151
+ };
152
+ [window, global].forEach((element) => {
153
+ Object.defineProperty(element, 'requestAnimationFrame', {
154
+ writable: true,
155
+ configurable: true,
156
+ value: requestAnimationFrame,
157
+ });
158
+ });
159
+ return requestAnimationFrame;
160
+ };
161
+ /**
162
+ * Convert string to given type
163
+ * @param value - string value to format
164
+ * @param type - new value output type
165
+ * @returns string value converted to given type
166
+ */
167
+ const convertString = (value, type) => {
168
+ switch (type) {
169
+ case 'date':
170
+ return new Date(value);
171
+ case 'number':
172
+ return Number(value);
173
+ default:
174
+ return value;
175
+ }
176
+ };
177
+ /**
178
+ * Get range underflow value from input['min]
179
+ * @param input - HTMLInputElement
180
+ * @returns truthy iv value is underflow
181
+ */
182
+ const getRangeUnderflow = (input) => {
183
+ const value = convertString(input.value, input.type);
184
+ if (['date', 'number'].includes(input.type) && input.hasAttribute('min') && input.value.length > 0) {
185
+ const min = convertString(input.min, input.type);
186
+ return value < min;
187
+ }
188
+ else {
189
+ return false;
190
+ }
191
+ };
192
+ /**
193
+ * Get range overflow value from input['max]
194
+ * @param input - HTMLInputElement
195
+ * @returns truthy iv value is overflow
196
+ */
197
+ const getRangeOverflow = (input) => {
198
+ const value = convertString(input.value, input.type);
199
+ if (['date', 'number'].includes(input.type) && input.hasAttribute('max') && input.value.length > 0) {
200
+ const max = convertString(input.max, input.type);
201
+ return value > max;
202
+ }
203
+ else {
204
+ return false;
205
+ }
206
+ };
207
+ /**
208
+ * HTMLSelectElement type guard
209
+ * @param input - HTMLElement to test
210
+ * @returns truthy if element is HTMLSelectElement
211
+ */
212
+ const isHTMLSelectElement = (input) => input.options !== undefined;
213
+ /**
214
+ * Is value missing from input
215
+ * @param input - input to test
216
+ * @returns truthy if value is required
217
+ */
218
+ const isValueMissing = (input) => {
219
+ if (input.hasAttribute('required') && input.required === true) {
220
+ if (['checkbox', 'radio'].includes(input.type)) {
221
+ return input.checked === false;
222
+ }
223
+ else if (isHTMLSelectElement(input)) {
224
+ return input.options.item(input.options.selectedIndex)?.value === '';
225
+ }
226
+ else {
227
+ return input.value.length === 0;
228
+ }
229
+ }
230
+ else {
231
+ return false;
232
+ }
233
+ };
234
+ /**
235
+ * Get input validity
236
+ * @param input - input prototype
237
+ * @returns input validity state
238
+ */
239
+ const getValidity = (input) => {
240
+ // required field without a value
241
+ const valueMissing = isValueMissing(input);
242
+ // value of a number field is not a number | value of a date field is not a date
243
+ const badInput = ['number', 'date'].includes(input.type) &&
244
+ isNaN(input.type === 'date' ? Date.parse(input.value) : input.value);
245
+ // value does not conform to the pattern
246
+ const patternMismatch = input.hasAttribute('pattern') && new RegExp(input.pattern).test(input.value) === false;
247
+ // value of a number|date field is higher than the max attribute
248
+ const rangeOverflow = getRangeOverflow(input);
249
+ // value of a number|date field is lower than the min attribute
250
+ const rangeUnderflow = getRangeUnderflow(input);
251
+ // value of a number field does not conform to the stepattribute
252
+ const stepMismatch = input.type === 'number' &&
253
+ input.hasAttribute('step') &&
254
+ input.step !== 'any' &&
255
+ Number(input.value) % parseFloat(input.step) !== 0;
256
+ // the user has edited a too-long value in a field with maxlength
257
+ const tooLong = input.hasAttribute('maxLength') && input.value?.length > Number(input.maxLength);
258
+ // the user has edited a too-short value in a field with minlength
259
+ const tooShort = input.hasAttribute('minLength') && input.value?.length < Number(input.minLength);
260
+ // value of a email or URL field is not an email address or URL
261
+ const typeMismatch = input.type === 'url' && !URL.canParse(input.value);
262
+ // value of validationMessage is not an empty string
263
+ const customError = false;
264
+ const valid = ![
265
+ valueMissing,
266
+ badInput,
267
+ patternMismatch,
268
+ rangeOverflow,
269
+ rangeUnderflow,
270
+ stepMismatch,
271
+ tooLong,
272
+ tooShort,
273
+ typeMismatch,
274
+ customError,
275
+ ].some((invalid) => invalid);
276
+ return {
277
+ badInput,
278
+ customError,
279
+ patternMismatch,
280
+ rangeOverflow,
281
+ rangeUnderflow,
282
+ stepMismatch,
283
+ tooLong,
284
+ tooShort,
285
+ typeMismatch,
286
+ valid,
287
+ valueMissing,
288
+ };
289
+ };
290
+ /**
291
+ * Utility function that mocks the HTMLInputElement[`vality`] state API and the HTMLInputElement.checkvalidty() methode.
292
+ * Recommended to execute inside `test`.
293
+ * @example
294
+ * ```
295
+ * Array.from(document.querySelectorInputs('input')).forEach(setUpHTMLInputElementValidity);
296
+ * ```
297
+ */
298
+ const setUpHTMLInputElementValidity = (input) => {
299
+ input.checkValidity = () => {
300
+ const { valid } = getValidity(input);
301
+ input.dispatchEvent(new CustomEvent('invalid', { detail: !valid }));
302
+ return valid;
303
+ };
304
+ Object.defineProperty(input, 'validity', {
305
+ get: () => getValidity(input),
306
+ configurable: true,
307
+ });
308
+ };
309
+
310
+ exports.setUpHTMLInputElementValidity = setUpHTMLInputElementValidity;
311
+ exports.setUpRequestAnimationFrameMock = setUpRequestAnimationFrameMock;
312
+ exports.setupMutationObserverMock = setupMutationObserverMock;
313
+ exports.setupResizeObserverMock = setupResizeObserverMock;
314
+ exports.setupSubmitEventMock = setupSubmitEventMock;
315
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../src/tests/unit/unit.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA;;;;;;;;;;;;;;;;;;;AAmBG;AACI,MAAM,yBAAyB,GAAG,CAAC,EACxC,UAAU,EACV,OAAO,EACP,WAAW,GACqB,KAA6B;AAC7D,IAAA,MAAM,oBAAoB,CAAA;AACxB;;AAEG;QACH,UAAU,GAAe,UAAU;AACnC;;AAEG;QACH,OAAO,GAA2D,OAAO;AACzE;;AAEG;QACH,WAAW,GAA2B,WAAW;AACjD;;AAEG;AACH,QAAA,EAAE;AACF,QAAA,WAAA,CAAY,EAAoB,EAAA;AAC9B,YAAA,IAAI,CAAC,EAAE,GAAG,EAAE;QACd;AACD;IAED,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,KAAI;AACnC,QAAA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,kBAAkB,EAAE;AACjD,YAAA,QAAQ,EAAE,IAAI;AACd,YAAA,YAAY,EAAE,IAAI;AAClB,YAAA,KAAK,EAAE,oBAAoB;AAC5B,SAAA,CAAC;AACJ,IAAA,CAAC,CAAC;AAEF,IAAA,OAAO,oBAAoB;AAC7B;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;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vE,MAAM,WAAW,GAAG,KAAK;IAEzB,MAAM,KAAK,GAAG,CAAC;QACb,YAAY;QACZ,QAAQ;QACR,eAAe;QACf,aAAa;QACb,cAAc;QACd,YAAY;QACZ,OAAO;QACP,QAAQ;QACR,YAAY;QACZ,WAAW;KACZ,CAAC,IAAI,CAAC,CAAC,OAAO,KAAK,OAAO,CAAC;IAC5B,OAAO;QACL,QAAQ;QACR,WAAW;QACX,eAAe;QACf,aAAa;QACb,cAAc;QACd,YAAY;QACZ,OAAO;QACP,QAAQ;QACR,YAAY;QACZ,KAAK;QACL,YAAY;KACb;AACH,CAAC;AAED;;;;;;;AAOG;AACI,MAAM,6BAA6B,GAAG,CAAC,KAAuB,KAAI;AACvE,IAAA,KAAK,CAAC,aAAa,GAAG,MAAK;QACzB,MAAM,EAAE,KAAK,EAAE,GAAG,WAAW,CAAC,KAAK,CAAC;AACpC,QAAA,KAAK,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC;AACnE,QAAA,OAAO,KAAK;AACd,IAAA,CAAC;AACD,IAAA,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,UAAU,EAAE;AACvC,QAAA,GAAG,EAAE,MAAM,WAAW,CAAC,KAAK,CAAC;AAC7B,QAAA,YAAY,EAAE,IAAI;AACnB,KAAA,CAAC;AACJ;;;;;;"}
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Define MutationObserver setup function signature
3
+ */
4
+ type SetupMutationObserverMockParams = {
5
+ disconnect: MutationObserver['disconnect'];
6
+ observe: MutationObserver['observe'];
7
+ takeRecords: MutationObserver['takeRecords'];
8
+ };
9
+ /**
10
+ * Define ResizeObserver setup function signature
11
+ */
12
+ type setupResizeObserverMockParams = {
13
+ disconnect: ResizeObserver['disconnect'];
14
+ observe: ResizeObserver['observe'];
15
+ };
16
+
17
+ /**
18
+ * Utility function that mocks the `MutationObserver` API. Recommended to execute inside `beforeEach`.
19
+ * @param mutationObserverMock - Parameter that is sent to the `Object.defineProperty`
20
+ * overwrite method. `jest.fn()` mock functions can be passed here if the goal is to not only
21
+ * mock the mutation observer, but its methods.
22
+ * You can manually fire an intersection entry:
23
+ * @param mutationObserverMock - configuration object
24
+ * @returns Mocked MutationObserver
25
+ * @example
26
+ * ```
27
+ * let fireMo;
28
+ * setupMutationObserverMock({
29
+ * observe: function () {
30
+ * fireMo = this.cb;
31
+ * },
32
+ * });
33
+ * ...
34
+ * fireMo([{ type: 'childList', addedNodes: [AMockElemenet, AnotherMockElemenet], target: yourMockElemenet }]);;
35
+ * ```
36
+ */
37
+ declare const setupMutationObserverMock: ({ disconnect, observe, takeRecords, }: SetupMutationObserverMockParams) => typeof MutationObserver;
38
+ /**
39
+ * Utility function that mocks the `ResizeObserver` API. Recommended to execute inside `beforeEach`.
40
+ * @param resizeObserverMock - Parameter that is sent to the `Object.defineProperty`
41
+ * overwrite method. `jest.fn()` mock functions can be passed here if the goal is to not only
42
+ * mock the resize observer, but its methods.
43
+ * You can manually fire an intersection entry:
44
+ * @param resizeObserverMock - configuration object
45
+ * @returns Mocked ResizeObserver
46
+ * @example
47
+ * ```
48
+ * let fireRo;
49
+ * setupResizeObserverMock({
50
+ * observe: function () {
51
+ * fireRo = this.cb;
52
+ * },
53
+ * });
54
+ * ...
55
+ * fireRo([{
56
+ * borderBoxSize: ResizeObserverSize[],
57
+ * contentBoxSize: ResizeObserverSize[],
58
+ * contentRect: DOMRectReadOnly,
59
+ * devicePixelContentBoxSize: ResizeObserverSize[],
60
+ * target: yourMockElemenet
61
+ * }]);;
62
+ * ```
63
+ */
64
+ declare const setupResizeObserverMock: ({ disconnect, observe, }: setupResizeObserverMockParams) => typeof ResizeObserver;
65
+ declare class MockCustomEvent extends Event {
66
+ /**
67
+ *
68
+ */
69
+ detail: any;
70
+ }
71
+ /**
72
+ * Utility function that mocks the `SubmitEvent` API. Recommended to execute inside `beforeEach`.
73
+ * @example
74
+ * ```
75
+ * setupSubmitEventMock();
76
+ * ```
77
+ * @returns custom event mock
78
+ */
79
+ declare const setupSubmitEventMock: () => typeof MockCustomEvent;
80
+ /**
81
+ * Utility function that mocks the `requestAnimationFrame` API. Recommended to execute inside `test`.
82
+ * @example
83
+ * ```
84
+ * setUpRequestAnimationFrameMock(jest.runOnlyPendingTimers);
85
+ * ```
86
+ * @param faketimer - recommended to use jest.runOnlyPendingTimers()
87
+ * @returns custom setUpRequestAnimationFrameMock mock
88
+ */
89
+ declare const setUpRequestAnimationFrameMock: (faketimer: () => void) => (callback: FrameRequestCallback) => number;
90
+ /**
91
+ * Utility function that mocks the HTMLInputElement[`vality`] state API and the HTMLInputElement.checkvalidty() methode.
92
+ * Recommended to execute inside `test`.
93
+ * @example
94
+ * ```
95
+ * Array.from(document.querySelectorInputs('input')).forEach(setUpHTMLInputElementValidity);
96
+ * ```
97
+ */
98
+ declare const setUpHTMLInputElementValidity: (input: HTMLInputElement) => void;
99
+
100
+ export { setUpHTMLInputElementValidity, setUpRequestAnimationFrameMock, setupMutationObserverMock, setupResizeObserverMock, setupSubmitEventMock };