Skip to content

Commit

Permalink
feat: add submit and cancel functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-master committed Jun 12, 2021
1 parent 6f4b862 commit bcd8304
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/hooks/usePicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { usePrevious } from './usePrevious';
import { solarEvents } from '../events/solar';
// Types
import type {
DateConfig,
DatePickerConfig,
DateConfigTypes,
PickerExtraDateInfo,
PickerDateModel,
Expand All @@ -47,11 +47,11 @@ export function usePicker(props: WheelPickerProps) {
/**
* Date picker columns config
*
* @return {Required<DateConfig>}
* @return {Required<DatePickerConfig>}
* @private
*/
const configs = useMemo<Required<DateConfig>>(() => {
const config = { ...props.config } as Required<DateConfig>;
const configs = useMemo<Required<DatePickerConfig>>(() => {
const config = { ...props.config } as Required<DatePickerConfig>;
if (config.month && !config.month.formatter) {
config.month.formatter = (value) => jalaliMonths[value.month!];
}
Expand Down
10 changes: 3 additions & 7 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ import type { WheelPickerSelectEvent } from './components/WheelPicker/index.type

const Picker: React.FC<PickerProps> = (props) => {
const [isOpen, setIsOpen] = React.useState<boolean>(false);
const [
selectedDate,
setSelectedDate,
] = React.useState<WheelPickerSelectEvent>();
const [selectedDate, setSelectedDate] =
React.useState<WheelPickerSelectEvent>();

React.useEffect(() => {
setIsOpen(props.isOpen);
Expand Down Expand Up @@ -57,7 +55,6 @@ const Picker: React.FC<PickerProps> = (props) => {
maxDate={props.maxDate}
endYear={props.endYear}
onChange={handleOnChange}
disabled={props.disabled}
startYear={props.startYear}
addDayName={props.addDayName}
initialValue={props.initialValue}
Expand Down Expand Up @@ -88,7 +85,6 @@ Picker.defaultProps = {
classNamePrefix: 'persian-datepicker',
submitText: 'تایید',
cancelText: 'انصراف',
disabled: false,
showCancelButton: true,
disableSheetDrag: true,
addDayName: false,
Expand All @@ -97,7 +93,7 @@ Picker.defaultProps = {
export { Picker, WheelPicker };
export * from './helpers/date';
export type {
DateConfig,
DatePickerConfig,
WheelPickerSelectEvent,
WheelPickerProps,
PickerColumnCaption,
Expand Down

0 comments on commit bcd8304

Please sign in to comment.