@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.cjs CHANGED
@@ -96,7 +96,12 @@ var buttonVariants = classVarianceAuthority.cva(
96
96
  accent: "btn-grad text-white rounded-full",
97
97
  metal: "btn-metal text-white min-w-22",
98
98
  ghost: "p-1 h-auto rounded-sm bg-transparent text-sub-darkgray transition-colors hover:bg-gray-100",
99
- link: "bg-transparent border-none text-main-blue underline-offset-4 hover:underline h-auto p-0"
99
+ link: "bg-transparent border-none text-main-blue underline-offset-4 hover:underline h-auto p-0",
100
+ // inkstone: 흑백 미니멀. 색은 --fz-ink-* 변수(styles/inkstone.css)에서 읽는다.
101
+ 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)]",
102
+ "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)]",
103
+ "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)]",
104
+ "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))]"
100
105
  },
101
106
  size: {
102
107
  default: "h-8 px-4 font-semibold",
@@ -3818,6 +3823,15 @@ var VARIANT_CONFIG = {
3818
3823
  titleColor: "text-slate-100",
3819
3824
  descColor: "text-slate-400",
3820
3825
  closeBtn: "text-slate-500 group-hover:text-slate-300"
3826
+ },
3827
+ // inkstone: 흰 바탕에 아래 테두리만. 아이콘은 회색 네모 칸 안의 먹색.
3828
+ inkstone: {
3829
+ container: "bg-[var(--fz-ink-surface)] border-[var(--fz-ink-line)]",
3830
+ iconBg: "bg-[var(--fz-ink-soft)] rounded-[2px]",
3831
+ iconColor: "text-[var(--fz-ink-text)]",
3832
+ titleColor: "text-[var(--fz-ink-text)]",
3833
+ descColor: "text-[var(--fz-ink-text-tertiary)]",
3834
+ closeBtn: "text-[var(--fz-ink-text-tertiary)] group-hover:text-[var(--fz-ink-text)]"
3821
3835
  }
3822
3836
  };
