@farmzone/fz-react-ui 1.1.18 → 1.2.1

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.js CHANGED
@@ -59,7 +59,12 @@ var buttonVariants = cva(
59
59
  accent: "btn-grad text-white rounded-full",
60
60
  metal: "btn-metal text-white min-w-22",
61
61
  ghost: "p-1 h-auto rounded-sm bg-transparent text-sub-darkgray transition-colors hover:bg-gray-100",
62
- link: "bg-transparent border-none text-main-blue underline-offset-4 hover:underline h-auto p-0"
62
+ link: "bg-transparent border-none text-main-blue underline-offset-4 hover:underline h-auto p-0",
63
+ // inkstone: 흑백 미니멀. 색은 --fz-ink-* 변수(styles/inkstone.css)에서 읽는다.
64
+ inkstone: "rounded-[2px] bg-[var(--fz-ink)] border border-[var(--fz-ink)] text-[var(--fz-ink-contrast)] hover:bg-[var(--fz-ink-hover)] hover:border-[var(--fz-ink-hover)] active:bg-[var(--fz-ink)]",
65
+ "inkstone-outline": "rounded-[2px] bg-[var(--fz-ink-surface)] border border-[var(--fz-ink-line-strong)] text-[var(--fz-ink-text)] hover:bg-[var(--fz-ink-soft)] active:bg-[var(--fz-ink-selected)]",
66
+ "inkstone-ghost": "rounded-[2px] bg-transparent border border-transparent text-[var(--fz-ink-text-secondary)] hover:bg-[var(--fz-ink-soft)] hover:text-[var(--fz-ink-text)] active:bg-[var(--fz-ink-selected)]",
67
+ "inkstone-danger": "rounded-[2px] bg-[var(--fz-ink-surface)] border border-[var(--fz-ink-danger)] text-[var(--fz-ink-danger)] hover:bg-[color-mix(in_srgb,var(--fz-ink-danger)_8%,var(--fz-ink-surface))]"
63
68
  },
64
69
  size: {
65
70
  default: "h-8 px-4 font-semibold",
@@ -3781,6 +3786,15 @@ var VARIANT_CONFIG = {
3781
3786
  titleColor: "text-slate-100",
3782
3787
  descColor: "text-slate-400",
3783
3788
  closeBtn: "text-slate-500 group-hover:text-slate-300"
3789
+ },
3790
+ // inkstone: 흰 바탕에 아래 테두리만. 아이콘은 회색 네모 칸 안의 먹색.
3791
+ inkstone: {
3792
+ container: "bg-[var(--fz-ink-surface)] border-[var(--fz-ink-line)]",
3793
+ iconBg: "bg-[var(--fz-ink-soft)] rounded-[2px]",
3794
+ iconColor: "text-[var(--fz-ink-text)]",
3795
+ titleColor: "text-[var(--fz-ink-text)]",
3796
+ descColor: "text-[var(--fz-ink-text-tertiary)]",
3797
+ closeBtn: "text-[var(--fz-ink-text-tertiary)] group-hover:text-[var(--fz-ink-text)]"
3784
3798
  }
3785
3799
  };
