@super-calendar/native 2.3.2 → 2.4.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 +21 -0
- package/dist/{DefaultMonthEvent-BW6qy50X.d.ts → DefaultMonthEvent-BSvuJUFk.d.ts} +174 -173
- package/dist/{DefaultMonthEvent-BbCMc60z.d.mts → DefaultMonthEvent-zDj9dHEv.d.mts} +174 -173
- package/dist/{MonthList-CFXm7BK_.js → MonthList-Aczb2RSY.js} +219 -108
- package/dist/{MonthList-BidXJMfm.mjs → MonthList-zPLklHAY.mjs} +203 -110
- package/dist/index.d.mts +221 -263
- package/dist/index.d.ts +221 -263
- package/dist/index.js +549 -209
- package/dist/index.mjs +542 -214
- package/dist/picker.d.mts +1 -1
- package/dist/picker.d.ts +1 -1
- package/dist/picker.js +1 -1
- package/dist/picker.mjs +1 -1
- package/package.json +2 -2
- package/src/components/Agenda.tsx +52 -11
- package/src/components/AllDayLane.tsx +22 -8
- package/src/components/Calendar.tsx +84 -5
- package/src/components/DefaultEvent.tsx +4 -0
- package/src/components/MonthList.tsx +52 -10
- package/src/components/MonthPager.tsx +45 -6
- package/src/components/MonthView.tsx +133 -74
- package/src/components/ResourceTimeline.tsx +276 -35
- package/src/components/TimeGrid.tsx +282 -162
- package/src/index.tsx +12 -4
- package/src/types.ts +16 -1
- package/src/utils/slots.ts +83 -0
package/src/index.tsx
CHANGED
|
@@ -20,14 +20,16 @@
|
|
|
20
20
|
*
|
|
21
21
|
* @module
|
|
22
22
|
*/
|
|
23
|
-
export { Calendar, type CalendarProps } from "./components/Calendar";
|
|
24
|
-
export { Agenda, type AgendaProps } from "./components/Agenda";
|
|
25
|
-
export { MonthView, type MonthViewProps } from "./components/MonthView";
|
|
23
|
+
export { Calendar, type CalendarProps, type CalendarSlot } from "./components/Calendar";
|
|
24
|
+
export { Agenda, type AgendaProps, type AgendaSlot } from "./components/Agenda";
|
|
25
|
+
export { MonthView, type MonthViewProps, type MonthViewSlot } from "./components/MonthView";
|
|
26
|
+
export { type ResolvedSlot, type SlotDefault, type SlotStyleProps } from "./utils/slots";
|
|
26
27
|
export { MonthPager, type MonthPagerProps } from "./components/MonthPager";
|
|
27
|
-
export { MonthList, type MonthListProps } from "./components/MonthList";
|
|
28
|
+
export { MonthList, type MonthListProps, type MonthListSlot } from "./components/MonthList";
|
|
28
29
|
export {
|
|
29
30
|
TimeGrid,
|
|
30
31
|
type TimeGridProps,
|
|
32
|
+
type TimeGridSlot,
|
|
31
33
|
type EventDragHandler,
|
|
32
34
|
type EventDragStartHandler,
|
|
33
35
|
type HourRenderer,
|
|
@@ -89,6 +91,12 @@ export {
|
|
|
89
91
|
weekdayFormatToken,
|
|
90
92
|
} from "@super-calendar/core";
|
|
91
93
|
export { expandRecurringEvents } from "@super-calendar/core";
|
|
94
|
+
export {
|
|
95
|
+
type ICalEvent,
|
|
96
|
+
parseICalendar,
|
|
97
|
+
toICalendar,
|
|
98
|
+
type ToICalendarOptions,
|
|
99
|
+
} from "@super-calendar/core";
|
|
92
100
|
export { eventsInTimeZone, toZonedTime } from "@super-calendar/core";
|
|
93
101
|
export {
|
|
94
102
|
buildMonthWeeks,
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { ComponentType } from "react";
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
AccessibilityActionEvent,
|
|
4
|
+
AccessibilityActionInfo,
|
|
5
|
+
StyleProp,
|
|
6
|
+
ViewStyle,
|
|
7
|
+
} from "react-native";
|
|
3
8
|
import type { SharedValue } from "react-native-reanimated";
|
|
4
9
|
import type { CalendarEvent, CalendarMode } from "@super-calendar/core";
|
|
5
10
|
|
|
@@ -62,6 +67,16 @@ export type RenderEventArgs<T = unknown> = {
|
|
|
62
67
|
* their default label; `undefined` falls back to that default.
|
|
63
68
|
*/
|
|
64
69
|
accessibilityLabel?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Screen-reader actions the built-in renderer places on the event, so
|
|
72
|
+
* VoiceOver/TalkBack users can act on it without a gesture. On a draggable
|
|
73
|
+
* time-grid event these are move / resize steps; wired to the same commit path
|
|
74
|
+
* as dragging. A custom renderer should spread these (plus `onAccessibilityAction`)
|
|
75
|
+
* onto its pressable to keep the event operable by assistive tech.
|
|
76
|
+
*/
|
|
77
|
+
accessibilityActions?: ReadonlyArray<AccessibilityActionInfo>;
|
|
78
|
+
/** Handles an `accessibilityActions` invocation; pair it with `accessibilityActions`. */
|
|
79
|
+
onAccessibilityAction?: (event: AccessibilityActionEvent) => void;
|
|
65
80
|
onPress: () => void;
|
|
66
81
|
/** Wired when the consumer passes `onLongPressEvent`; otherwise undefined. */
|
|
67
82
|
onLongPress?: () => void;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// Per-slot styling for the native renderer.
|
|
2
|
+
//
|
|
3
|
+
// Every component styles itself from the theme, so zero-config consumers get a
|
|
4
|
+
// full look with no setup. This module mirrors the dom renderer's slot contract
|
|
5
|
+
// for consumers who style with Tailwind classes instead: each styleable element
|
|
6
|
+
// is a named "slot" that accepts a `className` (resolved by a Tailwind runtime
|
|
7
|
+
// such as uniwind or NativeWind, which compile the library's source through the
|
|
8
|
+
// consumer's bundler) and/or a style override.
|
|
9
|
+
//
|
|
10
|
+
// The contract, shared with the dom renderer: a slot's *structural* styles (the
|
|
11
|
+
// layout the component needs to not fall apart) always apply. Its *themed*
|
|
12
|
+
// styles (colours, typography, spacing) apply only when no class is supplied
|
|
13
|
+
// for that slot; supply a class and you own those. A per-slot `styles` override
|
|
14
|
+
// always merges last. Without a Tailwind runtime, `className` is an unknown
|
|
15
|
+
// prop React Native silently ignores, so the props are safe to pass everywhere.
|
|
16
|
+
|
|
17
|
+
import { createContext, createElement, type ReactNode, useContext, useMemo } from "react";
|
|
18
|
+
import type { StyleProp, TextStyle } from "react-native";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Per-slot styling overrides. Give a slot a Tailwind class (uniwind/NativeWind)
|
|
22
|
+
* and/or a style override; missing slots keep the built-in look.
|
|
23
|
+
*/
|
|
24
|
+
export interface SlotStyleProps<Slot extends string> {
|
|
25
|
+
/**
|
|
26
|
+
* Class names per slot. Supplying a class for a slot drops the built-in
|
|
27
|
+
* *themed* styles for that slot so the class fully controls its look; the
|
|
28
|
+
* *structural* styles the layout depends on are kept. Requires a Tailwind
|
|
29
|
+
* runtime (uniwind, NativeWind) in the consuming app.
|
|
30
|
+
*/
|
|
31
|
+
classNames?: Partial<Record<Slot, string>>;
|
|
32
|
+
/** Style overrides per slot, merged last (win over defaults and classes). */
|
|
33
|
+
styles?: Partial<Record<Slot, StyleProp<TextStyle>>>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** A slot's built-in styling, split so classes can replace the look but not the layout. */
|
|
37
|
+
export interface SlotDefault {
|
|
38
|
+
/** Structural styles kept even when a class is supplied. */
|
|
39
|
+
base?: StyleProp<TextStyle>;
|
|
40
|
+
/** Themed styles (colour, type, spacing) dropped when a class is supplied. */
|
|
41
|
+
themed?: StyleProp<TextStyle>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** The props a resolved slot spreads onto an element. */
|
|
45
|
+
export interface ResolvedSlot {
|
|
46
|
+
style: StyleProp<TextStyle>;
|
|
47
|
+
className?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Build a slot resolver for one render. `slot(name, defaults)` returns the
|
|
52
|
+
* props to spread on that element: the resolved `style` array and, when the
|
|
53
|
+
* consumer supplied one, a `className` for the Tailwind runtime to pick up.
|
|
54
|
+
*/
|
|
55
|
+
export function createSlots<Slot extends string>({ classNames, styles }: SlotStyleProps<Slot>) {
|
|
56
|
+
return (name: Slot, defaults?: SlotDefault): ResolvedSlot => {
|
|
57
|
+
const slotClass = classNames?.[name];
|
|
58
|
+
return {
|
|
59
|
+
style: [defaults?.base, slotClass ? undefined : defaults?.themed, styles?.[name]],
|
|
60
|
+
...(slotClass ? { className: slotClass } : null),
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Deeply componentized views (the time grid) distribute their slot maps through
|
|
66
|
+
// context, like the theme, instead of threading two props through every layer.
|
|
67
|
+
const SlotStylesContext = createContext<SlotStyleProps<string>>({});
|
|
68
|
+
|
|
69
|
+
/** Provide a component's `classNames`/`styles` maps to its internal slots. */
|
|
70
|
+
export function SlotStylesProvider({
|
|
71
|
+
classNames,
|
|
72
|
+
styles,
|
|
73
|
+
children,
|
|
74
|
+
}: SlotStyleProps<string> & { children: ReactNode }) {
|
|
75
|
+
const value = useMemo(() => ({ classNames, styles }), [classNames, styles]);
|
|
76
|
+
return createElement(SlotStylesContext.Provider, { value }, children);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Resolve slots against the nearest {@link SlotStylesProvider}'s maps. */
|
|
80
|
+
export function useSlots<Slot extends string>() {
|
|
81
|
+
const maps = useContext(SlotStylesContext) as SlotStyleProps<Slot>;
|
|
82
|
+
return useMemo(() => createSlots<Slot>(maps), [maps]);
|
|
83
|
+
}
|