@molecule/app-mini-calendar-react 4.0.0 → 4.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/README.md CHANGED
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
3
  Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
4
  Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
5
  To change this document, edit the module-level JSDoc in src/index.ts.
6
- Generated: 2026-11-12T04:41:03.524Z
6
+ Generated: 2026-11-25T00:25:46.840Z
7
7
  -->
8
8
 
9
9
  # @molecule/app-mini-calendar-react
@@ -59,7 +59,11 @@ interface MiniCalendarProps {
59
59
  month?: Date
60
60
  /** Called when the user navigates months. */
61
61
  onMonthChange?: (date: Date) => void
62
- /** Locale for weekday + month name formatting. */
62
+ /**
63
+ * Locale for weekday + month name formatting. Defaults to the app's active
64
+ * locale (`useLocale()`), so the names follow a locale switch; an explicit
65
+ * `locale` still wins.
66
+ */
63
67
  locale?: string
64
68
  /** Optional day-disabled predicate. */
65
69
  isDisabled?: (date: Date) => boolean
@@ -74,7 +78,9 @@ interface MiniCalendarProps {
74
78
 
75
79
  Compact month-view calendar. Supports controlled `selected` + `month`
76
80
  props or runs uncontrolled. Weekday / month names come from
77
- `Intl.DateTimeFormat` so locales render correctly without extra data.
81
+ `Intl.DateTimeFormat` in the `locale` prop, or the app's active locale when
82
+ it is omitted. The prev/next buttons' aria-labels go through `t()`
83
+ (`miniCalendar.aria.*`, English `defaultValue`s).
78
84
 
79
85
  ```typescript
80
86
  function MiniCalendar({
@@ -98,7 +104,7 @@ Peer dependencies:
98
104
 
99
105
  - `@molecule/app-react` ^4.0.0
100
106
  - `@molecule/app-ui` ^1.0.1
101
- - `@molecule/app-ui-react` ^4.0.0
107
+ - `@molecule/app-ui-react` ^4.4.0
102
108
  - `react` ^18.0.0 || ^19.0.0
103
109
 
104
110
  ### Runtime Dependencies
@@ -112,11 +118,18 @@ Requires a wired ClassMap bond (`setClassMap(...)` at startup) —
112
118
  `getClassMap()` throws before wiring, and the prev/next buttons come
113
119
  from `@molecule/app-ui-react`.
114
120
 
115
- Weekday and month names localize automatically through
116
- `Intl.DateTimeFormat(locale)` — no locale bond involved. The prev/next
117
- button aria-labels are currently English-only.
121
+ Weekday and month names come from `Intl.DateTimeFormat(locale)` — an
122
+ explicit `locale` prop wins, otherwise the app's active locale, so they
123
+ follow a locale switch. The prev/next buttons' aria-labels go through
124
+ `t()` (`miniCalendar.aria.previousMonth` / `miniCalendar.aria.nextMonth`,
125
+ English `defaultValue`s); translations live in the
126
+ `@molecule/app-locales-mini-calendar` bond.
118
127
 
119
128
  When `month` is supplied the visible month is fully controlled —
120
129
  wire `onMonthChange` too or the arrows will appear dead. The grid
121
130
  always renders 6 weeks; days outside the visible month render dimmed
122
131
  and remain clickable unless `isDisabled` filters them.
132
+
133
+ ## Translations
134
+
135
+ Translation strings are provided by `@molecule/app-locales-mini-calendar`.
@@ -9,7 +9,11 @@ export interface MiniCalendarProps {
9
9
  month?: Date;
10
10
  /** Called when the user navigates months. */
11
11
  onMonthChange?: (date: Date) => void;
12
- /** Locale for weekday + month name formatting. */
12
+ /**
13
+ * Locale for weekday + month name formatting. Defaults to the app's active
14
+ * locale (`useLocale()`), so the names follow a locale switch; an explicit
15
+ * `locale` still wins.
16
+ */
13
17
  locale?: string;
14
18
  /** Optional day-disabled predicate. */
15
19
  isDisabled?: (date: Date) => boolean;
@@ -19,7 +23,9 @@ export interface MiniCalendarProps {
19
23
  /**
20
24
  * Compact month-view calendar. Supports controlled `selected` + `month`
21
25
  * props or runs uncontrolled. Weekday / month names come from
22
- * `Intl.DateTimeFormat` so locales render correctly without extra data.
26
+ * `Intl.DateTimeFormat` in the `locale` prop, or the app's active locale when
27
+ * it is omitted. The prev/next buttons' aria-labels go through `t()`
28
+ * (`miniCalendar.aria.*`, English `defaultValue`s).
23
29
  * @param props - Component props (see {@link MiniCalendarProps}).
24
30
  */
25
31
  export declare function MiniCalendar({ selected, onSelect, month: monthProp, onMonthChange, locale, isDisabled, className, }: MiniCalendarProps): JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"MiniCalendar.d.ts","sourceRoot":"","sources":["../src/MiniCalendar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAY,MAAM,OAAO,CAAA;AAK1C,sCAAsC;AACtC,MAAM,WAAW,iBAAiB;IAChC,yDAAyD;IACzD,QAAQ,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;IACxB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;IAC/B,yEAAyE;IACzE,KAAK,CAAC,EAAE,IAAI,CAAA;IACZ,6CAA6C;IAC7C,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;IACpC,kDAAkD;IAClD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,uCAAuC;IACvC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAA;IACpC,qBAAqB;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAkCD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,QAAQ,EACR,KAAK,EAAE,SAAS,EAChB,aAAa,EACb,MAAM,EACN,UAAU,EACV,SAAS,GACV,EAAE,iBAAiB,GAAG,GAAG,CAAC,OAAO,CAmFjC"}
1
+ {"version":3,"file":"MiniCalendar.d.ts","sourceRoot":"","sources":["../src/MiniCalendar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAY,MAAM,OAAO,CAAA;AAO1C,sCAAsC;AACtC,MAAM,WAAW,iBAAiB;IAChC,yDAAyD;IACzD,QAAQ,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;IACxB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;IAC/B,yEAAyE;IACzE,KAAK,CAAC,EAAE,IAAI,CAAA;IACZ,6CAA6C;IAC7C,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;IACpC;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,uCAAuC;IACvC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAA;IACpC,qBAAqB;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAkCD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,QAAQ,EACR,KAAK,EAAE,SAAS,EAChB,aAAa,EACb,MAAM,EACN,UAAU,EACV,SAAS,GACV,EAAE,iBAAiB,GAAG,GAAG,CAAC,OAAO,CAsGjC"}
@@ -1,7 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState } from 'react';
3
+ import { useLocale, useTranslation } from '@molecule/app-react';
3
4
  import { getClassMap } from '@molecule/app-ui';
4
5
  import { Button } from '@molecule/app-ui-react';
6
+ import { Box, Pressable, Text } from '@molecule/app-ui-react/elements';
5
7
  /**
6
8
  * Coerces a Date or ISO string to a Date, returning undefined for invalid values.
7
9
  * @param v
@@ -34,10 +36,16 @@ function isSameDay(a, b) {
34
36
  /**
35
37
  * Compact month-view calendar. Supports controlled `selected` + `month`
36
38
  * props or runs uncontrolled. Weekday / month names come from
37
- * `Intl.DateTimeFormat` so locales render correctly without extra data.
39
+ * `Intl.DateTimeFormat` in the `locale` prop, or the app's active locale when
40
+ * it is omitted. The prev/next buttons' aria-labels go through `t()`
41
+ * (`miniCalendar.aria.*`, English `defaultValue`s).
38
42
  * @param props - Component props (see {@link MiniCalendarProps}).
39
43
  */
40
44
  export function MiniCalendar({ selected, onSelect, month: monthProp, onMonthChange, locale, isDisabled, className, }) {
45
+ const { t } = useTranslation();
46
+ // Re-renders on a locale switch, so the formatted names change language at
47
+ // once. An explicit `locale` prop still wins.
48
+ const activeLocale = useLocale();
41
49
  const cm = getClassMap();
42
50
  const selectedDate = toDate(selected);
43
51
  const [internalMonth, setInternalMonth] = useState(startOfMonth(monthProp ?? selectedDate ?? new Date()));
@@ -52,8 +60,9 @@ export function MiniCalendar({ selected, onSelect, month: monthProp, onMonthChan
52
60
  setInternalMonth(next);
53
61
  onMonthChange?.(next);
54
62
  }
55
- const monthFmt = new Intl.DateTimeFormat(locale, { month: 'long', year: 'numeric' });
56
- const weekdayFmt = new Intl.DateTimeFormat(locale, { weekday: 'narrow' });
63
+ const resolvedLocale = locale ?? activeLocale;
64
+ const monthFmt = new Intl.DateTimeFormat(resolvedLocale, { month: 'long', year: 'numeric' });
65
+ const weekdayFmt = new Intl.DateTimeFormat(resolvedLocale, { weekday: 'narrow' });
57
66
  // Build grid: 6 rows × 7 cols, starting from the Sunday before the 1st.
58
67
  const first = startOfMonth(visibleMonth);
59
68
  const gridStart = new Date(first);
@@ -66,10 +75,12 @@ export function MiniCalendar({ selected, onSelect, month: monthProp, onMonthChan
66
75
  }
67
76
  // Weekday header derived from the first week
68
77
  const weekdayHeader = days.slice(0, 7);
69
- return (_jsxs("div", { className: cm.cn(cm.stack(2), className), children: [_jsxs("header", { className: cm.flex({ justify: 'between', align: 'center', gap: 'sm' }), children: [_jsx(Button, { variant: "ghost", size: "sm", onClick: () => navigate(-1), "aria-label": "Previous month", children: "\u2039" }), _jsx("span", { className: cm.cn(cm.textSize('sm'), cm.fontWeight('semibold')), children: monthFmt.format(visibleMonth) }), _jsx(Button, { variant: "ghost", size: "sm", onClick: () => navigate(1), "aria-label": "Next month", children: "\u203A" })] }), _jsxs("div", { className: cm.grid({ cols: 7, gap: 'xs' }), children: [weekdayHeader.map((d, i) => (_jsx("span", { className: cm.cn(cm.textSize('xs'), cm.fontWeight('semibold'), cm.textCenter), children: weekdayFmt.format(d) }, i))), days.map((d, i) => {
78
+ return (_jsxs(Box, { as: "div", className: cm.cn(cm.stack(2), className), children: [_jsxs(Box, { as: "header", className: cm.flex({ justify: 'between', align: 'center', gap: 'sm' }), children: [_jsx(Button, { variant: "ghost", size: "sm", onClick: () => navigate(-1), "aria-label": t('miniCalendar.aria.previousMonth', undefined, {
79
+ defaultValue: 'Previous month',
80
+ }), children: "\u2039" }), _jsx(Text, { as: "span", className: cm.cn(cm.textSize('sm'), cm.fontWeight('semibold')), children: monthFmt.format(visibleMonth) }), _jsx(Button, { variant: "ghost", size: "sm", onClick: () => navigate(1), "aria-label": t('miniCalendar.aria.nextMonth', undefined, { defaultValue: 'Next month' }), children: "\u203A" })] }), _jsxs(Box, { as: "div", className: cm.grid({ cols: 7, gap: 'xs' }), children: [weekdayHeader.map((d, i) => (_jsx(Text, { as: "span", className: cm.cn(cm.textSize('xs'), cm.fontWeight('semibold'), cm.textCenter), children: weekdayFmt.format(d) }, i))), days.map((d, i) => {
70
81
  const outOfMonth = d.getMonth() !== visibleMonth.getMonth();
71
82
  const isSelected = selectedDate && isSameDay(d, selectedDate);
72
83
  const disabled = isDisabled?.(d) ?? false;
73
- return (_jsx("button", { type: "button", onClick: () => !disabled && onSelect?.(d), disabled: disabled, "aria-current": isSelected ? 'date' : undefined, className: cm.cn(cm.textSize('xs'), cm.sp('py', 1), cm.textCenter, cm.roundedFull, isSelected ? cm.fontWeight('bold') : cm.fontWeight('medium')), style: outOfMonth ? { opacity: 0.3 } : undefined, children: d.getDate() }, i));
84
+ return (_jsx(Pressable, { as: "button", type: "button", onClick: () => !disabled && onSelect?.(d), disabled: disabled, "aria-current": isSelected ? 'date' : undefined, className: cm.cn(cm.textSize('xs'), cm.sp('py', 1), cm.textCenter, cm.roundedFull, isSelected ? cm.fontWeight('bold') : cm.fontWeight('medium')), webStyle: outOfMonth ? { opacity: 0.3 } : undefined, children: d.getDate() }, i));
74
85
  })] })] }));
75
86
  }
package/dist/index.d.ts CHANGED
@@ -21,9 +21,12 @@
21
21
  * `getClassMap()` throws before wiring, and the prev/next buttons come
22
22
  * from `@molecule/app-ui-react`.
23
23
  *
24
- * Weekday and month names localize automatically through
25
- * `Intl.DateTimeFormat(locale)` — no locale bond involved. The prev/next
26
- * button aria-labels are currently English-only.
24
+ * Weekday and month names come from `Intl.DateTimeFormat(locale)` — an
25
+ * explicit `locale` prop wins, otherwise the app's active locale, so they
26
+ * follow a locale switch. The prev/next buttons' aria-labels go through
27
+ * `t()` (`miniCalendar.aria.previousMonth` / `miniCalendar.aria.nextMonth`,
28
+ * English `defaultValue`s); translations live in the
29
+ * `@molecule/app-locales-mini-calendar` bond.
27
30
  *
28
31
  * When `month` is supplied the visible month is fully controlled —
29
32
  * wire `onMonthChange` too or the arrows will appear dead. The grid
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,cAAc,mBAAmB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,cAAc,mBAAmB,CAAA"}
package/dist/index.js CHANGED
@@ -21,9 +21,12 @@
21
21
  * `getClassMap()` throws before wiring, and the prev/next buttons come
22
22
  * from `@molecule/app-ui-react`.
23
23
  *
24
- * Weekday and month names localize automatically through
25
- * `Intl.DateTimeFormat(locale)` — no locale bond involved. The prev/next
26
- * button aria-labels are currently English-only.
24
+ * Weekday and month names come from `Intl.DateTimeFormat(locale)` — an
25
+ * explicit `locale` prop wins, otherwise the app's active locale, so they
26
+ * follow a locale switch. The prev/next buttons' aria-labels go through
27
+ * `t()` (`miniCalendar.aria.previousMonth` / `miniCalendar.aria.nextMonth`,
28
+ * English `defaultValue`s); translations live in the
29
+ * `@molecule/app-locales-mini-calendar` bond.
27
30
  *
28
31
  * When `month` is supplied the visible month is fully controlled —
29
32
  * wire `onMonthChange` too or the arrows will appear dead. The grid
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/app-mini-calendar-react",
3
- "version": "4.0.0",
3
+ "version": "4.1.0",
4
4
  "description": "Month-view calendar with day selection and prev/next navigation",
5
5
  "homepage": "https://www.molecule.dev/packages/app-mini-calendar-react",
6
6
  "type": "module",
@@ -35,13 +35,13 @@
35
35
  "peerDependencies": {
36
36
  "@molecule/app-react": "^4.0.0",
37
37
  "@molecule/app-ui": "^1.0.1",
38
- "@molecule/app-ui-react": "^4.0.0",
38
+ "@molecule/app-ui-react": "^4.4.0",
39
39
  "react": "^18.0.0 || ^19.0.0"
40
40
  },
41
41
  "devDependencies": {
42
- "@molecule/app-react": "4.0.0",
43
- "@molecule/app-ui": "1.3.9",
44
- "@molecule/app-ui-react": "4.0.0",
42
+ "@molecule/app-react": "4.17.0",
43
+ "@molecule/app-ui": "1.13.0",
44
+ "@molecule/app-ui-react": "4.11.0",
45
45
  "@types/node": "26.6.5",
46
46
  "@types/react": "19.3.0",
47
47
  "@types/react-dom": "19.3.0",