react-native-kanban 0.0.0-stage → 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 (70) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +242 -2
  3. package/lib/module/components/Board.js +113 -0
  4. package/lib/module/components/Board.js.map +1 -0
  5. package/lib/module/components/Card.js +68 -0
  6. package/lib/module/components/Card.js.map +1 -0
  7. package/lib/module/components/Column.js +78 -0
  8. package/lib/module/components/Column.js.map +1 -0
  9. package/lib/module/components/createBaseStyles.js +107 -0
  10. package/lib/module/components/createBaseStyles.js.map +1 -0
  11. package/lib/module/components/types.js +4 -0
  12. package/lib/module/components/types.js.map +1 -0
  13. package/lib/module/helpers.js +205 -0
  14. package/lib/module/helpers.js.map +1 -0
  15. package/lib/module/index.js +12 -0
  16. package/lib/module/index.js.map +1 -0
  17. package/lib/module/package.json +1 -0
  18. package/lib/module/theme/ThemeContext.js +32 -0
  19. package/lib/module/theme/ThemeContext.js.map +1 -0
  20. package/lib/module/theme/createKanbanTheme.js +47 -0
  21. package/lib/module/theme/createKanbanTheme.js.map +1 -0
  22. package/lib/module/theme/index.js +6 -0
  23. package/lib/module/theme/index.js.map +1 -0
  24. package/lib/module/theme/presets.js +133 -0
  25. package/lib/module/theme/presets.js.map +1 -0
  26. package/lib/module/theme/types.js +4 -0
  27. package/lib/module/theme/types.js.map +1 -0
  28. package/lib/module/types.js +2 -0
  29. package/lib/module/types.js.map +1 -0
  30. package/lib/typescript/package.json +1 -0
  31. package/lib/typescript/src/components/Board.d.ts +14 -0
  32. package/lib/typescript/src/components/Board.d.ts.map +1 -0
  33. package/lib/typescript/src/components/Card.d.ts +25 -0
  34. package/lib/typescript/src/components/Card.d.ts.map +1 -0
  35. package/lib/typescript/src/components/Column.d.ts +26 -0
  36. package/lib/typescript/src/components/Column.d.ts.map +1 -0
  37. package/lib/typescript/src/components/createBaseStyles.d.ts +26 -0
  38. package/lib/typescript/src/components/createBaseStyles.d.ts.map +1 -0
  39. package/lib/typescript/src/components/types.d.ts +84 -0
  40. package/lib/typescript/src/components/types.d.ts.map +1 -0
  41. package/lib/typescript/src/helpers.d.ts +50 -0
  42. package/lib/typescript/src/helpers.d.ts.map +1 -0
  43. package/lib/typescript/src/index.d.ts +9 -0
  44. package/lib/typescript/src/index.d.ts.map +1 -0
  45. package/lib/typescript/src/theme/ThemeContext.d.ts +10 -0
  46. package/lib/typescript/src/theme/ThemeContext.d.ts.map +1 -0
  47. package/lib/typescript/src/theme/createKanbanTheme.d.ts +15 -0
  48. package/lib/typescript/src/theme/createKanbanTheme.d.ts.map +1 -0
  49. package/lib/typescript/src/theme/index.d.ts +6 -0
  50. package/lib/typescript/src/theme/index.d.ts.map +1 -0
  51. package/lib/typescript/src/theme/presets.d.ts +6 -0
  52. package/lib/typescript/src/theme/presets.d.ts.map +1 -0
  53. package/lib/typescript/src/theme/types.d.ts +89 -0
  54. package/lib/typescript/src/theme/types.d.ts.map +1 -0
  55. package/lib/typescript/src/types.d.ts +47 -0
  56. package/lib/typescript/src/types.d.ts.map +1 -0
  57. package/package.json +172 -4
  58. package/src/components/Board.tsx +135 -0
  59. package/src/components/Card.tsx +89 -0
  60. package/src/components/Column.tsx +133 -0
  61. package/src/components/createBaseStyles.ts +123 -0
  62. package/src/components/types.ts +99 -0
  63. package/src/helpers.ts +288 -0
  64. package/src/index.tsx +61 -0
  65. package/src/theme/ThemeContext.tsx +35 -0
  66. package/src/theme/createKanbanTheme.ts +59 -0
  67. package/src/theme/index.ts +9 -0
  68. package/src/theme/presets.ts +100 -0
  69. package/src/theme/types.ts +112 -0
  70. package/src/types.ts +57 -0
