@flightlesslabs/dodo-ui 0.10.2 → 0.11.0
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/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/stories/Home.mdx +1 -1
- package/dist/stories/components/Form/DatePicker/DatePicker.stories.svelte +16 -0
- package/dist/stories/components/Form/DatePicker/DatePicker.svelte +2 -1
- package/dist/stories/components/Form/DatePicker/DatePicker.svelte.d.ts +3 -1
- package/dist/stories/components/Form/DatePicker/Positions/AutoPosition/AutoPosition.stories.svelte +43 -0
- package/dist/stories/components/Form/DatePicker/Positions/AutoPosition/AutoPosition.stories.svelte.d.ts +18 -0
- package/dist/stories/components/Form/DatePicker/Positions/Positions.stories.svelte +54 -0
- package/dist/stories/components/Form/DatePicker/Positions/Positions.stories.svelte.d.ts +18 -0
- package/dist/stories/components/Form/Select/Options/OptionFormat.mdx +1 -1
- package/dist/stories/components/Info/Calendar/Calendar.stories.svelte +14 -0
- package/dist/stories/components/Info/Calendar/Calendar.svelte +2 -1
- package/dist/stories/components/Info/Calendar/Calendar.svelte.d.ts +3 -3
- package/dist/stories/components/Info/Calendar/SubComponents/CalendarDatesChart/CalendarDateChip/CalendarDateChip.svelte +2 -215
- package/dist/stories/components/Info/Calendar/SubComponents/CalendarDatesChart/CalendarDateChip/CalendarDateChip.svelte.d.ts +1 -7
- package/dist/stories/components/Info/Calendar/SubComponents/CalendarDatesChart/CalendarDateChip/utils/scss/mixins.scss +0 -46
- package/dist/stories/components/Info/Calendar/SubComponents/CalendarDatesChart/CalendarDatesChart.stories.svelte +14 -0
- package/dist/stories/components/Info/Calendar/SubComponents/CalendarDatesChart/CalendarDatesChart.svelte +3 -25
- package/dist/stories/components/Info/Calendar/SubComponents/CalendarDatesChart/CalendarDatesChart.svelte.d.ts +4 -5
- package/dist/stories/components/Info/Calendar/utils/createDateOfMonth/createDateOfMonth.d.ts +27 -0
- package/dist/stories/components/Info/Calendar/utils/createDateOfMonth/createDateOfMonth.js +72 -0
- package/dist/stories/components/Info/Calendar/utils/createDateOfMonth/index.mdx +121 -0
- package/dist/stories/components/Info/Calendar/utils/getDatesOfMonth/getDatesOfMonth.d.ts +10 -0
- package/dist/stories/components/Info/Calendar/utils/{getDatesOfMonth.js → getDatesOfMonth/getDatesOfMonth.js} +20 -13
- package/dist/stories/components/Info/Calendar/utils/getDatesOfMonth/index.mdx +37 -0
- package/dist/stories/components/Info/Calendar/utils/types.d.ts +0 -4
- package/dist/stories/components/Layout/Menu/DynamicMenu/Options/OptionFormat.mdx +1 -1
- package/dist/stories/developer tools/directives/clickOutside/index.mdx +1 -1
- package/dist/stories/developer tools/helpers/Numbers/cleanNumericString/index.mdx +1 -1
- package/dist/stories/developer tools/helpers/Numbers/isValidNumberValue/index.mdx +1 -1
- package/dist/stories/developer tools/helpers/Time/getMoment/getMoment.d.ts +10 -11
- package/dist/stories/developer tools/helpers/Time/getMoment/getMoment.js +8 -8
- package/dist/stories/developer tools/helpers/Time/getMoment/index.mdx +32 -5
- package/dist/stories/developer tools/helpers/logger/index.mdx +1 -1
- package/dist/stories/developer tools/philosophy/Colors/Colors.mdx +1 -1
- package/dist/stories/developer tools/philosophy/Themes.mdx +1 -1
- package/package.json +22 -26
- package/src/lib/index.ts +3 -3
- package/src/lib/stories/components/Form/DatePicker/DatePicker.svelte +10 -0
- package/src/lib/stories/components/Info/Calendar/Calendar.svelte +8 -2
- package/src/lib/stories/components/Info/Calendar/SubComponents/CalendarDatesChart/CalendarDateChip/CalendarDateChip.svelte +2 -25
- package/src/lib/stories/components/Info/Calendar/SubComponents/CalendarDatesChart/CalendarDateChip/utils/scss/mixins.scss +0 -46
- package/src/lib/stories/components/Info/Calendar/SubComponents/CalendarDatesChart/CalendarDatesChart.svelte +23 -53
- package/src/lib/stories/components/Info/Calendar/utils/createDateOfMonth/createDateOfMonth.ts +120 -0
- package/src/lib/stories/components/Info/Calendar/utils/{getDatesOfMonth.ts → getDatesOfMonth/getDatesOfMonth.ts} +30 -16
- package/src/lib/stories/components/Info/Calendar/utils/types.ts +0 -5
- package/src/lib/stories/developer tools/helpers/Time/getMoment/getMoment.ts +11 -12
- package/dist/stories/components/Info/Calendar/utils/createDateOfMonth.d.ts +0 -28
- package/dist/stories/components/Info/Calendar/utils/createDateOfMonth.js +0 -87
- package/dist/stories/components/Info/Calendar/utils/getDatesOfMonth.d.ts +0 -10
- package/dist/stories/components/Info/Calendar/utils/index.mdx +0 -64
- package/src/lib/stories/components/Info/Calendar/utils/createDateOfMonth.ts +0 -160
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ConfigType, OptionType } from 'dayjs';
|
|
2
|
-
import dayjs from 'dayjs';
|
|
2
|
+
import dayjs, { Dayjs } from 'dayjs';
|
|
3
3
|
import utc from 'dayjs/plugin/utc.js';
|
|
4
4
|
import timezone from 'dayjs/plugin/timezone.js';
|
|
5
5
|
import customParseFormat from 'dayjs/plugin/customParseFormat.js';
|
|
@@ -15,14 +15,13 @@ export type GetMomentDate = ConfigType;
|
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Optional formatting string used to parse the date.
|
|
18
|
-
* Refer to dayjs customParseFormat plugin for supported formats.
|
|
19
18
|
*/
|
|
20
19
|
export type GetMomentFormat = OptionType;
|
|
21
20
|
|
|
22
21
|
/**
|
|
23
22
|
* Settings to control how the moment is returned (UTC, timezone, or local).
|
|
24
23
|
*/
|
|
25
|
-
export
|
|
24
|
+
export interface GetMomentSettings {
|
|
26
25
|
/**
|
|
27
26
|
* Timezone string (e.g., "America/New_York").
|
|
28
27
|
*/
|
|
@@ -32,28 +31,28 @@ export type GetMomentSettings = {
|
|
|
32
31
|
* Whether to return the time in UTC. If true, overrides timezone.
|
|
33
32
|
*/
|
|
34
33
|
utc?: boolean;
|
|
35
|
-
}
|
|
34
|
+
}
|
|
36
35
|
|
|
37
36
|
/**
|
|
38
37
|
* A wrapper around dayjs to return a moment-like object with optional formatting,
|
|
39
38
|
* timezone, or UTC handling.
|
|
40
39
|
*
|
|
41
|
-
* @param
|
|
42
|
-
* @param
|
|
43
|
-
* @param
|
|
44
|
-
* @returns
|
|
40
|
+
* @param date - The input date, time, or string to be parsed.
|
|
41
|
+
* @param format - A custom format string for parsing the input date.
|
|
42
|
+
* @param settings - Optional settings for timezone or UTC output.
|
|
43
|
+
* @returns A dayjs object in local, UTC, or specified timezone.
|
|
45
44
|
*
|
|
46
45
|
* @example
|
|
47
|
-
* getMoment('2025-01-01T12:00:00Z', { utc: true }).format()
|
|
48
|
-
* getMoment('01-01-2025',
|
|
46
|
+
* getMoment('2025-01-01T12:00:00Z', undefined, { utc: true }).format()
|
|
47
|
+
* getMoment('01-01-2025', 'DD-MM-YYYY', { timezone: 'Asia/Kolkata' }).format()
|
|
49
48
|
*/
|
|
50
49
|
export default function getMoment(
|
|
51
50
|
date?: GetMomentDate,
|
|
52
51
|
format?: GetMomentFormat,
|
|
53
52
|
settings?: GetMomentSettings,
|
|
54
|
-
):
|
|
53
|
+
): Dayjs {
|
|
55
54
|
const timezone = settings?.timezone;
|
|
56
|
-
const utc = settings?.utc
|
|
55
|
+
const utc = settings?.utc ?? false;
|
|
57
56
|
|
|
58
57
|
if (utc) {
|
|
59
58
|
return dayjs.utc(dayjs(date, format));
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { DateOfMonth } from './types.js';
|
|
2
|
-
import type { CalendarWeekNames } from '../SubComponents/CalendarDatesChart/CalendarWeek/CalendarWeek.svelte';
|
|
3
|
-
export interface CreateDatesOfMonthSettings {
|
|
4
|
-
/** Day considered as start of the week */
|
|
5
|
-
startOfWeek?: CalendarWeekNames;
|
|
6
|
-
/** Include leading days from the previous month */
|
|
7
|
-
showLastMonth?: boolean;
|
|
8
|
-
/** Include trailing days from the next month */
|
|
9
|
-
showNextMonth?: boolean;
|
|
10
|
-
/** Set today manually */
|
|
11
|
-
today?: Date;
|
|
12
|
-
/** Minimum allowed date, rest of the dates will be disabled */
|
|
13
|
-
minDate?: Date;
|
|
14
|
-
/** Maxium allowed date, rest of the dates will be disabled */
|
|
15
|
-
maxDate?: Date;
|
|
16
|
-
/** Exclude Dates, these dates will be disabled */
|
|
17
|
-
excludeDates?: Date[];
|
|
18
|
-
/** Include Dates, rest of the dates will be disabled */
|
|
19
|
-
includeDates?: Date[];
|
|
20
|
-
/** Optional IANA timezone */
|
|
21
|
-
timezone?: string;
|
|
22
|
-
/** Use UTC time */
|
|
23
|
-
utc?: boolean;
|
|
24
|
-
/** Range value */
|
|
25
|
-
rangeValue?: [Date, Date];
|
|
26
|
-
}
|
|
27
|
-
export type CreateDateOfMonthType = 'currentMonth' | 'nextMonth' | 'lastMonth';
|
|
28
|
-
export default function createDateOfMonth(date?: Date, settings?: CreateDatesOfMonthSettings, monthType?: CreateDateOfMonthType): DateOfMonth;
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import getMoment from '../../../../developer tools/helpers/Time/getMoment/getMoment.js';
|
|
2
|
-
function dateMoment(date, settings) {
|
|
3
|
-
return getMoment(date, undefined, {
|
|
4
|
-
timezone: settings?.timezone,
|
|
5
|
-
utc: settings?.utc,
|
|
6
|
-
});
|
|
7
|
-
}
|
|
8
|
-
function getIsToday(dayMoment, todayDate, todayManual) {
|
|
9
|
-
const dayDateFormat = dayMoment.format('DD-MM-YYYY');
|
|
10
|
-
let today = false;
|
|
11
|
-
if (todayManual && todayManual === dayDateFormat) {
|
|
12
|
-
today = true;
|
|
13
|
-
}
|
|
14
|
-
else if (todayDate === dayDateFormat) {
|
|
15
|
-
today = true;
|
|
16
|
-
}
|
|
17
|
-
return today;
|
|
18
|
-
}
|
|
19
|
-
function getIsDateDisabled(dayMoment, minDate, maxDate, excludeDates, includeDates) {
|
|
20
|
-
const dayDateFormat = dayMoment.format('DD-MM-YYYY');
|
|
21
|
-
let disabled = false;
|
|
22
|
-
if (minDate?.isValid() && dayMoment.isBefore(minDate)) {
|
|
23
|
-
disabled = true;
|
|
24
|
-
}
|
|
25
|
-
if (maxDate?.isValid() && dayMoment.isAfter(maxDate)) {
|
|
26
|
-
disabled = true;
|
|
27
|
-
}
|
|
28
|
-
if (excludeDates?.length && excludeDates.includes(dayDateFormat)) {
|
|
29
|
-
disabled = true;
|
|
30
|
-
}
|
|
31
|
-
if (includeDates?.length && !includeDates.includes(dayDateFormat)) {
|
|
32
|
-
disabled = true;
|
|
33
|
-
}
|
|
34
|
-
return disabled;
|
|
35
|
-
}
|
|
36
|
-
export default function createDateOfMonth(date, settings, monthType = 'currentMonth') {
|
|
37
|
-
const minDate = settings?.minDate ? dateMoment(settings.minDate, settings) : undefined;
|
|
38
|
-
const maxDate = settings?.maxDate ? dateMoment(settings.maxDate, settings) : undefined;
|
|
39
|
-
const excludeDates = settings?.excludeDates?.length
|
|
40
|
-
? settings?.excludeDates.map((item) => dateMoment(item, settings).format('DD-MM-YYYY'))
|
|
41
|
-
: undefined;
|
|
42
|
-
const includeDates = settings?.includeDates?.length
|
|
43
|
-
? settings?.includeDates.map((item) => dateMoment(item, settings).format('DD-MM-YYYY'))
|
|
44
|
-
: undefined;
|
|
45
|
-
const [range1, range2] = settings?.rangeValue || [];
|
|
46
|
-
const rangeStart = range1 ? dateMoment(range1, settings) : undefined;
|
|
47
|
-
const rangeEnd = range2 ? dateMoment(range2, settings) : undefined;
|
|
48
|
-
const todayDate = dateMoment(undefined, settings).format('DD-MM-YYYY');
|
|
49
|
-
const todayManual = settings?.today
|
|
50
|
-
? dateMoment(settings?.today, settings).format('DD-MM-YYYY')
|
|
51
|
-
: undefined;
|
|
52
|
-
const dayMoment = dateMoment(date, settings);
|
|
53
|
-
const dayMomentDayFormatted = dayMoment.format('DD-MM-YYYY');
|
|
54
|
-
let isRangeStart = false;
|
|
55
|
-
let isRangeEnd = false;
|
|
56
|
-
let inRange = false;
|
|
57
|
-
if (rangeStart && rangeEnd) {
|
|
58
|
-
if (dayMomentDayFormatted === rangeStart.format('DD-MM-YYYY')) {
|
|
59
|
-
isRangeStart = true;
|
|
60
|
-
}
|
|
61
|
-
if (dayMomentDayFormatted === rangeEnd.format('DD-MM-YYYY')) {
|
|
62
|
-
isRangeEnd = true;
|
|
63
|
-
}
|
|
64
|
-
if (dayMoment.isAfter(rangeStart) && dayMoment.isBefore(rangeEnd)) {
|
|
65
|
-
inRange = true;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
const dataToExport = {
|
|
69
|
-
id: `${dayMoment.valueOf()}`,
|
|
70
|
-
date: dayMoment.toDate(),
|
|
71
|
-
isCurrentMonth: true,
|
|
72
|
-
disabled: getIsDateDisabled(dayMoment, minDate, maxDate, excludeDates, includeDates),
|
|
73
|
-
today: getIsToday(dayMoment, todayDate, todayManual),
|
|
74
|
-
isRangeStart,
|
|
75
|
-
isRangeEnd,
|
|
76
|
-
inRange,
|
|
77
|
-
};
|
|
78
|
-
if (monthType === 'lastMonth') {
|
|
79
|
-
dataToExport.isLastMonth = true;
|
|
80
|
-
dataToExport.isCurrentMonth = false;
|
|
81
|
-
}
|
|
82
|
-
else if (monthType === 'nextMonth') {
|
|
83
|
-
dataToExport.isNextMonth = true;
|
|
84
|
-
dataToExport.isCurrentMonth = false;
|
|
85
|
-
}
|
|
86
|
-
return dataToExport;
|
|
87
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { DateOfMonth } from './types.js';
|
|
2
|
-
import { type CreateDatesOfMonthSettings } from './createDateOfMonth.js';
|
|
3
|
-
/**
|
|
4
|
-
* Generates a calendar grid of dates for a given month.
|
|
5
|
-
*
|
|
6
|
-
* @param {Date} date - The base date for the month to generate.
|
|
7
|
-
* @param {GetDatesOfMonthSettings} [settings] - Optional settings for formatting and display.
|
|
8
|
-
* @returns {(DateOfMonth[][] | null)} - A 2D array of DateOfMonth objects representing the calendar, or null if invalid.
|
|
9
|
-
*/
|
|
10
|
-
export default function getDatesOfMonth(date?: Date, settings?: CreateDatesOfMonthSettings): DateOfMonth[][] | null;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { Source } from '@storybook/blocks';
|
|
2
|
-
|
|
3
|
-
# Utils
|
|
4
|
-
|
|
5
|
-
## `getDatesOfMonth`
|
|
6
|
-
|
|
7
|
-
`getDatesOfMonth(date, settings)` generates a calendar view of a given month with options to include dates from the previous and next month.
|
|
8
|
-
|
|
9
|
-
### Usage
|
|
10
|
-
|
|
11
|
-
<Source
|
|
12
|
-
dark
|
|
13
|
-
language="ts"
|
|
14
|
-
code={`
|
|
15
|
-
import { getDatesOfMonth, getMoment} from '@flightlesslabs/dodo-ui';
|
|
16
|
-
|
|
17
|
-
const dates = getDatesOfMonth(new Date(), {
|
|
18
|
-
showLastMonth: false,
|
|
19
|
-
showNextMonth: false,
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
// Or
|
|
23
|
-
|
|
24
|
-
const dates2 = getDatesOfMonth(getMoment('01-02-2025', 'DD-MM-YYYY').toDate());
|
|
25
|
-
|
|
26
|
-
`}
|
|
27
|
-
/>
|
|
28
|
-
|
|
29
|
-
## Types
|
|
30
|
-
|
|
31
|
-
### `DateOfMonth`
|
|
32
|
-
|
|
33
|
-
<Source
|
|
34
|
-
dark
|
|
35
|
-
language="ts"
|
|
36
|
-
code={`
|
|
37
|
-
type DateOfMonth = {
|
|
38
|
-
id: string;
|
|
39
|
-
dayNumber: number;
|
|
40
|
-
date: Date;
|
|
41
|
-
isCurrentMonth?: boolean;
|
|
42
|
-
isLastMonth?: boolean;
|
|
43
|
-
isNextMonth?: boolean;
|
|
44
|
-
};
|
|
45
|
-
`}
|
|
46
|
-
/>
|
|
47
|
-
|
|
48
|
-
### Enum: `DAYS_OF_WEEK`
|
|
49
|
-
|
|
50
|
-
<Source
|
|
51
|
-
dark
|
|
52
|
-
language="ts"
|
|
53
|
-
code={`
|
|
54
|
-
const enum DAYS_OF_WEEK {
|
|
55
|
-
SUN,
|
|
56
|
-
MON,
|
|
57
|
-
TUE,
|
|
58
|
-
WED,
|
|
59
|
-
THU,
|
|
60
|
-
FRI,
|
|
61
|
-
SAT,
|
|
62
|
-
}
|
|
63
|
-
`}
|
|
64
|
-
/>
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import getMoment from '$lib/stories/developer tools/helpers/Time/getMoment/getMoment.js';
|
|
2
|
-
import type dayjs from 'dayjs';
|
|
3
|
-
import type { DateOfMonth } from './types.js';
|
|
4
|
-
import type { CalendarWeekNames } from '../SubComponents/CalendarDatesChart/CalendarWeek/CalendarWeek.svelte';
|
|
5
|
-
|
|
6
|
-
export interface CreateDatesOfMonthSettings {
|
|
7
|
-
/** Day considered as start of the week */
|
|
8
|
-
startOfWeek?: CalendarWeekNames;
|
|
9
|
-
|
|
10
|
-
/** Include leading days from the previous month */
|
|
11
|
-
showLastMonth?: boolean;
|
|
12
|
-
|
|
13
|
-
/** Include trailing days from the next month */
|
|
14
|
-
showNextMonth?: boolean;
|
|
15
|
-
|
|
16
|
-
/** Set today manually */
|
|
17
|
-
today?: Date;
|
|
18
|
-
|
|
19
|
-
/** Minimum allowed date, rest of the dates will be disabled */
|
|
20
|
-
minDate?: Date;
|
|
21
|
-
|
|
22
|
-
/** Maxium allowed date, rest of the dates will be disabled */
|
|
23
|
-
maxDate?: Date;
|
|
24
|
-
|
|
25
|
-
/** Exclude Dates, these dates will be disabled */
|
|
26
|
-
excludeDates?: Date[];
|
|
27
|
-
|
|
28
|
-
/** Include Dates, rest of the dates will be disabled */
|
|
29
|
-
includeDates?: Date[];
|
|
30
|
-
|
|
31
|
-
/** Optional IANA timezone */
|
|
32
|
-
timezone?: string;
|
|
33
|
-
|
|
34
|
-
/** Use UTC time */
|
|
35
|
-
utc?: boolean;
|
|
36
|
-
|
|
37
|
-
/** Range value */
|
|
38
|
-
rangeValue?: [Date, Date];
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export type CreateDateOfMonthType = 'currentMonth' | 'nextMonth' | 'lastMonth';
|
|
42
|
-
|
|
43
|
-
function dateMoment(date?: Date, settings?: CreateDatesOfMonthSettings) {
|
|
44
|
-
return getMoment(date, undefined, {
|
|
45
|
-
timezone: settings?.timezone,
|
|
46
|
-
utc: settings?.utc,
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function getIsToday(dayMoment: dayjs.Dayjs, todayDate: string, todayManual: string | undefined) {
|
|
51
|
-
const dayDateFormat = dayMoment.format('DD-MM-YYYY');
|
|
52
|
-
let today = false;
|
|
53
|
-
|
|
54
|
-
if (todayManual && todayManual === dayDateFormat) {
|
|
55
|
-
today = true;
|
|
56
|
-
} else if (todayDate === dayDateFormat) {
|
|
57
|
-
today = true;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return today;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function getIsDateDisabled(
|
|
64
|
-
dayMoment: dayjs.Dayjs,
|
|
65
|
-
minDate: dayjs.Dayjs | undefined,
|
|
66
|
-
maxDate: dayjs.Dayjs | undefined,
|
|
67
|
-
excludeDates: string[] | undefined,
|
|
68
|
-
includeDates: string[] | undefined,
|
|
69
|
-
) {
|
|
70
|
-
const dayDateFormat = dayMoment.format('DD-MM-YYYY');
|
|
71
|
-
let disabled = false;
|
|
72
|
-
|
|
73
|
-
if (minDate?.isValid() && dayMoment.isBefore(minDate)) {
|
|
74
|
-
disabled = true;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (maxDate?.isValid() && dayMoment.isAfter(maxDate)) {
|
|
78
|
-
disabled = true;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (excludeDates?.length && excludeDates.includes(dayDateFormat)) {
|
|
82
|
-
disabled = true;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (includeDates?.length && !includeDates.includes(dayDateFormat)) {
|
|
86
|
-
disabled = true;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return disabled;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export default function createDateOfMonth(
|
|
93
|
-
date?: Date,
|
|
94
|
-
settings?: CreateDatesOfMonthSettings,
|
|
95
|
-
monthType: CreateDateOfMonthType = 'currentMonth',
|
|
96
|
-
): DateOfMonth {
|
|
97
|
-
const minDate = settings?.minDate ? dateMoment(settings.minDate, settings) : undefined;
|
|
98
|
-
const maxDate = settings?.maxDate ? dateMoment(settings.maxDate, settings) : undefined;
|
|
99
|
-
const excludeDates = settings?.excludeDates?.length
|
|
100
|
-
? settings?.excludeDates.map((item) => dateMoment(item, settings).format('DD-MM-YYYY'))
|
|
101
|
-
: undefined;
|
|
102
|
-
const includeDates = settings?.includeDates?.length
|
|
103
|
-
? settings?.includeDates.map((item) => dateMoment(item, settings).format('DD-MM-YYYY'))
|
|
104
|
-
: undefined;
|
|
105
|
-
|
|
106
|
-
const [range1, range2] = settings?.rangeValue || [];
|
|
107
|
-
|
|
108
|
-
const rangeStart = range1 ? dateMoment(range1, settings) : undefined;
|
|
109
|
-
const rangeEnd = range2 ? dateMoment(range2, settings) : undefined;
|
|
110
|
-
|
|
111
|
-
const todayDate = dateMoment(undefined, settings).format('DD-MM-YYYY');
|
|
112
|
-
|
|
113
|
-
const todayManual = settings?.today
|
|
114
|
-
? dateMoment(settings?.today, settings).format('DD-MM-YYYY')
|
|
115
|
-
: undefined;
|
|
116
|
-
|
|
117
|
-
const dayMoment = dateMoment(date, settings);
|
|
118
|
-
const dayMomentDayFormatted = dayMoment.format('DD-MM-YYYY');
|
|
119
|
-
|
|
120
|
-
let isRangeStart = false;
|
|
121
|
-
|
|
122
|
-
let isRangeEnd = false;
|
|
123
|
-
|
|
124
|
-
let inRange = false;
|
|
125
|
-
|
|
126
|
-
if (rangeStart && rangeEnd) {
|
|
127
|
-
if (dayMomentDayFormatted === rangeStart.format('DD-MM-YYYY')) {
|
|
128
|
-
isRangeStart = true;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (dayMomentDayFormatted === rangeEnd.format('DD-MM-YYYY')) {
|
|
132
|
-
isRangeEnd = true;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (dayMoment.isAfter(rangeStart) && dayMoment.isBefore(rangeEnd)) {
|
|
136
|
-
inRange = true;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const dataToExport: DateOfMonth = {
|
|
141
|
-
id: `${dayMoment.valueOf()}`,
|
|
142
|
-
date: dayMoment.toDate(),
|
|
143
|
-
isCurrentMonth: true,
|
|
144
|
-
disabled: getIsDateDisabled(dayMoment, minDate, maxDate, excludeDates, includeDates),
|
|
145
|
-
today: getIsToday(dayMoment, todayDate, todayManual),
|
|
146
|
-
isRangeStart,
|
|
147
|
-
isRangeEnd,
|
|
148
|
-
inRange,
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
if (monthType === 'lastMonth') {
|
|
152
|
-
dataToExport.isLastMonth = true;
|
|
153
|
-
dataToExport.isCurrentMonth = false;
|
|
154
|
-
} else if (monthType === 'nextMonth') {
|
|
155
|
-
dataToExport.isNextMonth = true;
|
|
156
|
-
dataToExport.isCurrentMonth = false;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
return dataToExport;
|
|
160
|
-
}
|