@pareto-engineering/design-system 5.0.5 → 5.1.1

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.
Files changed (96) hide show
  1. package/dist/cjs/a/Charts/AreaChart/AreaChart.js +3 -13
  2. package/dist/cjs/a/Charts/BarChart/BarChart.js +6 -4
  3. package/dist/cjs/a/Charts/Common/CustomLegend/CustomLegend.js +26 -7
  4. package/dist/cjs/a/Charts/Common/CustomLegend/styles.scss +41 -14
  5. package/dist/cjs/a/Charts/Common/CustomTooltipContent/CustomTooltipContent.js +18 -7
  6. package/dist/cjs/a/Charts/Common/YLabelsDropDown/YlabelsDropDown.js +3 -4
  7. package/dist/cjs/a/Charts/Common/YLabelsDropDown/styles.scss +7 -6
  8. package/dist/cjs/a/Charts/PieChart/PieChart.js +99 -0
  9. package/dist/cjs/a/Charts/PieChart/index.js +13 -0
  10. package/dist/cjs/a/Charts/PieChart/styles.scss +48 -0
  11. package/dist/cjs/a/Charts/index.js +8 -1
  12. package/dist/cjs/a/Notification/styles.scss +17 -5
  13. package/dist/cjs/a/index.js +6 -0
  14. package/dist/cjs/f/FormInput/FormInput.js +1 -1
  15. package/dist/cjs/f/fields/EditorInput/EditorInput.js +7 -3
  16. package/dist/cjs/f/fields/EditorInput/common/ExposePlainTextPlugin.js +40 -0
  17. package/dist/cjs/f/fields/EditorInput/common/ToolbarPlugin/ToolbarPlugin.js +1 -1
  18. package/dist/cjs/f/fields/EditorInput/common/index.js +7 -0
  19. package/dist/cjs/f/fields/LatexPreviewInput/LatexPreviewInput.js +1 -1
  20. package/dist/cjs/f/fields/LatexPreviewInput/styles.scss +1 -0
  21. package/dist/cjs/f/fields/TextareaInput/TextareaInput.js +4 -2
  22. package/dist/cjs/g/ExpandableLexicalPreview/ExpandableLexicalPreview.js +4 -2
  23. package/dist/cjs/g/ExpandableLexicalPreview/styles.scss +0 -1
  24. package/dist/cjs/g/FormBuilder/common/Builder/common/InputBuilder/InputBuilder.js +27 -1
  25. package/dist/cjs/g/FormBuilder/common/Builder/common/InputBuilder/styles.scss +15 -0
  26. package/dist/cjs/g/FormBuilder/common/Builder/common/Section/Section.js +6 -2
  27. package/dist/cjs/g/FormBuilder/common/Renderer/Renderer.js +6 -0
  28. package/dist/cjs/utils/applyCharacterLimit.js +75 -0
  29. package/dist/cjs/utils/formatting.js +10 -2
  30. package/dist/cjs/utils/index.js +14 -1
  31. package/dist/es/a/Charts/AreaChart/AreaChart.js +3 -13
  32. package/dist/es/a/Charts/BarChart/BarChart.js +6 -4
  33. package/dist/es/a/Charts/Common/CustomLegend/CustomLegend.js +38 -21
  34. package/dist/es/a/Charts/Common/CustomLegend/styles.scss +41 -14
  35. package/dist/es/a/Charts/Common/CustomTooltipContent/CustomTooltipContent.js +19 -8
  36. package/dist/es/a/Charts/Common/YLabelsDropDown/YlabelsDropDown.js +3 -5
  37. package/dist/es/a/Charts/Common/YLabelsDropDown/styles.scss +7 -6
  38. package/dist/es/a/Charts/PieChart/PieChart.js +89 -0
  39. package/dist/es/a/Charts/PieChart/index.js +1 -0
  40. package/dist/es/a/Charts/PieChart/styles.scss +48 -0
  41. package/dist/es/a/Charts/index.js +2 -1
  42. package/dist/es/a/Notification/styles.scss +17 -5
  43. package/dist/es/a/index.js +1 -1
  44. package/dist/es/f/FormInput/FormInput.js +1 -1
  45. package/dist/es/f/fields/EditorInput/EditorInput.js +8 -4
  46. package/dist/es/f/fields/EditorInput/common/ExposePlainTextPlugin.js +32 -0
  47. package/dist/es/f/fields/EditorInput/common/ToolbarPlugin/ToolbarPlugin.js +1 -1
  48. package/dist/es/f/fields/EditorInput/common/index.js +2 -1
  49. package/dist/es/f/fields/LatexPreviewInput/LatexPreviewInput.js +1 -1
  50. package/dist/es/f/fields/LatexPreviewInput/styles.scss +1 -0
  51. package/dist/es/f/fields/TextareaInput/TextareaInput.js +4 -2
  52. package/dist/es/g/ExpandableLexicalPreview/ExpandableLexicalPreview.js +4 -2
  53. package/dist/es/g/ExpandableLexicalPreview/styles.scss +0 -1
  54. package/dist/es/g/FormBuilder/common/Builder/common/InputBuilder/InputBuilder.js +27 -1
  55. package/dist/es/g/FormBuilder/common/Builder/common/InputBuilder/styles.scss +15 -0
  56. package/dist/es/g/FormBuilder/common/Builder/common/Section/Section.js +6 -2
  57. package/dist/es/g/FormBuilder/common/Renderer/Renderer.js +6 -0
  58. package/dist/es/utils/applyCharacterLimit.js +67 -0
  59. package/dist/es/utils/formatting.js +7 -0
  60. package/dist/es/utils/index.js +2 -1
  61. package/package.json +3 -3
  62. package/src/stories/a/AreaChart.stories.jsx +1 -1
  63. package/src/stories/a/BarChart.stories.jsx +1 -1
  64. package/src/stories/a/PieChart.stories.jsx +53 -0
  65. package/src/ui/a/Charts/AreaChart/AreaChart.jsx +8 -14
  66. package/src/ui/a/Charts/BarChart/BarChart.jsx +4 -2
  67. package/src/ui/a/Charts/Common/CustomLegend/CustomLegend.jsx +54 -29
  68. package/src/ui/a/Charts/Common/CustomLegend/styles.scss +41 -14
  69. package/src/ui/a/Charts/Common/CustomTooltipContent/CustomTooltipContent.jsx +25 -13
  70. package/src/ui/a/Charts/Common/YLabelsDropDown/YlabelsDropDown.jsx +4 -4
  71. package/src/ui/a/Charts/Common/YLabelsDropDown/styles.scss +7 -6
  72. package/src/ui/a/Charts/PieChart/PieChart.jsx +125 -0
  73. package/src/ui/a/Charts/PieChart/index.js +1 -0
  74. package/src/ui/a/Charts/PieChart/styles.scss +48 -0
  75. package/src/ui/a/Charts/index.js +1 -0
  76. package/src/ui/a/Notification/styles.scss +17 -5
  77. package/src/ui/a/index.js +1 -1
  78. package/src/ui/f/FormInput/FormInput.jsx +1 -0
  79. package/src/ui/f/fields/EditorInput/EditorInput.jsx +24 -9
  80. package/src/ui/f/fields/EditorInput/common/ExposePlainTextPlugin.jsx +42 -0
  81. package/src/ui/f/fields/EditorInput/common/ToolbarPlugin/ToolbarPlugin.jsx +1 -1
  82. package/src/ui/f/fields/EditorInput/common/index.js +1 -0
  83. package/src/ui/f/fields/LatexPreviewInput/LatexPreviewInput.jsx +1 -0
  84. package/src/ui/f/fields/LatexPreviewInput/styles.scss +1 -0
  85. package/src/ui/f/fields/TextareaInput/TextareaInput.jsx +2 -0
  86. package/src/ui/g/ExpandableLexicalPreview/ExpandableLexicalPreview.jsx +3 -3
  87. package/src/ui/g/ExpandableLexicalPreview/styles.scss +0 -1
  88. package/src/ui/g/FormBuilder/common/Builder/common/InputBuilder/InputBuilder.jsx +34 -0
  89. package/src/ui/g/FormBuilder/common/Builder/common/InputBuilder/styles.scss +15 -0
  90. package/src/ui/g/FormBuilder/common/Builder/common/Section/Section.jsx +10 -2
  91. package/src/ui/g/FormBuilder/common/Renderer/Renderer.jsx +5 -0
  92. package/src/ui/g/FormBuilder/common/Renderer/common/Section/Section.jsx +0 -1
  93. package/src/ui/utils/applyCharacterLimit.js +80 -0
  94. package/src/ui/utils/formatting.js +8 -0
  95. package/src/ui/utils/index.js +4 -1
  96. package/tests/__snapshots__/Storyshots.test.js.snap +1167 -447
