@webstudio-is/react-sdk 0.65.0 → 0.67.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/app/custom-components/form.ws.js +2 -2
- package/lib/app/custom-components/image.js +7 -13
- package/lib/app/custom-components/index.js +4 -1
- package/lib/app/params.js +1 -0
- package/lib/cjs/app/custom-components/form.ws.js +2 -2
- package/lib/cjs/app/custom-components/image.js +3 -12
- package/lib/cjs/app/custom-components/index.js +4 -1
- package/lib/cjs/app/params.js +1 -0
- package/lib/cjs/components/__generated__/{code.props.js → code-text.props.js} +3 -3
- package/lib/cjs/components/__generated__/html-embed.props.js +31 -0
- package/lib/cjs/components/blockquote.ws.js +2 -2
- package/lib/cjs/components/body.ws.js +2 -2
- package/lib/cjs/components/bold.ws.js +2 -2
- package/lib/cjs/components/box.ws.js +2 -2
- package/lib/cjs/components/button.ws.js +2 -2
- package/lib/cjs/components/checkbox-field.ws.js +2 -2
- package/lib/cjs/components/checkbox.ws.js +2 -2
- package/lib/cjs/components/{code.js → code-text.js} +6 -6
- package/lib/cjs/components/{code.ws.js → code-text.ws.js} +10 -10
- package/lib/cjs/components/component-meta.js +2 -2
- package/lib/cjs/components/components-utils.js +1 -43
- package/lib/cjs/components/components.js +4 -2
- package/lib/cjs/components/error-message.ws.js +2 -2
- package/lib/cjs/components/form.ws.js +2 -2
- package/lib/cjs/components/fragment.ws.js +1 -1
- package/lib/cjs/components/heading.ws.js +2 -2
- package/lib/cjs/components/html-embed.js +80 -0
- package/lib/cjs/components/html-embed.ws.js +43 -0
- package/lib/cjs/components/image.ws.js +2 -2
- package/lib/cjs/components/index.js +11 -57
- package/lib/cjs/components/input.ws.js +2 -2
- package/lib/cjs/components/italic.ws.js +2 -2
- package/lib/cjs/components/label.ws.js +2 -2
- package/lib/cjs/components/link-block.ws.js +2 -2
- package/lib/cjs/components/link.ws.js +2 -2
- package/lib/cjs/components/list-item.ws.js +2 -2
- package/lib/cjs/components/list.ws.js +2 -2
- package/lib/cjs/components/paragraph.ws.js +2 -2
- package/lib/cjs/components/radio-button-field.ws.js +2 -2
- package/lib/cjs/components/radio-button.ws.js +2 -2
- package/lib/cjs/components/separator.ws.js +2 -2
- package/lib/cjs/components/slot.ws.js +2 -2
- package/lib/cjs/components/span.ws.js +2 -2
- package/lib/cjs/components/subscript.ws.js +2 -2
- package/lib/cjs/components/success-message.ws.js +2 -2
- package/lib/cjs/components/superscript.ws.js +2 -2
- package/lib/cjs/components/text-block.ws.js +2 -2
- package/lib/cjs/components/textarea.ws.js +2 -2
- package/lib/cjs/css/css.js +2 -5
- package/lib/cjs/css/normalize.js +1 -1
- package/lib/cjs/css/presets.js +8 -1
- package/lib/cjs/tree/create-elements-tree.js +2 -4
- package/lib/components/__generated__/html-embed.props.js +11 -0
- package/lib/components/blockquote.ws.js +2 -2
- package/lib/components/body.ws.js +2 -2
- package/lib/components/bold.ws.js +2 -2
- package/lib/components/box.ws.js +2 -2
- package/lib/components/button.ws.js +2 -2
- package/lib/components/checkbox-field.ws.js +2 -2
- package/lib/components/checkbox.ws.js +2 -2
- package/lib/components/{code.js → code-text.js} +3 -3
- package/lib/components/{code.ws.js → code-text.ws.js} +5 -5
- package/lib/components/component-meta.js +3 -3
- package/lib/components/components-utils.js +1 -43
- package/lib/components/components.js +4 -2
- package/lib/components/error-message.ws.js +2 -2
- package/lib/components/form.ws.js +2 -2
- package/lib/components/fragment.ws.js +1 -1
- package/lib/components/heading.ws.js +2 -2
- package/lib/components/html-embed.js +65 -0
- package/lib/components/html-embed.ws.js +23 -0
- package/lib/components/image.ws.js +2 -2
- package/lib/components/index.js +11 -57
- package/lib/components/input.ws.js +2 -2
- package/lib/components/italic.ws.js +2 -2
- package/lib/components/label.ws.js +2 -2
- package/lib/components/link-block.ws.js +2 -2
- package/lib/components/link.ws.js +2 -2
- package/lib/components/list-item.ws.js +2 -2
- package/lib/components/list.ws.js +2 -2
- package/lib/components/paragraph.ws.js +2 -2
- package/lib/components/radio-button-field.ws.js +2 -2
- package/lib/components/radio-button.ws.js +2 -2
- package/lib/components/separator.ws.js +2 -2
- package/lib/components/slot.ws.js +2 -2
- package/lib/components/span.ws.js +2 -2
- package/lib/components/subscript.ws.js +2 -2
- package/lib/components/success-message.ws.js +2 -2
- package/lib/components/superscript.ws.js +2 -2
- package/lib/components/text-block.ws.js +2 -2
- package/lib/components/textarea.ws.js +2 -2
- package/lib/css/css.js +2 -5
- package/lib/css/normalize.js +2 -2
- package/lib/css/presets.js +8 -1
- package/lib/tree/create-elements-tree.js +2 -4
- package/lib/types/app/params.d.ts +22 -1
- package/lib/types/components/__generated__/html-embed.props.d.ts +2 -0
- package/lib/types/components/{code.d.ts → code-text.d.ts} +1 -1
- package/lib/types/components/{code.stories.d.ts → code-text.stories.d.ts} +1 -1
- package/lib/types/components/component-meta.d.ts +1785 -10
- package/lib/types/components/components-utils.d.ts +6 -3
- package/lib/types/components/components.d.ts +2 -1
- package/lib/types/components/html-embed.d.ts +7 -0
- package/lib/types/components/html-embed.stories.d.ts +11 -0
- package/lib/types/components/html-embed.ws.d.ts +3 -0
- package/lib/types/components/index.d.ts +2 -2
- package/lib/types/context.d.ts +1 -0
- package/lib/types/css/css.d.ts +2 -0
- package/lib/types/css/presets.d.ts +1 -0
- package/lib/types/css/style-rules.d.ts +1 -1
- package/lib/types/embed-template.d.ts +1 -1
- package/lib/types/tree/create-elements-tree.d.ts +2 -2
- package/package.json +14 -13
- package/src/app/custom-components/form.ws.tsx +2 -2
- package/src/app/custom-components/image.tsx +7 -13
- package/src/app/custom-components/index.ts +4 -1
- package/src/app/params.ts +23 -1
- package/src/components/__generated__/html-embed.props.ts +10 -0
- package/src/components/blockquote.ws.tsx +2 -2
- package/src/components/body.ws.tsx +2 -2
- package/src/components/bold.ws.tsx +2 -2
- package/src/components/box.ws.ts +2 -2
- package/src/components/button.ws.tsx +2 -2
- package/src/components/checkbox-field.ws.tsx +2 -2
- package/src/components/checkbox.ws.tsx +2 -2
- package/src/components/code-text.stories.tsx +16 -0
- package/src/components/{code.tsx → code-text.tsx} +2 -2
- package/src/components/{code.ws.tsx → code-text.ws.tsx} +5 -5
- package/src/components/component-meta.ts +3 -6
- package/src/components/components-utils.ts +14 -58
- package/src/components/components.ts +2 -1
- package/src/components/error-message.ws.tsx +2 -2
- package/src/components/form.ws.tsx +2 -2
- package/src/components/fragment.ws.ts +1 -1
- package/src/components/heading.ws.tsx +2 -2
- package/src/components/html-embed.stories.tsx +16 -0
- package/src/components/html-embed.tsx +96 -0
- package/src/components/html-embed.ws.ts +22 -0
- package/src/components/image.ws.tsx +2 -2
- package/src/components/index.ts +10 -87
- package/src/components/input.ws.tsx +2 -2
- package/src/components/italic.ws.tsx +2 -2
- package/src/components/label.ws.tsx +2 -2
- package/src/components/link-block.ws.tsx +2 -2
- package/src/components/link.ws.tsx +2 -2
- package/src/components/list-item.ws.tsx +2 -2
- package/src/components/list.ws.tsx +2 -2
- package/src/components/paragraph.ws.tsx +2 -2
- package/src/components/radio-button-field.ws.tsx +2 -2
- package/src/components/radio-button.ws.tsx +2 -2
- package/src/components/separator.ws.tsx +2 -2
- package/src/components/slot.ws.ts +2 -2
- package/src/components/span.ws.tsx +2 -2
- package/src/components/subscript.ws.tsx +2 -2
- package/src/components/success-message.ws.tsx +2 -2
- package/src/components/superscript.ws.tsx +2 -2
- package/src/components/text-block.ws.tsx +2 -2
- package/src/components/textarea.ws.tsx +2 -2
- package/src/context.tsx +1 -0
- package/src/css/css.ts +4 -5
- package/src/css/normalize.ts +2 -2
- package/src/css/presets.ts +7 -0
- package/src/tree/create-elements-tree.tsx +3 -5
- package/lib/cjs/tree/session-storage-polyfill.js +0 -65
- package/lib/tree/session-storage-polyfill.js +0 -45
- package/lib/types/tree/session-storage-polyfill.d.ts +0 -2
- package/src/components/code.stories.tsx +0 -16
- package/src/tree/session-storage-polyfill.tsx +0 -50
- /package/lib/components/__generated__/{code.props.js → code-text.props.js} +0 -0
- /package/lib/types/components/__generated__/{code.props.d.ts → code-text.props.d.ts} +0 -0
- /package/lib/types/components/{code.ws.d.ts → code-text.ws.d.ts} +0 -0
- /package/src/components/__generated__/{code.props.ts → code-text.props.ts} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PaintBrushIcon } from "@webstudio-is/icons";
|
|
1
|
+
import { PaintBrushIcon } from "@webstudio-is/icons/svg";
|
|
2
2
|
import { span } from "../css/normalize";
|
|
3
3
|
import {
|
|
4
4
|
defaultStates,
|
|
@@ -16,7 +16,7 @@ const presetStyle = {
|
|
|
16
16
|
export const meta: WsComponentMeta = {
|
|
17
17
|
type: "rich-text-child",
|
|
18
18
|
label: "Styled Text",
|
|
19
|
-
|
|
19
|
+
icon: PaintBrushIcon,
|
|
20
20
|
states: defaultStates,
|
|
21
21
|
presetStyle,
|
|
22
22
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SubscriptIcon } from "@webstudio-is/icons";
|
|
1
|
+
import { SubscriptIcon } from "@webstudio-is/icons/svg";
|
|
2
2
|
import { sub } from "../css/normalize";
|
|
3
3
|
import {
|
|
4
4
|
defaultStates,
|
|
@@ -16,7 +16,7 @@ const presetStyle = {
|
|
|
16
16
|
export const meta: WsComponentMeta = {
|
|
17
17
|
type: "rich-text-child",
|
|
18
18
|
label: "Subscript Text",
|
|
19
|
-
|
|
19
|
+
icon: SubscriptIcon,
|
|
20
20
|
states: defaultStates,
|
|
21
21
|
presetStyle,
|
|
22
22
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BoxIcon } from "@webstudio-is/icons";
|
|
1
|
+
import { BoxIcon } from "@webstudio-is/icons/svg";
|
|
2
2
|
import type {
|
|
3
3
|
WsComponentMeta,
|
|
4
4
|
WsComponentPropsMeta,
|
|
@@ -14,7 +14,7 @@ const presetStyle = {
|
|
|
14
14
|
export const meta: WsComponentMeta = {
|
|
15
15
|
type: "container",
|
|
16
16
|
label: "Success Message",
|
|
17
|
-
|
|
17
|
+
icon: BoxIcon,
|
|
18
18
|
presetStyle,
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SuperscriptIcon } from "@webstudio-is/icons";
|
|
1
|
+
import { SuperscriptIcon } from "@webstudio-is/icons/svg";
|
|
2
2
|
import { sup } from "../css/normalize";
|
|
3
3
|
import {
|
|
4
4
|
defaultStates,
|
|
@@ -16,7 +16,7 @@ const presetStyle = {
|
|
|
16
16
|
export const meta: WsComponentMeta = {
|
|
17
17
|
type: "rich-text-child",
|
|
18
18
|
label: "Superscript Text",
|
|
19
|
-
|
|
19
|
+
icon: SuperscriptIcon,
|
|
20
20
|
states: defaultStates,
|
|
21
21
|
presetStyle,
|
|
22
22
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TextBlockIcon } from "@webstudio-is/icons";
|
|
1
|
+
import { TextBlockIcon } from "@webstudio-is/icons/svg";
|
|
2
2
|
import {
|
|
3
3
|
defaultStates,
|
|
4
4
|
type PresetStyle,
|
|
@@ -23,7 +23,7 @@ export const meta: WsComponentMeta = {
|
|
|
23
23
|
category: "typography",
|
|
24
24
|
type: "rich-text",
|
|
25
25
|
label: "Text Block",
|
|
26
|
-
|
|
26
|
+
icon: TextBlockIcon,
|
|
27
27
|
states: defaultStates,
|
|
28
28
|
presetStyle,
|
|
29
29
|
children: [{ type: "text", value: "Block of text you can edit" }],
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FormTextAreaIcon } from "@webstudio-is/icons";
|
|
1
|
+
import { FormTextAreaIcon } from "@webstudio-is/icons/svg";
|
|
2
2
|
import { textarea } from "../css/normalize";
|
|
3
3
|
import {
|
|
4
4
|
type WsComponentMeta,
|
|
@@ -21,7 +21,7 @@ export const meta: WsComponentMeta = {
|
|
|
21
21
|
category: "forms",
|
|
22
22
|
type: "control",
|
|
23
23
|
label: "Text Area",
|
|
24
|
-
|
|
24
|
+
icon: FormTextAreaIcon,
|
|
25
25
|
presetStyle,
|
|
26
26
|
states: [
|
|
27
27
|
...defaultStates,
|
package/src/context.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import type { Assets } from "@webstudio-is/asset-uploader";
|
|
|
4
4
|
import type { Pages, PropsByInstanceId } from "./props";
|
|
5
5
|
|
|
6
6
|
export const ReactSdkContext = createContext<{
|
|
7
|
+
renderer?: "canvas";
|
|
7
8
|
propsByInstanceIdStore: ReadableAtom<PropsByInstanceId>;
|
|
8
9
|
assetsStore: ReadableAtom<Assets>;
|
|
9
10
|
pagesStore: ReadableAtom<Pages>;
|
package/src/css/css.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { createCssEngine, type TransformValue } from "@webstudio-is/css-engine";
|
|
2
2
|
import type { Asset, Assets } from "@webstudio-is/asset-uploader";
|
|
3
3
|
import type { Build } from "@webstudio-is/project-build";
|
|
4
|
-
import {
|
|
5
|
-
import { getComponentMeta } from "../components";
|
|
4
|
+
import type { WsComponentMeta } from "../components/component-meta";
|
|
6
5
|
import { idAttribute } from "../tree";
|
|
7
6
|
import { addGlobalRules } from "./global-rules";
|
|
8
7
|
import { getPresetStyleRules, getStyleRules } from "./style-rules";
|
|
@@ -12,6 +11,7 @@ type Data = {
|
|
|
12
11
|
breakpoints?: Build["breakpoints"];
|
|
13
12
|
styles?: Build["styles"];
|
|
14
13
|
styleSourceSelections?: Build["styleSourceSelections"];
|
|
14
|
+
componentMetas: Map<string, WsComponentMeta>;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
type CssOptions = {
|
|
@@ -61,9 +61,8 @@ export const generateCssText = (data: Data, options: CssOptions) => {
|
|
|
61
61
|
engine.addMediaRule(breakpoint.id, breakpoint);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
for (const component of
|
|
65
|
-
const
|
|
66
|
-
const presetStyle = meta?.presetStyle;
|
|
64
|
+
for (const [component, meta] of data.componentMetas) {
|
|
65
|
+
const presetStyle = meta.presetStyle;
|
|
67
66
|
if (presetStyle === undefined) {
|
|
68
67
|
continue;
|
|
69
68
|
}
|
package/src/css/normalize.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
// webstudio custom opinionated presets
|
|
19
|
-
import { borders } from "./presets";
|
|
19
|
+
import { borders, outline } from "./presets";
|
|
20
20
|
import type { EmbedTemplateStyleDecl } from "../embed-template";
|
|
21
21
|
|
|
22
22
|
export type Styles = EmbedTemplateStyleDecl[];
|
|
@@ -37,7 +37,7 @@ const boxSizing = {
|
|
|
37
37
|
* box-sizing: border-box;
|
|
38
38
|
}
|
|
39
39
|
*/
|
|
40
|
-
const baseStyle = [boxSizing, ...borders] satisfies Styles;
|
|
40
|
+
const baseStyle = [boxSizing, ...borders, ...outline] satisfies Styles;
|
|
41
41
|
|
|
42
42
|
export const div = baseStyle;
|
|
43
43
|
export const address = baseStyle;
|
package/src/css/presets.ts
CHANGED
|
@@ -7,23 +7,22 @@ import type { GetComponent } from "../components/components-utils";
|
|
|
7
7
|
import { ReactSdkContext } from "../context";
|
|
8
8
|
import type { Pages, PropsByInstanceId } from "../props";
|
|
9
9
|
import type { WebstudioComponent } from "./webstudio-component";
|
|
10
|
-
import { SessionStoragePolyfill } from "./session-storage-polyfill";
|
|
11
10
|
|
|
12
11
|
type InstanceSelector = Instance["id"][];
|
|
13
12
|
|
|
14
13
|
export const createElementsTree = ({
|
|
14
|
+
renderer,
|
|
15
15
|
instances,
|
|
16
16
|
rootInstanceId,
|
|
17
|
-
sandbox,
|
|
18
17
|
propsByInstanceIdStore,
|
|
19
18
|
assetsStore,
|
|
20
19
|
pagesStore,
|
|
21
20
|
Component,
|
|
22
21
|
getComponent,
|
|
23
22
|
}: {
|
|
23
|
+
renderer?: "canvas";
|
|
24
24
|
instances: Instances;
|
|
25
25
|
rootInstanceId: Instance["id"];
|
|
26
|
-
sandbox?: boolean;
|
|
27
26
|
propsByInstanceIdStore: ReadableAtom<PropsByInstanceId>;
|
|
28
27
|
assetsStore: ReadableAtom<Assets>;
|
|
29
28
|
pagesStore: ReadableAtom<Pages>;
|
|
@@ -50,7 +49,6 @@ export const createElementsTree = ({
|
|
|
50
49
|
children: [
|
|
51
50
|
<Fragment key="children">
|
|
52
51
|
{children}
|
|
53
|
-
{sandbox && <SessionStoragePolyfill />}
|
|
54
52
|
<ScrollRestoration />
|
|
55
53
|
<Scripts />
|
|
56
54
|
</Fragment>,
|
|
@@ -59,7 +57,7 @@ export const createElementsTree = ({
|
|
|
59
57
|
});
|
|
60
58
|
return (
|
|
61
59
|
<ReactSdkContext.Provider
|
|
62
|
-
value={{ propsByInstanceIdStore, assetsStore, pagesStore }}
|
|
60
|
+
value={{ propsByInstanceIdStore, assetsStore, pagesStore, renderer }}
|
|
63
61
|
>
|
|
64
62
|
{root}
|
|
65
63
|
</ReactSdkContext.Provider>
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var session_storage_polyfill_exports = {};
|
|
20
|
-
__export(session_storage_polyfill_exports, {
|
|
21
|
-
SessionStoragePolyfill: () => SessionStoragePolyfill
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(session_storage_polyfill_exports);
|
|
24
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
-
const polyfill = function() {
|
|
26
|
-
try {
|
|
27
|
-
const key = "__session_storage_availability_test__";
|
|
28
|
-
sessionStorage.setItem(key, "test");
|
|
29
|
-
sessionStorage.removeItem(key);
|
|
30
|
-
} catch (error) {
|
|
31
|
-
alert(
|
|
32
|
-
'It looks like you have disabled cookies in your browser. Webstudio builder may not work properly.\n\nTo enable cookies, go to "Setting" > "Privacy and security" > "Cookies and other site data", and make sure neither "Block all cookies" nor "Block third-party cookies" are selected.\n\nRead more at https://support.google.com/chrome/answer/95647'
|
|
33
|
-
);
|
|
34
|
-
const data = /* @__PURE__ */ new Map();
|
|
35
|
-
Object.defineProperty(window, "sessionStorage", {
|
|
36
|
-
value: {
|
|
37
|
-
setItem: (key, val) => {
|
|
38
|
-
console.warn(
|
|
39
|
-
`Session storage is unavailable due to Error "${error.message}". A polyfill is used to set value of "${key}". The value will be lost when the page is reloaded.`
|
|
40
|
-
);
|
|
41
|
-
data.set(key, String(val));
|
|
42
|
-
},
|
|
43
|
-
getItem: (key) => {
|
|
44
|
-
console.warn(
|
|
45
|
-
`Session storage is unavailable due to Error "${error.message}". A polyfill is used to get value of "${key}". The value will be undefined if the page was reloaded after it was set.`
|
|
46
|
-
);
|
|
47
|
-
return data.get(key);
|
|
48
|
-
},
|
|
49
|
-
removeItem: (key) => {
|
|
50
|
-
data.delete(key);
|
|
51
|
-
},
|
|
52
|
-
clear: () => {
|
|
53
|
-
data.clear();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
}.toString();
|
|
59
|
-
const SessionStoragePolyfill = () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
60
|
-
"script",
|
|
61
|
-
{
|
|
62
|
-
dangerouslySetInnerHTML: { __html: `(${polyfill})()` },
|
|
63
|
-
suppressHydrationWarning: true
|
|
64
|
-
}
|
|
65
|
-
);
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
const polyfill = function() {
|
|
3
|
-
try {
|
|
4
|
-
const key = "__session_storage_availability_test__";
|
|
5
|
-
sessionStorage.setItem(key, "test");
|
|
6
|
-
sessionStorage.removeItem(key);
|
|
7
|
-
} catch (error) {
|
|
8
|
-
alert(
|
|
9
|
-
'It looks like you have disabled cookies in your browser. Webstudio builder may not work properly.\n\nTo enable cookies, go to "Setting" > "Privacy and security" > "Cookies and other site data", and make sure neither "Block all cookies" nor "Block third-party cookies" are selected.\n\nRead more at https://support.google.com/chrome/answer/95647'
|
|
10
|
-
);
|
|
11
|
-
const data = /* @__PURE__ */ new Map();
|
|
12
|
-
Object.defineProperty(window, "sessionStorage", {
|
|
13
|
-
value: {
|
|
14
|
-
setItem: (key, val) => {
|
|
15
|
-
console.warn(
|
|
16
|
-
`Session storage is unavailable due to Error "${error.message}". A polyfill is used to set value of "${key}". The value will be lost when the page is reloaded.`
|
|
17
|
-
);
|
|
18
|
-
data.set(key, String(val));
|
|
19
|
-
},
|
|
20
|
-
getItem: (key) => {
|
|
21
|
-
console.warn(
|
|
22
|
-
`Session storage is unavailable due to Error "${error.message}". A polyfill is used to get value of "${key}". The value will be undefined if the page was reloaded after it was set.`
|
|
23
|
-
);
|
|
24
|
-
return data.get(key);
|
|
25
|
-
},
|
|
26
|
-
removeItem: (key) => {
|
|
27
|
-
data.delete(key);
|
|
28
|
-
},
|
|
29
|
-
clear: () => {
|
|
30
|
-
data.clear();
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
}.toString();
|
|
36
|
-
const SessionStoragePolyfill = () => /* @__PURE__ */ jsx(
|
|
37
|
-
"script",
|
|
38
|
-
{
|
|
39
|
-
dangerouslySetInnerHTML: { __html: `(${polyfill})()` },
|
|
40
|
-
suppressHydrationWarning: true
|
|
41
|
-
}
|
|
42
|
-
);
|
|
43
|
-
export {
|
|
44
|
-
SessionStoragePolyfill
|
|
45
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { ComponentStory, ComponentMeta } from "@storybook/react";
|
|
2
|
-
import { Code as CodePrimitive } from "./code";
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
title: "Components/Code",
|
|
6
|
-
component: CodePrimitive,
|
|
7
|
-
} as ComponentMeta<typeof CodePrimitive>;
|
|
8
|
-
|
|
9
|
-
const Template: ComponentStory<typeof CodePrimitive> = (args) => (
|
|
10
|
-
<CodePrimitive {...args} />
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
export const Code = Template.bind({});
|
|
14
|
-
Code.args = {
|
|
15
|
-
children: "alert('Hello World!')",
|
|
16
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
// This is a temporary work around for https://github.com/remix-run/remix/issues/3659
|
|
2
|
-
|
|
3
|
-
// The code is based on this discussion https://bugs.chromium.org/p/chromium/issues/detail?id=357625
|
|
4
|
-
const polyfill = function () {
|
|
5
|
-
try {
|
|
6
|
-
const key = "__session_storage_availability_test__";
|
|
7
|
-
sessionStorage.setItem(key, "test"); // test
|
|
8
|
-
sessionStorage.removeItem(key); // cleanup
|
|
9
|
-
} catch (error) {
|
|
10
|
-
alert(
|
|
11
|
-
'It looks like you have disabled cookies in your browser. Webstudio builder may not work properly.\n\nTo enable cookies, go to "Setting" > "Privacy and security" > "Cookies and other site data", and make sure neither "Block all cookies" nor "Block third-party cookies" are selected.\n\nRead more at https://support.google.com/chrome/answer/95647'
|
|
12
|
-
);
|
|
13
|
-
const data = new Map();
|
|
14
|
-
Object.defineProperty(window, "sessionStorage", {
|
|
15
|
-
value: {
|
|
16
|
-
setItem: (key: string, val: unknown) => {
|
|
17
|
-
// eslint-disable-next-line no-console
|
|
18
|
-
console.warn(
|
|
19
|
-
`Session storage is unavailable due to Error "${
|
|
20
|
-
(error as Error).message
|
|
21
|
-
}". A polyfill is used to set value of "${key}". The value will be lost when the page is reloaded.`
|
|
22
|
-
);
|
|
23
|
-
data.set(key, String(val));
|
|
24
|
-
},
|
|
25
|
-
getItem: (key: string) => {
|
|
26
|
-
// eslint-disable-next-line no-console
|
|
27
|
-
console.warn(
|
|
28
|
-
`Session storage is unavailable due to Error "${
|
|
29
|
-
(error as Error).message
|
|
30
|
-
}". A polyfill is used to get value of "${key}". The value will be undefined if the page was reloaded after it was set.`
|
|
31
|
-
);
|
|
32
|
-
return data.get(key);
|
|
33
|
-
},
|
|
34
|
-
removeItem: (key: string) => {
|
|
35
|
-
data.delete(key);
|
|
36
|
-
},
|
|
37
|
-
clear: () => {
|
|
38
|
-
data.clear();
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
}.toString();
|
|
44
|
-
|
|
45
|
-
export const SessionStoragePolyfill = () => (
|
|
46
|
-
<script
|
|
47
|
-
dangerouslySetInnerHTML={{ __html: `(${polyfill})()` }}
|
|
48
|
-
suppressHydrationWarning
|
|
49
|
-
/>
|
|
50
|
-
);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|