@moontra/moonui 2.4.0 → 2.4.1

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
@@ -11,6 +11,7 @@ var jsxRuntime = require('react/jsx-runtime');
11
11
  var classVarianceAuthority = require('class-variance-authority');
12
12
  var AvatarPrimitive = require('@radix-ui/react-avatar');
13
13
  var framerMotion = require('framer-motion');
14
+ var dateFns = require('date-fns');
14
15
  var CheckboxPrimitive = require('@radix-ui/react-checkbox');
15
16
  require('react-dom');
16
17
  var reactSlot = require('@radix-ui/react-slot');
@@ -18,7 +19,6 @@ var LabelPrimitive = require('@radix-ui/react-label');
18
19
  var PopoverPrimitive = require('@radix-ui/react-popover');
19
20
  var TabsPrimitive = require('@radix-ui/react-tabs');
20
21
  var DialogPrimitive = require('@radix-ui/react-dialog');
21
- var dateFns = require('date-fns');
22
22
  var DropdownMenuPrimitive = require('@radix-ui/react-dropdown-menu');
23
23
  var SelectPrimitive = require('@radix-ui/react-select');
24
24
  var SeparatorPrimitive = require('@radix-ui/react-separator');
@@ -1128,6 +1128,202 @@ var CardFooter = t__namespace.forwardRef(({ className, ...props }, ref) => /* @_
1128
1128
  }
1129
1129
  ));
1130
1130
  CardFooter.displayName = "CardFooter";
1131
+ function Calendar({
1132
+ mode = "single",
1133
+ selected,
1134
+ onSelect,
1135
+ disabled,
1136
+ showOutsideDays = false,
1137
+ className,
1138
+ classNames,
1139
+ numberOfMonths = 1,
1140
+ defaultMonth,
1141
+ ...props
1142
+ }) {
1143
+ const [currentMonth, setCurrentMonth] = t__namespace.useState(
1144
+ defaultMonth || selected && selected || /* @__PURE__ */ new Date()
1145
+ );
1146
+ const weekDays = [
1147
+ { short: "S", full: "Sunday" },
1148
+ { short: "M", full: "Monday" },
1149
+ { short: "T", full: "Tuesday" },
1150
+ { short: "W", full: "Wednesday" },
1151
+ { short: "T", full: "Thursday" },
1152
+ { short: "F", full: "Friday" },
1153
+ { short: "S", full: "Saturday" }
1154
+ ];
1155
+ const handlePreviousMonth = () => {
1156
+ setCurrentMonth(dateFns.subMonths(currentMonth, 1));
1157
+ };
1158
+ const handleNextMonth = () => {
1159
+ setCurrentMonth(dateFns.addMonths(currentMonth, 1));
1160
+ };
1161
+ const handleDateClick = (date) => {
1162
+ if (disabled?.(date))
1163
+ return;
1164
+ if (mode === "single") {
1165
+ onSelect?.(date);
1166
+ } else if (mode === "range") {
1167
+ const currentSelection = selected;
1168
+ if (!currentSelection?.from || currentSelection.from && currentSelection.to) {
1169
+ onSelect?.({ from: date, to: void 0 });
1170
+ } else {
1171
+ if (date < currentSelection.from) {
1172
+ onSelect?.({ from: date, to: currentSelection.from });
1173
+ } else {
1174
+ onSelect?.({ from: currentSelection.from, to: date });
1175
+ }
1176
+ }
1177
+ }
1178
+ };
1179
+ const isDateSelected = (date) => {
1180
+ if (!selected)
1181
+ return false;
1182
+ if (mode === "single") {
1183
+ return dateFns.isSameDay(date, selected);
1184
+ } else if (mode === "range") {
1185
+ const range = selected;
1186
+ if (range.from && range.to) {
1187
+ return date >= range.from && date <= range.to;
1188
+ }
1189
+ return range.from ? dateFns.isSameDay(date, range.from) : false;
1190
+ }
1191
+ return false;
1192
+ };
1193
+ const isRangeStart = (date) => {
1194
+ if (mode !== "range" || !selected)
1195
+ return false;
1196
+ const range = selected;
1197
+ return range.from ? dateFns.isSameDay(date, range.from) : false;
1198
+ };
1199
+ const isRangeEnd = (date) => {
1200
+ if (mode !== "range" || !selected)
1201
+ return false;
1202
+ const range = selected;
1203
+ return range.to ? dateFns.isSameDay(date, range.to) : false;
1204
+ };
1205
+ const isRangeMiddle = (date) => {
1206
+ if (mode !== "range" || !selected)
1207
+ return false;
1208
+ const range = selected;
1209
+ if (!range.from || !range.to)
1210
+ return false;
1211
+ return date > range.from && date < range.to;
1212
+ };
1213
+ const getDaysInMonth = () => {
1214
+ const start = dateFns.startOfMonth(currentMonth);
1215
+ const end = dateFns.endOfMonth(currentMonth);
1216
+ const days2 = dateFns.eachDayOfInterval({ start, end });
1217
+ const firstDayOfWeek = dateFns.getDay(start);
1218
+ const previousMonthDays = [];
1219
+ if (firstDayOfWeek > 0 && showOutsideDays) {
1220
+ const previousMonthStart = dateFns.startOfWeek(start);
1221
+ const previousMonthEnd = new Date(start);
1222
+ previousMonthEnd.setDate(previousMonthEnd.getDate() - 1);
1223
+ previousMonthDays.push(...dateFns.eachDayOfInterval({
1224
+ start: previousMonthStart,
1225
+ end: previousMonthEnd
1226
+ }));
1227
+ }
1228
+ const lastDayOfWeek = dateFns.getDay(end);
1229
+ const nextMonthDays = [];
1230
+ if (lastDayOfWeek < 6 && showOutsideDays) {
1231
+ const nextMonthStart = new Date(end);
1232
+ nextMonthStart.setDate(nextMonthStart.getDate() + 1);
1233
+ const nextMonthEnd = dateFns.endOfWeek(end);
1234
+ nextMonthDays.push(...dateFns.eachDayOfInterval({
1235
+ start: nextMonthStart,
1236
+ end: nextMonthEnd
1237
+ }));
1238
+ }
1239
+ const emptyCells = [];
1240
+ if (!showOutsideDays && firstDayOfWeek > 0) {
1241
+ for (let i = 0; i < firstDayOfWeek; i++) {
1242
+ emptyCells.push(null);
1243
+ }
1244
+ }
1245
+ return [...previousMonthDays, ...emptyCells, ...days2, ...nextMonthDays];
1246
+ };
1247
+ const days = getDaysInMonth();
1248
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("moonui-theme", "p-0", className), children: [
1249
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between px-6 py-4 border-b border-border/50 dark:border-gray-700/50", children: [
1250
+ /* @__PURE__ */ jsxRuntime.jsx(
1251
+ "button",
1252
+ {
1253
+ onClick: handlePreviousMonth,
1254
+ className: cn(
1255
+ "h-10 w-10 bg-transparent p-0 rounded-lg",
1256
+ "hover:bg-muted transition-colors",
1257
+ "inline-flex items-center justify-center"
1258
+ ),
1259
+ type: "button",
1260
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronLeft, { className: "h-5 w-5" })
1261
+ }
1262
+ ),
1263
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-base font-medium", children: dateFns.format(currentMonth, "MMMM yyyy") }),
1264
+ /* @__PURE__ */ jsxRuntime.jsx(
1265
+ "button",
1266
+ {
1267
+ onClick: handleNextMonth,
1268
+ className: cn(
1269
+ "h-10 w-10 bg-transparent p-0 rounded-lg",
1270
+ "hover:bg-muted transition-colors",
1271
+ "inline-flex items-center justify-center"
1272
+ ),
1273
+ type: "button",
1274
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRight, { className: "h-5 w-5" })
1275
+ }
1276
+ )
1277
+ ] }),
1278
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-6 pb-4", children: [
1279
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-7 mb-2", children: weekDays.map((day, index) => /* @__PURE__ */ jsxRuntime.jsx(
1280
+ "div",
1281
+ {
1282
+ className: "text-muted-foreground text-xs font-medium h-10 flex items-center justify-center",
1283
+ title: day.full,
1284
+ children: day.short
1285
+ },
1286
+ `weekday-${index}`
1287
+ )) }),
1288
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-7 gap-1", children: days.map((date, index) => {
1289
+ if (!date) {
1290
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-10 w-10" }, `empty-${index}`);
1291
+ }
1292
+ const isOutsideMonth = !dateFns.isSameMonth(date, currentMonth);
1293
+ const isDisabled = disabled?.(date) || false;
1294
+ const isSelected = isDateSelected(date);
1295
+ const isTodayDate = dateFns.isToday(date);
1296
+ const rangeStart = isRangeStart(date);
1297
+ const rangeEnd = isRangeEnd(date);
1298
+ const rangeMiddle = isRangeMiddle(date);
1299
+ return /* @__PURE__ */ jsxRuntime.jsx(
1300
+ "button",
1301
+ {
1302
+ onClick: () => handleDateClick(date),
1303
+ disabled: isDisabled,
1304
+ className: cn(
1305
+ "h-10 w-10 p-0 font-normal",
1306
+ "inline-flex items-center justify-center rounded-lg",
1307
+ "hover:bg-muted transition-colors text-sm",
1308
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
1309
+ isOutsideMonth && "text-muted-foreground/50",
1310
+ isDisabled && "text-muted-foreground/30 cursor-not-allowed hover:bg-transparent",
1311
+ isSelected && !rangeMiddle && "bg-primary text-primary-foreground font-medium hover:bg-primary hover:text-primary-foreground",
1312
+ isTodayDate && "font-semibold relative after:absolute after:bottom-1 after:left-1/2 after:-translate-x-1/2 after:h-1 after:w-1 after:rounded-full after:bg-primary",
1313
+ rangeMiddle && "bg-accent/30 text-accent-foreground rounded-none",
1314
+ rangeStart && "rounded-r-none",
1315
+ rangeEnd && "rounded-l-none"
1316
+ ),
1317
+ type: "button",
1318
+ children: dateFns.format(date, "d")
1319
+ },
1320
+ date.toISOString()
1321
+ );
1322
+ }) })
1323
+ ] })
1324
+ ] });
1325
+ }
1326
+ Calendar.displayName = "Calendar";
1131
1327
  var getCardType = (number) => {
1132
1328
  const patterns = {
1133
1329
  visa: /^4/,
@@ -7438,202 +7634,6 @@ function createSortableHeader(label) {
7438
7634
  }
7439
7635
  );
7440
7636
  }
