@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.
Files changed (67) hide show
  1. package/LICENSE +21 -0
  2. package/dist/chunk-22J2RTMN.js +1397 -0
  3. package/dist/chunk-22J2RTMN.js.map +1 -0
  4. package/dist/chunk-2P7T6QQK.cjs +206 -0
  5. package/dist/chunk-2P7T6QQK.cjs.map +1 -0
  6. package/dist/chunk-7TBDPNLY.cjs +649 -0
  7. package/dist/chunk-7TBDPNLY.cjs.map +1 -0
  8. package/dist/chunk-CZ6X6PZT.js +1237 -0
  9. package/dist/chunk-CZ6X6PZT.js.map +1 -0
  10. package/dist/chunk-D6SXPF4F.cjs +397 -0
  11. package/dist/chunk-D6SXPF4F.cjs.map +1 -0
  12. package/dist/chunk-DNYVEOAX.js +11 -0
  13. package/dist/chunk-DNYVEOAX.js.map +1 -0
  14. package/dist/chunk-E526FHZ4.js +169 -0
  15. package/dist/chunk-E526FHZ4.js.map +1 -0
  16. package/dist/chunk-GE6XUREM.cjs +1277 -0
  17. package/dist/chunk-GE6XUREM.cjs.map +1 -0
  18. package/dist/chunk-GFH5HOCO.js +605 -0
  19. package/dist/chunk-GFH5HOCO.js.map +1 -0
  20. package/dist/chunk-IWBXYV4U.js +203 -0
  21. package/dist/chunk-IWBXYV4U.js.map +1 -0
  22. package/dist/chunk-MYZT2OG7.js +350 -0
  23. package/dist/chunk-MYZT2OG7.js.map +1 -0
  24. package/dist/chunk-O5F4LLSL.js +445 -0
  25. package/dist/chunk-O5F4LLSL.js.map +1 -0
  26. package/dist/chunk-TDGSY5W6.cjs +474 -0
  27. package/dist/chunk-TDGSY5W6.cjs.map +1 -0
  28. package/dist/chunk-VVVZO2LE.cjs +13 -0
  29. package/dist/chunk-VVVZO2LE.cjs.map +1 -0
  30. package/dist/chunk-W4XXXJRW.cjs +196 -0
  31. package/dist/chunk-W4XXXJRW.cjs.map +1 -0
  32. package/dist/chunk-YB5ZJKNG.cjs +1484 -0
  33. package/dist/chunk-YB5ZJKNG.cjs.map +1 -0
  34. package/dist/dashboard/index.cjs +102 -0
  35. package/dist/dashboard/index.cjs.map +1 -0
  36. package/dist/dashboard/index.js +5 -0
  37. package/dist/dashboard/index.js.map +1 -0
  38. package/dist/index.cjs +569 -4288
  39. package/dist/index.cjs.map +1 -1
  40. package/dist/index.js +15 -4136
  41. package/dist/index.js.map +1 -1
  42. package/dist/layout/ModulePage.d.ts.map +1 -1
  43. package/dist/layout/Topbar.d.ts.map +1 -1
  44. package/dist/layout/index.cjs +90 -0
  45. package/dist/layout/index.cjs.map +1 -0
  46. package/dist/layout/index.js +5 -0
  47. package/dist/layout/index.js.map +1 -0
  48. package/dist/layout/useCrossModuleBack.d.ts +16 -0
  49. package/dist/layout/useCrossModuleBack.d.ts.map +1 -0
  50. package/dist/preset.cjs +18 -0
  51. package/dist/preset.cjs.map +1 -0
  52. package/dist/preset.js +3 -0
  53. package/dist/preset.js.map +1 -0
  54. package/dist/primitives/breadcrumb.d.ts.map +1 -1
  55. package/dist/primitives/index.cjs +347 -0
  56. package/dist/primitives/index.cjs.map +1 -0
  57. package/dist/primitives/index.js +6 -0
  58. package/dist/primitives/index.js.map +1 -0
  59. package/dist/theme/index.cjs +41 -0
  60. package/dist/theme/index.cjs.map +1 -0
  61. package/dist/theme/index.js +4 -0
  62. package/dist/theme/index.js.map +1 -0
  63. package/package.json +10 -10
  64. package/src/layout/ModulePage.tsx +15 -8
  65. package/src/layout/Topbar.tsx +5 -1
  66. package/src/layout/useCrossModuleBack.ts +30 -0
  67. 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(onBack)
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 = !onBack ? 'icon' : (backStyle ?? appStyle)
256
- const effectiveStyle: BackButtonStyle = style !== 'icon' && !parentLabel ? 'icon' : style
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' && onBack && (
268
+ {effectiveStyle === 'icon' && effectiveOnBack && (
262
269
  <button
263
- onClick={onBack}
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={onBack} className="hover:text-foreground transition-colors">{parentLabel}</button>
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={onBack}
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: parentLabel as string })}
314
+ {t('crud.detail.backTo', { entities: effectiveParentLabel as string })}
308
315
  </button>
309
316
  {titleBlock}
310
317
  </div>
@@ -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(onBack)
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={onBack}
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
- {parent}
29
+ {effectiveParent}
26
30
  </button>
27
31
  {current !== undefined && (
28
32
  <>