next-recomponents 1.4.2 → 1.4.4

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.mts CHANGED
@@ -141,4 +141,9 @@ interface Props extends React$1.DetailedHTMLProps<React$1.DialogHTMLAttributes<H
141
141
  }
142
142
  declare function Modal({ button, children, ref }: Props): react_jsx_runtime.JSX.Element;
143
143
 
144
- export { Alert, Button, Container, Form, Input, Modal, Select, Table, TextArea, regularExpresions, useResources };
144
+ type PreProps = {
145
+ data: string;
146
+ };
147
+ declare const Pre: React$1.FC<PreProps>;
148
+
149
+ export { Alert, Button, Container, Form, Input, Modal, Pre, Select, Table, TextArea, regularExpresions, useResources };
package/dist/index.d.ts CHANGED
@@ -141,4 +141,9 @@ interface Props extends React$1.DetailedHTMLProps<React$1.DialogHTMLAttributes<H
141
141
  }
142
142
  declare function Modal({ button, children, ref }: Props): react_jsx_runtime.JSX.Element;
143
143
 
144
- export { Alert, Button, Container, Form, Input, Modal, Select, Table, TextArea, regularExpresions, useResources };
144
+ type PreProps = {
145
+ data: string;
146
+ };
147
+ declare const Pre: React$1.FC<PreProps>;
148
+
149
+ export { Alert, Button, Container, Form, Input, Modal, Pre, Select, Table, TextArea, regularExpresions, useResources };
package/dist/index.js CHANGED
@@ -2974,6 +2974,7 @@ __export(index_exports, {
2974
2974
  Form: () => Form,
2975
2975
  Input: () => Input,
2976
2976
  Modal: () => Modal,
2977
+ Pre: () => pre_default,
2977
2978
  Select: () => Select,
2978
2979
  Table: () => Table,
2979
2980
  TextArea: () => TextArea,
@@ -11183,10 +11184,11 @@ function TD(_a) {
11183
11184
  }) }),
11184
11185
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { children: (item == null ? void 0 : item.handler) ? import_react23.default.Children.map(item.handler, (handler) => {
11185
11186
  if (import_react23.default.isValidElement(handler)) {
11186
- return import_react23.default.cloneElement(handler, {
11187
+ const _a3 = handler.props, { defaultValue } = _a3, restProps = __objRest(_a3, ["defaultValue"]);
11188
+ return import_react23.default.cloneElement(handler, __spreadProps(__spreadValues({}, restProps), {
11187
11189
  value: mapedData[index][item.name].content,
11188
11190
  onChange: (e) => {
11189
- var _a3, _b3;
11191
+ var _a4, _b3;
11190
11192
  const nmd = [...mapedData];
11191
11193
  nmd[index][item.name].content = e.target.value;
11192
11194
  e.item = Object.assign(
@@ -11203,9 +11205,9 @@ function TD(_a) {
11203
11205
  setMapedData == null ? void 0 : setMapedData(nmd2);
11204
11206
  };
11205
11207
  setMapedData == null ? void 0 : setMapedData(nmd);
11206
- (_b3 = (_a3 = handler == null ? void 0 : handler.props) == null ? void 0 : _a3.onChange) == null ? void 0 : _b3.call(_a3, e);
11208
+ (_b3 = (_a4 = handler == null ? void 0 : handler.props) == null ? void 0 : _a4.onChange) == null ? void 0 : _b3.call(_a4, e);
11207
11209
  }
11208
- });
11210
+ }));
11209
11211
  }
11210
11212
  return handler;
11211
11213
  }) : item == null ? void 0 : item.content })
@@ -32803,6 +32805,35 @@ function Modal({ button, children, ref }) {
32803
32805
  ] }) })
32804
32806
  ] });
32805
32807
  }
32808
+
32809
+ // src/pre/index.tsx
32810
+ var import_jsx_runtime19 = require("react/jsx-runtime");
32811
+ var Pre = ({ data }) => {
32812
+ let formatted = data;
32813
+ try {
32814
+ const parsed = JSON.parse(data);
32815
+ formatted = JSON.stringify(parsed, null, 2);
32816
+ } catch (err) {
32817
+ console.error("Invalid JSON string:", err);
32818
+ }
32819
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
32820
+ "pre",
32821
+ {
32822
+ style: {
32823
+ backgroundColor: "#f4f4f4",
32824
+ padding: "1rem",
32825
+ borderRadius: "8px",
32826
+ whiteSpace: "pre-wrap",
32827
+ // Permite saltos de línea
32828
+ wordBreak: "break-word",
32829
+ // Rompe palabras largas si es necesario
32830
+ fontFamily: "monospace"
32831
+ },
32832
+ children: formatted
32833
+ }
32834
+ );
32835
+ };
32836
+ var pre_default = Pre;
32806
32837
  // Annotate the CommonJS export names for ESM import in node:
32807
32838
  0 && (module.exports = {
32808
32839
  Alert,
@@ -32811,6 +32842,7 @@ function Modal({ button, children, ref }) {
32811
32842
  Form,
32812
32843
  Input,
32813
32844
  Modal,
32845
+ Pre,
32814
32846
  Select,
32815
32847
  Table,
32816
32848
  TextArea,
package/dist/index.mjs CHANGED
@@ -11173,10 +11173,11 @@ function TD(_a) {
11173
11173
  }) }),