7441
- function Calendar({
7442
- mode = "single",
7443
- selected,
7444
- onSelect,
7445
- disabled,
7446
- showOutsideDays = false,
7447
- className,
7448
- classNames,
7449
- numberOfMonths = 1,
7450
- defaultMonth,
7451
- ...props
7452
- }) {
7453
- const [currentMonth, setCurrentMonth] = t__namespace.useState(
7454
- defaultMonth || selected && selected || /* @__PURE__ */ new Date()
7455
- );
7456
- const weekDays = [
7457
- { short: "S", full: "Sunday" },
7458
- { short: "M", full: "Monday" },
7459
- { short: "T", full: "Tuesday" },
7460
- { short: "W", full: "Wednesday" },
7461
- { short: "T", full: "Thursday" },
7462
- { short: "F", full: "Friday" },
7463
- { short: "S", full: "Saturday" }
7464
- ];
7465
- const handlePreviousMonth = () => {
7466
- setCurrentMonth(dateFns.subMonths(currentMonth, 1));
7467
- };
7468
- const handleNextMonth = () => {
7469
- setCurrentMonth(dateFns.addMonths(currentMonth, 1));
7470
- };
7471
- const handleDateClick = (date) => {
7472
- if (disabled?.(date))
7473
- return;
7474
- if (mode === "single") {
7475
- onSelect?.(date);
7476
- } else if (mode === "range") {
7477
- const currentSelection = selected;
7478
- if (!currentSelection?.from || currentSelection.from && currentSelection.to) {
7479
- onSelect?.({ from: date, to: void 0 });
7480
- } else {
7481
- if (date < currentSelection.from) {
7482
- onSelect?.({ from: date, to: currentSelection.from });
7483
- } else {
7484
- onSelect?.({ from: currentSelection.from, to: date });
7485
- }
7486
- }
7487
- }
7488
- };
7489
- const isDateSelected = (date) => {
7490
- if (!selected)
7491
- return false;
7492
- if (mode === "single") {
7493
- return dateFns.isSameDay(date, selected);
7494
- } else if (mode === "range") {
7495
- const range = selected;
7496
- if (range.from && range.to) {
7497
- return date >= range.from && date <= range.to;
7498
- }
7499
- return range.from ? dateFns.isSameDay(date, range.from) : false;
7500
- }
7501
- return false;
7502
- };
7503
- const isRangeStart = (date) => {
7504
- if (mode !== "range" || !selected)
7505
- return false;
7506
- const range = selected;
7507
- return range.from ? dateFns.isSameDay(date, range.from) : false;
7508
- };
7509
- const isRangeEnd = (date) => {
7510
- if (mode !== "range" || !selected)
7511
- return false;
7512
- const range = selected;
7513
- return range.to ? dateFns.isSameDay(date, range.to) : false;
7514
- };
7515
- const isRangeMiddle = (date) => {
7516
- if (mode !== "range" || !selected)
7517
- return false;
7518
- const range = selected;
7519
- if (!range.from || !range.to)
7520
- return false;
7521
- return date > range.from && date < range.to;
7522
- };
7523
- const getDaysInMonth = () => {
7524
- const start = dateFns.startOfMonth(currentMonth);
7525
- const end = dateFns.endOfMonth(currentMonth);
7526
- const days2 = dateFns.eachDayOfInterval({ start, end });
7527
- const firstDayOfWeek = dateFns.getDay(start);
7528
- const previousMonthDays = [];
7529
- if (firstDayOfWeek > 0 && showOutsideDays) {
7530
- const previousMonthStart = dateFns.startOfWeek(start);
7531
- const previousMonthEnd = new Date(start);
7532
- previousMonthEnd.setDate(previousMonthEnd.getDate() - 1);
7533
- previousMonthDays.push(...dateFns.eachDayOfInterval({
7534
- start: previousMonthStart,
7535
- end: previousMonthEnd
7536
- }));
7537
- }
7538
- const lastDayOfWeek = dateFns.getDay(end);
7539
- const nextMonthDays = [];
7540
- if (lastDayOfWeek < 6 && showOutsideDays) {
7541
- const nextMonthStart = new Date(end);
7542
- nextMonthStart.setDate(nextMonthStart.getDate() + 1);
7543
- const nextMonthEnd = dateFns.endOfWeek(end);
7544
- nextMonthDays.push(...dateFns.eachDayOfInterval({
7545
- start: nextMonthStart,
7546
- end: nextMonthEnd
7547
- }));
7548
- }
7549
- const emptyCells = [];
7550
- if (!showOutsideDays && firstDayOfWeek > 0) {
7551
- for (let i = 0; i < firstDayOfWeek; i++) {
7552
- emptyCells.push(null);
7553
- }
7554
- }
7555
- return [...previousMonthDays, ...emptyCells, ...days2, ...nextMonthDays];
7556
- };
7557
- const days = getDaysInMonth();
7558
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("moonui-theme", "p-0", className), children: [
7559
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between px-6 py-4 border-b border-border/50 dark:border-gray-700/50", children: [
7560
- /* @__PURE__ */ jsxRuntime.jsx(
7561
- "button",
7562
- {
7563
- onClick: handlePreviousMonth,
7564
- className: cn(
7565
- "h-10 w-10 bg-transparent p-0 rounded-lg",
7566
- "hover:bg-muted transition-colors",
7567
- "inline-flex items-center justify-center"
7568
- ),
7569
- type: "button",
7570
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronLeft, { className: "h-5 w-5" })
7571
- }
7572
- ),
7573
- /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-base font-medium", children: dateFns.format(currentMonth, "MMMM yyyy") }),
7574
- /* @__PURE__ */ jsxRuntime.jsx(
7575
- "button",
7576
- {
7577
- onClick: handleNextMonth,
7578
- className: cn(
7579
- "h-10 w-10 bg-transparent p-0 rounded-lg",
7580
- "hover:bg-muted transition-colors",
7581
- "inline-flex items-center justify-center"
7582
- ),
7583
- type: "button",
7584
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRight, { className: "h-5 w-5" })
7585
- }
7586
- )
7587
- ] }),
7588
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-6 pb-4", children: [
7589
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-7 mb-2", children: weekDays.map((day, index) => /* @__PURE__ */ jsxRuntime.jsx(
7590
- "div",
7591
- {
7592
- className: "text-muted-foreground text-xs font-medium h-10 flex items-center justify-center",
7593
- title: day.full,
7594
- children: day.short
7595
- },
7596
- `weekday-${index}`
7597
- )) }),
7598
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-7 gap-1", children: days.map((date, index) => {
7599
- if (!date) {
7600
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-10 w-10" }, `empty-${index}`);
7601
- }
7602
- const isOutsideMonth = !dateFns.isSameMonth(date, currentMonth);
7603
- const isDisabled = disabled?.(date) || false;
7604
- const isSelected = isDateSelected(date);
7605
- const isTodayDate = dateFns.isToday(date);
7606
- const rangeStart = isRangeStart(date);
7607
- const rangeEnd = isRangeEnd(date);
7608
- const rangeMiddle = isRangeMiddle(date);
7609
- return /* @__PURE__ */ jsxRuntime.jsx(
7610
- "button",
7611
- {
7612
- onClick: () => handleDateClick(date),
7613
- disabled: isDisabled,
7614
- className: cn(
7615
- "h-10 w-10 p-0 font-normal",
7616
- "inline-flex items-center justify-center rounded-lg",
7617
- "hover:bg-muted transition-colors text-sm",
7618
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
7619
- isOutsideMonth && "text-muted-foreground/50",
7620
- isDisabled && "text-muted-foreground/30 cursor-not-allowed hover:bg-transparent",
7621
- isSelected && !rangeMiddle && "bg-primary text-primary-foreground font-medium hover:bg-primary hover:text-primary-foreground",
7622
- isTodayDate && "font-semibold relative after:absolute after:bottom-1 after:left-1/2 after:-translate-x-1/2 after:h-1 after:w-1 after:rounded-full after:bg-primary",
7623
- rangeMiddle && "bg-accent/30 text-accent-foreground rounded-none",
7624
- rangeStart && "rounded-r-none",
7625
- rangeEnd && "rounded-l-none"
7626
- ),
7627
- type: "button",
7628
- children: dateFns.format(date, "d")
7629
- },
7630
- date.toISOString()
7631
- );
7632
- }) })
7633
- ] })
7634
- ] });
7635
- }
7636
- Calendar.displayName = "Calendar";
7637
7637
  var pageTransitions2 = {
7638
7638
  initial: { opacity: 0, x: 20 },
7639
7639
  animate: { opacity: 1, x: 0 },
@@ -9249,7 +9249,8 @@ function MoonLogo({
9249
9249
  }) {
9250
9250
  const logoId = t__namespace.useId();
9251
9251
  const gradientId = `moon-gradient-${logoId}`;
9252
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("moonui-theme", "flex items-center gap-2", className), children: [
9252
+ const maskId = `moon-mask-${logoId}`;
9253
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex items-center gap-2", className), children: [
9253
9254
  /* @__PURE__ */ jsxRuntime.jsxs(
9254
9255
  "svg",
9255
9256
  {
@@ -9261,11 +9262,17 @@ function MoonLogo({
9261
9262
  className: "flex-shrink-0",
9262
9263
  ...props,
9263
9264
  children: [
9264
- variant === "gradient" && /* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsxs("linearGradient", { id: gradientId, x1: "0%", y1: "0%", x2: "100%", y2: "100%", children: [
9265
- /* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "0%", stopColor: "#3B82F6" }),
9266
- /* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "50%", stopColor: "#8B5CF6" }),
9267
- /* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "100%", stopColor: "#EC4899" })
9268
- ] }) }),
9265
+ /* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
9266
+ variant === "gradient" && /* @__PURE__ */ jsxRuntime.jsxs("linearGradient", { id: gradientId, x1: "0%", y1: "0%", x2: "100%", y2: "100%", children: [
9267
+ /* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "0%", stopColor: "#3B82F6" }),
9268
+ /* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "50%", stopColor: "#8B5CF6" }),
9269
+ /* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "100%", stopColor: "#EC4899" })
9270
+ ] }),
9271
+ /* @__PURE__ */ jsxRuntime.jsxs("mask", { id: maskId, children: [
9272
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { width: "32", height: "32", fill: "white" }),
9273
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "22", cy: "10", r: "10", fill: "black" })
9274
+ ] })
9275
+ ] }),
9269
9276
  /* @__PURE__ */ jsxRuntime.jsx(
9270
9277
  "circle",
9271
9278
  {
@@ -9273,17 +9280,8 @@ function MoonLogo({
9273
9280
  cy: "16",
9274
9281
  r: "14",
9275
9282
  fill: variant === "gradient" ? `url(#${gradientId})` : "currentColor",
9276
- className: variant === "default" ? "fill-primary" : ""
9277
- }
9278
- ),
9279
- /* @__PURE__ */ jsxRuntime.jsx(
9280
- "circle",
9281
- {
9282
- cx: "22",
9283
- cy: "10",
9284
- r: "10",
9285
- fill: "white",
9286
- className: "dark:fill-background"
9283
+ className: variant === "default" ? "fill-primary" : "",
9284
+ mask: `url(#${maskId})`
9287
9285
  }
9288
9286
  )
9289
9287
  ]
@@ -12902,6 +12900,7 @@ exports.MoonUIBreadcrumbList = BreadcrumbList;
12902
12900
  exports.MoonUIBreadcrumbPage = BreadcrumbPage;
12903
12901
  exports.MoonUIBreadcrumbSeparator = BreadcrumbSeparator;
12904
12902
  exports.MoonUIButton = Button;
12903
+ exports.MoonUICalendar = Calendar;
12905
12904
  exports.MoonUICard = Card;
12906
12905
  exports.MoonUICardCVCInput = CardCVCInput;
12907
12906
  exports.MoonUICardContent = CardContent;