impact-nova 2.0.6 → 2.0.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/ui/ag-grid-react/headers/header-search-input.d.ts +2 -2
- package/dist/components/ui/ag-grid-react/headers/header-search-input.js +210 -204
- package/dist/components/ui/ag-grid-react/headers/use-header-search-editing-state.d.ts +34 -0
- package/dist/components/ui/ag-grid-react/headers/use-header-search-editing-state.js +70 -0
- package/dist/components/ui/date-picker/date-picker.js +53 -53
- package/dist/components/ui/date-picker/date-range-picker.js +93 -93
- package/dist/components/ui/date-picker/month-picker.js +38 -38
- package/dist/components/ui/date-picker/month-range-picker.js +104 -104
- package/dist/components/ui/date-picker/multi-date-picker.js +31 -28
- package/dist/components/ui/date-picker/multi-month-picker.js +37 -34
- package/dist/components/ui/date-picker/multi-week-picker.js +35 -32
- package/dist/components/ui/date-picker/week-picker.js +62 -62
- package/dist/components/ui/date-picker/week-range-picker.js +62 -62
- package/dist/components/ui/select/select.js +34 -37
- package/dist/llms/rules/real-world-patterns.js +1 -1
- package/dist/llms/rules/troubleshooting.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ColDef, GridApi } from 'ag-grid-community';
|
|
2
|
+
import { HeaderSearchCommittedState } from './derive-header-search-state';
|
|
3
|
+
interface UseHeaderSearchEditingStateOptions {
|
|
4
|
+
api: GridApi;
|
|
5
|
+
colId: string;
|
|
6
|
+
colDef: ColDef | undefined;
|
|
7
|
+
isDateFilter: boolean;
|
|
8
|
+
isMonthVariant: boolean;
|
|
9
|
+
isWeekVariant: boolean;
|
|
10
|
+
datePickerVariant: "date" | "month" | "week";
|
|
11
|
+
dateDisplayFormat: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Inline header search display state.
|
|
15
|
+
*
|
|
16
|
+
* AG Grid's filter model is the source of truth. While inline search is open,
|
|
17
|
+
* AgGridWrapper skips refreshHeader on filterChanged, so this hook subscribes
|
|
18
|
+
* to filterChanged and keeps a column-scoped snapshot in React state. When the
|
|
19
|
+
* snapshot changes, committed display values are re-derived from the live filter
|
|
20
|
+
* model. While an input is focused, a draft overlays committed values so typing
|
|
21
|
+
* is not interrupted.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useHeaderSearchEditingState(options: UseHeaderSearchEditingStateOptions): {
|
|
24
|
+
searchText: string;
|
|
25
|
+
dateDisplayString: string;
|
|
26
|
+
selectedDate: Date;
|
|
27
|
+
selectedMonth: import('../../calendar').MonthSelection;
|
|
28
|
+
selectedWeek: import('../../calendar').WeekSelection;
|
|
29
|
+
updateDraft: (patch: Partial<HeaderSearchCommittedState>) => void;
|
|
30
|
+
handleFocus: () => void;
|
|
31
|
+
handleBlur: () => void;
|
|
32
|
+
clearEditingOverlay: () => void;
|
|
33
|
+
};
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { useCallback as V, useState as l, useEffect as b, useMemo as v } from "react";
|
|
2
|
+
import { subscribeGridApiEvent as W } from "../grid-api-event-subscription.js";
|
|
3
|
+
import { deriveHeaderSearchCommittedState as H } from "./derive-header-search-state.js";
|
|
4
|
+
function A(D) {
|
|
5
|
+
const {
|
|
6
|
+
api: e,
|
|
7
|
+
colId: r,
|
|
8
|
+
colDef: c,
|
|
9
|
+
isDateFilter: d,
|
|
10
|
+
isMonthVariant: u,
|
|
11
|
+
isWeekVariant: m,
|
|
12
|
+
datePickerVariant: S,
|
|
13
|
+
dateDisplayFormat: f
|
|
14
|
+
} = D, n = V(
|
|
15
|
+
() => JSON.stringify(e.getFilterModel()[r] ?? null),
|
|
16
|
+
[e, r]
|
|
17
|
+
), [y, g] = l(
|
|
18
|
+
n
|
|
19
|
+
), [i, o] = l(null), [M, p] = l(!1);
|
|
20
|
+
b(() => W(
|
|
21
|
+
e,
|
|
22
|
+
"filterChanged",
|
|
23
|
+
() => {
|
|
24
|
+
const a = n();
|
|
25
|
+
g(
|
|
26
|
+
(F) => F === a ? F : a
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
), [e, r, n]);
|
|
30
|
+
const h = v(() => H({
|
|
31
|
+
api: e,
|
|
32
|
+
colId: r,
|
|
33
|
+
colDef: c,
|
|
34
|
+
isDateFilter: d,
|
|
35
|
+
isMonthVariant: u,
|
|
36
|
+
isWeekVariant: m,
|
|
37
|
+
datePickerVariant: S,
|
|
38
|
+
dateDisplayFormat: f
|
|
39
|
+
}), [
|
|
40
|
+
e,
|
|
41
|
+
r,
|
|
42
|
+
c,
|
|
43
|
+
d,
|
|
44
|
+
u,
|
|
45
|
+
m,
|
|
46
|
+
S,
|
|
47
|
+
f,
|
|
48
|
+
y
|
|
49
|
+
]), s = (t) => M && i && i[t] !== void 0 ? i[t] : h[t], k = (t) => {
|
|
50
|
+
o((a) => ({ ...h, ...a, ...t }));
|
|
51
|
+
}, C = () => p(!0), x = () => {
|
|
52
|
+
p(!1), o(null);
|
|
53
|
+
}, E = () => {
|
|
54
|
+
o(null);
|
|
55
|
+
};
|
|
56
|
+
return {
|
|
57
|
+
searchText: s("searchText"),
|
|
58
|
+
dateDisplayString: s("dateDisplayString"),
|
|
59
|
+
selectedDate: s("selectedDate"),
|
|
60
|
+
selectedMonth: s("selectedMonth"),
|
|
61
|
+
selectedWeek: s("selectedWeek"),
|
|
62
|
+
updateDraft: k,
|
|
63
|
+
handleFocus: C,
|
|
64
|
+
handleBlur: x,
|
|
65
|
+
clearEditingOverlay: E
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export {
|
|
69
|
+
A as useHeaderSearchEditingState
|
|
70
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import * as
|
|
1
|
+
import { jsxs as P, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import * as o from "react";
|
|
3
3
|
import { Cross as Z, CalendarMonth as _ } from "impact-nova-icons";
|
|
4
|
-
import { format as h, isValid as I, parse as
|
|
4
|
+
import { format as h, isValid as I, parse as N } from "date-fns";
|
|
5
5
|
import { cn as $, padValidDateString as F, maskDate as ee } from "../../../lib/utils.js";
|
|
6
6
|
import { Input as te } from "../input.js";
|
|
7
7
|
import { Popover as ne, PopoverAnchor as re, PopoverContent as oe } from "../popover.js";
|
|
@@ -9,78 +9,78 @@ import { Calendar as ce } from "../calendar.js";
|
|
|
9
9
|
import { Tooltip as S, TooltipTrigger as E, TooltipContent as T } from "../tooltip.js";
|
|
10
10
|
import { getDateFnsLocale as ie } from "../../../i18n/getDateFnsLocale.js";
|
|
11
11
|
import { useImpactNovaI18n as le } from "../../../i18n/ImpactNovaI18nContext.js";
|
|
12
|
-
const ae =
|
|
12
|
+
const ae = o.forwardRef(
|
|
13
13
|
({
|
|
14
14
|
value: t,
|
|
15
|
-
onChange:
|
|
15
|
+
onChange: u,
|
|
16
16
|
format: n = "MM/dd/yyyy",
|
|
17
17
|
placeholder: j,
|
|
18
18
|
minDate: L,
|
|
19
19
|
maxDate: K,
|
|
20
20
|
startMonth: z,
|
|
21
21
|
endMonth: B,
|
|
22
|
-
showFooter:
|
|
23
|
-
weekStartsOn:
|
|
24
|
-
disabled:
|
|
22
|
+
showFooter: d = !0,
|
|
23
|
+
weekStartsOn: R,
|
|
24
|
+
disabled: a,
|
|
25
25
|
className: O,
|
|
26
26
|
...H
|
|
27
27
|
}, q) => {
|
|
28
|
-
const { locale:
|
|
29
|
-
|
|
30
|
-
const [
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}, [p]),
|
|
34
|
-
|
|
35
|
-
}, [t, n,
|
|
36
|
-
|
|
37
|
-
}, [
|
|
28
|
+
const { locale: b, t: m } = le(), i = o.useMemo(() => ie(b), [b]), G = j ?? m("datePicker.selectDate"), g = o.useRef(null), D = o.useRef(null);
|
|
29
|
+
o.useImperativeHandle(q, () => g.current);
|
|
30
|
+
const [c, l] = o.useState(!1), k = o.useRef(!1), [v, s] = o.useState(t), [p, f] = o.useState(t ? h(t, n, { locale: i }) : ""), [J, w] = o.useState(t || /* @__PURE__ */ new Date());
|
|
31
|
+
o.useEffect(() => {
|
|
32
|
+
g.current && D.current !== null && (g.current.setSelectionRange(D.current, D.current), D.current = null);
|
|
33
|
+
}, [p]), o.useEffect(() => {
|
|
34
|
+
c || (f(t ? h(t, n, { locale: i }) : ""), s(t));
|
|
35
|
+
}, [t, n, c, i]), o.useEffect(() => {
|
|
36
|
+
c && (s(t), w(t || /* @__PURE__ */ new Date()));
|
|
37
|
+
}, [c, t]);
|
|
38
38
|
const Q = (e) => {
|
|
39
|
-
|
|
39
|
+
s(e), e && f(h(e, n, { locale: i })), d || (u?.(e), l(!1));
|
|
40
40
|
}, U = (e) => {
|
|
41
|
-
|
|
41
|
+
u?.(e !== void 0 ? e : v), l(!1);
|
|
42
42
|
}, V = () => {
|
|
43
|
-
|
|
43
|
+
s(t), f(t ? h(t, n, { locale: i }) : ""), l(!1);
|
|
44
44
|
}, A = () => {
|
|
45
|
-
|
|
45
|
+
s(void 0), f(""), u?.(void 0), d || l(!1);
|
|
46
46
|
}, W = (e) => {
|
|
47
|
-
const
|
|
47
|
+
const y = e.target.value, C = ee(y, n, p);
|
|
48
48
|
if (f(C), C === "") {
|
|
49
|
-
|
|
49
|
+
s(void 0), d || u?.(void 0);
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
|
-
const
|
|
53
|
-
I(
|
|
52
|
+
const x = N(C, n, /* @__PURE__ */ new Date(), { locale: i });
|
|
53
|
+
I(x) && C.length === n.length && (s(x), w(x), d || u?.(x));
|
|
54
54
|
}, X = () => {
|
|
55
|
-
if (
|
|
56
|
-
const e = F(p, n),
|
|
57
|
-
!I(
|
|
58
|
-
}, M = (t ? h(t, n, { locale: i }) : "") !== p, Y = p.length === n.length && !I(
|
|
59
|
-
return /* @__PURE__ */
|
|
60
|
-
|
|
55
|
+
if (c) return;
|
|
56
|
+
const e = F(p, n), y = N(e, n, /* @__PURE__ */ new Date(), { locale: i });
|
|
57
|
+
!I(y) || e.length !== n.length ? (f(t ? h(t, n, { locale: i }) : ""), s(t)) : (f(e), d || u?.(y));
|
|
58
|
+
}, M = (t ? h(t, n, { locale: i }) : "") !== p, Y = p.length === n.length && !I(N(p, n, /* @__PURE__ */ new Date(), { locale: i }));
|
|
59
|
+
return /* @__PURE__ */ P(ne, { open: a ? !1 : c, onOpenChange: (e) => {
|
|
60
|
+
a || l(e);
|
|
61
61
|
}, children: [
|
|
62
|
-
/* @__PURE__ */
|
|
62
|
+
/* @__PURE__ */ r(re, { asChild: !0, children: /* @__PURE__ */ r("div", { "data-component": "date-picker", "data-state": c ? "open" : "closed", "data-pending": M || void 0, children: /* @__PURE__ */ r(
|
|
63
63
|
te,
|
|
64
64
|
{
|
|
65
|
-
ref:
|
|
65
|
+
ref: g,
|
|
66
66
|
value: p,
|
|
67
67
|
onChange: W,
|
|
68
68
|
onBlur: X,
|
|
69
|
-
onClick: (
|
|
69
|
+
onClick: () => !a && l(!0),
|
|
70
70
|
onKeyDown: (e) => {
|
|
71
|
-
(e.key === "Enter" || e.key === "ArrowDown") && !
|
|
71
|
+
(e.key === "Enter" || e.key === "ArrowDown") && !c && !a && (e.preventDefault(), k.current = !0, l(!0)), e.key === "Escape" && c && (e.preventDefault(), V());
|
|
72
72
|
},
|
|
73
|
-
placeholder:
|
|
74
|
-
disabled:
|
|
73
|
+
placeholder: c ? n : G,
|
|
74
|
+
disabled: a,
|
|
75
75
|
"data-form-control": "input",
|
|
76
76
|
className: $(
|
|
77
77
|
"cursor-pointer",
|
|
78
78
|
Y ? "text-destructive" : M ? "text-content-muted" : "",
|
|
79
79
|
O
|
|
80
80
|
),
|
|
81
|
-
suffix: /* @__PURE__ */
|
|
82
|
-
t && !
|
|
83
|
-
/* @__PURE__ */
|
|
81
|
+
suffix: /* @__PURE__ */ P("div", { className: "flex items-center gap-1", children: [
|
|
82
|
+
t && !a && /* @__PURE__ */ P(S, { children: [
|
|
83
|
+
/* @__PURE__ */ r(E, { asChild: !0, children: /* @__PURE__ */ r(
|
|
84
84
|
"button",
|
|
85
85
|
{
|
|
86
86
|
type: "button",
|
|
@@ -90,24 +90,24 @@ const ae = c.forwardRef(
|
|
|
90
90
|
e.stopPropagation(), A();
|
|
91
91
|
},
|
|
92
92
|
className: "inline-flex size-4 items-center justify-center bg-transparent border-none p-0 cursor-pointer",
|
|
93
|
-
children: /* @__PURE__ */
|
|
93
|
+
children: /* @__PURE__ */ r(Z, { className: "size-3 hover:text-content" })
|
|
94
94
|
}
|
|
95
95
|
) }),
|
|
96
|
-
/* @__PURE__ */
|
|
96
|
+
/* @__PURE__ */ r(T, { variant: "tertiary", side: "top", children: m("calendar.clear") })
|
|
97
97
|
] }),
|
|
98
|
-
/* @__PURE__ */
|
|
99
|
-
/* @__PURE__ */
|
|
100
|
-
e.stopPropagation(),
|
|
98
|
+
/* @__PURE__ */ P(S, { children: [
|
|
99
|
+
/* @__PURE__ */ r(E, { asChild: !0, children: /* @__PURE__ */ r("button", { type: "button", tabIndex: 0, "aria-label": m("datePicker.selectDate"), onClick: (e) => {
|
|
100
|
+
e.stopPropagation(), a || l(!c);
|
|
101
101
|
}, onKeyDown: (e) => {
|
|
102
|
-
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), e.stopPropagation(),
|
|
103
|
-
}, className: "inline-flex items-center justify-center bg-transparent border-none p-0 cursor-pointer", children: /* @__PURE__ */
|
|
104
|
-
/* @__PURE__ */
|
|
102
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), e.stopPropagation(), a || (k.current = !0, l(!c)));
|
|
103
|
+
}, className: "inline-flex items-center justify-center bg-transparent border-none p-0 cursor-pointer", children: /* @__PURE__ */ r(_, { className: "h-4 w-4 text-secondary-foreground" }) }) }),
|
|
104
|
+
/* @__PURE__ */ r(T, { variant: "tertiary", side: "top", children: m("datePicker.selectDate") })
|
|
105
105
|
] })
|
|
106
106
|
] }),
|
|
107
107
|
...H
|
|
108
108
|
}
|
|
109
109
|
) }) }),
|
|
110
|
-
/* @__PURE__ */
|
|
110
|
+
/* @__PURE__ */ r(
|
|
111
111
|
oe,
|
|
112
112
|
{
|
|
113
113
|
className: "w-auto p-0",
|
|
@@ -115,7 +115,7 @@ const ae = c.forwardRef(
|
|
|
115
115
|
onOpenAutoFocus: (e) => {
|
|
116
116
|
k.current || e.preventDefault(), k.current = !1;
|
|
117
117
|
},
|
|
118
|
-
children: /* @__PURE__ */
|
|
118
|
+
children: /* @__PURE__ */ r(
|
|
119
119
|
ce,
|
|
120
120
|
{
|
|
121
121
|
mode: "single",
|
|
@@ -126,12 +126,12 @@ const ae = c.forwardRef(
|
|
|
126
126
|
disabled: { before: L, after: K },
|
|
127
127
|
startMonth: z,
|
|
128
128
|
endMonth: B,
|
|
129
|
-
showFooter:
|
|
129
|
+
showFooter: d,
|
|
130
130
|
onApply: U,
|
|
131
131
|
onCancel: V,
|
|
132
132
|
onClear: A,
|
|
133
133
|
captionLayout: "dropdown",
|
|
134
|
-
...
|
|
134
|
+
...R !== void 0 ? { weekStartsOn: R } : {}
|
|
135
135
|
}
|
|
136
136
|
)
|
|
137
137
|
}
|