@@ -0,0 +1,67 @@
1
+ export const applyCharacterLimit = (setMaxLength = true) => {
2
+ setTimeout(() => {
3
+ document.querySelectorAll("[class*='limit-character-count-']").forEach(parent => {
4
+ const match = parent.className.match(/limit-character-count-(\d+)/);
5
+ if (!match) return;
6
+ const maxLength = parseInt(match[1], 10);
7
+ const fields = parent.matches("input[type='text'], input[type='email'], input[type='password'], input[type='search'], textarea") ? [parent] : Array.from(parent.querySelectorAll("input[type='text'], input[type='email'], input[type='password'], input[type='search'], textarea"));
8
+ if (!fields.length) return;
9
+ const characterCounterBaseClassName = 's-2 character-counter';
10
+ const characterCounterClassName = `${characterCounterBaseClassName} x-paragraph c-x`;
11
+ const characterCounterWarningClassName = `${characterCounterBaseClassName} x-orange c-x`;
12
+ const characterCounterErrorClassName = `${characterCounterBaseClassName} x-error c-x`;
13
+ fields.forEach(field => {
14
+ if (field.parentNode.querySelector('.character-counter')) return;
15
+ if (setMaxLength) {
16
+ field.setAttribute('maxlength', maxLength);
17
+ }
18
+ const counter = document.createElement('span');
19
+ counter.className = characterCounterClassName;
20
+ counter.style.position = 'absolute';
21
+ counter.style.right = '10px';
22
+ counter.style.bottom = '-20px';
23
+ counter.style.pointerEvents = 'none';
24
+ let wrapper;
25
+ const {
26
+ parentNode
27
+ } = field;
28
+ const computedStyle = window.getComputedStyle(parentNode);
29
+ if (parentNode.style && parentNode.style.position === 'relative' || computedStyle.getPropertyValue('position') === 'relative') {
30
+ wrapper = parentNode;
31
+ } else {
32
+ wrapper = document.createElement('div');
33
+ wrapper.style.position = 'relative';
34
+ wrapper.style.display = 'inline-block';
35
+ wrapper.style.width = '100%';
36
+ field.parentNode.insertBefore(wrapper, field);
37
+ wrapper.appendChild(field);
38
+ }
39
+ wrapper.appendChild(counter);
40
+ function updateCounter() {
41
+ if (field.value.length > maxLength) {
42
+ // eslint-disable-next-line no-param-reassign
43
+ field.value = field.value.substring(0, maxLength);
44
+ }
45
+ const {
46
+ length
47
+ } = field.value;
48
+ counter.textContent = `${length}/${maxLength}`;
49
+ if (length >= maxLength) {
50
+ counter.className = characterCounterErrorClassName;
51
+ } else if (length >= maxLength * 0.9) {
52
+ counter.className = characterCounterWarningClassName;
53
+ } else {
54
+ counter.className = characterCounterClassName;
55
+ }
56
+ }
57
+ field.removeEventListener('input', updateCounter);
58
+ field.removeEventListener('paste', updateCounter);
59
+ field.addEventListener('input', updateCounter);
60
+ field.addEventListener('paste', () => {
61
+ setTimeout(updateCounter, 0);
62
+ });
63
+ updateCounter();
64
+ });
65
+ });
66
+ }, 100); // Small delay to ensure DOM is ready
67
+ };
@@ -37,6 +37,9 @@ export const formatTime = seconds => {
37
37
  if (hours > 0) parts.push(`${hours}h`);
38
38
  if (minutes > 0 || hours > 0 && remainingSeconds > 0) parts.push(`${minutes}m`);
39
39
  if (remainingSeconds > 0) parts.push(`${remainingSeconds}s`);
40
+
41
+ // Cater for decimal seconds
42
+ if (parts.length === 0) return '0s';
40
43
  return parts.join(' ');
41
44
  };
