KDS-774: KdsDateInput: support Date object as v-model input/output#342
Draft
jschroeter wants to merge 1 commit intomasterfrom
Draft
KDS-774: KdsDateInput: support Date object as v-model input/output#342jschroeter wants to merge 1 commit intomasterfrom
jschroeter wants to merge 1 commit intomasterfrom
Conversation
KDS-774 (Style date/time inputs with minimal effort)
🦋 Changeset detectedLatest commit: eec45d4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates KdsDateInput to support using a Date object for its v-model (in addition to strings), and adjusts the Storybook controls plus adds a changeset entry.
Changes:
- Change
KdsDateInputv-model type toDate | string | nulland introduce an internalinputTextstring to support intermediate typing. - Update Storybook controls for
modelValue,datePickerMin, anddatePickerMaxto use thedatecontrol type. - Add a changeset describing the new v-model support.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| packages/components/src/forms/inputs/DateInput/KdsDateInput.vue | Switches v-model typing and introduces inputText + watcher; adjusts date picker and blur normalization behavior. |
| packages/components/src/forms/inputs/DateInput/KdsDateInput.stories.ts | Changes Storybook control types for date-related args. |
| .changeset/tangy-bugs-refuse.md | Declares a release note for the Date v-model support. |
Comments suppressed due to low confidence (1)
packages/components/src/forms/inputs/DateInput/KdsDateInput.stories.ts:105
args.modelValueis still initialized to an empty string, butargTypes.modelValuewas switched to adatecontrol. This mismatch makes the story controls inconsistent (andWithValue/ combinations below still pass strings). Consider either (1) keeping modelValue as a string control, or (2) switching the default and example story args toDate | nullso the stories reflect the new API clearly.
modelValue: {
control: "date",
description: "v-model binding for the date",
table: { category: "model" },
},
label: {
control: "text",
description: "Label shown above the input",
table: { category: "props" },
},
ariaLabel: {
control: "text",
description: "Accessible label used when no visible label is rendered",
table: { category: "props" },
},
description: {
control: "text",
description:
"Optional description displayed in an info popover next to the label. " +
"The info toggle button is only visible when hovering the input field.",
table: { category: "props" },
},
placeholder: {
control: "text",
description: "Placeholder shown when the input is empty",
table: { category: "props" },
},
datePickerMin: {
control: "date",
description: "Minimum selectable date passed to the date picker",
table: { category: "props" },
},
datePickerMax: {
control: "date",
description: "Maximum selectable date passed to the date picker",
table: { category: "props" },
},
disabled: {
control: "boolean",
table: { category: "props" },
},
error: {
control: "boolean",
table: { category: "props" },
},
validating: {
control: "boolean",
description: "Shows a spinner next to the subtext when true",
table: { category: "props" },
},
subText: {
control: "text",
description: "Helper text or error message shown below the input",
table: { category: "props" },
},
preserveSubTextSpace: {
control: "boolean",
table: { category: "props" },
},
},
args: {
modelValue: "",
label: "Label",
ariaLabel: undefined,
description: "",
placeholder: "",
datePickerMin: undefined,
datePickerMax: undefined,
disabled: false,
Comment on lines
111
to
115
| <BaseInput | ||
| ref="baseInput" | ||
| v-bind="slotProps" | ||
| v-model="modelValue" | ||
| v-model="inputText" | ||
| type="text" |
|
|
||
| const onDatePickerInput = (date: Date | string | null) => { | ||
| modelValue.value = formatDateToString(date); | ||
| const dateObj = date instanceof Date ? date : null; |
Comment on lines
63
to
70
| const datePickerValue = computed(() => { | ||
| if (typeof modelValue.value !== "string") { | ||
| return null; | ||
| const value = modelValue.value; | ||
| if (value instanceof Date) { | ||
| return value; | ||
| } | ||
| if (typeof value === "string") { | ||
| return parseDateString(value); | ||
| } |
Comment on lines
37
to
71
| @@ -62,12 +62,12 @@ const meta: Meta<typeof KdsDateInput> = { | |||
| table: { category: "props" }, | |||
| }, | |||
| datePickerMin: { | |||
| control: "text", | |||
| control: "date", | |||
| description: "Minimum selectable date passed to the date picker", | |||
| table: { category: "props" }, | |||
| }, | |||
| datePickerMax: { | |||
| control: "text", | |||
| control: "date", | |||
| description: "Maximum selectable date passed to the date picker", | |||
| @@ -0,0 +1,5 @@ | |||
| --- | |||
| "@knime/kds-components": patch | |||
Comment on lines
+33
to
+40
| const modelValue = defineModel<Date | string | null>({ default: null }); | ||
|
|
||
| // Internal string representation for the text input to allow intermediate typing states | ||
| const inputText = ref( | ||
| modelValue.value instanceof Date | ||
| ? formatDateToString(modelValue.value) | ||
| : (modelValue.value ?? ""), | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
KDS-774 (Style date/time inputs with minimal effort)