next-recomponents 1.4.4 → 1.4.6

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
@@ -146,4 +146,12 @@ type PreProps = {
146
146
  };
147
147
  declare const Pre: React$1.FC<PreProps>;
148
148
 
149
- export { Alert, Button, Container, Form, Input, Modal, Pre, Select, Table, TextArea, regularExpresions, useResources };
149
+ declare function useDates(): {
150
+ isValid: (date: string, date2?: any) => boolean;
151
+ now: (date?: string) => string;
152
+ addMinutes: (time: string, minutes: number) => string;
153
+ dateAddDays: (days: number, date?: string) => string;
154
+ dateSubDays: (days: number, date?: string) => string;
155
+ };
156
+
157
+ export { Alert, Button, Container, Form, Input, Modal, Pre, Select, Table, TextArea, regularExpresions, useDates, useResources };
package/dist/index.d.ts CHANGED
@@ -146,4 +146,12 @@ type PreProps = {
146
146
  };
147
147
  declare const Pre: React$1.FC<PreProps>;
148
148
 
149
- export { Alert, Button, Container, Form, Input, Modal, Pre, Select, Table, TextArea, regularExpresions, useResources };
149
+ declare function useDates(): {
150
+ isValid: (date: string, date2?: any) => boolean;
151
+ now: (date?: string) => string;
152
+ addMinutes: (time: string, minutes: number) => string;
153
+ dateAddDays: (days: number, date?: string) => string;
154
+ dateSubDays: (days: number, date?: string) => string;
155
+ };
156
+
157
+ export { Alert, Button, Container, Form, Input, Modal, Pre, Select, Table, TextArea, regularExpresions, useDates, useResources };
package/dist/index.js CHANGED
@@ -2979,6 +2979,7 @@ __export(index_exports, {
2979
2979
  Table: () => Table,
2980
2980
  TextArea: () => TextArea,
2981
2981
  regularExpresions: () => regular_expresions_default,
2982
+ useDates: () => useDates,
2982
2983
  useResources: () => useResources
2983
2984
  });
2984
2985
  module.exports = __toCommonJS(index_exports);
@@ -11184,8 +11185,9 @@ function TD(_a) {
11184
11185
  }) }),