3823
3837
  var SIZE_CONFIG = {
@@ -5057,7 +5071,8 @@ function Table(props) {
5057
5071
  tooltipConfig = "overflow",
5058
5072
  isDynamicHeight = true,
5059
5073
  showHorizontalDivider = true,
5060
- showVerticalDivider = true
5074
+ showVerticalDivider = true,
5075
+ variant = "default"
5061
5076
  } = props;
5062
5077
  const {
5063
5078
  fixed = false,
@@ -5537,82 +5552,89 @@ function Table(props) {
5537
5552
  const rest = baseRows.filter((row) => !effectiveRowOrder.includes(String(getRowKey(row.original, row.index))));
5538
5553
  return [...ordered, ...rest];
5539
5554
  }, [baseRows, effectiveRowOrder, getRowKey]);
5540
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-white rounded shadow-table border border-gray-200 overflow-hidden", children: [
5541
- /* @__PURE__ */ jsxRuntime.jsx(
5542
- "div",
5543
- {
5544
- id: "table-layout",
5545
- ref: scrollRef,
5546
- className: "relative w-full overflow-y-auto overflow-x-auto custom-view-scrollbar bg-white",
5547
- style: { height: `${tableHeight}px` },
5548
- children: /* @__PURE__ */ jsxRuntime.jsxs(
5549
- "table",
5555
+ return /* @__PURE__ */ jsxRuntime.jsxs(
5556
+ "div",
5557
+ {
5558
+ className: "bg-white rounded shadow-table border border-gray-200 overflow-hidden",
5559
+ "data-fz-table-variant": variant,
5560
+ children: [
5561
+ /* @__PURE__ */ jsxRuntime.jsx(
5562
+ "div",
5550
5563
  {
5551
- className: `table-fixed border-spacing-0${tableMinWidth === void 0 ? " w-full" : ""}`,
5552
- style: tableMinWidth !== void 0 ? { width: tableMinWidth, minWidth: tableMinWidth } : {
5553
- minWidth: orderedColumns.reduce(
5554
- (sum, col) => sum + (col.key === "__checkbox__" || col.width !== void 0 ? parseColPx(col) : 80),
5555
- 0
5556
- )
5557
- },
5558
- children: [
5559
- /* @__PURE__ */ jsxRuntime.jsx(
5560
- TableHeader,
5561
- {
5562
- columns: orderedColumns,
5563
- getAlignStyle,
5564
- sortOption,
5565
- onSortChange,
5566
- onColumnDragStartCapture: handleColumnDragStartCapture,
5567
- onColumnDragStart: handleColumnDragStart,
5568
- onColumnDrop: handleColumnDrop,
5569
- onColumnDragEnd: handleColumnDragEnd,
5570
- onColumnDragOver: handleColumnDragOver,
5571
- isColumnDraggable
5572
- }
5573
- ),
5574
- /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "w-full h-full", children: showSkeleton ? Array.from({ length: 3 }).map((_, rowIdx) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { className: "hover:bg-gray-50", children: [
5575
- leadingPinnedCols.map((col, idx) => /* @__PURE__ */ jsxRuntime.jsx(SkeletonTd, { col, showSquare: idx === 0 && !!checkboxInfo }, `leading-${idx}`)),
5576
- leftColspan > 0 && /* @__PURE__ */ jsxRuntime.jsx("td", { colSpan: leftColspan, style: { padding: 0, border: "none" } }),
5577
- virtualItems.map((vc) => /* @__PURE__ */ jsxRuntime.jsx(SkeletonTd, { col: groupCols[vc.index] }, `group-${vc.index}`)),
5578
- rightColspan > 0 && /* @__PURE__ */ jsxRuntime.jsx("td", { colSpan: rightColspan, style: { padding: 0, border: "none" } }),
5579
- trailingPinnedCols.map((col, idx) => /* @__PURE__ */ jsxRuntime.jsx(SkeletonTd, { col }, `trailing-${idx}`))
5580
- ] }, rowIdx)) : showEmpty ? /* @__PURE__ */ jsxRuntime.jsx(TableEmpty, { columnCount: allColumns.length }) : rows.map((row) => {
5581
- const rowId = String(getRowKey(row.original, row.index));
5582
- return /* @__PURE__ */ jsxRuntime.jsx(
5583
- TableDataRow,
5584
- {
5585
- record: row.original,
5586
- rowIdx: row.index,
5587
- rowId,
5588
- draggable: rowDraggable && !showSkeleton,
5589
- onDragStart: handleRowDragStart,
5590
- onDragOver: handleRowDragOver,
5591
- onDrop: handleRowDrop,
5592
- onDragEnd: handleRowDragEnd,
5593
- leftColspan,
5594
- rightColspan,
5595
- renderLeadingPinnedCols,
5596
- renderVisibleGroupCols,
5597
- renderTrailingPinnedCols
5598
- },
5599
- row.id
5600
- );
5601
- }) })
5602
- ]
5564
+ id: "table-layout",
5565
+ ref: scrollRef,
5566
+ className: "relative w-full overflow-y-auto overflow-x-auto custom-view-scrollbar bg-white",
5567
+ style: { height: `${tableHeight}px` },
5568
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
5569
+ "table",
5570
+ {
5571
+ className: `table-fixed border-spacing-0${tableMinWidth === void 0 ? " w-full" : ""}`,
5572
+ style: tableMinWidth !== void 0 ? { width: tableMinWidth, minWidth: tableMinWidth } : {
5573
+ minWidth: orderedColumns.reduce(
5574
+ (sum, col) => sum + (col.key === "__checkbox__" || col.width !== void 0 ? parseColPx(col) : 80),
5575
+ 0
5576
+ )
5577
+ },
5578
+ children: [
5579
+ /* @__PURE__ */ jsxRuntime.jsx(
5580
+ TableHeader,
5581
+ {
5582
+ columns: orderedColumns,
5583
+ getAlignStyle,
5584
+ sortOption,
5585
+ onSortChange,
5586
+ onColumnDragStartCapture: handleColumnDragStartCapture,
5587
+ onColumnDragStart: handleColumnDragStart,
5588
+ onColumnDrop: handleColumnDrop,
5589
+ onColumnDragEnd: handleColumnDragEnd,
5590
+ onColumnDragOver: handleColumnDragOver,
5591
+ isColumnDraggable
5592
+ }
5593
+ ),
5594
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "w-full h-full", children: showSkeleton ? Array.from({ length: 3 }).map((_, rowIdx) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { className: "hover:bg-gray-50", children: [
5595
+ leadingPinnedCols.map((col, idx) => /* @__PURE__ */ jsxRuntime.jsx(SkeletonTd, { col, showSquare: idx === 0 && !!checkboxInfo }, `leading-${idx}`)),
5596
+ leftColspan > 0 && /* @__PURE__ */ jsxRuntime.jsx("td", { colSpan: leftColspan, style: { padding: 0, border: "none" } }),
5597
+ virtualItems.map((vc) => /* @__PURE__ */ jsxRuntime.jsx(SkeletonTd, { col: groupCols[vc.index] }, `group-${vc.index}`)),
5598
+ rightColspan > 0 && /* @__PURE__ */ jsxRuntime.jsx("td", { colSpan: rightColspan, style: { padding: 0, border: "none" } }),
5599
+ trailingPinnedCols.map((col, idx) => /* @__PURE__ */ jsxRuntime.jsx(SkeletonTd, { col }, `trailing-${idx}`))
5600
+ ] }, rowIdx)) : showEmpty ? /* @__PURE__ */ jsxRuntime.jsx(TableEmpty, { columnCount: allColumns.length }) : rows.map((row) => {
5601
+ const rowId = String(getRowKey(row.original, row.index));
5602
+ return /* @__PURE__ */ jsxRuntime.jsx(
5603
+ TableDataRow,
5604
+ {
5605
+ record: row.original,
5606
+ rowIdx: row.index,
5607
+ rowId,
5608
+ draggable: rowDraggable && !showSkeleton,
5609
+ onDragStart: handleRowDragStart,
5610
+ onDragOver: handleRowDragOver,
5611
+ onDrop: handleRowDrop,
5612
+ onDragEnd: handleRowDragEnd,
5613
+ leftColspan,
5614
+ rightColspan,
5615
+ renderLeadingPinnedCols,
5616
+ renderVisibleGroupCols,
5617
+ renderTrailingPinnedCols
5618
+ },
5619
+ row.id
5620
+ );
5621
+ }) })
5622
+ ]
5623
+ }
5624
+ )
5603
5625
  }
5604
- )
5605
- }
5606
- ),
5607
- !showSkeleton && (paginationInfo || renderFooter?.renderLeft || renderFooter?.renderRight) && /* @__PURE__ */ jsxRuntime.jsx("div", { ref: footerRef, children: /* @__PURE__ */ jsxRuntime.jsx(
5608
- TableFooter,
5609
- {
5610
- paginationInfo,
5611
- renderLeft: renderFooter?.renderLeft,
5612
- renderRight: renderFooter?.renderRight
5613
- }
5614
- ) })
5615
- ] });
5626
+ ),
5627
+ !showSkeleton && (paginationInfo || renderFooter?.renderLeft || renderFooter?.renderRight) && /* @__PURE__ */ jsxRuntime.jsx("div", { ref: footerRef, children: /* @__PURE__ */ jsxRuntime.jsx(
5628
+ TableFooter,
5629
+ {
5630
+ paginationInfo,
5631
+ renderLeft: renderFooter?.renderLeft,
5632
+ renderRight: renderFooter?.renderRight
5633
+ }
5634
+ ) })
5635
+ ]
5636
+ }
5637
+ );
5616
5638
  }
