@zag-js/date-utils 1.46.0 → 1.48.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/align.d.mts +4 -8
- package/dist/align.d.ts +4 -8
- package/dist/align.js +15 -47
- package/dist/align.mjs +10 -21
- package/dist/assertion.d.mts +6 -10
- package/dist/assertion.d.ts +6 -10
- package/dist/assertion.js +21 -48
- package/dist/assertion.mjs +13 -19
- package/dist/constrain.d.mts +7 -10
- package/dist/constrain.d.ts +7 -10
- package/dist/constrain.js +68 -133
- package/dist/constrain.mjs +59 -110
- package/dist/date-month.d.mts +17 -21
- package/dist/date-month.d.ts +17 -21
- package/dist/date-month.js +103 -112
- package/dist/date-month.mjs +92 -86
- package/dist/date-year.d.mts +8 -11
- package/dist/date-year.d.ts +8 -11
- package/dist/date-year.js +35 -62
- package/dist/date-year.mjs +28 -34
- package/dist/duration.d.mts +8 -12
- package/dist/duration.d.ts +8 -12
- package/dist/duration.js +13 -37
- package/dist/duration.mjs +8 -11
- package/dist/format.d.mts +5 -8
- package/dist/format.d.ts +5 -8
- package/dist/format.js +35 -76
- package/dist/format.mjs +29 -49
- package/dist/formatter.d.mts +3 -6
- package/dist/formatter.d.ts +3 -6
- package/dist/formatter.js +26 -50
- package/dist/formatter.mjs +21 -24
- package/dist/get-era-format.d.mts +2 -6
- package/dist/get-era-format.d.ts +2 -6
- package/dist/get-era-format.js +9 -34
- package/dist/get-era-format.mjs +5 -9
- package/dist/index.d.mts +15 -15
- package/dist/index.d.ts +15 -15
- package/dist/index.js +66 -47
- package/dist/index.mjs +14 -14
- package/dist/locale.d.mts +3 -5
- package/dist/locale.d.ts +3 -5
- package/dist/locale.js +28 -55
- package/dist/locale.mjs +22 -28
- package/dist/mutation.d.mts +6 -10
- package/dist/mutation.d.ts +6 -10
- package/dist/mutation.js +21 -53
- package/dist/mutation.mjs +14 -30
- package/dist/pagination.d.mts +16 -19
- package/dist/pagination.d.ts +16 -19
- package/dist/pagination.js +120 -201
- package/dist/pagination.mjs +106 -166
- package/dist/parse-date.d.mts +2 -6
- package/dist/parse-date.d.ts +2 -6
- package/dist/parse-date.js +41 -72
- package/dist/parse-date.mjs +37 -47
- package/dist/preset.d.mts +3 -6
- package/dist/preset.d.ts +3 -6
- package/dist/preset.js +23 -63
- package/dist/preset.mjs +19 -47
- package/dist/types.d.mts +17 -20
- package/dist/types.d.ts +17 -20
- package/dist/types.js +4 -18
- package/dist/types.mjs +1 -0
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export
|
|
1
|
+
import { alignDate, alignStartDate } from "./align.mjs";
|
|
2
|
+
import { isDateEqual, isDateOutsideRange, isDateUnavailable, isNextRangeInvalid, isPreviousRangeInvalid } from "./assertion.mjs";
|
|
3
|
+
import { alignCenter, alignEnd, alignStart, constrainSegments, constrainStart, constrainValue } from "./constrain.mjs";
|
|
4
|
+
import { getEndDate, getUnitDuration } from "./duration.mjs";
|
|
5
|
+
import { formatRange, formatSelectedDate, formatVisibleRange } from "./format.mjs";
|
|
6
|
+
import { getDayFormatter, getMonthFormatter } from "./formatter.mjs";
|
|
7
|
+
import { getDaysInWeek, getEndOfWeek, getMonthDays, getMonthNames, getStartOfWeek, getWeekDays, getWeekOfYear, getWeekdayFormats } from "./date-month.mjs";
|
|
8
|
+
import { getDecadeRange, getDefaultYearRange, getYearsRange, normalizeYear } from "./date-year.mjs";
|
|
9
|
+
import { getPreviousAvailableDate, getTodayDate, setCalendar, setDate } from "./mutation.mjs";
|
|
10
|
+
import { getAdjustedDateFn, getNextPage, getNextRow, getNextSection, getPreviousPage, getPreviousRow, getPreviousSection, getSectionEnd, getSectionStart } from "./pagination.mjs";
|
|
11
|
+
import { ensureValidCharacters, getLocaleSeparator, isValidCharacter } from "./locale.mjs";
|
|
12
|
+
import { parseDateString } from "./parse-date.mjs";
|
|
13
|
+
import { getDateRangePreset } from "./preset.mjs";
|
|
14
|
+
export { alignCenter, alignDate, alignEnd, alignStart, alignStartDate, constrainSegments, constrainStart, constrainValue, ensureValidCharacters, formatRange, formatSelectedDate, formatVisibleRange, getAdjustedDateFn, getDateRangePreset, getDayFormatter, getDaysInWeek, getDecadeRange, getDefaultYearRange, getEndDate, getEndOfWeek, getLocaleSeparator, getMonthDays, getMonthFormatter, getMonthNames, getNextPage, getNextRow, getNextSection, getPreviousAvailableDate, getPreviousPage, getPreviousRow, getPreviousSection, getSectionEnd, getSectionStart, getStartOfWeek, getTodayDate, getUnitDuration, getWeekDays, getWeekOfYear, getWeekdayFormats, getYearsRange, isDateEqual, isDateOutsideRange, isDateUnavailable, isNextRangeInvalid, isPreviousRangeInvalid, isValidCharacter, normalizeYear, parseDateString, setCalendar, setDate };
|
package/dist/locale.d.mts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
declare const isValidCharacter: (char: string | null, separator: string, locale?: string) => boolean;
|
|
2
|
-
declare const ensureValidCharacters: (value: string, separator: string, locale?: string) => string;
|
|
3
|
-
declare function getLocaleSeparator(locale: string): string;
|
|
4
|
-
|
|
5
|
-
export { ensureValidCharacters, getLocaleSeparator, isValidCharacter };
|
|
1
|
+
export declare const isValidCharacter: (char: string | null, separator: string, locale?: string) => boolean;
|
|
2
|
+
export declare const ensureValidCharacters: (value: string, separator: string, locale?: string) => string;
|
|
3
|
+
export declare function getLocaleSeparator(locale: string): string;
|
package/dist/locale.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
declare const isValidCharacter: (char: string | null, separator: string, locale?: string) => boolean;
|
|
2
|
-
declare const ensureValidCharacters: (value: string, separator: string, locale?: string) => string;
|
|
3
|
-
declare function getLocaleSeparator(locale: string): string;
|
|
4
|
-
|
|
5
|
-
export { ensureValidCharacters, getLocaleSeparator, isValidCharacter };
|
|
1
|
+
export declare const isValidCharacter: (char: string | null, separator: string, locale?: string) => boolean;
|
|
2
|
+
export declare const ensureValidCharacters: (value: string, separator: string, locale?: string) => string;
|
|
3
|
+
export declare function getLocaleSeparator(locale: string): string;
|
package/dist/locale.js
CHANGED
|
@@ -1,63 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/locale.ts
|
|
21
|
-
var locale_exports = {};
|
|
22
|
-
__export(locale_exports, {
|
|
23
|
-
ensureValidCharacters: () => ensureValidCharacters,
|
|
24
|
-
getLocaleSeparator: () => getLocaleSeparator,
|
|
25
|
-
isValidCharacter: () => isValidCharacter
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
26
4
|
});
|
|
27
|
-
|
|
28
|
-
|
|
5
|
+
// src/locale.ts
|
|
6
|
+
const digitsCache = /* @__PURE__ */ new Map();
|
|
29
7
|
function getLocaleDigits(locale) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return digits;
|
|
8
|
+
let digits = digitsCache.get(locale);
|
|
9
|
+
if (digits != null) return digits;
|
|
10
|
+
digits = "0123456789" + new Intl.NumberFormat(locale, { useGrouping: false }).format(1234567890);
|
|
11
|
+
digitsCache.set(locale, digits);
|
|
12
|
+
return digits;
|
|
36
13
|
}
|
|
37
|
-
|
|
38
|
-
|
|
14
|
+
const isDigit = (char, locale) => {
|
|
15
|
+
return locale ? getLocaleDigits(locale).includes(char) : /\d/.test(char);
|
|
39
16
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
17
|
+
const isValidCharacter = (char, separator, locale) => {
|
|
18
|
+
if (!char) return true;
|
|
19
|
+
if (char.length !== 1) return true;
|
|
20
|
+
return isDigit(char, locale) || separator.includes(char);
|
|
44
21
|
};
|
|
45
|
-
|
|
46
|
-
|
|
22
|
+
const ensureValidCharacters = (value, separator, locale) => {
|
|
23
|
+
return value.split("").filter((char) => isValidCharacter(char, separator, locale)).join("");
|
|
47
24
|
};
|
|
48
|
-
|
|
25
|
+
const separatorCache = /* @__PURE__ */ new Map();
|
|
49
26
|
function getLocaleSeparator(locale) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return separator;
|
|
27
|
+
let separator = separatorCache.get(locale);
|
|
28
|
+
if (separator != null) return separator;
|
|
29
|
+
const literal = new Intl.DateTimeFormat(locale).formatToParts(/* @__PURE__ */ new Date()).find((part) => part.type === "literal");
|
|
30
|
+
separator = literal ? literal.value : "/";
|
|
31
|
+
separatorCache.set(locale, separator);
|
|
32
|
+
return separator;
|
|
57
33
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
getLocaleSeparator,
|
|
62
|
-
isValidCharacter
|
|
63
|
-
});
|
|
34
|
+
exports.ensureValidCharacters = ensureValidCharacters;
|
|
35
|
+
exports.getLocaleSeparator = getLocaleSeparator;
|
|
36
|
+
exports.isValidCharacter = isValidCharacter;
|
package/dist/locale.mjs
CHANGED
|
@@ -1,36 +1,30 @@
|
|
|
1
1
|
// src/locale.ts
|
|
2
|
-
|
|
2
|
+
const digitsCache = /* @__PURE__ */ new Map();
|
|
3
3
|
function getLocaleDigits(locale) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return digits;
|
|
4
|
+
let digits = digitsCache.get(locale);
|
|
5
|
+
if (digits != null) return digits;
|
|
6
|
+
digits = "0123456789" + new Intl.NumberFormat(locale, { useGrouping: false }).format(1234567890);
|
|
7
|
+
digitsCache.set(locale, digits);
|
|
8
|
+
return digits;
|
|
10
9
|
}
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const isDigit = (char, locale) => {
|
|
11
|
+
return locale ? getLocaleDigits(locale).includes(char) : /\d/.test(char);
|
|
13
12
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
const isValidCharacter = (char, separator, locale) => {
|
|
14
|
+
if (!char) return true;
|
|
15
|
+
if (char.length !== 1) return true;
|
|
16
|
+
return isDigit(char, locale) || separator.includes(char);
|
|
18
17
|
};
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
const ensureValidCharacters = (value, separator, locale) => {
|
|
19
|
+
return value.split("").filter((char) => isValidCharacter(char, separator, locale)).join("");
|
|
21
20
|
};
|
|
22
|
-
|
|
21
|
+
const separatorCache = /* @__PURE__ */ new Map();
|
|
23
22
|
function getLocaleSeparator(locale) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return separator;
|
|
23
|
+
let separator = separatorCache.get(locale);
|
|
24
|
+
if (separator != null) return separator;
|
|
25
|
+
const literal = new Intl.DateTimeFormat(locale).formatToParts(/* @__PURE__ */ new Date()).find((part) => part.type === "literal");
|
|
26
|
+
separator = literal ? literal.value : "/";
|
|
27
|
+
separatorCache.set(locale, separator);
|
|
28
|
+
return separator;
|
|
31
29
|
}
|
|
32
|
-
export {
|
|
33
|
-
ensureValidCharacters,
|
|
34
|
-
getLocaleSeparator,
|
|
35
|
-
isValidCharacter
|
|
36
|
-
};
|
|
30
|
+
export { ensureValidCharacters, getLocaleSeparator, isValidCharacter };
|
package/dist/mutation.d.mts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare function
|
|
6
|
-
declare function
|
|
7
|
-
declare function setDate(date: DateValue, startDate: DateValue, isDateUnavailable: DateAvailableFn, locale: string, minValue: DateValue, maxValue: DateValue): DateValue | undefined;
|
|
8
|
-
declare function getPreviousAvailableDate(date: DateValue, minValue: DateValue, locale: string, isDateUnavailable?: DateAvailableFn): DateValue | undefined;
|
|
9
|
-
|
|
10
|
-
export { getPreviousAvailableDate, getTodayDate, setCalendar, setDate };
|
|
1
|
+
import { DateAvailableFn } from "./types.mjs";
|
|
2
|
+
import { Calendar, DateValue } from "@internationalized/date";
|
|
3
|
+
export declare function getTodayDate(timeZone?: string, calendar?: Calendar): import("@internationalized/date").CalendarDate;
|
|
4
|
+
export declare function setCalendar(date: DateValue, calendar: Calendar): import("@internationalized/date").CalendarDateTime;
|
|
5
|
+
export declare function setDate(date: DateValue, startDate: DateValue, isDateUnavailable: DateAvailableFn, locale: string, minValue: DateValue, maxValue: DateValue): DateValue | undefined;
|
|
6
|
+
export declare function getPreviousAvailableDate(date: DateValue, minValue: DateValue, locale: string, isDateUnavailable?: DateAvailableFn): DateValue | undefined;
|
package/dist/mutation.d.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare function
|
|
6
|
-
declare function
|
|
7
|
-
declare function setDate(date: DateValue, startDate: DateValue, isDateUnavailable: DateAvailableFn, locale: string, minValue: DateValue, maxValue: DateValue): DateValue | undefined;
|
|
8
|
-
declare function getPreviousAvailableDate(date: DateValue, minValue: DateValue, locale: string, isDateUnavailable?: DateAvailableFn): DateValue | undefined;
|
|
9
|
-
|
|
10
|
-
export { getPreviousAvailableDate, getTodayDate, setCalendar, setDate };
|
|
1
|
+
import { DateAvailableFn } from "./types.js";
|
|
2
|
+
import { Calendar, DateValue } from "@internationalized/date";
|
|
3
|
+
export declare function getTodayDate(timeZone?: string, calendar?: Calendar): import("@internationalized/date").CalendarDate;
|
|
4
|
+
export declare function setCalendar(date: DateValue, calendar: Calendar): import("@internationalized/date").CalendarDateTime;
|
|
5
|
+
export declare function setDate(date: DateValue, startDate: DateValue, isDateUnavailable: DateAvailableFn, locale: string, minValue: DateValue, maxValue: DateValue): DateValue | undefined;
|
|
6
|
+
export declare function getPreviousAvailableDate(date: DateValue, minValue: DateValue, locale: string, isDateUnavailable?: DateAvailableFn): DateValue | undefined;
|
package/dist/mutation.js
CHANGED
|
@@ -1,62 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/mutation.ts
|
|
21
|
-
var mutation_exports = {};
|
|
22
|
-
__export(mutation_exports, {
|
|
23
|
-
getPreviousAvailableDate: () => getPreviousAvailableDate,
|
|
24
|
-
getTodayDate: () => getTodayDate,
|
|
25
|
-
setCalendar: () => setCalendar,
|
|
26
|
-
setDate: () => setDate
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
27
4
|
});
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
5
|
+
const require_constrain = require("./constrain.js");
|
|
6
|
+
let _internationalized_date = require("@internationalized/date");
|
|
7
|
+
// src/mutation.ts
|
|
31
8
|
function getTodayDate(timeZone, calendar) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
9
|
+
const tod = (0, _internationalized_date.today)(timeZone ?? (0, _internationalized_date.getLocalTimeZone)());
|
|
10
|
+
if (calendar) return (0, _internationalized_date.toCalendar)(tod, calendar);
|
|
11
|
+
return tod;
|
|
35
12
|
}
|
|
36
13
|
function setCalendar(date, calendar) {
|
|
37
|
-
|
|
14
|
+
return (0, _internationalized_date.toCalendar)((0, _internationalized_date.toCalendarDateTime)(date), calendar);
|
|
38
15
|
}
|
|
39
16
|
function setDate(date, startDate, isDateUnavailable, locale, minValue, maxValue) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
17
|
+
let result;
|
|
18
|
+
result = require_constrain.constrainValue(date, minValue, maxValue);
|
|
19
|
+
result = getPreviousAvailableDate(date, startDate, locale, isDateUnavailable);
|
|
20
|
+
return result;
|
|
44
21
|
}
|
|
45
22
|
function getPreviousAvailableDate(date, minValue, locale, isDateUnavailable) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
while (date.compare(minValue) >= 0 && isDateUnavailable(date, locale)) {
|
|
50
|
-
date = date.subtract({ days: 1 });
|
|
51
|
-
}
|
|
52
|
-
if (date.compare(minValue) >= 0) {
|
|
53
|
-
return date;
|
|
54
|
-
}
|
|
23
|
+
if (!isDateUnavailable) return date;
|
|
24
|
+
while (date.compare(minValue) >= 0 && isDateUnavailable(date, locale)) date = date.subtract({ days: 1 });
|
|
25
|
+
if (date.compare(minValue) >= 0) return date;
|
|
55
26
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
setCalendar,
|
|
61
|
-
setDate
|
|
62
|
-
});
|
|
27
|
+
exports.getPreviousAvailableDate = getPreviousAvailableDate;
|
|
28
|
+
exports.getTodayDate = getTodayDate;
|
|
29
|
+
exports.setCalendar = setCalendar;
|
|
30
|
+
exports.setDate = setDate;
|
package/dist/mutation.mjs
CHANGED
|
@@ -1,39 +1,23 @@
|
|
|
1
|
-
// src/mutation.ts
|
|
2
|
-
import {
|
|
3
|
-
getLocalTimeZone,
|
|
4
|
-
toCalendar,
|
|
5
|
-
toCalendarDateTime,
|
|
6
|
-
today
|
|
7
|
-
} from "@internationalized/date";
|
|
8
1
|
import { constrainValue } from "./constrain.mjs";
|
|
2
|
+
import { getLocalTimeZone, toCalendar, toCalendarDateTime, today } from "@internationalized/date";
|
|
3
|
+
// src/mutation.ts
|
|
9
4
|
function getTodayDate(timeZone, calendar) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
const tod = today(timeZone ?? getLocalTimeZone());
|
|
6
|
+
if (calendar) return toCalendar(tod, calendar);
|
|
7
|
+
return tod;
|
|
13
8
|
}
|
|
14
9
|
function setCalendar(date, calendar) {
|
|
15
|
-
|
|
10
|
+
return toCalendar(toCalendarDateTime(date), calendar);
|
|
16
11
|
}
|
|
17
12
|
function setDate(date, startDate, isDateUnavailable, locale, minValue, maxValue) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
let result;
|
|
14
|
+
result = constrainValue(date, minValue, maxValue);
|
|
15
|
+
result = getPreviousAvailableDate(date, startDate, locale, isDateUnavailable);
|
|
16
|
+
return result;
|
|
22
17
|
}
|
|
23
18
|
function getPreviousAvailableDate(date, minValue, locale, isDateUnavailable) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
while (date.compare(minValue) >= 0 && isDateUnavailable(date, locale)) {
|
|
28
|
-
date = date.subtract({ days: 1 });
|
|
29
|
-
}
|
|
30
|
-
if (date.compare(minValue) >= 0) {
|
|
31
|
-
return date;
|
|
32
|
-
}
|
|
19
|
+
if (!isDateUnavailable) return date;
|
|
20
|
+
while (date.compare(minValue) >= 0 && isDateUnavailable(date, locale)) date = date.subtract({ days: 1 });
|
|
21
|
+
if (date.compare(minValue) >= 0) return date;
|
|
33
22
|
}
|
|
34
|
-
export {
|
|
35
|
-
getPreviousAvailableDate,
|
|
36
|
-
getTodayDate,
|
|
37
|
-
setCalendar,
|
|
38
|
-
setDate
|
|
39
|
-
};
|
|
23
|
+
export { getPreviousAvailableDate, getTodayDate, setCalendar, setDate };
|
package/dist/pagination.d.mts
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
focusedDate: DateValue;
|
|
1
|
+
import { DateValue as DateValue$1 } from "./types.mjs";
|
|
2
|
+
import { DateDuration } from "@internationalized/date";
|
|
3
|
+
export interface AdjustDateParams {
|
|
4
|
+
startDate: DateValue$1;
|
|
5
|
+
focusedDate: DateValue$1;
|
|
7
6
|
}
|
|
8
|
-
interface AdjustDateReturn extends AdjustDateParams {
|
|
9
|
-
|
|
7
|
+
export interface AdjustDateReturn extends AdjustDateParams {
|
|
8
|
+
endDate: DateValue$1;
|
|
10
9
|
}
|
|
11
|
-
declare function getAdjustedDateFn(visibleDuration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue): (options: AdjustDateParams) => AdjustDateReturn;
|
|
12
|
-
declare function getNextPage(focusedDate: DateValue, startDate: DateValue, visibleDuration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue): AdjustDateReturn;
|
|
13
|
-
declare function getPreviousPage(focusedDate: DateValue, startDate: DateValue, visibleDuration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue): AdjustDateReturn;
|
|
14
|
-
declare function getNextRow(focusedDate: DateValue, startDate: DateValue, visibleDuration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue): AdjustDateReturn | undefined;
|
|
15
|
-
declare function getPreviousRow(focusedDate: DateValue, startDate: DateValue, visibleDuration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue): AdjustDateReturn | undefined;
|
|
16
|
-
declare function getSectionStart(focusedDate: DateValue, startDate: DateValue, visibleDuration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue): AdjustDateReturn | undefined;
|
|
17
|
-
declare function getSectionEnd(focusedDate: DateValue, startDate: DateValue, visibleDuration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue): AdjustDateReturn | undefined;
|
|
18
|
-
declare function getNextSection(focusedDate: DateValue, startDate: DateValue, larger: boolean, visibleDuration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue): AdjustDateReturn | undefined;
|
|
19
|
-
declare function getPreviousSection(focusedDate: DateValue, startDate: DateValue, larger: boolean, visibleDuration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue): AdjustDateReturn | undefined;
|
|
20
|
-
|
|
21
|
-
export { type AdjustDateParams, type AdjustDateReturn, getAdjustedDateFn, getNextPage, getNextRow, getNextSection, getPreviousPage, getPreviousRow, getPreviousSection, getSectionEnd, getSectionStart };
|
|
10
|
+
export declare function getAdjustedDateFn(visibleDuration: DateDuration, locale: string, minValue?: DateValue$1, maxValue?: DateValue$1): (options: AdjustDateParams) => AdjustDateReturn;
|
|
11
|
+
export declare function getNextPage(focusedDate: DateValue$1, startDate: DateValue$1, visibleDuration: DateDuration, locale: string, minValue?: DateValue$1, maxValue?: DateValue$1): AdjustDateReturn;
|
|
12
|
+
export declare function getPreviousPage(focusedDate: DateValue$1, startDate: DateValue$1, visibleDuration: DateDuration, locale: string, minValue?: DateValue$1, maxValue?: DateValue$1): AdjustDateReturn;
|
|
13
|
+
export declare function getNextRow(focusedDate: DateValue$1, startDate: DateValue$1, visibleDuration: DateDuration, locale: string, minValue?: DateValue$1, maxValue?: DateValue$1): AdjustDateReturn | undefined;
|
|
14
|
+
export declare function getPreviousRow(focusedDate: DateValue$1, startDate: DateValue$1, visibleDuration: DateDuration, locale: string, minValue?: DateValue$1, maxValue?: DateValue$1): AdjustDateReturn | undefined;
|
|
15
|
+
export declare function getSectionStart(focusedDate: DateValue$1, startDate: DateValue$1, visibleDuration: DateDuration, locale: string, minValue?: DateValue$1, maxValue?: DateValue$1): AdjustDateReturn | undefined;
|
|
16
|
+
export declare function getSectionEnd(focusedDate: DateValue$1, startDate: DateValue$1, visibleDuration: DateDuration, locale: string, minValue?: DateValue$1, maxValue?: DateValue$1): AdjustDateReturn | undefined;
|
|
17
|
+
export declare function getNextSection(focusedDate: DateValue$1, startDate: DateValue$1, larger: boolean, visibleDuration: DateDuration, locale: string, minValue?: DateValue$1, maxValue?: DateValue$1): AdjustDateReturn | undefined;
|
|
18
|
+
export declare function getPreviousSection(focusedDate: DateValue$1, startDate: DateValue$1, larger: boolean, visibleDuration: DateDuration, locale: string, minValue?: DateValue$1, maxValue?: DateValue$1): AdjustDateReturn | undefined;
|
package/dist/pagination.d.ts
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
focusedDate: DateValue;
|
|
1
|
+
import { DateValue as DateValue$1 } from "./types.js";
|
|
2
|
+
import { DateDuration } from "@internationalized/date";
|
|
3
|
+
export interface AdjustDateParams {
|
|
4
|
+
startDate: DateValue$1;
|
|
5
|
+
focusedDate: DateValue$1;
|
|
7
6
|
}
|
|
8
|
-
interface AdjustDateReturn extends AdjustDateParams {
|
|
9
|
-
|
|
7
|
+
export interface AdjustDateReturn extends AdjustDateParams {
|
|
8
|
+
endDate: DateValue$1;
|
|
10
9
|
}
|
|
11
|
-
declare function getAdjustedDateFn(visibleDuration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue): (options: AdjustDateParams) => AdjustDateReturn;
|
|
12
|
-
declare function getNextPage(focusedDate: DateValue, startDate: DateValue, visibleDuration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue): AdjustDateReturn;
|
|
13
|
-
declare function getPreviousPage(focusedDate: DateValue, startDate: DateValue, visibleDuration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue): AdjustDateReturn;
|
|
14
|
-
declare function getNextRow(focusedDate: DateValue, startDate: DateValue, visibleDuration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue): AdjustDateReturn | undefined;
|
|
15
|
-
declare function getPreviousRow(focusedDate: DateValue, startDate: DateValue, visibleDuration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue): AdjustDateReturn | undefined;
|
|
16
|
-
declare function getSectionStart(focusedDate: DateValue, startDate: DateValue, visibleDuration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue): AdjustDateReturn | undefined;
|
|
17
|
-
declare function getSectionEnd(focusedDate: DateValue, startDate: DateValue, visibleDuration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue): AdjustDateReturn | undefined;
|
|
18
|
-
declare function getNextSection(focusedDate: DateValue, startDate: DateValue, larger: boolean, visibleDuration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue): AdjustDateReturn | undefined;
|
|
19
|
-
declare function getPreviousSection(focusedDate: DateValue, startDate: DateValue, larger: boolean, visibleDuration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue): AdjustDateReturn | undefined;
|
|
20
|
-
|
|
21
|
-
export { type AdjustDateParams, type AdjustDateReturn, getAdjustedDateFn, getNextPage, getNextRow, getNextSection, getPreviousPage, getPreviousRow, getPreviousSection, getSectionEnd, getSectionStart };
|
|
10
|
+
export declare function getAdjustedDateFn(visibleDuration: DateDuration, locale: string, minValue?: DateValue$1, maxValue?: DateValue$1): (options: AdjustDateParams) => AdjustDateReturn;
|
|
11
|
+
export declare function getNextPage(focusedDate: DateValue$1, startDate: DateValue$1, visibleDuration: DateDuration, locale: string, minValue?: DateValue$1, maxValue?: DateValue$1): AdjustDateReturn;
|
|
12
|
+
export declare function getPreviousPage(focusedDate: DateValue$1, startDate: DateValue$1, visibleDuration: DateDuration, locale: string, minValue?: DateValue$1, maxValue?: DateValue$1): AdjustDateReturn;
|
|
13
|
+
export declare function getNextRow(focusedDate: DateValue$1, startDate: DateValue$1, visibleDuration: DateDuration, locale: string, minValue?: DateValue$1, maxValue?: DateValue$1): AdjustDateReturn | undefined;
|
|
14
|
+
export declare function getPreviousRow(focusedDate: DateValue$1, startDate: DateValue$1, visibleDuration: DateDuration, locale: string, minValue?: DateValue$1, maxValue?: DateValue$1): AdjustDateReturn | undefined;
|
|
15
|
+
export declare function getSectionStart(focusedDate: DateValue$1, startDate: DateValue$1, visibleDuration: DateDuration, locale: string, minValue?: DateValue$1, maxValue?: DateValue$1): AdjustDateReturn | undefined;
|
|
16
|
+
export declare function getSectionEnd(focusedDate: DateValue$1, startDate: DateValue$1, visibleDuration: DateDuration, locale: string, minValue?: DateValue$1, maxValue?: DateValue$1): AdjustDateReturn | undefined;
|
|
17
|
+
export declare function getNextSection(focusedDate: DateValue$1, startDate: DateValue$1, larger: boolean, visibleDuration: DateDuration, locale: string, minValue?: DateValue$1, maxValue?: DateValue$1): AdjustDateReturn | undefined;
|
|
18
|
+
export declare function getPreviousSection(focusedDate: DateValue$1, startDate: DateValue$1, larger: boolean, visibleDuration: DateDuration, locale: string, minValue?: DateValue$1, maxValue?: DateValue$1): AdjustDateReturn | undefined;
|