@payglocal_ui/flux-ui 0.2.6 → 0.3.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.
@@ -38,12 +38,21 @@ interface DatePickerProps {
38
38
  onChange: (v: string) => void;
39
39
  placeholder?: string;
40
40
  className?: string;
41
+ /** Earliest selectable date, `YYYY-MM-DD`. Days before it are struck out. */
41
42
  min?: string;
43
+ /**
44
+ * Latest selectable date, `YYYY-MM-DD`.
45
+ *
46
+ * Its absence is why a feature ended up hand-rolling a whole date chip to
47
+ * enforce an upper bound on Apply instead — an error after the fact, where
48
+ * the calendar could have said so before the click.
49
+ */
50
+ max?: string;
42
51
  label?: string;
43
52
  }
44
53
 
45
54
  /* ─── DatePicker ─────────────────────────────────────────────────────────── */
46
- export function DatePicker({ value, onChange, placeholder = "Select date", className, min, label }: DatePickerProps) {
55
+ export function DatePicker({ value, onChange, placeholder = "Select date", className, min, max, label }: DatePickerProps) {
47
56
  const today = new Date();
48
57
  const parsed = parseYMD(value);
49
58
 
@@ -123,10 +132,13 @@ export function DatePicker({ value, onChange, placeholder = "Select date", class
123
132
  const firstDay = firstDayOf(viewYear, viewMonth);
124
133
  const prevTotal = daysInMonth(viewYear, viewMonth === 0 ? 11 : viewMonth - 1);
125
134
  const minParsed = parseYMD(min ?? "");
135
+ const maxParsed = parseYMD(max ?? "");
126
136
 
127
137
  function isDisabled(y: number, m: number, d: number) {
128
- if (!minParsed) return false;
129
- return new Date(y, m, d) < new Date(minParsed.y, minParsed.m, minParsed.d);
138
+ const day = new Date(y, m, d);
139
+ if (minParsed && day < new Date(minParsed.y, minParsed.m, minParsed.d)) return true;
140
+ if (maxParsed && day > new Date(maxParsed.y, maxParsed.m, maxParsed.d)) return true;
141
+ return false;
130
142
  }
131
143
 
132
144
  type Cell = { d: number; m: number; y: number; current: boolean };