happy-dom 10.6.0 → 10.6.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.

Potentially problematic release.


This version of happy-dom might be problematic. Click here for more details.

Files changed (56) hide show
  1. package/cjs/nodes/html-button-element/HTMLButtonElement.cjs +2 -16
  2. package/cjs/nodes/html-button-element/HTMLButtonElement.cjs.map +1 -1
  3. package/cjs/nodes/html-button-element/HTMLButtonElement.d.ts.map +1 -1
  4. package/cjs/nodes/html-input-element/HTMLInputElement.cjs +6 -20
  5. package/cjs/nodes/html-input-element/HTMLInputElement.cjs.map +1 -1
  6. package/cjs/nodes/html-input-element/HTMLInputElement.d.ts.map +1 -1
  7. package/cjs/nodes/html-input-element/HTMLInputElementDateUtility.cjs +50 -0
  8. package/cjs/nodes/html-input-element/HTMLInputElementDateUtility.cjs.map +1 -0
  9. package/cjs/nodes/html-input-element/HTMLInputElementDateUtility.d.ts +20 -0
  10. package/cjs/nodes/html-input-element/HTMLInputElementDateUtility.d.ts.map +1 -0
  11. package/cjs/nodes/html-label-element/HTMLLabelElementUtility.cjs +39 -0
  12. package/cjs/nodes/html-label-element/HTMLLabelElementUtility.cjs.map +1 -0
  13. package/cjs/nodes/html-label-element/HTMLLabelElementUtility.d.ts +16 -0
  14. package/cjs/nodes/html-label-element/HTMLLabelElementUtility.d.ts.map +1 -0
  15. package/cjs/nodes/html-select-element/HTMLSelectElement.cjs +2 -16
  16. package/cjs/nodes/html-select-element/HTMLSelectElement.cjs.map +1 -1
  17. package/cjs/nodes/html-select-element/HTMLSelectElement.d.ts.map +1 -1
  18. package/cjs/nodes/html-text-area-element/HTMLTextAreaElement.cjs +2 -16
  19. package/cjs/nodes/html-text-area-element/HTMLTextAreaElement.cjs.map +1 -1
  20. package/cjs/nodes/html-text-area-element/HTMLTextAreaElement.d.ts.map +1 -1
  21. package/lib/nodes/html-button-element/HTMLButtonElement.d.ts.map +1 -1
  22. package/lib/nodes/html-button-element/HTMLButtonElement.js +2 -16
  23. package/lib/nodes/html-button-element/HTMLButtonElement.js.map +1 -1
  24. package/lib/nodes/html-input-element/HTMLInputElement.d.ts.map +1 -1
  25. package/lib/nodes/html-input-element/HTMLInputElement.js +6 -20
  26. package/lib/nodes/html-input-element/HTMLInputElement.js.map +1 -1
  27. package/lib/nodes/html-input-element/HTMLInputElementDateUtility.d.ts +20 -0
  28. package/lib/nodes/html-input-element/HTMLInputElementDateUtility.d.ts.map +1 -0
  29. package/lib/nodes/html-input-element/HTMLInputElementDateUtility.js +47 -0
  30. package/lib/nodes/html-input-element/HTMLInputElementDateUtility.js.map +1 -0
  31. package/lib/nodes/html-label-element/HTMLLabelElementUtility.d.ts +16 -0
  32. package/lib/nodes/html-label-element/HTMLLabelElementUtility.d.ts.map +1 -0
  33. package/lib/nodes/html-label-element/HTMLLabelElementUtility.js +33 -0
  34. package/lib/nodes/html-label-element/HTMLLabelElementUtility.js.map +1 -0
  35. package/lib/nodes/html-select-element/HTMLSelectElement.d.ts.map +1 -1
  36. package/lib/nodes/html-select-element/HTMLSelectElement.js +2 -16
  37. package/lib/nodes/html-select-element/HTMLSelectElement.js.map +1 -1
  38. package/lib/nodes/html-text-area-element/HTMLTextAreaElement.d.ts.map +1 -1
  39. package/lib/nodes/html-text-area-element/HTMLTextAreaElement.js +2 -16
  40. package/lib/nodes/html-text-area-element/HTMLTextAreaElement.js.map +1 -1
  41. package/package.json +1 -1
  42. package/src/nodes/html-button-element/HTMLButtonElement.ts +2 -20
  43. package/src/nodes/html-input-element/HTMLInputElement.ts +6 -24
  44. package/src/nodes/html-input-element/HTMLInputElementDateUtility.ts +48 -0
  45. package/src/nodes/html-label-element/HTMLLabelElementUtility.ts +39 -0
  46. package/src/nodes/html-select-element/HTMLSelectElement.ts +2 -20
  47. package/src/nodes/html-text-area-element/HTMLTextAreaElement.ts +2 -20
  48. package/cjs/nodes/html-input-element/HTMLInputDateUtility.cjs +0 -47
  49. package/cjs/nodes/html-input-element/HTMLInputDateUtility.cjs.map +0 -1
  50. package/cjs/nodes/html-input-element/HTMLInputDateUtility.d.ts +0 -15
  51. package/cjs/nodes/html-input-element/HTMLInputDateUtility.d.ts.map +0 -1
  52. package/lib/nodes/html-input-element/HTMLInputDateUtility.d.ts +0 -15
  53. package/lib/nodes/html-input-element/HTMLInputDateUtility.d.ts.map +0 -1
  54. package/lib/nodes/html-input-element/HTMLInputDateUtility.js +0 -42
  55. package/lib/nodes/html-input-element/HTMLInputDateUtility.js.map +0 -1
  56. package/src/nodes/html-input-element/HTMLInputDateUtility.ts +0 -44
