@contentful/field-editor-date 1.6.2 → 1.6.5
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/dist/cjs/DateEditor.js +7 -5
- package/dist/cjs/DatepickerInput.js +3 -1
- package/dist/cjs/TimepickerInput.js +4 -2
- package/dist/cjs/TimezonePickerInput.js +1 -1
- package/dist/cjs/utils/date.js +2 -2
- package/dist/esm/DateEditor.js +4 -4
- package/dist/esm/TimepickerInput.js +1 -1
- package/dist/esm/TimezonePickerInput.js +1 -1
- package/dist/esm/utils/date.js +2 -2
- package/dist/types/DateEditor.d.ts +2 -2
- package/dist/types/DatepickerInput.d.ts +2 -2
- package/dist/types/TimepickerInput.d.ts +2 -2
- package/dist/types/TimezonePickerInput.d.ts +2 -2
- package/package.json +7 -4
package/dist/cjs/DateEditor.js
CHANGED
|
@@ -43,7 +43,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
43
43
|
if (cache && cache.has(obj)) {
|
|
44
44
|
return cache.get(obj);
|
|
45
45
|
}
|
|
46
|
-
var newObj = {
|
|
46
|
+
var newObj = {
|
|
47
|
+
__proto__: null
|
|
48
|
+
};
|
|
47
49
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
48
50
|
for(var key in obj){
|
|
49
51
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -80,7 +82,7 @@ function useEffectWithoutFirstRender(callback, deps) {
|
|
|
80
82
|
callback();
|
|
81
83
|
}, deps);
|
|
82
84
|
}
|
|
83
|
-
function DateEditorContainer({ initialValue
|
|
85
|
+
function DateEditorContainer({ initialValue, usesTime, usesTimezone, uses12hClock, disabled, hasClear, onChange }) {
|
|
84
86
|
const [value, setValue] = _react.useState(()=>initialValue);
|
|
85
87
|
useEffectWithoutFirstRender(()=>{
|
|
86
88
|
onChange(value);
|
|
@@ -105,7 +107,7 @@ function DateEditorContainer({ initialValue , usesTime , usesTimezone , uses12hC
|
|
|
105
107
|
disabled: disabled,
|
|
106
108
|
time: value.time,
|
|
107
109
|
ampm: value.ampm,
|
|
108
|
-
onChange: ({ time
|
|
110
|
+
onChange: ({ time, ampm })=>{
|
|
109
111
|
setValue((value)=>({
|
|
110
112
|
...value,
|
|
111
113
|
time,
|
|
@@ -141,7 +143,7 @@ function DateEditorContainer({ initialValue , usesTime , usesTimezone , uses12hC
|
|
|
141
143
|
}, "Clear")));
|
|
142
144
|
}
|
|
143
145
|
function DateEditor(props) {
|
|
144
|
-
const { field
|
|
146
|
+
const { field, parameters } = props;
|
|
145
147
|
const formatParam = parameters?.instance?.format ?? 'timeZ';
|
|
146
148
|
const ampmParam = parameters?.instance?.ampm ?? '24';
|
|
147
149
|
const usesTime = formatParam !== 'dateonly';
|
|
@@ -152,7 +154,7 @@ function DateEditor(props) {
|
|
|
152
154
|
isInitiallyDisabled: props.isInitiallyDisabled,
|
|
153
155
|
isDisabled: props.isDisabled,
|
|
154
156
|
debounce: 0
|
|
155
|
-
}, ({ value
|
|
157
|
+
}, ({ value, disabled, setValue, externalReset })=>{
|
|
156
158
|
const datetimeValue = (0, _date.userInputFromDatetime)({
|
|
157
159
|
value,
|
|
158
160
|
uses12hClock
|
|
@@ -38,7 +38,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
38
38
|
if (cache && cache.has(obj)) {
|
|
39
39
|
return cache.get(obj);
|
|
40
40
|
}
|
|
41
|
-
var newObj = {
|
|
41
|
+
var newObj = {
|
|
42
|
+
__proto__: null
|
|
43
|
+
};
|
|
42
44
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
43
45
|
for(var key in obj){
|
|
44
46
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -38,7 +38,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
38
38
|
if (cache && cache.has(obj)) {
|
|
39
39
|
return cache.get(obj);
|
|
40
40
|
}
|
|
41
|
-
var newObj = {
|
|
41
|
+
var newObj = {
|
|
42
|
+
__proto__: null
|
|
43
|
+
};
|
|
42
44
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
43
45
|
for(var key in obj){
|
|
44
46
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -87,7 +89,7 @@ const getDefaultTime = ()=>{
|
|
|
87
89
|
const formatToString = (uses12hClock, value)=>{
|
|
88
90
|
return uses12hClock ? value.format('hh:mm A') : value.format('HH:mm');
|
|
89
91
|
};
|
|
90
|
-
const TimepickerInput = ({ disabled
|
|
92
|
+
const TimepickerInput = ({ disabled, uses12hClock, time = '12:00', ampm = 'AM', onChange })=>{
|
|
91
93
|
const [selectedTime, setSelectedTime] = (0, _react.useState)(()=>{
|
|
92
94
|
return formatToString(uses12hClock, getDefaultTime());
|
|
93
95
|
});
|
|
@@ -16,7 +16,7 @@ function _interop_require_default(obj) {
|
|
|
16
16
|
default: obj
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
-
const TimezonepickerInput = ({ disabled
|
|
19
|
+
const TimezonepickerInput = ({ disabled, onChange, value = _zoneOffsets.defaultZoneOffset })=>{
|
|
20
20
|
return _react.default.createElement(_f36components.Select, {
|
|
21
21
|
"aria-label": "Select timezone",
|
|
22
22
|
testId: "timezone-input",
|
package/dist/cjs/utils/date.js
CHANGED
|
@@ -71,7 +71,7 @@ function datetimeFromUserInput(input) {
|
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
-
function buildFieldValue({ data
|
|
74
|
+
function buildFieldValue({ data, usesTime, usesTimezone }) {
|
|
75
75
|
const date = datetimeFromUserInput(data);
|
|
76
76
|
if (date.invalid) {
|
|
77
77
|
return {
|
|
@@ -97,7 +97,7 @@ function getDefaultAMPM() {
|
|
|
97
97
|
function getDefaultUtcOffset() {
|
|
98
98
|
return startOfToday('Z');
|
|
99
99
|
}
|
|
100
|
-
function userInputFromDatetime({ value
|
|
100
|
+
function userInputFromDatetime({ value, uses12hClock }) {
|
|
101
101
|
const datetime = fieldValueToMoment(value);
|
|
102
102
|
if (datetime) {
|
|
103
103
|
const timeFormat = uses12hClock ? 'hh:mm' : 'HH:mm';
|
package/dist/esm/DateEditor.js
CHANGED
|
@@ -26,7 +26,7 @@ function useEffectWithoutFirstRender(callback, deps) {
|
|
|
26
26
|
callback();
|
|
27
27
|
}, deps);
|
|
28
28
|
}
|
|
29
|
-
function DateEditorContainer({ initialValue
|
|
29
|
+
function DateEditorContainer({ initialValue, usesTime, usesTimezone, uses12hClock, disabled, hasClear, onChange }) {
|
|
30
30
|
const [value, setValue] = React.useState(()=>initialValue);
|
|
31
31
|
useEffectWithoutFirstRender(()=>{
|
|
32
32
|
onChange(value);
|
|
@@ -51,7 +51,7 @@ function DateEditorContainer({ initialValue , usesTime , usesTimezone , uses12hC
|
|
|
51
51
|
disabled: disabled,
|
|
52
52
|
time: value.time,
|
|
53
53
|
ampm: value.ampm,
|
|
54
|
-
onChange: ({ time
|
|
54
|
+
onChange: ({ time, ampm })=>{
|
|
55
55
|
setValue((value)=>({
|
|
56
56
|
...value,
|
|
57
57
|
time,
|
|
@@ -87,7 +87,7 @@ function DateEditorContainer({ initialValue , usesTime , usesTimezone , uses12hC
|
|
|
87
87
|
}, "Clear")));
|
|
88
88
|
}
|
|
89
89
|
export function DateEditor(props) {
|
|
90
|
-
const { field
|
|
90
|
+
const { field, parameters } = props;
|
|
91
91
|
const formatParam = parameters?.instance?.format ?? 'timeZ';
|
|
92
92
|
const ampmParam = parameters?.instance?.ampm ?? '24';
|
|
93
93
|
const usesTime = formatParam !== 'dateonly';
|
|
@@ -98,7 +98,7 @@ export function DateEditor(props) {
|
|
|
98
98
|
isInitiallyDisabled: props.isInitiallyDisabled,
|
|
99
99
|
isDisabled: props.isDisabled,
|
|
100
100
|
debounce: 0
|
|
101
|
-
}, ({ value
|
|
101
|
+
}, ({ value, disabled, setValue, externalReset })=>{
|
|
102
102
|
const datetimeValue = userInputFromDatetime({
|
|
103
103
|
value,
|
|
104
104
|
uses12hClock
|
|
@@ -33,7 +33,7 @@ const getDefaultTime = ()=>{
|
|
|
33
33
|
const formatToString = (uses12hClock, value)=>{
|
|
34
34
|
return uses12hClock ? value.format('hh:mm A') : value.format('HH:mm');
|
|
35
35
|
};
|
|
36
|
-
export const TimepickerInput = ({ disabled
|
|
36
|
+
export const TimepickerInput = ({ disabled, uses12hClock, time = '12:00', ampm = 'AM', onChange })=>{
|
|
37
37
|
const [selectedTime, setSelectedTime] = useState(()=>{
|
|
38
38
|
return formatToString(uses12hClock, getDefaultTime());
|
|
39
39
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Select } from '@contentful/f36-components';
|
|
3
3
|
import { zoneOffsets, defaultZoneOffset } from './utils/zoneOffsets';
|
|
4
|
-
export const TimezonepickerInput = ({ disabled
|
|
4
|
+
export const TimezonepickerInput = ({ disabled, onChange, value = defaultZoneOffset })=>{
|
|
5
5
|
return React.createElement(Select, {
|
|
6
6
|
"aria-label": "Select timezone",
|
|
7
7
|
testId: "timezone-input",
|
package/dist/esm/utils/date.js
CHANGED
|
@@ -42,7 +42,7 @@ function datetimeFromUserInput(input) {
|
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
export function buildFieldValue({ data
|
|
45
|
+
export function buildFieldValue({ data, usesTime, usesTimezone }) {
|
|
46
46
|
const date = datetimeFromUserInput(data);
|
|
47
47
|
if (date.invalid) {
|
|
48
48
|
return {
|
|
@@ -68,7 +68,7 @@ export function getDefaultAMPM() {
|
|
|
68
68
|
export function getDefaultUtcOffset() {
|
|
69
69
|
return startOfToday('Z');
|
|
70
70
|
}
|
|
71
|
-
export function userInputFromDatetime({ value
|
|
71
|
+
export function userInputFromDatetime({ value, uses12hClock }) {
|
|
72
72
|
const datetime = fieldValueToMoment(value);
|
|
73
73
|
if (datetime) {
|
|
74
74
|
const timeFormat = uses12hClock ? 'hh:mm' : 'HH:mm';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { FieldAPI, ParametersAPI } from '@contentful/field-editor-shared';
|
|
3
3
|
import { TimeFormat, DateTimeFormat } from './types';
|
|
4
4
|
export interface DateEditorProps {
|
|
@@ -19,7 +19,7 @@ export interface DateEditorProps {
|
|
|
19
19
|
ampm?: TimeFormat;
|
|
20
20
|
}, Record<string, any>>;
|
|
21
21
|
}
|
|
22
|
-
export declare function DateEditor(props: DateEditorProps):
|
|
22
|
+
export declare function DateEditor(props: DateEditorProps): JSX.Element;
|
|
23
23
|
export declare namespace DateEditor {
|
|
24
24
|
var defaultProps: {
|
|
25
25
|
isInitiallyDisabled: boolean;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import moment from 'moment';
|
|
3
3
|
export type DatePickerProps = {
|
|
4
4
|
value?: moment.Moment;
|
|
5
5
|
onChange: (val: moment.Moment | undefined) => void;
|
|
6
6
|
disabled?: boolean;
|
|
7
7
|
};
|
|
8
|
-
export declare const DatepickerInput: (props: DatePickerProps) =>
|
|
8
|
+
export declare const DatepickerInput: (props: DatePickerProps) => JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
export type TimepickerProps = {
|
|
3
3
|
disabled: boolean;
|
|
4
4
|
uses12hClock: boolean;
|
|
@@ -9,4 +9,4 @@ export type TimepickerProps = {
|
|
|
9
9
|
time?: string;
|
|
10
10
|
ampm?: string;
|
|
11
11
|
};
|
|
12
|
-
export declare const TimepickerInput: ({ disabled, uses12hClock, time, ampm, onChange, }: TimepickerProps) =>
|
|
12
|
+
export declare const TimepickerInput: ({ disabled, uses12hClock, time, ampm, onChange, }: TimepickerProps) => JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
export type TimezonepickerProps = {
|
|
3
3
|
disabled: boolean;
|
|
4
4
|
onChange: (value: string) => void;
|
|
5
5
|
value?: string;
|
|
6
6
|
};
|
|
7
|
-
export declare const TimezonepickerInput: ({ disabled, onChange, value, }: TimezonepickerProps) =>
|
|
7
|
+
export declare const TimezonepickerInput: ({ disabled, onChange, value, }: TimezonepickerProps) => JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-date",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.5",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -38,18 +38,21 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@contentful/f36-components": "^4.34.1",
|
|
40
40
|
"@contentful/f36-tokens": "^4.0.1",
|
|
41
|
-
"@contentful/field-editor-shared": "^1.4.
|
|
41
|
+
"@contentful/field-editor-shared": "^1.4.5",
|
|
42
42
|
"emotion": "^10.0.17",
|
|
43
43
|
"moment": "^2.20.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@babel/core": "^7.7.4",
|
|
47
|
-
"@contentful/field-editor-test-utils": "^1.4.
|
|
47
|
+
"@contentful/field-editor-test-utils": "^1.4.6",
|
|
48
48
|
"@types/timezoned-date": "^3.0.0",
|
|
49
49
|
"timezoned-date": "^3.0.2"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"react": ">=16.8.0"
|
|
53
53
|
},
|
|
54
|
-
"
|
|
54
|
+
"publishConfig": {
|
|
55
|
+
"registry": "https://npm.pkg.github.com/"
|
|
56
|
+
},
|
|
57
|
+
"gitHead": "142d2039f023bf4ced956aae1dd08b27c35fdbaa"
|
|
55
58
|
}
|