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.

fix: set correct date time property in Time component (#5202)

Bogdan Chadkin079582343114
diff --git a/packages/sdk-components-react/src/__generated__/time.props.ts b/packages/sdk-components-react/src/__generated__/time.props.ts
index 54f507eff1..852f06d4a7 100644
--- a/packages/sdk-components-react/src/__generated__/time.props.ts
+++ b/packages/sdk-components-react/src/__generated__/time.props.ts
@@ -215,13 +215,6 @@ export const props: Record<string, PropMeta> = {
defaultValue: "medium",
options: ["full", "long", "medium", "short", "none"],
},
- datetime: {
- required: false,
- control: "text",
- type: "string",
- defaultValue: "dateTime attribute is not set",
- description: "Machine-readable value",
- },
language: {
required: false,
control: "select",
diff --git a/packages/sdk-components-react/src/time.tsx b/packages/sdk-components-react/src/time.tsx
index 761ac784f5..44df0070c8 100644
--- a/packages/sdk-components-react/src/time.tsx
+++ b/packages/sdk-components-react/src/time.tsx
@@ -1,4 +1,4 @@
-import { forwardRef, type ElementRef } from "react";
+import { forwardRef, type ComponentProps, type ElementRef } from "react";
const languages = [
"af",
@@ -345,8 +345,7 @@ const parseDate = (datetimeString: string) => {
}
};
-type TimeProps = {
- datetime?: string;
+type TimeProps = Pick<ComponentProps<"time">, "dateTime"> & {
language?: Language;
country?: Country;
dateStyle?: DateStyle;
@@ -360,7 +359,8 @@ export const Time = forwardRef<ElementRef<"time">, TimeProps>(
country = DEFAULT_COUNTRY,
dateStyle = DEFAULT_DATE_STYLE,
timeStyle = DEFAULT_TIME_STYLE,
- datetime = INITIAL_DATE_STRING,
+ // native html attribute in react style
+ dateTime = INITIAL_DATE_STRING,
...props
},
ref
@@ -375,7 +375,7 @@ export const Time = forwardRef<ElementRef<"time">, TimeProps>(
};
const datetimeString =
- datetime === null ? INVALID_DATE_STRING : datetime.toString();
+ dateTime === null ? INVALID_DATE_STRING : dateTime.toString();
const date = parseDate(datetimeString);
let formattedDate = datetimeString;