@pareto-engineering/design-system 5.2.1 → 5.3.0

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 (62) hide show
  1. package/dist/cjs/a/Charts/AreaChart/AreaChart.js +60 -5
  2. package/dist/cjs/a/Charts/AreaChart/styles.scss +22 -0
  3. package/dist/cjs/a/Charts/Common/CustomLegend/CustomLegend.js +19 -5
  4. package/dist/cjs/a/Charts/Common/CustomTooltipContent/CustomTooltipContent.js +133 -68
  5. package/dist/cjs/a/Charts/PieChart/PieChart.js +20 -7
  6. package/dist/cjs/a/ThroughPutIndicator/ThroughPutIndicator.js +78 -0
  7. package/dist/cjs/a/ThroughPutIndicator/index.js +13 -0
  8. package/dist/cjs/a/ThroughPutIndicator/styles.scss +35 -0
  9. package/dist/cjs/a/ToggleSwitch/ToggleSwitch.js +2 -1
  10. package/dist/cjs/a/ToggleSwitch/styles.scss +9 -2
  11. package/dist/cjs/a/Tooltip/Tooltip.js +19 -2
  12. package/dist/cjs/a/Tooltip/styles.scss +32 -4
  13. package/dist/cjs/a/index.js +8 -1
  14. package/dist/cjs/f/FormInput/FormInput.js +7 -1
  15. package/dist/cjs/f/fields/ToggleInput/ToggleInput.js +126 -0
  16. package/dist/cjs/f/fields/ToggleInput/index.js +13 -0
  17. package/dist/cjs/f/fields/ToggleInput/styles.scss +22 -0
  18. package/dist/cjs/f/fields/index.js +8 -1
  19. package/dist/cjs/utils/formatting.js +27 -18
  20. package/dist/cjs/utils/index.js +6 -0
  21. package/dist/es/a/Charts/AreaChart/AreaChart.js +61 -6
  22. package/dist/es/a/Charts/AreaChart/styles.scss +22 -0
  23. package/dist/es/a/Charts/Common/CustomLegend/CustomLegend.js +19 -5
  24. package/dist/es/a/Charts/Common/CustomTooltipContent/CustomTooltipContent.js +122 -66
  25. package/dist/es/a/Charts/PieChart/PieChart.js +20 -7
  26. package/dist/es/a/ThroughPutIndicator/ThroughPutIndicator.js +66 -0
  27. package/dist/es/a/ThroughPutIndicator/index.js +2 -0
  28. package/dist/es/a/ThroughPutIndicator/styles.scss +35 -0
  29. package/dist/es/a/ToggleSwitch/ToggleSwitch.js +2 -1
  30. package/dist/es/a/ToggleSwitch/styles.scss +9 -2
  31. package/dist/es/a/Tooltip/Tooltip.js +31 -12
  32. package/dist/es/a/Tooltip/styles.scss +32 -4
  33. package/dist/es/a/index.js +2 -1
  34. package/dist/es/f/FormInput/FormInput.js +8 -2
  35. package/dist/es/f/fields/ToggleInput/ToggleInput.js +116 -0
  36. package/dist/es/f/fields/ToggleInput/index.js +2 -0
  37. package/dist/es/f/fields/ToggleInput/styles.scss +22 -0
  38. package/dist/es/f/fields/index.js +2 -1
  39. package/dist/es/utils/formatting.js +25 -17
  40. package/dist/es/utils/index.js +1 -1
  41. package/package.json +5 -5
  42. package/src/ui/a/Charts/AreaChart/AreaChart.jsx +73 -9
  43. package/src/ui/a/Charts/AreaChart/styles.scss +22 -0
  44. package/src/ui/a/Charts/Common/CustomLegend/CustomLegend.jsx +20 -5
  45. package/src/ui/a/Charts/Common/CustomTooltipContent/CustomTooltipContent.jsx +126 -79
  46. package/src/ui/a/Charts/PieChart/PieChart.jsx +38 -17
  47. package/src/ui/a/ThroughPutIndicator/ThroughPutIndicator.jsx +90 -0
  48. package/src/ui/a/ThroughPutIndicator/index.js +2 -0
  49. package/src/ui/a/ThroughPutIndicator/styles.scss +35 -0
  50. package/src/ui/a/ToggleSwitch/ToggleSwitch.jsx +1 -1
  51. package/src/ui/a/ToggleSwitch/styles.scss +9 -2
  52. package/src/ui/a/Tooltip/Tooltip.jsx +55 -26
  53. package/src/ui/a/Tooltip/styles.scss +32 -4
  54. package/src/ui/a/index.js +1 -0
  55. package/src/ui/f/FormInput/FormInput.jsx +11 -0
  56. package/src/ui/f/fields/ToggleInput/ToggleInput.jsx +140 -0
  57. package/src/ui/f/fields/ToggleInput/index.js +2 -0
  58. package/src/ui/f/fields/ToggleInput/styles.scss +22 -0
  59. package/src/ui/f/fields/index.js +1 -0
  60. package/src/ui/utils/formatting.js +38 -29
  61. package/src/ui/utils/index.js +1 -1
  62. package/tests/__snapshots__/Storyshots.test.js.snap +7 -1
