@underverse-ui/underverse 1.0.88 → 1.0.90

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "package": "@underverse-ui/underverse",
3
- "version": "1.0.88",
3
+ "version": "1.0.90",
4
4
  "sourceEntry": "src/index.ts",
5
5
  "totalExports": 225,
6
6
  "exports": [
package/dist/index.cjs CHANGED
@@ -1981,40 +1981,48 @@ function getEnvironmentLocale(fallback) {
1981
1981
  }
1982
1982
  return fallback;
1983
1983
  }
1984
- function getExternalLocaleFallback(internalLocale) {
1985
- if (internalLocale !== "en") {
1986
- return internalLocale;
1987
- }
1988
- return getEnvironmentLocale(internalLocale);
1989
- }
1990
1984
  function useSmartTranslations(namespace) {
1991
1985
  const forceInternal = React6.useContext(ForceInternalContext);
1992
1986
  const nextIntlBridge = useNextIntlBridge();
1993
1987
  const internalT = useUnderverseTranslations(namespace);
1994
1988
  const internalLocale = useUnderverseLocale();
1989
+ const [environmentLocale, setEnvironmentLocale] = React6.useState(null);
1990
+ React6.useEffect(() => {
1991
+ if (forceInternal) return;
1992
+ if (nextIntlBridge) return;
1993
+ if (internalLocale !== "en") return;
1994
+ const detected = getEnvironmentLocale(internalLocale);
1995
+ if (detected !== internalLocale) {
1996
+ setEnvironmentLocale(detected);
1997
+ }
1998
+ }, [forceInternal, internalLocale, nextIntlBridge]);
1995
1999
  if (forceInternal) {
1996
2000
  return internalT;
1997
2001
  }
1998
- const resolvedLocale = nextIntlBridge?.locale ?? getExternalLocaleFallback(internalLocale);
1999
2002
  return (key) => {
2003
+ const primaryLocale = nextIntlBridge?.locale ?? internalLocale;
2004
+ const fallbackLocale = environmentLocale && environmentLocale !== primaryLocale ? environmentLocale : null;
2000
2005
  let translated = null;
2001
2006
  if (nextIntlBridge) {
2002
2007
  const nextIntlResult = nextIntlBridge.translate(namespace, key);
2003
2008
  translated = nextIntlResult.translated;
2004
2009
  }
2005
- const effectiveLocale = nextIntlBridge?.locale ?? getEnvironmentLocale(resolvedLocale);
2006
- const localizedDefault = getUnderverseDefaultTranslation(effectiveLocale, namespace, key);
2010
+ const localizedDefault = getUnderverseDefaultTranslation(primaryLocale, namespace, key);
2011
+ const fallbackLocalizedDefault = fallbackLocale ? getUnderverseDefaultTranslation(fallbackLocale, namespace, key) : key;
2007
2012
  const englishDefault = getUnderverseDefaultTranslation("en", namespace, key);
2008
2013
  const internalValue = internalT(key);
2009
- if (translated && !isUnresolvedTranslation(translated, namespace, key) && !(effectiveLocale !== "en" && localizedDefault !== englishDefault && translated === englishDefault)) {
2014
+ if (translated && !isUnresolvedTranslation(translated, namespace, key) && !(primaryLocale !== "en" && localizedDefault !== englishDefault && translated === englishDefault)) {
2010
2015
  return translated;
2011
2016
  }
2012
- if (internalLocale === effectiveLocale && internalValue !== key) {
2017
+ if (internalLocale === primaryLocale && internalValue !== key) {
2013
2018
  return internalValue;
2014
2019
  }
2015
2020
  if (localizedDefault !== key) {
2016
2021
  return localizedDefault;
2017
2022
  }
2023
+ if (fallbackLocalizedDefault !== key) {
2024
+ return fallbackLocalizedDefault;
2025
+ }
2018
2026
  if (internalValue !== key) {
2019
2027
  return internalValue;
2020
2028
  }
@@ -2028,7 +2036,7 @@ function useSmartLocale() {
2028
2036
  if (forceInternal) {
2029
2037
  return internalLocale;
2030
2038
  }
2031
- return nextIntlBridge?.locale ?? getExternalLocaleFallback(internalLocale);
2039
+ return nextIntlBridge?.locale ?? internalLocale;
2032
2040
  }
2033
2041
 
2034
2042
  // src/components/Input.tsx
@@ -16855,6 +16863,11 @@ var defaultLabels = {
16855
16863
  searchPlaceholder: "Search...",
16856
16864
  noResultsText: "No results found"
16857
16865
  };
16866
+ var TREE_NODE_BASE_PADDING_REM = 0.75;
16867
+ var TREE_NODE_INDENT_REM = 1;
16868
+ var TREE_BRANCH_OFFSET_CLASS = "ml-1.5 pl-1.5";
16869
+ var TREE_NODE_GAP_CLASS = "gap-1.5";
16870
+ var TREE_EXPANDER_PLACEHOLDER_CLASS = "w-5";
16858
16871
  function getInitialExpandedNodes(categories, defaultExpanded, viewOnly, inline) {
16859
16872
  if (!(viewOnly || inline) || !defaultExpanded) return /* @__PURE__ */ new Set();
16860
16873
  const parentIds = /* @__PURE__ */ new Set();
@@ -17043,13 +17056,14 @@ function CategoryTreeSelect(props) {
17043
17056
  {
17044
17057
  onClick: () => !viewOnly && handleSelect(category.id, category),
17045
17058
  className: cn(
17046
- "relative flex min-w-0 items-center gap-2.5 px-3 py-2.5 min-h-11 transition-all duration-200 rounded-3xl",
17059
+ "relative flex min-w-0 items-center px-3 py-2.5 min-h-11 transition-all duration-200 rounded-3xl",
17060
+ TREE_NODE_GAP_CLASS,
17047
17061
  !viewOnly && (isSelectable ? "cursor-pointer" : "cursor-default"),
17048
17062
  isSelectable && !isSelected && "hover:bg-accent/50",
17049
17063
  // Selected state - đồng bộ cho tất cả
17050
17064
  !viewOnly && isSelected && "bg-accent/40"
17051
17065
  ),
17052
- style: { paddingLeft: `${level * 1.25 + 0.75}rem` },
17066
+ style: { paddingLeft: `${level * TREE_NODE_INDENT_REM + TREE_NODE_BASE_PADDING_REM}rem` },
17053
17067
  children: [
17054
17068
  hasChildren ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
17055
17069
  "button",
@@ -17060,7 +17074,7 @@ function CategoryTreeSelect(props) {
17060
17074
  toggleExpand(category.id);
17061
17075
  },
17062
17076
  className: cn(
17063
- "p-1.5 rounded-lg transition-all duration-200",
17077
+ "p-0.5 rounded-lg transition-all duration-200",
17064
17078
  "hover:scale-110 active:scale-95",
17065
17079
  "focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",
17066
17080
  isExpanded && "text-primary",
@@ -17069,16 +17083,16 @@ function CategoryTreeSelect(props) {
17069
17083
  disabled: isSearchMode,
17070
17084
  children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className: cn("transition-transform duration-200", isExpanded && "rotate-90"), children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_lucide_react26.ChevronRight, { className: "w-4 h-4" }) })
17071
17085
  }
17072
- ) : /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { className: "w-7" }),
17086
+ ) : /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { className: TREE_EXPANDER_PLACEHOLDER_CLASS }),
17073
17087
  viewOnly ? (
17074
17088
  // View-only mode: just display the name with folder icon
17075
- /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: "flex min-w-0 items-center gap-2.5", children: [
17089
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: cn("flex min-w-0 items-center", TREE_NODE_GAP_CLASS), children: [
17076
17090
  category.icon ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className: "h-4 w-4 shrink-0 flex items-center justify-center text-muted-foreground/60", children: category.icon }) : hasChildren ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_lucide_react26.FolderTree, { className: "h-4 w-4 shrink-0 text-muted-foreground/60" }) : /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className: "h-1.5 w-1.5 shrink-0 rounded-full bg-muted-foreground/40" }),
