@zag-js/date-utils 0.0.0-dev-20230107115230 → 0.0.0-dev-20230107162034

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.
Files changed (72) hide show
  1. package/dist/align.d.ts +4 -4
  2. package/dist/align.js +20 -24
  3. package/dist/align.mjs +2 -2
  4. package/dist/assertion.d.ts +8 -8
  5. package/dist/assertion.js +15 -16
  6. package/dist/assertion.mjs +1 -1
  7. package/dist/chunk-6EJZROXM.mjs +45 -0
  8. package/dist/{chunk-TCPXGBJP.mjs → chunk-BBE325GQ.mjs} +9 -8
  9. package/dist/chunk-BUT5IUNZ.mjs +32 -0
  10. package/dist/{chunk-EXWX3KZT.mjs → chunk-CAV5WKCZ.mjs} +4 -2
  11. package/dist/chunk-GKU5M6QU.mjs +25 -0
  12. package/dist/{chunk-XHAL6X5Z.mjs → chunk-HKHGJ6WS.mjs} +3 -3
  13. package/dist/{chunk-ECAENYV6.mjs → chunk-HUBKWHIN.mjs} +1 -1
  14. package/dist/{chunk-M4F23P2U.mjs → chunk-JZVHAOWX.mjs} +3 -3
  15. package/dist/{chunk-2DZ3KIVJ.mjs → chunk-L3YHK2WH.mjs} +1 -1
  16. package/dist/chunk-MGPXEJO4.mjs +71 -0
  17. package/dist/chunk-MY373KF2.mjs +198 -0
  18. package/dist/chunk-URPTPFL3.mjs +31 -0
  19. package/dist/chunk-ZZPZ2BFS.mjs +52 -0
  20. package/dist/constrain.d.ts +6 -7
  21. package/dist/constrain.js +20 -25
  22. package/dist/constrain.mjs +1 -1
  23. package/dist/format-range.d.ts +2 -3
  24. package/dist/format-range.js +3 -3
  25. package/dist/format-range.mjs +1 -1
  26. package/dist/format-selected-date.d.ts +3 -3
  27. package/dist/format-selected-date.js +13 -13
  28. package/dist/format-selected-date.mjs +3 -4
  29. package/dist/format-visible-range.d.ts +3 -3
  30. package/dist/format-visible-range.js +18 -17
  31. package/dist/format-visible-range.mjs +4 -26
  32. package/dist/get-formatter.d.ts +4 -3
  33. package/dist/get-formatter.js +6 -8
  34. package/dist/get-formatter.mjs +1 -2
  35. package/dist/get-month-dates.mjs +2 -2
  36. package/dist/get-week-dates.d.ts +1 -1
  37. package/dist/get-week-dates.js +2 -2
  38. package/dist/get-week-dates.mjs +1 -1
  39. package/dist/index.d.ts +3 -2
  40. package/dist/index.js +284 -181
  41. package/dist/index.mjs +22 -19
  42. package/dist/mutation.d.ts +5 -5
  43. package/dist/mutation.js +16 -43
  44. package/dist/mutation.mjs +4 -5
  45. package/dist/pagination.d.ts +29 -10
  46. package/dist/pagination.js +183 -89
  47. package/dist/pagination.mjs +3 -2
  48. package/dist/placeholder.d.ts +1 -1
  49. package/dist/segment-constants.d.ts +1 -1
  50. package/dist/segment-limit.d.ts +2 -2
  51. package/dist/segment-limit.js +1 -1
  52. package/dist/segment-limit.mjs +1 -1
  53. package/dist/segment-mutation.d.ts +3 -4
  54. package/dist/segment-mutation.js +4 -2
  55. package/dist/segment-mutation.mjs +1 -1
  56. package/dist/segment-parts.d.ts +2 -2
  57. package/dist/segment-parts.js +4 -4
  58. package/dist/segment-parts.mjs +6 -6
  59. package/dist/types-cbf8b45a.d.ts +35 -0
  60. package/dist/types.d.ts +1 -1
  61. package/package.json +1 -1
  62. package/dist/chunk-6XKXGQP6.mjs +0 -32
  63. package/dist/chunk-7JERMWT3.mjs +0 -46
  64. package/dist/chunk-C4U2N3JC.mjs +0 -65
  65. package/dist/chunk-DI2YG6VG.mjs +0 -24
  66. package/dist/chunk-FJMTHABG.mjs +0 -8
  67. package/dist/chunk-HP2COJGP.mjs +0 -76
  68. package/dist/chunk-VWVBJ5CB.mjs +0 -110
  69. package/dist/get-era-format.d.ts +0 -5
  70. package/dist/get-era-format.js +0 -32
  71. package/dist/get-era-format.mjs +0 -6
  72. package/dist/types-9f60d2f1.d.ts +0 -61
