next-recomponents 1.6.94 → 1.6.95

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
@@ -166,4 +166,11 @@ declare function useExcel(): {
166
166
  importAllPages: (file: File) => Promise<Record<string, any[]>>;
167
167
  };
168
168
 
169
- export { Alert, Button, Container, Form, Input, Modal, Pre, Select, Table, TextArea, regularExpresions, useDates, useExcel, useResources };
169
+ interface CalendarProps extends DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement> {
170
+ enabledDates: Date[];
171
+ onChange?: any;
172
+ value?: any;
173
+ }
174
+ declare function MyCalendar({ enabledDates, onChange, defaultValue, className, ...otherProps }: CalendarProps): react_jsx_runtime.JSX.Element | null;
175
+
176
+ export { Alert, Button, Container, Form, Input, Modal, MyCalendar, Pre, Select, Table, TextArea, regularExpresions, useDates, useExcel, useResources };
package/dist/index.d.ts CHANGED
@@ -166,4 +166,11 @@ declare function useExcel(): {
166
166
  importAllPages: (file: File) => Promise<Record<string, any[]>>;
167
167
  };
168
168
 
169
- export { Alert, Button, Container, Form, Input, Modal, Pre, Select, Table, TextArea, regularExpresions, useDates, useExcel, useResources };
169
+ interface CalendarProps extends DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement> {
170
+ enabledDates: Date[];
171
+ onChange?: any;
172
+ value?: any;
173
+ }
174
+ declare function MyCalendar({ enabledDates, onChange, defaultValue, className, ...otherProps }: CalendarProps): react_jsx_runtime.JSX.Element | null;
175
+
176
+ export { Alert, Button, Container, Form, Input, Modal, MyCalendar, Pre, Select, Table, TextArea, regularExpresions, useDates, useExcel, 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
+ MyCalendar: () => MyCalendar,
2977
2978
  Pre: () => pre_default,
2978
2979
  Select: () => Select,
2979
2980
  Table: () => Table,
@@ -44428,6 +44429,117 @@ function useExcel() {
44428
44429
  importAllPages: importFileAllPages
44429
44430
  };
44430
44431
  }
