react-fill-calendar 0.1.0
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 +483 -0
- package/dist/index.umd.cjs +10 -0
- package/package.json +45 -0
- package/readme.md +36 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,483 @@
|
|
|
1
|
+
import X, { useMemo as re } from "react";
|
|
2
|
+
var P = { exports: {} }, w = {};
|
|
3
|
+
var V;
|
|
4
|
+
function te() {
|
|
5
|
+
if (V) return w;
|
|
6
|
+
V = 1;
|
|
7
|
+
var f = /* @__PURE__ */ Symbol.for("react.transitional.element"), m = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
8
|
+
function b(p, s, i) {
|
|
9
|
+
var u = null;
|
|
10
|
+
if (i !== void 0 && (u = "" + i), s.key !== void 0 && (u = "" + s.key), "key" in s) {
|
|
11
|
+
i = {};
|
|
12
|
+
for (var x in s)
|
|
13
|
+
x !== "key" && (i[x] = s[x]);
|
|
14
|
+
} else i = s;
|
|
15
|
+
return s = i.ref, {
|
|
16
|
+
$$typeof: f,
|
|
17
|
+
type: p,
|
|
18
|
+
key: u,
|
|
19
|
+
ref: s !== void 0 ? s : null,
|
|
20
|
+
props: i
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return w.Fragment = m, w.jsx = b, w.jsxs = b, w;
|
|
24
|
+
}
|
|
25
|
+
var k = {};
|
|
26
|
+
var B;
|
|
27
|
+
function ne() {
|
|
28
|
+
return B || (B = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
29
|
+
function f(e) {
|
|
30
|
+
if (e == null) return null;
|
|
31
|
+
if (typeof e == "function")
|
|
32
|
+
return e.$$typeof === Q ? null : e.displayName || e.name || null;
|
|
33
|
+
if (typeof e == "string") return e;
|
|
34
|
+
switch (e) {
|
|
35
|
+
case l:
|
|
36
|
+
return "Fragment";
|
|
37
|
+
case d:
|
|
38
|
+
return "Profiler";
|
|
39
|
+
case c:
|
|
40
|
+
return "StrictMode";
|
|
41
|
+
case O:
|
|
42
|
+
return "Suspense";
|
|
43
|
+
case D:
|
|
44
|
+
return "SuspenseList";
|
|
45
|
+
case Z:
|
|
46
|
+
return "Activity";
|
|
47
|
+
}
|
|
48
|
+
if (typeof e == "object")
|
|
49
|
+
switch (typeof e.tag == "number" && console.error(
|
|
50
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
51
|
+
), e.$$typeof) {
|
|
52
|
+
case A:
|
|
53
|
+
return "Portal";
|
|
54
|
+
case R:
|
|
55
|
+
return e.displayName || "Context";
|
|
56
|
+
case y:
|
|
57
|
+
return (e._context.displayName || "Context") + ".Consumer";
|
|
58
|
+
case g:
|
|
59
|
+
var r = e.render;
|
|
60
|
+
return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
61
|
+
case H:
|
|
62
|
+
return r = e.displayName || null, r !== null ? r : f(e.type) || "Memo";
|
|
63
|
+
case $:
|
|
64
|
+
r = e._payload, e = e._init;
|
|
65
|
+
try {
|
|
66
|
+
return f(e(r));
|
|
67
|
+
} catch {
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
function m(e) {
|
|
73
|
+
return "" + e;
|
|
74
|
+
}
|
|
75
|
+
function b(e) {
|
|
76
|
+
try {
|
|
77
|
+
m(e);
|
|
78
|
+
var r = !1;
|
|
79
|
+
} catch {
|
|
80
|
+
r = !0;
|
|
81
|
+
}
|
|
82
|
+
if (r) {
|
|
83
|
+
r = console;
|
|
84
|
+
var t = r.error, o = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
85
|
+
return t.call(
|
|
86
|
+
r,
|
|
87
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
88
|
+
o
|
|
89
|
+
), m(e);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function p(e) {
|
|
93
|
+
if (e === l) return "<>";
|
|
94
|
+
if (typeof e == "object" && e !== null && e.$$typeof === $)
|
|
95
|
+
return "<...>";
|
|
96
|
+
try {
|
|
97
|
+
var r = f(e);
|
|
98
|
+
return r ? "<" + r + ">" : "<...>";
|
|
99
|
+
} catch {
|
|
100
|
+
return "<...>";
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function s() {
|
|
104
|
+
var e = Y.A;
|
|
105
|
+
return e === null ? null : e.getOwner();
|
|
106
|
+
}
|
|
107
|
+
function i() {
|
|
108
|
+
return Error("react-stack-top-frame");
|
|
109
|
+
}
|
|
110
|
+
function u(e) {
|
|
111
|
+
if (L.call(e, "key")) {
|
|
112
|
+
var r = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
113
|
+
if (r && r.isReactWarning) return !1;
|
|
114
|
+
}
|
|
115
|
+
return e.key !== void 0;
|
|
116
|
+
}
|
|
117
|
+
function x(e, r) {
|
|
118
|
+
function t() {
|
|
119
|
+
U || (U = !0, console.error(
|
|
120
|
+
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
121
|
+
r
|
|
122
|
+
));
|
|
123
|
+
}
|
|
124
|
+
t.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
125
|
+
get: t,
|
|
126
|
+
configurable: !0
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
function v() {
|
|
130
|
+
var e = f(this.type);
|
|
131
|
+
return W[e] || (W[e] = !0, console.error(
|
|
132
|
+
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
133
|
+
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
134
|
+
}
|
|
135
|
+
function _(e, r, t, o, C, I) {
|
|
136
|
+
var a = t.ref;
|
|
137
|
+
return e = {
|
|
138
|
+
$$typeof: T,
|
|
139
|
+
type: e,
|
|
140
|
+
key: r,
|
|
141
|
+
props: t,
|
|
142
|
+
_owner: o
|
|
143
|
+
}, (a !== void 0 ? a : null) !== null ? Object.defineProperty(e, "ref", {
|
|
144
|
+
enumerable: !1,
|
|
145
|
+
get: v
|
|
146
|
+
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
147
|
+
configurable: !1,
|
|
148
|
+
enumerable: !1,
|
|
149
|
+
writable: !0,
|
|
150
|
+
value: 0
|
|
151
|
+
}), Object.defineProperty(e, "_debugInfo", {
|
|
152
|
+
configurable: !1,
|
|
153
|
+
enumerable: !1,
|
|
154
|
+
writable: !0,
|
|
155
|
+
value: null
|
|
156
|
+
}), Object.defineProperty(e, "_debugStack", {
|
|
157
|
+
configurable: !1,
|
|
158
|
+
enumerable: !1,
|
|
159
|
+
writable: !0,
|
|
160
|
+
value: C
|
|
161
|
+
}), Object.defineProperty(e, "_debugTask", {
|
|
162
|
+
configurable: !1,
|
|
163
|
+
enumerable: !1,
|
|
164
|
+
writable: !0,
|
|
165
|
+
value: I
|
|
166
|
+
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
167
|
+
}
|
|
168
|
+
function S(e, r, t, o, C, I) {
|
|
169
|
+
var a = r.children;
|
|
170
|
+
if (a !== void 0)
|
|
171
|
+
if (o)
|
|
172
|
+
if (K(a)) {
|
|
173
|
+
for (o = 0; o < a.length; o++)
|
|
174
|
+
h(a[o]);
|
|
175
|
+
Object.freeze && Object.freeze(a);
|
|
176
|
+
} else
|
|
177
|
+
console.error(
|
|
178
|
+
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
179
|
+
);
|
|
180
|
+
else h(a);
|
|
181
|
+
if (L.call(r, "key")) {
|
|
182
|
+
a = f(e);
|
|
183
|
+
var j = Object.keys(r).filter(function(ee) {
|
|
184
|
+
return ee !== "key";
|
|
185
|
+
});
|
|
186
|
+
o = 0 < j.length ? "{key: someKey, " + j.join(": ..., ") + ": ...}" : "{key: someKey}", J[a + o] || (j = 0 < j.length ? "{" + j.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
187
|
+
`A props object containing a "key" prop is being spread into JSX:
|
|
188
|
+
let props = %s;
|
|
189
|
+
<%s {...props} />
|
|
190
|
+
React keys must be passed directly to JSX without using spread:
|
|
191
|
+
let props = %s;
|
|
192
|
+
<%s key={someKey} {...props} />`,
|
|
193
|
+
o,
|
|
194
|
+
a,
|
|
195
|
+
j,
|
|
196
|
+
a
|
|
197
|
+
), J[a + o] = !0);
|
|
198
|
+
}
|
|
199
|
+
if (a = null, t !== void 0 && (b(t), a = "" + t), u(r) && (b(r.key), a = "" + r.key), "key" in r) {
|
|
200
|
+
t = {};
|
|
201
|
+
for (var M in r)
|
|
202
|
+
M !== "key" && (t[M] = r[M]);
|
|
203
|
+
} else t = r;
|
|
204
|
+
return a && x(
|
|
205
|
+
t,
|
|
206
|
+
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
207
|
+
), _(
|
|
208
|
+
e,
|
|
209
|
+
a,
|
|
210
|
+
t,
|
|
211
|
+
s(),
|
|
212
|
+
C,
|
|
213
|
+
I
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
function h(e) {
|
|
217
|
+
N(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === $ && (e._payload.status === "fulfilled" ? N(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
218
|
+
}
|
|
219
|
+
function N(e) {
|
|
220
|
+
return typeof e == "object" && e !== null && e.$$typeof === T;
|
|
221
|
+
}
|
|
222
|
+
var E = X, T = /* @__PURE__ */ Symbol.for("react.transitional.element"), A = /* @__PURE__ */ Symbol.for("react.portal"), l = /* @__PURE__ */ Symbol.for("react.fragment"), c = /* @__PURE__ */ Symbol.for("react.strict_mode"), d = /* @__PURE__ */ Symbol.for("react.profiler"), y = /* @__PURE__ */ Symbol.for("react.consumer"), R = /* @__PURE__ */ Symbol.for("react.context"), g = /* @__PURE__ */ Symbol.for("react.forward_ref"), O = /* @__PURE__ */ Symbol.for("react.suspense"), D = /* @__PURE__ */ Symbol.for("react.suspense_list"), H = /* @__PURE__ */ Symbol.for("react.memo"), $ = /* @__PURE__ */ Symbol.for("react.lazy"), Z = /* @__PURE__ */ Symbol.for("react.activity"), Q = /* @__PURE__ */ Symbol.for("react.client.reference"), Y = E.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, L = Object.prototype.hasOwnProperty, K = Array.isArray, F = console.createTask ? console.createTask : function() {
|
|
223
|
+
return null;
|
|
224
|
+
};
|
|
225
|
+
E = {
|
|
226
|
+
react_stack_bottom_frame: function(e) {
|
|
227
|
+
return e();
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
var U, W = {}, z = E.react_stack_bottom_frame.bind(
|
|
231
|
+
E,
|
|
232
|
+
i
|
|
233
|
+
)(), q = F(p(i)), J = {};
|
|
234
|
+
k.Fragment = l, k.jsx = function(e, r, t) {
|
|
235
|
+
var o = 1e4 > Y.recentlyCreatedOwnerStacks++;
|
|
236
|
+
return S(
|
|
237
|
+
e,
|
|
238
|
+
r,
|
|
239
|
+
t,
|
|
240
|
+
!1,
|
|
241
|
+
o ? Error("react-stack-top-frame") : z,
|
|
242
|
+
o ? F(p(e)) : q
|
|
243
|
+
);
|
|
244
|
+
}, k.jsxs = function(e, r, t) {
|
|
245
|
+
var o = 1e4 > Y.recentlyCreatedOwnerStacks++;
|
|
246
|
+
return S(
|
|
247
|
+
e,
|
|
248
|
+
r,
|
|
249
|
+
t,
|
|
250
|
+
!0,
|
|
251
|
+
o ? Error("react-stack-top-frame") : z,
|
|
252
|
+
o ? F(p(e)) : q
|
|
253
|
+
);
|
|
254
|
+
};
|
|
255
|
+
})()), k;
|
|
256
|
+
}
|
|
257
|
+
var G;
|
|
258
|
+
function oe() {
|
|
259
|
+
return G || (G = 1, process.env.NODE_ENV === "production" ? P.exports = te() : P.exports = ne()), P.exports;
|
|
260
|
+
}
|
|
261
|
+
var n = oe();
|
|
262
|
+
const ae = ({
|
|
263
|
+
fillingColor: f,
|
|
264
|
+
borderfillColor: m,
|
|
265
|
+
hoverborderColor: b,
|
|
266
|
+
cellBorderColor: p,
|
|
267
|
+
cellColor: s,
|
|
268
|
+
day: i,
|
|
269
|
+
isSelected: u = !1
|
|
270
|
+
}) => {
|
|
271
|
+
const x = (/* @__PURE__ */ new Date()).toLocaleDateString("en-US", {
|
|
272
|
+
month: "long",
|
|
273
|
+
day: "numeric",
|
|
274
|
+
year: "numeric"
|
|
275
|
+
}), v = i === x, _ = `
|
|
276
|
+
flex items-center justify-center
|
|
277
|
+
rounded-md border-2 transition-colors duration-150 hover:scale-150
|
|
278
|
+
${!v && !u && b ? "hover-border-var" : ""}
|
|
279
|
+
`;
|
|
280
|
+
return v ? /* @__PURE__ */ n.jsxs("div", { className: "relative flex items-center justify-center w-4 h-4", children: [
|
|
281
|
+
/* @__PURE__ */ n.jsx(
|
|
282
|
+
"div",
|
|
283
|
+
{
|
|
284
|
+
className: "absolute inset-0 rounded-md rainbow-spin",
|
|
285
|
+
style: {
|
|
286
|
+
background: "conic-gradient(from 0deg, #ff0000 0deg, #ff4000 20deg, #ff8000 40deg, #ffbf00 60deg, #ffff00 80deg, #bfff00 100deg, #80ff00 120deg, #40ff00 140deg, #00ff00 160deg, #00ff40 180deg, #00ff80 200deg, #00ffbf 220deg, #00ffff 240deg, #00bfff 260deg, #0080ff 280deg, #0040ff 300deg, #0000ff 320deg, #4000ff 340deg, #8000ff 360deg)",
|
|
287
|
+
padding: "2px",
|
|
288
|
+
boxShadow: "0 0 8px rgba(255,0,255,0.35), 0 0 14px rgba(0,255,255,0.25)",
|
|
289
|
+
borderRadius: "0.5rem"
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
),
|
|
293
|
+
/* @__PURE__ */ n.jsx("div", { className: "relative flex items-center justify-center w-4 h-4 rounded-md p-[2px]", children: /* @__PURE__ */ n.jsx(
|
|
294
|
+
"button",
|
|
295
|
+
{
|
|
296
|
+
type: "button",
|
|
297
|
+
className: "today-cell-btn flex items-center justify-center w-full h-full rounded-md border-2 border-transparent transition-colors duration-150 hover:scale-150",
|
|
298
|
+
style: {
|
|
299
|
+
"--border-fill-color": u ? m : p,
|
|
300
|
+
backgroundColor: u ? f : s
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
) })
|
|
304
|
+
] }) : /* @__PURE__ */ n.jsx(
|
|
305
|
+
"button",
|
|
306
|
+
{
|
|
307
|
+
type: "button",
|
|
308
|
+
className: `${_} w-4 h-4`,
|
|
309
|
+
style: u && !v ? {
|
|
310
|
+
backgroundColor: f,
|
|
311
|
+
borderColor: m,
|
|
312
|
+
"--hover-border-color": b
|
|
313
|
+
} : v ? void 0 : {
|
|
314
|
+
backgroundColor: s,
|
|
315
|
+
"--border-color": p,
|
|
316
|
+
"--hover-border-color": b
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
);
|
|
320
|
+
}, se = ({
|
|
321
|
+
fillingColor: f = "#50C878",
|
|
322
|
+
borderfillColor: m = "#27592D",
|
|
323
|
+
hoverborderColor: b = "#FFCCCB",
|
|
324
|
+
cellBorderColor: p = "#808080",
|
|
325
|
+
cellColor: s = "#ADADAD",
|
|
326
|
+
legend: i = !0,
|
|
327
|
+
mainBorder: u = !0,
|
|
328
|
+
borderColor: x = "#708090",
|
|
329
|
+
textColor: v = "#000000",
|
|
330
|
+
selectedDates: _ = [],
|
|
331
|
+
title: S = "Calendar"
|
|
332
|
+
}) => {
|
|
333
|
+
const h = /* @__PURE__ */ new Date(), N = X.useMemo(() => {
|
|
334
|
+
const l = (c) => {
|
|
335
|
+
if (!c) return "";
|
|
336
|
+
if (typeof c == "string") {
|
|
337
|
+
const d = c.split("-");
|
|
338
|
+
if (d.length === 3) {
|
|
339
|
+
const y = d[0], R = String(Number(d[1])).padStart(2, "0"), g = String(Number(d[2])).padStart(2, "0");
|
|
340
|
+
return `${y}-${R}-${g}`;
|
|
341
|
+
}
|
|
342
|
+
return c;
|
|
343
|
+
}
|
|
344
|
+
return typeof c == "object" && c.day ? l(c.day) : "";
|
|
345
|
+
};
|
|
346
|
+
return new Set(
|
|
347
|
+
(_ || []).map((c) => l(c)).filter(Boolean)
|
|
348
|
+
);
|
|
349
|
+
}, [_]), E = re(() => {
|
|
350
|
+
const l = h.getFullYear(), c = h.getMonth(), d = new Date(l, c - 1, 1), y = new Date(l, c + 2, 0), R = [], g = new Date(d);
|
|
351
|
+
for (; g <= y; ) {
|
|
352
|
+
const O = `${g.getFullYear()}-${String(g.getMonth() + 1).padStart(2, "0")}-${String(
|
|
353
|
+
g.getDate()
|
|
354
|
+
).padStart(2, "0")}`, D = N.has(O);
|
|
355
|
+
R.push({
|
|
356
|
+
key: O,
|
|
357
|
+
isSelected: D,
|
|
358
|
+
// keep a Date copy in case you want to use it later
|
|
359
|
+
dateObj: new Date(g)
|
|
360
|
+
}), g.setDate(g.getDate() + 1);
|
|
361
|
+
}
|
|
362
|
+
return R;
|
|
363
|
+
}, [_, h]), T = [], A = 15;
|
|
364
|
+
for (let l = 0; l < E.length; l += A)
|
|
365
|
+
T.push(E.slice(l, l + A));
|
|
366
|
+
return /* @__PURE__ */ n.jsxs(
|
|
367
|
+
"div",
|
|
368
|
+
{
|
|
369
|
+
className: `inline-flex flex-col gap-2 p-3 rounded-xl ${u ? "border shadow-sm" : ""} `,
|
|
370
|
+
style: {
|
|
371
|
+
borderColor: u ? x : void 0
|
|
372
|
+
},
|
|
373
|
+
children: [
|
|
374
|
+
i && /* @__PURE__ */ n.jsxs("div", { className: "flex justify-between text-sm", style: { color: v }, children: [
|
|
375
|
+
/* @__PURE__ */ n.jsx("strong", { children: S }),
|
|
376
|
+
/* @__PURE__ */ n.jsxs("div", { className: "flex items-center gap-2 font-semibold", children: [
|
|
377
|
+
/* @__PURE__ */ n.jsxs("div", { className: "relative flex items-center justify-center w-4 h-4", children: [
|
|
378
|
+
/* @__PURE__ */ n.jsx(
|
|
379
|
+
"div",
|
|
380
|
+
{
|
|
381
|
+
className: "absolute inset-0 rounded-md rainbow-spin",
|
|
382
|
+
style: {
|
|
383
|
+
background: "conic-gradient(from 0deg, #ff0000 0deg, #ff4000 20deg, #ff8000 40deg, #ffbf00 60deg, #ffff00 80deg, #bfff00 100deg, #80ff00 120deg, #40ff00 140deg, #00ff00 160deg, #00ff40 180deg, #00ff80 200deg, #00ffbf 220deg, #00ffff 240deg, #00bfff 260deg, #0080ff 280deg, #0040ff 300deg, #0000ff 320deg, #4000ff 340deg, #8000ff 360deg)",
|
|
384
|
+
padding: "2px",
|
|
385
|
+
boxShadow: "0 0 8px rgba(255,0,255,0.35), 0 0 14px rgba(0,255,255,0.25)",
|
|
386
|
+
borderRadius: "0.5rem"
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
),
|
|
390
|
+
/* @__PURE__ */ n.jsx("div", { className: "relative flex items-center justify-center w-4 h-4 rounded-md p-[2px]", children: /* @__PURE__ */ n.jsx(
|
|
391
|
+
"button",
|
|
392
|
+
{
|
|
393
|
+
type: "button",
|
|
394
|
+
className: "flex items-center justify-center w-full h-full rounded-md border-2 border-transparent transition-colors duration-150",
|
|
395
|
+
style: {
|
|
396
|
+
"--border-fill-color": m,
|
|
397
|
+
backgroundColor: s
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
) })
|
|
401
|
+
] }),
|
|
402
|
+
/* @__PURE__ */ n.jsx("span", { children: "Today" })
|
|
403
|
+
] }),
|
|
404
|
+
/* @__PURE__ */ n.jsxs("div", { className: "flex items-center gap-2 font-semibold", children: [
|
|
405
|
+
/* @__PURE__ */ n.jsx(
|
|
406
|
+
"button",
|
|
407
|
+
{
|
|
408
|
+
type: "button",
|
|
409
|
+
className: "flex items-center justify-center w-4 h-4 rounded-md border-2 border-emerald-600 transition-colors duration-150",
|
|
410
|
+
style: {
|
|
411
|
+
backgroundColor: f,
|
|
412
|
+
borderColor: m
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
),
|
|
416
|
+
/* @__PURE__ */ n.jsx("span", { children: "Completed" })
|
|
417
|
+
] })
|
|
418
|
+
] }),
|
|
419
|
+
/* @__PURE__ */ n.jsx("div", { className: "flex flex-col gap-1", children: T.map((l, c) => /* @__PURE__ */ n.jsx("div", { className: "flex gap-1", children: l.map((d) => {
|
|
420
|
+
const y = d.dateObj.toLocaleDateString("en-US", {
|
|
421
|
+
month: "long",
|
|
422
|
+
day: "numeric",
|
|
423
|
+
year: "numeric"
|
|
424
|
+
});
|
|
425
|
+
return /* @__PURE__ */ n.jsx(
|
|
426
|
+
"div",
|
|
427
|
+
{
|
|
428
|
+
className: "tooltip tooltip-top",
|
|
429
|
+
"data-tip": y,
|
|
430
|
+
children: /* @__PURE__ */ n.jsx(
|
|
431
|
+
ae,
|
|
432
|
+
{
|
|
433
|
+
fillingColor: f,
|
|
434
|
+
borderfillColor: m,
|
|
435
|
+
hoverborderColor: b,
|
|
436
|
+
cellBorderColor: p,
|
|
437
|
+
cellColor: s,
|
|
438
|
+
isSelected: d.isSelected,
|
|
439
|
+
day: y
|
|
440
|
+
}
|
|
441
|
+
)
|
|
442
|
+
},
|
|
443
|
+
d.key
|
|
444
|
+
);
|
|
445
|
+
}) }, c)) })
|
|
446
|
+
]
|
|
447
|
+
}
|
|
448
|
+
);
|
|
449
|
+
}, ce = () => {
|
|
450
|
+
const f = [
|
|
451
|
+
{
|
|
452
|
+
day: "2026-1-31"
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
day: "2026-1-30"
|
|
456
|
+
},
|
|
457
|
+
{
|
|
458
|
+
day: "2026-1-28"
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
day: "2026-2-3"
|
|
462
|
+
}
|
|
463
|
+
];
|
|
464
|
+
return /* @__PURE__ */ n.jsx(
|
|
465
|
+
se,
|
|
466
|
+
{
|
|
467
|
+
fillingColor: "#50C878",
|
|
468
|
+
borderfillColor: "#27592D",
|
|
469
|
+
title: "Habit Calendar",
|
|
470
|
+
hoverborderColor: "#FFCCCB",
|
|
471
|
+
cellColor: "#ADADAD",
|
|
472
|
+
cellBorderColor: "#808080",
|
|
473
|
+
legend: !0,
|
|
474
|
+
mainBorder: !0,
|
|
475
|
+
borderColor: "#708090",
|
|
476
|
+
textColor: "#708090",
|
|
477
|
+
selectedDates: f
|
|
478
|
+
}
|
|
479
|
+
);
|
|
480
|
+
};
|
|
481
|
+
export {
|
|
482
|
+
ce as default
|
|
483
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
(function(v,y){typeof exports=="object"&&typeof module<"u"?module.exports=y(require("react")):typeof define=="function"&&define.amd?define(["react"],y):(v=typeof globalThis<"u"?globalThis:v||self,v.FillCalendar=y(v.React))})(this,(function(v){"use strict";var y={exports:{}},k={};var U;function H(){if(U)return k;U=1;var f=Symbol.for("react.transitional.element"),m=Symbol.for("react.fragment");function b(p,s,i){var u=null;if(i!==void 0&&(u=""+i),s.key!==void 0&&(u=""+s.key),"key"in s){i={};for(var x in s)x!=="key"&&(i[x]=s[x])}else i=s;return s=i.ref,{$$typeof:f,type:p,key:u,ref:s!==void 0?s:null,props:i}}return k.Fragment=m,k.jsx=b,k.jsxs=b,k}var S={};var W;function Z(){return W||(W=1,process.env.NODE_ENV!=="production"&&(function(){function f(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ne?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case l:return"Fragment";case d:return"Profiler";case c:return"StrictMode";case P:return"Suspense";case F:return"SuspenseList";case te:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case O:return"Portal";case T:return e.displayName||"Context";case _:return(e._context.displayName||"Context")+".Consumer";case g:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case re:return r=e.displayName||null,r!==null?r:f(e.type)||"Memo";case Y:r=e._payload,e=e._init;try{return f(e(r))}catch{}}return null}function m(e){return""+e}function b(e){try{m(e);var r=!1}catch{r=!0}if(r){r=console;var n=r.error,o=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return n.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",o),m(e)}}function p(e){if(e===l)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===Y)return"<...>";try{var r=f(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function s(){var e=$.A;return e===null?null:e.getOwner()}function i(){return Error("react-stack-top-frame")}function u(e){if(J.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function x(e,r){function n(){V||(V=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}function h(){var e=f(this.type);return q[e]||(q[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function E(e,r,n,o,D,M){var a=n.ref;return e={$$typeof:N,type:e,key:r,props:n,_owner:o},(a!==void 0?a:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:h}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:D}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:M}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function A(e,r,n,o,D,M){var a=r.children;if(a!==void 0)if(o)if(oe(a)){for(o=0;o<a.length;o++)j(a[o]);Object.freeze&&Object.freeze(a)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else j(a);if(J.call(r,"key")){a=f(e);var w=Object.keys(r).filter(function(ae){return ae!=="key"});o=0<w.length?"{key: someKey, "+w.join(": ..., ")+": ...}":"{key: someKey}",X[a+o]||(w=0<w.length?"{"+w.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
|
+
let props = %s;
|
|
3
|
+
<%s {...props} />
|
|
4
|
+
React keys must be passed directly to JSX without using spread:
|
|
5
|
+
let props = %s;
|
|
6
|
+
<%s key={someKey} {...props} />`,o,a,w,a),X[a+o]=!0)}if(a=null,n!==void 0&&(b(n),a=""+n),u(r)&&(b(r.key),a=""+r.key),"key"in r){n={};for(var L in r)L!=="key"&&(n[L]=r[L])}else n=r;return a&&x(n,typeof e=="function"?e.displayName||e.name||"Unknown":e),E(e,a,n,s(),D,M)}function j(e){C(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===Y&&(e._payload.status==="fulfilled"?C(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function C(e){return typeof e=="object"&&e!==null&&e.$$typeof===N}var R=v,N=Symbol.for("react.transitional.element"),O=Symbol.for("react.portal"),l=Symbol.for("react.fragment"),c=Symbol.for("react.strict_mode"),d=Symbol.for("react.profiler"),_=Symbol.for("react.consumer"),T=Symbol.for("react.context"),g=Symbol.for("react.forward_ref"),P=Symbol.for("react.suspense"),F=Symbol.for("react.suspense_list"),re=Symbol.for("react.memo"),Y=Symbol.for("react.lazy"),te=Symbol.for("react.activity"),ne=Symbol.for("react.client.reference"),$=R.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,J=Object.prototype.hasOwnProperty,oe=Array.isArray,I=console.createTask?console.createTask:function(){return null};R={react_stack_bottom_frame:function(e){return e()}};var V,q={},B=R.react_stack_bottom_frame.bind(R,i)(),G=I(p(i)),X={};S.Fragment=l,S.jsx=function(e,r,n){var o=1e4>$.recentlyCreatedOwnerStacks++;return A(e,r,n,!1,o?Error("react-stack-top-frame"):B,o?I(p(e)):G)},S.jsxs=function(e,r,n){var o=1e4>$.recentlyCreatedOwnerStacks++;return A(e,r,n,!0,o?Error("react-stack-top-frame"):B,o?I(p(e)):G)}})()),S}var z;function Q(){return z||(z=1,process.env.NODE_ENV==="production"?y.exports=H():y.exports=Z()),y.exports}var t=Q();const K=({fillingColor:f,borderfillColor:m,hoverborderColor:b,cellBorderColor:p,cellColor:s,day:i,isSelected:u=!1})=>{const x=new Date().toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"}),h=i===x,E=`
|
|
7
|
+
flex items-center justify-center
|
|
8
|
+
rounded-md border-2 transition-colors duration-150 hover:scale-150
|
|
9
|
+
${!h&&!u&&b?"hover-border-var":""}
|
|
10
|
+
`;return h?t.jsxs("div",{className:"relative flex items-center justify-center w-4 h-4",children:[t.jsx("div",{className:"absolute inset-0 rounded-md rainbow-spin",style:{background:"conic-gradient(from 0deg, #ff0000 0deg, #ff4000 20deg, #ff8000 40deg, #ffbf00 60deg, #ffff00 80deg, #bfff00 100deg, #80ff00 120deg, #40ff00 140deg, #00ff00 160deg, #00ff40 180deg, #00ff80 200deg, #00ffbf 220deg, #00ffff 240deg, #00bfff 260deg, #0080ff 280deg, #0040ff 300deg, #0000ff 320deg, #4000ff 340deg, #8000ff 360deg)",padding:"2px",boxShadow:"0 0 8px rgba(255,0,255,0.35), 0 0 14px rgba(0,255,255,0.25)",borderRadius:"0.5rem"}}),t.jsx("div",{className:"relative flex items-center justify-center w-4 h-4 rounded-md p-[2px]",children:t.jsx("button",{type:"button",className:"today-cell-btn flex items-center justify-center w-full h-full rounded-md border-2 border-transparent transition-colors duration-150 hover:scale-150",style:{"--border-fill-color":u?m:p,backgroundColor:u?f:s}})})]}):t.jsx("button",{type:"button",className:`${E} w-4 h-4`,style:u&&!h?{backgroundColor:f,borderColor:m,"--hover-border-color":b}:h?void 0:{backgroundColor:s,"--border-color":p,"--hover-border-color":b}})},ee=({fillingColor:f="#50C878",borderfillColor:m="#27592D",hoverborderColor:b="#FFCCCB",cellBorderColor:p="#808080",cellColor:s="#ADADAD",legend:i=!0,mainBorder:u=!0,borderColor:x="#708090",textColor:h="#000000",selectedDates:E=[],title:A="Calendar"})=>{const j=new Date,C=v.useMemo(()=>{const l=c=>{if(!c)return"";if(typeof c=="string"){const d=c.split("-");if(d.length===3){const _=d[0],T=String(Number(d[1])).padStart(2,"0"),g=String(Number(d[2])).padStart(2,"0");return`${_}-${T}-${g}`}return c}return typeof c=="object"&&c.day?l(c.day):""};return new Set((E||[]).map(c=>l(c)).filter(Boolean))},[E]),R=v.useMemo(()=>{const l=j.getFullYear(),c=j.getMonth(),d=new Date(l,c-1,1),_=new Date(l,c+2,0),T=[],g=new Date(d);for(;g<=_;){const P=`${g.getFullYear()}-${String(g.getMonth()+1).padStart(2,"0")}-${String(g.getDate()).padStart(2,"0")}`,F=C.has(P);T.push({key:P,isSelected:F,dateObj:new Date(g)}),g.setDate(g.getDate()+1)}return T},[E,j]),N=[],O=15;for(let l=0;l<R.length;l+=O)N.push(R.slice(l,l+O));return t.jsxs("div",{className:`inline-flex flex-col gap-2 p-3 rounded-xl ${u?"border shadow-sm":""} `,style:{borderColor:u?x:void 0},children:[i&&t.jsxs("div",{className:"flex justify-between text-sm",style:{color:h},children:[t.jsx("strong",{children:A}),t.jsxs("div",{className:"flex items-center gap-2 font-semibold",children:[t.jsxs("div",{className:"relative flex items-center justify-center w-4 h-4",children:[t.jsx("div",{className:"absolute inset-0 rounded-md rainbow-spin",style:{background:"conic-gradient(from 0deg, #ff0000 0deg, #ff4000 20deg, #ff8000 40deg, #ffbf00 60deg, #ffff00 80deg, #bfff00 100deg, #80ff00 120deg, #40ff00 140deg, #00ff00 160deg, #00ff40 180deg, #00ff80 200deg, #00ffbf 220deg, #00ffff 240deg, #00bfff 260deg, #0080ff 280deg, #0040ff 300deg, #0000ff 320deg, #4000ff 340deg, #8000ff 360deg)",padding:"2px",boxShadow:"0 0 8px rgba(255,0,255,0.35), 0 0 14px rgba(0,255,255,0.25)",borderRadius:"0.5rem"}}),t.jsx("div",{className:"relative flex items-center justify-center w-4 h-4 rounded-md p-[2px]",children:t.jsx("button",{type:"button",className:"flex items-center justify-center w-full h-full rounded-md border-2 border-transparent transition-colors duration-150",style:{"--border-fill-color":m,backgroundColor:s}})})]}),t.jsx("span",{children:"Today"})]}),t.jsxs("div",{className:"flex items-center gap-2 font-semibold",children:[t.jsx("button",{type:"button",className:"flex items-center justify-center w-4 h-4 rounded-md border-2 border-emerald-600 transition-colors duration-150",style:{backgroundColor:f,borderColor:m}}),t.jsx("span",{children:"Completed"})]})]}),t.jsx("div",{className:"flex flex-col gap-1",children:N.map((l,c)=>t.jsx("div",{className:"flex gap-1",children:l.map(d=>{const _=d.dateObj.toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"});return t.jsx("div",{className:"tooltip tooltip-top","data-tip":_,children:t.jsx(K,{fillingColor:f,borderfillColor:m,hoverborderColor:b,cellBorderColor:p,cellColor:s,isSelected:d.isSelected,day:_})},d.key)})},c))})]})};return()=>{const f=[{day:"2026-1-31"},{day:"2026-1-30"},{day:"2026-1-28"},{day:"2026-2-3"}];return t.jsx(ee,{fillingColor:"#50C878",borderfillColor:"#27592D",title:"Habit Calendar",hoverborderColor:"#FFCCCB",cellColor:"#ADADAD",cellBorderColor:"#808080",legend:!0,mainBorder:!0,borderColor:"#708090",textColor:"#708090",selectedDates:f})}}));
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-fill-calendar",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Fill dates on a calendar displaying boxes for dates. Customize colors and borders. Perfect for habit tracking or event marking in React applications.",
|
|
5
|
+
"main": "dist/index.umd.cjs",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.umd.cjs"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"dev": "vite",
|
|
19
|
+
"build": "vite build",
|
|
20
|
+
"preview": "vite preview",
|
|
21
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"react",
|
|
25
|
+
"calendar",
|
|
26
|
+
"components"
|
|
27
|
+
],
|
|
28
|
+
"author": "",
|
|
29
|
+
"license": "ISC",
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"react": ">=17.0.0 <20.0.0",
|
|
32
|
+
"react-dom": ">=17.0.0 <20.0.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@tailwindcss/postcss": "^4.1.18",
|
|
36
|
+
"@vitejs/plugin-react": "^5.1.2",
|
|
37
|
+
"autoprefixer": "^10.4.24",
|
|
38
|
+
"daisyui": "^5.5.16",
|
|
39
|
+
"postcss": "^8.5.6",
|
|
40
|
+
"react": ">=17.0.0 <20.0.0",
|
|
41
|
+
"react-dom": ">=17.0.0 <20.0.0",
|
|
42
|
+
"tailwindcss": "^4.1.18",
|
|
43
|
+
"vite": "^7.3.1"
|
|
44
|
+
}
|
|
45
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# React Filled Calendar
|
|
2
|
+
|
|
3
|
+
A lightweight, customizable React calendar component that automatically fills and highlights dates passed in as props. Designed for simplicity, reusability, and easy styling with Tailwind and DaisyUI.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🚀 Features
|
|
8
|
+
|
|
9
|
+
- Pass in an array of dates to automatically fill or highlight them
|
|
10
|
+
- Fully responsive layout
|
|
11
|
+
- Built with React
|
|
12
|
+
- Easily styled with TailwindCSS + DaisyUI
|
|
13
|
+
- Ideal for dashboards, planners, journals, and scheduling tools
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 📦 Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install react-filled-calendar
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
## Props
|
|
25
|
+
|
|
26
|
+
| Prop | Type | Required | Default | Description |
|
|
27
|
+
|-------------------|------------|----------|-------------|-------------|
|
|
28
|
+
| `fillingColor` | `string` | No | `"#50C878"` | Background color used to fill selected or marked dates. |
|
|
29
|
+
| `borderfillColor` | `string` | No | `"#27592D"` | Border color applied to filled date cells. |
|
|
30
|
+
| `title` | `string` | No | `"Calendar"` | Title displayed above the calendar. |
|
|
31
|
+
| `hoverborderColor` | `string` | No | `"#FFCCCB"` | Border color applied when hovering over a date cell. |
|
|
32
|
+
| `cellColor` | `string` | No | `"#ADADAD"` | Background color for unfilled date cells. |
|
|
33
|
+
| `cellBorderColor` | `string` | No | `"#808080"` | Border color for unfilled date cells. |
|
|
34
|
+
| 'mainBorder' | `boolean` |No | `true` | Removes border and shadow for calendar |
|
|
35
|
+
| 'borderColor' | `string` | No | `"#708090"`| Changes color of calendar border |
|
|
36
|
+
| `legend` | `boolean` | No | `true` | Toggles the display of the legend explaining filled vs. unfilled dates. |
|