@farmzone/fz-react-ui 1.1.14 → 1.1.15

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.cjs CHANGED
@@ -2316,6 +2316,11 @@ function disableNextCalendarMonth(year, monthIndex, maxDate) {
2316
2316
  if (maxDate === void 0) return false;
2317
2317
  return isCalendarDayAfterMax(makeLocalDate(year, monthIndex + 1, 1), maxDate);
2318
2318
  }
2319
+ function disableNextCalendarYear(year, maxDate) {
2320
+ if (maxDate === void 0) return false;
2321
+ const maxYear = parseLocalYmd(maxDate)?.getFullYear();
2322
+ return maxYear !== void 0 && year + 1 > maxYear;
2323
+ }
2319
2324
  function scrollOpenYearSelectCheckedIntoView() {
2320
2325
  requestAnimationFrame(() => {
2321
2326
  const root2 = document.querySelector(YEAR_SELECT_OPEN_CONTENT_SELECTOR);
@@ -2326,10 +2331,23 @@ function scrollOpenYearSelectCheckedIntoView() {
2326
2331
  });
2327
2332
  }
2328
2333
  function dayCellButtonClass(opts) {
2329
- const { isToday, isSelected, isInRange, isRangeStart, isRangeEnd, interactiveDisabled } = opts;
2330
- const parts = ["w-8 h-8 text-sm flex items-center justify-center rounded-2xl transition-colors"];
2331
- if (isToday) parts.push("bg-gray-100");
2332
- if (isSelected && !isToday) parts.push("bg-neutral-200 text-gray-700");
2334
+ const { mode, isToday, isSelected, isInRange, isRangeStart, isRangeEnd, interactiveDisabled } = opts;
2335
+ const isTodayOnlyArrowCell = mode === "arrow" && isToday && !isSelected;
2336
+ const parts = [
2337
+ "w-8 h-8 text-sm flex items-center justify-center transition-colors",
2338
+ isTodayOnlyArrowCell ? "" : "rounded-2xl"
2339
+ ];
2340
+ if (mode === "arrow") {
2341
+ if (isToday && !isSelected) {
2342
+ parts.push("border-b-1 border-blue-500 text-blue-500");
2343
+ } else if (isToday && isSelected) {
2344
+ parts.push("border-b-0");
2345
+ }
2346
+ if (isSelected) parts.push("bg-blue-200/90");
2347
+ } else {
2348
+ if (isToday) parts.push("bg-gray-100");
2349
+ if (isSelected && !isToday) parts.push("bg-neutral-200 text-gray-700");
2350
+ }
2333
2351
  if (isInRange && !isToday) parts.push("bg-gray-100/90");
2334
2352
  if ((isRangeStart || isRangeEnd) && !isToday) parts.push("bg-neutral-300 text-gray-700 opacity-100");
2335
2353
  parts.push(interactiveDisabled ? "opacity-20 cursor-not-allowed" : "hover:bg-blue-100 cursor-pointer");
@@ -2356,12 +2374,14 @@ function RenderCalendar(props) {
2356
2374
  calendarYearRange,
2357
2375
  calendarSelectContainerClass,
2358
2376
  floating = false,
2359
- showTodayButton = true
2377
+ showTodayButton = true,
2378
+ mode = "select"
2360
2379
  } = props;
2361
2380
  const year = currentDate.getFullYear();
2362
2381
  const monthIndex = currentDate.getMonth();
2363
2382
  const anchorYear = year;
2364
2383
  const disableNextMonth = disableNextCalendarMonth(year, monthIndex, maxDate);
2384
+ const disableNextYear = disableNextCalendarYear(year, maxDate);
2365
2385
  const { leadingEmpty, daysInMonth, trailingEmpty } = getCalendarMonthGrid(year, monthIndex);
2366
2386
  const yearOptions = buildCalendarYearSelectOptions(maxDate, anchorYear, calendarYearRange);
2367
2387
  const monthOptions = buildCalendarMonthSelectOptions(year, maxDate);
@@ -2393,6 +2413,7 @@ function RenderCalendar(props) {
2393
2413
  onClick: () => handleDateSelect(date),
2394
2414
  disabled: isGreyedForRange || isPastMax,
2395
2415
  className: dayCellButtonClass({
2416
+ mode,
2396
2417
  isToday,
2397
2418
  isSelected: Boolean(isSelected),
2398
2419
  isInRange,
@@ -2427,7 +2448,62 @@ function RenderCalendar(props) {
2427
2448
  rangeEnd
2428
2449
  });
2429
2450
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: panelClass, onClick: stopBubble, onMouseDown: stopBubble, children: [
2430
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-1 flex items-center justify-between", children: [
2451
+ mode === "arrow" ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-1 flex h-8 items-center justify-between", children: [
2452
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center pl-1", children: [
2453
+ /* @__PURE__ */ jsxRuntime.jsx(
2454
+ "button",
2455
+ {
2456
+ type: "button",
2457
+ onClick: () => onYearChange(year - 1),
2458
+ className: "cursor-pointer rounded p-1 hover:bg-gray-100",
2459
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronsLeft, { className: "size-4" })
2460
+ }
2461
+ ),
2462
+ /* @__PURE__ */ jsxRuntime.jsx(
2463
+ "button",
2464
+ {
2465
+ type: "button",
2466
+ onClick: goToPreviousMonth,
2467
+ className: "cursor-pointer rounded p-1 hover:bg-gray-100",
2468
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronLeft, { className: "size-4" })
2469
+ }
2470
+ )
2471
+ ] }),
2472
+ /* @__PURE__ */ jsxRuntime.jsxs("h3", { className: "text-base font-medium text-gray-900", children: [
2473
+ String(year).padStart(4, "0"),
2474
+ " ",
2475
+ monthIndex + 1,
2476
+ "\uC6D4"
2477
+ ] }),
2478
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center", children: [
2479
+ /* @__PURE__ */ jsxRuntime.jsx(
2480
+ "button",
2481
+ {
2482
+ type: "button",
2483
+ onClick: goToNextMonth,
2484
+ disabled: disableNextMonth,
2485
+ className: cn(
2486
+ "rounded p-1",
2487
+ disableNextMonth ? "cursor-not-allowed opacity-30" : "cursor-pointer hover:bg-gray-100"
2488
+ ),
2489
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRight, { className: "size-4" })
2490
+ }
2491
+ ),
2492
+ /* @__PURE__ */ jsxRuntime.jsx(
2493
+ "button",
2494
+ {
2495
+ type: "button",
2496
+ onClick: () => onYearChange(year + 1),
2497
+ disabled: disableNextYear,
2498
+ className: cn(
2499
+ "rounded p-1",
2500
+ disableNextYear ? "cursor-not-allowed opacity-30" : "cursor-pointer hover:bg-gray-100"
2501
+ ),
2502
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronsRight, { className: "size-4" })
2503
+ }
2504
+ )
2505
+ ] })
2506
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-1 flex items-center justify-between", children: [
2431
2507
  /* @__PURE__ */ jsxRuntime.jsx(
2432
2508
  "button",
2433
2509
  {
@@ -2652,7 +2728,8 @@ function DatePickerRange(props) {
2652
2728
  maxDate,
2653
2729
  calendarYearRange,
2654
2730
  calendarSelectContainerClass,
2655
- showTodayButton = true
2731
+ showTodayButton = true,
2732
+ mode = "select"
2656
2733
  } = props;
2657
2734
  const [inputs, setInputs] = React6.useState({ start: startValue, end: endValue });
2658
2735
  const startInputValue = inputs.start;
@@ -2793,7 +2870,8 @@ function DatePickerRange(props) {
2793
2870
  maxDate,
2794
2871
  calendarYearRange,
2795
2872
  calendarSelectContainerClass,
2796
- showTodayButton
2873
+ showTodayButton,
2874
+ mode
2797
2875
  }
2798
2876
  )
2799
2877
  }
