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.

Merge image components (#1690)

Bogdan Chadkinfe4c19f22f7f
diff --git a/packages/image/package.json b/packages/image/package.json
index bcffe9c760..977601b6fc 100644
--- a/packages/image/package.json
+++ b/packages/image/package.json
@@ -11,15 +11,12 @@
"checks": "pnpm typecheck && pnpm lint && pnpm test",
"dev": "build-package --watch",
"build": "build-package",
- "build:args": "generate-arg-types './src/*.tsx !./src/**/*.stories.tsx !./src/**/*.ws.tsx' && prettier --write \"**/*.props.ts\"",
"dts": "tsc --declarationDir lib/types",
"lint": "eslint ./src --ext .ts,.tsx --max-warnings 0",
"storybook:run": "start-storybook -p 6006",
- "storybook:build": "build-storybook",
- "generate-types": "generate-arg-types"
+ "storybook:build": "build-storybook"
},
"dependencies": {
- "@webstudio-is/generate-arg-types": "workspace:^",
"react": "^18.2.0",
"warn-once": "^0.1.1"
},
@@ -40,7 +37,6 @@
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
- "module": "./lib/index.js",
"exports": {
"source": "./src/index.ts",
"import": "./lib/index.js",
diff --git a/packages/image/src/__generated__/image.props.ts b/packages/image/src/__generated__/image.props.ts
deleted file mode 100644
index 8c07ad2ece..0000000000
--- a/packages/image/src/__generated__/image.props.ts
+++ /dev/null
@@ -1,489 +0,0 @@
-import type { PropMeta } from "@webstudio-is/generate-arg-types";
-
-export const props: Record<string, PropMeta> = {
- slot: { required: false, control: "text", type: "string" },
- style: { required: false, control: "text", type: "string" },
- title: { required: false, control: "text", type: "string" },
- alt: { required: false, control: "text", type: "string" },
- crossOrigin: {
- required: false,
- control: "radio",
- type: "string",
- options: ["", "anonymous", "use-credentials"],
- },
- decoding: {
- required: false,
- control: "radio",
- type: "string",
- defaultValue: "async",
- options: ["async", "auto", "sync"],
- },
- height: { required: false, control: "number", type: "number" },
- loading: {
- required: false,
- control: "radio",
- type: "string",
- defaultValue: "lazy",
- options: ["eager", "lazy"],
- },
- referrerPolicy: {
- required: false,
- control: "select",
- type: "string",
- options: [
- "",
- "no-referrer",
- "no-referrer-when-downgrade",
- "origin",
- "origin-when-cross-origin",
- "same-origin",
- "strict-origin",
- "strict-origin-when-cross-origin",
- "unsafe-url",
- ],
- },
- sizes: { required: false, control: "text", type: "string" },
- src: { required: false, control: "text", type: "string", defaultValue: "" },
- srcSet: { required: false, control: "text", type: "string" },
- useMap: { required: false, control: "text", type: "string" },
- width: { required: false, control: "number", type: "number" },
- defaultChecked: { required: false, control: "boolean", type: "boolean" },
- defaultValue: { required: false, control: "text", type: "string" },
- suppressContentEditableWarning: {
- required: false,
- control: "boolean",
- type: "boolean",
- },
- suppressHydrationWarning: {
- required: false,
- control: "boolean",
- type: "boolean",
- },
- accessKey: { required: false, control: "text", type: "string" },
- className: { required: false, control: "text", type: "string" },
- contentEditable: { required: false, control: "text", type: "string" },
- contextMenu: { required: false, control: "text", type: "string" },
- dir: { required: false, control: "text", type: "string" },
- draggable: { required: false, control: "boolean", type: "boolean" },
- hidden: { required: false, control: "boolean", type: "boolean" },
- id: { required: false, control: "text", type: "string" },
- lang: { required: false, control: "text", type: "string" },
- placeholder: { required: false, control: "text", type: "string" },
- spellCheck: { required: false, control: "boolean", type: "boolean" },
- tabIndex: { required: false, control: "number", type: "number" },
- translate: {
- required: false,
- control: "radio",
- type: "string",
- options: ["yes", "no"],
- },
- radioGroup: { required: false, control: "text", type: "string" },
- role: { required: false, control: "text", type: "string" },
- about: { required: false, control: "text", type: "string" },
- datatype: { required: false, control: "text", type: "string" },
- inlist: { required: false, control: "text", type: "string" },
- prefix: { required: false, control: "text", type: "string" },
- property: { required: false, control: "text", type: "string" },
- resource: { required: false, control: "text", type: "string" },
- typeof: { required: false, control: "text", type: "string" },
- vocab: { required: false, control: "text", type: "string" },
- autoCapitalize: { required: false, control: "text", type: "string" },
- autoCorrect: { required: false, control: "text", type: "string" },
- autoSave: { required: false, control: "text", type: "string" },
- color: { required: false, control: "color", type: "string" },
- itemProp: { required: false, control: "text", type: "string" },
- itemScope: { required: false, control: "boolean", type: "boolean" },
- itemType: { required: false, control: "text", type: "string" },
- itemID: { required: false, control: "text", type: "string" },
- itemRef: { required: false, control: "text", type: "string" },
- results: { required: false, control: "number", type: "number" },
- security: { required: false, control: "text", type: "string" },
- unselectable: {
- required: false,
- control: "radio",
- type: "string",
- options: ["on", "off"],
- },
- inputMode: {
- description:
- "Hints at the type of data that might be entered by the user while editing the element or its contents\n@see https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute",
- required: false,
- control: "select",
- type: "string",
- options: [
- "text",
- "none",
- "search",
- "tel",
- "url",
- "email",
- "numeric",
- "decimal",
- ],
- },
- is: {
- description:
- "Specify that a standard HTML element should behave like a defined custom built-in element\n@see https://html.spec.whatwg.org/multipage/custom-elements.html#attr-is",
- required: false,
- control: "text",
- type: "string",
- },
- "aria-activedescendant": {
- description:
- "Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or application.",
- required: false,
- control: "text",
- type: "string",
- },
- "aria-atomic": {
- description:
- "Indicates whether assistive technologies will present all, or only parts of, the changed region based on the change notifications defined by the aria-relevant attribute.",
- required: false,
- control: "boolean",
- type: "boolean",
- },
- "aria-autocomplete": {
- description:
- "Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be\npresented if they are made.",
- required: false,
- control: "radio",
- type: "string",
- options: ["list", "none", "inline", "both"],
- },
- "aria-busy": {
- description:
- "Indicates an element is being modified and that assistive technologies MAY want to wait until the modifications are complete before exposing them to the user.",
- required: false,
- control: "boolean",
- type: "boolean",
- },
- "aria-checked": {
- description:
- 'Indicates the current "checked" state of checkboxes, radio buttons, and other widgets.\n@see aria-pressed\n@see aria-selected.',
- required: false,
- control: "text",
- type: "string",
- },
- "aria-colcount": {
- description:
- "Defines the total number of columns in a table, grid, or treegrid.\n@see aria-colindex.",
- required: false,
- control: "number",
- type: "number",
- },
- "aria-colindex": {
- description:
- "Defines an element's column index or position with respect to the total number of columns within a table, grid, or treegrid.\n@see aria-colcount\n@see aria-colspan.",
- required: false,
- control: "number",
- type: "number",
- },
- "aria-colspan": {
- description:
- "Defines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid.\n@see aria-colindex\n@see aria-rowspan.",
- required: false,
- control: "number",
- type: "number",
- },
- "aria-controls": {
- description:
- "Identifies the element (or elements) whose contents or presence are controlled by the current element.\n@see aria-owns.",
- required: false,
- control: "text",
- type: "string",
- },
- "aria-current": {
- description:
- "Indicates the element that represents the current item within a container or set of related elements.",
- required: false,
- control: "text",
- type: "string",
- },
- "aria-describedby": {
- description:
- "Identifies the element (or elements) that describes the object.\n@see aria-labelledby",
- required: false,
- control: "text",
- type: "string",
- },
- "aria-details": {
- description:
- "Identifies the element that provides a detailed, extended description for the object.\n@see aria-describedby.",
- required: false,
- control: "text",
- type: "string",
- },
- "aria-disabled": {
- description:
- "Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable.\n@see aria-hidden\n@see aria-readonly.",
- required: false,
- control: "boolean",
- type: "boolean",
- },
- "aria-dropeffect": {
- description:
- "Indicates what functions can be performed when a dragged object is released on the drop target.\n@deprecated in ARIA 1.1",
- required: false,
- control: "select",
- type: "string",
- options: ["link", "none", "copy", "execute", "move", "popup"],
- },
- "aria-errormessage": {
- description:
- "Identifies the element that provides an error message for the object.\n@see aria-invalid\n@see aria-describedby.",
- required: false,
- control: "text",
- type: "string",
- },
- "aria-expanded": {
- description:
- "Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed.",
- required: false,
- control: "boolean",
- type: "boolean",
- },
- "aria-flowto": {
- description:
- "Identifies the next element (or elements) in an alternate reading order of content which, at the user's discretion,\nallows assistive technology to override the general default of reading in document source order.",
- required: false,
- control: "text",
- type: "string",
- },
- "aria-grabbed": {
- description:
- 'Indicates an element\'s "grabbed" state in a drag-and-drop operation.\n@deprecated in ARIA 1.1',
- required: false,
- control: "boolean",
- type: "boolean",
- },
- "aria-haspopup": {
- description:
- "Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element.",
- required: false,
- control: "text",
- type: "string",
- },
- "aria-hidden": {
- description:
- "Indicates whether the element is exposed to an accessibility API.\n@see aria-disabled.",
- required: false,
- control: "boolean",
- type: "boolean",
- },
- "aria-invalid": {
- description:
- "Indicates the entered value does not conform to the format expected by the application.\n@see aria-errormessage.",
- required: false,
- control: "text",
- type: "string",
- },
- "aria-keyshortcuts": {
- description:
- "Indicates keyboard shortcuts that an author has implemented to activate or give focus to an element.",
- required: false,
- control: "text",
- type: "string",
- },
- "aria-label": {
- description:
- "Defines a string value that labels the current element.\n@see aria-labelledby.",
- required: false,
- control: "text",
- type: "string",
- },
- "aria-labelledby": {
- description:
- "Identifies the element (or elements) that labels the current element.\n@see aria-describedby.",
- required: false,
- control: "text",
- type: "string",
- },
- "aria-level": {
- description:
- "Defines the hierarchical level of an element within a structure.",
- required: false,
- control: "number",
- type: "number",
- },
- "aria-live": {
- description:
- "Indicates that an element will be updated, and describes the types of updates the user agents, assistive technologies, and user can expect from the live region.",
- required: false,
- control: "radio",
- type: "string",
- options: ["off", "assertive", "polite"],
- },
- "aria-modal": {
- description: "Indicates whether an element is modal when displayed.",
- required: false,
- control: "boolean",
- type: "boolean",
- },
- "aria-multiline": {
- description:
- "Indicates whether a text box accepts multiple lines of input or only a single line.",
- required: false,
- control: "boolean",
- type: "boolean",
- },
- "aria-multiselectable": {
- description:
- "Indicates that the user may select more than one item from the current selectable descendants.",
- required: false,
- control: "boolean",
- type: "boolean",
- },
- "aria-orientation": {
- description:
- "Indicates whether the element's orientation is horizontal, vertical, or unknown/ambiguous.",
- required: false,
- control: "radio",
- type: "string",
- options: ["horizontal", "vertical"],
- },
- "aria-owns": {
- description:
- "Identifies an element (or elements) in order to define a visual, functional, or contextual parent/child relationship\nbetween DOM elements where the DOM hierarchy cannot be used to represent the relationship.\n@see aria-controls.",
- required: false,
- control: "text",
- type: "string",
- },
- "aria-placeholder": {
- description:
- "Defines a short hint (a word or short phrase) intended to aid the user with data entry when the control has no value.\nA hint could be a sample value or a brief description of the expected format.",
- required: false,
- control: "text",
- type: "string",
- },
- "aria-posinset": {
- description:
- "Defines an element's number or position in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.\n@see aria-setsize.",
- required: false,
- control: "number",
- type: "number",
- },
- "aria-pressed": {
- description:
- 'Indicates the current "pressed" state of toggle buttons.\n@see aria-checked\n@see aria-selected.',
- required: false,
- control: "text",
- type: "string",
- },
- "aria-readonly": {
- description:
- "Indicates that the element is not editable, but is otherwise operable.\n@see aria-disabled.",
- required: false,
- control: "boolean",
- type: "boolean",
- },
- "aria-relevant": {
- description:
- "Indicates what notifications the user agent will trigger when the accessibility tree within a live region is modified.\n@see aria-atomic.",
- required: false,
- control: "select",
- type: "string",
- options: [
- "text",
- "additions",
- "additions removals",
- "additions text",
- "all",
- "removals",
- "removals additions",
- "removals text",
- "text additions",
- "text removals",
- ],
- },
- "aria-required": {
- description:
- "Indicates that user input is required on the element before a form may be submitted.",
- required: false,
- control: "boolean",
- type: "boolean",
- },
- "aria-roledescription": {
- description:
- "Defines a human-readable, author-localized description for the role of an element.",
- required: false,
- control: "text",
- type: "string",
- },
- "aria-rowcount": {
- description:
- "Defines the total number of rows in a table, grid, or treegrid.\n@see aria-rowindex.",
- required: false,
- control: "number",
- type: "number",
- },
- "aria-rowindex": {
- description:
- "Defines an element's row index or position with respect to the total number of rows within a table, grid, or treegrid.\n@see aria-rowcount\n@see aria-rowspan.",
- required: false,
- control: "number",
- type: "number",
- },
- "aria-rowspan": {
- description:
- "Defines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid.\n@see aria-rowindex\n@see aria-colspan.",
- required: false,
- control: "number",
- type: "number",
- },
- "aria-selected": {
- description:
- 'Indicates the current "selected" state of various widgets.\n@see aria-checked\n@see aria-pressed.',
- required: false,
- control: "boolean",
- type: "boolean",
- },
- "aria-setsize": {
- description:
- "Defines the number of items in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.\n@see aria-posinset.",
- required: false,
- control: "number",
- type: "number",
- },
- "aria-sort": {
- description:
- "Indicates if items in a table or grid are sorted in ascending or descending order.",
- required: false,
- control: "radio",
- type: "string",
- options: ["none", "ascending", "descending", "other"],
- },
- "aria-valuemax": {
- description: "Defines the maximum allowed value for a range widget.",
- required: false,
- control: "number",
- type: "number",
- },
- "aria-valuemin": {
- description: "Defines the minimum allowed value for a range widget.",
- required: false,
- control: "number",
- type: "number",
- },
- "aria-valuenow": {
- description:
- "Defines the current value for a range widget.\n@see aria-valuetext.",
- required: false,
- control: "number",
- type: "number",
- },
- "aria-valuetext": {
- description:
- "Defines the human readable text alternative of aria-valuenow for a range widget.",
- required: false,
- control: "text",
- type: "string",
- },
- quality: { required: false, control: "number", type: "number" },
- loader: { required: true, control: "text", type: "string" },
- optimize: {
- required: false,
- control: "boolean",
- type: "boolean",
- defaultValue: true,
- },
-};
diff --git a/packages/image/src/index.ts b/packages/image/src/index.ts
index af63c97824..52cfdbcc67 100644
--- a/packages/image/src/index.ts
+++ b/packages/image/src/index.ts
@@ -1,18 +1,3 @@
-import type { PropMeta } from "@webstudio-is/generate-arg-types";
export { Image } from "./image";
export type { ImageLoader } from "./image-optimize";
export * from "./image-loaders";
-import { props } from "./__generated__/image.props";
-
-// "loader" is our internal prop not intended to show up in the props panel
-const { loader, ...publicProps } = props;
-
-export const imageProps: Record<string, PropMeta> = {
- ...publicProps,
- src: {
- type: "string",
- control: "file",
- label: "Source",
- required: false,
- },
-};
diff --git a/packages/react-sdk/src/app/custom-components/__generated__/image.props.ts b/packages/react-sdk/src/app/custom-components/__generated__/image.props.ts
deleted file mode 100644
index 1c9a859383..0000000000
--- a/packages/react-sdk/src/app/custom-components/__generated__/image.props.ts
+++ /dev/null
@@ -1,487 +0,0 @@
-import type { PropMeta } from "@webstudio-is/generate-arg-types";
-
-export const props: Record<string, PropMeta> = {
- slot: { required: false, control: "text", type: "string" },
- style: { required: false, control: "text", type: "string" },
- title: { required: false, control: "text", type: "string" },
- alt: { required: false, control: "text", type: "string" },
- crossOrigin: {
- required: false,
- control: "radio",
- type: "string",
- options: ["", "anonymous", "use-credentials"],
- },
- decoding: {
- required: false,
- control: "radio",
- type: "string",
- options: ["async", "auto", "sync"],
- },
- height: { required: false, control: "number", type: "number" },
- loading: {
- required: false,
- control: "radio",
- type: "string",
- options: ["eager", "lazy"],
- },
- referrerPolicy: {
- required: false,
- control: "select",
- type: "string",
- options: [
- "",
- "no-referrer",
- "no-referrer-when-downgrade",
- "origin",
- "origin-when-cross-origin",
- "same-origin",
- "strict-origin",
- "strict-origin-when-cross-origin",
- "unsafe-url",
- ],
- },
- sizes: { required: false, control: "text", type: "string" },
- src: { required: false, control: "text", type: "string" },
- srcSet: { required: false, control: "text", type: "string" },
- useMap: { required: false, control: "text", type: "string" },
- width: { required: false, control: "number", type: "number" },
- defaultChecked: { required: false, control: "boolean", type: "boolean" },
- defaultValue: { required: false, control: "text", type: "string" },
- suppressContentEditableWarning: {
- required: false,
- control: "boolean",
- type: "boolean",
- },
- suppressHydrationWarning: {
- required: false,
- control: "boolean",
- type: "boolean",
- },
- accessKey: { required: false, control: "text", type: "string" },
- autoFocus: { required: false, control: "boolean", type: "boolean" },
- className: { required: false, control: "text", type: "string" },
- contentEditable: { required: false, control: "text", type: "string" },
- contextMenu: { required: false, control: "text", type: "string" },
- dir: { required: false, control: "text", type: "string" },
- draggable: { required: false, control: "boolean", type: "boolean" },
- hidden: { required: false, control: "boolean", type: "boolean" },
- id: { required: false, control: "text", type: "string" },
- lang: { required: false, control: "text", type: "string" },
- nonce: { required: false, control: "text", type: "string" },
- placeholder: { required: false, control: "text", type: "string" },
- spellCheck: { required: false, control: "boolean", type: "boolean" },
- tabIndex: { required: false, control: "number", type: "number" },
- translate: {
- required: false,
- control: "radio",
- type: "string",
- options: ["yes", "no"],
- },
- radioGroup: { required: false, control: "text", type: "string" },
- role: { required: false, control: "text", type: "string" },
- about: { required: false, control: "text", type: "string" },
- content: { required: false, control: "text", type: "string" },
- datatype: { required: false, control: "text", type: "string" },
- inlist: { required: false, control: "text", type: "string" },
- prefix: { required: false, control: "text", type: "string" },
- property: { required: false, control: "text", type: "string" },
- rel: { required: false, control: "text", type: "string" },
- resource: { required: false, control: "text", type: "string" },
- rev: { required: false, control: "text", type: "string" },
- typeof: { required: false, control: "text", type: "string" },
- vocab: { required: false, control: "text", type: "string" },
- autoCapitalize: { required: false, control: "text", type: "string" },
- autoCorrect: { required: false, control: "text", type: "string" },
- autoSave: { required: false, control: "text", type: "string" },
- color: { required: false, control: "color", type: "string" },
- itemProp: { required: false, control: "text", type: "string" },
- itemScope: { required: false, control: "boolean", type: "boolean" },
- itemType: { required: false, control: "text", type: "string" },
- itemID: { required: false, control: "text", type: "string" },
- itemRef: { required: false, control: "text", type: "string" },
- results: { required: false, control: "number", type: "number" },
- security: { required: false, control: "text", type: "string" },
- unselectable: {
- required: false,
- control: "radio",
- type: "string",
- options: ["on", "off"],
- },
- inputMode: {
- description:
- "Hints at the type of data that might be entered by the user while editing the element or its contents\n@see https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute",
- required: false,
- control: "select",
- type: "string",
- options: [
- "text",
- "none",
- "search",
- "tel",
- "url",
- "email",
- "numeric",
- "decimal",
- ],
- },
- is: {
- description:
- "Specify that a standard HTML element should behave like a defined custom built-in element\n@see https://html.spec.whatwg.org/multipage/custom-elements.html#attr-is",
- required: false,
- control: "text",
- type: "string",
- },
- "aria-activedescendant": {
- description:
- "Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or application.",
- required: false,
- control: "text",
- type: "string",
- },
- "aria-atomic": {
- description:
- "Indicates whether assistive technologies will present all, or only parts of, the changed region based on the change notifications defined by the aria-relevant attribute.",
- required: false,
- control: "boolean",
- type: "boolean",
- },
- "aria-autocomplete": {
- description:
- "Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be\npresented if they are made.",
- required: false,
- control: "select",
- type: "string",
- options: ["list", "none", "inline", "both"],
- },
- "aria-busy": {
- description:
- "Indicates an element is being modified and that assistive technologies MAY want to wait until the modifications are complete before exposing them to the user.",
- required: false,
- control: "boolean",
- type: "boolean",
- },
- "aria-checked": {
- description:
- 'Indicates the current "checked" state of checkboxes, radio buttons, and other widgets.\n@see aria-pressed\n@see aria-selected.',
- required: false,
- control: "text",
- type: "string",
- },
- "aria-colcount": {
- description:
- "Defines the total number of columns in a table, grid, or treegrid.\n@see aria-colindex.",
- required: false,
- control: "number",
- type: "number",
- },
- "aria-colindex": {
- description:
- "Defines an element's column index or position with respect to the total number of columns within a table, grid, or treegrid.\n@see aria-colcount\n@see aria-colspan.",
- required: false,
- control: "number",
- type: "number",
- },
- "aria-colspan": {
- description:
- "Defines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid.\n@see aria-colindex\n@see aria-rowspan.",
- required: false,
- control: "number",
- type: "number",
- },
- "aria-controls": {
- description:
- "Identifies the element (or elements) whose contents or presence are controlled by the current element.\n@see aria-owns.",
- required: false,
- control: "text",
- type: "string",
- },
- "aria-current": {
- description:
- "Indicates the element that represents the current item within a container or set of related elements.",
- required: false,
- control: "text",
- type: "string",
- },
- "aria-describedby": {
- description:
- "Identifies the element (or elements) that describes the object.\n@see aria-labelledby",
- required: false,
- control: "text",
- type: "string",
- },
- "aria-details": {
- description:
- "Identifies the element that provides a detailed, extended description for the object.\n@see aria-describedby.",
- required: false,
- control: "text",
- type: "string",
- },
- "aria-disabled": {
- description:
- "Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable.\n@see aria-hidden\n@see aria-readonly.",
- required: false,
- control: "boolean",
- type: "boolean",
- },
- "aria-dropeffect": {
- description:
- "Indicates what functions can be performed when a dragged object is released on the drop target.\n@deprecated in ARIA 1.1",
- required: false,
- control: "select",
- type: "string",
- options: ["link", "none", "copy", "execute", "move", "popup"],
- },
- "aria-errormessage": {
- description:
- "Identifies the element that provides an error message for the object.\n@see aria-invalid\n@see aria-describedby.",
- required: false,
- control: "text",
- type: "string",
- },
- "aria-expanded": {
- description:
- "Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed.",
- required: false,
- control: "boolean",
- type: "boolean",
- },
- "aria-flowto": {
- description:
- "Identifies the next element (or elements) in an alternate reading order of content which, at the user's discretion,\nallows assistive technology to override the general default of reading in document source order.",
- required: false,
- control: "text",
- type: "string",
- },
- "aria-grabbed": {
- description:
- 'Indicates an element\'s "grabbed" state in a drag-and-drop operation.\n@deprecated in ARIA 1.1',
- required: false,
- control: "boolean",
- type: "boolean",
- },
- "aria-haspopup": {
- description:
- "Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element.",
- required: false,
- control: "text",
- type: "string",
- },
- "aria-hidden": {
- description:
- "Indicates whether the element is exposed to an accessibility API.\n@see aria-disabled.",
- required: false,
- control: "boolean",
- type: "boolean",
- },
- "aria-invalid": {
- description:
- "Indicates the entered value does not conform to the format expected by the application.\n@see aria-errormessage.",
- required: false,
- control: "text",
- type: "string",
- },
- "aria-keyshortcuts": {
- description:
- "Indicates keyboard shortcuts that an author has implemented to activate or give focus to an element.",
- required: false,
- control: "text",
- type: "string",
- },
- "aria-label": {
- description:
- "Defines a string value that labels the current element.\n@see aria-labelledby.",
- required: false,
- control: "text",
- type: "string",
- },
- "aria-labelledby": {
- description:
- "Identifies the element (or elements) that labels the current element.\n@see aria-describedby.",
- required: false,
- control: "text",
- type: "string",
- },
- "aria-level": {
- description:
- "Defines the hierarchical level of an element within a structure.",
- required: false,
- control: "number",
- type: "number",
- },
- "aria-live": {
- description:
- "Indicates that an element will be updated, and describes the types of updates the user agents, assistive technologies, and user can expect from the live region.",
- required: false,
- control: "radio",
- type: "string",
- options: ["off", "assertive", "polite"],
- },
- "aria-modal": {
- description: "Indicates whether an element is modal when displayed.",
- required: false,
- control: "boolean",
- type: "boolean",
- },
- "aria-multiline": {
- description:
- "Indicates whether a text box accepts multiple lines of input or only a single line.",
- required: false,
- control: "boolean",
- type: "boolean",
- },
- "aria-multiselectable": {
- description:
- "Indicates that the user may select more than one item from the current selectable descendants.",
- required: false,
- control: "boolean",
- type: "boolean",
- },
- "aria-orientation": {
- description:
- "Indicates whether the element's orientation is horizontal, vertical, or unknown/ambiguous.",
- required: false,
- control: "radio",
- type: "string",
- options: ["horizontal", "vertical"],
- },
- "aria-owns": {
- description:
- "Identifies an element (or elements) in order to define a visual, functional, or contextual parent/child relationship\nbetween DOM elements where the DOM hierarchy cannot be used to represent the relationship.\n@see aria-controls.",
- required: false,
- control: "text",
- type: "string",
- },
- "aria-placeholder": {
- description:
- "Defines a short hint (a word or short phrase) intended to aid the user with data entry when the control has no value.\nA hint could be a sample value or a brief description of the expected format.",
- required: false,
- control: "text",
- type: "string",
- },
- "aria-posinset": {
- description:
- "Defines an element's number or position in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.\n@see aria-setsize.",
- required: false,
- control: "number",
- type: "number",
- },
- "aria-pressed": {
- description:
- 'Indicates the current "pressed" state of toggle buttons.\n@see aria-checked\n@see aria-selected.',
- required: false,
- control: "text",
- type: "string",
- },
- "aria-readonly": {
- description:
- "Indicates that the element is not editable, but is otherwise operable.\n@see aria-disabled.",
- required: false,
- control: "boolean",
- type: "boolean",
- },
- "aria-relevant": {
- description:
- "Indicates what notifications the user agent will trigger when the accessibility tree within a live region is modified.\n@see aria-atomic.",
- required: false,
- control: "select",
- type: "string",
- options: [
- "text",
- "additions",
- "additions removals",
- "additions text",
- "all",
- "removals",
- "removals additions",
- "removals text",
- "text additions",
- "text removals",
- ],
- },
- "aria-required": {
- description:
- "Indicates that user input is required on the element before a form may be submitted.",
- required: false,
- control: "boolean",
- type: "boolean",
- },
- "aria-roledescription": {
- description:
- "Defines a human-readable, author-localized description for the role of an element.",
- required: false,
- control: "text",
- type: "string",
- },
- "aria-rowcount": {
- description:
- "Defines the total number of rows in a table, grid, or treegrid.\n@see aria-rowindex.",
- required: false,
- control: "number",
- type: "number",
- },
- "aria-rowindex": {
- description:
- "Defines an element's row index or position with respect to the total number of rows within a table, grid, or treegrid.\n@see aria-rowcount\n@see aria-rowspan.",
- required: false,
- control: "number",
- type: "number",
- },
- "aria-rowspan": {
- description:
- "Defines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid.\n@see aria-rowindex\n@see aria-colspan.",
- required: false,
- control: "number",
- type: "number",
- },
- "aria-selected": {
- description:
- 'Indicates the current "selected" state of various widgets.\n@see aria-checked\n@see aria-pressed.',
- required: false,
- control: "boolean",
- type: "boolean",
- },
- "aria-setsize": {
- description:
- "Defines the number of items in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.\n@see aria-posinset.",
- required: false,
- control: "number",
- type: "number",
- },
- "aria-sort": {
- description:
- "Indicates if items in a table or grid are sorted in ascending or descending order.",
- required: false,
- control: "select",
- type: "string",
- options: ["none", "ascending", "descending", "other"],
- },
- "aria-valuemax": {
- description: "Defines the maximum allowed value for a range widget.",
- required: false,
- control: "number",
- type: "number",
- },
- "aria-valuemin": {
- description: "Defines the minimum allowed value for a range widget.",
- required: false,
- control: "number",
- type: "number",
- },
- "aria-valuenow": {
- description:
- "Defines the current value for a range widget.\n@see aria-valuetext.",
- required: false,
- control: "number",
- type: "number",
- },
- "aria-valuetext": {
- description:
- "Defines the human readable text alternative of aria-valuenow for a range widget.",
- required: false,
- control: "text",
- type: "string",
- },
- quality: { required: false, control: "number", type: "number" },
- loader: { required: true, control: "text", type: "string" },
- optimize: { required: false, control: "boolean", type: "boolean" },
-};
diff --git a/packages/react-sdk/src/app/custom-components/image.tsx b/packages/react-sdk/src/app/custom-components/image.tsx
deleted file mode 100644
index 127b2f29b1..0000000000
--- a/packages/react-sdk/src/app/custom-components/image.tsx
+++ /dev/null
@@ -1,55 +0,0 @@
-import {
- forwardRef,
- useMemo,
- type ComponentPropsWithoutRef,
- type ElementRef,
-} from "react";
-import {
- Image as WebstudioImage,
- createImageLoader,
-} from "@webstudio-is/image";
-import { Image as SdkImage } from "../../components/image";
-import { usePropAsset, getInstanceIdFromComponentProps } from "../../props";
-import { getParams } from "../params";
-
-const defaultTag = "img";
-
-type Props = ComponentPropsWithoutRef<typeof WebstudioImage>;
-
-export const Image = forwardRef<ElementRef<typeof defaultTag>, Props>(
- (props, ref) => {
- const asset = usePropAsset(getInstanceIdFromComponentProps(props), "src");
-
- const loader = useMemo(() => {
- const params = getParams();
- return createImageLoader({ imageBaseUrl: params.imageBaseUrl });
- }, []);
-
- const src = asset?.name ?? props.src;
-
- if (asset == null || loader == null) {
- return <SdkImage key={src} {...props} src={src} ref={ref} />;
- }
-
- return (
- <WebstudioImage
- /**
- * `key` is needed to recreate the image in case of asset change in builder,
- * this gives immediate feedback when an asset is changed.
- * Also, it visually fixes image distortion when another asset has a seriously different aspectRatio
- * (we change aspectRatio CSS prop on asset change)
- *
- * In non-builder mode, key on images are usually also a good idea,
- * prevents showing outdated images on route change.
- **/
- key={src}
- {...props}
- loader={loader}
- src={src}
- ref={ref}
- />
- );
- }
-);
-
-Image.displayName = "Image";
diff --git a/packages/react-sdk/src/app/custom-components/index.ts b/packages/react-sdk/src/app/custom-components/index.ts
index d2a9abd35e..aae0c771cb 100644
--- a/packages/react-sdk/src/app/custom-components/index.ts
+++ b/packages/react-sdk/src/app/custom-components/index.ts
@@ -1,6 +1,4 @@
-import { imageProps } from "@webstudio-is/image";
import type { WsComponentPropsMeta } from "../../components/component-meta";
-import { Image } from "./image";
import { Link } from "./link";
import { LinkBlock } from "./link-block";
import { RichTextLink } from "./rich-text-link";
@@ -8,7 +6,6 @@ import { Form } from "./form";
import { meta as formMeta, propsMeta as formPropsMeta } from "./form.ws";
export const customComponents = {
- Image,
Link,
RichTextLink,
LinkBlock,
@@ -16,10 +13,6 @@ export const customComponents = {
};
export const customComponentPropsMetas: Record<string, WsComponentPropsMeta> = {
- Image: {
- props: imageProps,
- initialProps: ["src", "width", "height", "alt", "loading"],
- },
Form: formPropsMeta,
};
diff --git a/packages/react-sdk/src/components/__generated__/image.props.ts b/packages/react-sdk/src/components/__generated__/image.props.ts
index ea648ac6f4..1c9a859383 100644
--- a/packages/react-sdk/src/components/__generated__/image.props.ts
+++ b/packages/react-sdk/src/components/__generated__/image.props.ts
@@ -4,7 +4,7 @@ export const props: Record<string, PropMeta> = {
slot: { required: false, control: "text", type: "string" },
style: { required: false, control: "text", type: "string" },
title: { required: false, control: "text", type: "string" },
- alt: { required: false, control: "text", type: "string", defaultValue: "" },
+ alt: { required: false, control: "text", type: "string" },
crossOrigin: {
required: false,
control: "radio",
@@ -41,7 +41,7 @@ export const props: Record<string, PropMeta> = {
],
},
sizes: { required: false, control: "text", type: "string" },
- src: { required: false, control: "text", type: "string", defaultValue: "" },
+ src: { required: false, control: "text", type: "string" },
srcSet: { required: false, control: "text", type: "string" },
useMap: { required: false, control: "text", type: "string" },
width: { required: false, control: "number", type: "number" },
@@ -481,4 +481,7 @@ export const props: Record<string, PropMeta> = {
control: "text",
type: "string",
},
+ quality: { required: false, control: "number", type: "number" },
+ loader: { required: true, control: "text", type: "string" },
+ optimize: { required: false, control: "boolean", type: "boolean" },
};
diff --git a/packages/react-sdk/src/components/image.tsx b/packages/react-sdk/src/components/image.tsx
index ffdc2e98a3..99efce1980 100644
--- a/packages/react-sdk/src/components/image.tsx
+++ b/packages/react-sdk/src/components/image.tsx
@@ -1,32 +1,18 @@
-import { forwardRef, type ElementRef, type ComponentProps } from "react";
+import {
+ type ComponentPropsWithoutRef,
+ type ElementRef,
+ forwardRef,
+ useMemo,
+} from "react";
+import {
+ Image as WebstudioImage,
+ createImageLoader,
+} from "@webstudio-is/image";
+import { usePropAsset, getInstanceIdFromComponentProps } from "../props";
+import { getParams } from "../app/params";
export const defaultTag = "img";
-// quality and optimize can be overwritten and used by asset transform
-// Or we need and additional way to pass them upper level
-type ImageProps = ComponentProps<typeof defaultTag>;
-
-export const Image = forwardRef<ElementRef<typeof defaultTag>, ImageProps>(
- (imageProps, ref) => {
- return (
- <img
- {...imageProps}
- src={imageProps.src || imagePlaceholderSvg}
- ref={ref}
- />
- );
- }
-);
-
-Image.defaultProps = {
- src: "",
- width: "",
- height: "",
- alt: "",
-};
-
-Image.displayName = "Image";
-
const imagePlaceholderSvg = `data:image/svg+xml;base64,${btoa(`<svg
width="140"
height="140"
@@ -50,3 +36,45 @@ const imagePlaceholderSvg = `data:image/svg+xml;base64,${btoa(`<svg
fill="#A2A2A2"
/>
</svg>`)}`;
+
+type Props = ComponentPropsWithoutRef<typeof WebstudioImage>;
+
+export const Image = forwardRef<ElementRef<typeof defaultTag>, Props>(
+ (props, ref) => {
+ const asset = usePropAsset(getInstanceIdFromComponentProps(props), "src");
+
+ const loader = useMemo(() => {
+ const params = getParams();
+ return createImageLoader({ imageBaseUrl: params.imageBaseUrl });
+ }, []);
+
+ const src = asset?.name ?? props.src;
+
+ if (asset == null || loader == null) {
+ return (
+ <img key={src} {...props} src={src || imagePlaceholderSvg} ref={ref} />
+ );
+ }
+
+ return (
+ <WebstudioImage
+ /**
+ * `key` is needed to recreate the image in case of asset change in builder,
+ * this gives immediate feedback when an asset is changed.
+ * Also, it visually fixes image distortion when another asset has a seriously different aspectRatio
+ * (we change aspectRatio CSS prop on asset change)
+ *
+ * In non-builder mode, key on images are usually also a good idea,
+ * prevents showing outdated images on route change.
+ **/
+ key={src}
+ {...props}
+ loader={loader}
+ src={src}
+ ref={ref}
+ />
+ );
+ }
+);
+
+Image.displayName = "Image";
diff --git a/packages/react-sdk/src/components/image.ws.tsx b/packages/react-sdk/src/components/image.ws.tsx
index 3e38b5a50a..7011cc2002 100644
--- a/packages/react-sdk/src/components/image.ws.tsx
+++ b/packages/react-sdk/src/components/image.ws.tsx
@@ -36,9 +36,12 @@ export const meta: WsComponentMeta = {
presetStyle,
};
+// "loader" is our internal prop not intended to show up in the props panel
+const { loader, ...publicProps } = props;
+
export const propsMeta: WsComponentPropsMeta = {
props: {
- ...props,
+ ...publicProps,
src: {
type: "string",
control: "file",
diff --git a/packages/sdk-size-test/package.json b/packages/sdk-size-test/package.json
index e8e85d9467..bd8172e612 100644
--- a/packages/sdk-size-test/package.json
+++ b/packages/sdk-size-test/package.json
@@ -15,7 +15,7 @@
},
{
"path": "functions/*.js",
- "limit": "242 kB",
+ "limit": "215 kB",
"gzip": false
}
],
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 2b5ab2f321..37a26652a4 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1018,9 +1018,6 @@ importers:
packages/image:
dependencies:
- '@webstudio-is/generate-arg-types':
- specifier: workspace:^
- version: link:../generate-arg-types
react:
specifier: 18.2.0
version: 18.2.0