@contentful/f36-datetime 4.0.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.
- package/LICENSE.md +7 -0
- package/README.md +7 -0
- package/dist/main.js +137 -0
- package/dist/main.js.map +1 -0
- package/dist/module.js +127 -0
- package/dist/module.js.map +1 -0
- package/dist/types.d.ts +603 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +36 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright (c) 2018-present Contentful GmbH
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
package/dist/main.js
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
var $iSxHR$react = require("react");
|
|
2
|
+
var $iSxHR$dayjs = require("dayjs");
|
|
3
|
+
var $iSxHR$dayjspluginutc = require("dayjs/plugin/utc");
|
|
4
|
+
var $iSxHR$dayjspluginrelativeTime = require("dayjs/plugin/relativeTime");
|
|
5
|
+
var $iSxHR$dayjsplugincalendar = require("dayjs/plugin/calendar");
|
|
6
|
+
|
|
7
|
+
function $parcel$export(e, n, v, s) {
|
|
8
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
9
|
+
}
|
|
10
|
+
function $parcel$interopDefault(a) {
|
|
11
|
+
return a && a.__esModule ? a.default : a;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
$parcel$export(module.exports, "DateTime", () => $8c9ef2783da7ec5f$export$82f9ebd9adeba146);
|
|
15
|
+
$parcel$export(module.exports, "RelativeDateTime", () => $de66f20f0f273947$export$6de14fd95adb1c8a);
|
|
16
|
+
$parcel$export(module.exports, "formatDateAndTime", () => $fe3d2807f48471b7$export$de4eb09f10f9c95e);
|
|
17
|
+
$parcel$export(module.exports, "formatMachineReadableDateTime", () => $fe3d2807f48471b7$export$5fb913e47d486079);
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
($parcel$interopDefault($iSxHR$dayjs)).extend(($parcel$interopDefault($iSxHR$dayjspluginutc)));
|
|
22
|
+
function $fe3d2807f48471b7$export$de4eb09f10f9c95e(date, format = 'full') {
|
|
23
|
+
let template;
|
|
24
|
+
switch(format){
|
|
25
|
+
case 'day':
|
|
26
|
+
template = 'DD MMM YYYY'; // 17 Aug 2021
|
|
27
|
+
break;
|
|
28
|
+
case 'weekday':
|
|
29
|
+
template = 'ddd, DD MMM'; // Tue, 17 Aug
|
|
30
|
+
break;
|
|
31
|
+
case 'time':
|
|
32
|
+
template = 'h:mm A'; // 3:45 PM
|
|
33
|
+
break;
|
|
34
|
+
default:
|
|
35
|
+
template = 'ddd, DD MMM YYYY [at] h:mm A';
|
|
36
|
+
}
|
|
37
|
+
return ($parcel$interopDefault($iSxHR$dayjs))(date).format(template);
|
|
38
|
+
}
|
|
39
|
+
function $fe3d2807f48471b7$export$5fb913e47d486079(date, format = 'full') {
|
|
40
|
+
let template;
|
|
41
|
+
switch(format){
|
|
42
|
+
case 'day':
|
|
43
|
+
template = 'YYYY-MM-DD'; // 2019-08-24
|
|
44
|
+
break;
|
|
45
|
+
case 'weekday':
|
|
46
|
+
template = 'MM-DD'; // 08-24
|
|
47
|
+
break;
|
|
48
|
+
case 'time':
|
|
49
|
+
template = 'HH:mm:ss.SSS'; // 15:44:07.000
|
|
50
|
+
break;
|
|
51
|
+
default:
|
|
52
|
+
template = 'YYYY-MM-DDTHH:mm:ss.SSS[Z]';
|
|
53
|
+
}
|
|
54
|
+
return ($parcel$interopDefault($iSxHR$dayjs))(date).utc().format(template);
|
|
55
|
+
}
|
|
56
|
+
const $fe3d2807f48471b7$export$3ae94a2503e890a1 = (date)=>{
|
|
57
|
+
return $fe3d2807f48471b7$export$de4eb09f10f9c95e(date, 'day');
|
|
58
|
+
};
|
|
59
|
+
const $fe3d2807f48471b7$export$3203edd9e5edd663 = (date)=>{
|
|
60
|
+
return $fe3d2807f48471b7$export$de4eb09f10f9c95e(date, 'time');
|
|
61
|
+
};
|
|
62
|
+
const $fe3d2807f48471b7$export$b89623867a65b725 = (date)=>{
|
|
63
|
+
return $fe3d2807f48471b7$export$de4eb09f10f9c95e(date, 'weekday');
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
($parcel$interopDefault($iSxHR$dayjs)).extend(($parcel$interopDefault($iSxHR$dayjspluginutc)));
|
|
71
|
+
($parcel$interopDefault($iSxHR$dayjs)).extend(($parcel$interopDefault($iSxHR$dayjspluginrelativeTime)));
|
|
72
|
+
($parcel$interopDefault($iSxHR$dayjs)).extend(($parcel$interopDefault($iSxHR$dayjsplugincalendar)));
|
|
73
|
+
function $4e7e5146bc048e19$export$68534c3ecebfa124(date, baseDate = new Date()) {
|
|
74
|
+
return ($parcel$interopDefault($iSxHR$dayjs))(date).from(baseDate);
|
|
75
|
+
}
|
|
76
|
+
function $4e7e5146bc048e19$export$aa1a2def90bfd930(date, baseDate = new Date()) {
|
|
77
|
+
const isToday = ($parcel$interopDefault($iSxHR$dayjs))(date).isSame(baseDate, 'day');
|
|
78
|
+
if (!isToday) // if the date is not today, we display it with "Yesterday", "Tomorrow", etc.
|
|
79
|
+
// and if the date is not in the current week then it will display "17 Aug 2021"
|
|
80
|
+
return ($parcel$interopDefault($iSxHR$dayjs))(date).calendar(baseDate, {
|
|
81
|
+
sameElse: 'DD MMM YYYY'
|
|
82
|
+
});
|
|
83
|
+
// returns "... ago"
|
|
84
|
+
return $4e7e5146bc048e19$export$68534c3ecebfa124(date, baseDate);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
const $8c9ef2783da7ec5f$var$_DateTime = ({ date: date , format: format = 'full' , testId: testId = 'cf-ui-date-time' , ...otherProps }, ref)=>{
|
|
90
|
+
const machineReadableDate = $fe3d2807f48471b7$export$5fb913e47d486079(date);
|
|
91
|
+
return(/*#__PURE__*/ ($parcel$interopDefault($iSxHR$react)).createElement("time", {
|
|
92
|
+
dateTime: machineReadableDate,
|
|
93
|
+
"data-test-id": testId,
|
|
94
|
+
...otherProps,
|
|
95
|
+
ref: ref
|
|
96
|
+
}, $fe3d2807f48471b7$export$de4eb09f10f9c95e(date, format)));
|
|
97
|
+
};
|
|
98
|
+
const $8c9ef2783da7ec5f$export$82f9ebd9adeba146 = /*#__PURE__*/ ($parcel$interopDefault($iSxHR$react)).forwardRef($8c9ef2783da7ec5f$var$_DateTime);
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
($parcel$interopDefault($iSxHR$dayjs)).extend(($parcel$interopDefault($iSxHR$dayjspluginutc)));
|
|
108
|
+
($parcel$interopDefault($iSxHR$dayjs)).extend(($parcel$interopDefault($iSxHR$dayjspluginrelativeTime)));
|
|
109
|
+
($parcel$interopDefault($iSxHR$dayjs)).extend(($parcel$interopDefault($iSxHR$dayjsplugincalendar)));
|
|
110
|
+
const $de66f20f0f273947$var$_RelativeDateTime = ({ date: date , baseDate: baseDate , isRelativeToCurrentWeek: isRelativeToCurrentWeek = false , testId: testId = 'cf-ui-relative-date-time' , ...otherProps }, ref)=>{
|
|
111
|
+
const now = new Date();
|
|
112
|
+
const referenceDate = baseDate !== null && baseDate !== void 0 ? baseDate : now;
|
|
113
|
+
const dayjsDate = ($parcel$interopDefault($iSxHR$dayjs))(date);
|
|
114
|
+
const machineReadableDate = $fe3d2807f48471b7$export$5fb913e47d486079(date);
|
|
115
|
+
let relativeDate;
|
|
116
|
+
if (isRelativeToCurrentWeek && !dayjsDate.isSame(referenceDate, 'day')) /**
|
|
117
|
+
* if isRelativeToCurrentWeek is true and the date is not today, we display the date with Yesterday, Tomorrow, etc
|
|
118
|
+
* or, if the date is not in the current week, it displays "17 Aug 2021"
|
|
119
|
+
*
|
|
120
|
+
* check formatRelativeToCurrentWeekDateTime for more details
|
|
121
|
+
*/ relativeDate = $4e7e5146bc048e19$export$aa1a2def90bfd930(date, referenceDate);
|
|
122
|
+
else // otherwise we display it with "... ago" or "in ..." notation
|
|
123
|
+
relativeDate = $4e7e5146bc048e19$export$68534c3ecebfa124(date, referenceDate);
|
|
124
|
+
return(/*#__PURE__*/ ($parcel$interopDefault($iSxHR$react)).createElement("time", {
|
|
125
|
+
dateTime: machineReadableDate,
|
|
126
|
+
"data-test-id": testId,
|
|
127
|
+
...otherProps,
|
|
128
|
+
ref: ref
|
|
129
|
+
}, relativeDate));
|
|
130
|
+
};
|
|
131
|
+
const $de66f20f0f273947$export$6de14fd95adb1c8a = /*#__PURE__*/ ($parcel$interopDefault($iSxHR$react)).forwardRef($de66f20f0f273947$var$_RelativeDateTime);
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;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AAD;OAEH8B,YAAD;AAGL,CAxCD;AA8CO,KAAA,CAAM9C,yCAAgB,iBAAGI,sCAAK,CAACgB,UAAN,CAAiBsB,uCAAjB;;","sources":["packages/components/datetime/src/index.ts","packages/components/datetime/src/DateTime/DateTime.tsx","packages/components/datetime/src/utils/index.ts","packages/components/datetime/src/utils/formatDateTimeUtils.ts","packages/components/datetime/src/utils/relativeDateTimeUtils.ts","packages/components/datetime/src/RelativeDateTime/RelativeDateTime.tsx"],"sourcesContent":["export { DateTime } from './DateTime/DateTime';\nexport type { DateTimeProps } from './DateTime/DateTime';\nexport { RelativeDateTime } from './RelativeDateTime/RelativeDateTime';\nexport type { RelativeDateTimeProps } from './RelativeDateTime/RelativeDateTime';\nexport { formatDateAndTime, formatMachineReadableDateTime } from './utils';\n","import React from 'react';\nimport {\n CommonProps,\n PropsWithHTMLElement,\n ExpandProps,\n} from '@contentful/f36-core';\n\nimport type { DateType, DateFormat } from '../types';\nimport { formatDateAndTime, formatMachineReadableDateTime } from '../utils';\n\ninterface DateTimeOwnProps extends CommonProps {\n /**\n * The date that will be displayed. It accepts a JS Date, an ISO8601 Timestamp string, or Unix Epoch Milliseconds number\n */\n date: DateType;\n /**\n * The format in which the date will be presented\n *\n * @default full\n **/\n format?: DateFormat;\n}\n\nexport type DateTimeProps = PropsWithHTMLElement<DateTimeOwnProps, 'time'>;\n\nconst _DateTime = (\n {\n date,\n format = 'full',\n testId = 'cf-ui-date-time',\n ...otherProps\n }: ExpandProps<DateTimeProps>,\n ref: React.Ref<HTMLTimeElement>,\n) => {\n const machineReadableDate = formatMachineReadableDateTime(date);\n\n return (\n <time\n dateTime={machineReadableDate}\n data-test-id={testId}\n {...otherProps}\n ref={ref}\n >\n {formatDateAndTime(date, format)}\n </time>\n );\n};\n\n/**\n * The DateTime component will format a date to a human friendly format and wrap it in a `<time>` tag\n */\nexport const DateTime = React.forwardRef(_DateTime);\n","export {\n formatDateAndTime,\n formatMachineReadableDateTime,\n formatDate,\n formatTime,\n formatWeekdayDate,\n} from './formatDateTimeUtils';\n\nexport {\n formatRelativeDateTime,\n formatRelativeToCurrentWeekDateTime,\n} from './relativeDateTimeUtils';\n","import dayjs from 'dayjs';\nimport utcPlugin from 'dayjs/plugin/utc';\ndayjs.extend(utcPlugin);\n\nimport type { DateType, DateFormat } from '../types';\n\n/**\n * A funtion that will return a formatted date string. The format will dependend on the option\n * passed in the second argument.\n * By default, it will return a string with Forma 36’s \"full\" format (e.g. Tue, 17 Aug 2021 at 3:45 PM)\n *\n * @param {DateType} date - the date to be formatted\n * @param {DateFormat} format - the desired format (\"full\", \"day\", \"weekday\", or \"time\")\n * @returns a formatted date\n *\n * @example\n * formatDateAndTime('2021-08-17T15:45:00') // returns \"Tue, 17 Aug 2021 at 3:45 PM\"\n *\n * @example\n * formatDateAndTime('2021-08-17T15:45:00', 'day') // returns \"17 Aug 2021\"\n */\nexport function formatDateAndTime(\n date: DateType,\n format: DateFormat = 'full',\n): string {\n let template: string;\n\n switch (format) {\n case 'day':\n template = 'DD MMM YYYY'; // 17 Aug 2021\n break;\n case 'weekday':\n template = 'ddd, DD MMM'; // Tue, 17 Aug\n break;\n case 'time':\n template = 'h:mm A'; // 3:45 PM\n break;\n default:\n template = 'ddd, DD MMM YYYY [at] h:mm A'; // Tue, 17 Aug 2021 at 3:45 PM\n }\n\n return dayjs(date).format(template);\n}\n\n/**\n * A funtion that will return a machine-readable date string that should be passed to the `datetime` attribute of a `<time>` tag\n * By default, it will return a string with \"YYYY-MM-DDTHH:mm:ss.SSS[Z]\" format\n *\n * @param {DateType} date - the date to be formatted\n * @param {DateFormat} format - the desired format (\"full\", \"day\", \"weekday\", or \"time\")\n * @returns a formatted date\n *\n * @example\n * formatMachineReadableDateTime(date) // returns 2019-08-13T10:00:00.000Z\n *\n * @example\n * formatMachineReadableDateTime(date, 'day') // returns 2019-08-13\n */\nexport function formatMachineReadableDateTime(\n date: DateType,\n format: DateFormat = 'full',\n): string {\n let template: string;\n\n switch (format) {\n case 'day':\n template = 'YYYY-MM-DD'; // 2019-08-24\n break;\n case 'weekday':\n template = 'MM-DD'; // 08-24\n break;\n case 'time':\n template = 'HH:mm:ss.SSS'; // 15:44:07.000\n break;\n default:\n template = 'YYYY-MM-DDTHH:mm:ss.SSS[Z]'; // 2019-08-24T15:44:07.000Z\n }\n\n return dayjs(date).utc().format(template);\n}\n\n/**\n * @example\n * > formatDate(date)\n * 13 Aug 2019\n */\nexport const formatDate = (date: DateType): string => {\n return formatDateAndTime(date, 'day');\n};\n\n/**\n * @example\n * > formatTime(date)\n * 8:00 AM\n */\nexport const formatTime = (date: DateType): string => {\n return formatDateAndTime(date, 'time');\n};\n\n/**\n * @example\n * > formatWeekdayDate(date)\n * Mon, 12 Aug\n */\nexport const formatWeekdayDate = (date: DateType): string => {\n return formatDateAndTime(date, 'weekday');\n};\n","import dayjs from 'dayjs';\nimport utcPlugin from 'dayjs/plugin/utc';\nimport relativeTime from 'dayjs/plugin/relativeTime';\nimport calendarPlugin from 'dayjs/plugin/calendar';\ndayjs.extend(utcPlugin);\ndayjs.extend(relativeTime);\ndayjs.extend(calendarPlugin);\n\nimport type { DateType } from '../types';\n\n/**\n * A function that will return a string with how far a given date is in the past or future,\n * using a baseDate as reference. If the baseDate is not passed, the function will use today as reference.\n *\n * @param {DateType} date - the date to be formatted\n * @param {DateFormat} baseDate - the date that should be used as a reference (default is \"today\")\n * @returns a relative date\n *\n * @example\n * // Considering today as 18.08.2021\n * formatRelativeDateTime('2021-08-17T15:45:00') // returns \"a day ago\"\n *\n * @example\n * formatRelativeDateTime('2021-08-17T15:45:00', '2021-08-16') // returns \"in a day\"\n */\nexport function formatRelativeDateTime(\n date: DateType,\n baseDate: DateType = new Date(),\n) {\n return dayjs(date).from(baseDate);\n}\n\n/**\n * A function that formats a date relative to Today or to the `baseDate` if passed.\n * If the date is not today, it will return a string with \"Yesterday ...\", \"Tomorrow ...\", etc\n * If the date is not in the current week, it return a string with \"DD MMM YYYY\" format\n * If the date is today, it will return a string with \"... ago\" or \"in ...\"\n *\n * @param {DateType} date - the date to be formatted\n * @param {DateFormat} baseDate - the date that should be used as a reference (default is \"today\")\n * @returns a relative date\n *\n * @example\n * // Considering today as 18.08.2021\n * formatRelativeToCurrentWeekDateTime('2021-08-17T15:45:00') // returns \"Yesterday at 3:45 PM\"\n *\n * @example\n * formatRelativeToCurrentWeekDateTime('2021-08-17T15:45:00', '2021-08-16') // returns \"Tomorrow at 3:45 PM\"\n */\nexport function formatRelativeToCurrentWeekDateTime(\n date: DateType,\n baseDate: DateType = new Date(),\n) {\n const isToday = dayjs(date).isSame(baseDate, 'day');\n\n if (!isToday) {\n // if the date is not today, we display it with \"Yesterday\", \"Tomorrow\", etc.\n // and if the date is not in the current week then it will display \"17 Aug 2021\"\n return dayjs(date).calendar(baseDate, {\n sameElse: 'DD MMM YYYY',\n });\n }\n\n // returns \"... ago\"\n return formatRelativeDateTime(date, baseDate);\n}\n","import React from 'react';\nimport {\n CommonProps,\n PropsWithHTMLElement,\n ExpandProps,\n} from '@contentful/f36-core';\n\nimport dayjs from 'dayjs';\nimport utcPlugin from 'dayjs/plugin/utc';\nimport relativeTime from 'dayjs/plugin/relativeTime';\nimport calendarPlugin from 'dayjs/plugin/calendar';\ndayjs.extend(utcPlugin);\ndayjs.extend(relativeTime);\ndayjs.extend(calendarPlugin);\n\nimport type { DateType } from '../types';\nimport {\n formatMachineReadableDateTime,\n formatRelativeDateTime,\n formatRelativeToCurrentWeekDateTime,\n} from '../utils';\n\ninterface RelativeDateTimeInternalProps extends CommonProps {\n /**\n * The date that will be displayed. It accepts a JS Date, an ISO8601 Timestamp string, or Unix Epoch Milliseconds number\n */\n date: DateType;\n /**\n * If a value is passed to baseDate, then the component will compare both dates and return the time between them.\n * If no value is passed then the date will be compared to \"now\"\n *\n * @default \"Now\"\n */\n baseDate?: DateType;\n /**\n * Sets the date to be relative only if it is in the current week\n * @default false\n */\n isRelativeToCurrentWeek?: boolean;\n}\n\nexport type RelativeDateTimeProps = PropsWithHTMLElement<\n RelativeDateTimeInternalProps,\n 'time'\n>;\n\nconst _RelativeDateTime = (\n {\n date,\n baseDate,\n isRelativeToCurrentWeek = false,\n testId = 'cf-ui-relative-date-time',\n ...otherProps\n }: ExpandProps<RelativeDateTimeProps>,\n ref: React.Ref<HTMLTimeElement>,\n) => {\n const now = new Date();\n const referenceDate = baseDate ?? now;\n const dayjsDate = dayjs(date);\n const machineReadableDate = formatMachineReadableDateTime(date);\n\n let relativeDate: string;\n\n if (isRelativeToCurrentWeek && !dayjsDate.isSame(referenceDate, 'day')) {\n /**\n * if isRelativeToCurrentWeek is true and the date is not today, we display the date with Yesterday, Tomorrow, etc\n * or, if the date is not in the current week, it displays \"17 Aug 2021\"\n *\n * check formatRelativeToCurrentWeekDateTime for more details\n */\n relativeDate = formatRelativeToCurrentWeekDateTime(date, referenceDate);\n } else {\n // otherwise we display it with \"... ago\" or \"in ...\" notation\n relativeDate = formatRelativeDateTime(date, referenceDate);\n }\n\n return (\n <time\n dateTime={machineReadableDate}\n data-test-id={testId}\n {...otherProps}\n ref={ref}\n >\n {relativeDate}\n </time>\n );\n};\n\n/**\n * The RelativeDateTime will show a `date` relative to \"now\" or to the `baseDate`\n * (e.g. in a day, in one month, one month ago, etc).\n */\nexport const RelativeDateTime = React.forwardRef(_RelativeDateTime);\n"],"names":["DateTime","DateTimeProps","RelativeDateTime","RelativeDateTimeProps","formatDateAndTime","formatMachineReadableDateTime","React","CommonProps","PropsWithHTMLElement","ExpandProps","DateType","DateFormat","DateTimeOwnProps","date","format","_DateTime","testId","otherProps","ref","Ref","HTMLTimeElement","machineReadableDate","forwardRef","formatDate","formatTime","formatWeekdayDate","formatRelativeDateTime","formatRelativeToCurrentWeekDateTime","dayjs","utcPlugin","extend","template","utc","relativeTime","calendarPlugin","baseDate","Date","from","isToday","isSame","calendar","sameElse","RelativeDateTimeInternalProps","isRelativeToCurrentWeek","_RelativeDateTime","now","referenceDate","dayjsDate","relativeDate"],"version":3,"file":"main.js.map"}
|
package/dist/module.js
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import $fUYts$react from "react";
|
|
2
|
+
import $fUYts$dayjs from "dayjs";
|
|
3
|
+
import $fUYts$dayjspluginutc from "dayjs/plugin/utc";
|
|
4
|
+
import $fUYts$dayjspluginrelativeTime from "dayjs/plugin/relativeTime";
|
|
5
|
+
import $fUYts$dayjsplugincalendar from "dayjs/plugin/calendar";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
$fUYts$dayjs.extend($fUYts$dayjspluginutc);
|
|
11
|
+
function $ee655ad1301c8997$export$de4eb09f10f9c95e(date, format = 'full') {
|
|
12
|
+
let template;
|
|
13
|
+
switch(format){
|
|
14
|
+
case 'day':
|
|
15
|
+
template = 'DD MMM YYYY'; // 17 Aug 2021
|
|
16
|
+
break;
|
|
17
|
+
case 'weekday':
|
|
18
|
+
template = 'ddd, DD MMM'; // Tue, 17 Aug
|
|
19
|
+
break;
|
|
20
|
+
case 'time':
|
|
21
|
+
template = 'h:mm A'; // 3:45 PM
|
|
22
|
+
break;
|
|
23
|
+
default:
|
|
24
|
+
template = 'ddd, DD MMM YYYY [at] h:mm A';
|
|
25
|
+
}
|
|
26
|
+
return $fUYts$dayjs(date).format(template);
|
|
27
|
+
}
|
|
28
|
+
function $ee655ad1301c8997$export$5fb913e47d486079(date, format = 'full') {
|
|
29
|
+
let template;
|
|
30
|
+
switch(format){
|
|
31
|
+
case 'day':
|
|
32
|
+
template = 'YYYY-MM-DD'; // 2019-08-24
|
|
33
|
+
break;
|
|
34
|
+
case 'weekday':
|
|
35
|
+
template = 'MM-DD'; // 08-24
|
|
36
|
+
break;
|
|
37
|
+
case 'time':
|
|
38
|
+
template = 'HH:mm:ss.SSS'; // 15:44:07.000
|
|
39
|
+
break;
|
|
40
|
+
default:
|
|
41
|
+
template = 'YYYY-MM-DDTHH:mm:ss.SSS[Z]';
|
|
42
|
+
}
|
|
43
|
+
return $fUYts$dayjs(date).utc().format(template);
|
|
44
|
+
}
|
|
45
|
+
const $ee655ad1301c8997$export$3ae94a2503e890a1 = (date)=>{
|
|
46
|
+
return $ee655ad1301c8997$export$de4eb09f10f9c95e(date, 'day');
|
|
47
|
+
};
|
|
48
|
+
const $ee655ad1301c8997$export$3203edd9e5edd663 = (date)=>{
|
|
49
|
+
return $ee655ad1301c8997$export$de4eb09f10f9c95e(date, 'time');
|
|
50
|
+
};
|
|
51
|
+
const $ee655ad1301c8997$export$b89623867a65b725 = (date)=>{
|
|
52
|
+
return $ee655ad1301c8997$export$de4eb09f10f9c95e(date, 'weekday');
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
$fUYts$dayjs.extend($fUYts$dayjspluginutc);
|
|
60
|
+
$fUYts$dayjs.extend($fUYts$dayjspluginrelativeTime);
|
|
61
|
+
$fUYts$dayjs.extend($fUYts$dayjsplugincalendar);
|
|
62
|
+
function $162585a33f185f78$export$68534c3ecebfa124(date, baseDate = new Date()) {
|
|
63
|
+
return $fUYts$dayjs(date).from(baseDate);
|
|
64
|
+
}
|
|
65
|
+
function $162585a33f185f78$export$aa1a2def90bfd930(date, baseDate = new Date()) {
|
|
66
|
+
const isToday = $fUYts$dayjs(date).isSame(baseDate, 'day');
|
|
67
|
+
if (!isToday) // if the date is not today, we display it with "Yesterday", "Tomorrow", etc.
|
|
68
|
+
// and if the date is not in the current week then it will display "17 Aug 2021"
|
|
69
|
+
return $fUYts$dayjs(date).calendar(baseDate, {
|
|
70
|
+
sameElse: 'DD MMM YYYY'
|
|
71
|
+
});
|
|
72
|
+
// returns "... ago"
|
|
73
|
+
return $162585a33f185f78$export$68534c3ecebfa124(date, baseDate);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
const $02aa7794cdab25f9$var$_DateTime = ({ date: date , format: format = 'full' , testId: testId = 'cf-ui-date-time' , ...otherProps }, ref)=>{
|
|
79
|
+
const machineReadableDate = $ee655ad1301c8997$export$5fb913e47d486079(date);
|
|
80
|
+
return(/*#__PURE__*/ $fUYts$react.createElement("time", {
|
|
81
|
+
dateTime: machineReadableDate,
|
|
82
|
+
"data-test-id": testId,
|
|
83
|
+
...otherProps,
|
|
84
|
+
ref: ref
|
|
85
|
+
}, $ee655ad1301c8997$export$de4eb09f10f9c95e(date, format)));
|
|
86
|
+
};
|
|
87
|
+
const $02aa7794cdab25f9$export$82f9ebd9adeba146 = /*#__PURE__*/ $fUYts$react.forwardRef($02aa7794cdab25f9$var$_DateTime);
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
$fUYts$dayjs.extend($fUYts$dayjspluginutc);
|
|
97
|
+
$fUYts$dayjs.extend($fUYts$dayjspluginrelativeTime);
|
|
98
|
+
$fUYts$dayjs.extend($fUYts$dayjsplugincalendar);
|
|
99
|
+
const $f5a0093d268a4b59$var$_RelativeDateTime = ({ date: date , baseDate: baseDate , isRelativeToCurrentWeek: isRelativeToCurrentWeek = false , testId: testId = 'cf-ui-relative-date-time' , ...otherProps }, ref)=>{
|
|
100
|
+
const now = new Date();
|
|
101
|
+
const referenceDate = baseDate !== null && baseDate !== void 0 ? baseDate : now;
|
|
102
|
+
const dayjsDate = $fUYts$dayjs(date);
|
|
103
|
+
const machineReadableDate = $ee655ad1301c8997$export$5fb913e47d486079(date);
|
|
104
|
+
let relativeDate;
|
|
105
|
+
if (isRelativeToCurrentWeek && !dayjsDate.isSame(referenceDate, 'day')) /**
|
|
106
|
+
* if isRelativeToCurrentWeek is true and the date is not today, we display the date with Yesterday, Tomorrow, etc
|
|
107
|
+
* or, if the date is not in the current week, it displays "17 Aug 2021"
|
|
108
|
+
*
|
|
109
|
+
* check formatRelativeToCurrentWeekDateTime for more details
|
|
110
|
+
*/ relativeDate = $162585a33f185f78$export$aa1a2def90bfd930(date, referenceDate);
|
|
111
|
+
else // otherwise we display it with "... ago" or "in ..." notation
|
|
112
|
+
relativeDate = $162585a33f185f78$export$68534c3ecebfa124(date, referenceDate);
|
|
113
|
+
return(/*#__PURE__*/ $fUYts$react.createElement("time", {
|
|
114
|
+
dateTime: machineReadableDate,
|
|
115
|
+
"data-test-id": testId,
|
|
116
|
+
...otherProps,
|
|
117
|
+
ref: ref
|
|
118
|
+
}, relativeDate));
|
|
119
|
+
};
|
|
120
|
+
const $f5a0093d268a4b59$export$6de14fd95adb1c8a = /*#__PURE__*/ $fUYts$react.forwardRef($f5a0093d268a4b59$var$_RelativeDateTime);
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
export {$02aa7794cdab25f9$export$82f9ebd9adeba146 as DateTime, $f5a0093d268a4b59$export$6de14fd95adb1c8a as RelativeDateTime, $ee655ad1301c8997$export$de4eb09f10f9c95e as formatDateAndTime, $ee655ad1301c8997$export$5fb913e47d486079 as formatMachineReadableDateTime};
|
|
127
|
+
//# sourceMappingURL=module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;AGEA4B,YAAK,CAACE,MAAN,CAAaD,qBAAb;SAmBgBzB,yCAAT,CACLS,IADK,EAELC,MAAkB,GAAG,CAFhB,OAGG,CAHV;IAIE,GAAA,CAAIiB,QAAQ;IAEZ,MAAA,CAAQjB,MAAR;QACE,IAAA,CAAK,CAAL;YACEiB,QAAQ,GAAG,CAAX,aAA0B,CAA1BA,AAA0B,EAA1BA,AAA0B,YAA1BA;YACA,KAAA;QACF,IAAA,CAAK,CAAL;YACEA,QAAQ,GAAG,CAAX,aAA0B,CAA1BA,AAA0B,EAA1BA,AAA0B,YAA1BA;YACA,KAAA;QACF,IAAA,CAAK,CAAL;YACEA,QAAQ,GAAG,CAAX,QAAqB,CAArBA,AAAqB,EAArBA,AAAqB,QAArBA;YACA,KAAA;;YAEAA,QAAQ,GAA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G,CAJX,+BAKKC,UAAH,CACY,CAPU,EAQxBC,GARwB,GASrB,CARH;IASA,KAAA,CAAM2B,GAAG,GAAG,GAAA,CAAIT,IAAJ;IACZ,KAAA,CAAMU,aAAa,GAAGX,QAAQ,aAARA,QAAQ,cAARA,QAAQ,GAAIU,GAAlC;IACA,KAAA,CAAME,SAAS,GAAGnB,YAAK,CAACf,IAAD;IACvB,KAAA,CAAMQ,mBAAmB,GAAGhB,yCAA6B,CAACQ,IAAD;IAEzD,GAAA,CAAImC,YAAY;IAEhB,EAAA,EAAIL,uBAAuB,KAAKI,SAAS,CAACR,MAAV,CAAiBO,aAAjB,EAAgC,CAAhC,OAC9B,EAKJ,AALI;;;;;KAKJ,AALI,EAKJ,CACIE,YAAY,GAAGrB,yCAAmC,CAACd,IAAD,EAAOiC,aAAP;SAElD,EAAA,AAAA,4DAAA;IACAE,YAAY,GAAGtB,yCAAsB,CAACb,IAAD,EAAOiC,aAAP;IAGvC,MAAA,0CACG,CAAD;QACE,QAAA,EAAUzB,mBAAD;QACT,CAAA,eAAcL,MAAD;WACTC,UAAJ;QACA,GAAA,EAAKC,GAAD;OAEH8B,YAAD;AAGL,CAxCD;AA8CO,KAAA,CAAM9C,yCAAgB,iBAAGI,YAAK,CAACgB,UAAN,CAAiBsB,uCAAjB;;","sources":["packages/components/datetime/src/index.ts","packages/components/datetime/src/DateTime/DateTime.tsx","packages/components/datetime/src/utils/index.ts","packages/components/datetime/src/utils/formatDateTimeUtils.ts","packages/components/datetime/src/utils/relativeDateTimeUtils.ts","packages/components/datetime/src/RelativeDateTime/RelativeDateTime.tsx"],"sourcesContent":["export { DateTime } from './DateTime/DateTime';\nexport type { DateTimeProps } from './DateTime/DateTime';\nexport { RelativeDateTime } from './RelativeDateTime/RelativeDateTime';\nexport type { RelativeDateTimeProps } from './RelativeDateTime/RelativeDateTime';\nexport { formatDateAndTime, formatMachineReadableDateTime } from './utils';\n","import React from 'react';\nimport {\n CommonProps,\n PropsWithHTMLElement,\n ExpandProps,\n} from '@contentful/f36-core';\n\nimport type { DateType, DateFormat } from '../types';\nimport { formatDateAndTime, formatMachineReadableDateTime } from '../utils';\n\ninterface DateTimeOwnProps extends CommonProps {\n /**\n * The date that will be displayed. It accepts a JS Date, an ISO8601 Timestamp string, or Unix Epoch Milliseconds number\n */\n date: DateType;\n /**\n * The format in which the date will be presented\n *\n * @default full\n **/\n format?: DateFormat;\n}\n\nexport type DateTimeProps = PropsWithHTMLElement<DateTimeOwnProps, 'time'>;\n\nconst _DateTime = (\n {\n date,\n format = 'full',\n testId = 'cf-ui-date-time',\n ...otherProps\n }: ExpandProps<DateTimeProps>,\n ref: React.Ref<HTMLTimeElement>,\n) => {\n const machineReadableDate = formatMachineReadableDateTime(date);\n\n return (\n <time\n dateTime={machineReadableDate}\n data-test-id={testId}\n {...otherProps}\n ref={ref}\n >\n {formatDateAndTime(date, format)}\n </time>\n );\n};\n\n/**\n * The DateTime component will format a date to a human friendly format and wrap it in a `<time>` tag\n */\nexport const DateTime = React.forwardRef(_DateTime);\n","export {\n formatDateAndTime,\n formatMachineReadableDateTime,\n formatDate,\n formatTime,\n formatWeekdayDate,\n} from './formatDateTimeUtils';\n\nexport {\n formatRelativeDateTime,\n formatRelativeToCurrentWeekDateTime,\n} from './relativeDateTimeUtils';\n","import dayjs from 'dayjs';\nimport utcPlugin from 'dayjs/plugin/utc';\ndayjs.extend(utcPlugin);\n\nimport type { DateType, DateFormat } from '../types';\n\n/**\n * A funtion that will return a formatted date string. The format will dependend on the option\n * passed in the second argument.\n * By default, it will return a string with Forma 36’s \"full\" format (e.g. Tue, 17 Aug 2021 at 3:45 PM)\n *\n * @param {DateType} date - the date to be formatted\n * @param {DateFormat} format - the desired format (\"full\", \"day\", \"weekday\", or \"time\")\n * @returns a formatted date\n *\n * @example\n * formatDateAndTime('2021-08-17T15:45:00') // returns \"Tue, 17 Aug 2021 at 3:45 PM\"\n *\n * @example\n * formatDateAndTime('2021-08-17T15:45:00', 'day') // returns \"17 Aug 2021\"\n */\nexport function formatDateAndTime(\n date: DateType,\n format: DateFormat = 'full',\n): string {\n let template: string;\n\n switch (format) {\n case 'day':\n template = 'DD MMM YYYY'; // 17 Aug 2021\n break;\n case 'weekday':\n template = 'ddd, DD MMM'; // Tue, 17 Aug\n break;\n case 'time':\n template = 'h:mm A'; // 3:45 PM\n break;\n default:\n template = 'ddd, DD MMM YYYY [at] h:mm A'; // Tue, 17 Aug 2021 at 3:45 PM\n }\n\n return dayjs(date).format(template);\n}\n\n/**\n * A funtion that will return a machine-readable date string that should be passed to the `datetime` attribute of a `<time>` tag\n * By default, it will return a string with \"YYYY-MM-DDTHH:mm:ss.SSS[Z]\" format\n *\n * @param {DateType} date - the date to be formatted\n * @param {DateFormat} format - the desired format (\"full\", \"day\", \"weekday\", or \"time\")\n * @returns a formatted date\n *\n * @example\n * formatMachineReadableDateTime(date) // returns 2019-08-13T10:00:00.000Z\n *\n * @example\n * formatMachineReadableDateTime(date, 'day') // returns 2019-08-13\n */\nexport function formatMachineReadableDateTime(\n date: DateType,\n format: DateFormat = 'full',\n): string {\n let template: string;\n\n switch (format) {\n case 'day':\n template = 'YYYY-MM-DD'; // 2019-08-24\n break;\n case 'weekday':\n template = 'MM-DD'; // 08-24\n break;\n case 'time':\n template = 'HH:mm:ss.SSS'; // 15:44:07.000\n break;\n default:\n template = 'YYYY-MM-DDTHH:mm:ss.SSS[Z]'; // 2019-08-24T15:44:07.000Z\n }\n\n return dayjs(date).utc().format(template);\n}\n\n/**\n * @example\n * > formatDate(date)\n * 13 Aug 2019\n */\nexport const formatDate = (date: DateType): string => {\n return formatDateAndTime(date, 'day');\n};\n\n/**\n * @example\n * > formatTime(date)\n * 8:00 AM\n */\nexport const formatTime = (date: DateType): string => {\n return formatDateAndTime(date, 'time');\n};\n\n/**\n * @example\n * > formatWeekdayDate(date)\n * Mon, 12 Aug\n */\nexport const formatWeekdayDate = (date: DateType): string => {\n return formatDateAndTime(date, 'weekday');\n};\n","import dayjs from 'dayjs';\nimport utcPlugin from 'dayjs/plugin/utc';\nimport relativeTime from 'dayjs/plugin/relativeTime';\nimport calendarPlugin from 'dayjs/plugin/calendar';\ndayjs.extend(utcPlugin);\ndayjs.extend(relativeTime);\ndayjs.extend(calendarPlugin);\n\nimport type { DateType } from '../types';\n\n/**\n * A function that will return a string with how far a given date is in the past or future,\n * using a baseDate as reference. If the baseDate is not passed, the function will use today as reference.\n *\n * @param {DateType} date - the date to be formatted\n * @param {DateFormat} baseDate - the date that should be used as a reference (default is \"today\")\n * @returns a relative date\n *\n * @example\n * // Considering today as 18.08.2021\n * formatRelativeDateTime('2021-08-17T15:45:00') // returns \"a day ago\"\n *\n * @example\n * formatRelativeDateTime('2021-08-17T15:45:00', '2021-08-16') // returns \"in a day\"\n */\nexport function formatRelativeDateTime(\n date: DateType,\n baseDate: DateType = new Date(),\n) {\n return dayjs(date).from(baseDate);\n}\n\n/**\n * A function that formats a date relative to Today or to the `baseDate` if passed.\n * If the date is not today, it will return a string with \"Yesterday ...\", \"Tomorrow ...\", etc\n * If the date is not in the current week, it return a string with \"DD MMM YYYY\" format\n * If the date is today, it will return a string with \"... ago\" or \"in ...\"\n *\n * @param {DateType} date - the date to be formatted\n * @param {DateFormat} baseDate - the date that should be used as a reference (default is \"today\")\n * @returns a relative date\n *\n * @example\n * // Considering today as 18.08.2021\n * formatRelativeToCurrentWeekDateTime('2021-08-17T15:45:00') // returns \"Yesterday at 3:45 PM\"\n *\n * @example\n * formatRelativeToCurrentWeekDateTime('2021-08-17T15:45:00', '2021-08-16') // returns \"Tomorrow at 3:45 PM\"\n */\nexport function formatRelativeToCurrentWeekDateTime(\n date: DateType,\n baseDate: DateType = new Date(),\n) {\n const isToday = dayjs(date).isSame(baseDate, 'day');\n\n if (!isToday) {\n // if the date is not today, we display it with \"Yesterday\", \"Tomorrow\", etc.\n // and if the date is not in the current week then it will display \"17 Aug 2021\"\n return dayjs(date).calendar(baseDate, {\n sameElse: 'DD MMM YYYY',\n });\n }\n\n // returns \"... ago\"\n return formatRelativeDateTime(date, baseDate);\n}\n","import React from 'react';\nimport {\n CommonProps,\n PropsWithHTMLElement,\n ExpandProps,\n} from '@contentful/f36-core';\n\nimport dayjs from 'dayjs';\nimport utcPlugin from 'dayjs/plugin/utc';\nimport relativeTime from 'dayjs/plugin/relativeTime';\nimport calendarPlugin from 'dayjs/plugin/calendar';\ndayjs.extend(utcPlugin);\ndayjs.extend(relativeTime);\ndayjs.extend(calendarPlugin);\n\nimport type { DateType } from '../types';\nimport {\n formatMachineReadableDateTime,\n formatRelativeDateTime,\n formatRelativeToCurrentWeekDateTime,\n} from '../utils';\n\ninterface RelativeDateTimeInternalProps extends CommonProps {\n /**\n * The date that will be displayed. It accepts a JS Date, an ISO8601 Timestamp string, or Unix Epoch Milliseconds number\n */\n date: DateType;\n /**\n * If a value is passed to baseDate, then the component will compare both dates and return the time between them.\n * If no value is passed then the date will be compared to \"now\"\n *\n * @default \"Now\"\n */\n baseDate?: DateType;\n /**\n * Sets the date to be relative only if it is in the current week\n * @default false\n */\n isRelativeToCurrentWeek?: boolean;\n}\n\nexport type RelativeDateTimeProps = PropsWithHTMLElement<\n RelativeDateTimeInternalProps,\n 'time'\n>;\n\nconst _RelativeDateTime = (\n {\n date,\n baseDate,\n isRelativeToCurrentWeek = false,\n testId = 'cf-ui-relative-date-time',\n ...otherProps\n }: ExpandProps<RelativeDateTimeProps>,\n ref: React.Ref<HTMLTimeElement>,\n) => {\n const now = new Date();\n const referenceDate = baseDate ?? now;\n const dayjsDate = dayjs(date);\n const machineReadableDate = formatMachineReadableDateTime(date);\n\n let relativeDate: string;\n\n if (isRelativeToCurrentWeek && !dayjsDate.isSame(referenceDate, 'day')) {\n /**\n * if isRelativeToCurrentWeek is true and the date is not today, we display the date with Yesterday, Tomorrow, etc\n * or, if the date is not in the current week, it displays \"17 Aug 2021\"\n *\n * check formatRelativeToCurrentWeekDateTime for more details\n */\n relativeDate = formatRelativeToCurrentWeekDateTime(date, referenceDate);\n } else {\n // otherwise we display it with \"... ago\" or \"in ...\" notation\n relativeDate = formatRelativeDateTime(date, referenceDate);\n }\n\n return (\n <time\n dateTime={machineReadableDate}\n data-test-id={testId}\n {...otherProps}\n ref={ref}\n >\n {relativeDate}\n </time>\n );\n};\n\n/**\n * The RelativeDateTime will show a `date` relative to \"now\" or to the `baseDate`\n * (e.g. in a day, in one month, one month ago, etc).\n */\nexport const RelativeDateTime = React.forwardRef(_RelativeDateTime);\n"],"names":["DateTime","DateTimeProps","RelativeDateTime","RelativeDateTimeProps","formatDateAndTime","formatMachineReadableDateTime","React","CommonProps","PropsWithHTMLElement","ExpandProps","DateType","DateFormat","DateTimeOwnProps","date","format","_DateTime","testId","otherProps","ref","Ref","HTMLTimeElement","machineReadableDate","forwardRef","formatDate","formatTime","formatWeekdayDate","formatRelativeDateTime","formatRelativeToCurrentWeekDateTime","dayjs","utcPlugin","extend","template","utc","relativeTime","calendarPlugin","baseDate","Date","from","isToday","isSame","calendar","sameElse","RelativeDateTimeInternalProps","isRelativeToCurrentWeek","_RelativeDateTime","now","referenceDate","dayjsDate","relativeDate"],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,603 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { CommonProps, PropsWithHTMLElement } from "@contentful/f36-core";
|
|
3
|
+
type DateType = Date | string | number;
|
|
4
|
+
type DateFormat = 'full' | 'time' | 'weekday' | 'day';
|
|
5
|
+
/**
|
|
6
|
+
* A funtion that will return a formatted date string. The format will dependend on the option
|
|
7
|
+
* passed in the second argument.
|
|
8
|
+
* By default, it will return a string with Forma 36’s "full" format (e.g. Tue, 17 Aug 2021 at 3:45 PM)
|
|
9
|
+
*
|
|
10
|
+
* @param {DateType} date - the date to be formatted
|
|
11
|
+
* @param {DateFormat} format - the desired format ("full", "day", "weekday", or "time")
|
|
12
|
+
* @returns a formatted date
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* formatDateAndTime('2021-08-17T15:45:00') // returns "Tue, 17 Aug 2021 at 3:45 PM"
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* formatDateAndTime('2021-08-17T15:45:00', 'day') // returns "17 Aug 2021"
|
|
19
|
+
*/
|
|
20
|
+
export function formatDateAndTime(date: DateType, format?: DateFormat): string;
|
|
21
|
+
/**
|
|
22
|
+
* A funtion that will return a machine-readable date string that should be passed to the `datetime` attribute of a `<time>` tag
|
|
23
|
+
* By default, it will return a string with "YYYY-MM-DDTHH:mm:ss.SSS[Z]" format
|
|
24
|
+
*
|
|
25
|
+
* @param {DateType} date - the date to be formatted
|
|
26
|
+
* @param {DateFormat} format - the desired format ("full", "day", "weekday", or "time")
|
|
27
|
+
* @returns a formatted date
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* formatMachineReadableDateTime(date) // returns 2019-08-13T10:00:00.000Z
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* formatMachineReadableDateTime(date, 'day') // returns 2019-08-13
|
|
34
|
+
*/
|
|
35
|
+
export function formatMachineReadableDateTime(date: DateType, format?: DateFormat): string;
|
|
36
|
+
interface DateTimeOwnProps extends CommonProps {
|
|
37
|
+
/**
|
|
38
|
+
* The date that will be displayed. It accepts a JS Date, an ISO8601 Timestamp string, or Unix Epoch Milliseconds number
|
|
39
|
+
*/
|
|
40
|
+
date: DateType;
|
|
41
|
+
/**
|
|
42
|
+
* The format in which the date will be presented
|
|
43
|
+
*
|
|
44
|
+
* @default full
|
|
45
|
+
**/
|
|
46
|
+
format?: DateFormat;
|
|
47
|
+
}
|
|
48
|
+
export type DateTimeProps = PropsWithHTMLElement<DateTimeOwnProps, 'time'>;
|
|
49
|
+
/**
|
|
50
|
+
* The DateTime component will format a date to a human friendly format and wrap it in a `<time>` tag
|
|
51
|
+
*/
|
|
52
|
+
export const DateTime: React.ForwardRefExoticComponent<{
|
|
53
|
+
slot?: string;
|
|
54
|
+
title?: string;
|
|
55
|
+
key?: React.Key;
|
|
56
|
+
dateTime?: string;
|
|
57
|
+
defaultChecked?: boolean;
|
|
58
|
+
defaultValue?: string | number | readonly string[];
|
|
59
|
+
suppressContentEditableWarning?: boolean;
|
|
60
|
+
suppressHydrationWarning?: boolean;
|
|
61
|
+
accessKey?: string;
|
|
62
|
+
contentEditable?: (boolean | "true" | "false") | "inherit";
|
|
63
|
+
contextMenu?: string;
|
|
64
|
+
dir?: string;
|
|
65
|
+
draggable?: boolean | "true" | "false";
|
|
66
|
+
hidden?: boolean;
|
|
67
|
+
id?: string;
|
|
68
|
+
lang?: string;
|
|
69
|
+
placeholder?: string;
|
|
70
|
+
spellCheck?: boolean | "true" | "false";
|
|
71
|
+
tabIndex?: number;
|
|
72
|
+
translate?: "yes" | "no";
|
|
73
|
+
radioGroup?: string;
|
|
74
|
+
role?: string;
|
|
75
|
+
about?: string;
|
|
76
|
+
datatype?: string;
|
|
77
|
+
inlist?: any;
|
|
78
|
+
prefix?: string;
|
|
79
|
+
property?: string;
|
|
80
|
+
resource?: string;
|
|
81
|
+
typeof?: string;
|
|
82
|
+
vocab?: string;
|
|
83
|
+
autoCapitalize?: string;
|
|
84
|
+
autoCorrect?: string;
|
|
85
|
+
autoSave?: string;
|
|
86
|
+
color?: string;
|
|
87
|
+
itemProp?: string;
|
|
88
|
+
itemScope?: boolean;
|
|
89
|
+
itemType?: string;
|
|
90
|
+
itemID?: string;
|
|
91
|
+
itemRef?: string;
|
|
92
|
+
results?: number;
|
|
93
|
+
security?: string;
|
|
94
|
+
unselectable?: "on" | "off";
|
|
95
|
+
inputMode?: "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | "search";
|
|
96
|
+
is?: string;
|
|
97
|
+
'aria-activedescendant'?: string;
|
|
98
|
+
'aria-atomic'?: boolean | "true" | "false";
|
|
99
|
+
'aria-autocomplete'?: "none" | "inline" | "list" | "both";
|
|
100
|
+
'aria-busy'?: boolean | "true" | "false";
|
|
101
|
+
'aria-checked'?: boolean | "true" | "false" | "mixed";
|
|
102
|
+
'aria-colcount'?: number;
|
|
103
|
+
'aria-colindex'?: number;
|
|
104
|
+
'aria-colspan'?: number;
|
|
105
|
+
'aria-controls'?: string;
|
|
106
|
+
'aria-current'?: boolean | "time" | "date" | "true" | "false" | "page" | "step" | "location";
|
|
107
|
+
'aria-describedby'?: string;
|
|
108
|
+
'aria-details'?: string;
|
|
109
|
+
'aria-disabled'?: boolean | "true" | "false";
|
|
110
|
+
'aria-dropeffect'?: "link" | "none" | "copy" | "execute" | "move" | "popup";
|
|
111
|
+
'aria-errormessage'?: string;
|
|
112
|
+
'aria-expanded'?: boolean | "true" | "false";
|
|
113
|
+
'aria-flowto'?: string;
|
|
114
|
+
'aria-grabbed'?: boolean | "true" | "false";
|
|
115
|
+
'aria-haspopup'?: boolean | "dialog" | "menu" | "true" | "false" | "listbox" | "tree" | "grid";
|
|
116
|
+
'aria-hidden'?: boolean | "true" | "false";
|
|
117
|
+
'aria-invalid'?: boolean | "true" | "false" | "grammar" | "spelling";
|
|
118
|
+
'aria-keyshortcuts'?: string;
|
|
119
|
+
'aria-label'?: string;
|
|
120
|
+
'aria-labelledby'?: string;
|
|
121
|
+
'aria-level'?: number;
|
|
122
|
+
'aria-live'?: "off" | "assertive" | "polite";
|
|
123
|
+
'aria-modal'?: boolean | "true" | "false";
|
|
124
|
+
'aria-multiline'?: boolean | "true" | "false";
|
|
125
|
+
'aria-multiselectable'?: boolean | "true" | "false";
|
|
126
|
+
'aria-orientation'?: "horizontal" | "vertical";
|
|
127
|
+
'aria-owns'?: string;
|
|
128
|
+
'aria-placeholder'?: string;
|
|
129
|
+
'aria-posinset'?: number;
|
|
130
|
+
'aria-pressed'?: boolean | "true" | "false" | "mixed";
|
|
131
|
+
'aria-readonly'?: boolean | "true" | "false";
|
|
132
|
+
'aria-relevant'?: "text" | "additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text additions" | "text removals";
|
|
133
|
+
'aria-required'?: boolean | "true" | "false";
|
|
134
|
+
'aria-roledescription'?: string;
|
|
135
|
+
'aria-rowcount'?: number;
|
|
136
|
+
'aria-rowindex'?: number;
|
|
137
|
+
'aria-rowspan'?: number;
|
|
138
|
+
'aria-selected'?: boolean | "true" | "false";
|
|
139
|
+
'aria-setsize'?: number;
|
|
140
|
+
'aria-sort'?: "none" | "ascending" | "descending" | "other";
|
|
141
|
+
'aria-valuemax'?: number;
|
|
142
|
+
'aria-valuemin'?: number;
|
|
143
|
+
'aria-valuenow'?: number;
|
|
144
|
+
'aria-valuetext'?: string;
|
|
145
|
+
children?: React.ReactNode;
|
|
146
|
+
dangerouslySetInnerHTML?: {
|
|
147
|
+
__html: string;
|
|
148
|
+
};
|
|
149
|
+
onCopy?: React.ClipboardEventHandler<HTMLElement>;
|
|
150
|
+
onCopyCapture?: React.ClipboardEventHandler<HTMLElement>;
|
|
151
|
+
onCut?: React.ClipboardEventHandler<HTMLElement>;
|
|
152
|
+
onCutCapture?: React.ClipboardEventHandler<HTMLElement>;
|
|
153
|
+
onPaste?: React.ClipboardEventHandler<HTMLElement>;
|
|
154
|
+
onPasteCapture?: React.ClipboardEventHandler<HTMLElement>;
|
|
155
|
+
onCompositionEnd?: React.CompositionEventHandler<HTMLElement>;
|
|
156
|
+
onCompositionEndCapture?: React.CompositionEventHandler<HTMLElement>;
|
|
157
|
+
onCompositionStart?: React.CompositionEventHandler<HTMLElement>;
|
|
158
|
+
onCompositionStartCapture?: React.CompositionEventHandler<HTMLElement>;
|
|
159
|
+
onCompositionUpdate?: React.CompositionEventHandler<HTMLElement>;
|
|
160
|
+
onCompositionUpdateCapture?: React.CompositionEventHandler<HTMLElement>;
|
|
161
|
+
onFocus?: React.FocusEventHandler<HTMLElement>;
|
|
162
|
+
onFocusCapture?: React.FocusEventHandler<HTMLElement>;
|
|
163
|
+
onBlur?: React.FocusEventHandler<HTMLElement>;
|
|
164
|
+
onBlurCapture?: React.FocusEventHandler<HTMLElement>;
|
|
165
|
+
onChange?: React.FormEventHandler<HTMLElement>;
|
|
166
|
+
onChangeCapture?: React.FormEventHandler<HTMLElement>;
|
|
167
|
+
onBeforeInput?: React.FormEventHandler<HTMLElement>;
|
|
168
|
+
onBeforeInputCapture?: React.FormEventHandler<HTMLElement>;
|
|
169
|
+
onInput?: React.FormEventHandler<HTMLElement>;
|
|
170
|
+
onInputCapture?: React.FormEventHandler<HTMLElement>;
|
|
171
|
+
onReset?: React.FormEventHandler<HTMLElement>;
|
|
172
|
+
onResetCapture?: React.FormEventHandler<HTMLElement>;
|
|
173
|
+
onSubmit?: React.FormEventHandler<HTMLElement>;
|
|
174
|
+
onSubmitCapture?: React.FormEventHandler<HTMLElement>;
|
|
175
|
+
onInvalid?: React.FormEventHandler<HTMLElement>;
|
|
176
|
+
onInvalidCapture?: React.FormEventHandler<HTMLElement>;
|
|
177
|
+
onLoad?: React.ReactEventHandler<HTMLElement>;
|
|
178
|
+
onLoadCapture?: React.ReactEventHandler<HTMLElement>;
|
|
179
|
+
onError?: React.ReactEventHandler<HTMLElement>;
|
|
180
|
+
onErrorCapture?: React.ReactEventHandler<HTMLElement>;
|
|
181
|
+
onKeyDown?: React.KeyboardEventHandler<HTMLElement>;
|
|
182
|
+
onKeyDownCapture?: React.KeyboardEventHandler<HTMLElement>;
|
|
183
|
+
onKeyPress?: React.KeyboardEventHandler<HTMLElement>;
|
|
184
|
+
onKeyPressCapture?: React.KeyboardEventHandler<HTMLElement>;
|
|
185
|
+
onKeyUp?: React.KeyboardEventHandler<HTMLElement>;
|
|
186
|
+
onKeyUpCapture?: React.KeyboardEventHandler<HTMLElement>;
|
|
187
|
+
onAbort?: React.ReactEventHandler<HTMLElement>;
|
|
188
|
+
onAbortCapture?: React.ReactEventHandler<HTMLElement>;
|
|
189
|
+
onCanPlay?: React.ReactEventHandler<HTMLElement>;
|
|
190
|
+
onCanPlayCapture?: React.ReactEventHandler<HTMLElement>;
|
|
191
|
+
onCanPlayThrough?: React.ReactEventHandler<HTMLElement>;
|
|
192
|
+
onCanPlayThroughCapture?: React.ReactEventHandler<HTMLElement>;
|
|
193
|
+
onDurationChange?: React.ReactEventHandler<HTMLElement>;
|
|
194
|
+
onDurationChangeCapture?: React.ReactEventHandler<HTMLElement>;
|
|
195
|
+
onEmptied?: React.ReactEventHandler<HTMLElement>;
|
|
196
|
+
onEmptiedCapture?: React.ReactEventHandler<HTMLElement>;
|
|
197
|
+
onEncrypted?: React.ReactEventHandler<HTMLElement>;
|
|
198
|
+
onEncryptedCapture?: React.ReactEventHandler<HTMLElement>;
|
|
199
|
+
onEnded?: React.ReactEventHandler<HTMLElement>;
|
|
200
|
+
onEndedCapture?: React.ReactEventHandler<HTMLElement>;
|
|
201
|
+
onLoadedData?: React.ReactEventHandler<HTMLElement>;
|
|
202
|
+
onLoadedDataCapture?: React.ReactEventHandler<HTMLElement>;
|
|
203
|
+
onLoadedMetadata?: React.ReactEventHandler<HTMLElement>;
|
|
204
|
+
onLoadedMetadataCapture?: React.ReactEventHandler<HTMLElement>;
|
|
205
|
+
onLoadStart?: React.ReactEventHandler<HTMLElement>;
|
|
206
|
+
onLoadStartCapture?: React.ReactEventHandler<HTMLElement>;
|
|
207
|
+
onPause?: React.ReactEventHandler<HTMLElement>;
|
|
208
|
+
onPauseCapture?: React.ReactEventHandler<HTMLElement>;
|
|
209
|
+
onPlay?: React.ReactEventHandler<HTMLElement>;
|
|
210
|
+
onPlayCapture?: React.ReactEventHandler<HTMLElement>;
|
|
211
|
+
onPlaying?: React.ReactEventHandler<HTMLElement>;
|
|
212
|
+
onPlayingCapture?: React.ReactEventHandler<HTMLElement>;
|
|
213
|
+
onProgress?: React.ReactEventHandler<HTMLElement>;
|
|
214
|
+
onProgressCapture?: React.ReactEventHandler<HTMLElement>;
|
|
215
|
+
onRateChange?: React.ReactEventHandler<HTMLElement>;
|
|
216
|
+
onRateChangeCapture?: React.ReactEventHandler<HTMLElement>;
|
|
217
|
+
onSeeked?: React.ReactEventHandler<HTMLElement>;
|
|
218
|
+
onSeekedCapture?: React.ReactEventHandler<HTMLElement>;
|
|
219
|
+
onSeeking?: React.ReactEventHandler<HTMLElement>;
|
|
220
|
+
onSeekingCapture?: React.ReactEventHandler<HTMLElement>;
|
|
221
|
+
onStalled?: React.ReactEventHandler<HTMLElement>;
|
|
222
|
+
onStalledCapture?: React.ReactEventHandler<HTMLElement>;
|
|
223
|
+
onSuspend?: React.ReactEventHandler<HTMLElement>;
|
|
224
|
+
onSuspendCapture?: React.ReactEventHandler<HTMLElement>;
|
|
225
|
+
onTimeUpdate?: React.ReactEventHandler<HTMLElement>;
|
|
226
|
+
onTimeUpdateCapture?: React.ReactEventHandler<HTMLElement>;
|
|
227
|
+
onVolumeChange?: React.ReactEventHandler<HTMLElement>;
|
|
228
|
+
onVolumeChangeCapture?: React.ReactEventHandler<HTMLElement>;
|
|
229
|
+
onWaiting?: React.ReactEventHandler<HTMLElement>;
|
|
230
|
+
onWaitingCapture?: React.ReactEventHandler<HTMLElement>;
|
|
231
|
+
onAuxClick?: React.MouseEventHandler<HTMLElement>;
|
|
232
|
+
onAuxClickCapture?: React.MouseEventHandler<HTMLElement>;
|
|
233
|
+
onClick?: React.MouseEventHandler<HTMLElement>;
|
|
234
|
+
onClickCapture?: React.MouseEventHandler<HTMLElement>;
|
|
235
|
+
onContextMenu?: React.MouseEventHandler<HTMLElement>;
|
|
236
|
+
onContextMenuCapture?: React.MouseEventHandler<HTMLElement>;
|
|
237
|
+
onDoubleClick?: React.MouseEventHandler<HTMLElement>;
|
|
238
|
+
onDoubleClickCapture?: React.MouseEventHandler<HTMLElement>;
|
|
239
|
+
onDrag?: React.DragEventHandler<HTMLElement>;
|
|
240
|
+
onDragCapture?: React.DragEventHandler<HTMLElement>;
|
|
241
|
+
onDragEnd?: React.DragEventHandler<HTMLElement>;
|
|
242
|
+
onDragEndCapture?: React.DragEventHandler<HTMLElement>;
|
|
243
|
+
onDragEnter?: React.DragEventHandler<HTMLElement>;
|
|
244
|
+
onDragEnterCapture?: React.DragEventHandler<HTMLElement>;
|
|
245
|
+
onDragExit?: React.DragEventHandler<HTMLElement>;
|
|
246
|
+
onDragExitCapture?: React.DragEventHandler<HTMLElement>;
|
|
247
|
+
onDragLeave?: React.DragEventHandler<HTMLElement>;
|
|
248
|
+
onDragLeaveCapture?: React.DragEventHandler<HTMLElement>;
|
|
249
|
+
onDragOver?: React.DragEventHandler<HTMLElement>;
|
|
250
|
+
onDragOverCapture?: React.DragEventHandler<HTMLElement>;
|
|
251
|
+
onDragStart?: React.DragEventHandler<HTMLElement>;
|
|
252
|
+
onDragStartCapture?: React.DragEventHandler<HTMLElement>;
|
|
253
|
+
onDrop?: React.DragEventHandler<HTMLElement>;
|
|
254
|
+
onDropCapture?: React.DragEventHandler<HTMLElement>;
|
|
255
|
+
onMouseDown?: React.MouseEventHandler<HTMLElement>;
|
|
256
|
+
onMouseDownCapture?: React.MouseEventHandler<HTMLElement>;
|
|
257
|
+
onMouseEnter?: React.MouseEventHandler<HTMLElement>;
|
|
258
|
+
onMouseLeave?: React.MouseEventHandler<HTMLElement>;
|
|
259
|
+
onMouseMove?: React.MouseEventHandler<HTMLElement>;
|
|
260
|
+
onMouseMoveCapture?: React.MouseEventHandler<HTMLElement>;
|
|
261
|
+
onMouseOut?: React.MouseEventHandler<HTMLElement>;
|
|
262
|
+
onMouseOutCapture?: React.MouseEventHandler<HTMLElement>;
|
|
263
|
+
onMouseOver?: React.MouseEventHandler<HTMLElement>;
|
|
264
|
+
onMouseOverCapture?: React.MouseEventHandler<HTMLElement>;
|
|
265
|
+
onMouseUp?: React.MouseEventHandler<HTMLElement>;
|
|
266
|
+
onMouseUpCapture?: React.MouseEventHandler<HTMLElement>;
|
|
267
|
+
onSelect?: React.ReactEventHandler<HTMLElement>;
|
|
268
|
+
onSelectCapture?: React.ReactEventHandler<HTMLElement>;
|
|
269
|
+
onTouchCancel?: React.TouchEventHandler<HTMLElement>;
|
|
270
|
+
onTouchCancelCapture?: React.TouchEventHandler<HTMLElement>;
|
|
271
|
+
onTouchEnd?: React.TouchEventHandler<HTMLElement>;
|
|
272
|
+
onTouchEndCapture?: React.TouchEventHandler<HTMLElement>;
|
|
273
|
+
onTouchMove?: React.TouchEventHandler<HTMLElement>;
|
|
274
|
+
onTouchMoveCapture?: React.TouchEventHandler<HTMLElement>;
|
|
275
|
+
onTouchStart?: React.TouchEventHandler<HTMLElement>;
|
|
276
|
+
onTouchStartCapture?: React.TouchEventHandler<HTMLElement>;
|
|
277
|
+
onPointerDown?: React.PointerEventHandler<HTMLElement>;
|
|
278
|
+
onPointerDownCapture?: React.PointerEventHandler<HTMLElement>;
|
|
279
|
+
onPointerMove?: React.PointerEventHandler<HTMLElement>;
|
|
280
|
+
onPointerMoveCapture?: React.PointerEventHandler<HTMLElement>;
|
|
281
|
+
onPointerUp?: React.PointerEventHandler<HTMLElement>;
|
|
282
|
+
onPointerUpCapture?: React.PointerEventHandler<HTMLElement>;
|
|
283
|
+
onPointerCancel?: React.PointerEventHandler<HTMLElement>;
|
|
284
|
+
onPointerCancelCapture?: React.PointerEventHandler<HTMLElement>;
|
|
285
|
+
onPointerEnter?: React.PointerEventHandler<HTMLElement>;
|
|
286
|
+
onPointerEnterCapture?: React.PointerEventHandler<HTMLElement>;
|
|
287
|
+
onPointerLeave?: React.PointerEventHandler<HTMLElement>;
|
|
288
|
+
onPointerLeaveCapture?: React.PointerEventHandler<HTMLElement>;
|
|
289
|
+
onPointerOver?: React.PointerEventHandler<HTMLElement>;
|
|
290
|
+
onPointerOverCapture?: React.PointerEventHandler<HTMLElement>;
|
|
291
|
+
onPointerOut?: React.PointerEventHandler<HTMLElement>;
|
|
292
|
+
onPointerOutCapture?: React.PointerEventHandler<HTMLElement>;
|
|
293
|
+
onGotPointerCapture?: React.PointerEventHandler<HTMLElement>;
|
|
294
|
+
onGotPointerCaptureCapture?: React.PointerEventHandler<HTMLElement>;
|
|
295
|
+
onLostPointerCapture?: React.PointerEventHandler<HTMLElement>;
|
|
296
|
+
onLostPointerCaptureCapture?: React.PointerEventHandler<HTMLElement>;
|
|
297
|
+
onScroll?: React.UIEventHandler<HTMLElement>;
|
|
298
|
+
onScrollCapture?: React.UIEventHandler<HTMLElement>;
|
|
299
|
+
onWheel?: React.WheelEventHandler<HTMLElement>;
|
|
300
|
+
onWheelCapture?: React.WheelEventHandler<HTMLElement>;
|
|
301
|
+
onAnimationStart?: React.AnimationEventHandler<HTMLElement>;
|
|
302
|
+
onAnimationStartCapture?: React.AnimationEventHandler<HTMLElement>;
|
|
303
|
+
onAnimationEnd?: React.AnimationEventHandler<HTMLElement>;
|
|
304
|
+
onAnimationEndCapture?: React.AnimationEventHandler<HTMLElement>;
|
|
305
|
+
onAnimationIteration?: React.AnimationEventHandler<HTMLElement>;
|
|
306
|
+
onAnimationIterationCapture?: React.AnimationEventHandler<HTMLElement>;
|
|
307
|
+
onTransitionEnd?: React.TransitionEventHandler<HTMLElement>;
|
|
308
|
+
onTransitionEndCapture?: React.TransitionEventHandler<HTMLElement>;
|
|
309
|
+
date: DateType;
|
|
310
|
+
format?: DateFormat;
|
|
311
|
+
className?: string;
|
|
312
|
+
testId?: string;
|
|
313
|
+
style?: React.CSSProperties;
|
|
314
|
+
} & React.RefAttributes<HTMLTimeElement>>;
|
|
315
|
+
interface RelativeDateTimeInternalProps extends CommonProps {
|
|
316
|
+
/**
|
|
317
|
+
* The date that will be displayed. It accepts a JS Date, an ISO8601 Timestamp string, or Unix Epoch Milliseconds number
|
|
318
|
+
*/
|
|
319
|
+
date: DateType;
|
|
320
|
+
/**
|
|
321
|
+
* If a value is passed to baseDate, then the component will compare both dates and return the time between them.
|
|
322
|
+
* If no value is passed then the date will be compared to "now"
|
|
323
|
+
*
|
|
324
|
+
* @default "Now"
|
|
325
|
+
*/
|
|
326
|
+
baseDate?: DateType;
|
|
327
|
+
/**
|
|
328
|
+
* Sets the date to be relative only if it is in the current week
|
|
329
|
+
* @default false
|
|
330
|
+
*/
|
|
331
|
+
isRelativeToCurrentWeek?: boolean;
|
|
332
|
+
}
|
|
333
|
+
export type RelativeDateTimeProps = PropsWithHTMLElement<RelativeDateTimeInternalProps, 'time'>;
|
|
334
|
+
/**
|
|
335
|
+
* The RelativeDateTime will show a `date` relative to "now" or to the `baseDate`
|
|
336
|
+
* (e.g. in a day, in one month, one month ago, etc).
|
|
337
|
+
*/
|
|
338
|
+
export const RelativeDateTime: React.ForwardRefExoticComponent<{
|
|
339
|
+
slot?: string;
|
|
340
|
+
title?: string;
|
|
341
|
+
key?: React.Key;
|
|
342
|
+
dateTime?: string;
|
|
343
|
+
defaultChecked?: boolean;
|
|
344
|
+
defaultValue?: string | number | readonly string[];
|
|
345
|
+
suppressContentEditableWarning?: boolean;
|
|
346
|
+
suppressHydrationWarning?: boolean;
|
|
347
|
+
accessKey?: string;
|
|
348
|
+
contentEditable?: (boolean | "true" | "false") | "inherit";
|
|
349
|
+
contextMenu?: string;
|
|
350
|
+
dir?: string;
|
|
351
|
+
draggable?: boolean | "true" | "false";
|
|
352
|
+
hidden?: boolean;
|
|
353
|
+
id?: string;
|
|
354
|
+
lang?: string;
|
|
355
|
+
placeholder?: string;
|
|
356
|
+
spellCheck?: boolean | "true" | "false";
|
|
357
|
+
tabIndex?: number;
|
|
358
|
+
translate?: "yes" | "no";
|
|
359
|
+
radioGroup?: string;
|
|
360
|
+
role?: string;
|
|
361
|
+
about?: string;
|
|
362
|
+
datatype?: string;
|
|
363
|
+
inlist?: any;
|
|
364
|
+
prefix?: string;
|
|
365
|
+
property?: string;
|
|
366
|
+
resource?: string;
|
|
367
|
+
typeof?: string;
|
|
368
|
+
vocab?: string;
|
|
369
|
+
autoCapitalize?: string;
|
|
370
|
+
autoCorrect?: string;
|
|
371
|
+
autoSave?: string;
|
|
372
|
+
color?: string;
|
|
373
|
+
itemProp?: string;
|
|
374
|
+
itemScope?: boolean;
|
|
375
|
+
itemType?: string;
|
|
376
|
+
itemID?: string;
|
|
377
|
+
itemRef?: string;
|
|
378
|
+
results?: number;
|
|
379
|
+
security?: string;
|
|
380
|
+
unselectable?: "on" | "off";
|
|
381
|
+
inputMode?: "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | "search";
|
|
382
|
+
is?: string;
|
|
383
|
+
'aria-activedescendant'?: string;
|
|
384
|
+
'aria-atomic'?: boolean | "true" | "false";
|
|
385
|
+
'aria-autocomplete'?: "none" | "inline" | "list" | "both";
|
|
386
|
+
'aria-busy'?: boolean | "true" | "false";
|
|
387
|
+
'aria-checked'?: boolean | "true" | "false" | "mixed";
|
|
388
|
+
'aria-colcount'?: number;
|
|
389
|
+
'aria-colindex'?: number;
|
|
390
|
+
'aria-colspan'?: number;
|
|
391
|
+
'aria-controls'?: string;
|
|
392
|
+
'aria-current'?: boolean | "time" | "date" | "true" | "false" | "page" | "step" | "location";
|
|
393
|
+
'aria-describedby'?: string;
|
|
394
|
+
'aria-details'?: string;
|
|
395
|
+
'aria-disabled'?: boolean | "true" | "false";
|
|
396
|
+
'aria-dropeffect'?: "link" | "none" | "copy" | "execute" | "move" | "popup";
|
|
397
|
+
'aria-errormessage'?: string;
|
|
398
|
+
'aria-expanded'?: boolean | "true" | "false";
|
|
399
|
+
'aria-flowto'?: string;
|
|
400
|
+
'aria-grabbed'?: boolean | "true" | "false";
|
|
401
|
+
'aria-haspopup'?: boolean | "dialog" | "menu" | "true" | "false" | "listbox" | "tree" | "grid";
|
|
402
|
+
'aria-hidden'?: boolean | "true" | "false";
|
|
403
|
+
'aria-invalid'?: boolean | "true" | "false" | "grammar" | "spelling";
|
|
404
|
+
'aria-keyshortcuts'?: string;
|
|
405
|
+
'aria-label'?: string;
|
|
406
|
+
'aria-labelledby'?: string;
|
|
407
|
+
'aria-level'?: number;
|
|
408
|
+
'aria-live'?: "off" | "assertive" | "polite";
|
|
409
|
+
'aria-modal'?: boolean | "true" | "false";
|
|
410
|
+
'aria-multiline'?: boolean | "true" | "false";
|
|
411
|
+
'aria-multiselectable'?: boolean | "true" | "false";
|
|
412
|
+
'aria-orientation'?: "horizontal" | "vertical";
|
|
413
|
+
'aria-owns'?: string;
|
|
414
|
+
'aria-placeholder'?: string;
|
|
415
|
+
'aria-posinset'?: number;
|
|
416
|
+
'aria-pressed'?: boolean | "true" | "false" | "mixed";
|
|
417
|
+
'aria-readonly'?: boolean | "true" | "false";
|
|
418
|
+
'aria-relevant'?: "text" | "additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text additions" | "text removals";
|
|
419
|
+
'aria-required'?: boolean | "true" | "false";
|
|
420
|
+
'aria-roledescription'?: string;
|
|
421
|
+
'aria-rowcount'?: number;
|
|
422
|
+
'aria-rowindex'?: number;
|
|
423
|
+
'aria-rowspan'?: number;
|
|
424
|
+
'aria-selected'?: boolean | "true" | "false";
|
|
425
|
+
'aria-setsize'?: number;
|
|
426
|
+
'aria-sort'?: "none" | "ascending" | "descending" | "other";
|
|
427
|
+
'aria-valuemax'?: number;
|
|
428
|
+
'aria-valuemin'?: number;
|
|
429
|
+
'aria-valuenow'?: number;
|
|
430
|
+
'aria-valuetext'?: string;
|
|
431
|
+
children?: React.ReactNode;
|
|
432
|
+
dangerouslySetInnerHTML?: {
|
|
433
|
+
__html: string;
|
|
434
|
+
};
|
|
435
|
+
onCopy?: React.ClipboardEventHandler<HTMLElement>;
|
|
436
|
+
onCopyCapture?: React.ClipboardEventHandler<HTMLElement>;
|
|
437
|
+
onCut?: React.ClipboardEventHandler<HTMLElement>;
|
|
438
|
+
onCutCapture?: React.ClipboardEventHandler<HTMLElement>;
|
|
439
|
+
onPaste?: React.ClipboardEventHandler<HTMLElement>;
|
|
440
|
+
onPasteCapture?: React.ClipboardEventHandler<HTMLElement>;
|
|
441
|
+
onCompositionEnd?: React.CompositionEventHandler<HTMLElement>;
|
|
442
|
+
onCompositionEndCapture?: React.CompositionEventHandler<HTMLElement>;
|
|
443
|
+
onCompositionStart?: React.CompositionEventHandler<HTMLElement>;
|
|
444
|
+
onCompositionStartCapture?: React.CompositionEventHandler<HTMLElement>;
|
|
445
|
+
onCompositionUpdate?: React.CompositionEventHandler<HTMLElement>;
|
|
446
|
+
onCompositionUpdateCapture?: React.CompositionEventHandler<HTMLElement>;
|
|
447
|
+
onFocus?: React.FocusEventHandler<HTMLElement>;
|
|
448
|
+
onFocusCapture?: React.FocusEventHandler<HTMLElement>;
|
|
449
|
+
onBlur?: React.FocusEventHandler<HTMLElement>;
|
|
450
|
+
onBlurCapture?: React.FocusEventHandler<HTMLElement>;
|
|
451
|
+
onChange?: React.FormEventHandler<HTMLElement>;
|
|
452
|
+
onChangeCapture?: React.FormEventHandler<HTMLElement>;
|
|
453
|
+
onBeforeInput?: React.FormEventHandler<HTMLElement>;
|
|
454
|
+
onBeforeInputCapture?: React.FormEventHandler<HTMLElement>;
|
|
455
|
+
onInput?: React.FormEventHandler<HTMLElement>;
|
|
456
|
+
onInputCapture?: React.FormEventHandler<HTMLElement>;
|
|
457
|
+
onReset?: React.FormEventHandler<HTMLElement>;
|
|
458
|
+
onResetCapture?: React.FormEventHandler<HTMLElement>;
|
|
459
|
+
onSubmit?: React.FormEventHandler<HTMLElement>;
|
|
460
|
+
onSubmitCapture?: React.FormEventHandler<HTMLElement>;
|
|
461
|
+
onInvalid?: React.FormEventHandler<HTMLElement>;
|
|
462
|
+
onInvalidCapture?: React.FormEventHandler<HTMLElement>;
|
|
463
|
+
onLoad?: React.ReactEventHandler<HTMLElement>;
|
|
464
|
+
onLoadCapture?: React.ReactEventHandler<HTMLElement>;
|
|
465
|
+
onError?: React.ReactEventHandler<HTMLElement>;
|
|
466
|
+
onErrorCapture?: React.ReactEventHandler<HTMLElement>;
|
|
467
|
+
onKeyDown?: React.KeyboardEventHandler<HTMLElement>;
|
|
468
|
+
onKeyDownCapture?: React.KeyboardEventHandler<HTMLElement>;
|
|
469
|
+
onKeyPress?: React.KeyboardEventHandler<HTMLElement>;
|
|
470
|
+
onKeyPressCapture?: React.KeyboardEventHandler<HTMLElement>;
|
|
471
|
+
onKeyUp?: React.KeyboardEventHandler<HTMLElement>;
|
|
472
|
+
onKeyUpCapture?: React.KeyboardEventHandler<HTMLElement>;
|
|
473
|
+
onAbort?: React.ReactEventHandler<HTMLElement>;
|
|
474
|
+
onAbortCapture?: React.ReactEventHandler<HTMLElement>;
|
|
475
|
+
onCanPlay?: React.ReactEventHandler<HTMLElement>;
|
|
476
|
+
onCanPlayCapture?: React.ReactEventHandler<HTMLElement>;
|
|
477
|
+
onCanPlayThrough?: React.ReactEventHandler<HTMLElement>;
|
|
478
|
+
onCanPlayThroughCapture?: React.ReactEventHandler<HTMLElement>;
|
|
479
|
+
onDurationChange?: React.ReactEventHandler<HTMLElement>;
|
|
480
|
+
onDurationChangeCapture?: React.ReactEventHandler<HTMLElement>;
|
|
481
|
+
onEmptied?: React.ReactEventHandler<HTMLElement>;
|
|
482
|
+
onEmptiedCapture?: React.ReactEventHandler<HTMLElement>;
|
|
483
|
+
onEncrypted?: React.ReactEventHandler<HTMLElement>;
|
|
484
|
+
onEncryptedCapture?: React.ReactEventHandler<HTMLElement>;
|
|
485
|
+
onEnded?: React.ReactEventHandler<HTMLElement>;
|
|
486
|
+
onEndedCapture?: React.ReactEventHandler<HTMLElement>;
|
|
487
|
+
onLoadedData?: React.ReactEventHandler<HTMLElement>;
|
|
488
|
+
onLoadedDataCapture?: React.ReactEventHandler<HTMLElement>;
|
|
489
|
+
onLoadedMetadata?: React.ReactEventHandler<HTMLElement>;
|
|
490
|
+
onLoadedMetadataCapture?: React.ReactEventHandler<HTMLElement>;
|
|
491
|
+
onLoadStart?: React.ReactEventHandler<HTMLElement>;
|
|
492
|
+
onLoadStartCapture?: React.ReactEventHandler<HTMLElement>;
|
|
493
|
+
onPause?: React.ReactEventHandler<HTMLElement>;
|
|
494
|
+
onPauseCapture?: React.ReactEventHandler<HTMLElement>;
|
|
495
|
+
onPlay?: React.ReactEventHandler<HTMLElement>;
|
|
496
|
+
onPlayCapture?: React.ReactEventHandler<HTMLElement>;
|
|
497
|
+
onPlaying?: React.ReactEventHandler<HTMLElement>;
|
|
498
|
+
onPlayingCapture?: React.ReactEventHandler<HTMLElement>;
|
|
499
|
+
onProgress?: React.ReactEventHandler<HTMLElement>;
|
|
500
|
+
onProgressCapture?: React.ReactEventHandler<HTMLElement>;
|
|
501
|
+
onRateChange?: React.ReactEventHandler<HTMLElement>;
|
|
502
|
+
onRateChangeCapture?: React.ReactEventHandler<HTMLElement>;
|
|
503
|
+
onSeeked?: React.ReactEventHandler<HTMLElement>;
|
|
504
|
+
onSeekedCapture?: React.ReactEventHandler<HTMLElement>;
|
|
505
|
+
onSeeking?: React.ReactEventHandler<HTMLElement>;
|
|
506
|
+
onSeekingCapture?: React.ReactEventHandler<HTMLElement>;
|
|
507
|
+
onStalled?: React.ReactEventHandler<HTMLElement>;
|
|
508
|
+
onStalledCapture?: React.ReactEventHandler<HTMLElement>;
|
|
509
|
+
onSuspend?: React.ReactEventHandler<HTMLElement>;
|
|
510
|
+
onSuspendCapture?: React.ReactEventHandler<HTMLElement>;
|
|
511
|
+
onTimeUpdate?: React.ReactEventHandler<HTMLElement>;
|
|
512
|
+
onTimeUpdateCapture?: React.ReactEventHandler<HTMLElement>;
|
|
513
|
+
onVolumeChange?: React.ReactEventHandler<HTMLElement>;
|
|
514
|
+
onVolumeChangeCapture?: React.ReactEventHandler<HTMLElement>;
|
|
515
|
+
onWaiting?: React.ReactEventHandler<HTMLElement>;
|
|
516
|
+
onWaitingCapture?: React.ReactEventHandler<HTMLElement>;
|
|
517
|
+
onAuxClick?: React.MouseEventHandler<HTMLElement>;
|
|
518
|
+
onAuxClickCapture?: React.MouseEventHandler<HTMLElement>;
|
|
519
|
+
onClick?: React.MouseEventHandler<HTMLElement>;
|
|
520
|
+
onClickCapture?: React.MouseEventHandler<HTMLElement>;
|
|
521
|
+
onContextMenu?: React.MouseEventHandler<HTMLElement>;
|
|
522
|
+
onContextMenuCapture?: React.MouseEventHandler<HTMLElement>;
|
|
523
|
+
onDoubleClick?: React.MouseEventHandler<HTMLElement>;
|
|
524
|
+
onDoubleClickCapture?: React.MouseEventHandler<HTMLElement>;
|
|
525
|
+
onDrag?: React.DragEventHandler<HTMLElement>;
|
|
526
|
+
onDragCapture?: React.DragEventHandler<HTMLElement>;
|
|
527
|
+
onDragEnd?: React.DragEventHandler<HTMLElement>;
|
|
528
|
+
onDragEndCapture?: React.DragEventHandler<HTMLElement>;
|
|
529
|
+
onDragEnter?: React.DragEventHandler<HTMLElement>;
|
|
530
|
+
onDragEnterCapture?: React.DragEventHandler<HTMLElement>;
|
|
531
|
+
onDragExit?: React.DragEventHandler<HTMLElement>;
|
|
532
|
+
onDragExitCapture?: React.DragEventHandler<HTMLElement>;
|
|
533
|
+
onDragLeave?: React.DragEventHandler<HTMLElement>;
|
|
534
|
+
onDragLeaveCapture?: React.DragEventHandler<HTMLElement>;
|
|
535
|
+
onDragOver?: React.DragEventHandler<HTMLElement>;
|
|
536
|
+
onDragOverCapture?: React.DragEventHandler<HTMLElement>;
|
|
537
|
+
onDragStart?: React.DragEventHandler<HTMLElement>;
|
|
538
|
+
onDragStartCapture?: React.DragEventHandler<HTMLElement>;
|
|
539
|
+
onDrop?: React.DragEventHandler<HTMLElement>;
|
|
540
|
+
onDropCapture?: React.DragEventHandler<HTMLElement>;
|
|
541
|
+
onMouseDown?: React.MouseEventHandler<HTMLElement>;
|
|
542
|
+
onMouseDownCapture?: React.MouseEventHandler<HTMLElement>;
|
|
543
|
+
onMouseEnter?: React.MouseEventHandler<HTMLElement>;
|
|
544
|
+
onMouseLeave?: React.MouseEventHandler<HTMLElement>;
|
|
545
|
+
onMouseMove?: React.MouseEventHandler<HTMLElement>;
|
|
546
|
+
onMouseMoveCapture?: React.MouseEventHandler<HTMLElement>;
|
|
547
|
+
onMouseOut?: React.MouseEventHandler<HTMLElement>;
|
|
548
|
+
onMouseOutCapture?: React.MouseEventHandler<HTMLElement>;
|
|
549
|
+
onMouseOver?: React.MouseEventHandler<HTMLElement>;
|
|
550
|
+
onMouseOverCapture?: React.MouseEventHandler<HTMLElement>;
|
|
551
|
+
onMouseUp?: React.MouseEventHandler<HTMLElement>;
|
|
552
|
+
onMouseUpCapture?: React.MouseEventHandler<HTMLElement>;
|
|
553
|
+
onSelect?: React.ReactEventHandler<HTMLElement>;
|
|
554
|
+
onSelectCapture?: React.ReactEventHandler<HTMLElement>;
|
|
555
|
+
onTouchCancel?: React.TouchEventHandler<HTMLElement>;
|
|
556
|
+
onTouchCancelCapture?: React.TouchEventHandler<HTMLElement>;
|
|
557
|
+
onTouchEnd?: React.TouchEventHandler<HTMLElement>;
|
|
558
|
+
onTouchEndCapture?: React.TouchEventHandler<HTMLElement>;
|
|
559
|
+
onTouchMove?: React.TouchEventHandler<HTMLElement>;
|
|
560
|
+
onTouchMoveCapture?: React.TouchEventHandler<HTMLElement>;
|
|
561
|
+
onTouchStart?: React.TouchEventHandler<HTMLElement>;
|
|
562
|
+
onTouchStartCapture?: React.TouchEventHandler<HTMLElement>;
|
|
563
|
+
onPointerDown?: React.PointerEventHandler<HTMLElement>;
|
|
564
|
+
onPointerDownCapture?: React.PointerEventHandler<HTMLElement>;
|
|
565
|
+
onPointerMove?: React.PointerEventHandler<HTMLElement>;
|
|
566
|
+
onPointerMoveCapture?: React.PointerEventHandler<HTMLElement>;
|
|
567
|
+
onPointerUp?: React.PointerEventHandler<HTMLElement>;
|
|
568
|
+
onPointerUpCapture?: React.PointerEventHandler<HTMLElement>;
|
|
569
|
+
onPointerCancel?: React.PointerEventHandler<HTMLElement>;
|
|
570
|
+
onPointerCancelCapture?: React.PointerEventHandler<HTMLElement>;
|
|
571
|
+
onPointerEnter?: React.PointerEventHandler<HTMLElement>;
|
|
572
|
+
onPointerEnterCapture?: React.PointerEventHandler<HTMLElement>;
|
|
573
|
+
onPointerLeave?: React.PointerEventHandler<HTMLElement>;
|
|
574
|
+
onPointerLeaveCapture?: React.PointerEventHandler<HTMLElement>;
|
|
575
|
+
onPointerOver?: React.PointerEventHandler<HTMLElement>;
|
|
576
|
+
onPointerOverCapture?: React.PointerEventHandler<HTMLElement>;
|
|
577
|
+
onPointerOut?: React.PointerEventHandler<HTMLElement>;
|
|
578
|
+
onPointerOutCapture?: React.PointerEventHandler<HTMLElement>;
|
|
579
|
+
onGotPointerCapture?: React.PointerEventHandler<HTMLElement>;
|
|
580
|
+
onGotPointerCaptureCapture?: React.PointerEventHandler<HTMLElement>;
|
|
581
|
+
onLostPointerCapture?: React.PointerEventHandler<HTMLElement>;
|
|
582
|
+
onLostPointerCaptureCapture?: React.PointerEventHandler<HTMLElement>;
|
|
583
|
+
onScroll?: React.UIEventHandler<HTMLElement>;
|
|
584
|
+
onScrollCapture?: React.UIEventHandler<HTMLElement>;
|
|
585
|
+
onWheel?: React.WheelEventHandler<HTMLElement>;
|
|
586
|
+
onWheelCapture?: React.WheelEventHandler<HTMLElement>;
|
|
587
|
+
onAnimationStart?: React.AnimationEventHandler<HTMLElement>;
|
|
588
|
+
onAnimationStartCapture?: React.AnimationEventHandler<HTMLElement>;
|
|
589
|
+
onAnimationEnd?: React.AnimationEventHandler<HTMLElement>;
|
|
590
|
+
onAnimationEndCapture?: React.AnimationEventHandler<HTMLElement>;
|
|
591
|
+
onAnimationIteration?: React.AnimationEventHandler<HTMLElement>;
|
|
592
|
+
onAnimationIterationCapture?: React.AnimationEventHandler<HTMLElement>;
|
|
593
|
+
onTransitionEnd?: React.TransitionEventHandler<HTMLElement>;
|
|
594
|
+
onTransitionEndCapture?: React.TransitionEventHandler<HTMLElement>;
|
|
595
|
+
date: DateType;
|
|
596
|
+
baseDate?: DateType;
|
|
597
|
+
isRelativeToCurrentWeek?: boolean;
|
|
598
|
+
className?: string;
|
|
599
|
+
testId?: string;
|
|
600
|
+
style?: React.CSSProperties;
|
|
601
|
+
} & React.RefAttributes<HTMLTimeElement>>;
|
|
602
|
+
|
|
603
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;AAAA,gBAAuB,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC;AAE9C,kBAAyB,MAAM,GA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAlEL,QAAQ;eAOH,QAAQ;8BAKO,OAAO;;;;yCAsDgC,CAAC","sources":["packages/components/datetime/src/src/types.ts","packages/components/datetime/src/src/utils/formatDateTimeUtils.ts","packages/components/datetime/src/src/utils/relativeDateTimeUtils.ts","packages/components/datetime/src/src/utils/index.ts","packages/components/datetime/src/src/DateTime/DateTime.tsx","packages/components/datetime/src/src/RelativeDateTime/RelativeDateTime.tsx","packages/components/datetime/src/src/index.ts","packages/components/datetime/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,"export { DateTime } from './DateTime/DateTime';\nexport type { DateTimeProps } from './DateTime/DateTime';\nexport { RelativeDateTime } from './RelativeDateTime/RelativeDateTime';\nexport type { RelativeDateTimeProps } from './RelativeDateTime/RelativeDateTime';\nexport { formatDateAndTime, formatMachineReadableDateTime } from './utils';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@contentful/f36-datetime",
|
|
3
|
+
"version": "4.0.0",
|
|
4
|
+
"description": "Forma 36: DateTime component",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "parcel build"
|
|
7
|
+
},
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@babel/runtime": "^7.6.2",
|
|
10
|
+
"@contentful/f36-core": "^4.0.0",
|
|
11
|
+
"@contentful/f36-tokens": "^4.0.0",
|
|
12
|
+
"dayjs": "^1.10.6",
|
|
13
|
+
"emotion": "^10.0.17"
|
|
14
|
+
},
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"react": ">=16.8"
|
|
17
|
+
},
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"main": "dist/main.js",
|
|
23
|
+
"module": "dist/module.js",
|
|
24
|
+
"types": "dist/types.d.ts",
|
|
25
|
+
"source": "src/index.ts",
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"browserslist": "extends @contentful/browserslist-config",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/contentful/forma-36"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"gitHead": "01d931c77410619d05cd00dbb3b5acc5d8ae2cdf"
|
|
36
|
+
}
|