@ltht-react/type-summary 2.0.50 → 2.0.52
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.
|
@@ -31,22 +31,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
32
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
33
33
|
var styled_1 = __importDefault(require("@emotion/styled"));
|
|
34
|
+
var date_fns_1 = require("date-fns");
|
|
34
35
|
var styles_1 = require("@ltht-react/styles");
|
|
35
36
|
var utils_1 = require("@ltht-react/utils");
|
|
36
37
|
var StyledDateSummary = styled_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n color: ", ";\n text-decoration: ", ";\n display: inline-block;\n"], ["\n color: ", ";\n text-decoration: ", ";\n display: inline-block;\n"])), styles_1.TEXT_COLOURS.PRIMARY, function (_a) {
|
|
37
38
|
var enteredInError = _a.enteredInError;
|
|
38
39
|
return (enteredInError ? 'line-through' : 'none');
|
|
39
40
|
});
|
|
40
|
-
var
|
|
41
|
-
var _a;
|
|
41
|
+
var formatAsISODate = function (partialDateTime) {
|
|
42
42
|
if (!(partialDateTime === null || partialDateTime === void 0 ? void 0 : partialDateTime.value))
|
|
43
43
|
return '';
|
|
44
|
-
var date =
|
|
45
|
-
return (
|
|
44
|
+
var date = (0, date_fns_1.parseISO)(partialDateTime.value);
|
|
45
|
+
return (0, date_fns_1.format)(date, 'dd-MMM-yyyy');
|
|
46
46
|
};
|
|
47
47
|
var DateSummary = function (_a) {
|
|
48
48
|
var datetime = _a.datetime, enteredInError = _a.enteredInError, dateOnlyView = _a.dateOnlyView, rest = __rest(_a, ["datetime", "enteredInError", "dateOnlyView"]);
|
|
49
|
-
return ((0, jsx_runtime_1.jsx)(StyledDateSummary, __assign({ enteredInError: enteredInError, dateOnlyView: dateOnlyView }, rest, { children: dateOnlyView ?
|
|
49
|
+
return ((0, jsx_runtime_1.jsx)(StyledDateSummary, __assign({ enteredInError: enteredInError, dateOnlyView: dateOnlyView }, rest, { children: dateOnlyView ? formatAsISODate(datetime) : (0, utils_1.partialDateTimeText)(datetime) })));
|
|
50
50
|
};
|
|
51
51
|
exports.default = DateSummary;
|
|
52
52
|
var templateObject_1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-summary.js","sourceRoot":"","sources":["../../src/atoms/date-summary.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2DAAoC;
|
|
1
|
+
{"version":3,"file":"date-summary.js","sourceRoot":"","sources":["../../src/atoms/date-summary.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2DAAoC;AACpC,qCAA2C;AAE3C,6CAAiD;AAEjD,2CAAuD;AAEvD,IAAM,iBAAiB,GAAG,gBAAM,CAAC,GAAG,2IAAoB,aAC7C,EAAoB,wBACV,EAAkE,+BAEtF,KAHU,qBAAY,CAAC,OAAO,EACV,UAAC,EAAkB;QAAhB,cAAc,oBAAA;IAAO,OAAA,CAAC,cAAc,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC;AAA1C,CAA0C,CAEtF,CAAA;AAED,IAAM,eAAe,GAAG,UAAC,eAAwC;IAC/D,IAAI,CAAC,CAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,KAAK,CAAA;QAAE,OAAO,EAAE,CAAA;IAEtC,IAAM,IAAI,GAAG,IAAA,mBAAQ,EAAC,eAAe,CAAC,KAAK,CAAC,CAAA;IAC5C,OAAO,IAAA,iBAAM,EAAC,IAAI,EAAE,aAAa,CAAC,CAAA;AACpC,CAAC,CAAA;AAED,IAAM,WAAW,GAAc,UAAC,EAAmD;IAAjD,IAAA,QAAQ,cAAA,EAAE,cAAc,oBAAA,EAAE,YAAY,kBAAA,EAAK,IAAI,cAAjD,8CAAmD,CAAF;IAAO,OAAA,CACtF,uBAAC,iBAAiB,aAAC,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,IAAM,IAAI,cACpF,YAAY,CAAC,CAAC,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAA,2BAAmB,EAAC,QAAQ,CAAC,IACvD,CACrB,CAAA;CAAA,CAAA;AAaD,kBAAe,WAAW,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ltht-react/type-summary",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.52",
|
|
4
4
|
"description": "ltht-react clinical Summary component.",
|
|
5
5
|
"author": "LTHT",
|
|
6
6
|
"homepage": "",
|
|
@@ -28,13 +28,13 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@emotion/react": "^11.0.0",
|
|
30
30
|
"@emotion/styled": "^11.0.0",
|
|
31
|
-
"@ltht-react/card": "^2.0.
|
|
32
|
-
"@ltht-react/icon": "^2.0.
|
|
33
|
-
"@ltht-react/list": "^2.0.
|
|
34
|
-
"@ltht-react/styles": "^2.0.
|
|
35
|
-
"@ltht-react/types": "^2.0.
|
|
36
|
-
"@ltht-react/utils": "^2.0.
|
|
31
|
+
"@ltht-react/card": "^2.0.52",
|
|
32
|
+
"@ltht-react/icon": "^2.0.52",
|
|
33
|
+
"@ltht-react/list": "^2.0.52",
|
|
34
|
+
"@ltht-react/styles": "^2.0.52",
|
|
35
|
+
"@ltht-react/types": "^2.0.52",
|
|
36
|
+
"@ltht-react/utils": "^2.0.52",
|
|
37
37
|
"react": "^18.2.0"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "b2a025b4e62c39f94bdebb97c5d5722b57b68910"
|
|
40
40
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { HTMLAttributes, FC } from 'react'
|
|
2
2
|
import styled from '@emotion/styled'
|
|
3
|
+
import { format, parseISO } from 'date-fns'
|
|
3
4
|
|
|
4
5
|
import { TEXT_COLOURS } from '@ltht-react/styles'
|
|
5
6
|
import { PartialDateTime } from '@ltht-react/types'
|
|
@@ -11,16 +12,16 @@ const StyledDateSummary = styled.div<IStyledDateSummary>`
|
|
|
11
12
|
display: inline-block;
|
|
12
13
|
`
|
|
13
14
|
|
|
14
|
-
const
|
|
15
|
+
const formatAsISODate = (partialDateTime?: PartialDateTime | null): string => {
|
|
15
16
|
if (!partialDateTime?.value) return ''
|
|
16
17
|
|
|
17
|
-
const date =
|
|
18
|
-
return date
|
|
18
|
+
const date = parseISO(partialDateTime.value)
|
|
19
|
+
return format(date, 'dd-MMM-yyyy')
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
const DateSummary: FC<Props> = ({ datetime, enteredInError, dateOnlyView, ...rest }) => (
|
|
22
23
|
<StyledDateSummary enteredInError={enteredInError} dateOnlyView={dateOnlyView} {...rest}>
|
|
23
|
-
{dateOnlyView ?
|
|
24
|
+
{dateOnlyView ? formatAsISODate(datetime) : partialDateTimeText(datetime)}
|
|
24
25
|
</StyledDateSummary>
|
|
25
26
|
)
|
|
26
27
|
|