@nar-bus/lena-ui-shared 1.3.11 → 1.3.13

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/dist/index.d.ts CHANGED
@@ -147,8 +147,8 @@ export declare interface AppHeaderLogo {
147
147
 
148
148
  export declare interface AppHeaderProps {
149
149
  breadcrumbs: BreadcrumbItem[];
150
- theme: 'light' | 'dark' | 'system';
151
- onThemeChange: (theme: 'light' | 'dark' | 'system') => void;
150
+ theme: 'light' | 'dark';
151
+ onThemeChange: (theme: 'light' | 'dark') => void;
152
152
  locale?: string;
153
153
  onLocaleChange?: (locale: string) => void;
154
154
  user?: AppHeaderUser | null;
@@ -239,6 +239,8 @@ declare interface AsyncSelectFieldProps<TFieldValues extends FieldValues> {
239
239
  cols?: 1 | 2 | 3 | 4 | 6 | 12;
240
240
  }
241
241
 
242
+ export declare function autoStatusColor(value: string): string;
243
+
242
244
  export declare function Avatar({ className, size, ...props }: React_2.ComponentProps<typeof AvatarPrimitive.Root> & {
243
245
  size?: "default" | "sm" | "lg";
244
246
  }): JSX.Element;
@@ -278,6 +280,10 @@ declare interface BadgeCellProps {
278
280
  className?: string;
279
281
  }
280
282
 
283
+ declare type BadgeSize = keyof typeof SIZE_STYLES;
284
+
285
+ declare type BadgeVariant = keyof typeof VARIANT_STYLES;
286
+
281
287
  export declare const badgeVariants: (props?: ({
282
288
  variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
283
289
  } & ClassProp) | undefined) => string;
@@ -347,6 +353,22 @@ export declare function BreadcrumbSeparator({ children, className, ...props }: R
347
353
 
348
354
  export declare function BreadcrumbUIItem({ className, ...props }: React_2.ComponentProps<"li">): JSX.Element;
349
355
 
356
+ /**
357
+ * Manifest groups + current pathname'den breadcrumb zinciri türetir.
358
+ *
359
+ * Children in manifest items are treated as tab-level navigation and are NOT
360
+ * included in the breadcrumb trail. The breadcrumb stops at the parent item.
361
+ *
362
+ * @example
363
+ * buildBreadcrumbsFromManifest(manifest.groups, '/device-management/meters', 'tr')
364
+ * // → [{ label: 'Envanter', href: '/brand-model' }, { label: 'Cihaz Yönetimi' }]
365
+ * // Note: 'Sayaçlar' (tab) is NOT included — breadcrumb stops at parent
366
+ *
367
+ * buildBreadcrumbsFromManifest(manifest.groups, '/simcard', 'tr')
368
+ * // → [{ label: 'Envanter', href: '/brand-model' }, { label: 'SIM Kartlar' }]
369
+ */
370
+ export declare function buildBreadcrumbsFromManifest(groups: ManifestGroup[], pathname: string, locale: string): BreadcrumbItem[];
371
+
350
372
  export declare interface BulkAction<TData> {
351
373
  id: string;
352
374
  label: string;
@@ -1688,6 +1710,17 @@ export declare interface GaugeFooterStat {
1688
1710
  colorClass?: string;
1689
1711
  }
1690
1712
 
1713
+ /**
1714
+ * Get a tone color class string from a base color family.
1715
+ * Each unique value gets a deterministic tone level within the family.
1716
+ * All class strings are pre-defined for Tailwind JIT compatibility.
1717
+ *
1718
+ * @example
1719
+ * generateToneColor('G_2', 'accent') // lighter cyan
1720
+ * generateToneColor('G_5', 'accent') // darker cyan
1721
+ */
1722
+ export declare function generateToneColor(value: string, baseColor: StatusColor): string;
1723
+
1691
1724
  /**
1692
1725
  * Get error path for highlighting in tree view
1693
1726
  */
@@ -1732,7 +1765,7 @@ export declare interface HeaderCreateButtonProps {
1732
1765
 
1733
1766
  export declare type HeaderGradient = 'teal' | 'navy' | 'cherry' | 'emerald' | 'amber' | 'violet' | 'rose' | 'indigo' | 'orange';
1734
1767
 
1735
- export declare function HeaderQuickSearch({ placeholder, value, onValueChange, open, onOpenChange, loading, shortcutKey, shouldFilter, className, children, }: HeaderQuickSearchProps): JSX.Element;
1768
+ export declare function HeaderQuickSearch({ placeholder, value, onValueChange, open, onOpenChange, loading, shortcutKey, shouldFilter, filter, className, children, }: HeaderQuickSearchProps): JSX.Element;
1736
1769
 
1737
1770
  export declare interface HeaderQuickSearchProps {
1738
1771
  placeholder?: string;
@@ -1743,6 +1776,8 @@ export declare interface HeaderQuickSearchProps {
1743
1776
  loading?: boolean;
1744
1777
  shortcutKey?: string;
1745
1778
  shouldFilter?: boolean;
1779
+ /** Custom filter function for cmdk (default: starts-with) */
1780
+ filter?: (value: string, search: string) => number;
1746
1781
  className?: string;
1747
1782
  children?: ReactNode;
1748
1783
  }
@@ -2192,6 +2227,22 @@ export declare interface LocationMapProps {
2192
2227
  className?: string;
2193
2228
  }
2194
2229
 
2230
+ export declare interface ManifestGroup {
2231
+ label?: string | ManifestTitle | null;
2232
+ href?: string;
2233
+ items: ManifestNavItem[];
2234
+ }
2235
+
2236
+ export declare interface ManifestNavItem {
2237
+ title: string | ManifestTitle;
2238
+ href: string;
2239
+ children?: ManifestNavItem[];
2240
+ }
2241
+
2242
+ declare interface ManifestTitle {
2243
+ [key: string]: string;
2244
+ }
2245
+
2195
2246
  export declare const MAP_TOOLTIP_OPTIONS: Partial<TooltipOptions>;
2196
2247
 
2197
2248
  /** Fixes Leaflet map sizing when rendered inside hidden tabs or collapsible panels */
@@ -2339,7 +2390,7 @@ export declare function PageErrorBoundary({ children }: {
2339
2390
  children: ReactNode;
2340
2391
  }): JSX.Element;
2341
2392
 
2342
- export declare function PageHeader({ title, description, icon: Icon, breadcrumbs, actions, className, onBreadcrumbsChange, }: PageHeaderProps): JSX.Element;
2393
+ export declare function PageHeader({ title, description, icon: Icon, actions, className, }: PageHeaderProps): JSX.Element;
2343
2394
 
2344
2395
  export declare interface PageHeaderProps {
2345
2396
  title: string;
@@ -2347,11 +2398,8 @@ export declare interface PageHeaderProps {
2347
2398
  icon: React.ComponentType<{
2348
2399
  className?: string;
2349
2400
  }>;
2350
- breadcrumbs: BreadcrumbItem[];
2351
2401
  actions?: React.ReactNode;
2352
2402
  className?: string;
2353
- /** Callback to sync breadcrumbs with external store (e.g. uiStore) */
2354
- onBreadcrumbsChange?: (breadcrumbs: BreadcrumbItem[]) => void;
2355
2403
  }
2356
2404
 
2357
2405
  export declare function Pagination({ className, ...props }: React_2.ComponentProps<"nav">): JSX.Element;
@@ -2420,6 +2468,43 @@ export declare function PopoverContent({ className, align, sideOffset, ...props
2420
2468
 
2421
2469
  export declare function PopoverTrigger({ ...props }: React_2.ComponentProps<typeof PopoverPrimitive.Trigger>): JSX.Element;
2422
2470
 
2471
+ export declare function PreviewSection({ title, children, className }: PreviewSectionProps): JSX.Element;
2472
+
2473
+ export declare interface PreviewSectionProps {
2474
+ title: string;
2475
+ children: ReactNode;
2476
+ className?: string;
2477
+ }
2478
+
2479
+ export declare function PreviewSheet({ open, onOpenChange, title, icon: Icon, headerGradient, badge, headerActions, footerActions, children, className, maxWidth, isLoading, closeLabel, }: PreviewSheetProps): JSX.Element;
2480
+
2481
+ export declare interface PreviewSheetProps {
2482
+ open: boolean;
2483
+ onOpenChange: (open: boolean) => void;
2484
+ title: string;
2485
+ /** Icon component rendered in the gradient header */
2486
+ icon?: ComponentType<{
2487
+ className?: string;
2488
+ style?: CSSProperties;
2489
+ }>;
2490
+ /** Gradient color theme for the header */
2491
+ headerGradient?: FormSheetGradient;
2492
+ /** Optional badge rendered next to the title */
2493
+ badge?: ReactNode;
2494
+ /** Action buttons rendered in the header (right side, replaces close button) */
2495
+ headerActions?: ReactNode;
2496
+ /** Action buttons rendered in the footer (right side) */
2497
+ footerActions?: ReactNode;
2498
+ children: ReactNode;
2499
+ className?: string;
2500
+ /** Sheet max width — defaults to 'lg' */
2501
+ maxWidth?: 'lg' | 'xl' | '2xl';
2502
+ /** Shows a centered loading spinner instead of children */
2503
+ isLoading?: boolean;
2504
+ /** Close button label override */
2505
+ closeLabel?: string;
2506
+ }
2507
+
2423
2508
  export declare const priorityColors: {
2424
2509
  readonly HIGH: "bg-status-error/10 text-status-error border-status-error/30 ring-status-error/30";
2425
2510
  readonly MEDIUM: "bg-status-warning/10 text-status-warning border-status-warning/30 ring-status-warning/30";
@@ -2839,6 +2924,12 @@ declare interface SimpleDataTableProps<TData> {
2839
2924
  headerTextColor?: string;
2840
2925
  }
2841
2926
 
2927
+ declare const SIZE_STYLES: {
2928
+ readonly xs: "px-1.5 py-0 text-2xs-plus";
2929
+ readonly sm: "px-2 py-0.5 text-2xs-plus";
2930
+ readonly md: "px-2.5 py-1 text-2xs-plus";
2931
+ };
2932
+
2842
2933
  export declare function Skeleton({ className, ...props }: React.ComponentProps<"div">): JSX.Element;
2843
2934
 
2844
2935
  export declare function Slider({ className, defaultValue, value, min, max, ...props }: React_2.ComponentProps<typeof SliderPrimitive.Root>): JSX.Element;
@@ -2875,41 +2966,72 @@ export declare interface StatCardProps {
2875
2966
  }
2876
2967
 
2877
2968
  /**
2878
- * Status badge for displaying enum/status values.
2879
- * Provides consistent styling across all tables.
2969
+ * Unified badge component for the entire platform.
2970
+ * Single source of truth for all badge styling — status, tags, counters, labels.
2880
2971
  *
2881
- * @example
2972
+ * @example Status badge with color mapping
2882
2973
  * ```tsx
2883
- * <StatusBadge
2884
- * value={row.status}
2885
- * colorMap={{
2886
- * ACTIVE: statusColors.success,
2887
- * INACTIVE: statusColors.neutral,
2888
- * }}
2889
- * labelMap={{
2890
- * ACTIVE: 'Active',
2891
- * INACTIVE: 'Inactive',
2892
- * }}
2893
- * showDot
2894
- * icon={<Wifi className="h-3 w-3" />}
2895
- * />
2974
+ * <StatusBadge value="ACTIVE" colorMap={colors} labelMap={labels} showDot />
2975
+ * ```
2976
+ *
2977
+ * @example Auto-colored enum (no colorMap needed)
2978
+ * ```tsx
2979
+ * <StatusBadge value={row.protocolName} autoColor />
2980
+ * ```
2981
+ *
2982
+ * @example Simple tag/label
2983
+ * ```tsx
2984
+ * <StatusBadge variant="outline">DLMS</StatusBadge>
2985
+ * ```
2986
+ *
2987
+ * @example Counter badge (xs size)
2988
+ * ```tsx
2989
+ * <StatusBadge variant="destructive" size="xs">{count}</StatusBadge>
2990
+ * ```
2991
+ *
2992
+ * @example Compact badge (sm size)
2993
+ * ```tsx
2994
+ * <StatusBadge variant="outline" size="sm">{label}</StatusBadge>
2896
2995
  * ```
2897
2996
  */
2898
- export declare function StatusBadge<T extends string>({ value, colorMap, labelMap, icon, showDot, dotColorMap, pulse, size, showLabel, className, }: StatusBadgeProps<T>): JSX.Element;
2899
-
2900
- declare interface StatusBadgeProps<T extends string> {
2901
- value: T | null | undefined;
2902
- colorMap: Record<T, string>;
2997
+ export declare function StatusBadge<T extends string>({ value, colorMap, autoColor, toneColor, labelMap, icon, iconMap, showDot, dotColorMap, pulse, size, showLabel, variant, accentColorMap, minWidth, children, showNullState, className, ...htmlProps }: StatusBadgeProps<T>): JSX.Element;
2998
+
2999
+ declare interface StatusBadgeBaseProps<T extends string> {
3000
+ /** Enum/status value used with colorMap for semantic coloring */
3001
+ value?: T | null | undefined;
3002
+ /** Map enum values to Tailwind color classes */
3003
+ colorMap?: Record<T, string>;
3004
+ /** Auto-assign color from value string hash (no colorMap needed) */
3005
+ autoColor?: boolean;
3006
+ /** Base color family for graduated tone coloring — each value gets a unique tone within the family */
3007
+ toneColor?: StatusColor;
3008
+ /** Map enum values to display labels */
2903
3009
  labelMap?: Record<T, string>;
3010
+ /** Global icon — same icon for all values */
2904
3011
  icon?: React.ReactNode;
3012
+ /** Per-value icon — different icon per enum value (takes priority over `icon`) */
3013
+ iconMap?: Partial<Record<T, React.ReactNode>>;
2905
3014
  showDot?: boolean;
2906
3015
  dotColorMap?: Record<T, string>;
2907
3016
  pulse?: boolean | Record<T, boolean>;
2908
- size?: 'sm' | 'md';
3017
+ /** xs: counter/mini | sm: compact | md: default */
3018
+ size?: BadgeSize;
2909
3019
  showLabel?: boolean;
3020
+ /** Visual variant */
3021
+ variant?: BadgeVariant;
3022
+ /** Accent bar color map for variant="mono" */
3023
+ accentColorMap?: Partial<Record<T, string>>;
3024
+ /** Optional min-width Tailwind class for table column alignment */
3025
+ minWidth?: string;
3026
+ /** Direct children — for simple tag/label/counter usage without value+colorMap */
3027
+ children?: React.ReactNode;
3028
+ /** Show null state when value is null/undefined. Default: true for value mode, false for children mode */
3029
+ showNullState?: boolean;
2910
3030
  className?: string;
2911
3031
  }
2912
3032
 
3033
+ declare type StatusBadgeProps<T extends string> = StatusBadgeBaseProps<T> & Omit<React.HTMLAttributes<HTMLSpanElement>, keyof StatusBadgeBaseProps<T>>;
3034
+
2913
3035
  export declare type StatusColor = keyof typeof statusColors;
2914
3036
 
2915
3037
  /**
@@ -3347,6 +3469,51 @@ export declare interface UrlState {
3347
3469
  f?: FilterState[];
3348
3470
  }
3349
3471
 
3472
+ /**
3473
+ * Enterprise breadcrumb hook — derives breadcrumbs from manifest groups + current route.
3474
+ *
3475
+ * @example
3476
+ * // Header.tsx
3477
+ * const breadcrumbs = useAutoBreadcrumbs({
3478
+ * groups: manifest.groups,
3479
+ * pathname,
3480
+ * locale,
3481
+ * tail, // from useBreadcrumbs() store
3482
+ * });
3483
+ */
3484
+ export declare function useAutoBreadcrumbs({ groups, pathname, locale, tail, }: UseAutoBreadcrumbsOptions): BreadcrumbItem[];
3485
+
3486
+ export declare interface UseAutoBreadcrumbsOptions {
3487
+ /** Manifest navigation groups (source of truth for breadcrumb hierarchy) */
3488
+ groups: ManifestGroup[];
3489
+ /** Current route pathname */
3490
+ pathname: string;
3491
+ /** Active locale for resolving multilingual titles */
3492
+ locale: string;
3493
+ /** Optional tail items from detail pages (appended to auto-breadcrumbs) */
3494
+ tail?: BreadcrumbItem[];
3495
+ }
3496
+
3497
+ /**
3498
+ * Declarative breadcrumb tail hook for detail pages.
3499
+ * Sets tail items on mount and auto-clears on unmount.
3500
+ * Uses deep comparison to avoid unnecessary updates.
3501
+ *
3502
+ * @param items - Breadcrumb items to append (undefined = skip, e.g. while loading)
3503
+ * @param setBreadcrumbs - Setter from store (e.g. useSetBreadcrumbs from lena-ui-core)
3504
+ *
3505
+ * @example
3506
+ * const setBreadcrumbs = useSetBreadcrumbs();
3507
+ * useBreadcrumbTail(
3508
+ * meter ? [
3509
+ * { label: 'Sayaçlar', href: '/device-management/meters' },
3510
+ * { label: meter.serialNumber },
3511
+ * ] : undefined,
3512
+ * setBreadcrumbs,
3513
+ * );
3514
+ */
3515
+ export declare function useBreadcrumbTail(items: BreadcrumbItem[] | undefined, setBreadcrumbs: (items: BreadcrumbItem[]) => void): void;
3516
+
3350
3517
  export declare function useDataTable<TData>(options: UseDataTableOptions<TData>): UseDataTableReturn<TData>;
3351
3518
 
3352
3519
  declare interface UseDataTableOptions<TData> extends CreateDataTableStoreOptions {
@@ -3740,6 +3907,15 @@ export declare interface ValidationStatusProps {
3740
3907
  showDetails?: boolean;
3741
3908
  }
3742
3909
 
3910
+ declare const VARIANT_STYLES: {
3911
+ readonly default: "";
3912
+ readonly mono: "font-mono tracking-tight";
3913
+ readonly outline: "border-border text-foreground ring-0 border";
3914
+ readonly secondary: "bg-secondary text-secondary-foreground ring-0";
3915
+ readonly destructive: "bg-destructive text-white ring-0";
3916
+ readonly ghost: "ring-0 text-foreground";
3917
+ };
3918
+
3743
3919
  /**
3744
3920
  * Adds monthly average fields to chart data.
3745
3921
  * Date format: "dd/MM" — groups by month part, calculates average per key.