Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

refactor: rewrite normalize styles with css (#3951)

Bogdan Chadkin431e58dd34ad
diff --git a/apps/builder/app/builder/features/style-panel/shared/style-info.test.ts b/apps/builder/app/builder/features/style-panel/shared/style-info.test.ts
index b86547967d..2c2296ffa0 100644
--- a/apps/builder/app/builder/features/style-panel/shared/style-info.test.ts
+++ b/apps/builder/app/builder/features/style-panel/shared/style-info.test.ts
@@ -236,8 +236,12 @@ test("compute inherited styles", () => {
"fontFamily": {
"instanceId": "1",
"value": {
- "type": "keyword",
- "value": "Arial, Roboto, sans-serif",
+ "type": "fontFamily",
+ "value": [
+ "Arial",
+ "Roboto",
+ "sans-serif",
+ ],
},
},
"fontSize": {
diff --git a/packages/react-sdk/package.json b/packages/react-sdk/package.json
index 0a18d819fd..514355b2cd 100644
--- a/packages/react-sdk/package.json
+++ b/packages/react-sdk/package.json
@@ -6,7 +6,7 @@
"homepage": "https://webstudio.is",
"type": "module",
"scripts": {
- "build": "rm -rf lib && esbuild src/index.ts src/runtime.ts ./src/css/normalize.ts --outdir=lib --bundle --format=esm --packages=external",
+ "build": "rm -rf lib && esbuild src/index.ts src/runtime.ts --outdir=lib --bundle --format=esm --packages=external",
"dts": "tsc --project tsconfig.dts.json",
"typecheck": "tsc",
"test": "NODE_OPTIONS=--experimental-vm-modules jest --passWithNoTests"
@@ -51,11 +51,6 @@
"types": "./lib/types/runtime.d.ts",
"import": "./lib/runtime.js"
},
- "./css-normalize": {
- "webstudio": "./src/css/normalize.ts",
- "types": "./lib/types/css/normalize.d.ts",
- "import": "./lib/css/normalize.js"
- },
"./placeholder": {
"types": "./placeholder.d.ts"
}
diff --git a/packages/react-sdk/src/css/normalize-type-check.ts b/packages/react-sdk/src/css/normalize-type-check.ts
deleted file mode 100644
index f124b9eb4e..0000000000
--- a/packages/react-sdk/src/css/normalize-type-check.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import * as normalize from "./normalize";
-import type { HtmlTags } from "html-tags";
-import type { Style } from "@webstudio-is/css-engine";
-
-// no way I found to check exports https://github.com/microsoft/TypeScript/issues/38511
-// we can check here that all exports represents a valid html tag
-const normalizeWithKeyof = { ...normalize };
-
-type ExportedTags = keyof typeof normalizeWithKeyof;
-// Custom tags are needed because we need to be able to address
-// elements like input `type="checkbox"` and HTML has historically terrible naming.
-type CustomTags = "checkbox" | "radio";
-type ExpectedTags = HtmlTags | CustomTags;
-
-type ValidTags = ExportedTags extends ExpectedTags ? ExportedTags : false;
-
-normalizeWithKeyof satisfies Record<ValidTags, Style>;
diff --git a/packages/react-sdk/src/css/normalize.ts b/packages/react-sdk/src/css/normalize.ts
deleted file mode 100644
index 38ef72452c..0000000000
--- a/packages/react-sdk/src/css/normalize.ts
+++ /dev/null
@@ -1,509 +0,0 @@
-/**
- * Based on https://github.com/sindresorhus/modern-normalize
- *
- * Attributions
- *
- * The MIT License (MIT)
- * Copyright (c) Nicolas Gallagher
- * Copyright (c) Jonathan Neal
- * Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
- */
-
-// webstudio custom opinionated presets
-import { borderStyle, borderWidth, outline } from "./presets";
-import type { EmbedTemplateStyleDecl } from "../embed-template";
-
-export type Styles = EmbedTemplateStyleDecl[];
-
-/**
- * Use a better box model (opinionated).
- */
-const boxSizing = {
- property: "boxSizing",
- value: { type: "keyword", value: "border-box" },
-} satisfies EmbedTemplateStyleDecl;
-
-/**
- * We dont support rules like this now, implement boxSizing for each used element
- * *,
- * ::before,
- * ::after {
- * box-sizing: border-box;
- * }
- */
-const baseStyle = [boxSizing, ...borderWidth, ...outline] satisfies Styles;
-
-export const div = baseStyle;
-export const address = baseStyle;
-export const article = baseStyle;
-export const aside = baseStyle;
-export const figure = baseStyle;
-export const footer = baseStyle;
-export const header = baseStyle;
-export const main = baseStyle;
-export const nav = baseStyle;
-export const section = baseStyle;
-export const form = baseStyle;
-export const label = baseStyle;
-export const time = baseStyle;
-
-export const h1 = baseStyle;
-export const h2 = baseStyle;
-export const h3 = baseStyle;
-export const h4 = baseStyle;
-export const h5 = baseStyle;
-export const h6 = baseStyle;
-
-export const i = baseStyle;
-
-export const img = baseStyle;
-
-export const a = baseStyle;
-export const li = baseStyle;
-export const ul = baseStyle;
-export const ol = baseStyle;
-
-export const p = baseStyle;
-export const span = baseStyle;
-
-// @todo for now not applied to html, as we don't have html element
-/**
- * 1. Correct the line height in all browsers.
- * 2. Prevent adjustments of font size after orientation changes in iOS.
- * 3. Use a more readable tab size (opinionated).
- */
-export const html = [
- /* 1 */
- {
- property: "lineHeight",
- value: { type: "unit", value: 1.15, unit: "number" },
- },
- /* 2 */
- {
- property: "textSizeAdjust",
- value: { type: "unit", value: 100, unit: "%" },
- },
- /* 3 */
- {
- property: "tabSize",
- value: { type: "unit", value: 4, unit: "number" },
- },
- boxSizing,
- ...borderWidth,
-] satisfies Styles;
-
-/**
- * 1. Remove the margin in all browsers.
- * 2. Improve consistency of default fonts in all browsers. (https://github.com/sindresorhus/modern-normalize/issues/3)
- */
-export const body = [
- /* 1 */
- {
- property: "marginTop",
- value: { type: "unit", value: 0, unit: "number" },
- },
- {
- property: "marginRight",
- value: { type: "unit", value: 0, unit: "number" },
- },
- {
- property: "marginBottom",
- value: { type: "unit", value: 0, unit: "number" },
- },
- {
- property: "marginLeft",
- value: { type: "unit", value: 0, unit: "number" },
- },
- /* 2 */
- {
- property: "fontFamily",
- value: {
- type: "keyword",
- value: "Arial, Roboto, sans-serif",
- },
- },
- {
- property: "fontSize",
- value: { type: "unit", unit: "px", value: 16 },
- },
- {
- property: "lineHeight",
- value: { type: "unit", unit: "number", value: 1.2 },
- },
- boxSizing,
- ...borderWidth,
-] satisfies Styles;
-
-/**
- * 1. Add the correct height in Firefox.
- * 2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)
- */
-export const hr = [
- /* 1 */
- {
- property: "height",
- value: { type: "unit", value: 0, unit: "number" },
- },
- /* 2 */
- {
- property: "color",
- value: { type: "keyword", value: "inherit" },
- },
- boxSizing,
- ...borderWidth,
-] satisfies Styles;
-
-/**
-Add the correct text decoration in Chrome, Edge, and Safari.
-
-!!!Skipped as we don't support this logic!!!
-
-abbr[title] {
- text-decoration: underline dotted;
-}
-*/
-
-/**
- * Add the correct font weight in Edge and Safari.
- */
-export const b = [
- {
- property: "fontWeight",
- value: { type: "keyword", value: "700" },
- },
- boxSizing,
- ...borderWidth,
-] satisfies Styles;
-
-export const strong = b;
-
-/**
- * 1. Improve consistency of default fonts in all browsers. (https://github.com/sindresorhus/modern-normalize/issues/3)
- * 2. Correct the odd 'em' font sizing in all browsers.
- */
-export const code = [
- /* 1 */
- {
- property: "fontFamily",
- value: {
- type: "keyword",
- value: `ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace`,
- },
- },
- /* 2 */
- {
- property: "fontSize",
- value: { type: "unit", value: 1, unit: "em" },
- },
- boxSizing,
- ...borderWidth,
-] satisfies Styles;
-
-export const kbd = code;
-export const samp = code;
-export const pre = code;
-
-/**
- * Add the correct font size in all browsers.
- */
-export const small = [
- {
- property: "fontSize",
- value: { type: "unit", value: 80, unit: "%" },
- },
- boxSizing,
- ...borderWidth,
-] satisfies Styles;
-
-/**
- * Prevent 'sub' and 'sup' elements from affecting the line height in all browsers.
- */
-const subSupBase = [
- {
- property: "fontSize",
- value: { type: "unit", value: 75, unit: "%" },
- },
- {
- property: "lineHeight",
- value: { type: "unit", value: 0, unit: "number" },
- },
- {
- property: "position",
- value: { type: "keyword", value: "relative" },
- },
- {
- property: "verticalAlign",
- value: { type: "keyword", value: "baseline" },
- },
- boxSizing,
- ...borderWidth,
-] satisfies Styles;
-
-export const sub = [
- ...subSupBase,
- {
- property: "bottom",
- value: { type: "unit", value: -0.25, unit: "em" },
- },
-] satisfies Styles;
-
-export const sup = [
- ...subSupBase,
- {
- property: "top",
- value: { type: "unit", value: -0.5, unit: "em" },
- },
-] satisfies Styles;
-
-/*
-Tabular data
-============
-*/
-
-/**
- * 1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)
- * 2. Correct table border color inheritance in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)
- */
-export const table = [
- /* 1 */
- {
- property: "textIndent",
- value: { type: "unit", value: 0, unit: "number" },
- },
- ...borderWidth,
- /* 2 */
- {
- property: "borderTopColor",
- value: { type: "keyword", value: "inherit" },
- },
- {
- property: "borderRightColor",
- value: { type: "keyword", value: "inherit" },
- },
- {
- property: "borderBottomColor",
- value: { type: "keyword", value: "inherit" },
- },
- {
- property: "borderLeftColor",
- value: { type: "keyword", value: "inherit" },
- },
- boxSizing,
-] satisfies Styles;
-
-/*
-Forms
-=====
-*/
-
-/**
- * 1. Change the font styles in all browsers.
- * 2. Remove the margin in Firefox and Safari.
- */
-const buttonBase = [
- /* 1 */
- {
- property: "fontFamily",
- value: { type: "keyword", value: "inherit" },
- },
- {
- property: "fontSize",
- value: { type: "unit", value: 100, unit: "%" },
- },
- {
- property: "lineHeight",
- value: { type: "unit", value: 1.15, unit: "number" },
- },
- /* 2 */
- {
- property: "marginTop",
- value: { type: "unit", value: 0, unit: "number" },
- },
- {
- property: "marginRight",
- value: { type: "unit", value: 0, unit: "number" },
- },
- {
- property: "marginBottom",
- value: { type: "unit", value: 0, unit: "number" },
- },
- {
- property: "marginLeft",
- value: { type: "unit", value: 0, unit: "number" },
- },
- boxSizing,
- ...borderWidth,
-] satisfies Styles;
-
-// Input and Textarea uses border style inset by default, wich we don't support in style panel.
-export const input = [...buttonBase, ...borderStyle("solid")];
-export const textarea = input;
-export const optgroup = buttonBase;
-
-// Radio and checkbox have by default border style "none", we are setting it here to reflect in the style panel.
-export const radio = [...buttonBase, ...borderStyle("none")];
-export const checkbox = [...buttonBase, ...borderStyle("none")];
-
-/**
- * Remove the inheritance of text transform in Edge and Firefox.
- */
-export const button = [
- ...buttonBase,
- // Button uses border style outset by default, wich we don't support in style panel.
- ...borderStyle("solid"),
- {
- property: "textTransform",
- value: { type: "keyword", value: "none" },
- },
-] satisfies Styles;
-
-export const select = button;
-
-/**
-Correct the inability to style clickable types in iOS and Safari.
-
-!!!Skipped as we don't support this logic!!!
-
-buttonBase,
-[type='button'],
-[type='reset'],
-[type='submit'] {
- -webkit-appearance: buttonBase;
-}
-*/
-
-/**
-Remove the inner border and padding in Firefox.
-
-!!!Skipped as we don't support this logic!!!
-
-::-moz-focus-inner {
- border-style: none;
- padding: 0;
-}
-*/
-
-/**
-Restore the focus styles unset by the previous rule.
-
-!!!Skipped as we don't support this logic!!!
-
-:-moz-focusring {
- outline: 1px dotted ButtonText;
-}
-*/
-
-/**
-Remove the additional ':invalid' styles in Firefox.
-See: https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737
-
-!!!Skipped as we don't support this logic!!!
-
-:-moz-ui-invalid {
- box-shadow: none;
-}
-*/
-
-/**
- * Remove the padding so developers are not caught out when they zero out 'fieldset' elements in all browsers.
- */
-export const legend = [
- {
- property: "paddingTop",
- value: { type: "unit", value: 0, unit: "number" },
- },
- {
- property: "paddingRight",
- value: { type: "unit", value: 0, unit: "number" },
- },
- {
- property: "paddingBottom",
- value: { type: "unit", value: 0, unit: "number" },
- },
- {
- property: "paddingLeft",
- value: { type: "unit", value: 0, unit: "number" },
- },
- boxSizing,
- ...borderWidth,
-] satisfies Styles;
-
-/**
- * Add the correct vertical alignment in Chrome and Firefox.
- */
-export const progress = [
- {
- property: "verticalAlign",
- value: { type: "keyword", value: "baseline" },
- },
- boxSizing,
- ...borderWidth,
-] satisfies Styles;
-
-/**
-Correct the cursor style of increment and decrement buttons in Safari.
-
-!!!Skipped as we don't support this logic!!!
-
-::-webkit-inner-spin-buttonBase,
-::-webkit-outer-spin-buttonBase {
- height: auto;
-}
-*/
-
-/**
-1. Correct the odd appearance in Chrome and Safari.
-2. Correct the outline style in Safari.
-
-!!!Skipped as we don't support this logic!!!
-
-[type='search'] {
- -webkit-appearance: textfield;
- outline-offset: -2px;
-}
-*/
-
-/**
-Remove the inner padding in Chrome and Safari on macOS.
-
-!!!Skipped as we don't support this logic!!!
-
-::-webkit-search-decoration {
- -webkit-appearance: none;
-}
-*/
-
-/**
-1. Correct the inability to style clickable types in iOS and Safari.
-2. Change font properties to 'inherit' in Safari.
-
-!!!Skipped as we don't support this logic!!!
-
-::-webkit-file-upload-buttonBase {
- -webkit-appearance: buttonBase;
- font: inherit;
-}
-*/
-
-/*
-Interactive
-===========
-*/
-
-/**
- * Add the correct display in Chrome and Safari.
- */
-export const summary = [
- {
- property: "display",
- value: { type: "keyword", value: "list-item" },
- },
- boxSizing,
- ...borderWidth,
-] satisfies Styles;
diff --git a/packages/react-sdk/src/css/presets.ts b/packages/react-sdk/src/css/presets.ts
deleted file mode 100644
index 278c762371..0000000000
--- a/packages/react-sdk/src/css/presets.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-import type { Styles } from "./normalize";
-
-export const borderWidth: Styles = [
- {
- property: "borderTopWidth",
- value: { type: "unit", value: 1, unit: "px" },
- },
- {
- property: "borderRightWidth",
- value: { type: "unit", value: 1, unit: "px" },
- },
- {
- property: "borderBottomWidth",
- value: { type: "unit", value: 1, unit: "px" },
- },
- {
- property: "borderLeftWidth",
- value: { type: "unit", value: 1, unit: "px" },
- },
-];
-
-export const outline: Styles = [
- {
- property: "outlineWidth",
- value: { type: "unit", value: 1, unit: "px" },
- },
-];
-
-export const borderStyle = (value: string): Styles => [
- {
- property: "borderTopStyle",
- value: { type: "keyword", value },
- },
- {
- property: "borderRightStyle",
- value: { type: "keyword", value },
- },
- {
- property: "borderBottomStyle",
- value: { type: "keyword", value },
- },
- {
- property: "borderLeftStyle",
- value: { type: "keyword", value },
- },
-];
diff --git a/packages/sdk-components-react-radix/package.json b/packages/sdk-components-react-radix/package.json
index 5694f92b23..99b4b810bf 100644
--- a/packages/sdk-components-react-radix/package.json
+++ b/packages/sdk-components-react-radix/package.json
@@ -61,7 +61,8 @@
"@radix-ui/react-tooltip": "^1.1.2",
"@webstudio-is/css-engine": "workspace:*",
"@webstudio-is/icons": "workspace:*",
- "@webstudio-is/react-sdk": "workspace:*"
+ "@webstudio-is/react-sdk": "workspace:*",
+ "@webstudio-is/sdk": "workspace:*"
},
"devDependencies": {
"@types/node": "^20.12.7",
diff --git a/packages/sdk-components-react-radix/src/accordion.ws.ts b/packages/sdk-components-react-radix/src/accordion.ws.ts
index 928c73d8a9..28a3bc0bb8 100644
--- a/packages/sdk-components-react-radix/src/accordion.ws.ts
+++ b/packages/sdk-components-react-radix/src/accordion.ws.ts
@@ -14,7 +14,7 @@ import {
type WsComponentPropsMeta,
type WsEmbedTemplate,
} from "@webstudio-is/react-sdk";
-import { div, h3, button } from "@webstudio-is/react-sdk/css-normalize";
+import { div, h3, button } from "@webstudio-is/sdk/normalize.css";
import * as tc from "./theme/tailwind-classes";
import { buttonReset } from "./theme/styles";
import {
diff --git a/packages/sdk-components-react-radix/src/checkbox.ws.ts b/packages/sdk-components-react-radix/src/checkbox.ws.ts
index dc8036a43c..f5b595c540 100644
--- a/packages/sdk-components-react-radix/src/checkbox.ws.ts
+++ b/packages/sdk-components-react-radix/src/checkbox.ws.ts
@@ -8,7 +8,7 @@ import {
type WsComponentMeta,
type WsComponentPropsMeta,
} from "@webstudio-is/react-sdk";
-import { button, span } from "@webstudio-is/react-sdk/css-normalize";
+import { button, span } from "@webstudio-is/sdk/normalize.css";
import * as tc from "./theme/tailwind-classes";
import { buttonReset } from "./theme/styles";
import {
diff --git a/packages/sdk-components-react-radix/src/collapsible.ws.ts b/packages/sdk-components-react-radix/src/collapsible.ws.ts
index 388ea7316d..150d31822e 100644
--- a/packages/sdk-components-react-radix/src/collapsible.ws.ts
+++ b/packages/sdk-components-react-radix/src/collapsible.ws.ts
@@ -8,7 +8,7 @@ import type {
WsComponentMeta,
WsComponentPropsMeta,
} from "@webstudio-is/react-sdk";
-import { div } from "@webstudio-is/react-sdk/css-normalize";
+import { div } from "@webstudio-is/sdk/normalize.css";
import {
propsCollapsible,
propsCollapsibleContent,
diff --git a/packages/sdk-components-react-radix/src/dialog.ws.ts b/packages/sdk-components-react-radix/src/dialog.ws.ts
index 6b3016fc1c..d3fe35447c 100644
--- a/packages/sdk-components-react-radix/src/dialog.ws.ts
+++ b/packages/sdk-components-react-radix/src/dialog.ws.ts
@@ -14,7 +14,7 @@ import {
type WsComponentMeta,
type WsComponentPropsMeta,
} from "@webstudio-is/react-sdk";
-import { div, button, h2, p } from "@webstudio-is/react-sdk/css-normalize";
+import { div, button, h2, p } from "@webstudio-is/sdk/normalize.css";
import * as tc from "./theme/tailwind-classes";
import {
propsDialog,
diff --git a/packages/sdk-components-react-radix/src/label.ws.ts b/packages/sdk-components-react-radix/src/label.ws.ts
index 3199545bc9..4be30474a5 100644
--- a/packages/sdk-components-react-radix/src/label.ws.ts
+++ b/packages/sdk-components-react-radix/src/label.ws.ts
@@ -5,7 +5,7 @@ import {
type WsComponentMeta,
type WsComponentPropsMeta,
} from "@webstudio-is/react-sdk";
-import { label } from "@webstudio-is/react-sdk/css-normalize";
+import { label } from "@webstudio-is/sdk/normalize.css";
import { props } from "./__generated__/label.props";
import * as tc from "./theme/tailwind-classes";
diff --git a/packages/sdk-components-react-radix/src/navigation-menu.ws.ts b/packages/sdk-components-react-radix/src/navigation-menu.ws.ts
index 2f887542cf..993e663bb8 100644
--- a/packages/sdk-components-react-radix/src/navigation-menu.ws.ts
+++ b/packages/sdk-components-react-radix/src/navigation-menu.ws.ts
@@ -13,7 +13,7 @@ import type {
WsComponentMeta,
WsComponentPropsMeta,
} from "@webstudio-is/react-sdk";
-import { div } from "@webstudio-is/react-sdk/css-normalize";
+import { div } from "@webstudio-is/sdk/normalize.css";
import * as tc from "./theme/tailwind-classes";
import { getButtonStyles } from "./theme/styles";
import {
diff --git a/packages/sdk-components-react-radix/src/popover.ws.ts b/packages/sdk-components-react-radix/src/popover.ws.ts
index c0050c5eec..2376cfe39b 100644
--- a/packages/sdk-components-react-radix/src/popover.ws.ts
+++ b/packages/sdk-components-react-radix/src/popover.ws.ts
@@ -4,7 +4,7 @@ import {
type WsComponentMeta,
type WsComponentPropsMeta,
} from "@webstudio-is/react-sdk";
-import { div } from "@webstudio-is/react-sdk/css-normalize";
+import { div } from "@webstudio-is/sdk/normalize.css";
import * as tc from "./theme/tailwind-classes";
import { getButtonStyles } from "./theme/styles";
import {
diff --git a/packages/sdk-components-react-radix/src/radio-group.ws.ts b/packages/sdk-components-react-radix/src/radio-group.ws.ts
index feffd87e28..c3da65a994 100644
--- a/packages/sdk-components-react-radix/src/radio-group.ws.ts
+++ b/packages/sdk-components-react-radix/src/radio-group.ws.ts
@@ -10,7 +10,7 @@ import {
type WsComponentMeta,
type WsComponentPropsMeta,
} from "@webstudio-is/react-sdk";
-import { button, div, span } from "@webstudio-is/react-sdk/css-normalize";
+import { button, div, span } from "@webstudio-is/sdk/normalize.css";
import * as tc from "./theme/tailwind-classes";
import { buttonReset } from "./theme/styles";
import {
diff --git a/packages/sdk-components-react-radix/src/select.ws.ts b/packages/sdk-components-react-radix/src/select.ws.ts
index a4898e01a6..c9af648153 100644
--- a/packages/sdk-components-react-radix/src/select.ws.ts
+++ b/packages/sdk-components-react-radix/src/select.ws.ts
@@ -15,7 +15,7 @@ import type {
WsComponentPropsMeta,
WsEmbedTemplate,
} from "@webstudio-is/react-sdk";
-import { button, div, span } from "@webstudio-is/react-sdk/css-normalize";
+import { button, div, span } from "@webstudio-is/sdk/normalize.css";
import * as tc from "./theme/tailwind-classes";
import {
propsSelect,
diff --git a/packages/sdk-components-react-radix/src/switch.ws.ts b/packages/sdk-components-react-radix/src/switch.ws.ts
index a7921c51f9..8eed96b620 100644
--- a/packages/sdk-components-react-radix/src/switch.ws.ts
+++ b/packages/sdk-components-react-radix/src/switch.ws.ts
@@ -4,7 +4,7 @@ import {
type WsComponentMeta,
type WsComponentPropsMeta,
} from "@webstudio-is/react-sdk";
-import { button, span } from "@webstudio-is/react-sdk/css-normalize";
+import { button, span } from "@webstudio-is/sdk/normalize.css";
import * as tc from "./theme/tailwind-classes";
import { buttonReset } from "./theme/styles";
import { propsSwitch, propsSwitchThumb } from "./__generated__/switch.props";
diff --git a/packages/sdk-components-react-radix/src/tabs.ws.ts b/packages/sdk-components-react-radix/src/tabs.ws.ts
index 4ab05483aa..621376cf05 100644
--- a/packages/sdk-components-react-radix/src/tabs.ws.ts
+++ b/packages/sdk-components-react-radix/src/tabs.ws.ts
@@ -11,7 +11,7 @@ import {
type WsComponentMeta,
type WsComponentPropsMeta,
} from "@webstudio-is/react-sdk";
-import { button, div } from "@webstudio-is/react-sdk/css-normalize";
+import { button, div } from "@webstudio-is/sdk/normalize.css";
import * as tc from "./theme/tailwind-classes";
import { buttonReset } from "./theme/styles";
import {
diff --git a/packages/sdk-components-react-radix/src/tooltip.ws.ts b/packages/sdk-components-react-radix/src/tooltip.ws.ts
index b463c28ff0..581fbcbc7e 100644
--- a/packages/sdk-components-react-radix/src/tooltip.ws.ts
+++ b/packages/sdk-components-react-radix/src/tooltip.ws.ts
@@ -4,7 +4,7 @@ import {
type WsComponentMeta,
type WsComponentPropsMeta,
} from "@webstudio-is/react-sdk";
-import { div } from "@webstudio-is/react-sdk/css-normalize";
+import { div } from "@webstudio-is/sdk/normalize.css";
import * as tc from "./theme/tailwind-classes";
import {
propsTooltip,
diff --git a/packages/sdk-components-react/package.json b/packages/sdk-components-react/package.json
index 963a368a8d..b8c69d4d8c 100644
--- a/packages/sdk-components-react/package.json
+++ b/packages/sdk-components-react/package.json
@@ -50,6 +50,7 @@
"@webstudio-is/icons": "workspace:*",
"@webstudio-is/image": "workspace:*",
"@webstudio-is/react-sdk": "workspace:*",
+ "@webstudio-is/sdk": "workspace:*",
"colord": "^2.9.3",
"micromark": "^4.0.0"
},
diff --git a/packages/sdk-components-react/src/body.ws.ts b/packages/sdk-components-react/src/body.ws.ts
index a1e0b324f6..57d024a74d 100644
--- a/packages/sdk-components-react/src/body.ws.ts
+++ b/packages/sdk-components-react/src/body.ws.ts
@@ -5,7 +5,7 @@ import {
type WsComponentMeta,
type WsComponentPropsMeta,
} from "@webstudio-is/react-sdk";
-import { body } from "@webstudio-is/react-sdk/css-normalize";
+import { body } from "@webstudio-is/sdk/normalize.css";
import { props } from "./__generated__/body.props";
import type { defaultTag } from "./body";
diff --git a/packages/sdk-components-react/src/bold.ws.ts b/packages/sdk-components-react/src/bold.ws.ts
index 5ec7919760..4f139da0fb 100644
--- a/packages/sdk-components-react/src/bold.ws.ts
+++ b/packages/sdk-components-react/src/bold.ws.ts
@@ -5,7 +5,7 @@ import {
type WsComponentMeta,
type WsComponentPropsMeta,
} from "@webstudio-is/react-sdk";
-import { b } from "@webstudio-is/react-sdk/css-normalize";
+import { b } from "@webstudio-is/sdk/normalize.css";
import { props } from "./__generated__/bold.props";
import type { defaultTag } from "./bold";
diff --git a/packages/sdk-components-react/src/box.ws.ts b/packages/sdk-components-react/src/box.ws.ts
index 967ab17bca..d5ac3e68d7 100644
--- a/packages/sdk-components-react/src/box.ws.ts
+++ b/packages/sdk-components-react/src/box.ws.ts
@@ -17,7 +17,7 @@ import {
main,
nav,
section,
-} from "@webstudio-is/react-sdk/css-normalize";
+} from "@webstudio-is/sdk/normalize.css";
import { props } from "./__generated__/box.props";
import type { Box } from "./box";
diff --git a/packages/sdk-components-react/src/button.ws.ts b/packages/sdk-components-react/src/button.ws.ts
index 5a5dddc66a..bad0130d7b 100644
--- a/packages/sdk-components-react/src/button.ws.ts
+++ b/packages/sdk-components-react/src/button.ws.ts
@@ -5,7 +5,7 @@ import {
type WsComponentMeta,
type WsComponentPropsMeta,
} from "@webstudio-is/react-sdk";
-import { button } from "@webstudio-is/react-sdk/css-normalize";
+import { button } from "@webstudio-is/sdk/normalize.css";
import { props } from "./__generated__/button.props";
import type { defaultTag } from "./button";
diff --git a/packages/sdk-components-react/src/checkbox.ws.ts b/packages/sdk-components-react/src/checkbox.ws.ts
index 5b83b9b13f..bf2abb37ff 100644
--- a/packages/sdk-components-react/src/checkbox.ws.ts
+++ b/packages/sdk-components-react/src/checkbox.ws.ts
@@ -5,7 +5,7 @@ import {
type PresetStyle,
defaultStates,
} from "@webstudio-is/react-sdk";
-import { checkbox } from "@webstudio-is/react-sdk/css-normalize";
+import { checkbox } from "@webstudio-is/sdk/normalize.css";
import type { defaultTag } from "./checkbox";
import { props } from "./__generated__/checkbox.props";
diff --git a/packages/sdk-components-react/src/code-text.ws.ts b/packages/sdk-components-react/src/code-text.ws.ts
index 1d4adfec4f..396fcc72a4 100644
--- a/packages/sdk-components-react/src/code-text.ws.ts
+++ b/packages/sdk-components-react/src/code-text.ws.ts
@@ -5,7 +5,7 @@ import {
type WsComponentMeta,
type WsComponentPropsMeta,
} from "@webstudio-is/react-sdk";
-import { code } from "@webstudio-is/react-sdk/css-normalize";
+import { code } from "@webstudio-is/sdk/normalize.css";
import type { defaultTag } from "./code-text";
import { props } from "./__generated__/code-text.props";
diff --git a/packages/sdk-components-react/src/form.ws.ts b/packages/sdk-components-react/src/form.ws.ts
index 61ff28ec8a..a1c47d2e0c 100644
--- a/packages/sdk-components-react/src/form.ws.ts
+++ b/packages/sdk-components-react/src/form.ws.ts
@@ -5,7 +5,7 @@ import {
type WsComponentMeta,
type WsComponentPropsMeta,
} from "@webstudio-is/react-sdk";
-import { form } from "@webstudio-is/react-sdk/css-normalize";
+import { form } from "@webstudio-is/sdk/normalize.css";
import type { defaultTag } from "./form";
import { props } from "./__generated__/form.props";
@@ -19,6 +19,7 @@ const presetStyle = {
export const meta: WsComponentMeta = {
category: "forms",
type: "container",
+ label: "Form",
invalidAncestors: ["Form", "Button", "Link"],
description: "Create filters, surveys, searches and more.",
icon: FormIcon,
diff --git a/packages/sdk-components-react/src/heading.ws.ts b/packages/sdk-components-react/src/heading.ws.ts
index be114a70ec..f4028d1cb4 100644
--- a/packages/sdk-components-react/src/heading.ws.ts
+++ b/packages/sdk-components-react/src/heading.ws.ts
@@ -6,7 +6,7 @@ import {
type WsComponentMeta,
type WsComponentPropsMeta,
} from "@webstudio-is/react-sdk";
-import { h1, h2, h3, h4, h5, h6 } from "@webstudio-is/react-sdk/css-normalize";
+import { h1, h2, h3, h4, h5, h6 } from "@webstudio-is/sdk/normalize.css";
import type { Heading } from "./heading";
import { props } from "./__generated__/heading.props";
diff --git a/packages/sdk-components-react/src/image.ws.ts b/packages/sdk-components-react/src/image.ws.ts
index 8d287e9e2f..b4accbcd56 100644
--- a/packages/sdk-components-react/src/image.ws.ts
+++ b/packages/sdk-components-react/src/image.ws.ts
@@ -5,7 +5,7 @@ import {
type WsComponentMeta,
type WsComponentPropsMeta,
} from "@webstudio-is/react-sdk";
-import { img } from "@webstudio-is/react-sdk/css-normalize";
+import { img } from "@webstudio-is/sdk/normalize.css";
import type { defaultTag } from "./image";
import { props } from "./__generated__/image.props";
diff --git a/packages/sdk-components-react/src/input.ws.ts b/packages/sdk-components-react/src/input.ws.ts
index b189e183c3..32f12bf0f9 100644
--- a/packages/sdk-components-react/src/input.ws.ts
+++ b/packages/sdk-components-react/src/input.ws.ts
@@ -5,7 +5,7 @@ import {
type WsComponentMeta,
type WsComponentPropsMeta,
} from "@webstudio-is/react-sdk";
-import { input } from "@webstudio-is/react-sdk/css-normalize";
+import { input } from "@webstudio-is/sdk/normalize.css";
import type { defaultTag } from "./input";
import { props } from "./__generated__/input.props";
diff --git a/packages/sdk-components-react/src/italic.ws.ts b/packages/sdk-components-react/src/italic.ws.ts
index 7f95c0ca23..393e2ca404 100644
--- a/packages/sdk-components-react/src/italic.ws.ts
+++ b/packages/sdk-components-react/src/italic.ws.ts
@@ -6,7 +6,7 @@ import {
type WsComponentMeta,
type WsComponentPropsMeta,
} from "@webstudio-is/react-sdk";
-import { i } from "@webstudio-is/react-sdk/css-normalize";
+import { i } from "@webstudio-is/sdk/normalize.css";
import { props } from "./__generated__/italic.props";
const presetStyle = {
diff --git a/packages/sdk-components-react/src/label.ws.ts b/packages/sdk-components-react/src/label.ws.ts
index 1db58b6c49..8b55535ee2 100644
--- a/packages/sdk-components-react/src/label.ws.ts
+++ b/packages/sdk-components-react/src/label.ws.ts
@@ -5,7 +5,7 @@ import {
type PresetStyle,
defaultStates,
} from "@webstudio-is/react-sdk";
-import { label } from "@webstudio-is/react-sdk/css-normalize";
+import { label } from "@webstudio-is/sdk/normalize.css";
import { props } from "./__generated__/label.props";
import type { defaultTag } from "./label";
diff --git a/packages/sdk-components-react/src/link.ws.ts b/packages/sdk-components-react/src/link.ws.ts
index 2185afe216..9ee59481ce 100644
--- a/packages/sdk-components-react/src/link.ws.ts
+++ b/packages/sdk-components-react/src/link.ws.ts
@@ -5,7 +5,7 @@ import {
type WsComponentMeta,
type WsComponentPropsMeta,
} from "@webstudio-is/react-sdk";
-import { a } from "@webstudio-is/react-sdk/css-normalize";
+import { a } from "@webstudio-is/sdk/normalize.css";
import type { defaultTag } from "./link";
import { props } from "./__generated__/link.props";
diff --git a/packages/sdk-components-react/src/list-item.ws.ts b/packages/sdk-components-react/src/list-item.ws.ts
index cee9b4fed9..92938c044e 100644
--- a/packages/sdk-components-react/src/list-item.ws.ts
+++ b/packages/sdk-components-react/src/list-item.ws.ts
@@ -5,7 +5,7 @@ import {
type WsComponentMeta,
type WsComponentPropsMeta,
} from "@webstudio-is/react-sdk";
-import { li } from "@webstudio-is/react-sdk/css-normalize";
+import { li } from "@webstudio-is/sdk/normalize.css";
import type { defaultTag } from "./list-item";
import { props } from "./__generated__/list-item.props";
diff --git a/packages/sdk-components-react/src/list.ws.ts b/packages/sdk-components-react/src/list.ws.ts
index a22057e4d8..fd647e6f0b 100644
--- a/packages/sdk-components-react/src/list.ws.ts
+++ b/packages/sdk-components-react/src/list.ws.ts
@@ -5,7 +5,7 @@ import {
type WsComponentMeta,
type WsComponentPropsMeta,
} from "@webstudio-is/react-sdk";
-import { ol, ul } from "@webstudio-is/react-sdk/css-normalize";
+import { ol, ul } from "@webstudio-is/sdk/normalize.css";
import { props } from "./__generated__/list.props";
import type { ListTag } from "./list";
diff --git a/packages/sdk-components-react/src/paragraph.ws.ts b/packages/sdk-components-react/src/paragraph.ws.ts
index ced5424e66..9887b916f4 100644
--- a/packages/sdk-components-react/src/paragraph.ws.ts
+++ b/packages/sdk-components-react/src/paragraph.ws.ts
@@ -5,7 +5,7 @@ import {
type WsComponentMeta,
type WsComponentPropsMeta,
} from "@webstudio-is/react-sdk";
-import { p } from "@webstudio-is/react-sdk/css-normalize";
+import { p } from "@webstudio-is/sdk/normalize.css";
import type { defaultTag } from "./paragraph";
import { props } from "./__generated__/paragraph.props";
diff --git a/packages/sdk-components-react/src/radio-button.ws.ts b/packages/sdk-components-react/src/radio-button.ws.ts
index 8d94cf7252..4d051d515d 100644
--- a/packages/sdk-components-react/src/radio-button.ws.ts
+++ b/packages/sdk-components-react/src/radio-button.ws.ts
@@ -6,7 +6,7 @@ import {
defaultStates,
} from "@webstudio-is/react-sdk";
import type { defaultTag } from "./radio-button";
-import { radio } from "@webstudio-is/react-sdk/css-normalize";
+import { radio } from "@webstudio-is/sdk/normalize.css";
import { props } from "./__generated__/radio-button.props";
const presetStyle = {
diff --git a/packages/sdk-components-react/src/select.ws.ts b/packages/sdk-components-react/src/select.ws.ts
index d5e1b59db2..0704093be9 100644
--- a/packages/sdk-components-react/src/select.ws.ts
+++ b/packages/sdk-components-react/src/select.ws.ts
@@ -5,7 +5,7 @@ import {
type WsComponentMeta,
type WsComponentPropsMeta,
} from "@webstudio-is/react-sdk";
-import { select } from "@webstudio-is/react-sdk/css-normalize";
+import { select } from "@webstudio-is/sdk/normalize.css";
import type { defaultTag } from "./select";
import { props } from "./__generated__/select.props";
diff --git a/packages/sdk-components-react/src/separator.ws.ts b/packages/sdk-components-react/src/separator.ws.ts
index 49c152c94b..db0ae5557d 100644
--- a/packages/sdk-components-react/src/separator.ws.ts
+++ b/packages/sdk-components-react/src/separator.ws.ts
@@ -5,7 +5,7 @@ import {
type WsComponentMeta,
type WsComponentPropsMeta,
} from "@webstudio-is/react-sdk";
-import { hr } from "@webstudio-is/react-sdk/css-normalize";
+import { hr } from "@webstudio-is/sdk/normalize.css";
import { props } from "./__generated__/separator.props";
import type { defaultTag } from "./separator";
diff --git a/packages/sdk-components-react/src/span.ws.ts b/packages/sdk-components-react/src/span.ws.ts
index a6e2df4ecb..9779568fd0 100644
--- a/packages/sdk-components-react/src/span.ws.ts
+++ b/packages/sdk-components-react/src/span.ws.ts
@@ -5,7 +5,7 @@ import {
type WsComponentMeta,
type WsComponentPropsMeta,
} from "@webstudio-is/react-sdk";
-import { span } from "@webstudio-is/react-sdk/css-normalize";
+import { span } from "@webstudio-is/sdk/normalize.css";
import type { defaultTag } from "./span";
import { props } from "./__generated__/span.props";
diff --git a/packages/sdk-components-react/src/subscript.ws.ts b/packages/sdk-components-react/src/subscript.ws.ts
index 406972d12e..284591520f 100644
--- a/packages/sdk-components-react/src/subscript.ws.ts
+++ b/packages/sdk-components-react/src/subscript.ws.ts
@@ -5,7 +5,7 @@ import {
type WsComponentMeta,
type WsComponentPropsMeta,
} from "@webstudio-is/react-sdk";
-import { sub } from "@webstudio-is/react-sdk/css-normalize";
+import { sub } from "@webstudio-is/sdk/normalize.css";
import type { defaultTag } from "./subscript";
import { props } from "./__generated__/subscript.props";
diff --git a/packages/sdk-components-react/src/superscript.ws.ts b/packages/sdk-components-react/src/superscript.ws.ts
index 14e72a5d1d..6b42f1672d 100644
--- a/packages/sdk-components-react/src/superscript.ws.ts
+++ b/packages/sdk-components-react/src/superscript.ws.ts
@@ -5,7 +5,7 @@ import {
type WsComponentMeta,
type WsComponentPropsMeta,
} from "@webstudio-is/react-sdk";
-import { sup } from "@webstudio-is/react-sdk/css-normalize";
+import { sup } from "@webstudio-is/sdk/normalize.css";
import type { defaultTag } from "./superscript";
import { props } from "./__generated__/superscript.props";
diff --git a/packages/sdk-components-react/src/text.ws.ts b/packages/sdk-components-react/src/text.ws.ts
index 3e14538f60..ad979ae3bd 100644
--- a/packages/sdk-components-react/src/text.ws.ts
+++ b/packages/sdk-components-react/src/text.ws.ts
@@ -5,7 +5,7 @@ import {
type WsComponentMeta,
type WsComponentPropsMeta,
} from "@webstudio-is/react-sdk";
-import { div } from "@webstudio-is/react-sdk/css-normalize";
+import { div } from "@webstudio-is/sdk/normalize.css";
import { props } from "./__generated__/text.props";
import type { defaultTag } from "./text";
diff --git a/packages/sdk-components-react/src/textarea.ws.ts b/packages/sdk-components-react/src/textarea.ws.ts
index 78a62dbe18..5dddcd3f0f 100644
--- a/packages/sdk-components-react/src/textarea.ws.ts
+++ b/packages/sdk-components-react/src/textarea.ws.ts
@@ -5,7 +5,7 @@ import {
type PresetStyle,
defaultStates,
} from "@webstudio-is/react-sdk";
-import { textarea } from "@webstudio-is/react-sdk/css-normalize";
+import { textarea } from "@webstudio-is/sdk/normalize.css";
import type { defaultTag } from "./textarea";
import { props } from "./__generated__/textarea.props";
diff --git a/packages/sdk-components-react/src/time.ws.ts b/packages/sdk-components-react/src/time.ws.ts
index a897428af0..4d145b7170 100644
--- a/packages/sdk-components-react/src/time.ws.ts
+++ b/packages/sdk-components-react/src/time.ws.ts
@@ -7,7 +7,7 @@ import {
type WsComponentPropsMeta,
} from "@webstudio-is/react-sdk";
-import { time } from "@webstudio-is/react-sdk/css-normalize";
+import { time } from "@webstudio-is/sdk/normalize.css";
import { props } from "./__generated__/time.props";
diff --git a/packages/sdk-components-react/src/vimeo-play-button.ws.ts b/packages/sdk-components-react/src/vimeo-play-button.ws.ts
index 41fc332a84..fc2591acee 100644
--- a/packages/sdk-components-react/src/vimeo-play-button.ws.ts
+++ b/packages/sdk-components-react/src/vimeo-play-button.ws.ts
@@ -6,7 +6,7 @@ import {
} from "@webstudio-is/react-sdk";
import { props } from "./__generated__/vimeo-play-button.props";
import { ButtonElementIcon } from "@webstudio-is/icons/svg";
-import { button } from "@webstudio-is/react-sdk/css-normalize";
+import { button } from "@webstudio-is/sdk/normalize.css";
import { defaultTag } from "./vimeo-play-button";
const presetStyle = {
diff --git a/packages/sdk-components-react/src/vimeo-spinner.ws.ts b/packages/sdk-components-react/src/vimeo-spinner.ws.ts
index 236b57d227..356e87f2f2 100644
--- a/packages/sdk-components-react/src/vimeo-spinner.ws.ts
+++ b/packages/sdk-components-react/src/vimeo-spinner.ws.ts
@@ -5,7 +5,7 @@ import {
type WsComponentPropsMeta,
} from "@webstudio-is/react-sdk";
import { props } from "./__generated__/vimeo-spinner.props";
-import { div } from "@webstudio-is/react-sdk/css-normalize";
+import { div } from "@webstudio-is/sdk/normalize.css";
import { BoxIcon } from "@webstudio-is/icons/svg";
const presetStyle = {
diff --git a/packages/sdk-components-react/src/vimeo.ws.ts b/packages/sdk-components-react/src/vimeo.ws.ts
index bf7e4011f8..e81e989429 100644
--- a/packages/sdk-components-react/src/vimeo.ws.ts
+++ b/packages/sdk-components-react/src/vimeo.ws.ts
@@ -5,7 +5,7 @@ import {
type WsComponentMeta,
type WsComponentPropsMeta,
} from "@webstudio-is/react-sdk";
-import { div } from "@webstudio-is/react-sdk/css-normalize";
+import { div } from "@webstudio-is/sdk/normalize.css";
import { props } from "./__generated__/vimeo.props";
import { Vimeo } from "./vimeo";
import type { ComponentProps } from "react";
diff --git a/packages/sdk/package.json b/packages/sdk/package.json
index 72059a52fc..8f30fd52a1 100644
--- a/packages/sdk/package.json
+++ b/packages/sdk/package.json
@@ -12,6 +12,11 @@
"types": "./lib/types/index.d.ts",
"import": "./lib/index.js"
},
+ "./normalize.css": {
+ "webstudio": "./src/__generated__/normalize.css.ts",
+ "types": "./lib/types/__generated__/normalize.css.d.ts",
+ "import": "./lib/__generated__/normalize.css.js"
+ },
"./testing": {
"webstudio": "./src/testing.ts"
}
@@ -24,7 +29,8 @@
"scripts": {
"typecheck": "tsc",
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
- "build": "rm -rf lib && esbuild src/index.ts --outdir=lib --bundle --format=esm --packages=external",
+ "build:normalize.css": "tsx --conditions=webstudio ./scripts/normalize.css.ts && prettier --write src/__generated__/normalize.css.ts",
+ "build": "rm -rf lib && esbuild src/index.ts src/__generated__/normalize.css.ts --outdir=lib --bundle --format=esm --packages=external",
"dts": "tsc --project tsconfig.dts.json"
},
"dependencies": {
@@ -37,8 +43,10 @@
},
"devDependencies": {
"@jest/globals": "^29.7.0",
+ "@webstudio-is/css-data": "workspace:*",
"@webstudio-is/jest-config": "workspace:*",
"@webstudio-is/tsconfig": "workspace:*",
+ "html-tags": "^4.0.0",
"strip-indent": "^4.0.0"
}
}
diff --git a/packages/sdk/scripts/normalize.css.ts b/packages/sdk/scripts/normalize.css.ts
new file mode 100644
index 0000000000..22ef921c3d
--- /dev/null
+++ b/packages/sdk/scripts/normalize.css.ts
@@ -0,0 +1,68 @@
+import { mkdir, readFile, writeFile } from "node:fs/promises";
+import { parseCss } from "@webstudio-is/css-data";
+import htmlTags from "html-tags";
+
+const mapGroupBy = <Item, Key>(
+ array: Item[] | Iterable<Item>,
+ getKey: (item: Item) => Key
+) => {
+ const groups = new Map<Key, Item[]>();
+ for (const item of array) {
+ const key = getKey(item);
+ let group = groups.get(key);
+ if (group === undefined) {
+ group = [];
+ groups.set(key, group);
+ }
+ group.push(item);
+ }
+ return groups;
+};
+
+const css = await readFile("./src/normalize.css", "utf8");
+const parsed = parseCss(css);
+const groups = mapGroupBy(parsed, (styleDecl) => styleDecl.selector);
+
+const validTags = [
+ ...htmlTags,
+ // exceptions to access preset styles in Checkbox and Radio components
+ "checkbox",
+ "radio",
+];
+
+const cache = new Map<string, string>();
+
+let code = "";
+code += `import type { StyleProperty, StyleValue } from "@webstudio-is/css-engine";\n`;
+code += `
+type StyleDecl = {
+ state?: string;
+ property: StyleProperty;
+ value: StyleValue;
+}
+
+`;
+for (const [tag, styles] of groups) {
+ if (validTags.includes(tag) === false) {
+ throw Error(`Unexpected tag "${tag}"`);
+ }
+ const newStyles = styles.map(({ state, property, value }) => ({
+ state,
+ property,
+ value,
+ }));
+ let serializedStyles = JSON.stringify(newStyles);
+ const cachedTag = cache.get(serializedStyles);
+ // to prevent duplicating same styles
+ // assign already rendered tag to the tag with same styles
+ if (cachedTag) {
+ serializedStyles = cachedTag;
+ code += `export const ${tag} = ${cachedTag};\n\n`;
+ } else {
+ cache.set(serializedStyles, tag);
+ code += `export const ${tag}: StyleDecl[] = ${serializedStyles};\n\n`;
+ }
+}
+
+await mkdir("./src/__generated__", { recursive: true });
+await writeFile("./src/__generated__/normalize.css.ts", code);
diff --git a/packages/sdk/src/__generated__/normalize.css.ts b/packages/sdk/src/__generated__/normalize.css.ts
new file mode 100644
index 0000000000..b6e278167a
--- /dev/null
+++ b/packages/sdk/src/__generated__/normalize.css.ts
@@ -0,0 +1,526 @@
+import type { StyleProperty, StyleValue } from "@webstudio-is/css-engine";
+
+type StyleDecl = {
+ state?: string;
+ property: StyleProperty;
+ value: StyleValue;
+};
+
+export const div: StyleDecl[] = [
+ { property: "boxSizing", value: { type: "keyword", value: "border-box" } },
+ { property: "borderTopWidth", value: { type: "unit", unit: "px", value: 1 } },
+ {
+ property: "borderRightWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderBottomWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderLeftWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ { property: "outlineWidth", value: { type: "unit", unit: "px", value: 1 } },
+];
+
+export const address = div;
+
+export const article = div;
+
+export const aside = div;
+
+export const figure = div;
+
+export const footer = div;
+
+export const header = div;
+
+export const main = div;
+
+export const nav = div;
+
+export const section = div;
+
+export const form = div;
+
+export const label = div;
+
+export const time = div;
+
+export const h1 = div;
+
+export const h2 = div;
+
+export const h3 = div;
+
+export const h4 = div;
+
+export const h5 = div;
+
+export const h6 = div;
+
+export const i = div;
+
+export const img = div;
+
+export const a = div;
+
+export const li = div;
+
+export const ul = div;
+
+export const ol = div;
+
+export const p = div;
+
+export const span = div;
+
+export const html: StyleDecl[] = [
+ {
+ property: "lineHeight",
+ value: { type: "unit", unit: "number", value: 1.15 },
+ },
+ {
+ property: "textSizeAdjust",
+ value: { type: "unit", unit: "%", value: 100 },
+ },
+ { property: "tabSize", value: { type: "unit", unit: "number", value: 4 } },
+ { property: "boxSizing", value: { type: "keyword", value: "border-box" } },
+ { property: "borderTopWidth", value: { type: "unit", unit: "px", value: 1 } },
+ {
+ property: "borderRightWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderBottomWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderLeftWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+];
+
+export const body: StyleDecl[] = [
+ { property: "marginTop", value: { type: "unit", unit: "number", value: 0 } },
+ {
+ property: "marginRight",
+ value: { type: "unit", unit: "number", value: 0 },
+ },
+ {
+ property: "marginBottom",
+ value: { type: "unit", unit: "number", value: 0 },
+ },
+ { property: "marginLeft", value: { type: "unit", unit: "number", value: 0 } },
+ {
+ property: "fontFamily",
+ value: { type: "fontFamily", value: ["Arial", "Roboto", "sans-serif"] },
+ },
+ { property: "fontSize", value: { type: "unit", unit: "px", value: 16 } },
+ {
+ property: "lineHeight",
+ value: { type: "unit", unit: "number", value: 1.2 },
+ },
+ { property: "boxSizing", value: { type: "keyword", value: "border-box" } },
+ { property: "borderTopWidth", value: { type: "unit", unit: "px", value: 1 } },
+ {
+ property: "borderRightWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderBottomWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderLeftWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+];
+
+export const hr: StyleDecl[] = [
+ { property: "height", value: { type: "unit", unit: "number", value: 0 } },
+ { property: "color", value: { type: "keyword", value: "inherit" } },
+ { property: "boxSizing", value: { type: "keyword", value: "border-box" } },
+ { property: "borderTopWidth", value: { type: "unit", unit: "px", value: 1 } },
+ {
+ property: "borderRightWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderBottomWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderLeftWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+];
+
+export const b: StyleDecl[] = [
+ {
+ property: "fontWeight",
+ value: { type: "unit", unit: "number", value: 700 },
+ },
+ { property: "boxSizing", value: { type: "keyword", value: "border-box" } },
+ { property: "borderTopWidth", value: { type: "unit", unit: "px", value: 1 } },
+ {
+ property: "borderRightWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderBottomWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderLeftWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+];
+
+export const strong = b;
+
+export const code: StyleDecl[] = [
+ {
+ property: "fontFamily",
+ value: {
+ type: "fontFamily",
+ value: [
+ "ui-monospace",
+ "SFMono-Regular",
+ "Consolas",
+ "Liberation Mono",
+ "Menlo",
+ "monospace",
+ ],
+ },
+ },
+ { property: "fontSize", value: { type: "unit", unit: "em", value: 1 } },
+ { property: "boxSizing", value: { type: "keyword", value: "border-box" } },
+ { property: "borderTopWidth", value: { type: "unit", unit: "px", value: 1 } },
+ {
+ property: "borderRightWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderBottomWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderLeftWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+];
+
+export const kbd = code;
+
+export const samp = code;
+
+export const pre = code;
+
+export const small: StyleDecl[] = [
+ { property: "fontSize", value: { type: "unit", unit: "%", value: 80 } },
+ { property: "boxSizing", value: { type: "keyword", value: "border-box" } },
+ { property: "borderTopWidth", value: { type: "unit", unit: "px", value: 1 } },
+ {
+ property: "borderRightWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderBottomWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderLeftWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+];
+
+export const sub: StyleDecl[] = [
+ { property: "fontSize", value: { type: "unit", unit: "%", value: 75 } },
+ { property: "lineHeight", value: { type: "unit", unit: "number", value: 0 } },
+ { property: "position", value: { type: "keyword", value: "relative" } },
+ { property: "verticalAlign", value: { type: "keyword", value: "baseline" } },
+ { property: "boxSizing", value: { type: "keyword", value: "border-box" } },
+ { property: "borderTopWidth", value: { type: "unit", unit: "px", value: 1 } },
+ {
+ property: "borderRightWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderBottomWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderLeftWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ { property: "bottom", value: { type: "unit", unit: "em", value: -0.25 } },
+];
+
+export const sup: StyleDecl[] = [
+ { property: "fontSize", value: { type: "unit", unit: "%", value: 75 } },
+ { property: "lineHeight", value: { type: "unit", unit: "number", value: 0 } },
+ { property: "position", value: { type: "keyword", value: "relative" } },
+ { property: "verticalAlign", value: { type: "keyword", value: "baseline" } },
+ { property: "boxSizing", value: { type: "keyword", value: "border-box" } },
+ { property: "borderTopWidth", value: { type: "unit", unit: "px", value: 1 } },
+ {
+ property: "borderRightWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderBottomWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderLeftWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ { property: "top", value: { type: "unit", unit: "em", value: -0.5 } },
+];
+
+export const table: StyleDecl[] = [
+ { property: "textIndent", value: { type: "unit", unit: "number", value: 0 } },
+ { property: "borderTopWidth", value: { type: "unit", unit: "px", value: 1 } },
+ {
+ property: "borderRightWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderBottomWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderLeftWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ { property: "borderTopColor", value: { type: "keyword", value: "inherit" } },
+ {
+ property: "borderRightColor",
+ value: { type: "keyword", value: "inherit" },
+ },
+ {
+ property: "borderBottomColor",
+ value: { type: "keyword", value: "inherit" },
+ },
+ { property: "borderLeftColor", value: { type: "keyword", value: "inherit" } },
+ { property: "boxSizing", value: { type: "keyword", value: "border-box" } },
+];
+
+export const input: StyleDecl[] = [
+ { property: "fontFamily", value: { type: "keyword", value: "inherit" } },
+ { property: "fontSize", value: { type: "unit", unit: "%", value: 100 } },
+ {
+ property: "lineHeight",
+ value: { type: "unit", unit: "number", value: 1.15 },
+ },
+ { property: "marginTop", value: { type: "unit", unit: "number", value: 0 } },
+ {
+ property: "marginRight",
+ value: { type: "unit", unit: "number", value: 0 },
+ },
+ {
+ property: "marginBottom",
+ value: { type: "unit", unit: "number", value: 0 },
+ },
+ { property: "marginLeft", value: { type: "unit", unit: "number", value: 0 } },
+ { property: "boxSizing", value: { type: "keyword", value: "border-box" } },
+ { property: "borderTopWidth", value: { type: "unit", unit: "px", value: 1 } },
+ {
+ property: "borderRightWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderBottomWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderLeftWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ { property: "borderTopStyle", value: { type: "keyword", value: "solid" } },
+ { property: "borderRightStyle", value: { type: "keyword", value: "solid" } },
+ { property: "borderBottomStyle", value: { type: "keyword", value: "solid" } },
+ { property: "borderLeftStyle", value: { type: "keyword", value: "solid" } },
+];
+
+export const textarea = input;
+
+export const optgroup: StyleDecl[] = [
+ { property: "fontFamily", value: { type: "keyword", value: "inherit" } },
+ { property: "fontSize", value: { type: "unit", unit: "%", value: 100 } },
+ {
+ property: "lineHeight",
+ value: { type: "unit", unit: "number", value: 1.15 },
+ },
+ { property: "marginTop", value: { type: "unit", unit: "number", value: 0 } },
+ {
+ property: "marginRight",
+ value: { type: "unit", unit: "number", value: 0 },
+ },
+ {
+ property: "marginBottom",
+ value: { type: "unit", unit: "number", value: 0 },
+ },
+ { property: "marginLeft", value: { type: "unit", unit: "number", value: 0 } },
+ { property: "boxSizing", value: { type: "keyword", value: "border-box" } },
+ { property: "borderTopWidth", value: { type: "unit", unit: "px", value: 1 } },
+ {
+ property: "borderRightWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderBottomWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderLeftWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+];
+
+export const radio: StyleDecl[] = [
+ { property: "fontFamily", value: { type: "keyword", value: "inherit" } },
+ { property: "fontSize", value: { type: "unit", unit: "%", value: 100 } },
+ {
+ property: "lineHeight",
+ value: { type: "unit", unit: "number", value: 1.15 },
+ },
+ { property: "marginTop", value: { type: "unit", unit: "number", value: 0 } },
+ {
+ property: "marginRight",
+ value: { type: "unit", unit: "number", value: 0 },
+ },
+ {
+ property: "marginBottom",
+ value: { type: "unit", unit: "number", value: 0 },
+ },
+ { property: "marginLeft", value: { type: "unit", unit: "number", value: 0 } },
+ { property: "boxSizing", value: { type: "keyword", value: "border-box" } },
+ { property: "borderTopWidth", value: { type: "unit", unit: "px", value: 1 } },
+ {
+ property: "borderRightWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderBottomWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderLeftWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ { property: "borderTopStyle", value: { type: "keyword", value: "none" } },
+ { property: "borderRightStyle", value: { type: "keyword", value: "none" } },
+ { property: "borderBottomStyle", value: { type: "keyword", value: "none" } },
+ { property: "borderLeftStyle", value: { type: "keyword", value: "none" } },
+];
+
+export const checkbox = radio;
+
+export const button: StyleDecl[] = [
+ { property: "fontFamily", value: { type: "keyword", value: "inherit" } },
+ { property: "fontSize", value: { type: "unit", unit: "%", value: 100 } },
+ {
+ property: "lineHeight",
+ value: { type: "unit", unit: "number", value: 1.15 },
+ },
+ { property: "marginTop", value: { type: "unit", unit: "number", value: 0 } },
+ {
+ property: "marginRight",
+ value: { type: "unit", unit: "number", value: 0 },
+ },
+ {
+ property: "marginBottom",
+ value: { type: "unit", unit: "number", value: 0 },
+ },
+ { property: "marginLeft", value: { type: "unit", unit: "number", value: 0 } },
+ { property: "boxSizing", value: { type: "keyword", value: "border-box" } },
+ { property: "borderTopWidth", value: { type: "unit", unit: "px", value: 1 } },
+ {
+ property: "borderRightWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderBottomWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderLeftWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ { property: "borderTopStyle", value: { type: "keyword", value: "solid" } },
+ { property: "borderRightStyle", value: { type: "keyword", value: "solid" } },
+ { property: "borderBottomStyle", value: { type: "keyword", value: "solid" } },
+ { property: "borderLeftStyle", value: { type: "keyword", value: "solid" } },
+ { property: "textTransform", value: { type: "keyword", value: "none" } },
+];
+
+export const select = button;
+
+export const legend: StyleDecl[] = [
+ { property: "paddingTop", value: { type: "unit", unit: "number", value: 0 } },
+ {
+ property: "paddingRight",
+ value: { type: "unit", unit: "number", value: 0 },
+ },
+ {
+ property: "paddingBottom",
+ value: { type: "unit", unit: "number", value: 0 },
+ },
+ {
+ property: "paddingLeft",
+ value: { type: "unit", unit: "number", value: 0 },
+ },
+ { property: "boxSizing", value: { type: "keyword", value: "border-box" } },
+ { property: "borderTopWidth", value: { type: "unit", unit: "px", value: 1 } },
+ {
+ property: "borderRightWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderBottomWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderLeftWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+];
+
+export const progress: StyleDecl[] = [
+ { property: "verticalAlign", value: { type: "keyword", value: "baseline" } },
+ { property: "boxSizing", value: { type: "keyword", value: "border-box" } },
+ { property: "borderTopWidth", value: { type: "unit", unit: "px", value: 1 } },
+ {
+ property: "borderRightWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderBottomWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderLeftWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+];
+
+export const summary: StyleDecl[] = [
+ { property: "display", value: { type: "keyword", value: "list-item" } },
+ { property: "boxSizing", value: { type: "keyword", value: "border-box" } },
+ { property: "borderTopWidth", value: { type: "unit", unit: "px", value: 1 } },
+ {
+ property: "borderRightWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderBottomWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderLeftWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+];
diff --git a/packages/sdk/src/normalize.css b/packages/sdk/src/normalize.css
new file mode 100644
index 0000000000..23afbd35cf
--- /dev/null
+++ b/packages/sdk/src/normalize.css
@@ -0,0 +1,372 @@
+/**
+ * Based on https://github.com/sindresorhus/modern-normalize
+ *
+ * Attributions
+ *
+ * The MIT License (MIT)
+ * Copyright (c) Nicolas Gallagher
+ * Copyright (c) Jonathan Neal
+ * Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
+ */
+
+/**
+ * We dont support rules like this now, implement box-sizing for each used element
+ * *,
+ * ::before,
+ * ::after {
+ * box-sizing: border-box;
+ * }
+ */
+
+div,
+address,
+article,
+aside,
+figure,
+footer,
+header,
+main,
+nav,
+section,
+form,
+label,
+time,
+h1,
+h2,
+h3,
+h4,
+h5,
+h6,
+i,
+img,
+a,
+li,
+ul,
+ol,
+p,
+span {
+ /**
+ * Use a better box model (opinionated).
+ */
+ box-sizing: border-box;
+ /* webstudio custom opinionated presets */
+ border-width: 1px;
+ outline-width: 1px;
+}
+
+/* @todo for now not applied to html, as we don't have html element */
+/**
+ * 1. Correct the line height in all browsers.
+ * 2. Prevent adjustments of font size after orientation changes in iOS.
+ * 3. Use a more readable tab size (opinionated).
+ */
+html {
+ /* 1 */
+ line-height: 1.15;
+ /* 2 */
+ -webkit-text-size-adjust: 100%;
+ /* 3 */
+ tab-size: 4;
+ /* webstudio custom opinionated presets */
+ box-sizing: border-box;
+ border-width: 1px;
+}
+
+/**
+ * 1. Remove the margin in all browsers.
+ * 2. Improve consistency of default fonts in all browsers. (https://github.com/sindresorhus/modern-normalize/issues/3)
+ */
+body {
+ /* 1 */
+ margin: 0;
+ /* 2 */
+ font-family: Arial, Roboto, sans-serif;
+ font-size: 16px;
+ line-height: 1.2;
+ /* webstudio custom opinionated presets */
+ box-sizing: border-box;
+ border-width: 1px;
+}
+
+/**
+ * 1. Add the correct height in Firefox.
+ * 2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)
+ */
+hr {
+ /* 1 */
+ height: 0;
+ /* 2 */
+ color: inherit;
+ /* webstudio custom opinionated presets */
+ box-sizing: border-box;
+ border-width: 1px;
+}
+
+/**
+Add the correct text decoration in Chrome, Edge, and Safari.
+
+!!!Skipped as we don't support this logic!!!
+
+abbr[title] {
+ text-decoration: underline dotted;
+}
+*/
+
+/**
+ * Add the correct font weight in Edge and Safari.
+ */
+b,
+strong {
+ font-weight: 700;
+ /* webstudio custom opinionated presets */
+ box-sizing: border-box;
+ border-width: 1px;
+}
+
+/**
+ * 1. Improve consistency of default fonts in all browsers. (https://github.com/sindresorhus/modern-normalize/issues/3)
+ * 2. Correct the odd 'em' font sizing in all browsers.
+ */
+code,
+kbd,
+samp,
+pre {
+ /* 1 */
+ font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo,
+ monospace;
+ /* 2 */
+ font-size: 1em;
+ /* webstudio custom opinionated presets */
+ box-sizing: border-box;
+ border-width: 1px;
+}
+
+/**
+ * Add the correct font size in all browsers.
+ */
+small {
+ font-size: 80%;
+ /* webstudio custom opinionated presets */
+ box-sizing: border-box;
+ border-width: 1px;
+}
+
+/**
+ * Prevent 'sub' and 'sup' elements from affecting the line height in all browsers.
+ */
+sub,
+sup {
+ font-size: 75%;
+ line-height: 0;
+ position: relative;
+ vertical-align: baseline;
+ /* webstudio custom opinionated presets */
+ box-sizing: border-box;
+ border-width: 1px;
+}
+
+sub {
+ bottom: -0.25em;
+}
+
+sup {
+ top: -0.5em;
+}
+
+/*
+Tabular data
+============
+*/
+
+/**
+ * 1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)
+ * 2. Correct table border color inheritance in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)
+ */
+table {
+ /* 1 */
+ text-indent: 0;
+ border-width: 1px;
+ /* 2 */
+ border-color: inherit;
+ box-sizing: border-box;
+}
+
+/*
+Forms
+=====
+*/
+
+input,
+textarea,
+optgroup,
+/* These are non-standard tags, defined this way to be able to access in component presets */
+radio,
+checkbox,
+button,
+select {
+ /* 1 */
+ font-family: inherit;
+ font-size: 100%;
+ line-height: 1.15;
+ /* 2 */
+ margin: 0;
+ /* webstudio custom opinionated presets */
+ box-sizing: border-box;
+ border-width: 1px;
+}
+
+/* Input and Textarea uses border style inset by default, wich we don't support in style panel. */
+input,
+textarea {
+ border-style: solid;
+}
+
+/*
+Radio and checkbox have by default border style "none", we are setting it here to reflect in the style panel.
+
+These are non-standard tags, defined this way to be able to access in component presets
+*/
+radio,
+checkbox {
+ border-style: none;
+}
+
+/**
+ * Remove the inheritance of text transform in Edge and Firefox.
+ */
+button,
+select {
+ border-style: solid;
+ text-transform: none;
+}
+
+/**
+Correct the inability to style clickable types in iOS and Safari.
+
+!!!Skipped as we don't support this logic!!!
+
+button,
+[type='button'],
+[type='reset'],
+[type='submit'] {
+ -webkit-appearance: button;
+}
+*/
+
+/**
+Remove the inner border and padding in Firefox.
+
+!!!Skipped as we don't support this logic!!!
+
+::-moz-focus-inner {
+ border-style: none;
+ padding: 0;
+}
+*/
+
+/**
+Restore the focus styles unset by the previous rule.
+
+!!!Skipped as we don't support this logic!!!
+
+:-moz-focusring {
+ outline: 1px dotted ButtonText;
+}
+*/
+
+/**
+Remove the additional ':invalid' styles in Firefox.
+See: https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737
+
+!!!Skipped as we don't support this logic!!!
+
+:-moz-ui-invalid {
+ box-shadow: none;
+}
+*/
+
+/**
+ * Remove the padding so developers are not caught out when they zero out 'fieldset' elements in all browsers.
+ */
+legend {
+ padding: 0;
+ /* webstudio custom opinionated presets */
+ box-sizing: border-box;
+ border-width: 1px;
+}
+
+/**
+ * Add the correct vertical alignment in Chrome and Firefox.
+ */
+progress {
+ vertical-align: baseline;
+ /* webstudio custom opinionated presets */
+ box-sizing: border-box;
+ border-width: 1px;
+}
+
+/**
+Correct the cursor style of increment and decrement buttons in Safari.
+
+!!!Skipped as we don't support this logic!!!
+
+::-webkit-inner-spin-button,
+::-webkit-outer-spin-button {
+ height: auto;
+}
+*/
+
+/**
+1. Correct the odd appearance in Chrome and Safari.
+2. Correct the outline style in Safari.
+
+!!!Skipped as we don't support this logic!!!
+
+[type='search'] {
+ -webkit-appearance: textfield;
+ outline-offset: -2px;
+}
+*/
+
+/**
+Remove the inner padding in Chrome and Safari on macOS.
+
+!!!Skipped as we don't support this logic!!!
+
+::-webkit-search-decoration {
+ -webkit-appearance: none;
+}
+*/
+
+/**
+1. Correct the inability to style clickable types in iOS and Safari.
+2. Change font properties to 'inherit' in Safari.
+
+!!!Skipped as we don't support this logic!!!
+
+::-webkit-file-upload-button {
+ -webkit-appearance: button;
+ font: inherit;
+}
+*/
+
+/*
+Interactive
+===========
+*/
+
+/**
+ * Add the correct display in Chrome and Safari.
+ */
+summary {
+ display: list-item;
+ /* webstudio custom opinionated presets */
+ box-sizing: border-box;
+ border-width: 1px;
+}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 19adba3082..c0967b0229 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1812,12 +1812,18 @@ importers:
'@jest/globals':
specifier: ^29.7.0
version: 29.7.0
+ '@webstudio-is/css-data':
+ specifier: workspace:*
+ version: link:../css-data
'@webstudio-is/jest-config':
specifier: workspace:*
version: link:../jest-config
'@webstudio-is/tsconfig':
specifier: workspace:*
version: link:../tsconfig
+ html-tags:
+ specifier: ^4.0.0
+ version: 4.0.0
strip-indent:
specifier: ^4.0.0
version: 4.0.0
@@ -1858,6 +1864,9 @@ importers:
'@webstudio-is/react-sdk':
specifier: workspace:*
version: link:../react-sdk
+ '@webstudio-is/sdk':
+ specifier: workspace:*
+ version: link:../sdk
colord:
specifier: ^2.9.3
version: 2.9.3
@@ -1946,6 +1955,9 @@ importers:
'@webstudio-is/react-sdk':
specifier: workspace:*
version: link:../react-sdk
+ '@webstudio-is/sdk':
+ specifier: workspace:*
+ version: link:../sdk
devDependencies:
'@types/node':
specifier: ^20.12.7