@desynova-digital/components 9.0.26 → 9.1.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 (170) hide show
  1. package/_helpers/globals.js +9 -10
  2. package/_helpers/pagination.js +10 -15
  3. package/_helpers/story-example.js +16 -39
  4. package/_helpers/story-helpers.js +15 -14
  5. package/_helpers/story-stack.js +22 -43
  6. package/_helpers/uniqueId.js +2 -5
  7. package/_helpers/utils.js +28 -4
  8. package/atoms/avatar/avatar.js +19 -42
  9. package/atoms/avatar/avatar.story.js +25 -58
  10. package/atoms/avatar/index.js +13 -11
  11. package/atoms/badge/badge.js +14 -37
  12. package/atoms/badge/badge.story.js +45 -103
  13. package/atoms/badge/index.js +12 -10
  14. package/atoms/button/button.js +85 -161
  15. package/atoms/button/button.story.js +354 -508
  16. package/atoms/button/index.js +5 -9
  17. package/atoms/card/card.js +26 -55
  18. package/atoms/card/card.story.js +39 -88
  19. package/atoms/card/index.js +12 -10
  20. package/atoms/cardStack/cardStack.js +88 -147
  21. package/atoms/cardStack/cardStack.story.js +106 -210
  22. package/atoms/cardStack/index.js +12 -10
  23. package/atoms/cardV2/cardV2.js +57 -106
  24. package/atoms/cardV2/cardV2.story.js +184 -232
  25. package/atoms/cardV2/content.js +154 -256
  26. package/atoms/cardV2/index.js +4 -8
  27. package/atoms/cardV2/thumbnail.js +138 -208
  28. package/atoms/cardV2/timeline.js +167 -123
  29. package/atoms/checkbox/checkbox.js +85 -157
  30. package/atoms/checkbox/checkbox.story.js +237 -365
  31. package/atoms/checkbox/index.js +4 -9
  32. package/atoms/customSelect/customSelect.js +136 -215
  33. package/atoms/customSelect/customSelect.story.js +745 -851
  34. package/atoms/customSelect/index.js +4 -8
  35. package/atoms/datePicker/datePicker.js +299 -431
  36. package/atoms/datePicker/datePicker.story.js +453 -501
  37. package/atoms/datePicker/index.js +4 -8
  38. package/atoms/dateTime/dateTime.js +3 -6
  39. package/atoms/dateTime/dateTime.story.js +17 -63
  40. package/atoms/dateTime/index.js +5 -9
  41. package/atoms/draftInputText/draftInputText.js +121 -189
  42. package/atoms/draftInputText/draftInputText.story.js +200 -249
  43. package/atoms/draftInputText/index.js +5 -9
  44. package/atoms/dropdown/dropdown.js +38 -66
  45. package/atoms/dropdown/dropdown.story.js +102 -262
  46. package/atoms/dropdown/index.js +4 -8
  47. package/atoms/dropdownList/dropdownList.js +78 -108
  48. package/atoms/dropdownList/dropdownList.story.js +1546 -1621
  49. package/atoms/dropdownList/index.js +4 -8
  50. package/atoms/graphs/barGraph/barGraph.js +95 -146
  51. package/atoms/graphs/barGraph/barGraph.story.js +65 -87
  52. package/atoms/graphs/barGraph/index.js +4 -8
  53. package/atoms/graphs/circleDonut/circleDonut.js +177 -229
  54. package/atoms/graphs/circleDonut/circleDonut.story.js +328 -394
  55. package/atoms/graphs/circleDonut/index.js +5 -9
  56. package/atoms/graphs/circleGraph/circleGraph.js +60 -90
  57. package/atoms/graphs/circleGraph/circleGraph.story.js +36 -54
  58. package/atoms/graphs/circleGraph/index.js +4 -8
  59. package/atoms/graphs/circleNested/circleNested.js +216 -262
  60. package/atoms/graphs/circleNested/circleNested.story.js +91 -116
  61. package/atoms/graphs/circleNested/index.js +5 -9
  62. package/atoms/graphs/pieChart/index.js +4 -8
  63. package/atoms/graphs/pieChart/pieChart.js +162 -191
  64. package/atoms/graphs/pieChart/pieChart.story.js +147 -176
  65. package/atoms/graphs/verticalBarGraph/index.js +5 -9
  66. package/atoms/graphs/verticalBarGraph/verticalBarGraph.js +75 -98
  67. package/atoms/graphs/verticalBarGraph/verticalBarGraph.story.js +26 -45
  68. package/atoms/icon/icon.js +41 -72
  69. package/atoms/icon/icon.story.js +831 -260
  70. package/atoms/icon/index.js +19 -12
  71. package/atoms/image/image.js +18 -32
  72. package/atoms/image/image.story.js +10 -19
  73. package/atoms/image/index.js +4 -8
  74. package/atoms/inputText/index.js +4 -8
  75. package/atoms/inputText/inputText.js +86 -131
  76. package/atoms/inputText/inputText.story.js +191 -255
  77. package/atoms/label/index.js +4 -8
  78. package/atoms/label/label.js +25 -50
  79. package/atoms/label/label.story.js +42 -83
  80. package/atoms/loader/CircleLoader.js +29 -63
  81. package/atoms/loader/ShimmerComponent/CollabShimmerCard.js +39 -50
  82. package/atoms/loader/ShimmerComponent/CollabShimmerCardTray.js +41 -42
  83. package/atoms/loader/ShimmerComponent/FiltersShimmer.js +30 -30
  84. package/atoms/loader/ShimmerComponent/GraphDetailShimmer.js +21 -34
  85. package/atoms/loader/ShimmerComponent/GraphTitleShimmer.js +30 -34
  86. package/atoms/loader/ShimmerComponent/GraphsComponentShimmer.js +23 -32
  87. package/atoms/loader/ShimmerComponent/Shimmer.js +24 -32
  88. package/atoms/loader/ThreeDotLoader.js +14 -29
  89. package/atoms/loader/index.js +13 -11
  90. package/atoms/loader/loader.js +34 -58
  91. package/atoms/loader/loader.story.js +48 -52
  92. package/atoms/loader/spinningLoader.js +23 -34
  93. package/atoms/popup/index.js +5 -9
  94. package/atoms/popup/popup.js +123 -208
  95. package/atoms/popup/popup.story.js +97 -131
  96. package/atoms/radio/index.js +18 -11
  97. package/atoms/radio/radio.js +58 -112
  98. package/atoms/radio/radio.story.js +197 -420
  99. package/atoms/select/index.js +4 -8
  100. package/atoms/select/select.js +48 -86
  101. package/atoms/sideBar/index.js +5 -9
  102. package/atoms/sideBar/sidebar.js +89 -140
  103. package/atoms/switch/index.js +4 -8
  104. package/atoms/switch/switch.js +56 -86
  105. package/atoms/switch/switch.story.js +268 -415
  106. package/atoms/tag/index.js +12 -10
  107. package/atoms/tag/tag.js +29 -63
  108. package/atoms/tag/tag.story.js +135 -209
  109. package/atoms/textarea/index.js +5 -9
  110. package/atoms/textarea/textarea.js +55 -99
  111. package/atoms/textarea/textarea.story.js +48 -41
  112. package/atoms/thematicBreak/index.js +12 -10
  113. package/atoms/thematicBreak/thematicBreak.js +20 -38
  114. package/atoms/thematicBreak/thematicBreak.story.js +25 -37
  115. package/atoms/timeCodeInput/index.js +4 -8
  116. package/atoms/timeCodeInput/timCodeInput.story.js +21 -35
  117. package/atoms/timeCodeInput/timeCodeInput.js +33 -51
  118. package/atoms/timer/index.js +5 -9
  119. package/atoms/timer/timer.js +57 -108
  120. package/atoms/timer/timer.story.js +13 -26
  121. package/atoms/toast/index.js +5 -9
  122. package/atoms/toast/toast.js +81 -116
  123. package/atoms/toast/toast.story.js +50 -76
  124. package/atoms/videoCard/index.js +12 -10
  125. package/atoms/videoCard/videoCard.js +265 -447
  126. package/atoms/videoCard/videoCard.story.js +495 -710
  127. package/components.js +411 -294
  128. package/index.js +350 -61
  129. package/molecules/carousel/carousel.js +121 -207
  130. package/molecules/carousel/carousel.story.js +240 -223
  131. package/molecules/carousel/index.js +5 -9
  132. package/molecules/errorScreen/CollabErrorScreen.js +35 -66
  133. package/molecules/errorScreen/TableErrorScreen.js +109 -102
  134. package/molecules/errorScreen/TableErrorScreen.jsx +7 -6
  135. package/molecules/errorScreen/errorScreen.js +41 -94
  136. package/molecules/filter/constants.js +1 -0
  137. package/molecules/filter/filter.js +378 -562
  138. package/molecules/filter/filter.story.js +79 -104
  139. package/molecules/filter/index.js +5 -9
  140. package/molecules/graphCard/graphCard.js +97 -193
  141. package/molecules/graphCard/graphCard.story.js +159 -191
  142. package/molecules/graphCard/index.js +4 -8
  143. package/molecules/graphCard/loader.js +28 -68
  144. package/molecules/graphDetailCard/graphDetailCard.js +115 -183
  145. package/molecules/graphDetailCard/graphDetailCard.story.js +218 -254
  146. package/molecules/graphDetailCard/index.js +5 -9
  147. package/molecules/pageHeader/index.js +12 -10
  148. package/molecules/pageHeader/pageHeader.js +38 -79
  149. package/molecules/pageHeader/pageHeader.story.js +34 -55
  150. package/molecules/pagination/index.js +4 -8
  151. package/molecules/pagination/pagination.js +126 -202
  152. package/molecules/pagination/pagination.story.js +40 -52
  153. package/molecules/richTextInput/RichTextInput.js +354 -0
  154. package/molecules/richTextInput/RichTextInput.story.js +50 -0
  155. package/molecules/richTextInput/index.js +9 -0
  156. package/molecules/table/index.js +4 -8
  157. package/molecules/table/table-column.js +10 -16
  158. package/molecules/table/table-header.js +31 -72
  159. package/molecules/table/table.js +743 -1075
  160. package/molecules/table/table.story.js +274 -304
  161. package/molecules/tabs/index.js +4 -8
  162. package/molecules/tabs/tabs.js +112 -184
  163. package/molecules/tabs/tabs.story.js +66 -133
  164. package/molecules/videoCardList/index.js +4 -8
  165. package/molecules/videoCardList/videoCardList.js +24 -41
  166. package/molecules/videoCardList/videoCardList.story.js +449 -664
  167. package/molecules/videoPlayer/index.js +4 -8
  168. package/molecules/videoPlayer/videoPlayer.js +1019 -1097
  169. package/molecules/videoPlayer/videoPlayer.story.js +10 -21
  170. package/package.json +2 -2
