@basic-ui/dates 0.0.45 → 0.0.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,3 @@
1
- # Base Components
2
-
3
- All the components in this module should be FREE of any styling. They should only implement the core functionality of patterns. Styling should be responsibility of other components using this.
1
+ # Base Components
2
+
3
+ All the components in this module should be FREE of any styling. They should only implement the core functionality of patterns. Styling should be responsibility of other components using this.
@@ -116,8 +116,8 @@ function useInnerFocus() {
116
116
  };
117
117
  }
118
118
 
119
- /**
120
- * Merges props from RangeDatePicker and DatePicker
119
+ /**
120
+ * Merges props from RangeDatePicker and DatePicker
121
121
  */
122
122
  function usePropsMerge(props) {
123
123
  const context = useRangeDatePickerContext();
@@ -1,24 +1,24 @@
1
- import type { ElementType, HTMLAttributes } from 'react';
2
- import type { DayNames, MonthNames } from './dateTypes';
3
- export declare type DatePickerProps = Omit<HTMLAttributes<HTMLDivElement>, 'value' | 'defaultValue' | 'onChange'> & {
4
- as?: ElementType<any>;
5
- minDate?: Date;
6
- maxDate?: Date;
7
- dayNames?: DayNames;
8
- monthNames?: MonthNames;
9
- onChange?: (from: Date | null) => void;
10
- value?: Date | null;
11
- defaultValue?: Date | null;
12
- type?: 'from' | 'to';
13
- };
14
- export declare const DatePicker: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLDivElement>, "value" | "defaultValue" | "onChange"> & {
15
- as?: ElementType<any> | undefined;
16
- minDate?: Date | undefined;
17
- maxDate?: Date | undefined;
18
- dayNames?: DayNames | undefined;
19
- monthNames?: MonthNames | undefined;
20
- onChange?: ((from: Date | null) => void) | undefined;
21
- value?: Date | null | undefined;
22
- defaultValue?: Date | null | undefined;
23
- type?: "from" | "to" | undefined;
24
- } & import("react").RefAttributes<HTMLDivElement>>;
1
+ import type { ElementType, HTMLAttributes } from 'react';
2
+ import type { DayNames, MonthNames } from './dateTypes';
3
+ export declare type DatePickerProps = Omit<HTMLAttributes<HTMLDivElement>, 'value' | 'defaultValue' | 'onChange'> & {
4
+ as?: ElementType<any>;
5
+ minDate?: Date;
6
+ maxDate?: Date;
7
+ dayNames?: DayNames;
8
+ monthNames?: MonthNames;
9
+ onChange?: (from: Date | null) => void;
10
+ value?: Date | null;
11
+ defaultValue?: Date | null;
12
+ type?: 'from' | 'to';
13
+ };
14
+ export declare const DatePicker: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLDivElement>, "value" | "defaultValue" | "onChange"> & {
15
+ as?: ElementType<any> | undefined;
16
+ minDate?: Date | undefined;
17
+ maxDate?: Date | undefined;
18
+ dayNames?: DayNames | undefined;
19
+ monthNames?: MonthNames | undefined;
20
+ onChange?: ((from: Date | null) => void) | undefined;
21
+ value?: Date | null | undefined;
22
+ defaultValue?: Date | null | undefined;
23
+ type?: "from" | "to" | undefined;
24
+ } & import("react").RefAttributes<HTMLDivElement>>;
@@ -8,8 +8,8 @@ import { reducer } from './hooks';
8
8
  import { useRangeDatePickerContext, DatePickerProvider } from './contexts';
9
9
  import { jsx as _jsx } from "react/jsx-runtime";
10
10
 
11
- /**
12
- * Merges props from RangeDatePicker and DatePicker
11
+ /**
12
+ * Merges props from RangeDatePicker and DatePicker
13
13
  */
14
14
  function usePropsMerge(props) {
15
15
  var context = useRangeDatePickerContext();
@@ -1 +1 @@
1
- {"version":3,"file":"DatePicker.js","names":["forwardRef","useMemo","useRef","useReducer","assignMultipleRefs","reducer","useRangeDatePickerContext","DatePickerProvider","usePropsMerge","props","context","type","Error","mergedProps","minDate","maxDate","dayNames","monthNames","value","from","onChange","onChangeFrom","to","onChangeTo","undefined","Date","valueOf","DatePicker","ref","as","Comp","propMinDate","propMaxDate","controlledValue","defaultValue","rest","datePickerRef","onChangeRef","current","controlledValueRef","initialData","isFocused","navigationDay","navigationMonth","navigationYear","selectedDate","state","dispatch","contextValue"],"sources":["../../../src/DatePicker/DatePicker.tsx"],"sourcesContent":["import type { ElementType, HTMLAttributes } from 'react';\r\nimport { forwardRef, useMemo, useRef, useReducer } from 'react';\r\nimport { assignMultipleRefs } from '@basic-ui/core';\r\n\r\nimport type { ReducerState } from './hooks';\r\nimport { reducer } from './hooks';\r\nimport type { DayNames, MonthNames } from './dateTypes';\r\nimport type { DatePickerContextProps } from './contexts';\r\nimport { useRangeDatePickerContext, DatePickerProvider } from './contexts';\r\n\r\nexport type DatePickerProps = Omit<\r\n HTMLAttributes<HTMLDivElement>,\r\n 'value' | 'defaultValue' | 'onChange'\r\n> & {\r\n as?: ElementType<any>;\r\n minDate?: Date;\r\n maxDate?: Date;\r\n dayNames?: DayNames;\r\n monthNames?: MonthNames;\r\n onChange?: (from: Date | null) => void;\r\n value?: Date | null;\r\n defaultValue?: Date | null;\r\n type?: 'from' | 'to';\r\n};\r\n\r\n/**\r\n * Merges props from RangeDatePicker and DatePicker\r\n */\r\nfunction usePropsMerge(props: DatePickerProps) {\r\n const context = useRangeDatePickerContext();\r\n if (context && !props.type) {\r\n throw new Error(\r\n \"<DatePicker /> as a children of <RangeDatePicker /> needs a 'type'\"\r\n );\r\n }\r\n\r\n if (!context) {\r\n return props;\r\n } else {\r\n const mergedProps = {\r\n ...props,\r\n minDate: context.minDate,\r\n maxDate: context.maxDate,\r\n dayNames: context.dayNames,\r\n monthNames: context.monthNames,\r\n ...(props.type === 'from'\r\n ? {\r\n value: context.from,\r\n onChange: context.onChangeFrom,\r\n }\r\n : {\r\n // props.type === 'to'\r\n value: context.to,\r\n onChange: context.onChangeTo,\r\n minDate:\r\n context.from !== null && context.from !== undefined\r\n ? new Date(context.from.valueOf() + 86400000)\r\n : context.minDate,\r\n }),\r\n };\r\n\r\n return mergedProps;\r\n }\r\n}\r\n\r\nexport const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(\r\n function DatePicker(props, ref) {\r\n const {\r\n as: Comp = 'div',\r\n minDate: propMinDate = new Date(0),\r\n maxDate: propMaxDate = new Date(),\r\n dayNames,\r\n monthNames,\r\n onChange,\r\n value: controlledValue,\r\n defaultValue,\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n type, // just to avoid passing it to DOM\r\n ...rest\r\n } = usePropsMerge(props);\r\n const datePickerRef = useRef<HTMLDivElement | null>(null);\r\n const minDate = propMinDate,\r\n maxDate = propMaxDate;\r\n\r\n const onChangeRef = useRef(onChange);\r\n onChangeRef.current = onChange;\r\n\r\n const controlledValueRef = useRef(controlledValue);\r\n controlledValueRef.current = controlledValue;\r\n\r\n const initialData: ReducerState = {\r\n isFocused: false,\r\n navigationDay: -1,\r\n navigationMonth: -1,\r\n navigationYear: -1,\r\n selectedDate: defaultValue !== undefined ? defaultValue : null,\r\n };\r\n const [state, dispatch] = useReducer(reducer, initialData);\r\n\r\n if (!dayNames || !monthNames) {\r\n throw new Error(\r\n 'Props dayNames and monthNames not specified in <DatePicker />'\r\n );\r\n }\r\n\r\n const contextValue: DatePickerContextProps = useMemo(\r\n () => ({\r\n minDate,\r\n maxDate,\r\n dayNames,\r\n monthNames,\r\n datePickerRef,\r\n controlledValueRef,\r\n state,\r\n dispatch,\r\n onChangeRef,\r\n }),\r\n [maxDate, minDate, dayNames, monthNames, state]\r\n );\r\n\r\n return (\r\n <DatePickerProvider value={contextValue}>\r\n <Comp\r\n ref={assignMultipleRefs(ref, datePickerRef)}\r\n data-has-focus={state.isFocused ? '' : undefined}\r\n {...rest}\r\n />\r\n </DatePickerProvider>\r\n );\r\n }\r\n);\r\n"],"mappings":";;;;AACA,SAASA,UAAT,EAAqBC,OAArB,EAA8BC,MAA9B,EAAsCC,UAAtC,QAAwD,OAAxD;AACA,SAASC,kBAAT,QAAmC,gBAAnC;AAGA,SAASC,OAAT,QAAwB,SAAxB;AAGA,SAASC,yBAAT,EAAoCC,kBAApC,QAA8D,YAA9D;;;AAiBA;AACA;AACA;AACA,SAASC,aAAT,CAAuBC,KAAvB,EAA+C;EAC7C,IAAMC,OAAO,GAAGJ,yBAAyB,EAAzC;;EACA,IAAII,OAAO,IAAI,CAACD,KAAK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C,UAA7B,EAAyC6B,KAAzC,CAZkD,CAApD;EAeA,oBACE,KAAC,kBAAD;IAAoB,KAAK,EAAEE,YAA3B;IAAA,uBACE,KAAC,IAAD;MACE,GAAG,EAAE5C,kBAAkB,CAACwB,GAAD,EAAMQ,aAAN,CADzB;MAEE,kBAAgBU,KAAK,CAACL,SAAN,GAAkB,EAAlB,GAAuBjB;IAFzC,GAGMW,IAHN;EADF,EADF;AASD,CAhEiC,CAA7B"}
1
+ {"version":3,"file":"DatePicker.js","names":["forwardRef","useMemo","useRef","useReducer","assignMultipleRefs","reducer","useRangeDatePickerContext","DatePickerProvider","usePropsMerge","props","context","type","Error","mergedProps","minDate","maxDate","dayNames","monthNames","value","from","onChange","onChangeFrom","to","onChangeTo","undefined","Date","valueOf","DatePicker","ref","as","Comp","propMinDate","propMaxDate","controlledValue","defaultValue","rest","datePickerRef","onChangeRef","current","controlledValueRef","initialData","isFocused","navigationDay","navigationMonth","navigationYear","selectedDate","state","dispatch","contextValue"],"sources":["../../../src/DatePicker/DatePicker.tsx"],"sourcesContent":["import type { ElementType, HTMLAttributes } from 'react';\nimport { forwardRef, useMemo, useRef, useReducer } from 'react';\nimport { assignMultipleRefs } from '@basic-ui/core';\n\nimport type { ReducerState } from './hooks';\nimport { reducer } from './hooks';\nimport type { DayNames, MonthNames } from './dateTypes';\nimport type { DatePickerContextProps } from './contexts';\nimport { useRangeDatePickerContext, DatePickerProvider } from './contexts';\n\nexport type DatePickerProps = Omit<\n HTMLAttributes<HTMLDivElement>,\n 'value' | 'defaultValue' | 'onChange'\n> & {\n as?: ElementType<any>;\n minDate?: Date;\n maxDate?: Date;\n dayNames?: DayNames;\n monthNames?: MonthNames;\n onChange?: (from: Date | null) => void;\n value?: Date | null;\n defaultValue?: Date | null;\n type?: 'from' | 'to';\n};\n\n/**\n * Merges props from RangeDatePicker and DatePicker\n */\nfunction usePropsMerge(props: DatePickerProps) {\n const context = useRangeDatePickerContext();\n if (context && !props.type) {\n throw new Error(\n \"<DatePicker /> as a children of <RangeDatePicker /> needs a 'type'\"\n );\n }\n\n if (!context) {\n return props;\n } else {\n const mergedProps = {\n ...props,\n minDate: context.minDate,\n maxDate: context.maxDate,\n dayNames: context.dayNames,\n monthNames: context.monthNames,\n ...(props.type === 'from'\n ? {\n value: context.from,\n onChange: context.onChangeFrom,\n }\n : {\n // props.type === 'to'\n value: context.to,\n onChange: context.onChangeTo,\n minDate:\n context.from !== null && context.from !== undefined\n ? new Date(context.from.valueOf() + 86400000)\n : context.minDate,\n }),\n };\n\n return mergedProps;\n }\n}\n\nexport const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(\n function DatePicker(props, ref) {\n const {\n as: Comp = 'div',\n minDate: propMinDate = new Date(0),\n maxDate: propMaxDate = new Date(),\n dayNames,\n monthNames,\n onChange,\n value: controlledValue,\n defaultValue,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n type, // just to avoid passing it to DOM\n ...rest\n } = usePropsMerge(props);\n const datePickerRef = useRef<HTMLDivElement | null>(null);\n const minDate = propMinDate,\n maxDate = propMaxDate;\n\n const onChangeRef = useRef(onChange);\n onChangeRef.current = onChange;\n\n const controlledValueRef = useRef(controlledValue);\n controlledValueRef.current = controlledValue;\n\n const initialData: ReducerState = {\n isFocused: false,\n navigationDay: -1,\n navigationMonth: -1,\n navigationYear: -1,\n selectedDate: defaultValue !== undefined ? defaultValue : null,\n };\n const [state, dispatch] = useReducer(reducer, initialData);\n\n if (!dayNames || !monthNames) {\n throw new Error(\n 'Props dayNames and monthNames not specified in <DatePicker />'\n );\n }\n\n const contextValue: DatePickerContextProps = useMemo(\n () => ({\n minDate,\n maxDate,\n dayNames,\n monthNames,\n datePickerRef,\n controlledValueRef,\n state,\n dispatch,\n onChangeRef,\n }),\n [maxDate, minDate, dayNames, monthNames, state]\n );\n\n return (\n <DatePickerProvider value={contextValue}>\n <Comp\n ref={assignMultipleRefs(ref, datePickerRef)}\n data-has-focus={state.isFocused ? '' : undefined}\n {...rest}\n />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CAAN;EAGD;;EAED,IAAMoC,YAAoC,GAAG/C,OAAO,CAClD;IAAA,OAAO;MACLa,OAAO,EAAPA,OADK;MAELC,OAAO,EAAPA,OAFK;MAGLC,QAAQ,EAARA,QAHK;MAILC,UAAU,EAAVA,UAJK;MAKLmB,aAAa,EAAbA,aALK;MAMLG,kBAAkB,EAAlBA,kBANK;MAOLO,KAAK,EAALA,KAPK;MAQLC,QAAQ,EAARA,QARK;MASLV,WAAW,EAAXA;IATK,CAAP;EAAA,CADkD,EAYlD,CAACtB,OAAD,EAAUD,OAAV,EAAmBE,QAAnB,EAA6BC,UAA7B,EAAyC6B,KAAzC,CAZkD,CAApD;EAeA,oBACE,KAAC,kBAAD;IAAoB,KAAK,EAAEE,YAA3B;IAAA,uBACE,KAAC,IAAD;MACE,GAAG,EAAE5C,kBAAkB,CAACwB,GAAD,EAAMQ,aAAN,CADzB;MAEE,kBAAgBU,KAAK,CAACL,SAAN,GAAkB,EAAlB,GAAuBjB;IAFzC,GAGMW,IAHN;EADF,EADF;AASD,CAhEiC,CAA7B"}
@@ -1,8 +1,8 @@
1
- import type { ElementType, SelectHTMLAttributes } from 'react';
2
- export interface DatePickerSelectProps extends SelectHTMLAttributes<HTMLSelectElement> {
3
- groupType?: 'from' | 'to';
4
- type: 'month_year' | 'day';
5
- emptyOption?: string;
6
- as?: ElementType<any>;
7
- }
8
- export declare const DatePickerSelect: import("react").ForwardRefExoticComponent<DatePickerSelectProps & import("react").RefAttributes<unknown>>;
1
+ import type { ElementType, SelectHTMLAttributes } from 'react';
2
+ export interface DatePickerSelectProps extends SelectHTMLAttributes<HTMLSelectElement> {
3
+ groupType?: 'from' | 'to';
4
+ type: 'month_year' | 'day';
5
+ emptyOption?: string;
6
+ as?: ElementType<any>;
7
+ }
8
+ export declare const DatePickerSelect: import("react").ForwardRefExoticComponent<DatePickerSelectProps & import("react").RefAttributes<unknown>>;
@@ -1 +1 @@
1
- {"version":3,"file":"DatePickerSelect.js","names":["forwardRef","memo","wrapEvent","differenceInCalendarMonths","addMonths","getDaysInMonth","setDate","useInnerFocus","SET_DATE","NAVIGATE","useDatePickerContext","MonthYearOptions","minDate","maxDate","monthNames","emptyOption","ret","diff","i","date","year","getFullYear","month","getMonth","push","DayOptions","Date","dayNames","day","newDate","valueOf","getDay","DatePickerSelect","DatePicker","ref","as","Comp","type","onFocus","onBlur","onChange","children","rest","onChangeRef","dispatch","controlledValueRef","data","state","handleFocus","handleBlur","stateSelectedDate","selectedDate","navigationYear","navigationMonth","navigationDay","current","undefined","handleChange","e","nextState","target","value","split","yearStr","monthStr","parseInt","nextDate","UTC","getDate","disabled"],"sources":["../../../src/DatePicker/DatePickerSelect.tsx"],"sourcesContent":["import type { ChangeEvent, ElementType, SelectHTMLAttributes } from 'react';\r\nimport { forwardRef, memo } from 'react';\r\nimport { wrapEvent } from '@basic-ui/core';\r\nimport {\r\n differenceInCalendarMonths,\r\n addMonths,\r\n getDaysInMonth,\r\n setDate,\r\n} from 'date-fns';\r\n\r\nimport { useInnerFocus, SET_DATE, NAVIGATE } from './hooks';\r\nimport type { DayNames, MonthNames } from './dateTypes';\r\nimport { useDatePickerContext } from './contexts';\r\n\r\nexport interface DatePickerSelectProps\r\n extends SelectHTMLAttributes<HTMLSelectElement> {\r\n groupType?: 'from' | 'to';\r\n type: 'month_year' | 'day';\r\n emptyOption?: string;\r\n\r\n as?: ElementType<any>;\r\n}\r\n\r\nconst MonthYearOptions = memo(\r\n ({\r\n minDate,\r\n maxDate,\r\n monthNames,\r\n emptyOption,\r\n }: {\r\n minDate: Date;\r\n maxDate: Date;\r\n monthNames: MonthNames;\r\n emptyOption: string;\r\n }) => {\r\n const ret = [\r\n <option key={'empty'} value=\"\" disabled>\r\n {emptyOption}\r\n </option>,\r\n ];\r\n\r\n const diff = differenceInCalendarMonths(maxDate, minDate);\r\n for (let i = 0; i <= diff; i++) {\r\n const date = addMonths(minDate, i);\r\n const year = date.getFullYear();\r\n const month = date.getMonth();\r\n\r\n ret.push(\r\n <option key={`${year}_${month}`} value={`${year}-${month}`}>\r\n {monthNames[month]} {year}\r\n </option>\r\n );\r\n }\r\n\r\n return <>{ret}</>;\r\n }\r\n);\r\n\r\nconst DayOptions = memo(\r\n ({\r\n date = new Date(0),\r\n dayNames,\r\n minDate,\r\n emptyOption,\r\n }: {\r\n date: Date | undefined;\r\n dayNames: DayNames;\r\n minDate: Date;\r\n emptyOption: string;\r\n }) => {\r\n if (!date) {\r\n return null;\r\n }\r\n\r\n const ret = [\r\n <option key={'empty'} value=\"\" disabled>\r\n {emptyOption}\r\n </option>,\r\n ];\r\n\r\n for (let day = 1; day <= getDaysInMonth(date); day++) {\r\n const newDate = setDate(date, day);\r\n ret.push(\r\n <option\r\n key={`day_${day}`}\r\n value={`${day}`}\r\n disabled={newDate.valueOf() < minDate.valueOf()}\r\n >\r\n {(newDate.getDay(), dayNames[newDate.getDay()])} {day}\r\n </option>\r\n );\r\n }\r\n\r\n return <>{ret}</>;\r\n }\r\n);\r\n\r\nexport const DatePickerSelect = forwardRef(function DatePicker(\r\n {\r\n as: Comp = 'select',\r\n type,\r\n onFocus,\r\n onBlur,\r\n onChange,\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n children,\r\n emptyOption = '',\r\n ...rest\r\n }: DatePickerSelectProps,\r\n ref\r\n) {\r\n const {\r\n minDate,\r\n maxDate,\r\n monthNames,\r\n onChangeRef,\r\n dayNames,\r\n dispatch,\r\n controlledValueRef,\r\n state: data,\r\n } = useDatePickerContext();\r\n const { handleFocus, handleBlur } = useInnerFocus();\r\n\r\n const { selectedDate: stateSelectedDate } = data;\r\n let {\r\n navigationYear: year,\r\n navigationMonth: month,\r\n navigationDay: day,\r\n } = data;\r\n\r\n const selectedDate =\r\n controlledValueRef.current !== undefined\r\n ? controlledValueRef.current\r\n : stateSelectedDate;\r\n\r\n const handleChange = (e: ChangeEvent<HTMLSelectElement>) => {\r\n const nextState = {\r\n year,\r\n month,\r\n day,\r\n };\r\n\r\n switch (type) {\r\n case 'month_year': {\r\n nextState.year = -1;\r\n nextState.month = -1;\r\n nextState.day = -1;\r\n\r\n if (e.target.value) {\r\n const [yearStr, monthStr] = e.target.value.split('-');\r\n nextState.year = parseInt(yearStr, 10);\r\n nextState.month = parseInt(monthStr, 10);\r\n nextState.day = -1;\r\n }\r\n\r\n dispatch({ type: NAVIGATE, ...nextState });\r\n break;\r\n }\r\n case 'day': {\r\n nextState.day = -1;\r\n if (e.target.value) {\r\n nextState.day = parseInt(e.target.value, 10);\r\n }\r\n\r\n let nextDate: Date | undefined = undefined;\r\n if (nextState.day !== -1) {\r\n if (nextState.year >= 0 && nextState.month >= 0) {\r\n nextDate = new Date(\r\n Date.UTC(nextState.year, nextState.month, nextState.day)\r\n );\r\n } else if (selectedDate !== null) {\r\n nextDate = new Date(\r\n Date.UTC(\r\n selectedDate.getFullYear(),\r\n selectedDate.getMonth(),\r\n nextState.day\r\n )\r\n );\r\n }\r\n }\r\n\r\n if (nextDate !== undefined) {\r\n onChangeRef.current && onChangeRef.current(nextDate);\r\n dispatch({ type: SET_DATE, selectedDate: nextDate });\r\n } else {\r\n dispatch({ type: NAVIGATE, ...nextState });\r\n }\r\n break;\r\n }\r\n }\r\n };\r\n\r\n if (year < 0 && month < 0 && day <= 0 && selectedDate !== null) {\r\n year = selectedDate.getFullYear();\r\n month = selectedDate.getMonth();\r\n day = selectedDate.getDate();\r\n }\r\n\r\n let value = '';\r\n let disabled = false;\r\n if (type === 'month_year') {\r\n if (month >= 0 && year >= 0) {\r\n value = `${year}-${month}`;\r\n }\r\n } else if (type === 'day') {\r\n disabled = month < 0 || year < 0;\r\n if (day > 0) {\r\n value = `${day}`;\r\n }\r\n }\r\n\r\n return (\r\n <Comp\r\n ref={ref}\r\n onFocus={wrapEvent(onFocus, handleFocus)}\r\n onBlur={wrapEvent(onBlur, handleBlur)}\r\n onChange={wrapEvent(onChange, handleChange)}\r\n value={value}\r\n disabled={disabled}\r\n data-has-selected={value !== '' ? '' : undefined}\r\n {...rest}\r\n >\r\n {type === 'month_year' ? (\r\n <MonthYearOptions\r\n minDate={minDate}\r\n maxDate={maxDate}\r\n monthNames={monthNames}\r\n emptyOption={emptyOption}\r\n />\r\n ) : type === 'day' ? (\r\n <DayOptions\r\n date={\r\n month >= 0 && year >= 0\r\n ? new Date(Date.UTC(year, month, 15))\r\n : undefined\r\n }\r\n dayNames={dayNames}\r\n minDate={minDate}\r\n emptyOption={emptyOption}\r\n />\r\n ) : null}\r\n </Comp>\r\n );\r\n});\r\n"],"mappings":";;;;AACA,SAASA,UAAT,EAAqBC,IAArB,QAAiC,OAAjC;AACA,SAASC,SAAT,QAA0B,gBAA1B;AACA,SACEC,0BADF,EAEEC,SAFF,EAGEC,cAHF,EAIEC,OAJF,QAKO,UALP;AAOA,SAASC,aAAT,EAAwBC,QAAxB,EAAkCC,QAAlC,QAAkD,SAAlD;AAEA,SAASC,oBAAT,QAAqC,YAArC;;;;AAWA,IAAMC,gBAAgB,gBAAGV,IAAI,CAC3B,gBAUM;EAAA,IATJW,OASI,QATJA,OASI;EAAA,IARJC,OAQI,QARJA,OAQI;EAAA,IAPJC,UAOI,QAPJA,UAOI;EAAA,IANJC,WAMI,QANJA,WAMI;EACJ,IAAMC,GAAG,GAAG,cACV;IAAsB,KAAK,EAAC,EAA5B;IAA+B,QAAQ,MAAvC;IAAA,UACGD;EADH,GAAa,OAAb,CADU,CAAZ;EAMA,IAAME,IAAI,GAAGd,0BAA0B,CAACU,OAAD,EAAUD,OAAV,CAAvC;;EACA,KAAK,IAAIM,CAAC,GAAG,CAAb,EAAgBA,CAAC,IAAID,IAArB,EAA2BC,CAAC,EAA5B,EAAgC;IAC9B,IAAMC,IAAI,GAAGf,SAAS,CAACQ,OAAD,EAAUM,CAAV,CAAtB;IACA,IAAME,IAAI,GAAGD,IAAI,CAACE,WAAL,EAAb;IACA,IAAMC,KAAK,GAAGH,IAAI,CAACI,QAAL,EAAd;IAEAP,GAAG,CAACQ,IAAJ,eACE;MAAiC,KAA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pB;IAGE,MAAM,EAAE9C,SAAS,CAACqC,MAAD,EAASU,UAAT,CAHnB;IAIE,QAAQ,EAAE/C,SAAS,CAACsC,QAAD,EAAWiB,YAAX,CAJrB;IAKE,KAAK,EAAEI,KALT;IAME,QAAQ,EAAEQ,QANZ;IAOE,qBAAmBR,KAAK,KAAK,EAAV,GAAe,EAAf,GAAoBL;EAPzC,GAQMd,IARN;IAAA,UAUGL,IAAI,KAAK,YAAT,gBACC,KAAC,gBAAD;MACE,OAAO,EAAEzB,OADX;MAEE,OAAO,EAAEC,OAFX;MAGE,UAAU,EAAEC,UAHd;MAIE,WAAW,EAAEC;IAJf,EADD,GAOGsB,IAAI,KAAK,KAAT,gBACF,KAAC,UAAD;MACE,IAAI,EACFf,KAAK,IAAI,CAAT,IAAcF,IAAI,IAAI,CAAtB,GACI,IAAIM,IAAJ,CAASA,IAAI,CAACyC,GAAL,CAAS/C,IAAT,EAAeE,KAAf,EAAsB,EAAtB,CAAT,CADJ,GAEIkC,SAJR;MAME,QAAQ,EAAE7B,QANZ;MAOE,OAAO,EAAEf,OAPX;MAQE,WAAW,EAAEG;IARf,EADE,GAWA;EA5BN,GADF;AAgCD,CAlJyC,CAAnC"}
1
+ {"version":3,"file":"DatePickerSelect.js","names":["forwardRef","memo","wrapEvent","differenceInCalendarMonths","addMonths","getDaysInMonth","setDate","useInnerFocus","SET_DATE","NAVIGATE","useDatePickerContext","MonthYearOptions","minDate","maxDate","monthNames","emptyOption","ret","diff","i","date","year","getFullYear","month","getMonth","push","DayOptions","Date","dayNames","day","newDate","valueOf","getDay","DatePickerSelect","DatePicker","ref","as","Comp","type","onFocus","onBlur","onChange","children","rest","onChangeRef","dispatch","controlledValueRef","data","state","handleFocus","handleBlur","stateSelectedDate","selectedDate","navigationYear","navigationMonth","navigationDay","current","undefined","handleChange","e","nextState","target","value","split","yearStr","monthStr","parseInt","nextDate","UTC","getDate","disabled"],"sources":["../../../src/DatePicker/DatePickerSelect.tsx"],"sourcesContent":["import type { ChangeEvent, ElementType, SelectHTMLAttributes } from 'react';\nimport { forwardRef, memo } from 'react';\nimport { wrapEvent } from '@basic-ui/core';\nimport {\n differenceInCalendarMonths,\n addMonths,\n getDaysInMonth,\n setDate,\n} from 'date-fns';\n\nimport { useInnerFocus, SET_DATE, NAVIGATE } from './hooks';\nimport type { DayNames, MonthNames } from './dateTypes';\nimport { useDatePickerContext } from './contexts';\n\nexport interface DatePickerSelectProps\n extends SelectHTMLAttributes<HTMLSelectElement> {\n groupType?: 'from' | 'to';\n type: 'month_year' | 'day';\n emptyOption?: string;\n\n as?: ElementType<any>;\n}\n\nconst MonthYearOptions = memo(\n ({\n minDate,\n maxDate,\n monthNames,\n emptyOption,\n }: {\n minDate: Date;\n maxDate: Date;\n monthNames: MonthNames;\n emptyOption: string;\n }) => {\n const ret = [\n <option key={'empty'} value=\"\" disabled>\n {emptyOption}\n </option>,\n ];\n\n const diff = differenceInCalendarMonths(maxDate, minDate);\n for (let i = 0; i <= diff; i++) {\n const date = addMonths(minDate, i);\n const year = date.getFullYear();\n const month = date.getMonth();\n\n ret.push(\n <option key={`${year}_${month}`} value={`${year}-${month}`}>\n {monthNames[month]} {year}\n </option>\n );\n }\n\n return <>{ret}</>;\n }\n);\n\nconst DayOptions = memo(\n ({\n date = new Date(0),\n dayNames,\n minDate,\n emptyOption,\n }: {\n date: Date | undefined;\n dayNames: DayNames;\n minDate: Date;\n emptyOption: string;\n }) => {\n if (!date) {\n return null;\n }\n\n const ret = [\n <option key={'empty'} value=\"\" disabled>\n {emptyOption}\n </option>,\n ];\n\n for (let day = 1; day <= getDaysInMonth(date); day++) {\n const newDate = setDate(date, day);\n ret.push(\n <option\n key={`day_${day}`}\n value={`${day}`}\n disabled={newDate.valueOf() < minDate.valueOf()}\n >\n {(newDate.getDay(), dayNames[newDate.getDay()])} {day}\n </option>\n );\n }\n\n return <>{ret}</>;\n }\n);\n\nexport const DatePickerSelect = forwardRef(function DatePicker(\n {\n as: Comp = 'select',\n type,\n onFocus,\n onBlur,\n onChange,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n children,\n emptyOption = '',\n ...rest\n }: DatePickerSelectProps,\n ref\n) {\n const {\n minDate,\n maxDate,\n monthNames,\n onChangeRef,\n dayNames,\n dispatch,\n controlledValueRef,\n state: data,\n } = useDatePickerContext();\n const { handleFocus, handleBlur } = useInnerFocus();\n\n const { selectedDate: stateSelectedDate } = data;\n let {\n navigationYear: year,\n navigationMonth: month,\n navigationDay: day,\n } = data;\n\n const selectedDate =\n controlledValueRef.current !== undefined\n ? controlledValueRef.current\n : stateSelectedDate;\n\n const handleChange = (e: ChangeEvent<HTMLSelectElement>) => {\n const nextState = {\n year,\n month,\n day,\n };\n\n switch (type) {\n case 'month_year': {\n nextState.year = -1;\n nextState.month = -1;\n nextState.day = -1;\n\n if (e.target.value) {\n const [yearStr, monthStr] = e.target.value.split('-');\n nextState.year = parseInt(yearStr, 10);\n nextState.month = parseInt(monthStr, 10);\n nextState.day = -1;\n }\n\n dispatch({ type: NAVIGATE, ...nextState });\n break;\n }\n case 'day': {\n nextState.day = -1;\n if (e.target.value) {\n nextState.day = parseInt(e.target.value, 10);\n }\n\n let nextDate: Date | undefined = undefined;\n if (nextState.day !== -1) {\n if (nextState.year >= 0 && nextState.month >= 0) {\n nextDate = new Date(\n Date.UTC(nextState.year, nextState.month, nextState.day)\n );\n } else if (selectedDate !== null) {\n nextDate = new Date(\n Date.UTC(\n selectedDate.getFullYear(),\n selectedDate.getMonth(),\n nextState.day\n )\n );\n }\n }\n\n if (nextDate !== undefined) {\n onChangeRef.current && onChangeRef.current(nextDate);\n dispatch({ type: SET_DATE, selectedDate: nextDate });\n } else {\n dispatch({ type: NAVIGATE, ...nextState });\n }\n break;\n }\n }\n };\n\n if (year < 0 && month < 0 && day <= 0 && selectedDate !== null) {\n year = selectedDate.getFullYear();\n month = selectedDate.getMonth();\n day = selectedDate.getDate();\n }\n\n let value = '';\n let disabled = false;\n if (type === 'month_year') {\n if (month >= 0 && year >= 0) {\n value = `${year}-${month}`;\n }\n } else if (type === 'day') {\n disabled = month < 0 || year < 0;\n if (day > 0) {\n value = `${day}`;\n }\n }\n\n return (\n <Comp\n ref={ref}\n onFocus={wrapEvent(onFocus, handleFocus)}\n onBlur={wrapEvent(onBlur, handleBlur)}\n onChange={wrapEvent(onChange, handleChange)}\n value={value}\n disabled={disabled}\n data-has-selected={value !== '' ? '' : undefined}\n {...rest}\n >\n {type === 'month_year' ? (\n <MonthYearOptions\n minDate={minDate}\n maxDate={maxDate}\n monthNames={monthNames}\n emptyOption={emptyOption}\n />\n ) : type === 'day' ? (\n <DayOptions\n date={\n month >= 0 && year >= 0\n ? new Date(Date.UTC(year, month, 15))\n : undefined\n }\n dayNames={dayNames}\n minDate={minDate}\n emptyOption={emptyOption}\n />\n ) : null}\n </Comp>\n );\n});\n"],"mappings":";;;;AACA,SAASA,UAAT,EAAqBC,IAArB,QAAiC,OAAjC;AACA,SAASC,SAAT,QAA0B,gBAA1B;AACA,SACEC,0BADF,EAEEC,SAFF,EAGEC,cAHF,EAIEC,OAJF,QAKO,UALP;AAOA,SAASC,aAAT,EAAwBC,QAAxB,EAAkCC,QAAlC,QAAkD,SAAlD;AAEA,SAASC,oBAAT,QAAqC,YAArC;;;;AAWA,IAAMC,gBAAgB,gBAAGV,IAAI,CAC3B,gBAUM;EAAA,IATJW,OASI,QATJA,OASI;EAAA,IARJC,OAQI,QARJA,OAQI;EAAA,IAPJC,UAOI,QAPJA,UAOI;EAAA,IANJC,WAMI,QANJA,WAMI;EACJ,IAAMC,GAAG,GAAG,cACV;IAAsB,KAAK,EAAC,EAA5B;IAA+B,QAAQ,MAAvC;IAAA,UACGD;EADH,GAAa,OAAb,CADU,CAAZ;EAMA,IAAME,IAAI,GAAGd,0BAA0B,CAACU,OAAD,EAAUD,OAAV,CAAvC;;EACA,KAAK,IAAIM,CAAC,GAAG,CAAb,EAAgBA,CAAC,IAAID,IAArB,EAA2BC,CAAC,EAA5B,EAAgC;IA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,IAAI,GAAG,CAA/B;;IACA,IAAIQ,GAAG,GAAG,CAAV,EAAa;MACXiC,KAAK,aAAMjC,GAAN,CAAL;IACD;EACF;;EAED,oBACE,KAAC,IAAD;IACE,GAAG,EAAEM,GADP;IAEE,OAAO,EAAEhC,SAAS,CAACoC,OAAD,EAAUU,WAAV,CAFpB;IAGE,MAAM,EAAE9C,SAAS,CAACqC,MAAD,EAASU,UAAT,CAHnB;IAIE,QAAQ,EAAE/C,SAAS,CAACsC,QAAD,EAAWiB,YAAX,CAJrB;IAKE,KAAK,EAAEI,KALT;IAME,QAAQ,EAAEQ,QANZ;IAOE,qBAAmBR,KAAK,KAAK,EAAV,GAAe,EAAf,GAAoBL;EAPzC,GAQMd,IARN;IAAA,UAUGL,IAAI,KAAK,YAAT,gBACC,KAAC,gBAAD;MACE,OAAO,EAAEzB,OADX;MAEE,OAAO,EAAEC,OAFX;MAGE,UAAU,EAAEC,UAHd;MAIE,WAAW,EAAEC;IAJf,EADD,GAOGsB,IAAI,KAAK,KAAT,gBACF,KAAC,UAAD;MACE,IAAI,EACFf,KAAK,IAAI,CAAT,IAAcF,IAAI,IAAI,CAAtB,GACI,IAAIM,IAAJ,CAASA,IAAI,CAACyC,GAAL,CAAS/C,IAAT,EAAeE,KAAf,EAAsB,EAAtB,CAAT,CADJ,GAEIkC,SAJR;MAME,QAAQ,EAAE7B,QANZ;MAOE,OAAO,EAAEf,OAPX;MAQE,WAAW,EAAEG;IARf,EADE,GAWA;EA5BN,GADF;AAgCD,CAlJyC,CAAnC"}
@@ -1,28 +1,28 @@
1
- import type { ElementType, HTMLAttributes, ReactNode } from 'react';
2
- import type { MonthNames, DayNames } from './dateTypes';
3
- export declare type RangeDatePickerProps = Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> & {
4
- as?: ElementType<any>;
5
- minDate?: Date;
6
- maxDate?: Date;
7
- dayNames: DayNames;
8
- monthNames: MonthNames;
9
- children?: ReactNode[];
10
- onChange?: (from: Date | null, to: Date | null) => void;
11
- from?: Date | null;
12
- to?: Date | null;
13
- defaultFrom?: Date | null;
14
- defaultTo?: Date | null;
15
- };
16
- export declare const RangeDatePicker: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLDivElement>, "onChange"> & {
17
- as?: ElementType<any> | undefined;
18
- minDate?: Date | undefined;
19
- maxDate?: Date | undefined;
20
- dayNames: DayNames;
21
- monthNames: MonthNames;
22
- children?: ReactNode[] | undefined;
23
- onChange?: ((from: Date | null, to: Date | null) => void) | undefined;
24
- from?: Date | null | undefined;
25
- to?: Date | null | undefined;
26
- defaultFrom?: Date | null | undefined;
27
- defaultTo?: Date | null | undefined;
28
- } & import("react").RefAttributes<HTMLDivElement>>;
1
+ import type { ElementType, HTMLAttributes, ReactNode } from 'react';
2
+ import type { MonthNames, DayNames } from './dateTypes';
3
+ export declare type RangeDatePickerProps = Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> & {
4
+ as?: ElementType<any>;
5
+ minDate?: Date;
6
+ maxDate?: Date;
7
+ dayNames: DayNames;
8
+ monthNames: MonthNames;
9
+ children?: ReactNode[];
10
+ onChange?: (from: Date | null, to: Date | null) => void;
11
+ from?: Date | null;
12
+ to?: Date | null;
13
+ defaultFrom?: Date | null;
14
+ defaultTo?: Date | null;
15
+ };
16
+ export declare const RangeDatePicker: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLDivElement>, "onChange"> & {
17
+ as?: ElementType<any> | undefined;
18
+ minDate?: Date | undefined;
19
+ maxDate?: Date | undefined;
20
+ dayNames: DayNames;
21
+ monthNames: MonthNames;
22
+ children?: ReactNode[] | undefined;
23
+ onChange?: ((from: Date | null, to: Date | null) => void) | undefined;
24
+ from?: Date | null | undefined;
25
+ to?: Date | null | undefined;
26
+ defaultFrom?: Date | null | undefined;
27
+ defaultTo?: Date | null | undefined;
28
+ } & import("react").RefAttributes<HTMLDivElement>>;
@@ -1 +1 @@
1
- {"version":3,"file":"RangeDatePicker.js","names":["forwardRef","useRef","useState","assignMultipleRefs","adjustDates","RangeDatePickerProvider","RangeDatePicker","ref","as","Comp","minDate","propMinDate","Date","maxDate","propMaxDate","dayNames","monthNames","onChange","controlledFrom","from","controlledTo","to","defaultFrom","defaultTo","rest","isControlled","undefined","rangeDatePickerRef","stateFrom","stateTo","setDates","innerHasFocus","setInnerHasFocus","onChangeFrom","nextFrom","nextTo","onChangeTo","contextValue"],"sources":["../../../src/DatePicker/RangeDatePicker.tsx"],"sourcesContent":["import type { ElementType, HTMLAttributes, ReactNode } from 'react';\r\nimport { forwardRef, useRef, useState } from 'react';\r\nimport { assignMultipleRefs } from '@basic-ui/core';\r\n\r\nimport type { MonthNames, DayNames } from './dateTypes';\r\nimport { adjustDates } from './adjustDates';\r\nimport type { RangeDatePickerContextProps } from './contexts';\r\nimport { RangeDatePickerProvider } from './contexts';\r\n\r\nexport type RangeDatePickerProps = Omit<\r\n HTMLAttributes<HTMLDivElement>,\r\n 'onChange'\r\n> & {\r\n as?: ElementType<any>;\r\n minDate?: Date;\r\n maxDate?: Date;\r\n dayNames: DayNames;\r\n monthNames: MonthNames;\r\n children?: ReactNode[];\r\n onChange?: (from: Date | null, to: Date | null) => void;\r\n from?: Date | null;\r\n to?: Date | null;\r\n defaultFrom?: Date | null;\r\n defaultTo?: Date | null;\r\n};\r\n\r\nexport const RangeDatePicker = forwardRef<HTMLDivElement, RangeDatePickerProps>(\r\n function RangeDatePicker(\r\n {\r\n as: Comp = 'div',\r\n minDate: propMinDate = new Date(0),\r\n maxDate: propMaxDate = new Date(),\r\n dayNames,\r\n monthNames,\r\n onChange,\r\n from: controlledFrom,\r\n to: controlledTo,\r\n defaultFrom,\r\n defaultTo,\r\n ...rest\r\n },\r\n ref\r\n ) {\r\n const isControlled =\r\n controlledFrom !== undefined && controlledTo !== undefined;\r\n\r\n const minDate = propMinDate,\r\n maxDate = propMaxDate;\r\n\r\n const rangeDatePickerRef = useRef<HTMLDivElement | null>(null);\r\n const [{ from: stateFrom, to: stateTo }, setDates] = useState({\r\n from: (defaultFrom || null) as Date | null,\r\n to: (defaultTo || null) as Date | null,\r\n });\r\n const [innerHasFocus, setInnerHasFocus] = useState(false);\r\n\r\n const onChangeFrom = (from: Date | null) => {\r\n const to = stateTo;\r\n const { from: nextFrom, to: nextTo } = adjustDates(from, to, 'from');\r\n\r\n onChange && onChange(nextFrom, nextTo);\r\n setDates({ from: nextFrom, to: nextTo });\r\n };\r\n\r\n const onChangeTo = (to: Date | null) => {\r\n const from = stateFrom;\r\n const { from: nextFrom, to: nextTo } = adjustDates(from, to, 'to');\r\n\r\n onChange && onChange(nextFrom, nextTo);\r\n setDates({ from: nextFrom, to: nextTo });\r\n };\r\n\r\n const from = isControlled ? controlledFrom : stateFrom;\r\n const to = isControlled ? controlledTo : stateTo;\r\n\r\n const contextValue: RangeDatePickerContextProps = {\r\n rangeDatePickerRef,\r\n innerHasFocus,\r\n setInnerHasFocus,\r\n minDate,\r\n maxDate,\r\n from,\r\n to,\r\n dayNames,\r\n monthNames,\r\n onChangeFrom,\r\n onChangeTo,\r\n };\r\n\r\n return (\r\n <RangeDatePickerProvider value={contextValue}>\r\n <Comp\r\n ref={assignMultipleRefs(ref, rangeDatePickerRef)}\r\n data-has-focus={innerHasFocus ? '' : undefined}\r\n {...rest}\r\n />\r\n </RangeDatePickerProvider>\r\n );\r\n }\r\n);\r\n"],"mappings":";;;;AACA,SAASA,UAAT,EAAqBC,MAArB,EAA6BC,QAA7B,QAA6C,OAA7C;AACA,SAASC,kBAAT,QAAmC,gBAAnC;AAGA,SAASC,WAAT,QAA4B,eAA5B;AAEA,SAASC,uBAAT,QAAwC,YAAxC;;AAmBA,OAAO,IAAMC,eAAe,gBAAGN,UAAU,CACvC,SAASM,eAAT,OAcEC,GAdF,EAeE;EAAA,mBAbEC,EAaF;EAAA,IAbMC,IAaN,wBAba,KAab;EAAA,wBAZEC,OAYF;EAAA,IAZWC,WAYX,6BAZyB,IAAIC,IAAJ,CAAS,CAAT,CAYzB;EAAA,wBAXEC,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bA,UAAa,CAACf,EAAD,EAAqB;IACtC,IAAMF,IAAI,GAAGS,SAAb;;IACA,oBAAuCxB,WAAW,CAACe,IAAD,EAAOE,EAAP,EAAW,IAAX,CAAlD;IAAA,IAAca,QAAd,iBAAQf,IAAR;IAAA,IAA4BgB,MAA5B,iBAAwBd,EAAxB;;IAEAJ,QAAQ,IAAIA,QAAQ,CAACiB,QAAD,EAAWC,MAAX,CAApB;IACAL,QAAQ,CAAC;MAAEX,IAAI,EAAEe,QAAR;MAAkBb,EAAE,EAAEc;IAAtB,CAAD,CAAR;EACD,CAND;;EAQA,IAAMhB,IAAI,GAAGM,YAAY,GAAGP,cAAH,GAAoBU,SAA7C;EACA,IAAMP,EAAE,GAAGI,YAAY,GAAGL,YAAH,GAAkBS,OAAzC;EAEA,IAAMQ,YAAyC,GAAG;IAChDV,kBAAkB,EAAlBA,kBADgD;IAEhDI,aAAa,EAAbA,aAFgD;IAGhDC,gBAAgB,EAAhBA,gBAHgD;IAIhDtB,OAAO,EAAPA,OAJgD;IAKhDG,OAAO,EAAPA,OALgD;IAMhDM,IAAI,EAAJA,IANgD;IAOhDE,EAAE,EAAFA,EAPgD;IAQhDN,QAAQ,EAARA,QARgD;IAShDC,UAAU,EAAVA,UATgD;IAUhDiB,YAAY,EAAZA,YAVgD;IAWhDG,UAAU,EAAVA;EAXgD,CAAlD;EAcA,oBACE,KAAC,uBAAD;IAAyB,KAAK,EAAEC,YAAhC;IAAA,uBACE,KAAC,IAAD;MACE,GAAG,EAAElC,kBAAkB,CAACI,GAAD,EAAMoB,kBAAN,CADzB;MAEE,kBAAgBI,aAAa,GAAG,EAAH,GAAQL;IAFvC,GAGMF,IAHN;EADF,EADF;AASD,CAxEsC,CAAlC"}
1
+ {"version":3,"file":"RangeDatePicker.js","names":["forwardRef","useRef","useState","assignMultipleRefs","adjustDates","RangeDatePickerProvider","RangeDatePicker","ref","as","Comp","minDate","propMinDate","Date","maxDate","propMaxDate","dayNames","monthNames","onChange","controlledFrom","from","controlledTo","to","defaultFrom","defaultTo","rest","isControlled","undefined","rangeDatePickerRef","stateFrom","stateTo","setDates","innerHasFocus","setInnerHasFocus","onChangeFrom","nextFrom","nextTo","onChangeTo","contextValue"],"sources":["../../../src/DatePicker/RangeDatePicker.tsx"],"sourcesContent":["import type { ElementType, HTMLAttributes, ReactNode } from 'react';\nimport { forwardRef, useRef, useState } from 'react';\nimport { assignMultipleRefs } from '@basic-ui/core';\n\nimport type { MonthNames, DayNames } from './dateTypes';\nimport { adjustDates } from './adjustDates';\nimport type { RangeDatePickerContextProps } from './contexts';\nimport { RangeDatePickerProvider } from './contexts';\n\nexport type RangeDatePickerProps = Omit<\n HTMLAttributes<HTMLDivElement>,\n 'onChange'\n> & {\n as?: ElementType<any>;\n minDate?: Date;\n maxDate?: Date;\n dayNames: DayNames;\n monthNames: MonthNames;\n children?: ReactNode[];\n onChange?: (from: Date | null, to: Date | null) => void;\n from?: Date | null;\n to?: Date | null;\n defaultFrom?: Date | null;\n defaultTo?: Date | null;\n};\n\nexport const RangeDatePicker = forwardRef<HTMLDivElement, RangeDatePickerProps>(\n function RangeDatePicker(\n {\n as: Comp = 'div',\n minDate: propMinDate = new Date(0),\n maxDate: propMaxDate = new Date(),\n dayNames,\n monthNames,\n onChange,\n from: controlledFrom,\n to: controlledTo,\n defaultFrom,\n defaultTo,\n ...rest\n },\n ref\n ) {\n const isControlled =\n controlledFrom !== undefined && controlledTo !== undefined;\n\n const minDate = propMinDate,\n maxDate = propMaxDate;\n\n const rangeDatePickerRef = useRef<HTMLDivElement | null>(null);\n const [{ from: stateFrom, to: stateTo }, setDates] = useState({\n from: (defaultFrom || null) as Date | null,\n to: (defaultTo || null) as Date | null,\n });\n const [innerHasFocus, setInnerHasFocus] = useState(false);\n\n const onChangeFrom = (from: Date | null) => {\n const to = stateTo;\n const { from: nextFrom, to: nextTo } = adjustDates(from, to, 'from');\n\n onChange && onChange(nextFrom, nextTo);\n setDates({ from: nextFrom, to: nextTo });\n };\n\n const onChangeTo = (to: Date | null) => {\n const from = stateFrom;\n const { from: nextFrom, to: nextTo } = adjustDates(from, to, 'to');\n\n onChange && onChange(nextFrom, nextTo);\n setDates({ from: nextFrom, to: nextTo });\n };\n\n const from = isControlled ? controlledFrom : stateFrom;\n const to = isControlled ? controlledTo : stateTo;\n\n const contextValue: RangeDatePickerContextProps = {\n rangeDatePickerRef,\n innerHasFocus,\n setInnerHasFocus,\n minDate,\n maxDate,\n from,\n to,\n dayNames,\n monthNames,\n onChangeFrom,\n onChangeTo,\n };\n\n return (\n <RangeDatePickerProvider value={contextValue}>\n <Comp\n ref={assignMultipleRefs(ref, rangeDatePickerRef)}\n data-has-focus={innerHasFocus ? '' : undefined}\n {...rest}\n />\n </RangeDatePickerProvider>\n );\n }\n);\n"],"mappings":";;;;AACA,SAASA,UAAT,EAAqBC,MAArB,EAA6BC,QAA7B,QAA6C,OAA7C;AACA,SAASC,kBAAT,QAAmC,gBAAnC;AAGA,SAASC,WAAT,QAA4B,eAA5B;AAEA,SAASC,uBAAT,QAAwC,YAAxC;;AAmBA,OAAO,IAAMC,eAAe,gBAAGN,UAAU,CACvC,SAASM,eAAT,OAcEC,GAdF,EAeE;EAAA,mBAbEC,EAaF;EAAA,IAbMC,IAaN,wBAba,KAab;EAAA,wBAZEC,OAYF;EAAA,IAZWC,WAYX,6BAZyB,IAAIC,IAAJ,CAAS,CAAT,CAYzB;EAAA,wBAXEC,OAWF;EAAA,IAXWC,WAWX,6BAXyB,IAAIF,IAAJ,EAWzB;EAAA,IAVEG,QAUF,QAVEA,QAUF;EAAA,IATEC,UASF,QATEA,UASF;EAAA,IAREC,QAQF,QAREA,QAQF;EAAA,IAPQC,cAOR,QAPEC,IAOF;EAAA,IANMC,YAMN,QANEC,EAMF;EAAA,IALEC,WAKF,QALEA,WAKF;EAAA,IAJEC,SAIF,QAJEA,SAIF;EAAA,IAHKC,IAGL;;EACA,IAAMC,YAAY,GAChBP,cAAc,KAAKQ,SAAnB,IAAgCN,YAAY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EACD,CAND;;EAQA,IAAMhB,IAAI,GAAGM,YAAY,GAAGP,cAAH,GAAoBU,SAA7C;EACA,IAAMP,EAAE,GAAGI,YAAY,GAAGL,YAAH,GAAkBS,OAAzC;EAEA,IAAMQ,YAAyC,GAAG;IAChDV,kBAAkB,EAAlBA,kBADgD;IAEhDI,aAAa,EAAbA,aAFgD;IAGhDC,gBAAgB,EAAhBA,gBAHgD;IAIhDtB,OAAO,EAAPA,OAJgD;IAKhDG,OAAO,EAAPA,OALgD;IAMhDM,IAAI,EAAJA,IANgD;IAOhDE,EAAE,EAAFA,EAPgD;IAQhDN,QAAQ,EAARA,QARgD;IAShDC,UAAU,EAAVA,UATgD;IAUhDiB,YAAY,EAAZA,YAVgD;IAWhDG,UAAU,EAAVA;EAXgD,CAAlD;EAcA,oBACE,KAAC,uBAAD;IAAyB,KAAK,EAAEC,YAAhC;IAAA,uBACE,KAAC,IAAD;MACE,GAAG,EAAElC,kBAAkB,CAACI,GAAD,EAAMoB,kBAAN,CADzB;MAEE,kBAAgBI,aAAa,GAAG,EAAH,GAAQL;IAFvC,GAGMF,IAHN;EADF,EADF;AASD,CAxEsC,CAAlC"}
@@ -1,4 +1,4 @@
1
- export declare function adjustDates(from: Date | null, to: Date | null, frozenParam: 'from' | 'to'): {
2
- from: Date | null;
3
- to: Date | null;
4
- };
1
+ export declare function adjustDates(from: Date | null, to: Date | null, frozenParam: 'from' | 'to'): {
2
+ from: Date | null;
3
+ to: Date | null;
4
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"adjustDates.js","names":["addDays","isValid","differenceInDays","adjustDates","from","to","frozenParam"],"sources":["../../../src/DatePicker/adjustDates.ts"],"sourcesContent":["import { addDays, isValid, differenceInDays } from 'date-fns';\r\n\r\nexport function adjustDates(\r\n from: Date | null,\r\n to: Date | null,\r\n frozenParam: 'from' | 'to'\r\n) {\r\n if (to && isValid(to) && from && isValid(from)) {\r\n if (differenceInDays(to, from) < 1) {\r\n if (frozenParam === 'from') {\r\n to = addDays(from, 1); // add one day\r\n } else {\r\n from = addDays(from, -1); // remove one day\r\n }\r\n }\r\n }\r\n\r\n return { from, to };\r\n}\r\n"],"mappings":"AAAA,SAASA,OAAT,EAAkBC,OAAlB,EAA2BC,gBAA3B,QAAmD,UAAnD;AAEA,OAAO,SAASC,WAAT,CACLC,IADK,EAELC,EAFK,EAGLC,WAHK,EAIL;EACA,IAAID,EAAE,IAAIJ,OAAO,CAACI,EAAD,CAAb,IAAqBD,IAArB,IAA6BH,OAAO,CAACG,IAAD,CAAxC,EAAgD;IAC9C,IAAIF,gBAAgB,CAACG,EAAD,EAAKD,IAAL,CAAhB,GAA6B,CAAjC,EAAoC;MAClC,IAAIE,WAAW,KAAK,MAApB,EAA4B;QAC1BD,EAAE,GAAGL,OAAO,CAACI,IAAD,EAAO,CAAP,CAAZ,CAD0B,CACH;MACxB,CAFD,MAEO;QACLA,IAAI,GAAGJ,OAAO,CAACI,IAAD,EAAO,CAAC,CAAR,CAAd,CADK,CACqB;MAC3B;IACF;EACF;;EAED,OAAO;IAAEA,IAAI,EAAJA,IAAF;IAAQC,EAAE,EAAFA;EAAR,CAAP;AACD"}
1
+ {"version":3,"file":"adjustDates.js","names":["addDays","isValid","differenceInDays","adjustDates","from","to","frozenParam"],"sources":["../../../src/DatePicker/adjustDates.ts"],"sourcesContent":["import { addDays, isValid, differenceInDays } from 'date-fns';\n\nexport function adjustDates(\n from: Date | null,\n to: Date | null,\n frozenParam: 'from' | 'to'\n) {\n if (to && isValid(to) && from && isValid(from)) {\n if (differenceInDays(to, from) < 1) {\n if (frozenParam === 'from') {\n to = addDays(from, 1); // add one day\n } else {\n from = addDays(from, -1); // remove one day\n }\n }\n }\n\n return { from, to };\n}\n"],"mappings":"AAAA,SAASA,OAAT,EAAkBC,OAAlB,EAA2BC,gBAA3B,QAAmD,UAAnD;AAEA,OAAO,SAASC,WAAT,CACLC,IADK,EAELC,EAFK,EAGLC,WAHK,EAIL;EACA,IAAID,EAAE,IAAIJ,OAAO,CAACI,EAAD,CAAb,IAAqBD,IAArB,IAA6BH,OAAO,CAACG,IAAD,CAAxC,EAAgD;IAC9C,IAAIF,gBAAgB,CAACG,EAAD,EAAKD,IAAL,CAAhB,GAA6B,CAAjC,EAAoC;MAClC,IAAIE,WAAW,KAAK,MAApB,EAA4B;QAC1BD,EAAE,GAAGL,OAAO,CAACI,IAAD,EAAO,CAAP,CAAZ,CAD0B,CACH;MACxB,CAFD,MAEO;QACLA,IAAI,GAAGJ,OAAO,CAACI,IAAD,EAAO,CAAC,CAAR,CAAd,CADK,CACqB;MAC3B;IACF;EACF;;EAED,OAAO;IAAEA,IAAI,EAAJA,IAAF;IAAQC,EAAE,EAAFA;EAAR,CAAP;AACD"}
@@ -1,31 +1,31 @@
1
- import type { MutableRefObject } from 'react';
2
- import type { MonthNames, DayNames } from './dateTypes';
3
- import type { ReducerState, ReducerActions } from './hooks';
4
- export interface RangeDatePickerContextProps {
5
- rangeDatePickerRef: MutableRefObject<HTMLDivElement | null>;
6
- innerHasFocus: boolean;
7
- setInnerHasFocus: (hasFocus: boolean) => void;
8
- minDate: Date;
9
- maxDate: Date;
10
- from?: Date | null;
11
- to?: Date | null;
12
- onChangeFrom: (d: Date | null) => void;
13
- onChangeTo: (d: Date | null) => void;
14
- dayNames: DayNames;
15
- monthNames: MonthNames;
16
- }
17
- export declare const RangeDatePickerProvider: import("react").Provider<RangeDatePickerContextProps | null>;
18
- export declare const useRangeDatePickerContext: () => RangeDatePickerContextProps | null;
19
- export interface DatePickerContextProps {
20
- minDate: Date;
21
- maxDate: Date;
22
- dayNames: DayNames;
23
- monthNames: MonthNames;
24
- datePickerRef: MutableRefObject<HTMLDivElement | null>;
25
- state: ReducerState;
26
- dispatch: (value: ReducerActions) => void;
27
- controlledValueRef: MutableRefObject<Date | null | undefined>;
28
- onChangeRef: MutableRefObject<((from: Date | null) => void) | undefined>;
29
- }
30
- export declare const useDatePickerContext: () => DatePickerContextProps;
31
- export declare const DatePickerProvider: import("react").Provider<DatePickerContextProps>;
1
+ import type { MutableRefObject } from 'react';
2
+ import type { MonthNames, DayNames } from './dateTypes';
3
+ import type { ReducerState, ReducerActions } from './hooks';
4
+ export interface RangeDatePickerContextProps {
5
+ rangeDatePickerRef: MutableRefObject<HTMLDivElement | null>;
6
+ innerHasFocus: boolean;
7
+ setInnerHasFocus: (hasFocus: boolean) => void;
8
+ minDate: Date;
9
+ maxDate: Date;
10
+ from?: Date | null;
11
+ to?: Date | null;
12
+ onChangeFrom: (d: Date | null) => void;
13
+ onChangeTo: (d: Date | null) => void;
14
+ dayNames: DayNames;
15
+ monthNames: MonthNames;
16
+ }
17
+ export declare const RangeDatePickerProvider: import("react").Provider<RangeDatePickerContextProps | null>;
18
+ export declare const useRangeDatePickerContext: () => RangeDatePickerContextProps | null;
19
+ export interface DatePickerContextProps {
20
+ minDate: Date;
21
+ maxDate: Date;
22
+ dayNames: DayNames;
23
+ monthNames: MonthNames;
24
+ datePickerRef: MutableRefObject<HTMLDivElement | null>;
25
+ state: ReducerState;
26
+ dispatch: (value: ReducerActions) => void;
27
+ controlledValueRef: MutableRefObject<Date | null | undefined>;
28
+ onChangeRef: MutableRefObject<((from: Date | null) => void) | undefined>;
29
+ }
30
+ export declare const useDatePickerContext: () => DatePickerContextProps;
31
+ export declare const DatePickerProvider: import("react").Provider<DatePickerContextProps>;
@@ -1 +1 @@
1
- {"version":3,"file":"contexts.js","names":["createContext","useContext","rangeContext","RangeDatePickerProvider","Provider","useRangeDatePickerContext","datePickerContext","useDatePickerContext","DatePickerProvider"],"sources":["../../../src/DatePicker/contexts.ts"],"sourcesContent":["import type { MutableRefObject } from 'react';\r\nimport { createContext, useContext } from 'react';\r\n\r\nimport type { MonthNames, DayNames } from './dateTypes';\r\nimport type { ReducerState, ReducerActions } from './hooks';\r\n\r\n// RangeDatePicker\r\nexport interface RangeDatePickerContextProps {\r\n rangeDatePickerRef: MutableRefObject<HTMLDivElement | null>;\r\n innerHasFocus: boolean;\r\n setInnerHasFocus: (hasFocus: boolean) => void;\r\n minDate: Date;\r\n maxDate: Date;\r\n from?: Date | null;\r\n to?: Date | null;\r\n onChangeFrom: (d: Date | null) => void;\r\n onChangeTo: (d: Date | null) => void;\r\n dayNames: DayNames;\r\n monthNames: MonthNames;\r\n}\r\n\r\nconst rangeContext = createContext<RangeDatePickerContextProps | null>(null);\r\nexport const { Provider: RangeDatePickerProvider } = rangeContext;\r\nexport const useRangeDatePickerContext = () => useContext(rangeContext);\r\n\r\n// DatePicker\r\nexport interface DatePickerContextProps {\r\n minDate: Date;\r\n maxDate: Date;\r\n dayNames: DayNames;\r\n monthNames: MonthNames;\r\n datePickerRef: MutableRefObject<HTMLDivElement | null>;\r\n state: ReducerState;\r\n dispatch: (value: ReducerActions) => void;\r\n controlledValueRef: MutableRefObject<Date | null | undefined>;\r\n onChangeRef: MutableRefObject<((from: Date | null) => void) | undefined>;\r\n}\r\nconst datePickerContext = createContext<DatePickerContextProps>(null as any);\r\nexport const useDatePickerContext = () => useContext(datePickerContext);\r\nexport const { Provider: DatePickerProvider } = datePickerContext;\r\n"],"mappings":"AACA,SAASA,aAAT,EAAwBC,UAAxB,QAA0C,OAA1C;AAoBA,IAAMC,YAAY,gBAAGF,aAAa,CAAqC,IAArC,CAAlC;AACO,IAAkBG,uBAAlB,GAA8CD,YAA9C,CAAQE,QAAR;;AACP,OAAO,IAAMC,yBAAyB,GAAG,SAA5BA,yBAA4B;EAAA,OAAMJ,UAAU,CAACC,YAAD,CAAhB;AAAA,CAAlC,C,CAEP;;AAYA,IAAMI,iBAAiB,gBAAGN,aAAa,CAAyB,IAAzB,CAAvC;AACA,OAAO,IAAMO,oBAAoB,GAAG,SAAvBA,oBAAuB;EAAA,OAAMN,UAAU,CAACK,iBAAD,CAAhB;AAAA,CAA7B;AACA,IAAkBE,kBAAlB,GAAyCF,iBAAzC,CAAQF,QAAR"}
1
+ {"version":3,"file":"contexts.js","names":["createContext","useContext","rangeContext","RangeDatePickerProvider","Provider","useRangeDatePickerContext","datePickerContext","useDatePickerContext","DatePickerProvider"],"sources":["../../../src/DatePicker/contexts.ts"],"sourcesContent":["import type { MutableRefObject } from 'react';\nimport { createContext, useContext } from 'react';\n\nimport type { MonthNames, DayNames } from './dateTypes';\nimport type { ReducerState, ReducerActions } from './hooks';\n\n// RangeDatePicker\nexport interface RangeDatePickerContextProps {\n rangeDatePickerRef: MutableRefObject<HTMLDivElement | null>;\n innerHasFocus: boolean;\n setInnerHasFocus: (hasFocus: boolean) => void;\n minDate: Date;\n maxDate: Date;\n from?: Date | null;\n to?: Date | null;\n onChangeFrom: (d: Date | null) => void;\n onChangeTo: (d: Date | null) => void;\n dayNames: DayNames;\n monthNames: MonthNames;\n}\n\nconst rangeContext = createContext<RangeDatePickerContextProps | null>(null);\nexport const { Provider: RangeDatePickerProvider } = rangeContext;\nexport const useRangeDatePickerContext = () => useContext(rangeContext);\n\n// DatePicker\nexport interface DatePickerContextProps {\n minDate: Date;\n maxDate: Date;\n dayNames: DayNames;\n monthNames: MonthNames;\n datePickerRef: MutableRefObject<HTMLDivElement | null>;\n state: ReducerState;\n dispatch: (value: ReducerActions) => void;\n controlledValueRef: MutableRefObject<Date | null | undefined>;\n onChangeRef: MutableRefObject<((from: Date | null) => void) | undefined>;\n}\nconst datePickerContext = createContext<DatePickerContextProps>(null as any);\nexport const useDatePickerContext = () => useContext(datePickerContext);\nexport const { Provider: DatePickerProvider } = datePickerContext;\n"],"mappings":"AACA,SAASA,aAAT,EAAwBC,UAAxB,QAA0C,OAA1C;AAoBA,IAAMC,YAAY,gBAAGF,aAAa,CAAqC,IAArC,CAAlC;AACO,IAAkBG,uBAAlB,GAA8CD,YAA9C,CAAQE,QAAR;;AACP,OAAO,IAAMC,yBAAyB,GAAG,SAA5BA,yBAA4B;EAAA,OAAMJ,UAAU,CAACC,YAAD,CAAhB;AAAA,CAAlC,C,CAEP;;AAYA,IAAMI,iBAAiB,gBAAGN,aAAa,CAAyB,IAAzB,CAAvC;AACA,OAAO,IAAMO,oBAAoB,GAAG,SAAvBA,oBAAuB;EAAA,OAAMN,UAAU,CAACK,iBAAD,CAAhB;AAAA,CAA7B;AACA,IAAkBE,kBAAlB,GAAyCF,iBAAzC,CAAQF,QAAR"}
@@ -1,15 +1,15 @@
1
- export declare type DayNames = [string, string, string, string, string, string, string];
2
- export declare type MonthNames = [
3
- string,
4
- string,
5
- string,
6
- string,
7
- string,
8
- string,
9
- string,
10
- string,
11
- string,
12
- string,
13
- string,
14
- string
15
- ];
1
+ export declare type DayNames = [string, string, string, string, string, string, string];
2
+ export declare type MonthNames = [
3
+ string,
4
+ string,
5
+ string,
6
+ string,
7
+ string,
8
+ string,
9
+ string,
10
+ string,
11
+ string,
12
+ string,
13
+ string,
14
+ string
15
+ ];
@@ -1 +1 @@
1
- {"version":3,"file":"dateTypes.js","names":[],"sources":["../../../src/DatePicker/dateTypes.ts"],"sourcesContent":["export type DayNames = [string, string, string, string, string, string, string];\r\n\r\nexport type MonthNames = [\r\n string,\r\n string,\r\n string,\r\n string,\r\n string,\r\n string,\r\n string,\r\n string,\r\n string,\r\n string,\r\n string,\r\n string\r\n];\r\n"],"mappings":""}
1
+ {"version":3,"file":"dateTypes.js","names":[],"sources":["../../../src/DatePicker/dateTypes.ts"],"sourcesContent":["export type DayNames = [string, string, string, string, string, string, string];\n\nexport type MonthNames = [\n string,\n string,\n string,\n string,\n string,\n string,\n string,\n string,\n string,\n string,\n string,\n string\n];\n"],"mappings":""}
@@ -1,36 +1,36 @@
1
- export declare const FOCUS = "FOCUS";
2
- export declare const BLUR = "BLUR";
3
- export declare const NAVIGATE = "NAVIGATE";
4
- export declare const SET_DATE = "SET_DATE";
5
- export declare type ActionTypes = typeof FOCUS | typeof BLUR | typeof NAVIGATE | typeof SET_DATE;
6
- export interface ReducerState {
7
- isFocused: boolean;
8
- navigationYear: number;
9
- navigationMonth: number;
10
- navigationDay: number;
11
- selectedDate: Date | null;
12
- }
13
- interface FocusAction {
14
- type: typeof FOCUS;
15
- }
16
- interface NavigateAction {
17
- type: typeof NAVIGATE;
18
- year: number;
19
- month: number;
20
- day: number;
21
- }
22
- interface SetDateAction {
23
- type: typeof SET_DATE;
24
- selectedDate: Date | null;
25
- }
26
- interface BlurAction {
27
- type: typeof BLUR;
28
- selectedDate: Date | null;
29
- }
30
- export declare type ReducerActions = FocusAction | BlurAction | NavigateAction | SetDateAction;
31
- export declare function reducer(currentState: Readonly<ReducerState>, action: ReducerActions): ReducerState;
32
- export declare function useInnerFocus(): {
33
- handleFocus: () => void;
34
- handleBlur: () => void;
35
- };
36
- export {};
1
+ export declare const FOCUS = "FOCUS";
2
+ export declare const BLUR = "BLUR";
3
+ export declare const NAVIGATE = "NAVIGATE";
4
+ export declare const SET_DATE = "SET_DATE";
5
+ export declare type ActionTypes = typeof FOCUS | typeof BLUR | typeof NAVIGATE | typeof SET_DATE;
6
+ export interface ReducerState {
7
+ isFocused: boolean;
8
+ navigationYear: number;
9
+ navigationMonth: number;
10
+ navigationDay: number;
11
+ selectedDate: Date | null;
12
+ }
13
+ interface FocusAction {
14
+ type: typeof FOCUS;
15
+ }
16
+ interface NavigateAction {
17
+ type: typeof NAVIGATE;
18
+ year: number;
19
+ month: number;
20
+ day: number;
21
+ }
22
+ interface SetDateAction {
23
+ type: typeof SET_DATE;
24
+ selectedDate: Date | null;
25
+ }
26
+ interface BlurAction {
27
+ type: typeof BLUR;
28
+ selectedDate: Date | null;
29
+ }
30
+ export declare type ReducerActions = FocusAction | BlurAction | NavigateAction | SetDateAction;
31
+ export declare function reducer(currentState: Readonly<ReducerState>, action: ReducerActions): ReducerState;
32
+ export declare function useInnerFocus(): {
33
+ handleFocus: () => void;
34
+ handleBlur: () => void;
35
+ };
36
+ export {};
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.js","names":["useRangeDatePickerContext","useDatePickerContext","FOCUS","BLUR","NAVIGATE","SET_DATE","reducer","currentState","action","type","isFocused","navigationYear","navigationMonth","navigationDay","selectedDate","year","month","day","useInnerFocus","dispatch","onChangeRef","datePickerRef","state","rangeCtx","handleFocus","setInnerHasFocus","handleBlur","requestAnimationFrame","current","contains","document","activeElement","rangeDatePickerRef"],"sources":["../../../src/DatePicker/hooks.tsx"],"sourcesContent":["import { useRangeDatePickerContext, useDatePickerContext } from './contexts';\r\n\r\n////////////////////////////////////////////////////////////////////////////////\r\n// Actions\r\n\r\nexport const FOCUS = 'FOCUS';\r\n\r\nexport const BLUR = 'BLUR';\r\n\r\nexport const NAVIGATE = 'NAVIGATE';\r\n\r\nexport const SET_DATE = 'SET_DATE';\r\n\r\nexport type ActionTypes =\r\n | typeof FOCUS\r\n | typeof BLUR\r\n | typeof NAVIGATE\r\n | typeof SET_DATE;\r\n\r\n////////////////////////////////////////////////////////////////////////////////\r\n// Reducer\r\n\r\nexport interface ReducerState {\r\n isFocused: boolean;\r\n navigationYear: number;\r\n navigationMonth: number;\r\n navigationDay: number;\r\n selectedDate: Date | null;\r\n}\r\n\r\ninterface FocusAction {\r\n type: typeof FOCUS;\r\n}\r\n\r\ninterface NavigateAction {\r\n type: typeof NAVIGATE;\r\n year: number;\r\n month: number;\r\n day: number;\r\n}\r\ninterface SetDateAction {\r\n type: typeof SET_DATE;\r\n selectedDate: Date | null;\r\n}\r\n\r\ninterface BlurAction {\r\n type: typeof BLUR;\r\n selectedDate: Date | null;\r\n}\r\n\r\nexport type ReducerActions =\r\n | FocusAction\r\n | BlurAction\r\n | NavigateAction\r\n | SetDateAction;\r\n\r\nexport function reducer(\r\n currentState: Readonly<ReducerState>,\r\n action: ReducerActions\r\n): ReducerState {\r\n switch (action.type) {\r\n case FOCUS:\r\n return {\r\n ...currentState,\r\n isFocused: true,\r\n };\r\n case BLUR:\r\n return {\r\n ...currentState,\r\n navigationYear: -1,\r\n navigationMonth: -1,\r\n navigationDay: -1,\r\n selectedDate: action.selectedDate,\r\n isFocused: false,\r\n };\r\n case NAVIGATE:\r\n return {\r\n ...currentState,\r\n navigationYear: action.year,\r\n navigationMonth: action.month,\r\n navigationDay: action.day,\r\n };\r\n case SET_DATE: {\r\n return {\r\n ...currentState,\r\n navigationYear: -1,\r\n navigationMonth: -1,\r\n navigationDay: -1,\r\n selectedDate: action.selectedDate,\r\n };\r\n }\r\n }\r\n}\r\n\r\n////////////////////////////////////////////////////////////////////////////////\r\n// Hooks\r\n\r\nexport function useInnerFocus() {\r\n const {\r\n dispatch,\r\n onChangeRef,\r\n datePickerRef,\r\n state: { selectedDate, navigationMonth, navigationYear, navigationDay },\r\n } = useDatePickerContext();\r\n const rangeCtx = useRangeDatePickerContext();\r\n\r\n const handleFocus = () => {\r\n dispatch({ type: FOCUS });\r\n if (rangeCtx) {\r\n rangeCtx.setInnerHasFocus(true);\r\n }\r\n };\r\n\r\n const handleBlur = () => {\r\n requestAnimationFrame(() => {\r\n // we on want to close only if focus rests outside the datepicker\r\n if (\r\n datePickerRef.current &&\r\n !datePickerRef.current.contains(document.activeElement)\r\n ) {\r\n if (\r\n selectedDate &&\r\n navigationYear >= 0 &&\r\n navigationMonth >= 0 &&\r\n navigationDay === -1\r\n ) {\r\n // user started picking a new day, but haven't finished :(\r\n onChangeRef.current && onChangeRef.current(null);\r\n dispatch({ type: BLUR, selectedDate: null });\r\n } else {\r\n dispatch({ type: BLUR, selectedDate });\r\n }\r\n }\r\n\r\n if (\r\n rangeCtx &&\r\n rangeCtx.rangeDatePickerRef.current &&\r\n !rangeCtx.rangeDatePickerRef.current.contains(document.activeElement)\r\n ) {\r\n rangeCtx.setInnerHasFocus(false);\r\n }\r\n });\r\n };\r\n\r\n return { handleFocus, handleBlur };\r\n}\r\n"],"mappings":";AAAA,SAASA,yBAAT,EAAoCC,oBAApC,QAAgE,YAAhE,C,CAEA;AACA;;AAEA,OAAO,IAAMC,KAAK,GAAG,OAAd;AAEP,OAAO,IAAMC,IAAI,GAAG,MAAb;AAEP,OAAO,IAAMC,QAAQ,GAAG,UAAjB;AAEP,OAAO,IAAMC,QAAQ,GAAG,UAAjB;AA6CP,OAAO,SAASC,OAAT,CACLC,Y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AA1B;IACD;EACF,CALD;;EAOA,IAAMC,UAAU,GAAG,SAAbA,UAAa,GAAM;IACvBC,qBAAqB,CAAC,YAAM;MAC1B;MACA,IACEN,aAAa,CAACO,OAAd,IACA,CAACP,aAAa,CAACO,OAAd,CAAsBC,QAAtB,CAA+BC,QAAQ,CAACC,aAAxC,CAFH,EAGE;QACA,IACEjB,YAAY,IACZH,cAAc,IAAI,CADlB,IAEAC,eAAe,IAAI,CAFnB,IAGAC,aAAa,KAAK,CAAC,CAJrB,EAKE;UACA;UACAO,WAAW,CAACQ,OAAZ,IAAuBR,WAAW,CAACQ,OAAZ,CAAoB,IAApB,CAAvB;UACAT,QAAQ,CAAC;YAAEV,IAAI,EAAEN,IAAR;YAAcW,YAAY,EAAE;UAA5B,CAAD,CAAR;QACD,CATD,MASO;UACLK,QAAQ,CAAC;YAAEV,IAAI,EAAEN,IAAR;YAAcW,YAAY,EAAZA;UAAd,CAAD,CAAR;QACD;MACF;;MAED,IACES,QAAQ,IACRA,QAAQ,CAACS,kBAAT,CAA4BJ,OAD5B,IAEA,CAACL,QAAQ,CAACS,kBAAT,CAA4BJ,OAA5B,CAAoCC,QAApC,CAA6CC,QAAQ,CAACC,aAAtD,CAHH,EAIE;QACAR,QAAQ,CAACE,gBAAT,CAA0B,KAA1B;MACD;IACF,CA3BoB,CAArB;EA4BD,CA7BD;;EA+BA,OAAO;IAAED,WAAW,EAAXA,WAAF;IAAeE,UAAU,EAAVA;EAAf,CAAP;AACD"}
1
+ {"version":3,"file":"hooks.js","names":["useRangeDatePickerContext","useDatePickerContext","FOCUS","BLUR","NAVIGATE","SET_DATE","reducer","currentState","action","type","isFocused","navigationYear","navigationMonth","navigationDay","selectedDate","year","month","day","useInnerFocus","dispatch","onChangeRef","datePickerRef","state","rangeCtx","handleFocus","setInnerHasFocus","handleBlur","requestAnimationFrame","current","contains","document","activeElement","rangeDatePickerRef"],"sources":["../../../src/DatePicker/hooks.tsx"],"sourcesContent":["import { useRangeDatePickerContext, useDatePickerContext } from './contexts';\n\n////////////////////////////////////////////////////////////////////////////////\n// Actions\n\nexport const FOCUS = 'FOCUS';\n\nexport const BLUR = 'BLUR';\n\nexport const NAVIGATE = 'NAVIGATE';\n\nexport const SET_DATE = 'SET_DATE';\n\nexport type ActionTypes =\n | typeof FOCUS\n | typeof BLUR\n | typeof NAVIGATE\n | typeof SET_DATE;\n\n////////////////////////////////////////////////////////////////////////////////\n// Reducer\n\nexport interface ReducerState {\n isFocused: boolean;\n navigationYear: number;\n navigationMonth: number;\n navigationDay: number;\n selectedDate: Date | null;\n}\n\ninterface FocusAction {\n type: typeof FOCUS;\n}\n\ninterface NavigateAction {\n type: typeof NAVIGATE;\n year: number;\n month: number;\n day: number;\n}\ninterface SetDateAction {\n type: typeof SET_DATE;\n selectedDate: Date | null;\n}\n\ninterface BlurAction {\n type: typeof BLUR;\n selectedDate: Date | null;\n}\n\nexport type ReducerActions =\n | FocusAction\n | BlurAction\n | NavigateAction\n | SetDateAction;\n\nexport function reducer(\n currentState: Readonly<ReducerState>,\n action: ReducerActions\n): ReducerState {\n switch (action.type) {\n case FOCUS:\n return {\n ...currentState,\n isFocused: true,\n };\n case BLUR:\n return {\n ...currentState,\n navigationYear: -1,\n navigationMonth: -1,\n navigationDay: -1,\n selectedDate: action.selectedDate,\n isFocused: false,\n };\n case NAVIGATE:\n return {\n ...currentState,\n navigationYear: action.year,\n navigationMonth: action.month,\n navigationDay: action.day,\n };\n case SET_DATE: {\n return {\n ...currentState,\n navigationYear: -1,\n navigationMonth: -1,\n navigationDay: -1,\n selectedDate: action.selectedDate,\n };\n }\n }\n}\n\n////////////////////////////////////////////////////////////////////////////////\n// Hooks\n\nexport function useInnerFocus() {\n const {\n dispatch,\n onChangeRef,\n datePickerRef,\n state: { selectedDate, navigationMonth, navigationYear, navigationDay },\n } = useDatePickerContext();\n const rangeCtx = useRangeDatePickerContext();\n\n const handleFocus = () => {\n dispatch({ type: FOCUS });\n if (rangeCtx) {\n rangeCtx.setInnerHasFocus(true);\n }\n };\n\n const handleBlur = () => {\n requestAnimationFrame(() => {\n // we on want to close only if focus rests outside the datepicker\n if (\n datePickerRef.current &&\n !datePickerRef.current.contains(document.activeElement)\n ) {\n if (\n selectedDate &&\n navigationYear >= 0 &&\n navigationMonth >= 0 &&\n navigationDay === -1\n ) {\n // user started picking a new day, but haven't finished :(\n onChangeRef.current && onChangeRef.current(null);\n dispatch({ type: BLUR, selectedDate: null });\n } else {\n dispatch({ type: BLUR, selectedDate });\n }\n }\n\n if (\n rangeCtx &&\n rangeCtx.rangeDatePickerRef.current &&\n !rangeCtx.rangeDatePickerRef.current.contains(document.activeElement)\n ) {\n rangeCtx.setInnerHasFocus(false);\n }\n });\n };\n\n return { handleFocus, handleBlur };\n}\n"],"mappings":";AAAA,SAASA,yBAAT,EAAoCC,oBAApC,QAAgE,YAAhE,C,CAEA;AACA;;AAEA,OAAO,IAAMC,KAAK,GAAG,OAAd;AAEP,OAAO,IAAMC,IAAI,GAAG,MAAb;AAEP,OAAO,IAAMC,QAAQ,GAAG,UAAjB;AAEP,OAAO,IAAMC,QAAQ,GAAG,UAAjB;AA6CP,OAAO,SAASC,OAAT,CACLC,YADK,EAELC,MAFK,EAGS;EACd,QAAQA,MAAM,CAACC,IAAf;IACE,KAAKP,KAAL;MACE,6BACKK,YADL;QAEEG,SAAS,EAAE;MAFb;;IAIF,KAAKP,IAAL;MACE,6BACKI,YADL;QAEEI,cAAc,EAAE,CAAC,CAFnB;QAGEC,eAAe,EAAE,CAAC,CAHpB;QAIEC,aAAa,EAAE,CAAC,CAJlB;QAKEC,YAAY,EAAEN,MAAM,CAACM,YALvB;QAMEJ,SAAS,EAAE;MANb;;IAQF,KAAKN,QAAL;MACE,6BACKG,YADL;QAEEI,cAAc,EAAEH,MAAM,CAACO,IAFzB;QAGEH,eAAe,EAAEJ,MAAM,CAACQ,KAH1B;QAIEH,aAAa,EAAEL,MAAM,CAACS;MAJxB;;IAMF,KAAKZ,QAAL;MAAe;QACb,6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ACLK,QAAQ,CAAC;YAAEV,IAAI,EAAEN,IAAR;YAAcW,YAAY,EAAZA;UAAd,CAAD,CAAR;QACD;MACF;;MAED,IACES,QAAQ,IACRA,QAAQ,CAACS,kBAAT,CAA4BJ,OAD5B,IAEA,CAACL,QAAQ,CAACS,kBAAT,CAA4BJ,OAA5B,CAAoCC,QAApC,CAA6CC,QAAQ,CAACC,aAAtD,CAHH,EAIE;QACAR,QAAQ,CAACE,gBAAT,CAA0B,KAA1B;MACD;IACF,CA3BoB,CAArB;EA4BD,CA7BD;;EA+BA,OAAO;IAAED,WAAW,EAAXA,WAAF;IAAeE,UAAU,EAAVA;EAAf,CAAP;AACD"}
@@ -1,5 +1,5 @@
1
- export * from './DatePicker';
2
- export * from './RangeDatePicker';
3
- export * from './DatePickerSelect';
4
- export * from './dateTypes';
5
- export * from './contexts';
1
+ export * from './DatePicker';
2
+ export * from './RangeDatePicker';
3
+ export * from './DatePickerSelect';
4
+ export * from './dateTypes';
5
+ export * from './contexts';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/DatePicker/index.tsx"],"sourcesContent":["export * from './DatePicker';\r\nexport * from './RangeDatePicker';\r\nexport * from './DatePickerSelect';\r\nexport * from './dateTypes';\r\nexport * from './contexts';\r\n"],"mappings":"AAAA,cAAc,cAAd;AACA,cAAc,mBAAd;AACA,cAAc,oBAAd;AACA,cAAc,aAAd;AACA,cAAc,YAAd"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/DatePicker/index.tsx"],"sourcesContent":["export * from './DatePicker';\nexport * from './RangeDatePicker';\nexport * from './DatePickerSelect';\nexport * from './dateTypes';\nexport * from './contexts';\n"],"mappings":"AAAA,cAAc,cAAd;AACA,cAAc,mBAAd;AACA,cAAc,oBAAd;AACA,cAAc,aAAd;AACA,cAAc,YAAd"}
@@ -1 +1 @@
1
- export * from './DatePicker';
1
+ export * from './DatePicker';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["export * from './DatePicker';\r\n"],"mappings":"AAAA,cAAc,cAAd"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["export * from './DatePicker';\n"],"mappings":"AAAA,cAAc,cAAd"}