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,223 +1,235 @@
1
- import { jsxs as u, jsx as i } from "react/jsx-runtime";
2
- import * as f from "react";
3
- import { X as ae } from "lucide-react";
4
- import { CalendarMonth as de, Info as ie } from "../../../icons/index.js";
5
- import { format as d, parse as L, isValid as O } from "date-fns";
6
- import { cn as g, maskDate as z } from "../../../lib/utils.js";
7
- import { Popover as ce, PopoverTrigger as le, PopoverContent as fe } from "../popover.js";
8
- import { Calendar as pe } from "../calendar.js";
9
- import { resolveWeekSelection as me } from "../../../lib/fiscal-calendar.js";
10
- const ue = f.forwardRef(
1
+ import { jsxs as b, jsx as f } from "react/jsx-runtime";
2
+ import * as o from "react";
3
+ import { X as pe } from "lucide-react";
4
+ import { CalendarMonth as me, Info as ue } from "../../../icons/index.js";
5
+ import { format as x, isValid as S, parse as R } from "date-fns";
6
+ import { cn as N, padValidDateString as X, maskDate as q } from "../../../lib/utils.js";
7
+ import { Popover as ge, PopoverTrigger as xe, PopoverContent as he } from "../popover.js";
8
+ import { Calendar as be } from "../calendar.js";
9
+ import { resolveWeekSelection as we } from "../../../lib/fiscal-calendar.js";
10
+ const g = (e, r = "MM/dd/yyyy") => {
11
+ const t = x(e.startDate, r), W = x(e.endDate, r);
12
+ return `${t} - ${W}`;
13
+ }, ke = o.forwardRef(
11
14
  ({
12
- value: t,
13
- onChange: p,
14
- format: n = "MM/dd/yyyy",
15
- minDate: T,
16
- maxDate: X,
17
- fromYear: q,
18
- toYear: G,
19
- showFooter: a = !0,
20
- calendarType: v = "calendar",
21
- fiscalMode: N = "basic",
22
- selectionMode: C = "week",
23
- fiscalMonthPattern: S,
24
- fiscalYearStartMonth: W = 1,
25
- weekStartsOn: P = 1,
26
- disabled: x,
27
- className: H,
28
- isError: b,
29
- size: R,
30
- label: I,
31
- helperText: V,
32
- required: J,
33
- prefix: xe,
34
- prefixClick: ge,
35
- ...K
36
- }, Q) => {
37
- const [s, h] = f.useState(!1), [o, c] = f.useState(t), [U, w] = f.useState(t?.from ? d(t.from.startDate, n) : ""), [Z, y] = f.useState(t?.to ? d(t.to.endDate, n) : ""), [$, D] = f.useState(t?.from?.startDate || /* @__PURE__ */ new Date());
38
- f.useEffect(() => {
39
- w(t?.from ? d(t.from.startDate, n) : ""), y(t?.to ? d(t.to.endDate, n) : "");
40
- }, [t, n]), f.useEffect(() => {
41
- s && (c(t), D(t?.from?.startDate || /* @__PURE__ */ new Date()));
42
- }, [s]);
43
- const Y = (e) => {
44
- c(e), !a && e?.from && e?.to && (p?.(e), h(!1));
45
- }, _ = (e) => {
46
- let r = e !== void 0 ? e : o;
47
- r?.from && !r.to && (r = { ...r, to: r.from }), p?.(r), h(!1);
48
- }, F = () => {
49
- c(t), h(!1);
50
- }, A = () => {
51
- c(void 0), w(""), y(""), p?.(void 0), a || h(!1);
52
- }, E = (e) => me(e, {
53
- calendarType: v,
54
- fiscalMode: N,
55
- selectionMode: C,
56
- fiscalMonthPattern: S,
57
- fiscalYearStartMonth: W,
58
- weekStartsOn: P
59
- }), ee = (e) => {
60
- const r = z(e.target.value, n);
61
- if (w(r), r === "") {
62
- const l = { from: void 0, to: o?.to };
63
- c(l), a || p?.(l);
15
+ value: e,
16
+ onChange: r,
17
+ format: t = "MM/dd/yyyy",
18
+ placeholder: W = "Select Week Range",
19
+ minDate: G,
20
+ maxDate: J,
21
+ fromYear: K,
22
+ toYear: Q,
23
+ showFooter: p = !0,
24
+ calendarType: E = "calendar",
25
+ fiscalMode: v = "basic",
26
+ selectionMode: A = "week",
27
+ fiscalMonthPattern: M,
28
+ fiscalYearStartMonth: T = 1,
29
+ weekStartsOn: j = 1,
30
+ disabled: w,
31
+ className: U,
32
+ isError: C,
33
+ size: B,
34
+ label: L,
35
+ helperText: O,
36
+ required: Z,
37
+ prefix: ye,
38
+ prefixClick: De,
39
+ ...Y
40
+ }, _) => {
41
+ const $ = o.useRef(null), F = o.useRef(null);
42
+ o.useRef(null), o.useRef(null), o.useImperativeHandle(_, () => $.current);
43
+ const [i, I] = o.useState(!1), [k, c] = o.useState(e), [y, m] = o.useState(e?.from ? x(e.from.startDate, t) : ""), [D, u] = o.useState(e?.to ? x(e.to.endDate, t) : ""), [ee, P] = o.useState(e?.from?.startDate || /* @__PURE__ */ new Date());
44
+ o.useEffect(() => {
45
+ !i && e && (m(e?.from ? x(e.from.startDate, t) : ""), u(e?.to ? x(e.to.endDate, t) : ""), c(e));
46
+ }, [e, t, i]), o.useEffect(() => {
47
+ i && (c(e), m(e?.from ? x(e.from.startDate, t) : ""), u(e?.to ? x(e.to.endDate, t) : ""), P(e?.from?.startDate || /* @__PURE__ */ new Date()));
48
+ }, [i, e, t]);
49
+ const te = (n) => {
50
+ c(n), n?.from && m(g(n.from, t)), n?.to && u(g(n.to, t)), !p && n?.from && n?.to && n.from.startDate.getTime() !== n.to.startDate.getTime() && (r?.(n), I(!1));
51
+ }, ne = (n) => {
52
+ r?.(n !== void 0 ? n : k), I(!1);
53
+ }, oe = () => {
54
+ c(e), m(e?.from ? g(e.from, t) : ""), u(e?.to ? g(e.to, t) : ""), I(!1);
55
+ }, z = () => {
56
+ c(void 0), m(""), u(""), r?.(void 0), p || I(!1);
57
+ }, V = (n) => we(n, {
58
+ calendarType: E,
59
+ fiscalMode: v,
60
+ selectionMode: A,
61
+ fiscalMonthPattern: M,
62
+ fiscalYearStartMonth: T,
63
+ weekStartsOn: j
64
+ }), se = (n) => {
65
+ const a = n.target.value, s = q(a, t, y);
66
+ if (m(s), s === "") {
67
+ const l = { from: void 0, to: k?.to };
68
+ c(l), p || r?.(l);
64
69
  return;
65
70
  }
66
- const m = L(r, n, /* @__PURE__ */ new Date());
67
- if (O(m)) {
68
- const k = { from: E(m), to: o?.to };
69
- c(k), D(m), a || p?.(k);
71
+ const d = R(s, t, /* @__PURE__ */ new Date());
72
+ if (S(d) && s.length === t.length) {
73
+ const h = { from: V(d), to: k?.to };
74
+ c(h), p || r?.(h);
70
75
  }
71
- }, te = (e) => {
72
- const r = z(e.target.value, n);
73
- if (y(r), r === "") {
74
- const l = { from: o?.from, to: void 0 };
75
- c(l), a || p?.(l);
76
+ }, re = (n) => {
77
+ const a = n.target.value, s = q(a, t, D);
78
+ if (u(s), s === "") {
79
+ const l = { from: k?.from, to: void 0 };
80
+ c(l), p || r?.(l);
76
81
  return;
77
82
  }
78
- const m = L(r, n, /* @__PURE__ */ new Date());
79
- if (O(m)) {
80
- const l = E(m), k = { from: o?.from, to: l };
81
- c(k), D(m), a || p?.(k);
83
+ const d = R(s, t, /* @__PURE__ */ new Date());
84
+ if (S(d) && s.length === t.length) {
85
+ const l = V(d), h = { from: k?.from, to: l };
86
+ c(h), d && P(d), p || r?.(h);
82
87
  }
83
- }, j = () => {
84
- s || (w(o?.from ? d(o.from.startDate, n) : ""), y(o?.to ? d(o.to.endDate, n) : ""));
85
- }, ne = t?.from ? d(t.from.startDate, n) : "", oe = t?.to ? d(t.to.endDate, n) : "", B = a && s ? o?.from ? d(o.from.startDate, n) : "" : U, M = a && s ? o?.to ? d(o.to.endDate, n) : o?.from ? d(o.from.endDate, n) : "" : Z, re = a && s && B !== ne, se = a && s && M !== oe;
86
- return /* @__PURE__ */ u("div", { className: "w-full space-y-1.5 min-w-[240px]", "data-component": "week-range-picker", "data-disabled": x || void 0, children: [
87
- I && /* @__PURE__ */ u(
88
+ }, H = () => {
89
+ if (i) return;
90
+ const n = X(y, t), a = X(D, t), s = R(n, t, /* @__PURE__ */ new Date()), d = R(a, t, /* @__PURE__ */ new Date()), l = S(s) && n.length === t.length, h = S(d) && a.length === t.length;
91
+ if (!l || !h)
92
+ m(e?.from ? g(e.from, t) : ""), u(e?.to ? g(e.to, t) : ""), c(e);
93
+ else if (m(n), u(a), !p) {
94
+ const fe = V(s), ae = V(d);
95
+ r?.({ from: fe, to: ae });
96
+ }
97
+ }, ie = (e?.from ? g(e.from, t) : "") !== y, ce = (e?.to ? g(e.to, t) : "") !== D, de = y.length === t.length && !S(R(y, t, /* @__PURE__ */ new Date())), le = D.length === t.length && !S(R(D, t, /* @__PURE__ */ new Date()));
98
+ return /* @__PURE__ */ b("div", { className: "w-full space-y-1.5 min-w-[240px]", "data-component": "week-range-picker", "data-disabled": w || void 0, children: [
99
+ L && /* @__PURE__ */ b(
88
100
  "label",
89
101
  {
90
- className: g(
102
+ className: N(
91
103
  "text-xs font-medium leading-[18px] text-[#60697d]",
92
- x && "opacity-70",
93
- b && "text-destructive"
104
+ w && "opacity-70",
105
+ C && "text-destructive"
94
106
  ),
95
107
  children: [
96
- I,
108
+ L,
97
109
  " ",
98
- J && /* @__PURE__ */ i("span", { className: "text-destructive", children: "*" })
110
+ Z && /* @__PURE__ */ f("span", { className: "text-destructive", children: "*" })
99
111
  ]
100
112
  }
101
113
  ),
102
- /* @__PURE__ */ u(ce, { open: s, onOpenChange: h, children: [
103
- /* @__PURE__ */ i(le, { asChild: !0, children: /* @__PURE__ */ u(
114
+ /* @__PURE__ */ b(ge, { open: i, onOpenChange: I, children: [
115
+ /* @__PURE__ */ f(xe, { asChild: !0, children: /* @__PURE__ */ b(
104
116
  "div",
105
117
  {
106
- "data-state": s ? "open" : "closed",
107
- className: g(
118
+ "data-state": i ? "open" : "closed",
119
+ className: N(
108
120
  "flex w-full items-center justify-between gap-2 rounded-md border bg-white px-3 text-sm shadow-sm transition-colors hover:border-primary disabled:cursor-not-allowed disabled:bg-disabled-secondary-bg disabled:text-disabled-text disabled:border-border",
109
- b ? "border-destructive hover:border-destructive" : "border-input",
110
- R === "sm" ? "h-6" : R === "md" ? "h-[28px]" : "h-8",
111
- x && "pointer-events-none opacity-100 bg-disabled-secondary-bg border-border text-disabled-text hover:border-border",
121
+ C ? "border-destructive hover:border-destructive" : "border-input",
122
+ B === "sm" ? "h-6" : B === "md" ? "h-[28px]" : "h-8",
123
+ w && "pointer-events-none opacity-100 bg-disabled-secondary-bg border-border text-disabled-text hover:border-border",
112
124
  "cursor-pointer",
113
- H
125
+ U
114
126
  ),
115
127
  children: [
116
- /* @__PURE__ */ u("div", { className: "flex items-center gap-4 flex-1 min-w-0", children: [
117
- /* @__PURE__ */ i(
128
+ /* @__PURE__ */ b("div", { className: "flex items-center gap-4 flex-1 min-w-0", children: [
129
+ /* @__PURE__ */ f(
118
130
  "input",
119
131
  {
120
- ref: Q,
132
+ ref: $,
121
133
  type: "text",
122
- value: B,
123
- onChange: ee,
124
- onBlur: j,
125
- onClick: (e) => s && e.stopPropagation(),
126
- placeholder: s ? n : "Start Week",
127
- disabled: !!x,
134
+ value: y,
135
+ onChange: se,
136
+ onBlur: H,
137
+ onClick: (n) => i && n.stopPropagation(),
138
+ placeholder: i ? t : W,
139
+ disabled: !!w,
128
140
  "data-field": "start",
129
- className: g(
141
+ className: N(
130
142
  "flex-1 min-w-0 bg-transparent p-0 text-sm font-medium outline-none placeholder:font-medium placeholder:text-[#dfe2e7] disabled:cursor-not-allowed disabled:opacity-50",
131
- re && "text-muted-foreground"
143
+ de ? "text-destructive" : ie ? "text-muted-foreground" : ""
132
144
  ),
133
- ...K
145
+ ...Y
134
146
  }
135
147
  ),
136
- /* @__PURE__ */ i(
148
+ /* @__PURE__ */ f(
137
149
  "input",
138
150
  {
151
+ ref: F,
139
152
  type: "text",
140
- value: M,
141
- onChange: te,
142
- onBlur: j,
143
- onClick: (e) => s && e.stopPropagation(),
144
- placeholder: s ? n : "End Week",
145
- disabled: !!x,
153
+ value: D,
154
+ onChange: re,
155
+ onBlur: H,
156
+ onClick: (n) => i && n.stopPropagation(),
157
+ placeholder: i ? t : W,
158
+ disabled: !!w,
146
159
  "data-field": "end",
147
- className: g(
160
+ className: N(
148
161
  "flex-1 min-w-0 bg-transparent p-0 text-sm font-medium outline-none placeholder:font-medium placeholder:text-[#dfe2e7] disabled:cursor-not-allowed disabled:opacity-50",
149
- se && "text-muted-foreground"
162
+ le ? "text-destructive" : ce ? "text-muted-foreground" : ""
150
163
  )
151
164
  }
152
165
  )
153
166
  ] }),
154
- /* @__PURE__ */ u("div", { className: "flex items-center gap-1 shrink-0", children: [
155
- t?.from && !x && /* @__PURE__ */ i(
156
- ae,
167
+ /* @__PURE__ */ b("div", { className: "flex items-center gap-1 shrink-0", children: [
168
+ e?.from && !w && /* @__PURE__ */ f(
169
+ pe,
157
170
  {
158
171
  className: "h-4 w-4 cursor-pointer hover:text-foreground text-muted-foreground",
159
- onClick: (e) => {
160
- e.stopPropagation(), A();
172
+ onClick: (n) => {
173
+ n.stopPropagation(), z();
161
174
  }
162
175
  }
163
176
  ),
164
- /* @__PURE__ */ i(de, { className: "h-4 w-4 text-secondary-foreground" })
177
+ /* @__PURE__ */ f(me, { className: "h-4 w-4 text-secondary-foreground" })
165
178
  ] })
166
179
  ]
167
180
  }
168
181
  ) }),
169
- /* @__PURE__ */ i(
170
- fe,
182
+ /* @__PURE__ */ f(
183
+ he,
171
184
  {
172
185
  className: "w-auto p-0",
173
186
  align: "start",
174
- onOpenAutoFocus: (e) => e.preventDefault(),
175
- children: /* @__PURE__ */ i(
176
- pe,
187
+ onOpenAutoFocus: (n) => n.preventDefault(),
188
+ children: /* @__PURE__ */ f(
189
+ be,
177
190
  {
178
191
  pickerType: "week",
179
192
  weekMode: "range",
180
- selectedWeeks: o,
181
- onWeekSelect: Y,
182
- month: $,
183
- onMonthChange: D,
184
- fromDate: T,
185
- toDate: X,
186
- fromYear: q,
187
- toYear: G,
188
- showFooter: a,
189
- calendarType: v,
190
- fiscalMode: N,
191
- selectionMode: C,
192
- fiscalMonthPattern: S,
193
- fiscalYearStartMonth: W,
194
- weekStartsOn: P,
195
- onApply: _,
196
- onCancel: F,
197
- onClear: A,
193
+ selectedWeeks: k,
194
+ onWeekSelect: te,
195
+ month: ee,
196
+ onMonthChange: P,
197
+ disabled: { before: G, after: J },
198
+ fromYear: K,
199
+ toYear: Q,
200
+ showFooter: p,
201
+ calendarType: E,
202
+ fiscalMode: v,
203
+ selectionMode: A,
204
+ fiscalMonthPattern: M,
205
+ fiscalYearStartMonth: T,
206
+ weekStartsOn: j,
207
+ onApply: ne,
208
+ onCancel: oe,
209
+ onClear: z,
198
210
  captionLayout: "dropdown"
199
211
  }
200
212
  )
201
213
  }
202
214
  )
203
215
  ] }),
204
- V && /* @__PURE__ */ u("div", { className: g("flex items-center gap-1", b && "text-destructive"), children: [
205
- !b && /* @__PURE__ */ i(ie, { size: 10, className: "shrink-0 text-muted-foreground" }),
206
- /* @__PURE__ */ i(
216
+ O && /* @__PURE__ */ b("div", { className: N("flex items-center gap-1", C && "text-destructive"), children: [
217
+ !C && /* @__PURE__ */ f(ue, { size: 10, className: "shrink-0 text-muted-foreground" }),
218
+ /* @__PURE__ */ f(
207
219
  "p",
208
220
  {
209
- className: g(
221
+ className: N(
210
222
  "text-[10px] text-[#7a8294]",
211
- b && "text-destructive"
223
+ C && "text-destructive"
212
224
  ),
213
- children: V
225
+ children: O
214
226
  }
215
227
  )
216
228
  ] })
217
229
  ] });
218
230
  }
219
231
  );
220
- ue.displayName = "WeekRangePicker";
232
+ ke.displayName = "WeekRangePicker";
221
233
  export {
222
- ue as WeekRangePicker
234
+ ke as WeekRangePicker
223
235
  };
@@ -2,7 +2,7 @@ import { VariantProps } from 'class-variance-authority';
2
2
  import * as React from "react";
3
3
  declare const dynamicLayoutVariants: (props?: {
4
4
  layout?: "grid" | "flex" | "stack";
5
- columns?: 12 | 1 | 4 | 3 | 2 | 6;
5
+ columns?: 1 | 12 | 4 | 3 | 2 | 6;
6
6
  gap?: "sm" | "md" | "lg" | "xl" | "none";
7
7
  } & import('class-variance-authority/types').ClassProp) => string;
8
8
  export interface DynamicLayoutProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof dynamicLayoutVariants> {
@@ -1,3 +1,4 @@
1
1
  import { ClassValue } from 'clsx';
2
2
  export declare function cn(...inputs: ClassValue[]): string;
3
- export declare function maskDate(value: string, formatStr: string): string;
3
+ export declare function maskDate(value: string, formatStr: string, previousValue?: string): string;
4
+ export declare function padValidDateString(value: string, formatStr: string): string;
package/dist/lib/utils.js CHANGED
@@ -1,18 +1,34 @@
1
- import { clsx as l } from "clsx";
2
- import { twMerge as s } from "tailwind-merge";
3
- function f(...e) {
4
- return s(l(e));
1
+ import { clsx as f } from "clsx";
2
+ import { twMerge as d } from "tailwind-merge";
3
+ function x(...s) {
4
+ return d(f(s));
5
5
  }
6
- function m(e, r) {
7
- const i = e.replace(/\D/g, "");
8
- let t = "", o = 0;
9
- for (let n = 0; n < r.length && o < i.length; n++) {
10
- const c = r[n];
11
- /[a-zA-Z]/.test(c) ? t += i[o++] : t += c;
6
+ function P(s, g, l = "") {
7
+ if (!s) return "";
8
+ const r = g.replace(/[a-zA-Z]/g, "")[0] || "/", a = l && s.length < l.length, n = s.split(r), i = g.split(r), c = [];
9
+ for (let t = 0; t < n.length && !(t >= i.length); t++) {
10
+ let e = n[t].replace(/[^0-9]/g, "");
11
+ const o = i[t].length;
12
+ if (e.length > o) {
13
+ const p = e.substring(o);
14
+ e = e.substring(0, o), n[t + 1] !== void 0 ? n[t + 1] = p + n[t + 1] : n.push(p);
15
+ }
16
+ !a && t < n.length - 1 && e.length > 0 && e.length < o && (e = e.padStart(o, "0")), c.push(e);
12
17
  }
13
- return t;
18
+ let h = c.join(r);
19
+ if (!a) {
20
+ const t = c.length - 1;
21
+ t < i.length - 1 && c[t].length === i[t].length && (h.endsWith(r) || (h += r));
22
+ }
23
+ return h;
24
+ }
25
+ function b(s, g) {
26
+ if (!s) return "";
27
+ const l = g.replace(/[a-zA-Z]/g, "")[0] || "/", r = s.split(l), a = g.split(l);
28
+ return r.map((n, i) => a[i] && n ? n.padStart(a[i].length, "0") : n).join(l);
14
29
  }
15
30
  export {
16
- f as cn,
17
- m as maskDate
31
+ x as cn,
32
+ P as maskDate,
33
+ b as padValidDateString
18
34
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  {
3
3
  "name": "impact-nova",
4
- "version": "1.0.0",
4
+ "version": "1.1.0",
5
5
  "description": "Enterprise-grade React design system built with React 19, Vite, Tailwind CSS, and Radix UI. Comprehensive UI component library for scalable, accessible, and performant applications.",
6
6
  "type": "module",
7
7
  "main": "./dist/index.js",