next-recomponents 1.3.2 → 1.3.3

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
@@ -11172,6 +11172,31 @@ function TD(_a) {
11172
11172
  },
11173
11173
  { defaultValue: item == null ? void 0 : item.content }
11174
11174
  );
11175
+ const newProps2 = handlers && Object.keys(handlers[item == null ? void 0 : item.name].props).reduce(
11176
+ (acc, i) => {
11177
+ try {
11178
+ const newAcc = __spreadValues({}, acc);
11179
+ const hasEvent = `${i}`.startsWith("on");
11180
+ if (hasEvent) {
11181
+ newAcc[i] = (e) => {
11182
+ var _a2, _b2;
11183
+ e.item = item;
11184
+ (_b2 = (_a2 = handlers[item == null ? void 0 : item.name].props)[i]) == null ? void 0 : _b2.call(_a2, e);
11185
+ if (i == "onChange") {
11186
+ const newData = [...mapedData];
11187
+ newData[index][item == null ? void 0 : item.name].content = e.target.value;
11188
+ setMapedData == null ? void 0 : setMapedData(newData);
11189
+ }
11190
+ };
11191
+ } else if (i == "value") {
11192
+ newAcc[i] = item == null ? void 0 : item.content;
11193
+ }
11194
+ return newAcc;
11195
+ } catch (error) {
11196
+ }
11197
+ },
11198
+ { defaultValue: item == null ? void 0 : item.content }
11199
+ );
11175
11200
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
11176
11201
  "td",
11177
11202
  {
@@ -11185,19 +11210,7 @@ function TD(_a) {
11185
11210
  ].join(" "),
11186
11211
  children: handlers && handlers[item == null ? void 0 : item.name] ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { children: import_react23.default.Children.map(handlers[item == null ? void 0 : item.name], (child) => {
11187
11212
  if (import_react23.default.isValidElement(child)) {
11188
- const oldProps = (child == null ? void 0 : child.props) || {};
11189
- const alteredProps = __spreadProps(__spreadValues({}, oldProps), {
11190
- value: item == null ? void 0 : item.content,
11191
- onChange: (e) => {
11192
- var _a2;
11193
- const newData = [...mapedData];
11194
- newData[index][item == null ? void 0 : item.name].content = e.target.value;
11195
- setMapedData == null ? void 0 : setMapedData(newData);
11196
- e.item = item;
11197
- (_a2 = oldProps == null ? void 0 : oldProps.onChange) == null ? void 0 : _a2.call(oldProps, e);
11198
- }
11199
- });
11200
- return import_react23.default.cloneElement(child, __spreadValues({}, alteredProps));
11213
+ return import_react23.default.cloneElement(child, __spreadValues({}, newProps2));
11201
11214
  }
11202
11215
  }) }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
11203
11216
  "div",
package/dist/index.mjs CHANGED
@@ -11162,6 +11162,31 @@ function TD(_a) {
11162
11162
  },
11163
11163
  { defaultValue: item == null ? void 0 : item.content }
11164
11164
  );
11165
+ const newProps2 = handlers && Object.keys(handlers[item == null ? void 0 : item.name].props).reduce(
11166
+ (acc, i) => {
11167
+ try {
11168
+ const newAcc = __spreadValues({}, acc);
11169
+ const hasEvent = `${i}`.startsWith("on");
11170
+ if (hasEvent) {
11171
+ newAcc[i] = (e) => {
11172
+ var _a2, _b2;
11173
+ e.item = item;
11174
+ (_b2 = (_a2 = handlers[item == null ? void 0 : item.name].props)[i]) == null ? void 0 : _b2.call(_a2, e);
11175
+ if (i == "onChange") {
11176
+ const newData = [...mapedData];
11177
+ newData[index][item == null ? void 0 : item.name].content = e.target.value;
11178
+ setMapedData == null ? void 0 : setMapedData(newData);
11179
+ }
11180
+ };
11181
+ } else if (i == "value") {
11182
+ newAcc[i] = item == null ? void 0 : item.content;
11183
+ }
11184
+ return newAcc;
11185
+ } catch (error) {
11186
+ }
11187
+ },
11188
+ { defaultValue: item == null ? void 0 : item.content }
11189
+ );
11165
11190
  return /* @__PURE__ */ jsx8(
11166
11191
  "td",
11167
11192
  {
@@ -11175,19 +11200,7 @@ function TD(_a) {
11175
11200
  ].join(" "),
11176
11201
  children: handlers && handlers[item == null ? void 0 : item.name] ? /* @__PURE__ */ jsx8("div", { children: React3.Children.map(handlers[item == null ? void 0 : item.name], (child) => {
11177
11202
  if (React3.isValidElement(child)) {
11178
- const oldProps = (child == null ? void 0 : child.props) || {};
11179
- const alteredProps = __spreadProps(__spreadValues({}, oldProps), {
11180
- value: item == null ? void 0 : item.content,
11181
- onChange: (e) => {
11182
- var _a2;
11183
- const newData = [...mapedData];
11184
- newData[index][item == null ? void 0 : item.name].content = e.target.value;
11185
- setMapedData == null ? void 0 : setMapedData(newData);
11186
- e.item = item;
11187
- (_a2 = oldProps == null ? void 0 : oldProps.onChange) == null ? void 0 : _a2.call(oldProps, e);
11188
- }
11189
- });
11190
- return React3.cloneElement(child, __spreadValues({}, alteredProps));
11203
+ return React3.cloneElement(child, __spreadValues({}, newProps2));
11191
11204
  }
11192
11205
  }) }) : /* @__PURE__ */ jsxs6(
11193
11206
  "div",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-recomponents",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/table/td.tsx CHANGED
@@ -57,6 +57,32 @@ export default function TD({
57
57
  },
58
58
  { defaultValue: item?.content }
59
59
  );
60
+
61
+ const newProps2 =
62
+ handlers &&
63
+ Object.keys(handlers[item?.name].props).reduce(
64
+ (acc: any, i) => {
65
+ try {
66
+ const newAcc = { ...acc };
67
+ const hasEvent = `${i}`.startsWith("on");
68
+ if (hasEvent) {
69
+ newAcc[i] = (e: any) => {
70
+ e.item = item;
71
+ handlers[item?.name].props[i]?.(e);
72
+ if (i == "onChange") {
73
+ const newData = [...mapedData];
74
+ newData[index][item?.name].content = e.target.value;
75
+ setMapedData?.(newData);
76
+ }
77
+ };
78
+ } else if (i == "value") {
79
+ newAcc[i] = item?.content;
80
+ }
81
+ return newAcc;
82
+ } catch (error) {}
83
+ },
84
+ { defaultValue: item?.content }
85
+ );
60
86
  return (
61
87
  <td
62
88
  onDoubleClick={(e) => setIsHidded(!isHidded)}
@@ -72,20 +98,8 @@ export default function TD({
72
98
  <div>
73
99
  {React.Children.map(handlers[item?.name], (child) => {
74
100
  if (React.isValidElement(child)) {
75
- const oldProps: any = child?.props || {};
76
- const alteredProps = {
77
- ...oldProps,
78
- value: item?.content,
79
- onChange: (e: any) => {
80
- const newData = [...mapedData];
81
- newData[index][item?.name].content = e.target.value;
82
- setMapedData?.(newData);
83
- e.item = item;
84
- oldProps?.onChange?.(e);
85
- },
86
- };
87
101
  return React.cloneElement(child as any, {
88
- ...alteredProps,
102
+ ...newProps2,
89
103
  });
90
104
  }
91
105
  })}