44432
+
44433
+ // src/calendar/index.tsx
44434
+ var import_react31 = require("react");
44435
+ var import_react_datepicker = __toESM(require("react-datepicker"));
44436
+ var import_react_datepicker2 = require("react-datepicker/dist/react-datepicker.css");
44437
+
44438
+ // src/calendar/calendar.icon.tsx
44439
+ var import_jsx_runtime22 = require("react/jsx-runtime");
44440
+ function CalendarIcon() {
44441
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
44442
+ "svg",
44443
+ {
44444
+ stroke: "currentColor",
44445
+ fill: "currentColor",
44446
+ strokeWidth: "0",
44447
+ viewBox: "0 0 448 512",
44448
+ height: "20px",
44449
+ width: "20px",
44450
+ xmlns: "http://www.w3.org/2000/svg",
44451
+ children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M12 192h424c6.6 0 12 5.4 12 12v260c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V204c0-6.6 5.4-12 12-12zm436-44v-36c0-26.5-21.5-48-48-48h-48V12c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v52H160V12c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v52H48C21.5 64 0 85.5 0 112v36c0 6.6 5.4 12 12 12h424c6.6 0 12-5.4 12-12z" })
44452
+ }
44453
+ );
44454
+ }
44455
+
44456
+ // src/calendar/index.tsx
44457
+ var import_jsx_runtime23 = require("react/jsx-runtime");
44458
+ function MyCalendar(_a) {
44459
+ var _b = _a, {
44460
+ enabledDates,
44461
+ onChange,
44462
+ defaultValue = "",
44463
+ className = ""
44464
+ } = _b, otherProps = __objRest(_b, [
44465
+ "enabledDates",
44466
+ "onChange",
44467
+ "defaultValue",
44468
+ "className"
44469
+ ]);
44470
+ const modalRef = (0, import_react31.useRef)(null);
44471
+ const [selectedDate, setSelectedDate] = (0, import_react31.useState)(null);
44472
+ const [dateStr, setDateStr] = (0, import_react31.useState)(
44473
+ defaultValue
44474
+ );
44475
+ const [visible, setVisible] = (0, import_react31.useState)(false);
44476
+ (0, import_react31.useEffect)(() => {
44477
+ setVisible(typeof window !== "undefined");
44478
+ }, []);
44479
+ function handleChange(date) {
44480
+ var _a2, _b2;
44481
+ if (!date) return;
44482
+ setSelectedDate(date);
44483
+ const formattedDate = date.toISOString().split("T")[0];
44484
+ setDateStr(formattedDate);
44485
+ onChange == null ? void 0 : onChange({ target: { value: formattedDate } });
44486
+ (_b2 = (_a2 = modalRef.current) == null ? void 0 : _a2.close) == null ? void 0 : _b2.call(_a2);
44487
+ }
44488
+ if (!(enabledDates == null ? void 0 : enabledDates.length)) {
44489
+ return null;
44490
+ }
44491
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "relative", children: [
44492
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
44493
+ "div",
44494
+ {
44495
+ onClick: () => {
44496
+ var _a2, _b2;
44497
+ return (_b2 = (_a2 = modalRef == null ? void 0 : modalRef.current) == null ? void 0 : _a2.showModal) == null ? void 0 : _b2.call(_a2);
44498
+ },
44499
+ className: "cursor-pointer flex items-center justify-center",
44500
+ children: [
44501
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
44502
+ "input",
44503
+ __spreadProps(__spreadValues({}, otherProps), {
44504
+ className: [
44505
+ "p-2 w-full rounded border shadow cursor-pointer",
44506
+ className
44507
+ ].join(" "),
44508
+ value: dateStr,
44509
+ onChange: () => {
44510
+ },
44511
+ readOnly: true
44512
+ })
44513
+ ),
44514
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "absolute", style: { right: "10px" }, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(CalendarIcon, {}) })
44515
+ ]
44516
+ }
44517
+ ),
44518
+ visible && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
44519
+ "dialog",
44520
+ {
44521
+ ref: modalRef,
44522
+ id: "my-calendar-modal-item",
44523
+ onClick: (e) => {
44524
+ var _a2;
44525
+ const el = e.target;
44526
+ if ((el == null ? void 0 : el.id) === "my-calendar-modal-item") {
44527
+ (_a2 = modalRef.current) == null ? void 0 : _a2.close();
44528
+ }
44529
+ },
44530
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
44531
+ import_react_datepicker.default,
44532
+ {
44533
+ inline: true,
44534
+ selected: selectedDate,
44535
+ onChange: handleChange,
44536
+ includeDates: enabledDates
44537
+ }
44538
+ )
44539
+ }
44540
+ )
44541
+ ] });
44542
+ }
44431
44543
  // Annotate the CommonJS export names for ESM import in node:
