impact-nova 1.0.0 → 1.1.0

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.
@@ -1,50 +1,61 @@
1
- import { jsx as r, jsxs as u } from "react/jsx-runtime";
2
- import { CalendarDays as m } from "lucide-react";
3
- const f = (e, i) => {
4
- if (e == null || e === "") return "";
1
+ import { jsx as e, jsxs as o } from "react/jsx-runtime";
2
+ import "lucide-react";
3
+ const u = (t, r) => {
4
+ if (t == null || t === "") return "";
5
5
  try {
6
- const t = e instanceof Date ? e : new Date(String(e));
7
- return isNaN(t.getTime()) ? String(e) : i === "time" ? t.toLocaleTimeString(void 0, { hour: "2-digit", minute: "2-digit" }) : i === "datetime-local" ? t.toLocaleString(void 0, {
6
+ const i = t instanceof Date ? t : new Date(String(t));
7
+ return isNaN(i.getTime()) ? String(t) : r === "time" ? i.toLocaleTimeString(void 0, { hour: "2-digit", minute: "2-digit" }) : r === "datetime-local" ? i.toLocaleString(void 0, {
8
8
  year: "numeric",
9
9
  month: "short",
10
10
  day: "numeric",
11
11
  hour: "2-digit",
12
12
  minute: "2-digit"
13
- }) : t.toLocaleDateString(void 0, {
13
+ }) : i.toLocaleDateString(void 0, {
14
14
  year: "numeric",
15
15
  month: "short",
16
16
  day: "numeric"
17
17
  });
18
18
  } catch {
19
- return String(e);
19
+ return String(t);
20
20
  }
21
- }, h = (e) => {
21
+ }, m = (t) => {
22
22
  const {
23
- valueFormatted: i,
24
- value: t,
25
- dateType: d = "date",
26
- placeholder: l = "Select date...",
23
+ valueFormatted: r,
24
+ value: i,
25
+ dateType: s = "date",
26
+ placeholder: h = "Select date...",
27
27
  disabled: n,
28
- colDef: s
29
- } = e, c = !n && s?.editable === !0, a = i ?? f(t, d), o = !a;
30
- return /* @__PURE__ */ r(
28
+ colDef: l
29
+ } = t, c = !n && l?.editable === !0, a = r ?? u(i, s), d = !a;
30
+ return /* @__PURE__ */ e(
31
31
  "div",
32
32
  {
33
33
  className: `w-full h-full flex items-center ag-cell-inner-padding ${n ? "opacity-60 cursor-not-allowed" : c ? "in-ag-editable-cell-highlight" : ""}`,
34
- children: /* @__PURE__ */ u(
34
+ children: /* @__PURE__ */ o(
35
35
  "div",
36
36
  {
37
37
  className: "flex w-full items-center justify-between rounded-[8px] bg-white px-1.5 h-7 cursor-pointer",
38
38
  children: [
39
- /* @__PURE__ */ r("span", { className: `truncate text-sm font-medium text-[#1f2b4d] ${o ? "text-[#dfe2e7]" : ""}`, children: o ? l : a }),
40
- /* @__PURE__ */ r(m, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" })
39
+ /* @__PURE__ */ e("span", { className: `truncate text-sm font-medium text-[#1f2b4d] ${d ? "text-[#dfe2e7]" : ""}`, children: d ? h : a }),
40
+ /* @__PURE__ */ e("span", { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground", children: /* @__PURE__ */ o("svg", { xmlns: "http://www.w3.org/2000/svg", width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
41
+ /* @__PURE__ */ e("rect", { x: "3", y: "4", width: "18", height: "18", rx: "2" }),
42
+ /* @__PURE__ */ e("path", { d: "M16 2v4" }),
43
+ /* @__PURE__ */ e("path", { d: "M8 2v4" }),
44
+ /* @__PURE__ */ e("path", { d: "M3 10h18" }),
45
+ /* @__PURE__ */ e("path", { d: "M8 14h.01" }),
46
+ /* @__PURE__ */ e("path", { d: "M12 14h.01" }),
47
+ /* @__PURE__ */ e("path", { d: "M16 14h.01" }),
48
+ /* @__PURE__ */ e("path", { d: "M8 18h.01" }),
49
+ /* @__PURE__ */ e("path", { d: "M12 18h.01" }),
50
+ /* @__PURE__ */ e("path", { d: "M16 18h.01" })
51
+ ] }) })
41
52
  ]
42
53
  }
43
54
  )
44
55
  }
45
56
  );
46
57
  };
47
- h.displayName = "DateDisplayRenderer";
58
+ m.displayName = "DateDisplayRenderer";
48
59
  export {
49
- h as DateDisplayRenderer
60
+ m as DateDisplayRenderer
50
61
  };
@@ -8,15 +8,13 @@ export interface DateCellEditorProps extends ICellEditorParams {
8
8
  max?: string;
9
9
  }
10
10
  /**
11
- * DateCellEditor - AG Grid popup cell editor with a native date input.
11
+ * DateCellEditor - AG Grid popup cell editor using the project's Calendar component.
12
12
  *
13
- * Uses the browser's native date picker for reliable cross-browser support.
14
- * Mounted by AG Grid as a popup editor (requires `cellEditorPopup: true`).
13
+ * Opens the Calendar directly on mount so the user sees the calendar popup
14
+ * immediately on click no extra interaction needed.
15
15
  *
16
16
  * Returns an ISO string on commit, which AG Grid stores as the cell value.
17
17
  *
18
- * Only holds a single piece of state: the current date string.
19
- *
20
18
  * Usage in colDef:
21
19
  * ```ts
22
20
  * {
@@ -1,30 +1,26 @@
1
- import { jsx as c } from "react/jsx-runtime";
2
- import { forwardRef as h, useRef as y, useState as S, useImperativeHandle as b, useCallback as u } from "react";
3
- const w = (e, n) => {
4
- if (e == null || e === "") return "";
5
- try {
6
- const t = e instanceof Date ? e : new Date(String(e));
7
- return isNaN(t.getTime()) ? "" : n === "date" ? t.toISOString().split("T")[0] : n === "datetime-local" ? t.toISOString().slice(0, 16) : n === "time" ? t.toISOString().slice(11, 16) : "";
8
- } catch {
9
- return "";
10
- }
11
- }, C = h((e, n) => {
1
+ import { jsx as S } from "react/jsx-runtime";
2
+ import { forwardRef as M, useState as b, useImperativeHandle as y, useEffect as N, useCallback as c } from "react";
3
+ import { Calendar as P } from "../../../calendar.js";
4
+ const d = (t) => {
5
+ if (!(t == null || t === ""))
6
+ try {
7
+ const n = t instanceof Date ? t : new Date(String(t));
8
+ return isNaN(n.getTime()) ? void 0 : n;
9
+ } catch {
10
+ return;
11
+ }
12
+ }, I = M((t, n) => {
12
13
  const {
13
- value: t,
14
- dateType: a = "date",
15
- min: l,
16
- max: d,
17
- stopEditing: s
18
- } = e, i = y(null), [o, f] = S(w(t, a));
19
- b(n, () => ({
14
+ value: l,
15
+ min: u,
16
+ max: p,
17
+ node: i,
18
+ column: m,
19
+ stopEditing: f
20
+ } = t, g = d(l), [C, h] = b(g), [v, D] = b(g || /* @__PURE__ */ new Date());
21
+ y(n, () => ({
20
22
  getValue() {
21
- if (!o) return null;
22
- if (a === "time") return o;
23
- try {
24
- return new Date(o).toISOString();
25
- } catch {
26
- return o;
27
- }
23
+ return l;
28
24
  },
29
25
  isCancelBeforeStart() {
30
26
  return !1;
@@ -34,40 +30,46 @@ const w = (e, n) => {
34
30
  },
35
31
  isPopup() {
36
32
  return !0;
37
- },
38
- afterGuiAttached() {
39
- if (i.current) {
40
- i.current.focus();
41
- try {
42
- i.current.showPicker?.();
43
- } catch {
44
- }
45
- }
46
33
  }
47
- }));
48
- const p = u((r) => {
49
- f(r.target.value);
50
- }, []), m = u((r) => {
51
- r.key === "Enter" || r.key === "Escape" || r.key === "Tab" || r.stopPropagation();
52
- }, []), g = u(() => {
53
- s();
54
- }, [s]);
55
- return /* @__PURE__ */ c("div", { className: "p-1 bg-white border border-primary rounded-md shadow-lg", children: /* @__PURE__ */ c(
56
- "input",
34
+ })), N(() => {
35
+ const e = "ag-custom-component-popup", a = (o) => {
36
+ o instanceof HTMLElement && o.hasAttribute("data-radix-popper-content-wrapper") && o.classList.add(e);
37
+ }, s = new MutationObserver((o) => {
38
+ for (const L of o)
39
+ L.addedNodes.forEach(a);
40
+ });
41
+ return s.observe(document.body, { childList: !0, subtree: !0 }), document.querySelectorAll("[data-radix-popper-content-wrapper]").forEach((o) => {
42
+ o.classList.add(e);
43
+ }), () => s.disconnect();
44
+ }, []);
45
+ const r = c((e) => {
46
+ const a = m?.getColId();
47
+ if (a && i) {
48
+ const s = e ? `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}` : null;
49
+ i.setDataValue(a, s);
50
+ }
51
+ f();
52
+ }, [m, i, f]), w = c((e) => {
53
+ h(e), r(e);
54
+ }, [r]), E = c(() => {
55
+ h(void 0), r(void 0);
56
+ }, [r]), A = u ? d(u) : void 0, x = p ? d(p) : void 0;
57
+ return /* @__PURE__ */ S("div", { className: "ag-custom-component-popup bg-white border border-input rounded-md shadow-lg", children: /* @__PURE__ */ S(
58
+ P,
57
59
  {
58
- ref: i,
59
- type: a,
60
- value: o,
61
- onChange: p,
62
- onKeyDown: m,
63
- onBlur: g,
64
- min: l,
65
- max: d,
66
- className: "px-2 py-1.5 text-sm font-medium bg-white border border-input rounded focus:outline-none focus:border-primary cursor-pointer"
60
+ mode: "single",
61
+ selected: C,
62
+ onSelect: w,
63
+ month: v,
64
+ onMonthChange: D,
65
+ disabled: { before: A, after: x },
66
+ showFooter: !1,
67
+ onClear: E,
68
+ captionLayout: "dropdown"
67
69
  }
68
70
  ) });
69
71
  });
