@transferwise/components 0.0.0-experimental-cbb427b → 0.0.0-experimental-53fa20a

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 (86) hide show
  1. package/build/index.esm.js +94 -133
  2. package/build/index.esm.js.map +1 -1
  3. package/build/index.js +94 -133
  4. package/build/index.js.map +1 -1
  5. package/build/types/common/dateUtils/getDayNames/getDayNames.d.ts +1 -1
  6. package/build/types/common/dateUtils/getDayNames/getDayNames.d.ts.map +1 -1
  7. package/build/types/common/dateUtils/getDayNames/index.d.ts +1 -1
  8. package/build/types/common/dateUtils/getDayNames/index.d.ts.map +1 -1
  9. package/build/types/common/dateUtils/getMonthNames/getMonthNames.d.ts +1 -1
  10. package/build/types/common/dateUtils/getMonthNames/getMonthNames.d.ts.map +1 -1
  11. package/build/types/common/dateUtils/getMonthNames/index.d.ts +1 -1
  12. package/build/types/common/dateUtils/getMonthNames/index.d.ts.map +1 -1
  13. package/build/types/common/dateUtils/index.d.ts +6 -6
  14. package/build/types/common/dateUtils/index.d.ts.map +1 -1
  15. package/build/types/common/dateUtils/isDateValid/index.d.ts +1 -1
  16. package/build/types/common/dateUtils/isDateValid/index.d.ts.map +1 -1
  17. package/build/types/common/dateUtils/isDateValid/isDateValid.d.ts +2 -2
  18. package/build/types/common/dateUtils/isDateValid/isDateValid.d.ts.map +1 -1
  19. package/build/types/common/dateUtils/isMonthAndYearFormat/index.d.ts +1 -1
  20. package/build/types/common/dateUtils/isMonthAndYearFormat/index.d.ts.map +1 -1
  21. package/build/types/common/dateUtils/isMonthAndYearFormat/isMonthAndYearFormat.d.ts +1 -1
  22. package/build/types/common/dateUtils/isMonthAndYearFormat/isMonthAndYearFormat.d.ts.map +1 -1
  23. package/build/types/common/dateUtils/isWithinRange/index.d.ts +1 -1
  24. package/build/types/common/dateUtils/isWithinRange/index.d.ts.map +1 -1
  25. package/build/types/common/dateUtils/isWithinRange/isWithinRange.d.ts +1 -1
  26. package/build/types/common/dateUtils/isWithinRange/isWithinRange.d.ts.map +1 -1
  27. package/build/types/common/dateUtils/moveToWithinRange/index.d.ts +1 -1
  28. package/build/types/common/dateUtils/moveToWithinRange/index.d.ts.map +1 -1
  29. package/build/types/common/dateUtils/moveToWithinRange/moveToWithinRange.d.ts +1 -1
  30. package/build/types/common/dateUtils/moveToWithinRange/moveToWithinRange.d.ts.map +1 -1
  31. package/build/types/dateInput/DateInput.d.ts +30 -41
  32. package/build/types/dateInput/DateInput.d.ts.map +1 -1
  33. package/build/types/dateInput/DateInput.messages.d.ts +24 -33
  34. package/build/types/dateInput/DateInput.messages.d.ts.map +1 -1
  35. package/build/types/dateInput/index.d.ts +1 -1
  36. package/build/types/dateInput/index.d.ts.map +1 -1
  37. package/build/types/dateInput/utils/convertToLocalMidnight/convertToLocalMidnight.d.ts +1 -1
  38. package/build/types/dateInput/utils/convertToLocalMidnight/convertToLocalMidnight.d.ts.map +1 -1
  39. package/build/types/dateInput/utils/convertToLocalMidnight/index.d.ts +1 -1
  40. package/build/types/dateInput/utils/convertToLocalMidnight/index.d.ts.map +1 -1
  41. package/build/types/dateInput/utils/index.d.ts +1 -2
  42. package/build/types/dateInput/utils/index.d.ts.map +1 -1
  43. package/build/types/drawer/Drawer.d.ts.map +1 -1
  44. package/build/types/modal/Modal.d.ts.map +1 -1
  45. package/package.json +1 -1
  46. package/src/common/dateUtils/getDayNames/getDayNames.spec.js +2 -2
  47. package/src/common/dateUtils/getDayNames/{getDayNames.js → getDayNames.ts} +5 -2
  48. package/src/common/dateUtils/getMonthNames/getMonthNames.spec.js +9 -8
  49. package/src/common/dateUtils/getMonthNames/{getMonthNames.js → getMonthNames.ts} +5 -3
  50. package/src/common/dateUtils/isDateValid/{isDateValid.spec.js → isDateValid.spec.ts} +1 -1
  51. package/src/common/dateUtils/isDateValid/isDateValid.ts +13 -0
  52. package/src/common/dateUtils/isMonthAndYearFormat/isMonthAndYearFormat.spec.js +3 -7
  53. package/src/common/dateUtils/isMonthAndYearFormat/{isMonthAndYearFormat.js → isMonthAndYearFormat.ts} +1 -1
  54. package/src/common/dateUtils/isWithinRange/{isWithinRange.spec.js → isWithinRange.spec.ts} +0 -10
  55. package/src/common/dateUtils/isWithinRange/{isWithinRange.js → isWithinRange.ts} +1 -1
  56. package/src/common/dateUtils/moveToWithinRange/{moveToWithinRange.js → moveToWithinRange.ts} +2 -2
  57. package/src/dateInput/DateInput.spec.js +7 -56
  58. package/src/dateInput/DateInput.story.tsx +11 -8
  59. package/src/dateInput/{DateInput.js → DateInput.tsx} +113 -121
  60. package/src/dateInput/utils/convertToLocalMidnight/{convertToLocalMidnight.js → convertToLocalMidnight.ts} +1 -1
  61. package/src/dateInput/utils/{index.js → index.ts} +0 -1
  62. package/src/dateLookup/dayCalendar/table/DayCalendarTable.js +1 -0
  63. package/src/drawer/Drawer.js +13 -2
  64. package/src/drawer/__snapshots__/Drawer.rtl.spec.js.snap +1 -0
  65. package/src/modal/Modal.tsx +6 -3
  66. package/src/popover/Popover.spec.js +16 -8
  67. package/src/popover/__snapshots__/Popover.spec.js.snap +0 -56
  68. package/build/types/dateInput/utils/explodeDate/explodeDate.d.ts +0 -6
  69. package/build/types/dateInput/utils/explodeDate/explodeDate.d.ts.map +0 -1
  70. package/build/types/dateInput/utils/explodeDate/index.d.ts +0 -2
  71. package/build/types/dateInput/utils/explodeDate/index.d.ts.map +0 -1
  72. package/src/common/dateUtils/isDateValid/isDateValid.js +0 -6
  73. package/src/dateInput/utils/explodeDate/explodeDate.js +0 -7
  74. package/src/dateInput/utils/explodeDate/explodeDate.spec.js +0 -11
  75. package/src/dateInput/utils/explodeDate/index.js +0 -1
  76. /package/src/common/dateUtils/getDayNames/{index.js → index.ts} +0 -0
  77. /package/src/common/dateUtils/getMonthNames/{index.js → index.ts} +0 -0
  78. /package/src/common/dateUtils/{index.js → index.ts} +0 -0
  79. /package/src/common/dateUtils/isDateValid/{index.js → index.ts} +0 -0
  80. /package/src/common/dateUtils/isMonthAndYearFormat/{index.js → index.ts} +0 -0
  81. /package/src/common/dateUtils/isWithinRange/{index.js → index.ts} +0 -0
  82. /package/src/common/dateUtils/moveToWithinRange/{index.js → index.ts} +0 -0
  83. /package/src/dateInput/{DateInput.messages.js → DateInput.messages.ts} +0 -0
  84. /package/src/dateInput/{index.js → index.ts} +0 -0
  85. /package/src/dateInput/utils/convertToLocalMidnight/{convertToLocalMidnight.spec.js → convertToLocalMidnight.spec.ts} +0 -0
  86. /package/src/dateInput/utils/convertToLocalMidnight/{index.js → index.ts} +0 -0
