@rubenpazch/date-input 3.2.4 → 3.3.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.
package/README.md CHANGED
@@ -30,8 +30,8 @@ Campo de fecha con calendario desplegable. Se escribe en el formato del idioma
30
30
  | `hint` | `string` | | | Texto de ayuda. |
31
31
  | `id` | `string` | | | id del input; si no se pasa se genera uno (la etiqueta se asocia sola). |
32
32
  | `label` | `string` | | | Etiqueta visible. |
33
- | `labels` | `Partial<DateInputLabels>` | | | Textos del calendario; por defecto en el idioma de `locale`. |
34
- | `locale` | `string` | | `es` | Idioma: `es` (por defecto, día/mes) o `en` (mes/día). |
33
+ | `labels` | `Partial<DateInputLabels>` | | | Textos del calendario; por defecto en el idioma de `locale` o del proveedor. |
34
+ | `locale` | `string` | | | Idioma y formato: `es` (día/mes) o `en` (mes/día). Por defecto, el de `UiLocaleProvider` (sin proveedor, `es-PE`). |
35
35
  | `maxDate` | `string` | | | Fecha máxima seleccionable (ISO). |
36
36
  | `minDate` | `string` | | | Fecha mínima seleccionable (ISO). |
37
37
  | `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. |
@@ -37,9 +37,12 @@ export interface DateInputProps {
37
37
  className?: string;
38
38
  /** Texto de ayuda. */
39
39
  hint?: string;
40
- /** Idioma: `es` (por defecto, día/mes) o `en` (mes/día). */
40
+ /**
41
+ * Idioma y formato: `es` (día/mes) o `en` (mes/día). Por defecto, el de
42
+ * `UiLocaleProvider` (sin proveedor, `es-PE`).
43
+ */
41
44
  locale?: string;
42
- /** Textos del calendario; por defecto en el idioma de `locale`. */
45
+ /** Textos del calendario; por defecto en el idioma de `locale` o del proveedor. */
43
46
  labels?: Partial<DateInputLabels>;
44
47
  /**
45
48
  * En pantallas pequeñas (< 640 px) el calendario se abre a pantalla completa y vuelve al
@@ -1 +1 @@
1
- {"version":3,"file":"DateInput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AmF;IACnF,MAAM,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IAClC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAKD;;;GAGG;AACH,QAAA,MAAM,SAAS,yFA8Xd,CAAC;AAIF,eAAe,SAAS,CAAC"}
package/dist/index.cjs.js CHANGED
@@ -935,7 +935,7 @@ const IconButton = require$$0.forwardRef(({ icon, variant = "default", size: siz
935
935
  ]
936
936
  .filter(Boolean)
937
937
  .join(" ");
938
- return (jsxRuntimeExports.jsxs("div", { className: styles$1.root, children: [jsxRuntimeExports.jsx("button", { ref: ref, disabled: disabled, className: buttonClasses, "data-focus-trigger": focusTriggerType, onMouseEnter: () => tooltip && setShowTooltip(true), onMouseLeave: () => setShowTooltip(false), onFocus: () => tooltip && setShowTooltip(true), onBlur: () => setShowTooltip(false), ...props, children: jsxRuntimeExports.jsx("span", { className: iconSizeClass, children: icon }) }), tooltip && showTooltip && (jsxRuntimeExports.jsx("div", { className: `${styles$1.tooltip} ${tooltipPosClass}`, children: tooltip }))] }));
938
+ return (jsxRuntimeExports.jsxs("div", { className: styles$1.root, children: [jsxRuntimeExports.jsx("button", { ref: ref, disabled: disabled, className: buttonClasses, "data-focus-trigger": focusTriggerType, onMouseEnter: () => tooltip && setShowTooltip(true), onMouseLeave: () => setShowTooltip(false), onFocus: () => tooltip && setShowTooltip(true), onBlur: () => setShowTooltip(false), ...props, type: type, children: jsxRuntimeExports.jsx("span", { className: iconSizeClass, children: icon }) }), tooltip && showTooltip && (jsxRuntimeExports.jsx("div", { className: `${styles$1.tooltip} ${tooltipPosClass}`, children: tooltip }))] }));
939
939
  }
940
940
  // Icon button with text
941
941
  const textButtonClasses = [
@@ -1026,37 +1026,17 @@ var css_248z = ".DateInput-module_wrapper__MP3pN {\n display: flex;\n flex-dir
1026
1026
  var styles = {"wrapper":"DateInput-module_wrapper__MP3pN","label":"DateInput-module_label__5Viox","required":"DateInput-module_required__LLtRa","inputWrapper":"DateInput-module_inputWrapper__7reUr","inputContainer":"DateInput-module_inputContainer__-gSJ0","inputError":"DateInput-module_inputError__l6qyl","inputDisabled":"DateInput-module_inputDisabled__UfVE3","input":"DateInput-module_input__xXOdW","icon":"DateInput-module_icon__QYsQ2","calendar":"DateInput-module_calendar__J2TaA","header":"DateInput-module_header__l1q1l","navIconPrev":"DateInput-module_navIconPrev__m4nOB","navIconNext":"DateInput-module_navIconNext__uHOxV","monthTitle":"DateInput-module_monthTitle__ubEKP","dayNames":"DateInput-module_dayNames__nlbfg","dayName":"DateInput-module_dayName__tUYuM","calendarGrid":"DateInput-module_calendarGrid__duNI4","dayButton":"DateInput-module_dayButton__5YF7V","dayEmpty":"DateInput-module_dayEmpty__G6G3v","daySelectable":"DateInput-module_daySelectable__JTaJu","daySelected":"DateInput-module_daySelected__E-Dn9","dayToday":"DateInput-module_dayToday__agR7N","dayDisabled":"DateInput-module_dayDisabled__xHiwC","quickActions":"DateInput-module_quickActions__6-1px","actionButton":"DateInput-module_actionButton__PZFxK","hint":"DateInput-module_hint__FQbf3","errorRow":"DateInput-module_errorRow__8nWQ1","errorIcon":"DateInput-module_errorIcon__s1CsH","errorText":"DateInput-module_errorText__970HV","fullScreen":"DateInput-module_fullScreen__NZYIy","sheetBar":"DateInput-module_sheetBar__Q-Hau","sheetTitle":"DateInput-module_sheetTitle__uupQ-"};
1027
1027
  styleInject(css_248z);
1028
1028
 
1029
- const LABELS_ES = {
1030
- openCalendar: "Abrir calendario",
1031
- previousMonth: "Mes anterior",
1032
- nextMonth: "Mes siguiente",
1033
- today: "Hoy",
1034
- clear: "Limpiar",
1035
- calendar: "Calendario",
1036
- close: "Cerrar",
1037
- };
1038
- const LABELS_EN = {
1039
- openCalendar: "Open calendar",
1040
- previousMonth: "Previous month",
1041
- nextMonth: "Next month",
1042
- today: "Today",
1043
- clear: "Clear",
1044
- calendar: "Calendar",
1045
- close: "Close",
1046
- };
1047
- const DAY_NAMES_ES = ["Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sáb"];
1048
- const DAY_NAMES_EN = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
1049
1029
  const classNames = (...classes) => classes.filter(Boolean).join(" ");
1050
1030
  /**
1051
1031
  * Campo de fecha con calendario desplegable. Se escribe en el formato del idioma
1052
1032
  * (DD/MM/AAAA en español) y devuelve siempre ISO `AAAA-MM-DD`, en hora local.
1053
1033
  */
1054
- const DateInput = require$$0.forwardRef(function DateInput({ id, name, label, value, onChange, placeholder, error, required = false, disabled = false, minDate, maxDate, className = "", hint, locale = "es", labels, mobileFullScreen = true, }, ref) {
1055
- const isEs = locale.startsWith("es");
1056
- const text = {
1057
- ...(isEs ? LABELS_ES : LABELS_EN),
1058
- ...labels,
1059
- };
1034
+ const DateInput = require$$0.forwardRef(function DateInput({ id, name, label, value, onChange, placeholder, error, required = false, disabled = false, minDate, maxDate, className = "", hint, locale: localeProp, labels, mobileFullScreen = true, }, ref) {
1035
+ // Sin `locale` propio, el idioma y el formato del proveedor (UiLocaleProvider)
1036
+ const ui = shared.useUiLocale();
1037
+ const locale = localeProp ?? ui.intlLocale;
1038
+ const text = shared.useUiMessages("dateInput", localeProp ? shared.getUiMessages(shared.uiLocaleOf(localeProp)).dateInput : undefined, labels);
1039
+ const dayNames = require$$0.useMemo(() => shared.shortWeekdays(locale), [locale]);
1060
1040
  const field = shared.useFieldIds({
1061
1041
  id,
1062
1042
  name,
@@ -1165,7 +1145,7 @@ const DateInput = require$$0.forwardRef(function DateInput({ id, name, label, va
1165
1145
  }
1166
1146
  if (!disabled)
1167
1147
  setIsOpen(true);
1168
- }, placeholder: placeholder ?? shared.datePlaceholder(locale), disabled: disabled, className: styles.input, role: "combobox", "aria-haspopup": "dialog", "aria-expanded": isOpen, "aria-controls": isOpen ? calendarId : undefined }), jsxRuntimeExports$1.jsx(IconButton, { icon: jsxRuntimeExports$1.jsx(e, { size: "md", className: styles.icon }), "aria-label": text.openCalendar, onClick: () => !disabled && setIsOpen(!isOpen), disabled: disabled, size: "small", variant: "secondary", quiet: true })] }), isOpen && !disabled && (jsxRuntimeExports$1.jsxs("div", { ref: calendarRef, id: calendarId, className: classNames(styles.calendar, fullScreen && styles.fullScreen), role: "dialog", "aria-modal": fullScreen || undefined, "aria-label": fullScreen && label ? label : text.calendar, children: [fullScreen && (jsxRuntimeExports$1.jsxs("div", { className: styles.sheetBar, children: [jsxRuntimeExports$1.jsx("span", { className: styles.sheetTitle, children: label || text.calendar }), jsxRuntimeExports$1.jsx(b, { type: "button", variant: "text", color: "secondary", size: "small", onClick: () => setIsOpen(false), children: text.close })] })), jsxRuntimeExports$1.jsxs("div", { className: styles.header, children: [jsxRuntimeExports$1.jsx(IconButton, { icon: jsxRuntimeExports$1.jsx(o, { size: "md", className: styles.navIconPrev }), "aria-label": text.previousMonth, onClick: handlePreviousMonth, size: "small", variant: "secondary", quiet: true }), jsxRuntimeExports$1.jsx("h3", { className: styles.monthTitle, "aria-live": "polite", children: shared.formatMonthYear(currentMonth, locale) }), jsxRuntimeExports$1.jsx(IconButton, { icon: jsxRuntimeExports$1.jsx(o, { size: "md", className: styles.navIconNext }), "aria-label": text.nextMonth, onClick: handleNextMonth, size: "small", variant: "secondary", quiet: true })] }), jsxRuntimeExports$1.jsx("div", { className: styles.dayNames, "aria-hidden": "true", children: (isEs ? DAY_NAMES_ES : DAY_NAMES_EN).map((day) => (jsxRuntimeExports$1.jsx("div", { className: styles.dayName, children: day }, day))) }), jsxRuntimeExports$1.jsx("div", { className: styles.calendarGrid, children: calendarDays.map((day, index) => {
1148
+ }, placeholder: placeholder ?? shared.datePlaceholder(locale), disabled: disabled, className: styles.input, role: "combobox", "aria-haspopup": "dialog", "aria-expanded": isOpen, "aria-controls": isOpen ? calendarId : undefined }), jsxRuntimeExports$1.jsx(IconButton, { icon: jsxRuntimeExports$1.jsx(e, { size: "md", className: styles.icon }), "aria-label": text.openCalendar, onClick: () => !disabled && setIsOpen(!isOpen), disabled: disabled, size: "small", variant: "secondary", quiet: true })] }), isOpen && !disabled && (jsxRuntimeExports$1.jsxs("div", { ref: calendarRef, id: calendarId, className: classNames(styles.calendar, fullScreen && styles.fullScreen), role: "dialog", "aria-modal": fullScreen || undefined, "aria-label": fullScreen && label ? label : text.calendar, children: [fullScreen && (jsxRuntimeExports$1.jsxs("div", { className: styles.sheetBar, children: [jsxRuntimeExports$1.jsx("span", { className: styles.sheetTitle, children: label || text.calendar }), jsxRuntimeExports$1.jsx(b, { type: "button", variant: "text", color: "secondary", size: "small", onClick: () => setIsOpen(false), children: text.close })] })), jsxRuntimeExports$1.jsxs("div", { className: styles.header, children: [jsxRuntimeExports$1.jsx(IconButton, { icon: jsxRuntimeExports$1.jsx(o, { size: "md", className: styles.navIconPrev }), "aria-label": text.previousMonth, onClick: handlePreviousMonth, size: "small", variant: "secondary", quiet: true }), jsxRuntimeExports$1.jsx("h3", { className: styles.monthTitle, "aria-live": "polite", children: shared.formatMonthYear(currentMonth, locale) }), jsxRuntimeExports$1.jsx(IconButton, { icon: jsxRuntimeExports$1.jsx(o, { size: "md", className: styles.navIconNext }), "aria-label": text.nextMonth, onClick: handleNextMonth, size: "small", variant: "secondary", quiet: true })] }), jsxRuntimeExports$1.jsx("div", { className: styles.dayNames, "aria-hidden": "true", children: dayNames.map((day) => (jsxRuntimeExports$1.jsx("div", { className: styles.dayName, children: day }, day))) }), jsxRuntimeExports$1.jsx("div", { className: styles.calendarGrid, children: calendarDays.map((day, index) => {
1169
1149
  if (day === null) {
1170
1150
  return (jsxRuntimeExports$1.jsx("span", { className: classNames(styles.dayButton, styles.dayEmpty) }, `vacio-${index}`));
1171
1151
  }
package/dist/index.d.ts CHANGED
@@ -38,9 +38,12 @@ interface DateInputProps {
38
38
  className?: string;
39
39
  /** Texto de ayuda. */
40
40
  hint?: string;
41
- /** Idioma: `es` (por defecto, día/mes) o `en` (mes/día). */
41
+ /**
42
+ * Idioma y formato: `es` (día/mes) o `en` (mes/día). Por defecto, el de
43
+ * `UiLocaleProvider` (sin proveedor, `es-PE`).
44
+ */
42
45
  locale?: string;
43
- /** Textos del calendario; por defecto en el idioma de `locale`. */
46
+ /** Textos del calendario; por defecto en el idioma de `locale` o del proveedor. */
44
47
  labels?: Partial<DateInputLabels>;
45
48
  /**
46
49
  * En pantallas pequeñas (< 640 px) el calendario se abre a pantalla completa y vuelve al
package/dist/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import require$$0, { useState, useRef, useEffect } from 'react';
2
- import { toLegacySize, useFieldIds, parseISODate, useClickOutside, useEscapeKey, useMediaQuery, MOBILE_QUERY, useLockBodyScroll, useFocusTrap, formatLocalDate, datePlaceholder, mergeRefs, formatMonthYear, parseLocalDate, toISODate } from '@rubenpazch/shared';
2
+ import { toLegacySize, useUiLocale, useUiMessages, getUiMessages, uiLocaleOf, shortWeekdays, useFieldIds, parseISODate, useClickOutside, useEscapeKey, useMediaQuery, MOBILE_QUERY, useLockBodyScroll, useFocusTrap, formatLocalDate, datePlaceholder, mergeRefs, formatMonthYear, parseLocalDate, toISODate } from '@rubenpazch/shared';
3
3
 
4
4
  var jsxRuntime$1 = {exports: {}};
5
5
 
@@ -933,7 +933,7 @@ const IconButton = require$$0.forwardRef(({ icon, variant = "default", size: siz
933
933
  ]
934
934
  .filter(Boolean)
935
935
  .join(" ");
936
- return (jsxRuntimeExports.jsxs("div", { className: styles$1.root, children: [jsxRuntimeExports.jsx("button", { ref: ref, disabled: disabled, className: buttonClasses, "data-focus-trigger": focusTriggerType, onMouseEnter: () => tooltip && setShowTooltip(true), onMouseLeave: () => setShowTooltip(false), onFocus: () => tooltip && setShowTooltip(true), onBlur: () => setShowTooltip(false), ...props, children: jsxRuntimeExports.jsx("span", { className: iconSizeClass, children: icon }) }), tooltip && showTooltip && (jsxRuntimeExports.jsx("div", { className: `${styles$1.tooltip} ${tooltipPosClass}`, children: tooltip }))] }));
936
+ return (jsxRuntimeExports.jsxs("div", { className: styles$1.root, children: [jsxRuntimeExports.jsx("button", { ref: ref, disabled: disabled, className: buttonClasses, "data-focus-trigger": focusTriggerType, onMouseEnter: () => tooltip && setShowTooltip(true), onMouseLeave: () => setShowTooltip(false), onFocus: () => tooltip && setShowTooltip(true), onBlur: () => setShowTooltip(false), ...props, type: type, children: jsxRuntimeExports.jsx("span", { className: iconSizeClass, children: icon }) }), tooltip && showTooltip && (jsxRuntimeExports.jsx("div", { className: `${styles$1.tooltip} ${tooltipPosClass}`, children: tooltip }))] }));
937
937
  }
938
938
  // Icon button with text
939
939
  const textButtonClasses = [
@@ -1024,37 +1024,17 @@ var css_248z = ".DateInput-module_wrapper__MP3pN {\n display: flex;\n flex-dir
1024
1024
  var styles = {"wrapper":"DateInput-module_wrapper__MP3pN","label":"DateInput-module_label__5Viox","required":"DateInput-module_required__LLtRa","inputWrapper":"DateInput-module_inputWrapper__7reUr","inputContainer":"DateInput-module_inputContainer__-gSJ0","inputError":"DateInput-module_inputError__l6qyl","inputDisabled":"DateInput-module_inputDisabled__UfVE3","input":"DateInput-module_input__xXOdW","icon":"DateInput-module_icon__QYsQ2","calendar":"DateInput-module_calendar__J2TaA","header":"DateInput-module_header__l1q1l","navIconPrev":"DateInput-module_navIconPrev__m4nOB","navIconNext":"DateInput-module_navIconNext__uHOxV","monthTitle":"DateInput-module_monthTitle__ubEKP","dayNames":"DateInput-module_dayNames__nlbfg","dayName":"DateInput-module_dayName__tUYuM","calendarGrid":"DateInput-module_calendarGrid__duNI4","dayButton":"DateInput-module_dayButton__5YF7V","dayEmpty":"DateInput-module_dayEmpty__G6G3v","daySelectable":"DateInput-module_daySelectable__JTaJu","daySelected":"DateInput-module_daySelected__E-Dn9","dayToday":"DateInput-module_dayToday__agR7N","dayDisabled":"DateInput-module_dayDisabled__xHiwC","quickActions":"DateInput-module_quickActions__6-1px","actionButton":"DateInput-module_actionButton__PZFxK","hint":"DateInput-module_hint__FQbf3","errorRow":"DateInput-module_errorRow__8nWQ1","errorIcon":"DateInput-module_errorIcon__s1CsH","errorText":"DateInput-module_errorText__970HV","fullScreen":"DateInput-module_fullScreen__NZYIy","sheetBar":"DateInput-module_sheetBar__Q-Hau","sheetTitle":"DateInput-module_sheetTitle__uupQ-"};
1025
1025
  styleInject(css_248z);
1026
1026
 
1027
- const LABELS_ES = {
1028
- openCalendar: "Abrir calendario",
1029
- previousMonth: "Mes anterior",
1030
- nextMonth: "Mes siguiente",
1031
- today: "Hoy",
1032
- clear: "Limpiar",
1033
- calendar: "Calendario",
1034
- close: "Cerrar",
1035
- };
1036
- const LABELS_EN = {
1037
- openCalendar: "Open calendar",
1038
- previousMonth: "Previous month",
1039
- nextMonth: "Next month",
1040
- today: "Today",
1041
- clear: "Clear",
1042
- calendar: "Calendar",
1043
- close: "Close",
1044
- };
1045
- const DAY_NAMES_ES = ["Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sáb"];
1046
- const DAY_NAMES_EN = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
1047
1027
  const classNames = (...classes) => classes.filter(Boolean).join(" ");
1048
1028
  /**
1049
1029
  * Campo de fecha con calendario desplegable. Se escribe en el formato del idioma
1050
1030
  * (DD/MM/AAAA en español) y devuelve siempre ISO `AAAA-MM-DD`, en hora local.
1051
1031
  */
1052
- const DateInput = require$$0.forwardRef(function DateInput({ id, name, label, value, onChange, placeholder, error, required = false, disabled = false, minDate, maxDate, className = "", hint, locale = "es", labels, mobileFullScreen = true, }, ref) {
1053
- const isEs = locale.startsWith("es");
1054
- const text = {
1055
- ...(isEs ? LABELS_ES : LABELS_EN),
1056
- ...labels,
1057
- };
1032
+ const DateInput = require$$0.forwardRef(function DateInput({ id, name, label, value, onChange, placeholder, error, required = false, disabled = false, minDate, maxDate, className = "", hint, locale: localeProp, labels, mobileFullScreen = true, }, ref) {
1033
+ // Sin `locale` propio, el idioma y el formato del proveedor (UiLocaleProvider)
1034
+ const ui = useUiLocale();
1035
+ const locale = localeProp ?? ui.intlLocale;
1036
+ const text = useUiMessages("dateInput", localeProp ? getUiMessages(uiLocaleOf(localeProp)).dateInput : undefined, labels);
1037
+ const dayNames = require$$0.useMemo(() => shortWeekdays(locale), [locale]);
1058
1038
  const field = useFieldIds({
1059
1039
  id,
1060
1040
  name,
@@ -1163,7 +1143,7 @@ const DateInput = require$$0.forwardRef(function DateInput({ id, name, label, va
1163
1143
  }
1164
1144
  if (!disabled)
1165
1145
  setIsOpen(true);
1166
- }, placeholder: placeholder ?? datePlaceholder(locale), disabled: disabled, className: styles.input, role: "combobox", "aria-haspopup": "dialog", "aria-expanded": isOpen, "aria-controls": isOpen ? calendarId : undefined }), jsxRuntimeExports$1.jsx(IconButton, { icon: jsxRuntimeExports$1.jsx(e, { size: "md", className: styles.icon }), "aria-label": text.openCalendar, onClick: () => !disabled && setIsOpen(!isOpen), disabled: disabled, size: "small", variant: "secondary", quiet: true })] }), isOpen && !disabled && (jsxRuntimeExports$1.jsxs("div", { ref: calendarRef, id: calendarId, className: classNames(styles.calendar, fullScreen && styles.fullScreen), role: "dialog", "aria-modal": fullScreen || undefined, "aria-label": fullScreen && label ? label : text.calendar, children: [fullScreen && (jsxRuntimeExports$1.jsxs("div", { className: styles.sheetBar, children: [jsxRuntimeExports$1.jsx("span", { className: styles.sheetTitle, children: label || text.calendar }), jsxRuntimeExports$1.jsx(b, { type: "button", variant: "text", color: "secondary", size: "small", onClick: () => setIsOpen(false), children: text.close })] })), jsxRuntimeExports$1.jsxs("div", { className: styles.header, children: [jsxRuntimeExports$1.jsx(IconButton, { icon: jsxRuntimeExports$1.jsx(o, { size: "md", className: styles.navIconPrev }), "aria-label": text.previousMonth, onClick: handlePreviousMonth, size: "small", variant: "secondary", quiet: true }), jsxRuntimeExports$1.jsx("h3", { className: styles.monthTitle, "aria-live": "polite", children: formatMonthYear(currentMonth, locale) }), jsxRuntimeExports$1.jsx(IconButton, { icon: jsxRuntimeExports$1.jsx(o, { size: "md", className: styles.navIconNext }), "aria-label": text.nextMonth, onClick: handleNextMonth, size: "small", variant: "secondary", quiet: true })] }), jsxRuntimeExports$1.jsx("div", { className: styles.dayNames, "aria-hidden": "true", children: (isEs ? DAY_NAMES_ES : DAY_NAMES_EN).map((day) => (jsxRuntimeExports$1.jsx("div", { className: styles.dayName, children: day }, day))) }), jsxRuntimeExports$1.jsx("div", { className: styles.calendarGrid, children: calendarDays.map((day, index) => {
1146
+ }, placeholder: placeholder ?? datePlaceholder(locale), disabled: disabled, className: styles.input, role: "combobox", "aria-haspopup": "dialog", "aria-expanded": isOpen, "aria-controls": isOpen ? calendarId : undefined }), jsxRuntimeExports$1.jsx(IconButton, { icon: jsxRuntimeExports$1.jsx(e, { size: "md", className: styles.icon }), "aria-label": text.openCalendar, onClick: () => !disabled && setIsOpen(!isOpen), disabled: disabled, size: "small", variant: "secondary", quiet: true })] }), isOpen && !disabled && (jsxRuntimeExports$1.jsxs("div", { ref: calendarRef, id: calendarId, className: classNames(styles.calendar, fullScreen && styles.fullScreen), role: "dialog", "aria-modal": fullScreen || undefined, "aria-label": fullScreen && label ? label : text.calendar, children: [fullScreen && (jsxRuntimeExports$1.jsxs("div", { className: styles.sheetBar, children: [jsxRuntimeExports$1.jsx("span", { className: styles.sheetTitle, children: label || text.calendar }), jsxRuntimeExports$1.jsx(b, { type: "button", variant: "text", color: "secondary", size: "small", onClick: () => setIsOpen(false), children: text.close })] })), jsxRuntimeExports$1.jsxs("div", { className: styles.header, children: [jsxRuntimeExports$1.jsx(IconButton, { icon: jsxRuntimeExports$1.jsx(o, { size: "md", className: styles.navIconPrev }), "aria-label": text.previousMonth, onClick: handlePreviousMonth, size: "small", variant: "secondary", quiet: true }), jsxRuntimeExports$1.jsx("h3", { className: styles.monthTitle, "aria-live": "polite", children: formatMonthYear(currentMonth, locale) }), jsxRuntimeExports$1.jsx(IconButton, { icon: jsxRuntimeExports$1.jsx(o, { size: "md", className: styles.navIconNext }), "aria-label": text.nextMonth, onClick: handleNextMonth, size: "small", variant: "secondary", quiet: true })] }), jsxRuntimeExports$1.jsx("div", { className: styles.dayNames, "aria-hidden": "true", children: dayNames.map((day) => (jsxRuntimeExports$1.jsx("div", { className: styles.dayName, children: day }, day))) }), jsxRuntimeExports$1.jsx("div", { className: styles.calendarGrid, children: calendarDays.map((day, index) => {
1167
1147
  if (day === null) {
1168
1148
  return (jsxRuntimeExports$1.jsx("span", { className: classNames(styles.dayButton, styles.dayEmpty) }, `vacio-${index}`));
1169
1149
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rubenpazch/date-input",
3
- "version": "3.2.4",
3
+ "version": "3.3.1",
4
4
  "description": "DateInput 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.6.0",
38
- "@rubenpazch/shared": "5.3.0"
35
+ "@rubenpazch/button": "6.2.6",
36
+ "@rubenpazch/icon-button": "4.2.4",
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"