@webstudio-is/react-sdk 0.87.1 → 0.88.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/src/props.ts CHANGED
@@ -31,7 +31,6 @@ export const useInstanceProps = (instanceId: Instance["id"]) => {
31
31
  dataSourceValuesStore,
32
32
  executeEffectfulExpression,
33
33
  setDataSourceValues,
34
- renderer,
35
34
  indexesWithinAncestors,
36
35
  } = useContext(ReactSdkContext);
37
36
  const index = indexesWithinAncestors.get(instanceId);
@@ -61,10 +60,6 @@ export const useInstanceProps = (instanceId: Instance["id"]) => {
61
60
  }
62
61
  if (prop.type === "action") {
63
62
  instancePropsObject[prop.name] = (...args: unknown[]) => {
64
- // prevent all actions in canvas mode
65
- if (renderer === "canvas") {
66
- return;
67
- }
68
63
  for (const value of prop.value) {
69
64
  if (value.type === "execute") {
70
65
  const argsMap = new Map<string, unknown>();
@@ -91,7 +86,6 @@ export const useInstanceProps = (instanceId: Instance["id"]) => {
91
86
  propsByInstanceIdStore,
92
87
  dataSourceValuesStore,
93
88
  instanceId,
94
- renderer,
95
89
  executeEffectfulExpression,
96
90
  setDataSourceValues,
97
91
  index,
@@ -147,54 +141,64 @@ export const resolveUrlProp = (
147
141
  if (instanceProps === undefined) {
148
142
  return;
149
143
  }
150
- for (const prop of instanceProps) {
151
- if (prop.name !== name) {
144
+
145
+ let prop = undefined;
146
+
147
+ // We had a bug that some props were duplicated https://github.com/webstudio-is/webstudio-builder/pull/2170
148
+ // Use the latest prop to ensure consistency with the builder settings panel.
149
+ for (const intanceProp of instanceProps) {
150
+ if (intanceProp.name !== name) {
152
151
  continue;
153
152
  }
153
+ prop = intanceProp;
154
+ }
154
155
 
155
- if (prop.type === "page") {
156
- if (typeof prop.value === "string") {
157
- const page = pages.get(prop.value);
158
- return page && { type: "page", page };
159
- }
156
+ if (prop === undefined) {
157
+ return;
158
+ }
160
159
 
161
- const { instanceId, pageId } = prop.value;
160
+ if (prop.type === "page") {
161
+ if (typeof prop.value === "string") {
162
+ const page = pages.get(prop.value);
163
+ return page && { type: "page", page };
164
+ }
162
165
 
163
- const page = pages.get(pageId);
166
+ const { instanceId, pageId } = prop.value;
164
167
 
165
- if (page === undefined) {
166
- return;
167
- }
168
+ const page = pages.get(pageId);
168
169
 
169
- const idProp = props.get(instanceId)?.find((prop) => prop.name === "id");
170
-
171
- return {
172
- type: "page",
173
- page,
174
- instanceId,
175
- hash:
176
- idProp === undefined || idProp.type !== "string"
177
- ? undefined
178
- : idProp.value,
179
- };
170
+ if (page === undefined) {
171
+ return;
180
172
  }
181
173
 
182
- if (prop.type === "string") {
183
- for (const page of pages.values()) {
184
- if (page.path === prop.value) {
185
- return { type: "page", page };
186
- }
187
- }
188
- return { type: "string", url: prop.value };
189
- }
174
+ const idProp = props.get(instanceId)?.find((prop) => prop.name === "id");
175
+
176
+ return {
177
+ type: "page",
178
+ page,
179
+ instanceId,
180
+ hash:
181
+ idProp === undefined || idProp.type !== "string"
182
+ ? undefined
183
+ : idProp.value,
184
+ };
185
+ }
190
186
 
191
- if (prop.type === "asset") {
192
- const asset = assets.get(prop.value);
193
- return asset && { type: "asset", asset };
187
+ if (prop.type === "string") {
188
+ for (const page of pages.values()) {
189
+ if (page.path === prop.value) {
190
+ return { type: "page", page };
191
+ }
194
192
  }
193
+ return { type: "string", url: prop.value };
194
+ }
195
195
 
196
- return;
196
+ if (prop.type === "asset") {
197
+ const asset = assets.get(prop.value);
198
+ return asset && { type: "asset", asset };
197
199
  }
200
+
201
+ return;
198
202
  };
199
203
 
200
204
  // this utility is used for link component in both builder and preview