@lafarmer28/densitycalendarnative 0.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.
Files changed (90) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +37 -0
  3. package/lib/module/components/density-calendar/context/ks-density-calendar-context.js +5 -0
  4. package/lib/module/components/density-calendar/context/ks-density-calendar-context.js.map +1 -0
  5. package/lib/module/components/density-calendar/context/ks-density-calendar-provider.js +68 -0
  6. package/lib/module/components/density-calendar/context/ks-density-calendar-provider.js.map +1 -0
  7. package/lib/module/components/density-calendar/context/use-ks-density-calendar-context.js +12 -0
  8. package/lib/module/components/density-calendar/context/use-ks-density-calendar-context.js.map +1 -0
  9. package/lib/module/components/density-calendar/day-view/day-navigation.js +172 -0
  10. package/lib/module/components/density-calendar/day-view/day-navigation.js.map +1 -0
  11. package/lib/module/components/density-calendar/day-view/ks-density-calendar-day-view.js +183 -0
  12. package/lib/module/components/density-calendar/day-view/ks-density-calendar-day-view.js.map +1 -0
  13. package/lib/module/components/density-calendar/ks-density-calendar-root.js +201 -0
  14. package/lib/module/components/density-calendar/ks-density-calendar-root.js.map +1 -0
  15. package/lib/module/components/density-calendar/ks-density-calendar.js +24 -0
  16. package/lib/module/components/density-calendar/ks-density-calendar.js.map +1 -0
  17. package/lib/module/components/density-calendar/ks-error-popup/ks-error-tooltip.js +74 -0
  18. package/lib/module/components/density-calendar/ks-error-popup/ks-error-tooltip.js.map +1 -0
  19. package/lib/module/components/density-calendar/ks-slider/ks-slider.js +174 -0
  20. package/lib/module/components/density-calendar/ks-slider/ks-slider.js.map +1 -0
  21. package/lib/module/components/density-calendar/ks-toggler/ks-toggler.js +72 -0
  22. package/lib/module/components/density-calendar/ks-toggler/ks-toggler.js.map +1 -0
  23. package/lib/module/components/density-calendar/month-view/days-of-week.js +51 -0
  24. package/lib/module/components/density-calendar/month-view/days-of-week.js.map +1 -0
  25. package/lib/module/components/density-calendar/month-view/ks-density-calendar-month-view.js +212 -0
  26. package/lib/module/components/density-calendar/month-view/ks-density-calendar-month-view.js.map +1 -0
  27. package/lib/module/components/density-calendar/month-view/top-navigation.js +118 -0
  28. package/lib/module/components/density-calendar/month-view/top-navigation.js.map +1 -0
  29. package/lib/module/components/density-calendar/utility-functions.js +50 -0
  30. package/lib/module/components/density-calendar/utility-functions.js.map +1 -0
  31. package/lib/module/components/density-calendar/week-view/ks-density-calendar-week-view.js +152 -0
  32. package/lib/module/components/density-calendar/week-view/ks-density-calendar-week-view.js.map +1 -0
  33. package/lib/module/components/density-calendar/week-view/top.js +53 -0
  34. package/lib/module/components/density-calendar/week-view/top.js.map +1 -0
  35. package/lib/module/index.js +4 -0
  36. package/lib/module/index.js.map +1 -0
  37. package/lib/module/package.json +1 -0
  38. package/lib/typescript/package.json +1 -0
  39. package/lib/typescript/src/components/density-calendar/context/ks-density-calendar-context.d.ts +17 -0
  40. package/lib/typescript/src/components/density-calendar/context/ks-density-calendar-context.d.ts.map +1 -0
  41. package/lib/typescript/src/components/density-calendar/context/ks-density-calendar-provider.d.ts +19 -0
  42. package/lib/typescript/src/components/density-calendar/context/ks-density-calendar-provider.d.ts.map +1 -0
  43. package/lib/typescript/src/components/density-calendar/context/use-ks-density-calendar-context.d.ts +2 -0
  44. package/lib/typescript/src/components/density-calendar/context/use-ks-density-calendar-context.d.ts.map +1 -0
  45. package/lib/typescript/src/components/density-calendar/day-view/day-navigation.d.ts +17 -0
  46. package/lib/typescript/src/components/density-calendar/day-view/day-navigation.d.ts.map +1 -0
  47. package/lib/typescript/src/components/density-calendar/day-view/ks-density-calendar-day-view.d.ts +21 -0
  48. package/lib/typescript/src/components/density-calendar/day-view/ks-density-calendar-day-view.d.ts.map +1 -0
  49. package/lib/typescript/src/components/density-calendar/ks-density-calendar-root.d.ts +14 -0
  50. package/lib/typescript/src/components/density-calendar/ks-density-calendar-root.d.ts.map +1 -0
  51. package/lib/typescript/src/components/density-calendar/ks-density-calendar.d.ts +43 -0
  52. package/lib/typescript/src/components/density-calendar/ks-density-calendar.d.ts.map +1 -0
  53. package/lib/typescript/src/components/density-calendar/ks-error-popup/ks-error-tooltip.d.ts +8 -0
  54. package/lib/typescript/src/components/density-calendar/ks-error-popup/ks-error-tooltip.d.ts.map +1 -0
  55. package/lib/typescript/src/components/density-calendar/ks-slider/ks-slider.d.ts +8 -0
  56. package/lib/typescript/src/components/density-calendar/ks-slider/ks-slider.d.ts.map +1 -0
  57. package/lib/typescript/src/components/density-calendar/ks-toggler/ks-toggler.d.ts +3 -0
  58. package/lib/typescript/src/components/density-calendar/ks-toggler/ks-toggler.d.ts.map +1 -0
  59. package/lib/typescript/src/components/density-calendar/month-view/days-of-week.d.ts +3 -0
  60. package/lib/typescript/src/components/density-calendar/month-view/days-of-week.d.ts.map +1 -0
  61. package/lib/typescript/src/components/density-calendar/month-view/ks-density-calendar-month-view.d.ts +17 -0
  62. package/lib/typescript/src/components/density-calendar/month-view/ks-density-calendar-month-view.d.ts.map +1 -0
  63. package/lib/typescript/src/components/density-calendar/month-view/top-navigation.d.ts +11 -0
  64. package/lib/typescript/src/components/density-calendar/month-view/top-navigation.d.ts.map +1 -0
  65. package/lib/typescript/src/components/density-calendar/utility-functions.d.ts +9 -0
  66. package/lib/typescript/src/components/density-calendar/utility-functions.d.ts.map +1 -0
  67. package/lib/typescript/src/components/density-calendar/week-view/ks-density-calendar-week-view.d.ts +12 -0
  68. package/lib/typescript/src/components/density-calendar/week-view/ks-density-calendar-week-view.d.ts.map +1 -0
  69. package/lib/typescript/src/components/density-calendar/week-view/top.d.ts +6 -0
  70. package/lib/typescript/src/components/density-calendar/week-view/top.d.ts.map +1 -0
  71. package/lib/typescript/src/index.d.ts +2 -0
  72. package/lib/typescript/src/index.d.ts.map +1 -0
  73. package/package.json +166 -0
  74. package/src/components/density-calendar/context/ks-density-calendar-context.tsx +23 -0
  75. package/src/components/density-calendar/context/ks-density-calendar-provider.tsx +96 -0
  76. package/src/components/density-calendar/context/use-ks-density-calendar-context.tsx +15 -0
  77. package/src/components/density-calendar/day-view/day-navigation.tsx +199 -0
  78. package/src/components/density-calendar/day-view/ks-density-calendar-day-view.tsx +245 -0
  79. package/src/components/density-calendar/ks-density-calendar-root.tsx +215 -0
  80. package/src/components/density-calendar/ks-density-calendar.tsx +74 -0
  81. package/src/components/density-calendar/ks-error-popup/ks-error-tooltip.tsx +71 -0
  82. package/src/components/density-calendar/ks-slider/ks-slider.tsx +185 -0
  83. package/src/components/density-calendar/ks-toggler/ks-toggler.tsx +69 -0
  84. package/src/components/density-calendar/month-view/days-of-week.tsx +47 -0
  85. package/src/components/density-calendar/month-view/ks-density-calendar-month-view.tsx +289 -0
  86. package/src/components/density-calendar/month-view/top-navigation.tsx +137 -0
  87. package/src/components/density-calendar/utility-functions.ts +67 -0
  88. package/src/components/density-calendar/week-view/ks-density-calendar-week-view.tsx +189 -0
  89. package/src/components/density-calendar/week-view/top.tsx +54 -0
  90. package/src/index.tsx +1 -0