5617
5639
  var CarouselContext = React6__namespace.createContext(null);
5618
5640
  function useCarousel() {
@@ -8352,6 +8374,26 @@ var VARIANT_STYLES = {
8352
8374
  tabTextSize: "text-sm",
8353
8375
  scrollPadding: "px-4 pt-2",
8354
8376
  rounded: "rounded-t-none"
8377
+ },
8378
+ // inkstone: 흑백 미니멀. 선택된 탭만 먹(검정) 바탕에 흰 글자, 나머지는 흰 바탕 + 회색 테두리.
8379
+ inkstone: {
8380
+ container: "bg-[var(--fz-ink-canvas)]",
8381
+ activeTab: "bg-[var(--fz-ink)] border-[var(--fz-ink)] text-[var(--fz-ink-contrast)]",
8382
+ 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)]",
8383
+ activeText: "font-bold text-[var(--fz-ink-contrast)]",
8384
+ inactiveText: "font-medium",
8385
+ indicator: "bg-transparent",
8386
+ closeBtn: "ml-auto rounded-[2px] opacity-60 hover:opacity-100 hover:bg-[color-mix(in_srgb,currentColor_18%,transparent)]",
8387
+ closeBtnWH: "w-4 h-4",
8388
+ closeBtnSize: 12,
8389
+ plusBtnArea: "bg-[var(--fz-ink-canvas)]",
8390
+ plusBtn: "text-[var(--fz-ink-text-tertiary)] hover:text-[var(--fz-ink-text)] hover:bg-[var(--fz-ink-soft)]",
8391
+ fadeOpacity: 0.12,
8392
+ tabHeight: "h-[30px]",
8393
+ tabPx: "px-3",
8394
+ tabTextSize: "text-xs",
8395
+ scrollPadding: "px-2 pt-2",
8396
+ rounded: "rounded-t-[2px]"
8355
8397
  }
8356
8398
  };
8357
8399
  var PLUS_BTN_WIDTH = 36;
@@ -9370,7 +9412,7 @@ function BaseUploader(props) {
9370
9412
  const errors = [];
9371
9413
  for (const file of incoming) {
9372
9414
  if (!checkAccept(file, accept)) {
9373
- errors.push(`${file.name}: \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uB294 \uD30C\uC77C \uD615\uC2DD`);
9415
+ errors.push(`${file.name}: \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uB294 \uD30C\uC77C \uD615\uC2DD\uC785\uB2C8\uB2E4.`);
9374
9416
  continue;
9375
9417
  }
9376
9418
  if (maxSize && file.size > maxSize) {
@@ -9944,6 +9986,34 @@ var VARIANT_STYLES2 = {
9944
9986
  paddingLeft: "10px"
9945
9987
  },
9946
9988
  footerBorder: "border-t border-gray-200"
9989
+ },
9990
+ // inkstone: 흑백 미니멀. 현재 메뉴는 회색 바탕 + 굵은 글자로만 표시하고 색 띠를 두지 않는다.
9991
+ inkstone: {
9992
+ aside: "bg-[var(--fz-ink-canvas)]",
9993
+ sectionTitle: "text-[11px] font-medium text-[var(--fz-ink-text-tertiary)] mb-1 px-2",
9994
+ itemActive: "font-bold",
9995
+ itemInactive: "text-[var(--fz-ink-text)] hover:bg-[var(--fz-ink-soft)]",
9996
+ subItemActive: "text-[var(--fz-ink-text)] font-bold",
9997
+ subItemInactive: "text-[var(--fz-ink-text-secondary)] hover:bg-[var(--fz-ink-soft)] hover:text-[var(--fz-ink-text)]",
9998
+ childGroupBorder: "border-[var(--fz-ink-line)]",
9999
+ childActive: "font-bold",
10000
+ childInactive: "text-[var(--fz-ink-text-secondary)] hover:bg-[var(--fz-ink-soft)] hover:text-[var(--fz-ink-text)]",
10001
+ grandchildActive: "text-[var(--fz-ink-text)] font-bold",
10002
+ grandchildInactive: "text-[var(--fz-ink-text-tertiary)] hover:bg-[var(--fz-ink-soft)] hover:text-[var(--fz-ink-text)]",
10003
+ collapseBtn: "bg-transparent hover:bg-[var(--fz-ink-soft)]",
10004
+ collapseIcon: "#525252",
10005
+ rounded: "rounded-[2px]",
10006
+ itemPy: "py-2",
10007
+ childPy: "py-1.5",
10008
+ grandchildPy: "py-1",
10009
+ itemFont: "font-medium",
10010
+ itemTextSize: "text-[13px]",
10011
+ grandchildTextSize: "text-xs",
10012
+ iconClass: "w-4 h-4 flex-shrink-0",
10013
+ activeItemStyle: { color: "var(--fz-ink-text)", backgroundColor: "var(--fz-ink-soft)" },
10014
+ activeChildStyle: { color: "var(--fz-ink-text)", backgroundColor: "var(--fz-ink-soft)" },
10015
+ activeGrandchildStyle: { color: "var(--fz-ink-text)", backgroundColor: "var(--fz-ink-soft)" },
10016
+ footerBorder: "border-t border-[var(--fz-ink-line)]"
9947
10017
  }
9948
10018
  };
9949
10019
  function tintedStyle(color) {
@@ -10012,6 +10082,13 @@ var ACCENT_APPLIERS = {
10012
10082
  borderLeft: `2px solid ${c}`,
10013
10083
  paddingLeft: "10px"
10014
10084
  })
10085
+ },
10086
+ // inkstone keeps its flat grey highlight; a primaryColor only tints it, with no side bar.
10087
+ inkstone: {
10088
+ itemActive: tintedStyle,
10089
+ subItemActive: textStyle,
10090
+ childActive: tintedStyle,
10091
+ grandchildActive: textStyle
10015
10092
  }
