✨(react) make DatePicker elements accessible
Declare and export reusable element from the DatePicker sub-packages, to make them easily usable accros the design system or any application.
This commit is contained in:
committed by
aleb_the_flash
parent
52bd807b27
commit
f8326c5de6
@@ -3,7 +3,7 @@ import { render, screen, within } from "@testing-library/react";
|
|||||||
import React, { FormEvent, useState } from "react";
|
import React, { FormEvent, useState } from "react";
|
||||||
import { expect, vi, afterEach } from "vitest";
|
import { expect, vi, afterEach } from "vitest";
|
||||||
import { CunninghamProvider } from ":/components/Provider";
|
import { CunninghamProvider } from ":/components/Provider";
|
||||||
import DatePicker from ":/components/Forms/DatePicker/DatePicker";
|
import { DatePicker } from ":/components/Forms/DatePicker/DatePicker";
|
||||||
import { Button } from ":/components/Button";
|
import { Button } from ":/components/Button";
|
||||||
|
|
||||||
describe("<DatePicker/>", () => {
|
describe("<DatePicker/>", () => {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export type DatePickerProps = DatePickerAuxSubProps & {
|
|||||||
onChange?: (value: string | null) => void | undefined;
|
onChange?: (value: string | null) => void | undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
const DatePicker = (props: DatePickerProps) => {
|
export const DatePicker = (props: DatePickerProps) => {
|
||||||
if (props.defaultValue && props.value) {
|
if (props.defaultValue && props.value) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"You cannot use both defaultValue and value props on DatePicker component"
|
"You cannot use both defaultValue and value props on DatePicker component"
|
||||||
@@ -82,5 +82,3 @@ const DatePicker = (props: DatePickerProps) => {
|
|||||||
</DatePickerAux>
|
</DatePickerAux>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default DatePicker;
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export type DateRangePickerProps = DatePickerAuxSubProps & {
|
|||||||
onChange?: (value: [string, string] | null) => void;
|
onChange?: (value: [string, string] | null) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
const DateRangePicker = ({
|
export const DateRangePicker = ({
|
||||||
startLabel,
|
startLabel,
|
||||||
endLabel,
|
endLabel,
|
||||||
...props
|
...props
|
||||||
@@ -103,5 +103,3 @@ const DateRangePicker = ({
|
|||||||
</DatePickerAux>
|
</DatePickerAux>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default DateRangePicker;
|
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import { Meta, StoryFn } from "@storybook/react";
|
|||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { CunninghamProvider } from ":/components/Provider";
|
import { CunninghamProvider } from ":/components/Provider";
|
||||||
import { Button } from ":/components/Button";
|
import { Button } from ":/components/Button";
|
||||||
import DateRangePicker from ":/components/Forms/DatePicker/DateRangePicker";
|
import { DateRangePicker } from ":/components/Forms/DatePicker/DateRangePicker";
|
||||||
import DatePicker from ":/components/Forms/DatePicker/DatePicker";
|
import { DatePicker } from ":/components/Forms/DatePicker/DatePicker";
|
||||||
import {
|
import {
|
||||||
StringOrDate,
|
StringOrDate,
|
||||||
StringsOrDateRange,
|
StringsOrDateRange,
|
||||||
|
|||||||
@@ -1 +1,5 @@
|
|||||||
// todo : what do we export ?
|
export * from "./DatePicker";
|
||||||
|
export * from "./DateRangePicker";
|
||||||
|
|
||||||
|
export * from "./types";
|
||||||
|
export * from "./utils";
|
||||||
|
|||||||
Reference in New Issue
Block a user