@sfperusacdev/sf-ui 0.1.21 → 0.1.23

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';
@@ -11,11 +11,15 @@ type InputProps<TFormValues extends FieldValues> = {
11
11
  className?: string;
12
12
  placeholder?: string;
13
13
  readOnly?: boolean;
14
+ /** límites nativos para type="number" (y step opcional) */
15
+ min?: number | string;
16
+ max?: number | string;
17
+ step?: number | string;
14
18
  onChange?: (value: string) => void;
15
19
  icon?: IconType;
16
20
  small?: boolean;
17
21
  onIconClick?: () => Promise<void> | void;
18
22
  onRefresh?: () => Promise<void> | void;
19
23
  };
20
- export declare const Input: <TFormValues extends FieldValues>({ form, name, label, info, required, type, className, placeholder, readOnly, onChange, icon, small, onIconClick, onRefresh, }: InputProps<TFormValues>) => React.JSX.Element;
24
+ export declare const Input: <TFormValues extends FieldValues>({ form, name, label, info, required, type, className, placeholder, readOnly, min, max, step, onChange, icon, small, onIconClick, onRefresh, }: InputProps<TFormValues>) => React.JSX.Element;
21
25
  export {};
@@ -0,0 +1,37 @@
1
+ import { FieldValues, Path, UseFormReturn } from 'react-hook-form';
2
+ export type DateRangeAdjustEnd = "start" | "month-end" | "none";
3
+ type DateRangeFieldsProps<TFormValues extends FieldValues> = {
4
+ form: UseFormReturn<TFormValues>;
5
+ startName: Path<TFormValues>;
6
+ endName: Path<TFormValues>;
7
+ startLabel?: string;
8
+ endLabel?: string;
9
+ required?: boolean;
10
+ /** por defecto hereda `required`; útil para rangos con fin opcional */
11
+ endRequired?: boolean;
12
+ small?: boolean;
13
+ readOnlyEnd?: boolean;
14
+ /**
15
+ * Qué hacer cuando el fin queda antes del inicio:
16
+ * - "start": el fin se iguala al inicio (default)
17
+ * - "month-end": el fin salta al último día del mes del inicio (contratos)
18
+ * - "none": no autocorrige (el `min` nativo igual limita el calendario)
19
+ */
20
+ adjustEnd?: DateRangeAdjustEnd;
21
+ /** notifica la autocorrección (para que el consumidor muestre su toast) */
22
+ onEndAdjusted?: (nuevaFecha: string) => void;
23
+ className?: string;
24
+ };
25
+ /**
26
+ * Par de fechas Desde/Hasta ligado a DOS campos planos del formulario
27
+ * (p.ej. `fecha_inicio` / `fecha_fin` de un entity), cada uno con su label.
28
+ * El calendario del fin no permite fechas anteriores al inicio (min nativo)
29
+ * y, si igual queda un rango invertido (tipeo manual, cambio del inicio),
30
+ * el fin se autocorrige según `adjustEnd`.
31
+ *
32
+ * Diferencia con `DateRangeInput`: aquel es UN solo campo cuyo valor es un
33
+ * objeto `{start, end}` (con soporte UTC) — ideal para filtros; este mapea
34
+ * directo a columnas del entity, que es el caso de los mantenimientos.
35
+ */
36
+ export declare const DateRangeFields: <TFormValues extends FieldValues>({ form, startName, endName, startLabel, endLabel, required, endRequired, small, readOnlyEnd, adjustEnd, onEndAdjusted, className, }: DateRangeFieldsProps<TFormValues>) => import("react").JSX.Element;
37
+ export {};
@@ -1,5 +1,7 @@
1
1
  export { DateRangeInput } from './DateRangeInput';
2
2
  export type { DateRangeInputProps } from './DateRangeInput';
3
+ export { DateRangeFields } from './DateRangeFields';
4
+ export type { DateRangeAdjustEnd } from './DateRangeFields';
3
5
  export { DateRangeUtcInput } from './DateRangeUtcInput';
4
6
  export { TimeRangeInput } from './TimeRangeInput';
5
7
  export type { TimeRangeInputProps } from './TimeRangeInput';
@@ -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;
@@ -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.21",
3
+ "version": "0.1.23",
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",