@@ -2,15 +2,13 @@ import Event from '../../event/Event.js';
2
2
  import EventPhaseEnum from '../../event/EventPhaseEnum.js';
3
3
  import INamedNodeMap from '../../named-node-map/INamedNodeMap.js';
4
4
  import ValidityState from '../../validity-state/ValidityState.js';
5
- import IDocument from '../document/IDocument.js';
6
5
  import HTMLElement from '../html-element/HTMLElement.js';
7
6
  import HTMLFormElement from '../html-form-element/HTMLFormElement.js';
8
7
  import IHTMLFormElement from '../html-form-element/IHTMLFormElement.js';
8
+ import HTMLLabelElementUtility from '../html-label-element/HTMLLabelElementUtility.js';
9
9
  import IHTMLLabelElement from '../html-label-element/IHTMLLabelElement.js';
10
10
  import INode from '../node/INode.js';
11
11
  import INodeList from '../node/INodeList.js';
12
- import NodeList from '../node/NodeList.js';
13
- import IShadowRoot from '../shadow-root/IShadowRoot.js';
14
12
  import HTMLButtonElementNamedNodeMap from './HTMLButtonElementNamedNodeMap.js';
15
13
  import IHTMLButtonElement from './IHTMLButtonElement.js';
16
14
 
@@ -140,23 +138,7 @@ export default class HTMLButtonElement extends HTMLElement implements IHTMLButto
140
138
  * @returns Label elements.
141
139
  */
142
140
  public get labels(): INodeList<IHTMLLabelElement> {
143
- const id = this.id;
144
- if (id) {
145
- const rootNode = <IDocument | IShadowRoot>this.getRootNode();
146
- const labels = rootNode.querySelectorAll(`label[for="${id}"]`);
147
-
148
- let parent = this.parentNode;
149
- while (parent) {
150
- if (parent['tagName'] === 'LABEL') {
151
- labels.push(<IHTMLLabelElement>parent);
152
- break;
153
- }
154
- parent = parent.parentNode;
155
- }
156
-
157
- return <INodeList<IHTMLLabelElement>>labels;
158
- }
159
- return new NodeList<IHTMLLabelElement>();
141
+ return HTMLLabelElementUtility.getAssociatedLabelElements(this);
160
142
  }
161
143
 
