@farmzone/fz-react-ui 1.1.13 → 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
@@ -108,6 +108,8 @@ interface TextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {
108
108
  message?: string;
109
109
  label?: string;
110
110
  bare?: boolean;
111
+ /** 값의 첫 글자로 스페이스 입력을 막을지 (기본 false — 막으려면 true로 선언) */
112
+ blockLeadingSpace?: boolean;
111
113
  }
112
114
  declare function Textarea(props: TextareaProps): react.JSX.Element;
113
115
 
@@ -493,6 +495,7 @@ type DatePickerBaseProps = {
493
495
  calendarYearRange?: CalendarYearRange;
494
496
  calendarSelectContainerClass?: string;
495
497
  showTodayButton?: boolean;
498
+ mode?: "select" | "arrow";
496
499
  };
497
500
  type DatePickerSingleMode = DatePickerBaseProps & {
498
501
  isRange?: false;
package/dist/index.d.ts CHANGED
@@ -108,6 +108,8 @@ interface TextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {
108
108
  message?: string;
109
109
  label?: string;
110
110
  bare?: boolean;
111
+ /** 값의 첫 글자로 스페이스 입력을 막을지 (기본 false — 막으려면 true로 선언) */
112
+ blockLeadingSpace?: boolean;
111
113
  }
112
114
  declare function Textarea(props: TextareaProps): react.JSX.Element;
113
115
 
@@ -493,6 +495,7 @@ type DatePickerBaseProps = {
493
495
  calendarYearRange?: CalendarYearRange;
494
496
  calendarSelectContainerClass?: string;
495
497
  showTodayButton?: boolean;
498
+ mode?: "select" | "arrow";
496
499
  };
497
500
  type DatePickerSingleMode = DatePickerBaseProps & {
498
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';
@@ -573,7 +573,13 @@ function Input2(props) {
573
573
  {
574
574
  id: inputId,
575
575
  type: actualType === "money" || actualType === "number" ? "text" : actualType,
576
- className: cn("w-full", leftIcon && "pl-10", hasRightSlot && "pr-10", getStatusStyles(), className),
576
+ className: cn(
577
+ "w-full",
578
+ leftIcon && "pl-10!",
579
+ hasRightSlot && "pr-10!",
580
+ getStatusStyles(),
581
+ className
582
+ ),
577
583
  placeholder,
578
584
  disabled,
579
585
  ref,
@@ -608,6 +614,8 @@ function Textarea(props) {
608
614
  bare = false,
609
615
  id,
610
616
  rows = 4,
617
+ blockLeadingSpace = false,
618
+ onKeyDown,
611
619
  ...rest
612
620
  } = props;
613
621
  const randomId = useId();
@@ -632,6 +640,12 @@ function Textarea(props) {
632
640
  return "text-muted-foreground";
633
641
  }
634
642
  };
643
+ const handleKeyDown = (event) => {
644
+ if (blockLeadingSpace && event.key === " " && event.currentTarget.selectionStart === 0) {
645
+ event.preventDefault();
646
+ }
647
+ onKeyDown?.(event);
648
+ };
635
649
  const textareaEl = /* @__PURE__ */ jsx(
636
650
  "textarea",
637
651
  {
@@ -641,9 +655,10 @@ function Textarea(props) {
641
655
  placeholder,
642
656
  disabled,
643
657
  readOnly,
658
+ onKeyDown: handleKeyDown,
644
659
  className: cn(
645
- "placeholder:text-muted-foreground custom-view-scrollbar border-input flex w-full min-w-0 resize-y rounded-md border border-gray-300 bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
646
- "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[1px]",
660
+ "placeholder:text-muted-foreground custom-view-scrollbar border-input flex w-full min-w-0 resize-none rounded-md border border-gray-300 bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
661
+ "focus-visible:border-blue-600 focus-visible:ring-blue-600/30 focus-visible:ring-[1px]",
647
662
  "aria-invalid:ring-destructive/20 aria-invalid:border-destructive",
648
663
  getStatusStyles(),
649
664
  className
@@ -2264,6 +2279,11 @@ function disableNextCalendarMonth(year, monthIndex, maxDate) {
2264
2279
  if (maxDate === void 0) return false;
2265
2280
  return isCalendarDayAfterMax(makeLocalDate(year, monthIndex + 1, 1), maxDate);
2266
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
+ }
2267
2287
  function scrollOpenYearSelectCheckedIntoView() {
2268
2288
  requestAnimationFrame(() => {
2269
2289
  const root2 = document.querySelector(YEAR_SELECT_OPEN_CONTENT_SELECTOR);
@@ -2274,10 +2294,23 @@ function scrollOpenYearSelectCheckedIntoView() {
2274
2294
  });
2275
2295
  }
2276
2296
  function dayCellButtonClass(opts) {
2277
- const { isToday, isSelected, isInRange, isRangeStart, isRangeEnd, interactiveDisabled } = opts;
2278
- const parts = ["w-8 h-8 text-sm flex items-center justify-center rounded-2xl transition-colors"];
2279
- if (isToday) parts.push("bg-gray-100");
2280
- 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
+ }
2281
2314
  if (isInRange && !isToday) parts.push("bg-gray-100/90");
2282
2315
  if ((isRangeStart || isRangeEnd) && !isToday) parts.push("bg-neutral-300 text-gray-700 opacity-100");
2283
2316
  parts.push(interactiveDisabled ? "opacity-20 cursor-not-allowed" : "hover:bg-blue-100 cursor-pointer");
@@ -2304,12 +2337,14 @@ function RenderCalendar(props) {
2304
2337
  calendarYearRange,
2305
2338
  calendarSelectContainerClass,
2306
2339
  floating = false,
2307
- showTodayButton = true
2340
+ showTodayButton = true,
2341
+ mode = "select"
2308
2342
  } = props;
2309
2343
  const year = currentDate.getFullYear();
2310
2344
  const monthIndex = currentDate.getMonth();
2311
2345
  const anchorYear = year;
2312
2346
  const disableNextMonth = disableNextCalendarMonth(year, monthIndex, maxDate);
2347
+ const disableNextYear = disableNextCalendarYear(year, maxDate);
2313
2348
  const { leadingEmpty, daysInMonth, trailingEmpty } = getCalendarMonthGrid(year, monthIndex);
2314
2349
  const yearOptions = buildCalendarYearSelectOptions(maxDate, anchorYear, calendarYearRange);
2315
2350
  const monthOptions = buildCalendarMonthSelectOptions(year, maxDate);
@@ -2341,6 +2376,7 @@ function RenderCalendar(props) {
2341
2376
  onClick: () => handleDateSelect(date),
2342
2377
  disabled: isGreyedForRange || isPastMax,
2343
2378
  className: dayCellButtonClass({
2379
+ mode,
2344
2380
  isToday,
2345
2381
  isSelected: Boolean(isSelected),
2346
2382
  isInRange,
@@ -2375,7 +2411,62 @@ function RenderCalendar(props) {
2375
2411
  rangeEnd
2376
2412
  });
2377
2413
  return /* @__PURE__ */ jsxs("div", { className: panelClass, onClick: stopBubble, onMouseDown: stopBubble, children: [
2378
- /* @__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: [
2379
2470
  /* @__PURE__ */ jsx(
2380
2471
  "button",
2381
2472
  {
@@ -2600,7 +2691,8 @@ function DatePickerRange(props) {
2600
2691
  maxDate,
2601
2692
  calendarYearRange,
2602
2693
  calendarSelectContainerClass,
2603
- showTodayButton = true
2694
+ showTodayButton = true,
2695
+ mode = "select"
2604
2696
  } = props;
2605
2697
  const [inputs, setInputs] = useState({ start: startValue, end: endValue });
2606
2698
  const startInputValue = inputs.start;
@@ -2741,7 +2833,8 @@ function DatePickerRange(props) {
2741
2833
  maxDate,
2742
2834
  calendarYearRange,
2743
2835
  calendarSelectContainerClass,
2744
- showTodayButton
2836
+ showTodayButton,
2837
+ mode
2745
2838
  }
2746
2839
  )
2747
2840
  }
@@ -2842,7 +2935,8 @@ function DatePickerSingle(props) {
2842
2935
  calendarYearRange,
2843
2936
  calendarSelectContainerClass,
2844
2937
  onBlur,
2845
- showTodayButton = true
2938
+ showTodayButton = true,
2939
+ mode = "select"
2846
2940
  } = props;
2847
2941
  const [inputValue, setInputValue] = useState(value);
2848
2942
  const calendarRef = useRef(null);
@@ -2938,7 +3032,8 @@ function DatePickerSingle(props) {
2938
3032
  maxDate,
2939
3033
  calendarYearRange,
2940
3034
  calendarSelectContainerClass,
2941
- showTodayButton
3035
+ showTodayButton,
3036
+ mode
2942
3037
  }
2943
3038
  )
2944
3039
  }
@@ -3014,7 +3109,8 @@ function DatePicker(props) {
3014
3109
  maxDate,
3015
3110
  calendarYearRange,
3016
3111
  calendarSelectContainerClass,
3017
- showTodayButton
3112
+ showTodayButton,
3113
+ mode
3018
3114
  } = props;
3019
3115
  if (isRange) {
3020
3116
  const { startValue, endValue, onRangeChange } = props;
@@ -3034,7 +3130,8 @@ function DatePicker(props) {
3034
3130
  maxDate,
3035
3131
  calendarYearRange,
3036
3132
  calendarSelectContainerClass,
3037
- showTodayButton
3133
+ showTodayButton,
3134
+ mode
3038
3135
  }
3039
3136
  );
3040
3137
  }
@@ -3057,7 +3154,8 @@ function DatePicker(props) {
3057
3154
  calendarYearRange,
3058
3155
  calendarSelectContainerClass,
3059
3156
  showTodayButton,
3060
- onBlur
3157
+ onBlur,
3158
+ mode
3061
3159
  }
3062
3160
  );
3063
3161
  }