17077
17091
  /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { className: "min-w-0 text-sm font-medium leading-snug break-words [overflow-wrap:anywhere]", children: category.name })
17078
17092
  ] })
17079
17093
  ) : (
17080
17094
  // Single/Multi select mode: icon + text + badge
17081
- /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: "flex min-w-0 flex-1 items-center gap-2.5 overflow-hidden", children: [
17095
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: cn("flex min-w-0 flex-1 items-center overflow-hidden", TREE_NODE_GAP_CLASS), children: [
17082
17096
  category.icon && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className: "h-4 w-4 shrink-0 flex items-center justify-center text-current", children: category.icon }),
17083
17097
  /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
17084
17098
  "span",
@@ -17097,7 +17111,17 @@ function CategoryTreeSelect(props) {
17097
17111
  ]
17098
17112
  }
17099
17113
  ),
17100
- hasChildren && isExpanded && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className: cn("ml-2 pl-2 border-l-2 border-dashed border-border/50", "animate-in slide-in-from-top-2 fade-in-50 duration-200"), children: children.map((child) => renderCategory(child, level + 1)) })
17114
+ hasChildren && isExpanded && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
17115
+ "div",
17116
+ {
17117
+ className: cn(
17118
+ TREE_BRANCH_OFFSET_CLASS,
17119
+ "border-l-2 border-dashed border-border/50",
17120
+ "animate-in slide-in-from-top-2 fade-in-50 duration-200"
17121
+ ),
17122
+ children: children.map((child) => renderCategory(child, level + 1))
17123
+ }
17124
+ )
17101
17125
  ]
17102
17126
  },
17103
17127
  category.id
@@ -21069,7 +21093,8 @@ function DataTableBodyRows({
21069
21093
  getRowKey,
21070
21094
  getStickyColumnStyle,
21071
21095
  getStickyCellClass,
21072
- t
21096
+ t,
21097
+ labels
21073
21098
  }) {
21074
21099
  return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(TableBody, { children: loading2 ? /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(TableRow, { children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(TableCell, { colSpan: leafColumns.length, className: "text-center py-8", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("div", { className: "flex items-center justify-center gap-2 text-muted-foreground", children: [
21075
21100
  /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("svg", { className: "animate-spin h-4 w-4", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [
@@ -21087,7 +21112,7 @@ function DataTableBodyRows({
21087
21112
  t("loading"),
21088
21113
  "\u2026"
21089
21114
  ] })
21090
- ] }) }) }) : displayedData.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(TableRow, { children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(TableCell, { colSpan: leafColumns.length, className: "text-center py-6 text-muted-foreground", children: t("noData") }) }) : displayedData.map((row, idx) => {
21115
+ ] }) }) }) : displayedData.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(TableRow, { children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(TableCell, { colSpan: leafColumns.length, className: "text-center py-6 text-muted-foreground", children: labels?.noData || t("noData") }) }) : displayedData.map((row, idx) => {
21091
21116
  const isStripedRow = striped && idx % 2 === 0;
21092
21117
  return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
21093
21118
  TableRow,
@@ -22354,7 +22379,8 @@ function DataTable({
22354
22379
  getRowKey,
22355
22380
  getStickyColumnStyle,
22356
22381
  getStickyCellClass,
22357
- t
22382
+ t,
22383
+ labels
22358
22384
  }
22359
22385
  )
22360
22386
  ]