10016
10093
  };
10017
10094
  function Sidebar(props) {
@@ -10025,6 +10102,7 @@ function Sidebar(props) {
10025
10102
  showCollapseButton = false,
10026
10103
  collapseButtonPlacement = "right",
10027
10104
  variant = "light",
10105
+ width,
10028
10106
  primaryColor
10029
10107
  } = props;
10030
10108
  const { pathname } = reactRouter.useLocation();
@@ -10102,12 +10180,13 @@ function Sidebar(props) {
10102
10180
  "aside",
10103
10181
  {
10104
10182
  className: `
10105
- ${isCollapsed ? "w-11 min-w-11" : "min-w-60 w-62"}
10183
+ ${isCollapsed ? "w-11 min-w-11" : width === void 0 ? "min-w-60 w-62" : ""}
10106
10184
  transition-[width,min-width] duration-300 ease-in-out
10107
10185
  relative h-screen shrink-0 overflow-x-hidden flex flex-col
10108
10186
  ${s.aside}
10109
10187
  ${className ?? ""}
10110
10188
  `,
10189
+ style: !isCollapsed && width !== void 0 ? { width, minWidth: width } : void 0,
10111
10190
  children: [
10112
10191
  showCollapseButton && !isHeaderRenderProp && /* @__PURE__ */ jsxRuntime.jsx(
10113
10192
  "button",
@@ -10121,147 +10200,154 @@ function Sidebar(props) {
10121
10200
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: `flex-1 min-h-0 hide-scrollbar ${overflowVisible ? "overflow-y-auto" : "overflow-hidden"}`, children: /* @__PURE__ */ jsxRuntime.jsxs(
10122
10201
  "div",
10123
10202
  {
10124
- 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"}`,
10203
+ 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"}`,
10125
10204
  style: { transitionDelay: isCollapsed ? "0ms" : "150ms" },
10126
10205
  children: [
10127
10206
  !isHeaderRenderProp && headerContent,
10128
- /* @__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: [
10129
- section.title && /* @__PURE__ */ jsxRuntime.jsx("div", { className: s.sectionTitle, children: section.title }),
10130
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-0.5", children: section.items.map((item) => {
10131
- const isActive = !item.children && pathname === item.path;
10132
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
10133
- /* @__PURE__ */ jsxRuntime.jsxs(
10134
- "button",
10135
- {
10136
- onClick: () => {
10137
- if (item.children) {
10138
- toggleExpand(item.label);
10139
- } else if (item.path) {
10140
- handleItemClick(item.path);
10141
- }
10142
- },
10143
- className: `
10207
+ /* @__PURE__ */ jsxRuntime.jsx(
10208
+ "nav",
10209
+ {
10210
+ className: `${variant === "inkstone" ? "space-y-4 px-2" : "space-y-6"} ${variant === "system-dark" || variant === "system-light" ? "px-1" : ""}`,
10211
+ children: menuSections.map((section, sectionIndex) => /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
10212
+ section.title && /* @__PURE__ */ jsxRuntime.jsx("div", { className: s.sectionTitle, children: section.title }),
10213
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-0.5", children: section.items.map((item) => {
10214
+ const isActive = !item.children && pathname === item.path;
10215
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
10216
+ /* @__PURE__ */ jsxRuntime.jsxs(
10217
+ "button",
10218
+ {
10219
+ onClick: () => {
10220
+ if (item.children) {
10221
+ toggleExpand(item.label);
10222
+ } else if (item.path) {
10223
+ handleItemClick(item.path);
10224
+ }
10225
+ },
10226
+ className: `
10144
10227
  w-full text-left flex items-center gap-2 px-3 ${s.itemPy} ${s.rounded} ${s.itemTextSize} ${s.itemFont} transition-colors cursor-pointer
10145
10228
  ${isActive ? s.itemActive : s.itemInactive}
10146
10229
  `,
10147
- style: {
10148
- ...isActive ? s.activeItemStyle : {},
10149
- ...isActive && primaryColor ? applier.itemActive(primaryColor) : {}
10150
- },
10151
- children: [
10152
- /* @__PURE__ */ jsxRuntime.jsx(item.icon, { className: s.iconClass }),
10153
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-1", children: item.label }),
10154
- item.children && /* @__PURE__ */ jsxRuntime.jsx(
10155
- "svg",
10156
- {
10157
- className: `w-4 h-4 transition-transform ${expandedItems.has(item.label) ? "rotate-90" : ""}`,
10158
- fill: "none",
10159
- stroke: "currentColor",
10160
- viewBox: "0 0 24 24",
10161
- children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 5l7 7-7 7" })
10162
- }
10163
- ),
10164
- item.path?.includes("https") && /* @__PURE__ */ jsxRuntime.jsx(
10165
- "svg",
10166
- {
10167
- className: "w-4 h-4 flex-shrink-0 opacity-50",
10168
- fill: "none",
10169
- stroke: "currentColor",
10170
- viewBox: "0 0 24 24",
10171
- children: /* @__PURE__ */ jsxRuntime.jsx(
10172
- "path",
10230
+ style: {
10231
+ ...isActive ? s.activeItemStyle : {},
10232
+ ...isActive && primaryColor ? applier.itemActive(primaryColor) : {}
10233
+ },
10234
+ children: [
10235
+ /* @__PURE__ */ jsxRuntime.jsx(item.icon, { className: s.iconClass }),
10236
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: `flex-1 ${variant === "inkstone" ? "min-w-0 truncate text-left" : ""}`, children: item.label }),
10237
+ item.badge !== void 0 && item.badge !== null && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "shrink-0 text-xs font-medium opacity-60", children: item.badge }),
10238
+ item.children && /* @__PURE__ */ jsxRuntime.jsx(
10239
+ "svg",
10240
+ {
10241
+ className: `w-4 h-4 transition-transform ${expandedItems.has(item.label) ? "rotate-90" : ""}`,
10242
+ fill: "none",
10243
+ stroke: "currentColor",
10244
+ viewBox: "0 0 24 24",
10245
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 5l7 7-7 7" })
10246
+ }
10247
+ ),
10248
+ item.path?.includes("https") && /* @__PURE__ */ jsxRuntime.jsx(
10249
+ "svg",
10173
10250
  {
10174
- strokeLinecap: "round",
10175
- strokeLinejoin: "round",
10176
- strokeWidth: 2,
10177
- d: "M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"
10251
+ className: "w-4 h-4 flex-shrink-0 opacity-50",
10252
+ fill: "none",
10253
+ stroke: "currentColor",
10254
+ viewBox: "0 0 24 24",
10255
+ children: /* @__PURE__ */ jsxRuntime.jsx(
10256
+ "path",
10257
+ {
10258
+ strokeLinecap: "round",
10259
+ strokeLinejoin: "round",
10260
+ strokeWidth: 2,
10261
+ d: "M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"
10262
+ }
10263
+ )
10178
10264
  }
10179
10265
  )
10180
- }
10181
- )
10182
- ]
10183
- }
10184
- ),
10185
- item.children && expandedItems.has(item.label) && /* @__PURE__ */ jsxRuntime.jsx("div", { className: `ml-5 mt-0.5 space-y-0.5 border-l ${s.childGroupBorder}`, children: item.children.map((child, childIndex) => {
10186
- if (child.children && child.children.length > 0) {
10187
- const subKey = `${item.label}::${child.label}`;
10188
- const isSubExpanded = expandedSubItems.has(subKey);
10189
- const isSubActive = child.children.some((gc) => gc.path === pathname);
10190
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
10191
- /* @__PURE__ */ jsxRuntime.jsxs(
10192
- "button",
10193
- {
10194
- onClick: () => toggleSubExpand(subKey),
10195
- className: `
10266
+ ]
10267
+ }
10268
+ ),
10269
+ item.children && expandedItems.has(item.label) && /* @__PURE__ */ jsxRuntime.jsx("div", { className: `ml-5 mt-0.5 space-y-0.5 border-l ${s.childGroupBorder}`, children: item.children.map((child, childIndex) => {
10270
+ if (child.children && child.children.length > 0) {
10271
+ const subKey = `${item.label}::${child.label}`;
10272
+ const isSubExpanded = expandedSubItems.has(subKey);
10273
+ const isSubActive = child.children.some((gc) => gc.path === pathname);
10274
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
10275
+ /* @__PURE__ */ jsxRuntime.jsxs(
10276
+ "button",
10277
+ {
10278
+ onClick: () => toggleSubExpand(subKey),
10279
+ className: `
10196
10280
  w-full text-left flex items-center justify-between pl-4 pr-3 ${s.childPy} ${s.rounded} ${s.itemTextSize} transition-colors cursor-pointer
10197
10281
  ${isSubActive ? s.subItemActive : s.subItemInactive}
10198
10282
  `,
10199
- style: isSubActive && primaryColor ? applier.subItemActive(primaryColor) : void 0,
10200
- children: [
10201
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: child.label }),
10202
- /* @__PURE__ */ jsxRuntime.jsx(
10203
- "svg",
10204
- {
10205
- className: `w-3 h-3 transition-transform ${isSubExpanded ? "rotate-90" : ""}`,
10206
- fill: "none",
10207
- stroke: "currentColor",
10208
- viewBox: "0 0 24 24",
10209
- children: /* @__PURE__ */ jsxRuntime.jsx(
10210
- "path",
10283
+ style: isSubActive && primaryColor ? applier.subItemActive(primaryColor) : void 0,
10284
+ children: [
10285
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: child.label }),
10286
+ /* @__PURE__ */ jsxRuntime.jsx(
10287
+ "svg",
10211
10288
  {
10212
- strokeLinecap: "round",
10213
- strokeLinejoin: "round",
10214
- strokeWidth: 2,
10215
- d: "M9 5l7 7-7 7"
10289
+ className: `w-3 h-3 transition-transform ${isSubExpanded ? "rotate-90" : ""}`,
10290
+ fill: "none",
10291
+ stroke: "currentColor",
10292
+ viewBox: "0 0 24 24",
10293
+ children: /* @__PURE__ */ jsxRuntime.jsx(
10294
+ "path",
10295
+ {
10296
+ strokeLinecap: "round",
10297
+ strokeLinejoin: "round",
10298
+ strokeWidth: 2,
10299
+ d: "M9 5l7 7-7 7"
10300
+ }
10301
+ )
10216
10302
  }
10217
10303
  )
10218
- }
10219
- )
10220
- ]
10221
- }
10222
- ),
10223
- isSubExpanded && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-3 mt-0.5 space-y-0.5 pl-2", children: child.children.map((grandchild) => {
10224
- const isGrandchildActive = pathname === grandchild.path;
10225
- return /* @__PURE__ */ jsxRuntime.jsx(
10226
- "button",
10227
- {
10228
- onClick: () => handleItemClick(grandchild.path),
10229
- className: `
10304
+ ]
10305
+ }
10306
+ ),
10307
+ isSubExpanded && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-3 mt-0.5 space-y-0.5 pl-2", children: child.children.map((grandchild) => {
10308
+ const isGrandchildActive = pathname === grandchild.path;
10309
+ return /* @__PURE__ */ jsxRuntime.jsx(
10310
+ "button",
10311
+ {
10312
+ onClick: () => handleItemClick(grandchild.path),
10313
+ className: `
10230
10314
  w-full text-left px-3 ${s.grandchildPy} ${s.rounded} ${s.grandchildTextSize} transition-colors cursor-pointer
10231
10315
  ${isGrandchildActive ? s.grandchildActive : s.grandchildInactive}
10232
10316
  `,
10233
- style: {
10234
- ...isGrandchildActive ? s.activeGrandchildStyle : {},
10235
- ...isGrandchildActive && primaryColor ? applier.grandchildActive(primaryColor) : {}
10236
- },
10237
- children: grandchild.label
10238
- },
10239
- grandchild.path
10240
- );
10241
- }) })
10242
- ] }, child.label);
10243
- }
10244
- const isChildActive = pathname === child.path;
10245
- return /* @__PURE__ */ jsxRuntime.jsx(
10246
- "button",
10247
- {
10248
- onClick: () => handleItemClick(child.path ?? ""),
10249
- className: `
10317
+ style: {
10318
+ ...isGrandchildActive ? s.activeGrandchildStyle : {},
10319
+ ...isGrandchildActive && primaryColor ? applier.grandchildActive(primaryColor) : {}
10320
+ },
10321
+ children: grandchild.label
10322
+ },
10323
+ grandchild.path
10324
+ );
10325
+ }) })
10326
+ ] }, child.label);
10327
+ }
10328
+ const isChildActive = pathname === child.path;
10329
+ return /* @__PURE__ */ jsxRuntime.jsx(
10330
+ "button",
10331
+ {
10332
+ onClick: () => handleItemClick(child.path ?? ""),
10333
+ className: `
10250
10334
  w-full text-left pl-4 pr-3 ${s.childPy} ${s.rounded} ${s.itemTextSize} transition-colors cursor-pointer
10251
10335
  ${isChildActive ? s.childActive : s.childInactive}
10252
10336
  `,
10253
- style: {
10254
- ...isChildActive ? s.activeChildStyle : {},
10255
- ...isChildActive && primaryColor ? applier.childActive(primaryColor) : {}
10256
- },
10257
- children: child.label
10258
- },
10259
- childIndex
10260
- );
10337
+ style: {
10338
+ ...isChildActive ? s.activeChildStyle : {},
10339
+ ...isChildActive && primaryColor ? applier.childActive(primaryColor) : {}
10340
+ },
10341
+ children: child.label
10342
+ },
10343
+ childIndex
10344
+ );
10345
+ }) })
10346
+ ] }, item.label);
10261
10347
  }) })
