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.

chore: fix types generator in time component (#4038)

Oleg Isonenbdab4f67df9b
diff --git a/packages/sdk-components-react/src/time.test.ts b/packages/sdk-components-react/src/time.test.ts
index 6575c985f8..87eeddaa5c 100644
--- a/packages/sdk-components-react/src/time.test.ts
+++ b/packages/sdk-components-react/src/time.test.ts
@@ -1,5 +1,7 @@
import { expect, test } from "@jest/globals";
-import { parseDate } from "./time";
+import { __testing__ } from "./time";
+
+const { parseDate } = __testing__;
test("13-digit Unix timestamp", () => {
expect(parseDate("1724938577059")).toEqual(
diff --git a/packages/sdk-components-react/src/time.tsx b/packages/sdk-components-react/src/time.tsx
index 8317f9d477..761ac784f5 100644
--- a/packages/sdk-components-react/src/time.tsx
+++ b/packages/sdk-components-react/src/time.tsx
@@ -1,4 +1,4 @@
-import * as React from "react";
+import { forwardRef, type ElementRef } from "react";
const languages = [
"af",
@@ -281,14 +281,6 @@ type Country = (typeof countries)[number];
type DateStyle = Intl.DateTimeFormatOptions["dateStyle"] | "none";
type TimeStyle = Intl.DateTimeFormatOptions["timeStyle"] | "none";
-export type TimeProps = {
- datetime?: string;
- language?: Language;
- country?: Country;
- dateStyle?: DateStyle;
- timeStyle?: TimeStyle;
-};
-
const INITIAL_DATE_STRING = "dateTime attribute is not set";
const INVALID_DATE_STRING = "";
@@ -327,7 +319,7 @@ const timeStyleOrUndefined = (
return undefined;
};
-export const parseDate = (datetimeString: string) => {
+const parseDate = (datetimeString: string) => {
if (datetimeString === "") {
return;
}
@@ -353,7 +345,15 @@ export const parseDate = (datetimeString: string) => {
}
};
-export const Time = React.forwardRef<React.ElementRef<"time">, TimeProps>(
+type TimeProps = {
+ datetime?: string;
+ language?: Language;
+ country?: Country;
+ dateStyle?: DateStyle;
+ timeStyle?: TimeStyle;
+};
+
+export const Time = forwardRef<ElementRef<"time">, TimeProps>(
(
{
language = DEFAULT_LANGUAGE,
@@ -395,3 +395,7 @@ export const Time = React.forwardRef<React.ElementRef<"time">, TimeProps>(
);
}
);
+
+export const __testing__ = {
+ parseDate,
+};