@widergy/energy-ui 3.123.1 → 3.124.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 (26) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/components/UTActionCard/components/Header/index.js +1 -1
  3. package/dist/components/UTLabel/README.md +7 -2
  4. package/dist/components/UTLabel/UTLabel.stories.js +13 -0
  5. package/dist/components/UTLabel/components/Markdown/components/BlockQuote/index.js +48 -0
  6. package/dist/components/UTLabel/components/Markdown/components/BlockQuote/styles.module.scss +16 -0
  7. package/dist/components/UTLabel/components/Markdown/components/Citation/index.js +28 -0
  8. package/dist/components/UTLabel/components/Markdown/components/CitationGroup/index.js +25 -0
  9. package/dist/components/UTLabel/components/Markdown/components/CitationGroup/styles.module.scss +22 -0
  10. package/dist/components/UTLabel/components/Markdown/components/Links/constants.js +8 -0
  11. package/dist/components/UTLabel/components/Markdown/components/Links/index.js +46 -0
  12. package/dist/components/UTLabel/components/Markdown/components/Links/styles.module.scss +3 -0
  13. package/dist/components/UTLabel/components/Markdown/components/ListItem/index.js +53 -0
  14. package/dist/components/UTLabel/components/Markdown/components/ListItem/styles.module.scss +22 -0
  15. package/dist/components/UTLabel/components/Markdown/components/Section/index.js +59 -0
  16. package/dist/components/UTLabel/components/Markdown/components/Section/styles.module.scss +13 -0
  17. package/dist/components/UTLabel/components/Markdown/components/WithCustomHandler/index.js +25 -0
  18. package/dist/components/UTLabel/components/Markdown/constants.js +66 -0
  19. package/dist/components/UTLabel/components/Markdown/customPlugins/remarkCitations.js +189 -0
  20. package/dist/components/UTLabel/components/Markdown/customPlugins/remarkDeflist.js +94 -0
  21. package/dist/components/UTLabel/components/Markdown/index.js +41 -0
  22. package/dist/components/UTLabel/components/Markdown/utils.js +39 -0
  23. package/dist/components/UTLabel/constants.js +3 -17
  24. package/dist/components/UTLabel/index.js +10 -15
  25. package/dist/components/UTLabel/theme.js +153 -3
  26. package/package.json +4 -2
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [3.124.0](https://github.com/widergy/energy-ui/compare/v3.123.1...v3.124.0) (2025-12-09)
2
+
3
+
4
+ ### Features
5
+
6
+ * [PDI-501] UTLabel markdown plugins ([#727](https://github.com/widergy/energy-ui/issues/727)) ([2aa6e9a](https://github.com/widergy/energy-ui/commit/2aa6e9af166284ee63469b1766cdc88eb53b5c10))
7
+
1
8
  ## [3.123.1](https://github.com/widergy/energy-ui/compare/v3.123.0...v3.123.1) (2025-12-09)
2
9
 
3
10
 
@@ -82,7 +82,7 @@ Header.propTypes = {
82
82
  }),
83
83
  variant: (0, _propTypes.oneOf)([_constants.HEADER_ACTIONS_VARIANTS.DEFAULT, _constants.HEADER_ACTIONS_VARIANTS.BUTTON_GROUP])
84
84
  }),
85
- setMainActionHoverVisible: _propTypes.string,
85
+ setMainActionHoverVisible: _propTypes.func,
86
86
  size: (0, _propTypes.oneOf)([_constants.SIZES.MEDIUM, _constants.SIZES.SMALL]),
87
87
  status: _propTypes.string,
88
88
  statusAlignment: (0, _propTypes.oneOf)([_constants.PLACE_SELF_TYPES.CENTER, _constants.PLACE_SELF_TYPES.END, _constants.PLACE_SELF_TYPES.START]),
@@ -11,10 +11,11 @@ Component used for displaying text values and markdown.
11
11
  | className | string | | Additional classes. |
12
12
  | classes | string | | Classes returned by UTLabel's own[theme](./theme.js#L40) `retrieveStyle`. |
