@widergy/energy-ui 3.123.1 → 3.125.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 (35) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/components/UTActionCard/components/Header/index.js +1 -1
  3. package/dist/components/UTCalendar/components/Day/index.js +37 -0
  4. package/dist/components/UTCalendar/components/Day/styles.module.scss +36 -0
  5. package/dist/components/UTCalendar/components/TimeInput/index.js +39 -0
  6. package/dist/components/UTCalendar/components/TimeInput/styles.module.scss +12 -0
  7. package/dist/components/UTCalendar/constants.js +15 -0
  8. package/dist/components/UTCalendar/index.js +119 -0
  9. package/dist/components/UTCalendar/styles.module.scss +122 -0
  10. package/dist/components/UTLabel/README.md +7 -2
  11. package/dist/components/UTLabel/UTLabel.stories.js +13 -0
  12. package/dist/components/UTLabel/components/Markdown/components/BlockQuote/index.js +48 -0
  13. package/dist/components/UTLabel/components/Markdown/components/BlockQuote/styles.module.scss +16 -0
  14. package/dist/components/UTLabel/components/Markdown/components/Citation/index.js +28 -0
  15. package/dist/components/UTLabel/components/Markdown/components/CitationGroup/index.js +25 -0
  16. package/dist/components/UTLabel/components/Markdown/components/CitationGroup/styles.module.scss +22 -0
  17. package/dist/components/UTLabel/components/Markdown/components/Links/constants.js +8 -0
  18. package/dist/components/UTLabel/components/Markdown/components/Links/index.js +46 -0
  19. package/dist/components/UTLabel/components/Markdown/components/Links/styles.module.scss +3 -0
  20. package/dist/components/UTLabel/components/Markdown/components/ListItem/index.js +53 -0
  21. package/dist/components/UTLabel/components/Markdown/components/ListItem/styles.module.scss +22 -0
  22. package/dist/components/UTLabel/components/Markdown/components/Section/index.js +59 -0
  23. package/dist/components/UTLabel/components/Markdown/components/Section/styles.module.scss +13 -0
  24. package/dist/components/UTLabel/components/Markdown/components/WithCustomHandler/index.js +25 -0
  25. package/dist/components/UTLabel/components/Markdown/constants.js +66 -0
  26. package/dist/components/UTLabel/components/Markdown/customPlugins/remarkCitations.js +189 -0
  27. package/dist/components/UTLabel/components/Markdown/customPlugins/remarkDeflist.js +94 -0
  28. package/dist/components/UTLabel/components/Markdown/index.js +41 -0
  29. package/dist/components/UTLabel/components/Markdown/utils.js +39 -0
  30. package/dist/components/UTLabel/constants.js +3 -17
  31. package/dist/components/UTLabel/index.js +10 -15
  32. package/dist/components/UTLabel/theme.js +153 -3
  33. package/dist/components/UTRadioGroup/versions/V1/components/Radio/theme.js +1 -5
  34. package/dist/index.js +7 -0
  35. package/package.json +6 -2
@@ -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;