@sfperusacdev/sf-ui 0.1.22 → 0.1.24

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.
@@ -0,0 +1,17 @@
1
+ import { ReactNode } from 'react';
2
+ type StatCardProps = {
3
+ value: ReactNode;
4
+ label: ReactNode;
5
+ /** color CSS del acento superior (y del icono); default var(--sf-success) */
6
+ accent?: string;
7
+ /** icono opcional; se pinta dentro de un halo del color del acento */
8
+ icon?: ReactNode;
9
+ className?: string;
10
+ };
11
+ /**
12
+ * Tarjeta KPI de los reportes (mockup transporte): franja superior de color,
13
+ * icono con halo, valor grande y label. El halo se deriva del acento con
14
+ * color-mix para no pedir dos colores.
15
+ */
16
+ export declare const StatCard: ({ value, label, accent, icon, className }: StatCardProps) => import("react").JSX.Element;
17
+ export {};
@@ -2,6 +2,7 @@ export { Stepper } from './Stepper';
2
2
  export type { StepperVariant } from './Stepper';
3
3
  export { TramoCard } from './TramoCard';
4
4
  export type { TramoCardTipo } from './TramoCard';
5
+ export { StatCard } from './StatCard';
5
6
  export { Calendar } from './Calendar';
6
7
  export { MONTH_NAMES, WEEKDAY_LABELS, toLocalYMD, parseYMD, buildMonthGrid } from './calendarUtils';
7
8
  export { DonutGauge, DonutGaugeRow } from './DonutGauge';
@@ -0,0 +1,9 @@
1
+ export type AppsGridIconProps = {
2
+ className?: string;
3
+ };
4
+ /**
5
+ * Lanzador de aplicaciones: cuadrícula de 9 puntos (3×3), el patrón que la
6
+ * gente reconoce como "ver todos los módulos". No usar `FiGrid` para esto:
7
+ * es una cuadrícula de 2×2 y se lee como "cambiar de vista", no como launcher.
8
+ */
9
+ export declare const AppsGridIcon: ({ className }: AppsGridIconProps) => import("react").JSX.Element;
@@ -1,2 +1,4 @@
1
+ export { AppsGridIcon } from './AppsGridIcon';
2
+ export type { AppsGridIconProps } from './AppsGridIcon';
1
3
  export { SyncIcon } from './SyncIcon';
2
4
  export type { SyncIconProps } from './SyncIcon';
@@ -10,6 +10,11 @@ export type AppShellNavItem = {
10
10
  * submenú largo sin cabeceras de sección. Se ignora en el primer item.
11
11
  */
12
12
  dividerBefore?: boolean;
13
+ /**
14
+ * Oculta el item sin sacarlo del árbol de navegación: útil para features
15
+ * detrás de bandera o permiso, donde la definición del menú es estática.
16
+ */
17
+ hidden?: boolean;
13
18
  };