10262
- ] }, item.label);
10263
- }) })
10264
- ] }, section.title ?? sectionIndex)) })
10348
+ ] }, section.title ?? sectionIndex))
10349
+ }
10350
+ )
10265
10351
  ]
10266
10352
  }
10267
10353
  ) }),
@@ -10730,20 +10816,24 @@ function createPasteHandler(processFilesRef) {
10730
10816
  return true;
10731
10817
  };
10732
10818
  }
10819
+ var RICH_EDITOR_DROP_HANDLED = "__richEditorDropHandled";
10733
10820
  function createDropHandler(processFilesRef) {
10734
10821
  return (_view, event) => {
10735
10822
  const files = Array.from(event.dataTransfer?.files ?? []);
10736
10823
  if (files.length === 0) return false;
10737
10824
  event.preventDefault();
10825
+ event[RICH_EDITOR_DROP_HANDLED] = true;
10738
10826
  processFilesRef.current(files);
10739
10827
  return true;
10740
10828
  };
10741
10829
  }
10830
+
10831
+ // src/lib/fileFormat.ts
10742
10832
  var FORMAT_EXT_ALIASES = {
10743
10833
  JPG: ["jpg", "jpeg"],
10744
10834
  JPEG: ["jpg", "jpeg"]
10745
10835
  };
