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