@@ -1,2 +1,2 @@
1
- export { d as DateSegments, S as SEGMENT_PAGE_STEP, i as isSegmentEditable } from './types-9f60d2f1.js';
1
+ export { c as DateSegments, S as SEGMENT_PAGE_STEP, i as isSegmentEditable } from './types-cbf8b45a.js';
2
2
  import '@internationalized/date';
@@ -1,7 +1,7 @@
1
1
  import { DateValue } from '@internationalized/date';
2
- import { e as DateSegmentPart, f as DateFormatOptions } from './types-9f60d2f1.js';
2
+ import { d as DateSegmentPart, e as DateFormatOptions } from './types-cbf8b45a.js';
3
3
 
4
- declare function getSegmentLimits(date: DateValue, type: DateSegmentPart, options: DateFormatOptions): {
4
+ declare function getSegmentLimits(date: DateValue, type: DateSegmentPart, options?: Pick<DateFormatOptions, "hour12">): {
5
5
  value: number;
6
6
  min: number;
7
7
  max: number;
@@ -62,7 +62,7 @@ function getSegmentLimits(date, type, options) {
62
62
  max: 12
63
63
  };
64
64
  case "hour":
65
- if (options.hour12) {
65
+ if (options == null ? void 0 : options.hour12) {
66
66
  let isPM = date.hour >= 12;
67
67
  return {
68
68
  value: date.hour,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getSegmentLimits
3
- } from "./chunk-2DZ3KIVJ.mjs";
3
+ } from "./chunk-L3YHK2WH.mjs";
4
4
  export {
5
5
  getSegmentLimits
6
6
  };
@@ -1,8 +1,7 @@
1
- import * as _internationalized_date from '@internationalized/date';
2
1
  import { DateValue } from '@internationalized/date';
3
- import { e as DateSegmentPart, f as DateFormatOptions } from './types-9f60d2f1.js';
2
+ import { d as DateSegmentPart, e as DateFormatOptions } from './types-cbf8b45a.js';
4
3
 
5
- declare function addSegment(date: DateValue, part: DateSegmentPart, amount: number, options: DateFormatOptions): _internationalized_date.CalendarDate | _internationalized_date.CalendarDateTime | _internationalized_date.ZonedDateTime | undefined;
6
- declare function setSegment(date: DateValue, part: DateSegmentPart, value: number, options: DateFormatOptions): _internationalized_date.CalendarDate | _internationalized_date.CalendarDateTime | _internationalized_date.ZonedDateTime | undefined;
4
+ declare function addSegment(date: DateValue, part: DateSegmentPart, amount: number, options?: Pick<DateFormatOptions, "hour12">): DateValue;
5
+ declare function setSegment(date: DateValue, part: DateSegmentPart, value: number, options?: Pick<DateFormatOptions, "hour12">): DateValue;
7
6
 
8
7
  export { addSegment, setSegment };
@@ -44,10 +44,11 @@ function addSegment(date, part, amount, options) {
44
44
  case "second":
45
45
  return date.cycle(part, amount, {
46
46
  round: part !== "hour",
47
- hourCycle: options.hour12 ? 12 : 24
47
+ hourCycle: (options == null ? void 0 : options.hour12) ? 12 : 24
48
48
  });
49
49
  }
50
50
  }
51
+ return date;
51
52
  }
52
53
  function setSegment(date, part, value, options) {
53
54
  switch (part) {
@@ -66,7 +67,7 @@ function setSegment(date, part, value, options) {
66
67
  return isPM === wasPM ? date : date.set({ hour: wasPM ? hours - 12 : hours + 12 });
67
68
  }
68
69
  case "hour":
69
- if (options.hour12) {
70
+ if (options == null ? void 0 : options.hour12) {
70
71
  let hours = date.hour;
71
72
  let wasPM = hours >= 12;
72
73
  if (!wasPM && value === 12) {
@@ -81,6 +82,7 @@ function setSegment(date, part, value, options) {
81
82
  return date.set({ [part]: value });
82
83
  }
83
84
  }
85
+ return date;
84
86
  }
85
87
  // Annotate the CommonJS export names for ESM import in node:
86
88
  0 && (module.exports = {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  addSegment,
3
3
  setSegment
4
- } from "./chunk-EXWX3KZT.mjs";
4
+ } from "./chunk-CAV5WKCZ.mjs";
5
5
  export {
6
6
  addSegment,
7
7
  setSegment
@@ -1,8 +1,8 @@
1
1
  import { DateValue, DateFormatter } from '@internationalized/date';
2
- import { g as DateSegmentContext } from './types-9f60d2f1.js';
2
+ import { c as DateSegments } from './types-cbf8b45a.js';
3
3
 
4
4
  declare function getAllSegments(segments: Intl.DateTimeFormatPart[]): {};
5
- declare function getSegments(ctx: DateSegmentContext, date: DateValue, formatter: DateFormatter): ({
5
+ declare function getSegments(date: DateValue, validSegments: DateSegments, formatter: DateFormatter, timeZone: string): ({
6
6
  isPlaceholder: boolean;
7
7
  placeholder: any;
8
8
  isEditable: boolean;
@@ -80,7 +80,7 @@ function getSegmentLimits(date, type, options) {
80
80
  max: 12
81
81
  };
82
82
  case "hour":
83
- if (options.hour12) {
83
+ if (options == null ? void 0 : options.hour12) {
84
84
  let isPM = date.hour >= 12;
85
85
  return {
86
86
  value: date.hour,
@@ -118,13 +118,13 @@ function getPlaceholder(params) {
118
118
  const placeholder = { day: "dd", month: "mm", year: "yyyy" };
119
119
  return placeholder[params.field];
120
120
  }
121
- function getSegments(ctx, date, formatter) {
122
- const segments = formatter.formatToParts(date.toDate(ctx.timeZone));
121
+ function getSegments(date, validSegments, formatter, timeZone) {
122
+ const segments = formatter.formatToParts(date.toDate(timeZone));
123
123
  return segments.map((segment) => {
124
124
  let isEditable = isSegmentEditable(segment.type);
125
125
  if (segment.type === "era")
126
126
  isEditable = false;
127
- let isPlaceholder = isSegmentEditable(segment.type) && !ctx.validSegments[segment.type];
127
+ let isPlaceholder = isSegmentEditable(segment.type) && !validSegments[segment.type];
128
128
  let placeholder = isSegmentEditable(segment.type) ? getPlaceholder({ field: segment.type }) : null;
129
129
  return {
130
130
  type: segment.type,
@@ -1,9 +1,9 @@
1
+ import {
2
+ getSegmentLimits
3
+ } from "./chunk-L3YHK2WH.mjs";
1
4
  import {
2
5
  isSegmentEditable
3
6
  } from "./chunk-6NI2PIAA.mjs";
4
- import {
5
- getSegmentLimits
6
- } from "./chunk-2DZ3KIVJ.mjs";
7
7
 
8
8
  // src/segment-parts.ts
9
9
  function getAllSegments(segments) {
@@ -13,13 +13,13 @@ function getPlaceholder(params) {
13
13
  const placeholder = { day: "dd", month: "mm", year: "yyyy" };
14
14
  return placeholder[params.field];
15
15
  }
16
- function getSegments(ctx, date, formatter) {
17
- const segments = formatter.formatToParts(date.toDate(ctx.timeZone));
16
+ function getSegments(date, validSegments, formatter, timeZone) {
17
+ const segments = formatter.formatToParts(date.toDate(timeZone));
18
18
  return segments.map((segment) => {
19
19
  let isEditable = isSegmentEditable(segment.type);
20
20
  if (segment.type === "era")
21
21
  isEditable = false;
22
- let isPlaceholder = isSegmentEditable(segment.type) && !ctx.validSegments[segment.type];
22
+ let isPlaceholder = isSegmentEditable(segment.type) && !validSegments[segment.type];
23
23
  let placeholder = isSegmentEditable(segment.type) ? getPlaceholder({ field: segment.type }) : null;
24
24
  return {
25
25
  type: segment.type,
@@ -0,0 +1,35 @@
1
+ import { DateFormatter, DateValue } from '@internationalized/date';
2
+
3
+ declare const EDITABLE_SEGMENTS: {
4
+ year: boolean;
5
+ month: boolean;
6
+ day: boolean;
7
+ hour: boolean;
8
+ minute: boolean;
9
+ second: boolean;
10
+ dayPeriod: boolean;
11
+ era: boolean;
12
+ };
13
+ type DateSegments = Partial<typeof EDITABLE_SEGMENTS>;
14
+ declare const SEGMENT_PAGE_STEP: {
15
+ year: number;
16
+ month: number;
17
+ day: number;
18
+ hour: number;
19
+ minute: number;
20
+ second: number;
21
+ };
22
+ declare function isSegmentEditable(segment: DateSegmentPart): any;
23
+
24
+ type DateGranularity = "day" | "hour" | "minute" | "second" | "year" | "month";
25
+ type DateAlignment = "start" | "end" | "center";
26
+ type GetFormatterFn = (options: Intl.DateTimeFormatOptions) => DateFormatter;
27
+ type DateAvailableFn = (date: DateValue) => boolean;
28
+ type GetPlaceholderFn = (options: {
29
+ field: string;
30
+ locale: string;
31
+ }) => string;
32
+ type DateSegmentPart = Intl.DateTimeFormatPartTypes;
33
+ type DateFormatOptions = Intl.ResolvedDateTimeFormatOptions;
34
+
35
+ export { DateAlignment as D, GetFormatterFn as G, SEGMENT_PAGE_STEP as S, DateAvailableFn as a, DateGranularity as b, DateSegments as c, DateSegmentPart as d, DateFormatOptions as e, GetPlaceholderFn as f, isSegmentEditable as i };
package/dist/types.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  import '@internationalized/date';
2
- export { a as DateAlignment, D as DateContext, b as DateDescriptionContext, f as DateFormatOptions, c as DateGranularity, g as DateSegmentContext, e as DateSegmentPart, h as DateValueRange } from './types-9f60d2f1.js';
2
+ export { D as DateAlignment, a as DateAvailableFn, e as DateFormatOptions, b as DateGranularity, d as DateSegmentPart, c as DateSegments, G as GetFormatterFn, f as GetPlaceholderFn } from './types-cbf8b45a.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/date-utils",
3
- "version": "0.0.0-dev-20230107115230",
3
+ "version": "0.0.0-dev-20230107162034",
4
4
  "description": "Date utilities for zag.js",
5
5
  "keywords": [
6
6
  "js",
@@ -1,32 +0,0 @@
1
- import {
2
- alignCenter,
3
- alignEnd,
4
- alignStart
5
- } from "./chunk-HP2COJGP.mjs";
6
-
7
- // src/align.ts
8
- function alignDate(ctx, date, alignment) {
9
- switch (alignment) {
10
- case "start":
11
- return alignStart(ctx, date);
12
- case "end":
13
- return alignEnd(ctx, date);
14
- case "center":
15
- default:
16
- return alignCenter(ctx, date);
17
- }
18
- }
19
- function alignStartDate(ctx, focusedDate, startDate, endDate) {
20
- if (focusedDate.compare(startDate) < 0) {
21
- return alignEnd(ctx, focusedDate);
22
- }
23
- if (focusedDate.compare(endDate) > 0) {
24
- return alignStart(ctx, focusedDate);
25
- }
26
- return startDate;
27
- }
28
-
29
- export {
30
- alignDate,
31
- alignStartDate
32
- };
@@ -1,46 +0,0 @@
1
- // src/assertion.ts
2
- import { isSameDay, isToday } from "@internationalized/date";
3
- function isTodayDate(date, timezone) {
4
- return isToday(date, timezone);
5
- }
6
- function isDateEqual(dateA, dateB) {
7
- return dateB != null && isSameDay(dateA, dateB);
8
- }
9
- function isDateInvalid(ctx, date) {
10
- return ctx.min != null && date.compare(ctx.min) < 0 || ctx.max != null && date.compare(ctx.max) > 0;
11
- }
12
- function isDateDisabled(ctx, date, startDate, endDate) {
13
- return date.compare(startDate) < 0 || date.compare(endDate) > 0 || isDateInvalid(ctx, date);
14
- }
15
- function isDateUnavailable(ctx, date) {
16
- var _a;
17
- if (!date) {
18
- return false;
19
- }
20
- if ((_a = ctx.isUnavailable) == null ? void 0 : _a.call(ctx, date)) {
21
- return true;
22
- }
23
- return isDateInvalid(ctx, date);
24
- }
25
- function isDateOutsideVisibleRange(date, startDate, endDate) {
26
- return date.compare(startDate) < 0 || date.compare(endDate) > 0;
27
- }
28
- function isPreviousVisibleRangeInvalid(ctx, startDate) {
29
- let prev = startDate.subtract({ days: 1 });
30
- return isSameDay(prev, startDate) || isDateInvalid(ctx, prev);
31
- }
32
- function isNextVisibleRangeInvalid(ctx, endDate) {
33
- let next = endDate.add({ days: 1 });
34
- return isSameDay(next, endDate) || isDateInvalid(ctx, next);
35
- }
36
-
37
- export {
38
- isTodayDate,
39
- isDateEqual,
40
- isDateInvalid,
41
- isDateDisabled,
42
- isDateUnavailable,
43
- isDateOutsideVisibleRange,
44
- isPreviousVisibleRangeInvalid,
45
- isNextVisibleRangeInvalid
46
- };
@@ -1,65 +0,0 @@
1
- import {
2
- isDateUnavailable
3
- } from "./chunk-7JERMWT3.mjs";
4
- import {
5
- constrainValue
6
- } from "./chunk-HP2COJGP.mjs";
7
-
8
- // src/mutation.ts
9
- import { GregorianCalendar, toCalendar, toCalendarDate, today } from "@internationalized/date";
10
- function clampDate(ctx, date) {
11
- return constrainValue(ctx, date);
12
- }
13
- function getTodayDate(timezone) {
14
- return today(timezone);
15
- }
16
- function getNextDay(date) {
17
- return date.add({ days: 1 });
18
- }
19
- function getPreviousDay(date) {
20
- return date.subtract({ days: 1 });
21
- }
22
- function setMonth(date, month) {
23
- return date.set({ month });
24
- }
25
- function setYear(date, year) {
26
- return date.set({ year });
27
- }
28
- function setCalendar(date, calendar) {
29
- return toCalendar(toCalendarDate(date), calendar);
30
- }
31
- function setDate(ctx, date, nextDate, startDate) {
32
- let result;
33
- result = clampDate(ctx, nextDate);
34
- result = getPreviousAvailableDate(ctx, nextDate, startDate);
35
- if (!result)
36
- return;
37
- result = toCalendar(result, (date == null ? void 0 : date.calendar) || new GregorianCalendar());
38
- if (date && "hour" in date) {
39
- return date.set(result);
40
- }
41
- return result;
42
- }
43
- function getPreviousAvailableDate(ctx, date, min) {
44
- const minValue = min != null ? min : ctx.min;
45
- if (!isDateUnavailable(ctx, date) || !minValue) {
46
- return date;
47
- }
48
- while (date.compare(minValue) >= 0 && isDateUnavailable(ctx, date)) {
49
- date = date.subtract({ days: 1 });
50
- }
51
- if (date.compare(minValue) >= 0) {
52
- return date;
53
- }
54
- }
55
-
56
- export {
57
- clampDate,
58
- getTodayDate,
59
- getNextDay,
60
- getPreviousDay,
61
- setMonth,
62
- setYear,
63
- setCalendar,
64
- setDate
65
- };
@@ -1,24 +0,0 @@
1
- import {
2
- getDateFormatter
3
- } from "./chunk-TCPXGBJP.mjs";
4
- import {
5
- formatRange
6
- } from "./chunk-XHAL6X5Z.mjs";
7
-
8
- // src/format-selected-date.ts
9
- import { isSameDay } from "@internationalized/date";
10
- function formatSelectedDate(ctx) {
11
- const { start, end = start, timeZone } = ctx;
12
- let formatter = getDateFormatter(ctx);
13
- if (ctx.isSelectingRange || start == null || end == null) {
14
- return "";
15
- }
16
- if (isSameDay(start, end)) {
17
- return formatter.format(start.toDate(timeZone));
18
- }
19
- return formatRange(ctx, formatter);
20
- }
21
-
22
- export {
23
- formatSelectedDate
24
- };
@@ -1,8 +0,0 @@
1
- // src/get-era-format.ts
2
- function getEraFormat(date) {
3
- return (date == null ? void 0 : date.calendar.identifier) === "gregory" && date.era === "BC" ? "short" : void 0;
4
- }
5
-
6
- export {
7
- getEraFormat
8
- };
@@ -1,76 +0,0 @@
1
- // src/constrain.ts
2
- import {
3
- maxDate,
4
- minDate,
5
- startOfMonth,
6
- startOfWeek,
7
- startOfYear,
8
- toCalendarDate
9
- } from "@internationalized/date";
10
- function alignCenter(ctx, date) {
11
- const { duration } = ctx;
12
- let halfDuration = {};
13
- for (let key in duration) {
14
- halfDuration[key] = Math.floor(duration[key] / 2);
15
- if (halfDuration[key] > 0 && duration[key] % 2 === 0) {
16
- halfDuration[key]--;
17
- }
18
- }
19
- let aligned = alignStart(ctx, date).subtract(halfDuration);
20
- return constrainStart(ctx, date, aligned);
21
- }
22
- function alignStart(ctx, date) {
23
- let { locale, duration } = ctx;
24
- let aligned = date;
25
- if (duration.years) {
26
- aligned = startOfYear(date);
27
- } else if (duration.months) {
28
- aligned = startOfMonth(date);
29
- } else if (duration.weeks) {
30
- aligned = startOfWeek(date, locale);
31
- }
32
- return constrainStart(ctx, date, aligned);
33
- }
34
- function alignEnd(ctx, date) {
35
- const { duration } = ctx;
36
- let d = { ...duration };
37
- if (d.days) {
38
- d.days--;
39
- } else if (d.weeks) {
40
- d.weeks--;
41
- } else if (d.months) {
42
- d.months--;
43
- } else if (d.years) {
44
- d.years--;
45
- }
46
- let aligned = alignStart(ctx, date).subtract(d);
47
- return constrainStart(ctx, date, aligned);
48
- }
49
- function constrainValue(ctx, date) {
50
- let { min, max } = ctx;
51
- if (min) {
52
- date = maxDate(date, toCalendarDate(min));
53
- }
54
- if (max) {
55
- date = minDate(date, toCalendarDate(max));
56
- }
57
- return date;
58
- }
59
- function constrainStart(ctx, date, aligned) {
60
- let { min, max } = ctx;
61
- if (min && date.compare(min) >= 0) {
62
- aligned = maxDate(aligned, alignStart(ctx, toCalendarDate(min)));
63
- }
64
- if (max && date.compare(max) <= 0) {
65
- aligned = minDate(aligned, alignEnd(ctx, toCalendarDate(max)));
66
- }
67
- return aligned;
68
- }
69
-
70
- export {
71
- alignCenter,
72
- alignStart,
73
- alignEnd,
74
- constrainValue,
75
- constrainStart
76
- };
@@ -1,110 +0,0 @@
1
- import {
2
- alignStart,
3
- constrainStart,
4
- constrainValue
5
- } from "./chunk-HP2COJGP.mjs";
6
- import {
7
- getUnitDuration
8
- } from "./chunk-ZSLC7OI2.mjs";
9
-
10
- // src/pagination.ts
11
- import { endOfMonth, endOfWeek, startOfMonth, startOfWeek } from "@internationalized/date";
12
- function getNextPage(ctx, date, startDate) {
13
- const start = startDate.add(ctx.duration);
14
- return {
15
- startDate: alignStart(ctx, constrainStart(ctx, date, start)),
16
- focusedDate: constrainValue(ctx, date.add(ctx.duration))
17
- };
18
- }
19
- function getPreviousPage(ctx, date, startDate) {
20
- const start = startDate.subtract(ctx.duration);
21
- return {
22
- startDate: alignStart(ctx, constrainStart(ctx, date, start)),
23
- focusedDate: constrainValue(ctx, date.subtract(ctx.duration))
24
- };
25
- }
26
- function getSectionStart(ctx, date, startDate) {
27
- const d = ctx.duration;
28
- if (d.days) {
29
- return startDate;
30
- }
31
- if (d.weeks) {
32
- return startOfWeek(date, ctx.locale);
33
- }
34
- if (d.months || d.years) {
35
- return startOfMonth(date);
36
- }
37
- }
38
- function getSectionEnd(ctx, date, endDate) {
39
- const d = ctx.duration;
40
- if (d.days) {
41
- return endDate;
42
- }
43
- if (d.weeks) {
44
- return endOfWeek(date, ctx.locale);
45
- }
46
- if (d.months || d.years) {
47
- return endOfMonth(date);
48
- }
49
- }
50
- function getNextSection(ctx, date, larger) {
51
- const d = ctx.duration;
52
- const unitDuration = getUnitDuration(ctx.duration);
53
- if (!larger && !d.days) {
54
- return date.add(unitDuration);
55
- }
56
- if (d.days) {
57
- return date.add(d);
58
- }
59
- if (d.weeks) {
60
- return date.add({ months: 1 });
61
- }
62
- if (d.months || d.years) {
63
- return date.add({ years: 1 });
64
- }
65
- }
66
- function getPreviousSection(ctx, date, larger) {
67
- const d = ctx.duration;
68
- const unitDuration = getUnitDuration(ctx.duration);
69
- if (!larger && !d.days) {
70
- return date.subtract(unitDuration);
71
- }
72
- if (d.days) {
73
- return date.subtract(ctx.duration);
74
- }
75
- if (d.weeks) {
76
- return date.subtract({ months: 1 });
77
- }
78
- if (d.months || d.years) {
79
- return date.subtract({ years: 1 });
80
- }
81
- }
82
- function getNextRow(ctx, date, startDate) {
83
- const d = ctx.duration;
84
- if (d.days) {
85
- return getNextPage(ctx, date, startDate);
86
- }
87
- if (d.weeks || d.months || d.years) {
88
- return date.add({ weeks: 1 });
89
- }
90
- }
91
- function getPreviousRow(ctx, date, startDate) {
92
- const d = ctx.duration;
93
- if (d.days) {
94
- return getPreviousPage(ctx, date, startDate);
95
- }
96
- if (d.weeks || d.months || d.years) {
97
- return date.subtract({ weeks: 1 });
98
- }
99
- }
100
-
101
- export {
102
- getNextPage,
103
- getPreviousPage,
104
- getSectionStart,
105
- getSectionEnd,
106
- getNextSection,
107
- getPreviousSection,
108
- getNextRow,
109
- getPreviousRow
110
- };
@@ -1,5 +0,0 @@
1
- import { CalendarDate } from '@internationalized/date';
2
-
3
- declare function getEraFormat(date: CalendarDate | undefined): "short" | undefined;
4
-
5
- export { getEraFormat };
@@ -1,32 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
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/get-era-format.ts
21
- var get_era_format_exports = {};
22
- __export(get_era_format_exports, {
23
- getEraFormat: () => getEraFormat
24
- });
25
- module.exports = __toCommonJS(get_era_format_exports);
26
- function getEraFormat(date) {
27
- return (date == null ? void 0 : date.calendar.identifier) === "gregory" && date.era === "BC" ? "short" : void 0;
28
- }
29
- // Annotate the CommonJS export names for ESM import in node:
30
- 0 && (module.exports = {
31
- getEraFormat
32
- });
@@ -1,6 +0,0 @@
1
- import {
2
- getEraFormat
3
- } from "./chunk-FJMTHABG.mjs";
4
- export {
5
- getEraFormat
6
- };