44432
44544
  0 && (module.exports = {
44433
44545
  Alert,
@@ -44436,6 +44548,7 @@ function useExcel() {
44436
44548
  Form,
44437
44549
  Input,
44438
44550
  Modal,
44551
+ MyCalendar,
44439
44552
  Pre,
44440
44553
  Select,
44441
44554
  Table,
package/dist/index.mjs CHANGED
@@ -44419,6 +44419,121 @@ function useExcel() {
44419
44419
  importAllPages: importFileAllPages
44420
44420
  };
44421
44421
  }
44422
+
44423
+ // src/calendar/index.tsx
44424
+ import {
44425
+ useEffect as useEffect9,
44426
+ useRef as useRef7,
44427
+ useState as useState10
44428
+ } from "react";
44429
+ import DatePicker from "react-datepicker";
44430
+ import "react-datepicker/dist/react-datepicker.css";
44431
+
44432
+ // src/calendar/calendar.icon.tsx
44433
+ import { jsx as jsx21 } from "react/jsx-runtime";
44434
+ function CalendarIcon() {
44435
+ return /* @__PURE__ */ jsx21(
44436
+ "svg",
44437
+ {
44438
+ stroke: "currentColor",
44439
+ fill: "currentColor",
44440
+ strokeWidth: "0",
44441
+ viewBox: "0 0 448 512",
44442
+ height: "20px",
44443
+ width: "20px",
44444
+ xmlns: "http://www.w3.org/2000/svg",
44445
+ children: /* @__PURE__ */ jsx21("path", { d: "M12 192h424c6.6 0 12 5.4 12 12v260c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V204c0-6.6 5.4-12 12-12zm436-44v-36c0-26.5-21.5-48-48-48h-48V12c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v52H160V12c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v52H48C21.5 64 0 85.5 0 112v36c0 6.6 5.4 12 12 12h424c6.6 0 12-5.4 12-12z" })
44446
+ }
44447
+ );
44448
+ }
44449
+
44450
+ // src/calendar/index.tsx
44451
+ import { jsx as jsx22, jsxs as jsxs14 } from "react/jsx-runtime";
44452
+ function MyCalendar(_a) {
44453
+ var _b = _a, {
44454
+ enabledDates,
44455
+ onChange,
44456
+ defaultValue = "",
44457
+ className = ""
44458
+ } = _b, otherProps = __objRest(_b, [
44459
+ "enabledDates",
44460
+ "onChange",
44461
+ "defaultValue",
44462
+ "className"
44463
+ ]);
44464
+ const modalRef = useRef7(null);
44465
+ const [selectedDate, setSelectedDate] = useState10(null);
44466
+ const [dateStr, setDateStr] = useState10(
44467
+ defaultValue
44468
+ );
44469
+ const [visible, setVisible] = useState10(false);
44470
+ useEffect9(() => {
44471
+ setVisible(typeof window !== "undefined");
44472
+ }, []);
44473
+ function handleChange(date) {
44474
+ var _a2, _b2;
44475
+ if (!date) return;
44476
+ setSelectedDate(date);
44477
+ const formattedDate = date.toISOString().split("T")[0];
44478
+ setDateStr(formattedDate);
44479
+ onChange == null ? void 0 : onChange({ target: { value: formattedDate } });
44480
+ (_b2 = (_a2 = modalRef.current) == null ? void 0 : _a2.close) == null ? void 0 : _b2.call(_a2);
44481
+ }
44482
+ if (!(enabledDates == null ? void 0 : enabledDates.length)) {
44483
+ return null;
44484
+ }
44485
+ return /* @__PURE__ */ jsxs14("div", { className: "relative", children: [
44486
+ /* @__PURE__ */ jsxs14(
44487
+ "div",
44488
+ {
44489
+ onClick: () => {
44490
+ var _a2, _b2;
44491
+ return (_b2 = (_a2 = modalRef == null ? void 0 : modalRef.current) == null ? void 0 : _a2.showModal) == null ? void 0 : _b2.call(_a2);
44492
+ },
44493
+ className: "cursor-pointer flex items-center justify-center",
44494
+ children: [
44495
+ /* @__PURE__ */ jsx22(
44496
+ "input",
44497
+ __spreadProps(__spreadValues({}, otherProps), {
44498
+ className: [
44499
+ "p-2 w-full rounded border shadow cursor-pointer",
44500
+ className
44501
+ ].join(" "),
44502
+ value: dateStr,
44503
+ onChange: () => {
44504
+ },
44505
+ readOnly: true
44506
+ })
44507
+ ),
44508
+ /* @__PURE__ */ jsx22("div", { className: "absolute", style: { right: "10px" }, children: /* @__PURE__ */ jsx22(CalendarIcon, {}) })
44509
+ ]
44510
+ }
44511
+ ),
44512
+ visible && /* @__PURE__ */ jsx22(
44513
+ "dialog",
44514
+ {
44515
+ ref: modalRef,
44516
+ id: "my-calendar-modal-item",
44517
+ onClick: (e) => {
44518
+ var _a2;
44519
+ const el = e.target;
44520
+ if ((el == null ? void 0 : el.id) === "my-calendar-modal-item") {
44521
+ (_a2 = modalRef.current) == null ? void 0 : _a2.close();
44522
+ }
44523
+ },
44524
+ children: /* @__PURE__ */ jsx22(
44525
+ DatePicker,
44526
+ {
44527
+ inline: true,
44528
+ selected: selectedDate,
44529
+ onChange: handleChange,
44530
+ includeDates: enabledDates
44531
+ }
44532
+ )
44533
+ }
44534
+ )
44535
+ ] });
44536
+ }
44422
44537
  export {
44423
44538
  Alert,
44424
44539
  Button,
@@ -44426,6 +44541,7 @@ export {
44426
44541
  Form,
44427
44542
  Input,
44428
44543
  Modal,
44544
+ MyCalendar,
44429
44545
  pre_default as Pre,
44430
44546
  Select,
44431
44547
  Table,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-recomponents",
3
- "version": "1.6.94",
3
+ "version": "1.6.95",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -21,6 +21,7 @@
21
21
  "axios": "^1.9.0",
22
22
  "moment": "^2.30.1",
23
23
  "react": "^19.1.0",
24
+ "react-datepicker": "^8.4.0",
24
25
  "react-dom": "^19.1.0"
25
26
  }
26
27
  }
@@ -0,0 +1,15 @@
1
+ export default function CalendarIcon() {
2
+ return (
3
+ <svg
4
+ stroke="currentColor"
5
+ fill="currentColor"
6
+ strokeWidth="0"
7
+ viewBox="0 0 448 512"
8
+ height="20px"
9
+ width="20px"
10
+ xmlns="http://www.w3.org/2000/svg"
11
+ >
12
+ <path d="M12 192h424c6.6 0 12 5.4 12 12v260c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V204c0-6.6 5.4-12 12-12zm436-44v-36c0-26.5-21.5-48-48-48h-48V12c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v52H160V12c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v52H48C21.5 64 0 85.5 0 112v36c0 6.6 5.4 12 12 12h424c6.6 0 12-5.4 12-12z"></path>
13
+ </svg>
14
+ );
15
+ }
@@ -0,0 +1,96 @@
1
+ "use client";
2
+ import {
3
+ DetailedHTMLProps,
4
+ InputHTMLAttributes,
5
+ useEffect,
6
+ useRef,
7
+ useState,
8
+ } from "react";
9
+ import DatePicker from "react-datepicker";
10
+ import "react-datepicker/dist/react-datepicker.css";
11
+ import CalendarIcon from "./calendar.icon";
12
+
13
+ interface CalendarProps
14
+ extends DetailedHTMLProps<
15
+ InputHTMLAttributes<HTMLInputElement>,
16
+ HTMLInputElement
17
+ > {
18
+ enabledDates: Date[];
19
+ onChange?: any;
20
+ value?: any;
21
+ }
22
+
23
+ export default function MyCalendar({
24
+ enabledDates,
25
+ onChange,
26
+ defaultValue = "",
27
+ className = "",
28
+ ...otherProps
29
+ }: CalendarProps) {
30
+ const modalRef = useRef<HTMLDialogElement>(null);
31
+ const [selectedDate, setSelectedDate] = useState<Date | null>(null);
32
+ const [dateStr, setDateStr] = useState<string | number | readonly string[]>(
33
+ defaultValue
34
+ );
35
+ const [visible, setVisible] = useState(false);
36
+
37
+ useEffect(() => {
38
+ setVisible(typeof window !== "undefined");
39
+ }, []);
40
+
41
+ function handleChange(date: Date | null) {
42
+ if (!date) return;
43
+ setSelectedDate(date);
44
+ const formattedDate = date.toISOString().split("T")[0];
45
+ setDateStr(formattedDate);
46
+ onChange?.({ target: { value: formattedDate } });
47
+ modalRef.current?.close?.();
48
+ }
49
+
50
+ if (!enabledDates?.length) {
51
+ return null;
52
+ }
53
+
54
+ return (
55
+ <div className="relative">
56
+ <div
57
+ onClick={() => modalRef?.current?.showModal?.()}
58
+ className="cursor-pointer flex items-center justify-center"
59
+ >
60
+ <input
61
+ {...otherProps}
62
+ className={[
63
+ "p-2 w-full rounded border shadow cursor-pointer",
64
+ className,
65
+ ].join(" ")}
66
+ value={dateStr}
67
+ onChange={() => {}}
68
+ readOnly
69
+ />
70
+ <div className="absolute" style={{ right: "10px" }}>
71
+ <CalendarIcon />
72
+ </div>
73
+ </div>
74
+
75
+ {visible && (
76
+ <dialog
77
+ ref={modalRef}
78
+ id="my-calendar-modal-item"
79
+ onClick={(e) => {
80
+ const el = e.target as HTMLElement;
81
+ if (el?.id === "my-calendar-modal-item") {
82
+ modalRef.current?.close();
83
+ }
84
+ }}
85
+ >
86
+ <DatePicker
87
+ inline
88
+ selected={selectedDate}
89
+ onChange={handleChange}
90
+ includeDates={enabledDates}
91
+ />
92
+ </dialog>
93
+ )}
94
+ </div>
95
+ );
96
+ }
package/src/index.tsx CHANGED
@@ -12,3 +12,4 @@ export { default as Modal } from "./modal";
12
12
  export { default as Pre } from "./pre";
13
13
  export { default as useDates } from "./use-dates";
14
14
  export { default as useExcel } from "./use-excel";
15
+ export { default as MyCalendar } from "./calendar";