@micromag/element-text 0.4.69 → 0.4.74

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 +249 -67
  2. package/package.json +9 -7
package/es/index.js CHANGED
@@ -1,86 +1,268 @@
1
- import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
- import _objectSpread from '@babel/runtime/helpers/objectSpread2';
1
+ import { c } from 'react/compiler-runtime';
3
2
  import classNames from 'classnames';
4
3
  import { useId } from 'react';
5
4
  import { LinkStyle, HighlightStyle } from '@micromag/core/components';
6
5
  import { getStyleFromLink, getStyleFromHighlight, getStyleFromText, getStyleFromBox, getStyleFromMargin, cssEscape } from '@micromag/core/utils';
7
- import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
6
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
8
7
 
9
8
  var styles = {"container":"micromag-element-text-container","showEmpty":"micromag-element-text-showEmpty","withLineClamp":"micromag-element-text-withLineClamp"};
10
9
 
11
- function Text(_ref) {
12
- var _ref$body = _ref.body,
13
- body = _ref$body === void 0 ? null : _ref$body,
14
- _ref$textStyle = _ref.textStyle,
15
- textStyle = _ref$textStyle === void 0 ? null : _ref$textStyle,
16
- _ref$boxStyle = _ref.boxStyle,
17
- boxStyle = _ref$boxStyle === void 0 ? null : _ref$boxStyle,
18
- _ref$linksStyle = _ref.linksStyle,
19
- linksStyle = _ref$linksStyle === void 0 ? null : _ref$linksStyle,
20
- _ref$margin = _ref.margin,
21
- margin = _ref$margin === void 0 ? null : _ref$margin,
22
- _ref$lineClamp = _ref.lineClamp,
23
- lineClamp = _ref$lineClamp === void 0 ? null : _ref$lineClamp,
24
- _ref$showEmpty = _ref.showEmpty,
25
- showEmpty = _ref$showEmpty === void 0 ? false : _ref$showEmpty,
26
- _ref$className = _ref.className,
27
- className = _ref$className === void 0 ? null : _ref$className,
28
- _ref$emptyClassName = _ref.emptyClassName,
29
- emptyClassName = _ref$emptyClassName === void 0 ? null : _ref$emptyClassName,
30
- _ref$inline = _ref.inline,
31
- inline = _ref$inline === void 0 ? false : _ref$inline,
32
- _ref$refText = _ref.refText,
33
- refText = _ref$refText === void 0 ? null : _ref$refText;
34
- var _ref2 = textStyle || {},
35
- _ref2$link = _ref2.link,
36
- linkStyle = _ref2$link === void 0 ? null : _ref2$link,
37
- _ref2$highlight = _ref2.highlight,
38
- highlightStyle = _ref2$highlight === void 0 ? null : _ref2$highlight;
39
- var finalStyle = {};
40
- var finalLinkStyle = linkStyle !== null ? getStyleFromLink(linkStyle) : null;
41
- var finalHighlightStyle = highlightStyle !== null ? getStyleFromHighlight(highlightStyle) : null;
42
-
43
- // if (highlightStyle !== null) {
44
- // console.log('highlightStyle', highlightStyle);
45
- // }
46
-
47
- if (textStyle !== null) {
48
- finalStyle = _objectSpread(_objectSpread({}, finalStyle), getStyleFromText(textStyle));
49
- }
50
- if (boxStyle !== null) {
51
- finalStyle = _objectSpread(_objectSpread({}, finalStyle), getStyleFromBox(boxStyle));
10
+ function Text(t0) {
11
+ const $ = c(55);
12
+ const {
13
+ body: t1,
14
+ textStyle: t2,
15
+ boxStyle: t3,
16
+ linksStyle: t4,
17
+ margin: t5,
18
+ lineClamp: t6,
19
+ showEmpty: t7,
20
+ className: t8,
21
+ emptyClassName: t9,
22
+ inline: t10,
23
+ refText: t11
24
+ } = t0;
25
+ const body = t1 === undefined ? null : t1;
26
+ const textStyle = t2 === undefined ? null : t2;
27
+ const boxStyle = t3 === undefined ? null : t3;
28
+ const linksStyle = t4 === undefined ? null : t4;
29
+ const margin = t5 === undefined ? null : t5;
30
+ const lineClamp = t6 === undefined ? null : t6;
31
+ const showEmpty = t7 === undefined ? false : t7;
32
+ const className = t8 === undefined ? null : t8;
33
+ const emptyClassName = t9 === undefined ? null : t9;
34
+ const inline = t10 === undefined ? false : t10;
35
+ const refText = t11 === undefined ? null : t11;
36
+ let t12;
37
+ if ($[0] !== textStyle) {
38
+ t12 = textStyle || {};
39
+ $[0] = textStyle;
40
+ $[1] = t12;
41
+ } else {
42
+ t12 = $[1];
52
43
  }
53
- if (lineClamp !== null) {
54
- finalStyle.WebkitLineClamp = lineClamp;
44
+ const {
45
+ link: t13,
46
+ highlight: t14
47
+ } = t12;
48
+ const linkStyle = t13 === undefined ? null : t13;
49
+ const highlightStyle = t14 === undefined ? null : t14;
50
+ let finalHighlightStyle;
51
+ let finalLinkStyle;
52
+ let finalStyle;
53
+ if ($[2] !== boxStyle || $[3] !== highlightStyle || $[4] !== lineClamp || $[5] !== linkStyle || $[6] !== textStyle) {
54
+ finalStyle = {};
55
+ let t15;
56
+ if ($[10] !== linkStyle) {
57
+ t15 = linkStyle !== null ? getStyleFromLink(linkStyle) : null;
58
+ $[10] = linkStyle;
59
+ $[11] = t15;
60
+ } else {
61
+ t15 = $[11];
62
+ }
63
+ finalLinkStyle = t15;
64
+ let t16;
65
+ if ($[12] !== highlightStyle) {
66
+ t16 = highlightStyle !== null ? getStyleFromHighlight(highlightStyle) : null;
67
+ $[12] = highlightStyle;
68
+ $[13] = t16;
69
+ } else {
70
+ t16 = $[13];
71
+ }
72
+ finalHighlightStyle = t16;
73
+ if (textStyle !== null) {
74
+ const t17 = finalStyle;
75
+ let t18;
76
+ if ($[14] !== textStyle) {
77
+ t18 = getStyleFromText(textStyle);
78
+ $[14] = textStyle;
79
+ $[15] = t18;
80
+ } else {
81
+ t18 = $[15];
82
+ }
83
+ finalStyle = {
84
+ ...t17,
85
+ ...t18
86
+ };
87
+ }
88
+ if (boxStyle !== null) {
89
+ const t17 = finalStyle;
90
+ let t18;
91
+ if ($[16] !== boxStyle) {
92
+ t18 = getStyleFromBox(boxStyle);
93
+ $[16] = boxStyle;
94
+ $[17] = t18;
95
+ } else {
96
+ t18 = $[17];
97
+ }
98
+ finalStyle = {
99
+ ...t17,
100
+ ...t18
101
+ };
102
+ }
103
+ if (lineClamp !== null) {
104
+ finalStyle.WebkitLineClamp = lineClamp;
105
+ }
106
+ $[2] = boxStyle;
107
+ $[3] = highlightStyle;
108
+ $[4] = lineClamp;
109
+ $[5] = linkStyle;
110
+ $[6] = textStyle;
111
+ $[7] = finalHighlightStyle;
112
+ $[8] = finalLinkStyle;
113
+ $[9] = finalStyle;
114
+ } else {
115
+ finalHighlightStyle = $[7];
116
+ finalLinkStyle = $[8];
117
+ finalStyle = $[9];
55
118
  }
56
119
  if (margin !== null) {
57
- finalStyle = _objectSpread(_objectSpread({}, finalStyle), getStyleFromMargin(margin));
120
+ const t15 = finalStyle;
121
+ let t16;
122
+ if ($[18] !== margin) {
123
+ t16 = getStyleFromMargin(margin);
124
+ $[18] = margin;
125
+ $[19] = t16;
126
+ } else {
127
+ t16 = $[19];
128
+ }
129
+ let t17;
130
+ if ($[20] !== finalStyle || $[21] !== t16) {
131
+ t17 = {
132
+ ...t15,
133
+ ...t16
134
+ };
135
+ $[20] = finalStyle;
136
+ $[21] = t16;
137
+ $[22] = t17;
138
+ } else {
139
+ t17 = $[22];
140
+ }
141
+ finalStyle = t17;
58
142
  }
59
143
  if (linksStyle !== null) {
60
- finalLinkStyle = _objectSpread(_objectSpread({}, finalLinkStyle), getStyleFromText(linksStyle));
144
+ const t15 = finalLinkStyle;
145
+ let t16;
146
+ if ($[23] !== linksStyle) {
147
+ t16 = getStyleFromText(linksStyle);
148
+ $[23] = linksStyle;
149
+ $[24] = t16;
150
+ } else {
151
+ t16 = $[24];
152
+ }
153
+ let t17;
154
+ if ($[25] !== finalLinkStyle || $[26] !== t16) {
155
+ t17 = {
156
+ ...t15,
157
+ ...t16
158
+ };
159
+ $[25] = finalLinkStyle;
160
+ $[26] = t16;
161
+ $[27] = t17;
162
+ } else {
163
+ t17 = $[27];
164
+ }
165
+ finalLinkStyle = t17;
61
166
  }
62
- var needsId = finalLinkStyle !== null || highlightStyle !== null;
63
- var uniqueId = useId();
64
- var id = needsId ? "text-component-".concat(uniqueId) : null;
65
- var tagProps = {
66
- id: id,
67
- className: classNames([styles.container, className, _defineProperty(_defineProperty(_defineProperty({}, styles.withLineClamp, lineClamp !== null), styles.showEmpty, showEmpty), emptyClassName, showEmpty && emptyClassName !== null)]),
68
- style: finalStyle,
69
- dangerouslySetInnerHTML: {
167
+ const needsId = finalLinkStyle !== null || highlightStyle !== null;
168
+ const uniqueId = useId();
169
+ const id = needsId ? `text-component-${uniqueId}` : null;
170
+ const t15 = lineClamp !== null;
171
+ const t16 = showEmpty && emptyClassName !== null;
172
+ let t17;
173
+ if ($[28] !== className || $[29] !== emptyClassName || $[30] !== showEmpty || $[31] !== t15 || $[32] !== t16) {
174
+ t17 = classNames([styles.container, className, {
175
+ [styles.withLineClamp]: t15,
176
+ [styles.showEmpty]: showEmpty,
177
+ [emptyClassName]: t16
178
+ }]);
179
+ $[28] = className;
180
+ $[29] = emptyClassName;
181
+ $[30] = showEmpty;
182
+ $[31] = t15;
183
+ $[32] = t16;
184
+ $[33] = t17;
185
+ } else {
186
+ t17 = $[33];
187
+ }
188
+ let t18;
189
+ if ($[34] !== body) {
190
+ t18 = {
70
191
  __html: body
71
- },
72
- ref: refText
73
- };
74
- var Tag = "".concat(inline ? 'span' : 'div');
75
- return /*#__PURE__*/jsxs(Fragment, {
76
- children: [finalLinkStyle !== null ? /*#__PURE__*/jsx(LinkStyle, {
77
- selector: "#".concat(cssEscape(id)),
192
+ };
193
+ $[34] = body;
194
+ $[35] = t18;
195
+ } else {
196
+ t18 = $[35];
197
+ }
198
+ let t19;
199
+ if ($[36] !== finalStyle || $[37] !== id || $[38] !== refText || $[39] !== t17 || $[40] !== t18) {
200
+ t19 = {
201
+ id,
202
+ className: t17,
203
+ style: finalStyle,
204
+ dangerouslySetInnerHTML: t18,
205
+ ref: refText
206
+ };
207
+ $[36] = finalStyle;
208
+ $[37] = id;
209
+ $[38] = refText;
210
+ $[39] = t17;
211
+ $[40] = t18;
212
+ $[41] = t19;
213
+ } else {
214
+ t19 = $[41];
215
+ }
216
+ const tagProps = t19;
217
+ const Tag = `${inline ? "span" : "div"}`;
218
+ let t20;
219
+ if ($[42] !== finalLinkStyle || $[43] !== id) {
220
+ t20 = finalLinkStyle !== null ? /*#__PURE__*/jsx(LinkStyle, {
221
+ selector: `#${cssEscape(id)}`,
78
222
  style: finalLinkStyle
79
- }) : null, finalHighlightStyle !== null ? /*#__PURE__*/jsx(HighlightStyle, {
80
- selector: "#".concat(cssEscape(id)),
223
+ }) : null;
224
+ $[42] = finalLinkStyle;
225
+ $[43] = id;
226
+ $[44] = t20;
227
+ } else {
228
+ t20 = $[44];
229
+ }
230
+ let t21;
231
+ if ($[45] !== finalHighlightStyle || $[46] !== id) {
232
+ t21 = finalHighlightStyle !== null ? /*#__PURE__*/jsx(HighlightStyle, {
233
+ selector: `#${cssEscape(id)}`,
81
234
  style: finalHighlightStyle
82
- }) : null, /*#__PURE__*/jsx(Tag, _objectSpread({}, tagProps))]
83
- });
235
+ }) : null;
236
+ $[45] = finalHighlightStyle;
237
+ $[46] = id;
238
+ $[47] = t21;
239
+ } else {
240
+ t21 = $[47];
241
+ }
242
+ let t22;
243
+ if ($[48] !== Tag || $[49] !== tagProps) {
244
+ t22 = /*#__PURE__*/jsx(Tag, {
245
+ ...tagProps
246
+ });
247
+ $[48] = Tag;
248
+ $[49] = tagProps;
249
+ $[50] = t22;
250
+ } else {
251
+ t22 = $[50];
252
+ }
253
+ let t23;
254
+ if ($[51] !== t20 || $[52] !== t21 || $[53] !== t22) {
255
+ t23 = /*#__PURE__*/jsxs(Fragment, {
256
+ children: [t20, t21, t22]
257
+ });
258
+ $[51] = t20;
259
+ $[52] = t21;
260
+ $[53] = t22;
261
+ $[54] = t23;
262
+ } else {
263
+ t23 = $[54];
264
+ }
265
+ return t23;
84
266
  }
85
267
 
86
268
  export { Text as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/element-text",
3
- "version": "0.4.69",
3
+ "version": "0.4.74",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [
@@ -32,9 +32,11 @@
32
32
  "license": "ISC",
33
33
  "type": "module",
34
34
  "module": "es/index.js",
35
+ "style": "./assets/css/styles.css",
35
36
  "exports": {
36
37
  ".": {
37
38
  "types": "./es/index.d.ts",
39
+ "style": "./assets/css/styles.css",
38
40
  "import": "./es/index.js"
39
41
  },
40
42
  "./assets/css/styles": "./assets/css/styles.css",
@@ -51,16 +53,16 @@
51
53
  "build": "../../scripts/prepare-package.sh --types"
52
54
  },
53
55
  "devDependencies": {
54
- "react": "^18.3.0 || ^19.0.0",
55
- "react-dom": "^18.3.0 || ^19.0.0"
56
+ "react": "^19.0.0",
57
+ "react-dom": "^19.0.0"
56
58
  },
57
59
  "peerDependencies": {
58
- "react": "^18.3.0 || ^19.0.0",
59
- "react-dom": "^18.3.0 || ^19.0.0"
60
+ "react": "^19.0.0",
61
+ "react-dom": "^19.0.0"
60
62
  },
61
63
  "dependencies": {
62
64
  "@babel/runtime": "^7.28.6",
63
- "@micromag/core": "^0.4.69",
65
+ "@micromag/core": "^0.4.74",
64
66
  "classnames": "^2.2.6",
65
67
  "react-intl": "^8.1.3 || ^10.0.0",
66
68
  "uuid": "^9.0.0"
@@ -69,6 +71,6 @@
69
71
  "access": "public",
70
72
  "registry": "https://registry.npmjs.org/"
71
73
  },
72
- "gitHead": "509e113dc06022d6092e4aac9f47ccd5facfd59d",
74
+ "gitHead": "fe510ee87845280d0760cb292aef9d2eb69e67c1",
73
75
  "types": "es/index.d.ts"
74
76
  }