@motor-hero/ui-kit 0.34.0 → 0.35.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.
package/dist/index.js CHANGED
@@ -1213,9 +1213,9 @@ function ColorPicker({
1213
1213
  // src/components/date-picker.tsx
1214
1214
  import * as PopoverPrimitive4 from "@radix-ui/react-popover";
1215
1215
  import { InputMask } from "@react-input/mask";
1216
- import { format, isValid, parse } from "date-fns";
1216
+ import { endOfYear, format, isValid, parse, subYears } from "date-fns";
1217
1217
  import { ptBR } from "date-fns/locale";
1218
- import { CalendarIcon, ChevronLeft, ChevronRight, Clock } from "lucide-react";
1218
+ import { CalendarIcon, ChevronDown, ChevronLeft, ChevronRight, Clock } from "lucide-react";
1219
1219
  import * as React9 from "react";
1220
1220
  import { DayPicker } from "react-day-picker";
1221
1221
  import { Drawer as DrawerPrimitive3 } from "vaul";
@@ -1261,29 +1261,37 @@ function toMatchers(minDate, maxDate, disabledDates) {
1261
1261
  }
1262
1262
  var triggerInputClass = "flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 pr-10 text-sm shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:focus-visible:ring-destructive";
1263
1263
  var fieldInputClass = "flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring";
1264
+ var navButtonClass2 = "inline-flex size-(--cell-size) shrink-0 select-none items-center justify-center rounded-md p-0 transition-colors hover:bg-accent hover:text-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:opacity-50";
1264
1265
  var calendarClassNames = {
1265
- months: "flex flex-col",
1266
- month: "flex flex-col gap-4",
1267
- month_caption: "flex justify-center pt-1 relative items-center h-7",
1268
- caption_label: "text-sm font-medium",
1269
- nav: "flex items-center gap-1 absolute inset-x-0 top-0 justify-between px-1",
1270
- button_previous: "inline-flex size-7 items-center justify-center rounded-md border border-input bg-transparent p-0 opacity-50 hover:opacity-100",
1271
- button_next: "inline-flex size-7 items-center justify-center rounded-md border border-input bg-transparent p-0 opacity-50 hover:opacity-100",
1272
- month_grid: "w-full border-collapse space-y-1",
1266
+ months: "relative flex flex-col gap-4",
1267
+ month: "flex w-full flex-col gap-4",
1268
+ month_caption: "flex h-(--cell-size) w-full items-center justify-center px-(--cell-size)",
1269
+ caption_label: "flex h-8 items-center gap-1 rounded-md pl-2 pr-1 text-sm font-medium select-none [&>svg]:size-3.5 [&>svg]:text-muted-foreground",
1270
+ dropdowns: "flex h-(--cell-size) w-full items-center justify-center gap-1.5 text-sm font-medium",
1271
+ dropdown_root: "relative rounded-md border border-input shadow-xs has-focus:border-ring has-focus:ring-[3px] has-focus:ring-ring/50",
1272
+ dropdown: "absolute inset-0 bg-popover opacity-0",
1273
+ nav: "absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",
1274
+ button_previous: navButtonClass2,
1275
+ button_next: navButtonClass2,
1276
+ month_grid: "w-full border-collapse",
1273
1277
  weekdays: "flex",
1274
- weekday: "text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",
1275
- week: "flex w-full mt-2",
1276
- day: "relative p-0 text-center text-sm focus-within:relative focus-within:z-20",
1277
- day_button: "inline-flex size-8 items-center justify-center rounded-md p-0 font-normal hover:bg-accent hover:text-accent-foreground aria-selected:opacity-100",
1278
- selected: "bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground rounded-md [&>button]:bg-primary [&>button]:text-primary-foreground",
1278
+ weekday: "flex-1 select-none rounded-md text-[0.8rem] font-normal text-muted-foreground",
1279
+ week: "mt-2 flex w-full",
1280
+ day: "relative aspect-square h-full w-full select-none p-0 text-center aria-selected:[&>button]:bg-primary aria-selected:[&>button]:text-primary-foreground aria-selected:[&>button]:hover:bg-primary",
1281
+ day_button: "inline-flex aspect-square size-auto w-full min-w-(--cell-size) items-center justify-center rounded-md p-0 font-normal transition-colors hover:bg-accent hover:text-accent-foreground",
1279
1282
  today: "bg-accent text-accent-foreground rounded-md",
1280
1283
  outside: "text-muted-foreground opacity-50",
1281
1284
  disabled: "text-muted-foreground opacity-50 pointer-events-none",
1282
1285
  hidden: "invisible"
1283
1286
  };
1284
1287
  var calendarComponents = {
1285
- Chevron: ({ orientation }) => orientation === "left" ? /* @__PURE__ */ jsx20(ChevronLeft, { className: "size-4" }) : /* @__PURE__ */ jsx20(ChevronRight, { className: "size-4" })
1288
+ Chevron: ({ orientation }) => {
1289
+ if (orientation === "left") return /* @__PURE__ */ jsx20(ChevronLeft, { className: "size-4" });
1290
+ if (orientation === "right") return /* @__PURE__ */ jsx20(ChevronRight, { className: "size-4" });
1291
+ return /* @__PURE__ */ jsx20(ChevronDown, { className: "size-4" });
1292
+ }
1286
1293
  };
1294
+ var formatMonthDropdown = (date) => date.toLocaleString("pt-BR", { month: "short" });
1287
1295
  function DatePickerImpl({
1288
1296
  value,
1289
1297
  onChange,
@@ -1308,6 +1316,8 @@ function DatePickerImpl({
1308
1316
  const committedDate = withTime ? dateTimeToDate(value) : dateOnlyToDate(value);
1309
1317
  const displayValue = displayFor(value, withTime);
1310
1318
  const matchers = toMatchers(minDate, maxDate, disabledDates);
1319
+ const startMonth = dateOnlyToDate(minDate) ?? subYears(/* @__PURE__ */ new Date(), 100);
1320
+ const endMonth = dateOnlyToDate(maxDate) ?? endOfYear(/* @__PURE__ */ new Date());
1311
1321
  const setOpen = (next) => {
1312
1322
  setOpenRaw(next);
1313
1323
  if (next) {
@@ -1404,11 +1414,15 @@ function DatePickerImpl({
1404
1414
  {
1405
1415
  mode: "single",
1406
1416
  locale: ptBR,
1417
+ captionLayout: "dropdown",
1418
+ formatters: { formatMonthDropdown },
1419
+ startMonth,
1420
+ endMonth,
1407
1421
  selected: withTime ? pendingDate : committedDate,
1408
1422
  defaultMonth: (withTime ? pendingDate : committedDate) ?? /* @__PURE__ */ new Date(),
1409
1423
  onSelect: (date) => date && handleCalendarSelect(date),
1410
1424
  disabled: matchers,
1411
- className: withTime ? "p-0" : "p-3",
1425
+ className: cn(withTime ? "p-0" : "p-3", "[--cell-size:2rem]"),
1412
1426
  classNames: calendarClassNames,
1413
1427
  components: calendarComponents
1414
1428
  }