@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.
- package/es/index.js +249 -67
- package/package.json +9 -7
package/es/index.js
CHANGED
|
@@ -1,86 +1,268 @@
|
|
|
1
|
-
import
|
|
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
|
|
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(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
textStyle
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
54
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
|
80
|
-
|
|
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
|
|
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.
|
|
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": "^
|
|
55
|
-
"react-dom": "^
|
|
56
|
+
"react": "^19.0.0",
|
|
57
|
+
"react-dom": "^19.0.0"
|
|
56
58
|
},
|
|
57
59
|
"peerDependencies": {
|
|
58
|
-
"react": "^
|
|
59
|
-
"react-dom": "^
|
|
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.
|
|
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": "
|
|
74
|
+
"gitHead": "fe510ee87845280d0760cb292aef9d2eb69e67c1",
|
|
73
75
|
"types": "es/index.d.ts"
|
|
74
76
|
}
|