package/src/helpers.ts ADDED
@@ -0,0 +1,288 @@
1
+ import type {
2
+ CardDestination,
3
+ CardSource,
4
+ ColumnDestination,
5
+ ColumnSource,
6
+ KanbanBoard,
7
+ KanbanCard,
8
+ KanbanColumn,
9
+ KanbanId,
10
+ } from './types';
11
+
12
+ /**
13
+ * Pure, immutable helpers for updating a board.
14
+ *
15
+ * Every helper returns a new board and never mutates its input. Columns and
16
+ * cards that did not change keep their object identity, so memoized columns
17
+ * and cards skip re-rendering. When nothing changes (unknown id, same
18
+ * position), the original board object is returned as-is.
19
+ */
20
+
21
+ /** Where a new card or column goes: start, end, or an exact index. */
22
+ export type InsertPosition = 'top' | 'bottom' | number;
23
+
24
+ export interface CardLocation<TCard extends KanbanCard = KanbanCard> {
25
+ card: TCard;
26
+ columnId: KanbanId;
27
+ columnIndex: number;
28
+ position: number;
29
+ }
30
+
31
+ const clamp = (value: number, min: number, max: number) =>
32
+ Math.min(Math.max(value, min), max);
33
+
34
+ const resolveIndex = (position: InsertPosition | undefined, length: number) => {
35
+ if (position === 'top') return 0;
36
+ if (position === undefined || position === 'bottom') return length;
37
+ return clamp(Math.trunc(position), 0, length);
38
+ };
39
+
40
+ const insertAt = <T>(list: readonly T[], index: number, item: T): T[] => {
41
+ const next = list.slice();
42
+ next.splice(index, 0, item);
43
+ return next;
44
+ };
45
+
46
+ const removeAt = <T>(list: readonly T[], index: number): T[] => {
47
+ const next = list.slice();
48
+ next.splice(index, 1);
49
+ return next;
50
+ };
51
+
52
+ const columnIndexOf = (
53
+ board: { columns: ReadonlyArray<{ id: KanbanId }> },
54
+ columnId: KanbanId
55
+ ) => board.columns.findIndex((column) => column.id === columnId);
56
+
57
+ /** Finds a card anywhere on the board. */
58
+ export function findCard<
59
+ TCard extends KanbanCard,
60
+ TColumn extends KanbanColumn<TCard>,
61
+ >(
62
+ board: KanbanBoard<TCard, TColumn>,
63
+ cardId: KanbanId
64
+ ): CardLocation<TCard> | undefined {
65
+ for (let columnIndex = 0; columnIndex < board.columns.length; columnIndex++) {
66
+ const column = board.columns[columnIndex]!;
67
+ const position = column.cards.findIndex((card) => card.id === cardId);
68
+ if (position !== -1) {
69
+ return {
70
+ card: column.cards[position]!,
71
+ columnId: column.id,
72
+ columnIndex,
73
+ position,
74
+ };
75
+ }
76
+ }
77
+ return undefined;
78
+ }
79
+
80
+ /**
81
+ * Moves a card within a column or to another column.
82
+ * `toPosition` is the card's final index in the destination column.
83
+ */
84
+ export function moveCard<
85
+ TCard extends KanbanCard,
86
+ TColumn extends KanbanColumn<TCard>,
87
+ >(
88
+ board: KanbanBoard<TCard, TColumn>,
89
+ source: CardSource,
90
+ destination: CardDestination
91
+ ): KanbanBoard<TCard, TColumn> {
92
+ const fromIndex = columnIndexOf(board, source.fromColumnId);
93
+ const toColumnIndex = columnIndexOf(board, destination.toColumnId);
94
+ if (fromIndex === -1 || toColumnIndex === -1) return board;
95
+
96
+ const fromColumn = board.columns[fromIndex]!;
97
+ const card = fromColumn.cards[source.fromPosition];
98
+ if (!card) return board;
99
+
100
+ if (fromIndex === toColumnIndex) {
101
+ const position = clamp(
102
+ Math.trunc(destination.toPosition),
103
+ 0,
104
+ fromColumn.cards.length - 1
105
+ );
106
+ if (position === source.fromPosition) return board;
107
+ const cards = insertAt(
108
+ removeAt(fromColumn.cards, source.fromPosition),
109
+ position,
110
+ card
111
+ );
112
+ const columns = board.columns.slice();
113
+ columns[fromIndex] = { ...fromColumn, cards };
114
+ return { ...board, columns };
115
+ }
116
+
117
+ const toColumn = board.columns[toColumnIndex]!;
118
+ const columns = board.columns.slice();
119
+ columns[fromIndex] = {
120
+ ...fromColumn,
121
+ cards: removeAt(fromColumn.cards, source.fromPosition),
122
+ };
123
+ columns[toColumnIndex] = {
124
+ ...toColumn,
125
+ cards: insertAt(
126
+ toColumn.cards,
127
+ resolveIndex(destination.toPosition, toColumn.cards.length),
128
+ card
129
+ ),
130
+ };
131
+ return { ...board, columns };
132
+ }
133
+
134
+ /** Moves a column to a new index. */
135
+ export function moveColumn<
136
+ TCard extends KanbanCard,
137
+ TColumn extends KanbanColumn<TCard>,
138
+ >(
139
+ board: KanbanBoard<TCard, TColumn>,
140
+ source: ColumnSource,
141
+ destination: ColumnDestination
142
+ ): KanbanBoard<TCard, TColumn> {
143
+ const column = board.columns[source.fromPosition];
144
+ if (!column) return board;
145
+ const position = clamp(
146
+ Math.trunc(destination.toPosition),
147
+ 0,
148
+ board.columns.length - 1
149
+ );
150
+ if (position === source.fromPosition) return board;
151
+ return {
152
+ ...board,
153
+ columns: insertAt(
154
+ removeAt(board.columns, source.fromPosition),
155
+ position,
156
+ column
157
+ ),
158
+ };
159
+ }
160
+
161
+ /** Adds a card to a column. Defaults to the bottom of the column. */
162
+ export function addCard<
163
+ TCard extends KanbanCard,
164
+ TColumn extends KanbanColumn<TCard>,
165
+ >(
166
+ board: KanbanBoard<TCard, TColumn>,
167
+ columnId: KanbanId,
168
+ card: TCard,
169
+ options: { position?: InsertPosition } = {}
170
+ ): KanbanBoard<TCard, TColumn> {
171
+ const index = columnIndexOf(board, columnId);
172
+ if (index === -1) return board;
173
+ const column = board.columns[index]!;
174
+ const columns = board.columns.slice();
175
+ columns[index] = {
176
+ ...column,
177
+ cards: insertAt(
178
+ column.cards,
179
+ resolveIndex(options.position, column.cards.length),
180
+ card
181
+ ),
182
+ };
183
+ return { ...board, columns };
184
+ }
185
+
186
+ /** Removes a card from the board, wherever it is. */
187
+ export function removeCard<
188
+ TCard extends KanbanCard,
189
+ TColumn extends KanbanColumn<TCard>,
190
+ >(
191
+ board: KanbanBoard<TCard, TColumn>,
192
+ cardId: KanbanId
193
+ ): KanbanBoard<TCard, TColumn> {
194
+ const location = findCard(board, cardId);
195
+ if (!location) return board;
196
+ const column = board.columns[location.columnIndex]!;
197
+ const columns = board.columns.slice();
198
+ columns[location.columnIndex] = {
199
+ ...column,
200
+ cards: removeAt(column.cards, location.position),
201
+ };
202
+ return { ...board, columns };
203
+ }
204
+
205
+ /**
206
+ * Updates a card in place. Pass a partial object to merge, or a function that
207
+ * returns the next card. The card's `id` cannot be changed.
208
+ */
209
+ export function updateCard<
210
+ TCard extends KanbanCard,
211
+ TColumn extends KanbanColumn<TCard>,
212
+ >(
213
+ board: KanbanBoard<TCard, TColumn>,
214
+ cardId: KanbanId,
215
+ update: Partial<Omit<TCard, 'id'>> | ((card: TCard) => TCard)
216
+ ): KanbanBoard<TCard, TColumn> {
217
+ const location = findCard(board, cardId);
218
+ if (!location) return board;
219
+ const next =
220
+ typeof update === 'function'
221
+ ? update(location.card)
222
+ : ({ ...location.card, ...update } as TCard);
223
+ if (next === location.card) return board;
224
+ const column = board.columns[location.columnIndex]!;
225
+ const cards = column.cards.slice();
226
+ cards[location.position] = { ...next, id: location.card.id };
227
+ const columns = board.columns.slice();
228
+ columns[location.columnIndex] = { ...column, cards };
229
+ return { ...board, columns };
230
+ }
231
+
232
+ /** Adds a column. Defaults to the end of the board. */
233
+ export function addColumn<
234
+ TCard extends KanbanCard,
235
+ TColumn extends KanbanColumn<TCard>,
236
+ >(
237
+ board: KanbanBoard<TCard, TColumn>,
238
+ column: TColumn,
239
+ options: { position?: InsertPosition } = {}
240
+ ): KanbanBoard<TCard, TColumn> {
241
+ return {
242
+ ...board,
243
+ columns: insertAt(
244
+ board.columns,
245
+ resolveIndex(options.position, board.columns.length),
246
+ column
247
+ ),
248
+ };
249
+ }
250
+
251
+ /** Removes a column and all of its cards. */
252
+ export function removeColumn<
253
+ TCard extends KanbanCard,
254
+ TColumn extends KanbanColumn<TCard>,
255
+ >(
256
+ board: KanbanBoard<TCard, TColumn>,
257
+ columnId: KanbanId
258
+ ): KanbanBoard<TCard, TColumn> {
259
+ const index = columnIndexOf(board, columnId);
260
+ if (index === -1) return board;
261
+ return { ...board, columns: removeAt(board.columns, index) };
262
+ }
263
+
264
+ /**
265
+ * Updates a column's fields (title, custom fields, or cards). Pass a partial
266
+ * object to merge, or a function that returns the next column. The column's
267
+ * `id` cannot be changed.
268
+ */
269
+ export function updateColumn<
270
+ TCard extends KanbanCard,
271
+ TColumn extends KanbanColumn<TCard>,
272
+ >(
273
+ board: KanbanBoard<TCard, TColumn>,
274
+ columnId: KanbanId,
275
+ update: Partial<Omit<TColumn, 'id'>> | ((column: TColumn) => TColumn)
276
+ ): KanbanBoard<TCard, TColumn> {
277
+ const index = columnIndexOf(board, columnId);
278
+ if (index === -1) return board;
279
+ const column = board.columns[index]!;
280
+ const next =
281
+ typeof update === 'function'
282
+ ? update(column)
283
+ : ({ ...column, ...update } as TColumn);
284
+ if (next === column) return board;
285
+ const columns = board.columns.slice();
286
+ columns[index] = { ...next, id: column.id };
287
+ return { ...board, columns };
288
+ }
package/src/index.tsx ADDED
@@ -0,0 +1,61 @@
1
+ // Components
2
+ export { Board } from './components/Board';
3
+ export { DefaultCard } from './components/Card';
4
+ export type {
5
+ BoardProps,
6
+ CardRenderInfo,
7
+ ColumnRenderInfo,
8
+ KanbanLabels,
9
+ KanbanStyles,
10
+ } from './components/types';
11
+
12
+ // Board helpers
13
+ export {
14
+ addCard,
15
+ addColumn,
16
+ findCard,
17
+ moveCard,
18
+ moveColumn,
19
+ removeCard,
20
+ removeColumn,
21
+ updateCard,
22
+ updateColumn,
23
+ } from './helpers';
24
+ export type { CardLocation, InsertPosition } from './helpers';
25
+
26
+ // Theming
27
+ export {
28
+ createKanbanTheme,
29
+ darkTheme,
30
+ lightTheme,
31
+ useKanbanTheme,
32
+ } from './theme';
33
+ export type {
34
+ CreateKanbanThemeOptions,
35
+ DeepPartial,
36
+ KanbanColorScheme,
37
+ KanbanDensity,
38
+ KanbanTextStyle,
39
+ KanbanTheme,
40
+ KanbanThemeColors,
41
+ KanbanThemeInput,
42
+ KanbanThemeOverrides,
43
+ KanbanThemePreset,
44
+ KanbanThemeProp,
45
+ KanbanThemeRadius,
46
+ KanbanThemeShadows,
47
+ KanbanThemeSpacing,
48
+ KanbanThemeTypography,
49
+ } from './theme';
50
+
51
+ // Data model
52
+ export type {
53
+ CardDestination,
54
+ CardSource,
55
+ ColumnDestination,
56
+ ColumnSource,
57
+ KanbanBoard,
58
+ KanbanCard,
59
+ KanbanColumn,
60
+ KanbanId,
61
+ } from './types';
@@ -0,0 +1,35 @@
1
+ import { createContext, useContext, useMemo } from 'react';
2
+ import { useColorScheme } from 'react-native';
3
+ import { createKanbanTheme } from './createKanbanTheme';
4
+ import { lightTheme } from './presets';
5
+ import type { KanbanDensity, KanbanTheme, KanbanThemeProp } from './types';
6
+
7
+ const KanbanThemeContext = createContext<KanbanTheme>(lightTheme);
8
+
9
+ export const KanbanThemeProvider = KanbanThemeContext.Provider;
10
+
11
+ /**
12
+ * The board's resolved theme. Use it inside `renderCard` and other render
13
+ * props so custom UI matches the board (including light/dark switching).
14
+ */
15
+ export function useKanbanTheme(): KanbanTheme {
16
+ return useContext(KanbanThemeContext);
17
+ }
18
+
19
+ /** Resolves a theme prop, following the device scheme for `'auto'`. */
20
+ export function useResolvedKanbanTheme(
21
+ theme: KanbanThemeProp | undefined,
22
+ density: KanbanDensity | undefined
23
+ ): KanbanTheme {
24
+ const systemColorScheme = useColorScheme();
25
+ const scheme = systemColorScheme === 'dark' ? 'dark' : 'light';
26
+ // Themes are plain data, so a serialized key keeps the resolved theme stable
27
+ // when callers pass a new inline object with the same values every render.
28
+ const key = typeof theme === 'string' ? theme : JSON.stringify(theme ?? null);
29
+
30
+ return useMemo(
31
+ () => createKanbanTheme(theme, { systemColorScheme: scheme, density }),
32
+ // eslint-disable-next-line react-hooks/exhaustive-deps
33
+ [key, scheme, density]
34
+ );
35
+ }
@@ -0,0 +1,59 @@
1
+ import { darkTheme, densityOverrides, lightTheme } from './presets';
2
+ import type {
3
+ KanbanColorScheme,
4
+ KanbanDensity,
5
+ KanbanTheme,
6
+ KanbanThemeOverrides,
7
+ KanbanThemeProp,
8
+ } from './types';
9
+
10
+ export interface CreateKanbanThemeOptions {
11
+ /** The device scheme, used when the theme is `'auto'`. Defaults to light. */
12
+ systemColorScheme?: KanbanColorScheme | null;
13
+ density?: KanbanDensity;
14
+ }
15
+
16
+ const isPlainObject = (value: unknown): value is Record<string, unknown> =>
17
+ typeof value === 'object' &&
18
+ value !== null &&
19
+ !Array.isArray(value) &&
20
+ Object.getPrototypeOf(value) === Object.prototype;
21
+
22
+ /** Recursively merges plain objects. Arrays and other values are replaced. */
23
+ export function deepMerge<T extends object>(target: T, source: unknown): T {
24
+ if (!isPlainObject(source)) return target;
25
+ const result: Record<string, unknown> = { ...(target as object) };
26
+ for (const [key, value] of Object.entries(source)) {
27
+ if (value === undefined) continue;
28
+ const current = result[key];
29
+ result[key] =
30
+ isPlainObject(value) && isPlainObject(current)
31
+ ? deepMerge(current, value)
32
+ : value;
33
+ }
34
+ return result as T;
35
+ }
36
+
37
+ /**
38
+ * Resolves a theme prop into a complete theme.
39
+ *
40
+ * Order: preset → density → shared overrides → light/dark-only overrides.
41
+ */
42
+ export function createKanbanTheme(
43
+ theme: KanbanThemeProp = 'light',
44
+ options: CreateKanbanThemeOptions = {}
45
+ ): KanbanTheme {
46
+ const density = options.density ?? 'comfortable';
47
+ const input = typeof theme === 'string' ? { base: theme } : theme;
48
+ const { base = 'light', light, dark, ...shared } = input;
49
+
50
+ const scheme: KanbanColorScheme =
51
+ base === 'auto' ? (options.systemColorScheme ?? 'light') : base;
52
+ const preset = scheme === 'dark' ? darkTheme : lightTheme;
53
+
54
+ let resolved = deepMerge(preset, densityOverrides[density]);
55
+ resolved = deepMerge(resolved, shared as KanbanThemeOverrides);
56
+ resolved = deepMerge(resolved, scheme === 'dark' ? dark : light);
57
+
58
+ return { ...resolved, scheme, density };
59
+ }
@@ -0,0 +1,9 @@
1
+ export { createKanbanTheme, deepMerge } from './createKanbanTheme';
2
+ export type { CreateKanbanThemeOptions } from './createKanbanTheme';
3
+ export { darkTheme, lightTheme } from './presets';
4
+ export {
5
+ KanbanThemeProvider,
6
+ useKanbanTheme,
7
+ useResolvedKanbanTheme,
8
+ } from './ThemeContext';
9
+ export type * from './types';
@@ -0,0 +1,100 @@
1
+ import type {
2
+ KanbanDensity,
3
+ KanbanTheme,
4
+ KanbanThemeColors,
5
+ KanbanThemeOverrides,
6
+ } from './types';
7
+
8
+ const lightColors: KanbanThemeColors = {
9
+ background: '#F8FAFC',
10
+ column: '#EEF2F6',
11
+ columnTitle: '#0F172A',
12
+ card: '#FFFFFF',
13
+ cardTitle: '#0F172A',
14
+ cardDescription: '#64748B',
15
+ countBadge: '#E2E8F0',
16
+ countBadgeText: '#475569',
17
+ border: '#E2E8F0',
18
+ accent: '#4F46E5',
19
+ onAccent: '#FFFFFF',
20
+ emptyColumnText: '#94A3B8',
21
+ placeholder: 'rgba(79, 70, 229, 0.10)',
22
+ };
23
+
24
+ const darkColors: KanbanThemeColors = {
25
+ background: '#0B1120',
26
+ column: '#131C2E',
27
+ columnTitle: '#E2E8F0',
28
+ card: '#1E293B',
29
+ cardTitle: '#F1F5F9',
30
+ cardDescription: '#94A3B8',
31
+ countBadge: '#2B3A52',
32
+ countBadgeText: '#CBD5E1',
33
+ border: '#2B3A52',
34
+ accent: '#818CF8',
35
+ onAccent: '#0B1120',
36
+ emptyColumnText: '#64748B',
37
+ placeholder: 'rgba(129, 140, 248, 0.14)',
38
+ };
39
+
40
+ const comfortable: Omit<KanbanTheme, 'scheme' | 'colors' | 'shadows'> = {
41
+ density: 'comfortable',
42
+ spacing: {
43
+ boardPadding: 16,
44
+ columnGap: 12,
45
+ columnPadding: 12,
46
+ cardGap: 8,
47
+ cardPadding: 12,
48
+ },
49
+ radius: { column: 14, card: 10, badge: 999 },
50
+ typography: {
51
+ columnTitle: { fontSize: 15, fontWeight: '600', lineHeight: 20 },
52
+ cardTitle: { fontSize: 15, fontWeight: '500', lineHeight: 20 },
53
+ cardDescription: { fontSize: 13, lineHeight: 18 },
54
+ countBadge: { fontSize: 12, fontWeight: '600', lineHeight: 16 },
55
+ emptyColumn: { fontSize: 13, lineHeight: 18 },
56
+ },
57
+ };
58
+
59
+ /** Spacing and type adjustments applied on top of a preset for each density. */
60
+ export const densityOverrides: Record<KanbanDensity, KanbanThemeOverrides> = {
61
+ comfortable: {},
62
+ compact: {
63
+ spacing: {
64
+ boardPadding: 12,
65
+ columnGap: 8,
66
+ columnPadding: 8,
67
+ cardGap: 6,
68
+ cardPadding: 8,
69
+ },
70
+ radius: { column: 10, card: 8 },
71
+ typography: {
72
+ columnTitle: { fontSize: 14, lineHeight: 18 },
73
+ cardTitle: { fontSize: 13, lineHeight: 18 },
74
+ cardDescription: { fontSize: 12, lineHeight: 16 },
75
+ countBadge: { fontSize: 11, lineHeight: 14 },
76
+ emptyColumn: { fontSize: 12, lineHeight: 16 },
77
+ },
78
+ },
79
+ };
80
+
81
+ export const lightTheme: KanbanTheme = {
82
+ scheme: 'light',
83
+ ...comfortable,
84
+ colors: lightColors,
85
+ shadows: {
86
+ card: {
87
+ boxShadow:
88
+ '0px 1px 2px rgba(15, 23, 42, 0.08), 0px 1px 1px rgba(15, 23, 42, 0.04)',
89
+ },
90
+ },
91
+ };
92
+
93
+ export const darkTheme: KanbanTheme = {
94
+ scheme: 'dark',
95
+ ...comfortable,
96
+ colors: darkColors,
97
+ shadows: {
98
+ card: { boxShadow: '0px 1px 2px rgba(0, 0, 0, 0.45)' },
99
+ },
100
+ };
@@ -0,0 +1,112 @@
1
+ import type { TextStyle, ViewStyle } from 'react-native';
2
+
3
+ export type KanbanColorScheme = 'light' | 'dark';
4
+
5
+ /** `auto` follows the device's light/dark setting. */
6
+ export type KanbanThemePreset = 'light' | 'dark' | 'auto';
7
+
8
+ /** `compact` tightens spacing and type for dense boards. */
9
+ export type KanbanDensity = 'comfortable' | 'compact';
10
+
11
+ export interface KanbanThemeColors {
12
+ /** Board background behind the columns. */
13
+ background: string;
14
+ column: string;
15
+ columnTitle: string;
16
+ card: string;
17
+ cardTitle: string;
18
+ cardDescription: string;
19
+ countBadge: string;
20
+ countBadgeText: string;
21
+ border: string;
22
+ /** Brand color for interactive bits (buttons, focus, drop indicators). */
23
+ accent: string;
24
+ /** Text and icons drawn on top of `accent`. */
25
+ onAccent: string;
26
+ emptyColumnText: string;
27
+ /** Fill for the drop placeholder while dragging (used from 0.2.0). */
28
+ placeholder: string;
29
+ }
30
+
31
+ export interface KanbanThemeSpacing {
32
+ /** Padding around the whole board. */
33
+ boardPadding: number;
34
+ /** Horizontal gap between columns. */
35
+ columnGap: number;
36
+ /** Padding inside each column. */
37
+ columnPadding: number;
38
+ /** Vertical gap between cards. */
39
+ cardGap: number;
40
+ /** Padding inside each card. */
41
+ cardPadding: number;
42
+ }
43
+
44
+ export interface KanbanThemeRadius {
45
+ column: number;
46
+ card: number;
47
+ badge: number;
48
+ }
49
+
50
+ export type KanbanTextStyle = Pick<
51
+ TextStyle,
52
+ | 'fontFamily'
53
+ | 'fontSize'
54
+ | 'fontWeight'
55
+ | 'fontStyle'
56
+ | 'lineHeight'
57
+ | 'letterSpacing'
58
+ | 'textTransform'
59
+ >;
60
+
61
+ export interface KanbanThemeTypography {
62
+ columnTitle: KanbanTextStyle;
63
+ cardTitle: KanbanTextStyle;
64
+ cardDescription: KanbanTextStyle;
65
+ countBadge: KanbanTextStyle;
66
+ emptyColumn: KanbanTextStyle;
67
+ }
68
+
69
+ export interface KanbanThemeShadows {
70
+ card: ViewStyle;
71
+ }
72
+
73
+ /** A fully resolved theme, as returned by `useKanbanTheme()`. */
74
+ export interface KanbanTheme {
75
+ scheme: KanbanColorScheme;
76
+ density: KanbanDensity;
77
+ colors: KanbanThemeColors;
78
+ spacing: KanbanThemeSpacing;
79
+ radius: KanbanThemeRadius;
80
+ typography: KanbanThemeTypography;
81
+ shadows: KanbanThemeShadows;
82
+ }
83
+
84
+ export type DeepPartial<T> = {
85
+ [K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K];
86
+ };
87
+
88
+ export type KanbanThemeTokens = Omit<KanbanTheme, 'scheme' | 'density'>;
89
+
90
+ /** Any subset of theme tokens. Nested objects are merged, not replaced. */
91
+ export type KanbanThemeOverrides = DeepPartial<KanbanThemeTokens>;
92
+
93
+ /**
94
+ * Custom theme for `<Board theme={...} />`.
95
+ *
96
+ * @example
97
+ * theme={{
98
+ * base: 'auto',
99
+ * colors: { accent: '#7C3AED' },
100
+ * dark: { colors: { background: '#000000' } },
101
+ * }}
102
+ */
103
+ export interface KanbanThemeInput extends KanbanThemeOverrides {
104
+ /** Preset to start from. Defaults to `'light'`. */
105
+ base?: KanbanThemePreset;
106
+ /** Overrides applied only when the resolved scheme is light. */
107
+ light?: KanbanThemeOverrides;
108
+ /** Overrides applied only when the resolved scheme is dark. */
109
+ dark?: KanbanThemeOverrides;
110
+ }
111
+
112
+ export type KanbanThemeProp = KanbanThemePreset | KanbanThemeInput;