impact-nova 2.5.7 → 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 +80 -61
- 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 +201 -108
- package/dist/components/data-display/calendar/calendar-day-picker-view.d.ts +11 -3
- package/dist/components/data-display/calendar/calendar-day-picker-view.js +136 -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 +49 -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 +31 -11
- package/dist/components/data-display/calendar/use-calendar-state.js +370 -163
- 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/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/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 +27 -36
- 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 +19 -4
- package/dist/form-react/utils/date.utils.d.ts +1 -1
- package/dist/form-react/utils/date.utils.js +38 -38
- package/dist/i18n/defaultMessages.d.ts +19 -1
- package/dist/i18n/defaultMessages.js +37 -20
- package/dist/i18n/locales/de.js +18 -1
- package/dist/i18n/locales/es.js +18 -1
- package/dist/i18n/locales/hi.js +18 -1
- package/dist/i18n/locales/kn.js +18 -1
- 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/package.json +5 -1
- package/dist/lib/fiscal-calendar.d.ts +0 -62
- package/dist/lib/fiscal-calendar.js +0 -99
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Headless fiscal calendar types. No React. Civil dates are YYYY-MM-DD.
|
|
3
|
+
*/
|
|
4
|
+
export type CivilDate = string;
|
|
5
|
+
export type CalendarKind = "gregorian" | "fiscal";
|
|
6
|
+
export type FiscalMode = "basic" | "advanced" | "custom";
|
|
7
|
+
export type RetailPatternId = "4-4-5" | "4-5-4" | "5-4-4";
|
|
8
|
+
export type LeapWeekPolicy = "append-last-period" | "period-13";
|
|
9
|
+
export type FyLabelStyle = "fy-short" | "fy-long" | "ending-year" | "starting-year";
|
|
10
|
+
export type Weekday = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
11
|
+
/** Per-period week counts, e.g. [4,4,5,4,4,5,4,4,5,4,4,5] */
|
|
12
|
+
export type FiscalMonthPattern = number[];
|
|
13
|
+
export type FyAnchorRule = "on-or-before" | "closest-weekday";
|
|
14
|
+
export type FiscalCalendarConfig = {
|
|
15
|
+
kind: "shifted-year";
|
|
16
|
+
fyStartMonth: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
|
|
17
|
+
fyStartDay?: number;
|
|
18
|
+
fyLabel?: FyLabelStyle;
|
|
19
|
+
weekStartsOn?: Weekday;
|
|
20
|
+
} | {
|
|
21
|
+
kind: "retail";
|
|
22
|
+
pattern: RetailPatternId | FiscalMonthPattern;
|
|
23
|
+
weekStartsOn: Weekday;
|
|
24
|
+
fyAnchor: {
|
|
25
|
+
month: number;
|
|
26
|
+
day: number;
|
|
27
|
+
rule: FyAnchorRule;
|
|
28
|
+
};
|
|
29
|
+
leapWeekPolicy?: LeapWeekPolicy;
|
|
30
|
+
fyLabel?: FyLabelStyle;
|
|
31
|
+
} | {
|
|
32
|
+
kind: "custom-table";
|
|
33
|
+
periods: ReadonlyArray<{
|
|
34
|
+
fy: number;
|
|
35
|
+
period: number;
|
|
36
|
+
start: CivilDate;
|
|
37
|
+
end: CivilDate;
|
|
38
|
+
}>;
|
|
39
|
+
fyLabel?: FyLabelStyle;
|
|
40
|
+
weekStartsOn?: Weekday;
|
|
41
|
+
};
|
|
42
|
+
export interface FiscalWeek {
|
|
43
|
+
fy: number;
|
|
44
|
+
week: number;
|
|
45
|
+
start: CivilDate;
|
|
46
|
+
end: CivilDate;
|
|
47
|
+
period: number;
|
|
48
|
+
quarter: 1 | 2 | 3 | 4;
|
|
49
|
+
}
|
|
50
|
+
export interface FiscalPeriod {
|
|
51
|
+
fy: number;
|
|
52
|
+
period: number;
|
|
53
|
+
label: string;
|
|
54
|
+
displayLabel: string;
|
|
55
|
+
start: CivilDate;
|
|
56
|
+
end: CivilDate;
|
|
57
|
+
weekCount: number;
|
|
58
|
+
quarter: 1 | 2 | 3 | 4;
|
|
59
|
+
gregorianMonthSpan: ReadonlyArray<{
|
|
60
|
+
year: number;
|
|
61
|
+
month: number;
|
|
62
|
+
}>;
|
|
63
|
+
}
|
|
64
|
+
export interface FiscalQuarter {
|
|
65
|
+
fy: number;
|
|
66
|
+
quarter: 1 | 2 | 3 | 4;
|
|
67
|
+
start: CivilDate;
|
|
68
|
+
end: CivilDate;
|
|
69
|
+
periods: readonly number[];
|
|
70
|
+
}
|
|
71
|
+
export interface FiscalYearModel {
|
|
72
|
+
fy: number;
|
|
73
|
+
start: CivilDate;
|
|
74
|
+
end: CivilDate;
|
|
75
|
+
weekCount: 52 | 53;
|
|
76
|
+
periodCount: 12 | 13;
|
|
77
|
+
weeks: readonly FiscalWeek[];
|
|
78
|
+
periods: readonly FiscalPeriod[];
|
|
79
|
+
quarters: readonly FiscalQuarter[];
|
|
80
|
+
}
|
|
81
|
+
export interface DateCellMeta {
|
|
82
|
+
iso: CivilDate;
|
|
83
|
+
gregorian: {
|
|
84
|
+
year: number;
|
|
85
|
+
month: number;
|
|
86
|
+
day: number;
|
|
87
|
+
};
|
|
88
|
+
fy?: number;
|
|
89
|
+
fiscalWeek?: number;
|
|
90
|
+
fiscalPeriod?: number;
|
|
91
|
+
fiscalQuarter?: 1 | 2 | 3 | 4;
|
|
92
|
+
isPeriodStart?: boolean;
|
|
93
|
+
isPeriodEnd?: boolean;
|
|
94
|
+
isFyStart?: boolean;
|
|
95
|
+
isFyEnd?: boolean;
|
|
96
|
+
crossesGregorianMonth?: boolean;
|
|
97
|
+
}
|
|
98
|
+
export type Granularity = "day" | "week" | "period" | "quarter" | "year";
|
|
99
|
+
export type CalendarSelectionMode = "single" | "multiple" | "range" | "multi-range";
|
|
100
|
+
export interface CalendarInterval {
|
|
101
|
+
start: CivilDate;
|
|
102
|
+
end: CivilDate;
|
|
103
|
+
granularity: Granularity;
|
|
104
|
+
fy?: number;
|
|
105
|
+
period?: number;
|
|
106
|
+
week?: number;
|
|
107
|
+
quarter?: 1 | 2 | 3 | 4;
|
|
108
|
+
}
|
|
109
|
+
export type CalendarSelection = {
|
|
110
|
+
mode: "single";
|
|
111
|
+
value: CalendarInterval | null;
|
|
112
|
+
} | {
|
|
113
|
+
mode: "multiple";
|
|
114
|
+
value: CalendarInterval[];
|
|
115
|
+
} | {
|
|
116
|
+
mode: "range";
|
|
117
|
+
value: {
|
|
118
|
+
from: CalendarInterval;
|
|
119
|
+
to?: CalendarInterval;
|
|
120
|
+
} | null;
|
|
121
|
+
} | {
|
|
122
|
+
mode: "multi-range";
|
|
123
|
+
value: Array<{
|
|
124
|
+
from: CalendarInterval;
|
|
125
|
+
to: CalendarInterval;
|
|
126
|
+
}>;
|
|
127
|
+
};
|
|
128
|
+
/** Picker-facing week value. Dates are local civil midnights. */
|
|
129
|
+
export interface WeekSelection {
|
|
130
|
+
year: number;
|
|
131
|
+
month: number;
|
|
132
|
+
weekOfMonth: number;
|
|
133
|
+
startDate: Date;
|
|
134
|
+
endDate: Date;
|
|
135
|
+
}
|
|
136
|
+
/** Legacy fiscal-month block described as a WeekSelection (weekOfMonth = period index). */
|
|
137
|
+
export interface FiscalMonth {
|
|
138
|
+
index: number;
|
|
139
|
+
startDate: Date;
|
|
140
|
+
endDate: Date;
|
|
141
|
+
weekCount: number;
|
|
142
|
+
}
|
|
143
|
+
export declare const FISCAL_PATTERNS: Record<RetailPatternId, FiscalMonthPattern>;
|
|
144
|
+
export declare const DEFAULT_LEAP_WEEK_POLICY: LeapWeekPolicy;
|
|
145
|
+
export declare const DEFAULT_FY_LABEL: FyLabelStyle;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const E = {
|
|
2
|
+
"4-4-5": [4, 4, 5, 4, 4, 5, 4, 4, 5, 4, 4, 5],
|
|
3
|
+
"4-5-4": [4, 5, 4, 4, 5, 4, 4, 5, 4, 4, 5, 4],
|
|
4
|
+
"5-4-4": [5, 4, 4, 5, 4, 4, 5, 4, 4, 5, 4, 4]
|
|
5
|
+
}, L = "append-last-period", o = "fy-short";
|
|
6
|
+
export {
|
|
7
|
+
o as DEFAULT_FY_LABEL,
|
|
8
|
+
L as DEFAULT_LEAP_WEEK_POLICY,
|
|
9
|
+
E as FISCAL_PATTERNS
|
|
10
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CalendarKind, FiscalMode, FiscalMonth, FiscalMonthPattern, Granularity, WeekSelection, FiscalCalendarConfig, Weekday } from './types';
|
|
2
|
+
export type { FiscalMode, FiscalMonth, FiscalMonthPattern };
|
|
3
|
+
export declare function getFiscalWeekSelection(date: Date, weekStartsOn: Weekday): WeekSelection;
|
|
4
|
+
export declare function buildFiscalMonthCalendar(civilYear: number, pattern: FiscalMonthPattern, weekStartsOn: Weekday, fiscalYearStartMonth?: number): FiscalMonth[];
|
|
5
|
+
export declare function getFiscalMonthSelection(date: Date, fiscalCalendar: FiscalMonth[]): WeekSelection | undefined;
|
|
6
|
+
export declare function getCalendarWeekSelection(date: Date, weekStartsOn: Weekday): WeekSelection;
|
|
7
|
+
export interface ResolveWeekSelectionOptions {
|
|
8
|
+
calendarKind?: CalendarKind;
|
|
9
|
+
fiscalMode?: FiscalMode;
|
|
10
|
+
granularity?: Granularity;
|
|
11
|
+
fiscalMonthPattern?: FiscalMonthPattern;
|
|
12
|
+
fiscalYearStartMonth?: number;
|
|
13
|
+
weekStartsOn?: Weekday;
|
|
14
|
+
}
|
|
15
|
+
export declare function resolveWeekSelection(date: Date, options?: ResolveWeekSelectionOptions): WeekSelection;
|
|
16
|
+
export declare function toFiscalCalendarConfig(options: {
|
|
17
|
+
calendarKind?: CalendarKind;
|
|
18
|
+
fiscalMode?: FiscalMode;
|
|
19
|
+
fiscalMonthPattern?: FiscalMonthPattern;
|
|
20
|
+
fiscalYearStartMonth?: number;
|
|
21
|
+
weekStartsOn?: Weekday;
|
|
22
|
+
}): FiscalCalendarConfig | undefined;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { FISCAL_PATTERNS as y } from "./types.js";
|
|
2
|
+
function g(t, a) {
|
|
3
|
+
const e = new Date(t), s = (e.getDay() + 7 - a) % 7;
|
|
4
|
+
return e.setDate(e.getDate() - s), e.setHours(0, 0, 0, 0), e;
|
|
5
|
+
}
|
|
6
|
+
function D(t, a) {
|
|
7
|
+
const e = new Date(t);
|
|
8
|
+
return e.setDate(e.getDate() + a), e;
|
|
9
|
+
}
|
|
10
|
+
function u(t, a) {
|
|
11
|
+
const e = g(t, a), n = D(e, 6), c = new Date(t.getFullYear(), t.getMonth(), 1).getDay(), o = e.getDate(), r = e.getMonth() === t.getMonth() ? o : 1, i = Math.ceil((r + c) / 7);
|
|
12
|
+
return {
|
|
13
|
+
year: t.getFullYear(),
|
|
14
|
+
month: t.getMonth(),
|
|
15
|
+
weekOfMonth: Math.max(1, i),
|
|
16
|
+
startDate: e,
|
|
17
|
+
endDate: n
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function M(t, a, e, n = 1) {
|
|
21
|
+
if (a.length !== 12)
|
|
22
|
+
throw new Error(`fiscalMonthPattern must have exactly 12 entries, got ${a.length}`);
|
|
23
|
+
const s = new Date(t, n - 1, 1);
|
|
24
|
+
let c = g(s, e);
|
|
25
|
+
const o = [];
|
|
26
|
+
for (let r = 0; r < 12; r++) {
|
|
27
|
+
const i = a[r], f = new Date(c), l = D(f, i * 7 - 1);
|
|
28
|
+
o.push({ index: r, startDate: f, endDate: l, weekCount: i }), c = D(l, 1);
|
|
29
|
+
}
|
|
30
|
+
return o;
|
|
31
|
+
}
|
|
32
|
+
function w(t, a) {
|
|
33
|
+
const e = new Date(t);
|
|
34
|
+
e.setHours(0, 0, 0, 0);
|
|
35
|
+
for (const n of a) {
|
|
36
|
+
const s = new Date(n.startDate);
|
|
37
|
+
s.setHours(0, 0, 0, 0);
|
|
38
|
+
const c = new Date(n.endDate);
|
|
39
|
+
if (c.setHours(23, 59, 59, 999), e >= s && e <= c)
|
|
40
|
+
return {
|
|
41
|
+
year: n.startDate.getFullYear(),
|
|
42
|
+
month: n.startDate.getMonth(),
|
|
43
|
+
weekOfMonth: n.index + 1,
|
|
44
|
+
startDate: n.startDate,
|
|
45
|
+
endDate: n.endDate
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function d(t, a) {
|
|
50
|
+
const e = g(t, a), n = D(e, 6), s = new Date(t.getFullYear(), t.getMonth(), 1), c = new Date(t.getFullYear(), t.getMonth() + 1, 0), o = e < s ? new Date(s) : new Date(e), r = n > c ? new Date(c) : new Date(n), f = new Date(o.getFullYear(), o.getMonth(), 1).getDay(), l = o.getDate(), h = Math.ceil((l + f) / 7);
|
|
51
|
+
return {
|
|
52
|
+
year: o.getFullYear(),
|
|
53
|
+
month: o.getMonth(),
|
|
54
|
+
weekOfMonth: Math.max(1, h),
|
|
55
|
+
startDate: o,
|
|
56
|
+
endDate: r
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function F(t, a = {}) {
|
|
60
|
+
const {
|
|
61
|
+
calendarKind: e = "gregorian",
|
|
62
|
+
fiscalMode: n = "basic",
|
|
63
|
+
granularity: s,
|
|
64
|
+
fiscalMonthPattern: c,
|
|
65
|
+
fiscalYearStartMonth: o = 1,
|
|
66
|
+
weekStartsOn: r = 1
|
|
67
|
+
} = a;
|
|
68
|
+
if (e !== "fiscal")
|
|
69
|
+
return d(t, r);
|
|
70
|
+
if (n === "basic" || s !== "period")
|
|
71
|
+
return u(t, r);
|
|
72
|
+
const i = c ?? y["4-4-5"];
|
|
73
|
+
if (i.length !== 12)
|
|
74
|
+
return u(t, r);
|
|
75
|
+
const f = M(
|
|
76
|
+
t.getFullYear(),
|
|
77
|
+
i,
|
|
78
|
+
r,
|
|
79
|
+
o
|
|
80
|
+
), l = w(t, f);
|
|
81
|
+
if (l) return l;
|
|
82
|
+
const h = M(
|
|
83
|
+
t.getFullYear() - 1,
|
|
84
|
+
i,
|
|
85
|
+
r,
|
|
86
|
+
o
|
|
87
|
+
);
|
|
88
|
+
return w(t, h) ?? u(t, r);
|
|
89
|
+
}
|
|
90
|
+
function S(t) {
|
|
91
|
+
if (t.calendarKind !== "fiscal") return;
|
|
92
|
+
const a = t.weekStartsOn ?? 1, e = t.fiscalYearStartMonth ?? 1;
|
|
93
|
+
return {
|
|
94
|
+
kind: "retail",
|
|
95
|
+
pattern: t.fiscalMonthPattern ?? y["4-4-5"],
|
|
96
|
+
weekStartsOn: a,
|
|
97
|
+
fyAnchor: { month: e, day: 1, rule: "on-or-before" }
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
export {
|
|
101
|
+
M as buildFiscalMonthCalendar,
|
|
102
|
+
d as getCalendarWeekSelection,
|
|
103
|
+
w as getFiscalMonthSelection,
|
|
104
|
+
u as getFiscalWeekSelection,
|
|
105
|
+
F as resolveWeekSelection,
|
|
106
|
+
S as toFiscalCalendarConfig
|
|
107
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "impact-nova",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.8",
|
|
4
4
|
"description": "Enterprise-grade React design system built with React 19, Vite, Tailwind CSS, and Radix UI. Built-in internationalization (i18n) and comprehensive UI component library for scalable, accessible, and performant applications.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"workspaces": [
|
|
@@ -509,6 +509,10 @@
|
|
|
509
509
|
"./guidance/adapters/dialog": {
|
|
510
510
|
"types": "./dist/components/flows/guidance/adapters/dialog.d.ts",
|
|
511
511
|
"import": "./dist/components/flows/guidance/adapters/dialog.js"
|
|
512
|
+
},
|
|
513
|
+
"./fiscal-calendar": {
|
|
514
|
+
"types": "./dist/lib/fiscal-calendar/index.d.ts",
|
|
515
|
+
"import": "./dist/lib/fiscal-calendar/index.js"
|
|
512
516
|
}
|
|
513
517
|
},
|
|
514
518
|
"scripts": {
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { WeekSelection } from '../components/data-display/calendar';
|
|
2
|
-
export type CalendarType = "calendar" | "fiscal";
|
|
3
|
-
export type FiscalMode = "basic" | "advanced" | "custom";
|
|
4
|
-
export type SelectionMode = "week" | "fiscalMonth";
|
|
5
|
-
/** Per-month week counts for the fiscal year, e.g. [4,4,5,4,4,5,4,4,5,4,4,5] */
|
|
6
|
-
export type FiscalMonthPattern = number[];
|
|
7
|
-
/** Describes one fiscal month (a contiguous block of weeks). */
|
|
8
|
-
export interface FiscalMonth {
|
|
9
|
-
/** 0-based index within the fiscal year (0 = first fiscal month) */
|
|
10
|
-
index: number;
|
|
11
|
-
startDate: Date;
|
|
12
|
-
endDate: Date;
|
|
13
|
-
weekCount: number;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Pre-defined fiscal month patterns, each repeated 4× to yield 12 fiscal months.
|
|
17
|
-
* The pattern describes the number of weeks in each of the 3-month period.
|
|
18
|
-
* Sum = 13 weeks per quarter × 4 = 52 weeks per year.
|
|
19
|
-
*/
|
|
20
|
-
export declare const FISCAL_PATTERNS: Record<string, FiscalMonthPattern>;
|
|
21
|
-
/**
|
|
22
|
-
* Returns the WeekSelection for a basic 7-day fiscal week.
|
|
23
|
-
* Unlike the "calendar" mode, the week is NOT clipped to month boundaries.
|
|
24
|
-
*/
|
|
25
|
-
export declare function getFiscalWeekSelection(date: Date, weekStartsOn: 0 | 1 | 2 | 3 | 4 | 5 | 6): WeekSelection;
|
|
26
|
-
/**
|
|
27
|
-
* Build the fiscal month calendar for one civil year.
|
|
28
|
-
*
|
|
29
|
-
* @param civilYear The civil year (e.g. 2026)
|
|
30
|
-
* @param pattern Array of week-counts per fiscal month (length 12)
|
|
31
|
-
* @param weekStartsOn Day the fiscal week begins
|
|
32
|
-
* @param fiscalYearStartMonth 1-based month where the fiscal year starts (default 1 = January)
|
|
33
|
-
*
|
|
34
|
-
* The first fiscal month starts at `weekStart(fiscalYearStartMonth 1st, civilYear)`.
|
|
35
|
-
* Each subsequent fiscal month begins exactly (weekCount × 7) days after the previous one.
|
|
36
|
-
*/
|
|
37
|
-
export declare function buildFiscalMonthCalendar(civilYear: number, pattern: FiscalMonthPattern, weekStartsOn: 0 | 1 | 2 | 3 | 4 | 5 | 6, fiscalYearStartMonth?: number): FiscalMonth[];
|
|
38
|
-
/**
|
|
39
|
-
* Given a date and a pre-built fiscal calendar, find which fiscal month the date
|
|
40
|
-
* falls in and return a WeekSelection spanning that entire fiscal month.
|
|
41
|
-
*
|
|
42
|
-
* Returns `undefined` if the date is outside the fiscal calendar range.
|
|
43
|
-
*/
|
|
44
|
-
export declare function getFiscalMonthSelection(date: Date, fiscalCalendar: FiscalMonth[]): WeekSelection | undefined;
|
|
45
|
-
/**
|
|
46
|
-
* Standard calendar week selection – the week is clipped to the month boundary
|
|
47
|
-
* (same as the existing "normal" behaviour).
|
|
48
|
-
*/
|
|
49
|
-
export declare function getCalendarWeekSelection(date: Date, weekStartsOn: 0 | 1 | 2 | 3 | 4 | 5 | 6): WeekSelection;
|
|
50
|
-
export interface ResolveWeekSelectionOptions {
|
|
51
|
-
calendarType?: CalendarType;
|
|
52
|
-
fiscalMode?: FiscalMode;
|
|
53
|
-
selectionMode?: SelectionMode;
|
|
54
|
-
fiscalMonthPattern?: FiscalMonthPattern;
|
|
55
|
-
fiscalYearStartMonth?: number;
|
|
56
|
-
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Unified entry point for computing a WeekSelection from a clicked date,
|
|
60
|
-
* respecting the full new API.
|
|
61
|
-
*/
|
|
62
|
-
export declare function resolveWeekSelection(date: Date, options?: ResolveWeekSelectionOptions): WeekSelection;
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
const M = {
|
|
2
|
-
"4-4-5": [4, 4, 5, 4, 4, 5, 4, 4, 5, 4, 4, 5]
|
|
3
|
-
};
|
|
4
|
-
function g(t, a) {
|
|
5
|
-
const e = new Date(t), s = (e.getDay() + 7 - a) % 7;
|
|
6
|
-
return e.setDate(e.getDate() - s), e.setHours(0, 0, 0, 0), e;
|
|
7
|
-
}
|
|
8
|
-
function f(t, a) {
|
|
9
|
-
const e = new Date(t);
|
|
10
|
-
return e.setDate(e.getDate() + a), e;
|
|
11
|
-
}
|
|
12
|
-
function u(t, a) {
|
|
13
|
-
const e = g(t, a), n = f(e, 6), c = new Date(t.getFullYear(), t.getMonth(), 1).getDay(), r = e.getDate(), o = e.getMonth() === t.getMonth() ? r : 1, l = Math.ceil((o + c) / 7);
|
|
14
|
-
return {
|
|
15
|
-
year: t.getFullYear(),
|
|
16
|
-
month: t.getMonth(),
|
|
17
|
-
weekOfMonth: Math.max(1, l),
|
|
18
|
-
startDate: e,
|
|
19
|
-
endDate: n
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
function w(t, a, e, n = 1) {
|
|
23
|
-
if (a.length !== 12)
|
|
24
|
-
throw new Error(`fiscalMonthPattern must have exactly 12 entries, got ${a.length}`);
|
|
25
|
-
const s = new Date(t, n - 1, 1);
|
|
26
|
-
let c = g(s, e);
|
|
27
|
-
const r = [];
|
|
28
|
-
for (let o = 0; o < 12; o++) {
|
|
29
|
-
const l = a[o], D = new Date(c), i = f(D, l * 7 - 1);
|
|
30
|
-
r.push({ index: o, startDate: D, endDate: i, weekCount: l }), c = f(i, 1);
|
|
31
|
-
}
|
|
32
|
-
return r;
|
|
33
|
-
}
|
|
34
|
-
function y(t, a) {
|
|
35
|
-
const e = new Date(t);
|
|
36
|
-
e.setHours(0, 0, 0, 0);
|
|
37
|
-
for (const n of a) {
|
|
38
|
-
const s = new Date(n.startDate);
|
|
39
|
-
s.setHours(0, 0, 0, 0);
|
|
40
|
-
const c = new Date(n.endDate);
|
|
41
|
-
if (c.setHours(23, 59, 59, 999), e >= s && e <= c)
|
|
42
|
-
return {
|
|
43
|
-
year: n.startDate.getFullYear(),
|
|
44
|
-
month: n.startDate.getMonth(),
|
|
45
|
-
weekOfMonth: n.index + 1,
|
|
46
|
-
startDate: n.startDate,
|
|
47
|
-
endDate: n.endDate
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
function d(t, a) {
|
|
52
|
-
const e = g(t, a), n = f(e, 6), s = new Date(t.getFullYear(), t.getMonth(), 1), c = new Date(t.getFullYear(), t.getMonth() + 1, 0), r = e < s ? new Date(s) : new Date(e), o = n > c ? new Date(c) : new Date(n), D = new Date(r.getFullYear(), r.getMonth(), 1).getDay(), i = r.getDate(), h = Math.ceil((i + D) / 7);
|
|
53
|
-
return {
|
|
54
|
-
year: r.getFullYear(),
|
|
55
|
-
month: r.getMonth(),
|
|
56
|
-
weekOfMonth: Math.max(1, h),
|
|
57
|
-
startDate: r,
|
|
58
|
-
endDate: o
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
function k(t, a = {}) {
|
|
62
|
-
const {
|
|
63
|
-
calendarType: e = "calendar",
|
|
64
|
-
fiscalMode: n = "basic",
|
|
65
|
-
selectionMode: s = "week",
|
|
66
|
-
fiscalMonthPattern: c,
|
|
67
|
-
fiscalYearStartMonth: r = 1,
|
|
68
|
-
weekStartsOn: o = 1
|
|
69
|
-
} = a;
|
|
70
|
-
if (e === "calendar")
|
|
71
|
-
return d(t, o);
|
|
72
|
-
if (n === "basic" || s === "week")
|
|
73
|
-
return u(t, o);
|
|
74
|
-
const l = c ?? M["4-4-5"];
|
|
75
|
-
if (l.length !== 12)
|
|
76
|
-
return u(t, o);
|
|
77
|
-
const D = w(
|
|
78
|
-
t.getFullYear(),
|
|
79
|
-
l,
|
|
80
|
-
o,
|
|
81
|
-
r
|
|
82
|
-
), i = y(t, D);
|
|
83
|
-
if (i) return i;
|
|
84
|
-
const h = w(
|
|
85
|
-
t.getFullYear() - 1,
|
|
86
|
-
l,
|
|
87
|
-
o,
|
|
88
|
-
r
|
|
89
|
-
);
|
|
90
|
-
return y(t, h) ?? u(t, o);
|
|
91
|
-
}
|
|
92
|
-
export {
|
|
93
|
-
M as FISCAL_PATTERNS,
|
|
94
|
-
w as buildFiscalMonthCalendar,
|
|
95
|
-
d as getCalendarWeekSelection,
|
|
96
|
-
y as getFiscalMonthSelection,
|
|
97
|
-
u as getFiscalWeekSelection,
|
|
98
|
-
k as resolveWeekSelection
|
|
99
|
-
};
|