11174
11174
  /* @__PURE__ */ jsx8("div", { children: (item == null ? void 0 : item.handler) ? React3.Children.map(item.handler, (handler) => {
11175
11175
  if (React3.isValidElement(handler)) {
11176
- return React3.cloneElement(handler, {
11176
+ const _a3 = handler.props, { defaultValue } = _a3, restProps = __objRest(_a3, ["defaultValue"]);
11177
+ return React3.cloneElement(handler, __spreadProps(__spreadValues({}, restProps), {
11177
11178
  value: mapedData[index][item.name].content,
11178
11179
  onChange: (e) => {
11179
- var _a3, _b3;
11180
+ var _a4, _b3;
11180
11181
  const nmd = [...mapedData];
11181
11182
  nmd[index][item.name].content = e.target.value;
11182
11183
  e.item = Object.assign(
@@ -11193,9 +11194,9 @@ function TD(_a) {
11193
11194
  setMapedData == null ? void 0 : setMapedData(nmd2);
11194
11195
  };
11195
11196
  setMapedData == null ? void 0 : setMapedData(nmd);
11196
- (_b3 = (_a3 = handler == null ? void 0 : handler.props) == null ? void 0 : _a3.onChange) == null ? void 0 : _b3.call(_a3, e);
11197
+ (_b3 = (_a4 = handler == null ? void 0 : handler.props) == null ? void 0 : _a4.onChange) == null ? void 0 : _b3.call(_a4, e);
11197
11198
  }
11198
- });
11199
+ }));
11199
11200
  }
11200
11201
  return handler;
11201
11202
  }) : item == null ? void 0 : item.content })
@@ -32799,6 +32800,35 @@ function Modal({ button, children, ref }) {
32799
32800
  ] }) })
32800
32801
  ] });
32801
32802
  }
32803
+
32804
+ // src/pre/index.tsx
32805
+ import { jsx as jsx18 } from "react/jsx-runtime";
32806
+ var Pre = ({ data }) => {
32807
+ let formatted = data;
32808
+ try {
32809
+ const parsed = JSON.parse(data);
32810
+ formatted = JSON.stringify(parsed, null, 2);
32811
+ } catch (err) {
32812
+ console.error("Invalid JSON string:", err);
32813
+ }
32814
+ return /* @__PURE__ */ jsx18(
32815
+ "pre",
32816
+ {
32817
+ style: {
32818
+ backgroundColor: "#f4f4f4",
32819
+ padding: "1rem",
32820
+ borderRadius: "8px",
32821
+ whiteSpace: "pre-wrap",
32822
+ // Permite saltos de línea
32823
+ wordBreak: "break-word",
32824
+ // Rompe palabras largas si es necesario
32825
+ fontFamily: "monospace"
32826
+ },
32827
+ children: formatted
32828
+ }
32829
+ );
32830
+ };
32831
+ var pre_default = Pre;
32802
32832
  export {
32803
32833
  Alert,
32804
32834
  Button,
@@ -32806,6 +32836,7 @@ export {
32806
32836
  Form,
32807
32837
  Input,
32808
32838
  Modal,
32839
+ pre_default as Pre,
32809
32840
  Select,
32810
32841
  Table,
32811
32842
  TextArea,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-recomponents",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.tsx CHANGED
@@ -9,3 +9,4 @@ export { default as TextArea } from "./text-area";
9
9
  export { default as useResources } from "./use-resources";
10
10
  export { default as Select } from "./select";
11
11
  export { default as Modal } from "./modal";
12
+ export { default as Pre } from "./pre";
@@ -0,0 +1,33 @@
1
+ import React from "react";
2
+
3
+ type PreProps = {
4
+ data: string;
5
+ };
6
+
7
+ const Pre: React.FC<PreProps> = ({ data }) => {
8
+ let formatted = data;
9
+
10
+ try {
11
+ const parsed = JSON.parse(data);
12
+ formatted = JSON.stringify(parsed, null, 2); // Formatea con indentación
13
+ } catch (err) {
14
+ console.error("Invalid JSON string:", err);
15
+ }
16
+
17
+ return (
18
+ <pre
19
+ style={{
20
+ backgroundColor: "#f4f4f4",
21
+ padding: "1rem",
22
+ borderRadius: "8px",
23
+ whiteSpace: "pre-wrap", // Permite saltos de línea
24
+ wordBreak: "break-word", // Rompe palabras largas si es necesario
25
+ fontFamily: "monospace",
26
+ }}
27
+ >
28
+ {formatted}
29
+ </pre>
30
+ );
31
+ };
32
+
33
+ export default Pre;
package/src/table/td.tsx CHANGED
@@ -77,7 +77,10 @@ export default function TD({
77
77
  {item?.handler
78
78
  ? React.Children.map(item.handler, (handler) => {
79
79
  if (React.isValidElement(handler)) {
80
+ const { defaultValue, ...restProps } = handler.props;
81
+
80
82
  return React.cloneElement(handler as any, {
83
+ ...restProps,
81
84
  value: mapedData[index][item.name].content,
82
85
  onChange: (e: any) => {
83
86
  const nmd = [...mapedData];