3786
3800
  var SIZE_CONFIG = {
@@ -5020,7 +5034,8 @@ function Table(props) {
5020
5034
  tooltipConfig = "overflow",
5021
5035
  isDynamicHeight = true,
5022
5036
  showHorizontalDivider = true,
5023
- showVerticalDivider = true
5037
+ showVerticalDivider = true,
5038
+ variant = "default"
5024
5039
  } = props;
5025
5040
  const {
5026
5041
  fixed = false,
@@ -5500,82 +5515,89 @@ function Table(props) {
5500
5515
  const rest = baseRows.filter((row) => !effectiveRowOrder.includes(String(getRowKey(row.original, row.index))));
5501
5516
  return [...ordered, ...rest];
5502
5517
  }, [baseRows, effectiveRowOrder, getRowKey]);
5503
- return /* @__PURE__ */ jsxs("div", { className: "bg-white rounded shadow-table border border-gray-200 overflow-hidden", children: [
5504
- /* @__PURE__ */ jsx(
5505
- "div",
5506
- {
5507
- id: "table-layout",
5508
- ref: scrollRef,
5509
- className: "relative w-full overflow-y-auto overflow-x-auto custom-view-scrollbar bg-white",
5510
- style: { height: `${tableHeight}px` },
5511
- children: /* @__PURE__ */ jsxs(
5512
- "table",
5518
+ return /* @__PURE__ */ jsxs(
5519
+ "div",
5520
+ {
5521
+ className: "bg-white rounded shadow-table border border-gray-200 overflow-hidden",
5522
+ "data-fz-table-variant": variant,
5523
+ children: [
5524
+ /* @__PURE__ */ jsx(
5525
+ "div",
5513
5526
  {
5514
- className: `table-fixed border-spacing-0${tableMinWidth === void 0 ? " w-full" : ""}`,
5515
- style: tableMinWidth !== void 0 ? { width: tableMinWidth, minWidth: tableMinWidth } : {
5516
- minWidth: orderedColumns.reduce(
5517
- (sum, col) => sum + (col.key === "__checkbox__" || col.width !== void 0 ? parseColPx(col) : 80),
5518
- 0
5519
- )
5520
- },
5521
- children: [
5522
- /* @__PURE__ */ jsx(
5523
- TableHeader,
5524
- {
5525
- columns: orderedColumns,
5526
- getAlignStyle,
5527
- sortOption,
5528
- onSortChange,
5529
- onColumnDragStartCapture: handleColumnDragStartCapture,
5530
- onColumnDragStart: handleColumnDragStart,
5531
- onColumnDrop: handleColumnDrop,
5532
- onColumnDragEnd: handleColumnDragEnd,
5533
- onColumnDragOver: handleColumnDragOver,
5534
- isColumnDraggable
5535
- }
5536
- ),
5537
- /* @__PURE__ */ jsx("tbody", { className: "w-full h-full", children: showSkeleton ? Array.from({ length: 3 }).map((_, rowIdx) => /* @__PURE__ */ jsxs("tr", { className: "hover:bg-gray-50", children: [
5538
- leadingPinnedCols.map((col, idx) => /* @__PURE__ */ jsx(SkeletonTd, { col, showSquare: idx === 0 && !!checkboxInfo }, `leading-${idx}`)),
5539
- leftColspan > 0 && /* @__PURE__ */ jsx("td", { colSpan: leftColspan, style: { padding: 0, border: "none" } }),
5540
- virtualItems.map((vc) => /* @__PURE__ */ jsx(SkeletonTd, { col: groupCols[vc.index] }, `group-${vc.index}`)),
5541
- rightColspan > 0 && /* @__PURE__ */ jsx("td", { colSpan: rightColspan, style: { padding: 0, border: "none" } }),
5542
- trailingPinnedCols.map((col, idx) => /* @__PURE__ */ jsx(SkeletonTd, { col }, `trailing-${idx}`))
5543
- ] }, rowIdx)) : showEmpty ? /* @__PURE__ */ jsx(TableEmpty, { columnCount: allColumns.length }) : rows.map((row) => {
5544
- const rowId = String(getRowKey(row.original, row.index));
5545
- return /* @__PURE__ */ jsx(
5546
- TableDataRow,
5547
- {
5548
- record: row.original,
5549
- rowIdx: row.index,
5550
- rowId,
5551
- draggable: rowDraggable && !showSkeleton,
5552
- onDragStart: handleRowDragStart,
5553
- onDragOver: handleRowDragOver,
5554
- onDrop: handleRowDrop,
5555
- onDragEnd: handleRowDragEnd,
5556
- leftColspan,
5557
- rightColspan,
5558
- renderLeadingPinnedCols,
5559
- renderVisibleGroupCols,
5560
- renderTrailingPinnedCols
5561
- },
5562
- row.id
5563
- );
5564
- }) })
5565
- ]
5527
+ id: "table-layout",
5528
+ ref: scrollRef,
5529
+ className: "relative w-full overflow-y-auto overflow-x-auto custom-view-scrollbar bg-white",
5530
+ style: { height: `${tableHeight}px` },
5531
+ children: /* @__PURE__ */ jsxs(
5532
+ "table",
5533
+ {
5534
+ className: `table-fixed border-spacing-0${tableMinWidth === void 0 ? " w-full" : ""}`,
5535
+ style: tableMinWidth !== void 0 ? { width: tableMinWidth, minWidth: tableMinWidth } : {
5536
+ minWidth: orderedColumns.reduce(
5537
+ (sum, col) => sum + (col.key === "__checkbox__" || col.width !== void 0 ? parseColPx(col) : 80),
5538
+ 0
5539
+ )
5540
+ },
5541
+ children: [
5542
+ /* @__PURE__ */ jsx(
5543
+ TableHeader,
5544
+ {
5545
+ columns: orderedColumns,
5546
+ getAlignStyle,
5547
+ sortOption,
5548
+ onSortChange,
5549
+ onColumnDragStartCapture: handleColumnDragStartCapture,
5550
+ onColumnDragStart: handleColumnDragStart,
5551
+ onColumnDrop: handleColumnDrop,
5552
+ onColumnDragEnd: handleColumnDragEnd,
5553
+ onColumnDragOver: handleColumnDragOver,
5554
+ isColumnDraggable
5555
+ }
5556
+ ),
5557
+ /* @__PURE__ */ jsx("tbody", { className: "w-full h-full", children: showSkeleton ? Array.from({ length: 3 }).map((_, rowIdx) => /* @__PURE__ */ jsxs("tr", { className: "hover:bg-gray-50", children: [
5558
+ leadingPinnedCols.map((col, idx) => /* @__PURE__ */ jsx(SkeletonTd, { col, showSquare: idx === 0 && !!checkboxInfo }, `leading-${idx}`)),
5559
+ leftColspan > 0 && /* @__PURE__ */ jsx("td", { colSpan: leftColspan, style: { padding: 0, border: "none" } }),
5560
+ virtualItems.map((vc) => /* @__PURE__ */ jsx(SkeletonTd, { col: groupCols[vc.index] }, `group-${vc.index}`)),
5561
+ rightColspan > 0 && /* @__PURE__ */ jsx("td", { colSpan: rightColspan, style: { padding: 0, border: "none" } }),
5562
+ trailingPinnedCols.map((col, idx) => /* @__PURE__ */ jsx(SkeletonTd, { col }, `trailing-${idx}`))
5563
+ ] }, rowIdx)) : showEmpty ? /* @__PURE__ */ jsx(TableEmpty, { columnCount: allColumns.length }) : rows.map((row) => {
5564
+ const rowId = String(getRowKey(row.original, row.index));
5565
+ return /* @__PURE__ */ jsx(
5566
+ TableDataRow,
5567
+ {
5568
+ record: row.original,
5569
+ rowIdx: row.index,
5570
+ rowId,
5571
+ draggable: rowDraggable && !showSkeleton,
5572
+ onDragStart: handleRowDragStart,
5573
+ onDragOver: handleRowDragOver,
5574
+ onDrop: handleRowDrop,
5575
+ onDragEnd: handleRowDragEnd,
5576
+ leftColspan,
5577
+ rightColspan,
5578
+ renderLeadingPinnedCols,
5579
+ renderVisibleGroupCols,
5580
+ renderTrailingPinnedCols
5581
+ },
5582
+ row.id
5583
+ );
5584
+ }) })
5585
+ ]
5586
+ }
5587
+ )
5566
5588
  }
5567
- )
5568
- }
5569
- ),
5570
- !showSkeleton && (paginationInfo || renderFooter?.renderLeft || renderFooter?.renderRight) && /* @__PURE__ */ jsx("div", { ref: footerRef, children: /* @__PURE__ */ jsx(
5571
- TableFooter,
5572
- {
5573
- paginationInfo,
5574
- renderLeft: renderFooter?.renderLeft,
5575
- renderRight: renderFooter?.renderRight
5576
- }
5577
- ) })
5578
- ] });
5589
+ ),
5590
+ !showSkeleton && (paginationInfo || renderFooter?.renderLeft || renderFooter?.renderRight) && /* @__PURE__ */ jsx("div", { ref: footerRef, children: /* @__PURE__ */ jsx(
5591
+ TableFooter,
5592
+ {
5593
+ paginationInfo,
5594
+ renderLeft: renderFooter?.renderLeft,
5595
+ renderRight: renderFooter?.renderRight
5596
+ }
5597
+ ) })
5598
+ ]
5599
+ }
5600
+ );
5579
5601
  }
