@deix/rossini-core 1.0.7 → 1.0.9

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.
package/lib/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deix/rossini-core",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "main": "lib/src/index.js",
5
5
  "type": "commonjs",
6
6
  "repository": {
@@ -1 +1 @@
1
- {"version":3,"file":"ImprovementChip.d.ts","sourceRoot":"","sources":["../../../../../src/components/display/StyledValue/ImprovementChip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAQ,SAAS,EAAW,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAuB,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGxE,MAAM,WAAW,oBAAqB,SAAQ,SAAS;IACrD,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,uBAAuB,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IAC5D,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,OAAO,CAAC,EAAE,iBAAiB,GAAG,MAAM,CAAC;CACtC;AAoCD,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAkCnD,CAAC;AAEF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"ImprovementChip.d.ts","sourceRoot":"","sources":["../../../../../src/components/display/StyledValue/ImprovementChip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAQ,SAAS,EAAW,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAuB,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGxE,MAAM,WAAW,oBAAqB,SAAQ,SAAS;IACrD,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,uBAAuB,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IAC5D,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,OAAO,CAAC,EAAE,iBAAiB,GAAG,MAAM,CAAC;CACtC;AA4CD,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAuCnD,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -5,11 +5,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const react_1 = __importDefault(require("react"));
7
7
  const icons_material_1 = require("@mui/icons-material");
8
+ const NewReleasesOutlined_1 = __importDefault(require("@mui/icons-material/NewReleasesOutlined"));
8
9
  const material_1 = require("@mui/material");
9
10
  const types_1 = require("../../../types");
10
11
  const utils_1 = require("../../../utils");
11
12
  const getColor = (delta, tol, isIncreasePositive) => {
12
- if (delta >= tol) {
13
+ if (delta === undefined) {
14
+ return 'success';
15
+ }
16
+ else if (delta >= tol) {
13
17
  switch (isIncreasePositive) {
14
18
  case true:
15
19
  return 'success';
@@ -30,7 +34,10 @@ const getColor = (delta, tol, isIncreasePositive) => {
30
34
  }
31
35
  };
32
36
  const getIcon = (delta, tol, size) => {
33
- if (delta >= tol) {
37
+ if (delta === undefined) {
38
+ return react_1.default.createElement(NewReleasesOutlined_1.default, { fontSize: size });
39
+ }
40
+ else if (delta >= tol) {
34
41
  return react_1.default.createElement(icons_material_1.North, { fontSize: size });
35
42
  }
36
43
  else if (delta <= -tol) {
@@ -47,8 +54,12 @@ const ImprovementChip = ({ currentValue, previousValue, stationaryTolerance = 0.
47
54
  }, isIncreasePositive = true, tooltip, size = 'small', color, }) => {
48
55
  const locale = (0, utils_1.useLocale)();
49
56
  const tooltipString = tooltip && (0, types_1.isStringTranslation)(tooltip) ? tooltip[locale] : tooltip;
50
- const delta = (currentValue - previousValue) / previousValue;
51
- const deltaString = delta.toLocaleString(locale, percentageFormatOptions);
57
+ const delta = previousValue !== 0
58
+ ? (currentValue - previousValue) / previousValue
59
+ : undefined;
60
+ const deltaString = delta
61
+ ? delta.toLocaleString(locale, percentageFormatOptions)
62
+ : 'NEW';
52
63
  return (react_1.default.createElement(material_1.Tooltip, { title: tooltipString || '' },
53
64
  react_1.default.createElement(material_1.Chip, { icon: getIcon(delta, stationaryTolerance, size), label: deltaString, color: color || getColor(delta, stationaryTolerance, isIncreasePositive), size: size })));
54
65
  };
@@ -24,7 +24,7 @@ export interface StyledValueProps {
24
24
  cardProps?: CardProps;
25
25
  loading?: boolean;
26
26
  onCardClick?: (e: React.MouseEvent<HTMLElement>) => void;
27
- improvementChipProps?: Pick<Partial<ImprovementChipProps>, 'isIncreasePositive' | 'stationaryTolerance'>;
27
+ improvementChipProps?: Pick<Partial<ImprovementChipProps>, 'isIncreasePositive' | 'stationaryTolerance' | 'color'>;
28
28
  }
29
29
  declare const StyledValue: React.FC<StyledValueProps>;
30
30
  export default StyledValue;
@@ -1 +1 @@
1
- {"version":3,"file":"StyledValue.d.ts","sourceRoot":"","sources":["../../../../../src/components/display/StyledValue/StyledValue.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,EAIL,SAAS,EAIT,eAAe,EAChB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAuB,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGxE,OAAwB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAG1E,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,kBAAkB,CAAC;CAC7B;AAMD,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,YAAY,CAAC;IAC9C,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,YAAY,CAAC;IACtD,aAAa,CAAC,EAAE,OAAO,CACrB,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,mBAAmB,CACtD,CAAC;IACF,OAAO,EAAE,MAAM,GAAG,iBAAiB,CAAC;IACpC,OAAO,CAAC,EAAE,MAAM,GAAG,iBAAiB,CAAC;IACrC,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,eAAe,CAAC;IACvC,sBAAsB,CAAC,EAAE,eAAe,CAAC;IACzC,sBAAsB,CAAC,EAAE,eAAe,CAAC;IACzC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IACzD,oBAAoB,CAAC,EAAE,IAAI,CACzB,OAAO,CAAC,oBAAoB,CAAC,EAC7B,oBAAoB,GAAG,qBAAqB,CAC7C,CAAC;CACH;AAED,QAAA,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA2I3C,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"StyledValue.d.ts","sourceRoot":"","sources":["../../../../../src/components/display/StyledValue/StyledValue.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,EAIL,SAAS,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AC,EAAE,CAAC,gBAAgB,CA6I3C,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -76,7 +76,9 @@ const StyledValue = (props) => {
76
76
  justifyContent: 'space-between',
77
77
  alignItems: 'center',
78
78
  } },
79
- previousValue && stringPreviousValue && (react_1.default.createElement(ImprovementChip_1.default, { currentValue: value, previousValue: previousValue, tooltip: `${stringPreviousValue} ${translations_json_1.default['tooltipPreviousPeriod'][locale]}`, ...improvementChipProps })),
79
+ previousValue !== undefined &&
80
+ previousValue !== null &&
81
+ stringPreviousValue && (react_1.default.createElement(ImprovementChip_1.default, { currentValue: value, previousValue: previousValue, tooltip: `${stringPreviousValue} ${translations_json_1.default['tooltipPreviousPeriod'][locale]}`, ...improvementChipProps })),
80
82
  react_1.default.createElement(material_1.Typography, { ...valueTypographyProps }, loading || isLoadingValue || value === undefined ? (react_1.default.createElement(material_1.Skeleton, null)) : (stringValue)))),
81
83
  react_1.default.createElement(material_1.Typography, { ...captionTypographyProps }, captionString),
82
84
  details && (react_1.default.createElement(material_1.Typography, { ...detailsTypographyProps }, detailsString)))));
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useValue = void 0;
4
4
  const react_query_1 = require("react-query");
5
5
  const getValue = async (apiClient, value) => {
6
- if (value) {
6
+ if (value !== undefined && value !== null) {
7
7
  if (value instanceof Date) {
8
8
  return value;
9
9
  }