@pareto-engineering/design-system 5.0.0 → 5.0.2

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 (123) hide show
  1. package/dist/cjs/a/{AreaChart → Charts/AreaChart}/AreaChart.js +89 -73
  2. package/dist/cjs/a/Charts/AreaChart/styles.scss +48 -0
  3. package/dist/cjs/a/Charts/BarChart/BarChart.js +137 -0
  4. package/dist/cjs/a/Charts/BarChart/index.js +13 -0
  5. package/dist/cjs/a/Charts/BarChart/styles.scss +48 -0
  6. package/dist/cjs/a/Charts/Common/CustomLegend/CustomLegend.js +88 -0
  7. package/dist/cjs/a/Charts/Common/CustomLegend/index.js +13 -0
  8. package/dist/cjs/a/Charts/Common/CustomLegend/styles.scss +67 -0
  9. package/dist/cjs/a/Charts/Common/CustomTooltipContent/CustomTooltipContent.js +97 -0
  10. package/dist/cjs/a/Charts/Common/CustomTooltipContent/index.js +13 -0
  11. package/dist/cjs/a/Charts/Common/CustomTooltipContent/styles.scss +22 -0
  12. package/dist/cjs/a/Charts/Common/YLabelsDropDown/YlabelsDropDown.js +97 -0
  13. package/dist/cjs/a/Charts/Common/YLabelsDropDown/index.js +13 -0
  14. package/dist/cjs/a/Charts/Common/YLabelsDropDown/styles.scss +89 -0
  15. package/dist/cjs/a/Charts/Common/index.js +26 -0
  16. package/dist/cjs/a/Charts/PieChart/PieChart.js +99 -0
  17. package/dist/cjs/a/Charts/PieChart/index.js +13 -0
  18. package/dist/cjs/a/Charts/PieChart/styles.scss +48 -0
  19. package/dist/cjs/a/Charts/index.js +26 -0
  20. package/dist/cjs/a/Tooltip/styles.scss +1 -1
  21. package/dist/cjs/a/index.js +14 -2
  22. package/dist/cjs/f/FormInput/FormInput.js +6 -0
  23. package/dist/cjs/f/fields/FileUpload/FileUpload.js +18 -4
  24. package/dist/cjs/f/fields/LatexPreviewInput/LatexPreviewInput.js +78 -0
  25. package/dist/cjs/f/fields/LatexPreviewInput/convertLatexToHtml.js +46 -0
  26. package/dist/cjs/f/fields/LatexPreviewInput/index.js +20 -0
  27. package/dist/cjs/f/fields/LatexPreviewInput/styles.scss +24 -0
  28. package/dist/cjs/f/fields/index.js +13 -0
  29. package/dist/cjs/g/FormBuilder/FormBuilder.js +3 -6
  30. package/dist/cjs/g/FormBuilder/common/Builder/Builder.js +1 -3
  31. package/dist/cjs/g/FormBuilder/common/Builder/common/InputBuilder/InputBuilder.js +5 -7
  32. package/dist/cjs/g/FormBuilder/common/Builder/common/Section/Section.js +2 -4
  33. package/dist/cjs/g/FormBuilder/common/Renderer/Renderer.js +2 -4
  34. package/dist/cjs/g/FormBuilder/common/Renderer/common/Section/Section.js +2 -10
  35. package/dist/cjs/utils/formatting.js +119 -0
  36. package/dist/cjs/utils/index.js +26 -1
  37. package/dist/es/a/{AreaChart → Charts/AreaChart}/AreaChart.js +88 -69
  38. package/dist/es/a/Charts/AreaChart/styles.scss +48 -0
  39. package/dist/es/a/Charts/BarChart/BarChart.js +128 -0
  40. package/dist/es/a/Charts/BarChart/index.js +1 -0
  41. package/dist/es/a/Charts/BarChart/styles.scss +48 -0
  42. package/dist/es/a/Charts/Common/CustomLegend/CustomLegend.js +76 -0
  43. package/dist/es/a/Charts/Common/CustomLegend/index.js +1 -0
  44. package/dist/es/a/Charts/Common/CustomLegend/styles.scss +67 -0
  45. package/dist/es/a/Charts/Common/CustomTooltipContent/CustomTooltipContent.js +87 -0
  46. package/dist/es/a/Charts/Common/CustomTooltipContent/index.js +1 -0
  47. package/dist/es/a/Charts/Common/CustomTooltipContent/styles.scss +22 -0
  48. package/dist/es/a/Charts/Common/YLabelsDropDown/YlabelsDropDown.js +86 -0
  49. package/dist/es/a/Charts/Common/YLabelsDropDown/index.js +1 -0
  50. package/dist/es/a/Charts/Common/YLabelsDropDown/styles.scss +89 -0
  51. package/dist/es/a/Charts/Common/index.js +3 -0
  52. package/dist/es/a/Charts/PieChart/PieChart.js +89 -0
  53. package/dist/es/a/Charts/PieChart/index.js +1 -0
  54. package/dist/es/a/Charts/PieChart/styles.scss +48 -0
  55. package/dist/es/a/Charts/index.js +3 -0
  56. package/dist/es/a/Tooltip/styles.scss +1 -1
  57. package/dist/es/a/index.js +1 -1
  58. package/dist/es/f/FormInput/FormInput.js +7 -1
  59. package/dist/es/f/fields/FileUpload/FileUpload.js +18 -4
  60. package/dist/es/f/fields/LatexPreviewInput/LatexPreviewInput.js +70 -0
  61. package/dist/es/f/fields/LatexPreviewInput/convertLatexToHtml.js +31 -0
  62. package/dist/es/f/fields/LatexPreviewInput/index.js +3 -0
  63. package/dist/es/f/fields/LatexPreviewInput/styles.scss +24 -0
  64. package/dist/es/f/fields/index.js +1 -0
  65. package/dist/es/g/FormBuilder/FormBuilder.js +3 -6
  66. package/dist/es/g/FormBuilder/common/Builder/Builder.js +1 -3
  67. package/dist/es/g/FormBuilder/common/Builder/common/InputBuilder/InputBuilder.js +5 -7
  68. package/dist/es/g/FormBuilder/common/Builder/common/Section/Section.js +2 -4
  69. package/dist/es/g/FormBuilder/common/Renderer/Renderer.js +2 -4
  70. package/dist/es/g/FormBuilder/common/Renderer/common/Section/Section.js +32 -42
  71. package/dist/es/utils/formatting.js +109 -0
  72. package/dist/es/utils/index.js +2 -1
  73. package/jest.config.js +3 -0
  74. package/package.json +7 -3
  75. package/src/stories/a/AreaChart.stories.jsx +1 -1
  76. package/src/stories/a/BarChart.stories.jsx +89 -0
  77. package/src/stories/a/PieChart.stories.jsx +53 -0
  78. package/src/ui/a/{AreaChart → Charts/AreaChart}/AreaChart.jsx +114 -65
  79. package/src/ui/a/Charts/AreaChart/styles.scss +48 -0
  80. package/src/ui/a/Charts/BarChart/BarChart.jsx +167 -0
  81. package/src/ui/a/Charts/BarChart/index.js +1 -0
  82. package/src/ui/a/Charts/BarChart/styles.scss +48 -0
  83. package/src/ui/a/Charts/Common/CustomLegend/CustomLegend.jsx +109 -0
  84. package/src/ui/a/Charts/Common/CustomLegend/index.js +1 -0
  85. package/src/ui/a/Charts/Common/CustomLegend/styles.scss +67 -0
  86. package/src/ui/a/Charts/Common/CustomTooltipContent/CustomTooltipContent.jsx +117 -0
  87. package/src/ui/a/Charts/Common/CustomTooltipContent/index.js +1 -0
  88. package/src/ui/a/Charts/Common/CustomTooltipContent/styles.scss +22 -0
  89. package/src/ui/a/Charts/Common/YLabelsDropDown/YlabelsDropDown.jsx +121 -0
  90. package/src/ui/a/Charts/Common/YLabelsDropDown/index.js +1 -0
  91. package/src/ui/a/Charts/Common/YLabelsDropDown/styles.scss +89 -0
  92. package/src/ui/a/Charts/Common/index.js +3 -0
  93. package/src/ui/a/Charts/PieChart/PieChart.jsx +125 -0
  94. package/src/ui/a/Charts/PieChart/index.js +1 -0
  95. package/src/ui/a/Charts/PieChart/styles.scss +48 -0
  96. package/src/ui/a/Charts/index.js +3 -0
  97. package/src/ui/a/Tooltip/styles.scss +1 -1
  98. package/src/ui/a/index.js +1 -1
  99. package/src/ui/f/FormInput/FormInput.jsx +11 -0
  100. package/src/ui/f/fields/FileUpload/FileUpload.jsx +24 -4
  101. package/src/ui/f/fields/LatexPreviewInput/LatexPreviewInput.jsx +91 -0
  102. package/src/ui/f/fields/LatexPreviewInput/convertLatexToHtml.jsx +38 -0
  103. package/src/ui/f/fields/LatexPreviewInput/index.js +3 -0
  104. package/src/ui/f/fields/LatexPreviewInput/styles.scss +24 -0
  105. package/src/ui/f/fields/index.js +4 -0
  106. package/src/ui/g/FormBuilder/FormBuilder.jsx +0 -3
  107. package/src/ui/g/FormBuilder/common/Builder/Builder.jsx +0 -2
  108. package/src/ui/g/FormBuilder/common/Builder/common/InputBuilder/InputBuilder.jsx +4 -7
  109. package/src/ui/g/FormBuilder/common/Builder/common/Section/Section.jsx +0 -2
  110. package/src/ui/g/FormBuilder/common/Renderer/Renderer.jsx +0 -2
  111. package/src/ui/g/FormBuilder/common/Renderer/common/Section/Section.jsx +49 -64
  112. package/src/ui/utils/formatting.js +133 -0
  113. package/src/ui/utils/index.js +3 -0
  114. package/tests/__snapshots__/Storyshots.test.js.snap +2227 -296
  115. package/tests/emptyMock.js +3 -0
  116. package/tests/mockTextEncoder.js +7 -0
  117. package/tests/test-setup.js +7 -0
  118. package/dist/cjs/a/AreaChart/styles.scss +0 -89
  119. package/dist/es/a/AreaChart/styles.scss +0 -89
  120. package/src/ui/a/AreaChart/styles.scss +0 -89
  121. /package/dist/cjs/a/{AreaChart → Charts/AreaChart}/index.js +0 -0
  122. /package/dist/es/a/{AreaChart → Charts/AreaChart}/index.js +0 -0
  123. /package/src/ui/a/{AreaChart → Charts/AreaChart}/index.js +0 -0
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var React = _react;
9
+ var _propTypes = _interopRequireDefault(require("prop-types"));
10
+ var _exports = _interopRequireDefault(require("@pareto-engineering/bem/exports"));
11
+ var _formik = require("formik");
12
+ var _convertLatexToHtml = _interopRequireDefault(require("./convertLatexToHtml"));
13
+ var _TextareaInput = require("../TextareaInput");
14
+ require("./styles.scss");
15
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
17
+ 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; }
18
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } /* @pareto-engineering/generator-front 1.0.12 */
19
+ // Local Definitions
20
+
21
+ const baseClassName = _exports.default.base;
22
+ const componentClassName = 'latex-preview-input';
23
+
24
+ /**
25
+ * This is the component description.
26
+ */
27
+ const LatexPreviewInput = _ref => {
28
+ let {
29
+ id,
30
+ className,
31
+ userClassName,
32
+ disabled,
33
+ style,
34
+ ...otherProps
35
+ } = _ref;
36
+ const {
37
+ name
38
+ } = otherProps;
39
+ const {
40
+ values
41
+ } = (0, _formik.useFormikContext)();
42
+ const LatexPreview = (0, _react.useMemo)(() => (0, _convertLatexToHtml.default)(values[name]), [values[name]]);
43
+ return /*#__PURE__*/React.createElement("div", {
44
+ id: id,
45
+ className: [baseClassName, componentClassName, userClassName, 'form-input'].filter(e => e).join(' '),
46
+ style: style
47
+ }, /*#__PURE__*/React.createElement(_TextareaInput.TextareaInput, _extends({
48
+ className: "preview-child",
49
+ disabled: disabled
50
+ }, otherProps)), /*#__PURE__*/React.createElement("div", {
51
+ className: "latex-container preview-child",
52
+ dangerouslySetInnerHTML: {
53
+ __html: LatexPreview
54
+ }
55
+ }));
56
+ };
57
+ LatexPreviewInput.propTypes = {
58
+ /**
59
+ * The HTML id for this element
60
+ */
61
+ id: _propTypes.default.string,
62
+ /**
63
+ * The HTML class names for this element
64
+ */
65
+ className: _propTypes.default.string,
66
+ /**
67
+ * The React-written, css properties for this element.
68
+ */
69
+ style: _propTypes.default.objectOf(_propTypes.default.string),
70
+ /**
71
+ * Whether the Form input input should be disabled
72
+ */
73
+ disabled: _propTypes.default.bool
74
+ };
75
+ LatexPreviewInput.defaultProps = {
76
+ disabled: false
77
+ };
78
+ var _default = exports.default = /*#__PURE__*/(0, _react.memo)(LatexPreviewInput);
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var React = _interopRequireWildcard(require("react"));
8
+ var _reactMarkdown = _interopRequireDefault(require("react-markdown"));
9
+ var _remarkMath = _interopRequireDefault(require("remark-math"));
10
+ var _betterReactMathjax = require("better-react-mathjax");
11
+ var _svg = _interopRequireDefault(require("rehype-mathjax/svg"));
12
+ var _server = _interopRequireDefault(require("react-dom/server"));
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
+ 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; }
16
+ const convertLatexToHtml = content => {
17
+ if (content.includes('https://forte-assets.pareto.ai/')) {
18
+ return content;
19
+ }
20
+ const processedContent = content.replaceAll(/\\\\/g, '\n\n');
21
+ const renderedContent = _server.default.renderToString(/*#__PURE__*/React.createElement(_betterReactMathjax.MathJaxContext, null, /*#__PURE__*/React.createElement(_reactMarkdown.default, {
22
+ remarkPlugins: [_remarkMath.default],
23
+ rehypePlugins: [_svg.default],
24
+ components: {
25
+ math: _ref => {
26
+ let {
27
+ value
28
+ } = _ref;
29
+ return /*#__PURE__*/React.createElement(_betterReactMathjax.MathJax.Node, {
30
+ formula: value
31
+ });
32
+ },
33
+ inlineMath: _ref2 => {
34
+ let {
35
+ value
36
+ } = _ref2;
37
+ return /*#__PURE__*/React.createElement(_betterReactMathjax.MathJax.Node, {
38
+ inline: true,
39
+ formula: value
40
+ });
41
+ }
42
+ }
43
+ }, processedContent)));
44
+ return renderedContent;
45
+ };
46
+ var _default = exports.default = convertLatexToHtml;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "LatexPreviewInput", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _LatexPreviewInput.default;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "convertLatexToHtml", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _convertLatexToHtml.default;
16
+ }
17
+ });
18
+ var _LatexPreviewInput = _interopRequireDefault(require("./LatexPreviewInput"));
19
+ var _convertLatexToHtml = _interopRequireDefault(require("./convertLatexToHtml"));
20
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -0,0 +1,24 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+
3
+ @use "@pareto-engineering/bem";
4
+
5
+ $default-margin: 1em;
6
+
7
+ .#{bem.$base}.latex-preview-input {
8
+ display: flex;
9
+ flex-direction: row;
10
+ gap: $default-margin;
11
+
12
+ > .preview-child {
13
+ flex: 1;
14
+ }
15
+
16
+ > .latex-container {
17
+ border: 1px solid var(--ui-lines);
18
+ border-radius: var(--theme-default-border-radius);
19
+ margin-top: calc($default-margin * 2.5);
20
+ max-width: 50%;
21
+ overflow: auto;
22
+ padding: 0 $default-margin;
23
+ }
24
+ }
@@ -27,6 +27,12 @@ Object.defineProperty(exports, "FileUpload", {
27
27
  return _FileUpload.FileUpload;
28
28
  }
29
29
  });
