@mirai/ui 1.0.12 → 1.0.13
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/build/components/Button/Button.js +67 -0
- package/build/components/Button/Button.js.map +1 -0
- package/build/components/Button/Button.module.css +90 -0
- package/build/components/Button/__tests__/__snapshots__/Button.test.js.snap +113 -0
- package/build/components/Button/index.js +19 -0
- package/build/components/Button/index.js.map +1 -0
- package/build/components/Calendar/Calendar.Month.js +129 -0
- package/build/components/Calendar/Calendar.Month.js.map +1 -0
- package/build/components/Calendar/Calendar.Week.js +177 -0
- package/build/components/Calendar/Calendar.Week.js.map +1 -0
- package/build/components/Calendar/Calendar.Weekdays.js +45 -0
- package/build/components/Calendar/Calendar.Weekdays.js.map +1 -0
- package/build/components/Calendar/Calendar.constants.js +11 -0
- package/build/components/Calendar/Calendar.constants.js.map +1 -0
- package/build/components/Calendar/Calendar.js +196 -0
- package/build/components/Calendar/Calendar.js.map +1 -0
- package/build/components/Calendar/Calendar.module.css +127 -0
- package/build/components/Calendar/__tests__/__snapshots__/Calendar.test.jsx.snap +20477 -0
- package/build/components/Calendar/helpers/getFirstDateOfMonth.js +16 -0
- package/build/components/Calendar/helpers/getFirstDateOfMonth.js.map +1 -0
- package/build/components/Calendar/helpers/getFirstDateOfWeek.js +20 -0
- package/build/components/Calendar/helpers/getFirstDateOfWeek.js.map +1 -0
- package/build/components/Calendar/helpers/getHeader.js +23 -0
- package/build/components/Calendar/helpers/getHeader.js.map +1 -0
- package/build/components/Calendar/helpers/getToday.js +15 -0
- package/build/components/Calendar/helpers/getToday.js.map +1 -0
- package/build/components/Calendar/helpers/getWeekDays.js +27 -0
- package/build/components/Calendar/helpers/getWeekDays.js.map +1 -0
- package/build/components/Calendar/helpers/getWeekNumber.js +17 -0
- package/build/components/Calendar/helpers/getWeekNumber.js.map +1 -0
- package/build/components/Calendar/helpers/index.js +97 -0
- package/build/components/Calendar/helpers/index.js.map +1 -0
- package/build/components/Calendar/helpers/isJest.js +9 -0
- package/build/components/Calendar/helpers/isJest.js.map +1 -0
- package/build/components/Calendar/index.js +19 -0
- package/build/components/Calendar/index.js.map +1 -0
- package/build/components/Form/Form.js +217 -0
- package/build/components/Form/Form.js.map +1 -0
- package/build/components/Form/__tests__/__snapshots__/Form.test.jsx.snap +47 -0
- package/build/components/Form/helpers/getChildrenErrors.js +51 -0
- package/build/components/Form/helpers/getChildrenErrors.js.map +1 -0
- package/build/components/Form/helpers/getChildrenValues.js +51 -0
- package/build/components/Form/helpers/getChildrenValues.js.map +1 -0
- package/build/components/Form/helpers/getField.js +17 -0
- package/build/components/Form/helpers/getField.js.map +1 -0
- package/build/components/Form/helpers/groupState.js +29 -0
- package/build/components/Form/helpers/groupState.js.map +1 -0
- package/build/components/Form/helpers/index.js +58 -0
- package/build/components/Form/helpers/index.js.map +1 -0
- package/build/components/Form/index.js +19 -0
- package/build/components/Form/index.js.map +1 -0
- package/build/components/InputNumber/InputNumber.js +91 -0
- package/build/components/InputNumber/InputNumber.js.map +1 -0
- package/build/components/InputNumber/InputNumber.module.css +25 -0
- package/build/components/InputNumber/__tests__/__snapshots__/InputNumber.test.js.snap +698 -0
- package/build/components/InputNumber/index.js +19 -0
- package/build/components/InputNumber/index.js.map +1 -0
- package/build/components/InputOption/InputOption.constants.js +13 -0
- package/build/components/InputOption/InputOption.constants.js.map +1 -0
- package/build/components/InputOption/InputOption.js +80 -0
- package/build/components/InputOption/InputOption.js.map +1 -0
- package/build/components/InputOption/InputOption.module.css +43 -0
- package/build/components/InputOption/__tests__/__snapshots__/InputOption.test.js.snap +232 -0
- package/build/components/InputOption/index.js +19 -0
- package/build/components/InputOption/index.js.map +1 -0
- package/build/components/InputSelect/InputSelect.js +123 -0
- package/build/components/InputSelect/InputSelect.js.map +1 -0
- package/build/components/InputSelect/__tests__/__snapshots__/InputSelect.test.js.snap +490 -0
- package/build/components/InputSelect/index.js +19 -0
- package/build/components/InputSelect/index.js.map +1 -0
- package/build/components/InputText/InputText.js +141 -0
- package/build/components/InputText/InputText.js.map +1 -0
- package/build/components/InputText/InputText.module.css +107 -0
- package/build/components/InputText/__tests__/__snapshots__/InputText.test.js.snap +255 -0
- package/build/components/InputText/index.js +19 -0
- package/build/components/InputText/index.js.map +1 -0
- package/build/components/Menu/Menu.Option.js +58 -0
- package/build/components/Menu/Menu.Option.js.map +1 -0
- package/build/components/Menu/Menu.js +73 -0
- package/build/components/Menu/Menu.js.map +1 -0
- package/build/components/Menu/Menu.module.css +50 -0
- package/build/components/Menu/__tests__/__snapshots__/Menu.test.jsx.snap +178 -0
- package/build/components/Menu/index.js +19 -0
- package/build/components/Menu/index.js.map +1 -0
- package/build/components/Modal/Modal.js +61 -0
- package/build/components/Modal/Modal.js.map +1 -0
- package/build/components/Modal/Modal.module.css +72 -0
- package/build/components/Modal/__tests__/__snapshots__/Modal.test.js.snap +150 -0
- package/build/components/Modal/index.js +19 -0
- package/build/components/Modal/index.js.map +1 -0
- package/build/components/Table/Table.Row.js +92 -0
- package/build/components/Table/Table.Row.js.map +1 -0
- package/build/components/Table/Table.js +119 -0
- package/build/components/Table/Table.js.map +1 -0
- package/build/components/Table/Table.module.css +78 -0
- package/build/components/Table/__tests__/__snapshots__/Table.test.js.snap +2285 -0
- package/build/components/Table/helpers/index.js +19 -0
- package/build/components/Table/helpers/index.js.map +1 -0
- package/build/components/Table/helpers/select.js +29 -0
- package/build/components/Table/helpers/select.js.map +1 -0
- package/build/components/Table/index.js +19 -0
- package/build/components/Table/index.js.map +1 -0
- package/build/components/Tooltip/Tooltip.js +95 -0
- package/build/components/Tooltip/Tooltip.js.map +1 -0
- package/build/components/Tooltip/Tooltip.module.css +26 -0
- package/build/components/Tooltip/__tests__/__snapshots__/Tooltip.test.jsx.snap +117 -0
- package/build/components/Tooltip/index.js +19 -0
- package/build/components/Tooltip/index.js.map +1 -0
- package/build/components/index.js +149 -0
- package/build/components/index.js.map +1 -0
- package/build/helpers/getInputErrors.js +45 -0
- package/build/helpers/getInputErrors.js.map +1 -0
- package/build/helpers/index.js +32 -0
- package/build/helpers/index.js.map +1 -0
- package/build/helpers/isValidDate.js +72 -0
- package/build/helpers/isValidDate.js.map +1 -0
- package/build/helpers/isValidEmail.js +15 -0
- package/build/helpers/isValidEmail.js.map +1 -0
- package/build/helpers/isValidPhone.js +25 -0
- package/build/helpers/isValidPhone.js.map +1 -0
- package/build/helpers/styles.js +21 -0
- package/build/helpers/styles.js.map +1 -0
- package/build/hooks/helpers/getNavigator.js +33 -0
- package/build/hooks/helpers/getNavigator.js.map +1 -0
- package/build/hooks/helpers/getResolution.js +22 -0
- package/build/hooks/helpers/getResolution.js.map +1 -0
- package/build/hooks/helpers/index.js +32 -0
- package/build/hooks/helpers/index.js.map +1 -0
- package/build/hooks/index.js +19 -0
- package/build/hooks/index.js.map +1 -0
- package/build/hooks/useDevice.js +60 -0
- package/build/hooks/useDevice.js.map +1 -0
- package/build/index.js +71 -0
- package/build/index.js.map +1 -0
- package/build/primitives/Checkbox/Checkbox.js +66 -0
- package/build/primitives/Checkbox/Checkbox.js.map +1 -0
- package/build/primitives/Checkbox/Checkbox.module.css +45 -0
- package/build/primitives/Checkbox/__tests__/__snapshots__/Checkbox.test.js.snap +127 -0
- package/build/primitives/Checkbox/index.js +19 -0
- package/build/primitives/Checkbox/index.js.map +1 -0
- package/build/primitives/Icon/Icon.constants.js +30 -0
- package/build/primitives/Icon/Icon.constants.js.map +1 -0
- package/build/primitives/Icon/Icon.js +46 -0
- package/build/primitives/Icon/Icon.js.map +1 -0
- package/build/primitives/Icon/Icon.module.css +11 -0
- package/build/primitives/Icon/__tests__/__snapshots__/Icon.test.js.snap +133 -0
- package/build/primitives/Icon/index.js +31 -0
- package/build/primitives/Icon/index.js.map +1 -0
- package/build/primitives/Input/Input.js +85 -0
- package/build/primitives/Input/Input.js.map +1 -0
- package/build/primitives/Input/Input.module.css +32 -0
- package/build/primitives/Input/__tests__/__snapshots__/Input.test.js.snap +74 -0
- package/build/primitives/Input/helpers/index.js +19 -0
- package/build/primitives/Input/helpers/index.js.map +1 -0
- package/build/primitives/Input/helpers/parseValue.js +17 -0
- package/build/primitives/Input/helpers/parseValue.js.map +1 -0
- package/build/primitives/Input/index.js +19 -0
- package/build/primitives/Input/index.js.map +1 -0
- package/build/primitives/Layer/Layer.js +115 -0
- package/build/primitives/Layer/Layer.js.map +1 -0
- package/build/primitives/Layer/Layer.module.css +10 -0
- package/build/primitives/Layer/LayerContent.js +22 -0
- package/build/primitives/Layer/LayerContent.js.map +1 -0
- package/build/primitives/Layer/__tests__/__snapshots__/Layer.test.js.snap +89 -0
- package/build/primitives/Layer/helpers/getElementLayout.js +23 -0
- package/build/primitives/Layer/helpers/getElementLayout.js.map +1 -0
- package/build/primitives/Layer/helpers/getLayerPosition.js +45 -0
- package/build/primitives/Layer/helpers/getLayerPosition.js.map +1 -0
- package/build/primitives/Layer/helpers/index.js +32 -0
- package/build/primitives/Layer/helpers/index.js.map +1 -0
- package/build/primitives/Layer/index.js +32 -0
- package/build/primitives/Layer/index.js.map +1 -0
- package/build/primitives/Pressable/Pressable.constants.js +9 -0
- package/build/primitives/Pressable/Pressable.constants.js.map +1 -0
- package/build/primitives/Pressable/Pressable.js +67 -0
- package/build/primitives/Pressable/Pressable.js.map +1 -0
- package/build/primitives/Pressable/Pressable.module.css +18 -0
- package/build/primitives/Pressable/__tests__/__snapshots__/Pressable.test.js.snap +53 -0
- package/build/primitives/Pressable/index.js +19 -0
- package/build/primitives/Pressable/index.js.map +1 -0
- package/build/primitives/Radio/Radio.js +62 -0
- package/build/primitives/Radio/Radio.js.map +1 -0
- package/build/primitives/Radio/Radio.module.css +60 -0
- package/build/primitives/Radio/__tests__/__snapshots__/Radio.test.js.snap +125 -0
- package/build/primitives/Radio/index.js +19 -0
- package/build/primitives/Radio/index.js.map +1 -0
- package/build/primitives/ScrollView/ScrollView.js +112 -0
- package/build/primitives/ScrollView/ScrollView.js.map +1 -0
- package/build/primitives/ScrollView/ScrollView.module.css +35 -0
- package/build/primitives/ScrollView/__tests__/__snapshots__/ScrollView.test.js.snap +535 -0
- package/build/primitives/ScrollView/index.js +19 -0
- package/build/primitives/ScrollView/index.js.map +1 -0
- package/build/primitives/Select/Select.js +95 -0
- package/build/primitives/Select/Select.js.map +1 -0
- package/build/primitives/Select/Select.module.css +27 -0
- package/build/primitives/Select/__tests__/__snapshots__/Select.test.js.snap +178 -0
- package/build/primitives/Select/index.js +19 -0
- package/build/primitives/Select/index.js.map +1 -0
- package/build/primitives/Switch/Switch.js +60 -0
- package/build/primitives/Switch/Switch.js.map +1 -0
- package/build/primitives/Switch/Switch.module.css +65 -0
- package/build/primitives/Switch/__tests__/__snapshots__/Switch.test.js.snap +104 -0
- package/build/primitives/Switch/index.js +19 -0
- package/build/primitives/Switch/index.js.map +1 -0
- package/build/primitives/Text/Text.js +57 -0
- package/build/primitives/Text/Text.js.map +1 -0
- package/build/primitives/Text/Text.module.css +33 -0
- package/build/primitives/Text/__tests__/__snapshots__/Text.test.js.snap +92 -0
- package/build/primitives/Text/index.js +19 -0
- package/build/primitives/Text/index.js.map +1 -0
- package/build/primitives/View/View.js +52 -0
- package/build/primitives/View/View.js.map +1 -0
- package/build/primitives/View/View.module.css +17 -0
- package/build/primitives/View/__tests__/__snapshots__/View.test.js.snap +62 -0
- package/build/primitives/View/index.js +19 -0
- package/build/primitives/View/index.js.map +1 -0
- package/build/primitives/index.js +149 -0
- package/build/primitives/index.js.map +1 -0
- package/build/theme/default.theme.css +55 -0
- package/build/theme/helpers/camelcase.js +16 -0
- package/build/theme/helpers/camelcase.js.map +1 -0
- package/build/theme/helpers/index.js +19 -0
- package/build/theme/helpers/index.js.map +1 -0
- package/build/theme/index.js +19 -0
- package/build/theme/index.js.map +1 -0
- package/build/theme/theme.js +53 -0
- package/build/theme/theme.js.map +1 -0
- package/package.json +3 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getFirstDateOfMonth = void 0;
|
|
7
|
+
|
|
8
|
+
var _locale = require("@mirai/locale");
|
|
9
|
+
|
|
10
|
+
var getFirstDateOfMonth = function getFirstDateOfMonth() {
|
|
11
|
+
var date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date();
|
|
12
|
+
return (0, _locale.UTC)(new Date(date.getFullYear(), date.getMonth(), 1));
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
exports.getFirstDateOfMonth = getFirstDateOfMonth;
|
|
16
|
+
//# sourceMappingURL=getFirstDateOfMonth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFirstDateOfMonth.js","names":["getFirstDateOfMonth","date","Date","getFullYear","getMonth"],"sources":["../../../../src/components/Calendar/helpers/getFirstDateOfMonth.js"],"sourcesContent":["import { UTC } from '@mirai/locale';\n\nexport const getFirstDateOfMonth = (date = new Date()) => UTC(new Date(date.getFullYear(), date.getMonth(), 1));\n"],"mappings":";;;;;;;AAAA;;AAEO,IAAMA,mBAAmB,GAAG,SAAtBA,mBAAsB;EAAA,IAACC,IAAD,uEAAQ,IAAIC,IAAJ,EAAR;EAAA,OAAuB,iBAAI,IAAIA,IAAJ,CAASD,IAAI,CAACE,WAAL,EAAT,EAA6BF,IAAI,CAACG,QAAL,EAA7B,EAA8C,CAA9C,CAAJ,CAAvB;AAAA,CAA5B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getFirstDateOfWeek = void 0;
|
|
7
|
+
|
|
8
|
+
var _locale = require("@mirai/locale");
|
|
9
|
+
|
|
10
|
+
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
11
|
+
var WEEK_MS = 7 * DAY_MS;
|
|
12
|
+
|
|
13
|
+
var getFirstDateOfWeek = function getFirstDateOfWeek(week, year) {
|
|
14
|
+
var date = (0, _locale.UTC)(new Date(year, 0, 1, 0));
|
|
15
|
+
var offsetTimeStart = DAY_MS * (date.getDay() - 1);
|
|
16
|
+
return (0, _locale.UTC)(new Date(date.getTime() + WEEK_MS * (week - 1) - offsetTimeStart));
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
exports.getFirstDateOfWeek = getFirstDateOfWeek;
|
|
20
|
+
//# sourceMappingURL=getFirstDateOfWeek.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFirstDateOfWeek.js","names":["DAY_MS","WEEK_MS","getFirstDateOfWeek","week","year","date","Date","offsetTimeStart","getDay","getTime"],"sources":["../../../../src/components/Calendar/helpers/getFirstDateOfWeek.js"],"sourcesContent":["import { UTC } from '@mirai/locale';\n\nconst DAY_MS = 24 * 60 * 60 * 1000;\nconst WEEK_MS = 7 * DAY_MS;\n\nexport const getFirstDateOfWeek = (week, year) => {\n const date = UTC(new Date(year, 0, 1, 0));\n const offsetTimeStart = DAY_MS * (date.getDay() - 1);\n\n return UTC(new Date(date.getTime() + WEEK_MS * (week - 1) - offsetTimeStart));\n};\n"],"mappings":";;;;;;;AAAA;;AAEA,IAAMA,MAAM,GAAG,KAAK,EAAL,GAAU,EAAV,GAAe,IAA9B;AACA,IAAMC,OAAO,GAAG,IAAID,MAApB;;AAEO,IAAME,kBAAkB,GAAG,SAArBA,kBAAqB,CAACC,IAAD,EAAOC,IAAP,EAAgB;EAChD,IAAMC,IAAI,GAAG,iBAAI,IAAIC,IAAJ,CAASF,IAAT,EAAe,CAAf,EAAkB,CAAlB,EAAqB,CAArB,CAAJ,CAAb;EACA,IAAMG,eAAe,GAAGP,MAAM,IAAIK,IAAI,CAACG,MAAL,KAAgB,CAApB,CAA9B;EAEA,OAAO,iBAAI,IAAIF,IAAJ,CAASD,IAAI,CAACI,OAAL,KAAiBR,OAAO,IAAIE,IAAI,GAAG,CAAX,CAAxB,GAAwCI,eAAjD,CAAJ,CAAP;AACD,CALM"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getHeader = void 0;
|
|
7
|
+
|
|
8
|
+
var _locale = require("@mirai/locale");
|
|
9
|
+
|
|
10
|
+
var getHeader = function getHeader(date, locale) {
|
|
11
|
+
var month = (0, _locale.dateFormat)(date, {
|
|
12
|
+
locale: locale,
|
|
13
|
+
month: 'long'
|
|
14
|
+
});
|
|
15
|
+
var year = (0, _locale.dateFormat)(date, {
|
|
16
|
+
locale: locale,
|
|
17
|
+
year: 'numeric'
|
|
18
|
+
});
|
|
19
|
+
return "".concat(month, " ").concat(year);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
exports.getHeader = getHeader;
|
|
23
|
+
//# sourceMappingURL=getHeader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getHeader.js","names":["getHeader","date","locale","month","year"],"sources":["../../../../src/components/Calendar/helpers/getHeader.js"],"sourcesContent":["import { dateFormat } from '@mirai/locale';\n\nexport const getHeader = (date, locale) => {\n const month = dateFormat(date, { locale, month: 'long' });\n const year = dateFormat(date, { locale, year: 'numeric' });\n\n return `${month} ${year}`;\n};\n"],"mappings":";;;;;;;AAAA;;AAEO,IAAMA,SAAS,GAAG,SAAZA,SAAY,CAACC,IAAD,EAAOC,MAAP,EAAkB;EACzC,IAAMC,KAAK,GAAG,wBAAWF,IAAX,EAAiB;IAAEC,MAAM,EAANA,MAAF;IAAUC,KAAK,EAAE;EAAjB,CAAjB,CAAd;EACA,IAAMC,IAAI,GAAG,wBAAWH,IAAX,EAAiB;IAAEC,MAAM,EAANA,MAAF;IAAUE,IAAI,EAAE;EAAhB,CAAjB,CAAb;EAEA,iBAAUD,KAAV,cAAmBC,IAAnB;AACD,CALM"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getToday = void 0;
|
|
7
|
+
|
|
8
|
+
var _locale = require("@mirai/locale");
|
|
9
|
+
|
|
10
|
+
var getToday = function getToday() {
|
|
11
|
+
return (0, _locale.UTC)(new Date());
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.getToday = getToday;
|
|
15
|
+
//# sourceMappingURL=getToday.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getToday.js","names":["getToday","Date"],"sources":["../../../../src/components/Calendar/helpers/getToday.js"],"sourcesContent":["import { UTC } from '@mirai/locale';\n\nexport const getToday = () => UTC(new Date());\n"],"mappings":";;;;;;;AAAA;;AAEO,IAAMA,QAAQ,GAAG,SAAXA,QAAW;EAAA,OAAM,iBAAI,IAAIC,IAAJ,EAAJ,CAAN;AAAA,CAAjB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getWeekDays = void 0;
|
|
7
|
+
|
|
8
|
+
var _locale = require("@mirai/locale");
|
|
9
|
+
|
|
10
|
+
var _getToday = require("./getToday");
|
|
11
|
+
|
|
12
|
+
var getWeekDays = function getWeekDays(locale) {
|
|
13
|
+
var today = (0, _getToday.getToday)();
|
|
14
|
+
var weekdays = [];
|
|
15
|
+
var date = (0, _locale.UTC)(new Date(today.setDate(today.getDate() - today.getDay() + (today.getDay() === 0 ? -6 : 1))));
|
|
16
|
+
Array.from(Array(7).keys()).forEach(function () {
|
|
17
|
+
weekdays.push((0, _locale.dateFormat)(date, {
|
|
18
|
+
locale: locale,
|
|
19
|
+
weekday: 'short'
|
|
20
|
+
}).substr(0, 3));
|
|
21
|
+
date.setDate(date.getDate() + 1);
|
|
22
|
+
});
|
|
23
|
+
return weekdays;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
exports.getWeekDays = getWeekDays;
|
|
27
|
+
//# sourceMappingURL=getWeekDays.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getWeekDays.js","names":["getWeekDays","locale","today","weekdays","date","Date","setDate","getDate","getDay","Array","from","keys","forEach","push","weekday","substr"],"sources":["../../../../src/components/Calendar/helpers/getWeekDays.js"],"sourcesContent":["import { dateFormat, UTC } from '@mirai/locale';\n\nimport { getToday } from './getToday';\n\nexport const getWeekDays = (locale) => {\n const today = getToday();\n const weekdays = [];\n\n const date = UTC(new Date(today.setDate(today.getDate() - today.getDay() + (today.getDay() === 0 ? -6 : 1))));\n Array.from(Array(7).keys()).forEach(() => {\n weekdays.push(dateFormat(date, { locale, weekday: 'short' }).substr(0, 3));\n date.setDate(date.getDate() + 1);\n });\n\n return weekdays;\n};\n"],"mappings":";;;;;;;AAAA;;AAEA;;AAEO,IAAMA,WAAW,GAAG,SAAdA,WAAc,CAACC,MAAD,EAAY;EACrC,IAAMC,KAAK,GAAG,yBAAd;EACA,IAAMC,QAAQ,GAAG,EAAjB;EAEA,IAAMC,IAAI,GAAG,iBAAI,IAAIC,IAAJ,CAASH,KAAK,CAACI,OAAN,CAAcJ,KAAK,CAACK,OAAN,KAAkBL,KAAK,CAACM,MAAN,EAAlB,IAAoCN,KAAK,CAACM,MAAN,OAAmB,CAAnB,GAAuB,CAAC,CAAxB,GAA4B,CAAhE,CAAd,CAAT,CAAJ,CAAb;EACAC,KAAK,CAACC,IAAN,CAAWD,KAAK,CAAC,CAAD,CAAL,CAASE,IAAT,EAAX,EAA4BC,OAA5B,CAAoC,YAAM;IACxCT,QAAQ,CAACU,IAAT,CAAc,wBAAWT,IAAX,EAAiB;MAAEH,MAAM,EAANA,MAAF;MAAUa,OAAO,EAAE;IAAnB,CAAjB,EAA+CC,MAA/C,CAAsD,CAAtD,EAAyD,CAAzD,CAAd;IACAX,IAAI,CAACE,OAAL,CAAaF,IAAI,CAACG,OAAL,KAAiB,CAA9B;EACD,CAHD;EAKA,OAAOJ,QAAP;AACD,CAXM"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getWeekNumber = void 0;
|
|
7
|
+
|
|
8
|
+
var _locale = require("@mirai/locale");
|
|
9
|
+
|
|
10
|
+
var getWeekNumber = function getWeekNumber(date) {
|
|
11
|
+
var firstDayOfYear = (0, _locale.UTC)(new Date(date.getFullYear(), 0, 1));
|
|
12
|
+
var pastDaysOfYear = (Number(date) - Number(firstDayOfYear)) / 86400000;
|
|
13
|
+
return Math.ceil((pastDaysOfYear + firstDayOfYear.getDay()) / 7);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
exports.getWeekNumber = getWeekNumber;
|
|
17
|
+
//# sourceMappingURL=getWeekNumber.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getWeekNumber.js","names":["getWeekNumber","date","firstDayOfYear","Date","getFullYear","pastDaysOfYear","Number","Math","ceil","getDay"],"sources":["../../../../src/components/Calendar/helpers/getWeekNumber.js"],"sourcesContent":["import { UTC } from '@mirai/locale';\n\nexport const getWeekNumber = (date) => {\n const firstDayOfYear = UTC(new Date(date.getFullYear(), 0, 1));\n const pastDaysOfYear = (Number(date) - Number(firstDayOfYear)) / 86400000;\n\n return Math.ceil((pastDaysOfYear + firstDayOfYear.getDay()) / 7);\n};\n"],"mappings":";;;;;;;AAAA;;AAEO,IAAMA,aAAa,GAAG,SAAhBA,aAAgB,CAACC,IAAD,EAAU;EACrC,IAAMC,cAAc,GAAG,iBAAI,IAAIC,IAAJ,CAASF,IAAI,CAACG,WAAL,EAAT,EAA6B,CAA7B,EAAgC,CAAhC,CAAJ,CAAvB;EACA,IAAMC,cAAc,GAAG,CAACC,MAAM,CAACL,IAAD,CAAN,GAAeK,MAAM,CAACJ,cAAD,CAAtB,IAA0C,QAAjE;EAEA,OAAOK,IAAI,CAACC,IAAL,CAAU,CAACH,cAAc,GAAGH,cAAc,CAACO,MAAf,EAAlB,IAA6C,CAAvD,CAAP;AACD,CALM"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _getFirstDateOfMonth = require("./getFirstDateOfMonth");
|
|
8
|
+
|
|
9
|
+
Object.keys(_getFirstDateOfMonth).forEach(function (key) {
|
|
10
|
+
if (key === "default" || key === "__esModule") return;
|
|
11
|
+
if (key in exports && exports[key] === _getFirstDateOfMonth[key]) return;
|
|
12
|
+
Object.defineProperty(exports, key, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _getFirstDateOfMonth[key];
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
var _getFirstDateOfWeek = require("./getFirstDateOfWeek");
|
|
21
|
+
|
|
22
|
+
Object.keys(_getFirstDateOfWeek).forEach(function (key) {
|
|
23
|
+
if (key === "default" || key === "__esModule") return;
|
|
24
|
+
if (key in exports && exports[key] === _getFirstDateOfWeek[key]) return;
|
|
25
|
+
Object.defineProperty(exports, key, {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function get() {
|
|
28
|
+
return _getFirstDateOfWeek[key];
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
var _getHeader = require("./getHeader");
|
|
34
|
+
|
|
35
|
+
Object.keys(_getHeader).forEach(function (key) {
|
|
36
|
+
if (key === "default" || key === "__esModule") return;
|
|
37
|
+
if (key in exports && exports[key] === _getHeader[key]) return;
|
|
38
|
+
Object.defineProperty(exports, key, {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function get() {
|
|
41
|
+
return _getHeader[key];
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
var _getToday = require("./getToday");
|
|
47
|
+
|
|
48
|
+
Object.keys(_getToday).forEach(function (key) {
|
|
49
|
+
if (key === "default" || key === "__esModule") return;
|
|
50
|
+
if (key in exports && exports[key] === _getToday[key]) return;
|
|
51
|
+
Object.defineProperty(exports, key, {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function get() {
|
|
54
|
+
return _getToday[key];
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
var _getWeekDays = require("./getWeekDays");
|
|
60
|
+
|
|
61
|
+
Object.keys(_getWeekDays).forEach(function (key) {
|
|
62
|
+
if (key === "default" || key === "__esModule") return;
|
|
63
|
+
if (key in exports && exports[key] === _getWeekDays[key]) return;
|
|
64
|
+
Object.defineProperty(exports, key, {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
get: function get() {
|
|
67
|
+
return _getWeekDays[key];
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
var _getWeekNumber = require("./getWeekNumber");
|
|
73
|
+
|
|
74
|
+
Object.keys(_getWeekNumber).forEach(function (key) {
|
|
75
|
+
if (key === "default" || key === "__esModule") return;
|
|
76
|
+
if (key in exports && exports[key] === _getWeekNumber[key]) return;
|
|
77
|
+
Object.defineProperty(exports, key, {
|
|
78
|
+
enumerable: true,
|
|
79
|
+
get: function get() {
|
|
80
|
+
return _getWeekNumber[key];
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
var _isJest = require("./isJest");
|
|
86
|
+
|
|
87
|
+
Object.keys(_isJest).forEach(function (key) {
|
|
88
|
+
if (key === "default" || key === "__esModule") return;
|
|
89
|
+
if (key in exports && exports[key] === _isJest[key]) return;
|
|
90
|
+
Object.defineProperty(exports, key, {
|
|
91
|
+
enumerable: true,
|
|
92
|
+
get: function get() {
|
|
93
|
+
return _isJest[key];
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/Calendar/helpers/index.js"],"sourcesContent":["export * from './getFirstDateOfMonth';\nexport * from './getFirstDateOfWeek';\nexport * from './getHeader';\nexport * from './getToday';\nexport * from './getWeekDays';\nexport * from './getWeekNumber';\nexport * from './isJest';\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.IS_JEST = void 0;
|
|
7
|
+
var IS_JEST = !window && (process && process).env ? process.env.JEST_WORKER_ID !== undefined : false;
|
|
8
|
+
exports.IS_JEST = IS_JEST;
|
|
9
|
+
//# sourceMappingURL=isJest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isJest.js","names":["IS_JEST","window","process","env","JEST_WORKER_ID","undefined"],"sources":["../../../../src/components/Calendar/helpers/isJest.js"],"sourcesContent":["export const IS_JEST = !window && (process && process).env ? process.env.JEST_WORKER_ID !== undefined : false;\n"],"mappings":";;;;;;AAAO,IAAMA,OAAO,GAAG,CAACC,MAAD,IAAW,CAACC,OAAO,IAAIA,OAAZ,EAAqBC,GAAhC,GAAsCD,OAAO,CAACC,GAAR,CAAYC,cAAZ,KAA+BC,SAArE,GAAiF,KAAjG"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _Calendar = require("./Calendar");
|
|
8
|
+
|
|
9
|
+
Object.keys(_Calendar).forEach(function (key) {
|
|
10
|
+
if (key === "default" || key === "__esModule") return;
|
|
11
|
+
if (key in exports && exports[key] === _Calendar[key]) return;
|
|
12
|
+
Object.defineProperty(exports, key, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _Calendar[key];
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Calendar/index.js"],"sourcesContent":["export * from './Calendar';\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.Form = void 0;
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
+
|
|
14
|
+
var _helpers = require("./helpers");
|
|
15
|
+
|
|
16
|
+
var _excluded = ["children", "debounce", "schema", "showErrors", "validateOnMount", "onBlur", "onChange", "onError", "onFocus", "onSubmit"];
|
|
17
|
+
|
|
18
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
+
|
|
20
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
+
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
+
|
|
24
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
25
|
+
|
|
26
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
27
|
+
|
|
28
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
29
|
+
|
|
30
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
31
|
+
|
|
32
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
33
|
+
|
|
34
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
35
|
+
|
|
36
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
37
|
+
|
|
38
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
39
|
+
|
|
40
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
41
|
+
|
|
42
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
43
|
+
|
|
44
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
45
|
+
|
|
46
|
+
var Form = function Form(_ref) {
|
|
47
|
+
var children = _ref.children,
|
|
48
|
+
_ref$debounce = _ref.debounce,
|
|
49
|
+
debounce = _ref$debounce === void 0 ? 0 : _ref$debounce,
|
|
50
|
+
_ref$schema = _ref.schema,
|
|
51
|
+
schema = _ref$schema === void 0 ? {} : _ref$schema,
|
|
52
|
+
showErrors = _ref.showErrors,
|
|
53
|
+
_ref$validateOnMount = _ref.validateOnMount,
|
|
54
|
+
validateOnMount = _ref$validateOnMount === void 0 ? false : _ref$validateOnMount,
|
|
55
|
+
onBlur = _ref.onBlur,
|
|
56
|
+
onChange = _ref.onChange,
|
|
57
|
+
onError = _ref.onError,
|
|
58
|
+
onFocus = _ref.onFocus,
|
|
59
|
+
onSubmit = _ref.onSubmit,
|
|
60
|
+
others = _objectWithoutProperties(_ref, _excluded);
|
|
61
|
+
|
|
62
|
+
var _useState = (0, _react.useState)({}),
|
|
63
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
64
|
+
error = _useState2[0],
|
|
65
|
+
setError = _useState2[1];
|
|
66
|
+
|
|
67
|
+
var _useState3 = (0, _react.useState)({}),
|
|
68
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
69
|
+
initialValue = _useState4[0],
|
|
70
|
+
setInitialValue = _useState4[1];
|
|
71
|
+
|
|
72
|
+
var _useState5 = (0, _react.useState)({}),
|
|
73
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
74
|
+
touched = _useState6[0],
|
|
75
|
+
setTouched = _useState6[1];
|
|
76
|
+
|
|
77
|
+
var _useState7 = (0, _react.useState)({}),
|
|
78
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
79
|
+
values = _useState8[0],
|
|
80
|
+
setValues = _useState8[1];
|
|
81
|
+
|
|
82
|
+
(0, _react.useEffect)(function () {
|
|
83
|
+
var nextValues = (0, _helpers.getChildrenValues)(children);
|
|
84
|
+
var nextChildrenKeys = Object.keys(nextValues).sort();
|
|
85
|
+
|
|
86
|
+
if (JSON.stringify(nextChildrenKeys) !== JSON.stringify(Object.keys(initialValue).sort())) {
|
|
87
|
+
setInitialValue(nextValues);
|
|
88
|
+
setValues(nextValues);
|
|
89
|
+
|
|
90
|
+
if (validateOnMount) {
|
|
91
|
+
var nextError = (0, _helpers.getChildrenErrors)({
|
|
92
|
+
children: children,
|
|
93
|
+
schema: schema,
|
|
94
|
+
values: nextValues
|
|
95
|
+
});
|
|
96
|
+
setError(nextError);
|
|
97
|
+
onError && onError(nextError);
|
|
98
|
+
} else {
|
|
99
|
+
setError({});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
setTouched({});
|
|
103
|
+
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
104
|
+
|
|
105
|
+
}, [children]);
|
|
106
|
+
(0, _react.useEffect)(function () {
|
|
107
|
+
if (!onChange || values === initialValue) return;
|
|
108
|
+
var timer = setTimeout(function () {
|
|
109
|
+
return onChange(values, (0, _helpers.groupState)({
|
|
110
|
+
initialValue: initialValue,
|
|
111
|
+
value: values,
|
|
112
|
+
touched: touched
|
|
113
|
+
}));
|
|
114
|
+
}, debounce);
|
|
115
|
+
return function () {
|
|
116
|
+
return clearTimeout(timer);
|
|
117
|
+
}; // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
118
|
+
}, [values]);
|
|
119
|
+
|
|
120
|
+
var handleChange = function handleChange(field, fieldValue) {
|
|
121
|
+
setValues(function () {
|
|
122
|
+
var nextValues = _objectSpread(_objectSpread({}, values), {}, _defineProperty({}, field, fieldValue));
|
|
123
|
+
|
|
124
|
+
handleError(nextValues);
|
|
125
|
+
return nextValues;
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
var handleError = function handleError(values) {
|
|
130
|
+
var nextError = (0, _helpers.getChildrenErrors)({
|
|
131
|
+
children: children,
|
|
132
|
+
schema: schema,
|
|
133
|
+
values: values
|
|
134
|
+
});
|
|
135
|
+
var hasError = Object.keys(nextError).length > 0;
|
|
136
|
+
var changed = JSON.stringify(error) !== JSON.stringify(nextError);
|
|
137
|
+
|
|
138
|
+
if (changed) {
|
|
139
|
+
setError(nextError);
|
|
140
|
+
onError && onError(nextError, hasError);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return {
|
|
144
|
+
changed: changed,
|
|
145
|
+
errors: nextError,
|
|
146
|
+
hasError: hasError
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
var handleFocus = function handleFocus(field, event) {
|
|
151
|
+
setTouched(_objectSpread(_objectSpread({}, touched), {}, _defineProperty({}, field, true)));
|
|
152
|
+
if (onFocus) onFocus(field, event);
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
var handleSubmit = function handleSubmit(event) {
|
|
156
|
+
var _handleError = handleError(values),
|
|
157
|
+
errors = _handleError.errors,
|
|
158
|
+
hasError = _handleError.hasError;
|
|
159
|
+
|
|
160
|
+
if (hasError && onError) onError(errors, hasError);else if (onSubmit) onSubmit(values, (0, _helpers.groupState)({
|
|
161
|
+
initialValue: initialValue,
|
|
162
|
+
value: values,
|
|
163
|
+
touched: touched
|
|
164
|
+
}), event);
|
|
165
|
+
event.preventDefault();
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
return (0, _react.useMemo)(function () {
|
|
169
|
+
return /*#__PURE__*/_react.default.createElement("form", {
|
|
170
|
+
"data-testid": others['data-testid'],
|
|
171
|
+
style: others.style,
|
|
172
|
+
onSubmit: handleSubmit
|
|
173
|
+
}, _react.default.Children.map(children, function (child, index) {
|
|
174
|
+
if (!child || child === null) return;
|
|
175
|
+
|
|
176
|
+
var _ref2 = child || {},
|
|
177
|
+
_ref2$props = _ref2.props,
|
|
178
|
+
props = _ref2$props === void 0 ? {} : _ref2$props;
|
|
179
|
+
|
|
180
|
+
var type = props.type;
|
|
181
|
+
var field = (0, _helpers.getField)(props);
|
|
182
|
+
return /*#__PURE__*/_react.default.cloneElement(child, _objectSpread({
|
|
183
|
+
key: index
|
|
184
|
+
}, field ? _objectSpread(_objectSpread(_objectSpread({}, props), schema[field]), {}, {
|
|
185
|
+
error: props.error ? props.error : showErrors && error[field],
|
|
186
|
+
onBlur: onBlur ? function (event) {
|
|
187
|
+
return onBlur(field, event);
|
|
188
|
+
} : undefined,
|
|
189
|
+
onChange: function onChange(value) {
|
|
190
|
+
return handleChange(field, value);
|
|
191
|
+
},
|
|
192
|
+
onFocus: function onFocus(event) {
|
|
193
|
+
return handleFocus(field, event);
|
|
194
|
+
}
|
|
195
|
+
}) : type === 'submit' ? _objectSpread(_objectSpread({}, props), {}, {
|
|
196
|
+
onPress: handleSubmit
|
|
197
|
+
}) : undefined));
|
|
198
|
+
}));
|
|
199
|
+
}, // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
200
|
+
[children, error, others, schema]);
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
exports.Form = Form;
|
|
204
|
+
Form.displayName = 'Component:Form';
|
|
205
|
+
Form.propTypes = {
|
|
206
|
+
children: _propTypes.default.node,
|
|
207
|
+
debounce: _propTypes.default.number,
|
|
208
|
+
schema: _propTypes.default.shape({}),
|
|
209
|
+
showErrors: _propTypes.default.bool,
|
|
210
|
+
validateOnMount: _propTypes.default.bool,
|
|
211
|
+
onBlur: _propTypes.default.func,
|
|
212
|
+
onChange: _propTypes.default.func,
|
|
213
|
+
onError: _propTypes.default.func,
|
|
214
|
+
onFocus: _propTypes.default.func,
|
|
215
|
+
onSubmit: _propTypes.default.func
|
|
216
|
+
};
|
|
217
|
+
//# sourceMappingURL=Form.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Form.js","names":["Form","children","debounce","schema","showErrors","validateOnMount","onBlur","onChange","onError","onFocus","onSubmit","others","error","setError","initialValue","setInitialValue","touched","setTouched","values","setValues","nextValues","nextChildrenKeys","Object","keys","sort","JSON","stringify","nextError","timer","setTimeout","value","clearTimeout","handleChange","field","fieldValue","handleError","hasError","length","changed","errors","handleFocus","event","handleSubmit","preventDefault","style","React","Children","map","child","index","props","type","cloneElement","key","undefined","onPress","displayName","propTypes","PropTypes","node","number","shape","bool","func"],"sources":["../../../src/components/Form/Form.jsx"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React, { useEffect, useMemo, useState } from 'react';\n\nimport { getChildrenErrors, getChildrenValues, getField, groupState } from './helpers';\n\nconst Form = ({\n children,\n debounce = 0,\n schema = {},\n showErrors,\n validateOnMount = false,\n onBlur,\n onChange,\n onError,\n onFocus,\n onSubmit,\n ...others\n}) => {\n const [error, setError] = useState({});\n const [initialValue, setInitialValue] = useState({});\n const [touched, setTouched] = useState({});\n const [values, setValues] = useState({});\n\n useEffect(() => {\n const nextValues = getChildrenValues(children);\n const nextChildrenKeys = Object.keys(nextValues).sort();\n\n if (JSON.stringify(nextChildrenKeys) !== JSON.stringify(Object.keys(initialValue).sort())) {\n setInitialValue(nextValues);\n setValues(nextValues);\n\n if (validateOnMount) {\n const nextError = getChildrenErrors({ children, schema, values: nextValues });\n setError(nextError);\n onError && onError(nextError);\n } else {\n setError({});\n }\n setTouched({});\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [children]);\n\n useEffect(() => {\n if (!onChange || values === initialValue) return;\n\n const timer = setTimeout(() => onChange(values, groupState({ initialValue, value: values, touched })), debounce);\n return () => clearTimeout(timer);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [values]);\n\n const handleChange = (field, fieldValue) => {\n setValues(() => {\n const nextValues = { ...values, [field]: fieldValue };\n\n handleError(nextValues);\n\n return nextValues;\n });\n };\n\n const handleError = (values) => {\n const nextError = getChildrenErrors({ children, schema, values });\n const hasError = Object.keys(nextError).length > 0;\n const changed = JSON.stringify(error) !== JSON.stringify(nextError);\n\n if (changed) {\n setError(nextError);\n onError && onError(nextError, hasError);\n }\n\n return { changed, errors: nextError, hasError };\n };\n\n const handleFocus = (field, event) => {\n setTouched({ ...touched, [field]: true });\n if (onFocus) onFocus(field, event);\n };\n\n const handleSubmit = (event) => {\n const { errors, hasError } = handleError(values);\n\n if (hasError && onError) onError(errors, hasError);\n else if (onSubmit) onSubmit(values, groupState({ initialValue, value: values, touched }), event);\n event.preventDefault();\n };\n\n return useMemo(\n () => (\n <form data-testid={others['data-testid']} style={others.style} onSubmit={handleSubmit}>\n {React.Children.map(children, (child, index) => {\n if (!child || child === null) return;\n\n const { props = {} } = child || {};\n const { type } = props;\n const field = getField(props);\n\n return React.cloneElement(child, {\n key: index,\n ...(field\n ? {\n ...props,\n ...schema[field],\n error: props.error ? props.error : showErrors && error[field],\n onBlur: onBlur ? (event) => onBlur(field, event) : undefined,\n onChange: (value) => handleChange(field, value),\n onFocus: (event) => handleFocus(field, event),\n }\n : type === 'submit'\n ? { ...props, onPress: handleSubmit }\n : undefined),\n });\n })}\n </form>\n ),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [children, error, others, schema],\n );\n};\n\nForm.displayName = 'Component:Form';\n\nForm.propTypes = {\n children: PropTypes.node,\n debounce: PropTypes.number,\n schema: PropTypes.shape({}),\n showErrors: PropTypes.bool,\n validateOnMount: PropTypes.bool,\n onBlur: PropTypes.func,\n onChange: PropTypes.func,\n onError: PropTypes.func,\n onFocus: PropTypes.func,\n onSubmit: PropTypes.func,\n};\n\nexport { Form };\n"],"mappings":"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"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`component:<Form> inherit:className 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<form />
|
|
6
|
+
</DocumentFragment>
|
|
7
|
+
`;
|
|
8
|
+
|
|
9
|
+
exports[`component:<Form> prop:children 1`] = `
|
|
10
|
+
<DocumentFragment>
|
|
11
|
+
<form>
|
|
12
|
+
<div
|
|
13
|
+
class="view inputContainer"
|
|
14
|
+
>
|
|
15
|
+
<span
|
|
16
|
+
class="text paragraph text label"
|
|
17
|
+
>
|
|
18
|
+
label
|
|
19
|
+
</span>
|
|
20
|
+
<div
|
|
21
|
+
class="view row inputBorder"
|
|
22
|
+
>
|
|
23
|
+
<input
|
|
24
|
+
class="input input"
|
|
25
|
+
name="name"
|
|
26
|
+
type="text"
|
|
27
|
+
value=""
|
|
28
|
+
/>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
</form>
|
|
32
|
+
</DocumentFragment>
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
exports[`component:<Form> renders 1`] = `
|
|
36
|
+
<DocumentFragment>
|
|
37
|
+
<form />
|
|
38
|
+
</DocumentFragment>
|
|
39
|
+
`;
|
|
40
|
+
|
|
41
|
+
exports[`component:<Form> testID 1`] = `
|
|
42
|
+
<DocumentFragment>
|
|
43
|
+
<form
|
|
44
|
+
data-testid="mirai"
|
|
45
|
+
/>
|
|
46
|
+
</DocumentFragment>
|
|
47
|
+
`;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getChildrenErrors = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _helpers = require("../../../helpers");
|
|
11
|
+
|
|
12
|
+
var _getField = require("./getField");
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
+
|
|
18
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
|
+
|
|
20
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
21
|
+
|
|
22
|
+
var getChildrenErrors = function getChildrenErrors() {
|
|
23
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
24
|
+
children = _ref.children,
|
|
25
|
+
_ref$schema = _ref.schema,
|
|
26
|
+
schema = _ref$schema === void 0 ? {} : _ref$schema,
|
|
27
|
+
_ref$values = _ref.values,
|
|
28
|
+
values = _ref$values === void 0 ? {} : _ref$values;
|
|
29
|
+
|
|
30
|
+
var errors = {};
|
|
31
|
+
|
|
32
|
+
_react.default.Children.forEach(children, function () {
|
|
33
|
+
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
34
|
+
_ref2$props = _ref2.props,
|
|
35
|
+
props = _ref2$props === void 0 ? {} : _ref2$props;
|
|
36
|
+
|
|
37
|
+
var field = (0, _getField.getField)(props);
|
|
38
|
+
|
|
39
|
+
if (field) {
|
|
40
|
+
var inputErrors = (0, _helpers.getInputErrors)(_objectSpread(_objectSpread(_objectSpread({}, props), schema[field]), {}, {
|
|
41
|
+
value: values[field]
|
|
42
|
+
}));
|
|
43
|
+
if (inputErrors) errors[field] = inputErrors;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
return errors;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
exports.getChildrenErrors = getChildrenErrors;
|
|
51
|
+
//# sourceMappingURL=getChildrenErrors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getChildrenErrors.js","names":["getChildrenErrors","children","schema","values","errors","React","Children","forEach","props","field","inputErrors","value"],"sources":["../../../../src/components/Form/helpers/getChildrenErrors.js"],"sourcesContent":["import React from 'react';\n\nimport { getInputErrors } from '../../../helpers';\nimport { getField } from './getField';\n\nexport const getChildrenErrors = ({ children, schema = {}, values = {} } = {}) => {\n const errors = {};\n\n React.Children.forEach(children, ({ props = {} } = {}) => {\n const field = getField(props);\n\n if (field) {\n const inputErrors = getInputErrors({ ...props, ...schema[field], value: values[field] });\n if (inputErrors) errors[field] = inputErrors;\n }\n });\n\n return errors;\n};\n"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;;;;;;;;;AAEO,IAAMA,iBAAiB,GAAG,SAApBA,iBAAoB,GAAiD;EAAA,+EAAP,EAAO;EAAA,IAA9CC,QAA8C,QAA9CA,QAA8C;EAAA,uBAApCC,MAAoC;EAAA,IAApCA,MAAoC,4BAA3B,EAA2B;EAAA,uBAAvBC,MAAuB;EAAA,IAAvBA,MAAuB,4BAAd,EAAc;;EAChF,IAAMC,MAAM,GAAG,EAAf;;EAEAC,eAAMC,QAAN,CAAeC,OAAf,CAAuBN,QAAvB,EAAiC,YAAyB;IAAA,gFAAP,EAAO;IAAA,wBAAtBO,KAAsB;IAAA,IAAtBA,KAAsB,4BAAd,EAAc;;IACxD,IAAMC,KAAK,GAAG,wBAASD,KAAT,CAAd;;IAEA,IAAIC,KAAJ,EAAW;MACT,IAAMC,WAAW,GAAG,2EAAoBF,KAApB,GAA8BN,MAAM,CAACO,KAAD,CAApC;QAA6CE,KAAK,EAAER,MAAM,CAACM,KAAD;MAA1D,GAApB;MACA,IAAIC,WAAJ,EAAiBN,MAAM,CAACK,KAAD,CAAN,GAAgBC,WAAhB;IAClB;EACF,CAPD;;EASA,OAAON,MAAP;AACD,CAbM"}
|