@@ -1,2 +1,2 @@
1
- export function getDayNames(locale: any, format?: string): string[];
1
+ export declare function getDayNames(locale: string, format?: Intl.DateTimeFormatOptions['weekday']): string[];
2
2
  //# sourceMappingURL=getDayNames.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getDayNames.d.ts","sourceRoot":"","sources":["../../../../../src/common/dateUtils/getDayNames/getDayNames.js"],"names":[],"mappings":"AAEA,oEAQC"}
1
+ {"version":3,"file":"getDayNames.d.ts","sourceRoot":"","sources":["../../../../../src/common/dateUtils/getDayNames/getDayNames.ts"],"names":[],"mappings":"AAEA,wBAAgB,WAAW,CACzB,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,IAAI,CAAC,qBAAqB,CAAC,SAAS,CAAW,YASxD"}
@@ -1,2 +1,2 @@
1
- export { getDayNames } from "./getDayNames";
1
+ export { getDayNames } from './getDayNames';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/common/dateUtils/getDayNames/index.js"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/common/dateUtils/getDayNames/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
@@ -1,2 +1,2 @@
1
- export function getMonthNames(locale: any, format?: string): string[];
1
+ export declare const getMonthNames: (locale: string, format?: Intl.DateTimeFormatOptions['month']) => string[];
2
2
  //# sourceMappingURL=getMonthNames.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getMonthNames.d.ts","sourceRoot":"","sources":["../../../../../src/common/dateUtils/getMonthNames/getMonthNames.js"],"names":[],"mappings":"AAEO,sEAUN"}