11185
11186
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { children: (item == null ? void 0 : item.handler) ? import_react23.default.Children.map(item.handler, (handler) => {
11186
11187
  if (import_react23.default.isValidElement(handler)) {
11187
- const _a3 = handler.props, { defaultValue } = _a3, restProps = __objRest(_a3, ["defaultValue"]);
11188
- return import_react23.default.cloneElement(handler, __spreadProps(__spreadValues({}, restProps), {
11188
+ const { type, props: props2 } = handler;
11189
+ const _a3 = props2, { defaultValue } = _a3, otherProps = __objRest(_a3, ["defaultValue"]);
11190
+ return import_react23.default.createElement(type, __spreadProps(__spreadValues({}, otherProps), {
11189
11191
  value: mapedData[index][item.name].content,
11190
11192
  onChange: (e) => {
11191
11193
  var _a4, _b3;
@@ -32834,6 +32836,31 @@ var Pre = ({ data }) => {
32834
32836
  );
32835
32837
  };
32836
32838
  var pre_default = Pre;
32839
+
32840
+ // src/use-dates/index.tsx
32841
+ var import_moment = __toESM(require("moment"));
32842
+ function useDates() {
32843
+ function isValid(date, date2 = (0, import_moment.default)()) {
32844
+ const date1 = (0, import_moment.default)(date.split("T")[0] + " 23:59:59");
32845
+ return date1.isAfter(date2);
32846
+ }
32847
+ function now2(date) {
32848
+ return date ? (0, import_moment.default)(date).format("YYYY-MM-DD") : (0, import_moment.default)(date).format("YYYY-MM-DD");
32849
+ }
32850
+ function dateAddDays(days2, date) {
32851
+ const date1 = (0, import_moment.default)(date);
32852
+ return date1.add(days2, "days").format("YYYY-MM-DD");
32853
+ }
32854
+ function dateSubDays(days2, date) {
32855
+ const date1 = (0, import_moment.default)(date);
32856
+ return date1.subtract(days2, "days").format("YYYY-MM-DD");
32857
+ }
32858
+ function addMinutes(time2, minutes) {
32859
+ const newTime = (0, import_moment.default)(time2, "HH:mm").add(minutes, "minutes");
32860
+ return newTime.format("HH:mm");
32861
+ }
32862
+ return { isValid, now: now2, addMinutes, dateAddDays, dateSubDays };
32863
+ }
32837
32864
  // Annotate the CommonJS export names for ESM import in node:
32838
32865
  0 && (module.exports = {
32839
32866
  Alert,
@@ -32847,6 +32874,7 @@ var pre_default = Pre;
32847
32874
  Table,
32848
32875
  TextArea,
32849
32876
  regularExpresions,
32877
+ useDates,
32850
32878
  useResources
32851
32879
  });
32852
32880
  /*! Bundled license information:
package/dist/index.mjs CHANGED
@@ -11173,8 +11173,9 @@ 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
- const _a3 = handler.props, { defaultValue } = _a3, restProps = __objRest(_a3, ["defaultValue"]);
11177
- return React3.cloneElement(handler, __spreadProps(__spreadValues({}, restProps), {
11176
+ const { type, props: props2 } = handler;
11177
+ const _a3 = props2, { defaultValue } = _a3, otherProps = __objRest(_a3, ["defaultValue"]);
11178
+ return React3.createElement(type, __spreadProps(__spreadValues({}, otherProps), {
11178
11179
  value: mapedData[index][item.name].content,
11179
11180
  onChange: (e) => {
11180
11181
  var _a4, _b3;
@@ -32829,6 +32830,31 @@ var Pre = ({ data }) => {
32829
32830
  );
32830
32831
  };
32831
32832
  var pre_default = Pre;
32833
+
32834
+ // src/use-dates/index.tsx
32835
+ import moment from "moment";
32836
+ function useDates() {
32837
+ function isValid(date, date2 = moment()) {
32838
+ const date1 = moment(date.split("T")[0] + " 23:59:59");
32839
+ return date1.isAfter(date2);
32840
+ }
32841
+ function now2(date) {
32842
+ return date ? moment(date).format("YYYY-MM-DD") : moment(date).format("YYYY-MM-DD");
32843
+ }
32844
+ function dateAddDays(days2, date) {
32845
+ const date1 = moment(date);
32846
+ return date1.add(days2, "days").format("YYYY-MM-DD");
32847
+ }
32848
+ function dateSubDays(days2, date) {
32849
+ const date1 = moment(date);
32850
+ return date1.subtract(days2, "days").format("YYYY-MM-DD");
32851
+ }
32852
+ function addMinutes(time2, minutes) {
32853
+ const newTime = moment(time2, "HH:mm").add(minutes, "minutes");
32854
+ return newTime.format("HH:mm");
32855
+ }
32856
+ return { isValid, now: now2, addMinutes, dateAddDays, dateSubDays };
32857
+ }
32832
32858
  export {
32833
32859
  Alert,
32834
32860
  Button,
@@ -32841,6 +32867,7 @@ export {
32841
32867
  Table,
32842
32868
  TextArea,
32843
32869
  regular_expresions_default as regularExpresions,
32870
+ useDates,
32844
32871
  useResources
32845
32872
  };
32846
32873
  /*! Bundled license information:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-recomponents",
3
- "version": "1.4.4",
3
+ "version": "1.4.6",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -18,6 +18,7 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "axios": "^1.9.0",
21
+ "moment": "^2.30.1",
21
22
  "react": "^19.1.0",
22
23
  "react-dom": "^19.1.0"
23
24
  }
package/src/index.tsx CHANGED
@@ -10,3 +10,4 @@ export { default as useResources } from "./use-resources";
10
10
  export { default as Select } from "./select";
11
11
  export { default as Modal } from "./modal";
12
12
  export { default as Pre } from "./pre";
13
+ export { default as useDates } from "./use-dates";
package/src/table/td.tsx CHANGED
@@ -77,10 +77,11 @@ 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;
80
+ const { type, props } = handler;
81
+ const { defaultValue, ...otherProps } = props;
81
82
 
82
- return React.cloneElement(handler as any, {
83
- ...restProps,
83
+ return React.createElement(type, {
84
+ ...otherProps,
84
85
  value: mapedData[index][item.name].content,
85
86
  onChange: (e: any) => {
86
87
  const nmd = [...mapedData];
@@ -0,0 +1,31 @@
1
+ import moment from "moment";
2
+
3
+ export default function useDates() {
4
+ function isValid(date: string, date2: any = moment()) {
5
+ const date1 = moment(date.split("T")[0] + " 23:59:59");
6
+ return date1.isAfter(date2);
7
+ }
8
+
9
+ function now(date?: string) {
10
+ return date
11
+ ? moment(date).format("YYYY-MM-DD")
12
+ : moment(date).format("YYYY-MM-DD");
13
+ }
14
+
15
+ function dateAddDays(days: number, date?: string) {
16
+ const date1 = moment(date);
17
+ return date1.add(days, "days").format("YYYY-MM-DD");
18
+ }
19
+
20
+ function dateSubDays(days: number, date?: string) {
21
+ const date1 = moment(date);
22
+ return date1.subtract(days, "days").format("YYYY-MM-DD");
23
+ }
24
+
25
+ function addMinutes(time: string, minutes: number) {
26
+ const newTime = moment(time, "HH:mm").add(minutes, "minutes");
27
+ return newTime.format("HH:mm");
28
+ }
29
+
30
+ return { isValid, now, addMinutes, dateAddDays, dateSubDays };
31
+ }