14
19
  export type AppShellCategory = {
15
20
  id: string;
@@ -44,6 +49,9 @@ export type AppShellModuleLauncher = {
44
49
  items: AppShellModuleLauncherItem[];
45
50
  title?: string;
46
51
  subtitle?: string;
52
+ /** Ícono del botón que abre el lanzador. Por defecto, la cuadrícula de 9 puntos. */
53
+ triggerIcon?: ReactNode;
54
+ ariaLabel?: string;
47
55
  };
48
56
  export type AppShellUserMenu = {
49
57
  fullName: string;
@@ -19,7 +19,28 @@ type CustomColumn<TData> = {
19
19
  enableHiding?: boolean;
20
20
  size?: number;
21
21
  };
22
- type CustomTableProps<TData extends Record<string, unknown>> = {
22
+ /**
23
+ * Configuración de las filas de detalle expandibles (master-detail).
24
+ *
25
+ * Se puede usar de dos maneras excluyentes:
26
+ * - `render`: contenido libre bajo la fila padre (tiene prioridad si se define).
27
+ * - `getRows` + `columns`: sub-tabla renderizada con el propio `CustomTable` en modo `embedded`.
28
+ */
29
+ type CustomTableDetail<TData, TDetail extends Record<string, unknown> = Record<string, unknown>> = {
30
+ /** Render libre del detalle. Si se define, ignora `getRows`/`columns`. */
31
+ render?: (row: TData) => ReactNode;
32
+ /** Filas hijas de la fila padre; se muestran en una sub-tabla. */
33
+ getRows?: (row: TData) => TDetail[];
34
+ /** Columnas de la sub-tabla de detalle. Requerido cuando se usa `getRows`. */
35
+ columns?: CustomColumn<TDetail>[];
36
+ /** Estado inicial del detalle: booleano global o predicado por fila. Por defecto `false`. */
37
+ defaultExpanded?: boolean | ((row: TData) => boolean);
38
+ /** Deshabilita el chevron para filas sin detalle. Por defecto todas son expandibles. */
39
+ isExpandable?: (row: TData) => boolean;
40
+ /** Mensaje de la sub-tabla cuando no hay filas hijas. */
41
+ emptyMessage?: string;
42
+ };
43
+ type CustomTableProps<TData extends Record<string, unknown>, TDetail extends Record<string, unknown> = Record<string, unknown>> = {
23
44
  id?: string;
24
45
  stateStore?: AsyncStateStore;
25
46
  data: TData[];
@@ -77,7 +98,12 @@ type CustomTableProps<TData extends Record<string, unknown>> = {
77
98
  headerVariant?: TableHeaderVariant;
78
99
  /** Oculta título, toolbar y chrome exterior — para uso dentro de ExpandableTableSection u otros contenedores. */
79
100
  embedded?: boolean;
101
+ /**
102
+ * Filas de detalle expandibles (master-detail). Agrega una columna de chevron al inicio
103
+ * y, al expandir, inserta una fila con el detalle debajo de la fila padre.
104
+ */
105
+ detail?: CustomTableDetail<TData, TDetail>;
80
106
  controller?: CustomTableController<TData>;
81
107
  };
82
- export declare function CustomTable<TData extends Record<string, unknown>>({ id, stateStore, data, columns, grouping, defaultGrouping, enableGrouping, enableSorting, enableFiltering, enablePagination, pageSize, fillParentHeight, maxBodyHeightPx, className, emptyMessage, title, subtitle, sidePanel, onGroupingChange, toolbarSlot, belowToolbarSlot, loading, loadingMessage, isFetching, error, onRetry, onRefresh, onRowClick, enableRowSelection, getRowActions, getBulkActions, bulkActionsSlot, onSelectionChange, headerVariant, embedded, controller, }: CustomTableProps<TData>): import("react").JSX.Element;
83
- export type { CustomColumn, CustomTableProps, TableAggregation };
108
+ export declare function CustomTable<TData extends Record<string, unknown>, TDetail extends Record<string, unknown> = Record<string, unknown>>({ id, stateStore, data, columns, grouping, defaultGrouping, enableGrouping, enableSorting, enableFiltering, enablePagination, pageSize, fillParentHeight, maxBodyHeightPx, className, emptyMessage, title, subtitle, sidePanel, onGroupingChange, toolbarSlot, belowToolbarSlot, loading, loadingMessage, isFetching, error, onRetry, onRefresh, onRowClick, enableRowSelection, getRowActions, getBulkActions, bulkActionsSlot, onSelectionChange, headerVariant, embedded, detail, controller, }: CustomTableProps<TData, TDetail>): import("react").JSX.Element;
109
+ export type { CustomColumn, CustomTableDetail, CustomTableProps, TableAggregation };
@@ -1,9 +1,17 @@
1
+ import { ReactNode } from 'react';
1
2
  export type EditableColumn<T extends Record<string, unknown>> = {
2
3
  id: keyof T & string;
3
4
  header: string;
4
5
  editable?: boolean;
5
6
  sortable?: boolean;
6
7
  align?: "left" | "right";
8
+ /** tipo del input en modo form (default "text") */
9
+ type?: "text" | "date" | "number";
10
+ placeholder?: string;
11
+ /** ancho CSS de la columna (p.ej. "2fr" no aplica: usar "220px" o "20%") */
12
+ width?: string;
13
+ /** celda custom en modo form (p.ej. botón PDF); recibe la fila y su índice real */
14
+ render?: (row: T, originalIndex: number) => ReactNode;
7
15
  };
8
16
  export type EditableDataGridProps<T extends Record<string, unknown>> = {
9
17
  data: T[];
@@ -11,5 +19,26 @@ export type EditableDataGridProps<T extends Record<string, unknown>> = {
11
19
  rowKey: keyof T & string;
12
20
  onChange?: (next: T[]) => void;
13
21
  className?: string;
22
+ /**
23
+ * - "cell" (default): la tabla se ve como texto y se edita celda a celda
24
+ * (doble clic / Enter), comportamiento histórico.
25
+ * - "form": grilla del mockup transporte — inputs siempre visibles por
26
+ * celda, columna #, botón para agregar fila en blanco y ✕ para quitar.
27
+ */
28
+ mode?: "cell" | "form";
29
+ /** modo form: muestra la columna # con el número de fila */
30
+ showIndex?: boolean;
31
+ /** modo form: agrega una fila en blanco (el consumidor la fabrica) */
32
+ onAddRow?: () => void;
33
+ addLabel?: string;
34
+ /** modo form: quita la fila (el consumidor decide si es delete o descarte) */
35
+ onRemoveRow?: (row: T, originalIndex: number) => void;
36
+ /** título del toolbar (p.ej. "Contactos · 8") */
37
+ title?: ReactNode;
38
+ /** paginación en cliente (mockup: "Mostrar 5 por página") */
39
+ pageSize?: number;
40
+ emptyMessage?: string;
14
41
  };
15
- export declare const EditableDataGrid: <T extends Record<string, unknown>>({ data, columns, rowKey, onChange, className, }: EditableDataGridProps<T>) => import("react").JSX.Element;
42
+ /** true si TODOS los campos indicados están vacíos ("" / null / undefined / 0 no cuenta como vacío) */
43
+ export declare const isBlankRow: <T extends object>(row: T, keys: Array<keyof T & string>) => boolean;
44
+ export declare const EditableDataGrid: <T extends Record<string, unknown>>({ data, columns, rowKey, onChange, className, mode, showIndex, onAddRow, addLabel, onRemoveRow, title, pageSize, emptyMessage, }: EditableDataGridProps<T>) => import("react").JSX.Element;
@@ -1,5 +1,5 @@
1
1
  export { CustomTable } from './CustomTable';
2
- export type { CustomColumn, CustomTableProps, TableHeaderVariant } from './CustomTable';
2
+ export type { CustomColumn, CustomTableDetail, CustomTableProps, TableHeaderVariant } from './CustomTable';
3
3
  export { AsyncCustomTable } from './AsyncCustomTable';
4
4
  export type { AsyncCustomTableProps } from './AsyncCustomTable';
5
5
  export { PaginationRangeInput } from './PaginationRangeInput';
@@ -20,7 +20,7 @@ export { ActiveFiltersBar } from './ActiveFiltersBar';
20
20
  export type { ActiveFiltersBarProps } from './ActiveFiltersBar';
21
21
  export { buildActiveFilterChips, formatColumnFilterValue } from './activeFilterUtils';
22
22
  export type { ActiveFilterChip } from './activeFilterUtils';
23
- export { EditableDataGrid } from './EditableDataGrid';
23
+ export { EditableDataGrid, isBlankRow } from './EditableDataGrid';
24
24
  export type { EditableColumn, EditableDataGridProps } from './EditableDataGrid';
25
25
  export { ExpandableTableSection } from './ExpandableTableSection';
26
26
  export type { ExpandableTableSectionItem, ExpandableTableSectionProps, ExpandableTableSectionTableConfig, } from './ExpandableTableSection';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sfperusacdev/sf-ui",
3
- "version": "0.1.22",
3
+ "version": "0.1.24",
4
4
  "description": "SF UI — librería de componentes React (inputs, tablas, hooks) para aplicaciones SF Perú.",
5
5
  "type": "module",
6
6
  "main": "./dist/sf-ui.umd.cjs",