42
45
  const parseDate = input => {
@@ -99,4 +102,8 @@ export const formatDate = (input, format = DATE_FORMATS.HUMAN_READABLE) => {
99
102
  } catch (error) {
100
103
  return 'Invalid Date';
101
104
  }
105
+ };
106
+ export const snakeCaseToTitleCase = word => {
107
+ const result = word.replace(/([A-Z])/g, ' $1');
108
+ return result.charAt(0).toUpperCase() + result.slice(1);
102
109
  };
@@ -1,2 +1,3 @@
1
1
  export { useWindowSize, useDynamicPosition, useOutsideClick } from "./hooks";
2
- export { formatTime, formatDate, DATE_FORMATS } from "./formatting";
2
+ export { formatTime, formatDate, DATE_FORMATS, snakeCaseToTitleCase } from "./formatting";
3
+ export { applyCharacterLimit } from "./applyCharacterLimit";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pareto-engineering/design-system",
3
- "version": "5.0.5",
3
+ "version": "5.1.1",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/es/index.js",
@@ -59,7 +59,7 @@
59
59
  "@lexical/selection": "0.12.2",
60
60
  "@lexical/table": "0.12.2",
61
61
  "@lexical/utils": "0.12.2",
62
- "@pareto-engineering/assets": "^5.0.0",
62
+ "@pareto-engineering/assets": "^5.1.1",
63
63
  "@pareto-engineering/bem": "^5.0.0",