30
+ Object.defineProperty(exports, "LatexPreviewInput", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _LatexPreviewInput.LatexPreviewInput;
34
+ }
35
+ });
30
36
  Object.defineProperty(exports, "LinkInput", {
31
37
  enumerable: true,
32
38
  get: function () {
@@ -75,6 +81,12 @@ Object.defineProperty(exports, "TextareaInput", {
75
81
  return _TextareaInput.TextareaInput;
76
82
  }
77
83
  });
84
+ Object.defineProperty(exports, "convertLatexToHtml", {
85
+ enumerable: true,
86
+ get: function () {
87
+ return _LatexPreviewInput.convertLatexToHtml;
88
+ }
89
+ });
78
90
  Object.defineProperty(exports, "fileUploadOptions", {
79
91
  enumerable: true,
80
92
  get: function () {
@@ -104,4 +116,5 @@ var _Checkbox = require("./Checkbox");
104
116
  var _QueryChoices = require("./QueryChoices");
105
117
  var _LinkInput = require("./LinkInput");
106
118
  var _EditorInput = require("./EditorInput");
119
+ var _LatexPreviewInput = require("./LatexPreviewInput");
107
120
  var _FileUpload = require("./FileUpload");
@@ -40,8 +40,7 @@ const FormBuilder = _ref => {
40
40
  initialBuilderValues,
41
41
  fileUploadStatus,
42
42
  handleFileDelete,
43
- taskData,
44
- customInputMap
43
+ taskData
45
44
  // ...otherProps
46
45
  } = _ref;
47
46
  const formattedJson = JSON.stringify(taskData, null, 2);
@@ -57,8 +56,7 @@ const FormBuilder = _ref => {
57
56
  formBuilderId: formBuilderId,
58
57
  onSave: onBuilderFormSave,
59
58
  onError: onBuilderError,
60
- validate: onBuilderValidate,
61
- customInputMap: customInputMap
59
+ validate: onBuilderValidate
62
60
  }), mode === 'render' && /*#__PURE__*/React.createElement(_common.Renderer, {
63
61
  formData: formData,
64
62
  onSave: onRendererFormSave,
@@ -66,8 +64,7 @@ const FormBuilder = _ref => {
66
64
  shouldSubmit: shouldSubmit,
67
65
  fileUploadStatus: fileUploadStatus,
68
66
  handleFileDelete: handleFileDelete,
69
- onFileUpload: onFileUpload,
70
- customInputMap: customInputMap
67
+ onFileUpload: onFileUpload
71
68
  }));
72
69
  };
73
70
  FormBuilder.propTypes = {
@@ -42,7 +42,6 @@ const Builder = _ref => {
42
42
  onError,
43
43
  validate,
44
44
  formBuilderId,
45
- customInputMap,
46
45
  initialValues = {}
47
46
  // ...otherProps
48
47
  } = _ref;
@@ -121,8 +120,7 @@ const Builder = _ref => {
121
120
  remove,
122
121
  values,
123
122
  setFieldValue
124
- }),
125
- customInputMap: customInputMap
123
+ })
126
124
  })), /*#__PURE__*/React.createElement("div", {
127
125
  className: "section-footer"
128
126
  }, /*#__PURE__*/React.createElement("button", {
@@ -36,8 +36,7 @@ const InputBuilder = _ref => {
36
36
  style,
37
37
  sectionIndex,
38
38
  inputIndex,
39
- onDelete,
40
- customInputMap
39
+ onDelete
41
40
  // ...otherProps
42
41
  } = _ref;
43
42
  const {
@@ -64,7 +63,6 @@ const InputBuilder = _ref => {
64
63
  const handleToggleShowSpecificFileTypes = () => {
65
64
  setFieldValue(`sections.${sectionIndex}.inputs.${inputIndex}.showSpecificFileTypes`, !input.showSpecificFileTypes);
66
65
  };
67
- const customInputTypes = customInputMap ? Object.keys(customInputMap) : [];
68
66
  return /*#__PURE__*/React.createElement("div", {
69
67
  id: id,
70
68
  className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
@@ -104,10 +102,10 @@ const InputBuilder = _ref => {
104
102
  }, {
105
103
  value: 'file',
106
104
  label: 'File upload'
107
- }, ...(customInputTypes && customInputTypes.map(customInputKey => ({
108
- value: customInputKey,
109
- label: customInputMap[customInputKey].label
110
- })))]
105
+ }, {
106
+ value: 'latex-preview-input',
107
+ label: 'Textbox with LaTeX preview'
108
+ }]
111
109
  }), /*#__PURE__*/React.createElement("div", {
112
110
  className: "controls"
113
111
  }, /*#__PURE__*/React.createElement("button", {
@@ -33,8 +33,7 @@ const Section = _ref => {
33
33
  className: userClassName,
34
34
  style,
35
35
  index,
36
- handleDeleteSection,
37
- customInputMap
36
+ handleDeleteSection
38
37
  // ...otherProps
39
38
  } = _ref;
40
39
  const {
@@ -66,8 +65,7 @@ const Section = _ref => {
66
65
  sectionIndex: index,
67
66
  inputIndex: indx,
68
67
  onDelete: handleDeleteInput,
69
- onCopy: handleCopyInput,
70
- customInputMap: customInputMap
68
+ onCopy: handleCopyInput
71
69
  }),
72
70
  identifier: input.name
73
71
  }));
@@ -71,8 +71,7 @@ const Renderer = _ref => {
71
71
  fileUploadStatus,
72
72
  handleFileDelete,
73
73
  onFileUpload,
74
- shouldUpdateInputStateInRealTime = true,
75
- customInputMap
74
+ shouldUpdateInputStateInRealTime = true
76
75
  // ...otherProps
77
76
  } = _ref;
78
77
  const [currentSectionIndex, setCurrentSectionIndex] = (0, _react.useState)(0);
@@ -150,8 +149,7 @@ const Renderer = _ref => {
150
149
  fileUploadStatus: fileUploadStatus,
151
150
  handleFileDelete: handleFileDelete,
152
151
  onFileUpload: onFileUpload,
153
- sectionIndex: sectionIndex,
154
- customInputMap: customInputMap
152
+ sectionIndex: sectionIndex
155
153
  }))), /*#__PURE__*/React.createElement("div", {
156
154
  className: "navigator-container"
157
155
  }, updatedFormData.sections.length > 1 && /*#__PURE__*/React.createElement(_b.Button, {
@@ -39,11 +39,9 @@ const Section = _ref => {
39
39
  fileUploadStatus,
40
40
  handleFileDelete,
41
41
  onFileUpload,
42
- sectionIndex,
43
- customInputMap
42
+ sectionIndex
44
43
  // ...otherProps
45
44
  } = _ref;
46
- const customInputTypes = customInputMap ? Object.keys(customInputMap) : [];
47
45
  return /*#__PURE__*/React.createElement("div", {
48
46
  id: id,
49
47
  className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
@@ -55,9 +53,7 @@ const Section = _ref => {
55
53
  name: "instructions"
56
54
  }), inputs?.map((input, inputIndex) => {
57
55
  const isFileInput = input.type === 'file';
58
- const isCustomInput = customInputTypes.includes(input.type);
59
- const CustomInputComponent = isCustomInput ? customInputMap[input.type].component : null;
60
- return !isCustomInput ? /*#__PURE__*/React.createElement(_f.FormInput, _extends({
56
+ return /*#__PURE__*/React.createElement(_f.FormInput, _extends({
61
57
  key: input.name
62
58
  }, input, {
63
59
  disabled: readOnly
@@ -76,10 +72,6 @@ const Section = _ref => {
76
72
  }));
77
73
  onFileUpload(filesToUpload);
78
74
  }
79
- })) : /*#__PURE__*/React.createElement(CustomInputComponent, _extends({
80
- key: input.name
81
- }, input, {
82
- disabled: readOnly
83
75
  }));
84
76
  }));
85
77
  };
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.snakeCaseToTitleCase = exports.formatTime = exports.formatDate = exports.DATE_FORMATS = void 0;
7
+ const DATE_FORMATS = exports.DATE_FORMATS = {
8
+ HUMAN_READABLE: 'human_readable',
9
+ TIME: 'time',
10
+ DATETIME: 'datetime',
11
+ CHART_DATE: 'chart_date',
12
+ CHART_TIME: 'chart_time',
13
+ WEEKDAY_DATE: 'weekday_date',
14
+ DAY_VIEW: 'day_view'
15
+ };
16
+ const isValidDate = date => date instanceof Date && !Number.isNaN(date);
17
+ const isTimeSliceFormat = input => {
18
+ const timeSliceRegex = /^([01]?[0-9]|2[0-3]):[0-5][0-9]$/;
19
+ return timeSliceRegex.test(input);
20
+ };
21
+ const createTimeFromSlice = timeSlice => {
22
+ const [hours, minutes] = timeSlice.split(':').map(Number);
23
+ const date = new Date();
24
+ date.setHours(hours, minutes, 0, 0);
25
+ return date;
26
+ };
27
+ const format12Hour = date => {
28
+ const hour = date.getHours();
29
+ const ampm = hour >= 12 ? 'PM' : 'AM';
30
+ const hour12 = hour % 12 || 12;
31
+ return `${hour12} ${ampm}`;
32
+ };
33
+ const shouldShowYear = date => {
34
+ const currentYear = new Date().getFullYear();
35
+ return date.getFullYear() !== currentYear;
36
+ };
37
+ const formatTime = seconds => {
38
+ if (!seconds) return '0s';
39
+ const hours = Math.floor(seconds / 3600);
40
+ const minutes = Math.floor(seconds % 3600 / 60);
41
+ const remainingSeconds = Math.floor(seconds % 60);
42
+ const parts = [];
43
+ if (hours > 0) parts.push(`${hours}h`);
44
+ if (minutes > 0 || hours > 0 && remainingSeconds > 0) parts.push(`${minutes}m`);
45
+ if (remainingSeconds > 0) parts.push(`${remainingSeconds}s`);
46
+
47
+ // Cater for decimal seconds
48
+ if (parts.length === 0) return '0s';
49
+ return parts.join(' ');
50
+ };
51
+ exports.formatTime = formatTime;
52
+ const parseDate = input => {
53
+ if (input instanceof Date) return input;
54
+ if (typeof input === 'number') return new Date(input);
55
+ if (typeof input === 'string') {
56
+ if (isTimeSliceFormat(input)) {
57
+ return createTimeFromSlice(input);
58
+ }
59
+ const parsed = new Date(input);
60
+ if (isValidDate(parsed)) return parsed;
61
+ const timestamp = parseInt(input, 10);
62
+ if (!Number.isNaN(timestamp)) {
63
+ const date = new Date(timestamp * 1000);
64
+ if (isValidDate(date)) return date;
65
+ }
66
+ }
67
+ return null;
68
+ };
69
+ const formatStrategies = {
70
+ [DATE_FORMATS.CHART_DATE]: date => {
71
+ const monthDay = date.toLocaleDateString('en-US', {
72
+ month: 'short',
73
+ day: 'numeric',
74
+ timeZone: 'UTC'
75
+ });
76
+ return shouldShowYear(date) ? `${monthDay} ${date.getFullYear()}` : monthDay;
77
+ },
78
+ [DATE_FORMATS.CHART_TIME]: date => format12Hour(date),
79
+ [DATE_FORMATS.HUMAN_READABLE]: date => date.toLocaleDateString('en-US', {
80
+ year: 'numeric',
81
+ month: 'short',
82
+ day: 'numeric',
83
+ timeZone: 'UTC'
84
+ }),
85
+ default: date => date.toISOString()
86
+ };
87
+ const formatDate = function (input) {
88
+ let format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DATE_FORMATS.HUMAN_READABLE;
89
+ try {
90
+ if (typeof input === 'string' && isTimeSliceFormat(input)) {
91
+ if (format === DATE_FORMATS.CHART_TIME || format === DATE_FORMATS.TIME) {
92
+ const date = createTimeFromSlice(input);
93
+ if (format === DATE_FORMATS.CHART_TIME) {
94
+ return format12Hour(date);
95
+ }
96
+ return date.toLocaleTimeString('en-US', {
97
+ hour: '2-digit',
98
+ minute: '2-digit',
99
+ timeZone: 'UTC'
100
+ });
101
+ }
102
+ return input;
103
+ }
104
+ const date = parseDate(input);
105
+ if (!date && (typeof input === 'string' || typeof input === 'number')) {
106
+ return input.toString();
107
+ }
108
+ const formatStrategy = formatStrategies[format] || formatStrategies.default;
109
+ return formatStrategy(date);
110
+ } catch (error) {
111
+ return 'Invalid Date';
112
+ }
113
+ };
114
+ exports.formatDate = formatDate;
115
+ const snakeCaseToTitleCase = word => {
116
+ const result = word.replace(/([A-Z])/g, ' $1');
117
+ return result.charAt(0).toUpperCase() + result.slice(1);
118
+ };
119
+ exports.snakeCaseToTitleCase = snakeCaseToTitleCase;
@@ -3,6 +3,30 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ Object.defineProperty(exports, "DATE_FORMATS", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _formatting.DATE_FORMATS;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "formatDate", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _formatting.formatDate;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "formatTime", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _formatting.formatTime;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "snakeCaseToTitleCase", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _formatting.snakeCaseToTitleCase;
28
+ }
29
+ });
6
30
  Object.defineProperty(exports, "useDynamicPosition", {
7
31
  enumerable: true,
8
32
  get: function () {
@@ -21,4 +45,5 @@ Object.defineProperty(exports, "useWindowSize", {
21
45
  return _hooks.useWindowSize;
22
46
  }
23
47
  });
24
- var _hooks = require("./hooks");
48
+ var _hooks = require("./hooks");
49
+ var _formatting = require("./formatting");