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.

feat: Added required, value, checked default checked to the initial props of checkbox and radio components (#3048)

Oleg Isonen92773cee40f3
diff --git a/packages/generate-arg-types/src/cli.ts b/packages/generate-arg-types/src/cli.ts
index dc07824186..7afaedbc91 100755
--- a/packages/generate-arg-types/src/cli.ts
+++ b/packages/generate-arg-types/src/cli.ts
@@ -1,5 +1,4 @@
#!/usr/bin/env tsx
-/* eslint-disable no-console */
import { mkdirSync, writeFileSync } from "node:fs";
import * as path from "node:path";
@@ -46,6 +45,7 @@ const componentFiles = fg.sync(globs);
console.info(`Resolved tscofig.json at ${tsConfigPath}\n`);
console.info(`Glob patterns used: \n${globs.join("\n")}\n`);
+console.info(`Excluding props: \n${cliArgs.values.exclude?.join("\n")}\n`);
console.info(`Found files to process: \n${componentFiles.join("\n")}\n`);
if (componentFiles.length === 0) {
diff --git a/packages/sdk-components-react/src/__generated__/checkbox.props.ts b/packages/sdk-components-react/src/__generated__/checkbox.props.ts
index ccb4eec528..b025b82079 100644
--- a/packages/sdk-components-react/src/__generated__/checkbox.props.ts
+++ b/packages/sdk-components-react/src/__generated__/checkbox.props.ts
@@ -738,6 +738,13 @@ export const props: Record<string, PropMeta> = {
type: "string",
options: ["on", "off"],
},
+ value: {
+ required: false,
+ control: "text",
+ type: "string",
+ description:
+ "Defines a default value which will be displayed in the element on pageload.",
+ },
vocab: { required: false, control: "text", type: "string" },
width: {
required: false,
diff --git a/packages/sdk-components-react/src/__generated__/radio-button.props.ts b/packages/sdk-components-react/src/__generated__/radio-button.props.ts
index ccb4eec528..b025b82079 100644
--- a/packages/sdk-components-react/src/__generated__/radio-button.props.ts
+++ b/packages/sdk-components-react/src/__generated__/radio-button.props.ts
@@ -738,6 +738,13 @@ export const props: Record<string, PropMeta> = {
type: "string",
options: ["on", "off"],
},
+ value: {
+ required: false,
+ control: "text",
+ type: "string",
+ description:
+ "Defines a default value which will be displayed in the element on pageload.",
+ },
vocab: { required: false, control: "text", type: "string" },
width: {
required: false,
diff --git a/packages/sdk-components-react/src/checkbox.tsx b/packages/sdk-components-react/src/checkbox.tsx
index b3ad8a9dd9..ef74195c1c 100644
--- a/packages/sdk-components-react/src/checkbox.tsx
+++ b/packages/sdk-components-react/src/checkbox.tsx
@@ -4,10 +4,10 @@ export const defaultTag = "input";
export const Checkbox = forwardRef<
ElementRef<typeof defaultTag>,
- Omit<ComponentProps<typeof defaultTag>, "type">
+ Omit<ComponentProps<typeof defaultTag>, "type" | "value"> & { value?: string }
// Make sure children are not passed down to an input, because this will result in error.
->(({ children: _children, ...props }, ref) => (
- <input {...props} type="checkbox" ref={ref} />
-));
+>(({ children: _children, ...props }, ref) => {
+ return <input {...props} type="checkbox" ref={ref} />;
+});
Checkbox.displayName = "Checkbox";
diff --git a/packages/sdk-components-react/src/checkbox.ws.ts b/packages/sdk-components-react/src/checkbox.ws.ts
index b3d6dfaf0a..d6bb3c7298 100644
--- a/packages/sdk-components-react/src/checkbox.ws.ts
+++ b/packages/sdk-components-react/src/checkbox.ws.ts
@@ -60,5 +60,13 @@ export const meta: WsComponentMeta = {
export const propsMeta: WsComponentPropsMeta = {
props,
- initialProps: ["id", "className", "name"],
+ initialProps: [
+ "id",
+ "className",
+ "name",
+ "value",
+ "required",
+ "checked",
+ "defaultChecked",
+ ],
};
diff --git a/packages/sdk-components-react/src/radio-button.tsx b/packages/sdk-components-react/src/radio-button.tsx
index a90f758ed6..d1a514895d 100644
--- a/packages/sdk-components-react/src/radio-button.tsx
+++ b/packages/sdk-components-react/src/radio-button.tsx
@@ -4,7 +4,7 @@ export const defaultTag = "input";
export const RadioButton = forwardRef<
ElementRef<typeof defaultTag>,
- Omit<ComponentProps<typeof defaultTag>, "type">
+ Omit<ComponentProps<typeof defaultTag>, "type" | "value"> & { value?: string }
// Make sure children are not passed down to an input, because this will result in error.
>(({ children: _children, ...props }, ref) => (
<input {...props} type="radio" ref={ref} />
diff --git a/packages/sdk-components-react/src/radio-button.ws.ts b/packages/sdk-components-react/src/radio-button.ws.ts
index 35e361f0e0..df5cfe91eb 100644
--- a/packages/sdk-components-react/src/radio-button.ws.ts
+++ b/packages/sdk-components-react/src/radio-button.ws.ts
@@ -61,5 +61,13 @@ export const meta: WsComponentMeta = {
export const propsMeta: WsComponentPropsMeta = {
props,
- initialProps: ["id", "className", "name"],
+ initialProps: [
+ "id",
+ "className",
+ "name",
+ "value",
+ "required",
+ "checked",
+ "defaultChecked",
+ ],
};