5580
5602
  var CarouselContext = React6.createContext(null);
5581
5603
  function useCarousel() {
@@ -8315,6 +8337,26 @@ var VARIANT_STYLES = {
8315
8337
  tabTextSize: "text-sm",
8316
8338
  scrollPadding: "px-4 pt-2",
8317
8339
  rounded: "rounded-t-none"
8340
+ },
8341
+ // inkstone: 흑백 미니멀. 선택된 탭만 먹(검정) 바탕에 흰 글자, 나머지는 흰 바탕 + 회색 테두리.
8342
+ inkstone: {
8343
+ container: "bg-[var(--fz-ink-canvas)]",
8344
+ activeTab: "bg-[var(--fz-ink)] border-[var(--fz-ink)] text-[var(--fz-ink-contrast)]",
8345
+ inactiveTab: "bg-[var(--fz-ink-surface)] border-[var(--fz-ink-line)] text-[var(--fz-ink-text-secondary)] hover:text-[var(--fz-ink-text)] hover:bg-[var(--fz-ink-soft)] hover:border-[var(--fz-ink-line-control)]",
8346
+ activeText: "font-bold text-[var(--fz-ink-contrast)]",
8347
+ inactiveText: "font-medium",
8348
+ indicator: "bg-transparent",
8349
+ closeBtn: "ml-auto rounded-[2px] opacity-60 hover:opacity-100 hover:bg-[color-mix(in_srgb,currentColor_18%,transparent)]",
8350
+ closeBtnWH: "w-4 h-4",
8351
+ closeBtnSize: 12,
8352
+ plusBtnArea: "bg-[var(--fz-ink-canvas)]",
8353
+ plusBtn: "text-[var(--fz-ink-text-tertiary)] hover:text-[var(--fz-ink-text)] hover:bg-[var(--fz-ink-soft)]",
8354
+ fadeOpacity: 0.12,
8355
+ tabHeight: "h-[30px]",
8356
+ tabPx: "px-3",
8357
+ tabTextSize: "text-xs",
8358
+ scrollPadding: "px-2 pt-2",
8359
+ rounded: "rounded-t-[2px]"
8318
8360
  }
8319
8361
  };
8320
8362
  var PLUS_BTN_WIDTH = 36;
@@ -9333,7 +9375,7 @@ function BaseUploader(props) {
9333
9375
  const errors = [];
9334
9376
  for (const file of incoming) {
9335
9377
  if (!checkAccept(file, accept)) {
9336
- errors.push(`${file.name}: \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uB294 \uD30C\uC77C \uD615\uC2DD`);
9378
+ errors.push(`${file.name}: \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uB294 \uD30C\uC77C \uD615\uC2DD\uC785\uB2C8\uB2E4.`);
9337
9379
  continue;
9338
9380
  }
9339
9381
  if (maxSize && file.size > maxSize) {
@@ -9907,6 +9949,34 @@ var VARIANT_STYLES2 = {
9907
9949
  paddingLeft: "10px"
9908
9950
  },
9909
9951
  footerBorder: "border-t border-gray-200"
9952
+ },
9953
+ // inkstone: 흑백 미니멀. 현재 메뉴는 회색 바탕 + 굵은 글자로만 표시하고 색 띠를 두지 않는다.
9954
+ inkstone: {
9955
+ aside: "bg-[var(--fz-ink-canvas)]",
9956
+ sectionTitle: "text-[11px] font-medium text-[var(--fz-ink-text-tertiary)] mb-1 px-2",
9957
+ itemActive: "font-bold",
9958
+ itemInactive: "text-[var(--fz-ink-text)] hover:bg-[var(--fz-ink-soft)]",
9959
+ subItemActive: "text-[var(--fz-ink-text)] font-bold",
9960
+ subItemInactive: "text-[var(--fz-ink-text-secondary)] hover:bg-[var(--fz-ink-soft)] hover:text-[var(--fz-ink-text)]",
9961
+ childGroupBorder: "border-[var(--fz-ink-line)]",
9962
+ childActive: "font-bold",
9963
+ childInactive: "text-[var(--fz-ink-text-secondary)] hover:bg-[var(--fz-ink-soft)] hover:text-[var(--fz-ink-text)]",
9964
+ grandchildActive: "text-[var(--fz-ink-text)] font-bold",
9965
+ grandchildInactive: "text-[var(--fz-ink-text-tertiary)] hover:bg-[var(--fz-ink-soft)] hover:text-[var(--fz-ink-text)]",
9966
+ collapseBtn: "bg-transparent hover:bg-[var(--fz-ink-soft)]",
9967
+ collapseIcon: "#525252",
9968
+ rounded: "rounded-[2px]",
9969
+ itemPy: "py-2",
9970
+ childPy: "py-1.5",
9971
+ grandchildPy: "py-1",
9972
+ itemFont: "font-medium",
9973
+ itemTextSize: "text-[13px]",
9974
+ grandchildTextSize: "text-xs",
9975
+ iconClass: "w-4 h-4 flex-shrink-0",
9976
+ activeItemStyle: { color: "var(--fz-ink-text)", backgroundColor: "var(--fz-ink-soft)" },
9977
+ activeChildStyle: { color: "var(--fz-ink-text)", backgroundColor: "var(--fz-ink-soft)" },
9978
+ activeGrandchildStyle: { color: "var(--fz-ink-text)", backgroundColor: "var(--fz-ink-soft)" },
9979
+ footerBorder: "border-t border-[var(--fz-ink-line)]"
9910
9980
  }
9911
9981
  };
9912
9982
  function tintedStyle(color) {
@@ -9975,6 +10045,13 @@ var ACCENT_APPLIERS = {
9975
10045
  borderLeft: `2px solid ${c}`,
9976
10046
  paddingLeft: "10px"
9977
10047
  })
10048
+ },
10049
+ // inkstone keeps its flat grey highlight; a primaryColor only tints it, with no side bar.
10050
+ inkstone: {
10051
+ itemActive: tintedStyle,
10052
+ subItemActive: textStyle,
10053
+ childActive: tintedStyle,
10054
+ grandchildActive: textStyle
9978
10055
  }