162
144
  /**
@@ -17,11 +17,9 @@ import INode from '../node/INode.js';
17
17
  import HTMLFormElement from '../html-form-element/HTMLFormElement.js';
18
18
  import INodeList from '../node/INodeList.js';
19
19
  import IHTMLLabelElement from '../html-label-element/IHTMLLabelElement.js';
20
- import IDocument from '../document/IDocument.js';
21
- import IShadowRoot from '../shadow-root/IShadowRoot.js';
22
- import NodeList from '../node/NodeList.js';
23
20
  import EventPhaseEnum from '../../event/EventPhaseEnum.js';
24
- import { dateIsoWeek, isoWeekDate } from './HTMLInputDateUtility.js';
21
+ import HTMLInputElementDateUtility from './HTMLInputElementDateUtility.js';
22
+ import HTMLLabelElementUtility from '../html-label-element/HTMLLabelElementUtility.js';
25
23
  import INamedNodeMap from '../../named-node-map/INamedNodeMap.js';
26
24
  import HTMLInputElementNamedNodeMap from './HTMLInputElementNamedNodeMap.js';
27
25
 
@@ -797,7 +795,7 @@ export default class HTMLInputElement extends HTMLElement implements IHTMLInputE
797
795
  case 'month':
798
796
  return isNaN(new Date(String(this.value)).getTime()) ? null : new Date(this.value);
799
797
  case 'week': {
800
- const d = isoWeekDate(this.value);
798
+ const d = HTMLInputElementDateUtility.isoWeekDate(this.value);
801
799
  return isNaN(d.getTime()) ? null : d;
802
800
  }
803
801
  case 'time': {
@@ -845,7 +843,7 @@ export default class HTMLInputElement extends HTMLElement implements IHTMLInputE
845
843
  this.value = value.toISOString().split('T')[1].slice(0, 5);
846
844
  break;
847
845
  case 'week':
848
- this.value = dateIsoWeek(value);
846
+ this.value = HTMLInputElementDateUtility.dateIsoWeek(value);
849
847
  break;
850
848
  }
851
849
  }
@@ -945,7 +943,7 @@ export default class HTMLInputElement extends HTMLElement implements IHTMLInputE
945
943
  case 'week':
946
944
  case 'week': {
947
945
  const d = new Date(Number(value));
948
- this.value = isNaN(d.getTime()) ? '' : dateIsoWeek(d);
946
+ this.value = isNaN(d.getTime()) ? '' : HTMLInputElementDateUtility.dateIsoWeek(d);
949
947
  break;
950
948
  }
951
949
  default:
@@ -962,23 +960,7 @@ export default class HTMLInputElement extends HTMLElement implements IHTMLInputE
962
960
  * @returns Label elements.
963
961
  */
964
962
  public get labels(): INodeList<IHTMLLabelElement> {
965
- const id = this.id;
966
- if (id) {
967
- const rootNode = <IDocument | IShadowRoot>this.getRootNode();
968
- const labels = rootNode.querySelectorAll(`label[for="${id}"]`);
969
-
970
- let parent = this.parentNode;
971
- while (parent) {
972
- if (parent['tagName'] === 'LABEL') {
973
- labels.push(<IHTMLLabelElement>parent);
974
- break;
975
- }
976
- parent = parent.parentNode;
977
- }
978
-
979
- return <INodeList<IHTMLLabelElement>>labels;
980
- }
981
- return new NodeList<IHTMLLabelElement>();
963
+ return HTMLLabelElementUtility.getAssociatedLabelElements(this);
982
964
  }
983
965
 
