@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.cjs +114 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +115 -17
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -610,7 +610,13 @@ function Input2(props) {
|
|
|
610
610
|
{
|
|
611
611
|
id: inputId,
|
|
612
612
|
type: actualType === "money" || actualType === "number" ? "text" : actualType,
|
|
613
|
-
className: cn(
|
|
613
|
+
className: cn(
|
|
614
|
+
"w-full",
|
|
615
|
+
leftIcon && "pl-10!",
|
|
616
|
+
hasRightSlot && "pr-10!",
|
|
617
|
+
getStatusStyles(),
|
|
618
|
+
className
|
|
619
|
+
),
|
|
614
620
|
placeholder,
|
|
615
621
|
disabled,
|
|
616
622
|
ref,
|
|
@@ -645,6 +651,8 @@ function Textarea(props) {
|
|
|
645
651
|
bare = false,
|
|
646
652
|
id,
|
|
647
653
|
rows = 4,
|
|
654
|
+
blockLeadingSpace = false,
|
|
655
|
+
onKeyDown,
|
|
648
656
|
...rest
|
|
649
657
|
} = props;
|
|
650
658
|
const randomId = React6.useId();
|
|
@@ -669,6 +677,12 @@ function Textarea(props) {
|
|
|
669
677
|
return "text-muted-foreground";
|
|
670
678
|
}
|
|
671
679
|
};
|
|
680
|
+
const handleKeyDown = (event) => {
|
|
681
|
+
if (blockLeadingSpace && event.key === " " && event.currentTarget.selectionStart === 0) {
|
|
682
|
+
event.preventDefault();
|
|
683
|
+
}
|
|
684
|
+
onKeyDown?.(event);
|
|
685
|
+
};
|
|
672
686
|
const textareaEl = /* @__PURE__ */ jsxRuntime.jsx(
|
|
673
687
|
"textarea",
|
|
674
688
|
{
|
|
@@ -678,9 +692,10 @@ function Textarea(props) {
|
|
|
678
692
|
placeholder,
|
|
679
693
|
disabled,
|
|
680
694
|
readOnly,
|
|
695
|
+
onKeyDown: handleKeyDown,
|
|
681
696
|
className: cn(
|
|
682
|
-
"placeholder:text-muted-foreground custom-view-scrollbar border-input flex w-full min-w-0 resize-
|
|
683
|
-
"focus-visible:border-
|
|
697
|
+
"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",
|
|
698
|
+
"focus-visible:border-blue-600 focus-visible:ring-blue-600/30 focus-visible:ring-[1px]",
|
|
684
699
|
"aria-invalid:ring-destructive/20 aria-invalid:border-destructive",
|
|
685
700
|
getStatusStyles(),
|
|
686
701
|
className
|
|
@@ -2301,6 +2316,11 @@ function disableNextCalendarMonth(year, monthIndex, maxDate) {
|
|
|
2301
2316
|
if (maxDate === void 0) return false;
|
|
2302
2317
|
return isCalendarDayAfterMax(makeLocalDate(year, monthIndex + 1, 1), maxDate);
|
|
2303
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
|
+
}
|
|
2304
2324
|
function scrollOpenYearSelectCheckedIntoView() {
|
|
2305
2325
|
requestAnimationFrame(() => {
|
|
2306
2326
|
const root2 = document.querySelector(YEAR_SELECT_OPEN_CONTENT_SELECTOR);
|
|
@@ -2311,10 +2331,23 @@ function scrollOpenYearSelectCheckedIntoView() {
|
|
|
2311
2331
|
});
|
|
2312
2332
|
}
|
|
2313
2333
|
function dayCellButtonClass(opts) {
|
|
2314
|
-
const { isToday, isSelected, isInRange, isRangeStart, isRangeEnd, interactiveDisabled } = opts;
|
|
2315
|
-
const
|
|
2316
|
-
|
|
2317
|
-
|
|
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
|
+
}
|
|
2318
2351
|
if (isInRange && !isToday) parts.push("bg-gray-100/90");
|
|
2319
2352
|
if ((isRangeStart || isRangeEnd) && !isToday) parts.push("bg-neutral-300 text-gray-700 opacity-100");
|
|
2320
2353
|
parts.push(interactiveDisabled ? "opacity-20 cursor-not-allowed" : "hover:bg-blue-100 cursor-pointer");
|
|
@@ -2341,12 +2374,14 @@ function RenderCalendar(props) {
|
|
|
2341
2374
|
calendarYearRange,
|
|
2342
2375
|
calendarSelectContainerClass,
|
|
2343
2376
|
floating = false,
|
|
2344
|
-
showTodayButton = true
|
|
2377
|
+
showTodayButton = true,
|
|
2378
|
+
mode = "select"
|
|
2345
2379
|
} = props;
|
|
2346
2380
|
const year = currentDate.getFullYear();
|
|
2347
2381
|
const monthIndex = currentDate.getMonth();
|
|
2348
2382
|
const anchorYear = year;
|
|
2349
2383
|
const disableNextMonth = disableNextCalendarMonth(year, monthIndex, maxDate);
|
|
2384
|
+
const disableNextYear = disableNextCalendarYear(year, maxDate);
|
|
2350
2385
|
const { leadingEmpty, daysInMonth, trailingEmpty } = getCalendarMonthGrid(year, monthIndex);
|
|
2351
2386
|
const yearOptions = buildCalendarYearSelectOptions(maxDate, anchorYear, calendarYearRange);
|
|
2352
2387
|
const monthOptions = buildCalendarMonthSelectOptions(year, maxDate);
|
|
@@ -2378,6 +2413,7 @@ function RenderCalendar(props) {
|
|
|
2378
2413
|
onClick: () => handleDateSelect(date),
|
|
2379
2414
|
disabled: isGreyedForRange || isPastMax,
|
|
2380
2415
|
className: dayCellButtonClass({
|
|
2416
|
+
mode,
|
|
2381
2417
|
isToday,
|
|
2382
2418
|
isSelected: Boolean(isSelected),
|
|
2383
2419
|
isInRange,
|
|
@@ -2412,7 +2448,62 @@ function RenderCalendar(props) {
|
|
|
2412
2448
|
rangeEnd
|
|
2413
2449
|
});
|
|
2414
2450
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: panelClass, onClick: stopBubble, onMouseDown: stopBubble, children: [
|
|
2415
|
-
/* @__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: [
|
|
2416
2507
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2417
2508
|
"button",
|
|
2418
2509
|
{
|
|
@@ -2637,7 +2728,8 @@ function DatePickerRange(props) {
|
|
|
2637
2728
|
maxDate,
|
|
2638
2729
|
calendarYearRange,
|
|
2639
2730
|
calendarSelectContainerClass,
|
|
2640
|
-
showTodayButton = true
|
|
2731
|
+
showTodayButton = true,
|
|
2732
|
+
mode = "select"
|
|
2641
2733
|
} = props;
|
|
2642
2734
|
const [inputs, setInputs] = React6.useState({ start: startValue, end: endValue });
|
|
2643
2735
|
const startInputValue = inputs.start;
|
|
@@ -2778,7 +2870,8 @@ function DatePickerRange(props) {
|
|
|
2778
2870
|
maxDate,
|
|
2779
2871
|
calendarYearRange,
|
|
2780
2872
|
calendarSelectContainerClass,
|
|
2781
|
-
showTodayButton
|
|
2873
|
+
showTodayButton,
|
|
2874
|
+
mode
|
|
2782
2875
|
}
|
|
2783
2876
|
)
|
|
2784
2877
|
}
|
|
@@ -2879,7 +2972,8 @@ function DatePickerSingle(props) {
|
|
|
2879
2972
|
calendarYearRange,
|
|
2880
2973
|
calendarSelectContainerClass,
|
|
2881
2974
|
onBlur,
|
|
2882
|
-
showTodayButton = true
|
|
2975
|
+
showTodayButton = true,
|
|
2976
|
+
mode = "select"
|
|
2883
2977
|
} = props;
|
|
2884
2978
|
const [inputValue, setInputValue] = React6.useState(value);
|
|
2885
2979
|
const calendarRef = React6.useRef(null);
|
|
@@ -2975,7 +3069,8 @@ function DatePickerSingle(props) {
|
|
|
2975
3069
|
maxDate,
|
|
2976
3070
|
calendarYearRange,
|
|
2977
3071
|
calendarSelectContainerClass,
|
|
2978
|
-
showTodayButton
|
|
3072
|
+
showTodayButton,
|
|
3073
|
+
mode
|
|
2979
3074
|
}
|
|
2980
3075
|
)
|
|
2981
3076
|
}
|
|
@@ -3051,7 +3146,8 @@ function DatePicker(props) {
|
|
|
3051
3146
|
maxDate,
|
|
3052
3147
|
calendarYearRange,
|
|
3053
3148
|
calendarSelectContainerClass,
|
|
3054
|
-
showTodayButton
|
|
3149
|
+
showTodayButton,
|
|
3150
|
+
mode
|
|
3055
3151
|
} = props;
|
|
3056
3152
|
if (isRange) {
|
|
3057
3153
|
const { startValue, endValue, onRangeChange } = props;
|
|
@@ -3071,7 +3167,8 @@ function DatePicker(props) {
|
|
|
3071
3167
|
maxDate,
|
|
3072
3168
|
calendarYearRange,
|
|
3073
3169
|
calendarSelectContainerClass,
|
|
3074
|
-
showTodayButton
|
|
3170
|
+
showTodayButton,
|
|
3171
|
+
mode
|
|
3075
3172
|
}
|
|
3076
3173
|
);
|
|
3077
3174
|
}
|
|
@@ -3094,7 +3191,8 @@ function DatePicker(props) {
|
|
|
3094
3191
|
calendarYearRange,
|
|
3095
3192
|
calendarSelectContainerClass,
|
|
3096
3193
|
showTodayButton,
|
|
3097
|
-
onBlur
|
|
3194
|
+
onBlur,
|
|
3195
|
+
mode
|
|
3098
3196
|
}
|
|
3099
3197
|
);
|
|
3100
3198
|
}
|