@refraktor/dates 0.0.1
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/.turbo/turbo-build.log +4 -0
- package/LICENSE +21 -0
- package/README.md +21 -0
- package/build/components/date-input/date-input.d.ts +4 -0
- package/build/components/date-input/date-input.d.ts.map +1 -0
- package/build/components/date-input/date-input.js +164 -0
- package/build/components/date-input/date-input.types.d.ts +96 -0
- package/build/components/date-input/date-input.types.d.ts.map +1 -0
- package/build/components/date-input/date-input.types.js +1 -0
- package/build/components/date-input/index.d.ts +3 -0
- package/build/components/date-input/index.d.ts.map +1 -0
- package/build/components/date-input/index.js +1 -0
- package/build/components/date-picker/date-picker.d.ts +4 -0
- package/build/components/date-picker/date-picker.d.ts.map +1 -0
- package/build/components/date-picker/date-picker.js +307 -0
- package/build/components/date-picker/date-picker.types.d.ts +86 -0
- package/build/components/date-picker/date-picker.types.d.ts.map +1 -0
- package/build/components/date-picker/date-picker.types.js +1 -0
- package/build/components/date-picker/index.d.ts +3 -0
- package/build/components/date-picker/index.d.ts.map +1 -0
- package/build/components/date-picker/index.js +1 -0
- package/build/components/dates-provider/context.d.ts +4 -0
- package/build/components/dates-provider/context.d.ts.map +1 -0
- package/build/components/dates-provider/context.js +10 -0
- package/build/components/dates-provider/dates-provider.d.ts +7 -0
- package/build/components/dates-provider/dates-provider.d.ts.map +1 -0
- package/build/components/dates-provider/dates-provider.js +65 -0
- package/build/components/dates-provider/index.d.ts +5 -0
- package/build/components/dates-provider/index.d.ts.map +1 -0
- package/build/components/dates-provider/index.js +3 -0
- package/build/components/dates-provider/types.d.ts +26 -0
- package/build/components/dates-provider/types.d.ts.map +1 -0
- package/build/components/dates-provider/types.js +1 -0
- package/build/components/dates-provider/use-dates.d.ts +2 -0
- package/build/components/dates-provider/use-dates.d.ts.map +1 -0
- package/build/components/dates-provider/use-dates.js +4 -0
- package/build/components/index.d.ts +8 -0
- package/build/components/index.d.ts.map +1 -0
- package/build/components/index.js +7 -0
- package/build/components/month-input/index.d.ts +3 -0
- package/build/components/month-input/index.d.ts.map +1 -0
- package/build/components/month-input/index.js +1 -0
- package/build/components/month-input/month-input.d.ts +4 -0
- package/build/components/month-input/month-input.d.ts.map +1 -0
- package/build/components/month-input/month-input.js +161 -0
- package/build/components/month-input/month-input.types.d.ts +85 -0
- package/build/components/month-input/month-input.types.d.ts.map +1 -0
- package/build/components/month-input/month-input.types.js +1 -0
- package/build/components/month-picker/index.d.ts +3 -0
- package/build/components/month-picker/index.d.ts.map +1 -0
- package/build/components/month-picker/index.js +1 -0
- package/build/components/month-picker/month-picker.d.ts +4 -0
- package/build/components/month-picker/month-picker.d.ts.map +1 -0
- package/build/components/month-picker/month-picker.js +229 -0
- package/build/components/month-picker/month-picker.types.d.ts +69 -0
- package/build/components/month-picker/month-picker.types.d.ts.map +1 -0
- package/build/components/month-picker/month-picker.types.js +1 -0
- package/build/components/picker-shared/index.d.ts +5 -0
- package/build/components/picker-shared/index.d.ts.map +1 -0
- package/build/components/picker-shared/index.js +2 -0
- package/build/components/picker-shared/picker-header.d.ts +4 -0
- package/build/components/picker-shared/picker-header.d.ts.map +1 -0
- package/build/components/picker-shared/picker-header.js +27 -0
- package/build/components/picker-shared/picker-header.types.d.ts +36 -0
- package/build/components/picker-shared/picker-header.types.d.ts.map +1 -0
- package/build/components/picker-shared/picker-header.types.js +1 -0
- package/build/components/picker-shared/picker.styles.d.ts +12 -0
- package/build/components/picker-shared/picker.styles.d.ts.map +1 -0
- package/build/components/picker-shared/picker.styles.js +53 -0
- package/build/components/picker-shared/picker.types.d.ts +4 -0
- package/build/components/picker-shared/picker.types.d.ts.map +1 -0
- package/build/components/picker-shared/picker.types.js +1 -0
- package/build/components/year-input/index.d.ts +3 -0
- package/build/components/year-input/index.d.ts.map +1 -0
- package/build/components/year-input/index.js +1 -0
- package/build/components/year-input/year-input.d.ts +4 -0
- package/build/components/year-input/year-input.d.ts.map +1 -0
- package/build/components/year-input/year-input.js +157 -0
- package/build/components/year-input/year-input.types.d.ts +74 -0
- package/build/components/year-input/year-input.types.d.ts.map +1 -0
- package/build/components/year-input/year-input.types.js +1 -0
- package/build/components/year-picker/index.d.ts +3 -0
- package/build/components/year-picker/index.d.ts.map +1 -0
- package/build/components/year-picker/index.js +1 -0
- package/build/components/year-picker/year-picker.d.ts +4 -0
- package/build/components/year-picker/year-picker.d.ts.map +1 -0
- package/build/components/year-picker/year-picker.js +236 -0
- package/build/components/year-picker/year-picker.types.d.ts +70 -0
- package/build/components/year-picker/year-picker.types.d.ts.map +1 -0
- package/build/components/year-picker/year-picker.types.js +1 -0
- package/build/index.d.ts +3 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +2 -0
- package/build/style.css +2 -0
- package/package.json +38 -0
- package/refraktor-dates-0.0.1-alpha.0.tgz +0 -0
- package/src/components/date-input/date-input.tsx +376 -0
- package/src/components/date-input/date-input.types.ts +161 -0
- package/src/components/date-input/index.ts +13 -0
- package/src/components/date-picker/date-picker.tsx +649 -0
- package/src/components/date-picker/date-picker.types.ts +145 -0
- package/src/components/date-picker/index.ts +15 -0
- package/src/components/dates-provider/context.ts +18 -0
- package/src/components/dates-provider/dates-provider.tsx +136 -0
- package/src/components/dates-provider/index.ts +10 -0
- package/src/components/dates-provider/types.ts +33 -0
- package/src/components/dates-provider/use-dates.ts +5 -0
- package/src/components/index.ts +7 -0
- package/src/components/month-input/index.ts +13 -0
- package/src/components/month-input/month-input.tsx +363 -0
- package/src/components/month-input/month-input.types.ts +139 -0
- package/src/components/month-picker/index.ts +14 -0
- package/src/components/month-picker/month-picker.tsx +458 -0
- package/src/components/month-picker/month-picker.types.ts +117 -0
- package/src/components/picker-shared/index.ts +7 -0
- package/src/components/picker-shared/picker-header.tsx +178 -0
- package/src/components/picker-shared/picker-header.types.ts +49 -0
- package/src/components/picker-shared/picker.styles.ts +69 -0
- package/src/components/picker-shared/picker.types.ts +4 -0
- package/src/components/year-input/index.ts +13 -0
- package/src/components/year-input/year-input.tsx +347 -0
- package/src/components/year-input/year-input.types.ts +118 -0
- package/src/components/year-picker/index.ts +15 -0
- package/src/components/year-picker/year-picker.tsx +504 -0
- package/src/components/year-picker/year-picker.types.ts +108 -0
- package/src/index.ts +3 -0
- package/src/style.css +1 -0
- package/tsconfig.json +13 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
+
import { RefraktorRadius, RefraktorSize, createClassNamesConfig, createComponentConfig, FactoryPayload } from "@refraktor/core";
|
|
3
|
+
import type { MonthPickerGetHeaderLabel, MonthPickerGetMonthAriaLabel, MonthPickerGetMonthLabel, MonthPickerGetNavigationAriaLabel } from "../month-picker";
|
|
4
|
+
export type DatePickerValue = Date;
|
|
5
|
+
export type DatePickerSize = RefraktorSize;
|
|
6
|
+
export type DatePickerRadius = RefraktorRadius;
|
|
7
|
+
export type DatePickerNavigationDirection = "previous" | "next";
|
|
8
|
+
export type DatePickerOnChange = (value: DatePickerValue) => void;
|
|
9
|
+
export type DatePickerGetDayLabel = (value: Date) => ReactNode;
|
|
10
|
+
export type DatePickerGetDayAriaLabel = (value: Date, selected: boolean) => string;
|
|
11
|
+
export type DatePickerGetWeekdayLabel = (dayOfWeek: number, label: string) => ReactNode;
|
|
12
|
+
export type DatePickerGetHeaderLabel = (month: number, year: number, value: Date) => ReactNode;
|
|
13
|
+
export type DatePickerGetNavigationAriaLabel = (direction: DatePickerNavigationDirection, value: Date) => string;
|
|
14
|
+
export type DatePickerClassNames = {
|
|
15
|
+
root?: string;
|
|
16
|
+
header?: string;
|
|
17
|
+
headerControls?: string;
|
|
18
|
+
headerControl?: string;
|
|
19
|
+
headerPreviousControl?: string;
|
|
20
|
+
headerNextControl?: string;
|
|
21
|
+
headerLabel?: string;
|
|
22
|
+
weekdays?: string;
|
|
23
|
+
weekday?: string;
|
|
24
|
+
grid?: string;
|
|
25
|
+
day?: string;
|
|
26
|
+
dayOutside?: string;
|
|
27
|
+
dayToday?: string;
|
|
28
|
+
daySelected?: string;
|
|
29
|
+
dayDisabled?: string;
|
|
30
|
+
monthPicker?: string;
|
|
31
|
+
};
|
|
32
|
+
export interface DatePickerProps extends Omit<ComponentPropsWithoutRef<"div">, "onChange" | "value" | "defaultValue"> {
|
|
33
|
+
/** Active date (controlled). */
|
|
34
|
+
value?: DatePickerValue;
|
|
35
|
+
/** Initial active date (uncontrolled). */
|
|
36
|
+
defaultValue?: DatePickerValue;
|
|
37
|
+
/** Callback called when active date changes. */
|
|
38
|
+
onChange?: DatePickerOnChange;
|
|
39
|
+
/** Minimum selectable date. */
|
|
40
|
+
minDate?: Date;
|
|
41
|
+
/** Maximum selectable date. */
|
|
42
|
+
maxDate?: Date;
|
|
43
|
+
/** Month picker columns @default `3` */
|
|
44
|
+
monthPickerColumns?: number;
|
|
45
|
+
/** Year picker years rendered in one page @default `9` */
|
|
46
|
+
yearPickerYearsPerPage?: number;
|
|
47
|
+
/** Year picker columns @default `3` */
|
|
48
|
+
yearPickerColumns?: number;
|
|
49
|
+
/** Whether all controls are disabled @default `false` */
|
|
50
|
+
disabled?: boolean;
|
|
51
|
+
/** Component size @default `md` */
|
|
52
|
+
size?: DatePickerSize;
|
|
53
|
+
/** Border radius @default `default` */
|
|
54
|
+
radius?: DatePickerRadius;
|
|
55
|
+
/** Custom weekday label renderer. */
|
|
56
|
+
getWeekdayLabel?: DatePickerGetWeekdayLabel;
|
|
57
|
+
/** Custom day label renderer. */
|
|
58
|
+
getDayLabel?: DatePickerGetDayLabel;
|
|
59
|
+
/** Custom aria-label generator for day buttons. */
|
|
60
|
+
getDayAriaLabel?: DatePickerGetDayAriaLabel;
|
|
61
|
+
/** Custom header label renderer for visible month. */
|
|
62
|
+
getHeaderLabel?: DatePickerGetHeaderLabel;
|
|
63
|
+
/** Custom aria-label generator for previous/next controls. */
|
|
64
|
+
getNavigationAriaLabel?: DatePickerGetNavigationAriaLabel;
|
|
65
|
+
/** Custom month label renderer in month view. */
|
|
66
|
+
getMonthLabel?: MonthPickerGetMonthLabel;
|
|
67
|
+
/** Custom aria-label generator for month buttons in month view. */
|
|
68
|
+
getMonthAriaLabel?: MonthPickerGetMonthAriaLabel;
|
|
69
|
+
/** Custom header label renderer in month view. */
|
|
70
|
+
getMonthHeaderLabel?: MonthPickerGetHeaderLabel;
|
|
71
|
+
/** Custom aria-label generator for month view navigation controls. */
|
|
72
|
+
getMonthNavigationAriaLabel?: MonthPickerGetNavigationAriaLabel;
|
|
73
|
+
/** Used for editing root class name. */
|
|
74
|
+
className?: string;
|
|
75
|
+
/** Used for styling different parts of the component. */
|
|
76
|
+
classNames?: DatePickerClassNames;
|
|
77
|
+
}
|
|
78
|
+
export interface DatePickerFactoryPayload extends FactoryPayload {
|
|
79
|
+
props: DatePickerProps;
|
|
80
|
+
ref: HTMLDivElement;
|
|
81
|
+
compound: {
|
|
82
|
+
configure: ReturnType<typeof createComponentConfig<DatePickerProps>>;
|
|
83
|
+
classNames: ReturnType<typeof createClassNamesConfig<DatePickerClassNames>>;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=date-picker.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-picker.types.d.ts","sourceRoot":"","sources":["../../../src/components/date-picker/date-picker.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5D,OAAO,EACH,eAAe,EACf,aAAa,EACb,sBAAsB,EACtB,qBAAqB,EACrB,cAAc,EACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EACR,yBAAyB,EACzB,4BAA4B,EAC5B,wBAAwB,EACxB,iCAAiC,EACpC,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC;AACnC,MAAM,MAAM,cAAc,GAAG,aAAa,CAAC;AAC3C,MAAM,MAAM,gBAAgB,GAAG,eAAe,CAAC;AAE/C,M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SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,yDAAyD;IACzD,UAAU,CAAC,EAAE,oBAAoB,CAAC;CACrC;AAED,MAAM,WAAW,wBAAyB,SAAQ,cAAc;IAC5D,KAAK,EAAE,eAAe,CAAC;IACvB,GAAG,EAAE,cAAc,CAAC;IACpB,QAAQ,EAAE;QACN,SAAS,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,eAAe,CAAC,CAAC,CAAC;QACrE,UAAU,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC,oBAAoB,CAAC,CAAC,CAAC;KAC/E,CAAC;CACL"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { default as DatePicker } from "./date-picker";
|
|
2
|
+
export type { DatePickerClassNames, DatePickerGetDayAriaLabel, DatePickerGetDayLabel, DatePickerGetHeaderLabel, DatePickerGetNavigationAriaLabel, DatePickerGetWeekdayLabel, DatePickerNavigationDirection, DatePickerOnChange, DatePickerProps, DatePickerRadius, DatePickerSize, DatePickerValue } from "./date-picker.types";
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/date-picker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AACtD,YAAY,EACR,oBAAoB,EACpB,yBAAyB,EACzB,qBAAqB,EACrB,wBAAwB,EACxB,gCAAgC,EAChC,yBAAyB,EACzB,6BAA6B,EAC7B,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,eAAe,EAClB,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as DatePicker } from "./date-picker";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/components/dates-provider/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAIjD,eAAO,MAAM,oBAAoB,oDAAwB,CAAC;AAE1D,eAAO,MAAM,eAAe,yBAU3B,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
const DatesContext = createContext(null);
|
|
3
|
+
export const DatesContextProvider = DatesContext.Provider;
|
|
4
|
+
export const useDatesContext = () => {
|
|
5
|
+
const context = useContext(DatesContext);
|
|
6
|
+
if (context === null) {
|
|
7
|
+
throw new Error("[@refraktor/dates] DatesProvider was not found in the tree");
|
|
8
|
+
}
|
|
9
|
+
return context;
|
|
10
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DatesProviderProps } from "./types";
|
|
2
|
+
export declare const DatesProvider: {
|
|
3
|
+
({ children, locale, firstDayOfWeek, weekdayFormat, consistentWeeks }: DatesProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
displayName: string;
|
|
5
|
+
};
|
|
6
|
+
export default DatesProvider;
|
|
7
|
+
//# sourceMappingURL=dates-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dates-provider.d.ts","sourceRoot":"","sources":["../../../src/components/dates-provider/dates-provider.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAER,kBAAkB,EAGrB,MAAM,SAAS,CAAC;AAsEjB,eAAO,MAAM,aAAa;2EAMvB,kBAAkB;;CA6CpB,CAAC;AAIF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import dayjs from "dayjs";
|
|
3
|
+
import localeData from "dayjs/plugin/localeData";
|
|
4
|
+
import { useCallback, useMemo } from "react";
|
|
5
|
+
import { DatesContextProvider } from "./context";
|
|
6
|
+
dayjs.extend(localeData);
|
|
7
|
+
const DEFAULT_FIRST_DAY_OF_WEEK = 1;
|
|
8
|
+
const DEFAULT_WEEKDAY_FORMAT = "short";
|
|
9
|
+
const DEFAULT_CONSISTENT_WEEKS = true;
|
|
10
|
+
const DEFAULT_LOCALE = "en";
|
|
11
|
+
const normalizeLocale = (locale) => {
|
|
12
|
+
const normalizedLocale = locale.trim().toLowerCase().replace(/_/g, "-");
|
|
13
|
+
if (!normalizedLocale) {
|
|
14
|
+
throw new Error("[@refraktor/dates] Invalid locale. Provide a non-empty locale string.");
|
|
15
|
+
}
|
|
16
|
+
return normalizedLocale;
|
|
17
|
+
};
|
|
18
|
+
const assertLocaleIsRegistered = (locale) => {
|
|
19
|
+
const locales = dayjs.Ls ?? {};
|
|
20
|
+
if (locales[locale])
|
|
21
|
+
return;
|
|
22
|
+
throw new Error(`[@refraktor/dates] Locale "${locale}" is not registered in dayjs. Import it before rendering DatesProvider (example: import "dayjs/locale/${locale}").`);
|
|
23
|
+
};
|
|
24
|
+
const isDayOfWeek = (value) => Number.isInteger(value) && value >= 0 && value <= 6;
|
|
25
|
+
const normalizeFirstDayOfWeek = (value) => {
|
|
26
|
+
if (!isDayOfWeek(value)) {
|
|
27
|
+
throw new Error(`[@refraktor/dates] Invalid firstDayOfWeek "${value}". Expected a number between 0 and 6.`);
|
|
28
|
+
}
|
|
29
|
+
return value;
|
|
30
|
+
};
|
|
31
|
+
const rotateWeekdays = (weekdays, firstDayOfWeek) => [...weekdays.slice(firstDayOfWeek), ...weekdays.slice(0, firstDayOfWeek)];
|
|
32
|
+
const getWeekdaysByFormat = (locale, format, firstDayOfWeek) => {
|
|
33
|
+
const localeData = dayjs().locale(locale).localeData();
|
|
34
|
+
const weekdays = format === "long"
|
|
35
|
+
? localeData.weekdays()
|
|
36
|
+
: format === "narrow"
|
|
37
|
+
? localeData.weekdaysMin()
|
|
38
|
+
: localeData.weekdaysShort();
|
|
39
|
+
return rotateWeekdays(weekdays, firstDayOfWeek);
|
|
40
|
+
};
|
|
41
|
+
export const DatesProvider = ({ children, locale = DEFAULT_LOCALE, firstDayOfWeek = DEFAULT_FIRST_DAY_OF_WEEK, weekdayFormat = DEFAULT_WEEKDAY_FORMAT, consistentWeeks = DEFAULT_CONSISTENT_WEEKS }) => {
|
|
42
|
+
const normalizedLocale = normalizeLocale(locale);
|
|
43
|
+
const normalizedFirstDayOfWeek = normalizeFirstDayOfWeek(firstDayOfWeek);
|
|
44
|
+
assertLocaleIsRegistered(normalizedLocale);
|
|
45
|
+
const createDate = useCallback((value) => dayjs(value).locale(normalizedLocale), [normalizedLocale]);
|
|
46
|
+
const weekdays = useMemo(() => getWeekdaysByFormat(normalizedLocale, weekdayFormat, normalizedFirstDayOfWeek), [normalizedFirstDayOfWeek, normalizedLocale, weekdayFormat]);
|
|
47
|
+
const contextValue = useMemo(() => ({
|
|
48
|
+
locale: normalizedLocale,
|
|
49
|
+
firstDayOfWeek: normalizedFirstDayOfWeek,
|
|
50
|
+
weekdayFormat,
|
|
51
|
+
consistentWeeks,
|
|
52
|
+
weekdays,
|
|
53
|
+
createDate
|
|
54
|
+
}), [
|
|
55
|
+
normalizedLocale,
|
|
56
|
+
normalizedFirstDayOfWeek,
|
|
57
|
+
weekdayFormat,
|
|
58
|
+
consistentWeeks,
|
|
59
|
+
weekdays,
|
|
60
|
+
createDate
|
|
61
|
+
]);
|
|
62
|
+
return (_jsx(DatesContextProvider, { value: contextValue, children: children }));
|
|
63
|
+
};
|
|
64
|
+
DatesProvider.displayName = "@refraktor/dates/DatesProvider";
|
|
65
|
+
export default DatesProvider;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as DatesProvider } from "./dates-provider";
|
|
2
|
+
export { useDatesContext } from "./context";
|
|
3
|
+
export { useDates } from "./use-dates";
|
|
4
|
+
export type { CreateDate, DatesContextValue, DatesProviderProps, DayOfWeek, WeekdayFormat } from "./types";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/dates-provider/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,YAAY,EACR,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,SAAS,EACT,aAAa,EAChB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ConfigType, Dayjs } from "dayjs";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
export type WeekdayFormat = "narrow" | "short" | "long";
|
|
4
|
+
export type DayOfWeek = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
5
|
+
export type CreateDate = (value?: ConfigType) => Dayjs;
|
|
6
|
+
export type DatesProviderProps = {
|
|
7
|
+
/** Content wrapped by the dates provider. */
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
/** Locale key imported by the user in dayjs. @default `en` */
|
|
10
|
+
locale?: string;
|
|
11
|
+
/** First day shown in week headers/grid. @default `1` (Monday) */
|
|
12
|
+
firstDayOfWeek?: DayOfWeek;
|
|
13
|
+
/** Weekday label style. @default `short` */
|
|
14
|
+
weekdayFormat?: WeekdayFormat;
|
|
15
|
+
/** Keep calendar grid at six rows. @default `true` */
|
|
16
|
+
consistentWeeks?: boolean;
|
|
17
|
+
};
|
|
18
|
+
export type DatesContextValue = {
|
|
19
|
+
locale: string;
|
|
20
|
+
firstDayOfWeek: DayOfWeek;
|
|
21
|
+
weekdayFormat: WeekdayFormat;
|
|
22
|
+
consistentWeeks: boolean;
|
|
23
|
+
weekdays: string[];
|
|
24
|
+
createDate: CreateDate;
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/dates-provider/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AACxD,MAAM,MAAM,SAAS,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAElD,MAAM,MAAM,UAAU,GAAG,CAAC,KAAK,CAAC,EAAE,UAAU,KAAK,KAAK,CAAC;AAEvD,MAAM,MAAM,kBAAkB,GAAG;IAC7B,6CAA6C;IAC7C,QAAQ,EAAE,SAAS,CAAC;IAEpB,8DAA8D;IAC9D,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,kEAAkE;IAClE,cAAc,CAAC,EAAE,SAAS,CAAC;IAE3B,4CAA4C;IAC5C,aAAa,CAAC,EAAE,aAAa,CAAC;IAE9B,sDAAsD;IACtD,eAAe,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,SAAS,CAAC;IAC1B,aAAa,EAAE,aAAa,CAAC;IAC7B,eAAe,EAAE,OAAO,CAAC;IACzB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,EAAE,UAAU,CAAC;CAC1B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-dates.d.ts","sourceRoot":"","sources":["../../../src/components/dates-provider/use-dates.ts"],"names":[],"mappings":"AAEA,wBAAgB,QAAQ,wCAEvB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./dates-provider";
|
|
2
|
+
export * from "./date-picker";
|
|
3
|
+
export * from "./date-input";
|
|
4
|
+
export * from "./month-picker";
|
|
5
|
+
export * from "./month-input";
|
|
6
|
+
export * from "./year-picker";
|
|
7
|
+
export * from "./year-input";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { default as MonthInput } from "./month-input";
|
|
2
|
+
export type { MonthInputClassNames, MonthInputFactoryPayload, MonthInputMiddlewares, MonthInputOnChange, MonthInputPositioning, MonthInputProps, MonthInputRadius, MonthInputSize, MonthInputValue, MonthInputValueFormat } from "./month-input.types";
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/month-input/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AACtD,YAAY,EACR,oBAAoB,EACpB,wBAAwB,EACxB,qBAAqB,EACrB,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,qBAAqB,EACxB,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as MonthInput } from "./month-input";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"month-input.d.ts","sourceRoot":"","sources":["../../../src/components/month-input/month-input.tsx"],"names":[],"mappings":"AA6BA,OAAO,EAEH,wBAAwB,EAE3B,MAAM,qBAAqB,CAAC;AA0C7B,QAAA,MAAM,UAAU,wEAyRd,CAAC;AAMH,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId, useUncontrolled } from "@refraktor/utils";
|
|
3
|
+
import { useCallback, useMemo } from "react";
|
|
4
|
+
import { createClassNamesConfig, createComponentConfig, factory, Input, Transition, useClassNames, useProps, useTheme } from "@refraktor/core";
|
|
5
|
+
import { autoUpdate, flip, FloatingFocusManager, FloatingPortal, inline, offset, shift, useDismiss, useFloating, useFocus, useInteractions, useRole } from "@floating-ui/react";
|
|
6
|
+
import { useDates } from "../dates-provider";
|
|
7
|
+
import { MonthPicker } from "../month-picker";
|
|
8
|
+
const DEFAULT_COLUMNS = 3;
|
|
9
|
+
const DEFAULT_YEAR_PICKER_YEARS_PER_PAGE = 9;
|
|
10
|
+
const DEFAULT_YEAR_PICKER_COLUMNS = 3;
|
|
11
|
+
const DEFAULT_VALUE_FORMAT = "MMMM YYYY";
|
|
12
|
+
const defaultProps = {
|
|
13
|
+
columns: DEFAULT_COLUMNS,
|
|
14
|
+
yearPickerYearsPerPage: DEFAULT_YEAR_PICKER_YEARS_PER_PAGE,
|
|
15
|
+
yearPickerColumns: DEFAULT_YEAR_PICKER_COLUMNS,
|
|
16
|
+
valueFormat: DEFAULT_VALUE_FORMAT,
|
|
17
|
+
disabled: false,
|
|
18
|
+
size: "md",
|
|
19
|
+
radius: "default",
|
|
20
|
+
positioning: {
|
|
21
|
+
placement: "bottom-start",
|
|
22
|
+
offset: 4
|
|
23
|
+
},
|
|
24
|
+
middlewares: {
|
|
25
|
+
flip: true,
|
|
26
|
+
shift: true
|
|
27
|
+
},
|
|
28
|
+
withinPortal: true,
|
|
29
|
+
closeOnClickOutside: true,
|
|
30
|
+
closeOnEscape: true
|
|
31
|
+
};
|
|
32
|
+
const isValidDate = (value) => value instanceof Date && !Number.isNaN(value.getTime());
|
|
33
|
+
const normalizeMonthValue = (value) => {
|
|
34
|
+
if (!isValidDate(value)) {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
const normalizedValue = new Date(value);
|
|
38
|
+
normalizedValue.setDate(1);
|
|
39
|
+
normalizedValue.setHours(0, 0, 0, 0);
|
|
40
|
+
return normalizedValue;
|
|
41
|
+
};
|
|
42
|
+
const MonthInput = factory((_props, ref) => {
|
|
43
|
+
const { cx, getRadius } = useTheme();
|
|
44
|
+
const { createDate } = useDates();
|
|
45
|
+
const { id, value, defaultValue, onChange, opened, defaultOpened, onOpenedChange, minYear, maxYear, columns, yearPickerYearsPerPage, yearPickerColumns, getMonthLabel, getMonthAriaLabel, getHeaderLabel, getNavigationAriaLabel, valueFormat, disabled, size, radius, positioning, middlewares, withinPortal, closeOnClickOutside, closeOnEscape, transitionProps, inputClassNames, className, classNames, onFocus, onBlur, onClick, onKeyDown, ...inputProps } = useProps("MonthInput", defaultProps, _props);
|
|
46
|
+
const classes = useClassNames("MonthInput", classNames);
|
|
47
|
+
const _id = useId(id);
|
|
48
|
+
const dropdownId = `${_id}-dropdown`;
|
|
49
|
+
const [selectedMonthState, setSelectedMonth] = useUncontrolled({
|
|
50
|
+
value,
|
|
51
|
+
defaultValue,
|
|
52
|
+
finalValue: undefined,
|
|
53
|
+
onChange: (nextMonth) => {
|
|
54
|
+
if (nextMonth !== undefined) {
|
|
55
|
+
onChange?.(nextMonth);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
const [isOpenState, setIsOpen] = useUncontrolled({
|
|
60
|
+
value: opened,
|
|
61
|
+
defaultValue: defaultOpened,
|
|
62
|
+
finalValue: false,
|
|
63
|
+
onChange: onOpenedChange
|
|
64
|
+
});
|
|
65
|
+
const isOpen = isOpenState && !disabled;
|
|
66
|
+
const middleware = useMemo(() => {
|
|
67
|
+
const middlewareList = [];
|
|
68
|
+
middlewareList.push(offset(positioning?.offset ?? 4));
|
|
69
|
+
if (middlewares?.flip ?? true) {
|
|
70
|
+
middlewareList.push(flip(typeof middlewares?.flip === "boolean"
|
|
71
|
+
? undefined
|
|
72
|
+
: middlewares.flip));
|
|
73
|
+
}
|
|
74
|
+
if (middlewares?.shift ?? true) {
|
|
75
|
+
middlewareList.push(shift(typeof middlewares?.shift === "boolean"
|
|
76
|
+
? undefined
|
|
77
|
+
: middlewares.shift));
|
|
78
|
+
}
|
|
79
|
+
if (middlewares?.inline) {
|
|
80
|
+
middlewareList.push(inline(typeof middlewares.inline === "boolean"
|
|
81
|
+
? undefined
|
|
82
|
+
: middlewares.inline));
|
|
83
|
+
}
|
|
84
|
+
return middlewareList;
|
|
85
|
+
}, [middlewares, positioning?.offset]);
|
|
86
|
+
const handleOpenChange = useCallback((nextOpen) => {
|
|
87
|
+
if (disabled && nextOpen) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
setIsOpen(nextOpen);
|
|
91
|
+
}, [disabled, setIsOpen]);
|
|
92
|
+
const floating = useFloating({
|
|
93
|
+
placement: positioning?.placement ?? "bottom-start",
|
|
94
|
+
open: isOpen,
|
|
95
|
+
onOpenChange: handleOpenChange,
|
|
96
|
+
middleware,
|
|
97
|
+
whileElementsMounted: autoUpdate
|
|
98
|
+
});
|
|
99
|
+
const focus = useFocus(floating.context, {
|
|
100
|
+
enabled: !disabled
|
|
101
|
+
});
|
|
102
|
+
const dismiss = useDismiss(floating.context, {
|
|
103
|
+
outsidePress: closeOnClickOutside,
|
|
104
|
+
escapeKey: closeOnEscape
|
|
105
|
+
});
|
|
106
|
+
const role = useRole(floating.context, {
|
|
107
|
+
role: "dialog"
|
|
108
|
+
});
|
|
109
|
+
const { getReferenceProps, getFloatingProps } = useInteractions([
|
|
110
|
+
focus,
|
|
111
|
+
dismiss,
|
|
112
|
+
role
|
|
113
|
+
]);
|
|
114
|
+
const setInputRef = useCallback((node) => {
|
|
115
|
+
floating.refs.setReference(node);
|
|
116
|
+
if (typeof ref === "function") {
|
|
117
|
+
ref(node);
|
|
118
|
+
}
|
|
119
|
+
else if (ref) {
|
|
120
|
+
ref.current = node;
|
|
121
|
+
}
|
|
122
|
+
}, [floating.refs, ref]);
|
|
123
|
+
const handleInputKeyDown = useCallback((event) => {
|
|
124
|
+
onKeyDown?.(event);
|
|
125
|
+
if (event.defaultPrevented || disabled) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (event.key === "ArrowDown" ||
|
|
129
|
+
event.key === "Enter" ||
|
|
130
|
+
event.key === " ") {
|
|
131
|
+
event.preventDefault();
|
|
132
|
+
setIsOpen(true);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (event.key === "Escape") {
|
|
136
|
+
event.preventDefault();
|
|
137
|
+
setIsOpen(false);
|
|
138
|
+
}
|
|
139
|
+
}, [disabled, onKeyDown, setIsOpen]);
|
|
140
|
+
const handleMonthChange = useCallback((nextMonth) => {
|
|
141
|
+
setSelectedMonth(nextMonth);
|
|
142
|
+
setIsOpen(false);
|
|
143
|
+
}, [setIsOpen, setSelectedMonth]);
|
|
144
|
+
const selectedMonth = normalizeMonthValue(selectedMonthState);
|
|
145
|
+
const inputValue = selectedMonth === undefined ? "" : createDate(selectedMonth).format(valueFormat);
|
|
146
|
+
const mergedReferenceProps = getReferenceProps({
|
|
147
|
+
onFocus,
|
|
148
|
+
onBlur,
|
|
149
|
+
onClick,
|
|
150
|
+
onKeyDown: handleInputKeyDown
|
|
151
|
+
});
|
|
152
|
+
const dropdownContent = (_jsx(Transition, { transition: "fade", duration: 150, mounted: isOpen, ...transitionProps, children: _jsx("div", { ref: floating.refs.setFloating, id: dropdownId, style: {
|
|
153
|
+
...floating.floatingStyles
|
|
154
|
+
}, className: cx("w-72 z-50 border border-[var(--refraktor-border)] bg-[var(--refraktor-bg)] p-2 text-[var(--refraktor-text)] shadow-md", getRadius(radius), classes.dropdown), ...getFloatingProps(), children: _jsx(MonthPicker, { value: selectedMonth, onChange: handleMonthChange, minYear: minYear, maxYear: maxYear, columns: columns, yearPickerYearsPerPage: yearPickerYearsPerPage, yearPickerColumns: yearPickerColumns, disabled: disabled, size: size, radius: radius, getMonthLabel: getMonthLabel, getMonthAriaLabel: getMonthAriaLabel, getHeaderLabel: getHeaderLabel, getNavigationAriaLabel: getNavigationAriaLabel, className: cx("bg-transparent p-0", classes.monthPicker) }) }) }));
|
|
155
|
+
const wrappedContent = isOpen ? (_jsx(FloatingFocusManager, { context: floating.context, modal: false, initialFocus: -1, returnFocus: false, children: dropdownContent })) : (dropdownContent);
|
|
156
|
+
return (_jsxs(_Fragment, { children: [_jsx(Input, { ref: setInputRef, id: _id, readOnly: true, value: inputValue, disabled: disabled, size: size, radius: radius, role: "combobox", "aria-haspopup": "dialog", "aria-expanded": isOpen, "aria-controls": isOpen ? dropdownId : undefined, className: cx(classes.input, className), classNames: inputClassNames, ...inputProps, ...mergedReferenceProps }), withinPortal ? (_jsx(FloatingPortal, { children: wrappedContent })) : (wrappedContent)] }));
|
|
157
|
+
});
|
|
158
|
+
MonthInput.displayName = "@refraktor/dates/MonthInput";
|
|
159
|
+
MonthInput.configure = createComponentConfig();
|
|
160
|
+
MonthInput.classNames = createClassNamesConfig();
|
|
161
|
+
export default MonthInput;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { FlipOptions, InlineOptions, Placement, ShiftOptions } from "@floating-ui/react";
|
|
2
|
+
import { createClassNamesConfig, createComponentConfig, FactoryPayload, InputFieldClassNames, InputProps, RefraktorRadius, RefraktorSize, TransitionProps } from "@refraktor/core";
|
|
3
|
+
import type { MonthPickerGetHeaderLabel, MonthPickerGetMonthAriaLabel, MonthPickerGetMonthLabel, MonthPickerGetNavigationAriaLabel } from "../month-picker";
|
|
4
|
+
export type MonthInputValue = Date;
|
|
5
|
+
export type MonthInputSize = RefraktorSize;
|
|
6
|
+
export type MonthInputRadius = RefraktorRadius;
|
|
7
|
+
export type MonthInputOnChange = (value: MonthInputValue) => void;
|
|
8
|
+
export type MonthInputValueFormat = string;
|
|
9
|
+
export type MonthInputPositioning = {
|
|
10
|
+
/** The placement of the dropdown relative to the input @default `bottom-start` */
|
|
11
|
+
placement?: Placement;
|
|
12
|
+
/** Offset distance from the input in pixels @default `4` */
|
|
13
|
+
offset?: number;
|
|
14
|
+
};
|
|
15
|
+
export type MonthInputMiddlewares = {
|
|
16
|
+
shift?: boolean | ShiftOptions;
|
|
17
|
+
flip?: boolean | FlipOptions;
|
|
18
|
+
inline?: boolean | InlineOptions;
|
|
19
|
+
};
|
|
20
|
+
export type MonthInputClassNames = {
|
|
21
|
+
input?: string;
|
|
22
|
+
dropdown?: string;
|
|
23
|
+
monthPicker?: string;
|
|
24
|
+
};
|
|
25
|
+
interface _MonthInputProps {
|
|
26
|
+
/** Selected month (controlled). */
|
|
27
|
+
value?: MonthInputValue;
|
|
28
|
+
/** Initial selected month (uncontrolled). */
|
|
29
|
+
defaultValue?: MonthInputValue;
|
|
30
|
+
/** Callback called when selected month changes. */
|
|
31
|
+
onChange?: MonthInputOnChange;
|
|
32
|
+
/** Dropdown open state (controlled). */
|
|
33
|
+
opened?: boolean;
|
|
34
|
+
/** Initial dropdown open state (uncontrolled). */
|
|
35
|
+
defaultOpened?: boolean;
|
|
36
|
+
/** Callback called when dropdown open state changes. */
|
|
37
|
+
onOpenedChange?: (opened: boolean) => void;
|
|
38
|
+
/** Minimum selectable year in month and year views. */
|
|
39
|
+
minYear?: number;
|
|
40
|
+
/** Maximum selectable year in month and year views. */
|
|
41
|
+
maxYear?: number;
|
|
42
|
+
/** Grid columns used by the month list @default `3` */
|
|
43
|
+
columns?: number;
|
|
44
|
+
/** Year picker years rendered in one page @default `9` */
|
|
45
|
+
yearPickerYearsPerPage?: number;
|
|
46
|
+
/** Year picker columns @default `3` */
|
|
47
|
+
yearPickerColumns?: number;
|
|
48
|
+
/** Custom month label renderer. */
|
|
49
|
+
getMonthLabel?: MonthPickerGetMonthLabel;
|
|
50
|
+
/** Custom aria-label generator for month buttons. */
|
|
51
|
+
getMonthAriaLabel?: MonthPickerGetMonthAriaLabel;
|
|
52
|
+
/** Custom header label renderer for visible year. */
|
|
53
|
+
getHeaderLabel?: MonthPickerGetHeaderLabel;
|
|
54
|
+
/** Custom aria-label generator for previous/next controls. */
|
|
55
|
+
getNavigationAriaLabel?: MonthPickerGetNavigationAriaLabel;
|
|
56
|
+
/** Dayjs format used to render selected month in the input @default `MMMM YYYY` */
|
|
57
|
+
valueFormat?: MonthInputValueFormat;
|
|
58
|
+
/** Positioning settings for the dropdown. */
|
|
59
|
+
positioning?: MonthInputPositioning;
|
|
60
|
+
/** Floating middleware settings. */
|
|
61
|
+
middlewares?: MonthInputMiddlewares;
|
|
62
|
+
/** Whether to render dropdown in a portal @default `true` */
|
|
63
|
+
withinPortal?: boolean;
|
|
64
|
+
/** Whether to close on click outside @default `true` */
|
|
65
|
+
closeOnClickOutside?: boolean;
|
|
66
|
+
/** Whether to close on Escape key @default `true` */
|
|
67
|
+
closeOnEscape?: boolean;
|
|
68
|
+
/** Transition props for dropdown, uses Transition internally */
|
|
69
|
+
transitionProps?: Omit<TransitionProps, "children" | "mounted">;
|
|
70
|
+
/** Used for styling the core Input field parts. */
|
|
71
|
+
inputClassNames?: InputFieldClassNames;
|
|
72
|
+
/** Used for styling MonthInput parts. */
|
|
73
|
+
classNames?: MonthInputClassNames;
|
|
74
|
+
}
|
|
75
|
+
export type MonthInputProps = _MonthInputProps & Omit<InputProps, "value" | "defaultValue" | "onChange" | "readOnly" | "classNames">;
|
|
76
|
+
export interface MonthInputFactoryPayload extends FactoryPayload {
|
|
77
|
+
props: MonthInputProps;
|
|
78
|
+
ref: HTMLInputElement;
|
|
79
|
+
compound: {
|
|
80
|
+
configure: ReturnType<typeof createComponentConfig<MonthInputProps>>;
|
|
81
|
+
classNames: ReturnType<typeof createClassNamesConfig<MonthInputClassNames>>;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export {};
|
|
85
|
+
//# sourceMappingURL=month-input.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"month-input.types.d.ts","sourceRoot":"","sources":["../../../src/components/month-input/month-input.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,WAAW,EACX,aAAa,EACb,SAAS,EACT,YAAY,EACf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACH,sBAAsB,EACtB,qBAAqB,EACrB,cAAc,EACd,oBAAoB,EACpB,UAAU,EACV,eAAe,EACf,aAAa,EACb,eAAe,EAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EACR,yBAAyB,EACzB,4BAA4B,EAC5B,wBAAwB,EACxB,iCAAiC,EACpC,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC;AACnC,MAAM,MAAM,cAAc,GAAG,aAAa,CAAC;AAC3C,MAAM,MAAM,gBAAgB,GAAG,eAAe,CAAC;AAC/C,MAAM,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;AAClE,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC;AAE3C,MAAM,MAAM,qBAAqB,GAAG;IAChC,kFAAkF;IAClF,SAAS,CAAC,EAAE,SAAS,CAAC;IAEtB,4DAA4D;IAC5D,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAChC,KAAK,CAAC,EAAE,OAAO,GAAG,YAAY,CAAC;IAC/B,IAAI,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC;IAC7B,MAAM,CAAC,EAAE,OAAO,GAAG,aAAa,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,U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,GAAG,SAAS,CAAC,CAAC;IAEhE,mDAAmD;IACnD,eAAe,CAAC,EAAE,oBAAoB,CAAC;IAEvC,yCAAyC;IACzC,UAAU,CAAC,EAAE,oBAAoB,CAAC;CACrC;AAED,MAAM,MAAM,eAAe,GAAG,gBAAgB,GAC1C,IAAI,CACA,UAAU,EACV,OAAO,GAAG,cAAc,GAAG,UAAU,GAAG,UAAU,GAAG,YAAY,CACpE,CAAC;AAEN,MAAM,WAAW,wBAAyB,SAAQ,cAAc;IAC5D,KAAK,EAAE,eAAe,CAAC;IACvB,GAAG,EAAE,gBAAgB,CAAC;IACtB,QAAQ,EAAE;QACN,SAAS,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,eAAe,CAAC,CAAC,CAAC;QACrE,UAAU,EAAE,UAAU,CAClB,OAAO,sBAAsB,CAAC,oBAAoB,CAAC,CACtD,CAAC;KACL,CAAC;CACL"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { default as MonthPicker } from "./month-picker";
|
|
2
|
+
export type { MonthPickerClassNames, MonthPickerGetHeaderLabel, MonthPickerGetMonthAriaLabel, MonthPickerGetMonthLabel, MonthPickerGetNavigationAriaLabel, MonthPickerNavigationDirection, MonthPickerOnChange, MonthPickerProps, MonthPickerRadius, MonthPickerSize, MonthPickerValue } from "./month-picker.types";
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/month-picker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACxD,YAAY,EACR,qBAAqB,EACrB,yBAAyB,EACzB,4BAA4B,EAC5B,wBAAwB,EACxB,iCAAiC,EACjC,8BAA8B,EAC9B,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EACnB,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as MonthPicker } from "./month-picker";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"month-picker.d.ts","sourceRoot":"","sources":["../../../src/components/month-picker/month-picker.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAEH,yBAAyB,EAG5B,MAAM,sBAAsB,CAAC;AAyE9B,QAAA,MAAM,WAAW,yEAoWf,CAAC;AAMH,eAAe,WAAW,CAAC"}
|