984
966
  /**
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Date utility for HTML input elements.
3
+ */
4
+ export default class HTMLInputElementDateUtility {
5
+ /**
6
+ * Returns iso week number from given date
7
+ *
8
+ * @param date Date or number.
9
+ * @returns Iso-week string.
10
+ */
11
+ public static dateIsoWeek(date: Date | number): string {
12
+ date = new Date(date);
13
+ const day = (date.getUTCDay() + 6) % 7;
14
+ date.setUTCDate(date.getUTCDate() - day + 3);
15
+ const firstThursday = date.getTime();
16
+ date.setUTCMonth(0, 1);
17
+ if (date.getDay() !== 4) {
18
+ date.setUTCMonth(0, 1 + ((4 - date.getDay() + 7) % 7));
19
+ }
20
+ return (
21
+ date.getUTCFullYear() +
22
+ '-W' +
23
+ String(1 + Math.ceil((firstThursday - date.getTime()) / 604800000)).padStart(2, '0')
24
+ );
25
+ }
26
+ /**
27
+ * Returns a date object for monday of given iso week string (\d\d\d\d-W\d\d)
28
+ *
29
+ * @param isoWeek Iso-week string.
30
+ * @returns Date.
31
+ */
32
+ public static isoWeekDate(isoWeek: string): Date {
33
+ // Algorythm adapted from https://en.wikipedia.org/wiki/ISO_week_date
34
+ const [, Y, W] = isoWeek.match(/^(\d{4})-W(\d{2})$/) || [];
35
+ if (!Y || !W || Number(W) > 53 || Number(W) < 1) {
36
+ return new Date('x'); // Return an invalid date
37
+ }
38
+ const date = new Date(`${Y}-01-01T00:00Z`);
39
+ const jan4th = new Date(`${Y}-01-04T00:00Z`);
40
+ const jan4thDay = (jan4th.getDay() + 6) % 7;
41
+ const ordinalDate = 1 + (Number(W) - 1) * 7 - jan4thDay + 3;
42
+ date.setUTCDate(ordinalDate);
43
+ if (date.getUTCFullYear() > Number(Y)) {
44
+ return new Date('x'); // Return an invalid date
45
+ }
46
+ return date;
47
+ }
48
+ }
@@ -0,0 +1,39 @@
1
+ import IDocument from '../document/IDocument.js';
2
+ import IHTMLElement from '../html-element/IHTMLElement.js';
3
+ import IHTMLLabelElement from './IHTMLLabelElement.js';
4
+ import INodeList from '../node/INodeList.js';
5
+ import NodeList from '../node/NodeList.js';
6
+ import IShadowRoot from '../shadow-root/IShadowRoot.js';
7
+
8
+ /**
9
+ * Utility for finding labels associated with a form element.
10
+ */
11
+ export default class HTMLLabelElementUtility {
12
+ /**
13
+ * Returns label elements for a form element.
14
+ *
15
+ * @param element Element to get labels for.
16
+ * @returns Label elements.
17
+ */
18
+ public static getAssociatedLabelElements(element: IHTMLElement): INodeList<IHTMLLabelElement> {
19
+ const id = element.id;
20
+ let labels: INodeList<IHTMLLabelElement>;
21
+ if (id) {
22
+ const rootNode = <IDocument | IShadowRoot>element.getRootNode();
23
+ labels = <INodeList<IHTMLLabelElement>>rootNode.querySelectorAll(`label[for="${id}"]`);
24
+ } else {
25
+ labels = new NodeList<IHTMLLabelElement>();
26
+ }
27
+
28
+ let parent = element.parentNode;
29
+ while (parent) {
30
+ if (parent['tagName'] === 'LABEL') {
31
+ labels.push(<IHTMLLabelElement>parent);
32
+ break;
33
+ }
34
+ parent = parent.parentNode;
35
+ }
36
+
37
+ return labels;
38
+ }
39
+ }
@@ -14,9 +14,7 @@ import INode from '../node/INode.js';
14
14
  import NodeTypeEnum from '../node/NodeTypeEnum.js';
15
15
  import HTMLFormElement from '../html-form-element/HTMLFormElement.js';
16
16
  import IHTMLCollection from '../element/IHTMLCollection.js';
17
- import NodeList from '../node/NodeList.js';
18
- import IDocument from '../document/IDocument.js';
19
- import IShadowRoot from '../shadow-root/IShadowRoot.js';
17
+ import HTMLLabelElementUtility from '../html-label-element/HTMLLabelElementUtility.js';
20
18
  import INamedNodeMap from '../../named-node-map/INamedNodeMap.js';
21
19
  import HTMLSelectElementNamedNodeMap from './HTMLSelectElementNamedNodeMap.js';