13
13
  | colorTheme | string | 'primary' | Color theme to style the UTLabel. Has to be defined in the proyect theme.[Example](#colortheme). |
14
+ | markdownExtended | bool | false | ⚠️ Requires`withMarkdown` to be set to `true` <br />Activates all markdown plugins for extended markdown support. |
14
15
  | markdownRenderers | object | [MARKDOWN_RENDERERS](./constants.js#L36) | ⚠️ Requires`withMarkdown` to be set to `true` <br />Object mapping tag names to React components. The keys in components are HTML equivalents for the things you write with markdown [List of tags](#markdown-renderers). |
15
16
  | title | string | | [Title global attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/title). |
16
- | variant | string | 'body' | Defines html component to use. For a list of available variants, check[here](#variants). Font sizes can be overwritten (⚠️ for the entire proyect) through the proyect's theme. |
17
- | weight | string | 'regular' | Defines font-weight to be used. For a list of available options, check[here](#font-weights). |
17
+ | variant | string | 'body' | Defines html component to use. For a list of available variants, check [here](#variants). Font sizes can be overwritten (⚠️ for the entire proyect) through the proyect's theme. |
18
+ | weight | string | 'regular' | Defines font-weight to be used. For a list of available options, check [here](#font-weights). |
18
19
  | withMarkdown | bool | false | Tells the component whether or not to render text inside as markdown. |
19
20
 
20
21
  ## Examples
@@ -80,6 +81,10 @@ const markdownRenderers = {
80
81
 
81
82
  <details>
82
83
  <summary>Show list of props for each component</summary>
84
+
85
+ **Custom Handler Behavior:**
86
+ If an element already has internal handling within UTLabel (such as `a`, `blockquote`, `h2`, etc.) and you pass a `customHandler` that returns `null`, the component will use its default internal behavior. This allows you to selectively override rendering for specific cases while falling back to the built-in logic when needed.
87
+
83
88
  The keys in components are HTML equivalents for the things you write with
84
89
  markdown (such as `h1` for `# heading`)**†**
85
90
 
@@ -52,6 +52,18 @@ var _default = exports.default = {
52
52
  }
53
53
  }
54
54
  },
55
+ markdownExtended: {
56
+ control: 'boolean',
57
+ description: 'Habilita todos los plugins de markdown',
58
+ table: {
59
+ defaultValue: {
60
+ summary: _constants.DEFAULT_PROPS.markdownExtended
61
+ },
62
+ type: {
63
+ summary: 'bool'
64
+ }
65
+ }
66
+ },
55
67
  markdownRenderers: {
56
68
  control: false,
57
69
  description: 'Mapper de componentes HTML a componentes react. Para más detalles revisar la sección Markdown Renderers',
@@ -132,6 +144,7 @@ var _default = exports.default = {
132
144
  const Default = exports.Default = {
133
145
  args: {
134
146
  colorTheme: _constants.DEFAULT_PROPS.colorTheme,
147
+ markdownExtended: _constants.DEFAULT_PROPS.markdownExtended,
135
148
  variant: _constants.DEFAULT_PROPS.variant,
136
149
  weight: _constants.DEFAULT_PROPS.weight,
137
150
  withMarkdown: _constants.DEFAULT_PROPS.withMarkdown,
@@ -0,0 +1,48 @@
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 _propTypes = require("prop-types");
9
+ var _WithCustomHandler = _interopRequireDefault(require("../WithCustomHandler"));
10
+ var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
13
+ const BlockQuote = _ref => {
14
+ let {
15
+ children,
16
+ classes
17
+ } = _ref;
18
+ const lines = [];
19
+ if (Array.isArray(children)) {
20
+ children.forEach(child => {
21
+ var _child$props;
22
+ if (typeof child === 'string') {
23
+ const parts = child.split('\n').filter(line => line.trim());
24
+ lines.push(...parts);
25
+ } else if ((child === null || child === void 0 ? void 0 : child.type) === 'p' && child !== null && child !== void 0 && (_child$props = child.props) !== null && _child$props !== void 0 && _child$props.children) {
26
+ const pChildren = child.props.children;
27
+ if (Array.isArray(pChildren)) {
28
+ pChildren.forEach(pChild => {
29
+ if (typeof pChild === 'string' && pChild.trim()) {
30
+ lines.push(pChild.trim());
31
+ }
32
+ });
33
+ } else if (typeof pChildren === 'string' && pChildren.trim()) {
34
+ lines.push(pChildren.trim());
35
+ }
36
+ }
37
+ });
38
+ }
39
+ return /*#__PURE__*/_react.default.createElement("div", {
40
+ className: "".concat(_stylesModule.default.blockquote, " ").concat(classes === null || classes === void 0 ? void 0 : classes.blockquote)
41
+ }, lines.map(line => /*#__PURE__*/_react.default.createElement("div", {
42
+ key: line
43
+ }, line)));
44
+ };
45
+ BlockQuote.propTypes = {
46
+ classes: (0, _propTypes.objectOf)(_propTypes.string)
47
+ };
48
+ var _default = exports.default = /*#__PURE__*/(0, _react.memo)((0, _WithCustomHandler.default)(BlockQuote));
@@ -0,0 +1,16 @@
1
+ .blockquote {
2
+ margin: 0 0 24px 0;
3
+ padding-left: 12px;
4
+ position: relative;
5
+ white-space: pre-line;
6
+
7
+ &:before {
8
+ border-radius: 3;
9
+ content: '';
10
+ display: block;
11
+ height: 100%;
12
+ left: 0;
13
+ position: absolute;
14
+ width: 2px;
15
+ }
16
+ }
@@ -0,0 +1,28 @@
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 _propTypes = require("prop-types");
9
+ var _UTButton = _interopRequireDefault(require("../../../../../UTButton"));
10
+ var _WithCustomHandler = _interopRequireDefault(require("../WithCustomHandler"));
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
13
+ const Citation = _ref => {
14
+ let {
15
+ label,
16
+ url
17
+ } = _ref;
18
+ return /*#__PURE__*/_react.default.createElement(_UTButton.default, {
19
+ colorTheme: "secondary",
20
+ onClick: () => window.open(url, '_blank', 'noopener,noreferrer'),
21
+ size: "small"
22
+ }, label);
23
+ };
24
+ Citation.propTypes = {
25
+ label: _propTypes.string,
26
+ url: _propTypes.string
27
+ };
28
+ var _default = exports.default = /*#__PURE__*/(0, _react.memo)((0, _WithCustomHandler.default)(Citation));
@@ -0,0 +1,25 @@
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 _propTypes = require("prop-types");
9
+ var _WithCustomHandler = _interopRequireDefault(require("../WithCustomHandler"));
10
+ var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
13
+ const CitationGroup = _ref => {
14
+ let {
15
+ children,
16
+ classes
17
+ } = _ref;
18
+ return /*#__PURE__*/_react.default.createElement("div", {
19
+ className: "".concat(_stylesModule.default.citationGroup, " ").concat(classes.citationGroup)
20
+ }, children);
21
+ };
22
+ CitationGroup.propTypes = {
23
+ classes: (0, _propTypes.objectOf)(_propTypes.string)
24
+ };
25
+ var _default = exports.default = /*#__PURE__*/(0, _react.memo)((0, _WithCustomHandler.default)(CitationGroup));
@@ -0,0 +1,22 @@
1
+ .citationGroup {
2
+ -webkit-overflow-scrolling: touch;
3
+ display: flex;
4
+ grid-gap: 8px;
5
+ overflow-x: auto;
6
+ overflow-y: hidden;
7
+ padding-bottom: 4px;
8
+ scroll-behavior: smooth;
9
+ scroll-snap-type: x mandatory;
10
+
11
+ button {
12
+ flex: 0 0 auto;
13
+ }
14
+
15
+ &::-webkit-scrollbar {
16
+ height: 8px;
17
+ }
18
+
19
+ &::-webkit-scrollbar * {
20
+ background-color: transparent;
21
+ }
22
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.DATA_FOOTNOTE_REF = exports.DATA_FOOTNOTE_BACKREF = void 0;
7
+ const DATA_FOOTNOTE_REF = exports.DATA_FOOTNOTE_REF = 'data-footnote-ref';
8
+ const DATA_FOOTNOTE_BACKREF = exports.DATA_FOOTNOTE_BACKREF = 'data-footnote-backref';
@@ -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 _propTypes = require("prop-types");
9
+ var _WithCustomHandler = _interopRequireDefault(require("../WithCustomHandler"));
10
+ var _constants = require("./constants");
11
+ var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
14
+ const Links = _ref => {
15
+ let {
16
+ [_constants.DATA_FOOTNOTE_REF]: dataFootnoteRef,
17
+ [_constants.DATA_FOOTNOTE_BACKREF]: dataFootnoteBackref,
18
+ children,
19
+ href,
20
+ id,
21
+ markdownExtended
22
+ } = _ref;
23
+ if (markdownExtended && dataFootnoteRef !== undefined) return /*#__PURE__*/_react.default.createElement("a", {
24
+ href: href,
25
+ id: id,
26
+ className: _stylesModule.default.isFootNoteRef
27
+ }, children);
28
+ if (markdownExtended && dataFootnoteBackref !== undefined) return /*#__PURE__*/_react.default.createElement("a", {
29
+ href: href,
30
+ id: id,
31
+ className: _stylesModule.default.isFootNoteRef
32
+ }, href.substring(20));
33
+ return /*#__PURE__*/_react.default.createElement("a", {
34
+ href: href,
35
+ rel: "noopener noreferrer",
36
+ target: "_blank"
37
+ }, children);
38
+ };
39
+ Links.propTypes = {
40
+ [_constants.DATA_FOOTNOTE_REF]: _propTypes.string,
41
+ [_constants.DATA_FOOTNOTE_BACKREF]: _propTypes.string,
42
+ href: _propTypes.string,
43
+ id: _propTypes.string,
44
+ markdownExtended: _propTypes.bool
45
+ };
46
+ var _default = exports.default = /*#__PURE__*/(0, _react.memo)((0, _WithCustomHandler.default)(Links));
@@ -0,0 +1,3 @@
1
+ .isFootNoteRef {
2
+ text-decoration: none !important;
3
+ }
@@ -0,0 +1,53 @@
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 _propTypes = require("prop-types");
9
+ var _UTIcon = _interopRequireDefault(require("../../../../../UTIcon"));
10
+ var _WithCustomHandler = _interopRequireDefault(require("../WithCustomHandler"));
11
+ var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
14
+ const ListItem = _ref => {
15
+ var _node$properties;
16
+ let {
17
+ children,
18
+ classes,
19
+ node,
20
+ ...props
21
+ } = _ref;
22
+ const classList = Array.isArray(node === null || node === void 0 || (_node$properties = node.properties) === null || _node$properties === void 0 ? void 0 : _node$properties.className) ? node.properties.className : [];
23
+ const isTaskListItem = classList.includes('task-list-item');
24
+ if (isTaskListItem) {
25
+ var _node$children, _checkbox$properties;
26
+ const checkbox = node === null || node === void 0 || (_node$children = node.children) === null || _node$children === void 0 ? void 0 : _node$children[0];
27
+ const isChecked = Boolean(checkbox === null || checkbox === void 0 || (_checkbox$properties = checkbox.properties) === null || _checkbox$properties === void 0 ? void 0 : _checkbox$properties.checked);
28
+ const contentNodes = Array.isArray(children) ? children.slice(1) : children;
29
+ return /*#__PURE__*/_react.default.createElement("li", {
30
+ className: _stylesModule.default.taskListItem
31
+ }, isChecked ? /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_UTIcon.default, {
32
+ area: true,
33
+ colorTheme: "success",
34
+ name: "IconCheck",
35
+ size: 16
36
+ }), /*#__PURE__*/_react.default.createElement("span", {
37
+ className: _stylesModule.default.itemContentChecked
38
+ }, contentNodes)) : /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("span", {
39
+ className: "".concat(_stylesModule.default.taskItemIconUnchecked, " ").concat(classes === null || classes === void 0 ? void 0 : classes.taskItemIconUnchecked)
40
+ }), /*#__PURE__*/_react.default.createElement("span", null, contentNodes)));
41
+ }
42
+ const safeChildren = Array.isArray(children) ? children : children ? [children] : [];
43
+ const mergedProps = {
44
+ ...props,
45
+ ...((node === null || node === void 0 ? void 0 : node.properties) || {})
46
+ };
47
+ return /*#__PURE__*/_react.default.createElement('li', mergedProps, safeChildren);
48
+ };
49
+ ListItem.propTypes = {
50
+ classes: (0, _propTypes.objectOf)(_propTypes.string),
51
+ node: _propTypes.object
52
+ };
53
+ var _default = exports.default = /*#__PURE__*/(0, _react.memo)((0, _WithCustomHandler.default)(ListItem));
@@ -0,0 +1,22 @@
1
+ .taskListItem {
2
+ align-items: center;
3
+ display: flex;
4
+ grid-gap: 8px;
5
+ list-style-type: none;
6
+ margin: 0;
7
+ }
8
+
9
+ .taskItemIconUnchecked {
10
+ border-radius: 50%;
11
+ border-style: solid;
12
+ border-width: 1px;
13
+ box-sizing: border-box;
14
+ display: inline-block;
15
+ flex-shrink: 0;
16
+ height: 20px;
17
+ width: 20px;
18
+ }
19
+
20
+ .itemContentChecked {
21
+ text-decoration: line-through;
22
+ }
@@ -0,0 +1,59 @@
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 _propTypes = require("prop-types");
9
+ var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
12
+ 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); }
13
+ const Section = _ref => {
14
+ var _node$properties;
15
+ let {
16
+ children,
17
+ classes,
18
+ node,
19
+ ...props
20
+ } = _ref;
21
+ const isFootnotesSection = (node === null || node === void 0 || (_node$properties = node.properties) === null || _node$properties === void 0 ? void 0 : _node$properties.dataFootnotes) !== undefined;
22
+ if (!isFootnotesSection) {
23
+ return /*#__PURE__*/_react.default.createElement('section', props, children);
24
+ }
25
+ const reactChildren = _react.default.Children.toArray(children);
26
+ const ol = reactChildren.find(c => (c === null || c === void 0 ? void 0 : c.type) === 'ol');
27
+ if (!ol) return /*#__PURE__*/_react.default.createElement("div", null);
28
+ const liNodes = _react.default.Children.toArray(ol.props.children).filter(c => {
29
+ var _c$props;
30
+ return (c === null || c === void 0 || (_c$props = c.props) === null || _c$props === void 0 || (_c$props = _c$props.node) === null || _c$props === void 0 ? void 0 : _c$props.tagName) === 'li';
31
+ });
32
+ return /*#__PURE__*/_react.default.createElement("div", {
33
+ className: "".concat(classes === null || classes === void 0 ? void 0 : classes.customFootnotes, " ").concat(_stylesModule.default.customFootnotes)
34
+ }, liNodes.map(li => {
35
+ const liChildren = _react.default.Children.toArray(li.props.children);
36
+ const p = liChildren.find(ch => (ch === null || ch === void 0 ? void 0 : ch.type) === 'p');
37
+ const sourceChildren = p ? _react.default.Children.toArray(p.props.children) : liChildren;
38
+ const textNodes = sourceChildren.filter(ch => typeof ch === 'string' || typeof ch === 'number');
39
+ const elementNodes = sourceChildren.filter(ch => !(typeof ch === 'string' || typeof ch === 'number'));
40
+ const textContent = textNodes.join('').trim();
41
+ return /*#__PURE__*/_react.default.createElement("div", {
42
+ className: _stylesModule.default.customFootnoteItem
43
+ }, /*#__PURE__*/_react.default.createElement("div", null, elementNodes.map(el => {
44
+ var _el$props;
45
+ if ((el === null || el === void 0 ? void 0 : el.type) === 'a' && typeof ((_el$props = el.props) === null || _el$props === void 0 ? void 0 : _el$props.href) === 'string') {
46
+ return /*#__PURE__*/_react.default.createElement("a", _extends({
47
+ href: el.props.href,
48
+ key: el.props.href
49
+ }, el.props || {}), el.props.children);
50
+ }
51
+ return /*#__PURE__*/_react.default.cloneElement(el);
52
+ })), textContent ? /*#__PURE__*/_react.default.createElement("span", null, textContent) : null);
53
+ }));
54
+ };
55
+ Section.propTypes = {
56
+ classes: (0, _propTypes.objectOf)(_propTypes.string),
57
+ node: _propTypes.object
58
+ };
59
+ var _default = exports.default = /*#__PURE__*/(0, _react.memo)(Section);
@@ -0,0 +1,13 @@
1
+ .customFootnotes {
2
+ margin: 0 0 24px 0;
3
+ }
4
+
5
+ .customFootnoteItem {
6
+ display: flex;
7
+
8
+ a {
9
+ font-size: 0.75em;
10
+ margin-right: 4px;
11
+ vertical-align: super;
12
+ }
13
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _propTypes = require("prop-types");
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ const WithCustomHandler = (Component, props) => {
11
+ const {
12
+ customHandler,
13
+ ...restProps
14
+ } = props;
15
+ if (customHandler) {
16
+ const CustomRenderer = customHandler(props);
17
+ if (CustomRenderer) return CustomRenderer;
18
+ }
19
+ return /*#__PURE__*/_react.default.createElement(Component, restProps);
20
+ };
21
+ WithCustomHandler.propTypes = {
22
+ customHandler: _propTypes.func
23
+ };
24
+ var _default = Component => props => WithCustomHandler(Component, props);
25
+ exports.default = _default;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.NODE_TYPES = exports.EXTENDED_CONFIG = exports.COMPONENTS_NAMES = exports.BASE_CONFIG = void 0;
7
+ var _remarkBreaks = _interopRequireDefault(require("remark-breaks"));
8
+ var _rehypeRaw = _interopRequireDefault(require("rehype-raw"));
9
+ var _remarkGfm = _interopRequireDefault(require("remark-gfm"));
10
+ var _BlockQuote = _interopRequireDefault(require("./components/BlockQuote"));
11
+ var _Citation = _interopRequireDefault(require("./components/Citation"));
12
+ var _CitationGroup = _interopRequireDefault(require("./components/CitationGroup"));
13
+ var _Links = _interopRequireDefault(require("./components/Links"));
14
+ var _ListItem = _interopRequireDefault(require("./components/ListItem"));
15
+ var _Section = _interopRequireDefault(require("./components/Section"));
16
+ var _remarkCitations = _interopRequireDefault(require("./customPlugins/remarkCitations"));
17
+ var _remarkDeflist = _interopRequireDefault(require("./customPlugins/remarkDeflist"));
18
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
19
+ const COMPONENTS_NAMES = exports.COMPONENTS_NAMES = {
20
+ BLOCKQUOTE: 'blockquote',
21
+ CITATION: 'citation',
22
+ CITATION_GROUP: 'citationgroup',
23
+ DEFINITION_LIST: 'dl',
24
+ DEFINITION_TERM: 'dt',
25
+ DEFINITION_DESCRIPTION: 'dd',
26
+ LINK: 'a',
27
+ LIST_ITEM: 'li',
28
+ HEADING_2: 'h2',
29
+ PARAGRAPH: 'p',
30
+ SECTION: 'section'
31
+ };
32
+ const NODE_TYPES = exports.NODE_TYPES = {
33
+ BLOCKQUOTE: 'blockquote',
34
+ CITATION: 'citation',
35
+ CITATION_GROUP: 'citationgroup',
36
+ DEFINITION_LIST: 'definitionList',
37
+ DEFINITION_TERM: 'definitionTerm',
38
+ DEFINITION_DESCRIPTION: 'definitionDescription',
39
+ HEADING: 'heading',
40
+ LINK: 'link',
41
+ LIST_ITEM: 'listItem',
42
+ PARAGRAPH: 'paragraph',
43
+ TABLE_CELL: 'tableCell',
44
+ TEXT: 'text'
45
+ };
46
+ const BASE_CONFIG = exports.BASE_CONFIG = {
47
+ disallowedElements: [COMPONENTS_NAMES.PARAGRAPH, COMPONENTS_NAMES.BLOCKQUOTE],
48
+ remarkPlugins: [_remarkBreaks.default],
49
+ rehypePlugins: [_rehypeRaw.default],
50
+ components: {
51
+ [COMPONENTS_NAMES.LINK]: _Links.default
52
+ }
53
+ };
54
+ const EXTENDED_CONFIG = exports.EXTENDED_CONFIG = {
55
+ disallowedElements: [],
56
+ remarkPlugins: [_remarkGfm.default, _remarkDeflist.default, _remarkCitations.default, _remarkBreaks.default],
57
+ rehypePlugins: [_rehypeRaw.default],
58
+ components: {
59
+ [COMPONENTS_NAMES.BLOCKQUOTE]: _BlockQuote.default,
60
+ [COMPONENTS_NAMES.CITATION]: _Citation.default,
61
+ [COMPONENTS_NAMES.CITATION_GROUP]: _CitationGroup.default,
62
+ [COMPONENTS_NAMES.LINK]: _Links.default,
63
+ [COMPONENTS_NAMES.LIST_ITEM]: _ListItem.default,
64
+ [COMPONENTS_NAMES.SECTION]: _Section.default
65
+ }
66
+ };
@@ -0,0 +1,189 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _unistUtilVisit = require("unist-util-visit");
8
+ var _constants = require("../constants");
9
+ /**
10
+ * Detecta el patrón de citas en un texto y lo convierte en componentes.
11
+ *
12
+ * Busca el patrón [Documento1.pdf†https://example.com/doc1.pdf] en el contenido.
13
+ * Si hay una sola cita, muestra un UTChip (componente Citation).
14
+ * Si hay múltiples citas, las renderiza dentro de un div contenedor (componente CitationGroup).
15
+ *
16
+ * @returns {Function} Función que procesa el árbol AST de remark
17
+ */
18
+ var _default = () => {
19
+ const pattern = /\[([^\]]+?)†(https?:\/\/[^\]]+?)\]/g;
20
+ return tree => {
21
+ (0, _unistUtilVisit.visit)(tree, node => {
22
+ const parentsToProcess = [_constants.NODE_TYPES.PARAGRAPH, _constants.NODE_TYPES.HEADING, _constants.NODE_TYPES.LIST_ITEM, _constants.NODE_TYPES.BLOCKQUOTE, _constants.NODE_TYPES.TABLE_CELL];
23
+ if (!parentsToProcess.includes(node.type) || !Array.isArray(node.children)) return;
24
+ const {
25
+ children
26
+ } = node;
27
+ const getText = n => {
28
+ if (n.type === _constants.NODE_TYPES.TEXT) return n.value || '';
29
+ if (n.type === _constants.NODE_TYPES.LINK) {
30
+ const inner = Array.isArray(n.children) ? n.children.map(getText).join('') : '';
31
+ return inner + (n.url || '');
32
+ }
33
+ if (Array.isArray(n.children)) return n.children.map(getText).join('');
34
+ return '';
35
+ };
36
+ const parts = children.map(child => {
37
+ const text = getText(child);
38
+ return {
39
+ node: child,
40
+ text,
41
+ length: text.length
42
+ };
43
+ });
44
+ const combined = parts.map(p => p.text).join('');
45
+ if (!combined.includes('†')) return;
46
+ const matches = [...combined.matchAll(pattern)];
47
+ if (matches.length === 0) return;
48
+ const findPartIndexByChar = charIndex => {
49
+ let acc = 0;
50
+ return parts.reduce((accumulator, part, idx) => {
51
+ if (accumulator.found) return accumulator;
52
+ const next = acc + part.length;
53
+ if (charIndex < next) {
54
+ return {
55
+ found: true,
56
+ partIndex: idx,
57
+ offsetInPart: charIndex - acc
58
+ };
59
+ }
60
+ acc = next;
61
+ return {
62
+ found: false,
63
+ partIndex: -1,
64
+ offsetInPart: -1
65
+ };
66
+ }, {
67
+ found: false,
68
+ partIndex: -1,
69
+ offsetInPart: -1
70
+ });
71
+ };
72
+ const newChildren = [];
73
+ let cursorChar = 0;
74
+ let consumedPartIndex = 0;
75
+ matches.forEach(match => {
76
+ const [full, label, url] = match;
77
+ const matchStart = match.index;
78
+ const matchEnd = matchStart + full.length;
79
+ if (matchStart > cursorChar) {
80
+ const endInfo = findPartIndexByChar(matchStart - 1);
81
+ for (let i = consumedPartIndex; i <= endInfo.partIndex; i += 1) {
82
+ const part = parts[i];
83
+ const partStartChar = parts.slice(0, i).reduce((a, b) => a + b.length, 0);
84
+ const takeFrom = Math.max(cursorChar - partStartChar, 0);
85
+ const takeTo = Math.min(matchStart - partStartChar, part.length);
86
+ if (takeFrom === 0 && takeTo === part.length) {
87
+ newChildren.push(part.node);
88
+ } else {
89
+ const textSlice = part.text.slice(takeFrom, takeTo);
90
+ if (textSlice) newChildren.push({
91
+ type: _constants.NODE_TYPES.TEXT,
92
+ value: textSlice
93
+ });
94
+ }
95
+ }
96
+ consumedPartIndex = endInfo.partIndex + 1;
97
+ }
98
+ const matchStartInfo = findPartIndexByChar(matchStart);
99
+ const matchEndInfo = findPartIndexByChar(matchEnd - 1);
100
+ if (matchStartInfo.partIndex > consumedPartIndex) {
101
+ for (let i = consumedPartIndex; i < matchStartInfo.partIndex; i += 1) {
102
+ newChildren.push(parts[i].node);
103
+ }
104
+ }
105
+ newChildren.push({
106
+ type: _constants.COMPONENTS_NAMES.CITATION,
107
+ data: {
108
+ hName: _constants.COMPONENTS_NAMES.CITATION,
109
+ hProperties: {
110
+ label,
111
+ url
112
+ }
113
+ }
114
+ });
115
+ consumedPartIndex = matchEndInfo.partIndex + 1;
116
+ cursorChar = matchEnd;
117
+ });
118
+ if (cursorChar < combined.length) {
119
+ const startInfo = findPartIndexByChar(cursorChar);
120
+ if (startInfo.found) {
121
+ const partStartChar = parts.slice(0, startInfo.partIndex).reduce((a, b) => a + b.length, 0);
122
+ const takeFrom = cursorChar - partStartChar;
123
+ const firstPart = parts[startInfo.partIndex];
124
+ if (takeFrom < firstPart.length) {
125
+ const slice = firstPart.text.slice(takeFrom);
126
+ if (slice) newChildren.push({
127
+ type: _constants.NODE_TYPES.TEXT,
128
+ value: slice
129
+ });
130
+ }
131
+ for (let i = Math.max(consumedPartIndex, startInfo.partIndex + 1); i < parts.length; i += 1) {
132
+ newChildren.push(parts[i].node);
133
+ }
134
+ } else {
135
+ for (let i = consumedPartIndex; i < parts.length; i += 1) {
136
+ newChildren.push(parts[i].node);
137
+ }
138
+ }
139
+ } else {
140
+ for (let i = consumedPartIndex; i < parts.length; i += 1) {
141
+ newChildren.push(parts[i].node);
142
+ }
143
+ }
144
+ const groupedChildren = [];
145
+ let i = 0;
146
+ while (i < newChildren.length) {
147
+ const child = newChildren[i];
148
+ if (child.type === _constants.COMPONENTS_NAMES.CITATION) {
149
+ let citationCount = 1;
150
+ let j = i + 1;
151
+ let endIndex = i + 1;
152
+ while (j < newChildren.length) {
153
+ const nextChild = newChildren[j];
154
+ if (nextChild.type === _constants.COMPONENTS_NAMES.CITATION) {
155
+ citationCount += 1;
156
+ endIndex = j + 1;
157
+ j += 1;
158
+ } else if (nextChild.type === _constants.NODE_TYPES.TEXT && nextChild.value.trim() === '') {
159
+ j += 1;
160
+ } else {
161
+ break;
162
+ }
163
+ }
164
+ if (citationCount >= 2) {
165
+ const citationGroup = {
166
+ type: _constants.COMPONENTS_NAMES.CITATION_GROUP,
167
+ children: newChildren.slice(i, endIndex),
168
+ data: {
169
+ hName: _constants.COMPONENTS_NAMES.CITATION_GROUP
170
+ }
171
+ };
172
+ groupedChildren.push(citationGroup);
173
+ i = endIndex;
174
+ } else {
175
+ groupedChildren.push(child);
176
+ i += 1;
177
+ }
178
+ } else {
179
+ groupedChildren.push(child);
180
+ i += 1;
181
+ }
182
+ }
183
+ if (groupedChildren.length > 0) {
184
+ node.children = groupedChildren;
185
+ }
186
+ });
187
+ };
188
+ };
189
+ exports.default = _default;
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = remarkDeflist;
7
+ var _unistUtilVisit = require("unist-util-visit");
8
+ var _constants = require("../constants");
9
+ /**
10
+ * remarkDeflist
11
+ *
12
+ * Convierte bloques como:
13
+ *
14
+ * Term 1
15
+ * : Description 1
16
+ * : Description 2
17
+ *
18
+ * Term 2
19
+ * : Desc A
20
+ *
21
+ * en un nodo <dl> con <dt> y <dd>
22
+ */
23
+ function remarkDeflist() {
24
+ return tree => {
25
+ (0, _unistUtilVisit.visit)(tree, _constants.NODE_TYPES.PARAGRAPH, (node, index, parent) => {
26
+ if (!parent || !Array.isArray(parent.children)) return;
27
+ const raw = node.children.map(ch => 'value' in ch ? ch.value : '').join('');
28
+ const lines = raw.split('\n');
29
+ if (!lines.some(l => l.trim().startsWith(':'))) return;
30
+ const items = [];
31
+ let currentTerm = null;
32
+ for (let i = 0; i < lines.length; i += 1) {
33
+ const line = lines[i];
34
+ const trimmed = line.trim();
35
+ if (trimmed && !trimmed.startsWith(':')) {
36
+ if (currentTerm) {
37
+ items.push(currentTerm);
38
+ }
39
+ currentTerm = {
40
+ term: trimmed,
41
+ desc: []
42
+ };
43
+ } else if (trimmed.startsWith(':')) {
44
+ if (!currentTerm) {
45
+ currentTerm = {
46
+ term: '',
47
+ desc: []
48
+ };
49
+ }
50
+ currentTerm.desc.push(trimmed.replace(/^:\s*/, ''));
51
+ }
52
+ }
53
+ if (currentTerm) {
54
+ items.push(currentTerm);
55
+ }
56
+ const dlNode = {
57
+ type: _constants.COMPONENTS_NAMES.DEFINITION_LIST,
58
+ data: {
59
+ hName: _constants.COMPONENTS_NAMES.DEFINITION_LIST
60
+ },
61
+ children: []
62
+ };
63
+ for (let j = 0; j < items.length; j += 1) {
64
+ const {
65
+ term,
66
+ desc
67
+ } = items[j];
68
+ dlNode.children.push({
69
+ type: _constants.COMPONENTS_NAMES.DEFINITION_TERM,
70
+ data: {
71
+ hName: _constants.COMPONENTS_NAMES.DEFINITION_TERM
72
+ },
73
+ children: [{
74
+ type: _constants.NODE_TYPES.TEXT,
75
+ value: term
76
+ }]
77
+ });
78
+ for (let k = 0; k < desc.length; k += 1) {
79
+ dlNode.children.push({
80
+ type: _constants.COMPONENTS_NAMES.DEFINITION_DESCRIPTION,
81
+ data: {
82
+ hName: _constants.COMPONENTS_NAMES.DEFINITION_DESCRIPTION
83
+ },
84
+ children: [{
85
+ type: _constants.NODE_TYPES.TEXT,
86
+ value: desc[k]
87
+ }]
88
+ });
89
+ }
90
+ }
91
+ parent.children.splice(index, 1, dlNode);
92
+ });
93
+ };
94
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _propTypes = require("prop-types");
9
+ var _reactMarkdown = _interopRequireDefault(require("react-markdown"));
10
+ var _utils = require("./utils");
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ const Markdown = _ref => {
13
+ let {
14
+ children,
15
+ classes,
16
+ markdownExtended,
17
+ markdownRenderers
18
+ } = _ref;
19
+ const {
20
+ components,
21
+ disallowedElements,
22
+ rehypePlugins,
23
+ remarkPlugins
24
+ } = (0, _utils.getMarkdownPlugins)(classes, markdownExtended, markdownRenderers);
25
+ return /*#__PURE__*/_react.default.createElement(_reactMarkdown.default
26
+ /* eslint-disable react/no-children-prop */, {
27
+ children: children,
28
+ components: components,
29
+ disallowedElements: disallowedElements,
30
+ remarkPlugins: remarkPlugins,
31
+ rehypePlugins: rehypePlugins,
32
+ skipHtml: false,
33
+ unwrapDisallowed: true
34
+ });
35
+ };
36
+ Markdown.propTypes = {
37
+ classes: (0, _propTypes.objectOf)(_propTypes.string),
38
+ markdownExtended: _propTypes.bool,
39
+ markdownRenderers: (0, _propTypes.objectOf)(_propTypes.func)
40
+ };
41
+ var _default = exports.default = Markdown;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getMarkdownPlugins = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _constants = require("./constants");
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ 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); }
11
+ const wrapComponents = (components, classes, markdownExtended, markdownRenderers) => Object.entries(components).reduce((wrapped, _ref) => {
12
+ let [key, Component] = _ref;
13
+ wrapped[key] = props => /*#__PURE__*/_react.default.createElement(Component, _extends({}, props, {
14
+ classes: classes,
15
+ customHandler: markdownRenderers === null || markdownRenderers === void 0 ? void 0 : markdownRenderers[key],
16
+ markdownExtended: markdownExtended
17
+ }));
18
+ return wrapped;
19
+ }, {});
20
+ const getMarkdownPlugins = function (classes, markdownExtended) {
21
+ let markdownRenderers = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
22
+ const {
23
+ components,
24
+ disallowedElements,
25
+ remarkPlugins,
26
+ rehypePlugins
27
+ } = markdownExtended ? _constants.EXTENDED_CONFIG : _constants.BASE_CONFIG;
28
+ const wrappedComponents = wrapComponents(components, classes, markdownExtended, markdownRenderers);
29
+ return {
30
+ components: {
31
+ ...markdownRenderers,
32
+ ...wrappedComponents
33
+ },
34
+ disallowedElements,
35
+ rehypePlugins,
36
+ remarkPlugins
37
+ };
38
+ };
39
+ exports.getMarkdownPlugins = getMarkdownPlugins;
@@ -3,10 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.WEIGHTS = exports.VARIANTS_SIZES = exports.VARIANTS_LINE_HEIGHT = exports.VARIANTS = exports.MARKDOWN_RENDERERS = exports.DEFAULT_PROPS = void 0;
7
- var _react = _interopRequireDefault(require("react"));
6
+ exports.WEIGHTS = exports.VARIANTS_SIZES = exports.VARIANTS_LINE_HEIGHT = exports.VARIANTS = exports.DEFAULT_PROPS = void 0;
8
7
  var _Palette = require("../../constants/Palette");
9
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
8
  const VARIANTS = exports.VARIANTS = {
11
9
  title1: 'h1',
12
10
  title2: 'h2',
@@ -54,23 +52,11 @@ const WEIGHTS = exports.WEIGHTS = {
54
52
  extrabold: 800,
55
53
  black: 900
56
54
  };
57
- const MARKDOWN_RENDERERS = exports.MARKDOWN_RENDERERS = {
58
- a: _ref => {
59
- let {
60
- href,
61
- children
62
- } = _ref;
63
- return /*#__PURE__*/_react.default.createElement("a", {
64
- href: href,
65
- rel: "noopener noreferrer",
66
- target: "_blank"
67
- }, children);
68
- }
69
- };
70
55
  const DEFAULT_PROPS = exports.DEFAULT_PROPS = {
71
56
  colorTheme: _Palette.COLOR_THEMES.dark,
72
57
  field: {},
73
- markdownRenderers: MARKDOWN_RENDERERS,
58
+ markdownExtended: false,
59
+ markdownRenderers: {},
74
60
  variant: 'body',
75
61
  weight: 'regular',
76
62
  withMarkdown: false
@@ -6,20 +6,16 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _propTypes = require("prop-types");
9
- var _reactMarkdown = _interopRequireDefault(require("react-markdown"));
10
- var _remarkBreaks = _interopRequireDefault(require("remark-breaks"));
11
- var _rehypeRaw = _interopRequireDefault(require("rehype-raw"));
12
9
  var _classesUtils = require("../../utils/classesUtils");
13
10
  var _componentUtils = require("../../utils/componentUtils");
14
11
  var _UTSkeleton = _interopRequireDefault(require("../UTSkeleton"));
15
12
  var _WithTheme = _interopRequireDefault(require("../WithTheme"));
13
+ var _Markdown = _interopRequireDefault(require("./components/Markdown"));
16
14
  var _constants = require("./constants");
17
15
  var _theme = require("./theme");
18
16
  var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
19
17
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
20
18
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
21
- /* eslint-disable react/no-children-prop */
22
-
23
19
  const UTLabel = _ref => {
24
20
  let {
25
21
  align,
@@ -27,6 +23,7 @@ const UTLabel = _ref => {
27
23
  className,
28
24
  classes: theme,
29
25
  dataTestId,
26
+ markdownExtended,
30
27
  markdownRenderers,
31
28
  title,
32
29
  variant,
@@ -37,19 +34,16 @@ const UTLabel = _ref => {
37
34
  const classes = (0, _react.useMemo)(() => (0, _classesUtils.mergeClasses)(theme, {
38
35
  className
39
36
  }), [theme, className]);
37
+ const componentClassname = "".concat(classes.root, " ").concat(withMarkdown ? classes.markdown : '', " ").concat(_stylesModule.default["".concat(align, "Alignment")] || '', " ").concat(classes.className);
40
38
  return /*#__PURE__*/_react.default.createElement(_UTSkeleton.default, null, /*#__PURE__*/_react.default.createElement(Component, {
41
- className: "".concat(classes.root, " ").concat(_stylesModule.default["".concat(align, "Alignment")] || '', " ").concat(classes.className).trim(),
39
+ className: componentClassname.trim(),
42
40
  "data-testid": dataTestId,
43
41
  title: title
44
- }, withMarkdown && /*#__PURE__*/_react.default.createElement(_reactMarkdown.default, {
45
- children: children,
46
- components: markdownRenderers,
47
- disallowedElements: ['p', 'blockquote'],
48
- rehypePlugins: [_rehypeRaw.default],
49
- remarkPlugins: [_remarkBreaks.default],
50
- skipHtml: false,
51
- unwrapDisallowed: true
52
- }) || children));
42
+ }, withMarkdown && /*#__PURE__*/_react.default.createElement(_Markdown.default, {
43
+ classes: classes,
44
+ markdownExtended: markdownExtended,
45
+ markdownRenderers: markdownRenderers
46
+ }, children) || children));
53
47
  };
54
48
  UTLabel.defaultProps = _constants.DEFAULT_PROPS;
55
49
  UTLabel.propTypes = {
@@ -57,6 +51,7 @@ UTLabel.propTypes = {
57
51
  classes: (0, _propTypes.objectOf)(_propTypes.string),
58
52
  className: _propTypes.string,
59
53
  dataTestId: _propTypes.string,
54
+ markdownExtended: _propTypes.bool,
60
55
  markdownRenderers: (0, _propTypes.objectOf)(_propTypes.func),
61
56
  title: _propTypes.string,
62
57
  variant: _propTypes.string,
@@ -19,7 +19,7 @@ const variantsColorTheme = (colorTheme, shade, theme) => {
19
19
  const linkColor = (theme, colorTheme) => {
20
20
  var _theme$Palette;
21
21
  const actionPaletteColors = ((_theme$Palette = theme.Palette) === null || _theme$Palette === void 0 ? void 0 : _theme$Palette.actions) || theme.Palette;
22
- const color = colorTheme === _Palette.COLOR_THEMES.light ? actionPaletteColors.negative[_Palette.COLOR_SHADES.shade05] : colorTheme === _Palette.COLOR_THEMES.error ? actionPaletteColors.error[_Palette.COLOR_SHADES.shade05] : actionPaletteColors.neutral[_Palette.COLOR_SHADES.shade05];
22
+ const color = colorTheme === _Palette.COLOR_THEMES.light ? actionPaletteColors[_Palette.COLOR_THEMES.negative][_Palette.COLOR_SHADES.shade05] : colorTheme === _Palette.COLOR_THEMES.error ? actionPaletteColors[_Palette.COLOR_THEMES.error][_Palette.COLOR_SHADES.shade05] : actionPaletteColors[_Palette.COLOR_THEMES.accent][_Palette.COLOR_SHADES.shade05];
23
23
  return color;
24
24
  };
25
25
  const getFontStyles = _ref => {
@@ -51,6 +51,8 @@ const retrieveStyle = _ref2 => {
51
51
  weight,
52
52
  variantsSizes
53
53
  } = _ref2;
54
+ const darkTextColor = colorTheme === _Palette.COLOR_THEMES.light ? theme.Palette[_Palette.COLOR_THEMES.light][_Palette.COLOR_SHADES.shade01] : theme.Palette[_Palette.COLOR_THEMES.dark][_Palette.COLOR_SHADES.shade05];
55
+ const grayTextColor = colorTheme === _Palette.COLOR_THEMES.light ? theme.Palette[_Palette.COLOR_THEMES.light][_Palette.COLOR_SHADES.shade01] : theme.Palette[_Palette.COLOR_THEMES.gray][_Palette.COLOR_SHADES.shade04];
54
56
  return {
55
57
  root: {
56
58
  color: variantsColorTheme((_field$configuration$ = field === null || field === void 0 || (_field$configuration = field.configuration) === null || _field$configuration === void 0 ? void 0 : _field$configuration.colorTheme) !== null && _field$configuration$ !== void 0 ? _field$configuration$ : colorTheme, (_field$configuration$2 = field === null || field === void 0 || (_field$configuration2 = field.configuration) === null || _field$configuration2 === void 0 ? void 0 : _field$configuration2.shade) !== null && _field$configuration$2 !== void 0 ? _field$configuration$2 : shade, theme),
@@ -60,10 +62,158 @@ const retrieveStyle = _ref2 => {
60
62
  weight: (_field$configuration$4 = field === null || field === void 0 || (_field$configuration4 = field.configuration) === null || _field$configuration4 === void 0 ? void 0 : _field$configuration4.weight) !== null && _field$configuration$4 !== void 0 ? _field$configuration$4 : weight,
61
63
  variantsSizes
62
64
  }),
63
- margin: 0,
64
- '& > a': {
65
+ margin: 0
66
+ },
67
+ markdown: {
68
+ '& a': {
65
69
  color: linkColor(theme, colorTheme)
70
+ },
71
+ '& h1, & h2, & h3, & h4, & h5, & h6': {
72
+ color: darkTextColor,
73
+ fontWeight: _constants.WEIGHTS.medium,
74
+ lineHeight: 1,
75
+ margin: '0 0 8px 0'
76
+ },
77
+ '& h1': {
78
+ fontSize: '1.875em'
79
+ },
80
+ '& h2': {
81
+ fontSize: '1.5em'
82
+ },
83
+ '& h3': {
84
+ fontSize: '1.375em'
85
+ },
86
+ '& h4': {
87
+ fontSize: '1.125em'
88
+ },
89
+ '& h5': {
90
+ fontSize: '1em',
91
+ margin: '0 0 12px 0'
92
+ },
93
+ '& h6': {
94
+ color: grayTextColor,
95
+ fontSize: '1em',
96
+ margin: '0 0 12px 0'
97
+ },
98
+ '& table': {
99
+ border: "1px solid ".concat(theme.Palette[_Palette.COLOR_THEMES.light][_Palette.COLOR_SHADES.shade04]),
100
+ borderCollapse: 'collapse',
101
+ margin: '0 0 24px 0',
102
+ width: '100%'
103
+ },
104
+ '& th, & td': {
105
+ border: "1px solid ".concat(theme.Palette[_Palette.COLOR_THEMES.light][_Palette.COLOR_SHADES.shade04]),
106
+ padding: '8px 12px',
107
+ textAlign: 'left'
108
+ },
109
+ '& th': {
110
+ backgroundColor: (theme.Palette.actions || theme.Palette)[_Palette.COLOR_THEMES.negative][_Palette.COLOR_SHADES.shade01],
111
+ color: grayTextColor,
112
+ fontWeight: _constants.WEIGHTS.medium
113
+ },
114
+ '& p': {
115
+ margin: '0 0 12px 0'
116
+ },
117
+ '& ol': {
118
+ paddingLeft: 24,
119
+ textAlign: 'start'
120
+ },
121
+ '& ul, & ol': {
122
+ margin: '0 0 24px 0'
123
+ },
124
+ '& ul:not(.contains-task-list)': {
125
+ paddingLeft: 24,
126
+ textAlign: 'start'
127
+ },
128
+ '& pre': {
129
+ backgroundColor: theme.Palette[_Palette.COLOR_THEMES.light][_Palette.COLOR_SHADES.shade03],
130
+ borderRadius: 8,
131
+ fontSize: '0.875em',
132
+ lineHeight: '1.25em',
133
+ margin: '0 0 24px 0',
134
+ padding: '12px 16px',
135
+ whiteSpace: 'pre-wrap'
136
+ },
137
+ '& dl': {
138
+ margin: '0 0 24px 0'
139
+ },
140
+ '& dd': {
141
+ fontSize: 'inherit',
142
+ margin: 0
143
+ },
144
+ '& dt': {
145
+ color: grayTextColor,
146
+ fontSize: _constants.VARIANTS_SIZES.small,
147
+ fontWeight: _constants.WEIGHTS.semibold
148
+ },
149
+ '& dl + dl': {
150
+ marginTop: -12
151
+ },
152
+ '& dt + dt, & dt + dd, & dd + dd': {
153
+ marginTop: 12
154
+ },
155
+ '& hr': {
156
+ borderColor: theme.Palette[_Palette.COLOR_THEMES.gray][_Palette.COLOR_SHADES.shade01],
157
+ borderTop: 0,
158
+ margin: '8px 0 24px'
159
+ },
160
+ '& li + li': {
161
+ marginTop: 12
162
+ },
163
+ '& li > ul': {
164
+ marginTop: 8
165
+ },
166
+ '& li::marker': {
167
+ color: theme.Palette[_Palette.COLOR_THEMES.gray][_Palette.COLOR_SHADES.shade01]
168
+ },
169
+ '& li > ul > li + li': {
170
+ marginTop: 8
171
+ },
172
+ '& li p': {
173
+ margin: 0
174
+ },
175
+ '& sup': {
176
+ fontSize: 'inherit'
177
+ },
178
+ '& sup > a': {
179
+ fontSize: '0.75em'
180
+ },
181
+ '& img, & video, & audio': {
182
+ borderRadius: 8,
183
+ margin: '0 0 24px 0'
184
+ },
185
+ '& .contains-task-list': {
186
+ display: 'flex',
187
+ flexDirection: 'column',
188
+ gridGap: '12px',
189
+ margin: '0 0 24px 0',
190
+ paddingLeft: 0,
191
+ '& li': {
192
+ margin: 0
193
+ }
194
+ },
195
+ '& :last-child': {
196
+ marginBottom: '0'
66
197
  }
198
+ },
199
+ blockquote: {
200
+ color: grayTextColor,
201
+ '&::before': {
202
+ background: theme.Palette[_Palette.COLOR_THEMES.gray][_Palette.COLOR_SHADES.shade01]
203
+ }
204
+ },
205
+ citationGroup: {
206
+ '&::-webkit-scrollbar-thumb': {
207
+ backgroundColor: theme.Palette[_Palette.COLOR_THEMES.gray][_Palette.COLOR_SHADES.shade04]
208
+ }
209
+ },
210
+ customFootnotes: {
211
+ '& span': {
212
+ color: grayTextColor
213
+ }
214
+ },
215
+ taskItemIconUnchecked: {
216
+ borderColor: theme.Palette[_Palette.COLOR_THEMES.gray][_Palette.COLOR_SHADES.shade01]
67
217
  }
68
218
  };
69
219
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widergy/energy-ui",
3
- "version": "3.123.1",
3
+ "version": "3.124.0",
4
4
  "description": "Widergy Web Components",
5
5
  "author": "widergy",
6
6
  "license": "MIT",
@@ -67,9 +67,11 @@
67
67
  "react-window": "^1.8.5",
68
68
  "rehype-raw": "^6.1.0",
69
69
  "remark-breaks": "^3.0.2",
70
+ "remark-gfm": "^3.0.1",
70
71
  "sass-loader": "^10.0.5",
71
72
  "sass": "^1.80.4",
72
- "seamless-immutable": "^7.1.4"
73
+ "seamless-immutable": "^7.1.4",
74
+ "unist-util-visit": "^4.0.0"
73
75
  },
74
76
  "devDependencies": {
75
77
  "@babel/cli": "^7.2.3",