impact-nova 2.5.8 → 2.5.9
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-display/calendar/calendar-day-picker-components.js +130 -129
- package/dist/components/data-display/calendar/calendar-fiscal-labels.js +6 -6
- package/dist/components/data-display/calendar/calendar-fiscal-period-nav.d.ts +16 -0
- package/dist/components/data-display/calendar/calendar-fiscal-period-nav.js +41 -0
- package/dist/components/data-display/calendar/use-fiscal-calendar.js +16 -15
- package/dist/components/forms/smart-input/smart-input.js +106 -85
- package/dist/components/forms/smart-input/smart-input.types.d.ts +5 -0
- package/dist/components/forms/textarea/textarea.js +29 -28
- package/dist/components/forms/textarea/textarea.types.d.ts +1 -0
- package/dist/form-react/Fields/TextField.js +25 -24
- package/dist/form-react/types/fields.types.d.ts +6 -0
- package/dist/lib/fiscal-calendar/civil-date.js +18 -18
- package/dist/llms/rules/best-practices.js +1 -1
- package/dist/llms/rules/installation.js +1 -1
- package/dist/llms/rules/real-world-patterns.js +1 -1
- package/dist/llms/rules/requirements.js +1 -1
- package/package.json +1 -1
|
@@ -1,98 +1,95 @@
|
|
|
1
1
|
import { jsx as i, jsxs as z } from "react/jsx-runtime";
|
|
2
|
-
import * as
|
|
3
|
-
import { useDayPicker as
|
|
2
|
+
import * as x from "react";
|
|
3
|
+
import { useDayPicker as V } from "react-day-picker";
|
|
4
4
|
import { ChevronRight as B } from "impact-nova-icons";
|
|
5
|
-
import { cn as
|
|
6
|
-
import { Button as
|
|
7
|
-
import { Select as
|
|
8
|
-
import { CalendarCaptionHeader as
|
|
9
|
-
import { CalendarDayButton as
|
|
10
|
-
import { PanelIndexContext as
|
|
11
|
-
import { CalendarWeekNumberCell as
|
|
12
|
-
import { paneCivilMonthIndex as
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { getAvailableMonths as
|
|
16
|
-
import { isCalendarPaddingWeek as
|
|
17
|
-
import { fiscalPeriodForWeek as
|
|
18
|
-
import { FiscalPeriodCaptionSelect as
|
|
19
|
-
function
|
|
20
|
-
if (m != null &&
|
|
5
|
+
import { cn as k } from "../../../lib/utils.js";
|
|
6
|
+
import { Button as M } from "../../primitives/button/button.js";
|
|
7
|
+
import { Select as R } from "../../forms/select/select.js";
|
|
8
|
+
import { CalendarCaptionHeader as ee } from "./calendar-caption-header.js";
|
|
9
|
+
import { CalendarDayButton as te } from "./calendar-day-button.js";
|
|
10
|
+
import { PanelIndexContext as N } from "./calendar-panel-context.js";
|
|
11
|
+
import { CalendarWeekNumberCell as re } from "./calendar-week-number-cell.js";
|
|
12
|
+
import { paneCivilMonthIndex as ne } from "./calendar-week-number-header.js";
|
|
13
|
+
import { buildFiscalYear as oe } from "../../../lib/fiscal-calendar/build-year.js";
|
|
14
|
+
import { civilMonthAtOffset as _, midMonthDate as E, visibleMonthForPeriod as G, periodForCivilMonth as ie } from "./calendar-fiscal-period-nav.js";
|
|
15
|
+
import { getAvailableMonths as ae } from "./calendar-month-utils.js";
|
|
16
|
+
import { isCalendarPaddingWeek as se, weekHasInMonthSelection as le, weekIntervalContinues as de } from "./calendar-padding-week.utils.js";
|
|
17
|
+
import { fiscalPeriodForWeek as ce } from "./calendar-week-utils.js";
|
|
18
|
+
import { FiscalPeriodCaptionSelect as me } from "./fiscal-period-caption-select.js";
|
|
19
|
+
function H(y, m, u) {
|
|
20
|
+
if (m != null && y)
|
|
21
21
|
try {
|
|
22
|
-
return
|
|
22
|
+
return oe(y, m).periods;
|
|
23
23
|
} catch {
|
|
24
24
|
}
|
|
25
|
-
return
|
|
25
|
+
return u ?? [];
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
function We({
|
|
31
|
-
buttonVariant: u,
|
|
27
|
+
function Ie({
|
|
28
|
+
buttonVariant: y,
|
|
32
29
|
pickerType: m,
|
|
33
|
-
calendarKind:
|
|
34
|
-
currentMonth:
|
|
35
|
-
monthsFull:
|
|
36
|
-
monthsShort:
|
|
37
|
-
resolvedStartMonth:
|
|
38
|
-
resolvedEndMonth:
|
|
39
|
-
availableYears:
|
|
40
|
-
fiscalPeriods:
|
|
30
|
+
calendarKind: u,
|
|
31
|
+
currentMonth: h,
|
|
32
|
+
monthsFull: b,
|
|
33
|
+
monthsShort: q,
|
|
34
|
+
resolvedStartMonth: J,
|
|
35
|
+
resolvedEndMonth: Q,
|
|
36
|
+
availableYears: g,
|
|
37
|
+
fiscalPeriods: C,
|
|
41
38
|
fiscalConfig: w,
|
|
42
|
-
weekStartsOn:
|
|
43
|
-
previousMonthLabel:
|
|
44
|
-
nextMonthLabel:
|
|
45
|
-
monthPlaceholder:
|
|
46
|
-
yearPlaceholder:
|
|
47
|
-
weekNumberLabel:
|
|
48
|
-
weekNumberHeader:
|
|
49
|
-
weekLabel:
|
|
50
|
-
fiscalWeekNumberLabel:
|
|
51
|
-
fiscalWeekAriaLabel:
|
|
52
|
-
getCellMeta:
|
|
53
|
-
onMonthChange:
|
|
54
|
-
onWeekSelect:
|
|
55
|
-
periodRowHover:
|
|
39
|
+
weekStartsOn: U,
|
|
40
|
+
previousMonthLabel: P,
|
|
41
|
+
nextMonthLabel: W,
|
|
42
|
+
monthPlaceholder: I,
|
|
43
|
+
yearPlaceholder: X,
|
|
44
|
+
weekNumberLabel: Z,
|
|
45
|
+
weekNumberHeader: F,
|
|
46
|
+
weekLabel: $,
|
|
47
|
+
fiscalWeekNumberLabel: L,
|
|
48
|
+
fiscalWeekAriaLabel: T,
|
|
49
|
+
getCellMeta: f,
|
|
50
|
+
onMonthChange: v,
|
|
51
|
+
onWeekSelect: A,
|
|
52
|
+
periodRowHover: Y = !1,
|
|
56
53
|
weekMode: O = "single",
|
|
57
|
-
components:
|
|
54
|
+
components: K
|
|
58
55
|
}) {
|
|
59
56
|
return {
|
|
60
|
-
Root: ({ className: e, rootRef: r, ...t }) => /* @__PURE__ */ i("div", { "data-slot": "calendar", ref: r, className:
|
|
57
|
+
Root: ({ className: e, rootRef: r, ...t }) => /* @__PURE__ */ i("div", { "data-slot": "calendar", ref: r, className: k(e), ...t }),
|
|
61
58
|
Chevron: ({ className: e, orientation: r, ...t }) => r === "left" ? /* @__PURE__ */ i(
|
|
62
59
|
B,
|
|
63
60
|
{
|
|
64
61
|
size: 16,
|
|
65
|
-
className:
|
|
62
|
+
className: k("rotate-180 text-content", e),
|
|
66
63
|
...t
|
|
67
64
|
}
|
|
68
|
-
) : r === "right" ? /* @__PURE__ */ i(B, { size: 16, className:
|
|
65
|
+
) : r === "right" ? /* @__PURE__ */ i(B, { size: 16, className: k("text-content", e), ...t }) : /* @__PURE__ */ i("span", {}),
|
|
69
66
|
PreviousMonthButton: (e) => /* @__PURE__ */ i(
|
|
70
|
-
|
|
67
|
+
M,
|
|
71
68
|
{
|
|
72
|
-
variant:
|
|
69
|
+
variant: y,
|
|
73
70
|
size: "icon",
|
|
74
71
|
className: "h-7 w-7",
|
|
75
|
-
"aria-label":
|
|
76
|
-
title:
|
|
72
|
+
"aria-label": P,
|
|
73
|
+
title: P,
|
|
77
74
|
...e
|
|
78
75
|
}
|
|
79
76
|
),
|
|
80
77
|
NextMonthButton: (e) => /* @__PURE__ */ i(
|
|
81
|
-
|
|
78
|
+
M,
|
|
82
79
|
{
|
|
83
|
-
variant:
|
|
80
|
+
variant: y,
|
|
84
81
|
size: "icon",
|
|
85
82
|
className: "h-7 w-7",
|
|
86
|
-
"aria-label":
|
|
87
|
-
title:
|
|
83
|
+
"aria-label": W,
|
|
84
|
+
title: W,
|
|
88
85
|
...e
|
|
89
86
|
}
|
|
90
87
|
),
|
|
91
88
|
MonthCaption: ({ displayIndex: e, calendarMonth: r, ...t }) => /* @__PURE__ */ i("div", { ...t }),
|
|
92
|
-
Month: ({ calendarMonth: e, displayIndex: r, className: t, children:
|
|
93
|
-
const d =
|
|
94
|
-
return /* @__PURE__ */ i(
|
|
95
|
-
|
|
89
|
+
Month: ({ calendarMonth: e, displayIndex: r, className: t, children: o, ...a }) => {
|
|
90
|
+
const d = x.Children.toArray(o), l = d[d.length - 1], s = d.slice(0, -1);
|
|
91
|
+
return /* @__PURE__ */ i(N.Provider, { value: r, children: /* @__PURE__ */ z("div", { className: k(t), ...a, children: [
|
|
92
|
+
s.length > 0 ? /* @__PURE__ */ i(ee, { children: s }) : null,
|
|
96
93
|
l
|
|
97
94
|
] }) });
|
|
98
95
|
},
|
|
@@ -100,56 +97,60 @@ function We({
|
|
|
100
97
|
"div",
|
|
101
98
|
{
|
|
102
99
|
"data-slot": "day-months",
|
|
103
|
-
"data-period-row-hover":
|
|
100
|
+
"data-period-row-hover": Y ? "true" : void 0,
|
|
104
101
|
"data-week-gutter-track": m === "week" ? "true" : void 0,
|
|
105
|
-
className:
|
|
102
|
+
className: k(e),
|
|
106
103
|
...t,
|
|
107
104
|
children: r
|
|
108
105
|
}
|
|
109
106
|
),
|
|
110
107
|
DropdownNav: ({ children: e, className: r, ...t }) => {
|
|
111
|
-
if (
|
|
108
|
+
if (u !== "fiscal")
|
|
112
109
|
return /* @__PURE__ */ i("div", { className: r, ...t, children: e });
|
|
113
|
-
const
|
|
114
|
-
const c =
|
|
110
|
+
const o = x.Children.toArray(e), a = (n) => x.isValidElement(n) && n.key != null ? String(n.key) : "", d = o.find((n) => a(n).endsWith("year")), l = o.find((n) => a(n).endsWith("month")), s = o.filter((n) => {
|
|
111
|
+
const c = a(n);
|
|
115
112
|
return !c.endsWith("year") && !c.endsWith("month");
|
|
116
113
|
});
|
|
117
114
|
return /* @__PURE__ */ z("div", { className: r, ...t, children: [
|
|
118
115
|
d,
|
|
119
116
|
l,
|
|
120
|
-
|
|
117
|
+
s
|
|
121
118
|
] });
|
|
122
119
|
},
|
|
123
120
|
MonthsDropdown: ({ value: e }) => {
|
|
124
|
-
const r =
|
|
125
|
-
if (
|
|
126
|
-
const
|
|
121
|
+
const r = x.useContext(N), t = r > 0, o = _(h, r), a = o.getFullYear();
|
|
122
|
+
if (u === "fiscal" && w) {
|
|
123
|
+
const s = f?.(E(o)) ?? f?.(o), n = H(w, s?.fy, C), c = ie(
|
|
124
|
+
n,
|
|
125
|
+
o.getFullYear(),
|
|
126
|
+
o.getMonth()
|
|
127
|
+
);
|
|
127
128
|
return /* @__PURE__ */ i(
|
|
128
|
-
|
|
129
|
+
me,
|
|
129
130
|
{
|
|
130
131
|
periods: n,
|
|
131
|
-
selectedPeriod:
|
|
132
|
-
placeholder:
|
|
133
|
-
onPeriodChange: (
|
|
134
|
-
|
|
132
|
+
selectedPeriod: c,
|
|
133
|
+
placeholder: I,
|
|
134
|
+
onPeriodChange: (p) => {
|
|
135
|
+
v(G(p, t));
|
|
135
136
|
}
|
|
136
137
|
}
|
|
137
138
|
);
|
|
138
139
|
}
|
|
139
|
-
const l =
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
140
|
+
const l = ae(
|
|
141
|
+
a,
|
|
142
|
+
b,
|
|
143
|
+
J,
|
|
144
|
+
Q
|
|
144
145
|
);
|
|
145
146
|
return /* @__PURE__ */ i(
|
|
146
|
-
|
|
147
|
+
R,
|
|
147
148
|
{
|
|
148
|
-
value: l.find((
|
|
149
|
-
onChange: (
|
|
150
|
-
if (
|
|
151
|
-
const n = parseInt(
|
|
152
|
-
|
|
149
|
+
value: l.find((s) => s.value === e?.toString()),
|
|
150
|
+
onChange: (s) => {
|
|
151
|
+
if (s && "value" in s) {
|
|
152
|
+
const n = parseInt(s.value);
|
|
153
|
+
v(t ? new Date(a, n - 1, 1) : new Date(a, n, 1));
|
|
153
154
|
}
|
|
154
155
|
},
|
|
155
156
|
scrollToSelectedOnOpen: !0,
|
|
@@ -158,105 +159,105 @@ function We({
|
|
|
158
159
|
menuWidth: "160px",
|
|
159
160
|
isSearchable: !0,
|
|
160
161
|
isClearable: !1,
|
|
161
|
-
placeholder:
|
|
162
|
+
placeholder: I
|
|
162
163
|
}
|
|
163
164
|
);
|
|
164
165
|
},
|
|
165
166
|
YearsDropdown: ({ value: e }) => {
|
|
166
|
-
const r =
|
|
167
|
+
const r = x.useContext(N), t = r > 0, o = u === "fiscal" && w, a = _(h, r), d = o ? f?.(E(a)) ?? f?.(a) : void 0, l = o && d?.fy != null ? String(d.fy) : e?.toString();
|
|
167
168
|
return /* @__PURE__ */ i(
|
|
168
|
-
|
|
169
|
+
R,
|
|
169
170
|
{
|
|
170
|
-
value:
|
|
171
|
+
value: g.find((n) => n.value === l),
|
|
171
172
|
onChange: (n) => {
|
|
172
173
|
if (n && "value" in n) {
|
|
173
174
|
const c = parseInt(n.value);
|
|
174
|
-
if (
|
|
175
|
-
const
|
|
176
|
-
|
|
175
|
+
if (o) {
|
|
176
|
+
const p = H(w, c, C), D = p.find((S) => S.period === d?.fiscalPeriod) ?? p[0];
|
|
177
|
+
D && v(G(D, t));
|
|
177
178
|
return;
|
|
178
179
|
}
|
|
179
180
|
if (t) {
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
181
|
+
const p = new Date(
|
|
182
|
+
h.getFullYear(),
|
|
183
|
+
h.getMonth() + 1,
|
|
183
184
|
1
|
|
184
185
|
).getMonth();
|
|
185
|
-
|
|
186
|
+
v(new Date(c, p - 1, 1));
|
|
186
187
|
} else
|
|
187
|
-
|
|
188
|
+
v(new Date(c, h.getMonth(), 1));
|
|
188
189
|
}
|
|
189
190
|
},
|
|
190
191
|
scrollToSelectedOnOpen: !0,
|
|
191
|
-
options:
|
|
192
|
+
options: g,
|
|
192
193
|
className: "w-[116px] shrink-0",
|
|
193
194
|
menuWidth: "140px",
|
|
194
195
|
isSearchable: !0,
|
|
195
196
|
isClearable: !1,
|
|
196
|
-
placeholder:
|
|
197
|
+
placeholder: X
|
|
197
198
|
}
|
|
198
199
|
);
|
|
199
200
|
},
|
|
200
201
|
DayButton: (e) => /* @__PURE__ */ i(
|
|
201
|
-
|
|
202
|
+
te,
|
|
202
203
|
{
|
|
203
204
|
...e,
|
|
204
205
|
pickerType: m,
|
|
205
206
|
modifiers: {
|
|
206
207
|
...e.modifiers,
|
|
207
|
-
fiscal_period_start: !!
|
|
208
|
-
fiscal_period_end: !!
|
|
208
|
+
fiscal_period_start: !!f?.(e.day.date)?.isPeriodStart,
|
|
209
|
+
fiscal_period_end: !!f?.(e.day.date)?.isPeriodEnd
|
|
209
210
|
}
|
|
210
211
|
}
|
|
211
212
|
),
|
|
212
|
-
Week: ({ week: e, className: r, children: t, onClick:
|
|
213
|
-
const { isSelected: d } =
|
|
213
|
+
Week: ({ week: e, className: r, children: t, onClick: o, ...a }) => {
|
|
214
|
+
const { isSelected: d } = V(), l = se(e), s = m === "week", n = Y && !l ? ce(e, f) : void 0, c = !l && le(e, d), D = m === "week" && O !== "multiple" && O !== "multi-range" && c ? de(e, d) : { prev: !1, next: !1 };
|
|
214
215
|
return /* @__PURE__ */ i(
|
|
215
216
|
"tr",
|
|
216
217
|
{
|
|
217
|
-
className:
|
|
218
|
+
className: k(
|
|
218
219
|
r,
|
|
219
220
|
l && "invisible",
|
|
220
|
-
|
|
221
|
+
s && !l && "cursor-pointer"
|
|
221
222
|
),
|
|
222
|
-
...
|
|
223
|
+
...a,
|
|
223
224
|
"aria-hidden": l || void 0,
|
|
224
225
|
"data-fiscal-period": n,
|
|
225
226
|
"data-week-selected": c ? !0 : void 0,
|
|
226
|
-
"data-week-continues-next":
|
|
227
|
-
"data-week-continues-prev":
|
|
228
|
-
onClick:
|
|
229
|
-
if (
|
|
227
|
+
"data-week-continues-next": D.next || void 0,
|
|
228
|
+
"data-week-continues-prev": D.prev || void 0,
|
|
229
|
+
onClick: s && !l ? (S) => {
|
|
230
|
+
if (o?.(S), S.defaultPrevented) return;
|
|
230
231
|
const j = S.target;
|
|
231
|
-
j.closest("button") || j.closest("[data-week-number]") ||
|
|
232
|
-
} :
|
|
232
|
+
j.closest("button") || j.closest("[data-week-number]") || A(e);
|
|
233
|
+
} : o,
|
|
233
234
|
children: t
|
|
234
235
|
}
|
|
235
236
|
);
|
|
236
237
|
},
|
|
237
238
|
WeekNumber: ({ week: e, ...r }) => /* @__PURE__ */ i(
|
|
238
|
-
|
|
239
|
+
re,
|
|
239
240
|
{
|
|
240
241
|
week: e,
|
|
241
|
-
weekStartsOn:
|
|
242
|
+
weekStartsOn: U,
|
|
242
243
|
pickerType: m,
|
|
243
|
-
calendarKind:
|
|
244
|
-
weekNumberLabel:
|
|
245
|
-
weekLabel:
|
|
246
|
-
fiscalWeekNumberLabel:
|
|
247
|
-
fiscalWeekAriaLabel:
|
|
248
|
-
getCellMeta:
|
|
249
|
-
onWeekSelect:
|
|
244
|
+
calendarKind: u,
|
|
245
|
+
weekNumberLabel: Z,
|
|
246
|
+
weekLabel: $,
|
|
247
|
+
fiscalWeekNumberLabel: L,
|
|
248
|
+
fiscalWeekAriaLabel: T,
|
|
249
|
+
getCellMeta: f,
|
|
250
|
+
onWeekSelect: A,
|
|
250
251
|
...r
|
|
251
252
|
}
|
|
252
253
|
),
|
|
253
254
|
WeekNumberHeader: (e) => {
|
|
254
|
-
const r =
|
|
255
|
-
return /* @__PURE__ */ i("th", { ...e, "aria-label":
|
|
255
|
+
const r = x.useContext(N), t = ne(u, h, r), o = t === void 0 ? F : q[t], a = t === void 0 ? F : b[t];
|
|
256
|
+
return /* @__PURE__ */ i("th", { ...e, "aria-label": a, children: o });
|
|
256
257
|
},
|
|
257
|
-
...
|
|
258
|
+
...K
|
|
258
259
|
};
|
|
259
260
|
}
|
|
260
261
|
export {
|
|
261
|
-
|
|
262
|
+
Ie as buildCalendarDayPickerComponents
|
|
262
263
|
};
|
|
@@ -17,7 +17,7 @@ const a = [
|
|
|
17
17
|
function u(r, t = "fy-short") {
|
|
18
18
|
return c(r, t);
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function d(r, t) {
|
|
21
21
|
if (t)
|
|
22
22
|
try {
|
|
23
23
|
const n = f(t, r);
|
|
@@ -28,7 +28,7 @@ function p(r, t) {
|
|
|
28
28
|
}
|
|
29
29
|
function $(r, t) {
|
|
30
30
|
const n = l(r), e = l(t);
|
|
31
|
-
return n.y === e.y
|
|
31
|
+
return n.y === e.y ? `${a[n.m - 1]} ${n.d} – ${a[e.m - 1]} ${e.d}` : `${a[n.m - 1]} ${n.d} ${n.y} – ${a[e.m - 1]} ${e.d} ${e.y}`;
|
|
32
32
|
}
|
|
33
33
|
function Q(r) {
|
|
34
34
|
return `Period ${r.period} (${$(r.start, r.end)})`;
|
|
@@ -52,11 +52,11 @@ function s(r) {
|
|
|
52
52
|
function L(r, t) {
|
|
53
53
|
return `P${r} ${u(t)}`;
|
|
54
54
|
}
|
|
55
|
-
function
|
|
55
|
+
function b(r, t) {
|
|
56
56
|
return `Q${r} ${u(t)}`;
|
|
57
57
|
}
|
|
58
58
|
function P(r) {
|
|
59
|
-
return r.fy != null ?
|
|
59
|
+
return r.fy != null ? b(r.quarter, r.fy) : `Q${r.quarter} ${r.year}`;
|
|
60
60
|
}
|
|
61
61
|
function I(r, t = "fy-long") {
|
|
62
62
|
return r.fy != null ? u(r.fy, t) : String(r.year);
|
|
@@ -77,7 +77,7 @@ function R(r, t) {
|
|
|
77
77
|
}
|
|
78
78
|
export {
|
|
79
79
|
L as formatFiscalPeriodInput,
|
|
80
|
-
|
|
80
|
+
b as formatFiscalQuarterInput,
|
|
81
81
|
u as formatFiscalYearLabel,
|
|
82
82
|
m as formatPeriodCell,
|
|
83
83
|
F as formatPeriodOption,
|
|
@@ -86,5 +86,5 @@ export {
|
|
|
86
86
|
P as formatQuarterInput,
|
|
87
87
|
R as formatQuarterLabelsForYear,
|
|
88
88
|
I as formatYearInput,
|
|
89
|
-
|
|
89
|
+
d as formatYearIntervalCaption
|
|
90
90
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FiscalPeriod } from '../../../lib/fiscal-calendar';
|
|
2
|
+
/** Local midnight on the 15th. FY can change on the 1st of a civil month. */
|
|
3
|
+
export declare function midMonthDate(month: Date): Date;
|
|
4
|
+
export declare function civilMonthAtOffset(month: Date, offset: number): Date;
|
|
5
|
+
/** Civil month (0-indexed) where `period` has the most days. */
|
|
6
|
+
export declare function dominantCivilMonthForPeriod(period: FiscalPeriod): {
|
|
7
|
+
year: number;
|
|
8
|
+
monthIndex: number;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Month the week/date grid should show after picking a fiscal period.
|
|
12
|
+
* Dual-month range pickers pass `isRightPanel` so the period lands on the right pane.
|
|
13
|
+
*/
|
|
14
|
+
export declare function visibleMonthForPeriod(period: FiscalPeriod, isRightPanel: boolean): Date;
|
|
15
|
+
/** Period that occupies the most days of a civil month (caption selected value). */
|
|
16
|
+
export declare function periodForCivilMonth(periods: readonly FiscalPeriod[], year: number, monthIndex: number): FiscalPeriod | undefined;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { setDate as m, startOfMonth as s, addMonths as h } from "date-fns";
|
|
2
|
+
import { parseCivilDate as d, toCivilDate as l, lastDayOfMonth as y, compareCivil as u, diffDays as v, minCivil as M, maxCivil as p } from "../../../lib/fiscal-calendar/civil-date.js";
|
|
3
|
+
function x(t) {
|
|
4
|
+
return m(s(t), 15);
|
|
5
|
+
}
|
|
6
|
+
function b(t, n) {
|
|
7
|
+
return s(h(t, n));
|
|
8
|
+
}
|
|
9
|
+
function c(t, n, o, e) {
|
|
10
|
+
const r = l(o, e + 1, 1), a = y(o, e + 1), i = p(t, r), f = M(n, a);
|
|
11
|
+
return u(i, f) > 0 ? 0 : v(f, i) + 1;
|
|
12
|
+
}
|
|
13
|
+
function C(t) {
|
|
14
|
+
const n = d(t.start);
|
|
15
|
+
let o = { year: n.y, monthIndex: n.m - 1, days: 0 };
|
|
16
|
+
const e = t.gregorianMonthSpan.length > 0 ? t.gregorianMonthSpan : [{ year: n.y, month: n.m - 1 }];
|
|
17
|
+
for (const { year: r, month: a } of e) {
|
|
18
|
+
const i = c(t.start, t.end, r, a);
|
|
19
|
+
i > o.days && (o = { year: r, monthIndex: a, days: i });
|
|
20
|
+
}
|
|
21
|
+
return { year: o.year, monthIndex: o.monthIndex };
|
|
22
|
+
}
|
|
23
|
+
function I(t, n) {
|
|
24
|
+
const { year: o, monthIndex: e } = C(t), r = s(new Date(o, e, 1));
|
|
25
|
+
return n ? h(r, -1) : r;
|
|
26
|
+
}
|
|
27
|
+
function O(t, n, o) {
|
|
28
|
+
let e, r = 0;
|
|
29
|
+
for (const a of t) {
|
|
30
|
+
const i = c(a.start, a.end, n, o);
|
|
31
|
+
i > r && (e = a, r = i);
|
|
32
|
+
}
|
|
33
|
+
return e;
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
b as civilMonthAtOffset,
|
|
37
|
+
C as dominantCivilMonthForPeriod,
|
|
38
|
+
x as midMonthDate,
|
|
39
|
+
O as periodForCivilMonth,
|
|
40
|
+
I as visibleMonthForPeriod
|
|
41
|
+
};
|
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { civilFromLocalDate as
|
|
3
|
-
import { buildFiscalYear as
|
|
4
|
-
import { getCellMeta as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import * as a from "react";
|
|
2
|
+
import { civilFromLocalDate as o } from "../../../lib/fiscal-calendar/civil-date.js";
|
|
3
|
+
import { buildFiscalYear as d } from "../../../lib/fiscal-calendar/build-year.js";
|
|
4
|
+
import { getCellMeta as l } from "../../../lib/fiscal-calendar/lookup.js";
|
|
5
|
+
import { midMonthDate as n } from "./calendar-fiscal-period-nav.js";
|
|
6
|
+
function F(t, r) {
|
|
7
|
+
const m = n(r), e = (t && l(t, o(m))?.fy) ?? r.getFullYear(), u = a.useMemo(() => {
|
|
8
|
+
if (t)
|
|
8
9
|
try {
|
|
9
|
-
return
|
|
10
|
+
return d(t, e);
|
|
10
11
|
} catch {
|
|
11
12
|
return;
|
|
12
13
|
}
|
|
13
|
-
}, [
|
|
14
|
-
(
|
|
15
|
-
if (
|
|
16
|
-
return
|
|
14
|
+
}, [t, e]), i = a.useCallback(
|
|
15
|
+
(s) => {
|
|
16
|
+
if (t)
|
|
17
|
+
return l(t, o(s));
|
|
17
18
|
},
|
|
18
|
-
[
|
|
19
|
+
[t]
|
|
19
20
|
);
|
|
20
|
-
return { model:
|
|
21
|
+
return { model: u, getCellMeta: i };
|
|
21
22
|
}
|
|
22
23
|
export {
|
|
23
|
-
|
|
24
|
+
F as useFiscalCalendar
|
|
24
25
|
};
|