@simplybusiness/mobius-datepicker 9.0.9 → 9.1.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.
- package/CHANGELOG.md +20 -0
- package/dist/cjs/components/DatePicker/CustomComponents/CaptionLabel.js +30 -0
- package/dist/cjs/components/DatePicker/CustomComponents/CaptionLabel.js.map +7 -0
- package/dist/cjs/components/DatePicker/CustomComponents/ChevronComponent.js +35 -0
- package/dist/cjs/components/DatePicker/CustomComponents/ChevronComponent.js.map +7 -0
- package/dist/cjs/components/DatePicker/CustomComponents/index.js +44 -0
- package/dist/cjs/components/DatePicker/CustomComponents/index.js.map +7 -0
- package/dist/cjs/components/DatePicker/DatePicker.js +547 -0
- package/dist/cjs/components/DatePicker/DatePicker.js.map +7 -0
- package/dist/cjs/components/DatePicker/DatePickerIcon.js +28 -0
- package/dist/cjs/components/DatePicker/DatePickerIcon.js.map +7 -0
- package/dist/{esm/DatePickerModal-RVUBO5DW.js → cjs/components/DatePicker/DatePickerModal.js} +63 -33
- package/dist/{esm/DatePickerModal-RVUBO5DW.js.map → cjs/components/DatePicker/DatePickerModal.js.map} +3 -3
- package/dist/cjs/components/DatePicker/constants.js +31 -0
- package/dist/cjs/components/DatePicker/constants.js.map +7 -0
- package/dist/cjs/components/DatePicker/index.js +548 -0
- package/dist/cjs/components/DatePicker/index.js.map +7 -0
- package/dist/cjs/components/DatePicker/utils/dateObjToString.js +32 -0
- package/dist/cjs/components/DatePicker/utils/dateObjToString.js.map +7 -0
- package/dist/cjs/components/DatePicker/utils/formatErrorMessageText.js +45 -0
- package/dist/cjs/components/DatePicker/utils/formatErrorMessageText.js.map +7 -0
- package/dist/cjs/components/DatePicker/utils/getStartWeekday.js +41 -0
- package/dist/cjs/components/DatePicker/utils/getStartWeekday.js.map +7 -0
- package/dist/cjs/components/DatePicker/utils/index.js +86 -0
- package/dist/cjs/components/DatePicker/utils/index.js.map +7 -0
- package/dist/cjs/components/DatePicker/utils/timezoneOffset.js +37 -0
- package/dist/cjs/components/DatePicker/utils/timezoneOffset.js.map +7 -0
- package/dist/cjs/components/DatePicker/utils/validateDateFormat.js +40 -0
- package/dist/cjs/components/DatePicker/utils/validateDateFormat.js.map +7 -0
- package/dist/cjs/components/DatePicker/utils/weekdayAsOneLetter.js +38 -0
- package/dist/cjs/components/DatePicker/utils/weekdayAsOneLetter.js.map +7 -0
- package/dist/cjs/hooks/index.js +19 -0
- package/dist/cjs/hooks/index.js.map +7 -0
- package/dist/cjs/hooks/useFocusTrap/index.js +19 -0
- package/dist/cjs/hooks/useFocusTrap/index.js.map +7 -0
- package/dist/cjs/hooks/useFocusTrap/useFocusTrap.js +65 -0
- package/dist/cjs/hooks/useFocusTrap/useFocusTrap.js.map +7 -0
- package/dist/cjs/index.js +4 -3
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/meta.json +993 -5
- package/dist/cjs/utils/StoryContainer.js +46 -0
- package/dist/cjs/utils/StoryContainer.js.map +7 -0
- package/dist/cjs/utils/excludeControls.js +30 -0
- package/dist/cjs/utils/excludeControls.js.map +7 -0
- package/dist/cjs/utils/index.js +41 -0
- package/dist/cjs/utils/index.js.map +7 -0
- package/dist/cjs/utils/isTouchDevice.js +32 -0
- package/dist/cjs/utils/isTouchDevice.js.map +7 -0
- package/dist/cjs/utils/mockMatchMedia.js +50 -0
- package/dist/cjs/utils/mockMatchMedia.js.map +7 -0
- package/dist/esm/chunk-24MISPYQ.js +1 -0
- package/dist/esm/chunk-24MISPYQ.js.map +7 -0
- package/dist/esm/chunk-4UUTCJ7P.js +11 -0
- package/dist/esm/chunk-4UUTCJ7P.js.map +7 -0
- package/dist/esm/chunk-52KEWVWB.js +12 -0
- package/dist/esm/chunk-52KEWVWB.js.map +7 -0
- package/dist/esm/chunk-5CHWCZUP.js +1 -0
- package/dist/esm/chunk-5CHWCZUP.js.map +7 -0
- package/dist/esm/chunk-6TTD4G74.js +20 -0
- package/dist/esm/chunk-6TTD4G74.js.map +7 -0
- package/dist/esm/chunk-A62CZFEQ.js +17 -0
- package/dist/esm/chunk-A62CZFEQ.js.map +7 -0
- package/dist/esm/chunk-AOSXRXGA.js +20 -0
- package/dist/esm/chunk-AOSXRXGA.js.map +7 -0
- package/dist/esm/chunk-CH3KSJSE.js +12 -0
- package/dist/esm/chunk-CH3KSJSE.js.map +7 -0
- package/dist/esm/chunk-E5XSED6Z.js +1 -0
- package/dist/esm/chunk-E5XSED6Z.js.map +7 -0
- package/dist/esm/chunk-GKDMKCFX.js +15 -0
- package/dist/esm/chunk-GKDMKCFX.js.map +7 -0
- package/dist/esm/chunk-IDU2FHOY.js +10 -0
- package/dist/esm/chunk-IDU2FHOY.js.map +7 -0
- package/dist/esm/chunk-IVRD2PA6.js +17 -0
- package/dist/esm/chunk-IVRD2PA6.js.map +7 -0
- package/dist/esm/chunk-KW6EFBPT.js +10 -0
- package/dist/esm/chunk-KW6EFBPT.js.map +7 -0
- package/dist/esm/chunk-LR7ML4HC.js +45 -0
- package/dist/esm/chunk-LR7ML4HC.js.map +7 -0
- package/dist/esm/chunk-TAURHEHL.js +193 -0
- package/dist/esm/chunk-TAURHEHL.js.map +7 -0
- package/dist/esm/chunk-UJQXNOUG.js +25 -0
- package/dist/esm/chunk-UJQXNOUG.js.map +7 -0
- package/dist/esm/chunk-UNC7C5OV.js +1 -0
- package/dist/esm/chunk-UNC7C5OV.js.map +7 -0
- package/dist/esm/components/DatePicker/CustomComponents/CaptionLabel.js +7 -0
- package/dist/esm/components/DatePicker/CustomComponents/CaptionLabel.js.map +7 -0
- package/dist/esm/components/DatePicker/CustomComponents/ChevronComponent.js +7 -0
- package/dist/esm/components/DatePicker/CustomComponents/ChevronComponent.js.map +7 -0
- package/dist/esm/components/DatePicker/CustomComponents/index.js +12 -0
- package/dist/esm/components/DatePicker/CustomComponents/index.js.map +7 -0
- package/dist/esm/components/DatePicker/DatePicker.js +15 -0
- package/dist/esm/components/DatePicker/DatePicker.js.map +7 -0
- package/dist/esm/components/DatePicker/DatePickerIcon.js +7 -0
- package/dist/esm/components/DatePicker/DatePickerIcon.js.map +7 -0
- package/dist/esm/components/DatePicker/DatePickerModal.js +134 -0
- package/dist/esm/components/DatePicker/DatePickerModal.js.map +7 -0
- package/dist/esm/components/DatePicker/constants.js +11 -0
- package/dist/esm/components/DatePicker/constants.js.map +7 -0
- package/dist/esm/components/DatePicker/index.js +15 -0
- package/dist/esm/components/DatePicker/index.js.map +7 -0
- package/dist/esm/components/DatePicker/utils/dateObjToString.js +7 -0
- package/dist/esm/components/DatePicker/utils/dateObjToString.js.map +7 -0
- package/dist/esm/components/DatePicker/utils/formatErrorMessageText.js +13 -0
- package/dist/esm/components/DatePicker/utils/formatErrorMessageText.js.map +7 -0
- package/dist/esm/components/DatePicker/utils/getStartWeekday.js +8 -0
- package/dist/esm/components/DatePicker/utils/getStartWeekday.js.map +7 -0
- package/dist/esm/components/DatePicker/utils/index.js +29 -0
- package/dist/esm/components/DatePicker/utils/index.js.map +7 -0
- package/dist/esm/components/DatePicker/utils/timezoneOffset.js +9 -0
- package/dist/esm/components/DatePicker/utils/timezoneOffset.js.map +7 -0
- package/dist/esm/components/DatePicker/utils/validateDateFormat.js +9 -0
- package/dist/esm/components/DatePicker/utils/validateDateFormat.js.map +7 -0
- package/dist/esm/components/DatePicker/utils/weekdayAsOneLetter.js +8 -0
- package/dist/esm/components/DatePicker/utils/weekdayAsOneLetter.js.map +7 -0
- package/dist/esm/hooks/index.js +3 -0
- package/dist/esm/hooks/index.js.map +7 -0
- package/dist/esm/hooks/useFocusTrap/index.js +3 -0
- package/dist/esm/hooks/useFocusTrap/index.js.map +7 -0
- package/dist/esm/hooks/useFocusTrap/useFocusTrap.js +7 -0
- package/dist/esm/hooks/useFocusTrap/useFocusTrap.js.map +7 -0
- package/dist/esm/index.js +10 -219
- package/dist/esm/index.js.map +3 -3
- package/dist/esm/meta.json +1146 -102
- package/dist/esm/utils/StoryContainer.js +25 -0
- package/dist/esm/utils/StoryContainer.js.map +7 -0
- package/dist/esm/utils/excludeControls.js +7 -0
- package/dist/esm/utils/excludeControls.js.map +7 -0
- package/dist/esm/utils/index.js +11 -0
- package/dist/esm/utils/index.js.map +7 -0
- package/dist/esm/utils/isTouchDevice.js +7 -0
- package/dist/esm/utils/isTouchDevice.js.map +7 -0
- package/dist/esm/utils/mockMatchMedia.js +29 -0
- package/dist/esm/utils/mockMatchMedia.js.map +7 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/components/DatePicker/DatePicker.d.ts +1 -0
- package/package.json +4 -3
- package/src/components/DatePicker/DatePicker.tsx +1 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/components/DatePicker/utils/formatErrorMessageText.ts
|
|
21
|
+
var formatErrorMessageText_exports = {};
|
|
22
|
+
__export(formatErrorMessageText_exports, {
|
|
23
|
+
DEFAULT_AFTER_MAX: () => DEFAULT_AFTER_MAX,
|
|
24
|
+
DEFAULT_BEFORE_MIN: () => DEFAULT_BEFORE_MIN,
|
|
25
|
+
DEFAULT_INVALID_DATE_MESSAGE: () => DEFAULT_INVALID_DATE_MESSAGE,
|
|
26
|
+
formatErrorMessageText: () => formatErrorMessageText
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(formatErrorMessageText_exports);
|
|
29
|
+
var import_date_fns = require("date-fns");
|
|
30
|
+
var DEFAULT_INVALID_DATE_MESSAGE = "Please enter a valid date";
|
|
31
|
+
var DEFAULT_BEFORE_MIN = "The date you selected is before the earliest allowed date";
|
|
32
|
+
var DEFAULT_AFTER_MAX = "The date you selected is after the latest allowed date";
|
|
33
|
+
var formatErrorMessageText = (actual, min, max) => {
|
|
34
|
+
const actualDate = new Date(actual);
|
|
35
|
+
const minDate = min && new Date(min);
|
|
36
|
+
const maxDate = max && new Date(max);
|
|
37
|
+
if (minDate && (0, import_date_fns.isBefore)(actualDate, minDate)) {
|
|
38
|
+
return DEFAULT_BEFORE_MIN;
|
|
39
|
+
}
|
|
40
|
+
if (maxDate && (0, import_date_fns.isAfter)(actualDate, maxDate)) {
|
|
41
|
+
return DEFAULT_AFTER_MAX;
|
|
42
|
+
}
|
|
43
|
+
return DEFAULT_INVALID_DATE_MESSAGE;
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=formatErrorMessageText.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/components/DatePicker/utils/formatErrorMessageText.ts"],
|
|
4
|
+
"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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAkC;AAE3B,IAAM,+BAA+B;AACrC,IAAM,qBACX;AACK,IAAM,oBACX;AAEK,IAAM,yBAAyB,CACpC,QACA,KACA,QACG;AACH,QAAM,aAAa,IAAI,KAAK,MAAM;AAClC,QAAM,UAAU,OAAO,IAAI,KAAK,GAAG;AACnC,QAAM,UAAU,OAAO,IAAI,KAAK,GAAG;AAEnC,MAAI,eAAW,0BAAS,YAAY,OAAO,GAAG;AAC5C,WAAO;AAAA,EACT;AAEA,MAAI,eAAW,yBAAQ,YAAY,OAAO,GAAG;AAC3C,WAAO;AAAA,EACT;AAEA,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/components/DatePicker/utils/getStartWeekday.ts
|
|
21
|
+
var getStartWeekday_exports = {};
|
|
22
|
+
__export(getStartWeekday_exports, {
|
|
23
|
+
getStartWeekday: () => getStartWeekday
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(getStartWeekday_exports);
|
|
26
|
+
|
|
27
|
+
// src/components/DatePicker/constants.ts
|
|
28
|
+
var SUNDAY_AS_NUMBER = 0;
|
|
29
|
+
var MONDAY_AS_NUMBER = 1;
|
|
30
|
+
var DEFAULT_LOCALE = "en-GB";
|
|
31
|
+
|
|
32
|
+
// src/components/DatePicker/utils/getStartWeekday.ts
|
|
33
|
+
var getStartWeekday = (locale) => {
|
|
34
|
+
switch (locale || DEFAULT_LOCALE) {
|
|
35
|
+
case "en-US":
|
|
36
|
+
return SUNDAY_AS_NUMBER;
|
|
37
|
+
default:
|
|
38
|
+
return MONDAY_AS_NUMBER;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=getStartWeekday.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/components/DatePicker/utils/getStartWeekday.ts", "../../../../../src/components/DatePicker/constants.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n DEFAULT_LOCALE,\n MONDAY_AS_NUMBER,\n SUNDAY_AS_NUMBER,\n} from \"../constants\";\n\ntype WeekStart = 0 | 1 | 2 | 3 | 4 | 5 | 6 | undefined;\n\n// Calculates start of week for calendar in UK and US locales\n// Add more to the switch statement as needed\nexport const getStartWeekday = (locale?: string): WeekStart => {\n switch (locale || DEFAULT_LOCALE) {\n case \"en-US\":\n return SUNDAY_AS_NUMBER;\n\n default:\n return MONDAY_AS_NUMBER;\n }\n};\n", "export const SUNDAY_AS_NUMBER = 0;\nexport const MONDAY_AS_NUMBER = 1;\nexport const DEFAULT_LOCALE = \"en-GB\";\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,mBAAmB;AACzB,IAAM,mBAAmB;AACzB,IAAM,iBAAiB;;;ADQvB,IAAM,kBAAkB,CAAC,WAA+B;AAC7D,UAAQ,UAAU,gBAAgB;AAAA,IAChC,KAAK;AACH,aAAO;AAAA,IAET;AACE,aAAO;AAAA,EACX;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/components/DatePicker/utils/index.ts
|
|
21
|
+
var utils_exports = {};
|
|
22
|
+
__export(utils_exports, {
|
|
23
|
+
DATE_FORMAT: () => DATE_FORMAT,
|
|
24
|
+
DEFAULT_AFTER_MAX: () => DEFAULT_AFTER_MAX,
|
|
25
|
+
DEFAULT_BEFORE_MIN: () => DEFAULT_BEFORE_MIN,
|
|
26
|
+
DEFAULT_INVALID_DATE_MESSAGE: () => DEFAULT_INVALID_DATE_MESSAGE,
|
|
27
|
+
dateObjToString: () => dateObjToString,
|
|
28
|
+
formatErrorMessageText: () => formatErrorMessageText,
|
|
29
|
+
validateDateFormat: () => validateDateFormat,
|
|
30
|
+
weekdayAsOneLetter: () => weekdayAsOneLetter
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(utils_exports);
|
|
33
|
+
|
|
34
|
+
// src/components/DatePicker/utils/dateObjToString.ts
|
|
35
|
+
var dateObjToString = (date) => {
|
|
36
|
+
const year = date.getFullYear();
|
|
37
|
+
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
38
|
+
const day = String(date.getDate()).padStart(2, "0");
|
|
39
|
+
return `${year}-${month}-${day}`;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// src/components/DatePicker/utils/formatErrorMessageText.ts
|
|
43
|
+
var import_date_fns = require("date-fns");
|
|
44
|
+
var DEFAULT_INVALID_DATE_MESSAGE = "Please enter a valid date";
|
|
45
|
+
var DEFAULT_BEFORE_MIN = "The date you selected is before the earliest allowed date";
|
|
46
|
+
var DEFAULT_AFTER_MAX = "The date you selected is after the latest allowed date";
|
|
47
|
+
var formatErrorMessageText = (actual, min, max) => {
|
|
48
|
+
const actualDate = new Date(actual);
|
|
49
|
+
const minDate = min && new Date(min);
|
|
50
|
+
const maxDate = max && new Date(max);
|
|
51
|
+
if (minDate && (0, import_date_fns.isBefore)(actualDate, minDate)) {
|
|
52
|
+
return DEFAULT_BEFORE_MIN;
|
|
53
|
+
}
|
|
54
|
+
if (maxDate && (0, import_date_fns.isAfter)(actualDate, maxDate)) {
|
|
55
|
+
return DEFAULT_AFTER_MAX;
|
|
56
|
+
}
|
|
57
|
+
return DEFAULT_INVALID_DATE_MESSAGE;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// src/components/DatePicker/utils/validateDateFormat.ts
|
|
61
|
+
var import_date_fns2 = require("date-fns");
|
|
62
|
+
var DATE_FORMAT = "yyyy-MM-dd";
|
|
63
|
+
var validateDateFormat = (date) => {
|
|
64
|
+
if (date === "") {
|
|
65
|
+
return "";
|
|
66
|
+
}
|
|
67
|
+
if ((0, import_date_fns2.isMatch)(date, DATE_FORMAT)) {
|
|
68
|
+
return date;
|
|
69
|
+
}
|
|
70
|
+
throw Error(
|
|
71
|
+
`DatePicker defaultValue '${date}' is invalid. The expected format is '${DATE_FORMAT}' `
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// src/components/DatePicker/constants.ts
|
|
76
|
+
var DEFAULT_LOCALE = "en-GB";
|
|
77
|
+
|
|
78
|
+
// src/components/DatePicker/utils/weekdayAsOneLetter.ts
|
|
79
|
+
var weekdayAsOneLetter = (date) => {
|
|
80
|
+
const locale = navigator.language || DEFAULT_LOCALE;
|
|
81
|
+
const oneLetter = date.toLocaleString(locale, {
|
|
82
|
+
weekday: "narrow"
|
|
83
|
+
});
|
|
84
|
+
return oneLetter;
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/components/DatePicker/utils/index.ts", "../../../../../src/components/DatePicker/utils/dateObjToString.ts", "../../../../../src/components/DatePicker/utils/formatErrorMessageText.ts", "../../../../../src/components/DatePicker/utils/validateDateFormat.ts", "../../../../../src/components/DatePicker/constants.ts", "../../../../../src/components/DatePicker/utils/weekdayAsOneLetter.ts"],
|
|
4
|
+
"sourcesContent": ["export * from \"./dateObjToString\";\nexport * from \"./formatErrorMessageText\";\nexport * from \"./validateDateFormat\";\nexport * from \"./weekdayAsOneLetter\";\n", "export const dateObjToString = (date: Date) => {\n const year = date.getFullYear();\n const month = String(date.getMonth() + 1).padStart(2, \"0\");\n const day = String(date.getDate()).padStart(2, \"0\");\n\n // Extract the date part from the Date object\n return `${year}-${month}-${day}`;\n};\n", "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", "import { isMatch } from \"date-fns\";\n\n// eg 2023-12-31\nexport const DATE_FORMAT = \"yyyy-MM-dd\";\n\nexport const validateDateFormat = (date: string) => {\n if (date === \"\") {\n return \"\";\n }\n\n if (isMatch(date, DATE_FORMAT)) {\n return date;\n }\n\n throw Error(\n `DatePicker defaultValue '${date}' is invalid. The expected format is '${DATE_FORMAT}' `,\n );\n};\n", "export const SUNDAY_AS_NUMBER = 0;\nexport const MONDAY_AS_NUMBER = 1;\nexport const DEFAULT_LOCALE = \"en-GB\";\n", "import { DEFAULT_LOCALE } from \"../constants\";\n\nexport const weekdayAsOneLetter = (date: Date) => {\n const locale = navigator.language || DEFAULT_LOCALE;\n const oneLetter = date.toLocaleString(locale, {\n weekday: \"narrow\",\n });\n\n return oneLetter;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,kBAAkB,CAAC,SAAe;AAC7C,QAAM,OAAO,KAAK,YAAY;AAC9B,QAAM,QAAQ,OAAO,KAAK,SAAS,IAAI,CAAC,EAAE,SAAS,GAAG,GAAG;AACzD,QAAM,MAAM,OAAO,KAAK,QAAQ,CAAC,EAAE,SAAS,GAAG,GAAG;AAGlD,SAAO,GAAG,IAAI,IAAI,KAAK,IAAI,GAAG;AAChC;;;ACPA,sBAAkC;AAE3B,IAAM,+BAA+B;AACrC,IAAM,qBACX;AACK,IAAM,oBACX;AAEK,IAAM,yBAAyB,CACpC,QACA,KACA,QACG;AACH,QAAM,aAAa,IAAI,KAAK,MAAM;AAClC,QAAM,UAAU,OAAO,IAAI,KAAK,GAAG;AACnC,QAAM,UAAU,OAAO,IAAI,KAAK,GAAG;AAEnC,MAAI,eAAW,0BAAS,YAAY,OAAO,GAAG;AAC5C,WAAO;AAAA,EACT;AAEA,MAAI,eAAW,yBAAQ,YAAY,OAAO,GAAG;AAC3C,WAAO;AAAA,EACT;AAEA,SAAO;AACT;;;AC1BA,IAAAA,mBAAwB;AAGjB,IAAM,cAAc;AAEpB,IAAM,qBAAqB,CAAC,SAAiB;AAClD,MAAI,SAAS,IAAI;AACf,WAAO;AAAA,EACT;AAEA,UAAI,0BAAQ,MAAM,WAAW,GAAG;AAC9B,WAAO;AAAA,EACT;AAEA,QAAM;AAAA,IACJ,4BAA4B,IAAI,yCAAyC,WAAW;AAAA,EACtF;AACF;;;ACfO,IAAM,iBAAiB;;;ACAvB,IAAM,qBAAqB,CAAC,SAAe;AAChD,QAAM,SAAS,UAAU,YAAY;AACrC,QAAM,YAAY,KAAK,eAAe,QAAQ;AAAA,IAC5C,SAAS;AAAA,EACX,CAAC;AAED,SAAO;AACT;",
|
|
6
|
+
"names": ["import_date_fns"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/components/DatePicker/utils/timezoneOffset.ts
|
|
21
|
+
var timezoneOffset_exports = {};
|
|
22
|
+
__export(timezoneOffset_exports, {
|
|
23
|
+
toLocal: () => toLocal,
|
|
24
|
+
toUTC: () => toUTC
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(timezoneOffset_exports);
|
|
27
|
+
function toUTC(localDate) {
|
|
28
|
+
return new Date(localDate.getTime() - localDate.getTimezoneOffset() * 6e4);
|
|
29
|
+
}
|
|
30
|
+
function toLocal(utcDateString) {
|
|
31
|
+
const utcDate = new Date(utcDateString);
|
|
32
|
+
if (Number.isNaN(utcDate.getTime())) {
|
|
33
|
+
throw new Error("Invalid date string");
|
|
34
|
+
}
|
|
35
|
+
return new Date(utcDate.getTime() + utcDate.getTimezoneOffset() * 6e4);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=timezoneOffset.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/components/DatePicker/utils/timezoneOffset.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Converts a local date-time to UTC\n * @param localDate - Date object in local timezone\n * @returns Date object in UTC\n */\nexport function toUTC(localDate: Date): Date {\n return new Date(localDate.getTime() - localDate.getTimezoneOffset() * 60000);\n}\n\nexport function toLocal(utcDateString: string): Date {\n const utcDate = new Date(utcDateString);\n if (Number.isNaN(utcDate.getTime())) {\n throw new Error(\"Invalid date string\");\n }\n // Convert UTC date to local date\n // by adding the timezone offset in milliseconds\n return new Date(utcDate.getTime() + utcDate.getTimezoneOffset() * 60000);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKO,SAAS,MAAM,WAAuB;AAC3C,SAAO,IAAI,KAAK,UAAU,QAAQ,IAAI,UAAU,kBAAkB,IAAI,GAAK;AAC7E;AAEO,SAAS,QAAQ,eAA6B;AACnD,QAAM,UAAU,IAAI,KAAK,aAAa;AACtC,MAAI,OAAO,MAAM,QAAQ,QAAQ,CAAC,GAAG;AACnC,UAAM,IAAI,MAAM,qBAAqB;AAAA,EACvC;AAGA,SAAO,IAAI,KAAK,QAAQ,QAAQ,IAAI,QAAQ,kBAAkB,IAAI,GAAK;AACzE;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/components/DatePicker/utils/validateDateFormat.ts
|
|
21
|
+
var validateDateFormat_exports = {};
|
|
22
|
+
__export(validateDateFormat_exports, {
|
|
23
|
+
DATE_FORMAT: () => DATE_FORMAT,
|
|
24
|
+
validateDateFormat: () => validateDateFormat
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(validateDateFormat_exports);
|
|
27
|
+
var import_date_fns = require("date-fns");
|
|
28
|
+
var DATE_FORMAT = "yyyy-MM-dd";
|
|
29
|
+
var validateDateFormat = (date) => {
|
|
30
|
+
if (date === "") {
|
|
31
|
+
return "";
|
|
32
|
+
}
|
|
33
|
+
if ((0, import_date_fns.isMatch)(date, DATE_FORMAT)) {
|
|
34
|
+
return date;
|
|
35
|
+
}
|
|
36
|
+
throw Error(
|
|
37
|
+
`DatePicker defaultValue '${date}' is invalid. The expected format is '${DATE_FORMAT}' `
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=validateDateFormat.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/components/DatePicker/utils/validateDateFormat.ts"],
|
|
4
|
+
"sourcesContent": ["import { isMatch } from \"date-fns\";\n\n// eg 2023-12-31\nexport const DATE_FORMAT = \"yyyy-MM-dd\";\n\nexport const validateDateFormat = (date: string) => {\n if (date === \"\") {\n return \"\";\n }\n\n if (isMatch(date, DATE_FORMAT)) {\n return date;\n }\n\n throw Error(\n `DatePicker defaultValue '${date}' is invalid. The expected format is '${DATE_FORMAT}' `,\n );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAwB;AAGjB,IAAM,cAAc;AAEpB,IAAM,qBAAqB,CAAC,SAAiB;AAClD,MAAI,SAAS,IAAI;AACf,WAAO;AAAA,EACT;AAEA,UAAI,yBAAQ,MAAM,WAAW,GAAG;AAC9B,WAAO;AAAA,EACT;AAEA,QAAM;AAAA,IACJ,4BAA4B,IAAI,yCAAyC,WAAW;AAAA,EACtF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/components/DatePicker/utils/weekdayAsOneLetter.ts
|
|
21
|
+
var weekdayAsOneLetter_exports = {};
|
|
22
|
+
__export(weekdayAsOneLetter_exports, {
|
|
23
|
+
weekdayAsOneLetter: () => weekdayAsOneLetter
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(weekdayAsOneLetter_exports);
|
|
26
|
+
|
|
27
|
+
// src/components/DatePicker/constants.ts
|
|
28
|
+
var DEFAULT_LOCALE = "en-GB";
|
|
29
|
+
|
|
30
|
+
// src/components/DatePicker/utils/weekdayAsOneLetter.ts
|
|
31
|
+
var weekdayAsOneLetter = (date) => {
|
|
32
|
+
const locale = navigator.language || DEFAULT_LOCALE;
|
|
33
|
+
const oneLetter = date.toLocaleString(locale, {
|
|
34
|
+
weekday: "narrow"
|
|
35
|
+
});
|
|
36
|
+
return oneLetter;
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=weekdayAsOneLetter.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/components/DatePicker/utils/weekdayAsOneLetter.ts", "../../../../../src/components/DatePicker/constants.ts"],
|
|
4
|
+
"sourcesContent": ["import { DEFAULT_LOCALE } from \"../constants\";\n\nexport const weekdayAsOneLetter = (date: Date) => {\n const locale = navigator.language || DEFAULT_LOCALE;\n const oneLetter = date.toLocaleString(locale, {\n weekday: \"narrow\",\n });\n\n return oneLetter;\n};\n", "export const SUNDAY_AS_NUMBER = 0;\nexport const MONDAY_AS_NUMBER = 1;\nexport const DEFAULT_LOCALE = \"en-GB\";\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,IAAM,iBAAiB;;;ADAvB,IAAM,qBAAqB,CAAC,SAAe;AAChD,QAAM,SAAS,UAAU,YAAY;AACrC,QAAM,YAAY,KAAK,eAAe,QAAQ;AAAA,IAC5C,SAAS;AAAA,EACX,CAAC;AAED,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/hooks/index.tsx
|
|
17
|
+
var hooks_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(hooks_exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/hooks/useFocusTrap/index.tsx
|
|
17
|
+
var useFocusTrap_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(useFocusTrap_exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/hooks/useFocusTrap/useFocusTrap.tsx
|
|
21
|
+
var useFocusTrap_exports = {};
|
|
22
|
+
__export(useFocusTrap_exports, {
|
|
23
|
+
default: () => FocusTrap
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(useFocusTrap_exports);
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
28
|
+
var useFocusTrap = () => {
|
|
29
|
+
const containerRef = (0, import_react.useRef)(null);
|
|
30
|
+
(0, import_react.useEffect)(() => {
|
|
31
|
+
if (containerRef.current) {
|
|
32
|
+
const element = containerRef.current;
|
|
33
|
+
const focusableElements = containerRef.current.querySelectorAll(
|
|
34
|
+
'[tabindex="0"], .mobius-date-picker__nav-button'
|
|
35
|
+
);
|
|
36
|
+
const firstElement = focusableElements[0];
|
|
37
|
+
const lastElement = focusableElements[focusableElements.length - 1];
|
|
38
|
+
const handleTabKeyPress = (event) => {
|
|
39
|
+
if (event.key === "Tab") {
|
|
40
|
+
if (event.shiftKey && document.activeElement === firstElement) {
|
|
41
|
+
event.preventDefault();
|
|
42
|
+
lastElement.focus();
|
|
43
|
+
} else if (!event.shiftKey && document.activeElement && document.activeElement.className.indexOf(
|
|
44
|
+
"mobius-date-picker__day-button"
|
|
45
|
+
) > -1) {
|
|
46
|
+
event.preventDefault();
|
|
47
|
+
firstElement.focus();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
element.addEventListener("keydown", handleTabKeyPress);
|
|
52
|
+
return () => {
|
|
53
|
+
element.removeEventListener("keydown", handleTabKeyPress);
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return () => {
|
|
57
|
+
};
|
|
58
|
+
}, []);
|
|
59
|
+
return containerRef;
|
|
60
|
+
};
|
|
61
|
+
function FocusTrap({ children }) {
|
|
62
|
+
const focusRef = useFocusTrap();
|
|
63
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "trap", ref: focusRef, children });
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=useFocusTrap.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/hooks/useFocusTrap/useFocusTrap.tsx"],
|
|
4
|
+
"sourcesContent": ["import type { ReactNode } from \"react\";\nimport { useEffect, useRef } from \"react\";\n\nconst useFocusTrap = () => {\n const containerRef = useRef<HTMLDivElement | null>(null);\n\n useEffect(() => {\n if (containerRef.current) {\n const element = containerRef.current;\n const focusableElements =\n containerRef.current.querySelectorAll<HTMLElement>(\n '[tabindex=\"0\"], .mobius-date-picker__nav-button',\n );\n\n const firstElement = focusableElements[0];\n const lastElement = focusableElements[focusableElements.length - 1];\n\n const handleTabKeyPress = (event: KeyboardEvent) => {\n if (event.key === \"Tab\") {\n if (event.shiftKey && document.activeElement === firstElement) {\n event.preventDefault();\n lastElement.focus();\n } else if (\n !event.shiftKey &&\n document.activeElement &&\n document.activeElement.className.indexOf(\n \"mobius-date-picker__day-button\",\n ) > -1\n ) {\n event.preventDefault();\n firstElement.focus();\n }\n }\n };\n\n element.addEventListener(\"keydown\", handleTabKeyPress);\n return () => {\n element.removeEventListener(\"keydown\", handleTabKeyPress);\n };\n }\n return () => {};\n }, []);\n\n return containerRef;\n};\n\nexport type FocusTrapProps = {\n children: ReactNode;\n};\n\nexport default function FocusTrap({ children }: FocusTrapProps) {\n const focusRef = useFocusTrap();\n\n return (\n <div className=\"trap\" ref={focusRef}>\n {children}\n </div>\n );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkC;AAqD9B;AAnDJ,IAAM,eAAe,MAAM;AACzB,QAAM,mBAAe,qBAA8B,IAAI;AAEvD,8BAAU,MAAM;AACd,QAAI,aAAa,SAAS;AACxB,YAAM,UAAU,aAAa;AAC7B,YAAM,oBACJ,aAAa,QAAQ;AAAA,QACnB;AAAA,MACF;AAEF,YAAM,eAAe,kBAAkB,CAAC;AACxC,YAAM,cAAc,kBAAkB,kBAAkB,SAAS,CAAC;AAElE,YAAM,oBAAoB,CAAC,UAAyB;AAClD,YAAI,MAAM,QAAQ,OAAO;AACvB,cAAI,MAAM,YAAY,SAAS,kBAAkB,cAAc;AAC7D,kBAAM,eAAe;AACrB,wBAAY,MAAM;AAAA,UACpB,WACE,CAAC,MAAM,YACP,SAAS,iBACT,SAAS,cAAc,UAAU;AAAA,YAC/B;AAAA,UACF,IAAI,IACJ;AACA,kBAAM,eAAe;AACrB,yBAAa,MAAM;AAAA,UACrB;AAAA,QACF;AAAA,MACF;AAEA,cAAQ,iBAAiB,WAAW,iBAAiB;AACrD,aAAO,MAAM;AACX,gBAAQ,oBAAoB,WAAW,iBAAiB;AAAA,MAC1D;AAAA,IACF;AACA,WAAO,MAAM;AAAA,IAAC;AAAA,EAChB,GAAG,CAAC,CAAC;AAEL,SAAO;AACT;AAMe,SAAR,UAA2B,EAAE,SAAS,GAAmB;AAC9D,QAAM,WAAW,aAAa;AAE9B,SACE,4CAAC,SAAI,WAAU,QAAO,KAAK,UACxB,UACH;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -363,11 +363,11 @@ var init_DatePickerModal = __esm({
|
|
|
363
363
|
});
|
|
364
364
|
|
|
365
365
|
// src/index.tsx
|
|
366
|
-
var
|
|
367
|
-
__export(
|
|
366
|
+
var src_exports = {};
|
|
367
|
+
__export(src_exports, {
|
|
368
368
|
DatePicker: () => DatePicker
|
|
369
369
|
});
|
|
370
|
-
module.exports = __toCommonJS(
|
|
370
|
+
module.exports = __toCommonJS(src_exports);
|
|
371
371
|
|
|
372
372
|
// src/components/DatePicker/DatePicker.tsx
|
|
373
373
|
var import_icons2 = require("@simplybusiness/icons");
|
|
@@ -385,6 +385,7 @@ var isTouchDevice = () => {
|
|
|
385
385
|
|
|
386
386
|
// src/components/DatePicker/DatePicker.tsx
|
|
387
387
|
init_utils();
|
|
388
|
+
var import_DatePicker = require("@simplybusiness/mobius-datepicker/src/components/DatePicker/DatePicker.css");
|
|
388
389
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
389
390
|
var DatePickerModal2 = (0, import_react3.lazy)(() => Promise.resolve().then(() => (init_DatePickerModal(), DatePickerModal_exports)));
|
|
390
391
|
var getValidationState = (isInvalid) => {
|