-
Notifications
You must be signed in to change notification settings - Fork 0
Kds 463 interval input with period duration picker #427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
mitri24
wants to merge
21
commits into
master
Choose a base branch
from
KDS-463-IntervalInput-with-Period-Duration-Picker
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
4c25b7f
KDS-463: KDS-509: KDS IntervalInput: base
mitri24 56f3946
KDS-463: KdsIntervalInput: optimated DesignComp.
mitri24 06574a4
KDS-463: changed folder to form fields
mitri24 a2c640f
KDS-463: KdsIntervalInput: popover added
mitri24 4c82f79
KDS-463: KdsIntervalInput: popover added
mitri24 90e85cd
KDS-463: KdsIntervalInput: fixed toggle button
mitri24 79d7393
KDS-463: KdsIntervalInput: fixed toggle button
mitri24 4f7f13c
KDS-463: KdsIntervalInput: PR Changes
mitri24 7dbd9d5
KDS-463: KdsIntervalInput: PR Changes
mitri24 8a7a157
KDS-463: KdsIntervalInput: PR Changes
mitri24 5d12034
KDS-463: Changes from PR
mitri24 a71484f
KDS-463: PR
mitri24 b497a5f
KDS-463: PR
mitri24 8edba6c
KDS-463: PR
mitri24 57a5564
KDS-463: cleanup DesignComparator
jschroeter a7e3e71
KDS-463: remove unused CSS
jschroeter a7dc1f0
simplify CSS
jschroeter d41662a
KDS-463: PR Changes
mitri24 57d85ce
KDS-463: PR Changes
mitri24 dae72af
KDS-463: PR Changes
mitri24 7d97289
KDS-463: PR Changes
mitri24 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@knime/kds-components": patch | ||
| --- | ||
|
|
||
| Add KdsIntervalInput component for ISO 8601 interval input |
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
252 changes: 252 additions & 0 deletions
252
packages/components/src/forms/inputs/IntervalInput/IntervalInputPopover.stories.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,252 @@ | ||
| import { ref, watchEffect } from "vue"; | ||
| import type { Meta, StoryObj } from "@storybook/vue3-vite"; | ||
| import { useArgs } from "storybook/preview-api"; | ||
| import { expect, userEvent, within } from "storybook/test"; | ||
|
|
||
| import { | ||
| buildAllCombinationsStory, | ||
| buildDesignComparatorStory, | ||
| } from "../../../test-utils/storybook"; | ||
|
|
||
| import IntervalInputPopover from "./IntervalInputPopoverContent.vue"; | ||
| import { kdsIntervalInputFormats } from "./enums"; | ||
| import { createDefaultPopoverModel } from "./intervalUtils"; | ||
| import type { | ||
| KdsIntervalInputUsedFormat, | ||
| KdsIntervalPopoverModel, | ||
| } from "./types"; | ||
|
|
||
| const createDatePopoverModel = (): KdsIntervalPopoverModel => { | ||
| const model = createDefaultPopoverModel(); | ||
|
|
||
| model.periodPart.years = 1; | ||
| model.periodPart.months = 2; | ||
| model.periodPart.days = 3; | ||
|
|
||
| return model; | ||
| }; | ||
|
|
||
| const createTimePopoverModel = (): KdsIntervalPopoverModel => { | ||
| const model = createDefaultPopoverModel(); | ||
|
|
||
| model.durationPart.hours = 1; | ||
| model.durationPart.minutes = 30; | ||
| model.durationPart.seconds = 45; | ||
|
|
||
| return model; | ||
| }; | ||
|
|
||
| const meta: Meta<typeof IntervalInputPopover> = { | ||
| title: "Form Fields/IntervalInput/IntervalInputPopover", | ||
| component: IntervalInputPopover, | ||
| tags: ["autodocs"], | ||
| parameters: { | ||
| docs: { | ||
| description: { | ||
| component: | ||
| "Popover content for interval input that lets users switch between date and time interval editing, choose direction, and edit interval parts directly.", | ||
| }, | ||
| }, | ||
| design: { | ||
| type: "figma", | ||
| url: "https://www.figma.com/design/AqT6Q5R4KyYqUb6n5uO2XE/%F0%9F%A7%A9-kds-Components?node-id=5109-26693", | ||
| }, | ||
| }, | ||
| argTypes: { | ||
| modelValue: { | ||
| control: "object", | ||
| description: | ||
| "Popover model that keeps date and time interval parts in parallel while editing.", | ||
| table: { category: "model" }, | ||
| }, | ||
| usedFormat: { | ||
| control: { type: "select" }, | ||
| options: ["date", "time"], | ||
| description: "Currently active editing mode inside the popover.", | ||
| table: { category: "model" }, | ||
| }, | ||
| format: { | ||
| control: { type: "select" }, | ||
| options: kdsIntervalInputFormats, | ||
| description: | ||
| "Available format modes. `date_or_time` enables switching inside the popover.", | ||
| table: { category: "props" }, | ||
| }, | ||
| allowDescending: { | ||
| control: "boolean", | ||
| description: "Shows the forward/backward direction switch when enabled.", | ||
| table: { category: "props" }, | ||
| }, | ||
| }, | ||
| args: { | ||
| modelValue: createDatePopoverModel(), | ||
| usedFormat: "date", | ||
| format: "date_or_time", | ||
| allowDescending: true, | ||
| }, | ||
| render: (args) => { | ||
| const [, updateArgs] = useArgs(); | ||
|
|
||
| return { | ||
| components: { IntervalInputPopover }, | ||
| setup() { | ||
| const modelValue = ref(args.modelValue); | ||
| const usedFormat = ref(args.usedFormat); | ||
|
|
||
| watchEffect(() => { | ||
| modelValue.value = args.modelValue; | ||
| }); | ||
|
|
||
| watchEffect(() => { | ||
| usedFormat.value = args.usedFormat; | ||
| }); | ||
|
|
||
| watchEffect(() => { | ||
| updateArgs({ | ||
| modelValue: modelValue.value, | ||
| usedFormat: usedFormat.value, | ||
| }); | ||
| }); | ||
|
|
||
| return { args, modelValue, usedFormat }; | ||
| }, | ||
| template: | ||
| '<IntervalInputPopover :format="args.format" :allow-descending="args.allowDescending" v-model="modelValue" v-model:used-format="usedFormat" />', | ||
| }; | ||
| }, | ||
| }; | ||
|
|
||
| export default meta; | ||
|
|
||
| type Story = StoryObj<typeof IntervalInputPopover>; | ||
|
|
||
| export const Default: Story = { | ||
| play: async ({ canvasElement }) => { | ||
| const canvas = within(canvasElement); | ||
| const user = userEvent.setup(); | ||
| const [modeGroup, directionGroup] = canvas.getAllByRole("radiogroup"); | ||
| const modeScope = within(modeGroup!); | ||
| const directionScope = within(directionGroup!); | ||
|
|
||
| const date = modeScope.getByRole("radio", { name: "Date" }); | ||
| const time = modeScope.getByRole("radio", { name: "Time" }); | ||
| const forward = directionScope.getByRole("radio", { name: "Forward" }); | ||
| const backward = directionScope.getByRole("radio", { name: "Backward" }); | ||
|
|
||
| await expect(date).toHaveAttribute("aria-checked", "true"); | ||
| await expect( | ||
| canvas.getByRole("spinbutton", { name: "Year" }), | ||
| ).toBeInTheDocument(); | ||
|
|
||
| await user.click(time); | ||
| await expect(time).toHaveAttribute("aria-checked", "true"); | ||
| await expect( | ||
| canvas.queryByRole("spinbutton", { name: "Year" }), | ||
| ).not.toBeInTheDocument(); | ||
| await expect( | ||
| canvas.getByRole("spinbutton", { name: "Hour" }), | ||
| ).toBeInTheDocument(); | ||
|
|
||
| await user.click(backward); | ||
| await expect(backward).toHaveAttribute("aria-checked", "true"); | ||
|
|
||
| backward.focus(); | ||
| await user.keyboard("{ArrowLeft}"); | ||
| await expect(forward).toHaveAttribute("aria-checked", "true"); | ||
| await expect(forward).toHaveFocus(); | ||
| }, | ||
| }; | ||
|
|
||
| export const WithTimeMode: Story = { | ||
| args: { | ||
| format: "date_or_time", | ||
| usedFormat: "time", | ||
| modelValue: createTimePopoverModel(), | ||
| }, | ||
| }; | ||
|
|
||
| export const DateOnly: Story = { | ||
| args: { | ||
| format: "date", | ||
| usedFormat: "date", | ||
| allowDescending: false, | ||
| modelValue: createDatePopoverModel(), | ||
| }, | ||
| }; | ||
|
|
||
| export const TimeOnly: Story = { | ||
| args: { | ||
| format: "time", | ||
| usedFormat: "time", | ||
| allowDescending: false, | ||
| modelValue: createTimePopoverModel(), | ||
| }, | ||
| }; | ||
|
|
||
| // TextOverflow story does not apply here. | ||
|
|
||
| export const DesignComparator: Story = buildDesignComparatorStory({ | ||
| component: IntervalInputPopover, | ||
| wrapperStyle: "width: 373px", | ||
| designsToCompare: { | ||
| IntervalInputPopover: { | ||
| props: { | ||
| modelValue: createDatePopoverModel(), | ||
| allowDescending: true, | ||
| format: "date_or_time", | ||
| usedFormat: "date", | ||
| }, | ||
| variants: { | ||
| "https://www.figma.com/design/AqT6Q5R4KyYqUb6n5uO2XE/%F0%9F%A7%A9-kds-Components?node-id=5109-26693": | ||
| { | ||
| usedFormat: "date", | ||
| parameters: { | ||
| figmaOffset: { | ||
| x: -22, | ||
| y: -20, | ||
| }, | ||
| }, | ||
| }, | ||
| "https://www.figma.com/design/AqT6Q5R4KyYqUb6n5uO2XE/%F0%9F%A7%A9-kds-Components?node-id=17594-4369": | ||
| { | ||
| usedFormat: "time", | ||
| parameters: { | ||
| figmaOffset: { | ||
| x: -22, | ||
| y: -20, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| export const AllCombinations: Story = buildAllCombinationsStory({ | ||
| component: IntervalInputPopover, | ||
| columns: 3, | ||
| combinationsProps: { | ||
| default: { | ||
| format: ["date_or_time"], | ||
| usedFormat: ["date"] as KdsIntervalInputUsedFormat[], | ||
| modelValue: [createDatePopoverModel(), createTimePopoverModel()], | ||
| allowDescending: [true], | ||
| }, | ||
| combinations: [ | ||
| { | ||
| format: ["date_or_time"], | ||
| usedFormat: ["date", "time"] as KdsIntervalInputUsedFormat[], | ||
| }, | ||
| { | ||
| format: ["date"], | ||
| usedFormat: ["date"] as KdsIntervalInputUsedFormat[], | ||
| allowDescending: [false, true], | ||
| }, | ||
| { | ||
| format: ["time"], | ||
| usedFormat: ["time"] as KdsIntervalInputUsedFormat[], | ||
| allowDescending: [false, true], | ||
| }, | ||
| ], | ||
| }, | ||
| }); | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.