@ltht-react/type-summary 2.0.48 → 2.0.50

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;
@@ -37,9 +37,16 @@ var StyledDateSummary = styled_1.default.div(templateObject_1 || (templateObject
37
37
  var enteredInError = _a.enteredInError;
38
38
  return (enteredInError ? 'line-through' : 'none');
39
39
  });
40
+ var formatAsDateOnly = function (partialDateTime) {
41
+ var _a;
42
+ if (!(partialDateTime === null || partialDateTime === void 0 ? void 0 : partialDateTime.value))
43
+ return '';
44
+ var date = new Date(partialDateTime.value);
45
+ return (_a = date.toISOString().split('T')[0]) !== null && _a !== void 0 ? _a : '';
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 ? formatAsDateOnly(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;AAEp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AAW,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,QAAQ,CAAC,IACxD,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.48",
3
+ "version": "2.0.50",
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.48",
32
- "@ltht-react/icon": "^2.0.48",
33
- "@ltht-react/list": "^2.0.48",
34
- "@ltht-react/styles": "^2.0.48",
35
- "@ltht-react/types": "^2.0.48",
36
- "@ltht-react/utils": "^2.0.48",
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",
37
37
  "react": "^18.2.0"
38
38
  },
39
- "gitHead": "83c867b3c4647ad58c17ed2631d9172a88024d6e"
39
+ "gitHead": "1fec4912afdb2b9a05cc8df7adbb695fb1ba9bd5"
40
40
  }
@@ -11,19 +11,28 @@ const StyledDateSummary = styled.div<IStyledDateSummary>`
11
11
  display: inline-block;
12
12
  `
13
13
 
14
- const DateSummary: FC<Props> = ({ datetime, enteredInError, ...rest }) => (
15
- <StyledDateSummary enteredInError={enteredInError} {...rest}>
16
- {partialDateTimeText(datetime)}
14
+ const formatAsDateOnly = (partialDateTime?: PartialDateTime | null): string => {
15
+ if (!partialDateTime?.value) return ''
16
+
17
+ const date = new Date(partialDateTime.value)
18
+ return date.toISOString().split('T')[0] ?? ''
19
+ }
20
+
21
+ const DateSummary: FC<Props> = ({ datetime, enteredInError, dateOnlyView, ...rest }) => (
22
+ <StyledDateSummary enteredInError={enteredInError} dateOnlyView={dateOnlyView} {...rest}>
23
+ {dateOnlyView ? formatAsDateOnly(datetime) : partialDateTimeText(datetime)}
17
24
  </StyledDateSummary>
18
25
  )
19
26
 
20
27
  interface Props extends HTMLAttributes<HTMLDivElement> {
21
28
  datetime?: PartialDateTime | null
22
29
  enteredInError?: boolean | undefined
30
+ dateOnlyView?: boolean
23
31
  }
24
32
 
25
33
  interface IStyledDateSummary {
26
34
  enteredInError?: boolean | undefined
35
+ dateOnlyView?: boolean
27
36
  }
28
37
 
29
38
  export default DateSummary