@@ -0,0 +1,74 @@
1
+ import KSDensityCalendarRoot from './ks-density-calendar-root';
2
+ import { KSDensityCalendarProvider } from './context/ks-density-calendar-provider';
3
+
4
+ export type KSDensityCalendarEventType = {
5
+ name: string;
6
+ start: Date;
7
+ end: Date;
8
+ };
9
+
10
+ export type KSOptionalProps = {
11
+ handleErrorPopup?: () => void;
12
+ handleCloseErrorPopup?: () => void;
13
+ };
14
+
15
+ export type ThemeKeyProps = {
16
+ themeKeys: {
17
+ togglerHandle?: string;
18
+ primaryColor: string;
19
+ primaryColorPnt6: string;
20
+ secondaryColor: string;
21
+ secondaryColorPnt1: string;
22
+ secondaryColorPnt15: string;
23
+ secondaryColorPnt2: string;
24
+ secondaryColorPnt3: string;
25
+ secondaryColorPnt4: string;
26
+ secondaryColorPnt5: string;
27
+ secondaryColorPnt6: string;
28
+ secondaryColorPnt8: string;
29
+ backgroundColor: string;
30
+ glowFilter: string;
31
+ checkboxBGC: string;
32
+ checkboxAfterColor: string;
33
+ backgroundImage: string;
34
+ trackBoxShadow: string;
35
+ carouselColor1: string;
36
+ carouselGradient1: string;
37
+ carouselGradient2: string;
38
+ buttonGradient: string;
39
+ listBGC: string;
40
+ };
41
+ };
42
+
43
+ export type KSDensityCalendarProps = {
44
+ displayDate: Date;
45
+ initialDisplayMode: string;
46
+ multScheduleData: KSDensityCalendarEventType[];
47
+ } & KSOptionalProps &
48
+ ThemeKeyProps;
49
+
50
+ export const KSDensityCalendar = ({
51
+ displayDate,
52
+ initialDisplayMode,
53
+ multScheduleData,
54
+ themeKeys,
55
+ }: KSDensityCalendarProps) => {
56
+ if (
57
+ initialDisplayMode !== 'Month' &&
58
+ initialDisplayMode !== 'Week' &&
59
+ initialDisplayMode !== 'Day'
60
+ ) {
61
+ return initialDisplayMode === 'Month';
62
+ }
63
+
64
+ return (
65
+ <KSDensityCalendarProvider>
66
+ <KSDensityCalendarRoot
67
+ displayDate={displayDate}
68
+ initialDisplayMode={initialDisplayMode}
69
+ multScheduleData={multScheduleData}
70
+ themeKeys={themeKeys}
71
+ />
72
+ </KSDensityCalendarProvider>
73
+ );
74
+ };
@@ -0,0 +1,71 @@
1
+ import { useState, type ReactNode } from 'react';
2
+ import { StyleSheet, View, Text, Pressable, Modal } from 'react-native';
3
+
4
+ interface Props {
5
+ children: ReactNode;
6
+ tooltip?: string;
7
+ }
8
+
9
+ const KSErrorTooltip = ({ children, tooltip }: Props) => {
10
+ const [visible, setVisible] = useState(false);
11
+
12
+ if (!tooltip) return <>{children}</>;
13
+
14
+ return (
15
+ <View style={styles.container}>
16
+ <Pressable
17
+ onPress={() => setVisible(!visible)}
18
+ onLongPress={() => setVisible(true)}
19
+ style={({ pressed }) => [{ opacity: pressed ? 0.7 : 1 }]}
20
+ >
21
+ {children}
22
+ </Pressable>
23
+
24
+ {visible && (
25
+ <Modal
26
+ transparent={true}
27
+ visible={visible}
28
+ animationType="fade"
29
+ onRequestClose={() => setVisible(false)}
30
+ >
31
+ <Pressable
32
+ style={styles.modalOverlay}
33
+ onPress={() => setVisible(false)}
34
+ >
35
+ <View style={styles.tooltipBox}>
36
+ <Text style={styles.tooltipText}>{tooltip}</Text>
37
+ </View>
38
+ </Pressable>
39
+ </Modal>
40
+ )}
41
+ </View>
42
+ );
43
+ };
44
+
45
+ const styles = StyleSheet.create({
46
+ container: {
47
+ alignSelf: 'flex-start',
48
+ },
49
+ modalOverlay: {
50
+ flex: 1,
51
+ backgroundColor: 'transparent',
52
+ justifyContent: 'center',
53
+ alignItems: 'center',
54
+ },
55
+ tooltipBox: {
56
+ backgroundColor: '#1e3a8a', // blue-900
57
+ padding: 8,
58
+ borderRadius: 4,
59
+ shadowColor: '#000',
60
+ shadowOffset: { width: 0, height: 2 },
61
+ shadowOpacity: 0.25,
62
+ shadowRadius: 3.84,
63
+ elevation: 5,
64
+ },
65
+ tooltipText: {
66
+ color: '#ffffff',
67
+ fontSize: 14,
68
+ },
69
+ });
70
+
71
+ export default KSErrorTooltip;
@@ -0,0 +1,185 @@
1
+ import { useRef, useCallback } from 'react';
2
+ import { StyleSheet, View, Text, PanResponder } from 'react-native';
3
+ import { useKSDensityCalendar } from '../context/use-ks-density-calendar-context';
4
+ import type { ThemeKeyProps } from '../ks-density-calendar';
5
+
6
+ type KSSliderProps = {
7
+ calendarDisplay: string;
8
+ themeKeys: ThemeKeyProps['themeKeys'];
9
+ };
10
+
11
+ const KSSlider = ({ themeKeys }: KSSliderProps) => {
12
+ const { state, dispatch, min, max } = useKSDensityCalendar();
13
+ const { minVal, maxVal } = state;
14
+
15
+ const sliderWidthRef = useRef(0);
16
+ const pageXRef = useRef(0);
17
+
18
+ const calculateValue = useCallback(
19
+ (touchX: number) => {
20
+ // Subtract the starting X position of the slider from the touch position
21
+ const relativeX = touchX - pageXRef.current;
22
+ const percentage = Math.max(
23
+ 0,
24
+ Math.min(1, relativeX / sliderWidthRef.current)
25
+ );
26
+ return Math.round(percentage * (max - min) + min);
27
+ },
28
+ [min, max]
29
+ );
30
+
31
+ const minPanResponder = useRef(
32
+ PanResponder.create({
33
+ onStartShouldSetPanResponder: () => true,
34
+ onPanResponderMove: (evt) => {
35
+ const newValue = calculateValue(evt.nativeEvent.pageX);
36
+ if (newValue <= maxVal) {
37
+ dispatch({ type: 'SET_VALUE', field: 'minVal', value: newValue });
38
+ dispatch({
39
+ type: 'SET_VALUE',
40
+ field: 'lastFocusedInput',
41
+ value: 'min',
42
+ });
43
+ }
44
+ },
45
+ })
46
+ ).current;
47
+
48
+ const maxPanResponder = useRef(
49
+ PanResponder.create({
50
+ onStartShouldSetPanResponder: () => true,
51
+ onPanResponderMove: (evt) => {
52
+ const newValue = calculateValue(evt.nativeEvent.pageX);
53
+ if (newValue >= minVal) {
54
+ dispatch({ type: 'SET_VALUE', field: 'maxVal', value: newValue });
55
+ dispatch({
56
+ type: 'SET_VALUE',
57
+ field: 'lastFocusedInput',
58
+ value: 'max',
59
+ });
60
+ }
61
+ },
62
+ })
63
+ ).current;
64
+
65
+ const minPos = (minVal / max) * 100;
66
+ const maxPos = (maxVal / max) * 100;
67
+
68
+ return (
69
+ <View style={styles.sliderContainer}>
70
+ <View style={styles.leftValue}>
71
+ <Text style={styles.valueText}>{minVal}</Text>
72
+ </View>
73
+
74
+ <View
75
+ style={styles.middle}
76
+ onLayout={(e) => {
77
+ const { width, x } = e.nativeEvent.layout;
78
+ sliderWidthRef.current = width;
79
+ // Note: In nested views, you might need .measure() for absolute pageX
80
+ // but for basic layouts, layout.x or a fixed container padding works.
81
+ pageXRef.current = x + 10; // 10 is the sliderContainer padding
82
+ }}
83
+ >
84
+ <View
85
+ style={[
86
+ styles.sliderTrack,
87
+ { backgroundColor: themeKeys.secondaryColorPnt15 },
88
+ ]}
89
+ />
90
+
91
+ <View
92
+ style={[
93
+ styles.sliderRange,
94
+ {
95
+ backgroundColor: themeKeys.secondaryColor,
96
+ left: `${minPos}%`,
97
+ width: `${maxPos - minPos}%`,
98
+ },
99
+ ]}
100
+ />
101
+
102
+ <View
103
+ {...minPanResponder.panHandlers}
104
+ style={[
105
+ styles.thumb,
106
+ {
107
+ left: `${minPos}%`,
108
+ backgroundColor: themeKeys.secondaryColor,
109
+ borderColor: '#fff',
110
+ },
111
+ ]}
112
+ />
113
+
114
+ <View
115
+ {...maxPanResponder.panHandlers}
116
+ style={[
117
+ styles.thumb,
118
+ {
119
+ left: `${maxPos}%`,
120
+ backgroundColor: themeKeys.secondaryColor,
121
+ borderColor: '#fff',
122
+ },
123
+ ]}
124
+ />
125
+ </View>
126
+
127
+ <View style={styles.rightValue}>
128
+ <Text style={styles.valueText}>{maxVal}</Text>
129
+ </View>
130
+ </View>
131
+ );
132
+ };
133
+
134
+ const styles = StyleSheet.create({
135
+ sliderContainer: {
136
+ flexDirection: 'row',
137
+ alignItems: 'center',
138
+ width: '100%',
139
+ height: 50,
140
+ paddingHorizontal: 10,
141
+ },
142
+ leftValue: {
143
+ width: '10%',
144
+ alignItems: 'flex-start',
145
+ },
146
+ middle: {
147
+ width: '80%',
148
+ height: 40,
149
+ justifyContent: 'center',
150
+ },
151
+ rightValue: {
152
+ width: '10%',
153
+ alignItems: 'flex-end',
154
+ },
155
+ valueText: {
156
+ fontSize: 14,
157
+ fontWeight: 'bold',
158
+ },
159
+ sliderTrack: {
160
+ height: 5,
161
+ width: '100%',
162
+ borderRadius: 3,
163
+ position: 'absolute',
164
+ },
165
+ sliderRange: {
166
+ height: 5,
167
+ borderRadius: 3,
168
+ position: 'absolute',
169
+ },
170
+ thumb: {
171
+ width: 24,
172
+ height: 24,
173
+ borderRadius: 12,
174
+ borderWidth: 2,
175
+ position: 'absolute',
176
+ marginLeft: -12,
177
+ elevation: 3,
178
+ shadowColor: '#000',
179
+ shadowOffset: { width: 0, height: 2 },
180
+ shadowOpacity: 0.2,
181
+ shadowRadius: 2,
182
+ },
183
+ });
184
+
185
+ export default KSSlider;
@@ -0,0 +1,69 @@
1
+ import { useEffect, useRef } from 'react';
2
+ import { StyleSheet, Pressable, Animated } from 'react-native';
3
+ import { useKSDensityCalendar } from '../context/use-ks-density-calendar-context';
4
+
5
+ const KSToggler = () => {
6
+ const { state, handleToggleSlider } = useKSDensityCalendar();
7
+ const { toggleKSSlider } = state;
8
+
9
+ const animatedValue = useRef(
10
+ new Animated.Value(toggleKSSlider ? 1 : 0)
11
+ ).current;
12
+
13
+ useEffect(() => {
14
+ Animated.spring(animatedValue, {
15
+ toValue: toggleKSSlider ? 1 : 0,
16
+ stiffness: 700,
17
+ damping: 30,
18
+ useNativeDriver: false,
19
+ }).start();
20
+ }, [toggleKSSlider]);
21
+
22
+ const translateX = animatedValue.interpolate({
23
+ inputRange: [0, 1],
24
+ outputRange: [0, 30],
25
+ });
26
+
27
+ const backgroundColor = animatedValue.interpolate({
28
+ inputRange: [0, 1],
29
+ outputRange: ['#ccc', '#007AFF'],
30
+ });
31
+
32
+ return (
33
+ <Pressable onPress={handleToggleSlider}>
34
+ <Animated.View style={[styles.switch, { backgroundColor }]}>
35
+ <Animated.View
36
+ style={[
37
+ styles.handle,
38
+ {
39
+ transform: [{ translateX }],
40
+ backgroundColor: '#fff',
41
+ },
42
+ ]}
43
+ />
44
+ </Animated.View>
45
+ </Pressable>
46
+ );
47
+ };
48
+
49
+ const styles = StyleSheet.create({
50
+ switch: {
51
+ width: 60,
52
+ height: 30,
53
+ borderRadius: 15,
54
+ padding: 5,
55
+ justifyContent: 'center',
56
+ },
57
+ handle: {
58
+ height: 20,
59
+ width: 20,
60
+ borderRadius: 10,
61
+ elevation: 2,
62
+ shadowColor: '#000',
63
+ shadowOffset: { width: 0, height: 1 },
64
+ shadowOpacity: 0.2,
65
+ shadowRadius: 1,
66
+ },
67
+ });
68
+
69
+ export default KSToggler;
@@ -0,0 +1,47 @@
1
+ import { StyleSheet, View, Text, ScrollView } from 'react-native';
2
+ import { useKSDensityCalendar } from '../context/use-ks-density-calendar-context';
3
+
4
+ const DaysOfWeek = () => {
5
+ const { daysOfWeek } = useKSDensityCalendar();
6
+
7
+ return (
8
+ <View style={styles.outerContainer}>
9
+ <ScrollView
10
+ horizontal
11
+ showsHorizontalScrollIndicator={false}
12
+ contentContainerStyle={styles.scrollContent}
13
+ scrollEnabled={false}
14
+ >
15
+ {Array.from({ length: 7 }, (_, index) => (
16
+ <View key={daysOfWeek[index] || index} style={styles.dayColumn}>
17
+ <Text style={styles.dayText}>{daysOfWeek[index]}</Text>
18
+ </View>
19
+ ))}
20
+ </ScrollView>
21
+ </View>
22
+ );
23
+ };
24
+
25
+ const styles = StyleSheet.create({
26
+ outerContainer: {
27
+ width: '100%',
28
+ paddingLeft: 8,
29
+ },
30
+ scrollContent: {
31
+ flexDirection: 'row',
32
+ alignItems: 'flex-start',
33
+ justifyContent: 'space-between',
34
+ width: '100%',
35
+ },
36
+ dayColumn: {
37
+ flex: 1,
38
+ alignItems: 'center',
39
+ justifyContent: 'center',
40
+ },
41
+ dayText: {
42
+ fontSize: 14,
43
+ fontWeight: '500',
44
+ },
45
+ });
46
+
47
+ export default DaysOfWeek;