22
20
 
@@ -229,23 +227,7 @@ export default class HTMLSelectElement extends HTMLElement implements IHTMLSelec
229
227
  * @returns Label elements.
230
228
  */
231
229
  public get labels(): INodeList<IHTMLLabelElement> {
232
- const id = this.id;
233
- if (id) {
234
- const rootNode = <IDocument | IShadowRoot>this.getRootNode();
235
- const labels = rootNode.querySelectorAll(`label[for="${id}"]`);
236
-
237
- let parent = this.parentNode;
238
- while (parent) {
239
- if (parent['tagName'] === 'LABEL') {
240
- labels.push(<IHTMLLabelElement>parent);
241
- break;
242
- }
243
- parent = parent.parentNode;
244
- }
245
-
246
- return <INodeList<IHTMLLabelElement>>labels;
247
- }
248
- return new NodeList<IHTMLLabelElement>();
230
+ return HTMLLabelElementUtility.getAssociatedLabelElements(this);
249
231
  }
250
232
 
251
233
  /**
@@ -11,9 +11,7 @@ import ValidityState from '../../validity-state/ValidityState.js';
11
11
  import IHTMLTextAreaElement from './IHTMLTextAreaElement.js';
12
12
  import INodeList from '../node/INodeList.js';
13
13
  import IHTMLLabelElement from '../html-label-element/IHTMLLabelElement.js';
14
- import IDocument from '../document/IDocument.js';
15
- import IShadowRoot from '../shadow-root/IShadowRoot.js';
16
- import NodeList from '../node/NodeList.js';
14
+ import HTMLLabelElementUtility from '../html-label-element/HTMLLabelElementUtility.js';
17
15
  import INamedNodeMap from '../../named-node-map/INamedNodeMap.js';
18
16
  import HTMLTextAreaElementNamedNodeMap from './HTMLTextAreaElementNamedNodeMap.js';
19
17
 
@@ -412,23 +410,7 @@ export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTex
412
410
  * @returns Label elements.
413
411
  */
414
412
  public get labels(): INodeList<IHTMLLabelElement> {
415
- const id = this.id;
416
- if (id) {
417
- const rootNode = <IDocument | IShadowRoot>this.getRootNode();
418
- const labels = rootNode.querySelectorAll(`label[for="${id}"]`);
419
-
420
- let parent = this.parentNode;
421
- while (parent) {
422
- if (parent['tagName'] === 'LABEL') {
423
- labels.push(<IHTMLLabelElement>parent);
424
- break;
425
- }
426
- parent = parent.parentNode;
427
- }
428
-
429
- return <INodeList<IHTMLLabelElement>>labels;
430
- }
431
- return new NodeList<IHTMLLabelElement>();
413
+ return HTMLLabelElementUtility.getAssociatedLabelElements(this);
432
414
  }
433
415
 