1
+ {"version":3,"file":"getMonthNames.d.ts","sourceRoot":"","sources":["../../../../../src/common/dateUtils/getMonthNames/getMonthNames.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,WAChB,MAAM,WACN,KAAK,qBAAqB,CAAC,OAAO,CAAC,KAC1C,MAAM,EASR,CAAC"}
@@ -1,2 +1,2 @@
1
- export { getMonthNames } from "./getMonthNames";
1
+ export { getMonthNames } from './getMonthNames';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/common/dateUtils/getMonthNames/index.js"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/common/dateUtils/getMonthNames/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
@@ -1,7 +1,7 @@
1
- export { getDayNames } from "./getDayNames";
2
- export { moveToWithinRange } from "./moveToWithinRange";
3
- export { isWithinRange } from "./isWithinRange";
4
- export { getMonthNames } from "./getMonthNames";
5
- export { isDateValid } from "./isDateValid";
6
- export { isMonthAndYearFormat } from "./isMonthAndYearFormat";
1
+ export { getDayNames } from './getDayNames';
2
+ export { moveToWithinRange } from './moveToWithinRange';
3
+ export { isWithinRange } from './isWithinRange';
4
+ export { getMonthNames } from './getMonthNames';
5
+ export { isDateValid } from './isDateValid';
6
+ export { isMonthAndYearFormat } from './isMonthAndYearFormat';
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/common/dateUtils/index.js"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/common/dateUtils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
@@ -1,2 +1,2 @@
1
- export { isDateValid, validDateString } from "./isDateValid";
1
+ export { isDateValid, validDateString } from './isDateValid';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/common/dateUtils/isDateValid/index.js"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/common/dateUtils/isDateValid/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
@@ -1,3 +1,3 @@
1
- export function isDateValid(date: any): boolean;
2
- export function validDateString(dateString: any): boolean;
1
+ export declare const isDateValid: (date: Date | string | null) => boolean;
2
+ export declare const validDateString: (dateString: string) => boolean;
3
3
  //# sourceMappingURL=isDateValid.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"isDateValid.d.ts","sourceRoot":"","sources":["../../../../../src/common/dateUtils/isDateValid/isDateValid.js"],"names":[],"mappings":"AAAO,gDAA4E;AAE5E,0DACkE"}
1
+ {"version":3,"file":"isDateValid.d.ts","sourceRoot":"","sources":["../../../../../src/common/dateUtils/isDateValid/isDateValid.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,SAAU,IAAI,GAAG,MAAM,GAAG,IAAI,YAQrD,CAAC;AAEF,eAAO,MAAM,eAAe,eAAgB,MAAM,YAA0C,CAAC"}
@@ -1,2 +1,2 @@
1
- export { isMonthAndYearFormat } from "./isMonthAndYearFormat";
1
+ export { isMonthAndYearFormat } from './isMonthAndYearFormat';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/common/dateUtils/isMonthAndYearFormat/index.js"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/common/dateUtils/isMonthAndYearFormat/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
@@ -1,2 +1,2 @@
1
- export function isMonthAndYearFormat(dateString: any): boolean;
1
+ export declare const isMonthAndYearFormat: (dateString: string) => boolean;
2
2
  //# sourceMappingURL=isMonthAndYearFormat.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"isMonthAndYearFormat.d.ts","sourceRoot":"","sources":["../../../../../src/common/dateUtils/isMonthAndYearFormat/isMonthAndYearFormat.js"],"names":[],"mappings":"AAEO,+DAC0D"}
1
+ {"version":3,"file":"isMonthAndYearFormat.d.ts","sourceRoot":"","sources":["../../../../../src/common/dateUtils/isMonthAndYearFormat/isMonthAndYearFormat.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,oBAAoB,eAAgB,MAAM,YACU,CAAC"}
@@ -1,2 +1,2 @@
1
- export { isWithinRange } from "./isWithinRange";
1
+ export { isWithinRange } from './isWithinRange';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/common/dateUtils/isWithinRange/index.js"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/common/dateUtils/isWithinRange/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
@@ -1,2 +1,2 @@
1
- export function isWithinRange(date: any, min: any, max: any): boolean;
1
+ export declare function isWithinRange(date: Date, min: Date, max: Date): boolean;
2
2
  //# sourceMappingURL=isWithinRange.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"isWithinRange.d.ts","sourceRoot":"","sources":["../../../../../src/common/dateUtils/isWithinRange/isWithinRange.js"],"names":[],"mappings":"AAAA,sEAEC"}
1
+ {"version":3,"file":"isWithinRange.d.ts","sourceRoot":"","sources":["../../../../../src/common/dateUtils/isWithinRange/isWithinRange.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,WAE7D"}
@@ -1,2 +1,2 @@
1
- export { moveToWithinRange } from "./moveToWithinRange";
1
+ export { moveToWithinRange } from './moveToWithinRange';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/common/dateUtils/moveToWithinRange/index.js"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/common/dateUtils/moveToWithinRange/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -1,2 +1,2 @@
1
- export function moveToWithinRange(date: any, min: any, max: any): any;
1
+ export declare function moveToWithinRange(date: Date, min: Date, max: Date): Date;
2
2
  //# sourceMappingURL=moveToWithinRange.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"moveToWithinRange.d.ts","sourceRoot":"","sources":["../../../../../src/common/dateUtils/moveToWithinRange/moveToWithinRange.js"],"names":[],"mappings":"AAGA,sEAEC"}
1
+ {"version":3,"file":"moveToWithinRange.d.ts","sourceRoot":"","sources":["../../../../../src/common/dateUtils/moveToWithinRange/moveToWithinRange.ts"],"names":[],"mappings":"AAGA,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,QAEjE"}
@@ -1,41 +1,30 @@
1
- import * as React from 'react';
2
-
3
- export type DateInputSize = "sm" | "md" | "lg";
4
-
5
- export type DateInputValue = string | Date;
6
-
7
- export type DateInputMonthFormat = "long" | "short";
8
-
9
- export type DateInputMode = "day-month-year" | "month-year";
10
-
11
- export interface DateInputPlaceholders {
12
- day?: React.ReactNode;
13
- month?: React.ReactNode;
14
- year?: React.ReactNode;
15
- }
16
-
17
- export interface DateInputProps {
18
- "aria-label"?: string;
19
- "aria-labelledby"?: string;
20
- disabled?: boolean;
21
- size?: DateInputSize;
22
- value?: DateInputValue;
23
- onChange: (...args: any[])=>any;
24
- onFocus?: (...args: any[])=>any;
25
- onBlur?: (...args: any[])=>any;
26
- dayLabel?: string;
27
- dayAutoComplete?: string;
28
- monthLabel?: string;
29
- yearLabel?: string;
30
- yearAutoComplete?: string;
31
- monthFormat?: DateInputMonthFormat;
32
- mode?: DateInputMode;
33
- placeholders?: DateInputPlaceholders;
34
- id?: string;
35
- selectProps?: Object;
36
- }
37
-
38
- declare const DateInput: React.FC<DateInputProps>;
39
-
40
- export default DateInput;
41
-
1
+ /// <reference types="react" />
2
+ import { SelectInputProps } from '..';
3
+ import { Size, DateMode, MonthFormat } from '../common';
4
+ export interface DateInputProps {
5
+ 'aria-label'?: string;
6
+ 'aria-labelledby'?: string;
7
+ disabled?: boolean;
8
+ size?: Size.SMALL | Size.MEDIUM | Size.LARGE;
9
+ value?: Date | string;
10
+ onChange: (value: string | null) => void;
11
+ onFocus?: React.FocusEventHandler<HTMLInputElement>;
12
+ onBlur?: React.FocusEventHandler<HTMLInputElement>;
13
+ dayLabel?: string;
14
+ dayAutoComplete?: string;
15
+ monthLabel?: string;
16
+ yearLabel?: string;
17
+ yearAutoComplete?: string;
18
+ monthFormat?: `${MonthFormat}`;
19
+ mode?: `${DateMode}`;
20
+ placeholders?: {
21
+ day?: string;
22
+ month?: string;
23
+ year?: string;
24
+ };
25
+ id?: string;
26
+ selectProps?: Partial<SelectInputProps<number | null>>;
27
+ }
28
+ declare const DateInput: ({ "aria-labelledby": ariaLabelledBy, "aria-label": ariaLabel, disabled, size, value, dayLabel, dayAutoComplete, monthLabel, yearLabel, yearAutoComplete, monthFormat, mode, onChange, onFocus, onBlur, placeholders, id, selectProps, }: DateInputProps) => import("react").JSX.Element;
29
+ export default DateInput;
30
+ //# sourceMappingURL=DateInput.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DateInput.d.ts","sourceRoot":"","sources":["../../../src/dateInput/DateInput.js"],"names":[],"mappings":";AAeA;;;;;;;;;;;;;;;;;;;gCA0QC"}
1
+ {"version":3,"file":"DateInput.d.ts","sourceRoot":"","sources":["../../../src/dateInput/DateInput.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAsB,gBAAgB,EAA4B,MAAM,IAAI,CAAC;AACpF,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAQxD,MAAM,WAAW,cAAc;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC;IAC7C,KAAK,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IACtB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACzC,OAAO,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IACpD,MAAM,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,GAAG,WAAW,EAAE,CAAC;IAC/B,IAAI,CAAC,EAAE,GAAG,QAAQ,EAAE,CAAC;IACrB,YAAY,CAAC,EAAE;QACb,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;IACF,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;CACxD;AAED,QAAA,MAAM,SAAS,4OAmBZ,cAAc,gCAuPhB,CAAC;AA8BF,eAAe,SAAS,CAAC"}
@@ -1,35 +1,26 @@
1
- declare namespace _default {
2
- namespace monthLabel {
3
- const id: string;
4
- const defaultMessage: string;
5
- }
6
- namespace dayLabel {
7
- const id_1: string;
8
- export { id_1 as id };
9
- const defaultMessage_1: string;
10
- export { defaultMessage_1 as defaultMessage };
11
- }
12
- namespace yearLabel {
13
- const id_2: string;
14
- export { id_2 as id };
15
- const defaultMessage_2: string;
16
- export { defaultMessage_2 as defaultMessage };
17
- }
18
- namespace dayPlaceholder {
19
- const id_3: string;
20
- export { id_3 as id };
21
- const defaultMessage_3: string;
22
- export { defaultMessage_3 as defaultMessage };
23
- export const description: string;
24
- }
25
- namespace yearPlaceholder {
26
- const id_4: string;
27
- export { id_4 as id };
28
- const defaultMessage_4: string;
29
- export { defaultMessage_4 as defaultMessage };
30
- const description_1: string;
31
- export { description_1 as description };
32
- }
33
- }
1
+ declare const _default: {
2
+ monthLabel: {
3
+ id: string;
4
+ defaultMessage: string;
5
+ };
6
+ dayLabel: {
7
+ id: string;
8
+ defaultMessage: string;
9
+ };
10
+ yearLabel: {
11
+ id: string;
12
+ defaultMessage: string;
13
+ };
14
+ dayPlaceholder: {
15
+ id: string;
16
+ defaultMessage: string;
17
+ description: string;
18
+ };
19
+ yearPlaceholder: {
20
+ id: string;
21
+ defaultMessage: string;
22
+ description: string;
23
+ };
24
+ };
34
25
  export default _default;
35
26
  //# sourceMappingURL=DateInput.messages.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DateInput.messages.d.ts","sourceRoot":"","sources":["../../../src/dateInput/DateInput.messages.js"],"names":[],"mappings":""}
1
+ {"version":3,"file":"DateInput.messages.d.ts","sourceRoot":"","sources":["../../../src/dateInput/DateInput.messages.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAEA,wBAuBG"}
@@ -1,3 +1,3 @@
1
+ import DateInput from './DateInput';
1
2
  export default DateInput;
2
- import DateInput from "./DateInput";
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dateInput/index.js"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dateInput/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,eAAe,SAAS,CAAC"}
@@ -1,2 +1,2 @@
1
- export function convertToLocalMidnight(date: any): Date;
1
+ export declare const convertToLocalMidnight: (date: string) => Date;
2
2
  //# sourceMappingURL=convertToLocalMidnight.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"convertToLocalMidnight.d.ts","sourceRoot":"","sources":["../../../../../src/dateInput/utils/convertToLocalMidnight/convertToLocalMidnight.js"],"names":[],"mappings":"AAAO,wDAIN"}
1
+ {"version":3,"file":"convertToLocalMidnight.d.ts","sourceRoot":"","sources":["../../../../../src/dateInput/utils/convertToLocalMidnight/convertToLocalMidnight.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,SAAU,MAAM,SAIlD,CAAC"}
@@ -1,2 +1,2 @@
1
- export { convertToLocalMidnight } from "./convertToLocalMidnight";
1
+ export { convertToLocalMidnight } from './convertToLocalMidnight';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/dateInput/utils/convertToLocalMidnight/index.js"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/dateInput/utils/convertToLocalMidnight/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC"}
@@ -1,3 +1,2 @@
1
- export { explodeDate } from "./explodeDate";
2
- export { convertToLocalMidnight } from "./convertToLocalMidnight";
1
+ export { convertToLocalMidnight } from './convertToLocalMidnight';
3
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/dateInput/utils/index.js"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/dateInput/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../../../src/drawer/Drawer.js"],"names":[],"mappings":";AAWA;;;;;;;;gCA0BC"}
1
+ {"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../../../src/drawer/Drawer.js"],"names":[],"mappings":";AAYA;;;;;;;;gCAoCC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../src/modal/Modal.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAU,MAAM,OAAO,CAAC;AAG1C,OAAO,EAGL,WAAW,EACX,cAAc,EAEd,WAAW,EACX,SAAS,EACT,UAAU,EACV,SAAS,EACT,cAAc,EACd,aAAa,EACb,cAAc,EAEf,MAAM,WAAW,CAAC;AASnB,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG;IACrC,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,IAAI,CAAC,EAAE,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,cAAc,CAAC;IAC3D,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,aAAa,GAAG,cAAc,CAAC;IACxC,QAAQ,CAAC,EAAE,WAAW,GAAG,cAAc,CAAC;IACxC,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC,CAAC;AAEF,QAAA,MAAM,KAAK,wHAYR,UAAU,gCAiHZ,CAAC;AAEF,eAAe,KAAK,CAAC"}
1
+ {"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../src/modal/Modal.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAU,MAAM,OAAO,CAAC;AAG1C,OAAO,EAGL,WAAW,EACX,cAAc,EAEd,WAAW,EACX,SAAS,EACT,UAAU,EACV,SAAS,EACT,cAAc,EACd,aAAa,EACb,cAAc,EAEf,MAAM,WAAW,CAAC;AASnB,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG;IACrC,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,IAAI,CAAC,EAAE,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,cAAc,CAAC;IAC3D,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,aAAa,GAAG,cAAc,CAAC;IACxC,QAAQ,CAAC,EAAE,WAAW,GAAG,cAAc,CAAC;IACxC,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC,CAAC;AAEF,QAAA,MAAM,KAAK,wHAYR,UAAU,gCAmHZ,CAAC;AAEF,eAAe,KAAK,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transferwise/components",
3
- "version": "0.0.0-experimental-cbb427b",
3
+ "version": "0.0.0-experimental-53fa20a",
4
4
  "description": "Neptune React components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -6,11 +6,11 @@ jest.mock('@transferwise/formatting', () => ({
6
6
 
7
7
  describe('getDayNames', () => {
8
8
  it('returns all weekdays', () => {
9
- expect(getDayNames()).toHaveLength(7);
9
+ expect(getDayNames('en')).toHaveLength(7);
10
10
  });
11
11
 
12
12
  it('starts with Monday and ends with Sunday', () => {
13
- const days = getDayNames();
13
+ const days = getDayNames('en');
14
14
  expect(days[0]).toBe(1);
15
15
  expect(days[days.length - 1]).toBe(0);
16
16
  });
@@ -1,7 +1,10 @@
1
1
  import { formatDate } from '@transferwise/formatting';
2
2
 
3
- export function getDayNames(locale, format = 'short') {
4
- const days = [];
3
+ export function getDayNames(
4
+ locale: string,
5
+ format: Intl.DateTimeFormatOptions['weekday'] = 'short',
6
+ ) {
7
+ const days: string[] = [];
5
8
  const date = new Date(2018, 0, 1); // 2018 started with Monday
6
9
  while (days.length < 7) {
7
10
  days.push(formatDate(date, locale, { weekday: format }));
@@ -1,8 +1,4 @@
1
- import { getMonthNames } from '..';
2
-
3
- jest.mock('@transferwise/formatting', () => ({
4
- formatDate: (month) => month.getMonth(),
5
- }));
1
+ import { getMonthNames } from './getMonthNames';
6
2
 
7
3
  describe('getMonthNames', () => {
8
4
  it('returns all months', () => {
@@ -10,8 +6,13 @@ describe('getMonthNames', () => {
10
6
  });
11
7
 
12
8
  it('starts with January and ends with December', () => {
13
- const months = getMonthNames();
14
- expect(months[0]).toBe(0);
15
- expect(months[months.length - 1]).toBe(11);
9
+ const months = getMonthNames('en', 'long');
10
+ expect(months[0]).toBe('January');
11
+ expect(months.at(-1)).toBe('December');
12
+ });
13
+
14
+ it('gets localized month names', () => {
15
+ const months = getMonthNames('fr', 'long');
16
+ expect(months[0]).toBe('janvier');
16
17
  });
17
18
  });
@@ -1,13 +1,15 @@
1
1
  import { formatDate } from '@transferwise/formatting';
2
2
 
3
- export const getMonthNames = (locale, format = 'long') => {
4
- const months = [];
3
+ export const getMonthNames = (
4
+ locale: string,
5
+ format: Intl.DateTimeFormatOptions['month'] = 'long',
6
+ ): string[] => {
7
+ const months: string[] = [];
5
8
  const date = new Date(2018, 0, 1);
6
9
  const monthFormat = { month: format };
7
10
  while (months.length < 12) {
8
11
  months.push(formatDate(date, locale, monthFormat));
9
12
  date.setMonth(date.getMonth() + 1);
10
13
  }
11
-
12
14
  return months;
13
15
  };
@@ -1,4 +1,4 @@
1
- import { isDateValid } from '.';
1
+ import { isDateValid } from '..';
2
2
 
3
3
  describe('isDateValid', () => {
4
4
  it('should return false for invalid format', () => {
@@ -0,0 +1,13 @@
1
+ export const isDateValid = (date: Date | string | null) => {
2
+ if (date === null) {
3
+ return false;
4
+ } else if (date instanceof Date) {
5
+ return validDateObject(date);
6
+ } else {
7
+ return validDateString(date);
8
+ }
9
+ };
10
+
11
+ export const validDateString = (dateString: string) => validDateObject(new Date(dateString));
12
+
13
+ const validDateObject = (dateObject: Date) => !isNaN(dateObject.getTime());
@@ -1,15 +1,11 @@
1
- import { isMonthAndYearFormat } from '.';
1
+ import { isMonthAndYearFormat } from '..';
2
2
 
3
3
  describe('isDateValid', () => {
4
- it('should return false if day is provided', () => {
4
+ it('should return false if day is provided as string', () => {
5
5
  expect(isMonthAndYearFormat('1998-02-04')).toBe(false);
6
6
  });
7
7
 
8
- it('should return true if day is not provided', () => {
8
+ it('should return true if day is not provided as string', () => {
9
9
  expect(isMonthAndYearFormat('1998-02')).toBe(true);
10
10
  });
11
-
12
- it('should return false if argument provided is not a string', () => {
13
- expect(isMonthAndYearFormat([])).toBe(false);
14
- });
15
11
  });
@@ -1,4 +1,4 @@
1
1
  import { validDateString } from '../isDateValid';
2
2
 
3
- export const isMonthAndYearFormat = (dateString) =>
3
+ export const isMonthAndYearFormat = (dateString: string) =>
4
4
  validDateString(dateString) && dateString.split('-').length < 3;
@@ -1,14 +1,6 @@
1
1
  import { isWithinRange } from '..';
2
2
 
3
3
  describe('isWithinRange', () => {
4
- it('returns true when no dates are provided', () => {
5
- expect(isWithinRange()).toBe(true);
6
- });
7
-
8
- it('returns true when no min and max', () => {
9
- expect(isWithinRange(new Date())).toBe(true);
10
- });
11
-
12
4
  it('returns true when date is between min and max', () => {
13
5
  const date = new Date('1995-12-20');
14
6
  const min = new Date('1995-12-19');
@@ -27,7 +19,6 @@ describe('isWithinRange', () => {
27
19
  const date = new Date('1995-12-20');
28
20
  const min = new Date('1995-12-21');
29
21
  const max = new Date('1995-12-22');
30
- expect(isWithinRange(date, min)).toBe(false);
31
22
  expect(isWithinRange(date, min, max)).toBe(false);
32
23
  });
33
24
 
@@ -35,7 +26,6 @@ describe('isWithinRange', () => {
35
26
  const date = new Date('1995-12-23');
36
27
  const min = new Date('1995-12-20');
37
28
  const max = new Date('1995-12-22');
38
- expect(isWithinRange(date, null, max)).toBe(false);
39
29
  expect(isWithinRange(date, min, max)).toBe(false);
40
30
  });
41
31
  });
@@ -1,3 +1,3 @@
1
- export function isWithinRange(date, min, max) {
1
+ export function isWithinRange(date: Date, min: Date, max: Date) {
2
2
  return !date || ((!min || date >= min) && (!max || date <= max));
3
3
  }
@@ -1,6 +1,6 @@
1
- import { isWithinRange } from '../isWithinRange';
1
+ import { isWithinRange } from '..';
2
2
 
3
3
  // Makes sure that date is between min and max dates, returns a cloned min or max
4
- export function moveToWithinRange(date, min, max) {
4
+ export function moveToWithinRange(date: Date, min: Date, max: Date) {
5
5
  return isWithinRange(date, min, max) ? date : new Date(min && date < min ? +min : +max);
6
6
  }