@@ -1,119 +1,94 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- var _react = require('react');
4
-
5
- var _react2 = _interopRequireDefault(_react);
6
-
7
- var _react3 = require('@storybook/react');
8
-
9
- var _storyHelpers = require('../../../_helpers/story-helpers');
10
-
11
- var _components = require('../../../../components');
12
-
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
-
15
- (0, _react3.storiesOf)('CircleNested').add('light theme', function () {
16
- return _react2.default.createElement(
17
- _storyHelpers.Example,
18
- { title: 'Appearances' },
19
- _react2.default.createElement(
20
- _storyHelpers.Stack,
21
- null,
22
- _react2.default.createElement(
23
- 'div',
24
- null,
25
- _react2.default.createElement(
26
- 'div',
27
- { style: { width: '295px', height: '295px' } },
28
- _react2.default.createElement(_components.CircleNested, {
29
- data: {
30
- graph_name: 'circle-nested',
31
- graph_type: '',
32
- data: {
33
- from_date: 1609698600000,
34
- to_date: 1610389799000,
35
- name: 'Ingest',
36
- total: 10,
37
- values: [{
38
- name: 'Finished',
39
- value: 'ingested',
40
- index: 1,
41
- data: 3,
42
- processed: 66
43
- }, {
44
- name: 'In Progress',
45
- value: 'started',
46
- index: 2,
47
- data: 5,
48
- inprogress: 7
49
- }, {
50
- name: 'Failed',
51
- value: 'failed',
52
- index: 4,
53
- data: 2,
54
- pending: 17
55
- }]
56
- }
57
- },
58
- graphColors: [['#00C8E7', '#00E6B9'], ['#FFE259', '#FFA751'], ['#FF8D29', '#F6462C'], ['#FFFFFF', '#DDDDDD']],
59
- graphPlaceholder: false,
60
- valueSub: 'Assets'
61
- })
62
- )
63
- )
64
- )
65
- );
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _react = _interopRequireDefault(require("react"));
5
+ var _react2 = require("@storybook/react");
6
+ var _storyHelpers = require("../../../_helpers/story-helpers");
7
+ var _components = require("../../../../components");
8
+ (0, _react2.storiesOf)('CircleNested').add('light theme', function () {
9
+ return /*#__PURE__*/_react["default"].createElement(_storyHelpers.Example, {
10
+ title: "Appearances"
11
+ }, /*#__PURE__*/_react["default"].createElement(_storyHelpers.Stack, null, /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("div", {
12
+ style: {
13
+ width: '295px',
14
+ height: '295px'
15
+ }
16
+ }, /*#__PURE__*/_react["default"].createElement(_components.CircleNested, {
17
+ data: {
18
+ graph_name: 'circle-nested',
19
+ graph_type: '',
20
+ data: {
21
+ from_date: 1609698600000,
22
+ to_date: 1610389799000,
23
+ name: 'Ingest',
24
+ total: 10,
25
+ values: [{
26
+ name: 'Finished',
27
+ value: 'ingested',
28
+ index: 1,
29
+ data: 3,
30
+ processed: 66
31
+ }, {
32
+ name: 'In Progress',
33
+ value: 'started',
34
+ index: 2,
35
+ data: 5,
36
+ inprogress: 7
37
+ }, {
38
+ name: 'Failed',
39
+ value: 'failed',
40
+ index: 4,
41
+ data: 2,
42
+ pending: 17
43
+ }]
44
+ }
45
+ },
46
+ graphColors: [['#00C8E7', '#00E6B9'], ['#FFE259', '#FFA751'], ['#FF8D29', '#F6462C'], ['#FFFFFF', '#DDDDDD']],
47
+ graphPlaceholder: false,
48
+ valueSub: 'Assets'
49
+ })))));
66
50
  });
67
-
68
- (0, _react3.storiesOf)('CircleNested').add('dark theme', function () {
69
- return _react2.default.createElement(
70
- _storyHelpers.Example,
71
- { title: 'Tag', background: 'dark' },
72
- _react2.default.createElement(
73
- _storyHelpers.Stack,
74
- null,
75
- _react2.default.createElement(
76
- 'div',
77
- null,
78
- _react2.default.createElement(
79
- 'div',
80
- { style: { width: '295px', height: '295px' } },
81
- _react2.default.createElement(_components.CircleNested, {
82
- data: {
83
- graph_name: 'circle-nested',
84
- graph_type: '',
85
- data: {
86
- from_date: 1609698600000,
87
- to_date: 1610389799000,
88
- name: 'Ingest',
89
- total: 10,
90
- values: [{
91
- name: 'Finished',
92
- value: 'ingested',
93
- index: 1,
94
- data: 3,
95
- processed: 66
96
- }, {
97
- name: 'In Progress',
98
- value: 'started',
99
- index: 2,
100
- data: 5,
101
- inprogress: 7
102
- }, {
103
- name: 'Failed',
104
- value: 'failed',
105
- index: 4,
106
- data: 2,
107
- pending: 17
108
- }]
109
- }
110
- },
111
- graphColors: [['#00C8E7', '#00E6B9'], ['#FFE259', '#FFA751'], ['#FF8D29', '#F6462C'], ['#FFFFFF', '#DDDDDD']],
112
- graphPlaceholder: false,
113
- valueSub: 'Asset'
114
- })
115
- )
116
- )
117
- )
118
- );
51
+ (0, _react2.storiesOf)('CircleNested').add('dark theme', function () {
52
+ return /*#__PURE__*/_react["default"].createElement(_storyHelpers.Example, {
53
+ title: "Tag",
54
+ background: "dark"
55
+ }, /*#__PURE__*/_react["default"].createElement(_storyHelpers.Stack, null, /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("div", {
56
+ style: {
57
+ width: '295px',
58
+ height: '295px'
59
+ }
60
+ }, /*#__PURE__*/_react["default"].createElement(_components.CircleNested, {
61
+ data: {
62
+ graph_name: 'circle-nested',
63
+ graph_type: '',
64
+ data: {
65
+ from_date: 1609698600000,
66
+ to_date: 1610389799000,
67
+ name: 'Ingest',
68
+ total: 10,
69
+ values: [{
70
+ name: 'Finished',
71
+ value: 'ingested',
72
+ index: 1,
73
+ data: 3,
74
+ processed: 66
75
+ }, {
76
+ name: 'In Progress',
77
+ value: 'started',
78
+ index: 2,
79
+ data: 5,
80
+ inprogress: 7
81
+ }, {
82
+ name: 'Failed',
83
+ value: 'failed',
84
+ index: 4,
85
+ data: 2,
86
+ pending: 17
87
+ }]
88
+ }
89
+ },
90
+ graphColors: [['#00C8E7', '#00E6B9'], ['#FFE259', '#FFA751'], ['#FF8D29', '#F6462C'], ['#FFFFFF', '#DDDDDD']],
91
+ graphPlaceholder: false,
92
+ valueSub: 'Asset'
93
+ })))));
119
94
  });
@@ -1,13 +1,9 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
-
7
- var _circleNested = require('./circleNested');
8
-
9
- var _circleNested2 = _interopRequireDefault(_circleNested);
10
-
11
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
-
13
- exports.default = _circleNested2.default;
7
+ exports["default"] = void 0;
8
+ var _circleNested = _interopRequireDefault(require("./circleNested"));
9
+ var _default = exports["default"] = _circleNested["default"];
@@ -1,13 +1,9 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
-
7
- var _pieChart = require("./pieChart");
8
-
9
- var _pieChart2 = _interopRequireDefault(_pieChart);
10
-
11
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
-
13
- exports.default = _pieChart2.default;
7
+ exports["default"] = void 0;
8
+ var _pieChart = _interopRequireDefault(require("./pieChart"));
9
+ var _default = exports["default"] = _pieChart["default"];
@@ -1,204 +1,175 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
3
5
  Object.defineProperty(exports, "__esModule", {
4
- value: true
6
+ value: true
5
7
  });
6
-
7
- var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
8
-
9
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
10
-
11
- var _templateObject = _taggedTemplateLiteral(['\n stroke: ', ';\n stroke-width: 0;\n'], ['\n stroke: ', ';\n stroke-width: 0;\n']),
12
- _templateObject2 = _taggedTemplateLiteral(['\n display: block;\n margin: 10px auto;\n'], ['\n display: block;\n margin: 10px auto;\n']);
13
-
14
- var _react = require('react');
15
-
16
- var _react2 = _interopRequireDefault(_react);
17
-
18
- var _styledComponents = require('styled-components');
19
-
20
- var _styledComponents2 = _interopRequireDefault(_styledComponents);
21
-
22
- var _propTypes = require('prop-types');
23
-
24
- var _propTypes2 = _interopRequireDefault(_propTypes);
25
-
26
- var _tokens = require('@desynova-digital/tokens');
27
-
28
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
-
30
- function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
31
-
32
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
33
-
34
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
35
-
36
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
37
-
38
- var PieChart = function (_React$Component) {
39
- _inherits(PieChart, _React$Component);
40
-
41
- function PieChart(props) {
42
- _classCallCheck(this, PieChart);
43
-
44
- var _this = _possibleConstructorReturn(this, (PieChart.__proto__ || Object.getPrototypeOf(PieChart)).call(this, props));
45
-
46
- _this.generateData = function (data) {
47
-
48
- var sectors = [];
49
- var l = (typeof _this.props.width == 'string' ? 100 : _this.props.width) / 2;
50
- var totalItems = data.total !== 0 ? data.total : 10;
51
- var a = 0; // Angle
52
- var aRad = 0; // Angle in Rad
53
- var z = 0; // Size z
54
- var x = 0; // Side x
55
- var y = 0; // Side y
56
- var X = 0; // SVG X coordinate
57
- var Y = 0; // SVG Y coordinate
58
- var R = 0; // Rotation
59
- var aCalc = 0;
60
- var arcSweep = 0;
61
-
62
- data.values.map(function (item, key) {
63
- var percent = (data.total != 0 ? item.data : 10) / totalItems;
64
- a = 360 * percent;
65
- aCalc = a > 180 ? 360 - a : a;
66
- aRad = aCalc * Math.PI / 180;
67
- z = Math.sqrt(2 * l * l - 2 * l * l * Math.cos(aRad));
68
- if (aCalc <= 90) {
69
- x = l * Math.sin(aRad);
70
- } else {
71
- x = l * Math.sin((180 - aCalc) * Math.PI / 180);
72
- }
73
-
74
- y = Math.sqrt(z * z - x * x);
75
- Y = y;
76
-
77
- if (a <= 180) {
78
- X = l + x;
79
- arcSweep = 0;
80
- } else {
81
- X = l - x;
82
- arcSweep = 1;
83
- }
84
-
85
- sectors.push({
86
- percentage: percent,
87
- label: item.name,
88
- arcSweep: arcSweep,
89
- value: item.value,
90
- L: l,
91
- X: X,
92
- Y: Y,
93
- R: R
94
- });
95
-
96
- R = R + a;
97
- });
98
-
99
- return sectors;
100
- };
101
-
102
- _this.componentDidMount = function () {
103
- var dataObj = _this.generateData(_this.props.data);
104
- _this.setState({ dataObj: dataObj });
105
- };
106
-
107
- _this.state = {
108
- dataObj: null
109
- };
110
- return _this;
111
- }
112
-
113
- _createClass(PieChart, [{
114
- key: 'getColors',
115
- value: function getColors(idx) {
116
- var arr = ["completed", "rejected", "pending", "failed"];
117
- return arr[idx];
8
+ exports["default"] = void 0;
9
+ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
14
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
15
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
16
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
17
+ var _react = _interopRequireDefault(require("react"));
18
+ var _styledComponents = _interopRequireWildcard(require("styled-components"));
19
+ var _propTypes = _interopRequireDefault(require("prop-types"));
20
+ var _tokens = require("@desynova-digital/tokens");
21
+ var _templateObject, _templateObject2;
22
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
23
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
24
+ function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
25
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
26
+ var PieChart = /*#__PURE__*/function (_React$Component) {
27
+ function PieChart(props) {
28
+ var _this;
29
+ (0, _classCallCheck2["default"])(this, PieChart);
30
+ _this = _callSuper(this, PieChart, [props]);
31
+ (0, _defineProperty2["default"])(_this, "generateData", function (data) {
32
+ var sectors = [];
33
+ var l = (typeof _this.props.width == 'string' ? 100 : _this.props.width) / 2;
34
+ var totalItems = data.total !== 0 ? data.total : 10;
35
+ var a = 0; // Angle
36
+ var aRad = 0; // Angle in Rad
37
+ var z = 0; // Size z
38
+ var x = 0; // Side x
39
+ var y = 0; // Side y
40
+ var X = 0; // SVG X coordinate
41
+ var Y = 0; // SVG Y coordinate
42
+ var R = 0; // Rotation
43
+ var aCalc = 0;
44
+ var arcSweep = 0;
45
+ data.values.map(function (item, key) {
46
+ var percent = (data.total != 0 ? item.data : 10) / totalItems;
47
+ a = 360 * percent;
48
+ aCalc = a > 180 ? 360 - a : a;
49
+ aRad = aCalc * Math.PI / 180;
50
+ z = Math.sqrt(2 * l * l - 2 * l * l * Math.cos(aRad));
51
+ if (aCalc <= 90) {
52
+ x = l * Math.sin(aRad);
53
+ } else {
54
+ x = l * Math.sin((180 - aCalc) * Math.PI / 180);
118
55
  }
119
- }, {
120
- key: 'render',
121
- value: function render() {
122
- var _this2 = this;
123
-
124
- var width = typeof this.props.width == 'string' ? 100 : this.props.width;
125
-
126
- return _react2.default.createElement(
127
- _react2.default.Fragment,
128
- null,
129
- this.state.dataObj ? _react2.default.createElement(
130
- GraphSVG,
131
- _extends({}, typeof this.props.width == 'string' ? "" : { "width": width }, typeof this.props.width == 'string' ? "" : { "height": this.props.height }, {
132
- viewBox: '0 0 ' + width + ' ' + this.props.height
133
- }),
134
- this.state.dataObj.map(function (data, index) {
135
- return data.percentage !== 1 ? _react2.default.createElement(StyledPath, _extends({}, _this2.props, {
136
- key: index,
137
- fill: _tokens.colors[_this2.props.theme].graph[_this2.getColors(index)],
138
- d: 'M' + data.L + ', ' + data.L + ' L' + data.L + ',0 A' + data.L + ',' + data.L + ' 1 ' + data.arcSweep + ',1 ' + data.X + ', ' + data.Y + ' z',
139
- transform: 'rotate(' + data.R + ', ' + data.L + ',' + data.L + ')'
140
- })) : _react2.default.createElement(StyledPath, _extends({}, _this2.props, {
141
- key: index,
142
- fill: _tokens.colors[_this2.props.theme].graph[_this2.getColors(index)],
143
- d: " \
56
+ y = Math.sqrt(z * z - x * x);
57
+ Y = y;
58
+ if (a <= 180) {
59
+ X = l + x;
60
+ arcSweep = 0;
61
+ } else {
62
+ X = l - x;
63
+ arcSweep = 1;
64
+ }
65
+ sectors.push({
66
+ percentage: percent,
67
+ label: item.name,
68
+ arcSweep: arcSweep,
69
+ value: item.value,
70
+ L: l,
71
+ X: X,
72
+ Y: Y,
73
+ R: R
74
+ });
75
+ R = R + a;
76
+ });
77
+ return sectors;
78
+ });
79
+ (0, _defineProperty2["default"])(_this, "componentDidMount", function () {
80
+ var dataObj = _this.generateData(_this.props.data);
81
+ _this.setState({
82
+ dataObj: dataObj
83
+ });
84
+ });
85
+ _this.state = {
86
+ dataObj: null
87
+ };
88
+ return _this;
89
+ }
90
+ (0, _inherits2["default"])(PieChart, _React$Component);
91
+ return (0, _createClass2["default"])(PieChart, [{
92
+ key: "getColors",
93
+ value: function getColors(idx) {
94
+ var arr = ["completed", "rejected", "pending", "failed"];
95
+ return arr[idx];
96
+ }
97
+ }, {
98
+ key: "render",
99
+ value: function render() {
100
+ var _this2 = this;
101
+ var width = typeof this.props.width == 'string' ? 100 : this.props.width;
102
+ return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, this.state.dataObj ? /*#__PURE__*/_react["default"].createElement(GraphSVG, (0, _extends2["default"])({}, typeof this.props.width == 'string' ? "" : {
103
+ "width": width
104
+ }, typeof this.props.width == 'string' ? "" : {
105
+ "height": this.props.height
106
+ }, {
107
+ viewBox: "0 0 ".concat(width, " ").concat(this.props.height)
108
+ }), this.state.dataObj.map(function (data, index) {
109
+ return data.percentage !== 1 ? /*#__PURE__*/_react["default"].createElement(StyledPath, (0, _extends2["default"])({}, _this2.props, {
110
+ key: index,
111
+ fill: _tokens.colors[_this2.props.theme].graph[_this2.getColors(index)],
112
+ d: "M".concat(data.L, ", ").concat(data.L, " L").concat(data.L, ",0 A").concat(data.L, ",").concat(data.L, " 1 ").concat(data.arcSweep, ",1 ").concat(data.X, ", ").concat(data.Y, " z"),
113
+ transform: "rotate(".concat(data.R, ", ").concat(data.L, ",").concat(data.L, ")")
114
+ })) : /*#__PURE__*/_react["default"].createElement(StyledPath, (0, _extends2["default"])({}, _this2.props, {
115
+ key: index,
116
+ fill: _tokens.colors[_this2.props.theme].graph[_this2.getColors(index)],
117
+ d: " \
144
118
  M " + width / 2 + ", " + width / 2 + " \
145
119
  m -" + width / 2 + ", 0 \
146
120
  a " + width / 2 + "," + width / 2 + " 0 1,0 " + width / 2 * 2 + ",0 \
147
121
  a " + width / 2 + "," + width / 2 + " 0 1,0 -" + width / 2 * 2 + ",0 \
148
- ", transform: 'rotate(' + data.R + ', ' + data.L + ',' + data.L + ')' }));
149
- }),
150
- this.props.type === 'donut' || this.props.type === 'donutThin' ? _react2.default.createElement('circle', { cx: width / 2, cy: width / 2, r: width / 2 * (this.props.type === 'donutThin' ? 0.97 : 0.90), fill: _tokens.colors[this.props.theme].base }) : null
151
- ) : null
152
- );
153
- }
154
- }]);
155
-
156
- return PieChart;
157
- }(_react2.default.Component);
158
-
159
- var StyledPath = _styledComponents2.default.path(_templateObject, function (props) {
160
- return _tokens.colors[props.theme].base;
122
+ ",
123
+ transform: "rotate(".concat(data.R, ", ").concat(data.L, ",").concat(data.L, ")")
124
+ }));
125
+ }), this.props.type === 'donut' || this.props.type === 'donutThin' ? /*#__PURE__*/_react["default"].createElement("circle", {
126
+ cx: width / 2,
127
+ cy: width / 2,
128
+ r: width / 2 * (this.props.type === 'donutThin' ? 0.97 : 0.90),
129
+ fill: _tokens.colors[this.props.theme].base
130
+ }) : null) : null);
131
+ }
132
+ }]);
133
+ }(_react["default"].Component);
134
+ var StyledPath = _styledComponents["default"].path(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n stroke: ", ";\n stroke-width: 0;\n"])), function (props) {
135
+ return _tokens.colors[props.theme].base;
161
136
  });
162
-
163
- var GraphSVG = _styledComponents2.default.svg(_templateObject2);
164
-
137
+ var GraphSVG = _styledComponents["default"].svg(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: block;\n margin: 10px auto;\n"])));
165
138
  PieChart.propTypes = {
166
- /** Graph Data */
167
- data: _propTypes2.default.object.isRequired,
168
- /** Graph size */
169
- // width: PropTypes.number,
170
- height: _propTypes2.default.number,
171
- colorType: _propTypes2.default.oneOf(['gradient', 'normal']),
172
- theme: _propTypes2.default.oneOf(['light', 'dark']),
173
- type: _propTypes2.default.oneOf(['pie', 'donut', 'donutThin'])
139
+ /** Graph Data */
140
+ data: _propTypes["default"].object.isRequired,
141
+ /** Graph size */
142
+ // width: PropTypes.number,
143
+ height: _propTypes["default"].number,
144
+ colorType: _propTypes["default"].oneOf(['gradient', 'normal']),
145
+ theme: _propTypes["default"].oneOf(['light', 'dark']),
146
+ type: _propTypes["default"].oneOf(['pie', 'donut', 'donutThin'])
174
147
  };
175
-
176
148
  PieChart.defaultProps = {
177
- data: {
178
- "name": "Archieve",
179
- "total": 0,
180
- "values": [{
181
- "name": "Archieved",
182
- "value": "archieved",
183
- "data": 0,
184
- "index": 1
185
- }, {
186
- "name": "InProcess",
187
- "value": "inprocess",
188
- "data": 0,
189
- "index": 2
190
- }, {
191
- "name": "Pending",
192
- "value": "pending",
193
- "data": 0,
194
- "index": 3
195
- }]
196
- },
197
- theme: 'light',
198
- width: 400,
199
- height: 400,
200
- colorType: 'normal',
201
- type: 'donut'
149
+ data: {
150
+ "name": "Archieve",
151
+ "total": 0,
152
+ "values": [{
153
+ "name": "Archieved",
154
+ "value": "archieved",
155
+ "data": 0,
156
+ "index": 1
157
+ }, {
158
+ "name": "InProcess",
159
+ "value": "inprocess",
160
+ "data": 0,
161
+ "index": 2
162
+ }, {
163
+ "name": "Pending",
164
+ "value": "pending",
165
+ "data": 0,
166
+ "index": 3
167
+ }]
168
+ },
169
+ theme: 'light',
170
+ width: 400,
171
+ height: 400,
172
+ colorType: 'normal',
173
+ type: 'donut'
202
174
  };
203
-
204
- exports.default = PieChart;
175
+ var _default = exports["default"] = PieChart;