next-recomponents 1.7.38 → 1.7.40

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.js CHANGED
@@ -11187,19 +11187,20 @@ function TD(_a) {
11187
11187
  try {
11188
11188
  const newAcc = __spreadValues({}, acc);
11189
11189
  const hasEvent = `${i}`.startsWith("on");
11190
+ const name = item.name;
11191
+ newAcc["value"] = item.content;
11192
+ newAcc["onChange"] = (e) => __async(null, null, function* () {
11193
+ const value = e.target.value;
11194
+ const newData1 = [...mapedData];
11195
+ newData1[index][name].content = value;
11196
+ setMapedData == null ? void 0 : setMapedData(newData1);
11197
+ });
11190
11198
  if (hasEvent) {
11191
11199
  newAcc[i] = (e) => __async(null, null, function* () {
11192
11200
  var _a3, _b3;
11193
- const value = e.target.value;
11194
- const name = item.name;
11195
- if (i == "onChange") {
11196
- const newData1 = [...mapedData];
11197
- newData1[index][name].content = value;
11198
- setMapedData == null ? void 0 : setMapedData(newData1);
11199
- }
11200
11201
  e.item = item;
11201
11202
  e.row = Object.keys(mapedData[index]).reduce((acc2, i2) => {
11202
- acc2[i2] = name == i2 ? e.target.value : mapedData[index][i2].content;
11203
+ acc2[i2] = mapedData[index][i2].content;
11203
11204
  return acc2;
11204
11205
  }, {});
11205
11206
  e.updateRow = (data) => {
@@ -11209,7 +11210,7 @@ function TD(_a) {
11209
11210
  }
11210
11211
  setMapedData == null ? void 0 : setMapedData(newData);
11211
11212
  };
11212
- yield (_b3 = (_a3 = symbols[item == null ? void 0 : item.name].props)[i]) == null ? void 0 : _b3.call(_a3, e);
11213
+ yield (_b3 = (_a3 = symbols[item == null ? void 0 : item.name].props) == null ? void 0 : _a3[i]) == null ? void 0 : _b3.call(_a3, e);
11213
11214
  });
11214
11215
  } else if (i == "row") {
11215
11216
  const row = Object.keys(mapedData[index]).reduce((acc2, i2) => {
@@ -11217,6 +11218,16 @@ function TD(_a) {
11217
11218
  return acc2;
11218
11219
  }, {});
11219
11220
  newAcc["row"] = row;
11221
+ newAcc["updateRow"] = (data) => {
11222
+ try {
11223
+ const newData = [...mapedData];
11224
+ for (const datum in data) {
11225
+ newData[index][datum].content = data[datum];
11226
+ }
11227
+ setMapedData == null ? void 0 : setMapedData(newData);
11228
+ } catch (error) {
11229
+ }
11230
+ };
11220
11231
  }
11221
11232
  return newAcc;
11222
11233
  } catch (error) {
@@ -11234,44 +11245,22 @@ function TD(_a) {
11234
11245
  "border-b max-w-[200px] p-2 "
11235
11246
  // ["number", "money"].includes(item?.cellTypeOf) && "text-right",
11236
11247
  ].join(" "),
11237
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: symbols && symbols[item == null ? void 0 : item.name] && "flex justify-between", children: [
11238
- symbols && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { children: import_react23.default.Children.map(symbols[item == null ? void 0 : item.name], (child) => {
11239
- if (import_react23.default.isValidElement(child)) {
11240
- const { type, props: props2 } = child;
11241
- return import_react23.default.createElement(type, __spreadValues({}, newProps));
11242
- }
11243
- return child;
11244
- }) }),
11245
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { children: (item == null ? void 0 : item.handler) ? import_react23.default.Children.map(item.handler, (handler) => {
11246
- if (import_react23.default.isValidElement(handler)) {
11247
- const { type, props: props2 } = handler;
11248
- return import_react23.default.createElement(type, __spreadProps(__spreadValues({}, props2), {
11249
- value: mapedData[index][item.name].content,
11250
- onChange: (e) => {
11251
- var _a3, _b3;
11252
- const nmd = [...mapedData];
11253
- nmd[index][item.name].content = e.target.value;
11254
- e.item = Object.assign(
11255
- {},
11256
- ...nmd.map(
11257
- (d) => Object.keys(d).map((k) => ({ [k]: d[k].content }))
11258
- )[index]
11259
- );
11260
- e.setData = (data) => {
11261
- const nmd2 = [...mapedData];
11262
- for (let datum in data) {
11263
- nmd2[index][datum].content = data[datum];
11264
- }
11265
- setMapedData == null ? void 0 : setMapedData(nmd2);
11266
- };
11267
- setMapedData == null ? void 0 : setMapedData(nmd);
11268
- (_b3 = (_a3 = handler == null ? void 0 : handler.props) == null ? void 0 : _a3.onChange) == null ? void 0 : _b3.call(_a3, e);
11248
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
11249
+ "div",
11250
+ {
11251
+ className: symbols && symbols[item == null ? void 0 : item.name] && "flex justify-between ",
11252
+ children: symbols ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center justify-between gap-1", children: [
11253
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { children: import_react23.default.Children.map(symbols[item == null ? void 0 : item.name], (child) => {
11254
+ if (import_react23.default.isValidElement(child)) {
11255
+ const { type, props: props2 } = child;
11256
+ return import_react23.default.createElement(type, __spreadValues({}, newProps));
11269
11257
  }
11270
- }));
11271
- }
11272
- return handler;
11273
- }) : item == null ? void 0 : item.content })
11274
- ] })
11258
+ return child;
11259
+ }) }),
11260
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { children: !(newProps == null ? void 0 : newProps["row"]) && item.content })
11261
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { children: item == null ? void 0 : item.content })
11262
+ }
11263
+ )
11275
11264
  }
