@rubenpazch/date-picker 3.2.3 → 3.3.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/README.md CHANGED
@@ -29,12 +29,13 @@ Selector de fecha con calendario (días, meses y años). Devuelve ISO `AAAA-MM-D
29
29
  | `hint` | `string` | | | |
30
30
  | `id` | `string` | | | id del input; si no se pasa se genera uno (la etiqueta se asocia sola). |
31
31
  | `label` | `string` | | | |
32
- | `locale` | `string` | | `es` | |
32
+ | `labels` | `enum` | | | Textos de la interfaz; por defecto en el idioma de `locale` o del proveedor. |
33
+ | `locale` | `string` | | | Idioma y formato: `es` (día/mes) o `en` (mes/día). Por defecto, el de `UiLocaleProvider` (sin proveedor, `es-PE`). |
33
34
  | `maxDate` | `string` | | | |
34
35
  | `minDate` | `string` | | | |
35
36
  | `mobileFullScreen` | `boolean` | | `true` | En pantallas pequeñas (< 640 px) el calendario se abre a pantalla completa y vuelve al campo al elegir la fecha. Por defecto true. |
36
37
  | `name` | `string` | | | name del input. |
37
- | `openCalendarLabel` | `string` | | | Texto del botón que abre el calendario (accesibilidad). |
38
+ | `openCalendarLabel` | `string` | | | Texto del botón que abre el calendario (accesibilidad). @deprecated Usa `labels.openCalendar`. |
38
39
  | `placeholder` | `string` | | | |
39
40
  | `readOnly` | `boolean` | | `false` | |
40
41
  | `required` | `boolean` | | `false` | |
@@ -1,10 +1,11 @@
1
1
  import React from "react";
2
+ import { type UiMessages } from "@rubenpazch/shared";
2
3
  export interface DatePickerProps {
3
4
  /** id del input; si no se pasa se genera uno (la etiqueta se asocia sola). */
4
5
  id?: string;
5
6
  /** name del input. */
6
7
  name?: string;
7
- /** Texto del botón que abre el calendario (accesibilidad). */
8
+ /** Texto del botón que abre el calendario (accesibilidad). @deprecated Usa `labels.openCalendar`. */
8
9
  openCalendarLabel?: string;
9
10
  label?: string;
10
11
  value: string;
@@ -18,7 +19,13 @@ export interface DatePickerProps {
18
19
  className?: string;
19
20
  hint?: string;
20
21
  readOnly?: boolean;
22
+ /**
23
+ * Idioma y formato: `es` (día/mes) o `en` (mes/día). Por defecto, el de
24
+ * `UiLocaleProvider` (sin proveedor, `es-PE`).
25
+ */
21
26
  locale?: string;
27
+ /** Textos de la interfaz; por defecto en el idioma de `locale` o del proveedor. */
28
+ labels?: Partial<UiMessages["datePicker"]>;
22
29
  /**
23
30
  * En pantallas pequeñas (< 640 px) el calendario se abre a pantalla completa y vuelve al
24
31
  * campo al elegir la fecha. Por defecto true.
@@ -1 +1 @@
1
- {"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../src/DatePicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAe3D,MAAM,WAAW,eAAe;IAC9B,8EAA8E;IAC9E,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,sBAAsB;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8DAA8D;IAC9D,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,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;IAChB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAID,sGAAsG;AACtG,QAAA,MAAM,UAAU,0FA8xBf,CAAC;AAIF,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../src/DatePicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAI3D,OAAO,EAgBL,KAAK,UAAU,EAChB,MAAM,oBAAoB,CAAC;AAG5B,MAAM,WAAW,eAAe;IAC9B,8EAA8E;IAC9E,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,sBAAsB;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qGAAqG;IACrG,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,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;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mFAAmF;IACnF,MAAM,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC;IAC3C;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAID,sGAAsG;AACtG,QAAA,MAAM,UAAU,0FA0tBf,CAAC;AAIF,eAAe,UAAU,CAAC"}
package/dist/index.cjs.js CHANGED
@@ -1027,7 +1027,11 @@ var styles = {"wrapper":"DatePicker-module_wrapper__PLuo9","label":"DatePicker-m
1027
1027
  styleInject(css_248z);
1028
1028
 
1029
1029
  /** Selector de fecha con calendario (días, meses y años). Devuelve ISO `AAAA-MM-DD` en hora local. */
1030
- const DatePicker = require$$0.forwardRef(function DatePicker({ id, name, openCalendarLabel, label, value, onChange, placeholder, error, required = false, disabled = false, minDate, maxDate, className = "", hint, readOnly = false, locale = "es", mobileFullScreen = true, }, ref) {
1030
+ const DatePicker = require$$0.forwardRef(function DatePicker({ id, name, openCalendarLabel, label, value, onChange, placeholder, error, required = false, disabled = false, minDate, maxDate, className = "", hint, readOnly = false, locale: localeProp, labels, mobileFullScreen = true, }, ref) {
1031
+ // Sin `locale` propio, el idioma y el formato del proveedor (UiLocaleProvider)
1032
+ const ui = shared.useUiLocale();
1033
+ const locale = localeProp ?? ui.intlLocale;
1034
+ const t = shared.useUiMessages("datePicker", localeProp ? shared.getUiMessages(shared.uiLocaleOf(localeProp)).datePicker : undefined, labels, { openCalendar: openCalendarLabel });
1031
1035
  const field = shared.useFieldIds({
1032
1036
  id,
1033
1037
  name,
@@ -1049,58 +1053,24 @@ const DatePicker = require$$0.forwardRef(function DatePicker({ id, name, openCal
1049
1053
  // Pantalla completa: sin scroll detrás, foco dentro y, al cerrar, de vuelta al campo.
1050
1054
  shared.useLockBodyScroll(abiertoCompleto);
1051
1055
  shared.useFocusTrap(calendarRef, abiertoCompleto);
1052
- const closeLabel = locale.startsWith("es") ? "Cerrar" : "Close";
1053
- const titleLabel = label || (locale.startsWith("es") ? "Elegir fecha" : "Select date");
1054
- const getLocaleLabels = () => {
1055
- if (locale.startsWith("es")) {
1056
- return {
1057
- placeholder: "DD/MM/AAAA",
1058
- today: "Hoy",
1059
- clear: "Limpiar",
1060
- required: "Este campo es obligatorio",
1061
- };
1062
- }
1063
- return {
1064
- placeholder: "MM/DD/YYYY",
1065
- today: "Today",
1066
- clear: "Clear",
1067
- required: "This field is required",
1068
- };
1056
+ const closeLabel = t.close;
1057
+ const titleLabel = label || t.title;
1058
+ const localeLabels = {
1059
+ placeholder: shared.datePlaceholder(locale),
1060
+ today: t.today,
1061
+ clear: t.clear,
1062
+ required: t.required,
1069
1063
  };
1070
- const localeLabels = getLocaleLabels();
1071
1064
  // Texto accesible de las flechas según la vista (días -> mes, meses -> año, años -> década).
1072
1065
  const navLabel = (dir) => {
1073
- const es = locale.startsWith("es");
1074
- const unidad = viewMode === "days"
1075
- ? es
1076
- ? "Mes"
1077
- : "month"
1078
- : viewMode === "months"
1079
- ? es
1080
- ? "Año"
1081
- : "year"
1082
- : es
1083
- ? "Década"
1084
- : "decade";
1085
- if (es)
1086
- return `${unidad} ${dir === "prev" ? "anterior" : "siguiente"}`;
1087
- return `${dir === "prev" ? "Previous" : "Next"} ${unidad}`;
1066
+ if (viewMode === "days")
1067
+ return dir === "prev" ? t.previousMonth : t.nextMonth;
1068
+ if (viewMode === "months")
1069
+ return dir === "prev" ? t.previousYear : t.nextYear;
1070
+ return dir === "prev" ? t.previousDecade : t.nextDecade;
1088
1071
  };
1089
1072
  // Format date based on locale
1090
- const formatDate = (date) => {
1091
- if (locale.startsWith("es")) {
1092
- return date.toLocaleDateString("es-ES", {
1093
- year: "numeric",
1094
- month: "2-digit",
1095
- day: "2-digit",
1096
- });
1097
- }
1098
- return date.toLocaleDateString("en-US", {
1099
- year: "numeric",
1100
- month: "2-digit",
1101
- day: "2-digit",
1102
- });
1103
- };
1073
+ const formatDate = (date) => shared.formatLocalDate(date, locale);
1104
1074
  const toIsoDateString = (date) => {
1105
1075
  const y = date.getFullYear();
1106
1076
  const m = `${date.getMonth() + 1}`.padStart(2, "0");
@@ -1260,52 +1230,11 @@ const DatePicker = require$$0.forwardRef(function DatePicker({ id, name, openCal
1260
1230
  return new Date(date.getFullYear(), date.getMonth(), 1).getDay();
1261
1231
  };
1262
1232
  // Get day names
1263
- const getDayNames = () => {
1264
- if (locale.startsWith("es")) {
1265
- return ["Do", "Lu", "Ma", "Mi", "Ju", "Vi", "Sá"];
1266
- }
1267
- return ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
1268
- };
1233
+ const getDayNames = () => shared.shortWeekdays(locale).map((dia) => dia.slice(0, 2));
1269
1234
  // Get month names
1270
- const getMonthNames = () => {
1271
- if (locale.startsWith("es")) {
1272
- return [
1273
- "Ene",
1274
- "Feb",
1275
- "Mar",
1276
- "Abr",
1277
- "May",
1278
- "Jun",
1279
- "Jul",
1280
- "Ago",
1281
- "Sep",
1282
- "Oct",
1283
- "Nov",
1284
- "Dic",
1285
- ];
1286
- }
1287
- return [
1288
- "Jan",
1289
- "Feb",
1290
- "Mar",
1291
- "Apr",
1292
- "May",
1293
- "Jun",
1294
- "Jul",
1295
- "Aug",
1296
- "Sep",
1297
- "Oct",
1298
- "Nov",
1299
- "Dec",
1300
- ];
1301
- };
1235
+ const getMonthNames = () => shared.shortMonths(locale);
1302
1236
  // Get month name
1303
- const getMonthName = (date) => {
1304
- if (locale.startsWith("es")) {
1305
- return date.toLocaleDateString("es-ES", { month: "long" });
1306
- }
1307
- return date.toLocaleDateString("en-US", { month: "long" });
1308
- };
1237
+ const getMonthName = (date) => date.toLocaleDateString(locale, { month: "long" });
1309
1238
  // Check if date is selectable
1310
1239
  const isDateSelectable = (day) => {
1311
1240
  const testDate = new Date(currentMonth.getFullYear(), currentMonth.getMonth(), day);
@@ -1398,8 +1327,7 @@ const DatePicker = require$$0.forwardRef(function DatePicker({ id, name, openCal
1398
1327
  (isFocused || isOpen) &&
1399
1328
  styles.inputFocused, error && styles.inputError, required && !value && !error && styles.inputRequired), children: [jsxRuntimeExports$1.jsx("input", { ref: shared.mergeRefs(inputRef, ref), ...field.controlProps, name: name, required: required, autoComplete: "off", role: "combobox",
1400
1329
  // En móvil se elige en el calendario: sin teclado virtual encima.
1401
- inputMode: fullScreen ? "none" : undefined, "aria-haspopup": "dialog", "aria-expanded": isOpen, type: "text", value: inputValue, onChange: handleInputChange, onBlur: handleInputBlur, onFocus: handleInputFocus, onClick: () => !disabled && !readOnly && setIsOpen(!isOpen), placeholder: placeholder || localeLabels.placeholder, disabled: disabled, readOnly: readOnly, className: classNames(styles.input, !disabled && !readOnly && styles.inputPointer, readOnly && styles.inputReadOnlyText, disabled && styles.inputDisabledText), "aria-label": label ? undefined : placeholder || localeLabels.placeholder }), jsxRuntimeExports$1.jsx(IconButton, { shape: "square", icon: jsxRuntimeExports$1.jsx(e, { size: "md", className: styles.icon }), "aria-label": openCalendarLabel ??
1402
- (locale.startsWith("es") ? "Abrir calendario" : "Open calendar"), onClick: () => !disabled && !readOnly && setIsOpen(!isOpen), disabled: disabled || readOnly, size: "small", variant: "secondary", quiet: true })] }), isOpen && !disabled && !readOnly && (jsxRuntimeExports$1.jsxs("div", { ref: calendarRef, className: classNames(styles.calendar, fullScreen && styles.fullScreen), role: "dialog", "aria-modal": fullScreen || undefined, "aria-label": titleLabel, children: [fullScreen && (jsxRuntimeExports$1.jsxs("div", { className: styles.sheetBar, children: [jsxRuntimeExports$1.jsx("span", { className: styles.sheetTitle, children: titleLabel }), jsxRuntimeExports$1.jsx(b, { type: "button", variant: "text", color: "secondary", size: "small", onClick: () => {
1330
+ inputMode: fullScreen ? "none" : undefined, "aria-haspopup": "dialog", "aria-expanded": isOpen, type: "text", value: inputValue, onChange: handleInputChange, onBlur: handleInputBlur, onFocus: handleInputFocus, onClick: () => !disabled && !readOnly && setIsOpen(!isOpen), placeholder: placeholder || localeLabels.placeholder, disabled: disabled, readOnly: readOnly, className: classNames(styles.input, !disabled && !readOnly && styles.inputPointer, readOnly && styles.inputReadOnlyText, disabled && styles.inputDisabledText), "aria-label": label ? undefined : placeholder || localeLabels.placeholder }), jsxRuntimeExports$1.jsx(IconButton, { shape: "square", icon: jsxRuntimeExports$1.jsx(e, { size: "md", className: styles.icon }), "aria-label": t.openCalendar, onClick: () => !disabled && !readOnly && setIsOpen(!isOpen), disabled: disabled || readOnly, size: "small", variant: "secondary", quiet: true })] }), isOpen && !disabled && !readOnly && (jsxRuntimeExports$1.jsxs("div", { ref: calendarRef, className: classNames(styles.calendar, fullScreen && styles.fullScreen), role: "dialog", "aria-modal": fullScreen || undefined, "aria-label": titleLabel, children: [fullScreen && (jsxRuntimeExports$1.jsxs("div", { className: styles.sheetBar, children: [jsxRuntimeExports$1.jsx("span", { className: styles.sheetTitle, children: titleLabel }), jsxRuntimeExports$1.jsx(b, { type: "button", variant: "text", color: "secondary", size: "small", onClick: () => {
1403
1331
  setIsOpen(false);
1404
1332
  setViewMode("days");
1405
1333
  }, children: closeLabel })] })), jsxRuntimeExports$1.jsxs("div", { className: styles.header, children: [jsxRuntimeExports$1.jsx(IconButton, { icon: jsxRuntimeExports$1.jsx(o, { size: "md", className: styles.navIconPrev }), "aria-label": navLabel("prev"), onClick: viewMode === "days"
package/dist/index.d.ts CHANGED
@@ -1,11 +1,12 @@
1
1
  import React from 'react';
2
+ import { UiMessages } from '@rubenpazch/shared';
2
3
 
3
4
  interface DatePickerProps {
4
5
  /** id del input; si no se pasa se genera uno (la etiqueta se asocia sola). */
5
6
  id?: string;
6
7
  /** name del input. */
7
8
  name?: string;
8
- /** Texto del botón que abre el calendario (accesibilidad). */
9
+ /** Texto del botón que abre el calendario (accesibilidad). @deprecated Usa `labels.openCalendar`. */
9
10
  openCalendarLabel?: string;
10
11
  label?: string;
11
12
  value: string;
@@ -19,7 +20,13 @@ interface DatePickerProps {
19
20
  className?: string;
20
21
  hint?: string;
21
22
  readOnly?: boolean;
23
+ /**
24
+ * Idioma y formato: `es` (día/mes) o `en` (mes/día). Por defecto, el de
25
+ * `UiLocaleProvider` (sin proveedor, `es-PE`).
26
+ */
22
27
  locale?: string;
28
+ /** Textos de la interfaz; por defecto en el idioma de `locale` o del proveedor. */
29
+ labels?: Partial<UiMessages["datePicker"]>;
23
30
  /**
24
31
  * En pantallas pequeñas (< 640 px) el calendario se abre a pantalla completa y vuelve al
25
32
  * campo al elegir la fecha. Por defecto true.
package/dist/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import require$$0, { useState, useRef, useEffect } from 'react';
2
- import { toLegacySize, useFieldIds, useMediaQuery, MOBILE_QUERY, useLockBodyScroll, useFocusTrap, mergeRefs, parseLocalDate } from '@rubenpazch/shared';
2
+ import { toLegacySize, useUiLocale, useUiMessages, getUiMessages, uiLocaleOf, useFieldIds, useMediaQuery, MOBILE_QUERY, useLockBodyScroll, useFocusTrap, datePlaceholder, mergeRefs, formatLocalDate, shortWeekdays, shortMonths, parseLocalDate } from '@rubenpazch/shared';
3
3
 
4
4
  var jsxRuntime$1 = {exports: {}};
5
5
 
@@ -1025,7 +1025,11 @@ var styles = {"wrapper":"DatePicker-module_wrapper__PLuo9","label":"DatePicker-m
1025
1025
  styleInject(css_248z);
1026
1026
 
1027
1027
  /** Selector de fecha con calendario (días, meses y años). Devuelve ISO `AAAA-MM-DD` en hora local. */
1028
- const DatePicker = require$$0.forwardRef(function DatePicker({ id, name, openCalendarLabel, label, value, onChange, placeholder, error, required = false, disabled = false, minDate, maxDate, className = "", hint, readOnly = false, locale = "es", mobileFullScreen = true, }, ref) {
1028
+ const DatePicker = require$$0.forwardRef(function DatePicker({ id, name, openCalendarLabel, label, value, onChange, placeholder, error, required = false, disabled = false, minDate, maxDate, className = "", hint, readOnly = false, locale: localeProp, labels, mobileFullScreen = true, }, ref) {
1029
+ // Sin `locale` propio, el idioma y el formato del proveedor (UiLocaleProvider)
1030
+ const ui = useUiLocale();
1031
+ const locale = localeProp ?? ui.intlLocale;
1032
+ const t = useUiMessages("datePicker", localeProp ? getUiMessages(uiLocaleOf(localeProp)).datePicker : undefined, labels, { openCalendar: openCalendarLabel });
1029
1033
  const field = useFieldIds({
1030
1034
  id,
1031
1035
  name,
@@ -1047,58 +1051,24 @@ const DatePicker = require$$0.forwardRef(function DatePicker({ id, name, openCal
1047
1051
  // Pantalla completa: sin scroll detrás, foco dentro y, al cerrar, de vuelta al campo.
1048
1052
  useLockBodyScroll(abiertoCompleto);
1049
1053
  useFocusTrap(calendarRef, abiertoCompleto);
1050
- const closeLabel = locale.startsWith("es") ? "Cerrar" : "Close";
1051
- const titleLabel = label || (locale.startsWith("es") ? "Elegir fecha" : "Select date");
1052
- const getLocaleLabels = () => {
1053
- if (locale.startsWith("es")) {
1054
- return {
1055
- placeholder: "DD/MM/AAAA",
1056
- today: "Hoy",
1057
- clear: "Limpiar",
1058
- required: "Este campo es obligatorio",
1059
- };
1060
- }
1061
- return {
1062
- placeholder: "MM/DD/YYYY",
1063
- today: "Today",
1064
- clear: "Clear",
1065
- required: "This field is required",
1066
- };
1054
+ const closeLabel = t.close;
1055
+ const titleLabel = label || t.title;
1056
+ const localeLabels = {
1057
+ placeholder: datePlaceholder(locale),
1058
+ today: t.today,
1059
+ clear: t.clear,
1060
+ required: t.required,
1067
1061
  };
1068
- const localeLabels = getLocaleLabels();
1069
1062
  // Texto accesible de las flechas según la vista (días -> mes, meses -> año, años -> década).
1070
1063
  const navLabel = (dir) => {
1071
- const es = locale.startsWith("es");
1072
- const unidad = viewMode === "days"
1073
- ? es
1074
- ? "Mes"
1075
- : "month"
1076
- : viewMode === "months"
1077
- ? es
1078
- ? "Año"
1079
- : "year"
1080
- : es
1081
- ? "Década"
1082
- : "decade";
1083
- if (es)
1084
- return `${unidad} ${dir === "prev" ? "anterior" : "siguiente"}`;
1085
- return `${dir === "prev" ? "Previous" : "Next"} ${unidad}`;
1064
+ if (viewMode === "days")
1065
+ return dir === "prev" ? t.previousMonth : t.nextMonth;
1066
+ if (viewMode === "months")
1067
+ return dir === "prev" ? t.previousYear : t.nextYear;
1068
+ return dir === "prev" ? t.previousDecade : t.nextDecade;
1086
1069
  };
1087
1070
  // Format date based on locale
1088
- const formatDate = (date) => {
1089
- if (locale.startsWith("es")) {
1090
- return date.toLocaleDateString("es-ES", {
1091
- year: "numeric",
1092
- month: "2-digit",
1093
- day: "2-digit",
1094
- });
1095
- }
1096
- return date.toLocaleDateString("en-US", {
1097
- year: "numeric",
1098
- month: "2-digit",
1099
- day: "2-digit",
1100
- });
1101
- };
1071
+ const formatDate = (date) => formatLocalDate(date, locale);
1102
1072
  const toIsoDateString = (date) => {
1103
1073
  const y = date.getFullYear();
1104
1074
  const m = `${date.getMonth() + 1}`.padStart(2, "0");
@@ -1258,52 +1228,11 @@ const DatePicker = require$$0.forwardRef(function DatePicker({ id, name, openCal
1258
1228
  return new Date(date.getFullYear(), date.getMonth(), 1).getDay();
1259
1229
  };
1260
1230
  // Get day names
1261
- const getDayNames = () => {
1262
- if (locale.startsWith("es")) {
1263
- return ["Do", "Lu", "Ma", "Mi", "Ju", "Vi", "Sá"];
1264
- }
1265
- return ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
1266
- };
1231
+ const getDayNames = () => shortWeekdays(locale).map((dia) => dia.slice(0, 2));
1267
1232
  // Get month names
1268
- const getMonthNames = () => {
1269
- if (locale.startsWith("es")) {
1270
- return [
1271
- "Ene",
1272
- "Feb",
1273
- "Mar",
1274
- "Abr",
1275
- "May",
1276
- "Jun",
1277
- "Jul",
1278
- "Ago",
1279
- "Sep",
1280
- "Oct",
1281
- "Nov",
1282
- "Dic",
1283
- ];
1284
- }
1285
- return [
1286
- "Jan",
1287
- "Feb",
1288
- "Mar",
1289
- "Apr",
1290
- "May",
1291
- "Jun",
1292
- "Jul",
1293
- "Aug",
1294
- "Sep",
1295
- "Oct",
1296
- "Nov",
1297
- "Dec",
1298
- ];
1299
- };
1233
+ const getMonthNames = () => shortMonths(locale);
1300
1234
  // Get month name
1301
- const getMonthName = (date) => {
1302
- if (locale.startsWith("es")) {
1303
- return date.toLocaleDateString("es-ES", { month: "long" });
1304
- }
1305
- return date.toLocaleDateString("en-US", { month: "long" });
1306
- };
1235
+ const getMonthName = (date) => date.toLocaleDateString(locale, { month: "long" });
1307
1236
  // Check if date is selectable
1308
1237
  const isDateSelectable = (day) => {
1309
1238
  const testDate = new Date(currentMonth.getFullYear(), currentMonth.getMonth(), day);
@@ -1396,8 +1325,7 @@ const DatePicker = require$$0.forwardRef(function DatePicker({ id, name, openCal
1396
1325
  (isFocused || isOpen) &&
1397
1326
  styles.inputFocused, error && styles.inputError, required && !value && !error && styles.inputRequired), children: [jsxRuntimeExports$1.jsx("input", { ref: mergeRefs(inputRef, ref), ...field.controlProps, name: name, required: required, autoComplete: "off", role: "combobox",
1398
1327
  // En móvil se elige en el calendario: sin teclado virtual encima.
1399
- inputMode: fullScreen ? "none" : undefined, "aria-haspopup": "dialog", "aria-expanded": isOpen, type: "text", value: inputValue, onChange: handleInputChange, onBlur: handleInputBlur, onFocus: handleInputFocus, onClick: () => !disabled && !readOnly && setIsOpen(!isOpen), placeholder: placeholder || localeLabels.placeholder, disabled: disabled, readOnly: readOnly, className: classNames(styles.input, !disabled && !readOnly && styles.inputPointer, readOnly && styles.inputReadOnlyText, disabled && styles.inputDisabledText), "aria-label": label ? undefined : placeholder || localeLabels.placeholder }), jsxRuntimeExports$1.jsx(IconButton, { shape: "square", icon: jsxRuntimeExports$1.jsx(e, { size: "md", className: styles.icon }), "aria-label": openCalendarLabel ??
1400
- (locale.startsWith("es") ? "Abrir calendario" : "Open calendar"), onClick: () => !disabled && !readOnly && setIsOpen(!isOpen), disabled: disabled || readOnly, size: "small", variant: "secondary", quiet: true })] }), isOpen && !disabled && !readOnly && (jsxRuntimeExports$1.jsxs("div", { ref: calendarRef, className: classNames(styles.calendar, fullScreen && styles.fullScreen), role: "dialog", "aria-modal": fullScreen || undefined, "aria-label": titleLabel, children: [fullScreen && (jsxRuntimeExports$1.jsxs("div", { className: styles.sheetBar, children: [jsxRuntimeExports$1.jsx("span", { className: styles.sheetTitle, children: titleLabel }), jsxRuntimeExports$1.jsx(b, { type: "button", variant: "text", color: "secondary", size: "small", onClick: () => {
1328
+ inputMode: fullScreen ? "none" : undefined, "aria-haspopup": "dialog", "aria-expanded": isOpen, type: "text", value: inputValue, onChange: handleInputChange, onBlur: handleInputBlur, onFocus: handleInputFocus, onClick: () => !disabled && !readOnly && setIsOpen(!isOpen), placeholder: placeholder || localeLabels.placeholder, disabled: disabled, readOnly: readOnly, className: classNames(styles.input, !disabled && !readOnly && styles.inputPointer, readOnly && styles.inputReadOnlyText, disabled && styles.inputDisabledText), "aria-label": label ? undefined : placeholder || localeLabels.placeholder }), jsxRuntimeExports$1.jsx(IconButton, { shape: "square", icon: jsxRuntimeExports$1.jsx(e, { size: "md", className: styles.icon }), "aria-label": t.openCalendar, onClick: () => !disabled && !readOnly && setIsOpen(!isOpen), disabled: disabled || readOnly, size: "small", variant: "secondary", quiet: true })] }), isOpen && !disabled && !readOnly && (jsxRuntimeExports$1.jsxs("div", { ref: calendarRef, className: classNames(styles.calendar, fullScreen && styles.fullScreen), role: "dialog", "aria-modal": fullScreen || undefined, "aria-label": titleLabel, children: [fullScreen && (jsxRuntimeExports$1.jsxs("div", { className: styles.sheetBar, children: [jsxRuntimeExports$1.jsx("span", { className: styles.sheetTitle, children: titleLabel }), jsxRuntimeExports$1.jsx(b, { type: "button", variant: "text", color: "secondary", size: "small", onClick: () => {
1401
1329
  setIsOpen(false);
1402
1330
  setViewMode("days");
1403
1331
  }, children: closeLabel })] })), jsxRuntimeExports$1.jsxs("div", { className: styles.header, children: [jsxRuntimeExports$1.jsx(IconButton, { icon: jsxRuntimeExports$1.jsx(o, { size: "md", className: styles.navIconPrev }), "aria-label": navLabel("prev"), onClick: viewMode === "days"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rubenpazch/date-picker",
3
- "version": "3.2.3",
3
+ "version": "3.3.0",
4
4
  "description": "DatePicker component",
5
5
  "private": false,
6
6
  "main": "dist/index.cjs.js",
@@ -32,10 +32,10 @@
32
32
  "@rubenpazch/tokens": "0.5.0"
33
33
  },
34
34
  "dependencies": {
35
- "@rubenpazch/button": "6.2.5",
36
- "@rubenpazch/icon-button": "4.2.2",
37
- "@rubenpazch/icons": "6.5.0",
38
- "@rubenpazch/shared": "5.3.0"
35
+ "@rubenpazch/button": "6.2.6",
36
+ "@rubenpazch/icon-button": "4.2.3",
37
+ "@rubenpazch/icons": "6.6.1",
38
+ "@rubenpazch/shared": "5.4.0"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@rubenpazch/typescript-config": "3.0.0"