@@ -5,6 +5,72 @@ import { formatTime, formatDate, DATE_FORMATS, snakeCaseToTitleCase } from "../.
5
5
  import "./styles.scss";
6
6
  const baseClassName = styleNames.base;
7
7
  const componentClassName = 'custom-tooltip-content';
8
+ const formatValue = (value, isTimeFormat) => {
9
+ if (isTimeFormat) {
10
+ return formatTime(value);
11
+ }
12
+ if (typeof value === 'number') {
13
+ return Number.isInteger(value) ? value : value.toFixed(2);
14
+ }
15
+ return value;
16
+ };
17
+ const PayoutPieChartLabel = ({
18
+ entry,
19
+ formatLabelValue
20
+ }) => /*#__PURE__*/React.createElement("div", {
21
+ className: "pie-chart-label"
22
+ }, /*#__PURE__*/React.createElement("div", {
23
+ className: "status"
24
+ }, /*#__PURE__*/React.createElement("span", {
25
+ className: "dot",
26
+ style: {
27
+ backgroundColor: entry?.payload?.color
28
+ }
29
+ }), /*#__PURE__*/React.createElement("p", {
30
+ className: "label",
31
+ key: `${entry.name}`,
32
+ style: {
33
+ color: entry.color,
34
+ textTransform: 'capitalize'
35
+ }
36
+ }, `${snakeCaseToTitleCase(entry.name)} `)), /*#__PURE__*/React.createElement("p", {
37
+ className: "value"
38
+ }, `${formatLabelValue(entry.value)}`));
39
+ const StandardPieChartLabel = ({
40
+ entry,
41
+ formatLabelValue
42
+ }) => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("p", null, "Submissions"), /*#__PURE__*/React.createElement("div", {
43
+ className: "pie-chart-label"
44
+ }, /*#__PURE__*/React.createElement("div", {
45
+ className: "status"
46
+ }, /*#__PURE__*/React.createElement("span", {
47
+ className: "dot",
48
+ style: {
49
+ backgroundColor: entry?.payload?.color
50
+ }
51
+ }), /*#__PURE__*/React.createElement("p", {
52
+ className: "label",
53
+ key: `${entry.name}`,
54
+ style: {
55
+ color: entry.color,
56
+ textTransform: 'capitalize'
57
+ }
58
+ }, `${snakeCaseToTitleCase(entry.name)} `)), /*#__PURE__*/React.createElement("p", {
59
+ className: "value"
60
+ }, `${formatLabelValue(entry.value)}`), /*#__PURE__*/React.createElement("p", {
61
+ className: "percentage-title"
62
+ }, `${entry?.payload?.percentage}%`)));
63
+ const StandardChartLabel = ({
64
+ entry,
65
+ formatLabelValue
66
+ }) => /*#__PURE__*/React.createElement("p", {
67
+ className: "label",
68
+ key: `${entry.name}`,
69
+ style: {
70
+ color: entry.color,
71
+ textTransform: 'capitalize'
72
+ }
73
+ }, `${snakeCaseToTitleCase(entry.name)}: ${formatLabelValue(entry.value)}`);
8
74
  const CustomTooltipContent = ({
9
75
  id,
10
76
  className: userClassName,
@@ -14,106 +80,96 @@ const CustomTooltipContent = ({
14
80
  active,
15
81
  payload,
16
82
  label,
17
- isPieChart
83
+ isPieChart,
84
+ isPayOutChart
18
85
  }) => {
19
- const formatLabelValue = value => {
20
- if (isTimeFormat) {
21
- return formatTime(value);
22
- }
23
- if (typeof value === 'number') {
24
- if (Number.isInteger(value)) return value;
25
- return value.toFixed(2);
86
+ const formatLabelValue = React.useCallback(value => formatValue(value, isTimeFormat), [isTimeFormat]);
87
+ const renderContent = React.useCallback(entry => {
88
+ if (isPieChart && isPayOutChart) {
89
+ return /*#__PURE__*/React.createElement(PayoutPieChartLabel, {
90
+ entry: entry,
91
+ formatLabelValue: formatLabelValue
92
+ });
26
93
  }
27
- return value;
28
- };
29
- const renderContent = entry => {
30
94
  if (isPieChart) {
31
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("p", null, "Submissions"), /*#__PURE__*/React.createElement("div", {
32
- className: "pie-chart-label"
33
- }, /*#__PURE__*/React.createElement("div", {
34
- className: "status"
35
- }, /*#__PURE__*/React.createElement("span", {
36
- className: "dot",
37
- style: {
38
- backgroundColor: entry?.payload?.color
39
- }
40
- }), /*#__PURE__*/React.createElement("p", {
41
- className: "label",
42
- key: `${entry.name}`,
43
- style: {
44
- color: entry.color,
45
- textTransform: 'capitalize'
46
- }
47
- }, `${snakeCaseToTitleCase(entry.name)} `)), /*#__PURE__*/React.createElement("p", {
48
- className: "value"
49
- }, `${formatLabelValue(entry.value)}`), /*#__PURE__*/React.createElement("p", {
50
- className: "percentage-title"
51
- }, `${entry?.payload?.percentage}%`)));
95
+ return /*#__PURE__*/React.createElement(StandardPieChartLabel, {
96
+ entry: entry,
97
+ formatLabelValue: formatLabelValue
98
+ });
52
99
  }
53
- return /*#__PURE__*/React.createElement("p", {
54
- className: "label",
55
- key: `${entry.name}`,
56
- style: {
57
- color: entry.color,
58
- textTransform: 'capitalize'
59
- }
60
- }, `${snakeCaseToTitleCase(entry.name)}: ${formatLabelValue(entry.value)}`);
61
- };
62
- if (active && payload && payload?.length) {
63
- const newPayload = payload.filter(item => item?.name !== 'bounds');
64
- return /*#__PURE__*/React.createElement("div", {
65
- id: id,
66
- className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' ')
67
- }, /*#__PURE__*/React.createElement("p", {
68
- className: "label"
69
- }, isDateValue ? formatDate(label, dateFormat) : label), newPayload.map(entry => renderContent(entry)));
100
+ return /*#__PURE__*/React.createElement(StandardChartLabel, {
101
+ entry: entry,
102
+ formatLabelValue: formatLabelValue
103
+ });
104
+ }, [isPieChart, isPayOutChart, formatLabelValue]);
105
+ if (!active || !payload || !payload.length) {
106
+ return null;
70
107
  }
71
- return null;
108
+ const filteredPayload = payload.filter(item => item?.name !== 'bounds');
109
+ return /*#__PURE__*/React.createElement("div", {
110
+ id: id,
111
+ className: [baseClassName, componentClassName, userClassName].filter(Boolean).join(' ')
112
+ }, /*#__PURE__*/React.createElement("p", {
113
+ className: "label"
114
+ }, isDateValue ? formatDate(label, dateFormat) : label), filteredPayload.map(entry => /*#__PURE__*/React.createElement(React.Fragment, {
115
+ key: entry.name || entry.dataKey
116
+ }, renderContent(entry))));
72
117
  };
73
118
  CustomTooltipContent.propTypes = {
74
119
  /**
75
- * The id of the dropdown component.
76
- */
120
+ * The id of the tooltip component
121
+ */
77
122
  id: PropTypes.string,
78
123
  /**
79
- * Additional class names for the dropdown component.
124
+ * Additional class names for the tooltip component
80
125
  */
81
126
  className: PropTypes.string,
82
127
  /**
83
- * Flag on whether it is a timeformat or not
128
+ * Flag indicating whether values should be formatted as time
84
129
  */
85
130
  isTimeFormat: PropTypes.bool,
86
131
  /**
87
- * The type of format for the datetime value
132
+ * The format to use for date values
88
133
  */
89
134
  dateFormat: PropTypes.oneOf(Object.values(DATE_FORMATS)),
90
135
  /**
91
- * Flag on whether the label is a date value or not
136
+ * Flag indicating whether the label is a date value
92
137
  */
93
138
  isDateValue: PropTypes.bool,
94
139
  /**
95
- * If set true, the tooltip is displayed.
96
- * If set false, the tooltip is hidden, usually calculated internally.
140
+ * If true, the tooltip is displayed
97
141
  */
98
142
  active: PropTypes.bool.isRequired,
99
143
  /**
100
- * The source data of the content to be displayed in the tooltip,
101
- * always calculated internally and cannot be user set.
144
+ * The source data to be displayed in the tooltip
102
145
  */
103
- payload: PropTypes.arrayOf(PropTypes.string).isRequired,
146
+ payload: PropTypes.arrayOf(PropTypes.shape({
147
+ name: PropTypes.string,
148
+ value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
149
+ payload: PropTypes.shape({}),
150
+ dataKey: PropTypes.string,
151
+ color: PropTypes.string
152
+ })).isRequired,
104
153
  /**
105
- *The label value which is active now, usually calculated internally.
154
+ * The label value which is active
106
155
  */
107
156
  label: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
108
157
  /**
109
- * Flag on whether the chart is a pie chart or not
158
+ * Flag indicating whether the chart is a pie chart
159
+ */
160
+ isPieChart: PropTypes.bool,
161
+ /**
162
+ * Flag indicating whether the chart is a payout chart
110
163
  */
111
- isPieChart: PropTypes.bool
164
+ isPayOutChart: PropTypes.bool
112
165
  };
113
166
  CustomTooltipContent.defaultProps = {
167
+ id: undefined,
168
+ className: undefined,
114
169
  isTimeFormat: false,
115
170
  isDateValue: true,
116
171
  dateFormat: DATE_FORMATS.HUMAN_READABLE,
117
- isPieChart: false
172
+ isPieChart: false,
173
+ isPayOutChart: false
118
174
  };
119
- export default CustomTooltipContent;
175
+ export default /*#__PURE__*/React.memo(CustomTooltipContent);
@@ -17,14 +17,18 @@ const PieChart = ({
17
17
  height,
18
18
  width,
19
19
  innerRadius,
20
- outerRadius
20
+ outerRadius,
21
+ formatTotal,
22
+ subtitleToCurrency,
23
+ isPayOutChart
21
24
  }) => {
22
25
  const total = data.reduce((sum, item) => sum + item[valueKey], 0);
26
+ const displayTotal = formatTotal ? formatTotal(total) : `${total}`;
23
27
  const formattedData = data.map(item => ({
24
28
  ...item,
25
29
  label: item[labelKey],
26
30
  color: colors[data.indexOf(item)],
27
- percentage: (item[valueKey] / total * 100).toFixed(0)
31
+ percentage: total === 0 ? 0.0 : (item[valueKey] / total * 100).toFixed(0)
28
32
  }));
29
33
  return /*#__PURE__*/React.createElement("div", {
30
34
  id: id,
@@ -53,7 +57,8 @@ const PieChart = ({
53
57
  }))), /*#__PURE__*/React.createElement(Tooltip, {
54
58
  content: /*#__PURE__*/React.createElement(CustomTooltipContent, {
55
59
  isDateValue: false,
56
- isPieChart: true
60
+ isPieChart: true,
61
+ isPayOutChart: isPayOutChart
57
62
  })
58
63
  }), /*#__PURE__*/React.createElement("text", {
59
64
  x: "50%",
@@ -71,14 +76,16 @@ const PieChart = ({
71
76
  dy: "1.2em",
72
77
  fill: "var(--heading)",
73
78
  fontSize: "22"
74
- }, `${total}`)))), /*#__PURE__*/React.createElement(CustomLegend, {
79
+ }, displayTotal)))), /*#__PURE__*/React.createElement(CustomLegend, {
75
80
  key: id,
76
81
  colorsArray: colors,
77
82
  yKeysArray: formattedData,
78
83
  capitalizedLegend: true,
79
84
  orientation: "vertical",
80
85
  getLegendItemTitle: entry => entry[labelKey],
81
- getLegendItemSubtitle: entry => entry[valueKey]
86
+ getLegendItemSubtitle: entry => entry[valueKey],
87
+ subtitleToCurrency: subtitleToCurrency,
88
+ isPayOutChart: isPayOutChart
82
89
  })));
