@webstudio-is/react-sdk 0.294.0 → 0.296.0
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/lib/index.js +31 -30
- package/package.json +9 -9
package/lib/index.js
CHANGED
|
@@ -252,10 +252,7 @@ import {
|
|
|
252
252
|
} from "@webstudio-is/sdk";
|
|
253
253
|
import { transpileExpression } from "@webstudio-is/expression";
|
|
254
254
|
import { indexProperty, tagProperty } from "@webstudio-is/sdk/runtime";
|
|
255
|
-
import {
|
|
256
|
-
getJsxPropName,
|
|
257
|
-
mapAttributeNames
|
|
258
|
-
} from "@webstudio-is/content-engine/jsx-attributes";
|
|
255
|
+
import { getJsxPropName } from "@webstudio-is/content-engine/jsx-attributes";
|
|
259
256
|
var generateAction = ({
|
|
260
257
|
scope,
|
|
261
258
|
prop,
|
|
@@ -378,11 +375,7 @@ ${tagProperty}=${JSON.stringify(instance.tag)}`;
|
|
|
378
375
|
let collectionDataValue;
|
|
379
376
|
let collectionItemValue;
|
|
380
377
|
let collectionItemKeyValue;
|
|
381
|
-
|
|
382
|
-
const instanceProps = Array.from(props.values()).filter(
|
|
383
|
-
(prop) => prop.instanceId === instance.id
|
|
384
|
-
);
|
|
385
|
-
const instancePropNames = new Set(instanceProps.map((prop) => prop.name));
|
|
378
|
+
const classNameValues = [];
|
|
386
379
|
const projectedResourceProps = /* @__PURE__ */ new Map();
|
|
387
380
|
const componentPropNames = new Set(Object.keys(meta?.props ?? {}));
|
|
388
381
|
const acceptsHtmlAttributes = hasTags || instance.tag !== void 0 || instance.component === elementComponent;
|
|
@@ -391,36 +384,45 @@ ${tagProperty}=${JSON.stringify(instance.tag)}`;
|
|
|
391
384
|
componentPropNames,
|
|
392
385
|
acceptsHtmlAttributes
|
|
393
386
|
});
|
|
394
|
-
const
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
387
|
+
const propsByGeneratedName = /* @__PURE__ */ new Map();
|
|
388
|
+
const classProps = /* @__PURE__ */ new Map();
|
|
389
|
+
for (const prop of props.values()) {
|
|
390
|
+
if (prop.instanceId !== instance.id || isAttributeNameSafe(prop.name) === false) {
|
|
391
|
+
continue;
|
|
392
|
+
}
|
|
393
|
+
const name = getGeneratedPropName(prop.name);
|
|
394
|
+
if (name === "className") {
|
|
395
|
+
classProps.set(prop.name, prop);
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
propsByGeneratedName.set(name, prop);
|
|
399
|
+
}
|
|
400
|
+
const generatedPropNames = /* @__PURE__ */ new Set([
|
|
401
|
+
...propsByGeneratedName.keys(),
|
|
402
|
+
...classProps.size > 0 ? ["className"] : []
|
|
403
|
+
]);
|
|
404
|
+
for (const [name, prop] of [
|
|
405
|
+
...propsByGeneratedName,
|
|
406
|
+
...Array.from(classProps.values(), (prop2) => ["className", prop2])
|
|
407
|
+
]) {
|
|
403
408
|
const propValue = generatePropValue({
|
|
404
409
|
scope,
|
|
405
410
|
prop,
|
|
406
411
|
dataSources,
|
|
407
412
|
usedDataSources
|
|
408
413
|
});
|
|
409
|
-
if (isAttributeNameSafe(prop.name) === false) {
|
|
410
|
-
continue;
|
|
411
|
-
}
|
|
412
414
|
if (prop.type === "resource") {
|
|
413
415
|
const propMeta = meta?.props?.[prop.name];
|
|
414
416
|
const resource = resources?.get(prop.value);
|
|
415
417
|
if (propMeta?.type === "resource" && resource !== void 0) {
|
|
416
|
-
for (const
|
|
417
|
-
|
|
418
|
-
|
|
418
|
+
for (const propName of propMeta.generatedProps ?? []) {
|
|
419
|
+
const generatedPropName = getGeneratedPropName(propName);
|
|
420
|
+
if (generatedPropNames.has(generatedPropName) === false && isAttributeNameSafe(propName)) {
|
|
421
|
+
projectedResourceProps.set(generatedPropName, resource[propName]);
|
|
419
422
|
}
|
|
420
423
|
}
|
|
421
424
|
}
|
|
422
425
|
}
|
|
423
|
-
const name = generatedPropNames.get(prop.id) ?? prop.name;
|
|
424
426
|
if (prop.name === showAttribute) {
|
|
425
427
|
if (propValue === "true") {
|
|
426
428
|
continue;
|
|
@@ -444,7 +446,7 @@ ${tagProperty}=${JSON.stringify(instance.tag)}`;
|
|
|
444
446
|
continue;
|
|
445
447
|
}
|
|
446
448
|
if (name === "className" && propValue !== void 0) {
|
|
447
|
-
|
|
449
|
+
classNameValues.push(propValue);
|
|
448
450
|
continue;
|
|
449
451
|
}
|
|
450
452
|
if (propValue !== void 0) {
|
|
@@ -452,15 +454,14 @@ ${tagProperty}=${JSON.stringify(instance.tag)}`;
|
|
|
452
454
|
${name}={${propValue}}`;
|
|
453
455
|
}
|
|
454
456
|
}
|
|
455
|
-
for (const [
|
|
456
|
-
const name = getGeneratedPropName(propName);
|
|
457
|
+
for (const [name, value] of projectedResourceProps) {
|
|
457
458
|
generatedProps += `
|
|
458
459
|
${name}={${JSON.stringify(value)}}`;
|
|
459
460
|
}
|
|
460
461
|
const classMapArray = classesMap?.get(instance.id);
|
|
461
|
-
if (classMapArray ||
|
|
462
|
+
if (classMapArray || classNameValues.length > 0) {
|
|
462
463
|
let classNameTemplate = classMapArray ? classMapArray.join(" ") : "";
|
|
463
|
-
|
|
464
|
+
for (const classNameValue of classNameValues) {
|
|
464
465
|
if (classNameTemplate) {
|
|
465
466
|
classNameTemplate += " ";
|
|
466
467
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/react-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.296.0",
|
|
4
4
|
"description": "Webstudio JavaScript / TypeScript API",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"typescript": "7.0.2",
|
|
16
16
|
"vitest": "^3.1.2",
|
|
17
17
|
"zod": "^4.4.3",
|
|
18
|
-
"@webstudio-is/template": "0.
|
|
18
|
+
"@webstudio-is/template": "0.296.0",
|
|
19
19
|
"@webstudio-is/tsconfig": "1.0.7"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
@@ -26,13 +26,13 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"change-case": "^5.4.4",
|
|
28
28
|
"nanoid": "^5.1.5",
|
|
29
|
-
"@webstudio-is/
|
|
30
|
-
"@webstudio-is/css-engine": "0.
|
|
31
|
-
"@webstudio-is/
|
|
32
|
-
"@webstudio-is/
|
|
33
|
-
"@webstudio-is/icons": "^0.
|
|
34
|
-
"@webstudio-is/sdk": "0.
|
|
35
|
-
"@webstudio-is/image": "0.
|
|
29
|
+
"@webstudio-is/expression": "0.296.0",
|
|
30
|
+
"@webstudio-is/css-engine": "0.296.0",
|
|
31
|
+
"@webstudio-is/content-engine": "0.296.0",
|
|
32
|
+
"@webstudio-is/fonts": "0.296.0",
|
|
33
|
+
"@webstudio-is/icons": "^0.296.0",
|
|
34
|
+
"@webstudio-is/sdk": "0.296.0",
|
|
35
|
+
"@webstudio-is/image": "0.296.0"
|
|
36
36
|
},
|
|
37
37
|
"exports": {
|
|
38
38
|
".": {
|