9979
10056
  };
9980
10057
  function Sidebar(props) {
@@ -9988,6 +10065,7 @@ function Sidebar(props) {
9988
10065
  showCollapseButton = false,
9989
10066
  collapseButtonPlacement = "right",
9990
10067
  variant = "light",
10068
+ width,
9991
10069
  primaryColor
9992
10070
  } = props;
9993
10071
  const { pathname } = useLocation();
@@ -10065,12 +10143,13 @@ function Sidebar(props) {
10065
10143
  "aside",
10066
10144
  {
10067
10145
  className: `
10068
- ${isCollapsed ? "w-11 min-w-11" : "min-w-60 w-62"}
10146
+ ${isCollapsed ? "w-11 min-w-11" : width === void 0 ? "min-w-60 w-62" : ""}
10069
10147
  transition-[width,min-width] duration-300 ease-in-out
10070
10148
  relative h-screen shrink-0 overflow-x-hidden flex flex-col
10071
10149
  ${s.aside}
10072
10150
  ${className ?? ""}
10073
10151
  `,
10152
+ style: !isCollapsed && width !== void 0 ? { width, minWidth: width } : void 0,
10074
10153
  children: [
10075
10154
  showCollapseButton && !isHeaderRenderProp && /* @__PURE__ */ jsx(
10076
10155
  "button",
@@ -10084,147 +10163,154 @@ function Sidebar(props) {
10084
10163
  /* @__PURE__ */ jsx("div", { className: `flex-1 min-h-0 hide-scrollbar ${overflowVisible ? "overflow-y-auto" : "overflow-hidden"}`, children: /* @__PURE__ */ jsxs(
10085
10164
  "div",
10086
10165
  {
10087
- 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"}`,
10166
+ className: `transition-opacity duration-200 ease-in-out ${isCollapsed ? "opacity-0 pointer-events-none select-none" : "opacity-100"} ${variant === "system-dark" || variant === "system-light" || variant === "inkstone" ? "pb-6" : "px-4 pb-6"}`,
10088
10167
  style: { transitionDelay: isCollapsed ? "0ms" : "150ms" },
10089
10168
  children: [
10090
10169
  !isHeaderRenderProp && headerContent,
10091
- /* @__PURE__ */ jsx("nav", { className: `space-y-6 ${variant === "system-dark" || variant === "system-light" ? "px-1" : ""}`, children: menuSections.map((section, sectionIndex) => /* @__PURE__ */ jsxs("div", { children: [
10092
- section.title && /* @__PURE__ */ jsx("div", { className: s.sectionTitle, children: section.title }),
10093
- /* @__PURE__ */ jsx("div", { className: "space-y-0.5", children: section.items.map((item) => {
10094
- const isActive = !item.children && pathname === item.path;
10095
- return /* @__PURE__ */ jsxs("div", { children: [
10096
- /* @__PURE__ */ jsxs(
10097
- "button",
10098
- {
10099
- onClick: () => {
10100
- if (item.children) {
10101
- toggleExpand(item.label);
10102
- } else if (item.path) {
10103
- handleItemClick(item.path);
10104
- }
10105
- },
10106
- className: `
10170
+ /* @__PURE__ */ jsx(
10171
+ "nav",
10172
+ {
10173
+ className: `${variant === "inkstone" ? "space-y-4 px-2" : "space-y-6"} ${variant === "system-dark" || variant === "system-light" ? "px-1" : ""}`,
10174
+ children: menuSections.map((section, sectionIndex) => /* @__PURE__ */ jsxs("div", { children: [
10175
+ section.title && /* @__PURE__ */ jsx("div", { className: s.sectionTitle, children: section.title }),
10176
+ /* @__PURE__ */ jsx("div", { className: "space-y-0.5", children: section.items.map((item) => {
10177
+ const isActive = !item.children && pathname === item.path;
10178
+ return /* @__PURE__ */ jsxs("div", { children: [
10179
+ /* @__PURE__ */ jsxs(
10180
+ "button",
10181
+ {
10182
+ onClick: () => {
10183
+ if (item.children) {
10184
+ toggleExpand(item.label);
10185
+ } else if (item.path) {
10186
+ handleItemClick(item.path);
10187
+ }
10188
+ },
10189
+ className: `
10107
10190
  w-full text-left flex items-center gap-2 px-3 ${s.itemPy} ${s.rounded} ${s.itemTextSize} ${s.itemFont} transition-colors cursor-pointer
10108
10191
  ${isActive ? s.itemActive : s.itemInactive}
10109
10192
  `,
10110
- style: {
10111
- ...isActive ? s.activeItemStyle : {},
10112
- ...isActive && primaryColor ? applier.itemActive(primaryColor) : {}
10113
- },
10114
- children: [
10115
- /* @__PURE__ */ jsx(item.icon, { className: s.iconClass }),
10116
- /* @__PURE__ */ jsx("span", { className: "flex-1", children: item.label }),
10117
- item.children && /* @__PURE__ */ jsx(
10118
- "svg",
10119
- {
10120
- className: `w-4 h-4 transition-transform ${expandedItems.has(item.label) ? "rotate-90" : ""}`,
10121
- fill: "none",
10122
- stroke: "currentColor",
10123
- viewBox: "0 0 24 24",
10124
- children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 5l7 7-7 7" })
10125
- }
10126
- ),
10127
- item.path?.includes("https") && /* @__PURE__ */ jsx(
10128
- "svg",
10129
- {
10130
- className: "w-4 h-4 flex-shrink-0 opacity-50",
10131
- fill: "none",
10132
- stroke: "currentColor",
10133
- viewBox: "0 0 24 24",
10134
- children: /* @__PURE__ */ jsx(
10135
- "path",
10193
+ style: {
10194
+ ...isActive ? s.activeItemStyle : {},
10195
+ ...isActive && primaryColor ? applier.itemActive(primaryColor) : {}
10196
+ },
10197
+ children: [
10198
+ /* @__PURE__ */ jsx(item.icon, { className: s.iconClass }),
10199
+ /* @__PURE__ */ jsx("span", { className: `flex-1 ${variant === "inkstone" ? "min-w-0 truncate text-left" : ""}`, children: item.label }),
10200
+ item.badge !== void 0 && item.badge !== null && /* @__PURE__ */ jsx("span", { className: "shrink-0 text-xs font-medium opacity-60", children: item.badge }),
10201
+ item.children && /* @__PURE__ */ jsx(
10202
+ "svg",
10203
+ {
10204
+ className: `w-4 h-4 transition-transform ${expandedItems.has(item.label) ? "rotate-90" : ""}`,
10205
+ fill: "none",
10206
+ stroke: "currentColor",
10207
+ viewBox: "0 0 24 24",
10208
+ children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 5l7 7-7 7" })
10209
+ }
10210
+ ),
10211
+ item.path?.includes("https") && /* @__PURE__ */ jsx(
10212
+ "svg",
10136
10213
  {
10137
- strokeLinecap: "round",
10138
- strokeLinejoin: "round",
10139
- strokeWidth: 2,
10140
- d: "M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"
10214
+ className: "w-4 h-4 flex-shrink-0 opacity-50",
10215
+ fill: "none",
10216
+ stroke: "currentColor",
10217
+ viewBox: "0 0 24 24",
10218
+ children: /* @__PURE__ */ jsx(
10219
+ "path",
10220
+ {
10221
+ strokeLinecap: "round",
10222
+ strokeLinejoin: "round",
10223
+ strokeWidth: 2,
10224
+ d: "M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"
10225
+ }
10226
+ )
10141
10227
  }
10142
10228
  )
10143
- }
10144
- )
10145
- ]
10146
- }
10147
- ),
10148
- item.children && expandedItems.has(item.label) && /* @__PURE__ */ jsx("div", { className: `ml-5 mt-0.5 space-y-0.5 border-l ${s.childGroupBorder}`, children: item.children.map((child, childIndex) => {
10149
- if (child.children && child.children.length > 0) {
10150
- const subKey = `${item.label}::${child.label}`;
10151
- const isSubExpanded = expandedSubItems.has(subKey);
10152
- const isSubActive = child.children.some((gc) => gc.path === pathname);
10153
- return /* @__PURE__ */ jsxs("div", { children: [
10154
- /* @__PURE__ */ jsxs(
10155
- "button",
10156
- {
10157
- onClick: () => toggleSubExpand(subKey),
10158
- className: `
10229
+ ]
10230
+ }
10231
+ ),
10232
+ item.children && expandedItems.has(item.label) && /* @__PURE__ */ jsx("div", { className: `ml-5 mt-0.5 space-y-0.5 border-l ${s.childGroupBorder}`, children: item.children.map((child, childIndex) => {
10233
+ if (child.children && child.children.length > 0) {
10234
+ const subKey = `${item.label}::${child.label}`;
10235
+ const isSubExpanded = expandedSubItems.has(subKey);
10236
+ const isSubActive = child.children.some((gc) => gc.path === pathname);
10237
+ return /* @__PURE__ */ jsxs("div", { children: [
10238
+ /* @__PURE__ */ jsxs(
10239
+ "button",
10240
+ {
10241
+ onClick: () => toggleSubExpand(subKey),
10242
+ className: `
10159
10243
  w-full text-left flex items-center justify-between pl-4 pr-3 ${s.childPy} ${s.rounded} ${s.itemTextSize} transition-colors cursor-pointer
10160
10244
  ${isSubActive ? s.subItemActive : s.subItemInactive}
10161
10245
  `,
10162
- style: isSubActive && primaryColor ? applier.subItemActive(primaryColor) : void 0,
10163
- children: [
10164
- /* @__PURE__ */ jsx("span", { children: child.label }),
10165
- /* @__PURE__ */ jsx(
10166
- "svg",
10167
- {
10168
- className: `w-3 h-3 transition-transform ${isSubExpanded ? "rotate-90" : ""}`,
10169
- fill: "none",
10170
- stroke: "currentColor",
10171
- viewBox: "0 0 24 24",
10172
- children: /* @__PURE__ */ jsx(
10173
- "path",
10246
+ style: isSubActive && primaryColor ? applier.subItemActive(primaryColor) : void 0,
10247
+ children: [
10248
+ /* @__PURE__ */ jsx("span", { children: child.label }),
10249
+ /* @__PURE__ */ jsx(
10250
+ "svg",
10174
10251
  {
10175
- strokeLinecap: "round",
10176
- strokeLinejoin: "round",
10177
- strokeWidth: 2,
10178
- d: "M9 5l7 7-7 7"
10252
+ className: `w-3 h-3 transition-transform ${isSubExpanded ? "rotate-90" : ""}`,
10253
+ fill: "none",
10254
+ stroke: "currentColor",
10255
+ viewBox: "0 0 24 24",
10256
+ children: /* @__PURE__ */ jsx(
10257
+ "path",
10258
+ {
10259
+ strokeLinecap: "round",
10260
+ strokeLinejoin: "round",
10261
+ strokeWidth: 2,
10262
+ d: "M9 5l7 7-7 7"
10263
+ }
10264
+ )
10179
10265
  }
10180
10266
  )
10181
- }
10182
- )
10183
- ]
10184
- }
10185
- ),
10186
- isSubExpanded && /* @__PURE__ */ jsx("div", { className: "ml-3 mt-0.5 space-y-0.5 pl-2", children: child.children.map((grandchild) => {
10187
- const isGrandchildActive = pathname === grandchild.path;
10188
- return /* @__PURE__ */ jsx(
10189
- "button",
10190
- {
10191
- onClick: () => handleItemClick(grandchild.path),
10192
- className: `
10267
+ ]
10268
+ }
10269
+ ),
10270
+ isSubExpanded && /* @__PURE__ */ jsx("div", { className: "ml-3 mt-0.5 space-y-0.5 pl-2", children: child.children.map((grandchild) => {
10271
+ const isGrandchildActive = pathname === grandchild.path;
10272
+ return /* @__PURE__ */ jsx(
10273
+ "button",
10274
+ {
10275
+ onClick: () => handleItemClick(grandchild.path),
10276
+ className: `
10193
10277
  w-full text-left px-3 ${s.grandchildPy} ${s.rounded} ${s.grandchildTextSize} transition-colors cursor-pointer
10194
10278
  ${isGrandchildActive ? s.grandchildActive : s.grandchildInactive}
10195
10279
  `,
10196
- style: {
10197
- ...isGrandchildActive ? s.activeGrandchildStyle : {},
10198
- ...isGrandchildActive && primaryColor ? applier.grandchildActive(primaryColor) : {}
10199
- },
10200
- children: grandchild.label
10201
- },
10202
- grandchild.path
10203
- );
10204
- }) })
10205
- ] }, child.label);
10206
- }
10207
- const isChildActive = pathname === child.path;
10208
- return /* @__PURE__ */ jsx(
10209
- "button",
10210
- {
10211
- onClick: () => handleItemClick(child.path ?? ""),
10212
- className: `
10280
+ style: {
10281
+ ...isGrandchildActive ? s.activeGrandchildStyle : {},
10282
+ ...isGrandchildActive && primaryColor ? applier.grandchildActive(primaryColor) : {}
10283
+ },
10284
+ children: grandchild.label
10285
+ },
10286
+ grandchild.path
10287
+ );
10288
+ }) })
10289
+ ] }, child.label);
10290
+ }
10291
+ const isChildActive = pathname === child.path;
10292
+ return /* @__PURE__ */ jsx(
10293
+ "button",
10294
+ {
10295
+ onClick: () => handleItemClick(child.path ?? ""),
10296
+ className: `
10213
10297
  w-full text-left pl-4 pr-3 ${s.childPy} ${s.rounded} ${s.itemTextSize} transition-colors cursor-pointer
10214
10298
  ${isChildActive ? s.childActive : s.childInactive}
10215
10299
  `,
10216
- style: {
10217
- ...isChildActive ? s.activeChildStyle : {},
10218
- ...isChildActive && primaryColor ? applier.childActive(primaryColor) : {}
10219
- },
10220
- children: child.label
10221
- },
10222
- childIndex
10223
- );
10300
+ style: {
10301
+ ...isChildActive ? s.activeChildStyle : {},
10302
+ ...isChildActive && primaryColor ? applier.childActive(primaryColor) : {}
10303
+ },
10304
+ children: child.label
10305
+ },
10306
+ childIndex
10307
+ );
10308
+ }) })
10309
+ ] }, item.label);
10224
10310
  }) })
10225
- ] }, item.label);
10226
- }) })
10227
- ] }, section.title ?? sectionIndex)) })
10311
+ ] }, section.title ?? sectionIndex))
10312
+ }
10313
+ )
10228
10314
  ]
