@zauru-sdk/components 6.5.5 → 6.6.0

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/CHANGELOG.md CHANGED
@@ -3,6 +3,28 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [6.6.0](https://github.com/intuitiva/zauru-typescript-sdk/compare/@zauru-sdk/components@6.5.6...@zauru-sdk/components@6.6.0) (2026-09-18)
7
+
8
+
9
+ ### Features
10
+
11
+ * registrar reglas automáticas de % rechazo en el historial ([4784849](https://github.com/intuitiva/zauru-typescript-sdk/commit/4784849904f9ac6570e60543895a858dece8e039))
12
+
13
+
14
+
15
+
16
+
17
+ ## [6.5.6](https://github.com/intuitiva/zauru-typescript-sdk/compare/@zauru-sdk/components@6.5.5...@zauru-sdk/components@6.5.6) (2026-09-17)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * resolver width % de ZauruTable contra el contenedor ([9518a4d](https://github.com/intuitiva/zauru-typescript-sdk/commit/9518a4d8d40d7655b26e0e25450e20cba271ac34))
23
+
24
+
25
+
26
+
27
+
6
28
  ## [6.5.5](https://github.com/intuitiva/zauru-typescript-sdk/compare/@zauru-sdk/components@6.5.4...@zauru-sdk/components@6.5.5) (2026-09-16)
7
29
 
8
30
 
@@ -0,0 +1,23 @@
1
+ export type RejectionPercentageHistoryItem = {
2
+ discount: number;
3
+ description?: string;
4
+ agency_id?: number;
5
+ employee_id?: number;
6
+ employee_name?: string;
7
+ created_at?: string;
8
+ type?: string;
9
+ };
10
+ type NamedRecord = {
11
+ id?: number;
12
+ name?: string;
13
+ };
14
+ export type RejectionPercentageHistoryListProps = {
15
+ items: RejectionPercentageHistoryItem[];
16
+ employees?: NamedRecord[];
17
+ agencies?: NamedRecord[];
18
+ actorLabel?: string;
19
+ emptyText?: string;
20
+ className?: string;
21
+ };
22
+ export declare const RejectionPercentageHistoryList: ({ items, employees, agencies, actorLabel, emptyText, className, }: RejectionPercentageHistoryListProps) => import("react/jsx-runtime").JSX.Element;
23
+ export {};
@@ -0,0 +1 @@
1
+ export * from "./RejectionPercentageHistoryList.js";
@@ -0,0 +1,55 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { isAutomaticRejectionRuleHistoryType, toFixedIfNeeded, } from "@zauru-sdk/common";
3
+ const formatHistoryDate = (value) => {
4
+ if (!value)
5
+ return "";
6
+ const date = new Date(value);
7
+ if (Number.isNaN(date.getTime()))
8
+ return value;
9
+ return new Intl.DateTimeFormat("es-GT", {
10
+ day: "2-digit",
11
+ month: "2-digit",
12
+ year: "numeric",
13
+ hour: "2-digit",
14
+ minute: "2-digit",
15
+ hour12: false,
16
+ })
17
+ .format(date)
18
+ .replace(",", "");
19
+ };
20
+ const formatSignedPercentage = (value, forceSign) => {
21
+ const formatted = toFixedIfNeeded(Math.abs(value));
22
+ if (value < 0)
23
+ return `-${formatted}%`;
24
+ if (forceSign && value > 0)
25
+ return `+${formatted}%`;
26
+ return `${formatted}%`;
27
+ };
28
+ const findName = (records, id) => {
29
+ if (id == null)
30
+ return undefined;
31
+ return records?.find((record) => record.id === id)?.name;
32
+ };
33
+ export const RejectionPercentageHistoryList = ({ items, employees, agencies, actorLabel = "Empleado", emptyText = "No hay historial de porcentajes registrado", className = "", }) => {
34
+ if (!items.length) {
35
+ return _jsx("p", { className: "text-gray-500 italic", children: emptyText });
36
+ }
37
+ return (_jsx("div", { className: `space-y-3 max-h-60 overflow-y-auto ${className}`.trim(), children: items.map((item, index) => {
38
+ const isAutomatic = isAutomaticRejectionRuleHistoryType(item.type);
39
+ const employeeName = item.employee_name?.trim() ||
40
+ findName(employees, item.employee_id) ||
41
+ (item.employee_id != null ? `ID: ${item.employee_id}` : "No especificado");
42
+ const agencyName = findName(agencies, item.agency_id) ||
43
+ (item.agency_id != null ? `ID: ${item.agency_id}` : "No especificada");
44
+ const description = item.description || "Sin descripción";
45
+ return (_jsxs("div", { className: isAutomatic
46
+ ? "border border-indigo-200 rounded-lg p-3 bg-indigo-50"
47
+ : "border border-gray-100 rounded-lg p-3 bg-gray-50", children: [_jsxs("div", { className: "flex justify-between items-start gap-3 mb-2", children: [_jsxs("div", { className: "flex items-center gap-2 min-w-0", children: [_jsx("span", { className: isAutomatic
48
+ ? "font-semibold text-indigo-800"
49
+ : "font-semibold text-blue-600", children: formatSignedPercentage(Number(item.discount) || 0, isAutomatic) }), isAutomatic ? (_jsx("span", { className: "shrink-0 whitespace-nowrap rounded-full bg-indigo-100 px-2 py-0.5 text-xs font-medium text-indigo-800", children: "Autom\u00E1tico" })) : null] }), item.created_at ? (_jsx("span", { className: "text-xs text-gray-500 shrink-0", children: formatHistoryDate(item.created_at) })) : null] }), _jsx("p", { className: isAutomatic
50
+ ? "text-sm text-indigo-900 mb-1"
51
+ : "text-sm text-gray-700 mb-1", title: description, children: description }), _jsxs("div", { className: "flex justify-between gap-3 text-xs text-gray-500", children: [_jsx("span", { className: "min-w-0", children: isAutomatic
52
+ ? "Aplicado por el sistema"
53
+ : `${actorLabel}: ${employeeName}` }), _jsxs("span", { className: "shrink-0", children: ["Agencia: ", agencyName] })] })] }, `${item.created_at ?? "entry"}-${item.type ?? "manual"}-${index}`));
54
+ }) }));
55
+ };
@@ -0,0 +1 @@
1
+ export * from "./RejectionPercentageHistoryList.js";
@@ -13,15 +13,15 @@ const headerTextWrapStyle = {
13
13
  wordBreak: "normal",
14
14
  lineHeight: "1.25",
15
15
  };
16
- const fullContentWidthStyle = {
17
- width: "max-content",
16
+ const fillContainerWidthStyle = {
17
+ width: "100%",
18
18
  minWidth: "100%",
19
19
  maxWidth: "none",
20
20
  };
21
21
  const customStyles = {
22
22
  table: {
23
23
  style: {
24
- ...fullContentWidthStyle,
24
+ ...fillContainerWidthStyle,
25
25
  },
26
26
  },
27
27
  tableWrapper: {
@@ -43,7 +43,7 @@ const customStyles = {
43
43
  },
44
44
  head: {
45
45
  style: {
46
- ...fullContentWidthStyle,
46
+ ...fillContainerWidthStyle,
47
47
  },
48
48
  },
49
49
  headRow: {
@@ -51,7 +51,7 @@ const customStyles = {
51
51
  minHeight: "40px",
52
52
  height: "auto",
53
53
  alignItems: "stretch",
54
- ...fullContentWidthStyle,
54
+ ...fillContainerWidthStyle,
55
55
  },
56
56
  denseStyle: {
57
57
  minHeight: "36px",
@@ -98,7 +98,7 @@ const customStyles = {
98
98
  },
99
99
  rows: {
100
100
  style: {
101
- ...fullContentWidthStyle,
101
+ ...fillContainerWidthStyle,
102
102
  },
103
103
  highlightOnHoverStyle: {
104
104
  backgroundColor: "rgb(230, 244, 244)",
@@ -233,7 +233,18 @@ export const ZauruTable = (props) => {
233
233
  if (!column || typeof column !== "object") {
234
234
  return column;
235
235
  }
236
- return { wrap: true, ...column };
236
+ const next = { wrap: true, ...column };
237
+ // RDT `width` sets both min-width and max-width, wiping a px floor.
238
+ // Keep % as flex-basis so minWidth/maxWidth/grow still apply.
239
+ if (typeof next.width === "string" && next.width.endsWith("%")) {
240
+ const pct = next.width;
241
+ delete next.width;
242
+ next.style = {
243
+ flexBasis: pct,
244
+ ...next.style,
245
+ };
246
+ }
247
+ return next;
237
248
  })
238
249
  : columns;
239
250
  return (_jsx("div", { className: "w-full min-w-0 max-w-full overflow-x-auto", children: _jsx(DataTable, { className: className, subHeaderWrap: true, theme: theme ?? "solarized", columns: normalizedColumns, conditionalRowStyles: conditionalRowStyles, data: filteredData, customStyles: customStyles, progressPending: loading, highlightOnHover: true, pointerOnHover: true, dense: true, striped: true, pagination: !whitOutPagination, persistTableHead: true, responsive: true, noHeader: true, expandableRows: !!expandable, expandOnRowClicked: !!expandable, expandableRowExpanded: expandable ? expandable.expandableRowExpanded : undefined, expandableRowsComponent: expandable ? expandable.expandableRowsComponent : undefined, subHeader: loadSubHeader, subHeaderComponent: subHeaderComponent, paginationServer: !!pagination, paginationTotalRows: pagination?.totalRows ?? undefined, onChangeRowsPerPage: pagination ? handlePerRowsChange : undefined, onChangePage: pagination ? handlePageChange : undefined, paginationComponentOptions: paginationComponentOptions, paginationRowsPerPageOptions: pagination?.rowsPerPageOptions
package/dist/esm/index.js CHANGED
@@ -27,3 +27,4 @@ export * from "./HOC/ValidateEmployeeAccess/index.js";
27
27
  export * from "./Routes/index.js";
28
28
  export * from "./SidePanel/index.js";
29
29
  export * from "./observability/index.js";
30
+ export * from "./DiscountHistory/index.js";
package/dist/index.d.ts CHANGED
@@ -27,3 +27,4 @@ export * from "./HOC/ValidateEmployeeAccess/index.js";
27
27
  export * from "./Routes/index.js";
28
28
  export * from "./SidePanel/index.js";
29
29
  export * from "./observability/index.js";
30
+ export * from "./DiscountHistory/index.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zauru-sdk/components",
3
- "version": "6.5.5",
3
+ "version": "6.6.0",
4
4
  "description": "Componentes reutilizables en las WebApps de Zauru.",
5
5
  "main": "./dist/esm/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -44,12 +44,12 @@
44
44
  "@reduxjs/toolkit": "^2.2.1",
45
45
  "@remix-run/node": "^2.8.1",
46
46
  "@remix-run/react": "^2.8.1",
47
- "@zauru-sdk/common": "^6.6.0",
48
- "@zauru-sdk/hooks": "^6.3.11",
47
+ "@zauru-sdk/common": "^6.7.0",
48
+ "@zauru-sdk/hooks": "^6.3.12",
49
49
  "@zauru-sdk/icons": "^6.0.0",
50
- "@zauru-sdk/redux": "^6.5.9",
51
- "@zauru-sdk/types": "^6.16.0",
52
- "@zauru-sdk/utils": "^6.16.1",
50
+ "@zauru-sdk/redux": "^6.5.10",
51
+ "@zauru-sdk/types": "^6.17.0",
52
+ "@zauru-sdk/utils": "^6.17.0",
53
53
  "browser-image-compression": "^2.0.2",
54
54
  "framer-motion": "^12.0.0",
55
55
  "jsonwebtoken": "^9.0.2",
@@ -62,5 +62,5 @@
62
62
  "styled-components": "^5.3.5",
63
63
  "zod": "^3.23.8"
64
64
  },
65
- "gitHead": "c157999c77c4d4a5cbb926466b8f3947b00f12f4"
65
+ "gitHead": "d3483aa3b55a9a692f955e6a56d13f33b70db1c4"
66
66
  }
@@ -0,0 +1,145 @@
1
+ import React from "react";
2
+ import {
3
+ isAutomaticRejectionRuleHistoryType,
4
+ toFixedIfNeeded,
5
+ } from "@zauru-sdk/common";
6
+
7
+ export type RejectionPercentageHistoryItem = {
8
+ discount: number;
9
+ description?: string;
10
+ agency_id?: number;
11
+ employee_id?: number;
12
+ employee_name?: string;
13
+ created_at?: string;
14
+ type?: string;
15
+ };
16
+
17
+ type NamedRecord = {
18
+ id?: number;
19
+ name?: string;
20
+ };
21
+
22
+ export type RejectionPercentageHistoryListProps = {
23
+ items: RejectionPercentageHistoryItem[];
24
+ employees?: NamedRecord[];
25
+ agencies?: NamedRecord[];
26
+ actorLabel?: string;
27
+ emptyText?: string;
28
+ className?: string;
29
+ };
30
+
31
+ const formatHistoryDate = (value?: string): string => {
32
+ if (!value) return "";
33
+ const date = new Date(value);
34
+ if (Number.isNaN(date.getTime())) return value;
35
+ return new Intl.DateTimeFormat("es-GT", {
36
+ day: "2-digit",
37
+ month: "2-digit",
38
+ year: "numeric",
39
+ hour: "2-digit",
40
+ minute: "2-digit",
41
+ hour12: false,
42
+ })
43
+ .format(date)
44
+ .replace(",", "");
45
+ };
46
+
47
+ const formatSignedPercentage = (
48
+ value: number,
49
+ forceSign: boolean,
50
+ ): string => {
51
+ const formatted = toFixedIfNeeded(Math.abs(value));
52
+ if (value < 0) return `-${formatted}%`;
53
+ if (forceSign && value > 0) return `+${formatted}%`;
54
+ return `${formatted}%`;
55
+ };
56
+
57
+ const findName = (
58
+ records: NamedRecord[] | undefined,
59
+ id: number | undefined,
60
+ ): string | undefined => {
61
+ if (id == null) return undefined;
62
+ return records?.find((record) => record.id === id)?.name;
63
+ };
64
+
65
+ export const RejectionPercentageHistoryList = ({
66
+ items,
67
+ employees,
68
+ agencies,
69
+ actorLabel = "Empleado",
70
+ emptyText = "No hay historial de porcentajes registrado",
71
+ className = "",
72
+ }: RejectionPercentageHistoryListProps) => {
73
+ if (!items.length) {
74
+ return <p className="text-gray-500 italic">{emptyText}</p>;
75
+ }
76
+
77
+ return (
78
+ <div className={`space-y-3 max-h-60 overflow-y-auto ${className}`.trim()}>
79
+ {items.map((item, index) => {
80
+ const isAutomatic = isAutomaticRejectionRuleHistoryType(item.type);
81
+ const employeeName =
82
+ item.employee_name?.trim() ||
83
+ findName(employees, item.employee_id) ||
84
+ (item.employee_id != null ? `ID: ${item.employee_id}` : "No especificado");
85
+ const agencyName =
86
+ findName(agencies, item.agency_id) ||
87
+ (item.agency_id != null ? `ID: ${item.agency_id}` : "No especificada");
88
+ const description = item.description || "Sin descripción";
89
+
90
+ return (
91
+ <div
92
+ key={`${item.created_at ?? "entry"}-${item.type ?? "manual"}-${index}`}
93
+ className={
94
+ isAutomatic
95
+ ? "border border-indigo-200 rounded-lg p-3 bg-indigo-50"
96
+ : "border border-gray-100 rounded-lg p-3 bg-gray-50"
97
+ }
98
+ >
99
+ <div className="flex justify-between items-start gap-3 mb-2">
100
+ <div className="flex items-center gap-2 min-w-0">
101
+ <span
102
+ className={
103
+ isAutomatic
104
+ ? "font-semibold text-indigo-800"
105
+ : "font-semibold text-blue-600"
106
+ }
107
+ >
108
+ {formatSignedPercentage(Number(item.discount) || 0, isAutomatic)}
109
+ </span>
110
+ {isAutomatic ? (
111
+ <span className="shrink-0 whitespace-nowrap rounded-full bg-indigo-100 px-2 py-0.5 text-xs font-medium text-indigo-800">
112
+ Automático
113
+ </span>
114
+ ) : null}
115
+ </div>
116
+ {item.created_at ? (
117
+ <span className="text-xs text-gray-500 shrink-0">
118
+ {formatHistoryDate(item.created_at)}
119
+ </span>
120
+ ) : null}
121
+ </div>
122
+ <p
123
+ className={
124
+ isAutomatic
125
+ ? "text-sm text-indigo-900 mb-1"
126
+ : "text-sm text-gray-700 mb-1"
127
+ }
128
+ title={description}
129
+ >
130
+ {description}
131
+ </p>
132
+ <div className="flex justify-between gap-3 text-xs text-gray-500">
133
+ <span className="min-w-0">
134
+ {isAutomatic
135
+ ? "Aplicado por el sistema"
136
+ : `${actorLabel}: ${employeeName}`}
137
+ </span>
138
+ <span className="shrink-0">Agencia: {agencyName}</span>
139
+ </div>
140
+ </div>
141
+ );
142
+ })}
143
+ </div>
144
+ );
145
+ };
@@ -0,0 +1 @@
1
+ export * from "./RejectionPercentageHistoryList.js";
@@ -20,8 +20,8 @@ const headerTextWrapStyle = {
20
20
  lineHeight: "1.25",
21
21
  } as const;
22
22
 
23
- const fullContentWidthStyle = {
24
- width: "max-content",
23
+ const fillContainerWidthStyle = {
24
+ width: "100%",
25
25
  minWidth: "100%",
26
26
  maxWidth: "none",
27
27
  } as const;
@@ -29,7 +29,7 @@ const fullContentWidthStyle = {
29
29
  const customStyles: TableStyles = {
30
30
  table: {
31
31
  style: {
32
- ...fullContentWidthStyle,
32
+ ...fillContainerWidthStyle,
33
33
  },
34
34
  },
35
35
  tableWrapper: {
@@ -51,7 +51,7 @@ const customStyles: TableStyles = {
51
51
  },
52
52
  head: {
53
53
  style: {
54
- ...fullContentWidthStyle,
54
+ ...fillContainerWidthStyle,
55
55
  },
56
56
  },
57
57
  headRow: {
@@ -59,7 +59,7 @@ const customStyles: TableStyles = {
59
59
  minHeight: "40px",
60
60
  height: "auto",
61
61
  alignItems: "stretch",
62
- ...fullContentWidthStyle,
62
+ ...fillContainerWidthStyle,
63
63
  },
64
64
  denseStyle: {
65
65
  minHeight: "36px",
@@ -106,7 +106,7 @@ const customStyles: TableStyles = {
106
106
  },
107
107
  rows: {
108
108
  style: {
109
- ...fullContentWidthStyle,
109
+ ...fillContainerWidthStyle,
110
110
  },
111
111
  highlightOnHoverStyle: {
112
112
  backgroundColor: "rgb(230, 244, 244)",
@@ -312,7 +312,18 @@ export const ZauruTable = (props: Props) => {
312
312
  if (!column || typeof column !== "object") {
313
313
  return column;
314
314
  }
315
- return { wrap: true, ...column };
315
+ const next = { wrap: true, ...column };
316
+ // RDT `width` sets both min-width and max-width, wiping a px floor.
317
+ // Keep % as flex-basis so minWidth/maxWidth/grow still apply.
318
+ if (typeof next.width === "string" && next.width.endsWith("%")) {
319
+ const pct = next.width;
320
+ delete next.width;
321
+ next.style = {
322
+ flexBasis: pct,
323
+ ...next.style,
324
+ };
325
+ }
326
+ return next;
316
327
  })
317
328
  : columns;
318
329
 
package/src/index.ts CHANGED
@@ -27,3 +27,4 @@ export * from "./HOC/ValidateEmployeeAccess/index.js";
27
27
  export * from "./Routes/index.js";
28
28
  export * from "./SidePanel/index.js";
29
29
  export * from "./observability/index.js";
30
+ export * from "./DiscountHistory/index.js";