@underverse-ui/underverse 1.0.88 → 1.0.89

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.89",
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
@@ -21069,7 +21077,8 @@ function DataTableBodyRows({
21069
21077
  getRowKey,
21070
21078
  getStickyColumnStyle,
21071
21079
  getStickyCellClass,
21072
- t
21080
+ t,
21081
+ labels
21073
21082
  }) {
21074
21083
  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
21084
  /* @__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 +21096,7 @@ function DataTableBodyRows({
21087
21096
  t("loading"),
21088
21097
  "\u2026"
21089
21098
  ] })
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) => {
21099
+ ] }) }) }) : 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
21100
  const isStripedRow = striped && idx % 2 === 0;
21092
21101
  return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
21093
21102
  TableRow,
@@ -22354,7 +22363,8 @@ function DataTable({
22354
22363
  getRowKey,
22355
22364
  getStickyColumnStyle,
22356
22365
  getStickyCellClass,
22357
- t
22366
+ t,
22367
+ labels
22358
22368
  }
22359
22369
  )
22360
22370
  ]