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.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
Exclude props (#2154)
Ivan Starkovf7f51f66cf5e
diff --git a/packages/generate-arg-types/src/arg-types.ts b/packages/generate-arg-types/src/arg-types.tsindex fba41e0897..977bda4f3a 100644--- a/packages/generate-arg-types/src/arg-types.ts+++ b/packages/generate-arg-types/src/arg-types.ts@@ -3,7 +3,10 @@ import { PropMeta } from "./types";export type FilterPredicate = (prop: PropItem) => boolean;-export const propsToArgTypes = (props: Record<string, PropItem>) => {+export const propsToArgTypes = (+ props: Record<string, PropItem>,+ exclude: string[]+) => {const entries = Object.entries(props);return (entries@@ -12,6 +15,8 @@ export const propsToArgTypes = (props: Record<string, PropItem>) => {})// Exclude webstudio builder props see react-sdk/src/tree/webstudio-component.tsx.filter(([propName]) => propName.startsWith("data-ws-") === false)+ // Exclude props that are in the exclude list+ .filter(([propName]) => exclude.includes(propName) === false).reduce((result, current) => {const [propName, prop] = current;diff --git a/packages/generate-arg-types/src/cli.ts b/packages/generate-arg-types/src/cli.tsindex 87aa6e7e80..40c9d6151d 100755--- a/packages/generate-arg-types/src/cli.ts+++ b/packages/generate-arg-types/src/cli.ts@@ -6,6 +6,7 @@ import * as path from "node:path";import { withCustomConfig } from "react-docgen-typescript";import fg from "fast-glob";import { propsToArgTypes } from "./arg-types";+import { parseArgs, type ParseArgsConfig } from "node:util";const GENERATED_FILES_DIR = "__generated__";@@ -14,7 +15,22 @@ const options = {shouldRemoveUndefinedFromOptional: true,};-const componentsGlobString = process.argv.slice(2).pop();+const CLI_ARGS_OPTIONS = {+ allowPositionals: true,+ options: {+ exclude: {+ type: "string",+ multiple: true,+ short: "e",+ },+ },+ strict: true,+} as const satisfies ParseArgsConfig;++const cliArgs = parseArgs({ args: process.argv.slice(2), ...CLI_ARGS_OPTIONS });++const componentsGlobString = cliArgs.positionals.join(" ");+const tsConfigPath = path.resolve(process.cwd(), "./tsconfig.json");if (typeof componentsGlobString === "undefined") {@@ -55,7 +71,10 @@ for (const filePath of componentFiles) {let fileContent = `import type { PropMeta } from "@webstudio-is/generate-arg-types";\n`;if (componentDocs.length === 1) {- const argTypes = propsToArgTypes(componentDocs[0].props);+ const argTypes = propsToArgTypes(+ componentDocs[0].props,+ cliArgs.values.exclude ?? []+ );fileContent = `${fileContent}export const props: Record<string, PropMeta> = ${JSON.stringify(@@ -65,7 +84,10 @@ for (const filePath of componentFiles) {for (const componentDoc of componentDocs) {const componentName = componentDoc.displayName;- const argTypes = propsToArgTypes(componentDoc.props);+ const argTypes = propsToArgTypes(+ componentDoc.props,+ cliArgs.values.exclude ?? []+ );fileContent = `${fileContent}export const props${componentName}: Record<string, PropMeta> = ${JSON.stringify(diff --git a/packages/sdk-components-react-radix/package.json b/packages/sdk-components-react-radix/package.jsonindex a90364b0bc..a6975837b5 100644--- a/packages/sdk-components-react-radix/package.json+++ b/packages/sdk-components-react-radix/package.json@@ -41,7 +41,7 @@"scripts": {"dev": "build-package --watch","build": "build-package",- "build:args": "generate-arg-types './src/*.tsx !./src/*.stories.tsx !./src/*.ws.tsx' && prettier --write \"**/*.props.ts\"",+ "build:args": "generate-arg-types './src/*.tsx !./src/*.stories.tsx !./src/*.ws.tsx' -e asChild -e modal -e defaultValue -e defaultOpen && prettier --write \"**/*.props.ts\"","dts": "tsc --project tsconfig.dts.json","typecheck": "tsc","checks": "pnpm typecheck",diff --git a/packages/sdk-components-react-radix/src/__generated__/dialog.props.ts b/packages/sdk-components-react-radix/src/__generated__/dialog.props.tsindex 2b80460954..6fcd70f666 100644--- a/packages/sdk-components-react-radix/src/__generated__/dialog.props.ts+++ b/packages/sdk-components-react-radix/src/__generated__/dialog.props.ts@@ -1,7 +1,6 @@import type { PropMeta } from "@webstudio-is/generate-arg-types";export const propsDialog: Record<string, PropMeta> = {- modal: { required: false, control: "boolean", type: "boolean" },open: { required: false, control: "boolean", type: "boolean" },};export const propsDialogTrigger: Record<string, PropMeta> = {};@@ -387,7 +386,6 @@ export const propsDialogOverlay: Record<string, PropMeta> = {control: "text",type: "string",},- asChild: { required: false, control: "boolean", type: "boolean" },autoCapitalize: { required: false, control: "text", type: "string" },autoCorrect: { required: false, control: "text", type: "string" },autoFocus: { required: false, control: "boolean", type: "boolean" },@@ -854,7 +852,6 @@ export const propsDialogContent: Record<string, PropMeta> = {control: "text",type: "string",},- asChild: { required: false, control: "boolean", type: "boolean" },autoCapitalize: { required: false, control: "text", type: "string" },autoCorrect: { required: false, control: "text", type: "string" },autoFocus: { required: false, control: "boolean", type: "boolean" },@@ -1321,7 +1318,6 @@ export const propsDialogClose: Record<string, PropMeta> = {control: "text",type: "string",},- asChild: { required: false, control: "boolean", type: "boolean" },autoCapitalize: { required: false, control: "text", type: "string" },autoCorrect: { required: false, control: "text", type: "string" },autoFocus: { required: false, control: "boolean", type: "boolean" },@@ -1802,7 +1798,6 @@ export const propsDialogTitle: Record<string, PropMeta> = {control: "text",type: "string",},- asChild: { required: false, control: "boolean", type: "boolean" },autoCapitalize: { required: false, control: "text", type: "string" },autoCorrect: { required: false, control: "text", type: "string" },autoFocus: { required: false, control: "boolean", type: "boolean" },@@ -2269,7 +2264,6 @@ export const propsDialogDescription: Record<string, PropMeta> = {control: "text",type: "string",},- asChild: { required: false, control: "boolean", type: "boolean" },autoCapitalize: { required: false, control: "text", type: "string" },autoCorrect: { required: false, control: "text", type: "string" },autoFocus: { required: false, control: "boolean", type: "boolean" },diff --git a/packages/sdk-components-react-radix/src/__generated__/navigation-menu.props.ts b/packages/sdk-components-react-radix/src/__generated__/navigation-menu.props.tsindex 7e017dcecf..d35307b015 100644--- a/packages/sdk-components-react-radix/src/__generated__/navigation-menu.props.ts+++ b/packages/sdk-components-react-radix/src/__generated__/navigation-menu.props.ts@@ -374,7 +374,6 @@ export const propsNavigationMenu: Record<string, PropMeta> = {control: "text",type: "string",},- asChild: { required: false, control: "boolean", type: "boolean" },autoCapitalize: { required: false, control: "text", type: "string" },autoCorrect: { required: false, control: "text", type: "string" },autoFocus: { required: false, control: "boolean", type: "boolean" },@@ -385,7 +384,6 @@ export const propsNavigationMenu: Record<string, PropMeta> = {contextMenu: { required: false, control: "text", type: "string" },datatype: { required: false, control: "text", type: "string" },defaultChecked: { required: false, control: "boolean", type: "boolean" },- defaultValue: { required: false, control: "text", type: "string" },delayDuration: {description:"The duration from when the pointer enters the trigger until the tooltip gets opened.\n@defaultValue 200",@@ -862,7 +860,6 @@ export const propsNavigationMenuList: Record<string, PropMeta> = {control: "text",type: "string",},- asChild: { required: false, control: "boolean", type: "boolean" },autoCapitalize: { required: false, control: "text", type: "string" },autoCorrect: { required: false, control: "text", type: "string" },autoFocus: { required: false, control: "boolean", type: "boolean" },@@ -1329,7 +1326,6 @@ export const propsNavigationMenuViewport: Record<string, PropMeta> = {control: "text",type: "string",},- asChild: { required: false, control: "boolean", type: "boolean" },autoCapitalize: { required: false, control: "text", type: "string" },autoCorrect: { required: false, control: "text", type: "string" },autoFocus: { required: false, control: "boolean", type: "boolean" },@@ -1796,7 +1792,6 @@ export const propsNavigationMenuContent: Record<string, PropMeta> = {control: "text",type: "string",},- asChild: { required: false, control: "boolean", type: "boolean" },autoCapitalize: { required: false, control: "text", type: "string" },autoCorrect: { required: false, control: "text", type: "string" },autoFocus: { required: false, control: "boolean", type: "boolean" },diff --git a/packages/sdk-components-react-radix/src/__generated__/popover.props.ts b/packages/sdk-components-react-radix/src/__generated__/popover.props.tsindex ec48fa2cbb..1d3679850c 100644--- a/packages/sdk-components-react-radix/src/__generated__/popover.props.ts+++ b/packages/sdk-components-react-radix/src/__generated__/popover.props.ts@@ -1,7 +1,6 @@import type { PropMeta } from "@webstudio-is/generate-arg-types";export const propsPopover: Record<string, PropMeta> = {- modal: { required: false, control: "boolean", type: "boolean" },open: { required: false, control: "boolean", type: "boolean" },};export const propsPopoverTrigger: Record<string, PropMeta> = {};@@ -396,7 +395,6 @@ export const propsPopoverContent: Record<string, PropMeta> = {type: "string",},arrowPadding: { required: false, control: "number", type: "number" },- asChild: { required: false, control: "boolean", type: "boolean" },autoCapitalize: { required: false, control: "text", type: "string" },autoCorrect: { required: false, control: "text", type: "string" },autoFocus: { required: false, control: "boolean", type: "boolean" },diff --git a/packages/sdk-components-react-radix/src/__generated__/sheet.props.ts b/packages/sdk-components-react-radix/src/__generated__/sheet.props.tsindex 476605a5f1..61fe1503c9 100644--- a/packages/sdk-components-react-radix/src/__generated__/sheet.props.ts+++ b/packages/sdk-components-react-radix/src/__generated__/sheet.props.ts@@ -1,7 +1,6 @@import type { PropMeta } from "@webstudio-is/generate-arg-types";export const propsSheet: Record<string, PropMeta> = {- modal: { required: false, control: "boolean", type: "boolean" },open: { required: false, control: "boolean", type: "boolean" },};export const propsSheetTrigger: Record<string, PropMeta> = {};@@ -387,7 +386,6 @@ export const propsSheetOverlay: Record<string, PropMeta> = {control: "text",type: "string",},- asChild: { required: false, control: "boolean", type: "boolean" },autoCapitalize: { required: false, control: "text", type: "string" },autoCorrect: { required: false, control: "text", type: "string" },autoFocus: { required: false, control: "boolean", type: "boolean" },@@ -859,7 +857,6 @@ export const propsSheetClose: Record<string, PropMeta> = {control: "text",type: "string",},- asChild: { required: false, control: "boolean", type: "boolean" },autoCapitalize: { required: false, control: "text", type: "string" },autoCorrect: { required: false, control: "text", type: "string" },autoFocus: { required: false, control: "boolean", type: "boolean" },@@ -1345,7 +1342,6 @@ export const propsSheetTitle: Record<string, PropMeta> = {control: "text",type: "string",},- asChild: { required: false, control: "boolean", type: "boolean" },autoCapitalize: { required: false, control: "text", type: "string" },autoCorrect: { required: false, control: "text", type: "string" },autoFocus: { required: false, control: "boolean", type: "boolean" },@@ -1817,7 +1813,6 @@ export const propsSheetDescription: Record<string, PropMeta> = {control: "text",type: "string",},- asChild: { required: false, control: "boolean", type: "boolean" },autoCapitalize: { required: false, control: "text", type: "string" },autoCorrect: { required: false, control: "text", type: "string" },autoFocus: { required: false, control: "boolean", type: "boolean" },@@ -2289,7 +2284,6 @@ export const propsSheetContent: Record<string, PropMeta> = {control: "text",type: "string",},- asChild: { required: false, control: "boolean", type: "boolean" },autoCapitalize: { required: false, control: "text", type: "string" },autoCorrect: { required: false, control: "text", type: "string" },autoFocus: { required: false, control: "boolean", type: "boolean" },diff --git a/packages/sdk-components-react-radix/src/__generated__/tabs.props.ts b/packages/sdk-components-react-radix/src/__generated__/tabs.props.tsindex 5a72bd5393..c05b4e664a 100644--- a/packages/sdk-components-react-radix/src/__generated__/tabs.props.ts+++ b/packages/sdk-components-react-radix/src/__generated__/tabs.props.ts@@ -876,7 +876,6 @@ export const propsTabsList: Record<string, PropMeta> = {control: "text",type: "string",},- asChild: { required: false, control: "boolean", type: "boolean" },autoCapitalize: { required: false, control: "text", type: "string" },autoCorrect: { required: false, control: "text", type: "string" },autoFocus: { required: false, control: "boolean", type: "boolean" },diff --git a/packages/sdk-components-react-radix/src/__generated__/tooltip.props.ts b/packages/sdk-components-react-radix/src/__generated__/tooltip.props.tsindex 6b6ea55332..dfd8a5cb5d 100644--- a/packages/sdk-components-react-radix/src/__generated__/tooltip.props.ts+++ b/packages/sdk-components-react-radix/src/__generated__/tooltip.props.ts@@ -407,7 +407,6 @@ export const propsTooltipContent: Record<string, PropMeta> = {type: "string",},arrowPadding: { required: false, control: "number", type: "number" },- asChild: { required: false, control: "boolean", type: "boolean" },autoCapitalize: { required: false, control: "text", type: "string" },autoCorrect: { required: false, control: "text", type: "string" },autoFocus: { required: false, control: "boolean", type: "boolean" },