@ltht-react/type-summary 2.0.49 → 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.
@@ -4,5 +4,6 @@ declare const DateSummary: FC<Props>;
4
4
  interface Props extends HTMLAttributes<HTMLDivElement> {
5
5
  datetime?: PartialDateTime | null;
6
6
  enteredInError?: boolean | undefined;
7
+ dateOnlyView?: boolean;
7
8
  }
8
9
  export default DateSummary;
@@ -31,15 +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
  });
41
+ var formatAsISODate = function (partialDateTime) {
42
+ if (!(partialDateTime === null || partialDateTime === void 0 ? void 0 : partialDateTime.value))
43
+ return '';
44
+ var date = (0, date_fns_1.parseISO)(partialDateTime.value);
45
+ return (0, date_fns_1.format)(date, 'dd-MMM-yyyy');
46
+ };
40
47
  var DateSummary = function (_a) {
41
- var datetime = _a.datetime, enteredInError = _a.enteredInError, rest = __rest(_a, ["datetime", "enteredInError"]);
42
- return ((0, jsx_runtime_1.jsx)(StyledDateSummary, __assign({ enteredInError: enteredInError }, rest, { children: (0, utils_1.partialDateTimeText)(datetime) })));
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 ? formatAsISODate(datetime) : (0, utils_1.partialDateTimeText)(datetime) })));
43
50
  };
44
51
  exports.default = DateSummary;
45
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,WAAW,GAAc,UAAC,EAAqC;IAAnC,IAAA,QAAQ,cAAA,EAAE,cAAc,oBAAA,EAAK,IAAI,cAAnC,8BAAqC,CAAF;IAAO,OAAA,CACxE,uBAAC,iBAAiB,aAAC,cAAc,EAAE,cAAc,IAAM,IAAI,cACxD,IAAA,2BAAmB,EAAC,QAAQ,CAAC,IACZ,CACrB,CAAA;CAAA,CAAA;AAWD,kBAAe,WAAW,CAAA"}
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.49",
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.49",
32
- "@ltht-react/icon": "^2.0.49",
33
- "@ltht-react/list": "^2.0.49",
34
- "@ltht-react/styles": "^2.0.49",
35
- "@ltht-react/types": "^2.0.49",
36
- "@ltht-react/utils": "^2.0.49",
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": "d5b64733a9e8e6f6e975a0d2e4ce31b5fcfad8be"
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,19 +12,28 @@ const StyledDateSummary = styled.div<IStyledDateSummary>`
11
12
  display: inline-block;
12
13
  `
13
14
 
14
- const DateSummary: FC<Props> = ({ datetime, enteredInError, ...rest }) => (
15
- <StyledDateSummary enteredInError={enteredInError} {...rest}>
16
- {partialDateTimeText(datetime)}
15
+ const formatAsISODate = (partialDateTime?: PartialDateTime | null): string => {
16
+ if (!partialDateTime?.value) return ''
17
+
18
+ const date = parseISO(partialDateTime.value)
19
+ return format(date, 'dd-MMM-yyyy')
20
+ }
21
+
22
+ const DateSummary: FC<Props> = ({ datetime, enteredInError, dateOnlyView, ...rest }) => (
23
+ <StyledDateSummary enteredInError={enteredInError} dateOnlyView={dateOnlyView} {...rest}>
24
+ {dateOnlyView ? formatAsISODate(datetime) : partialDateTimeText(datetime)}
17
25
  </StyledDateSummary>
18
26
  )
19
27
 
20
28
  interface Props extends HTMLAttributes<HTMLDivElement> {
21
29
  datetime?: PartialDateTime | null
22
30
  enteredInError?: boolean | undefined
31
+ dateOnlyView?: boolean
23
32
  }
24
33
 
25
34
  interface IStyledDateSummary {
26
35
  enteredInError?: boolean | undefined
36
+ dateOnlyView?: boolean
27
37
  }
28
38
 
29
39
  export default DateSummary