Skip to content
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

Add typescript types to fluid date picker and its skeleton state and fluid datepicker input #17385

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,22 @@ import { usePrefix } from '../../internal/usePrefix';
import { FormContext } from '../FluidForm/FormContext';
import { Calendar } from '@carbon/icons-react';

function FluidDatePickerSkeleton({
export interface FluidDatePickerSkeletonProps {
/**
* Specify an optional className to be applied to the outer FluidForm wrapper
*/
className?: string;
/**
* Specify which variant of the DatePicker the skeleton should mimic
*/
datePickerType?: 'simple' | 'single' | 'range';
}

const FluidDatePickerSkeleton: React.FC<FluidDatePickerSkeletonProps> = ({
className,
datePickerType = 'single',
...other
}) {
}) => {
const prefix = usePrefix();

const classNames = classnames(
Expand Down Expand Up @@ -54,7 +65,7 @@ function FluidDatePickerSkeleton({
</div>
</FormContext.Provider>
);
}
};

FluidDatePickerSkeleton.propTypes = {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,47 @@
*/

import PropTypes from 'prop-types';
import React from 'react';
import classnames from 'classnames';
import DatePicker from '../DatePicker';
import { usePrefix } from '../../internal/usePrefix';
import { FormContext } from '../FluidForm/FormContext';
import React from 'react';

export interface FluidDatePickerProps {
/**
* The child node(s)
*/
children?: React.ReactNode;
/**
* Specify an optional className to be applied to the outer FluidForm wrapper
*/
className?: string;
/**
* Specify whether or not the control is invalid
*/
invalid?: boolean;
/**
* Provide the text that is displayed when the control is in error state
*/
invalidText?: React.ReactNode;
/**
* Whether the input should be read-only
*/
readOnly?: boolean;
/**
* Specify whether the control is currently in warning state
*/
warn?: boolean;
/**
* Provide the text that is displayed when the control is in warning state
*/
warnText?: React.ReactNode;
}

const FluidDatePicker = React.forwardRef(function FluidDatePicker(
const FluidDatePicker: React.FC<FluidDatePickerProps> = React.forwardRef<
HTMLInputElement,
FluidDatePickerProps
>(function FluidDatePicker(
{
className,
children,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
*/

import FluidDatePicker from './FluidDatePicker';

import type { FluidDatePickerProps } from './FluidDatePicker';
import { FluidDatePickerSkeletonProps } from './FluidDatePicker.Skeleton';
export type { FluidDatePickerProps, FluidDatePickerSkeletonProps };
export { default as FluidDatePickerSkeleton } from './FluidDatePicker.Skeleton';
export default FluidDatePicker;
export { FluidDatePicker };
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
*/

import React from 'react';
import DatePickerInput from '../DatePickerInput';
import DatePickerInput, { DatePickerInputProps } from '../DatePickerInput';
import { FormContext } from '../FluidForm/FormContext';

const FluidDatePickerInput = React.forwardRef(function FluidDatePickerInput(
{ ...other },
ref
{ ...other }: DatePickerInputProps,
ref: React.Ref<HTMLDivElement>
) {
return (
<FormContext.Provider value={{ isFluid: true }}>
Expand Down
Loading