@lazerlen/legend-calendar 1.0.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/.eslintrc.js +29 -0
- package/.turbo/turbo-build.log +19 -0
- package/.turbo/turbo-lint.log +14 -0
- package/.turbo/turbo-test.log +261 -0
- package/.turbo/turbo-typecheck.log +1 -0
- package/CHANGELOG.md +127 -0
- package/dist/index.d.mts +679 -0
- package/dist/index.d.ts +679 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +47 -0
- package/src/components/Calendar.stories.tsx +226 -0
- package/src/components/Calendar.tsx +224 -0
- package/src/components/CalendarItemDay.tsx +385 -0
- package/src/components/CalendarItemEmpty.tsx +30 -0
- package/src/components/CalendarItemWeekName.tsx +67 -0
- package/src/components/CalendarList.stories.tsx +326 -0
- package/src/components/CalendarList.tsx +373 -0
- package/src/components/CalendarRowMonth.tsx +62 -0
- package/src/components/CalendarRowWeek.tsx +46 -0
- package/src/components/CalendarThemeProvider.tsx +43 -0
- package/src/components/HStack.tsx +67 -0
- package/src/components/VStack.tsx +67 -0
- package/src/components/index.ts +108 -0
- package/src/developer/decorators.tsx +54 -0
- package/src/developer/loggginHandler.tsx +6 -0
- package/src/developer/useRenderCount.ts +7 -0
- package/src/helpers/dates.test.ts +567 -0
- package/src/helpers/dates.ts +163 -0
- package/src/helpers/functions.ts +327 -0
- package/src/helpers/numbers.ts +11 -0
- package/src/helpers/strings.ts +2 -0
- package/src/helpers/tokens.ts +71 -0
- package/src/helpers/types.ts +3 -0
- package/src/hooks/useCalendar.test.ts +381 -0
- package/src/hooks/useCalendar.ts +351 -0
- package/src/hooks/useCalendarList.test.ts +382 -0
- package/src/hooks/useCalendarList.tsx +291 -0
- package/src/hooks/useDateRange.test.ts +128 -0
- package/src/hooks/useDateRange.ts +94 -0
- package/src/hooks/useOptimizedDayMetadata.test.ts +582 -0
- package/src/hooks/useOptimizedDayMetadata.ts +93 -0
- package/src/hooks/useTheme.ts +14 -0
- package/src/index.ts +24 -0
- package/tsconfig.json +13 -0
- package/tsup.config.ts +15 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the date formatted as YYYY-MM-DD, ensuring timezone doesn't affect
|
|
3
|
+
* the result.
|
|
4
|
+
*/
|
|
5
|
+
export function toDateId(date: Date) {
|
|
6
|
+
const year = date.getFullYear();
|
|
7
|
+
const month = date.getMonth() + 1; // getMonth() returns 0-11
|
|
8
|
+
const day = date.getDate();
|
|
9
|
+
|
|
10
|
+
// Pad single digit month and day with leading zeros
|
|
11
|
+
const monthFormatted = month < 10 ? `0${month}` : month;
|
|
12
|
+
const dayFormatted = day < 10 ? `0${day}` : day;
|
|
13
|
+
|
|
14
|
+
return `${year}-${monthFormatted}-${dayFormatted}`;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Converts a date ID to a `Date` object, correctly accounting for timezone.
|
|
19
|
+
*/
|
|
20
|
+
export function fromDateId(dateId: string) {
|
|
21
|
+
const [year, month, day] = dateId.split("-").map(Number);
|
|
22
|
+
return new Date(year, month - 1, day);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Returns the first day of the month for the given date.
|
|
27
|
+
*/
|
|
28
|
+
export function startOfMonth(date: Date) {
|
|
29
|
+
return new Date(date.getFullYear(), date.getMonth(), 1);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Returns the last day of the month for the given date.
|
|
34
|
+
*/
|
|
35
|
+
export function endOfMonth(date: Date) {
|
|
36
|
+
const nextMonth = new Date(date.getFullYear(), date.getMonth() + 1, 1);
|
|
37
|
+
const lastDay = new Date(nextMonth.getTime() - 1);
|
|
38
|
+
return new Date(lastDay);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Returns the first day of the week for the given date.
|
|
43
|
+
*/
|
|
44
|
+
export function startOfWeek(
|
|
45
|
+
baseDate: Date,
|
|
46
|
+
firstDayOfWeek: "monday" | "sunday"
|
|
47
|
+
): Date {
|
|
48
|
+
// Clone the baseDate to avoid modifying the original date
|
|
49
|
+
const date = new Date(baseDate.getTime());
|
|
50
|
+
|
|
51
|
+
// Calculate the day of the week (0 for Sunday, 1 for Monday, etc.)
|
|
52
|
+
const dayOfWeek = date.getDay();
|
|
53
|
+
const isSunday = dayOfWeek === 0;
|
|
54
|
+
|
|
55
|
+
if (isSunday && firstDayOfWeek === "monday") {
|
|
56
|
+
date.setDate(date.getDate() - 6);
|
|
57
|
+
return date;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Calculate the difference between the current day and the first day of the week
|
|
61
|
+
const diff = dayOfWeek - (firstDayOfWeek === "monday" ? 1 : 0);
|
|
62
|
+
date.setDate(date.getDate() - diff);
|
|
63
|
+
|
|
64
|
+
return date;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Add `n` months to the given date.
|
|
69
|
+
*/
|
|
70
|
+
export function addMonths(date: Date, months: number) {
|
|
71
|
+
const newDate = new Date(date);
|
|
72
|
+
newDate.setMonth(newDate.getMonth() + months);
|
|
73
|
+
return newDate;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Subtract `n` months from the given date.
|
|
78
|
+
*/
|
|
79
|
+
export function subMonths(date: Date, months: number) {
|
|
80
|
+
const newDate = new Date(date);
|
|
81
|
+
newDate.setMonth(newDate.getMonth() - months);
|
|
82
|
+
return newDate;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Add `n` days to the given date.
|
|
87
|
+
*/
|
|
88
|
+
export function addDays(date: Date, days: number) {
|
|
89
|
+
const newDate = new Date(date);
|
|
90
|
+
newDate.setDate(newDate.getDate() + days);
|
|
91
|
+
return newDate;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Subtract `n` days from the given date.
|
|
96
|
+
*/
|
|
97
|
+
export function subDays(date: Date, days: number) {
|
|
98
|
+
const newDate = new Date(date);
|
|
99
|
+
newDate.setDate(newDate.getDate() - days);
|
|
100
|
+
return newDate;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Does the given date fall on a weekend?
|
|
105
|
+
*/
|
|
106
|
+
export function isWeekend(date: Date) {
|
|
107
|
+
const day = date.getDay();
|
|
108
|
+
return day === 0 || day === 6;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Get the number of months between the given dates.
|
|
113
|
+
*/
|
|
114
|
+
export function differenceInMonths(laterDate: Date, earlierDate: Date) {
|
|
115
|
+
const yearDiff = laterDate.getFullYear() - earlierDate.getFullYear();
|
|
116
|
+
const monthDiff = laterDate.getMonth() - earlierDate.getMonth();
|
|
117
|
+
|
|
118
|
+
return yearDiff * 12 + monthDiff;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Get the number of weeks in the month for the given date.
|
|
123
|
+
*/
|
|
124
|
+
export function getWeeksInMonth(
|
|
125
|
+
date: Date,
|
|
126
|
+
firstDayOfWeek: "monday" | "sunday"
|
|
127
|
+
) {
|
|
128
|
+
const firstDay = new Date(date.getFullYear(), date.getMonth(), 1);
|
|
129
|
+
let dayOfWeek = firstDay.getDay();
|
|
130
|
+
|
|
131
|
+
// Adjust the first day of the week
|
|
132
|
+
if (firstDayOfWeek === "monday") {
|
|
133
|
+
dayOfWeek = dayOfWeek === 0 ? 6 : dayOfWeek - 1;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const totalDays = new Date(
|
|
137
|
+
date.getFullYear(),
|
|
138
|
+
date.getMonth() + 1,
|
|
139
|
+
0
|
|
140
|
+
).getDate();
|
|
141
|
+
|
|
142
|
+
return Math.ceil((dayOfWeek + totalDays) / 7);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Get the week of the month of the given date. The week index is 1-based.
|
|
147
|
+
*/
|
|
148
|
+
export function getWeekOfMonth(
|
|
149
|
+
date: Date,
|
|
150
|
+
firstDayOfWeek: "monday" | "sunday"
|
|
151
|
+
) {
|
|
152
|
+
const firstDay = new Date(date.getFullYear(), date.getMonth(), 1);
|
|
153
|
+
let dayOfWeek = firstDay.getDay();
|
|
154
|
+
|
|
155
|
+
// Adjust the first day of the week
|
|
156
|
+
if (firstDayOfWeek === "monday") {
|
|
157
|
+
dayOfWeek = dayOfWeek === 0 ? 6 : dayOfWeek - 1;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const dayOfMonth = date.getDate();
|
|
161
|
+
|
|
162
|
+
return Math.floor((dayOfWeek + dayOfMonth - 1) / 7) + 1;
|
|
163
|
+
}
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pipes the value of an expression into a pipeline of functions.
|
|
3
|
+
*
|
|
4
|
+
* See also [`flow`](#flow).
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* import { pipe } from 'fp-ts/function'
|
|
8
|
+
*
|
|
9
|
+
* const len = (s: string): number => s.length
|
|
10
|
+
* const double = (n: number): number => n * 2
|
|
11
|
+
*
|
|
12
|
+
* // without pipe
|
|
13
|
+
* assert.strictEqual(double(len('aaa')), 6)
|
|
14
|
+
*
|
|
15
|
+
* // with pipe
|
|
16
|
+
* assert.strictEqual(pipe('aaa', len, double), 6)
|
|
17
|
+
*
|
|
18
|
+
* @remark copied from https://github.com/gcanti/fp-ts/blob/master/src/function.ts
|
|
19
|
+
*/
|
|
20
|
+
export function pipe<A>(a: A): A;
|
|
21
|
+
export function pipe<A, B>(a: A, ab: (a: A) => B): B;
|
|
22
|
+
export function pipe<A, B, C>(a: A, ab: (a: A) => B, bc: (b: B) => C): C;
|
|
23
|
+
export function pipe<A, B, C, D>(
|
|
24
|
+
a: A,
|
|
25
|
+
ab: (a: A) => B,
|
|
26
|
+
bc: (b: B) => C,
|
|
27
|
+
cd: (c: C) => D
|
|
28
|
+
): D;
|
|
29
|
+
export function pipe<A, B, C, D, E>(
|
|
30
|
+
a: A,
|
|
31
|
+
ab: (a: A) => B,
|
|
32
|
+
bc: (b: B) => C,
|
|
33
|
+
cd: (c: C) => D,
|
|
34
|
+
de: (d: D) => E
|
|
35
|
+
): E;
|
|
36
|
+
export function pipe<A, B, C, D, E, F>(
|
|
37
|
+
a: A,
|
|
38
|
+
ab: (a: A) => B,
|
|
39
|
+
bc: (b: B) => C,
|
|
40
|
+
cd: (c: C) => D,
|
|
41
|
+
de: (d: D) => E,
|
|
42
|
+
ef: (e: E) => F
|
|
43
|
+
): F;
|
|
44
|
+
export function pipe<A, B, C, D, E, F, G>(
|
|
45
|
+
a: A,
|
|
46
|
+
ab: (a: A) => B,
|
|
47
|
+
bc: (b: B) => C,
|
|
48
|
+
cd: (c: C) => D,
|
|
49
|
+
de: (d: D) => E,
|
|
50
|
+
ef: (e: E) => F,
|
|
51
|
+
fg: (f: F) => G
|
|
52
|
+
): G;
|
|
53
|
+
export function pipe<A, B, C, D, E, F, G, H>(
|
|
54
|
+
a: A,
|
|
55
|
+
ab: (a: A) => B,
|
|
56
|
+
bc: (b: B) => C,
|
|
57
|
+
cd: (c: C) => D,
|
|
58
|
+
de: (d: D) => E,
|
|
59
|
+
ef: (e: E) => F,
|
|
60
|
+
fg: (f: F) => G,
|
|
61
|
+
gh: (g: G) => H
|
|
62
|
+
): H;
|
|
63
|
+
export function pipe<A, B, C, D, E, F, G, H, I>(
|
|
64
|
+
a: A,
|
|
65
|
+
ab: (a: A) => B,
|
|
66
|
+
bc: (b: B) => C,
|
|
67
|
+
cd: (c: C) => D,
|
|
68
|
+
de: (d: D) => E,
|
|
69
|
+
ef: (e: E) => F,
|
|
70
|
+
fg: (f: F) => G,
|
|
71
|
+
gh: (g: G) => H,
|
|
72
|
+
hi: (h: H) => I
|
|
73
|
+
): I;
|
|
74
|
+
export function pipe<A, B, C, D, E, F, G, H, I, J>(
|
|
75
|
+
a: A,
|
|
76
|
+
ab: (a: A) => B,
|
|
77
|
+
bc: (b: B) => C,
|
|
78
|
+
cd: (c: C) => D,
|
|
79
|
+
de: (d: D) => E,
|
|
80
|
+
ef: (e: E) => F,
|
|
81
|
+
fg: (f: F) => G,
|
|
82
|
+
gh: (g: G) => H,
|
|
83
|
+
hi: (h: H) => I,
|
|
84
|
+
ij: (i: I) => J
|
|
85
|
+
): J;
|
|
86
|
+
export function pipe<A, B, C, D, E, F, G, H, I, J, K>(
|
|
87
|
+
a: A,
|
|
88
|
+
ab: (a: A) => B,
|
|
89
|
+
bc: (b: B) => C,
|
|
90
|
+
cd: (c: C) => D,
|
|
91
|
+
de: (d: D) => E,
|
|
92
|
+
ef: (e: E) => F,
|
|
93
|
+
fg: (f: F) => G,
|
|
94
|
+
gh: (g: G) => H,
|
|
95
|
+
hi: (h: H) => I,
|
|
96
|
+
ij: (i: I) => J,
|
|
97
|
+
jk: (j: J) => K
|
|
98
|
+
): K;
|
|
99
|
+
export function pipe<A, B, C, D, E, F, G, H, I, J, K, L>(
|
|
100
|
+
a: A,
|
|
101
|
+
ab: (a: A) => B,
|
|
102
|
+
bc: (b: B) => C,
|
|
103
|
+
cd: (c: C) => D,
|
|
104
|
+
de: (d: D) => E,
|
|
105
|
+
ef: (e: E) => F,
|
|
106
|
+
fg: (f: F) => G,
|
|
107
|
+
gh: (g: G) => H,
|
|
108
|
+
hi: (h: H) => I,
|
|
109
|
+
ij: (i: I) => J,
|
|
110
|
+
jk: (j: J) => K,
|
|
111
|
+
kl: (k: K) => L
|
|
112
|
+
): L;
|
|
113
|
+
export function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M>(
|
|
114
|
+
a: A,
|
|
115
|
+
ab: (a: A) => B,
|
|
116
|
+
bc: (b: B) => C,
|
|
117
|
+
cd: (c: C) => D,
|
|
118
|
+
de: (d: D) => E,
|
|
119
|
+
ef: (e: E) => F,
|
|
120
|
+
fg: (f: F) => G,
|
|
121
|
+
gh: (g: G) => H,
|
|
122
|
+
hi: (h: H) => I,
|
|
123
|
+
ij: (i: I) => J,
|
|
124
|
+
jk: (j: J) => K,
|
|
125
|
+
kl: (k: K) => L,
|
|
126
|
+
lm: (l: L) => M
|
|
127
|
+
): M;
|
|
128
|
+
export function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N>(
|
|
129
|
+
a: A,
|
|
130
|
+
ab: (a: A) => B,
|
|
131
|
+
bc: (b: B) => C,
|
|
132
|
+
cd: (c: C) => D,
|
|
133
|
+
de: (d: D) => E,
|
|
134
|
+
ef: (e: E) => F,
|
|
135
|
+
fg: (f: F) => G,
|
|
136
|
+
gh: (g: G) => H,
|
|
137
|
+
hi: (h: H) => I,
|
|
138
|
+
ij: (i: I) => J,
|
|
139
|
+
jk: (j: J) => K,
|
|
140
|
+
kl: (k: K) => L,
|
|
141
|
+
lm: (l: L) => M,
|
|
142
|
+
mn: (m: M) => N
|
|
143
|
+
): N;
|
|
144
|
+
export function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O>(
|
|
145
|
+
a: A,
|
|
146
|
+
ab: (a: A) => B,
|
|
147
|
+
bc: (b: B) => C,
|
|
148
|
+
cd: (c: C) => D,
|
|
149
|
+
de: (d: D) => E,
|
|
150
|
+
ef: (e: E) => F,
|
|
151
|
+
fg: (f: F) => G,
|
|
152
|
+
gh: (g: G) => H,
|
|
153
|
+
hi: (h: H) => I,
|
|
154
|
+
ij: (i: I) => J,
|
|
155
|
+
jk: (j: J) => K,
|
|
156
|
+
kl: (k: K) => L,
|
|
157
|
+
lm: (l: L) => M,
|
|
158
|
+
mn: (m: M) => N,
|
|
159
|
+
no: (n: N) => O
|
|
160
|
+
): O;
|
|
161
|
+
|
|
162
|
+
export function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P>(
|
|
163
|
+
a: A,
|
|
164
|
+
ab: (a: A) => B,
|
|
165
|
+
bc: (b: B) => C,
|
|
166
|
+
cd: (c: C) => D,
|
|
167
|
+
de: (d: D) => E,
|
|
168
|
+
ef: (e: E) => F,
|
|
169
|
+
fg: (f: F) => G,
|
|
170
|
+
gh: (g: G) => H,
|
|
171
|
+
hi: (h: H) => I,
|
|
172
|
+
ij: (i: I) => J,
|
|
173
|
+
jk: (j: J) => K,
|
|
174
|
+
kl: (k: K) => L,
|
|
175
|
+
lm: (l: L) => M,
|
|
176
|
+
mn: (m: M) => N,
|
|
177
|
+
no: (n: N) => O,
|
|
178
|
+
op: (o: O) => P
|
|
179
|
+
): P;
|
|
180
|
+
|
|
181
|
+
export function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q>(
|
|
182
|
+
a: A,
|
|
183
|
+
ab: (a: A) => B,
|
|
184
|
+
bc: (b: B) => C,
|
|
185
|
+
cd: (c: C) => D,
|
|
186
|
+
de: (d: D) => E,
|
|
187
|
+
ef: (e: E) => F,
|
|
188
|
+
fg: (f: F) => G,
|
|
189
|
+
gh: (g: G) => H,
|
|
190
|
+
hi: (h: H) => I,
|
|
191
|
+
ij: (i: I) => J,
|
|
192
|
+
jk: (j: J) => K,
|
|
193
|
+
kl: (k: K) => L,
|
|
194
|
+
lm: (l: L) => M,
|
|
195
|
+
mn: (m: M) => N,
|
|
196
|
+
no: (n: N) => O,
|
|
197
|
+
op: (o: O) => P,
|
|
198
|
+
pq: (p: P) => Q
|
|
199
|
+
): Q;
|
|
200
|
+
|
|
201
|
+
export function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R>(
|
|
202
|
+
a: A,
|
|
203
|
+
ab: (a: A) => B,
|
|
204
|
+
bc: (b: B) => C,
|
|
205
|
+
cd: (c: C) => D,
|
|
206
|
+
de: (d: D) => E,
|
|
207
|
+
ef: (e: E) => F,
|
|
208
|
+
fg: (f: F) => G,
|
|
209
|
+
gh: (g: G) => H,
|
|
210
|
+
hi: (h: H) => I,
|
|
211
|
+
ij: (i: I) => J,
|
|
212
|
+
jk: (j: J) => K,
|
|
213
|
+
kl: (k: K) => L,
|
|
214
|
+
lm: (l: L) => M,
|
|
215
|
+
mn: (m: M) => N,
|
|
216
|
+
no: (n: N) => O,
|
|
217
|
+
op: (o: O) => P,
|
|
218
|
+
pq: (p: P) => Q,
|
|
219
|
+
qr: (q: Q) => R
|
|
220
|
+
): R;
|
|
221
|
+
|
|
222
|
+
export function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S>(
|
|
223
|
+
a: A,
|
|
224
|
+
ab: (a: A) => B,
|
|
225
|
+
bc: (b: B) => C,
|
|
226
|
+
cd: (c: C) => D,
|
|
227
|
+
de: (d: D) => E,
|
|
228
|
+
ef: (e: E) => F,
|
|
229
|
+
fg: (f: F) => G,
|
|
230
|
+
gh: (g: G) => H,
|
|
231
|
+
hi: (h: H) => I,
|
|
232
|
+
ij: (i: I) => J,
|
|
233
|
+
jk: (j: J) => K,
|
|
234
|
+
kl: (k: K) => L,
|
|
235
|
+
lm: (l: L) => M,
|
|
236
|
+
mn: (m: M) => N,
|
|
237
|
+
no: (n: N) => O,
|
|
238
|
+
op: (o: O) => P,
|
|
239
|
+
pq: (p: P) => Q,
|
|
240
|
+
qr: (q: Q) => R,
|
|
241
|
+
rs: (r: R) => S
|
|
242
|
+
): S;
|
|
243
|
+
|
|
244
|
+
export function pipe<
|
|
245
|
+
A,
|
|
246
|
+
B,
|
|
247
|
+
C,
|
|
248
|
+
D,
|
|
249
|
+
E,
|
|
250
|
+
F,
|
|
251
|
+
G,
|
|
252
|
+
H,
|
|
253
|
+
I,
|
|
254
|
+
J,
|
|
255
|
+
K,
|
|
256
|
+
L,
|
|
257
|
+
M,
|
|
258
|
+
N,
|
|
259
|
+
O,
|
|
260
|
+
P,
|
|
261
|
+
Q,
|
|
262
|
+
R,
|
|
263
|
+
S,
|
|
264
|
+
T
|
|
265
|
+
>(
|
|
266
|
+
a: A,
|
|
267
|
+
ab: (a: A) => B,
|
|
268
|
+
bc: (b: B) => C,
|
|
269
|
+
cd: (c: C) => D,
|
|
270
|
+
de: (d: D) => E,
|
|
271
|
+
ef: (e: E) => F,
|
|
272
|
+
fg: (f: F) => G,
|
|
273
|
+
gh: (g: G) => H,
|
|
274
|
+
hi: (h: H) => I,
|
|
275
|
+
ij: (i: I) => J,
|
|
276
|
+
jk: (j: J) => K,
|
|
277
|
+
kl: (k: K) => L,
|
|
278
|
+
lm: (l: L) => M,
|
|
279
|
+
mn: (m: M) => N,
|
|
280
|
+
no: (n: N) => O,
|
|
281
|
+
op: (o: O) => P,
|
|
282
|
+
pq: (p: P) => Q,
|
|
283
|
+
qr: (q: Q) => R,
|
|
284
|
+
rs: (r: R) => S,
|
|
285
|
+
st: (s: S) => T
|
|
286
|
+
): T;
|
|
287
|
+
export function pipe(
|
|
288
|
+
a: unknown,
|
|
289
|
+
ab?: Function,
|
|
290
|
+
bc?: Function,
|
|
291
|
+
cd?: Function,
|
|
292
|
+
de?: Function,
|
|
293
|
+
ef?: Function,
|
|
294
|
+
fg?: Function,
|
|
295
|
+
gh?: Function,
|
|
296
|
+
hi?: Function
|
|
297
|
+
): unknown {
|
|
298
|
+
switch (arguments.length) {
|
|
299
|
+
case 1:
|
|
300
|
+
return a;
|
|
301
|
+
case 2:
|
|
302
|
+
return ab!(a);
|
|
303
|
+
case 3:
|
|
304
|
+
return bc!(ab!(a));
|
|
305
|
+
case 4:
|
|
306
|
+
return cd!(bc!(ab!(a)));
|
|
307
|
+
case 5:
|
|
308
|
+
return de!(cd!(bc!(ab!(a))));
|
|
309
|
+
case 6:
|
|
310
|
+
return ef!(de!(cd!(bc!(ab!(a)))));
|
|
311
|
+
case 7:
|
|
312
|
+
return fg!(ef!(de!(cd!(bc!(ab!(a))))));
|
|
313
|
+
case 8:
|
|
314
|
+
return gh!(fg!(ef!(de!(cd!(bc!(ab!(a)))))));
|
|
315
|
+
case 9:
|
|
316
|
+
return hi!(gh!(fg!(ef!(de!(cd!(bc!(ab!(a))))))));
|
|
317
|
+
default: {
|
|
318
|
+
// eslint-disable-next-line prefer-rest-params
|
|
319
|
+
let ret = arguments[0];
|
|
320
|
+
for (let i = 1; i < arguments.length; i++) {
|
|
321
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, prefer-rest-params
|
|
322
|
+
ret = arguments[i](ret);
|
|
323
|
+
}
|
|
324
|
+
return ret;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a list of numbers from `start` (inclusive) to `stop`
|
|
3
|
+
* (inclusive). In mathematical terms, `range(a, b)` is equivalent to
|
|
4
|
+
* the interval `[a, b]`.
|
|
5
|
+
*
|
|
6
|
+
* An optional `step` can be provided to control the size of the increemnt (defaults to `1`).
|
|
7
|
+
*
|
|
8
|
+
* Copied from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from
|
|
9
|
+
*/
|
|
10
|
+
export const range = (start: number, stop: number, step = 1) =>
|
|
11
|
+
Array.from({ length: (stop - start) / step + 1 }, (_, i) => start + i * step);
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const baseTokens = {
|
|
2
|
+
spacing: {
|
|
3
|
+
0: 0,
|
|
4
|
+
2: 2,
|
|
5
|
+
4: 4,
|
|
6
|
+
6: 6,
|
|
7
|
+
8: 8,
|
|
8
|
+
12: 12,
|
|
9
|
+
16: 16,
|
|
10
|
+
20: 20,
|
|
11
|
+
24: 24,
|
|
12
|
+
},
|
|
13
|
+
} as const;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Minimal theme for the Legend Calendar component.
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export const lightTheme = {
|
|
20
|
+
...baseTokens,
|
|
21
|
+
colors: {
|
|
22
|
+
content: {
|
|
23
|
+
disabled: "#B0B0B0",
|
|
24
|
+
primary: "#000000",
|
|
25
|
+
secondary: "#212121",
|
|
26
|
+
inverse: {
|
|
27
|
+
primary: "#FFFFFF",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
background: {
|
|
31
|
+
primary: "#FFFFFF",
|
|
32
|
+
tertiary: "#EDEFEE",
|
|
33
|
+
tertiaryPressed: "#D1D2D3",
|
|
34
|
+
inverse: {
|
|
35
|
+
primary: "#000000",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
borders: {
|
|
39
|
+
default: "#E0E0E0",
|
|
40
|
+
},
|
|
41
|
+
transparent: "transparent",
|
|
42
|
+
},
|
|
43
|
+
} as const;
|
|
44
|
+
|
|
45
|
+
export const darkTheme = {
|
|
46
|
+
...baseTokens,
|
|
47
|
+
colors: {
|
|
48
|
+
content: {
|
|
49
|
+
disabled: "#bdbdbd",
|
|
50
|
+
primary: "#FFFFFF",
|
|
51
|
+
secondary: "#e8e8e8",
|
|
52
|
+
inverse: {
|
|
53
|
+
primary: "#000000",
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
background: {
|
|
57
|
+
primary: "#000000",
|
|
58
|
+
tertiary: "#111111",
|
|
59
|
+
tertiaryPressed: "#212121",
|
|
60
|
+
inverse: {
|
|
61
|
+
primary: "#FFFFFF",
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
borders: {
|
|
65
|
+
default: "#5c5c5c",
|
|
66
|
+
},
|
|
67
|
+
transparent: "transparent",
|
|
68
|
+
},
|
|
69
|
+
} as const;
|
|
70
|
+
|
|
71
|
+
export type BaseTheme = typeof lightTheme | typeof darkTheme;
|