83
90
  };
84
91
  PieChart.propTypes = {
@@ -94,7 +101,10 @@ PieChart.propTypes = {
94
101
  height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
95
102
  width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
96
103
  innerRadius: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
97
- outerRadius: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
104
+ outerRadius: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
105
+ formatTotal: PropTypes.func,
106
+ subtitleToCurrency: PropTypes.bool,
107
+ isPayOutChart: PropTypes.bool
98
108
  };
99
109
  PieChart.defaultProps = {
100
110
  id: undefined,
@@ -102,6 +112,9 @@ PieChart.defaultProps = {
102
112
  width: '100%',
103
113
  height: 300,
104
114
  innerRadius: '50%',
105
- outerRadius: '100%'
115
+ outerRadius: '100%',
116
+ formatTotal: null,
117
+ subtitleToCurrency: false,
118
+ isPayOutChart: false
106
119
  };
107
120
  export default PieChart;
@@ -0,0 +1,66 @@
1
+ import * as React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import styleNames from '@pareto-engineering/bem/exports';
4
+ import "./styles.scss";
5
+
6
+ // Local Definitions
7
+ const baseClassName = styleNames.base;
8
+ const componentClassName = 'throughput-indicator';
9
+ const ThroughPutIndicator = ({
10
+ data,
11
+ keyName = 'reserved'
12
+ }) => {
13
+ const renderNoChange = () => /*#__PURE__*/React.createElement("div", {
14
+ className: [baseClassName, componentClassName].filter(e => e).join(' ')
15
+ }, /*#__PURE__*/React.createElement("span", {
16
+ className: "no-change-text"
17
+ }, "No change"));
18
+ const renderChange = (direction, percentage, icon = direction === 'positive' ? 'S' : 'R') => /*#__PURE__*/React.createElement("div", {
19
+ className: [baseClassName, componentClassName].filter(e => e).join(' ')
20
+ }, /*#__PURE__*/React.createElement("span", {
21
+ className: `ai-icon ${direction}-throughput-indicator`
22
+ }, icon), /*#__PURE__*/React.createElement("p", null, percentage, "%"));
23
+
24
+ // Handle invalid or insufficient data
25
+ if (!data || data.length < 2) {
26
+ return renderNoChange();
27
+ }
28
+ const first = data[0][keyName];
29
+ const last = data[data.length - 1][keyName];
30
+
31
+ // Handle no change scenarios
32
+ if (first === 0 && last === 0) {
33
+ return renderNoChange();
34
+ }
35
+
36
+ // Handle special case: starting from zero
37
+ if (first === 0 && last !== 0) {
38
+ return renderChange('positive', '100');
39
+ }
40
+
41
+ // Calculate percentage change
42
+ const percentChange = (last - first) / Math.abs(first) * 100;
43
+ const rounded = Math.abs(percentChange).toFixed(1);
44
+
45
+ // No change
46
+ if (percentChange === 0) {
47
+ return renderNoChange();
48
+ }
49
+
50
+ // Positive or negative change
51
+ const direction = percentChange > 0 ? 'positive' : 'negative';
52
+ const icon = direction === 'positive' ? 'S' : 'R';
53
+ return renderChange(direction, rounded, icon);
54
+ };
55
+ ThroughPutIndicator.propTypes = {
56
+ /**
57
+ * The data to be displayed in the throughput indicator
58
+ */
59
+ // eslint-disable-next-line react/forbid-prop-types
60
+ data: PropTypes.arrayOf(PropTypes.object).isRequired,
61
+ /**
62
+ * The key name to be displayed in the throughput indicator
63
+ */
64
+ keyName: PropTypes.string
65
+ };
66
+ export default ThroughPutIndicator;
@@ -0,0 +1,2 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ export { default as ThroughPutIndicator } from "./ThroughPutIndicator";
@@ -0,0 +1,35 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+
3
+ @use "@pareto-engineering/bem";
4
+
5
+ $default-text-font-size: calc(var(--s-1) * 1rem);
6
+
7
+ .#{bem.$base} {
8
+ .throughput-indicator {
9
+ align-items: center;
10
+ border: 1px solid var(--hard-grey);
11
+ border-radius: 2rem;
12
+ display: flex;
13
+ gap: .5rem;
14
+ height: 3rem;
15
+ padding: .5rem;
16
+
17
+ .positive-throughput-indicator {
18
+ color: var(--success);
19
+ font-size: 1rem;
20
+ }
21
+
22
+ .negative-throughput-indicator {
23
+ color: var(--error);
24
+ font-size: .75rem;
25
+ }
26
+
27
+ .no-change-text {
28
+ color: var(--paragraph);
29
+ }
30
+
31
+ p {
32
+ font-size: 1rem;
33
+ }
34
+ }
35
+ }
@@ -36,7 +36,8 @@ const ToggleSwitch = ({
36
36
  checked: checked,
37
37
  onChange: handleOnChange
38
38
  }), /*#__PURE__*/React.createElement("label", {
39
- htmlFor: inputId
39
+ htmlFor: inputId,
40
+ className: checked ? 'checked' : ''
40
41
  }));
