@contentful/field-editor-date 1.7.0 → 1.7.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.
|
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "DatepickerInput", {
|
|
|
8
8
|
return DatepickerInput;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _react =
|
|
11
|
+
const _react = _interop_require_wildcard(require("react"));
|
|
12
12
|
const _f36components = require("@contentful/f36-components");
|
|
13
13
|
const _emotion = require("emotion");
|
|
14
14
|
const _moment = _interop_require_default(require("moment"));
|
|
@@ -17,12 +17,64 @@ function _interop_require_default(obj) {
|
|
|
17
17
|
default: obj
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
21
|
+
if (typeof WeakMap !== "function") return null;
|
|
22
|
+
var cacheBabelInterop = new WeakMap();
|
|
23
|
+
var cacheNodeInterop = new WeakMap();
|
|
24
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
25
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
26
|
+
})(nodeInterop);
|
|
27
|
+
}
|
|
28
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
29
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
30
|
+
return obj;
|
|
31
|
+
}
|
|
32
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
33
|
+
return {
|
|
34
|
+
default: obj
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
38
|
+
if (cache && cache.has(obj)) {
|
|
39
|
+
return cache.get(obj);
|
|
40
|
+
}
|
|
41
|
+
var newObj = {
|
|
42
|
+
__proto__: null
|
|
43
|
+
};
|
|
44
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
45
|
+
for(var key in obj){
|
|
46
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
47
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
48
|
+
if (desc && (desc.get || desc.set)) {
|
|
49
|
+
Object.defineProperty(newObj, key, desc);
|
|
50
|
+
} else {
|
|
51
|
+
newObj[key] = obj[key];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
newObj.default = obj;
|
|
56
|
+
if (cache) {
|
|
57
|
+
cache.set(obj, newObj);
|
|
58
|
+
}
|
|
59
|
+
return newObj;
|
|
60
|
+
}
|
|
61
|
+
const YEARS_INTO_FUTURE = 100;
|
|
62
|
+
const MIN_YEAR = '1000';
|
|
20
63
|
const styles = {
|
|
21
64
|
root: (0, _emotion.css)({
|
|
22
65
|
maxWidth: '270px'
|
|
23
66
|
})
|
|
24
67
|
};
|
|
25
68
|
const DatepickerInput = (props)=>{
|
|
69
|
+
const [fromDate, toDate] = (0, _react.useMemo)(()=>{
|
|
70
|
+
const fromDate = new Date(MIN_YEAR);
|
|
71
|
+
const toDate = new Date();
|
|
72
|
+
toDate.setFullYear(toDate.getFullYear() + YEARS_INTO_FUTURE);
|
|
73
|
+
return [
|
|
74
|
+
fromDate,
|
|
75
|
+
toDate
|
|
76
|
+
];
|
|
77
|
+
}, []);
|
|
26
78
|
const dateObj = props.value?.toObject();
|
|
27
79
|
const selectedDate = dateObj ? new Date(dateObj.years, dateObj.months, dateObj.date) : undefined;
|
|
28
80
|
return _react.default.createElement(_f36components.Datepicker, {
|
|
@@ -35,6 +87,8 @@ const DatepickerInput = (props)=>{
|
|
|
35
87
|
inputProps: {
|
|
36
88
|
isDisabled: props.disabled,
|
|
37
89
|
placeholder: ''
|
|
38
|
-
}
|
|
90
|
+
},
|
|
91
|
+
fromDate: fromDate,
|
|
92
|
+
toDate: toDate
|
|
39
93
|
});
|
|
40
94
|
};
|
|
@@ -1,13 +1,24 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
2
|
import { Datepicker } from '@contentful/f36-components';
|
|
3
3
|
import { css } from 'emotion';
|
|
4
4
|
import moment from 'moment';
|
|
5
|
+
const YEARS_INTO_FUTURE = 100;
|
|
6
|
+
const MIN_YEAR = '1000';
|
|
5
7
|
const styles = {
|
|
6
8
|
root: css({
|
|
7
9
|
maxWidth: '270px'
|
|
8
10
|
})
|
|
9
11
|
};
|
|
10
12
|
export const DatepickerInput = (props)=>{
|
|
13
|
+
const [fromDate, toDate] = useMemo(()=>{
|
|
14
|
+
const fromDate = new Date(MIN_YEAR);
|
|
15
|
+
const toDate = new Date();
|
|
16
|
+
toDate.setFullYear(toDate.getFullYear() + YEARS_INTO_FUTURE);
|
|
17
|
+
return [
|
|
18
|
+
fromDate,
|
|
19
|
+
toDate
|
|
20
|
+
];
|
|
21
|
+
}, []);
|
|
11
22
|
const dateObj = props.value?.toObject();
|
|
12
23
|
const selectedDate = dateObj ? new Date(dateObj.years, dateObj.months, dateObj.date) : undefined;
|
|
13
24
|
return React.createElement(Datepicker, {
|
|
@@ -20,6 +31,8 @@ export const DatepickerInput = (props)=>{
|
|
|
20
31
|
inputProps: {
|
|
21
32
|
isDisabled: props.disabled,
|
|
22
33
|
placeholder: ''
|
|
23
|
-
}
|
|
34
|
+
},
|
|
35
|
+
fromDate: fromDate,
|
|
36
|
+
toDate: toDate
|
|
24
37
|
});
|
|
25
38
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-date",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.2",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@contentful/f36-components": "^4.70.0",
|
|
40
40
|
"@contentful/f36-tokens": "^4.0.5",
|
|
41
|
-
"@contentful/field-editor-shared": "^2.3.
|
|
41
|
+
"@contentful/field-editor-shared": "^2.3.1",
|
|
42
42
|
"emotion": "^10.0.17",
|
|
43
43
|
"moment": "^2.20.0"
|
|
44
44
|
},
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"registry": "https://npm.pkg.github.com/"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "21b8e36ce7ed50abfe2a3a477103d5de1043674b"
|
|
58
58
|
}
|