Skip to content

Commit 889199b

Browse files
committed
chore: add storybook controls
1 parent 67273f4 commit 889199b

File tree

2 files changed

+79
-12
lines changed

2 files changed

+79
-12
lines changed

packages/blade/src/components/DatePicker/DatePicker.stories.tsx

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,64 @@ import StoryPageWrapper from '~utils/storybook/StoryPageWrapper';
1212
import { Sandbox } from '~utils/storybook/Sandbox';
1313
import { Code, Text } from '~components/Typography';
1414

15+
const propsCategory = {
16+
BASE_PROPS: 'DatePicker Props',
17+
INPUT_PROPS: 'Input Props',
18+
};
19+
20+
const baseProp = {
21+
table: {
22+
category: propsCategory.BASE_PROPS,
23+
},
24+
} as const;
25+
const inputProp = {
26+
table: {
27+
category: propsCategory.INPUT_PROPS,
28+
},
29+
} as const;
1530
export default {
1631
title: 'Components/DatePicker',
1732
component: DatePickerComponent,
1833
tags: ['autodocs'],
34+
argTypes: {
35+
value: baseProp,
36+
isOpen: baseProp,
37+
onChange: baseProp,
38+
selectionType: baseProp,
39+
presets: baseProp,
40+
minDate: baseProp,
41+
maxDate: baseProp,
42+
excludeDate: baseProp,
43+
picker: baseProp,
44+
onOpenChange: baseProp,
45+
allowSingleDateInRange: baseProp,
46+
defaultIsOpen: baseProp,
47+
defaultPicker: baseProp,
48+
defaultValue: baseProp,
49+
firstDayOfWeek: baseProp,
50+
onMonthSelect: baseProp,
51+
onYearSelect: baseProp,
52+
onNext: baseProp,
53+
onNextDecade: baseProp,
54+
onNextMonth: baseProp,
55+
onNextYear: baseProp,
56+
onPickerChange: baseProp,
57+
onPrevious: baseProp,
58+
onPreviousDecade: baseProp,
59+
onPreviousMonth: baseProp,
60+
onPreviousYear: baseProp,
61+
locale: baseProp,
62+
accessibilityLabel: inputProp,
63+
errorText: inputProp,
64+
helpText: inputProp,
65+
isDisabled: inputProp,
66+
isRequired: inputProp,
67+
label: inputProp,
68+
labelPosition: inputProp,
69+
size: inputProp,
70+
successText: inputProp,
71+
validationState: inputProp,
72+
},
1973
parameters: {
2074
docs: {
2175
page: () => (

packages/blade/src/components/DatePicker/types.ts

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,10 @@ type Preset = {
2424
};
2525

2626
type DateSelectionType = 'single' | 'range';
27+
type MantineInternalProps = '__onDayMouseEnter' | '__onDayClick' | 'getDayProps' | 'onMouseLeave';
2728
type CalendarProps<SelectionType extends DateSelectionType> = Pick<
2829
MantineDatePickerProps<SelectionType extends 'single' ? 'default' : 'range'>,
29-
| '__onDayMouseEnter'
30-
| '__onDayClick'
31-
| 'getDayProps'
32-
| 'onMouseLeave'
33-
| 'value'
34-
| 'defaultValue'
35-
| 'onChange'
36-
| 'onMonthSelect'
37-
| 'onYearSelect'
30+
MantineInternalProps | 'value' | 'defaultValue' | 'onChange' | 'onMonthSelect' | 'onYearSelect'
3831
> & {
3932
/**
4033
* Sets the selection mode of the calendar
@@ -46,12 +39,26 @@ type CalendarProps<SelectionType extends DateSelectionType> = Pick<
4639
* @default 'date'
4740
*/
4841
picker?: PickerType;
42+
/**
43+
* Sets the default picker type
44+
*/
4945
defaultPicker?: PickerType;
46+
/**
47+
* Callback which fires when picker type changes
48+
*/
5049
onPickerChange?: (picker: PickerType) => void;
5150

52-
// Standard controlled/uncontrolled state props
51+
/**
52+
* Controlled isOpen state
53+
*/
5354
isOpen?: boolean;
55+
/**
56+
* Uncontrolled isOpen state
57+
*/
5458
defaultIsOpen?: boolean;
59+
/**
60+
* Callback which fires when isOpen state changes
61+
*/
5562
onOpenChange?: ({ isOpen }: { isOpen: boolean }) => void;
5663

5764
/**
@@ -85,6 +92,9 @@ type CalendarProps<SelectionType extends DateSelectionType> = Pick<
8592
* Sets the maximum date that can be selected.
8693
*/
8794
maxDate?: Date;
95+
/**
96+
* Disables dates that do not pass the function.
97+
*/
8898
excludeDate?: (date: Date) => boolean;
8999
/**
90100
* Determines whether single date can be selected as range, applicable only when type="range"
@@ -98,7 +108,7 @@ type CalendarProps<SelectionType extends DateSelectionType> = Pick<
98108
*/
99109
locale?: string;
100110

101-
// Basic selection props
111+
// Basic event props
102112
onNext?: (date: Date) => void;
103113
onNextMonth?: (date: Date) => void;
104114
onNextYear?: (date: Date) => void;
@@ -109,7 +119,10 @@ type CalendarProps<SelectionType extends DateSelectionType> = Pick<
109119
onPreviousDecade?: (date: Date) => void;
110120
};
111121

112-
type DatePickerProps<Type extends DateSelectionType> = CalendarProps<Type> &
122+
type DatePickerProps<Type extends DateSelectionType> = Omit<
123+
CalendarProps<Type>,
124+
MantineInternalProps
125+
> &
113126
Omit<DatePickerCommonInputProps, 'inputRef' | 'referenceProps' | 'labelPosition'> & {
114127
label?: Type extends 'single' ? string : { start: string; end?: string };
115128
labelPosition?: BaseInputProps['labelPosition'];

0 commit comments

Comments
 (0)