10229
10315
  }
10230
10316
  ) }),
@@ -10693,20 +10779,24 @@ function createPasteHandler(processFilesRef) {
10693
10779
  return true;
10694
10780
  };
10695
10781
  }
10782
+ var RICH_EDITOR_DROP_HANDLED = "__richEditorDropHandled";
10696
10783
  function createDropHandler(processFilesRef) {
10697
10784
  return (_view, event) => {
10698
10785
  const files = Array.from(event.dataTransfer?.files ?? []);
10699
10786
  if (files.length === 0) return false;
10700
10787
  event.preventDefault();
10788
+ event[RICH_EDITOR_DROP_HANDLED] = true;
10701
10789
  processFilesRef.current(files);
10702
10790
  return true;
10703
10791
  };
10704
10792
  }
10793
+
10794
+ // src/lib/fileFormat.ts
10705
10795
  var FORMAT_EXT_ALIASES = {
10706
10796
  JPG: ["jpg", "jpeg"],
10707
10797
  JPEG: ["jpg", "jpeg"]
10708
10798
  };
10709
- function expandFormats(fileFormat) {
10799
+ function expandFileFormats(fileFormat) {
10710
10800
  const exts = /* @__PURE__ */ new Set();
10711
10801
  for (const format of fileFormat) {
10712
10802
  const key = format.toUpperCase();
@@ -10715,16 +10805,30 @@ function expandFormats(fileFormat) {
10715
10805
  }
10716
10806
  return exts;
10717
10807
  }
10718
- function extOf(fileName) {
10808
+ function getFileExtension(fileName) {
10719
10809
  return fileName.split(".").pop()?.toLowerCase() ?? "";
10720
10810
  }
10721
10811
  function buildAcceptAttribute(fileFormat) {
10722
10812
  if (!fileFormat || fileFormat.length === 0) return void 0;
10723
- return Array.from(expandFormats(fileFormat)).map((ext) => `.${ext}`).join(",");
10813
+ return Array.from(expandFileFormats(fileFormat)).map((ext) => `.${ext}`).join(",");
10814
+ }
10815
+ function splitFilesByFormat(files, fileFormat) {
10816
+ if (!fileFormat || fileFormat.length === 0) return { accepted: [...files], rejected: [] };
10817
+ const allowedExts = expandFileFormats(fileFormat);
10818
+ const accepted = [];
10819
+ const rejected = [];
10820
+ for (const file of files) {
10821
+ (allowedExts.has(getFileExtension(file.name)) ? accepted : rejected).push(file);
10822
+ }
10823
+ return { accepted, rejected };
10724
10824
  }
10825
+
10826
+ // src/components/RichEditor/hooks/useRichEditorFiles.ts
10725
10827
  function useRichEditorFiles(options = {}) {
10726
- const { fileFormat, onFileUpload, initialAttachments } = options;
10828
+ const { fileFormat, maxFiles, onFileUpload, initialAttachments } = options;
10727
10829
  const [attachments, setAttachments] = useState(() => initialAttachments ?? []);
10830
+ const attachmentsRef = useRef(attachments);
10831
+ attachmentsRef.current = attachments;
10728
10832
  const [isUploading, setIsUploading] = useState(false);
10729
10833
  const removeAttachment = useCallback((id) => {
10730
10834
  setAttachments((prev) => prev.filter((a) => a.id !== id));
@@ -10734,8 +10838,20 @@ function useRichEditorFiles(options = {}) {
10734
10838
  }, []);
10735
10839
  const processFiles = useCallback(
10736
10840
  async (files, editor) => {
10737
- const allowedExts = fileFormat ? expandFormats(fileFormat) : null;
10738
- const accepted = allowedExts ? files.filter((f) => allowedExts.has(extOf(f.name))) : files;
10841
+ const { accepted: splitAccepted, rejected: rejectedByFormat } = splitFilesByFormat(files, fileFormat);
10842
+ let accepted = splitAccepted;
10843
+ if (rejectedByFormat.length > 0) {
10844
+ toast.error("\uD5C8\uC6A9\uB418\uC9C0 \uC54A\uB294 \uD655\uC7A5\uC790\uC785\uB2C8\uB2E4.");
10845
+ }
10846
+ if (maxFiles) {
10847
+ const imageCount = editor ? (editor.getHTML().match(/<img\b/gi) ?? []).length : 0;
10848
+ const currentCount = attachmentsRef.current.length + imageCount;
10849
+ const remaining = Math.max(0, maxFiles - currentCount);
10850
+ if (accepted.length > remaining) {
10851
+ toast.error(`\uD30C\uC77C\uC740 \uCD5C\uB300 ${maxFiles}\uAC1C\uAE4C\uC9C0 \uCCA8\uBD80\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4.`);
10852
+ }
10853
+ accepted = accepted.slice(0, remaining);
10854
+ }
10739
10855
  if (accepted.length === 0) return;
10740
10856
  setIsUploading(true);
10741
10857
  try {
@@ -10768,7 +10884,7 @@ function useRichEditorFiles(options = {}) {
10768
10884
  setIsUploading(false);
10769
10885
  }
10770
10886
  },
10771
- [fileFormat, onFileUpload]
10887
+ [fileFormat, maxFiles, onFileUpload]
10772
10888
  );
10773
10889
  return { attachments, processFiles, removeAttachment, hydrateAttachments, isUploading };
10774
10890
  }
@@ -10843,6 +10959,7 @@ function useRichEditor(options = {}) {
10843
10959
  editorClassName,
10844
10960
  additionalExtensions = [],
10845
10961
  fileFormat,
10962
+ maxFiles,
10846
10963
  onFileUpload,
10847
10964
  onChange,
10848
10965
  onSubmit
@@ -10859,9 +10976,11 @@ function useRichEditor(options = {}) {
10859
10976
  const initialSplit = initialSplitRef.current;
10860
10977
  const { attachments, processFiles, removeAttachment, hydrateAttachments, isUploading } = useRichEditorFiles({
10861
10978
  fileFormat,
10979
+ maxFiles,
10862
10980
  onFileUpload,
10863
10981
  initialAttachments: initialSplit.attachments
10864
10982
  });
10983
+ const [imageCount, setImageCount] = useState(() => (initialSplit.html.match(/<img\b/gi) ?? []).length);
10865
10984
  const attachmentsRef = useRef(attachments);
10866
10985
  attachmentsRef.current = attachments;
10867
10986
  const editorRef = useRef(null);
@@ -10903,6 +11022,15 @@ function useRichEditor(options = {}) {
10903
11022
  }
10904
11023
  });
10905
11024
  editorRef.current = editor;
11025
+ useEffect(() => {
11026
+ if (!editor) return;
11027
+ const sync = () => setImageCount((editor.getHTML().match(/<img\b/gi) ?? []).length);
11028
+ sync();
11029
+ editor.on("transaction", sync);
11030
+ return () => {
11031
+ editor.off("transaction", sync);
11032
+ };
11033
+ }, [editor]);
10906
11034
  useEffect(() => {
10907
11035
  if (!editor) return;
10908
11036
  onChangeRef.current?.(composeRichEditorHtml(editor.getHTML(), attachments));
@@ -10927,6 +11055,7 @@ function useRichEditor(options = {}) {
10927
11055
  },
10928
11056
  isEmpty: editor?.isEmpty ?? true,
10929
11057
  attachments,
11058
+ attachmentCount: imageCount + attachments.length,
10930
11059
  removeAttachment,
10931
11060
  hydrateAttachments,
10932
11061
  processFiles: processFilesRef.current,
@@ -11174,7 +11303,7 @@ function RichEditorToolbar(props) {
11174
11303
  "div",
11175
11304
  {
11176
11305
  className: cn(
11177
- "flex flex-wrap items-center gap-0.5 p-2",
11306
+ "sticky top-0 z-10 flex flex-wrap items-center gap-0.5 p-2",
11178
11307
  theme.toolbar.wrapper,
11179
11308
  className
11180
11309
  ),
@@ -11519,7 +11648,7 @@ function RichEditorToolbar(props) {
11519
11648
  );
11520
11649
  }
11521
11650
  function RichEditorDropZone(props) {
11522
- const { children, className, "data-rich-editor-theme": themeAttr } = props;
11651
+ const { children, className, "data-rich-editor-theme": themeAttr, onDropFiles } = props;
11523
11652
  const theme = useRichEditorTheme();
11524
11653
  const [isDragging, setIsDragging] = useState(false);
11525
11654
  const counterRef = useRef(0);
@@ -11540,6 +11669,9 @@ function RichEditorDropZone(props) {
11540
11669
  e.preventDefault();
11541
11670
  counterRef.current = 0;
11542
11671
  setIsDragging(false);
11672
+ if (e.nativeEvent[RICH_EDITOR_DROP_HANDLED]) return;
11673
+ const files = Array.from(e.dataTransfer.files ?? []);
11674
+ if (files.length > 0) onDropFiles?.(files);
11543
11675
  };
11544
11676
  return /* @__PURE__ */ jsxs(
11545
11677
  "div",
@@ -11703,8 +11835,10 @@ var RichEditor = forwardRef(function RichEditor2({
11703
11835
  editable = true,
11704
11836
  autofocus,
11705
11837
  fileFormat,
11838
+ maxFiles,
11706
11839
  onFileUpload,
11707
- renderFilePreview
11840
+ renderFilePreview,
11841
+ fileCountUIRender
11708
11842
  }, ref) {
11709
11843
  const showToolbar = toolbar !== false;
11710
11844
  const toolbarOptions = typeof toolbar === "object" ? toolbar : {};
@@ -11724,6 +11858,7 @@ var RichEditor = forwardRef(function RichEditor2({
11724
11858
  const {
11725
11859
  editor,
11726
11860
  attachments,
11861
+ attachmentCount,
11727
11862
  removeAttachment,
11728
11863
  hydrateAttachments,
11729
11864
  processFiles,
@@ -11746,6 +11881,7 @@ var RichEditor = forwardRef(function RichEditor2({
11746
11881
  autofocus,
11747
11882
  editorClassName,
11748
11883
  fileFormat,
11884
+ maxFiles,
11749
11885
  onFileUpload,
11750
11886
  onChange: handleChange,
11751
11887
  onSubmit
@@ -11795,10 +11931,11 @@ var RichEditor = forwardRef(function RichEditor2({
11795
11931
  ...accentColor ? { "--rich-editor-accent-bg": accentColor } : {},
11796
11932
  ...accentTextColor ? { "--rich-editor-accent-text": accentTextColor } : {}
11797
11933
  };
11798
- return /* @__PURE__ */ jsx(RichEditorThemeProvider, { value: resolvedTheme, children: /* @__PURE__ */ jsxs(
11934
+ const showFileCountUI = imageFeatureEnabled && !!fileCountUIRender;
11935
+ const editorBox = /* @__PURE__ */ jsxs(
11799
11936
  "div",
11800
11937
  {
11801
- className: cn("overflow-hidden rounded-lg border border-gray-200 shadow-sm flex flex-col relative", className),
11938
+ className: cn("overflow-clip rounded-lg border border-gray-200 shadow-sm flex flex-col relative", className),
11802
11939
  "data-rich-editor-theme": theme,
11803
11940
  style: accentStyle,
11804
11941
  children: [
@@ -11826,7 +11963,7 @@ var RichEditor = forwardRef(function RichEditor2({
11826
11963
  }
11827
11964
  }
11828
11965
  ),
11829
- imageFeatureEnabled ? /* @__PURE__ */ jsxs(RichEditorDropZone, { className: "flex flex-1 flex-col", "data-rich-editor-theme": theme, children: [
11966
+ imageFeatureEnabled ? /* @__PURE__ */ jsxs(RichEditorDropZone, { className: "flex flex-1 flex-col", "data-rich-editor-theme": theme, onDropFiles: processFiles, children: [
11830
11967
  /* @__PURE__ */ jsx(
11831
11968
  RichEditorContent,
11832
11969
  {
@@ -11856,7 +11993,16 @@ var RichEditor = forwardRef(function RichEditor2({
11856
11993
  )
11857
11994
  ]
11858
11995
  }
11859
- ) });
11996
+ );
11997
+ return /* @__PURE__ */ jsx(RichEditorThemeProvider, { value: resolvedTheme, children: showFileCountUI ? (
11998
+ // 바깥에 position: relative 한 단만 더 둬서, fileCountUIRender가 돌려주는 요소가
11999
+ // absolute 포지션이면 에디터 박스 기준으로 겹쳐 뜨고, 일반 요소면 박스 바로 아래
12000
+ // 자연스러운 흐름으로 이어진다 — 호출부가 className 하나로 두 경우를 모두 고를 수 있다.
12001
+ /* @__PURE__ */ jsxs("div", { className: "relative", children: [
12002
+ editorBox,
12003
+ fileCountUIRender({ count: attachmentCount, max: maxFiles })
12004
+ ] })
12005
+ ) : editorBox });
11860
12006
  });
11861
12007
  var RichEditor_default = RichEditor;
11862
12008
  function useDetailController(params = {}) {