@ltht-react/type-summary 2.0.50 → 2.0.51

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 formatAsDateOnly = function (partialDateTime) {
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 = new Date(partialDateTime.value);
45
- return (_a = date.toISOString().split('T')[0]) !== null && _a !== void 0 ? _a : '';
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 ? formatAsDateOnly(datetime) : (0, utils_1.partialDateTimeText)(datetime) })));
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;AAEpC,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,gBAAgB,GAAG,UAAC,eAAwC;;IAChE,IAAI,CAAC,CAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,KAAK,CAAA;QAAE,OAAO,EAAE,CAAA;IAEtC,IAAM,IAAI,GAAG,IAAI,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAA;IAC5C,OAAO,MAAA,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,mCAAI,EAAE,CAAA;AAC/C,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,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAA,2BAAmB,EAAC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
2
  "name": "@ltht-react/type-summary",
3
- "version": "2.0.50",
3
+ "version": "2.0.51",
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.50",
32
- "@ltht-react/icon": "^2.0.50",
33
- "@ltht-react/list": "^2.0.50",
34
- "@ltht-react/styles": "^2.0.50",
35
- "@ltht-react/types": "^2.0.50",
36
- "@ltht-react/utils": "^2.0.50",
31
+ "@ltht-react/card": "^2.0.51",
32
+ "@ltht-react/icon": "^2.0.51",
33
+ "@ltht-react/list": "^2.0.51",
34
+ "@ltht-react/styles": "^2.0.51",
35
+ "@ltht-react/types": "^2.0.51",
36
+ "@ltht-react/utils": "^2.0.51",
37
37
  "react": "^18.2.0"
38
38
  },
39
- "gitHead": "1fec4912afdb2b9a05cc8df7adbb695fb1ba9bd5"
39
+ "gitHead": "21c74a5177982ec4ff17033b2284747dcf773755"
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 formatAsDateOnly = (partialDateTime?: PartialDateTime | null): string => {
15
+ const formatAsISODate = (partialDateTime?: PartialDateTime | null): string => {
15
16
  if (!partialDateTime?.value) return ''
16
17
 
17
- const date = new Date(partialDateTime.value)
18
- return date.toISOString().split('T')[0] ?? ''
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 ? formatAsDateOnly(datetime) : partialDateTimeText(datetime)}
24
+ {dateOnlyView ? formatAsISODate(datetime) : partialDateTimeText(datetime)}
24
25
  </StyledDateSummary>
25
26
  )
26
27