@farmzone/fz-react-ui 1.0.13 → 1.0.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
@@ -446,7 +446,7 @@ function Input({ className, type, ...props }) {
446
446
  "data-slot": "input",
447
447
  className: cn(
448
448
  "file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input border-gray-300 flex h-8 w-full min-w-0 rounded-sm border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
449
- "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[1px]",
449
+ "focus-visible:border-blue-600 focus-visible:ring-blue-600/30 focus-visible:ring-[1px]",
450
450
  "aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
451
451
  className
452
452
  ),
@@ -1096,43 +1096,50 @@ function Radio(props) {
1096
1096
  "--radio-checked": checkColor,
1097
1097
  "--radio-unchecked": unCheckColor
1098
1098
  };
1099
- const control = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex items-center gap-1.5", wrapperClassName), style: colorVars, children: [
1100
- /* @__PURE__ */ jsxRuntime.jsx(
1101
- RadioGroupPrimitive__namespace.Item,
1102
- {
1103
- value,
1104
- disabled,
1105
- id: inputId,
1106
- className: cn(
1107
- "group relative size-4 shrink-0 rounded-full border box-border transition-colors duration-200 outline-none",
1108
- "border-(--radio-unchecked) data-[state=checked]:border-(--radio-checked)",
1109
- "data-[state=unchecked]:hover:opacity-80",
1110
- disabled ? "cursor-not-allowed opacity-50" : "cursor-pointer"
1111
- ),
1112
- children: /* @__PURE__ */ jsxRuntime.jsx(RadioGroupPrimitive__namespace.Indicator, { className: "relative flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
1113
- lucideReact.CircleIcon,
1099
+ const control = /* @__PURE__ */ jsxRuntime.jsxs(
1100
+ "label",
1101
+ {
1102
+ htmlFor: inputId,
1103
+ className: cn("flex items-center gap-1.5", disabled ? "cursor-not-allowed" : "cursor-pointer", wrapperClassName),
1104
+ style: colorVars,
1105
+ children: [
1106
+ /* @__PURE__ */ jsxRuntime.jsx(
1107
+ RadioGroupPrimitive__namespace.Item,
1114
1108
  {
1109
+ value,
1110
+ disabled,
1111
+ id: inputId,
1115
1112
  className: cn(
1116
- "absolute top-1/2 left-1/2 size-2.5 -translate-x-1/2 -translate-y-1/2 fill-(--radio-checked) text-(--radio-checked) transition-opacity duration-200",
1117
- indicatorClassName
1118
- )
1113
+ "group relative size-4 shrink-0 rounded-full border box-border transition-colors duration-200 outline-none",
1114
+ "border-(--radio-unchecked) data-[state=checked]:border-(--radio-checked)",
1115
+ "data-[state=unchecked]:hover:opacity-80",
1116
+ disabled ? "cursor-not-allowed opacity-50" : "cursor-pointer"
1117
+ ),
1118
+ children: /* @__PURE__ */ jsxRuntime.jsx(RadioGroupPrimitive__namespace.Indicator, { className: "relative flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
1119
+ lucideReact.CircleIcon,
1120
+ {
1121
+ className: cn(
1122
+ "absolute top-1/2 left-1/2 size-2.5 -translate-x-1/2 -translate-y-1/2 fill-(--radio-checked) text-(--radio-checked) transition-opacity duration-200",
1123
+ indicatorClassName
1124
+ )
1125
+ }
1126
+ ) })
1119
1127
  }
1120
- ) })
1121
- }
1122
- ),
1123
- /* @__PURE__ */ jsxRuntime.jsx(
1124
- "label",
1125
- {
1126
- htmlFor: inputId,
1127
- className: cn(
1128
- "text-sm font-medium cursor-pointer text-black select-none",
1129
- disabled && "cursor-not-allowed text-gray-400 opacity-50",
1130
- labelClassName
1131
1128
  ),
1132
- children: label
1133
- }
1134
- )
1135
- ] });
1129
+ /* @__PURE__ */ jsxRuntime.jsx(
1130
+ "span",
1131
+ {
1132
+ className: cn(
1133
+ "text-sm font-medium text-black select-none",
1134
+ disabled && "text-gray-400 opacity-50",
1135
+ labelClassName
1136
+ ),
1137
+ children: label
1138
+ }
1139
+ )
1140
+ ]
1141
+ }
1142
+ );
1136
1143
  const withTooltip = (node) => {
1137
1144
  if (!disabled || !disabledMessage) return node;
1138
1145
  return /* @__PURE__ */ jsxRuntime.jsx(Tooltip2, { content: disabledMessage, position: "bottom", asChild: true, sideOffset: 4, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-flex", children: node }) });
@@ -1179,11 +1186,7 @@ function RadioGroup(props) {
1179
1186
  value,
1180
1187
  onValueChange: (newValue) => onChange(newValue),
1181
1188
  disabled,
1182
- className: cn(
1183
- "flex flex-wrap gap-3",
1184
- direction === "horizontal" ? "flex-row" : "flex-col",
1185
- containerClassName
1186
- ),
1189
+ className: cn("flex flex-wrap gap-3", direction === "horizontal" ? "flex-row" : "flex-col", containerClassName),
1187
1190
  children: options.map((option) => /* @__PURE__ */ jsxRuntime.jsx(
1188
1191
  Radio,
1189
1192
  {
@@ -2562,9 +2565,11 @@ function DatePickerRange(props) {
2562
2565
  const dateToShow = position === "end" ? endInputValue || startInputValue : startInputValue || endInputValue;
2563
2566
  toggleCalendar(dateToShow);
2564
2567
  };
2565
- const handleFieldEnter = () => {
2566
- onKeyDownEnter?.();
2568
+ const handleFieldEnter = (value) => {
2567
2569
  closeCalendar();
2570
+ if (onKeyDownEnter && value.length === 10) {
2571
+ onKeyDownEnter();
2572
+ }
2568
2573
  };
2569
2574
  const inputClassName = cn(
2570
2575
  "w-full px-2 py-1.25 border border-gray-300 shadow-xs outline-none text-sm rounded-sm pr-7 transition-colors",
@@ -2624,7 +2629,10 @@ function DatePickerRange(props) {
2624
2629
  className: inputClassName,
2625
2630
  maxLength: 10,
2626
2631
  onKeyDown: (e) => {
2627
- if (e.key === "Enter") handleFieldEnter();
2632
+ if (e.key === "Enter") {
2633
+ e.preventDefault();
2634
+ handleFieldEnter(startInputValue);
2635
+ }
2628
2636
  }
2629
2637
  }
2630
2638
  ),
@@ -2652,7 +2660,10 @@ function DatePickerRange(props) {
2652
2660
  className: inputClassName,
2653
2661
  maxLength: 10,
2654
2662
  onKeyDown: (e) => {
2655
- if (e.key === "Enter") handleFieldEnter();
2663
+ if (e.key === "Enter") {
2664
+ e.preventDefault();
2665
+ handleFieldEnter(endInputValue);
2666
+ }
2656
2667
  }
2657
2668
  }
2658
2669
  ),
@@ -2747,9 +2758,11 @@ function DatePickerSingle(props) {
2747
2758
  onBlur?.(formatted);
2748
2759
  closeCalendar();
2749
2760
  };
2750
- const handleFieldEnter = () => {
2751
- onKeyDownEnter?.();
2761
+ const handleFieldEnter = (value2) => {
2752
2762
  closeCalendar();
2763
+ if (onKeyDownEnter && value2.length === 10) {
2764
+ onKeyDownEnter();
2765
+ }
2753
2766
  };
2754
2767
  const calendarNode = /* @__PURE__ */ jsxRuntime.jsx(
2755
2768
  CalendarPortal,
@@ -2798,12 +2811,15 @@ function DatePickerSingle(props) {
2798
2811
  disabled,
2799
2812
  className: cn(
2800
2813
  "w-full px-2 py-1.25 border text-sm rounded-sm outline-none shadow-xs transition-colors",
2801
- validation ? "border-red-600 focus:border-main focus-visible:border-main focus-visible:ring-1 focus-visible:ring-main/30 focus-visible:outline-none" : "border-gray-300 focus:border-main focus-visible:border-main focus-visible:ring-1 focus-visible:ring-main/30 focus-visible:outline-none",
2814
+ validation ? "border-red-600 focus:border-blue-600 focus-visible:border-blue-600 focus-visible:ring-1 focus-visible:ring-blue-600/30 focus-visible:outline-none" : "border-gray-300 focus:border-blue-600 focus-visible:border-blue-600 focus-visible:ring-1 focus-visible:ring-blue-600/30 focus-visible:outline-none",
2802
2815
  disabled ? DATE_PICKER_FIELD_DISABLED_CLASS : "bg-white text-gray-900"
2803
2816
  ),
2804
2817
  maxLength: 10,
2805
2818
  onKeyDown: (e) => {
2806
- if (e.key === "Enter") handleFieldEnter();
2819
+ if (e.key === "Enter") {
2820
+ e.preventDefault();
2821
+ handleFieldEnter(inputValue);
2822
+ }
2807
2823
  },
2808
2824
  "data-date-input": "true"
2809
2825
  }
@@ -4578,7 +4594,7 @@ function TableEmpty(props) {
4578
4594
  const { columnCount } = props;
4579
4595
  return /* @__PURE__ */ jsxRuntime.jsx("tr", { children: /* @__PURE__ */ jsxRuntime.jsx("td", { colSpan: columnCount, className: "border-none bg-white p-0 align-middle", children: /* @__PURE__ */ jsxRuntime.jsxs(Empty, { className: "flex min-h-72 w-full flex-col items-center justify-center gap-1", children: [
4580
4596
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.TriangleAlert, { className: "size-8 shrink-0 text-gray-400", strokeWidth: 1.5 }),
4581
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-lg text-gray-500", children: "\uB4F1\uB85D\uB41C \uB370\uC774\uD130\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4." })
4597
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-md text-gray-500", children: "\uB4F1\uB85D\uB41C \uB370\uC774\uD130\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4." })
4582
4598
  ] }) }) });
4583
4599
  }
4584
4600
  function TableCellContent(props) {
@@ -7833,7 +7849,8 @@ function PageFilter(props) {
7833
7849
  {
7834
7850
  value: currentValue,
7835
7851
  onChange: handleDateChange(optionKey),
7836
- placeholder: option.placeholder
7852
+ placeholder: option.placeholder,
7853
+ onKeyDownEnter: handleSubmit
7837
7854
  }
7838
7855
  ) }, String(optionKey));
7839
7856
  case "date-range":
@@ -7842,7 +7859,8 @@ function PageFilter(props) {
7842
7859
  {
7843
7860
  startValue: currentValue,
7844
7861
  endValue: String(values[option.endKey] ?? ""),
7845
- onRangeChange: handleRangeChangeCurried(optionKey, option.endKey)
7862
+ onRangeChange: handleRangeChangeCurried(optionKey, option.endKey),
7863
+ onKeyDownEnter: handleSubmit
7846
7864
  }
7847
7865
  ) }, String(optionKey));
7848
7866
  case "checkbox":
@@ -9227,6 +9245,9 @@ function Sidebar(props) {
9227
9245
  const [overflowVisible, setOverflowVisible] = React6.useState(true);
9228
9246
  const [expandedItems, setExpandedItems] = React6.useState(/* @__PURE__ */ new Set());
9229
9247
  const [expandedSubItems, setExpandedSubItems] = React6.useState(/* @__PURE__ */ new Set());
9248
+ const toggleCollapse = () => setIsCollapsed((prev) => !prev);
9249
+ const isHeaderRenderProp = typeof header === "function";
9250
+ const headerContent = isHeaderRenderProp ? header({ isCollapsed, toggleCollapse }) : header;
9230
9251
  React6.useEffect(() => {
9231
9252
  if (isCollapsed) {
9232
9253
  setOverflowVisible(false);
@@ -9301,21 +9322,22 @@ function Sidebar(props) {
9301
9322
  ${className ?? ""}
9302
9323
  `,
9303
9324
  children: [
9304
- showCollapseButton && /* @__PURE__ */ jsxRuntime.jsx(
9325
+ showCollapseButton && !isHeaderRenderProp && /* @__PURE__ */ jsxRuntime.jsx(
9305
9326
  "button",
9306
9327
  {
9307
- onClick: () => setIsCollapsed((prev) => !prev),
9328
+ onClick: toggleCollapse,
9308
9329
  className: `absolute top-4 z-20 w-6.5 h-6.5 rounded-full flex items-center justify-center transition-colors cursor-pointer ${s.collapseBtn} ${collapseButtonPlacement === "left" ? "left-2" : "right-2"}`,
9309
9330
  children: isCollapsed ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.PanelRightClose, { size: 18, color: primaryColor ?? s.collapseIcon }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.PanelLeftClose, { size: 18, color: primaryColor ?? s.collapseIcon })
9310
9331
  }
9311
9332
  ),
9333
+ isHeaderRenderProp && headerContent,
9312
9334
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: `flex-1 min-h-0 hide-scrollbar ${overflowVisible ? "overflow-y-auto" : "overflow-hidden"}`, children: /* @__PURE__ */ jsxRuntime.jsxs(
9313
9335
  "div",
9314
9336
  {
9315
9337
  className: `transition-opacity duration-200 ease-in-out ${isCollapsed ? "opacity-0 pointer-events-none select-none" : "opacity-100"} ${variant === "system-dark" || variant === "system-light" ? "pb-6" : "px-4 pb-6"}`,
9316
9338
  style: { transitionDelay: isCollapsed ? "0ms" : "150ms" },
9317
9339
  children: [
9318
- header && header,
9340
+ !isHeaderRenderProp && headerContent,
9319
9341
  /* @__PURE__ */ jsxRuntime.jsx("nav", { className: `space-y-6 ${variant === "system-dark" || variant === "system-light" ? "px-1" : ""}`, children: menuSections.map((section, sectionIndex) => /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
9320
9342
  section.title && /* @__PURE__ */ jsxRuntime.jsx("div", { className: s.sectionTitle, children: section.title }),
9321
9343
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-0.5", children: section.items.map((item) => {
@@ -9795,7 +9817,16 @@ function DetailModalFrame(props) {
9795
9817
  ] }),
9796
9818
  /* @__PURE__ */ jsxRuntime.jsx(ModalFooter, { className: "flex justify-end", children: isEditMode ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
9797
9819
  /* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "outline", onClick: handleCancelEdit, disabled: controller.isSaving, children: "\uCDE8\uC18C" }),
9798
- /* @__PURE__ */ jsxRuntime.jsx(Button, { type: "submit", form: controller.formId, variant: "save", disabled: controller.isSaving, children: "\uC800\uC7A5" })
9820
+ /* @__PURE__ */ jsxRuntime.jsx(
9821
+ Button,
9822
+ {
9823
+ type: "submit",
9824
+ form: controller.formId,
9825
+ variant: "save",
9826
+ disabled: controller.isSaving || !controller.isDirty,
9827
+ children: "\uC800\uC7A5"
9828
+ }
9829
+ )
9799
9830
  ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
9800
9831
  canEdit && /* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "outline", onClick: handleEdit, children: "\uC218\uC815" }),
9801
9832
  renderFooterExtra,