impact-nova 1.6.2 → 1.6.3

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.
@@ -8,10 +8,6 @@ export declare const DataTable: ({ children, className }: {
8
8
  children: React.ReactNode;
9
9
  className?: string;
10
10
  }) => import("react/jsx-runtime").JSX.Element;
11
- /**
12
- * DataTable Content
13
- * Wraps AgGridWrapper and captures the API reference.
14
- */
15
11
  export declare function DataTableContent<TData>(props: AgGridWrapperProps<TData> & {
16
12
  className?: string;
17
13
  }): import("react/jsx-runtime").JSX.Element;
@@ -1,87 +1,121 @@
1
- import { jsx as r, jsxs as A } from "react/jsx-runtime";
2
- import { useState as e, useRef as R, useCallback as x, useEffect as _ } from "react";
3
- import { AgGridWrapper as D } from "../ag-grid-react/index.js";
4
- import { cn as b } from "../../../lib/utils.js";
5
- import { DataTableContext as G, useDataTable as E } from "./data-table-context.js";
6
- import { DATA_TABLE_SCOPED_SHEET_HOST_MIN_HEIGHT_PX as N } from "./data-table-constants.js";
7
- const H = {
1
+ import { jsx as c, jsxs as C } from "react/jsx-runtime";
2
+ import { useState as s, useRef as E, useCallback as A, useMemo as H, useEffect as _ } from "react";
3
+ import { AgGridWrapper as O } from "../ag-grid-react/index.js";
4
+ import { cn as y } from "../../../lib/utils.js";
5
+ import { DataTableContext as D, useDataTable as P } from "./data-table-context.js";
6
+ import { DATA_TABLE_SCOPED_SHEET_HOST_MIN_HEIGHT_PX as F } from "./data-table-constants.js";
7
+ import { AG_GRID_VALUE_FORMATTERS as N } from "../ag-grid-react/value-formatters.js";
8
+ const R = {
8
9
  default: 46,
9
10
  compact: 30,
10
11
  comfort: 52
11
- }, I = ({
12
- children: t,
13
- className: o
12
+ }, G = (o) => {
13
+ if (o)
14
+ return o.map((e) => {
15
+ if ("children" in e && e.children)
16
+ return {
17
+ ...e,
18
+ children: G(e.children)
19
+ };
20
+ const t = e;
21
+ return !t.valueFormatter && (t.type === "numericColumn" || t.type === "number") ? {
22
+ ...t,
23
+ valueFormatter: N.number
24
+ } : t;
25
+ });
26
+ }, W = ({
27
+ children: o,
28
+ className: e
14
29
  }) => {
15
- const [d, i] = e(null), [n, c] = e(null), [a, p] = e("medium"), [m, h] = e("full"), [s, u] = e("default"), [f, l] = e(!1), g = R(0), T = x((S) => {
16
- g.current = Math.max(0, g.current + S), l(g.current > 0);
17
- }, []), v = x((S) => {
18
- i(S);
19
- }, []), w = {
30
+ const [t, d] = s(null), [r, u] = s(null), [n, p] = s("medium"), [f, h] = s("full"), [a, m] = s("default"), [g, x] = s(!1), l = E(0), T = A((S) => {
31
+ l.current = Math.max(0, l.current + S), x(l.current > 0);
32
+ }, []), b = A((S) => {
33
+ d(S);
34
+ }, []), v = {
20
35
  small: "12px",
21
36
  medium: "14px",
22
37
  large: "16px"
23
- }[a], y = `${H[s]}px`;
24
- return /* @__PURE__ */ r(G.Provider, { value: {
25
- gridApi: d,
26
- registerApi: v,
27
- sheetTarget: n,
28
- setSheetTarget: c,
29
- scopedSheetOpen: f,
38
+ }[n], i = `${R[a]}px`;
39
+ return /* @__PURE__ */ c(D.Provider, { value: {
40
+ gridApi: t,
41
+ registerApi: b,
42
+ sheetTarget: r,
43
+ setSheetTarget: u,
44
+ scopedSheetOpen: g,
30
45
  registerScopedSheetDepth: T,
31
- fontSize: a,
46
+ fontSize: n,
32
47
  setFontSize: p,
33
- numericFormat: m,
48
+ numericFormat: f,
34
49
  setNumericFormat: h,
35
- rowHeight: s,
36
- setRowHeight: u
37
- }, children: /* @__PURE__ */ r(
50
+ rowHeight: a,
51
+ setRowHeight: m
52
+ }, children: /* @__PURE__ */ c(
38
53
  "div",
39
54
  {
40
55
  "data-component": "data-table",
41
- className: b("flex flex-col w-full min-h-0 rounded-[inherit]", o),
56
+ className: y("flex flex-col w-full min-h-0 rounded-[inherit]", e),
42
57
  style: {
43
- "--ag-font-size": w,
44
- "--ag-row-height": y
58
+ "--ag-font-size": v,
59
+ "--ag-row-height": i
45
60
  },
46
- children: t
61
+ children: o
47
62
  }
48
63
  ) });
64
+ }, w = {
65
+ full: "full_no",
66
+ k: "thou",
67
+ m: "mil",
68
+ b: "bil"
49
69
  };
50
- function k(t) {
70
+ function X(o) {
51
71
  const {
52
- registerApi: o,
53
- setSheetTarget: d,
54
- rowHeight: i,
55
- gridApi: n,
56
- scopedSheetOpen: c
57
- } = E(), { className: a, onGridReady: p, rowHeight: m, ...h } = t, s = H[i], u = m ?? s;
72
+ registerApi: e,
73
+ setSheetTarget: t,
74
+ rowHeight: d,
75
+ gridApi: r,
76
+ scopedSheetOpen: u,
77
+ numericFormat: n
78
+ } = P(), { className: p, onGridReady: f, rowHeight: h, context: a, columnDefs: m, ...g } = o, x = R[d], l = h ?? x, T = H(() => G(m), [m]), b = H(() => ({
79
+ ...a,
80
+ formatType: w[n]
81
+ }), [a, n]);
58
82
  _(() => {
59
- n?.resetRowHeights();
60
- }, [i, n]);
61
- const f = (l) => {
62
- o(l.api), p?.(l);
83
+ r?.resetRowHeights();
84
+ }, [d, r]), _(() => {
85
+ if (r) {
86
+ const i = r.getGridOption("context") || {};
87
+ r.setGridOption("context", {
88
+ ...i,
89
+ formatType: w[n]
90
+ }), r.refreshCells({ force: !0 });
91
+ }
92
+ }, [n, r]);
93
+ const v = (i) => {
94
+ e(i.api), f?.(i);
63
95
  };
64
- return /* @__PURE__ */ A(
96
+ return /* @__PURE__ */ C(
65
97
  "div",
66
98
  {
67
- className: b(
99
+ className: y(
68
100
  "relative flex-1 min-h-0 w-full bg-canvas-elevated rounded-b-[inherit] grid-rounded-bottom",
69
- a
101
+ p
70
102
  ),
71
- style: c ? { minHeight: N } : void 0,
103
+ style: u ? { minHeight: F } : void 0,
72
104
  children: [
73
- /* @__PURE__ */ r(
74
- D,
105
+ /* @__PURE__ */ c(
106
+ O,
75
107
  {
76
- ...h,
77
- rowHeight: u,
78
- onGridReady: f
108
+ ...g,
109
+ columnDefs: T,
110
+ rowHeight: l,
111
+ onGridReady: v,
112
+ context: b
79
113
  }
80
114
  ),
81
- /* @__PURE__ */ r(
115
+ /* @__PURE__ */ c(
82
116
  "div",
83
117
  {
84
- ref: d,
118
+ ref: t,
85
119
  className: "absolute inset-0 pointer-events-none z-[39] flex overflow-x-hidden overflow-y-visible"
86
120
  }
87
121
  )
@@ -89,12 +123,12 @@ function k(t) {
89
123
  }
90
124
  );
91
125
  }
92
- const B = ({
93
- children: t,
94
- className: o
95
- }) => /* @__PURE__ */ r("div", { "data-component": "data-table-toolbar", className: b("flex items-center justify-between px-4 py-3 shrink-0 bg-canvas-elevated rounded-t-[inherit]", o), children: t });
126
+ const U = ({
127
+ children: o,
128
+ className: e
129
+ }) => /* @__PURE__ */ c("div", { "data-component": "data-table-toolbar", className: y("flex items-center justify-between px-4 py-3 shrink-0 bg-canvas-elevated rounded-t-[inherit]", e), children: o });
96
130
  export {
97
- I as DataTable,
98
- k as DataTableContent,
99
- B as DataTableToolbar
131
+ W as DataTable,
132
+ X as DataTableContent,
133
+ U as DataTableToolbar
100
134
  };
@@ -1,120 +1,129 @@
1
- import { jsxs as C, jsx as r } from "react/jsx-runtime";
1
+ import { jsxs as C, jsx as c } from "react/jsx-runtime";
2
2
  import * as o from "react";
3
- import { X as W } from "lucide-react";
4
- import { CalendarMonth as Y } from "../../../icons/index.js";
5
- import { format as f, isValid as k, parse as w } from "date-fns";
6
- import { cn as Z, padValidDateString as _, maskDate as $ } from "../../../lib/utils.js";
7
- import { Input as F } from "../input.js";
8
- import { Popover as ee, PopoverTrigger as te, PopoverContent as ne } from "../popover.js";
3
+ import { X as Y } from "lucide-react";
4
+ import { CalendarMonth as Z } from "../../../icons/index.js";
5
+ import { format as u, isValid as x, parse as I } from "date-fns";
6
+ import { cn as _, padValidDateString as $, maskDate as F } from "../../../lib/utils.js";
7
+ import { Input as ee } from "../input.js";
8
+ import { Popover as te, PopoverTrigger as ne, PopoverContent as re } from "../popover.js";
9
9
  import { Calendar as oe } from "../calendar.js";
10
- import { Tooltip as T, TooltipTrigger as V, TooltipContent as A } from "../tooltip.js";
11
- import { getDateFnsLocale as re } from "../../../i18n/getDateFnsLocale.js";
12
- import { useImpactNovaI18n as ce } from "../../../i18n/ImpactNovaI18nContext.js";
10
+ import { Tooltip as M, TooltipTrigger as T, TooltipContent as A } from "../tooltip.js";
11
+ import { getDateFnsLocale as ce } from "../../../i18n/getDateFnsLocale.js";
12
+ import { useImpactNovaI18n as ie } from "../../../i18n/ImpactNovaI18nContext.js";
13
13
  const le = o.forwardRef(
14
14
  ({
15
- value: e,
16
- onChange: p,
15
+ value: t,
16
+ onChange: f,
17
17
  format: n = "MM/dd/yyyy",
18
- placeholder: v,
18
+ placeholder: E,
19
19
  minDate: L,
20
- maxDate: E,
21
- startMonth: O,
22
- endMonth: j,
20
+ maxDate: j,
21
+ startMonth: K,
22
+ endMonth: O,
23
23
  showFooter: d = !0,
24
- disabled: I,
24
+ disabled: R,
25
25
  className: B,
26
- ...b
27
- }, H) => {
28
- const { locale: S, t: P } = ce(), c = o.useMemo(() => re(S), [S]), X = v ?? P("datePicker.selectDate"), m = o.useRef(null), g = o.useRef(null);
29
- o.useImperativeHandle(H, () => m.current);
30
- const [l, u] = o.useState(!1), [M, i] = o.useState(e), [s, a] = o.useState(e ? f(e, n, { locale: c }) : ""), [q, x] = o.useState(e || /* @__PURE__ */ new Date());
26
+ ...H
27
+ }, X) => {
28
+ const { locale: b, t: m } = ie(), i = o.useMemo(() => ce(b), [b]), q = E ?? m("datePicker.selectDate"), g = o.useRef(null), y = o.useRef(null);
29
+ o.useImperativeHandle(X, () => g.current);
30
+ const [r, l] = o.useState(!1), D = o.useRef(!1), [N, a] = o.useState(t), [s, p] = o.useState(t ? u(t, n, { locale: i }) : ""), [z, w] = o.useState(t || /* @__PURE__ */ new Date());
31
31
  o.useEffect(() => {
32
- m.current && g.current !== null && (m.current.setSelectionRange(g.current, g.current), g.current = null);
32
+ g.current && y.current !== null && (g.current.setSelectionRange(y.current, y.current), y.current = null);
33
33
  }, [s]), o.useEffect(() => {
34
- l || (a(e ? f(e, n, { locale: c }) : ""), i(e));
35
- }, [e, n, l, c]), o.useEffect(() => {
36
- l && (i(e), x(e || /* @__PURE__ */ new Date()));
37
- }, [l, e]);
38
- const z = (t) => {
39
- i(t), t && a(f(t, n, { locale: c })), d || (p?.(t), u(!1));
40
- }, G = (t) => {
41
- p?.(t !== void 0 ? t : M), u(!1);
42
- }, J = () => {
43
- i(e), a(e ? f(e, n, { locale: c }) : ""), u(!1);
44
- }, N = () => {
45
- i(void 0), a(""), p?.(void 0), d || u(!1);
46
- }, K = (t) => {
47
- const h = t.target.value, D = $(h, n, s);
48
- if (a(D), D === "") {
49
- i(void 0), d || p?.(void 0);
34
+ r || (p(t ? u(t, n, { locale: i }) : ""), a(t));
35
+ }, [t, n, r, i]), o.useEffect(() => {
36
+ r && (a(t), w(t || /* @__PURE__ */ new Date()));
37
+ }, [r, t]);
38
+ const G = (e) => {
39
+ a(e), e && p(u(e, n, { locale: i })), d || (f?.(e), l(!1));
40
+ }, J = (e) => {
41
+ f?.(e !== void 0 ? e : N), l(!1);
42
+ }, S = () => {
43
+ a(t), p(t ? u(t, n, { locale: i }) : ""), l(!1);
44
+ }, V = () => {
45
+ a(void 0), p(""), f?.(void 0), d || l(!1);
46
+ }, Q = (e) => {
47
+ const h = e.target.value, k = F(h, n, s);
48
+ if (p(k), k === "") {
49
+ a(void 0), d || f?.(void 0);
50
50
  return;
51
51
  }
52
- const y = w(D, n, /* @__PURE__ */ new Date(), { locale: c });
53
- k(y) && D.length === n.length && (i(y), x(y), d || p?.(y));
54
- }, Q = () => {
55
- if (l) return;
56
- const t = _(s, n), h = w(t, n, /* @__PURE__ */ new Date(), { locale: c });
57
- !k(h) || t.length !== n.length ? (a(e ? f(e, n, { locale: c }) : ""), i(e)) : (a(t), d || p?.(h));
58
- }, R = (e ? f(e, n, { locale: c }) : "") !== s, U = s.length === n.length && !k(w(s, n, /* @__PURE__ */ new Date(), { locale: c }));
59
- return /* @__PURE__ */ C(ee, { open: l, onOpenChange: u, children: [
60
- /* @__PURE__ */ r(te, { asChild: !0, children: /* @__PURE__ */ r("div", { "data-component": "date-picker", "data-state": l ? "open" : "closed", "data-pending": R || void 0, children: /* @__PURE__ */ r(
61
- F,
52
+ const P = I(k, n, /* @__PURE__ */ new Date(), { locale: i });
53
+ x(P) && k.length === n.length && (a(P), w(P), d || f?.(P));
54
+ }, U = () => {
55
+ if (r) return;
56
+ const e = $(s, n), h = I(e, n, /* @__PURE__ */ new Date(), { locale: i });
57
+ !x(h) || e.length !== n.length ? (p(t ? u(t, n, { locale: i }) : ""), a(t)) : (p(e), d || f?.(h));
58
+ }, v = (t ? u(t, n, { locale: i }) : "") !== s, W = s.length === n.length && !x(I(s, n, /* @__PURE__ */ new Date(), { locale: i }));
59
+ return /* @__PURE__ */ C(te, { open: r, onOpenChange: l, children: [
60
+ /* @__PURE__ */ c(ne, { asChild: !0, children: /* @__PURE__ */ c("div", { "data-component": "date-picker", "data-state": r ? "open" : "closed", "data-pending": v || void 0, children: /* @__PURE__ */ c(
61
+ ee,
62
62
  {
63
- ref: m,
63
+ ref: g,
64
64
  value: s,
65
- onChange: K,
66
- onBlur: Q,
67
- onClick: (t) => l && t.stopPropagation(),
68
- placeholder: l ? n : X,
69
- disabled: I,
65
+ onChange: Q,
66
+ onBlur: U,
67
+ onClick: (e) => r && e.stopPropagation(),
68
+ onKeyDown: (e) => {
69
+ (e.key === "Enter" || e.key === "ArrowDown") && !r && (e.preventDefault(), D.current = !0, l(!0)), e.key === "Escape" && r && (e.preventDefault(), S());
70
+ },
71
+ placeholder: r ? n : q,
72
+ disabled: R,
70
73
  "data-form-control": "input",
71
- className: Z(
74
+ className: _(
72
75
  "cursor-pointer",
73
- U ? "text-destructive" : R ? "text-content-muted" : "",
76
+ W ? "text-destructive" : v ? "text-content-muted" : "",
74
77
  B
75
78
  ),
76
79
  suffix: /* @__PURE__ */ C("div", { className: "flex items-center gap-1", children: [
77
- e && !I && /* @__PURE__ */ C(T, { children: [
78
- /* @__PURE__ */ r(V, { asChild: !0, children: /* @__PURE__ */ r(
79
- W,
80
+ t && !R && /* @__PURE__ */ C(M, { children: [
81
+ /* @__PURE__ */ c(T, { asChild: !0, children: /* @__PURE__ */ c(
82
+ Y,
80
83
  {
81
84
  className: "h-4 w-4 cursor-pointer hover:text-content",
82
- onClick: (t) => {
83
- t.stopPropagation(), N();
85
+ onClick: (e) => {
86
+ e.stopPropagation(), V();
84
87
  }
85
88
  }
86
89
  ) }),
87
- /* @__PURE__ */ r(A, { variant: "tertiary", side: "top", children: P("calendar.clear") })
90
+ /* @__PURE__ */ c(A, { variant: "tertiary", side: "top", children: m("calendar.clear") })
88
91
  ] }),
89
- /* @__PURE__ */ C(T, { children: [
90
- /* @__PURE__ */ r(V, { asChild: !0, children: /* @__PURE__ */ r(Y, { className: "h-4 w-4 text-secondary-foreground" }) }),
91
- /* @__PURE__ */ r(A, { variant: "tertiary", side: "top", children: P("datePicker.selectDate") })
92
+ /* @__PURE__ */ C(M, { children: [
93
+ /* @__PURE__ */ c(T, { asChild: !0, children: /* @__PURE__ */ c("button", { type: "button", tabIndex: 0, "aria-label": m("datePicker.selectDate"), onClick: (e) => {
94
+ e.stopPropagation(), l(!r);
95
+ }, onKeyDown: (e) => {
96
+ (e.key === "Enter" || e.key === " ") && (e.preventDefault(), e.stopPropagation(), D.current = !0, l(!r));
97
+ }, className: "inline-flex items-center justify-center bg-transparent border-none p-0 cursor-pointer", children: /* @__PURE__ */ c(Z, { className: "h-4 w-4 text-secondary-foreground" }) }) }),
98
+ /* @__PURE__ */ c(A, { variant: "tertiary", side: "top", children: m("datePicker.selectDate") })
92
99
  ] })
93
100
  ] }),
94
- ...b
101
+ ...H
95
102
  }
96
103
  ) }) }),
97
- /* @__PURE__ */ r(
98
- ne,
104
+ /* @__PURE__ */ c(
105
+ re,
99
106
  {
100
107
  className: "w-auto p-0",
101
108
  align: "start",
102
- onOpenAutoFocus: (t) => t.preventDefault(),
103
- children: /* @__PURE__ */ r(
109
+ onOpenAutoFocus: (e) => {
110
+ D.current || e.preventDefault(), D.current = !1;
111
+ },
112
+ children: /* @__PURE__ */ c(
104
113
  oe,
105
114
  {
106
115
  mode: "single",
107
- selected: M,
108
- onSelect: z,
109
- month: q,
110
- onMonthChange: x,
111
- disabled: { before: L, after: E },
112
- startMonth: O,
113
- endMonth: j,
116
+ selected: N,
117
+ onSelect: G,
118
+ month: z,
119
+ onMonthChange: w,
120
+ disabled: { before: L, after: j },
121
+ startMonth: K,
122
+ endMonth: O,
114
123
  showFooter: d,
115
- onApply: G,
116
- onCancel: J,
117
- onClear: N,
124
+ onApply: J,
125
+ onCancel: S,
126
+ onClear: V,
118
127
  captionLayout: "dropdown"
119
128
  }
120
129
  )