@fayz-ai/ui 0.1.7 → 0.2.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Faya Labs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.cjs CHANGED
@@ -980,18 +980,29 @@ var Separator3 = React10__namespace.forwardRef(
980
980
  )
981
981
  );
982
982
  Separator3.displayName = SeparatorPrimitive__namespace.Root.displayName;
983
+ function useCrossModuleBack(onBack, parentLabel) {
984
+ const currentPath = typeof window !== "undefined" ? (window.location.hash ? window.location.hash.slice(1) : window.location.pathname) || "/" : "/";
985
+ const referrer = core.useNavReferrer(currentPath);
986
+ const cross = referrer && referrer.label && core.routeModule(referrer.path) !== core.routeModule(currentPath) ? referrer : null;
987
+ return {
988
+ onBack: cross ? () => core.navHistoryBack(onBack) : onBack,
989
+ parentLabel: cross ? cross.label : parentLabel,
990
+ isCrossModule: !!cross
991
+ };
992
+ }
983
993
  function Breadcrumb({ parent, current, onBack }) {
984
- useBackHandler(onBack);
994
+ const { onBack: effectiveOnBack, parentLabel: effectiveParent } = useCrossModuleBack(onBack, parent);
995
+ useBackHandler(effectiveOnBack);
985
996
  return /* @__PURE__ */ jsxRuntime.jsxs("nav", { className: "flex items-center gap-1.5 text-sm text-muted-foreground", children: [
986
997
  /* @__PURE__ */ jsxRuntime.jsxs(
987
998
  "button",
988
999
  {
989
1000
  type: "button",
990
- onClick: onBack,
1001
+ onClick: effectiveOnBack,
991
1002
  className: "inline-flex items-center gap-1 hover:text-foreground transition-colors",
992
1003
  children: [
993
1004
  /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.ArrowLeft, { className: "h-3.5 w-3.5" }),
994
- parent
1005
+ effectiveParent
995
1006
  ]
996
1007
  }
997
1008
  ),
@@ -2352,6 +2363,10 @@ var ICON_MAP2 = {
2352
2363
  Wheat: LucideIcons.Wheat,
2353
2364
  ArrowDownCircle: LucideIcons.ArrowDownCircle,
2354
2365
  ArrowUpCircle: LucideIcons.ArrowUpCircle,
2366
+ ArrowLeftRight: LucideIcons.ArrowLeftRight,
2367
+ Plug: LucideIcons.Plug,
2368
+ SlidersHorizontal: LucideIcons.SlidersHorizontal,
2369
+ TableProperties: LucideIcons.TableProperties,
2355
2370
  Landmark: LucideIcons.Landmark,
2356
2371
  Receipt: LucideIcons.Receipt,
2357
2372
  TrendingUp: LucideIcons.TrendingUp,
@@ -3016,16 +3031,17 @@ function useBackStyle() {
3016
3031
  function SubpageHeader({ title, subtitle, icon, onBack, parentLabel, actions, backStyle }) {
3017
3032
  const t = core.useTranslation();
3018
3033
  const appStyle = useBackStyle();
3019
- useBackHandler(onBack);
3034
+ const { onBack: effectiveOnBack, parentLabel: effectiveParentLabel } = useCrossModuleBack(onBack, parentLabel);
3035
+ useBackHandler(effectiveOnBack);
3020
3036
  const Icon2 = icon ? ICON_MAP2[icon] ?? null : null;
3021
- const style = !onBack ? "icon" : backStyle ?? appStyle;
3022
- const effectiveStyle = style !== "icon" && !parentLabel ? "icon" : style;
3037
+ const style = !effectiveOnBack ? "icon" : backStyle ?? appStyle;
3038
+ const effectiveStyle = style !== "icon" && !effectiveParentLabel ? "icon" : style;
3023
3039
  const titleBlock = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-4", children: [
3024
3040
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
3025
- effectiveStyle === "icon" && onBack && /* @__PURE__ */ jsxRuntime.jsx(
3041
+ effectiveStyle === "icon" && effectiveOnBack && /* @__PURE__ */ jsxRuntime.jsx(
3026
3042
  "button",
3027
3043
  {
3028
- onClick: onBack,
3044
+ onClick: effectiveOnBack,
3029
3045
  className: "flex h-8 w-8 items-center justify-center rounded-lg border hover:bg-muted bg-card shadow-button active:shadow-button-inset transition-colors",
3030
3046
  children: /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.ChevronLeft, { className: "h-4 w-4" })
3031
3047
  }
@@ -3042,7 +3058,7 @@ function SubpageHeader({ title, subtitle, icon, onBack, parentLabel, actions, ba
3042
3058
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4 mb-6", children: [
3043
3059
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-4", children: [
3044
3060
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: [
3045
- /* @__PURE__ */ jsxRuntime.jsx("button", { onClick: onBack, className: "hover:text-foreground transition-colors", children: parentLabel }),
3061
+ /* @__PURE__ */ jsxRuntime.jsx("button", { onClick: effectiveOnBack, className: "hover:text-foreground transition-colors", children: effectiveParentLabel }),
3046
3062
  /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.ChevronRight, { className: "h-3.5 w-3.5" }),
3047
3063
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground font-medium", children: title })
3048
3064
  ] }),
@@ -3056,11 +3072,11 @@ function SubpageHeader({ title, subtitle, icon, onBack, parentLabel, actions, ba
3056
3072
  /* @__PURE__ */ jsxRuntime.jsxs(
3057
3073
  "button",
3058
3074
  {
3059
- onClick: onBack,
3075
+ onClick: effectiveOnBack,
3060
3076
  className: "inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",
3061
3077
  children: [
3062
3078
  /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.ChevronLeft, { className: "h-4 w-4" }),
3063
- t("crud.detail.backTo", { entities: parentLabel })
3079
+ t("crud.detail.backTo", { entities: effectiveParentLabel })
3064
3080
  ]
3065
3081
  }
3066
3082
  ),