@webstudio-is/sdk-components-react 0.168.0 → 0.174.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/components.js +76 -45
- package/lib/metas.js +223 -64
- package/lib/props.js +1273 -6
- package/lib/types/__generated__/option.props.d.ts +2 -0
- package/lib/types/__generated__/select.props.d.ts +2 -0
- package/lib/types/blockquote.d.ts +0 -1
- package/lib/types/body.d.ts +0 -1
- package/lib/types/bold.d.ts +0 -1
- package/lib/types/button.d.ts +0 -1
- package/lib/types/checkbox.d.ts +1 -2
- package/lib/types/code-text.d.ts +1 -2
- package/lib/types/components.d.ts +2 -0
- package/lib/types/form.d.ts +0 -1
- package/lib/types/hooks.d.ts +2 -0
- package/lib/types/html-embed.d.ts +1 -1
- package/lib/types/html-embed.test.d.ts +1 -1
- package/lib/types/image.d.ts +3 -1
- package/lib/types/input.d.ts +1 -2
- package/lib/types/italic.d.ts +0 -1
- package/lib/types/label.d.ts +0 -1
- package/lib/types/list-item.d.ts +0 -1
- package/lib/types/metas.d.ts +2 -0
- package/lib/types/option.d.ts +2 -0
- package/lib/types/option.ws.d.ts +3 -0
- package/lib/types/paragraph.d.ts +0 -1
- package/lib/types/props.d.ts +2 -0
- package/lib/types/radio-button.d.ts +1 -2
- package/lib/types/select.d.ts +4 -0
- package/lib/types/select.ws.d.ts +3 -0
- package/lib/types/separator.d.ts +0 -1
- package/lib/types/span.d.ts +0 -1
- package/lib/types/subscript.d.ts +0 -1
- package/lib/types/superscript.d.ts +0 -1
- package/lib/types/textarea.d.ts +0 -1
- package/lib/types/vimeo-play-button.d.ts +0 -1
- package/lib/types/vimeo-preview-image.d.ts +17 -17
- package/lib/types/vimeo-spinner.d.ts +0 -1
- package/lib/types/vimeo.d.ts +1 -1
- package/lib/types/xml-node.d.ts +2 -2
- package/package.json +13 -11
package/lib/components.js
CHANGED
|
@@ -28,7 +28,8 @@ import {
|
|
|
28
28
|
useEffect,
|
|
29
29
|
useRef,
|
|
30
30
|
useSyncExternalStore,
|
|
31
|
-
useState
|
|
31
|
+
useState,
|
|
32
|
+
useMemo
|
|
32
33
|
} from "react";
|
|
33
34
|
import { mergeRefs } from "@react-aria/utils";
|
|
34
35
|
import { ReactSdkContext } from "@webstudio-is/react-sdk";
|
|
@@ -48,7 +49,6 @@ var patchDomEvents = () => {
|
|
|
48
49
|
return;
|
|
49
50
|
}
|
|
50
51
|
domContentLoadedPatched = true;
|
|
51
|
-
console.info("Patching DOMContentLoaded event listener");
|
|
52
52
|
const originalAddEventListener = document.addEventListener;
|
|
53
53
|
const originalWindowAddEventListener = window.addEventListener;
|
|
54
54
|
const domContentLoadedEvent = new Event("DOMContentLoaded");
|
|
@@ -91,6 +91,7 @@ var insertScript = (sourceScript) => {
|
|
|
91
91
|
return new Promise((resolve, reject) => {
|
|
92
92
|
const script = document.createElement("script");
|
|
93
93
|
const hasSrc = sourceScript.hasAttribute("src");
|
|
94
|
+
const isTypeModule = sourceScript.type === "module";
|
|
94
95
|
for (const { name, value } of sourceScript.attributes) {
|
|
95
96
|
script.setAttribute(name, value);
|
|
96
97
|
}
|
|
@@ -103,6 +104,19 @@ var insertScript = (sourceScript) => {
|
|
|
103
104
|
});
|
|
104
105
|
script.addEventListener("error", reject);
|
|
105
106
|
} else {
|
|
107
|
+
if (isTypeModule) {
|
|
108
|
+
const blob = new Blob([sourceScript.innerText], {
|
|
109
|
+
type: "text/javascript"
|
|
110
|
+
});
|
|
111
|
+
const url = URL.createObjectURL(blob);
|
|
112
|
+
import(
|
|
113
|
+
/* @vite-ignore */
|
|
114
|
+
url
|
|
115
|
+
).then(resolve).catch(reject).finally(() => {
|
|
116
|
+
URL.revokeObjectURL(url);
|
|
117
|
+
});
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
106
120
|
script.textContent = sourceScript.innerText;
|
|
107
121
|
}
|
|
108
122
|
sourceScript.replaceWith(script);
|
|
@@ -120,7 +134,6 @@ var processSyncTasks = async (syncTasks) => {
|
|
|
120
134
|
return;
|
|
121
135
|
}
|
|
122
136
|
patchDomEvents();
|
|
123
|
-
console.info("Start processing sync tasks");
|
|
124
137
|
processing = true;
|
|
125
138
|
while (syncTasksQueue.length > 0) {
|
|
126
139
|
const task = syncTasksQueue.shift();
|
|
@@ -128,7 +141,6 @@ var processSyncTasks = async (syncTasks) => {
|
|
|
128
141
|
}
|
|
129
142
|
executeDomEvents();
|
|
130
143
|
processing = false;
|
|
131
|
-
console.info("Stop processing sync tasks");
|
|
132
144
|
};
|
|
133
145
|
var execute = (container) => {
|
|
134
146
|
const scripts = container.querySelectorAll("script");
|
|
@@ -147,7 +159,7 @@ var execute = (container) => {
|
|
|
147
159
|
};
|
|
148
160
|
var Placeholder = (props) => {
|
|
149
161
|
const { code, innerRef, ...rest } = props;
|
|
150
|
-
return /* @__PURE__ */ jsx3("div", { ref: innerRef, ...rest, style: { padding: 20 }, children: 'Open the "Settings" panel to insert HTML code.' });
|
|
162
|
+
return /* @__PURE__ */ jsx3("div", { ref: innerRef, ...rest, style: { display: "block", padding: 20 }, children: 'Open the "Settings" panel to insert HTML code.' });
|
|
151
163
|
};
|
|
152
164
|
var useIsServer = () => {
|
|
153
165
|
const isServer = useSyncExternalStore(
|
|
@@ -169,6 +181,12 @@ var ClientEmbed = (props) => {
|
|
|
169
181
|
const { code, innerRef, ...rest } = props;
|
|
170
182
|
const containerRef = useRef(null);
|
|
171
183
|
const executeScripts = useRef(true);
|
|
184
|
+
const html = useMemo(
|
|
185
|
+
() => ({
|
|
186
|
+
__html: code ?? ""
|
|
187
|
+
}),
|
|
188
|
+
[code]
|
|
189
|
+
);
|
|
172
190
|
useEffect(() => {
|
|
173
191
|
const container = containerRef.current;
|
|
174
192
|
if (container && executeScripts.current) {
|
|
@@ -181,8 +199,7 @@ var ClientEmbed = (props) => {
|
|
|
181
199
|
{
|
|
182
200
|
...rest,
|
|
183
201
|
ref: mergeRefs(innerRef, containerRef),
|
|
184
|
-
|
|
185
|
-
dangerouslySetInnerHTML: { __html: code ?? "" }
|
|
202
|
+
dangerouslySetInnerHTML: html
|
|
186
203
|
}
|
|
187
204
|
);
|
|
188
205
|
};
|
|
@@ -193,7 +210,6 @@ var ServerEmbed = (props) => {
|
|
|
193
210
|
{
|
|
194
211
|
...rest,
|
|
195
212
|
ref: innerRef,
|
|
196
|
-
style: { display: "contents" },
|
|
197
213
|
dangerouslySetInnerHTML: { __html: code ?? "" }
|
|
198
214
|
}
|
|
199
215
|
);
|
|
@@ -360,59 +376,56 @@ import {
|
|
|
360
376
|
import { Image as WebstudioImage } from "@webstudio-is/image";
|
|
361
377
|
import { ReactSdkContext as ReactSdkContext2 } from "@webstudio-is/react-sdk";
|
|
362
378
|
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
363
|
-
var imagePlaceholderSvg = `data:image/svg+xml;base64,${btoa(`<svg
|
|
364
|
-
width="140"
|
|
365
|
-
height="140"
|
|
366
|
-
viewBox="0 0 600 600"
|
|
367
|
-
fill="none"
|
|
368
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
369
|
-
>
|
|
370
|
-
<rect width="600" height="600" fill="#CCCCCC" />
|
|
371
|
-
<path
|
|
372
|
-
fill-rule="evenodd"
|
|
373
|
-
clip-rule="evenodd"
|
|
374
|
-
d="M450 170H150C141.716 170 135 176.716 135 185V415C135 423.284 141.716 430 150 430H450C458.284 430 465 423.284 465 415V185C465 176.716 458.284 170 450 170ZM150 145C127.909 145 110 162.909 110 185V415C110 437.091 127.909 455 150 455H450C472.091 455 490 437.091 490 415V185C490 162.909 472.091 145 450 145H150Z"
|
|
375
|
-
fill="#A2A2A2"
|
|
376
|
-
/>
|
|
377
|
-
<path
|
|
378
|
-
d="M237.135 235.012C237.135 255.723 220.345 272.512 199.635 272.512C178.924 272.512 162.135 255.723 162.135 235.012C162.135 214.301 178.924 197.512 199.635 197.512C220.345 197.512 237.135 214.301 237.135 235.012Z"
|
|
379
|
-
fill="#A2A2A2"
|
|
380
|
-
/>
|
|
381
|
-
<path
|
|
382
|
-
d="M160 405V367.205L221.609 306.364L256.552 338.628L358.161 234L440 316.043V405H160Z"
|
|
383
|
-
fill="#A2A2A2"
|
|
384
|
-
/>
|
|
385
|
-
</svg>`)}`;
|
|
386
379
|
var Image = forwardRef19(
|
|
387
|
-
({
|
|
380
|
+
({
|
|
381
|
+
loading = "lazy",
|
|
382
|
+
width,
|
|
383
|
+
height,
|
|
384
|
+
optimize = true,
|
|
385
|
+
decoding: decodingProp,
|
|
386
|
+
$webstudio$canvasOnly$assetId,
|
|
387
|
+
...props
|
|
388
|
+
}, ref) => {
|
|
388
389
|
const src = String(props.src ?? "");
|
|
389
390
|
const { imageLoader, renderer, assetBaseUrl } = useContext2(ReactSdkContext2);
|
|
391
|
+
let decoding = decodingProp;
|
|
392
|
+
let key = src;
|
|
390
393
|
if (renderer === "canvas") {
|
|
391
394
|
loading = "eager";
|
|
395
|
+
decoding = "sync";
|
|
396
|
+
key = $webstudio$canvasOnly$assetId ?? src;
|
|
397
|
+
if (width !== void 0 && height !== void 0 && Number.isNaN(width) && Number.isNaN(height)) {
|
|
398
|
+
optimize = false;
|
|
399
|
+
width = void 0;
|
|
400
|
+
height = void 0;
|
|
401
|
+
}
|
|
392
402
|
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
{
|
|
397
|
-
loading,
|
|
398
|
-
...props,
|
|
399
|
-
src: src || imagePlaceholderSvg,
|
|
400
|
-
ref
|
|
401
|
-
},
|
|
402
|
-
src
|
|
403
|
-
);
|
|
403
|
+
let assetName = src;
|
|
404
|
+
if (src.startsWith(assetBaseUrl)) {
|
|
405
|
+
assetName = src.slice(assetBaseUrl.length);
|
|
404
406
|
}
|
|
405
|
-
|
|
407
|
+
console.info(
|
|
408
|
+
"assetName",
|
|
409
|
+
assetName,
|
|
410
|
+
"src",
|
|
411
|
+
src,
|
|
412
|
+
"assetBaseUrl",
|
|
413
|
+
assetBaseUrl
|
|
414
|
+
);
|
|
406
415
|
return /* @__PURE__ */ jsx18(
|
|
407
416
|
WebstudioImage,
|
|
408
417
|
{
|
|
409
418
|
loading,
|
|
419
|
+
decoding,
|
|
420
|
+
optimize,
|
|
421
|
+
width,
|
|
422
|
+
height,
|
|
410
423
|
...props,
|
|
411
424
|
loader: imageLoader,
|
|
412
425
|
src: assetName,
|
|
413
426
|
ref
|
|
414
427
|
},
|
|
415
|
-
|
|
428
|
+
key
|
|
416
429
|
);
|
|
417
430
|
}
|
|
418
431
|
);
|
|
@@ -1227,6 +1240,22 @@ var Time = React.forwardRef(
|
|
|
1227
1240
|
return /* @__PURE__ */ jsx31("time", { ref, dateTime: datetimeString, ...props, children: formattedDate });
|
|
1228
1241
|
}
|
|
1229
1242
|
);
|
|
1243
|
+
|
|
1244
|
+
// src/select.tsx
|
|
1245
|
+
import {
|
|
1246
|
+
getClosestInstance,
|
|
1247
|
+
getInstanceSelectorById
|
|
1248
|
+
} from "@webstudio-is/react-sdk";
|
|
1249
|
+
import { forwardRef as forwardRef35 } from "react";
|
|
1250
|
+
import { jsx as jsx32 } from "react/jsx-runtime";
|
|
1251
|
+
var Select = forwardRef35((props, ref) => /* @__PURE__ */ jsx32("select", { ...props, ref }));
|
|
1252
|
+
Select.displayName = "Select";
|
|
1253
|
+
|
|
1254
|
+
// src/option.tsx
|
|
1255
|
+
import { forwardRef as forwardRef36 } from "react";
|
|
1256
|
+
import { jsx as jsx33 } from "react/jsx-runtime";
|
|
1257
|
+
var Option = forwardRef36((props, ref) => /* @__PURE__ */ jsx33("option", { ...props, ref }));
|
|
1258
|
+
Option.displayName = "Option";
|
|
1230
1259
|
export {
|
|
1231
1260
|
Blockquote,
|
|
1232
1261
|
Body,
|
|
@@ -1246,9 +1275,11 @@ export {
|
|
|
1246
1275
|
Link,
|
|
1247
1276
|
List,
|
|
1248
1277
|
ListItem,
|
|
1278
|
+
Option,
|
|
1249
1279
|
Paragraph,
|
|
1250
1280
|
RadioButton,
|
|
1251
1281
|
RichTextLink,
|
|
1282
|
+
Select,
|
|
1252
1283
|
Separator,
|
|
1253
1284
|
Slot,
|
|
1254
1285
|
Span,
|