11276
11265
  );
11277
11266
  }
package/dist/index.mjs CHANGED
@@ -11169,19 +11169,20 @@ function TD(_a) {
11169
11169
  try {
11170
11170
  const newAcc = __spreadValues({}, acc);
11171
11171
  const hasEvent = `${i}`.startsWith("on");
11172
+ const name = item.name;
11173
+ newAcc["value"] = item.content;
11174
+ newAcc["onChange"] = (e) => __async(null, null, function* () {
11175
+ const value = e.target.value;
11176
+ const newData1 = [...mapedData];
11177
+ newData1[index][name].content = value;
11178
+ setMapedData == null ? void 0 : setMapedData(newData1);
11179
+ });
11172
11180
  if (hasEvent) {
11173
11181
  newAcc[i] = (e) => __async(null, null, function* () {
11174
11182
  var _a3, _b3;
11175
- const value = e.target.value;
11176
- const name = item.name;
11177
- if (i == "onChange") {
11178
- const newData1 = [...mapedData];
11179
- newData1[index][name].content = value;
11180
- setMapedData == null ? void 0 : setMapedData(newData1);
11181
- }
11182
11183
  e.item = item;
11183
11184
  e.row = Object.keys(mapedData[index]).reduce((acc2, i2) => {
11184
- acc2[i2] = name == i2 ? e.target.value : mapedData[index][i2].content;
11185
+ acc2[i2] = mapedData[index][i2].content;
11185
11186
  return acc2;
11186
11187
  }, {});
11187
11188
  e.updateRow = (data) => {
@@ -11191,7 +11192,7 @@ function TD(_a) {
11191
11192
  }
11192
11193
  setMapedData == null ? void 0 : setMapedData(newData);
11193
11194
  };
11194
- yield (_b3 = (_a3 = symbols[item == null ? void 0 : item.name].props)[i]) == null ? void 0 : _b3.call(_a3, e);
11195
+ yield (_b3 = (_a3 = symbols[item == null ? void 0 : item.name].props) == null ? void 0 : _a3[i]) == null ? void 0 : _b3.call(_a3, e);
11195
11196
  });
11196
11197
  } else if (i == "row") {
11197
11198
  const row = Object.keys(mapedData[index]).reduce((acc2, i2) => {
@@ -11199,6 +11200,16 @@ function TD(_a) {
11199
11200
  return acc2;
11200
11201
  }, {});
11201
11202
  newAcc["row"] = row;
11203
+ newAcc["updateRow"] = (data) => {
11204
+ try {
11205
+ const newData = [...mapedData];
11206
+ for (const datum in data) {
11207
+ newData[index][datum].content = data[datum];
11208
+ }
11209
+ setMapedData == null ? void 0 : setMapedData(newData);
11210
+ } catch (error) {
11211
+ }
11212
+ };
11202
11213
  }
11203
11214
  return newAcc;
11204
11215
  } catch (error) {
@@ -11216,44 +11227,22 @@ function TD(_a) {
11216
11227
  "border-b max-w-[200px] p-2 "
11217
11228
  // ["number", "money"].includes(item?.cellTypeOf) && "text-right",
11218
11229
  ].join(" "),
11219
- children: /* @__PURE__ */ jsxs6("div", { className: symbols && symbols[item == null ? void 0 : item.name] && "flex justify-between", children: [
11220
- symbols && /* @__PURE__ */ jsx8("div", { children: React3.Children.map(symbols[item == null ? void 0 : item.name], (child) => {
11221
- if (React3.isValidElement(child)) {
11222
- const { type, props: props2 } = child;
11223
- return React3.createElement(type, __spreadValues({}, newProps));
11224
- }
11225
- return child;
11226
- }) }),
11227
- /* @__PURE__ */ jsx8("div", { children: (item == null ? void 0 : item.handler) ? React3.Children.map(item.handler, (handler) => {
11228
- if (React3.isValidElement(handler)) {
11229
- const { type, props: props2 } = handler;
11230
- return React3.createElement(type, __spreadProps(__spreadValues({}, props2), {
11231
- value: mapedData[index][item.name].content,
11232
- onChange: (e) => {
11233
- var _a3, _b3;
11234
- const nmd = [...mapedData];
11235
- nmd[index][item.name].content = e.target.value;
11236
- e.item = Object.assign(
11237
- {},
11238
- ...nmd.map(
11239
- (d) => Object.keys(d).map((k) => ({ [k]: d[k].content }))
11240
- )[index]
11241
- );
11242
- e.setData = (data) => {
11243
- const nmd2 = [...mapedData];
11244
- for (let datum in data) {
11245
- nmd2[index][datum].content = data[datum];
11246
- }
11247
- setMapedData == null ? void 0 : setMapedData(nmd2);
11248
- };
11249
- setMapedData == null ? void 0 : setMapedData(nmd);
11250
- (_b3 = (_a3 = handler == null ? void 0 : handler.props) == null ? void 0 : _a3.onChange) == null ? void 0 : _b3.call(_a3, e);
11230
+ children: /* @__PURE__ */ jsx8(
11231
+ "div",
11232
+ {
11233
+ className: symbols && symbols[item == null ? void 0 : item.name] && "flex justify-between ",
11234
+ children: symbols ? /* @__PURE__ */ jsxs6("div", { className: "flex items-center justify-between gap-1", children: [
11235
+ /* @__PURE__ */ jsx8("div", { children: React3.Children.map(symbols[item == null ? void 0 : item.name], (child) => {
11236
+ if (React3.isValidElement(child)) {
11237
+ const { type, props: props2 } = child;
11238
+ return React3.createElement(type, __spreadValues({}, newProps));
11251
11239
  }
11252
- }));
11253
- }
11254
- return handler;
11255
- }) : item == null ? void 0 : item.content })
11256
- ] })
11240
+ return child;
11241
+ }) }),
11242
+ /* @__PURE__ */ jsx8("div", { children: !(newProps == null ? void 0 : newProps["row"]) && item.content })
11243
+ ] }) : /* @__PURE__ */ jsx8("div", { children: item == null ? void 0 : item.content })
11244
+ }
11245
+ )
11257
11246
  }
11258
11247
  );
11259
11248
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-recomponents",
3
- "version": "1.7.38",
3
+ "version": "1.7.40",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/table/td.tsx CHANGED
@@ -36,21 +36,20 @@ export default function TD({
36
36
  try {
37
37
  const newAcc = { ...acc };
38
38
  const hasEvent = `${i}`.startsWith("on");
39
+ const name = item.name;
40
+
41
+ newAcc["value"] = item.content;
42
+ newAcc["onChange"] = async (e: any) => {
43
+ const value = e.target.value;
44
+ const newData1 = [...mapedData];
45
+ newData1[index][name].content = value;
46
+ setMapedData?.(newData1);
47
+ };
39
48
  if (hasEvent) {
40
49
  newAcc[i] = async (e: any) => {
41
- const value = e.target.value;
42
- const name = item.name;
43
- //actualizar en automatico en el onchange
44
- if (i == "onChange") {
45
- const newData1 = [...mapedData];
46
- newData1[index][name].content = value;
47
- setMapedData?.(newData1);
48
- }
49
-
50
50
  e.item = item;
51
51
  e.row = Object.keys(mapedData[index]).reduce((acc, i) => {
52
- acc[i] =
53
- name == i ? e.target.value : mapedData[index][i].content;
52
+ acc[i] = mapedData[index][i].content;
54
53
  return acc;
55
54
  }, {} as any);
56
55
  e.updateRow = (data: Record<string, any>) => {
@@ -60,7 +59,8 @@ export default function TD({
60
59
  }
61
60
  setMapedData?.(newData);
62
61
  };
63
- await symbols[item?.name].props[i]?.(e);
62
+
63
+ await symbols[item?.name].props?.[i]?.(e);
64
64
  };
65
65
  } else if (i == "row") {
66
66
  const row = Object.keys(mapedData[index]).reduce((acc, i) => {
@@ -68,6 +68,15 @@ export default function TD({
68
68
  return acc;
69
69
  }, {} as any);
70
70
  newAcc["row"] = row;
71
+ newAcc["updateRow"] = (data: Record<string, any>) => {
72
+ try {
73
+ const newData = [...mapedData];
74
+ for (const datum in data) {
75
+ newData[index][datum].content = data[datum];
76
+ }
77
+ setMapedData?.(newData);
78
+ } catch (error) {}
79
+ };
71
80
  }
72
81
  return newAcc;
73
82
  } catch (error) {}
@@ -86,56 +95,27 @@ export default function TD({
86
95
  // ["number", "money"].includes(item?.cellTypeOf) && "text-right",
87
96
  ].join(" ")}
88
97
  >
89
- <div className={symbols && symbols[item?.name] && "flex justify-between"}>
90
- {symbols && (
91
- <div>
92
- {React.Children.map(symbols[item?.name], (child) => {
93
- if (React.isValidElement(child)) {
94
- const { type, props } = child;
95
- return React.createElement(type, {
96
- ...newProps,
97
- });
98
- }
99
- return child;
100
- })}
101
- </div>
102
- )}
103
-
104
- <div>
105
- {item?.handler
106
- ? React.Children.map(item.handler, (handler) => {
107
- if (React.isValidElement(handler)) {
108
- const { type, props } = handler;
109
-
98
+ <div
99
+ className={symbols && symbols[item?.name] && "flex justify-between "}
100
+ >
101
+ {symbols ? (
102
+ <div className="flex items-center justify-between gap-1">
103
+ <div>
104
+ {React.Children.map(symbols[item?.name], (child) => {
105
+ if (React.isValidElement(child)) {
106
+ const { type, props } = child;
110
107
  return React.createElement(type, {
111
- ...props,
112
- value: mapedData[index][item.name].content,
113
- onChange: (e: any) => {
114
- const nmd = [...mapedData];
115
- nmd[index][item.name].content = e.target.value;
116
- e.item = Object.assign(
117
- {},
118
- ...nmd.map((d: any) =>
119
- Object.keys(d).map((k) => ({ [k]: d[k].content }))
120
- )[index]
121
- );
122
- e.setData = (data: any) => {
123
- const nmd = [...mapedData];
124
- for (let datum in data) {
125
- nmd[index][datum].content = data[datum];
126
- }
127
- setMapedData?.(nmd);
128
- };
129
- setMapedData?.(nmd);
130
- handler?.props?.onChange?.(e);
131
- // console.log("hola mundo", e.item);
132
- },
108
+ ...newProps,
133
109
  });
134
110
  }
135
- return handler;
136
- })
137
- : item?.content}
138
- </div>
111
+ return child;
112
+ })}
113
+ </div>
114
+ <div>{!newProps?.["row"] && item.content}</div>
115
+ </div>
116
+ ) : (
117
+ <div>{item?.content}</div>
118
+ )}
139
119
  </div>
140
120
  </td>
141
121
  );