@fayz-ai/ui 0.1.7 → 0.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/LICENSE +21 -0
- package/dist/chunk-22J2RTMN.js +1397 -0
- package/dist/chunk-22J2RTMN.js.map +1 -0
- package/dist/chunk-2P7T6QQK.cjs +206 -0
- package/dist/chunk-2P7T6QQK.cjs.map +1 -0
- package/dist/chunk-7TBDPNLY.cjs +649 -0
- package/dist/chunk-7TBDPNLY.cjs.map +1 -0
- package/dist/chunk-CZ6X6PZT.js +1237 -0
- package/dist/chunk-CZ6X6PZT.js.map +1 -0
- package/dist/chunk-D6SXPF4F.cjs +397 -0
- package/dist/chunk-D6SXPF4F.cjs.map +1 -0
- package/dist/chunk-DNYVEOAX.js +11 -0
- package/dist/chunk-DNYVEOAX.js.map +1 -0
- package/dist/chunk-E526FHZ4.js +169 -0
- package/dist/chunk-E526FHZ4.js.map +1 -0
- package/dist/chunk-GE6XUREM.cjs +1277 -0
- package/dist/chunk-GE6XUREM.cjs.map +1 -0
- package/dist/chunk-GFH5HOCO.js +605 -0
- package/dist/chunk-GFH5HOCO.js.map +1 -0
- package/dist/chunk-IWBXYV4U.js +203 -0
- package/dist/chunk-IWBXYV4U.js.map +1 -0
- package/dist/chunk-MYZT2OG7.js +350 -0
- package/dist/chunk-MYZT2OG7.js.map +1 -0
- package/dist/chunk-O5F4LLSL.js +445 -0
- package/dist/chunk-O5F4LLSL.js.map +1 -0
- package/dist/chunk-TDGSY5W6.cjs +474 -0
- package/dist/chunk-TDGSY5W6.cjs.map +1 -0
- package/dist/chunk-VVVZO2LE.cjs +13 -0
- package/dist/chunk-VVVZO2LE.cjs.map +1 -0
- package/dist/chunk-W4XXXJRW.cjs +196 -0
- package/dist/chunk-W4XXXJRW.cjs.map +1 -0
- package/dist/chunk-YB5ZJKNG.cjs +1484 -0
- package/dist/chunk-YB5ZJKNG.cjs.map +1 -0
- package/dist/dashboard/index.cjs +102 -0
- package/dist/dashboard/index.cjs.map +1 -0
- package/dist/dashboard/index.js +5 -0
- package/dist/dashboard/index.js.map +1 -0
- package/dist/index.cjs +569 -4288
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -4136
- 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/index.cjs +90 -0
- package/dist/layout/index.cjs.map +1 -0
- package/dist/layout/index.js +5 -0
- package/dist/layout/index.js.map +1 -0
- package/dist/layout/useCrossModuleBack.d.ts +16 -0
- package/dist/layout/useCrossModuleBack.d.ts.map +1 -0
- package/dist/preset.cjs +18 -0
- package/dist/preset.cjs.map +1 -0
- package/dist/preset.js +3 -0
- package/dist/preset.js.map +1 -0
- package/dist/primitives/breadcrumb.d.ts.map +1 -1
- package/dist/primitives/index.cjs +347 -0
- package/dist/primitives/index.cjs.map +1 -0
- package/dist/primitives/index.js +6 -0
- package/dist/primitives/index.js.map +1 -0
- package/dist/theme/index.cjs +41 -0
- package/dist/theme/index.cjs.map +1 -0
- package/dist/theme/index.js +4 -0
- package/dist/theme/index.js.map +1 -0
- package/package.json +10 -10
- 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
|
@@ -7,6 +7,7 @@ import { ICON_MAP } from './Topbar'
|
|
|
7
7
|
import { useModuleHeaderSlot, useModuleHeaderActionsSlot } from './AppShell'
|
|
8
8
|
import { PageTransition } from './PageTransition'
|
|
9
9
|
import { useBackHandler } from './SaveBar'
|
|
10
|
+
import { useCrossModuleBack } from './useCrossModuleBack'
|
|
10
11
|
|
|
11
12
|
// ---------------------------------------------------------------------------
|
|
12
13
|
// PageHeaderActions — portals a page's primary action button(s) into the shell
|
|
@@ -248,19 +249,25 @@ export interface SubpageHeaderProps {
|
|
|
248
249
|
export function SubpageHeader({ title, subtitle, icon, onBack, parentLabel, actions, backStyle }: SubpageHeaderProps) {
|
|
249
250
|
const t = useTranslation()
|
|
250
251
|
const appStyle = useBackStyle()
|
|
252
|
+
|
|
253
|
+
// Defer to the global navigation history when the user came from another
|
|
254
|
+
// module, so the back link points at the actual previous page. Within the
|
|
255
|
+
// same module the page's own onBack/parentLabel pass through unchanged.
|
|
256
|
+
const { onBack: effectiveOnBack, parentLabel: effectiveParentLabel } = useCrossModuleBack(onBack, parentLabel)
|
|
257
|
+
|
|
251
258
|
// Wire this page's back action into the app-wide Escape key (no per-plugin code).
|
|
252
|
-
useBackHandler(
|
|
259
|
+
useBackHandler(effectiveOnBack)
|
|
253
260
|
const Icon = icon ? (ICON_MAP[icon] ?? null) : null
|
|
254
261
|
// Breadcrumb/link need a parent label; without one we fall back to the icon button.
|
|
255
|
-
const style: BackButtonStyle = !
|
|
256
|
-
const effectiveStyle: BackButtonStyle = style !== 'icon' && !
|
|
262
|
+
const style: BackButtonStyle = !effectiveOnBack ? 'icon' : (backStyle ?? appStyle)
|
|
263
|
+
const effectiveStyle: BackButtonStyle = style !== 'icon' && !effectiveParentLabel ? 'icon' : style
|
|
257
264
|
|
|
258
265
|
const titleBlock = (
|
|
259
266
|
<div className="flex items-center justify-between gap-4">
|
|
260
267
|
<div className="flex items-center gap-3">
|
|
261
|
-
{effectiveStyle === 'icon' &&
|
|
268
|
+
{effectiveStyle === 'icon' && effectiveOnBack && (
|
|
262
269
|
<button
|
|
263
|
-
onClick={
|
|
270
|
+
onClick={effectiveOnBack}
|
|
264
271
|
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"
|
|
265
272
|
>
|
|
266
273
|
<ChevronLeft className="h-4 w-4" />
|
|
@@ -285,7 +292,7 @@ export function SubpageHeader({ title, subtitle, icon, onBack, parentLabel, acti
|
|
|
285
292
|
<div className="space-y-4 mb-6">
|
|
286
293
|
<div className="flex items-center justify-between gap-4">
|
|
287
294
|
<div className="flex items-center gap-2 text-sm text-muted-foreground">
|
|
288
|
-
<button onClick={
|
|
295
|
+
<button onClick={effectiveOnBack} className="hover:text-foreground transition-colors">{effectiveParentLabel}</button>
|
|
289
296
|
<ChevronRight className="h-3.5 w-3.5" />
|
|
290
297
|
<span className="text-foreground font-medium">{title}</span>
|
|
291
298
|
</div>
|
|
@@ -300,11 +307,11 @@ export function SubpageHeader({ title, subtitle, icon, onBack, parentLabel, acti
|
|
|
300
307
|
return (
|
|
301
308
|
<div className="space-y-3 mb-6">
|
|
302
309
|
<button
|
|
303
|
-
onClick={
|
|
310
|
+
onClick={effectiveOnBack}
|
|
304
311
|
className="inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors"
|
|
305
312
|
>
|
|
306
313
|
<ChevronLeft className="h-4 w-4" />
|
|
307
|
-
{t('crud.detail.backTo', { entities:
|
|
314
|
+
{t('crud.detail.backTo', { entities: effectiveParentLabel as string })}
|
|
308
315
|
</button>
|
|
309
316
|
{titleBlock}
|
|
310
317
|
</div>
|
package/src/layout/Topbar.tsx
CHANGED
|
@@ -59,6 +59,10 @@ import {
|
|
|
59
59
|
Ruler,
|
|
60
60
|
ArrowUpRight,
|
|
61
61
|
ArrowDownRight,
|
|
62
|
+
ArrowLeftRight,
|
|
63
|
+
Plug,
|
|
64
|
+
SlidersHorizontal,
|
|
65
|
+
TableProperties,
|
|
62
66
|
UserPlus,
|
|
63
67
|
TreePalm,
|
|
64
68
|
PartyPopper,
|
|
@@ -176,7 +180,7 @@ export const ICON_MAP: Record<string, LucideIcon> = {
|
|
|
176
180
|
ClipboardList, Briefcase, UserCog, BookOpen, MessageCircle, Globe,
|
|
177
181
|
Percent, Tag, Camera, UtensilsCrossed, Search, MapPin, Handshake,
|
|
178
182
|
Contact, Building2, ChevronDown, Filter, Plus, List, Dog, Cat, PawPrint, Heart, LayoutTemplate, LeafyGreen, Apple, Egg, Wheat,
|
|
179
|
-
ArrowDownCircle, ArrowUpCircle, Landmark, Receipt, TrendingUp, CircleDollarSign, Clock, AlertTriangle, Sparkles, Wallet, Warehouse, Ruler, ArrowUpRight, ArrowDownRight, UserPlus, TreePalm,
|
|
183
|
+
ArrowDownCircle, ArrowUpCircle, ArrowLeftRight, Plug, SlidersHorizontal, TableProperties, Landmark, Receipt, TrendingUp, CircleDollarSign, Clock, AlertTriangle, Sparkles, Wallet, Warehouse, Ruler, ArrowUpRight, ArrowDownRight, UserPlus, TreePalm,
|
|
180
184
|
PartyPopper, Radio, CalendarDays, Banknote, Layers, Music, Eye, ListMusic, Disc3, UsersRound, Mic,
|
|
181
185
|
}
|
|
182
186
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useNavReferrer, navHistoryBack, routeModule } from '@fayz-ai/core'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Context-aware back target shared by all header/breadcrumb components.
|
|
5
|
+
*
|
|
6
|
+
* When the user arrived from a *different* module (tracked in the global
|
|
7
|
+
* navigation history), a page's own onBack/parentLabel point at its local
|
|
8
|
+
* parent — wrong for the referrer. In that case we return the referrer's label
|
|
9
|
+
* and a back action that pops the browser history to the actual previous page.
|
|
10
|
+
* Within the same module the page's own (more specific) values pass through
|
|
11
|
+
* unchanged, so existing behavior is preserved.
|
|
12
|
+
*/
|
|
13
|
+
export function useCrossModuleBack(onBack?: () => void, parentLabel?: string): {
|
|
14
|
+
onBack?: () => void
|
|
15
|
+
parentLabel?: string
|
|
16
|
+
isCrossModule: boolean
|
|
17
|
+
} {
|
|
18
|
+
const currentPath = typeof window !== 'undefined'
|
|
19
|
+
? ((window.location.hash ? window.location.hash.slice(1) : window.location.pathname) || '/')
|
|
20
|
+
: '/'
|
|
21
|
+
const referrer = useNavReferrer(currentPath)
|
|
22
|
+
const cross = referrer && referrer.label && routeModule(referrer.path) !== routeModule(currentPath)
|
|
23
|
+
? referrer
|
|
24
|
+
: null
|
|
25
|
+
return {
|
|
26
|
+
onBack: cross ? () => navHistoryBack(onBack) : onBack,
|
|
27
|
+
parentLabel: cross ? cross.label : parentLabel,
|
|
28
|
+
isCrossModule: !!cross,
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
2
|
import { ArrowLeft } from 'lucide-react'
|
|
3
3
|
import { useBackHandler } from '../layout/SaveBar'
|
|
4
|
+
import { useCrossModuleBack } from '../layout/useCrossModuleBack'
|
|
4
5
|
|
|
5
6
|
interface BreadcrumbProps {
|
|
6
7
|
/** Parent label (e.g. "Invoices", "Clients") — clicking navigates back */
|
|
@@ -12,17 +13,20 @@ interface BreadcrumbProps {
|
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
export function Breadcrumb({ parent, current, onBack }: BreadcrumbProps) {
|
|
16
|
+
// When the user came from another module, point "back" at that actual
|
|
17
|
+
// previous page; otherwise keep this page's own parent/onBack.
|
|
18
|
+
const { onBack: effectiveOnBack, parentLabel: effectiveParent } = useCrossModuleBack(onBack, parent)
|
|
15
19
|
// Wire this page's back action into the app-wide Escape key (no per-plugin code).
|
|
16
|
-
useBackHandler(
|
|
20
|
+
useBackHandler(effectiveOnBack)
|
|
17
21
|
return (
|
|
18
22
|
<nav className="flex items-center gap-1.5 text-sm text-muted-foreground">
|
|
19
23
|
<button
|
|
20
24
|
type="button"
|
|
21
|
-
onClick={
|
|
25
|
+
onClick={effectiveOnBack}
|
|
22
26
|
className="inline-flex items-center gap-1 hover:text-foreground transition-colors"
|
|
23
27
|
>
|
|
24
28
|
<ArrowLeft className="h-3.5 w-3.5" />
|
|
25
|
-
{
|
|
29
|
+
{effectiveParent}
|
|
26
30
|
</button>
|
|
27
31
|
{current !== undefined && (
|
|
28
32
|
<>
|