434
416
  /**
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isoWeekDate = exports.dateIsoWeek = void 0;
4
- /**
5
- * Return iso-week number from given date
6
- *
7
- * @param date Date|number.
8
- * @returns Iso-week string.
9
- */
10
- const dateIsoWeek = (date) => {
11
- date = new Date(date);
12
- const day = (date.getUTCDay() + 6) % 7;
13
- date.setUTCDate(date.getUTCDate() - day + 3);
14
- const firstThursday = date.getTime();
15
- date.setUTCMonth(0, 1);
16
- if (date.getDay() !== 4) {
17
- date.setUTCMonth(0, 1 + ((4 - date.getDay() + 7) % 7));
18
- }
19
- return (date.getUTCFullYear() +
20
- '-W' +
21
- String(1 + Math.ceil((firstThursday - date.getTime()) / 604800000)).padStart(2, '0'));
22
- };
23
- exports.dateIsoWeek = dateIsoWeek;
24
- /**
25
- * Return a date object for monday of given iso week string (\d\d\d\d-W\d\d)
26
- *
27
- * @param isoWeek Iso-week string.
28
- * @returns Date.
29
- */
30
- const isoWeekDate = (isoWeek) => {
31
- // Algorythm adapted from https://en.wikipedia.org/wiki/ISO_week_date
32
- const [, Y, W] = isoWeek.match(/^(\d{4})-W(\d{2})$/) || [];
33
- if (!Y || !W || Number(W) > 53 || Number(W) < 1) {
34
- return new Date('x'); // Return an invalid date
35
- }
36
- const date = new Date(`${Y}-01-01T00:00Z`);
37
- const jan4th = new Date(`${Y}-01-04T00:00Z`);
38
- const jan4thDay = (jan4th.getDay() + 6) % 7;
39
- const ordinalDate = 1 + (Number(W) - 1) * 7 - jan4thDay + 3;
40
- date.setUTCDate(ordinalDate);
41
- if (date.getUTCFullYear() > Number(Y)) {
42
- return new Date('x'); // Return an invalid date
43
- }
44
- return date;
45
- };
46
- exports.isoWeekDate = isoWeekDate;
47
- //# sourceMappingURL=HTMLInputDateUtility.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HTMLInputDateUtility.cjs","sourceRoot":"","sources":["../../../src/nodes/html-input-element/HTMLInputDateUtility.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACI,MAAM,WAAW,GAAG,CAAC,IAAmB,EAAU,EAAE;IAC1D,IAAI,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;IACtB,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IACvC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC;IAC7C,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;IACrC,IAAI,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACvB,IAAI,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE;QACxB,IAAI,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAA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,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,yBAAyB;KAC/C;IACD,OAAO,IAAI,CAAC;AACb,CAAC,CAAC;AAfW,QAAA,WAAW,eAetB"}
@@ -1,15 +0,0 @@
1
- /**
2
- * Return iso-week number from given date
3
- *
4
- * @param date Date|number.
5
- * @returns Iso-week string.
6
- */
7
- export declare const dateIsoWeek: (date: Date | number) => string;
8
- /**
9
- * Return a date object for monday of given iso week string (\d\d\d\d-W\d\d)
10
- *
11
- * @param isoWeek Iso-week string.
12
- * @returns Date.
13
- */
14
- export declare const isoWeekDate: (isoWeek: string) => Date;
15
- //# sourceMappingURL=HTMLInputDateUtility.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HTMLInputDateUtility.d.ts","sourceRoot":"","sources":["../../../src/nodes/html-input-element/HTMLInputDateUtility.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,WAAW,SAAU,IAAI,GAAG,MAAM,KAAG,MAcjD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,YAAa,MAAM,KAAG,IAe7C,CAAC"}
@@ -1,15 +0,0 @@
1
- /**
2
- * Return iso-week number from given date
3
- *
4
- * @param date Date|number.
5
- * @returns Iso-week string.
6
- */
7
- export declare const dateIsoWeek: (date: Date | number) => string;
8
- /**
9
- * Return a date object for monday of given iso week string (\d\d\d\d-W\d\d)
10
- *
11
- * @param isoWeek Iso-week string.
12
- * @returns Date.
13
- */
14
- export declare const isoWeekDate: (isoWeek: string) => Date;
15
- //# sourceMappingURL=HTMLInputDateUtility.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HTMLInputDateUtility.d.ts","sourceRoot":"","sources":["../../../src/nodes/html-input-element/HTMLInputDateUtility.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,WAAW,SAAU,IAAI,GAAG,MAAM,KAAG,MAcjD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,YAAa,MAAM,KAAG,IAe7C,CAAC"}
@@ -1,42 +0,0 @@
1
- /**
2
- * Return iso-week number from given date
3
- *
4
- * @param date Date|number.
5
- * @returns Iso-week string.
6
- */
7
- export const dateIsoWeek = (date) => {
8
- date = new Date(date);
9
- const day = (date.getUTCDay() + 6) % 7;
10
- date.setUTCDate(date.getUTCDate() - day + 3);
11
- const firstThursday = date.getTime();
12
- date.setUTCMonth(0, 1);
13
- if (date.getDay() !== 4) {
14
- date.setUTCMonth(0, 1 + ((4 - date.getDay() + 7) % 7));
15
- }
16
- return (date.getUTCFullYear() +
17
- '-W' +
18
- String(1 + Math.ceil((firstThursday - date.getTime()) / 604800000)).padStart(2, '0'));
19
- };
20
- /**
21
- * Return a date object for monday of given iso week string (\d\d\d\d-W\d\d)
22
- *
23
- * @param isoWeek Iso-week string.
24
- * @returns Date.
25
- */
26
- export const isoWeekDate = (isoWeek) => {
27
- // Algorythm adapted from https://en.wikipedia.org/wiki/ISO_week_date
28
- const [, Y, W] = isoWeek.match(/^(\d{4})-W(\d{2})$/) || [];
29
- if (!Y || !W || Number(W) > 53 || Number(W) < 1) {
30
- return new Date('x'); // Return an invalid date
31
- }
32
- const date = new Date(`${Y}-01-01T00:00Z`);
33
- const jan4th = new Date(`${Y}-01-04T00:00Z`);
34
- const jan4thDay = (jan4th.getDay() + 6) % 7;
35
- const ordinalDate = 1 + (Number(W) - 1) * 7 - jan4thDay + 3;
36
- date.setUTCDate(ordinalDate);
37
- if (date.getUTCFullYear() > Number(Y)) {
38
- return new Date('x'); // Return an invalid date
39
- }
40
- return date;
41
- };
42
- //# sourceMappingURL=HTMLInputDateUtility.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HTMLInputDateUtility.js","sourceRoot":"","sources":["../../../src/nodes/html-input-element/HTMLInputDateUtility.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAmB,EAAU,EAAE;IAC1D,IAAI,GA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AAI,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC3C,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC7C,MAAM,SAAS,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IAC5C,MAAM,WAAW,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,GAAG,CAAC,CAAC;IAC5D,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAC7B,IAAI,IAAI,CAAC,cAAc,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE;QACtC,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,yBAAyB;KAC/C;IACD,OAAO,IAAI,CAAC;AACb,CAAC,CAAC"}
@@ -1,44 +0,0 @@
1
- /**
2
- * Return iso-week number from given date
3
- *
4
- * @param date Date|number.
5
- * @returns Iso-week string.
6
- */
7
- export const dateIsoWeek = (date: Date | number): string => {
8
- date = new Date(date);
9
- const day = (date.getUTCDay() + 6) % 7;
10
- date.setUTCDate(date.getUTCDate() - day + 3);
11
- const firstThursday = date.getTime();
12
- date.setUTCMonth(0, 1);
13
- if (date.getDay() !== 4) {
14
- date.setUTCMonth(0, 1 + ((4 - date.getDay() + 7) % 7));
15
- }
16
- return (
17
- date.getUTCFullYear() +
18
- '-W' +
19
- String(1 + Math.ceil((firstThursday - date.getTime()) / 604800000)).padStart(2, '0')
20
- );
21
- };
22
-
23
- /**
24
- * Return a date object for monday of given iso week string (\d\d\d\d-W\d\d)
25
- *
26
- * @param isoWeek Iso-week string.
27
- * @returns Date.
28
- */
29
- export const isoWeekDate = (isoWeek: string): Date => {
30
- // Algorythm adapted from https://en.wikipedia.org/wiki/ISO_week_date
31
- const [, Y, W] = isoWeek.match(/^(\d{4})-W(\d{2})$/) || [];
32
- if (!Y || !W || Number(W) > 53 || Number(W) < 1) {
33
- return new Date('x'); // Return an invalid date
34
- }
35
- const date = new Date(`${Y}-01-01T00:00Z`);
36
- const jan4th = new Date(`${Y}-01-04T00:00Z`);
37
- const jan4thDay = (jan4th.getDay() + 6) % 7;
38
- const ordinalDate = 1 + (Number(W) - 1) * 7 - jan4thDay + 3;
39
- date.setUTCDate(ordinalDate);
40
- if (date.getUTCFullYear() > Number(Y)) {
41
- return new Date('x'); // Return an invalid date
42
- }
43
- return date;
44
- };