@simplybusiness/mobius-datepicker 6.3.0 → 6.3.2
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.
- package/CHANGELOG.md +13 -0
- package/dist/cjs/components/DatePicker/utils/formatErrorMessageText.js +10 -2
- package/dist/cjs/components/DatePicker/utils/formatErrorMessageText.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/components/DatePicker/utils/formatErrorMessageText.js +5 -3
- package/dist/esm/components/DatePicker/utils/formatErrorMessageText.js.map +1 -1
- package/dist/types/components/DatePicker/utils/formatErrorMessageText.d.ts +3 -1
- package/package.json +2 -2
- package/src/components/DatePicker/DatePicker.test.tsx +4 -5
- package/src/components/DatePicker/utils/formatErrorMessageText.test.ts +5 -5
- package/src/components/DatePicker/utils/formatErrorMessageText.ts +7 -3
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,12 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
+
DEFAULT_AFTER_MAX: function() {
|
|
13
|
+
return DEFAULT_AFTER_MAX;
|
|
14
|
+
},
|
|
15
|
+
DEFAULT_BEFORE_MIN: function() {
|
|
16
|
+
return DEFAULT_BEFORE_MIN;
|
|
17
|
+
},
|
|
12
18
|
DEFAULT_INVALID_DATE_MESSAGE: function() {
|
|
13
19
|
return DEFAULT_INVALID_DATE_MESSAGE;
|
|
14
20
|
},
|
|
@@ -18,15 +24,17 @@ _export(exports, {
|
|
|
18
24
|
});
|
|
19
25
|
const _datefns = require("date-fns");
|
|
20
26
|
const DEFAULT_INVALID_DATE_MESSAGE = "Please enter a valid date";
|
|
27
|
+
const DEFAULT_BEFORE_MIN = "The date you selected is before the earliest allowed date";
|
|
28
|
+
const DEFAULT_AFTER_MAX = "The date you selected is after the latest allowed date";
|
|
21
29
|
const formatErrorMessageText = (actual, min, max)=>{
|
|
22
30
|
const actualDate = new Date(actual);
|
|
23
31
|
const minDate = min && new Date(min);
|
|
24
32
|
const maxDate = max && new Date(max);
|
|
25
33
|
if (minDate && (0, _datefns.isBefore)(actualDate, minDate)) {
|
|
26
|
-
return
|
|
34
|
+
return DEFAULT_BEFORE_MIN;
|
|
27
35
|
}
|
|
28
36
|
if (maxDate && (0, _datefns.isAfter)(actualDate, maxDate)) {
|
|
29
|
-
return
|
|
37
|
+
return DEFAULT_AFTER_MAX;
|
|
30
38
|
}
|
|
31
39
|
return DEFAULT_INVALID_DATE_MESSAGE;
|
|
32
40
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/components/DatePicker/utils/formatErrorMessageText.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/DatePicker/utils/formatErrorMessageText.ts"],"sourcesContent":["import { isAfter, isBefore } from \"date-fns\";\n\nexport const DEFAULT_INVALID_DATE_MESSAGE = \"Please enter a valid date\";\nexport const DEFAULT_BEFORE_MIN =\n \"The date you selected is before the earliest allowed date\";\nexport const DEFAULT_AFTER_MAX =\n \"The date you selected is after the latest allowed date\";\n\nexport const formatErrorMessageText = (\n actual: string,\n min?: string,\n max?: string,\n) => {\n const actualDate = new Date(actual);\n const minDate = min && new Date(min);\n const maxDate = max && new Date(max);\n\n if (minDate && isBefore(actualDate, minDate)) {\n return DEFAULT_BEFORE_MIN;\n }\n\n if (maxDate && isAfter(actualDate, maxDate)) {\n return DEFAULT_AFTER_MAX;\n }\n\n return DEFAULT_INVALID_DATE_MESSAGE;\n};\n"],"names":["DEFAULT_AFTER_MAX","DEFAULT_BEFORE_MIN","DEFAULT_INVALID_DATE_MESSAGE","formatErrorMessageText","actual","min","max","actualDate","Date","minDate","maxDate","isBefore","isAfter"],"mappings":";;;;;;;;;;;IAKaA,iBAAiB;eAAjBA;;IAFAC,kBAAkB;eAAlBA;;IADAC,4BAA4B;eAA5BA;;IAMAC,sBAAsB;eAAtBA;;;yBARqB;AAE3B,MAAMD,+BAA+B;AACrC,MAAMD,qBACX;AACK,MAAMD,oBACX;AAEK,MAAMG,yBAAyB,CACpCC,QACAC,KACAC;IAEA,MAAMC,aAAa,IAAIC,KAAKJ;IAC5B,MAAMK,UAAUJ,OAAO,IAAIG,KAAKH;IAChC,MAAMK,UAAUJ,OAAO,IAAIE,KAAKF;IAEhC,IAAIG,WAAWE,IAAAA,iBAAQ,EAACJ,YAAYE,UAAU;QAC5C,OAAOR;IACT;IAEA,IAAIS,WAAWE,IAAAA,gBAAO,EAACL,YAAYG,UAAU;QAC3C,OAAOV;IACT;IAEA,OAAOE;AACT"}
|