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,19 +1,19 @@
1
- import { jsxs as y, jsx as o } from "react/jsx-runtime";
1
+ import { jsxs as y, jsx as r } from "react/jsx-runtime";
2
2
  import * as a from "react";
3
- import { X as v } from "lucide-react";
4
- import { CalendarMonth as R } from "../../../icons/index.js";
3
+ import { X as j } from "lucide-react";
4
+ import { CalendarMonth as v } from "../../../icons/index.js";
5
5
  import { format as h } from "date-fns";
6
- import { cn as E } from "../../../lib/utils.js";
7
- import { Input as I } from "../input.js";
8
- import { Popover as L, PopoverTrigger as V, PopoverContent as X } from "../popover.js";
9
- import { Calendar as b } from "../calendar.js";
10
- const q = (e, r = "MM/dd/yyyy") => {
11
- const c = h(e.startDate, r), i = h(e.endDate, r);
6
+ import { cn as R } from "../../../lib/utils.js";
7
+ import { Input as E } from "../input.js";
8
+ import { Popover as I, PopoverTrigger as L, PopoverContent as V } from "../popover.js";
9
+ import { Calendar as X } from "../calendar.js";
10
+ const q = (e, o = "MM/dd/yyyy") => {
11
+ const c = h(e.startDate, o), i = h(e.endDate, o);
12
12
  return `${c} - ${i}`;
13
13
  }, z = a.forwardRef(
14
14
  ({
15
15
  value: e,
16
- onChange: r,
16
+ onChange: o,
17
17
  format: c = "MM/dd/yyyy",
18
18
  placeholder: i = "Select Weeks",
19
19
  minDate: k,
@@ -30,33 +30,33 @@ const q = (e, r = "MM/dd/yyyy") => {
30
30
  disabled: d,
31
31
  className: N,
32
32
  ...A
33
- }, D) => {
33
+ }, O) => {
34
34
  const [p, n] = a.useState(!1), [f, s] = a.useState(e);
35
35
  a.useEffect(() => {
36
36
  p && s(e);
37
37
  }, [p]);
38
- const O = (t) => {
39
- s(t), l || r?.(t);
40
- }, T = (t) => {
41
- r?.(t !== void 0 ? t : f), n(!1);
38
+ const T = (t) => {
39
+ s(t), l || o?.(t);
40
+ }, D = (t) => {
41
+ o?.(t !== void 0 ? t : f), n(!1);
42
42
  }, $ = () => {
43
43
  s(e), n(!1);
44
44
  }, m = () => {
45
- s(void 0), r?.(void 0), l || n(!1);
46
- }, j = e && e.length > 0 ? e.length === 1 ? q(e[0], c) : `${e.length} weeks selected` : "";
47
- return /* @__PURE__ */ y(L, { open: p, onOpenChange: n, children: [
48
- /* @__PURE__ */ o(V, { asChild: !0, children: /* @__PURE__ */ o("div", { children: /* @__PURE__ */ o(
49
- I,
45
+ s(void 0), o?.(void 0), l || n(!1);
46
+ }, b = e && e.length > 0 ? e.length === 1 ? q(e[0], c) : `${e.length} weeks selected` : "";
47
+ return /* @__PURE__ */ y(I, { open: p, onOpenChange: n, children: [
48
+ /* @__PURE__ */ r(L, { asChild: !0, children: /* @__PURE__ */ r("div", { children: /* @__PURE__ */ r(
49
+ E,
50
50
  {
51
- ref: D,
52
- value: j,
51
+ ref: O,
52
+ value: b,
53
53
  placeholder: i,
54
54
  readOnly: !0,
55
55
  disabled: d,
56
- className: E("cursor-pointer", N),
56
+ className: R("cursor-pointer", N),
57
57
  suffix: /* @__PURE__ */ y("div", { className: "flex items-center gap-1", children: [
58
- e && e.length > 0 && !d && /* @__PURE__ */ o(
59
- v,
58
+ e && e.length > 0 && !d && /* @__PURE__ */ r(
59
+ j,
60
60
  {
61
61
  className: "h-4 w-4 cursor-pointer hover:text-foreground",
62
62
  onClick: (t) => {
@@ -64,26 +64,25 @@ const q = (e, r = "MM/dd/yyyy") => {
64
64
  }
65
65
  }
66
66
  ),
67
- /* @__PURE__ */ o(R, { className: "h-4 w-4 text-secondary-foreground" })
67
+ /* @__PURE__ */ r(v, { className: "h-4 w-4 text-secondary-foreground" })
68
68
  ] }),
69
69
  ...A
70
70
  }
71
71
  ) }) }),
72
- /* @__PURE__ */ o(
73
- X,
72
+ /* @__PURE__ */ r(
73
+ V,
74
74
  {
75
75
  className: "w-auto p-0",
76
76
  align: "start",
77
77
  onOpenAutoFocus: (t) => t.preventDefault(),
78
- children: /* @__PURE__ */ o(
79
- b,
78
+ children: /* @__PURE__ */ r(
79
+ X,
80
80
  {
81
81
  pickerType: "week",
82
82
  weekMode: "multiple",
83
83
  selectedWeeks: f,
84
- onWeekSelect: O,
85
- fromDate: k,
86
- toDate: u,
84
+ onWeekSelect: T,
85
+ disabled: { before: k, after: u },
87
86
  fromYear: g,
88
87
  toYear: C,
89
88
  showFooter: l,
@@ -93,7 +92,7 @@ const q = (e, r = "MM/dd/yyyy") => {
93
92
  fiscalMonthPattern: P,
94
93
  fiscalYearStartMonth: S,
95
94
  weekStartsOn: W,
96
- onApply: T,
95
+ onApply: D,
97
96
  onCancel: $,
98
97
  onClear: m,
99
98
  captionLayout: "dropdown"
@@ -1,135 +1,141 @@
1
- import { jsxs as A, jsx as i } from "react/jsx-runtime";
2
- import * as a from "react";
3
- import { X as H } from "lucide-react";
4
- import { CalendarMonth as J } from "../../../icons/index.js";
5
- import { format as M, parse as K, isValid as Q } from "date-fns";
6
- import { cn as U, maskDate as Z } from "../../../lib/utils.js";
7
- import { Input as _ } from "../input.js";
8
- import { Popover as Y, PopoverTrigger as F, PopoverContent as ee } from "../popover.js";
9
- import { Calendar as te } from "../calendar.js";
10
- import { resolveWeekSelection as ne } from "../../../lib/fiscal-calendar.js";
11
- const f = (t, r = "MM/dd/yyyy") => {
12
- const n = M(t.startDate, r), m = M(t.endDate, r);
13
- return `${n} - ${m}`;
14
- }, oe = a.forwardRef(
1
+ import { jsxs as b, jsx as p } from "react/jsx-runtime";
2
+ import * as o from "react";
3
+ import { X as U } from "lucide-react";
4
+ import { CalendarMonth as Z } from "../../../icons/index.js";
5
+ import { isValid as y, parse as D, format as j } from "date-fns";
6
+ import { cn as _, padValidDateString as Y, maskDate as F } from "../../../lib/utils.js";
7
+ import { Input as ee } from "../input.js";
8
+ import { Popover as ne, PopoverTrigger as te, PopoverContent as oe } from "../popover.js";
9
+ import { Calendar as se } from "../calendar.js";
10
+ import { resolveWeekSelection as re } from "../../../lib/fiscal-calendar.js";
11
+ const l = (e, s = "MM/dd/yyyy") => {
12
+ const t = j(e.startDate, s), h = j(e.endDate, s);
13
+ return `${t} - ${h}`;
14
+ }, ie = o.forwardRef(
15
15
  ({
16
- value: t,
17
- onChange: r,
18
- format: n = "MM/dd/yyyy",
19
- placeholder: m = "Select Week",
20
- minDate: V,
21
- maxDate: I,
22
- fromYear: $,
23
- toYear: T,
24
- showFooter: c = !0,
25
- calendarType: D = "calendar",
26
- fiscalMode: C = "basic",
27
- selectionMode: W = "week",
28
- fiscalMonthPattern: S,
29
- fiscalYearStartMonth: v = 1,
30
- weekStartsOn: w = 1,
31
- disabled: x,
32
- className: j,
33
- ...B
34
- }, E) => {
35
- const [o, l] = a.useState(!1), [s, p] = a.useState(t), [k, d] = a.useState(t ? f(t, n) : ""), [L, y] = a.useState(t?.startDate || /* @__PURE__ */ new Date());
36
- a.useEffect(() => {
37
- d(t ? f(t, n) : "");
38
- }, [t, n]), a.useEffect(() => {
39
- o && (p(t), y(t?.startDate || /* @__PURE__ */ new Date()));
40
- }, [o]);
41
- const O = (e) => {
42
- p(e), c || (r?.(e), l(!1));
43
- }, R = (e) => {
44
- r?.(e !== void 0 ? e : s), l(!1);
45
- }, X = () => {
46
- p(t), l(!1);
47
- }, g = () => {
48
- p(void 0), d(""), r?.(void 0), c || l(!1);
49
- }, b = (e) => ne(e, {
50
- calendarType: D,
51
- fiscalMode: C,
52
- selectionMode: W,
53
- fiscalMonthPattern: S,
54
- fiscalYearStartMonth: v,
55
- weekStartsOn: w
56
- }), q = (e) => {
57
- const u = Z(e.target.value, n);
58
- if (d(u), u === "") {
59
- p(void 0), c || r?.(void 0);
16
+ value: e,
17
+ onChange: s,
18
+ format: t = "MM/dd/yyyy",
19
+ placeholder: h = "Select Week",
20
+ minDate: B,
21
+ maxDate: E,
22
+ fromYear: L,
23
+ toYear: O,
24
+ showFooter: f = !0,
25
+ calendarType: w = "calendar",
26
+ fiscalMode: W = "basic",
27
+ selectionMode: S = "week",
28
+ fiscalMonthPattern: x,
29
+ fiscalYearStartMonth: C = 1,
30
+ weekStartsOn: P = 1,
31
+ disabled: V,
32
+ className: $,
33
+ ...H
34
+ }, X) => {
35
+ const I = o.useRef(null);
36
+ o.useRef(null), o.useImperativeHandle(X, () => I.current);
37
+ const [r, u] = o.useState(!1), [N, i] = o.useState(e), [d, c] = o.useState(e ? l(e, t) : ""), [q, k] = o.useState(e?.startDate || /* @__PURE__ */ new Date());
38
+ o.useEffect(() => {
39
+ !r && e && (c(l(e, t)), i(e));
40
+ }, [r, e, t]), o.useEffect(() => {
41
+ r && (i(e), k(e?.startDate || /* @__PURE__ */ new Date()), c(e ? l(e, t) : ""));
42
+ }, [r, e, t]);
43
+ const v = (n) => {
44
+ i(n), n && c(l(n, t)), f || (s?.(n), u(!1));
45
+ }, z = (n) => {
46
+ s?.(n !== void 0 ? n : N), u(!1);
47
+ }, G = () => {
48
+ i(e), c(e ? l(e, t) : ""), u(!1);
49
+ }, A = () => {
50
+ i(void 0), c(""), s?.(void 0), f || u(!1);
51
+ }, M = (n) => re(n, {
52
+ calendarType: w,
53
+ fiscalMode: W,
54
+ selectionMode: S,
55
+ fiscalMonthPattern: x,
56
+ fiscalYearStartMonth: C,
57
+ weekStartsOn: P
58
+ }), J = (n) => {
59
+ const g = n.target.value, a = F(g, t, d);
60
+ if (c(a), a === "") {
61
+ i(void 0), f || s?.(void 0);
60
62
  return;
61
63
  }
62
- const h = K(u, n, /* @__PURE__ */ new Date());
63
- if (Q(h)) {
64
- const N = b(h);
65
- p(N), y(h), c || r?.(N);
64
+ const m = D(a, t, /* @__PURE__ */ new Date());
65
+ if (y(m) && a.length === t.length) {
66
+ const T = M(m);
67
+ i(T), k(m), f || s?.(T);
66
68
  }
67
- }, z = () => {
68
- if (!o) {
69
- if (k === "") {
70
- g();
71
- return;
72
- }
73
- d(s ? f(s, n) : "");
69
+ }, K = () => {
70
+ if (r) return;
71
+ const n = Y(d, t), g = D(n, t, /* @__PURE__ */ new Date());
72
+ if (!y(g) || n.length !== t.length)
73
+ c(e ? l(e, t) : ""), i(e);
74
+ else if (c(n), !f) {
75
+ const a = M(g);
76
+ s?.(a);
74
77
  }
75
- }, P = c && o && (s ? f(s, n) : "") !== k, G = c && o ? s ? f(s, n) : "" : k;
76
- return /* @__PURE__ */ A(Y, { open: o, onOpenChange: l, children: [
77
- /* @__PURE__ */ i(F, { asChild: !0, children: /* @__PURE__ */ i("div", { "data-component": "week-picker", "data-state": o ? "open" : "closed", "data-pending": P || void 0, children: /* @__PURE__ */ i(
78
- _,
78
+ }, R = (e ? l(e, t) : "") !== d, Q = d.length === t.length && !y(D(d, t, /* @__PURE__ */ new Date()));
79
+ return /* @__PURE__ */ b(ne, { open: r, onOpenChange: u, children: [
80
+ /* @__PURE__ */ p(te, { asChild: !0, children: /* @__PURE__ */ p("div", { "data-component": "week-picker", "data-state": r ? "open" : "closed", "data-pending": R || void 0, children: /* @__PURE__ */ p(
81
+ ee,
79
82
  {
80
- ref: E,
81
- value: G,
82
- onChange: q,
83
- onBlur: z,
84
- onClick: (e) => o && e.stopPropagation(),
85
- placeholder: o ? `${n} - ${n}` : m,
86
- disabled: x,
83
+ ref: I,
84
+ value: d,
85
+ onChange: J,
86
+ onBlur: K,
87
+ onClick: (n) => r && n.stopPropagation(),
88
+ placeholder: r ? t : h,
89
+ disabled: V,
87
90
  "data-form-control": "input",
88
- className: U("cursor-pointer", P && "text-muted-foreground", j),
89
- suffix: /* @__PURE__ */ A("div", { className: "flex items-center gap-1", children: [
90
- t && !x && /* @__PURE__ */ i(
91
- H,
91
+ className: _(
92
+ "cursor-pointer",
93
+ Q ? "text-destructive" : R ? "text-muted-foreground" : "",
94
+ $
95
+ ),
96
+ suffix: /* @__PURE__ */ b("div", { className: "flex items-center gap-1", children: [
97
+ e && !V && /* @__PURE__ */ p(
98
+ U,
92
99
  {
93
100
  className: "h-4 w-4 cursor-pointer hover:text-foreground",
94
- onClick: (e) => {
95
- e.stopPropagation(), g();
101
+ onClick: (n) => {
102
+ n.stopPropagation(), A();
96
103
  }
97
104
  }
98
105
  ),
99
- /* @__PURE__ */ i(J, { className: "h-4 w-4 text-secondary-foreground" })
106
+ /* @__PURE__ */ p(Z, { className: "h-4 w-4 text-secondary-foreground" })
100
107
  ] }),
101
- ...B
108
+ ...H
102
109
  }
103
110
  ) }) }),
104
- /* @__PURE__ */ i(
105
- ee,
111
+ /* @__PURE__ */ p(
112
+ oe,
106
113
  {
107
114
  className: "w-auto p-0",
108
115
  align: "start",
109
- onOpenAutoFocus: (e) => e.preventDefault(),
110
- children: /* @__PURE__ */ i(
111
- te,
116
+ onOpenAutoFocus: (n) => n.preventDefault(),
117
+ children: /* @__PURE__ */ p(
118
+ se,
112
119
  {
113
120
  pickerType: "week",
114
121
  weekMode: "single",
115
- selectedWeeks: s,
116
- onWeekSelect: O,
117
- month: L,
118
- onMonthChange: y,
119
- fromDate: V,
120
- toDate: I,
121
- fromYear: $,
122
- toYear: T,
123
- showFooter: c,
124
- calendarType: D,
125
- fiscalMode: C,
126
- selectionMode: W,
127
- fiscalMonthPattern: S,
128
- fiscalYearStartMonth: v,
129
- weekStartsOn: w,
130
- onApply: R,
131
- onCancel: X,
132
- onClear: g,
122
+ selectedWeeks: N,
123
+ onWeekSelect: v,
124
+ month: q,
125
+ onMonthChange: k,
126
+ disabled: { before: B, after: E },
127
+ fromYear: L,
128
+ toYear: O,
129
+ showFooter: f,
130
+ calendarType: w,
131
+ fiscalMode: W,
132
+ selectionMode: S,
133
+ fiscalMonthPattern: x,
134
+ fiscalYearStartMonth: C,
135
+ weekStartsOn: P,
136
+ onApply: z,
137
+ onCancel: G,
138
+ onClear: A,
133
139
  captionLayout: "dropdown"
134
140
  }
135
141
  )
@@ -138,7 +144,7 @@ const f = (t, r = "MM/dd/yyyy") => {
138
144
  ] });
139
145
  }
140
146
  );
141
- oe.displayName = "WeekPicker";
147
+ ie.displayName = "WeekPicker";
142
148
  export {
143
- oe as WeekPicker
149
+ ie as WeekPicker
144
150
  };