@contentful/field-editor-date 1.6.28 → 1.7.0

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 = _interop_require_wildcard(require("react"));
11
+ const _react = _interop_require_default(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,64 +17,12 @@ 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 YEAR_RANGE = 100;
62
20
  const styles = {
63
21
  root: (0, _emotion.css)({
64
22
  maxWidth: '270px'
65
23
  })
66
24
  };
67
25
  const DatepickerInput = (props)=>{
68
- const [fromDate, toDate] = (0, _react.useMemo)(()=>{
69
- const fromDate = new Date();
70
- fromDate.setFullYear(fromDate.getFullYear() - YEAR_RANGE);
71
- const toDate = new Date();
72
- toDate.setFullYear(toDate.getFullYear() + YEAR_RANGE);
73
- return [
74
- fromDate,
75
- toDate
76
- ];
77
- }, []);
78
26
  const dateObj = props.value?.toObject();
79
27
  const selectedDate = dateObj ? new Date(dateObj.years, dateObj.months, dateObj.date) : undefined;
80
28
  return _react.default.createElement(_f36components.Datepicker, {
@@ -87,8 +35,6 @@ const DatepickerInput = (props)=>{
87
35
  inputProps: {
88
36
  isDisabled: props.disabled,
89
37
  placeholder: ''
90
- },
91
- fromDate: fromDate,
92
- toDate: toDate
38
+ }
93
39
  });
94
40
  };
@@ -1,24 +1,13 @@
1
- import React, { useMemo } from 'react';
1
+ import React from 'react';
2
2
  import { Datepicker } from '@contentful/f36-components';
3
3
  import { css } from 'emotion';
4
4
  import moment from 'moment';
5
- const YEAR_RANGE = 100;
6
5
  const styles = {
7
6
  root: css({
8
7
  maxWidth: '270px'
9
8
  })
10
9
  };
11
10
  export const DatepickerInput = (props)=>{
12
- const [fromDate, toDate] = useMemo(()=>{
13
- const fromDate = new Date();
14
- fromDate.setFullYear(fromDate.getFullYear() - YEAR_RANGE);
15
- const toDate = new Date();
16
- toDate.setFullYear(toDate.getFullYear() + YEAR_RANGE);
17
- return [
18
- fromDate,
19
- toDate
20
- ];
21
- }, []);
22
11
  const dateObj = props.value?.toObject();
23
12
  const selectedDate = dateObj ? new Date(dateObj.years, dateObj.months, dateObj.date) : undefined;
24
13
  return React.createElement(Datepicker, {
@@ -31,8 +20,6 @@ export const DatepickerInput = (props)=>{
31
20
  inputProps: {
32
21
  isDisabled: props.disabled,
33
22
  placeholder: ''
34
- },
35
- fromDate: fromDate,
36
- toDate: toDate
23
+ }
37
24
  });
38
25
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/field-editor-date",
3
- "version": "1.6.28",
3
+ "version": "1.7.0",
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.2.3",
41
+ "@contentful/field-editor-shared": "^2.3.0",
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": "58badec95e1faa6cc187f72e9da7627002618562"
57
+ "gitHead": "b533366fc5633e288dee85a7c5584d7fa0100ded"
58
58
  }