From 2952d41ef3866cc790ad0aad52dde91390df2744 Mon Sep 17 00:00:00 2001 From: Leonardo Victor Date: Sat, 30 Mar 2024 02:34:03 -0300 Subject: [PATCH 1/5] fix date validation and input value assign --- code/ui/blocks/src/controls/Date.tsx | 8 +++++++- code/ui/blocks/src/controls/types.ts | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/code/ui/blocks/src/controls/Date.tsx b/code/ui/blocks/src/controls/Date.tsx index 53eedf56c50c..f044ddb4f077 100644 --- a/code/ui/blocks/src/controls/Date.tsx +++ b/code/ui/blocks/src/controls/Date.tsx @@ -22,6 +22,7 @@ export const parseTime = (value: string) => { }; export const formatDate = (value: Date | number) => { + if (!value) return ''; const date = new Date(value); const year = `000${date.getFullYear()}`.slice(-4); const month = `0${date.getMonth() + 1}`.slice(-2); @@ -30,6 +31,7 @@ export const formatDate = (value: Date | number) => { }; export const formatTime = (value: Date | number) => { + if (!value) return ''; const date = new Date(value); const hours = `0${date.getHours()}`.slice(-2); const minutes = `0${date.getMinutes()}`.slice(-2); @@ -83,7 +85,9 @@ export const DateControl: FC = ({ name, value, onChange, onFocus, onB }, [value]); const onDateChange = (e: ChangeEvent) => { - const parsed = parseDate(e.target.value); + const inputValue = e.target.value; + if (!inputValue) return onChange(); + const parsed = parseDate(inputValue); const result = new Date(value); result.setFullYear(parsed.getFullYear(), parsed.getMonth(), parsed.getDate()); const time = result.getTime(); @@ -92,6 +96,8 @@ export const DateControl: FC = ({ name, value, onChange, onFocus, onB }; const onTimeChange = (e: ChangeEvent) => { + const inputValue = e.target.value; + if (!inputValue) return onChange(); const parsed = parseTime(e.target.value); const result = new Date(value); result.setHours(parsed.getHours()); diff --git a/code/ui/blocks/src/controls/types.ts b/code/ui/blocks/src/controls/types.ts index 26460ff6184c..4da8dc198977 100644 --- a/code/ui/blocks/src/controls/types.ts +++ b/code/ui/blocks/src/controls/types.ts @@ -5,7 +5,7 @@ export interface ControlProps { value?: T; defaultValue?: T; argType?: ArgType; - onChange: (value: T) => T | void; + onChange: (value?: T) => T | void; onFocus?: (evt: any) => void; onBlur?: (evt: any) => void; } From 895010aeade7632e5b3a2c6b4bf5d88a7f14b88d Mon Sep 17 00:00:00 2001 From: Leonardo Victor Date: Sat, 30 Mar 2024 02:34:03 -0300 Subject: [PATCH 2/5] fix date validation and input value assign --- code/ui/blocks/src/controls/Date.tsx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/code/ui/blocks/src/controls/Date.tsx b/code/ui/blocks/src/controls/Date.tsx index f044ddb4f077..4331b7053dcf 100644 --- a/code/ui/blocks/src/controls/Date.tsx +++ b/code/ui/blocks/src/controls/Date.tsx @@ -76,18 +76,17 @@ export const DateControl: FC = ({ name, value, onChange, onFocus, onB useEffect(() => { if (valid !== false) { if (dateRef && dateRef.current) { - dateRef.current.value = formatDate(value); + dateRef.current.value = value ? formatDate(value) : ''; } if (timeRef && timeRef.current) { - timeRef.current.value = formatTime(value); + timeRef.current.value = value ? formatTime(value) : ''; } } }, [value]); const onDateChange = (e: ChangeEvent) => { - const inputValue = e.target.value; - if (!inputValue) return onChange(); - const parsed = parseDate(inputValue); + if (!e.target.value) return onChange(); + const parsed = parseDate(e.target.value); const result = new Date(value); result.setFullYear(parsed.getFullYear(), parsed.getMonth(), parsed.getDate()); const time = result.getTime(); @@ -96,8 +95,7 @@ export const DateControl: FC = ({ name, value, onChange, onFocus, onB }; const onTimeChange = (e: ChangeEvent) => { - const inputValue = e.target.value; - if (!inputValue) return onChange(); + if (!e.target.value) return onChange(); const parsed = parseTime(e.target.value); const result = new Date(value); result.setHours(parsed.getHours()); From f02d94e6b069ee4bc8705e63decb60d83ce910d6 Mon Sep 17 00:00:00 2001 From: Leonardo Victor Date: Sat, 30 Mar 2024 17:12:41 -0300 Subject: [PATCH 3/5] remove empty string check --- code/ui/blocks/src/controls/Date.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/code/ui/blocks/src/controls/Date.tsx b/code/ui/blocks/src/controls/Date.tsx index 4331b7053dcf..938fc8c8c33b 100644 --- a/code/ui/blocks/src/controls/Date.tsx +++ b/code/ui/blocks/src/controls/Date.tsx @@ -22,7 +22,6 @@ export const parseTime = (value: string) => { }; export const formatDate = (value: Date | number) => { - if (!value) return ''; const date = new Date(value); const year = `000${date.getFullYear()}`.slice(-4); const month = `0${date.getMonth() + 1}`.slice(-2); @@ -31,7 +30,6 @@ export const formatDate = (value: Date | number) => { }; export const formatTime = (value: Date | number) => { - if (!value) return ''; const date = new Date(value); const hours = `0${date.getHours()}`.slice(-2); const minutes = `0${date.getMinutes()}`.slice(-2); From 739cf3bfbd80c70d481e8e2a0564b92dafb2def5 Mon Sep 17 00:00:00 2001 From: Won-Joon Lee Date: Fri, 17 May 2024 13:39:54 +0900 Subject: [PATCH 4/5] fix wrong CompatibleString type implementation --- code/lib/types/src/modules/core-common.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/lib/types/src/modules/core-common.ts b/code/lib/types/src/modules/core-common.ts index f16ef638cbf4..7addf01fcb5e 100644 --- a/code/lib/types/src/modules/core-common.ts +++ b/code/lib/types/src/modules/core-common.ts @@ -582,4 +582,4 @@ export interface CoreCommon_StorybookInfo { * const framework: Framework = '@storybook/nextjs'; // valid and will be autocompleted * const framework: Framework = path.dirname(require.resolve(path.join("@storybook/nextjs", "package.json"))) // valid */ -export type CompatibleString = T | (string & Record); +export type CompatibleString = T | (string & {}); From 9986a7812783176fa4a9f6dca9d0c5261b485042 Mon Sep 17 00:00:00 2001 From: storybook-bot <32066757+storybook-bot@users.noreply.github.com> Date: Tue, 21 May 2024 15:23:46 +0000 Subject: [PATCH 5/5] Update CHANGELOG.md for v8.1.2 [skip ci] --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fdbefeb9821..3856fc8a65de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 8.1.2 + +- Angular: Fix filtering of workspace config styles - [#27108](https://github.com/storybookjs/storybook/pull/27108), thanks @valentinpalkovic! +- Next.js: Avoid interfering with the svgr loader - [#27198](https://github.com/storybookjs/storybook/pull/27198), thanks @seanparmelee! + ## 8.1.1 - Docgen: Only add react-docgen info when a component is defined in the file - [#26967](https://github.com/storybookjs/storybook/pull/26967), thanks @glenjamin!