@micromag/element-heading 0.3.732 → 0.3.736

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 (2) hide show
  1. package/es/index.js +11 -12
  2. package/package.json +3 -3
package/es/index.js CHANGED
@@ -1,12 +1,10 @@
1
- import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
1
  import _objectSpread from '@babel/runtime/helpers/objectSpread2';
3
2
  import classNames from 'classnames';
4
3
  import PropTypes from 'prop-types';
5
- import React, { useMemo } from 'react';
6
- import { v1 } from 'uuid';
4
+ import React, { useId } from 'react';
7
5
  import { PropTypes as PropTypes$1 } from '@micromag/core';
8
6
  import { LinkStyle, HighlightStyle } from '@micromag/core/components';
9
- import { getStyleFromLink, getStyleFromHighlight, getStyleFromText, getStyleFromMargin } from '@micromag/core/utils';
7
+ import { getStyleFromLink, getStyleFromHighlight, getStyleFromText, getStyleFromMargin, addNonBreakingSpaces } from '@micromag/core/utils';
10
8
 
11
9
  var styles = {"container":"micromag-element-heading-container"};
12
10
 
@@ -16,6 +14,7 @@ var propTypes = {
16
14
  textStyle: PropTypes$1.textStyle,
17
15
  linksStyle: PropTypes$1.textStyle,
18
16
  margin: PropTypes$1.margin,
17
+ withoutNonBreakingSpaces: PropTypes.bool,
19
18
  className: PropTypes.string,
20
19
  headingRef: PropTypes.shape({})
21
20
  };
@@ -25,6 +24,7 @@ var defaultProps = {
25
24
  textStyle: null,
26
25
  linksStyle: null,
27
26
  margin: null,
27
+ withoutNonBreakingSpaces: false,
28
28
  className: null,
29
29
  headingRef: null
30
30
  };
@@ -34,6 +34,7 @@ var Heading = function Heading(_ref) {
34
34
  textStyle = _ref.textStyle,
35
35
  linksStyle = _ref.linksStyle,
36
36
  margin = _ref.margin,
37
+ withoutNonBreakingSpaces = _ref.withoutNonBreakingSpaces,
37
38
  className = _ref.className,
38
39
  headingRef = _ref.headingRef;
39
40
  var HeadingComponent = "h".concat(size);
@@ -55,21 +56,19 @@ var Heading = function Heading(_ref) {
55
56
  finalLinkStyle = _objectSpread(_objectSpread({}, finalLinkStyle), getStyleFromText(linksStyle));
56
57
  }
57
58
  var needsId = finalLinkStyle !== null || highlightStyle !== null;
58
- var id = useMemo(function () {
59
- return needsId ? "text-component-".concat(v1()) : null;
60
- }, [needsId]);
59
+ var id = useId();
61
60
  return /*#__PURE__*/React.createElement(React.Fragment, null, finalLinkStyle !== null ? /*#__PURE__*/React.createElement(LinkStyle, {
62
- selector: "#".concat(id),
61
+ selector: "#text-component-".concat(id),
63
62
  style: finalLinkStyle
64
63
  }) : null, finalHighlightStyle !== null ? /*#__PURE__*/React.createElement(HighlightStyle, {
65
- selector: "#".concat(id),
64
+ selector: "#text-component-".concat(id),
66
65
  style: finalHighlightStyle
67
66
  }) : null, /*#__PURE__*/React.createElement(HeadingComponent, {
68
- id: id,
69
- className: classNames([styles.container, _defineProperty({}, className, className !== null)]),
67
+ id: needsId ? "text-component-".concat(id) : null,
68
+ className: classNames([styles.container, className]),
70
69
  style: finalStyle,
71
70
  dangerouslySetInnerHTML: {
72
- __html: body
71
+ __html: !withoutNonBreakingSpaces ? addNonBreakingSpaces(body) : body
73
72
  },
74
73
  ref: headingRef
75
74
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/element-heading",
3
- "version": "0.3.732",
3
+ "version": "0.3.736",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [
@@ -59,7 +59,7 @@
59
59
  },
60
60
  "dependencies": {
61
61
  "@babel/runtime": "^7.13.10",
62
- "@micromag/core": "^0.3.732",
62
+ "@micromag/core": "^0.3.736",
63
63
  "classnames": "^2.2.6",
64
64
  "prop-types": "^15.7.2",
65
65
  "react-intl": "^6.6.4",
@@ -69,5 +69,5 @@
69
69
  "access": "public",
70
70
  "registry": "https://registry.npmjs.org/"
71
71
  },
72
- "gitHead": "5cb81184739b8b84d734bf2cdf5ae070562ab1dc"
72
+ "gitHead": "77bd0bf6941418463c0f7bbb68bf9b20379c5c55"
73
73
  }