@@ -2894,7 +2972,8 @@ function DatePickerSingle(props) {
2894
2972
  calendarYearRange,
2895
2973
  calendarSelectContainerClass,
2896
2974
  onBlur,
2897
- showTodayButton = true
2975
+ showTodayButton = true,
2976
+ mode = "select"
2898
2977
  } = props;
2899
2978
  const [inputValue, setInputValue] = React6.useState(value);
2900
2979
  const calendarRef = React6.useRef(null);
@@ -2990,7 +3069,8 @@ function DatePickerSingle(props) {
2990
3069
  maxDate,
2991
3070
  calendarYearRange,
2992
3071
  calendarSelectContainerClass,
2993
- showTodayButton
3072
+ showTodayButton,
3073
+ mode
2994
3074
  }
2995
3075
  )
2996
3076
  }
@@ -3066,7 +3146,8 @@ function DatePicker(props) {
3066
3146
  maxDate,
3067
3147
  calendarYearRange,
3068
3148
  calendarSelectContainerClass,
3069
- showTodayButton
3149
+ showTodayButton,
3150
+ mode
3070
3151
  } = props;
3071
3152
  if (isRange) {
3072
3153
  const { startValue, endValue, onRangeChange } = props;
@@ -3086,7 +3167,8 @@ function DatePicker(props) {
3086
3167
  maxDate,
3087
3168
  calendarYearRange,
3088
3169
  calendarSelectContainerClass,
3089
- showTodayButton
3170
+ showTodayButton,
3171
+ mode
3090
3172
  }
3091
3173
  );
3092
3174
  }
@@ -3109,7 +3191,8 @@ function DatePicker(props) {
3109
3191
  calendarYearRange,
3110
3192
  calendarSelectContainerClass,
3111
3193
  showTodayButton,
3112
- onBlur
3194
+ onBlur,
3195
+ mode
3113
3196
  }
3114
3197
  );
3115
3198
  }