@payglocal_ui/flux-ui 0.2.5 → 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 };
@@ -19,7 +19,9 @@ const DropdownMenuSubTrigger = React.forwardRef<
19
19
  <DropdownMenuPrimitive.SubTrigger
20
20
  ref={ref}
21
21
  className={cn(
22
- "flex cursor-default select-none items-center gap-2 rounded-lg px-3 py-2.5 text-[15px] outline-none",
22
+ // Matches DropdownMenuItem: a submenu row sits in the same list as the
23
+ // plain rows, so it cannot be a different size from them.
24
+ "flex cursor-default select-none items-center gap-2 rounded-lg px-2.5 py-1.5 text-[13px] outline-none",
23
25
  "focus:bg-muted data-[state=open]:bg-muted",
24
26
  inset && "pl-8",
25
27
  className
@@ -94,7 +96,9 @@ const DropdownMenuCheckboxItem = React.forwardRef<
94
96
  <DropdownMenuPrimitive.CheckboxItem
95
97
  ref={ref}
96
98
  className={cn(
97
- "relative flex cursor-default select-none items-center rounded-lg py-2 pl-8 pr-2 text-sm outline-none transition-colors",
99
+ // Matches DropdownMenuItem. `pl-8` stays: that gutter is the check /
100
+ // dot indicator's, not padding.
101
+ "relative flex cursor-default select-none items-center rounded-lg py-1.5 pl-8 pr-2.5 text-[13px] outline-none transition-colors",
98
102
  "focus:bg-muted focus:text-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
99
103
  className
100
104
  )}
@@ -118,7 +122,9 @@ const DropdownMenuRadioItem = React.forwardRef<
118
122
  <DropdownMenuPrimitive.RadioItem
119
123
  ref={ref}
120
124
  className={cn(
121
- "relative flex cursor-default select-none items-center rounded-lg py-2 pl-8 pr-2 text-sm outline-none transition-colors",
125
+ // Matches DropdownMenuItem. `pl-8` stays: that gutter is the check /
126
+ // dot indicator's, not padding.
127
+ "relative flex cursor-default select-none items-center rounded-lg py-1.5 pl-8 pr-2.5 text-[13px] outline-none transition-colors",
122
128
  "focus:bg-muted focus:text-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
123
129
  className
124
130
  )}