@rubenpazch/date-picker 2.0.0 → 2.0.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../src/DatePicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAM3D,UAAU,eAAe;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAID,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA+rBzC,CAAC;AAEF,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../src/DatePicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAM3D,UAAU,eAAe;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAID,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAisBzC,CAAC;AAEF,eAAe,UAAU,CAAC"}
package/dist/index.cjs.js CHANGED
@@ -1288,7 +1288,9 @@ const DatePicker = ({ label, value, onChange, placeholder, error, required = fal
1288
1288
  const isSelected = (day) => {
1289
1289
  if (!value)
1290
1290
  return false;
1291
- const selectedDate = new Date(value);
1291
+ const selectedDate = parseIsoDate(value);
1292
+ if (!selectedDate)
1293
+ return false;
1292
1294
  return (day === selectedDate.getDate() &&
1293
1295
  currentMonth.getMonth() === selectedDate.getMonth() &&
1294
1296
  currentMonth.getFullYear() === selectedDate.getFullYear());
@@ -1302,7 +1304,9 @@ const DatePicker = ({ label, value, onChange, placeholder, error, required = fal
1302
1304
  const isSelectedMonth = (monthIndex) => {
1303
1305
  if (!value)
1304
1306
  return false;
1305
- const selectedDate = new Date(value);
1307
+ const selectedDate = parseIsoDate(value);
1308
+ if (!selectedDate)
1309
+ return false;
1306
1310
  return (monthIndex === selectedDate.getMonth() &&
1307
1311
  currentYear === selectedDate.getFullYear());
1308
1312
  };
@@ -1315,7 +1319,9 @@ const DatePicker = ({ label, value, onChange, placeholder, error, required = fal
1315
1319
  const isSelectedYear = (year) => {
1316
1320
  if (!value)
1317
1321
  return false;
1318
- const selectedDate = new Date(value);
1322
+ const selectedDate = parseIsoDate(value);
1323
+ if (!selectedDate)
1324
+ return false;
1319
1325
  return year === selectedDate.getFullYear();
1320
1326
  };
1321
1327
  // Generate calendar days
@@ -1334,8 +1340,7 @@ const DatePicker = ({ label, value, onChange, placeholder, error, required = fal
1334
1340
  // Handle today button
1335
1341
  const handleToday = () => {
1336
1342
  const today = new Date();
1337
- const isoString = today.toISOString().split("T")[0];
1338
- onChange(isoString);
1343
+ onChange(toIsoDateString(today));
1339
1344
  setInputValue(formatDate(today));
1340
1345
  setCurrentMonth(today);
1341
1346
  setCurrentYear(today.getFullYear());
package/dist/index.esm.js CHANGED
@@ -1268,7 +1268,9 @@ const DatePicker = ({ label, value, onChange, placeholder, error, required = fal
1268
1268
  const isSelected = (day) => {
1269
1269
  if (!value)
1270
1270
  return false;
1271
- const selectedDate = new Date(value);
1271
+ const selectedDate = parseIsoDate(value);
1272
+ if (!selectedDate)
1273
+ return false;
1272
1274
  return (day === selectedDate.getDate() &&
1273
1275
  currentMonth.getMonth() === selectedDate.getMonth() &&
1274
1276
  currentMonth.getFullYear() === selectedDate.getFullYear());
@@ -1282,7 +1284,9 @@ const DatePicker = ({ label, value, onChange, placeholder, error, required = fal
1282
1284
  const isSelectedMonth = (monthIndex) => {
1283
1285
  if (!value)
1284
1286
  return false;
1285
- const selectedDate = new Date(value);
1287
+ const selectedDate = parseIsoDate(value);
1288
+ if (!selectedDate)
1289
+ return false;
1286
1290
  return (monthIndex === selectedDate.getMonth() &&
1287
1291
  currentYear === selectedDate.getFullYear());
1288
1292
  };
@@ -1295,7 +1299,9 @@ const DatePicker = ({ label, value, onChange, placeholder, error, required = fal
1295
1299
  const isSelectedYear = (year) => {
1296
1300
  if (!value)
1297
1301
  return false;
1298
- const selectedDate = new Date(value);
1302
+ const selectedDate = parseIsoDate(value);
1303
+ if (!selectedDate)
1304
+ return false;
1299
1305
  return year === selectedDate.getFullYear();
1300
1306
  };
1301
1307
  // Generate calendar days
@@ -1314,8 +1320,7 @@ const DatePicker = ({ label, value, onChange, placeholder, error, required = fal
1314
1320
  // Handle today button
1315
1321
  const handleToday = () => {
1316
1322
  const today = new Date();
1317
- const isoString = today.toISOString().split("T")[0];
1318
- onChange(isoString);
1323
+ onChange(toIsoDateString(today));
1319
1324
  setInputValue(formatDate(today));
1320
1325
  setCurrentMonth(today);
1321
1326
  setCurrentYear(today.getFullYear());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rubenpazch/date-picker",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "DatePicker component",
5
5
  "private": false,
6
6
  "main": "dist/index.cjs.js",