impact-nova 2.5.6 → 2.5.8
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/components/data/ag-grid-react/ag-grid.types.d.ts +2 -2
- package/dist/components/data/ag-grid-react/headers/components/date-filter-picker.d.ts +4 -2
- package/dist/components/data/ag-grid-react/headers/header-search-input.js +65 -65
- package/dist/components/data/ag-grid-react/headers/utils/date-utils.js +55 -48
- package/dist/components/data-display/calendar/calendar-apply-validation.d.ts +4 -2
- package/dist/components/data-display/calendar/calendar-apply-validation.js +82 -51
- package/dist/components/data-display/calendar/calendar-config.d.ts +13 -5
- package/dist/components/data-display/calendar/calendar-config.js +31 -20
- package/dist/components/data-display/calendar/calendar-day-button.js +43 -35
- package/dist/components/data-display/calendar/calendar-day-hover.d.ts +8 -0
- package/dist/components/data-display/calendar/calendar-day-hover.js +20 -0
- package/dist/components/data-display/calendar/calendar-day-picker-classnames.d.ts +8 -1
- package/dist/components/data-display/calendar/calendar-day-picker-classnames.js +40 -20
- package/dist/components/data-display/calendar/calendar-day-picker-components.d.ts +12 -1
- package/dist/components/data-display/calendar/calendar-day-picker-components.js +199 -98
- package/dist/components/data-display/calendar/calendar-day-picker-view.d.ts +12 -4
- package/dist/components/data-display/calendar/calendar-day-picker-view.js +139 -92
- package/dist/components/data-display/calendar/calendar-fiscal-labels.d.ts +38 -0
- package/dist/components/data-display/calendar/calendar-fiscal-labels.js +90 -0
- package/dist/components/data-display/calendar/calendar-footer-summary.d.ts +13 -4
- package/dist/components/data-display/calendar/calendar-footer-summary.js +101 -50
- package/dist/components/data-display/calendar/calendar-footer.d.ts +16 -7
- package/dist/components/data-display/calendar/calendar-footer.js +88 -66
- package/dist/components/data-display/calendar/calendar-gregorian-presets.d.ts +2 -0
- package/dist/components/data-display/calendar/calendar-gregorian-presets.js +26 -0
- package/dist/components/data-display/calendar/calendar-interval-caption.d.ts +1 -0
- package/dist/components/data-display/calendar/calendar-interval-caption.js +10 -0
- package/dist/components/data-display/calendar/calendar-interval-utils.d.ts +23 -0
- package/dist/components/data-display/calendar/calendar-interval-utils.js +154 -0
- package/dist/components/data-display/calendar/calendar-month-panes.d.ts +5 -1
- package/dist/components/data-display/calendar/calendar-month-panes.js +9 -7
- package/dist/components/data-display/calendar/calendar-month-picker-panel.d.ts +5 -1
- package/dist/components/data-display/calendar/calendar-month-picker-panel.js +76 -77
- package/dist/components/data-display/calendar/calendar-month-utils.d.ts +2 -0
- package/dist/components/data-display/calendar/calendar-month-utils.js +69 -60
- package/dist/components/data-display/calendar/calendar-padding-week.utils.d.ts +15 -0
- package/dist/components/data-display/calendar/calendar-padding-week.utils.js +22 -3
- package/dist/components/data-display/calendar/calendar-panel-context.d.ts +1 -1
- package/dist/components/data-display/calendar/calendar-period-cell.d.ts +18 -0
- package/dist/components/data-display/calendar/calendar-period-cell.js +89 -0
- package/dist/components/data-display/calendar/calendar-period-keyboard.d.ts +2 -0
- package/dist/components/data-display/calendar/calendar-period-keyboard.js +18 -0
- package/dist/components/data-display/calendar/calendar-preset-strip.d.ts +6 -0
- package/dist/components/data-display/calendar/calendar-preset-strip.js +26 -0
- package/dist/components/data-display/calendar/calendar-quarter-panes.d.ts +24 -0
- package/dist/components/data-display/calendar/calendar-quarter-panes.js +115 -0
- package/dist/components/data-display/calendar/calendar-quarter-utils.d.ts +19 -0
- package/dist/components/data-display/calendar/calendar-quarter-utils.js +95 -0
- package/dist/components/data-display/calendar/calendar-selection-appearance.d.ts +38 -0
- package/dist/components/data-display/calendar/calendar-selection-appearance.js +72 -0
- package/dist/components/data-display/calendar/calendar-selection.d.ts +20 -0
- package/dist/components/data-display/calendar/calendar-selection.js +31 -0
- package/dist/components/data-display/calendar/calendar-week-number-cell.d.ts +6 -1
- package/dist/components/data-display/calendar/calendar-week-number-cell.js +53 -38
- package/dist/components/data-display/calendar/calendar-week-number-header.d.ts +4 -0
- package/dist/components/data-display/calendar/calendar-week-number-header.js +15 -0
- package/dist/components/data-display/calendar/calendar-week-utils.d.ts +11 -3
- package/dist/components/data-display/calendar/calendar-week-utils.js +50 -42
- package/dist/components/data-display/calendar/calendar-year-panes.d.ts +18 -0
- package/dist/components/data-display/calendar/calendar-year-panes.js +98 -0
- package/dist/components/data-display/calendar/calendar-year-utils.d.ts +17 -0
- package/dist/components/data-display/calendar/calendar-year-utils.js +75 -0
- package/dist/components/data-display/calendar/calendar.d.ts +1 -1
- package/dist/components/data-display/calendar/calendar.js +303 -181
- package/dist/components/data-display/calendar/calendar.types.d.ts +53 -16
- package/dist/components/data-display/calendar/fiscal-period-caption-select.d.ts +7 -0
- package/dist/components/data-display/calendar/fiscal-period-caption-select.js +63 -0
- package/dist/components/data-display/calendar/index.d.ts +1 -1
- package/dist/components/data-display/calendar/use-calendar-day-picker-config.d.ts +12 -2
- package/dist/components/data-display/calendar/use-calendar-day-picker-config.js +92 -62
- package/dist/components/data-display/calendar/use-calendar-state.d.ts +32 -12
- package/dist/components/data-display/calendar/use-calendar-state.js +371 -164
- package/dist/components/data-display/calendar/use-fiscal-calendar.d.ts +5 -0
- package/dist/components/data-display/calendar/use-fiscal-calendar.js +24 -0
- package/dist/components/feedback/tooltip/overflow-tooltip.js +57 -57
- package/dist/components/flows/guidance/guidance-error-boundary.js +22 -14
- package/dist/components/flows/guidance/guidance-layer.js +34 -32
- package/dist/components/flows/guidance/help-center/assets/whats-new-guide-icon.svg.js +4 -0
- package/dist/components/flows/guidance/help-center/filter-help-center-guides.js +10 -7
- package/dist/components/flows/guidance/help-center/guide-catalog-section.d.ts +7 -0
- package/dist/components/flows/guidance/help-center/guide-catalog-section.js +24 -0
- package/dist/components/flows/guidance/help-center/guide-catalog-utils.d.ts +3 -0
- package/dist/components/flows/guidance/help-center/guide-catalog-utils.js +19 -0
- package/dist/components/flows/guidance/help-center/guide-catalog.d.ts +1 -1
- package/dist/components/flows/guidance/help-center/guide-catalog.js +89 -79
- package/dist/components/flows/guidance/help-center/help-center-guide-labels.d.ts +6 -0
- package/dist/components/flows/guidance/help-center/help-center-guide-labels.js +33 -0
- package/dist/components/flows/guidance/help-center/help-center-guide-row.d.ts +12 -0
- package/dist/components/flows/guidance/help-center/help-center-guide-row.js +57 -0
- package/dist/components/flows/guidance/help-center/help-center-guide-type-icons.d.ts +9 -0
- package/dist/components/flows/guidance/help-center/help-center-guide-type-icons.js +114 -0
- package/dist/components/flows/guidance/help-center/help-center-header.d.ts +1 -1
- package/dist/components/flows/guidance/help-center/help-center-header.js +20 -16
- package/dist/components/flows/guidance/help-center/help-center.constants.d.ts +1 -1
- package/dist/components/flows/guidance/help-center/help-center.constants.js +1 -1
- package/dist/components/flows/guidance/help-center/help-center.d.ts +3 -1
- package/dist/components/flows/guidance/help-center/help-center.js +74 -51
- package/dist/components/flows/guidance/help-center/help-center.types.d.ts +9 -1
- package/dist/components/flows/guidance/help-center/renderHelpCenterGuideTypeIcon.d.ts +4 -0
- package/dist/components/flows/guidance/help-center/renderHelpCenterGuideTypeIcon.js +18 -0
- package/dist/components/flows/guidance/help-center.d.ts +4 -2
- package/dist/components/flows/guidance/help-center.js +23 -14
- package/dist/components/flows/guidance/hooks/useGuidanceOverlayGeometry.js +19 -17
- package/dist/components/flows/guidance/index.d.ts +1 -1
- package/dist/components/flows/guidance/renderers/announcement-renderer.d.ts +1 -1
- package/dist/components/flows/guidance/renderers/announcement-renderer.js +20 -12
- package/dist/components/flows/guidance/renderers/guidance-card-shared.d.ts +9 -11
- package/dist/components/flows/guidance/renderers/guidance-card-shared.js +124 -177
- package/dist/components/flows/guidance/renderers/guidance-renderer-shared.d.ts +1 -1
- package/dist/components/flows/guidance/renderers/guidance-renderer-shared.js +57 -72
- package/dist/components/flows/guidance/renderers/guidance-tour-overlay.js +23 -23
- package/dist/components/flows/wizard/wizard.js +41 -38
- package/dist/components/forms/date-picker/date-input-behavior.d.ts +7 -0
- package/dist/components/forms/date-picker/date-input-behavior.js +28 -24
- package/dist/components/forms/date-picker/date-picker-shell.d.ts +13 -0
- package/dist/components/forms/date-picker/date-picker-shell.js +31 -0
- package/dist/components/forms/date-picker/date-picker.js +187 -167
- package/dist/components/forms/date-picker/date-picker.types.d.ts +90 -43
- package/dist/components/forms/date-picker/date-range-picker.js +273 -224
- package/dist/components/forms/date-picker/fiscal-pass-through.d.ts +13 -0
- package/dist/components/forms/date-picker/fiscal-pass-through.js +17 -0
- package/dist/components/forms/date-picker/fiscal-period-format.d.ts +9 -0
- package/dist/components/forms/date-picker/fiscal-period-format.js +50 -0
- package/dist/components/forms/date-picker/index.d.ts +12 -0
- package/dist/components/forms/date-picker/index.js +19 -7
- package/dist/components/forms/date-picker/month-picker.js +225 -182
- package/dist/components/forms/date-picker/month-range-picker.js +134 -110
- package/dist/components/forms/date-picker/multi-date-picker.js +77 -56
- package/dist/components/forms/date-picker/multi-month-picker.js +78 -57
- package/dist/components/forms/date-picker/multi-quarter-picker.d.ts +3 -0
- package/dist/components/forms/date-picker/multi-quarter-picker.js +177 -0
- package/dist/components/forms/date-picker/multi-week-picker.js +81 -70
- package/dist/components/forms/date-picker/multi-year-picker.d.ts +3 -0
- package/dist/components/forms/date-picker/multi-year-picker.js +179 -0
- package/dist/components/forms/date-picker/quarter-picker.d.ts +3 -0
- package/dist/components/forms/date-picker/quarter-picker.js +176 -0
- package/dist/components/forms/date-picker/quarter-range-picker.d.ts +3 -0
- package/dist/components/forms/date-picker/quarter-range-picker.js +177 -0
- package/dist/components/forms/date-picker/week-picker.js +148 -137
- package/dist/components/forms/date-picker/week-range-picker.js +216 -205
- package/dist/components/forms/date-picker/year-picker.d.ts +3 -0
- package/dist/components/forms/date-picker/year-picker.js +176 -0
- package/dist/components/forms/date-picker/year-range-picker.d.ts +3 -0
- package/dist/components/forms/date-picker/year-range-picker.js +179 -0
- package/dist/components/layout/horizontal-scroller/horizontal-scroller.js +35 -53
- package/dist/form-react/Fields/DateInputField.js +63 -58
- package/dist/form-react/Fields/DateRangeField.js +42 -37
- package/dist/form-react/Fields/MonthRangeField.js +50 -45
- package/dist/form-react/Fields/MultiWeekPickerField.js +7 -7
- package/dist/form-react/Fields/WeekRangePicker.js +44 -45
- package/dist/form-react/components/FieldRenderer.js +21 -23
- package/dist/form-react/registry/defaultFieldRegistrations.d.ts +9 -1
- package/dist/form-react/registry/defaultFieldRegistrations.js +11 -12
- package/dist/form-react/registry/resolveFieldComponent.d.ts +3 -2
- package/dist/form-react/registry/resolveFieldComponent.js +9 -133
- package/dist/form-react/types/fields.types.d.ts +22 -7
- package/dist/form-react/utils/date.utils.d.ts +3 -1
- package/dist/form-react/utils/date.utils.js +82 -53
- package/dist/i18n/defaultMessages.d.ts +29 -1
- package/dist/i18n/defaultMessages.js +54 -27
- package/dist/i18n/locales/de.js +31 -4
- package/dist/i18n/locales/es.js +31 -4
- package/dist/i18n/locales/hi.js +31 -4
- package/dist/i18n/locales/kn.js +31 -4
- package/dist/impact-nova-components.css +379 -3
- package/dist/impact-nova.css +1 -1
- package/dist/index.js +528 -516
- package/dist/lib/fiscal-calendar/build-year.d.ts +8 -0
- package/dist/lib/fiscal-calendar/build-year.js +173 -0
- package/dist/lib/fiscal-calendar/civil-date.d.ts +21 -0
- package/dist/lib/fiscal-calendar/civil-date.js +94 -0
- package/dist/lib/fiscal-calendar/index.d.ts +10 -0
- package/dist/lib/fiscal-calendar/index.js +40 -0
- package/dist/lib/fiscal-calendar/lookup.d.ts +4 -0
- package/dist/lib/fiscal-calendar/lookup.js +70 -0
- package/dist/lib/fiscal-calendar/presets.d.ts +8 -0
- package/dist/lib/fiscal-calendar/presets.js +99 -0
- package/dist/lib/fiscal-calendar/selection.d.ts +18 -0
- package/dist/lib/fiscal-calendar/selection.js +32 -0
- package/dist/lib/fiscal-calendar/types.d.ts +145 -0
- package/dist/lib/fiscal-calendar/types.js +10 -0
- package/dist/lib/fiscal-calendar/week-selection.d.ts +22 -0
- package/dist/lib/fiscal-calendar/week-selection.js +107 -0
- package/dist/lib/guidance/engine/guidance-engine.d.ts +7 -5
- package/dist/lib/guidance/engine/guidance-engine.js +115 -47
- package/dist/lib/guidance/triggers/trigger-registry.js +6 -6
- package/dist/lib/guidance/types/guidance.types.d.ts +11 -1
- package/dist/llms/rules/installation.js +1 -1
- package/dist/llms/rules/requirements.js +1 -1
- package/package.json +5 -1
- package/dist/lib/fiscal-calendar.d.ts +0 -62
- package/dist/lib/fiscal-calendar.js +0 -99
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CivilDate, FiscalCalendarConfig, FiscalMonthPattern, FiscalYearModel, FyLabelStyle, RetailPatternId } from './types';
|
|
2
|
+
export declare function configKey(config: FiscalCalendarConfig): string;
|
|
3
|
+
export declare function clearFiscalYearCache(): void;
|
|
4
|
+
export declare function resolvePattern(pattern: RetailPatternId | FiscalMonthPattern): FiscalMonthPattern;
|
|
5
|
+
export declare function quarterForPeriod(period: number): 1 | 2 | 3 | 4;
|
|
6
|
+
export declare function buildFiscalYear(config: FiscalCalendarConfig, fy: number): FiscalYearModel;
|
|
7
|
+
export declare function formatFyLabel(fy: number, style?: FyLabelStyle, model?: FiscalYearModel): string;
|
|
8
|
+
export declare function shiftedFyForDate(iso: CivilDate, fyStartMonth: number, fyStartDay?: number): number;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { diffDays as w, addDays as l, compareCivil as S, parseCivilDate as f, lastDayOfMonth as P, weekStart as b, formatCivilRange as $, toCivilDate as m, minCivil as E, maxCivil as D } from "./civil-date.js";
|
|
2
|
+
import { DEFAULT_FY_LABEL as O, DEFAULT_LEAP_WEEK_POLICY as v, FISCAL_PATTERNS as A } from "./types.js";
|
|
3
|
+
const F = /* @__PURE__ */ new Map();
|
|
4
|
+
function L(t) {
|
|
5
|
+
return JSON.stringify(t);
|
|
6
|
+
}
|
|
7
|
+
function W() {
|
|
8
|
+
F.clear();
|
|
9
|
+
}
|
|
10
|
+
function M(t) {
|
|
11
|
+
return typeof t == "string" ? A[t] : t;
|
|
12
|
+
}
|
|
13
|
+
function q(t) {
|
|
14
|
+
return t <= 3 ? 1 : t <= 6 ? 2 : t <= 9 ? 3 : 4;
|
|
15
|
+
}
|
|
16
|
+
function x(t, e) {
|
|
17
|
+
const r = f(t), n = f(e), s = [];
|
|
18
|
+
let o = r.y, a = r.m;
|
|
19
|
+
for (; o < n.y || o === n.y && a <= n.m; )
|
|
20
|
+
s.push({ year: o, month: a - 1 }), a += 1, a > 12 && (a = 1, o += 1);
|
|
21
|
+
return s;
|
|
22
|
+
}
|
|
23
|
+
function g(t, e, r, n, s) {
|
|
24
|
+
return {
|
|
25
|
+
fy: t,
|
|
26
|
+
period: e,
|
|
27
|
+
label: `Period ${e}`,
|
|
28
|
+
displayLabel: `Period ${e} (${$(r, n)})`,
|
|
29
|
+
start: r,
|
|
30
|
+
end: n,
|
|
31
|
+
weekCount: s,
|
|
32
|
+
quarter: q(e),
|
|
33
|
+
gregorianMonthSpan: x(r, n)
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function _(t, e, r) {
|
|
37
|
+
const n = [];
|
|
38
|
+
let s = 1;
|
|
39
|
+
for (const o of e) {
|
|
40
|
+
let a = b(o.start, r);
|
|
41
|
+
for (S(a, o.start) < 0 && (a = o.start); S(a, o.end) <= 0; ) {
|
|
42
|
+
const i = l(a, 6), c = E(i, o.end), d = D(a, o.start);
|
|
43
|
+
n.push({
|
|
44
|
+
fy: t,
|
|
45
|
+
week: s,
|
|
46
|
+
start: d,
|
|
47
|
+
end: c,
|
|
48
|
+
period: o.period,
|
|
49
|
+
quarter: o.quarter
|
|
50
|
+
}), s += 1, a = l(c, 1);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return n;
|
|
54
|
+
}
|
|
55
|
+
function y(t, e) {
|
|
56
|
+
const r = /* @__PURE__ */ new Map();
|
|
57
|
+
for (const n of e) {
|
|
58
|
+
const s = r.get(n.quarter) ?? [];
|
|
59
|
+
s.push(n), r.set(n.quarter, s);
|
|
60
|
+
}
|
|
61
|
+
return [1, 2, 3, 4].flatMap((n) => {
|
|
62
|
+
const s = r.get(n);
|
|
63
|
+
return !s || s.length === 0 ? [] : [{
|
|
64
|
+
fy: t,
|
|
65
|
+
quarter: n,
|
|
66
|
+
start: s[0].start,
|
|
67
|
+
end: s[s.length - 1].end,
|
|
68
|
+
periods: s.map((a) => a.period)
|
|
69
|
+
}];
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function C(t, e, r) {
|
|
73
|
+
const n = _(t, e, r);
|
|
74
|
+
return {
|
|
75
|
+
fy: t,
|
|
76
|
+
start: e[0].start,
|
|
77
|
+
end: e[e.length - 1].end,
|
|
78
|
+
weekCount: n.length === 53 ? 53 : 52,
|
|
79
|
+
periodCount: e.length === 13 ? 13 : 12,
|
|
80
|
+
weeks: n,
|
|
81
|
+
periods: e,
|
|
82
|
+
quarters: y(t, e)
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function R(t, e, r) {
|
|
86
|
+
return m(t, e, r);
|
|
87
|
+
}
|
|
88
|
+
function Y(t, e, r) {
|
|
89
|
+
const n = R(t, r.month, r.day), s = b(n, e);
|
|
90
|
+
if (r.rule === "on-or-before") return s;
|
|
91
|
+
const o = l(s, 7), a = Math.abs(w(n, s));
|
|
92
|
+
return Math.abs(w(o, n)) < a ? o : s;
|
|
93
|
+
}
|
|
94
|
+
function T(t, e) {
|
|
95
|
+
const r = M(t.pattern);
|
|
96
|
+
if (r.length !== 12)
|
|
97
|
+
throw new Error(`retail pattern must have 12 entries, got ${r.length}`);
|
|
98
|
+
const n = t.weekStartsOn, s = Y(e, n, t.fyAnchor), o = Y(e + 1, n, t.fyAnchor), i = w(o, s) >= 371, c = t.leapWeekPolicy ?? v, d = [];
|
|
99
|
+
let h = s;
|
|
100
|
+
for (let u = 0; u < 12; u++) {
|
|
101
|
+
let p = r[u];
|
|
102
|
+
i && c === "append-last-period" && u === 11 && (p += 1);
|
|
103
|
+
const k = l(h, p * 7 - 1);
|
|
104
|
+
d.push(g(e, u + 1, h, k, p)), h = l(k, 1);
|
|
105
|
+
}
|
|
106
|
+
if (i && c === "period-13") {
|
|
107
|
+
const u = l(h, 6);
|
|
108
|
+
d.push(g(e, 13, h, u, 1));
|
|
109
|
+
}
|
|
110
|
+
return C(e, d, n);
|
|
111
|
+
}
|
|
112
|
+
function B(t, e, r) {
|
|
113
|
+
if (e === 1 && r === 1)
|
|
114
|
+
return { start: m(t, 1, 1), end: m(t, 12, 31) };
|
|
115
|
+
const n = m(t - 1, e, r), s = m(t, e, r);
|
|
116
|
+
return { start: n, end: l(s, -1) };
|
|
117
|
+
}
|
|
118
|
+
function N(t, e) {
|
|
119
|
+
const r = t.fyStartDay ?? 1, { start: n, end: s } = B(e, t.fyStartMonth, r), o = t.weekStartsOn ?? 1, a = [];
|
|
120
|
+
let i = n, c = 1;
|
|
121
|
+
for (; S(i, s) <= 0; ) {
|
|
122
|
+
const { y: d, m: h } = f(i), u = P(d, h), p = E(u, s), k = Math.max(1, Math.ceil((w(p, i) + 1) / 7));
|
|
123
|
+
a.push(g(e, c, i, p, k)), i = l(p, 1), c += 1;
|
|
124
|
+
}
|
|
125
|
+
return C(e, a, o);
|
|
126
|
+
}
|
|
127
|
+
function I(t, e) {
|
|
128
|
+
const r = t.periods.filter((o) => o.fy === e).sort((o, a) => o.period - a.period);
|
|
129
|
+
if (r.length === 0)
|
|
130
|
+
throw new Error(`custom-table has no periods for FY ${e}`);
|
|
131
|
+
for (let o = 1; o < r.length; o++)
|
|
132
|
+
if (S(r[o].start, r[o - 1].end) <= 0)
|
|
133
|
+
throw new Error(`custom-table periods overlap in FY ${e}`);
|
|
134
|
+
const n = t.weekStartsOn ?? 1, s = r.map(
|
|
135
|
+
(o) => g(
|
|
136
|
+
e,
|
|
137
|
+
o.period,
|
|
138
|
+
o.start,
|
|
139
|
+
o.end,
|
|
140
|
+
Math.max(1, Math.ceil((w(o.end, o.start) + 1) / 7))
|
|
141
|
+
)
|
|
142
|
+
);
|
|
143
|
+
return C(e, s, n);
|
|
144
|
+
}
|
|
145
|
+
function J(t, e) {
|
|
146
|
+
const r = `${L(t)}:${e}`, n = F.get(r);
|
|
147
|
+
if (n) return n;
|
|
148
|
+
let s;
|
|
149
|
+
return t.kind === "retail" ? s = T(t, e) : t.kind === "shifted-year" ? s = N(t, e) : s = I(t, e), F.set(r, s), s;
|
|
150
|
+
}
|
|
151
|
+
function j(t, e = O, r) {
|
|
152
|
+
if (e === "fy-long") return `FY ${t}`;
|
|
153
|
+
if (e === "fy-short") return `FY${String(t).slice(-2)}`;
|
|
154
|
+
if (e === "ending-year") {
|
|
155
|
+
const o = r ? f(r.end).y : t;
|
|
156
|
+
return String(o);
|
|
157
|
+
}
|
|
158
|
+
const n = r ? f(r.start).y : t - 1, s = r ? f(r.end).y : t;
|
|
159
|
+
return `${String(n).slice(-2)}–${String(s).slice(-2)}`;
|
|
160
|
+
}
|
|
161
|
+
function z(t, e, r = 1) {
|
|
162
|
+
const { y: n, m: s, d: o } = f(t);
|
|
163
|
+
return e === 1 && r === 1 ? n : s > e || s === e && o >= r ? n + 1 : n;
|
|
164
|
+
}
|
|
165
|
+
export {
|
|
166
|
+
J as buildFiscalYear,
|
|
167
|
+
W as clearFiscalYearCache,
|
|
168
|
+
L as configKey,
|
|
169
|
+
j as formatFyLabel,
|
|
170
|
+
q as quarterForPeriod,
|
|
171
|
+
M as resolvePattern,
|
|
172
|
+
z as shiftedFyForDate
|
|
173
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CivilDate, Weekday } from './types';
|
|
2
|
+
export declare function parseCivilDate(iso: CivilDate): {
|
|
3
|
+
y: number;
|
|
4
|
+
m: number;
|
|
5
|
+
d: number;
|
|
6
|
+
};
|
|
7
|
+
export declare function toCivilDate(y: number, m: number, d: number): CivilDate;
|
|
8
|
+
export declare function addDays(iso: CivilDate, n: number): CivilDate;
|
|
9
|
+
export declare function diffDays(a: CivilDate, b: CivilDate): number;
|
|
10
|
+
export declare function compareCivil(a: CivilDate, b: CivilDate): number;
|
|
11
|
+
export declare function minCivil(a: CivilDate, b: CivilDate): CivilDate;
|
|
12
|
+
export declare function maxCivil(a: CivilDate, b: CivilDate): CivilDate;
|
|
13
|
+
/** 0 = Sunday … 6 = Saturday. Sakamoto; no Date. */
|
|
14
|
+
export declare function weekday(iso: CivilDate): Weekday;
|
|
15
|
+
export declare function weekStart(iso: CivilDate, weekStartsOn: Weekday): CivilDate;
|
|
16
|
+
export declare function daysInMonth(y: number, m: number): number;
|
|
17
|
+
export declare function lastDayOfMonth(y: number, m: number): CivilDate;
|
|
18
|
+
export declare function civilFromLocalDate(date: Date): CivilDate;
|
|
19
|
+
export declare function localDateFromCivil(iso: CivilDate): Date;
|
|
20
|
+
export declare const MONTH_SHORT: readonly ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
21
|
+
export declare function formatCivilRange(start: CivilDate, end: CivilDate): string;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
const h = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
2
|
+
function c(t) {
|
|
3
|
+
const n = h.exec(t);
|
|
4
|
+
if (!n)
|
|
5
|
+
throw new Error(`Invalid civil date: ${t}`);
|
|
6
|
+
const o = Number(n[1]), r = Number(n[2]), a = Number(n[3]);
|
|
7
|
+
if (r < 1 || r > 12 || a < 1 || a > 31)
|
|
8
|
+
throw new Error(`Invalid civil date: ${t}`);
|
|
9
|
+
return { y: o, m: r, d: a };
|
|
10
|
+
}
|
|
11
|
+
function l(t, n, o) {
|
|
12
|
+
return `${String(t).padStart(4, "0")}-${String(n).padStart(2, "0")}-${String(o).padStart(2, "0")}`;
|
|
13
|
+
}
|
|
14
|
+
function u(t, n, o) {
|
|
15
|
+
const r = Math.floor((14 - n) / 12), a = t + 4800 - r, e = n + 12 * r - 3;
|
|
16
|
+
return o + Math.floor((153 * e + 2) / 5) + 365 * a + Math.floor(a / 4) - Math.floor(a / 100) + Math.floor(a / 400) - 32045;
|
|
17
|
+
}
|
|
18
|
+
function y(t) {
|
|
19
|
+
const n = t + 32044, o = Math.floor((4 * n + 3) / 146097), r = n - Math.floor(146097 * o / 4), a = Math.floor((4 * r + 3) / 1461), e = r - Math.floor(1461 * a / 4), f = Math.floor((5 * e + 2) / 153), d = e - Math.floor((153 * f + 2) / 5) + 1, m = f + 3 - 12 * Math.floor(f / 10);
|
|
20
|
+
return { y: 100 * o + a - 4800 + Math.floor(f / 10), m, d };
|
|
21
|
+
}
|
|
22
|
+
function M(t, n) {
|
|
23
|
+
const { y: o, m: r, d: a } = c(t), e = y(u(o, r, a) + n);
|
|
24
|
+
return l(e.y, e.m, e.d);
|
|
25
|
+
}
|
|
26
|
+
function D(t, n) {
|
|
27
|
+
const o = c(t), r = c(n);
|
|
28
|
+
return u(o.y, o.m, o.d) - u(r.y, r.m, r.d);
|
|
29
|
+
}
|
|
30
|
+
function s(t, n) {
|
|
31
|
+
return t === n ? 0 : t < n ? -1 : 1;
|
|
32
|
+
}
|
|
33
|
+
function g(t, n) {
|
|
34
|
+
return s(t, n) <= 0 ? t : n;
|
|
35
|
+
}
|
|
36
|
+
function S(t, n) {
|
|
37
|
+
return s(t, n) >= 0 ? t : n;
|
|
38
|
+
}
|
|
39
|
+
function $(t) {
|
|
40
|
+
const { y: n, m: o, d: r } = c(t), a = [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4], e = o < 3 ? n - 1 : n;
|
|
41
|
+
return (e + Math.floor(e / 4) - Math.floor(e / 100) + Math.floor(e / 400) + a[o - 1] + r) % 7;
|
|
42
|
+
}
|
|
43
|
+
function C(t, n) {
|
|
44
|
+
const r = ($(t) + 7 - n) % 7;
|
|
45
|
+
return M(t, -r);
|
|
46
|
+
}
|
|
47
|
+
function v(t, n) {
|
|
48
|
+
return n === 2 ? t % 4 === 0 && t % 100 !== 0 || t % 400 === 0 ? 29 : 28 : [31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][n - 1];
|
|
49
|
+
}
|
|
50
|
+
function w(t, n) {
|
|
51
|
+
return l(t, n, v(t, n));
|
|
52
|
+
}
|
|
53
|
+
function I(t) {
|
|
54
|
+
return l(t.getFullYear(), t.getMonth() + 1, t.getDate());
|
|
55
|
+
}
|
|
56
|
+
function J(t) {
|
|
57
|
+
const { y: n, m: o, d: r } = c(t);
|
|
58
|
+
return new Date(n, o - 1, r);
|
|
59
|
+
}
|
|
60
|
+
const i = [
|
|
61
|
+
"Jan",
|
|
62
|
+
"Feb",
|
|
63
|
+
"Mar",
|
|
64
|
+
"Apr",
|
|
65
|
+
"May",
|
|
66
|
+
"Jun",
|
|
67
|
+
"Jul",
|
|
68
|
+
"Aug",
|
|
69
|
+
"Sep",
|
|
70
|
+
"Oct",
|
|
71
|
+
"Nov",
|
|
72
|
+
"Dec"
|
|
73
|
+
];
|
|
74
|
+
function N(t, n) {
|
|
75
|
+
const o = c(t), r = c(n);
|
|
76
|
+
return o.y === r.y && o.m === r.m ? `${i[o.m - 1]} ${o.d} – ${r.d}` : o.y === r.y ? `${i[o.m - 1]} ${o.d} – ${i[r.m - 1]} ${r.d}` : `${i[o.m - 1]} ${o.d} ${o.y} – ${i[r.m - 1]} ${r.d} ${r.y}`;
|
|
77
|
+
}
|
|
78
|
+
export {
|
|
79
|
+
i as MONTH_SHORT,
|
|
80
|
+
M as addDays,
|
|
81
|
+
I as civilFromLocalDate,
|
|
82
|
+
s as compareCivil,
|
|
83
|
+
v as daysInMonth,
|
|
84
|
+
D as diffDays,
|
|
85
|
+
N as formatCivilRange,
|
|
86
|
+
w as lastDayOfMonth,
|
|
87
|
+
J as localDateFromCivil,
|
|
88
|
+
S as maxCivil,
|
|
89
|
+
g as minCivil,
|
|
90
|
+
c as parseCivilDate,
|
|
91
|
+
l as toCivilDate,
|
|
92
|
+
C as weekStart,
|
|
93
|
+
$ as weekday
|
|
94
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type { CalendarInterval, CalendarKind, CalendarSelection, CalendarSelectionMode, CivilDate, DateCellMeta, FiscalCalendarConfig, FiscalMode, FiscalMonth, FiscalMonthPattern, FiscalPeriod, FiscalQuarter, FiscalWeek, FiscalYearModel, FyLabelStyle, Granularity, LeapWeekPolicy, RetailPatternId, WeekSelection, Weekday, } from './types';
|
|
2
|
+
export { DEFAULT_FY_LABEL, DEFAULT_LEAP_WEEK_POLICY, FISCAL_PATTERNS, } from './types';
|
|
3
|
+
export { addDays, civilFromLocalDate, compareCivil, diffDays, formatCivilRange, lastDayOfMonth, localDateFromCivil, parseCivilDate, toCivilDate, weekStart, weekday, } from './civil-date';
|
|
4
|
+
export { buildFiscalYear, clearFiscalYearCache, formatFyLabel, resolvePattern, shiftedFyForDate, } from './build-year';
|
|
5
|
+
export { getCellMeta, getFiscalYearForDate, clearFiscalLookupCache } from './lookup';
|
|
6
|
+
export { getFiscalPresets } from './presets';
|
|
7
|
+
export type { FiscalPreset } from './presets';
|
|
8
|
+
export { isSameInterval, nextIntervalSelection } from './selection';
|
|
9
|
+
export { buildFiscalMonthCalendar, getCalendarWeekSelection, getFiscalMonthSelection, getFiscalWeekSelection, resolveWeekSelection, toFiscalCalendarConfig, } from './week-selection';
|
|
10
|
+
export type { ResolveWeekSelectionOptions } from './week-selection';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { DEFAULT_FY_LABEL as t, DEFAULT_LEAP_WEEK_POLICY as l, FISCAL_PATTERNS as o } from "./types.js";
|
|
2
|
+
import { addDays as i, civilFromLocalDate as c, compareCivil as s, diffDays as F, formatCivilRange as n, lastDayOfMonth as f, localDateFromCivil as C, parseCivilDate as m, toCivilDate as D, weekStart as d, weekday as p } from "./civil-date.js";
|
|
3
|
+
import { buildFiscalYear as L, clearFiscalYearCache as S, formatFyLabel as g, resolvePattern as x, shiftedFyForDate as E } from "./build-year.js";
|
|
4
|
+
import { clearFiscalLookupCache as k, getCellMeta as y, getFiscalYearForDate as A } from "./lookup.js";
|
|
5
|
+
import { getFiscalPresets as P } from "./presets.js";
|
|
6
|
+
import { isSameInterval as I, nextIntervalSelection as M } from "./selection.js";
|
|
7
|
+
import { buildFiscalMonthCalendar as W, getCalendarWeekSelection as b, getFiscalMonthSelection as u, getFiscalWeekSelection as w, resolveWeekSelection as O, toFiscalCalendarConfig as R } from "./week-selection.js";
|
|
8
|
+
export {
|
|
9
|
+
t as DEFAULT_FY_LABEL,
|
|
10
|
+
l as DEFAULT_LEAP_WEEK_POLICY,
|
|
11
|
+
o as FISCAL_PATTERNS,
|
|
12
|
+
i as addDays,
|
|
13
|
+
W as buildFiscalMonthCalendar,
|
|
14
|
+
L as buildFiscalYear,
|
|
15
|
+
c as civilFromLocalDate,
|
|
16
|
+
k as clearFiscalLookupCache,
|
|
17
|
+
S as clearFiscalYearCache,
|
|
18
|
+
s as compareCivil,
|
|
19
|
+
F as diffDays,
|
|
20
|
+
n as formatCivilRange,
|
|
21
|
+
g as formatFyLabel,
|
|
22
|
+
b as getCalendarWeekSelection,
|
|
23
|
+
y as getCellMeta,
|
|
24
|
+
u as getFiscalMonthSelection,
|
|
25
|
+
P as getFiscalPresets,
|
|
26
|
+
w as getFiscalWeekSelection,
|
|
27
|
+
A as getFiscalYearForDate,
|
|
28
|
+
I as isSameInterval,
|
|
29
|
+
f as lastDayOfMonth,
|
|
30
|
+
C as localDateFromCivil,
|
|
31
|
+
M as nextIntervalSelection,
|
|
32
|
+
m as parseCivilDate,
|
|
33
|
+
x as resolvePattern,
|
|
34
|
+
O as resolveWeekSelection,
|
|
35
|
+
E as shiftedFyForDate,
|
|
36
|
+
D as toCivilDate,
|
|
37
|
+
R as toFiscalCalendarConfig,
|
|
38
|
+
d as weekStart,
|
|
39
|
+
p as weekday
|
|
40
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CivilDate, DateCellMeta, FiscalCalendarConfig, FiscalYearModel } from './types';
|
|
2
|
+
export declare function clearFiscalLookupCache(): void;
|
|
3
|
+
export declare function getCellMeta(config: FiscalCalendarConfig, iso: CivilDate): DateCellMeta | undefined;
|
|
4
|
+
export declare function getFiscalYearForDate(config: FiscalCalendarConfig, iso: CivilDate): FiscalYearModel | undefined;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { parseCivilDate as c, compareCivil as f, addDays as l } from "./civil-date.js";
|
|
2
|
+
import { buildFiscalYear as u, shiftedFyForDate as h, configKey as p } from "./build-year.js";
|
|
3
|
+
const y = /* @__PURE__ */ new Map();
|
|
4
|
+
function M() {
|
|
5
|
+
y.clear();
|
|
6
|
+
}
|
|
7
|
+
function m(e) {
|
|
8
|
+
const r = /* @__PURE__ */ new Map();
|
|
9
|
+
for (const t of e.weeks) {
|
|
10
|
+
let n = t.start;
|
|
11
|
+
for (; f(n, t.end) <= 0; ) {
|
|
12
|
+
const { y: o, m: i, d } = c(n), a = e.periods.find((s) => s.period === t.period);
|
|
13
|
+
r.set(n, {
|
|
14
|
+
iso: n,
|
|
15
|
+
gregorian: { year: o, month: i, day: d },
|
|
16
|
+
fy: e.fy,
|
|
17
|
+
fiscalWeek: t.week,
|
|
18
|
+
fiscalPeriod: t.period,
|
|
19
|
+
fiscalQuarter: t.quarter,
|
|
20
|
+
isPeriodStart: a ? n === a.start : !1,
|
|
21
|
+
isPeriodEnd: a ? n === a.end : !1,
|
|
22
|
+
isFyStart: n === e.start,
|
|
23
|
+
isFyEnd: n === e.end,
|
|
24
|
+
crossesGregorianMonth: a ? a.gregorianMonthSpan.length > 1 : !1
|
|
25
|
+
}), n = l(n, 1);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return r;
|
|
29
|
+
}
|
|
30
|
+
function F(e, r) {
|
|
31
|
+
if (e.kind === "shifted-year")
|
|
32
|
+
return h(r, e.fyStartMonth, e.fyStartDay ?? 1);
|
|
33
|
+
if (e.kind === "custom-table") {
|
|
34
|
+
const t = e.periods.find(
|
|
35
|
+
(n) => f(r, n.start) >= 0 && f(r, n.end) <= 0
|
|
36
|
+
);
|
|
37
|
+
return t ? t.fy : c(r).y;
|
|
38
|
+
}
|
|
39
|
+
return c(r).y;
|
|
40
|
+
}
|
|
41
|
+
function k(e, r) {
|
|
42
|
+
const t = `${p(e)}:${r}`, n = y.get(t);
|
|
43
|
+
if (n) return n;
|
|
44
|
+
const o = u(e, r), i = m(o);
|
|
45
|
+
return y.set(t, i), i;
|
|
46
|
+
}
|
|
47
|
+
function g(e, r) {
|
|
48
|
+
const t = F(e, r);
|
|
49
|
+
for (const d of [t, t - 1, t + 1])
|
|
50
|
+
try {
|
|
51
|
+
const s = k(e, d).get(r);
|
|
52
|
+
if (s) return s;
|
|
53
|
+
} catch {
|
|
54
|
+
}
|
|
55
|
+
const { y: n, m: o, d: i } = c(r);
|
|
56
|
+
return {
|
|
57
|
+
iso: r,
|
|
58
|
+
gregorian: { year: n, month: o, day: i }
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function C(e, r) {
|
|
62
|
+
const t = g(e, r);
|
|
63
|
+
if (t?.fy != null)
|
|
64
|
+
return u(e, t.fy);
|
|
65
|
+
}
|
|
66
|
+
export {
|
|
67
|
+
M as clearFiscalLookupCache,
|
|
68
|
+
g as getCellMeta,
|
|
69
|
+
C as getFiscalYearForDate
|
|
70
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CalendarInterval, CivilDate, FiscalCalendarConfig } from './types';
|
|
2
|
+
export interface FiscalPreset {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
interval: CalendarInterval;
|
|
6
|
+
comparison?: CalendarInterval;
|
|
7
|
+
}
|
|
8
|
+
export declare function getFiscalPresets(config: FiscalCalendarConfig, now: CivilDate): FiscalPreset[];
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { minCivil as y, compareCivil as h, addDays as c } from "./civil-date.js";
|
|
2
|
+
import { buildFiscalYear as q } from "./build-year.js";
|
|
3
|
+
import { getCellMeta as v, getFiscalYearForDate as b } from "./lookup.js";
|
|
4
|
+
function a(l, s, p, r = {}) {
|
|
5
|
+
return { start: l, end: s, granularity: p, ...r };
|
|
6
|
+
}
|
|
7
|
+
function Y(l, s) {
|
|
8
|
+
const p = v(l, s), r = b(l, s);
|
|
9
|
+
if (!p?.fy || !r) return [];
|
|
10
|
+
const i = r.periods.find((e) => e.period === p.fiscalPeriod), o = r.quarters.find((e) => e.quarter === p.fiscalQuarter), n = i && i.period > 1 ? r.periods.find((e) => e.period === i.period - 1) : void 0;
|
|
11
|
+
let t;
|
|
12
|
+
try {
|
|
13
|
+
t = q(l, r.fy - 1);
|
|
14
|
+
} catch {
|
|
15
|
+
t = void 0;
|
|
16
|
+
}
|
|
17
|
+
const f = o && o.quarter > 1 ? r.quarters.find((e) => e.quarter === o.quarter - 1) : t?.quarters[t.quarters.length - 1], d = [
|
|
18
|
+
{
|
|
19
|
+
id: "this-fy",
|
|
20
|
+
label: "This FY",
|
|
21
|
+
interval: a(r.start, r.end, "year", { fy: r.fy })
|
|
22
|
+
}
|
|
23
|
+
];
|
|
24
|
+
if (t && d.push({
|
|
25
|
+
id: "last-fy",
|
|
26
|
+
label: "Last FY",
|
|
27
|
+
interval: a(t.start, t.end, "year", { fy: t.fy })
|
|
28
|
+
}), i && (d.push({
|
|
29
|
+
id: "this-period",
|
|
30
|
+
label: "This Period",
|
|
31
|
+
interval: a(i.start, i.end, "period", {
|
|
32
|
+
fy: r.fy,
|
|
33
|
+
period: i.period
|
|
34
|
+
})
|
|
35
|
+
}), d.push({
|
|
36
|
+
id: "period-to-date",
|
|
37
|
+
label: "Period to date",
|
|
38
|
+
interval: a(i.start, y(s, i.end), "period", {
|
|
39
|
+
fy: r.fy,
|
|
40
|
+
period: i.period
|
|
41
|
+
})
|
|
42
|
+
})), n)
|
|
43
|
+
d.push({
|
|
44
|
+
id: "last-period",
|
|
45
|
+
label: "Last Period",
|
|
46
|
+
interval: a(n.start, n.end, "period", {
|
|
47
|
+
fy: r.fy,
|
|
48
|
+
period: n.period
|
|
49
|
+
})
|
|
50
|
+
});
|
|
51
|
+
else if (t) {
|
|
52
|
+
const e = t.periods[t.periods.length - 1];
|
|
53
|
+
d.push({
|
|
54
|
+
id: "last-period",
|
|
55
|
+
label: "Last Period",
|
|
56
|
+
interval: a(e.start, e.end, "period", {
|
|
57
|
+
fy: t.fy,
|
|
58
|
+
period: e.period
|
|
59
|
+
})
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
if (d.push({
|
|
63
|
+
id: "this-fytd",
|
|
64
|
+
label: "This FYTD",
|
|
65
|
+
interval: a(r.start, y(s, r.end), "year", { fy: r.fy })
|
|
66
|
+
}), o && d.push({
|
|
67
|
+
id: "this-fq",
|
|
68
|
+
label: "This FQ",
|
|
69
|
+
interval: a(o.start, o.end, "quarter", {
|
|
70
|
+
fy: r.fy,
|
|
71
|
+
quarter: o.quarter
|
|
72
|
+
})
|
|
73
|
+
}), f && d.push({
|
|
74
|
+
id: "last-fq",
|
|
75
|
+
label: "Last FQ",
|
|
76
|
+
interval: a(f.start, f.end, "quarter", {
|
|
77
|
+
fy: f.fy,
|
|
78
|
+
quarter: f.quarter
|
|
79
|
+
})
|
|
80
|
+
}), i && t) {
|
|
81
|
+
const e = t.periods.find((u) => u.period === i.period);
|
|
82
|
+
e && d.push({
|
|
83
|
+
id: "yoy-period",
|
|
84
|
+
label: "YoY same period",
|
|
85
|
+
interval: a(i.start, i.end, "period", {
|
|
86
|
+
fy: r.fy,
|
|
87
|
+
period: i.period
|
|
88
|
+
}),
|
|
89
|
+
comparison: a(e.start, e.end, "period", {
|
|
90
|
+
fy: t.fy,
|
|
91
|
+
period: e.period
|
|
92
|
+
})
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return d.filter((e) => h(e.interval.start, c(s, 1)) < 0);
|
|
96
|
+
}
|
|
97
|
+
export {
|
|
98
|
+
Y as getFiscalPresets
|
|
99
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CalendarInterval, CalendarSelectionMode } from './types';
|
|
2
|
+
export declare function isSameInterval(a: CalendarInterval, b: CalendarInterval): boolean;
|
|
3
|
+
export declare function nextIntervalSelection(interval: CalendarInterval, prev: CalendarInterval | CalendarInterval[] | {
|
|
4
|
+
from: CalendarInterval;
|
|
5
|
+
to?: CalendarInterval;
|
|
6
|
+
} | Array<{
|
|
7
|
+
from: CalendarInterval;
|
|
8
|
+
to?: CalendarInterval;
|
|
9
|
+
}> | {
|
|
10
|
+
from: CalendarInterval;
|
|
11
|
+
to?: CalendarInterval;
|
|
12
|
+
} | null | undefined, mode: CalendarSelectionMode): CalendarInterval | CalendarInterval[] | {
|
|
13
|
+
from: CalendarInterval;
|
|
14
|
+
to?: CalendarInterval;
|
|
15
|
+
} | Array<{
|
|
16
|
+
from: CalendarInterval;
|
|
17
|
+
to?: CalendarInterval;
|
|
18
|
+
}> | undefined;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { compareCivil as u } from "./civil-date.js";
|
|
2
|
+
function m(o, r) {
|
|
3
|
+
return o.start === r.start && o.end === r.end && o.granularity === r.granularity;
|
|
4
|
+
}
|
|
5
|
+
function i(o, r) {
|
|
6
|
+
return u(o.start, r.start) || u(o.end, r.end);
|
|
7
|
+
}
|
|
8
|
+
function g(o, r, c) {
|
|
9
|
+
if (c === "single") return o;
|
|
10
|
+
if (c === "multiple") {
|
|
11
|
+
const t = Array.isArray(r) && (r.length === 0 || !("from" in r[0])) ? r : [];
|
|
12
|
+
return t.some((e) => m(e, o)) ? t.filter((e) => !m(e, o)) : [...t, o];
|
|
13
|
+
}
|
|
14
|
+
if (c === "multi-range") {
|
|
15
|
+
const t = Array.isArray(r) ? r.filter(
|
|
16
|
+
(s) => s && typeof s == "object" && "from" in s
|
|
17
|
+
) : r && typeof r == "object" && "from" in r ? [r] : [], n = t[t.length - 1];
|
|
18
|
+
if (!n || n.to)
|
|
19
|
+
return [...t.filter(
|
|
20
|
+
(l) => !!l.to
|
|
21
|
+
), { from: o }];
|
|
22
|
+
if (m(o, n.from)) return t;
|
|
23
|
+
const e = i(o, n.from) < 0 ? { from: o, to: n.from } : { from: n.from, to: o };
|
|
24
|
+
return [...t.slice(0, -1), e];
|
|
25
|
+
}
|
|
26
|
+
const f = r;
|
|
27
|
+
return !f?.from || f.to ? { from: o } : m(o, f.from) ? f : i(o, f.from) < 0 ? { from: o, to: f.from } : { from: f.from, to: o };
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
m as isSameInterval,
|
|
31
|
+
g as nextIntervalSelection
|
|
32
|
+
};
|