Skip to content

KDS-774: KdsDateInput: support Date object as v-model input/output#342

Draft
jschroeter wants to merge 1 commit intomasterfrom
KDS-774-support-date-type
Draft

KDS-774: KdsDateInput: support Date object as v-model input/output#342
jschroeter wants to merge 1 commit intomasterfrom
KDS-774-support-date-type

Conversation

@jschroeter
Copy link
Member

KDS-774 (Style date/time inputs with minimal effort)

Copilot AI review requested due to automatic review settings March 18, 2026 16:54
@changeset-bot
Copy link

changeset-bot bot commented Mar 18, 2026

🦋 Changeset detected

Latest commit: eec45d4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@knime/kds-components Patch
@knime/kds-styles Patch
@knime/kds-documentation Patch

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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 KdsDateInput v-model type to Date | string | null and introduce an internal inputText string to support intermediate typing.
  • Update Storybook controls for modelValue, datePickerMin, and datePickerMax to use the date control 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.modelValue is still initialized to an empty string, but argTypes.modelValue was switched to a date control. This mismatch makes the story controls inconsistent (and WithValue / combinations below still pass strings). Consider either (1) keeping modelValue as a string control, or (2) switching the default and example story args to Date | null so 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 ?? ""),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants