@webstudio-is/sdk-components-react 0.253.0 → 0.255.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/head-slot.template.js +3 -3
- package/lib/html-embed.js +51 -44
- package/lib/time.js +16 -16
- package/package.json +7 -7
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsxs as i, jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import { $ as e } from "@webstudio-is/template";
|
|
3
|
-
const
|
|
3
|
+
const s = {
|
|
4
4
|
category: "general",
|
|
5
|
-
description: "The Head Slot component lets you customize page-specific head elements (like canonical URLs), which merge with your site's global head settings, with Head Slot definitions taking priority over Page Settings. For site-wide head changes, use
|
|
5
|
+
description: "The Head Slot component lets you customize page-specific head elements (like canonical URLs), which merge with your site's global head settings, with Head Slot definitions taking priority over Page Settings. For site-wide head changes, use project settings instead.",
|
|
6
6
|
order: 5,
|
|
7
7
|
template: /* @__PURE__ */ i(e.HeadSlot, { children: [
|
|
8
8
|
/* @__PURE__ */ t(e.HeadTitle, { "ws:label": "Title", children: "Title" }),
|
|
@@ -11,5 +11,5 @@ const l = {
|
|
|
11
11
|
] })
|
|
12
12
|
};
|
|
13
13
|
export {
|
|
14
|
-
|
|
14
|
+
s as meta
|
|
15
15
|
};
|
package/lib/html-embed.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { mergeRefs as
|
|
4
|
-
import { ReactSdkContext as
|
|
5
|
-
import { patchDomEvents as
|
|
6
|
-
const
|
|
1
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as b, useContext as x, useState as E, useSyncExternalStore as k, useRef as f, useMemo as T, useEffect as g } from "react";
|
|
3
|
+
import { mergeRefs as L } from "@react-aria/utils";
|
|
4
|
+
import { ReactSdkContext as _ } from "@webstudio-is/react-sdk/runtime";
|
|
5
|
+
import { patchDomEvents as C, executeDomEvents as w } from "./html-embed-patchers.js";
|
|
6
|
+
const M = {
|
|
7
7
|
scriptTestIdPrefix: "client-"
|
|
8
|
-
},
|
|
9
|
-
const r = document.createElement("script"),
|
|
8
|
+
}, O = (e) => new Promise((t, n) => {
|
|
9
|
+
const r = document.createElement("script"), i = e.hasAttribute("src"), a = e.type === "module";
|
|
10
10
|
for (const { name: c, value: o } of e.attributes)
|
|
11
11
|
r.setAttribute(c, o);
|
|
12
|
-
if (r.dataset.testid !== void 0 && (r.dataset.testid = `${
|
|
12
|
+
if (r.dataset.testid !== void 0 && (r.dataset.testid = `${M.scriptTestIdPrefix}${r.dataset.testid}`), i)
|
|
13
13
|
r.addEventListener("load", () => {
|
|
14
14
|
t();
|
|
15
15
|
}), r.addEventListener("error", n);
|
|
@@ -28,55 +28,55 @@ const C = {
|
|
|
28
28
|
}
|
|
29
29
|
r.textContent = e.innerText;
|
|
30
30
|
}
|
|
31
|
-
e.replaceWith(r),
|
|
32
|
-
}),
|
|
33
|
-
let
|
|
34
|
-
const
|
|
35
|
-
if (
|
|
36
|
-
for (
|
|
37
|
-
await
|
|
38
|
-
|
|
31
|
+
e.replaceWith(r), i === !1 && t();
|
|
32
|
+
}), d = [];
|
|
33
|
+
let u = !1;
|
|
34
|
+
const H = async (e) => {
|
|
35
|
+
if (d.push(...e), await Promise.resolve(), !u) {
|
|
36
|
+
for (C(), u = !0; d.length > 0; )
|
|
37
|
+
await d.shift()();
|
|
38
|
+
w(), u = !1;
|
|
39
39
|
}
|
|
40
|
-
},
|
|
40
|
+
}, I = (e) => {
|
|
41
41
|
const t = e.querySelectorAll("script"), n = [], r = [];
|
|
42
|
-
t.forEach((
|
|
43
|
-
(
|
|
42
|
+
t.forEach((i) => {
|
|
43
|
+
(i.hasAttribute("async") ? r : n).push(() => O(i));
|
|
44
44
|
});
|
|
45
|
-
for (const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
},
|
|
45
|
+
for (const i of r)
|
|
46
|
+
i();
|
|
47
|
+
H(n);
|
|
48
|
+
}, P = (e) => {
|
|
49
49
|
const { code: t, innerRef: n, ...r } = e;
|
|
50
|
-
return /* @__PURE__ */
|
|
51
|
-
},
|
|
50
|
+
return /* @__PURE__ */ s("div", { ref: n, ...r, style: { display: "block", padding: 20 }, children: 'Open the "Settings" panel to insert HTML code.' });
|
|
51
|
+
}, p = () => k(
|
|
52
52
|
() => () => {
|
|
53
53
|
},
|
|
54
54
|
() => !1,
|
|
55
55
|
() => !0
|
|
56
|
-
),
|
|
57
|
-
if (!
|
|
56
|
+
), l = (e) => {
|
|
57
|
+
if (!p())
|
|
58
58
|
return e.children;
|
|
59
59
|
}, m = (e) => {
|
|
60
|
-
const { code: t, innerRef: n, ...r } = e,
|
|
60
|
+
const { code: t, innerRef: n, ...r } = e, i = f(null), a = f(!0), c = T(
|
|
61
61
|
() => ({
|
|
62
62
|
__html: t ?? ""
|
|
63
63
|
}),
|
|
64
64
|
[t]
|
|
65
65
|
);
|
|
66
|
-
return
|
|
67
|
-
const o =
|
|
68
|
-
o && a.current && (a.current = !1,
|
|
69
|
-
}, []), /* @__PURE__ */
|
|
66
|
+
return g(() => {
|
|
67
|
+
const o = i.current;
|
|
68
|
+
o && a.current && (a.current = !1, I(o));
|
|
69
|
+
}, []), /* @__PURE__ */ s(
|
|
70
70
|
"div",
|
|
71
71
|
{
|
|
72
72
|
...r,
|
|
73
|
-
ref:
|
|
73
|
+
ref: L(n, i),
|
|
74
74
|
dangerouslySetInnerHTML: c
|
|
75
75
|
}
|
|
76
76
|
);
|
|
77
|
-
},
|
|
77
|
+
}, v = (e) => {
|
|
78
78
|
const { code: t, innerRef: n, ...r } = e;
|
|
79
|
-
return /* @__PURE__ */
|
|
79
|
+
return /* @__PURE__ */ s(
|
|
80
80
|
"div",
|
|
81
81
|
{
|
|
82
82
|
...r,
|
|
@@ -84,17 +84,24 @@ const O = async (e) => {
|
|
|
84
84
|
dangerouslySetInnerHTML: { __html: t ?? "" }
|
|
85
85
|
}
|
|
86
86
|
);
|
|
87
|
-
},
|
|
87
|
+
}, h = v, A = b(
|
|
88
88
|
(e, t) => {
|
|
89
|
-
const { code: n, executeScriptOnCanvas: r, clientOnly:
|
|
90
|
-
return n === void 0 || String(n).trim().length === 0 ? /* @__PURE__ */
|
|
91
|
-
|
|
89
|
+
const { code: n, executeScriptOnCanvas: r, clientOnly: i, children: a, ...c } = e, { renderer: o, isSafeMode: y } = x(_), R = p(), [S] = E(R);
|
|
90
|
+
return n === void 0 || String(n).trim().length === 0 ? /* @__PURE__ */ s(P, { innerRef: t, ...c }) : S ? i !== !0 ? /* @__PURE__ */ s(v, { innerRef: t, code: n, ...c }) : /* @__PURE__ */ s(l, { children: /* @__PURE__ */ s(m, { innerRef: t, code: n, ...c }) }) : y ? /* @__PURE__ */ s(l, { children: /* @__PURE__ */ s(
|
|
91
|
+
h,
|
|
92
|
+
{
|
|
93
|
+
innerRef: t,
|
|
94
|
+
code: n,
|
|
95
|
+
...c
|
|
96
|
+
}
|
|
97
|
+
) }) : o === "canvas" && r !== !0 ? /* @__PURE__ */ s(l, { children: /* @__PURE__ */ s(
|
|
98
|
+
h,
|
|
92
99
|
{
|
|
93
100
|
innerRef: t,
|
|
94
101
|
code: n,
|
|
95
102
|
...c
|
|
96
103
|
}
|
|
97
|
-
) }) : /* @__PURE__ */
|
|
104
|
+
) }) : /* @__PURE__ */ s(l, { children: /* @__PURE__ */ s(
|
|
98
105
|
m,
|
|
99
106
|
{
|
|
100
107
|
innerRef: t,
|
|
@@ -105,8 +112,8 @@ const O = async (e) => {
|
|
|
105
112
|
) });
|
|
106
113
|
}
|
|
107
114
|
);
|
|
108
|
-
|
|
115
|
+
A.displayName = "HtmlEmbed";
|
|
109
116
|
export {
|
|
110
|
-
|
|
111
|
-
|
|
117
|
+
A as HtmlEmbed,
|
|
118
|
+
M as __testing__
|
|
112
119
|
};
|
package/lib/time.js
CHANGED
|
@@ -291,7 +291,7 @@ const N = [
|
|
|
291
291
|
if (Number.isNaN(e.getTime()) === !1)
|
|
292
292
|
return e;
|
|
293
293
|
}, Y = (t, e, n = "en-US") => {
|
|
294
|
-
const
|
|
294
|
+
const s = (r, o = 2) => String(r).padStart(o, "0"), D = new Intl.DateTimeFormat(n, {
|
|
295
295
|
weekday: "long"
|
|
296
296
|
}).format(t), T = new Intl.DateTimeFormat(n, {
|
|
297
297
|
weekday: "short"
|
|
@@ -304,26 +304,26 @@ const N = [
|
|
|
304
304
|
YY: String(t.getFullYear()).slice(-2),
|
|
305
305
|
MMMM: l,
|
|
306
306
|
MMM: M,
|
|
307
|
-
MM:
|
|
307
|
+
MM: s(t.getMonth() + 1),
|
|
308
308
|
M: t.getMonth() + 1,
|
|
309
309
|
DDDD: D,
|
|
310
310
|
DDD: T,
|
|
311
|
-
DD:
|
|
311
|
+
DD: s(t.getDate()),
|
|
312
312
|
D: t.getDate(),
|
|
313
|
-
HH:
|
|
313
|
+
HH: s(t.getHours()),
|
|
314
314
|
H: t.getHours(),
|
|
315
|
-
mm:
|
|
315
|
+
mm: s(t.getMinutes()),
|
|
316
316
|
m: t.getMinutes(),
|
|
317
|
-
ss:
|
|
317
|
+
ss: s(t.getSeconds()),
|
|
318
318
|
s: t.getSeconds()
|
|
319
|
-
}, a = Object.keys(m).sort((
|
|
320
|
-
return e.replace(i, (
|
|
319
|
+
}, a = Object.keys(m).sort((r, o) => o.length - r.length), i = new RegExp(`\\b(${a.join("|")})\\b`, "g");
|
|
320
|
+
return e.replace(i, (r) => String(m[r]));
|
|
321
321
|
}, H = A(
|
|
322
322
|
({
|
|
323
323
|
language: t = c,
|
|
324
324
|
country: e = u,
|
|
325
325
|
dateStyle: n = G,
|
|
326
|
-
timeStyle:
|
|
326
|
+
timeStyle: s = I,
|
|
327
327
|
format: D,
|
|
328
328
|
// native html attribute in react style
|
|
329
329
|
dateTime: T = f,
|
|
@@ -333,21 +333,21 @@ const N = [
|
|
|
333
333
|
e
|
|
334
334
|
)}`, a = {
|
|
335
335
|
dateStyle: B(n),
|
|
336
|
-
timeStyle: R(
|
|
337
|
-
}, i = T === null ? E : T.toString(),
|
|
338
|
-
let
|
|
339
|
-
if (
|
|
336
|
+
timeStyle: R(s)
|
|
337
|
+
}, i = T === null ? E : T.toString(), r = U(i);
|
|
338
|
+
let o = i;
|
|
339
|
+
if (r)
|
|
340
340
|
if (D)
|
|
341
341
|
try {
|
|
342
|
-
|
|
342
|
+
o = Y(r, D, m);
|
|
343
343
|
} catch {
|
|
344
344
|
}
|
|
345
345
|
else
|
|
346
346
|
try {
|
|
347
|
-
|
|
347
|
+
o = new Intl.DateTimeFormat(m, a).format(r);
|
|
348
348
|
} catch {
|
|
349
349
|
}
|
|
350
|
-
return /* @__PURE__ */ S("time", { ref: M, dateTime: i, ...l, children:
|
|
350
|
+
return /* @__PURE__ */ S("time", { ref: M, dateTime: i, ...l, children: o });
|
|
351
351
|
}
|
|
352
352
|
);
|
|
353
353
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/sdk-components-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.255.0",
|
|
4
4
|
"description": "Webstudio default library for react",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"colord": "^2.9.3",
|
|
45
45
|
"micromark": "^4.0.2",
|
|
46
46
|
"micromark-extension-gfm-table": "^2.1.1",
|
|
47
|
-
"@webstudio-is/icons": "0.
|
|
48
|
-
"@webstudio-is/
|
|
49
|
-
"@webstudio-is/
|
|
50
|
-
"@webstudio-is/sdk": "0.
|
|
47
|
+
"@webstudio-is/icons": "0.255.0",
|
|
48
|
+
"@webstudio-is/image": "0.255.0",
|
|
49
|
+
"@webstudio-is/react-sdk": "0.255.0",
|
|
50
|
+
"@webstudio-is/sdk": "0.255.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@testing-library/dom": "^10.4.0",
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"vitest": "^3.1.2",
|
|
61
61
|
"@webstudio-is/generate-arg-types": "0.0.0",
|
|
62
62
|
"@webstudio-is/sdk-cli": "0.94.0",
|
|
63
|
-
"@webstudio-is/
|
|
64
|
-
"@webstudio-is/
|
|
63
|
+
"@webstudio-is/template": "0.255.0",
|
|
64
|
+
"@webstudio-is/tsconfig": "1.0.7"
|
|
65
65
|
},
|
|
66
66
|
"scripts": {
|
|
67
67
|
"build": "vite build --config ../../vite.sdk-components.config.ts",
|