@micromag/element-urbania-author 0.4.71 → 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 +317 -107
  2. package/package.json +12 -10
package/es/index.js CHANGED
@@ -1,6 +1,4 @@
1
- import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
- import _objectSpread from '@babel/runtime/helpers/objectSpread2';
3
- import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
1
+ import { c } from 'react/compiler-runtime';
4
2
  import classNames from 'classnames';
5
3
  import { useIntl } from 'react-intl';
6
4
  import { getOptimalImageUrl, pascalCase, isTextFilled } from '@micromag/core/utils';
@@ -11,122 +9,334 @@ import { jsx, jsxs } from 'react/jsx-runtime';
11
9
 
12
10
  var styles$1 = {"container":"micromag-element-urbania-author-avatar-container","shapeCircle":"micromag-element-urbania-author-avatar-shapeCircle","shape":"micromag-element-urbania-author-avatar-shape"};
13
11
 
14
- function Avatar(_ref) {
15
- var _ref$image = _ref.image,
16
- image = _ref$image === void 0 ? null : _ref$image,
17
- _ref$width = _ref.width,
18
- width = _ref$width === void 0 ? 100 : _ref$width,
19
- _ref$height = _ref.height,
20
- height = _ref$height === void 0 ? 100 : _ref$height,
21
- _ref$resolution = _ref.resolution,
22
- resolution = _ref$resolution === void 0 ? 1 : _ref$resolution,
23
- _ref$shape = _ref.shape,
24
- shape = _ref$shape === void 0 ? 'circle' : _ref$shape,
25
- _ref$isTag = _ref.isTag,
26
- isTag = _ref$isTag === void 0 ? false : _ref$isTag,
27
- _ref$className = _ref.className,
28
- className = _ref$className === void 0 ? null : _ref$className,
29
- _ref$shouldLoad = _ref.shouldLoad,
30
- shouldLoad = _ref$shouldLoad === void 0 ? true : _ref$shouldLoad;
31
- var supportsWebp = useSetting('supportsWebp', false);
32
- var imageResolution = useSetting('imageResolution', resolution);
33
- var imageAtSize = getOptimalImageUrl(image, width, height, {
34
- resolution: imageResolution,
35
- supportsWebp: supportsWebp
36
- });
37
- var finalShape = shape !== null ? pascalCase(shape) : null;
38
- return /*#__PURE__*/jsx("span", {
39
- className: classNames([styles$1.container, _defineProperty(_defineProperty({}, styles$1["shape".concat(finalShape)], finalShape !== null), styles$1.isTag, isTag), className]),
40
- children: /*#__PURE__*/jsx("span", {
12
+ function Avatar(t0) {
13
+ const $ = c(18);
14
+ const {
15
+ image: t1,
16
+ width: t2,
17
+ height: t3,
18
+ resolution: t4,
19
+ shape: t5,
20
+ isTag: t6,
21
+ className: t7,
22
+ shouldLoad: t8
23
+ } = t0;
24
+ const image = t1 === undefined ? null : t1;
25
+ const width = t2 === undefined ? 100 : t2;
26
+ const height = t3 === undefined ? 100 : t3;
27
+ const resolution = t4 === undefined ? 1 : t4;
28
+ const shape = t5 === undefined ? "circle" : t5;
29
+ const isTag = t6 === undefined ? false : t6;
30
+ const className = t7 === undefined ? null : t7;
31
+ const shouldLoad = t8 === undefined ? true : t8;
32
+ const supportsWebp = useSetting("supportsWebp", false);
33
+ const imageResolution = useSetting("imageResolution", resolution);
34
+ let t9;
35
+ if ($[0] !== height || $[1] !== image || $[2] !== imageResolution || $[3] !== supportsWebp || $[4] !== width) {
36
+ t9 = getOptimalImageUrl(image, width, height, {
37
+ resolution: imageResolution,
38
+ supportsWebp
39
+ });
40
+ $[0] = height;
41
+ $[1] = image;
42
+ $[2] = imageResolution;
43
+ $[3] = supportsWebp;
44
+ $[4] = width;
45
+ $[5] = t9;
46
+ } else {
47
+ t9 = $[5];
48
+ }
49
+ const imageAtSize = t9;
50
+ let t10;
51
+ if ($[6] !== shape) {
52
+ t10 = shape !== null ? pascalCase(shape) : null;
53
+ $[6] = shape;
54
+ $[7] = t10;
55
+ } else {
56
+ t10 = $[7];
57
+ }
58
+ const finalShape = t10;
59
+ const t11 = styles$1[`shape${finalShape}`];
60
+ const t12 = finalShape !== null;
61
+ let t13;
62
+ if ($[8] !== className || $[9] !== isTag || $[10] !== t11 || $[11] !== t12) {
63
+ t13 = classNames([styles$1.container, {
64
+ [t11]: t12,
65
+ [styles$1.isTag]: isTag
66
+ }, className]);
67
+ $[8] = className;
68
+ $[9] = isTag;
69
+ $[10] = t11;
70
+ $[11] = t12;
71
+ $[12] = t13;
72
+ } else {
73
+ t13 = $[12];
74
+ }
75
+ const t14 = shouldLoad ? `url("${imageAtSize}")` : null;
76
+ let t15;
77
+ if ($[13] !== t14) {
78
+ t15 = /*#__PURE__*/jsx("span", {
41
79
  className: styles$1.shape,
42
80
  style: {
43
- backgroundImage: shouldLoad ? "url(\"".concat(imageAtSize, "\")") : null
81
+ backgroundImage: t14
44
82
  }
45
- })
46
- });
83
+ });
84
+ $[13] = t14;
85
+ $[14] = t15;
86
+ } else {
87
+ t15 = $[14];
88
+ }
89
+ let t16;
90
+ if ($[15] !== t13 || $[16] !== t15) {
91
+ t16 = /*#__PURE__*/jsx("span", {
92
+ className: t13,
93
+ children: t15
94
+ });
95
+ $[15] = t13;
96
+ $[16] = t15;
97
+ $[17] = t16;
98
+ } else {
99
+ t16 = $[17];
100
+ }
101
+ return t16;
47
102
  }
48
103
 
49
104
  var styles = {"container":"micromag-element-urbania-author-container","image":"micromag-element-urbania-author-image","link":"micromag-element-urbania-author-link","right":"micromag-element-urbania-author-right","name":"micromag-element-urbania-author-name","prefix":"micromag-element-urbania-author-prefix","collaborator":"micromag-element-urbania-author-collaborator","collaboratorText":"micromag-element-urbania-author-collaboratorText","isSmall":"micromag-element-urbania-author-isSmall","withoutImage":"micromag-element-urbania-author-withoutImage","withoutBackground":"micromag-element-urbania-author-withoutBackground"};
50
105
 
51
- var _excluded = ["author", "withImage", "withoutLink", "withoutPrefix", "withoutBackground", "isSmall", "linkUnderlineColor", "className", "backgroundClassName", "collaboratorClassName", "shouldLoad"];
52
- function UrbaniaAuthor(_ref) {
53
- var _ref$author = _ref.author,
54
- author = _ref$author === void 0 ? null : _ref$author,
55
- _ref$withImage = _ref.withImage,
56
- withImage = _ref$withImage === void 0 ? true : _ref$withImage,
57
- _ref$withoutLink = _ref.withoutLink,
58
- withoutLink = _ref$withoutLink === void 0 ? false : _ref$withoutLink,
59
- _ref$withoutPrefix = _ref.withoutPrefix,
60
- withoutPrefix = _ref$withoutPrefix === void 0 ? false : _ref$withoutPrefix,
61
- _ref$withoutBackgroun = _ref.withoutBackground,
62
- withoutBackground = _ref$withoutBackgroun === void 0 ? false : _ref$withoutBackgroun,
63
- _ref$isSmall = _ref.isSmall,
64
- isSmall = _ref$isSmall === void 0 ? false : _ref$isSmall,
65
- _ref$linkUnderlineCol = _ref.linkUnderlineColor,
66
- linkUnderlineColor = _ref$linkUnderlineCol === void 0 ? null : _ref$linkUnderlineCol,
67
- _ref$className = _ref.className,
68
- className = _ref$className === void 0 ? null : _ref$className,
69
- _ref$backgroundClassN = _ref.backgroundClassName,
70
- backgroundClassName = _ref$backgroundClassN === void 0 ? null : _ref$backgroundClassN,
71
- _ref$collaboratorClas = _ref.collaboratorClassName,
72
- collaboratorClassName = _ref$collaboratorClas === void 0 ? null : _ref$collaboratorClas,
73
- _ref$shouldLoad = _ref.shouldLoad,
74
- shouldLoad = _ref$shouldLoad === void 0 ? true : _ref$shouldLoad,
75
- otherProps = _objectWithoutProperties(_ref, _excluded);
76
- var intl = useIntl();
77
- var _ref2 = author || {},
78
- _ref2$name = _ref2.name,
79
- name = _ref2$name === void 0 ? null : _ref2$name,
80
- _ref2$image = _ref2.image,
81
- image = _ref2$image === void 0 ? null : _ref2$image,
82
- _ref2$url = _ref2.url,
83
- url = _ref2$url === void 0 ? null : _ref2$url,
84
- _ref2$collaborator = _ref2.collaborator,
85
- collaborator = _ref2$collaborator === void 0 ? null : _ref2$collaborator;
86
- var withAvatar = withImage && image !== null;
87
- var prefix = intl.formatMessage({
88
- id: "jEK6B8",
89
- defaultMessage: [{
90
- "type": 0,
91
- "value": "By"
92
- }]
93
- });
94
- var authorText = isTextFilled(name) ? /*#__PURE__*/jsx(Text, _objectSpread({
95
- className: classNames([styles.name, backgroundClassName])
96
- }, name)) : null;
97
- var collaboratorText = isTextFilled(collaborator) ? /*#__PURE__*/jsx(Text, _objectSpread(_objectSpread({
98
- className: styles.collaboratorText
99
- }, collaborator), {}, {
100
- inline: true
101
- })) : null;
102
- return /*#__PURE__*/jsxs("div", _objectSpread(_objectSpread({
103
- className: classNames([styles.container, className, _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, styles.isSmall, isSmall), styles.withoutAvatar, withAvatar), styles.withoutImage, !withImage || image === null), styles.withoutBackground, withoutBackground)])
104
- }, otherProps), {}, {
105
- children: [!withoutPrefix ? /*#__PURE__*/jsx(Text, _objectSpread(_objectSpread({}, name), {}, {
106
+ function UrbaniaAuthor(t0) {
107
+ const $ = c(54);
108
+ let otherProps;
109
+ let t1;
110
+ let t10;
111
+ let t11;
112
+ let t2;
113
+ let t3;
114
+ let t4;
115
+ let t5;
116
+ let t6;
117
+ let t7;
118
+ let t8;
119
+ let t9;
120
+ if ($[0] !== t0) {
121
+ ({
122
+ author: t1,
123
+ withImage: t2,
124
+ withoutLink: t3,
125
+ withoutPrefix: t4,
126
+ withoutBackground: t5,
127
+ isSmall: t6,
128
+ linkUnderlineColor: t7,
129
+ className: t8,
130
+ backgroundClassName: t9,
131
+ collaboratorClassName: t10,
132
+ shouldLoad: t11,
133
+ ...otherProps
134
+ } = t0);
135
+ $[0] = t0;
136
+ $[1] = otherProps;
137
+ $[2] = t1;
138
+ $[3] = t10;
139
+ $[4] = t11;
140
+ $[5] = t2;
141
+ $[6] = t3;
142
+ $[7] = t4;
143
+ $[8] = t5;
144
+ $[9] = t6;
145
+ $[10] = t7;
146
+ $[11] = t8;
147
+ $[12] = t9;
148
+ } else {
149
+ otherProps = $[1];
150
+ t1 = $[2];
151
+ t10 = $[3];
152
+ t11 = $[4];
153
+ t2 = $[5];
154
+ t3 = $[6];
155
+ t4 = $[7];
156
+ t5 = $[8];
157
+ t6 = $[9];
158
+ t7 = $[10];
159
+ t8 = $[11];
160
+ t9 = $[12];
161
+ }
162
+ const author = t1 === undefined ? null : t1;
163
+ const withImage = t2 === undefined ? true : t2;
164
+ const withoutLink = t3 === undefined ? false : t3;
165
+ const withoutPrefix = t4 === undefined ? false : t4;
166
+ const withoutBackground = t5 === undefined ? false : t5;
167
+ const isSmall = t6 === undefined ? false : t6;
168
+ const linkUnderlineColor = t7 === undefined ? null : t7;
169
+ const className = t8 === undefined ? null : t8;
170
+ const backgroundClassName = t9 === undefined ? null : t9;
171
+ const collaboratorClassName = t10 === undefined ? null : t10;
172
+ const shouldLoad = t11 === undefined ? true : t11;
173
+ const intl = useIntl();
174
+ let t12;
175
+ if ($[13] !== author) {
176
+ t12 = author || {};
177
+ $[13] = author;
178
+ $[14] = t12;
179
+ } else {
180
+ t12 = $[14];
181
+ }
182
+ const {
183
+ name: t13,
184
+ image: t14,
185
+ url: t15,
186
+ collaborator: t16
187
+ } = t12;
188
+ const name = t13 === undefined ? null : t13;
189
+ const image = t14 === undefined ? null : t14;
190
+ const url = t15 === undefined ? null : t15;
191
+ const collaborator = t16 === undefined ? null : t16;
192
+ const withAvatar = withImage && image !== null;
193
+ let t17;
194
+ if ($[15] !== intl) {
195
+ t17 = intl.formatMessage({
196
+ id: "jEK6B8",
197
+ defaultMessage: "By"
198
+ });
199
+ $[15] = intl;
200
+ $[16] = t17;
201
+ } else {
202
+ t17 = $[16];
203
+ }
204
+ const prefix = t17;
205
+ let t18;
206
+ if ($[17] !== backgroundClassName || $[18] !== name) {
207
+ t18 = isTextFilled(name) ? /*#__PURE__*/jsx(Text, {
208
+ className: classNames([styles.name, backgroundClassName]),
209
+ ...name
210
+ }) : null;
211
+ $[17] = backgroundClassName;
212
+ $[18] = name;
213
+ $[19] = t18;
214
+ } else {
215
+ t18 = $[19];
216
+ }
217
+ const authorText = t18;
218
+ let t19;
219
+ if ($[20] !== collaborator) {
220
+ t19 = isTextFilled(collaborator) ? /*#__PURE__*/jsx(Text, {
221
+ className: styles.collaboratorText,
222
+ ...collaborator,
223
+ inline: true
224
+ }) : null;
225
+ $[20] = collaborator;
226
+ $[21] = t19;
227
+ } else {
228
+ t19 = $[21];
229
+ }
230
+ const collaboratorText = t19;
231
+ const t20 = !withImage || image === null;
232
+ let t21;
233
+ if ($[22] !== className || $[23] !== isSmall || $[24] !== t20 || $[25] !== withAvatar || $[26] !== withoutBackground) {
234
+ t21 = classNames([styles.container, className, {
235
+ [styles.isSmall]: isSmall,
236
+ [styles.withoutAvatar]: withAvatar,
237
+ [styles.withoutImage]: t20,
238
+ [styles.withoutBackground]: withoutBackground
239
+ }]);
240
+ $[22] = className;
241
+ $[23] = isSmall;
242
+ $[24] = t20;
243
+ $[25] = withAvatar;
244
+ $[26] = withoutBackground;
245
+ $[27] = t21;
246
+ } else {
247
+ t21 = $[27];
248
+ }
249
+ let t22;
250
+ if ($[28] !== backgroundClassName || $[29] !== name || $[30] !== prefix || $[31] !== withoutPrefix) {
251
+ t22 = !withoutPrefix ? /*#__PURE__*/jsx(Text, {
252
+ ...name,
106
253
  className: classNames([styles.prefix, backgroundClassName]),
107
- body: "<span>".concat(prefix, "<span>")
108
- })) : null, withAvatar ? /*#__PURE__*/jsx(Avatar, {
254
+ body: `<span>${prefix}<span>`
255
+ }) : null;
256
+ $[28] = backgroundClassName;
257
+ $[29] = name;
258
+ $[30] = prefix;
259
+ $[31] = withoutPrefix;
260
+ $[32] = t22;
261
+ } else {
262
+ t22 = $[32];
263
+ }
264
+ let t23;
265
+ if ($[33] !== image || $[34] !== shouldLoad || $[35] !== withAvatar) {
266
+ t23 = withAvatar ? /*#__PURE__*/jsx(Avatar, {
109
267
  className: styles.image,
110
268
  image: image,
111
269
  shouldLoad: shouldLoad
112
- }) : null, /*#__PURE__*/jsxs("div", {
270
+ }) : null;
271
+ $[33] = image;
272
+ $[34] = shouldLoad;
273
+ $[35] = withAvatar;
274
+ $[36] = t23;
275
+ } else {
276
+ t23 = $[36];
277
+ }
278
+ let t24;
279
+ if ($[37] !== authorText || $[38] !== linkUnderlineColor || $[39] !== url || $[40] !== withoutLink) {
280
+ t24 = url !== null && !withoutLink ? /*#__PURE__*/jsx(Link, {
281
+ className: styles.link,
282
+ url: url,
283
+ external: true,
284
+ style: {
285
+ backgroundImage: linkUnderlineColor !== null ? `linear-gradient(0deg, ${linkUnderlineColor} 0, ${linkUnderlineColor})` : null
286
+ },
287
+ children: authorText
288
+ }) : /*#__PURE__*/jsx("div", {
289
+ children: authorText
290
+ });
291
+ $[37] = authorText;
292
+ $[38] = linkUnderlineColor;
293
+ $[39] = url;
294
+ $[40] = withoutLink;
295
+ $[41] = t24;
296
+ } else {
297
+ t24 = $[41];
298
+ }
299
+ let t25;
300
+ if ($[42] !== collaboratorClassName || $[43] !== collaboratorText) {
301
+ t25 = collaboratorText !== null ? /*#__PURE__*/jsx("div", {
302
+ className: classNames([styles.collaborator, collaboratorClassName]),
303
+ children: collaboratorText !== null ? collaboratorText : null
304
+ }) : null;
305
+ $[42] = collaboratorClassName;
306
+ $[43] = collaboratorText;
307
+ $[44] = t25;
308
+ } else {
309
+ t25 = $[44];
310
+ }
311
+ let t26;
312
+ if ($[45] !== t24 || $[46] !== t25) {
313
+ t26 = /*#__PURE__*/jsxs("div", {
113
314
  className: styles.right,
114
- children: [url !== null && !withoutLink ? /*#__PURE__*/jsx(Link, {
115
- className: styles.link,
116
- url: url,
117
- external: true,
118
- style: {
119
- backgroundImage: linkUnderlineColor !== null ? "linear-gradient(0deg, ".concat(linkUnderlineColor, " 0, ").concat(linkUnderlineColor, ")") : null
120
- },
121
- children: authorText
122
- }) : /*#__PURE__*/jsx("div", {
123
- children: authorText
124
- }), collaboratorText !== null ? /*#__PURE__*/jsx("div", {
125
- className: classNames([styles.collaborator, collaboratorClassName]),
126
- children: collaboratorText !== null ? collaboratorText : null
127
- }) : null]
128
- })]
129
- }));
315
+ children: [t24, t25]
316
+ });
317
+ $[45] = t24;
318
+ $[46] = t25;
319
+ $[47] = t26;
320
+ } else {
321
+ t26 = $[47];
322
+ }
323
+ let t27;
324
+ if ($[48] !== otherProps || $[49] !== t21 || $[50] !== t22 || $[51] !== t23 || $[52] !== t26) {
325
+ t27 = /*#__PURE__*/jsxs("div", {
326
+ className: t21,
327
+ ...otherProps,
328
+ children: [t22, t23, t26]
329
+ });
330
+ $[48] = otherProps;
331
+ $[49] = t21;
332
+ $[50] = t22;
333
+ $[51] = t23;
334
+ $[52] = t26;
335
+ $[53] = t27;
336
+ } else {
337
+ t27 = $[53];
338
+ }
339
+ return t27;
130
340
  }
131
341
 
132
342
  export { UrbaniaAuthor as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/element-urbania-author",
3
- "version": "0.4.71",
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,19 +53,19 @@
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.71",
64
- "@micromag/element-button": "^0.4.71",
65
- "@micromag/element-link": "^0.4.71",
66
- "@micromag/element-text": "^0.4.71",
65
+ "@micromag/core": "^0.4.74",
66
+ "@micromag/element-button": "^0.4.74",
67
+ "@micromag/element-link": "^0.4.74",
68
+ "@micromag/element-text": "^0.4.74",
67
69
  "classnames": "^2.2.6",
68
70
  "lodash": "^4.17.23",
69
71
  "react-intl": "^8.1.3 || ^10.0.0",
@@ -73,6 +75,6 @@
73
75
  "access": "public",
74
76
  "registry": "https://registry.npmjs.org/"
75
77
  },
76
- "gitHead": "9101554bc5761e32b4a002a10d26800608c69773",
78
+ "gitHead": "fe510ee87845280d0760cb292aef9d2eb69e67c1",
77
79
  "types": "es/index.d.ts"
78
80
  }