@openmrs/esm-styleguide 9.0.3-pre.4342 → 9.0.3-pre.4371

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.
@@ -1,3 +1,3 @@
1
- [0] Successfully compiled: 123 files, copied 163 files with swc (224.21ms)
1
+ [0] Successfully compiled: 123 files, copied 163 files with swc (274.21ms)
2
2
  [0] swc --strip-leading-paths --copy-files src -d dist && svgo -rf dist --quiet exited with code 0
3
3
  [1] tsc --project tsconfig.build.json exited with code 0
@@ -333,6 +333,10 @@
333
333
  }
334
334
 
335
335
  /* Pagination */
336
+ .cds--pagination {
337
+ container: unset;
338
+ }
339
+
336
340
  .cds--pagination-nav__page:not(.cds--pagination-nav__page--direction) {
337
341
  &::after {
338
342
  @include brand-03(background-color);
@@ -1 +1 @@
1
- {"version":3,"file":"numeric-observation.component.d.ts","sourceRoot":"","sources":["../../src/numeric-observation/numeric-observation.component.tsx"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,OAAO,KAAyB,MAAM,OAAO,CAAC;AAG9C,OAAO,EAGL,KAAK,yBAAyB,EAC9B,KAAK,0BAA0B,EAC/B,KAAK,kBAAkB,EACxB,MAAM,wBAAwB,CAAC;AAIhC,MAAM,WAAW,uBAAuB;IACtC,uCAAuC;IACvC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,0BAA0B;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6DAA6D;IAC7D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4GAA4G;IAC5G,cAAc,CAAC,EAAE,yBAAyB,GAAG,0BAA0B,CAAC;IACxE,qDAAqD;IACrD,cAAc,CAAC,EAAE,kBAAkB,CAAC;IACpC,iDAAiD;IACjD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CA4GhE,CAAC"}
1
+ {"version":3,"file":"numeric-observation.component.d.ts","sourceRoot":"","sources":["../../src/numeric-observation/numeric-observation.component.tsx"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,OAAO,KAAyB,MAAM,OAAO,CAAC;AAG9C,OAAO,EAGL,KAAK,yBAAyB,EAC9B,KAAK,0BAA0B,EAC/B,KAAK,kBAAkB,EACxB,MAAM,wBAAwB,CAAC;AAIhC,MAAM,WAAW,uBAAuB;IACtC,uCAAuC;IACvC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,0BAA0B;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6DAA6D;IAC7D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4GAA4G;IAC5G,cAAc,CAAC,EAAE,yBAAyB,GAAG,0BAA0B,CAAC;IACxE,qDAAqD;IACrD,cAAc,CAAC,EAAE,kBAAkB,CAAC;IACpC,iDAAiD;IACjD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CA8GhE,CAAC"}
@@ -32,7 +32,8 @@ import styles from "./numeric-observation.module.scss";
32
32
  const labelId = label ? `omrs-numeric-obs-label-${label.replaceAll(/\s+/g, '-').toLowerCase()}-${generatedId}` : undefined;
33
33
  const valueId = `omrs-numeric-obs-value-${generatedId}`;
34
34
  const unitId = `omrs-numeric-obs-unit-${generatedId}`;
35
- const displayValue = value || getCoreTranslation('notAvailable', 'Not available');
35
+ const hasValue = value != null && value !== '';
36
+ const displayValue = hasValue ? value : getCoreTranslation('notAvailable', 'Not available');
36
37
  const interpretationClasses = classNames({
37
38
  [styles['critically-low']]: interpretation === 'critically_low' || interpretation === 'off_scale_low',
38
39
  [styles['critically-high']]: interpretation === 'critically_high' || interpretation === 'off_scale_high',
@@ -56,8 +57,7 @@ import styles from "./numeric-observation.module.scss";
56
57
  className: cellClasses,
57
58
  children: [
58
59
  displayValue,
59
- " ",
60
- unit ? ` ${unit}` : ''
60
+ hasValue && unit ? ` ${unit}` : ''
61
61
  ]
62
62
  });
63
63
  }
@@ -88,7 +88,7 @@ import styles from "./numeric-observation.module.scss";
88
88
  className: styles.value,
89
89
  children: displayValue
90
90
  }),
91
- value && unit && /*#__PURE__*/ _jsx("span", {
91
+ hasValue && unit && /*#__PURE__*/ _jsx("span", {
92
92
  id: unitId,
93
93
  className: styles.units,
94
94
  children: unit
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-styleguide",
3
- "version": "9.0.3-pre.4342",
3
+ "version": "9.0.3-pre.4371",
4
4
  "license": "MPL-2.0",
5
5
  "description": "The styleguide for OpenMRS SPA",
6
6
  "module": "dist/internal.js",
@@ -96,17 +96,17 @@
96
96
  "swr": "2.x"
97
97
  },
98
98
  "devDependencies": {
99
- "@openmrs/esm-api": "9.0.3-pre.4342",
100
- "@openmrs/esm-config": "9.0.3-pre.4342",
101
- "@openmrs/esm-emr-api": "9.0.3-pre.4342",
102
- "@openmrs/esm-error-handling": "9.0.3-pre.4342",
103
- "@openmrs/esm-extensions": "9.0.3-pre.4342",
104
- "@openmrs/esm-globals": "9.0.3-pre.4342",
105
- "@openmrs/esm-navigation": "9.0.3-pre.4342",
106
- "@openmrs/esm-react-utils": "9.0.3-pre.4342",
107
- "@openmrs/esm-state": "9.0.3-pre.4342",
108
- "@openmrs/esm-translations": "9.0.3-pre.4342",
109
- "@openmrs/esm-utils": "9.0.3-pre.4342",
99
+ "@openmrs/esm-api": "9.0.3-pre.4371",
100
+ "@openmrs/esm-config": "9.0.3-pre.4371",
101
+ "@openmrs/esm-emr-api": "9.0.3-pre.4371",
102
+ "@openmrs/esm-error-handling": "9.0.3-pre.4371",
103
+ "@openmrs/esm-extensions": "9.0.3-pre.4371",
104
+ "@openmrs/esm-globals": "9.0.3-pre.4371",
105
+ "@openmrs/esm-navigation": "9.0.3-pre.4371",
106
+ "@openmrs/esm-react-utils": "9.0.3-pre.4371",
107
+ "@openmrs/esm-state": "9.0.3-pre.4371",
108
+ "@openmrs/esm-translations": "9.0.3-pre.4371",
109
+ "@openmrs/esm-utils": "9.0.3-pre.4371",
110
110
  "@swc/cli": "0.8.0",
111
111
  "@swc/core": "1.15.18",
112
112
  "@types/geopattern": "^1.2.9",
@@ -333,6 +333,10 @@
333
333
  }
334
334
 
335
335
  /* Pagination */
336
+ .cds--pagination {
337
+ container: unset;
338
+ }
339
+
336
340
  .cds--pagination-nav__page:not(.cds--pagination-nav__page--direction) {
337
341
  &::after {
338
342
  @include brand-03(background-color);
@@ -84,7 +84,8 @@ export const NumericObservation: React.FC<NumericObservationProps> = ({
84
84
  const valueId = `omrs-numeric-obs-value-${generatedId}`;
85
85
  const unitId = `omrs-numeric-obs-unit-${generatedId}`;
86
86
 
87
- const displayValue = value || getCoreTranslation('notAvailable', 'Not available');
87
+ const hasValue = value != null && value !== '';
88
+ const displayValue = hasValue ? value : getCoreTranslation('notAvailable', 'Not available');
88
89
 
89
90
  const interpretationClasses = classNames({
90
91
  [styles['critically-low']]: interpretation === 'critically_low' || interpretation === 'off_scale_low',
@@ -110,7 +111,8 @@ export const NumericObservation: React.FC<NumericObservationProps> = ({
110
111
  if (variant === 'cell') {
111
112
  return (
112
113
  <div className={cellClasses}>
113
- {displayValue} {unit ? ` ${unit}` : ''}
114
+ {displayValue}
115
+ {hasValue && unit ? ` ${unit}` : ''}
114
116
  </div>
115
117
  );
116
118
  }
@@ -138,7 +140,7 @@ export const NumericObservation: React.FC<NumericObservationProps> = ({
138
140
  >
139
141
  {displayValue}
140
142
  </span>
141
- {value && unit && (
143
+ {hasValue && unit && (
142
144
  <span id={unitId} className={styles.units}>
143
145
  {unit}
144
146
  </span>
@@ -40,11 +40,26 @@ describe('NumericObservation', () => {
40
40
  expect(screen.getByText('BP')).toBeInTheDocument();
41
41
  });
42
42
 
43
- it('handles empty/null values gracefully', () => {
43
+ it('renders 0 as a value instead of "Not available"', () => {
44
+ renderNumericObservation(0, '°C', 'Temperature', '123');
45
+
46
+ expect(screen.getByText('0')).toBeInTheDocument();
47
+ expect(screen.getByText('°C')).toBeInTheDocument();
48
+ expect(screen.queryByText('Not available')).not.toBeInTheDocument();
49
+ });
50
+
51
+ it('renders "Not available" when value is null', () => {
44
52
  renderNumericObservation(null as any, '°C', 'Temperature', '123');
45
53
 
46
54
  expect(screen.getByText('Not available')).toBeInTheDocument();
47
55
  });
56
+
57
+ it('renders "Not available" when value is an empty string', () => {
58
+ renderNumericObservation('' as any, '°C', 'Temperature', '123');
59
+
60
+ expect(screen.getByText('Not available')).toBeInTheDocument();
61
+ expect(screen.queryByText('°C')).not.toBeInTheDocument();
62
+ });
48
63
  });
49
64
 
50
65
  describe('Variant Tests', () => {
@@ -61,6 +76,13 @@ describe('NumericObservation', () => {
61
76
  expect(screen.queryByTestId('numeric-observation-card')).not.toBeInTheDocument();
62
77
  expect(element.tagName).toBe('DIV');
63
78
  });
79
+
80
+ it('renders "Not available" without unit in cell variant when value is empty', () => {
81
+ renderNumericObservation('' as any, 'mmHg', 'BP', '123', 'cell');
82
+
83
+ expect(screen.getByText('Not available')).toBeInTheDocument();
84
+ expect(screen.queryByText(/mmHg/)).not.toBeInTheDocument();
85
+ });
64
86
  });
65
87
 
66
88
  describe('Interpretation Display', () => {