@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.d.cts CHANGED
@@ -495,6 +495,7 @@ type DatePickerBaseProps = {
495
495
  calendarYearRange?: CalendarYearRange;
496
496
  calendarSelectContainerClass?: string;
497
497
  showTodayButton?: boolean;
498
+ mode?: "select" | "arrow";
498
499
  };
499
500
  type DatePickerSingleMode = DatePickerBaseProps & {
500
501
  isRange?: false;
package/dist/index.d.ts CHANGED
@@ -495,6 +495,7 @@ type DatePickerBaseProps = {
495
495
  calendarYearRange?: CalendarYearRange;
496
496
  calendarSelectContainerClass?: string;
497
497
  showTodayButton?: boolean;
498
+ mode?: "select" | "arrow";
498
499
  };
499
500
  type DatePickerSingleMode = DatePickerBaseProps & {
500
501
  isRange?: false;
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import * as React6 from 'react';
6
6
  import React6__default, { forwardRef, useState, useRef, useEffect, useImperativeHandle, useCallback, memo, createContext, useContext, useMemo, useId, useLayoutEffect, useDeferredValue, Fragment as Fragment$1 } from 'react';
7
7
  import { Slot } from '@radix-ui/react-slot';
8
8
  import * as TooltipPrimitive from '@radix-ui/react-tooltip';
9
- import { ChevronLeft, ChevronRight, FileText, ZoomIn, ZoomOut, RotateCcw, RotateCw, Download, X, Heading1, Heading2, Heading3, Heading4, Bold, Italic, Strikethrough, Code, Baseline, AlignLeft, AlignCenter, AlignRight, List, ListOrdered, Quote, FileCode, Table as Table$1, Plus, Minus, Trash2, Check, CircleX, EyeOff, Eye, ChevronDown, Calendar, CircleIcon, ChevronUp, Search, TriangleAlert, Info, Pencil, BadgePlus, FileSearch2, Upload, FileUp, PanelRightClose, PanelLeftClose, ChevronFirst, ChevronLast, MoreHorizontal } from 'lucide-react';
9
+ import { ChevronLeft, ChevronRight, FileText, ZoomIn, ZoomOut, RotateCcw, RotateCw, Download, X, Heading1, Heading2, Heading3, Heading4, Bold, Italic, Strikethrough, Code, Baseline, AlignLeft, AlignCenter, AlignRight, List, ListOrdered, Quote, FileCode, Table as Table$1, Plus, Minus, Trash2, Check, CircleX, EyeOff, Eye, ChevronDown, Calendar, CircleIcon, ChevronUp, ChevronsLeft, ChevronsRight, Search, TriangleAlert, Info, Pencil, BadgePlus, FileSearch2, Upload, FileUp, PanelRightClose, PanelLeftClose, ChevronFirst, ChevronLast, MoreHorizontal } from 'lucide-react';
10
10
  import * as SwitchPrimitive from '@radix-ui/react-switch';
11
11
  import * as RadixSlider from '@radix-ui/react-slider';
12
12
  import * as SelectPrimitive from '@radix-ui/react-select';
@@ -2279,6 +2279,11 @@ function disableNextCalendarMonth(year, monthIndex, maxDate) {
2279
2279
  if (maxDate === void 0) return false;
2280
2280
  return isCalendarDayAfterMax(makeLocalDate(year, monthIndex + 1, 1), maxDate);
2281
2281
  }
2282
+ function disableNextCalendarYear(year, maxDate) {
2283
+ if (maxDate === void 0) return false;
2284
+ const maxYear = parseLocalYmd(maxDate)?.getFullYear();
2285
+ return maxYear !== void 0 && year + 1 > maxYear;
2286
+ }
2282
2287
  function scrollOpenYearSelectCheckedIntoView() {
2283
2288
  requestAnimationFrame(() => {
2284
2289
  const root2 = document.querySelector(YEAR_SELECT_OPEN_CONTENT_SELECTOR);
@@ -2289,10 +2294,23 @@ function scrollOpenYearSelectCheckedIntoView() {
2289
2294
  });
2290
2295
  }
2291
2296
  function dayCellButtonClass(opts) {
2292
- const { isToday, isSelected, isInRange, isRangeStart, isRangeEnd, interactiveDisabled } = opts;
2293
- const parts = ["w-8 h-8 text-sm flex items-center justify-center rounded-2xl transition-colors"];
2294
- if (isToday) parts.push("bg-gray-100");
2295
- if (isSelected && !isToday) parts.push("bg-neutral-200 text-gray-700");
2297
+ const { mode, isToday, isSelected, isInRange, isRangeStart, isRangeEnd, interactiveDisabled } = opts;
2298
+ const isTodayOnlyArrowCell = mode === "arrow" && isToday && !isSelected;
2299
+ const parts = [
2300
+ "w-8 h-8 text-sm flex items-center justify-center transition-colors",
2301
+ isTodayOnlyArrowCell ? "" : "rounded-2xl"
2302
+ ];
2303
+ if (mode === "arrow") {
2304
+ if (isToday && !isSelected) {
2305
+ parts.push("border-b-1 border-blue-500 text-blue-500");
2306
+ } else if (isToday && isSelected) {
2307
+ parts.push("border-b-0");
2308
+ }
2309
+ if (isSelected) parts.push("bg-blue-200/90");
2310
+ } else {
2311
+ if (isToday) parts.push("bg-gray-100");
2312
+ if (isSelected && !isToday) parts.push("bg-neutral-200 text-gray-700");
2313
+ }
2296
2314
  if (isInRange && !isToday) parts.push("bg-gray-100/90");
2297
2315
  if ((isRangeStart || isRangeEnd) && !isToday) parts.push("bg-neutral-300 text-gray-700 opacity-100");
2298
2316
  parts.push(interactiveDisabled ? "opacity-20 cursor-not-allowed" : "hover:bg-blue-100 cursor-pointer");
@@ -2319,12 +2337,14 @@ function RenderCalendar(props) {
2319
2337
  calendarYearRange,
2320
2338
  calendarSelectContainerClass,
2321
2339
  floating = false,
2322
- showTodayButton = true
2340
+ showTodayButton = true,
2341
+ mode = "select"
2323
2342
  } = props;
2324
2343
  const year = currentDate.getFullYear();
2325
2344
  const monthIndex = currentDate.getMonth();
2326
2345
  const anchorYear = year;
2327
2346
  const disableNextMonth = disableNextCalendarMonth(year, monthIndex, maxDate);
2347
+ const disableNextYear = disableNextCalendarYear(year, maxDate);
2328
2348
  const { leadingEmpty, daysInMonth, trailingEmpty } = getCalendarMonthGrid(year, monthIndex);
2329
2349
  const yearOptions = buildCalendarYearSelectOptions(maxDate, anchorYear, calendarYearRange);
2330
2350
  const monthOptions = buildCalendarMonthSelectOptions(year, maxDate);
@@ -2356,6 +2376,7 @@ function RenderCalendar(props) {
2356
2376
  onClick: () => handleDateSelect(date),
2357
2377
  disabled: isGreyedForRange || isPastMax,
2358
2378
  className: dayCellButtonClass({
2379
+ mode,
2359
2380
  isToday,
2360
2381
  isSelected: Boolean(isSelected),
2361
2382
  isInRange,
@@ -2390,7 +2411,62 @@ function RenderCalendar(props) {
2390
2411
  rangeEnd
2391
2412
  });
2392
2413
  return /* @__PURE__ */ jsxs("div", { className: panelClass, onClick: stopBubble, onMouseDown: stopBubble, children: [
2393
- /* @__PURE__ */ jsxs("div", { className: "mb-1 flex items-center justify-between", children: [
2414
+ mode === "arrow" ? /* @__PURE__ */ jsxs("div", { className: "mb-1 flex h-8 items-center justify-between", children: [
2415
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center pl-1", children: [
2416
+ /* @__PURE__ */ jsx(
2417
+ "button",
2418
+ {
2419
+ type: "button",
2420
+ onClick: () => onYearChange(year - 1),
2421
+ className: "cursor-pointer rounded p-1 hover:bg-gray-100",
2422
+ children: /* @__PURE__ */ jsx(ChevronsLeft, { className: "size-4" })
2423
+ }
2424
+ ),
2425
+ /* @__PURE__ */ jsx(
2426
+ "button",
2427
+ {
2428
+ type: "button",
2429
+ onClick: goToPreviousMonth,
2430
+ className: "cursor-pointer rounded p-1 hover:bg-gray-100",
2431
+ children: /* @__PURE__ */ jsx(ChevronLeft, { className: "size-4" })
2432
+ }
2433
+ )
2434
+ ] }),
2435
+ /* @__PURE__ */ jsxs("h3", { className: "text-base font-medium text-gray-900", children: [
2436
+ String(year).padStart(4, "0"),
2437
+ " ",
2438
+ monthIndex + 1,
2439
+ "\uC6D4"
2440
+ ] }),
2441
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
2442
+ /* @__PURE__ */ jsx(
2443
+ "button",
2444
+ {
2445
+ type: "button",
2446
+ onClick: goToNextMonth,
2447
+ disabled: disableNextMonth,
2448
+ className: cn(
2449
+ "rounded p-1",
2450
+ disableNextMonth ? "cursor-not-allowed opacity-30" : "cursor-pointer hover:bg-gray-100"
2451
+ ),
2452
+ children: /* @__PURE__ */ jsx(ChevronRight, { className: "size-4" })
2453
+ }
2454
+ ),
2455
+ /* @__PURE__ */ jsx(
2456
+ "button",
2457
+ {
2458
+ type: "button",
2459
+ onClick: () => onYearChange(year + 1),
2460
+ disabled: disableNextYear,
2461
+ className: cn(
2462
+ "rounded p-1",
2463
+ disableNextYear ? "cursor-not-allowed opacity-30" : "cursor-pointer hover:bg-gray-100"
2464
+ ),
2465
+ children: /* @__PURE__ */ jsx(ChevronsRight, { className: "size-4" })
2466
+ }
2467
+ )
2468
+ ] })
2469
+ ] }) : /* @__PURE__ */ jsxs("div", { className: "mb-1 flex items-center justify-between", children: [
2394
2470
  /* @__PURE__ */ jsx(
2395
2471
  "button",
2396
2472
  {
@@ -2615,7 +2691,8 @@ function DatePickerRange(props) {
2615
2691
  maxDate,
2616
2692
  calendarYearRange,
2617
2693
  calendarSelectContainerClass,
2618
- showTodayButton = true
2694
+ showTodayButton = true,
2695
+ mode = "select"
2619
2696
  } = props;
2620
2697
  const [inputs, setInputs] = useState({ start: startValue, end: endValue });
2621
2698
  const startInputValue = inputs.start;
@@ -2756,7 +2833,8 @@ function DatePickerRange(props) {
2756
2833
  maxDate,
2757
2834
  calendarYearRange,
2758
2835
  calendarSelectContainerClass,
2759
- showTodayButton
2836
+ showTodayButton,
2837
+ mode
2760
2838
  }
2761
2839
  )
2762
2840
  }
@@ -2857,7 +2935,8 @@ function DatePickerSingle(props) {
2857
2935
  calendarYearRange,
2858
2936
  calendarSelectContainerClass,
2859
2937
  onBlur,
2860
- showTodayButton = true
2938
+ showTodayButton = true,
2939
+ mode = "select"
2861
2940
  } = props;
2862
2941
  const [inputValue, setInputValue] = useState(value);
2863
2942
  const calendarRef = useRef(null);
@@ -2953,7 +3032,8 @@ function DatePickerSingle(props) {
2953
3032
  maxDate,
2954
3033
  calendarYearRange,
2955
3034
  calendarSelectContainerClass,
2956
- showTodayButton
3035
+ showTodayButton,
3036
+ mode
2957
3037
  }
2958
3038
  )
2959
3039
  }
@@ -3029,7 +3109,8 @@ function DatePicker(props) {
3029
3109
  maxDate,
3030
3110
  calendarYearRange,
3031
3111
  calendarSelectContainerClass,
3032
- showTodayButton
3112
+ showTodayButton,
3113
+ mode
3033
3114
  } = props;
3034
3115
  if (isRange) {
3035
3116
  const { startValue, endValue, onRangeChange } = props;
@@ -3049,7 +3130,8 @@ function DatePicker(props) {
3049
3130
  maxDate,
3050
3131
  calendarYearRange,
3051
3132
  calendarSelectContainerClass,
3052
- showTodayButton
3133
+ showTodayButton,
3134
+ mode
3053
3135
  }
3054
3136
  );
3055
3137
  }
@@ -3072,7 +3154,8 @@ function DatePicker(props) {
3072
3154
  calendarYearRange,
3073
3155
  calendarSelectContainerClass,
3074
3156
  showTodayButton,
3075
- onBlur
3157
+ onBlur,
3158
+ mode
3076
3159
  }
3077
3160
  );
3078
3161
  }