10746
- function expandFormats(fileFormat) {
10836
+ function expandFileFormats(fileFormat) {
10747
10837
  const exts = /* @__PURE__ */ new Set();
10748
10838
  for (const format of fileFormat) {
10749
10839
  const key = format.toUpperCase();
@@ -10752,16 +10842,30 @@ function expandFormats(fileFormat) {
10752
10842
  }
10753
10843
  return exts;
10754
10844
  }
10755
- function extOf(fileName) {
10845
+ function getFileExtension(fileName) {
10756
10846
  return fileName.split(".").pop()?.toLowerCase() ?? "";
10757
10847
  }
10758
10848
  function buildAcceptAttribute(fileFormat) {
10759
10849
  if (!fileFormat || fileFormat.length === 0) return void 0;
10760
- return Array.from(expandFormats(fileFormat)).map((ext) => `.${ext}`).join(",");
10850
+ return Array.from(expandFileFormats(fileFormat)).map((ext) => `.${ext}`).join(",");
10851
+ }
10852
+ function splitFilesByFormat(files, fileFormat) {
10853
+ if (!fileFormat || fileFormat.length === 0) return { accepted: [...files], rejected: [] };
10854
+ const allowedExts = expandFileFormats(fileFormat);
10855
+ const accepted = [];
10856
+ const rejected = [];
10857
+ for (const file of files) {
10858
+ (allowedExts.has(getFileExtension(file.name)) ? accepted : rejected).push(file);
10859
+ }
10860
+ return { accepted, rejected };
10761
10861
  }
10862
+
10863
+ // src/components/RichEditor/hooks/useRichEditorFiles.ts
10762
10864
  function useRichEditorFiles(options = {}) {
10763
- const { fileFormat, onFileUpload, initialAttachments } = options;
10865
+ const { fileFormat, maxFiles, onFileUpload, initialAttachments } = options;
10764
10866
  const [attachments, setAttachments] = React6.useState(() => initialAttachments ?? []);
10867
+ const attachmentsRef = React6.useRef(attachments);
10868
+ attachmentsRef.current = attachments;
10765
10869
  const [isUploading, setIsUploading] = React6.useState(false);
10766
10870
  const removeAttachment = React6.useCallback((id) => {
10767
10871
  setAttachments((prev) => prev.filter((a) => a.id !== id));
@@ -10771,8 +10875,20 @@ function useRichEditorFiles(options = {}) {
10771
10875
  }, []);
10772
10876
  const processFiles = React6.useCallback(
10773
10877
  async (files, editor) => {
10774
- const allowedExts = fileFormat ? expandFormats(fileFormat) : null;
10775
- const accepted = allowedExts ? files.filter((f) => allowedExts.has(extOf(f.name))) : files;
10878
+ const { accepted: splitAccepted, rejected: rejectedByFormat } = splitFilesByFormat(files, fileFormat);
10879
+ let accepted = splitAccepted;
10880
+ if (rejectedByFormat.length > 0) {
10881
+ toast.error("\uD5C8\uC6A9\uB418\uC9C0 \uC54A\uB294 \uD655\uC7A5\uC790\uC785\uB2C8\uB2E4.");
10882
+ }
10883
+ if (maxFiles) {
10884
+ const imageCount = editor ? (editor.getHTML().match(/<img\b/gi) ?? []).length : 0;
10885
+ const currentCount = attachmentsRef.current.length + imageCount;
10886
+ const remaining = Math.max(0, maxFiles - currentCount);
10887
+ if (accepted.length > remaining) {
10888
+ toast.error(`\uD30C\uC77C\uC740 \uCD5C\uB300 ${maxFiles}\uAC1C\uAE4C\uC9C0 \uCCA8\uBD80\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4.`);
10889
+ }
10890
+ accepted = accepted.slice(0, remaining);
10891
+ }
10776
10892
  if (accepted.length === 0) return;
10777
10893
  setIsUploading(true);
10778
10894
  try {
@@ -10805,7 +10921,7 @@ function useRichEditorFiles(options = {}) {
10805
10921
  setIsUploading(false);
10806
10922
  }
10807
10923
  },
10808
- [fileFormat, onFileUpload]
10924
+ [fileFormat, maxFiles, onFileUpload]
10809
10925
  );
10810
10926
  return { attachments, processFiles, removeAttachment, hydrateAttachments, isUploading };
10811
10927
  }
@@ -10880,6 +10996,7 @@ function useRichEditor(options = {}) {
10880
10996
  editorClassName,
10881
10997
  additionalExtensions = [],
10882
10998
  fileFormat,
10999
+ maxFiles,
10883
11000
  onFileUpload,
10884
11001
  onChange,
10885
11002
  onSubmit
@@ -10896,9 +11013,11 @@ function useRichEditor(options = {}) {
10896
11013
  const initialSplit = initialSplitRef.current;
10897
11014
  const { attachments, processFiles, removeAttachment, hydrateAttachments, isUploading } = useRichEditorFiles({
10898
11015
  fileFormat,
11016
+ maxFiles,
10899
11017
  onFileUpload,
10900
11018
  initialAttachments: initialSplit.attachments
10901
11019
  });
11020
+ const [imageCount, setImageCount] = React6.useState(() => (initialSplit.html.match(/<img\b/gi) ?? []).length);
10902
11021
  const attachmentsRef = React6.useRef(attachments);
10903
11022
  attachmentsRef.current = attachments;
10904
11023
  const editorRef = React6.useRef(null);
@@ -10940,6 +11059,15 @@ function useRichEditor(options = {}) {
10940
11059
  }
10941
11060
  });
10942
11061
  editorRef.current = editor;
11062
+ React6.useEffect(() => {
11063
+ if (!editor) return;
11064
+ const sync = () => setImageCount((editor.getHTML().match(/<img\b/gi) ?? []).length);
11065
+ sync();
11066
+ editor.on("transaction", sync);
11067
+ return () => {
11068
+ editor.off("transaction", sync);
11069
+ };
11070
+ }, [editor]);
10943
11071
  React6.useEffect(() => {
10944
11072
  if (!editor) return;
10945
11073
  onChangeRef.current?.(composeRichEditorHtml(editor.getHTML(), attachments));
@@ -10964,6 +11092,7 @@ function useRichEditor(options = {}) {
10964
11092
  },
10965
11093
  isEmpty: editor?.isEmpty ?? true,
10966
11094
  attachments,
11095
+ attachmentCount: imageCount + attachments.length,
10967
11096
  removeAttachment,
10968
11097
  hydrateAttachments,
10969
11098
  processFiles: processFilesRef.current,
@@ -11211,7 +11340,7 @@ function RichEditorToolbar(props) {
11211
11340
  "div",
11212
11341
  {
11213
11342
  className: cn(
11214
- "flex flex-wrap items-center gap-0.5 p-2",
11343
+ "sticky top-0 z-10 flex flex-wrap items-center gap-0.5 p-2",
11215
11344
  theme.toolbar.wrapper,
11216
11345
  className
11217
11346
  ),
@@ -11556,7 +11685,7 @@ function RichEditorToolbar(props) {
11556
11685
  );
11557
11686
  }
11558
11687
  function RichEditorDropZone(props) {
11559
- const { children, className, "data-rich-editor-theme": themeAttr } = props;
11688
+ const { children, className, "data-rich-editor-theme": themeAttr, onDropFiles } = props;
11560
11689
  const theme = useRichEditorTheme();
11561
11690
  const [isDragging, setIsDragging] = React6.useState(false);
11562
11691
  const counterRef = React6.useRef(0);
@@ -11577,6 +11706,9 @@ function RichEditorDropZone(props) {
11577
11706
  e.preventDefault();
11578
11707
  counterRef.current = 0;
11579
11708
  setIsDragging(false);
11709
+ if (e.nativeEvent[RICH_EDITOR_DROP_HANDLED]) return;
11710
+ const files = Array.from(e.dataTransfer.files ?? []);
11711
+ if (files.length > 0) onDropFiles?.(files);
11580
11712
  };
11581
11713
  return /* @__PURE__ */ jsxRuntime.jsxs(
11582
11714
  "div",
@@ -11740,8 +11872,10 @@ var RichEditor = React6.forwardRef(function RichEditor2({
11740
11872
  editable = true,
11741
11873
  autofocus,
11742
11874
  fileFormat,
11875
+ maxFiles,
11743
11876
  onFileUpload,
11744
- renderFilePreview
11877
+ renderFilePreview,
11878
+ fileCountUIRender
11745
11879
  }, ref) {
11746
11880
  const showToolbar = toolbar !== false;
11747
11881
  const toolbarOptions = typeof toolbar === "object" ? toolbar : {};
@@ -11761,6 +11895,7 @@ var RichEditor = React6.forwardRef(function RichEditor2({
11761
11895
  const {
11762
11896
  editor,
11763
11897
  attachments,
11898
+ attachmentCount,
11764
11899
  removeAttachment,
11765
11900
  hydrateAttachments,
11766
11901
  processFiles,
@@ -11783,6 +11918,7 @@ var RichEditor = React6.forwardRef(function RichEditor2({
11783
11918
  autofocus,
11784
11919
  editorClassName,
11785
11920
  fileFormat,
11921
+ maxFiles,
11786
11922
  onFileUpload,
11787
11923
  onChange: handleChange,
11788
11924
  onSubmit
@@ -11832,10 +11968,11 @@ var RichEditor = React6.forwardRef(function RichEditor2({
11832
11968
  ...accentColor ? { "--rich-editor-accent-bg": accentColor } : {},
11833
11969
  ...accentTextColor ? { "--rich-editor-accent-text": accentTextColor } : {}
11834
11970
  };
11835
- return /* @__PURE__ */ jsxRuntime.jsx(RichEditorThemeProvider, { value: resolvedTheme, children: /* @__PURE__ */ jsxRuntime.jsxs(
11971
+ const showFileCountUI = imageFeatureEnabled && !!fileCountUIRender;
11972
+ const editorBox = /* @__PURE__ */ jsxRuntime.jsxs(
11836
11973
  "div",
11837
11974
  {
11838
- className: cn("overflow-hidden rounded-lg border border-gray-200 shadow-sm flex flex-col relative", className),
11975
+ className: cn("overflow-clip rounded-lg border border-gray-200 shadow-sm flex flex-col relative", className),
11839
11976
  "data-rich-editor-theme": theme,
11840
11977
  style: accentStyle,
11841
11978
  children: [
@@ -11863,7 +12000,7 @@ var RichEditor = React6.forwardRef(function RichEditor2({
11863
12000
  }
11864
12001
  }
11865
12002
  ),
11866
- imageFeatureEnabled ? /* @__PURE__ */ jsxRuntime.jsxs(RichEditorDropZone, { className: "flex flex-1 flex-col", "data-rich-editor-theme": theme, children: [
12003
+ imageFeatureEnabled ? /* @__PURE__ */ jsxRuntime.jsxs(RichEditorDropZone, { className: "flex flex-1 flex-col", "data-rich-editor-theme": theme, onDropFiles: processFiles, children: [
11867
12004
  /* @__PURE__ */ jsxRuntime.jsx(
11868
12005
  RichEditorContent,
11869
12006
  {
@@ -11893,7 +12030,16 @@ var RichEditor = React6.forwardRef(function RichEditor2({
11893
12030
  )
11894
12031
  ]
11895
12032
  }
11896
- ) });
12033
+ );
12034
+ return /* @__PURE__ */ jsxRuntime.jsx(RichEditorThemeProvider, { value: resolvedTheme, children: showFileCountUI ? (
12035
+ // 바깥에 position: relative 한 단만 더 둬서, fileCountUIRender가 돌려주는 요소가
12036
+ // absolute 포지션이면 에디터 박스 기준으로 겹쳐 뜨고, 일반 요소면 박스 바로 아래
12037
+ // 자연스러운 흐름으로 이어진다 — 호출부가 className 하나로 두 경우를 모두 고를 수 있다.
12038
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
12039
+ editorBox,
12040
+ fileCountUIRender({ count: attachmentCount, max: maxFiles })
12041
+ ] })
12042
+ ) : editorBox });
11897
12043
  });
11898
12044
  var RichEditor_default = RichEditor;
11899
12045
  function useDetailController(params = {}) {