41
42
  ToggleSwitch.propTypes = {
42
43
  /**
@@ -7,7 +7,7 @@ $default-size: var(--size, 1.2em);
7
7
  $default-slider-color: var(--slider-color, var(--background-far));
8
8
  $default-slider-border-color: var(--slider-border-color, var(--ui-lines));
9
9
  $default-background-color: var(--slider-background-color, var(--interactive));
10
-
10
+ $default-background-disabled: var(--disabled, var(--background-far));
11
11
  .#{bem.$base}.toggle-switch {
12
12
  background: transparent;
13
13
  border: none;
@@ -21,7 +21,6 @@ $default-background-color: var(--slider-background-color, var(--interactive));
21
21
  }
22
22
 
23
23
  >label {
24
- background: $default-background-color;
25
24
  border-radius: $default-border-radius;
26
25
  cursor: pointer;
27
26
  display: block;
@@ -29,6 +28,14 @@ $default-background-color: var(--slider-background-color, var(--interactive));
29
28
  position: relative;
30
29
  width: calc($default-size * 2);
31
30
 
31
+ &.checked {
32
+ background: $default-background-color;
33
+ }
34
+
35
+ &:not(.checked) {
36
+ background: $default-background-disabled;
37
+ }
38
+
32
39
  &::after {
33
40
  background: $default-slider-color;
34
41
  border: 1px solid $default-slider-border-color;
@@ -1,5 +1,6 @@
1
1
  /* @pareto-engineering/generator-front 1.0.12 */
2
2
  import * as React from 'react';
3
+ import { useEffect } from 'react';
3
4
  import PropTypes from 'prop-types';
4
5
  import styleNames from '@pareto-engineering/bem/exports';
5
6
  import "./styles.scss";
@@ -17,23 +18,37 @@ const Tooltip = ({
17
18
  className: userClassName,
18
19
  style,
19
20
  position,
21
+ isFloating,
20
22
  color,
21
23
  description,
22
24
  content,
23
25
  children
24
26
  // ...otherProps
25
- }) => /*#__PURE__*/React.createElement("div", {
26
- id: id,
27
- className: [baseClassName, componentClassName, userClassName, `x-${color}`].filter(e => e).join(' '),
28
- style: style
29
- }, /*#__PURE__*/React.createElement("div", {
30
- className: "tooltip-trigger-wrapper",
31
- "aria-describedby": description
32
- }, children), /*#__PURE__*/React.createElement("div", {
33
- className: `tooltip-content ${position}`,
34
- role: "tooltip",
35
- id: description
36
- }, content));
27
+ }) => {
28
+ useEffect(() => {
29
+ const handleMouseMove = e => {
30
+ document.documentElement.style.setProperty('--mouse-x', `${e.clientX}px`);
31
+ document.documentElement.style.setProperty('--mouse-y', `${e.clientY}px`);
32
+ };
33
+ if (!isFloating) {
34
+ return () => window.removeEventListener('mousemove', handleMouseMove);
35
+ }
36
+ window.addEventListener('mousemove', handleMouseMove);
37
+ return () => window.removeEventListener('mousemove', handleMouseMove);
38
+ }, [isFloating]);
39
+ return /*#__PURE__*/React.createElement("div", {
40
+ id: id,
41
+ className: [baseClassName, componentClassName, userClassName, `x-${color}`].filter(e => e).join(' '),
42
+ style: style
43
+ }, /*#__PURE__*/React.createElement("div", {
44
+ className: "tooltip-trigger-wrapper",
45
+ "aria-describedby": description
46
+ }, children), /*#__PURE__*/React.createElement("div", {
47
+ className: ['tooltip-content', position, isFloating ? 'floating' : ''].filter(e => e).join(' '),
48
+ role: "tooltip",
49
+ id: description
50
+ }, content));
51
+ };
37
52
  Tooltip.propTypes = {
38
53
  /**
39
54
  * The HTML id for this element
@@ -63,6 +78,10 @@ Tooltip.propTypes = {
63
78
  * The position of the tooltip with respect to the trigger element
64
79
  */
65
80
  position: PropTypes.oneOf(['top', 'bottom', 'left', 'right']),
81
+ /**
82
+ * Whether or not the tooltip should be floating
83
+ */
84
+ isFloating: PropTypes.bool,
66
85
  /**
67
86
  * The base color of the tooltip
68
87
  */
@@ -24,25 +24,53 @@ $default-width: var(--tooltip-width, 20rem);
24
24
  visibility: hidden;
25
25
  z-index: 10;
26
26
 
27
- &.top {
27
+ &.floating.top {
28
+ left: var(--mouse-x);
29
+ position: fixed;
30
+ top: calc(var(--mouse-y) - $default-block-padding);
31
+ transform: translate(-50%, -100%);
32
+ }
33
+
34
+ &.floating.right {
35
+ left: calc(var(--mouse-x) + $default-inline-padding);
36
+ position: fixed;
37
+ top: var(--mouse-y);
38
+ transform: translateY(-50%);
39
+ }
40
+
41
+ &.floating.bottom {
42
+ left: var(--mouse-x);
43
+ position: fixed;
44
+ top: calc(var(--mouse-y) + $default-block-padding);
45
+ transform: translateX(-50%);
46
+ }
47
+
48
+ &.floating.left {
49
+ left: calc(var(--mouse-x) - $default-inline-padding);
50
+ position: fixed;
51
+ top: var(--mouse-y);
52
+ transform: translate(-100%, -50%);
53
+ }
54
+
55
+ &:not(.floating).top {
28
56
  --horizontal: -50%;
29
57
  bottom: calc(100% + $default-block-padding);
30
58
  left: 50%;
31
59
  }
32
60
 
33
- &.right {
61
+ &:not(.floating).right {
34
62
  --vertical: 50%;
35
63
  bottom: 50%;
36
64
  left: calc(100% + $default-inline-padding);
37
65
  }
38
66
 
39
- &.bottom {
67
+ &:not(.floating).bottom {
40
68
  --horizontal: -50%;
41
69
  left: 50%;
42
70
  top: calc(100% + $default-block-padding);
43
71
  }
44
72
 
45
- &.left {
73
+ &:not(.floating).left {
46
74
  --vertical: 50%;
47
75
  bottom: 50%;
48
76
  right: calc(100% + $default-inline-padding);
@@ -28,4 +28,5 @@ export { ToggleSwitch } from "./ToggleSwitch";
28
28
  export { XMLEditor } from "./XMLEditor";
29
29
  export { DatePicker } from "./DatePicker";
30
30
  export { Tooltip } from "./Tooltip";
31
- export { AreaChart, BarChart, PieChart } from "./Charts";
31
+ export { AreaChart, BarChart, PieChart } from "./Charts";
32
+ export { ThroughPutIndicator } from "./ThroughPutIndicator";
@@ -3,7 +3,7 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
3
3
  import * as React from 'react';
4
4
  import { memo } from 'react';
5
5
  import PropTypes from 'prop-types';
6
- import { TextInput, TextareaInput, ChoicesInput, SelectInput, QueryCombobox, QuerySelect, RatingsInput, Checkbox, QueryChoices, LinkInput, EditorInput, FileUpload, LatexPreviewInput } from "../fields";
6
+ import { TextInput, TextareaInput, ChoicesInput, SelectInput, QueryCombobox, QuerySelect, RatingsInput, Checkbox, QueryChoices, LinkInput, EditorInput, FileUpload, LatexPreviewInput, ToggleInput } from "../fields";
7
7
  import "./styles.scss";
8
8
 
9
9
  // Local Definitions
@@ -60,6 +60,12 @@ const FormInput = ({
60
60
  disabled: disabled
61
61
  }, otherProps));
62
62
  }
63
+ if (type === 'toggle') {
64
+ return /*#__PURE__*/React.createElement(ToggleInput, _extends({
65
+ className: newClassName,
66
+ disabled: disabled
67
+ }, otherProps));
68
+ }
63
69
  if (type === 'query-choices') {
64
70
  return /*#__PURE__*/React.createElement(QueryChoices, _extends({
65
71
  className: newClassName,
@@ -122,7 +128,7 @@ FormInput.propTypes = {
122
128
  /**
123
129
  * The HTML class names for this element
124
130
  */
125
- type: PropTypes.oneOf(['text', 'email', 'password', 'number', 'date', 'datetime', 'month', 'tel', 'hidden', 'select', 'choices', 'textarea', 'query-combobox', 'query-select', 'url', 'rating', 'checkbox',
131
+ type: PropTypes.oneOf(['text', 'email', 'password', 'number', 'date', 'datetime', 'month', 'tel', 'hidden', 'select', 'choices', 'textarea', 'query-combobox', 'query-select', 'url', 'rating', 'checkbox', 'toggle',
126
132
  // to be removed
127
133
  'extendedTypeInput']),
128
134
  /**