@molecule/app-mini-calendar-react 3.0.0 → 4.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.
- package/README.md +21 -8
- package/dist/MiniCalendar.d.ts +8 -2
- package/dist/MiniCalendar.d.ts.map +1 -1
- package/dist/MiniCalendar.js +14 -4
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3
- package/package.json +6 -6
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-
|
|
6
|
+
Generated: 2026-11-21T12:46:46.590Z
|
|
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
|
-
/**
|
|
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`
|
|
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({
|
|
@@ -96,9 +102,9 @@ function MiniCalendar({
|
|
|
96
102
|
|
|
97
103
|
Peer dependencies:
|
|
98
104
|
|
|
99
|
-
- `@molecule/app-react` ^
|
|
105
|
+
- `@molecule/app-react` ^4.0.0
|
|
100
106
|
- `@molecule/app-ui` ^1.0.1
|
|
101
|
-
- `@molecule/app-ui-react` ^
|
|
107
|
+
- `@molecule/app-ui-react` ^4.0.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
|
|
116
|
-
`
|
|
117
|
-
|
|
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`.
|
package/dist/MiniCalendar.d.ts
CHANGED
|
@@ -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
|
-
/**
|
|
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`
|
|
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;
|
|
1
|
+
{"version":3,"file":"MiniCalendar.d.ts","sourceRoot":"","sources":["../src/MiniCalendar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAY,MAAM,OAAO,CAAA;AAM1C,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,CAoGjC"}
|
package/dist/MiniCalendar.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
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';
|
|
5
6
|
/**
|
|
@@ -34,10 +35,16 @@ function isSameDay(a, b) {
|
|
|
34
35
|
/**
|
|
35
36
|
* Compact month-view calendar. Supports controlled `selected` + `month`
|
|
36
37
|
* props or runs uncontrolled. Weekday / month names come from
|
|
37
|
-
* `Intl.DateTimeFormat`
|
|
38
|
+
* `Intl.DateTimeFormat` in the `locale` prop, or the app's active locale when
|
|
39
|
+
* it is omitted. The prev/next buttons' aria-labels go through `t()`
|
|
40
|
+
* (`miniCalendar.aria.*`, English `defaultValue`s).
|
|
38
41
|
* @param props - Component props (see {@link MiniCalendarProps}).
|
|
39
42
|
*/
|
|
40
43
|
export function MiniCalendar({ selected, onSelect, month: monthProp, onMonthChange, locale, isDisabled, className, }) {
|
|
44
|
+
const { t } = useTranslation();
|
|
45
|
+
// Re-renders on a locale switch, so the formatted names change language at
|
|
46
|
+
// once. An explicit `locale` prop still wins.
|
|
47
|
+
const activeLocale = useLocale();
|
|
41
48
|
const cm = getClassMap();
|
|
42
49
|
const selectedDate = toDate(selected);
|
|
43
50
|
const [internalMonth, setInternalMonth] = useState(startOfMonth(monthProp ?? selectedDate ?? new Date()));
|
|
@@ -52,8 +59,9 @@ export function MiniCalendar({ selected, onSelect, month: monthProp, onMonthChan
|
|
|
52
59
|
setInternalMonth(next);
|
|
53
60
|
onMonthChange?.(next);
|
|
54
61
|
}
|
|
55
|
-
const
|
|
56
|
-
const
|
|
62
|
+
const resolvedLocale = locale ?? activeLocale;
|
|
63
|
+
const monthFmt = new Intl.DateTimeFormat(resolvedLocale, { month: 'long', year: 'numeric' });
|
|
64
|
+
const weekdayFmt = new Intl.DateTimeFormat(resolvedLocale, { weekday: 'narrow' });
|
|
57
65
|
// Build grid: 6 rows × 7 cols, starting from the Sunday before the 1st.
|
|
58
66
|
const first = startOfMonth(visibleMonth);
|
|
59
67
|
const gridStart = new Date(first);
|
|
@@ -66,7 +74,9 @@ export function MiniCalendar({ selected, onSelect, month: monthProp, onMonthChan
|
|
|
66
74
|
}
|
|
67
75
|
// Weekday header derived from the first week
|
|
68
76
|
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":
|
|
77
|
+
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": t('miniCalendar.aria.previousMonth', undefined, {
|
|
78
|
+
defaultValue: 'Previous month',
|
|
79
|
+
}), 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": t('miniCalendar.aria.nextMonth', undefined, { defaultValue: '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) => {
|
|
70
80
|
const outOfMonth = d.getMonth() !== visibleMonth.getMonth();
|
|
71
81
|
const isSelected = selectedDate && isSameDay(d, selectedDate);
|
|
72
82
|
const disabled = isDisabled?.(d) ?? false;
|
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
|
|
25
|
-
* `
|
|
26
|
-
*
|
|
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/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
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
|
|
25
|
-
* `
|
|
26
|
-
*
|
|
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": "
|
|
3
|
+
"version": "4.0.1",
|
|
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",
|
|
@@ -33,15 +33,15 @@
|
|
|
33
33
|
"directory": "packages/app/features/mini-calendar-react"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@molecule/app-react": "^
|
|
36
|
+
"@molecule/app-react": "^4.0.0",
|
|
37
37
|
"@molecule/app-ui": "^1.0.1",
|
|
38
|
-
"@molecule/app-ui-react": "^
|
|
38
|
+
"@molecule/app-ui-react": "^4.0.0",
|
|
39
39
|
"react": "^18.0.0 || ^19.0.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@molecule/app-react": "
|
|
43
|
-
"@molecule/app-ui": "1.
|
|
44
|
-
"@molecule/app-ui-react": "
|
|
42
|
+
"@molecule/app-react": "4.10.1",
|
|
43
|
+
"@molecule/app-ui": "1.5.0",
|
|
44
|
+
"@molecule/app-ui-react": "4.2.0",
|
|
45
45
|
"@types/node": "26.6.5",
|
|
46
46
|
"@types/react": "19.3.0",
|
|
47
47
|
"@types/react-dom": "19.3.0",
|