next-recomponents 1.4.5 → 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);
@@ -32835,6 +32836,31 @@ var Pre = ({ data }) => {
32835
32836
  );
32836
32837
  };
32837
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
+ }
32838
32864
  // Annotate the CommonJS export names for ESM import in node:
32839
32865
  0 && (module.exports = {
32840
32866
  Alert,
@@ -32848,6 +32874,7 @@ var pre_default = Pre;
32848
32874
  Table,
32849
32875
  TextArea,
32850
32876
  regularExpresions,
32877
+ useDates,
32851
32878
  useResources
32852
32879
  });
32853
32880
  /*! Bundled license information:
package/dist/index.mjs CHANGED
@@ -32830,6 +32830,31 @@ var Pre = ({ data }) => {
32830
32830
  );
32831
32831
  };
32832
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
+ }
32833
32858
  export {
32834
32859
  Alert,
32835
32860
  Button,
@@ -32842,6 +32867,7 @@ export {
32842
32867
  Table,
32843
32868
  TextArea,
32844
32869
  regular_expresions_default as regularExpresions,
32870
+ useDates,
32845
32871
  useResources
32846
32872
  };
32847
32873
  /*! Bundled license information:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-recomponents",
3
- "version": "1.4.5",
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";
@@ -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
+ }