@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 +21 -0
- package/dist/index.cjs +27 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -13
- package/dist/index.js.map +1 -1
- package/dist/layout/ModulePage.d.ts.map +1 -1
- package/dist/layout/Topbar.d.ts.map +1 -1
- package/dist/layout/useCrossModuleBack.d.ts +16 -0
- package/dist/layout/useCrossModuleBack.d.ts.map +1 -0
- package/dist/primitives/breadcrumb.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/layout/ModulePage.tsx +15 -8
- package/src/layout/Topbar.tsx +5 -1
- package/src/layout/useCrossModuleBack.ts +30 -0
- package/src/primitives/breadcrumb.tsx +7 -3
package/dist/index.js
CHANGED
|
@@ -7,13 +7,13 @@ import { cva } from 'class-variance-authority';
|
|
|
7
7
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
8
8
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
9
9
|
import * as LucideIcons from 'lucide-react';
|
|
10
|
-
import { X, ChevronRight, Check, Circle, ChevronDown, ChevronUp, Workflow, Star, MessageSquare, LayoutDashboard, Award, Zap, Mic, UsersRound, Disc3, ListMusic, Eye, Music, Layers, Banknote, CalendarDays, Radio, PartyPopper, Wheat, Egg, Apple, LeafyGreen, LayoutTemplate, Heart, PawPrint, Cat, Dog, Search, List, Plus, Filter, Building2, Contact, Handshake, MapPin, UtensilsCrossed, Camera, Tag, Percent, Globe, MessageCircle, BookOpen, UserCog, Briefcase, ClipboardList, Wrench, Target, ShoppingCart, Megaphone, DollarSign, Mail, FileText, BarChart3, Package, Calendar, Bell, CreditCard, Settings, Users, Home, ArrowUp, ArrowDown, ArrowUpDown, Loader2, ArrowLeft, Clock, ChevronLeft, CheckCircle2, AlertTriangle, XCircle, Info, PanelLeftClose, PanelLeft, Menu, SlidersHorizontal, RotateCcw, TreePalm, UserPlus, ArrowDownRight, ArrowUpRight, Ruler, Warehouse, Wallet, Sparkles, CircleDollarSign, TrendingUp, Receipt, Landmark, ArrowUpCircle, ArrowDownCircle, TrendingDown, EyeOff } from 'lucide-react';
|
|
10
|
+
import { X, ChevronRight, Check, Circle, ChevronDown, ChevronUp, Workflow, Star, MessageSquare, LayoutDashboard, Award, Zap, Mic, UsersRound, Disc3, ListMusic, Eye, Music, Layers, Banknote, CalendarDays, Radio, PartyPopper, Wheat, Egg, Apple, LeafyGreen, LayoutTemplate, Heart, PawPrint, Cat, Dog, Search, List, Plus, Filter, Building2, Contact, Handshake, MapPin, UtensilsCrossed, Camera, Tag, Percent, Globe, MessageCircle, BookOpen, UserCog, Briefcase, ClipboardList, Wrench, Target, ShoppingCart, Megaphone, DollarSign, Mail, FileText, BarChart3, Package, Calendar, Bell, CreditCard, Settings, Users, Home, ArrowUp, ArrowDown, ArrowUpDown, Loader2, ArrowLeft, Clock, ChevronLeft, CheckCircle2, AlertTriangle, XCircle, Info, PanelLeftClose, PanelLeft, Menu, SlidersHorizontal, RotateCcw, TreePalm, UserPlus, ArrowDownRight, ArrowUpRight, Ruler, Warehouse, Wallet, Sparkles, CircleDollarSign, TrendingUp, Receipt, Landmark, TableProperties, Plug, ArrowLeftRight, ArrowUpCircle, ArrowDownCircle, TrendingDown, EyeOff } from 'lucide-react';
|
|
11
11
|
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
12
12
|
import { useReactTable, getSortedRowModel, getCoreRowModel, flexRender } from '@tanstack/react-table';
|
|
13
13
|
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
14
14
|
import { Toaster } from 'sonner';
|
|
15
15
|
export { toast } from 'sonner';
|
|
16
|
-
import { hashRouterAdapter, useTranslation, getCurrentLocale, usePluginRuntime, getDashboardWidgets, resolvePluginComponent } from '@fayz-ai/core';
|
|
16
|
+
import { hashRouterAdapter, useTranslation, getCurrentLocale, usePluginRuntime, getDashboardWidgets, useNavReferrer, routeModule, navHistoryBack, resolvePluginComponent } from '@fayz-ai/core';
|
|
17
17
|
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
18
18
|
import * as SeparatorPrimitive from '@radix-ui/react-separator';
|
|
19
19
|
import * as Tooltip2 from '@radix-ui/react-tooltip';
|
|
@@ -952,18 +952,29 @@ var Separator3 = React10.forwardRef(
|
|
|
952
952
|
)
|
|
953
953
|
);
|
|
954
954
|
Separator3.displayName = SeparatorPrimitive.Root.displayName;
|
|
955
|
+
function useCrossModuleBack(onBack, parentLabel) {
|
|
956
|
+
const currentPath = typeof window !== "undefined" ? (window.location.hash ? window.location.hash.slice(1) : window.location.pathname) || "/" : "/";
|
|
957
|
+
const referrer = useNavReferrer(currentPath);
|
|
958
|
+
const cross = referrer && referrer.label && routeModule(referrer.path) !== routeModule(currentPath) ? referrer : null;
|
|
959
|
+
return {
|
|
960
|
+
onBack: cross ? () => navHistoryBack(onBack) : onBack,
|
|
961
|
+
parentLabel: cross ? cross.label : parentLabel,
|
|
962
|
+
isCrossModule: !!cross
|
|
963
|
+
};
|
|
964
|
+
}
|
|
955
965
|
function Breadcrumb({ parent, current, onBack }) {
|
|
956
|
-
|
|
966
|
+
const { onBack: effectiveOnBack, parentLabel: effectiveParent } = useCrossModuleBack(onBack, parent);
|
|
967
|
+
useBackHandler(effectiveOnBack);
|
|
957
968
|
return /* @__PURE__ */ jsxs("nav", { className: "flex items-center gap-1.5 text-sm text-muted-foreground", children: [
|
|
958
969
|
/* @__PURE__ */ jsxs(
|
|
959
970
|
"button",
|
|
960
971
|
{
|
|
961
972
|
type: "button",
|
|
962
|
-
onClick:
|
|
973
|
+
onClick: effectiveOnBack,
|
|
963
974
|
className: "inline-flex items-center gap-1 hover:text-foreground transition-colors",
|
|
964
975
|
children: [
|
|
965
976
|
/* @__PURE__ */ jsx(ArrowLeft, { className: "h-3.5 w-3.5" }),
|
|
966
|
-
|
|
977
|
+
effectiveParent
|
|
967
978
|
]
|
|
968
979
|
}
|
|
969
980
|
),
|
|
@@ -2324,6 +2335,10 @@ var ICON_MAP2 = {
|
|
|
2324
2335
|
Wheat: Wheat,
|
|
2325
2336
|
ArrowDownCircle,
|
|
2326
2337
|
ArrowUpCircle,
|
|
2338
|
+
ArrowLeftRight,
|
|
2339
|
+
Plug,
|
|
2340
|
+
SlidersHorizontal,
|
|
2341
|
+
TableProperties,
|
|
2327
2342
|
Landmark,
|
|
2328
2343
|
Receipt,
|
|
2329
2344
|
TrendingUp,
|
|
@@ -2988,16 +3003,17 @@ function useBackStyle() {
|
|
|
2988
3003
|
function SubpageHeader({ title, subtitle, icon, onBack, parentLabel, actions, backStyle }) {
|
|
2989
3004
|
const t = useTranslation();
|
|
2990
3005
|
const appStyle = useBackStyle();
|
|
2991
|
-
|
|
3006
|
+
const { onBack: effectiveOnBack, parentLabel: effectiveParentLabel } = useCrossModuleBack(onBack, parentLabel);
|
|
3007
|
+
useBackHandler(effectiveOnBack);
|
|
2992
3008
|
const Icon2 = icon ? ICON_MAP2[icon] ?? null : null;
|
|
2993
|
-
const style = !
|
|
2994
|
-
const effectiveStyle = style !== "icon" && !
|
|
3009
|
+
const style = !effectiveOnBack ? "icon" : backStyle ?? appStyle;
|
|
3010
|
+
const effectiveStyle = style !== "icon" && !effectiveParentLabel ? "icon" : style;
|
|
2995
3011
|
const titleBlock = /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-4", children: [
|
|
2996
3012
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
2997
|
-
effectiveStyle === "icon" &&
|
|
3013
|
+
effectiveStyle === "icon" && effectiveOnBack && /* @__PURE__ */ jsx(
|
|
2998
3014
|
"button",
|
|
2999
3015
|
{
|
|
3000
|
-
onClick:
|
|
3016
|
+
onClick: effectiveOnBack,
|
|
3001
3017
|
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",
|
|
3002
3018
|
children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4" })
|
|
3003
3019
|
}
|
|
@@ -3014,7 +3030,7 @@ function SubpageHeader({ title, subtitle, icon, onBack, parentLabel, actions, ba
|
|
|
3014
3030
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-4 mb-6", children: [
|
|
3015
3031
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-4", children: [
|
|
3016
3032
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: [
|
|
3017
|
-
/* @__PURE__ */ jsx("button", { onClick:
|
|
3033
|
+
/* @__PURE__ */ jsx("button", { onClick: effectiveOnBack, className: "hover:text-foreground transition-colors", children: effectiveParentLabel }),
|
|
3018
3034
|
/* @__PURE__ */ jsx(ChevronRight, { className: "h-3.5 w-3.5" }),
|
|
3019
3035
|
/* @__PURE__ */ jsx("span", { className: "text-foreground font-medium", children: title })
|
|
3020
3036
|
] }),
|
|
@@ -3028,11 +3044,11 @@ function SubpageHeader({ title, subtitle, icon, onBack, parentLabel, actions, ba
|
|
|
3028
3044
|
/* @__PURE__ */ jsxs(
|
|
3029
3045
|
"button",
|
|
3030
3046
|
{
|
|
3031
|
-
onClick:
|
|
3047
|
+
onClick: effectiveOnBack,
|
|
3032
3048
|
className: "inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",
|
|
3033
3049
|
children: [
|
|
3034
3050
|
/* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4" }),
|
|
3035
|
-
t("crud.detail.backTo", { entities:
|
|
3051
|
+
t("crud.detail.backTo", { entities: effectiveParentLabel })
|
|
3036
3052
|
]
|
|
3037
3053
|
}
|
|
3038
3054
|
),
|