@motor-hero/ui-kit 0.34.1 → 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/components/date-picker.d.ts.map +1 -1
- package/dist/index.cjs +16 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +18 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/date-picker.tsx +27 -9
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";
|
|
@@ -1266,7 +1266,10 @@ var calendarClassNames = {
|
|
|
1266
1266
|
months: "relative flex flex-col gap-4",
|
|
1267
1267
|
month: "flex w-full flex-col gap-4",
|
|
1268
1268
|
month_caption: "flex h-(--cell-size) w-full items-center justify-center px-(--cell-size)",
|
|
1269
|
-
caption_label: "text-sm font-medium select-none",
|
|
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",
|
|
1270
1273
|
nav: "absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",
|
|
1271
1274
|
button_previous: navButtonClass2,
|
|
1272
1275
|
button_next: navButtonClass2,
|
|
@@ -1282,8 +1285,13 @@ var calendarClassNames = {
|
|
|
1282
1285
|
hidden: "invisible"
|
|
1283
1286
|
};
|
|
1284
1287
|
var calendarComponents = {
|
|
1285
|
-
Chevron: ({ orientation }) =>
|
|
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,6 +1414,10 @@ 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),
|