storybook-addon-sdc 0.24.6 → 0.24.7

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/dist/preset.js +18 -3
  2. package/package.json +1 -1
package/dist/preset.js CHANGED
@@ -154,9 +154,24 @@ var renderComponent = (item) => {
154
154
  return `${kebabCaseName}.default.component({...${kebabCaseName}.Basic.baseArgs, ${storyArgs}, ${componentProps}})`;
155
155
  };
156
156
  var renderImage = (item) => {
157
- return JSON.stringify(
158
- `<img src="${item.uri}"${toAttributes(item.attributes)}>`
159
- );
157
+ const attrs = { ...item.attributes ?? {} };
158
+ if (item.uri != null) attrs.src = item.uri;
159
+ if (Array.isArray(item.srcset) && item.srcset.length > 0) {
160
+ attrs.srcset = item.srcset.map(
161
+ (s) => s && typeof s === "object" ? [s.uri, s.width].filter(Boolean).join(" ") : s
162
+ ).join(", ");
163
+ }
164
+ const mapped = {
165
+ width: item.width,
166
+ height: item.height,
167
+ alt: item.alt ?? "",
168
+ sizes: item.sizes,
169
+ title: item.title
170
+ };
171
+ for (const key of ["width", "height", "alt", "sizes", "title"]) {
172
+ if (mapped[key] != null) attrs[key] = mapped[key];
173
+ }
174
+ return JSON.stringify(`<img${toAttributes(attrs)} />`);
160
175
  };
161
176
  var renderElement = (item) => {
162
177
  return JSON.stringify(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storybook-addon-sdc",
3
- "version": "0.24.6",
3
+ "version": "0.24.7",
4
4
  "description": "Drupal Single Directory Components as stories",
5
5
  "keywords": [
6
6
  "SDC",