cpk-ui 0.7.0 → 0.8.0-beta.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 +15 -14
- package/components/modals/AlertDialog/AlertDialog.d.ts +11 -5
- package/components/modals/AlertDialog/AlertDialog.d.ts.map +1 -1
- package/components/modals/AlertDialog/AlertDialog.js +46 -36
- package/components/uis/Button/Button.d.ts.map +1 -1
- package/components/uis/Button/Button.js +16 -13
- package/components/uis/Calendar/Calendar.d.ts +6 -0
- package/components/uis/Calendar/Calendar.d.ts.map +1 -0
- package/components/uis/Calendar/Calendar.js +482 -0
- package/components/uis/Calendar/CalendarDay.d.ts +21 -0
- package/components/uis/Calendar/CalendarDay.d.ts.map +1 -0
- package/components/uis/Calendar/CalendarDay.js +172 -0
- package/components/uis/Calendar/CalendarHeader.d.ts +22 -0
- package/components/uis/Calendar/CalendarHeader.d.ts.map +1 -0
- package/components/uis/Calendar/CalendarHeader.js +40 -0
- package/components/uis/Calendar/CalendarPage.d.ts +46 -0
- package/components/uis/Calendar/CalendarPage.d.ts.map +1 -0
- package/components/uis/Calendar/CalendarPage.js +34 -0
- package/components/uis/Calendar/CalendarPager.d.ts +11 -0
- package/components/uis/Calendar/CalendarPager.d.ts.map +1 -0
- package/components/uis/Calendar/CalendarPager.js +115 -0
- package/components/uis/Calendar/CalendarPager.web.d.ts +11 -0
- package/components/uis/Calendar/CalendarPager.web.d.ts.map +1 -0
- package/components/uis/Calendar/CalendarPager.web.js +72 -0
- package/components/uis/Calendar/CalendarWeekRow.d.ts +20 -0
- package/components/uis/Calendar/CalendarWeekRow.d.ts.map +1 -0
- package/components/uis/Calendar/CalendarWeekRow.js +64 -0
- package/components/uis/Calendar/CalendarWeekdayRow.d.ts +24 -0
- package/components/uis/Calendar/CalendarWeekdayRow.d.ts.map +1 -0
- package/components/uis/Calendar/CalendarWeekdayRow.js +45 -0
- package/components/uis/Calendar/intl.d.ts +18 -0
- package/components/uis/Calendar/intl.d.ts.map +1 -0
- package/components/uis/Calendar/intl.js +146 -0
- package/components/uis/Calendar/palette.d.ts +10 -0
- package/components/uis/Calendar/palette.d.ts.map +1 -0
- package/components/uis/Calendar/palette.js +93 -0
- package/components/uis/Calendar/types.d.ts +286 -0
- package/components/uis/Calendar/types.d.ts.map +1 -0
- package/components/uis/Calendar/types.js +1 -0
- package/components/uis/Calendar/useCalendarState.d.ts +66 -0
- package/components/uis/Calendar/useCalendarState.d.ts.map +1 -0
- package/components/uis/Calendar/useCalendarState.js +211 -0
- package/components/uis/Calendar/utils.d.ts +114 -0
- package/components/uis/Calendar/utils.d.ts.map +1 -0
- package/components/uis/Calendar/utils.js +429 -0
- package/components/uis/ParallaxHeader/ParallaxHeader.d.ts +44 -0
- package/components/uis/ParallaxHeader/ParallaxHeader.d.ts.map +1 -0
- package/components/uis/ParallaxHeader/ParallaxHeader.js +142 -0
- package/index.d.ts +2 -0
- package/index.d.ts.map +1 -1
- package/index.js +2 -0
- package/package.json +2 -1
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
const OPTIONS = {
|
|
2
|
+
monthTitle: { year: 'numeric', month: 'long' },
|
|
3
|
+
weekdayNarrow: { weekday: 'narrow' },
|
|
4
|
+
dayNumber: { day: 'numeric' },
|
|
5
|
+
dayFull: { dateStyle: 'full' },
|
|
6
|
+
rangeDay: { month: 'short', day: 'numeric', year: 'numeric' },
|
|
7
|
+
};
|
|
8
|
+
const hasIntl = typeof Intl !== 'undefined' && typeof Intl.DateTimeFormat === 'function';
|
|
9
|
+
const formatCache = new Map();
|
|
10
|
+
export function getFormat(locale, shape) {
|
|
11
|
+
if (!hasIntl) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
const cacheKey = `${locale}|${shape}`;
|
|
15
|
+
if (formatCache.has(cacheKey)) {
|
|
16
|
+
return formatCache.get(cacheKey) ?? null;
|
|
17
|
+
}
|
|
18
|
+
let format = null;
|
|
19
|
+
try {
|
|
20
|
+
format = new Intl.DateTimeFormat(locale, OPTIONS[shape]);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
try {
|
|
24
|
+
format = new Intl.DateTimeFormat(undefined, OPTIONS[shape]);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
// Exotic runtime without a usable ICU. The English fallbacks below take over.
|
|
28
|
+
format = null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
formatCache.set(cacheKey, format);
|
|
32
|
+
return format;
|
|
33
|
+
}
|
|
34
|
+
/** The device locale, or `en-US` when the runtime has no `Intl`. */
|
|
35
|
+
export function resolveLocale() {
|
|
36
|
+
if (!hasIntl) {
|
|
37
|
+
return 'en-US';
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
return new Intl.DateTimeFormat().resolvedOptions().locale || 'en-US';
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return 'en-US';
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const FALLBACK_MONTHS = [
|
|
47
|
+
'January',
|
|
48
|
+
'February',
|
|
49
|
+
'March',
|
|
50
|
+
'April',
|
|
51
|
+
'May',
|
|
52
|
+
'June',
|
|
53
|
+
'July',
|
|
54
|
+
'August',
|
|
55
|
+
'September',
|
|
56
|
+
'October',
|
|
57
|
+
'November',
|
|
58
|
+
'December',
|
|
59
|
+
];
|
|
60
|
+
const FALLBACK_MONTHS_SHORT = [
|
|
61
|
+
'Jan',
|
|
62
|
+
'Feb',
|
|
63
|
+
'Mar',
|
|
64
|
+
'Apr',
|
|
65
|
+
'May',
|
|
66
|
+
'Jun',
|
|
67
|
+
'Jul',
|
|
68
|
+
'Aug',
|
|
69
|
+
'Sep',
|
|
70
|
+
'Oct',
|
|
71
|
+
'Nov',
|
|
72
|
+
'Dec',
|
|
73
|
+
];
|
|
74
|
+
const FALLBACK_WEEKDAYS = [
|
|
75
|
+
'Sunday',
|
|
76
|
+
'Monday',
|
|
77
|
+
'Tuesday',
|
|
78
|
+
'Wednesday',
|
|
79
|
+
'Thursday',
|
|
80
|
+
'Friday',
|
|
81
|
+
'Saturday',
|
|
82
|
+
];
|
|
83
|
+
const FALLBACK_WEEKDAY_NARROW = ['S', 'M', 'T', 'W', 'T', 'F', 'S'];
|
|
84
|
+
const monthTitle = (date, locale) => {
|
|
85
|
+
const format = getFormat(locale, 'monthTitle');
|
|
86
|
+
return format
|
|
87
|
+
? format.format(date)
|
|
88
|
+
: `${FALLBACK_MONTHS[date.getMonth()]} ${date.getFullYear()}`;
|
|
89
|
+
};
|
|
90
|
+
const rangeDay = (date, locale) => {
|
|
91
|
+
const format = getFormat(locale, 'rangeDay');
|
|
92
|
+
return format
|
|
93
|
+
? format.format(date)
|
|
94
|
+
: `${FALLBACK_MONTHS_SHORT[date.getMonth()]} ${date.getDate()}, ${date.getFullYear()}`;
|
|
95
|
+
};
|
|
96
|
+
const weekTitle = (start, end, locale) => {
|
|
97
|
+
const format = getFormat(locale, 'rangeDay');
|
|
98
|
+
if (format && typeof format.formatRange === 'function') {
|
|
99
|
+
try {
|
|
100
|
+
return format.formatRange(start, end);
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
// Older ICU without formatRange. Fall through to the manual join.
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return `${rangeDay(start, locale)} – ${rangeDay(end, locale)}`;
|
|
107
|
+
};
|
|
108
|
+
const weekdayLabel = (date, locale) => {
|
|
109
|
+
const format = getFormat(locale, 'weekdayNarrow');
|
|
110
|
+
return format ? format.format(date) : FALLBACK_WEEKDAY_NARROW[date.getDay()];
|
|
111
|
+
};
|
|
112
|
+
const dayNumber = (date, locale) => {
|
|
113
|
+
const format = getFormat(locale, 'dayNumber');
|
|
114
|
+
return format ? format.format(date) : String(date.getDate());
|
|
115
|
+
};
|
|
116
|
+
const dayAccessibilityLabel = (date, locale) => {
|
|
117
|
+
const format = getFormat(locale, 'dayFull');
|
|
118
|
+
return format
|
|
119
|
+
? format.format(date)
|
|
120
|
+
: `${FALLBACK_WEEKDAYS[date.getDay()]}, ${FALLBACK_MONTHS[date.getMonth()]} ${date.getDate()}, ${date.getFullYear()}`;
|
|
121
|
+
};
|
|
122
|
+
export const DEFAULT_FORMATTERS = Object.freeze({
|
|
123
|
+
monthTitle,
|
|
124
|
+
weekTitle,
|
|
125
|
+
weekdayLabel,
|
|
126
|
+
dayNumber,
|
|
127
|
+
dayAccessibilityLabel,
|
|
128
|
+
});
|
|
129
|
+
let formattersSeq = 0;
|
|
130
|
+
const formattersIds = new WeakMap();
|
|
131
|
+
/**
|
|
132
|
+
* A stable id per formatters object, so the grid LRU key changes when a caller
|
|
133
|
+
* swaps in different formatters but not when it re-renders with the same ones.
|
|
134
|
+
*/
|
|
135
|
+
export function getFormattersId(formatters) {
|
|
136
|
+
if (formatters === DEFAULT_FORMATTERS) {
|
|
137
|
+
return 'default';
|
|
138
|
+
}
|
|
139
|
+
let id = formattersIds.get(formatters);
|
|
140
|
+
if (!id) {
|
|
141
|
+
formattersSeq += 1;
|
|
142
|
+
id = `f${formattersSeq}`;
|
|
143
|
+
formattersIds.set(formatters, id);
|
|
144
|
+
}
|
|
145
|
+
return id;
|
|
146
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CpkTheme } from '../../../utils/theme';
|
|
2
|
+
import type { CalendarColors, CalendarPalette } from './types';
|
|
3
|
+
export declare function resolveCalendarPalette(theme: CpkTheme, colors?: CalendarColors): CalendarPalette;
|
|
4
|
+
/**
|
|
5
|
+
* `ThemeProvider` rebuilds its context value on every render, so comparing the
|
|
6
|
+
* resolved colours by value is what keeps `chrome` (and therefore all 42 cells)
|
|
7
|
+
* from re-rendering when nothing about the theme actually changed.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isSamePalette(a: CalendarPalette, b: CalendarPalette): boolean;
|
|
10
|
+
//# sourceMappingURL=palette.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"palette.d.ts","sourceRoot":"","sources":["../../../../src/components/uis/Calendar/palette.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AACnD,OAAO,KAAK,EAAC,cAAc,EAAE,eAAe,EAAC,MAAM,SAAS,CAAC;AAsC7D,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,QAAQ,EACf,MAAM,CAAC,EAAE,cAAc,GACtB,eAAe,CA4BjB;AA6BD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,eAAe,GAAG,OAAO,CAY7E"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { readableTextOn, relativeLuminance } from './utils';
|
|
2
|
+
/**
|
|
3
|
+
* The calendar reads exactly the tokens listed below and nothing else.
|
|
4
|
+
* `background` is the only literal in the component: the grid inherits the surface
|
|
5
|
+
* it sits on instead of painting its own, so dark mode needs no special casing.
|
|
6
|
+
*/
|
|
7
|
+
const TRANSPARENT = 'transparent';
|
|
8
|
+
/**
|
|
9
|
+
* Auto contrast for a caller supplied `selectedBackground`.
|
|
10
|
+
* A ledger colour such as a saturated yellow is unreadable under a hard coded white
|
|
11
|
+
* label, so the label is picked by relative luminance from the two text tokens.
|
|
12
|
+
*/
|
|
13
|
+
function resolveSelectedText(theme, selectedBackground) {
|
|
14
|
+
const contrastLuminance = relativeLuminance(theme.text.contrast);
|
|
15
|
+
const basicLuminance = relativeLuminance(theme.text.basic);
|
|
16
|
+
if (contrastLuminance === null || basicLuminance === null) {
|
|
17
|
+
return theme.text.contrast;
|
|
18
|
+
}
|
|
19
|
+
const lighter = contrastLuminance >= basicLuminance
|
|
20
|
+
? theme.text.contrast
|
|
21
|
+
: theme.text.basic;
|
|
22
|
+
const darker = contrastLuminance >= basicLuminance
|
|
23
|
+
? theme.text.basic
|
|
24
|
+
: theme.text.contrast;
|
|
25
|
+
return readableTextOn(selectedBackground, lighter, darker);
|
|
26
|
+
}
|
|
27
|
+
export function resolveCalendarPalette(theme, colors) {
|
|
28
|
+
const selectedBackground = colors?.selectedBackground ?? theme.role.primary;
|
|
29
|
+
const selectedText = colors?.selectedText ??
|
|
30
|
+
(colors?.selectedBackground
|
|
31
|
+
? resolveSelectedText(theme, colors.selectedBackground)
|
|
32
|
+
: theme.text.contrast);
|
|
33
|
+
return Object.freeze({
|
|
34
|
+
background: colors?.background ?? TRANSPARENT,
|
|
35
|
+
headerText: colors?.headerText ?? theme.text.basic,
|
|
36
|
+
navIcon: colors?.navIcon ?? theme.text.basic,
|
|
37
|
+
weekdayLabel: colors?.weekdayLabel ?? theme.text.label,
|
|
38
|
+
weekNumberLabel: colors?.weekNumberLabel ?? theme.text.disabled,
|
|
39
|
+
dayText: colors?.dayText ?? theme.text.basic,
|
|
40
|
+
sundayText: colors?.sundayText ?? theme.role.danger,
|
|
41
|
+
saturdayText: colors?.saturdayText ?? theme.role.info,
|
|
42
|
+
outsideText: colors?.outsideText ?? theme.text.disabled,
|
|
43
|
+
disabledText: colors?.disabledText ?? theme.text.disabled,
|
|
44
|
+
todayText: colors?.todayText ?? theme.role.secondary,
|
|
45
|
+
todayRing: colors?.todayRing ?? theme.role.secondary,
|
|
46
|
+
selectedBackground,
|
|
47
|
+
selectedText,
|
|
48
|
+
underlay: colors?.underlay ?? theme.role.underlay,
|
|
49
|
+
border: colors?.border ?? theme.role.border,
|
|
50
|
+
dot: colors?.dot ?? theme.role.primary,
|
|
51
|
+
badgeText: colors?.badgeText ?? theme.text.label,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
const PALETTE_KEYS = Object.keys(resolveCalendarPalette({
|
|
55
|
+
bg: { basic: '', paper: '', disabled: '' },
|
|
56
|
+
role: {
|
|
57
|
+
primary: '',
|
|
58
|
+
secondary: '',
|
|
59
|
+
success: '',
|
|
60
|
+
warning: '',
|
|
61
|
+
danger: '',
|
|
62
|
+
info: '',
|
|
63
|
+
accent: '',
|
|
64
|
+
link: '',
|
|
65
|
+
border: '',
|
|
66
|
+
underlay: '',
|
|
67
|
+
underlayContrast: '',
|
|
68
|
+
},
|
|
69
|
+
text: {
|
|
70
|
+
basic: '',
|
|
71
|
+
label: '',
|
|
72
|
+
placeholder: '',
|
|
73
|
+
disabled: '',
|
|
74
|
+
validation: '',
|
|
75
|
+
contrast: '',
|
|
76
|
+
},
|
|
77
|
+
}));
|
|
78
|
+
/**
|
|
79
|
+
* `ThemeProvider` rebuilds its context value on every render, so comparing the
|
|
80
|
+
* resolved colours by value is what keeps `chrome` (and therefore all 42 cells)
|
|
81
|
+
* from re-rendering when nothing about the theme actually changed.
|
|
82
|
+
*/
|
|
83
|
+
export function isSamePalette(a, b) {
|
|
84
|
+
if (a === b) {
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
for (const key of PALETTE_KEYS) {
|
|
88
|
+
if (a[key] !== b[key]) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { StyleProp, TextStyle, ViewStyle } from 'react-native';
|
|
3
|
+
/**
|
|
4
|
+
* Canonical day key. ALWAYS `yyyy-MM-dd`, zero padded, in the DEVICE LOCAL calendar.
|
|
5
|
+
* Keys sort lexicographically, so range checks are plain string compares.
|
|
6
|
+
*/
|
|
7
|
+
export type CalendarDateKey = string;
|
|
8
|
+
/** Canonical month key. ALWAYS `yyyy-MM`. */
|
|
9
|
+
export type CalendarMonthKey = string;
|
|
10
|
+
/**
|
|
11
|
+
* The key identifying one pager page: a month key in `mode='month'`, a day key
|
|
12
|
+
* (the first day of the week) in `mode='week'`.
|
|
13
|
+
*/
|
|
14
|
+
export type CalendarPageKey = CalendarMonthKey | CalendarDateKey;
|
|
15
|
+
/** 0 = Sunday … 6 = Saturday. Same numbering as `Date.prototype.getDay()`. */
|
|
16
|
+
export type WeekStart = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
17
|
+
export type CalendarWeekday = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
18
|
+
export type CalendarViewMode = 'month' | 'week';
|
|
19
|
+
export type CalendarSizeType = 'compact' | 'regular' | 'expanded' | number;
|
|
20
|
+
export type CalendarChangeSource = 'press' | 'swipe' | 'button' | 'keyboard' | 'imperative';
|
|
21
|
+
/**
|
|
22
|
+
* Structural shape of a Reanimated `SharedValue<number>` in `[0, 1]`.
|
|
23
|
+
* Declared structurally so the public API is not pinned to a Reanimated version.
|
|
24
|
+
*/
|
|
25
|
+
export type CalendarCollapseProgress = {
|
|
26
|
+
value: number;
|
|
27
|
+
};
|
|
28
|
+
export type CalendarDot = {
|
|
29
|
+
/** Stable identity within the day. Used as the React key. */
|
|
30
|
+
key: string;
|
|
31
|
+
/** Defaults to `palette.dot`. */
|
|
32
|
+
color?: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Everything one day cell can be decorated with. Looked up O(1) by `CalendarDateKey`.
|
|
36
|
+
* Marker objects SHOULD be referentially stable across renders so the cell memo bails.
|
|
37
|
+
*/
|
|
38
|
+
export type CalendarMarker = {
|
|
39
|
+
dots?: readonly CalendarDot[];
|
|
40
|
+
/** Overrides the selected pill background for this day only. */
|
|
41
|
+
selectedColor?: string;
|
|
42
|
+
/** Overrides the day number color when the day is NOT selected. */
|
|
43
|
+
textColor?: string;
|
|
44
|
+
/** Tiny caption under the number. Hidden when the font scale exceeds 1.3. */
|
|
45
|
+
badgeText?: string;
|
|
46
|
+
badgeColor?: string;
|
|
47
|
+
disabled?: boolean;
|
|
48
|
+
/** Appended to the cell accessibility label, e.g. "3 entries, minus 42,000 won". */
|
|
49
|
+
accessibilityHint?: string;
|
|
50
|
+
};
|
|
51
|
+
export type CalendarMarkerMap = Readonly<Record<CalendarDateKey, CalendarMarker>>;
|
|
52
|
+
export type CalendarDayModel = {
|
|
53
|
+
key: CalendarDateKey;
|
|
54
|
+
/** Local noon of that calendar day. Noon anchoring keeps DST off the day boundary. */
|
|
55
|
+
date: Date;
|
|
56
|
+
dayOfMonth: number;
|
|
57
|
+
/** 0 = Sunday, independent of `weekStart`. */
|
|
58
|
+
weekday: CalendarWeekday;
|
|
59
|
+
/** True when the cell belongs to the previous or next month (month mode only). */
|
|
60
|
+
isOutside: boolean;
|
|
61
|
+
/** 0 based row index inside the page grid. */
|
|
62
|
+
weekIndex: number;
|
|
63
|
+
/** Week number, only computed when `showWeekNumbers` is true, else 0. */
|
|
64
|
+
weekNumber: number;
|
|
65
|
+
};
|
|
66
|
+
export type CalendarDayState = {
|
|
67
|
+
day: CalendarDayModel;
|
|
68
|
+
isSelected: boolean;
|
|
69
|
+
isToday: boolean;
|
|
70
|
+
isDisabled: boolean;
|
|
71
|
+
marker?: CalendarMarker;
|
|
72
|
+
};
|
|
73
|
+
/** The resolved, frozen colour set threaded to every cell as one prop. */
|
|
74
|
+
export type CalendarPalette = Readonly<{
|
|
75
|
+
background: string;
|
|
76
|
+
headerText: string;
|
|
77
|
+
navIcon: string;
|
|
78
|
+
weekdayLabel: string;
|
|
79
|
+
weekNumberLabel: string;
|
|
80
|
+
dayText: string;
|
|
81
|
+
sundayText: string;
|
|
82
|
+
saturdayText: string;
|
|
83
|
+
outsideText: string;
|
|
84
|
+
disabledText: string;
|
|
85
|
+
todayText: string;
|
|
86
|
+
todayRing: string;
|
|
87
|
+
selectedBackground: string;
|
|
88
|
+
selectedText: string;
|
|
89
|
+
underlay: string;
|
|
90
|
+
border: string;
|
|
91
|
+
dot: string;
|
|
92
|
+
badgeText: string;
|
|
93
|
+
}>;
|
|
94
|
+
/** Caller facing overrides. Every key defaults to a cpk-ui theme token. */
|
|
95
|
+
export type CalendarColors = Partial<CalendarPalette>;
|
|
96
|
+
/** Resolved geometry. Every value is a pure function of `size` and the font scale. */
|
|
97
|
+
export type CalendarMetrics = Readonly<{
|
|
98
|
+
cellSize: number;
|
|
99
|
+
rowGap: number;
|
|
100
|
+
rowHeight: number;
|
|
101
|
+
weekdayRowHeight: number;
|
|
102
|
+
headerHeight: number;
|
|
103
|
+
/** Edge of the round day pill. */
|
|
104
|
+
numberSize: number;
|
|
105
|
+
dayFontSize: number;
|
|
106
|
+
weekdayFontSize: number;
|
|
107
|
+
headerFontSize: number;
|
|
108
|
+
badgeFontSize: number;
|
|
109
|
+
dotSize: number;
|
|
110
|
+
dotRowHeight: number;
|
|
111
|
+
/** Constant top inset of the day pill, so decorations never move the number. */
|
|
112
|
+
pillOffset: number;
|
|
113
|
+
weekNumberWidth: number;
|
|
114
|
+
}>;
|
|
115
|
+
export type CalendarFormatters = {
|
|
116
|
+
/** Header title, e.g. "August 2026" or "2026년 8월". */
|
|
117
|
+
monthTitle: (date: Date, locale: string) => string;
|
|
118
|
+
/** Header title in week mode, e.g. "Aug 23 – 29, 2026". */
|
|
119
|
+
weekTitle: (start: Date, end: Date, locale: string) => string;
|
|
120
|
+
/** Weekday column header, e.g. "S" or "일". */
|
|
121
|
+
weekdayLabel: (date: Date, locale: string) => string;
|
|
122
|
+
/** Day number. Respects locale numbering systems. */
|
|
123
|
+
dayNumber: (date: Date, locale: string) => string;
|
|
124
|
+
/** Full accessibility label, e.g. "Monday, August 24, 2026". */
|
|
125
|
+
dayAccessibilityLabel: (date: Date, locale: string) => string;
|
|
126
|
+
};
|
|
127
|
+
export type CalendarLabels = {
|
|
128
|
+
previousMonth?: string;
|
|
129
|
+
nextMonth?: string;
|
|
130
|
+
previousWeek?: string;
|
|
131
|
+
nextWeek?: string;
|
|
132
|
+
/** Appended to the today cell accessibility label. */
|
|
133
|
+
today?: string;
|
|
134
|
+
selected?: string;
|
|
135
|
+
weekNumber?: string;
|
|
136
|
+
/** Announced by the header live region on page change. */
|
|
137
|
+
pageAnnouncement?: (pageTitle: string) => string;
|
|
138
|
+
};
|
|
139
|
+
export type CalendarStyles = {
|
|
140
|
+
container?: StyleProp<ViewStyle>;
|
|
141
|
+
header?: StyleProp<ViewStyle>;
|
|
142
|
+
headerTitle?: StyleProp<TextStyle>;
|
|
143
|
+
weekdayRow?: StyleProp<ViewStyle>;
|
|
144
|
+
weekdayLabel?: StyleProp<TextStyle>;
|
|
145
|
+
weekRow?: StyleProp<ViewStyle>;
|
|
146
|
+
dayCell?: StyleProp<ViewStyle>;
|
|
147
|
+
dayText?: StyleProp<TextStyle>;
|
|
148
|
+
selectedDayCell?: StyleProp<ViewStyle>;
|
|
149
|
+
selectedDayText?: StyleProp<TextStyle>;
|
|
150
|
+
todayDayCell?: StyleProp<ViewStyle>;
|
|
151
|
+
todayDayText?: StyleProp<TextStyle>;
|
|
152
|
+
outsideDayText?: StyleProp<TextStyle>;
|
|
153
|
+
disabledDayText?: StyleProp<TextStyle>;
|
|
154
|
+
dotRow?: StyleProp<ViewStyle>;
|
|
155
|
+
dot?: StyleProp<ViewStyle>;
|
|
156
|
+
badgeText?: StyleProp<TextStyle>;
|
|
157
|
+
};
|
|
158
|
+
export type CalendarRenderDay = (ctx: CalendarDayState & {
|
|
159
|
+
palette: CalendarPalette;
|
|
160
|
+
cellSize: number;
|
|
161
|
+
}) => ReactNode;
|
|
162
|
+
/**
|
|
163
|
+
* Everything invariant across all cells of a page.
|
|
164
|
+
* Created once per (theme, size, callbacks) change and compared by identity.
|
|
165
|
+
*/
|
|
166
|
+
export type CalendarChrome = Readonly<{
|
|
167
|
+
palette: CalendarPalette;
|
|
168
|
+
metrics: CalendarMetrics;
|
|
169
|
+
/** Pre built geometry style objects. Stable while `metrics` is stable. */
|
|
170
|
+
geometry: Readonly<{
|
|
171
|
+
row: ViewStyle;
|
|
172
|
+
cell: ViewStyle;
|
|
173
|
+
pill: ViewStyle;
|
|
174
|
+
dayText: TextStyle;
|
|
175
|
+
badgeText: TextStyle;
|
|
176
|
+
dot: ViewStyle;
|
|
177
|
+
dotRow: ViewStyle;
|
|
178
|
+
weekNumber: ViewStyle;
|
|
179
|
+
weekNumberText: TextStyle;
|
|
180
|
+
}>;
|
|
181
|
+
showDots: boolean;
|
|
182
|
+
maxDots: number;
|
|
183
|
+
showBadges: boolean;
|
|
184
|
+
maxFontSizeMultiplier: number;
|
|
185
|
+
fontScale: number;
|
|
186
|
+
labels: Required<CalendarLabels>;
|
|
187
|
+
styles: CalendarStyles;
|
|
188
|
+
renderDay?: CalendarRenderDay;
|
|
189
|
+
onPress: (key: CalendarDateKey) => void;
|
|
190
|
+
onLongPress?: (key: CalendarDateKey) => void;
|
|
191
|
+
onDisabledPress?: (key: CalendarDateKey) => void;
|
|
192
|
+
}>;
|
|
193
|
+
/** Resolves whether a day is blocked. Identity changes are tracked by `disabledVersion`. */
|
|
194
|
+
export type CalendarDisabledResolver = (day: CalendarDayModel, marker?: CalendarMarker) => boolean;
|
|
195
|
+
export type CalendarHeaderContext = {
|
|
196
|
+
title: string;
|
|
197
|
+
date: Date;
|
|
198
|
+
mode: CalendarViewMode;
|
|
199
|
+
canGoPrevious: boolean;
|
|
200
|
+
canGoNext: boolean;
|
|
201
|
+
goPrevious: () => void;
|
|
202
|
+
goNext: () => void;
|
|
203
|
+
};
|
|
204
|
+
export type CalendarProps = {
|
|
205
|
+
/** Controlled selection. `null` clears it. A `Date` is normalized to its local day key. */
|
|
206
|
+
value?: Date | CalendarDateKey | null;
|
|
207
|
+
/** Uncontrolled initial selection. Ignored when `value !== undefined`. */
|
|
208
|
+
defaultValue?: Date | CalendarDateKey | null;
|
|
209
|
+
/**
|
|
210
|
+
* User interaction only, never fired on mount.
|
|
211
|
+
* Prefer `key` for persistence, `date` is provided for interop and is local midnight.
|
|
212
|
+
*/
|
|
213
|
+
onChange?: (date: Date, key: CalendarDateKey, source: CalendarChangeSource) => void;
|
|
214
|
+
/** Controlled page anchor: `'yyyy-MM'`, `'yyyy-MM-dd'` or a `Date`. */
|
|
215
|
+
month?: Date | CalendarPageKey;
|
|
216
|
+
defaultMonth?: Date | CalendarPageKey;
|
|
217
|
+
onMonthChange?: (firstDayOfPage: Date, key: CalendarPageKey, source: CalendarChangeSource) => void;
|
|
218
|
+
mode?: CalendarViewMode;
|
|
219
|
+
defaultMode?: CalendarViewMode;
|
|
220
|
+
onModeChange?: (mode: CalendarViewMode) => void;
|
|
221
|
+
/**
|
|
222
|
+
* Optional shared value in `[0, 1]`: 0 = full month, 1 = single week.
|
|
223
|
+
* When supplied the caller owns the collapse animation and the component only reads it.
|
|
224
|
+
* When omitted the component animates internally on `mode` change.
|
|
225
|
+
*/
|
|
226
|
+
collapseProgress?: CalendarCollapseProgress;
|
|
227
|
+
/** BCP-47 tag. Defaults to the runtime locale. */
|
|
228
|
+
locale?: string;
|
|
229
|
+
/** Defaults to the CLDR first day of the resolved locale region. */
|
|
230
|
+
weekStart?: WeekStart;
|
|
231
|
+
/**
|
|
232
|
+
* Injectable "now". A key is used verbatim, which lets hosts supply a day
|
|
233
|
+
* resolved in a business timezone instead of the device timezone.
|
|
234
|
+
* Defaults to an internal clock that re-arms at local midnight.
|
|
235
|
+
*/
|
|
236
|
+
today?: Date | CalendarDateKey;
|
|
237
|
+
/** Always render 6 rows so the height never changes between months. */
|
|
238
|
+
fixedWeeks?: boolean;
|
|
239
|
+
/** O(1) lookup by `yyyy-MM-dd`. MUST be memoized by the caller. */
|
|
240
|
+
markers?: CalendarMarkerMap;
|
|
241
|
+
showDots?: boolean;
|
|
242
|
+
maxDotsPerDay?: number;
|
|
243
|
+
showWeekNumbers?: boolean;
|
|
244
|
+
showOutsideDays?: boolean;
|
|
245
|
+
minDate?: Date | CalendarDateKey;
|
|
246
|
+
maxDate?: Date | CalendarDateKey;
|
|
247
|
+
/** Normalized to a `Set` once per identity change. */
|
|
248
|
+
disabledDates?: ReadonlySet<CalendarDateKey> | readonly CalendarDateKey[];
|
|
249
|
+
/** Escape hatch, called only for the mounted window. Must be pure and cheap. */
|
|
250
|
+
isDateDisabled?: (date: Date, key: CalendarDateKey) => boolean;
|
|
251
|
+
showHeader?: boolean;
|
|
252
|
+
showNavigationButtons?: boolean;
|
|
253
|
+
showWeekdayRow?: boolean;
|
|
254
|
+
paging?: 'swipe' | 'none';
|
|
255
|
+
monthsToShow?: 1 | 2;
|
|
256
|
+
size?: CalendarSizeType;
|
|
257
|
+
/** Multiplier cap applied to every text node. */
|
|
258
|
+
maxFontSizeMultiplier?: number;
|
|
259
|
+
colors?: CalendarColors;
|
|
260
|
+
styles?: CalendarStyles;
|
|
261
|
+
style?: StyleProp<ViewStyle>;
|
|
262
|
+
formatters?: Partial<CalendarFormatters>;
|
|
263
|
+
/** Must be referentially stable. */
|
|
264
|
+
renderHeader?: (ctx: CalendarHeaderContext) => ReactNode;
|
|
265
|
+
renderWeekdayLabel?: (ctx: {
|
|
266
|
+
weekday: CalendarWeekday;
|
|
267
|
+
label: string;
|
|
268
|
+
}) => ReactNode;
|
|
269
|
+
/** Full control of a cell. Receives everything precomputed, must not format dates itself. */
|
|
270
|
+
renderDay?: CalendarRenderDay;
|
|
271
|
+
onDayLongPress?: (date: Date, key: CalendarDateKey) => void;
|
|
272
|
+
onDisabledDayPress?: (date: Date, key: CalendarDateKey) => void;
|
|
273
|
+
labels?: CalendarLabels;
|
|
274
|
+
accessibilityLabel?: string;
|
|
275
|
+
testID?: string;
|
|
276
|
+
};
|
|
277
|
+
export type CalendarRef = {
|
|
278
|
+
goToMonth: (month: Date | CalendarPageKey, animated?: boolean) => void;
|
|
279
|
+
goToToday: (animated?: boolean) => void;
|
|
280
|
+
next: (animated?: boolean) => void;
|
|
281
|
+
previous: (animated?: boolean) => void;
|
|
282
|
+
setMode: (mode: CalendarViewMode, animated?: boolean) => void;
|
|
283
|
+
/** Move the roving focus to a specific day (screen reader / external keyboard). */
|
|
284
|
+
focusDay: (key: CalendarDateKey) => void;
|
|
285
|
+
};
|
|
286
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/uis/Calendar/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AACrC,O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B,KAAK,SAAS,CAAC;IACzD,kBAAkB,CAAC,EAAE,CAAC,GAAG,EAAE;QACzB,OAAO,EAAE,eAAe,CAAC;QACzB,KAAK,EAAE,MAAM,CAAC;KACf,KAAK,SAAS,CAAC;IAChB,6FAA6F;IAC7F,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAE9B,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,eAAe,KAAK,IAAI,CAAC;IAC5D,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,eAAe,KAAK,IAAI,CAAC;IAEhE,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,SAAS,EAAE,CAAC,KAAK,EAAE,IAAI,GAAG,eAAe,EAAE,QAAQ,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACvE,SAAS,EAAE,CAAC,QAAQ,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,IAAI,EAAE,CAAC,QAAQ,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACnC,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,OAAO,EAAE,CAAC,IAAI,EAAE,gBAAgB,EAAE,QAAQ,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IAC9D,mFAAmF;IACnF,QAAQ,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,IAAI,CAAC;CAC1C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { CalendarDateKey, CalendarDisabledResolver, CalendarViewMode, WeekStart } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Controlled first: the prop wins whenever it is not `undefined`, and the internal
|
|
4
|
+
* state is only used as the uncontrolled fallback.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useControllable<T>(controlled: T | undefined, initial: T): [T, (next: T) => void];
|
|
7
|
+
/**
|
|
8
|
+
* "Today" as a local noon date that re-arms itself at local midnight and also
|
|
9
|
+
* refreshes when the app returns to the foreground, so a device that slept through
|
|
10
|
+
* midnight still moves the highlight.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useToday(explicit?: Date | CalendarDateKey): Date;
|
|
13
|
+
/** Every spring and timing in the component collapses to duration 0 when this is on. */
|
|
14
|
+
export declare function useReduceMotion(): boolean;
|
|
15
|
+
export type CalendarDisabledState = {
|
|
16
|
+
resolver: CalendarDisabledResolver;
|
|
17
|
+
version: number;
|
|
18
|
+
minKey: CalendarDateKey | null;
|
|
19
|
+
maxKey: CalendarDateKey | null;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Precedence, first match wins:
|
|
23
|
+
* `marker.disabled` → `disabledDates` → `minDate`/`maxDate` → `isDateDisabled`.
|
|
24
|
+
* Range checks are lexicographic string compares, which are allocation free and
|
|
25
|
+
* timezone proof because `yyyy-MM-dd` sorts chronologically.
|
|
26
|
+
*/
|
|
27
|
+
export declare function useDisabledState(args: {
|
|
28
|
+
minDate?: Date | CalendarDateKey;
|
|
29
|
+
maxDate?: Date | CalendarDateKey;
|
|
30
|
+
disabledDates?: ReadonlySet<CalendarDateKey> | readonly CalendarDateKey[];
|
|
31
|
+
isDateDisabled?: (date: Date, key: CalendarDateKey) => boolean;
|
|
32
|
+
}): CalendarDisabledState;
|
|
33
|
+
export type CalendarKeyboardAction = {
|
|
34
|
+
type: 'move';
|
|
35
|
+
key: CalendarDateKey;
|
|
36
|
+
} | {
|
|
37
|
+
type: 'select';
|
|
38
|
+
} | null;
|
|
39
|
+
/**
|
|
40
|
+
* One handler covers the whole grid. Moving past a page edge simply targets a day
|
|
41
|
+
* outside the mounted page, and the caller pages to it while keeping focus.
|
|
42
|
+
*/
|
|
43
|
+
export declare function resolveKeyboardAction(args: {
|
|
44
|
+
key: string;
|
|
45
|
+
shiftKey: boolean;
|
|
46
|
+
focusedKey: CalendarDateKey;
|
|
47
|
+
weekStart: WeekStart;
|
|
48
|
+
isRTL: boolean;
|
|
49
|
+
mode: CalendarViewMode;
|
|
50
|
+
}): CalendarKeyboardAction;
|
|
51
|
+
/**
|
|
52
|
+
* Keeps the previous object for as long as a SHALLOW value compare says nothing
|
|
53
|
+
* changed.
|
|
54
|
+
*
|
|
55
|
+
* `labels`, `styles` and `formatters` are written as inline object literals at
|
|
56
|
+
* almost every call site — `labels={{today: t('calendar.today')}}` is the only
|
|
57
|
+
* way to localize the component — and a fresh identity there invalidates
|
|
58
|
+
* `chrome`, which re-renders all 42 day cells on every parent render. `palette`
|
|
59
|
+
* already compared by value for exactly this reason; these three did not.
|
|
60
|
+
*
|
|
61
|
+
* One level deep only. A caller writing `styles={{dayText: {fontWeight: '600'}}}`
|
|
62
|
+
* fully inline still allocates a new nested object every render and still pays;
|
|
63
|
+
* hoist the inner style object or wrap it in `useMemo`.
|
|
64
|
+
*/
|
|
65
|
+
export declare function useShallowStable<T extends object | undefined>(value: T): T;
|
|
66
|
+
//# sourceMappingURL=useCalendarState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCalendarState.d.ts","sourceRoot":"","sources":["../../../../src/components/uis/Calendar/useCalendarState.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,eAAe,EACf,wBAAwB,EACxB,gBAAgB,EAChB,SAAS,EACV,MAAM,SAAS,CAAC;AAYjB;;;GAGG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAC/B,UAAU,EAAE,CAAC,GAAG,SAAS,EACzB,OAAO,EAAE,CAAC,GACT,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC,CAcxB;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,CAAC,EAAE,IAAI,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