diff --git a/packages/react/src/components/Forms/DatePicker/index.mdx b/packages/react/src/components/Forms/DatePicker/index.mdx index c61831a..f6b4087 100644 --- a/packages/react/src/components/Forms/DatePicker/index.mdx +++ b/packages/react/src/components/Forms/DatePicker/index.mdx @@ -1,6 +1,7 @@ import { Canvas, Meta, Story, Source, ArgsTable } from '@storybook/addon-docs'; import { DatePicker } from "./index"; +import { DateRangePicker } from "./index"; @@ -16,6 +17,15 @@ UI components provided by [React-Spectrum](https://react-spectrum.adobe.com/reac ## Basic + + `} +/> + @@ -27,6 +37,38 @@ You can use the following props to change the default value of the DatePicker co +## Range + + + `} +/> + +When using it within a form, you'll access its values using separate inputs for the start and end values. The start input's +name will be the `DateRangePicker`'s name suffixed by `_start` and the end input's name will be the `DateRangePicker`'s name suffixed by `_end`. +Ex: If a `DateRangePicker` is named `"subscription"`, you would access its values as follow: + + + + + + + ## States @@ -61,6 +103,7 @@ using the component in a controlled way. + ## MinValue / MaxValue @@ -83,8 +126,14 @@ When passing an invalid date, for example outside of the valid range, the DatePi You can see the list of props below. +### DatePicker + +### DateRangePicker + + + ## Design tokens diff --git a/packages/react/src/components/Forms/DatePicker/index.stories.tsx b/packages/react/src/components/Forms/DatePicker/index.stories.tsx index 498d6ec..b75cee0 100644 --- a/packages/react/src/components/Forms/DatePicker/index.stories.tsx +++ b/packages/react/src/components/Forms/DatePicker/index.stories.tsx @@ -2,8 +2,12 @@ import { Meta, StoryFn } from "@storybook/react"; import React, { useState } from "react"; import { CunninghamProvider } from ":/components/Provider"; import { Button } from ":/components/Button"; +import DateRangePicker from ":/components/Forms/DatePicker/DateRangePicker"; import DatePicker from ":/components/Forms/DatePicker/DatePicker"; -import { StringOrDate } from ":/components/Forms/DatePicker/types"; +import { + StringOrDate, + StringsOrDateRange, +} from ":/components/Forms/DatePicker/types"; export default { title: "Components/Forms/DatePicker", @@ -103,3 +107,48 @@ export const Controlled = () => { ); }; + +export const RangeDefault = () => { + return ( +
+ + + +
+ ); +}; + +export const RangeDefaultValue = () => { + return ( + + + + ); +}; + +export const RangeControlled = () => { + const [value, setValue] = useState([ + "2023-05-23", + "2023-06-23", + ]); + return ( +
+ +
Value: {value?.join(" ")}
+ setValue(e)} + /> + +
+
+ ); +};