64
64
  "@pareto-engineering/styles": "^5.0.0",
65
65
  "@pareto-engineering/utils": "^5.0.0",
@@ -87,5 +87,5 @@
87
87
  "remark-math": "^6.0.0"
88
88
  },
89
89
  "browserslist": "> 2%",
90
- "gitHead": "d907245c47d1feee890e349bb9fa1d6d69b775d5"
90
+ "gitHead": "9af8ec028d247f108df8577a080c663edadc205b"
91
91
  }
@@ -4,7 +4,7 @@ import React from 'react'
4
4
  import { AreaChart } from 'ui'
5
5
 
6
6
  export default {
7
- title :'a/AreaChart',
7
+ title :'a/Charts/AreaChart',
8
8
  component:AreaChart,
9
9
  }
10
10
 
@@ -4,7 +4,7 @@ import React from 'react'
4
4
  import { BarChart } from 'ui'
5
5
 
6
6
  export default {
7
- title :'a/BarChart',
7
+ title :'a/Charts/BarChart',
8
8
  component:BarChart,
9
9
  }
10
10
 
@@ -0,0 +1,53 @@
1
+ import React from 'react'
2
+ import { PieChart } from 'ui'
3
+
4
+ export default {
5
+ title :'a/Charts/PieChart',
6
+ component:PieChart,
7
+ }
8
+
9
+ const data = [
10
+ { status: 'pendingReview', value: 230 },
11
+ { status: 'accepted', value: 350 },
12
+ { status: 'rejected', value: 80 },
13
+ { status: 'toRevise', value: 10 },
14
+ { status: 'revised', value: 60 },
15
+ ]
16
+
17
+ const Template = (args) => (
18
+ <div style={{ height: '100%', width: '100%' }}>
19
+ <PieChart {...args} />
20
+ </div>
21
+ )
22
+
23
+ export const Default = Template.bind({})
24
+ Default.args = {
25
+ data,
26
+ valueKey:'value',
27
+ labelKey:'status',
28
+ colors :['#8CB0F8', '#7F7CF6', '#FFD66E', '#E8E9ED', '#F6BC7E'],
29
+ height :400,
30
+ }
31
+
32
+ const TemplateSideBySide = (args) => (
33
+ <div style={{ display: 'flex', gap: '20px' }}>
34
+ <div style={{ flex: 1 }}>
35
+ {/* eslint-disable-next-line react/destructuring-assignment */}
36
+ <PieChart {...args[0]} />
37
+ </div>
38
+ <div style={{ flex: 1 }}>
39
+ {/* eslint-disable-next-line react/destructuring-assignment */}
40
+ <PieChart {...args[1]} />
41
+ </div>
42
+ </div>
43
+ )
44
+
45
+ export const SideBySide = TemplateSideBySide.bind({})
46
+ SideBySide.args = [
47
+ {
48
+ ...Default.args,
49
+ },
50
+ {
51
+ ...Default.args,
52
+ },
53
+ ]
@@ -50,18 +50,6 @@ const AreaChart = ({
50
50
 
51
51
  const [selectedYLabels, setSelectedYLabels] = useState(allYLabels)
52
52
 
53
- const processedData = data.map((item) => {
54
- const yValues = yKeys.map((key) => item[key])
55
- const lowerBound = Math.min(...yValues)
56
- const upperBound = Math.max(...yValues)
57
- const margin = (upperBound - lowerBound) * 0.1
58
- return {
59
- ...item,
60
- bounds:[lowerBound - margin, upperBound + margin],
61
- isTimeFormat,
62
- }
63
- })
64
-
65
53
  const yAxisBounds = () => {
66
54
  const yValues = data.map((item) => yKeys.map((key) => item[key]))
67
55
  const min = Math.min(...yValues.flat())
@@ -95,7 +83,7 @@ const AreaChart = ({
95
83
  capitalizedLegend={capitalizedLegend}
96
84
  />
97
85
  <ResponsiveContainer width={width} height={height}>
98
- <RechartsAreaChart data={processedData}>
86
+ <RechartsAreaChart data={data}>
99
87
  <CartesianGrid strokeDasharray="3 3" />
100
88
  <XAxis
101
89
  dataKey={xKey}
@@ -126,7 +114,13 @@ const AreaChart = ({
126
114
  return value.toFixed(2)
127
115
  }}
128
116
  />
129
- <Tooltip content={<CustomTooltipContent xLabel={xLabel} />} />
117
+ <Tooltip content={(
118
+ <CustomTooltipContent
119
+ dateFormat={dateFormat}
120
+ isTimeFormat={isTimeFormat}
121
+ />
122
+ )}
123
+ />
130
124
  {filled && (
131
125
  <Area
132
126
  id="bounds"
@@ -38,7 +38,8 @@ const BarChart = ({
38
38
  colors,
39
39
  height,
40
40
  width,
41
- // ...otherProps
41
+ isTimeFormat,
42
+ capitalizedLegend,
42
43
  }) => {
43
44
  const allYLabels = yKeys.map((key) => ({
44
45
  label:key,
@@ -69,6 +70,7 @@ const BarChart = ({
69
70
  <CustomLegend
70
71
  colorsArray={selectedYLabels.map((item) => item.color)}
71
72
  yKeysArray={selectedYLabels.map((item) => item.label)}
73
+ capitalizedLegend={capitalizedLegend}
72
74
  />
73
75
  <ResponsiveContainer width={width} height={height}>
74
76
  <RechartsBarChart data={data}>
@@ -87,7 +89,7 @@ const BarChart = ({
87
89
  axisLine={false}
88
90
  tickLine={false}
89
91
  />
90
- <Tooltip content={<CustomTooltipContent xLabel={xLabel} />} />
92
+ <Tooltip content={<CustomTooltipContent isTimeFormat={isTimeFormat} />} />
91
93
  {selectedYLabels.map((key) => (
92
94
  <Bar
93
95
  stackId="a"
@@ -4,6 +4,8 @@ import PropTypes from 'prop-types'
4
4
 
5
5
  import styleNames from '@pareto-engineering/bem/exports'
6
6
 
7
+ import { snakeCaseToTitleCase } from 'ui/utils'
8
+
7
9
  import './styles.scss'
8
10
 
9
11
  const baseClassName = styleNames.base
@@ -15,40 +17,44 @@ const CustomLegend = ({
15
17
  className: userClassName,
16
18
  colorsArray,
17
19
  yKeysArray,
20
+ orientation,
21
+ getLegendItemTitle,
22
+ getLegendItemSubtitle,
18
23
  capitalizedLegend,
19
- }) => {
20
- const capitalizeWord = (word) => {
21
- if (!capitalizedLegend) return word
22
- const wordsToCapitalize = ['average', 'best', 'worst']
23
- return word.split(' ').map((part) => (wordsToCapitalize.includes(part.toLowerCase())
24
- ? part.charAt(0).toUpperCase() + part.slice(1).toLowerCase()
25
- : part),
26
- ).join(' ')
27
- }
28
-
29
- return (
30
- <div
31
- id={id}
32
- className={[
33
- baseClassName,
34
- componentClassName,
35
- userClassName,
36
- ]
37
- .filter((e) => e)
38
- .join(' ')}
39
- >
40
- {yKeysArray.map((key, index) => (
41
- <div key={key} className="item">
24
+ }) => (
25
+ <div
26
+ id={id}
27
+ className={[
28
+ baseClassName,
29
+ componentClassName,
30
+ userClassName,
31
+ orientation,
32
+ ]
33
+ .filter((e) => e)
34
+ .join(' ')}
35
+ >
36
+ {yKeysArray.map((key, index) => (
37
+ <div key={key} className="item">
38
+ <div className="title">
42
39
  <span
43
40
  className="dot"
44
41
  style={{ backgroundColor: colorsArray[index] }}
45
42
  />
46
- <span className="text">{capitalizeWord(key)}</span>
43
+ <span className="text">
44
+ {
45
+ capitalizedLegend
46
+ ? snakeCaseToTitleCase(getLegendItemTitle(key))
47
+ : getLegendItemTitle(key)
48
+ }
49
+ </span>
47
50
  </div>
48
- ))}
49
- </div>
50
- )
51
- }
51
+ <span className="sub-title">
52
+ {getLegendItemSubtitle(key)}
53
+ </span>
54
+ </div>
55
+ ))}
56
+ </div>
57
+ )
52
58
 
53
59
  CustomLegend.propTypes = {
54
60
  /**
@@ -71,6 +77,21 @@ CustomLegend.propTypes = {
71
77
  */
72
78
  yKeysArray:PropTypes.arrayOf(PropTypes.string).isRequired,
73
79
 
80
+ /**
81
+ * The orientation of the Legend
82
+ */
83
+ orientation:PropTypes.oneOf(['vertical', 'horizontal']),
84
+
85
+ /**
86
+ * The function to get the legendItemKey
87
+ */
88
+ getLegendItemTitle:PropTypes.func,
89
+
90
+ /**
91
+ * The function to get legend children
92
+ */
93
+ getLegendItemSubtitle:PropTypes.func,
94
+
74
95
  /**
75
96
  * Flag on whether to capitalize legend keys
76
97
  */
@@ -78,7 +99,11 @@ CustomLegend.propTypes = {
78
99
  }
79
100
 
80
101
  CustomLegend.defaultProps = {
81
- capitalizedLegend:false,
102
+ orientation :'horizontal',
103
+ getLegendItemTitle :(key) => key,
104
+ /* eslint-disable no-unused-vars */
105
+ getLegendItemSubtitle:() => {},
106
+ capitalizedLegend :false,
82
107
  }
83
108
 
84
109
  export default CustomLegend
@@ -1,6 +1,7 @@
1
1
  @use "@pareto-engineering/bem";
2
2
 
3
3
  $default-padding: 1rem;
4
+ $default-margin: 1rem;
4
5
  $default-text-font-size: calc(var(--s-1) * 1rem);
5
6
  $default-border-radius: .25rem;
6
7
  $default-legend-gap: .625rem;
@@ -8,33 +9,59 @@ $default-legend-padding: calc($default-padding * .125) calc($default-padding * .
8
9
  $default-legend-dot-width: .5rem;
9
10
  $default-legend-dot-height: .5rem;
10
11
  $default-legend-dot-margin-right: .3125rem;
12
+ $default-box-shadow: 0 4px 16px 0 var(--soft-shadow);
11
13
 
12
14
  .#{bem.$base} {
13
15
  &.custom-legend {
14
- display: flex;
15
16
  gap: $default-legend-gap;
16
17
  justify-content: flex-end;
17
18
  padding-bottom: $default-padding;
18
19
  padding-right: calc($default-padding * .25);
19
20
 
21
+ &.vertical {
22
+ display: block;
23
+ margin-right: calc($default-margin * 2);
24
+ min-width: fit-content;
25
+
26
+ .item {
27
+ box-shadow: $default-box-shadow;
28
+ padding-top: $default-padding;
29
+ }
30
+ }
31
+
32
+ &.horizontal {
33
+ display: flex;
34
+ }
35
+
20
36
  .item {
21
- align-items: center;
22
37
  border-radius: $default-border-radius;
23
- display: flex;
24
38
  padding: $default-legend-padding;
25
- }
26
39
 
27
- .dot {
28
- border-radius: 50%;
29
- display: inline-block;
30
- height: $default-legend-dot-height;
31
- margin-right: $default-legend-dot-margin-right;
32
- width: $default-legend-dot-width;
33
- }
40
+ .title {
41
+ align-items: center;
42
+ display: flex;
43
+
44
+ .dot {
45
+ border-radius: 50%;
46
+ display: inline-block;
47
+ height: $default-legend-dot-height;
48
+ margin-right: $default-legend-dot-margin-right;
49
+ width: $default-legend-dot-width;
50
+ }
51
+
52
+ .text {
53
+ color: var(--paragraph);
54
+ font-size: calc($default-text-font-size * .75);
55
+ }
56
+ }
34
57
 
35
- .text {
36
- color: var(--paragraph);
37
- font-size: calc($default-text-font-size * .75);
58
+ .sub-title {
59
+ color: var(--heading);
60
+ display: flex;
61
+ font-size: calc($default-text-font-size * 1.2);
62
+ font-weight: 500;
63
+ justify-content: flex-end;
64
+ }
38
65
  }
39
66
  }
40
67
  }
@@ -4,7 +4,9 @@ import PropTypes from 'prop-types'
4
4
 
5
5
  import styleNames from '@pareto-engineering/bem/exports'
6
6
 
7
- import { formatTime, formatDate, DATE_FORMATS } from 'ui/utils'
7
+ import {
8
+ formatTime, formatDate, DATE_FORMATS, snakeCaseToTitleCase,
9
+ } from 'ui/utils'
8
10
 
9
11
  import './styles.scss'
10
12
 
@@ -15,13 +17,26 @@ const componentClassName = 'custom-tooltip-content'
15
17
  const CustomTooltipContent = ({
16
18
  id,
17
19
  className: userClassName,
18
- xLabel,
19
20
  dateFormat,
20
21
  isTimeFormat,
22
+ isDateValue,
21
23
  active,
22
24
  payload,
23
25
  label,
24
26
  }) => {
27
+ const formatLabelValue = (value) => {
28
+ if (isTimeFormat) {
29
+ return formatTime(value)
30
+ }
31
+
32
+ if (typeof value === 'number') {
33
+ if (Number.isInteger(value)) return value
34
+ return value.toFixed(2)
35
+ }
36
+
37
+ return value
38
+ }
39
+
25
40
  if (active && payload && payload.length) {
26
41
  const newPayload = payload.filter((item) => item.name !== 'bounds')
27
42
  return (
@@ -36,15 +51,11 @@ const CustomTooltipContent = ({
36
51
  .join(' ')}
37
52
  >
38
53
  <p className="label">
39
- {`${xLabel}: ${formatDate(label, dateFormat)}`}
54
+ {isDateValue ? formatDate(label, dateFormat) : label}
40
55
  </p>
41
56
  {newPayload.map((entry) => (
42
57
  <p className="label" key={`${entry.name}`} style={{ color: entry.color, textTransform: 'capitalize' }}>
43
- {`${entry.name}: ${
44
- isTimeFormat
45
- ? formatTime(entry.value)
46
- : entry.value
47
- }`}
58
+ {`${snakeCaseToTitleCase(entry.name)}: ${formatLabelValue(entry.value)}`}
48
59
  </p>
49
60
  ))}
50
61
  </div>
@@ -64,11 +75,6 @@ CustomTooltipContent.propTypes = {
64
75
  */
65
76
  className:PropTypes.string,
66
77
 
67
- /**
68
- * The label for the x-axis.
69
- */
70
- xLabel:PropTypes.string,
71
-
72
78
  /**
73
79
  * Flag on whether it is a timeformat or not
74
80
  */
@@ -79,6 +85,11 @@ CustomTooltipContent.propTypes = {
79
85
  */
80
86
  dateFormat:PropTypes.oneOf(Object.values(DATE_FORMATS)),
81
87
 
88
+ /**
89
+ * Flag on whether the label is a date value or not
90
+ */
91
+ isDateValue:PropTypes.bool,
92
+
82
93
  /**
83
94
  * If set true, the tooltip is displayed.
84
95
  * If set false, the tooltip is hidden, usually calculated internally.
@@ -99,6 +110,7 @@ CustomTooltipContent.propTypes = {
99
110
 
100
111
  CustomTooltipContent.defaultProps = {
101
112
  isTimeFormat:false,
113
+ isDateValue :true,
102
114
  dateFormat :DATE_FORMATS.HUMAN_READABLE,
103
115
  }
104
116
 
@@ -5,9 +5,9 @@ import PropTypes from 'prop-types'
5
5
 
6
6
  import styleNames from '@pareto-engineering/bem/exports'
7
7
 
8
- import './styles.scss'
8
+ import { snakeCaseToTitleCase } from 'ui/utils'
9
9
 
10
- // Local Definitions
10
+ import './styles.scss'
11
11
 
12
12
  const baseClassName = styleNames.base
13
13
 
@@ -65,7 +65,7 @@ const YLabelsDropDown = ({
65
65
  className="status-dot"
66
66
  style={{ backgroundColor: item.color }}
67
67
  />
68
- {item.label}
68
+ {snakeCaseToTitleCase(item.label)}
69
69
  {selectedYLabels.some((label) => label.label === item.label) && (
70
70
  <span className="icon checkmark">I</span>
71
71
  )}
@@ -115,7 +115,7 @@ YLabelsDropDown.propTypes = {
115
115
  }
116
116
 
117
117
  YLabelsDropDown.defaultProps = {
118
- placeholder:'Submission status',
118
+ placeholder:'Select Item',
119
119
  }
120
120
 
121
121
  export default YLabelsDropDown
@@ -1,7 +1,8 @@
1
1
  @use "@pareto-engineering/bem";
2
2
 
3
3
  $default-margin: 1rem;
4
- $default-border-radius: .25rem;
4
+ $default-border: var(--theme-default-input-border);
5
+ $default-border-radius: var(--theme-default-input-border-radius);
5
6
  $default-padding: 1rem;
6
7
  $default-width: 15rem;
7
8
  $default-box-shadow: 0 .25rem .75rem var(--ui-lines);
@@ -16,9 +17,9 @@ $default-checkmark-font-size: calc(var(--s-1) * .75rem);
16
17
 
17
18
  .dropdown-button {
18
19
  align-items: center;
19
- background-color: var(--soft-background-inputs);
20
- border: none;
21
- border-radius: $default-border-radius;
20
+ background-color: var(--background-far);
21
+ border: $default-border;
22
+ border-radius: calc($default-border-radius / 2);
22
23
  color: var(--hard-paragraph);
23
24
  cursor: pointer;
24
25
  display: flex;
@@ -53,8 +54,8 @@ $default-checkmark-font-size: calc(var(--s-1) * .75rem);
53
54
 
54
55
  .dropdown-item {
55
56
  align-items: center;
56
- border-radius: $default-border-radius;
57
- color: var(--hard-paragraph);
57
+ border-radius: calc($default-border-radius / 2);
58
+ color: var(--paragraph);
58
59
  cursor: pointer;
59
60
  display: flex;
60
61
  margin: calc($default-margin * .125);