70
- C.displayName = "DateCellEditor";
72
+ I.displayName = "DateCellEditor";
71
73
  export {
72
- C as DateCellEditor
74
+ I as DateCellEditor
73
75
  };
@@ -1,108 +1,112 @@
1
- import { jsxs as P, jsx as a } from "react/jsx-runtime";
2
- import * as i from "react";
3
- import { X } from "lucide-react";
4
- import { CalendarMonth as q } from "../../../icons/index.js";
5
- import { format as f, parse as x, isValid as v } from "date-fns";
6
- import { cn as z, maskDate as G } from "../../../lib/utils.js";
7
- import { Input as H } from "../input.js";
8
- import { Popover as J, PopoverTrigger as K, PopoverContent as Q } from "../popover.js";
9
- import { Calendar as U } from "../calendar.js";
10
- const W = i.forwardRef(
1
+ import { jsxs as V, jsx as l } from "react/jsx-runtime";
2
+ import * as o from "react";
3
+ import { X as z } from "lucide-react";
4
+ import { CalendarMonth as G } from "../../../icons/index.js";
5
+ import { format as a, isValid as x, parse as C } from "date-fns";
6
+ import { cn as J, padValidDateString as K, maskDate as Q } from "../../../lib/utils.js";
7
+ import { Input as U } from "../input.js";
8
+ import { Popover as W, PopoverTrigger as Y, PopoverContent as Z } from "../popover.js";
9
+ import { Calendar as _ } from "../calendar.js";
10
+ const $ = o.forwardRef(
11
11
  ({
12
- value: t,
12
+ value: e,
13
13
  onChange: p,
14
- format: n = "MM/dd/yyyy",
15
- placeholder: S = "Select Date",
16
- minDate: k,
14
+ format: t = "MM/dd/yyyy",
15
+ placeholder: k = "Select Date",
16
+ minDate: I,
17
17
  maxDate: M,
18
18
  fromYear: N,
19
- toYear: w,
20
- showFooter: s = !0,
21
- disabled: y,
22
- className: A,
23
- ...V
24
- }, I) => {
25
- const [o, l] = i.useState(!1), [r, c] = i.useState(t), [d, u] = i.useState(t ? f(t, n) : ""), [O, h] = i.useState(t || /* @__PURE__ */ new Date());
26
- i.useEffect(() => {
27
- u(t ? f(t, n) : "");
28
- }, [t, n]), i.useEffect(() => {
29
- o && (c(t), h(t || /* @__PURE__ */ new Date()));
30
- }, [o]);
31
- const T = (e) => {
32
- c(e), s || (p?.(e), l(!1));
33
- }, j = (e) => {
34
- p?.(e !== void 0 ? e : r), l(!1);
35
- }, B = () => {
36
- c(t), l(!1);
37
- }, D = () => {
38
- c(void 0), u(""), p?.(void 0), s || l(!1);
39
- }, E = (e) => {
40
- const m = G(e.target.value, n);
41
- if (u(m), m === "") {
42
- c(void 0), s || p?.(void 0);
19
+ toYear: A,
20
+ showFooter: f = !0,
21
+ disabled: P,
22
+ className: E,
23
+ ...O
24
+ }, T) => {
25
+ const g = o.useRef(null), h = o.useRef(null);
26
+ o.useImperativeHandle(T, () => g.current);
27
+ const [r, d] = o.useState(!1), [S, s] = o.useState(e), [i, c] = o.useState(e ? a(e, t) : ""), [j, y] = o.useState(e || /* @__PURE__ */ new Date());
28
+ o.useEffect(() => {
29
+ g.current && h.current !== null && (g.current.setSelectionRange(h.current, h.current), h.current = null);
30
+ }, [i]), o.useEffect(() => {
31
+ !r && e && (c(a(e, t)), s(e));
32
+ }, [e, t, r]), o.useEffect(() => {
33
+ r && (s(e), y(e || /* @__PURE__ */ new Date()));
34
+ }, [r, e]);
35
+ const B = (n) => {
36
+ s(n), n && c(a(n, t)), f || (p?.(n), d(!1));
37
+ }, v = (n) => {
38
+ p?.(n !== void 0 ? n : S), d(!1);
39
+ }, H = () => {
40
+ s(e), c(e ? a(e, t) : ""), d(!1);
41
+ }, w = () => {
42
+ s(void 0), c(""), p?.(void 0), f || d(!1);
43
+ }, L = (n) => {
44
+ const u = n.target.value, m = Q(u, t, i);
45
+ if (c(m), m === "") {
46
+ s(void 0), f || p?.(void 0);
43
47
  return;
44
48
  }
45
- const g = x(m, n, /* @__PURE__ */ new Date());
46
- v(g) && (c(g), h(g), s || p?.(g));
47
- }, R = () => {
48
- if (o) return;
49
- if (d === "") {
50
- D();
51
- return;
52
- }
53
- const e = x(d, n, /* @__PURE__ */ new Date());
54
- v(e) || u(r ? f(r, n) : "");
55
- }, C = s && o && (r ? f(r, n) : "") !== d, L = s && o ? r ? f(r, n) : "" : d;
56
- return /* @__PURE__ */ P(J, { open: o, onOpenChange: l, children: [
57
- /* @__PURE__ */ a(K, { asChild: !0, children: /* @__PURE__ */ a("div", { "data-component": "date-picker", "data-state": o ? "open" : "closed", "data-pending": C || void 0, children: /* @__PURE__ */ a(
58
- H,
49
+ const D = C(m, t, /* @__PURE__ */ new Date());
50
+ x(D) && m.length === t.length && (s(D), y(D), f || p?.(D));
51
+ }, X = () => {
52
+ if (r) return;
53
+ const n = K(i, t), u = C(n, t, /* @__PURE__ */ new Date());
54
+ !x(u) || n.length !== t.length ? (c(e ? a(e, t) : ""), s(e)) : (c(n), f || p?.(u));
55
+ }, R = (e ? a(e, t) : "") !== i, q = i.length === t.length && !x(C(i, t, /* @__PURE__ */ new Date()));
56
+ return /* @__PURE__ */ V(W, { open: r, onOpenChange: d, children: [
57
+ /* @__PURE__ */ l(Y, { asChild: !0, children: /* @__PURE__ */ l("div", { "data-component": "date-picker", "data-state": r ? "open" : "closed", "data-pending": R || void 0, children: /* @__PURE__ */ l(
58
+ U,
59
59
  {
60
- ref: I,
61
- value: L,
62
- onChange: E,
63
- onBlur: R,
64
- onClick: (e) => o && e.stopPropagation(),
65
- placeholder: o ? n : S,
66
- disabled: y,
60
+ ref: g,
61
+ value: i,
62
+ onChange: L,
63
+ onBlur: X,
64
+ onClick: (n) => r && n.stopPropagation(),
65
+ placeholder: r ? t : k,
66
+ disabled: P,
67
67
  "data-form-control": "input",
68
- className: z("cursor-pointer", C && "text-muted-foreground", A),
69
- suffix: /* @__PURE__ */ P("div", { className: "flex items-center gap-1", children: [
70
- t && !y && /* @__PURE__ */ a(
71
- X,
68
+ className: J(
69
+ "cursor-pointer",
70
+ q ? "text-destructive" : R ? "text-muted-foreground" : "",
71
+ E
72
+ ),
73
+ suffix: /* @__PURE__ */ V("div", { className: "flex items-center gap-1", children: [
74
+ e && !P && /* @__PURE__ */ l(
75
+ z,
72
76
  {
73
77
  className: "h-4 w-4 cursor-pointer hover:text-foreground",
74
- onClick: (e) => {
75
- e.stopPropagation(), D();
78
+ onClick: (n) => {
79
+ n.stopPropagation(), w();
76
80
  }
77
81
  }
78
82
  ),
79
- /* @__PURE__ */ a(q, { className: "h-4 w-4 text-secondary-foreground" })
83
+ /* @__PURE__ */ l(G, { className: "h-4 w-4 text-secondary-foreground" })
80
84
  ] }),
81
- ...V
85
+ ...O
82
86
  }
83
87
  ) }) }),
84
- /* @__PURE__ */ a(
85
- Q,
88
+ /* @__PURE__ */ l(
89
+ Z,
86
90
  {
87
91
  className: "w-auto p-0",
88
92
  align: "start",
89
- onOpenAutoFocus: (e) => e.preventDefault(),
90
- children: /* @__PURE__ */ a(
91
- U,
93
+ onOpenAutoFocus: (n) => n.preventDefault(),
94
+ children: /* @__PURE__ */ l(
95
+ _,
92
96
  {
93
97
  mode: "single",
94
- selected: r,
95
- onSelect: T,
96
- month: O,
97
- onMonthChange: h,
98
- fromDate: k,
98
+ selected: S,
99
+ onSelect: B,
100
+ month: j,
101
+ onMonthChange: y,
102
+ fromDate: I,
99
103
  toDate: M,
100
104
  fromYear: N,
101
- toYear: w,
102
- showFooter: s,
103
- onApply: j,
104
- onCancel: B,
105
- onClear: D,
105
+ toYear: A,
106
+ showFooter: f,
107
+ onApply: v,
108
+ onCancel: H,
109
+ onClear: w,
106
110
  captionLayout: "dropdown"
107
111
  }
108
112
  )
@@ -111,7 +115,7 @@ const W = i.forwardRef(
111
115
  ] });
112
116
  }
113
117
  );
114
- W.displayName = "DatePicker";
118
+ $.displayName = "DatePicker";
115
119
  export {
116
- W as DatePicker
120
+ $ as DatePicker
117
121
  };