@messenger-box/slack-ui-browser 10.0.3-alpha.176

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 (61) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE +21 -0
  3. package/lib/components/Home/Channels.js +62 -0
  4. package/lib/components/Home/Channels.js.map +1 -0
  5. package/lib/components/Home/DirectChannels.js +92 -0
  6. package/lib/components/Home/DirectChannels.js.map +1 -0
  7. package/lib/components/Home/InviteMembers.js +70 -0
  8. package/lib/components/Home/InviteMembers.js.map +1 -0
  9. package/lib/components/Home/Teams.js +62 -0
  10. package/lib/components/Home/Teams.js.map +1 -0
  11. package/lib/components/Home/TopCommonSlider.js +35 -0
  12. package/lib/components/Home/TopCommonSlider.js.map +1 -0
  13. package/lib/compute.js +223 -0
  14. package/lib/compute.js.map +1 -0
  15. package/lib/constants/routes.js +63 -0
  16. package/lib/constants/routes.js.map +1 -0
  17. package/lib/hooks/useOptimizedChannelsQueries.js +107 -0
  18. package/lib/hooks/useOptimizedChannelsQueries.js.map +1 -0
  19. package/lib/hooks/useRouteState.js +193 -0
  20. package/lib/hooks/useRouteState.js.map +1 -0
  21. package/lib/index.js +1 -0
  22. package/lib/index.js.map +1 -0
  23. package/lib/machines/routeMachine.js +804 -0
  24. package/lib/machines/routeMachine.js.map +1 -0
  25. package/lib/module.js +3 -0
  26. package/lib/module.js.map +1 -0
  27. package/lib/queries/slackuiQueries.js +144 -0
  28. package/lib/queries/slackuiQueries.js.map +1 -0
  29. package/lib/routes.json +260 -0
  30. package/lib/screens/Home/HomeScreen.js +664 -0
  31. package/lib/screens/Home/HomeScreen.js.map +1 -0
  32. package/lib/screens/Home/index.js +1 -0
  33. package/lib/screens/Home/index.js.map +1 -0
  34. package/package.json +52 -0
  35. package/rollup.config.mjs +41 -0
  36. package/src/components/Home/Channels.tsx +135 -0
  37. package/src/components/Home/DirectChannels.tsx +185 -0
  38. package/src/components/Home/InviteMembers.tsx +134 -0
  39. package/src/components/Home/Teams.tsx +129 -0
  40. package/src/components/Home/TopCommonSlider.tsx +70 -0
  41. package/src/components/Home/index.ts +5 -0
  42. package/src/components/index.ts +1 -0
  43. package/src/compute.ts +156 -0
  44. package/src/constants/index.ts +1 -0
  45. package/src/constants/routes.ts +92 -0
  46. package/src/hooks/index.ts +3 -0
  47. package/src/hooks/useOptimizedChannelsQueries.ts +165 -0
  48. package/src/hooks/useRouteState.ts +253 -0
  49. package/src/icons.ts +137 -0
  50. package/src/index.ts +11 -0
  51. package/src/machines/index.ts +9 -0
  52. package/src/machines/routeMachine.ts +682 -0
  53. package/src/module.tsx +6 -0
  54. package/src/queries/index.ts +1 -0
  55. package/src/queries/slackuiQueries.ts +227 -0
  56. package/src/screens/Home/HomeScreen.tsx +1308 -0
  57. package/src/screens/Home/index.ts +4 -0
  58. package/src/screens/NewChannel/NewChannelScreen.tsx +188 -0
  59. package/src/screens/NewChannel/index.ts +2 -0
  60. package/src/screens/index.ts +1 -0
  61. package/tsconfig.json +21 -0
@@ -0,0 +1,682 @@
1
+ import { assign, setup } from 'xstate';
2
+ import { SLACK_UI_ROUTES, SLACK_UI_ROUTE_KEYS, slackUiRoutePaths } from '../constants/routes';
3
+
4
+ /**
5
+ * Route States Enum - matches SLACK_UI_ROUTES
6
+ * Note: Using underscores instead of dots to avoid XState hierarchical state interpretation
7
+ */
8
+ export const enum RouteState {
9
+ Idle = 'idle',
10
+ Home = 'home',
11
+ ChannelsView = 'channelsView',
12
+ ChannelsNew = 'channelsNew',
13
+ MessagesView = 'messagesView',
14
+ MessagesNew = 'messagesNew',
15
+ TeamsView = 'teamsView',
16
+ TeamsNew = 'teamsNew',
17
+ Threads = 'threads',
18
+ Activity = 'activity',
19
+ Drafts = 'drafts',
20
+ Saved = 'saved',
21
+ Files = 'files',
22
+ Search = 'search',
23
+ Invite = 'invite',
24
+ InviteContacts = 'inviteContacts',
25
+ InviteEmail = 'inviteEmail',
26
+ InviteLink = 'inviteLink',
27
+ }
28
+
29
+ /**
30
+ * Route Actions Enum
31
+ */
32
+ export const enum RouteAction {
33
+ NAVIGATE_HOME = 'NAVIGATE_HOME',
34
+ NAVIGATE_CHANNEL = 'NAVIGATE_CHANNEL',
35
+ NAVIGATE_CHANNEL_NEW = 'NAVIGATE_CHANNEL_NEW',
36
+ NAVIGATE_MESSAGE = 'NAVIGATE_MESSAGE',
37
+ NAVIGATE_MESSAGE_NEW = 'NAVIGATE_MESSAGE_NEW',
38
+ NAVIGATE_TEAM = 'NAVIGATE_TEAM',
39
+ NAVIGATE_TEAM_NEW = 'NAVIGATE_TEAM_NEW',
40
+ NAVIGATE_THREADS = 'NAVIGATE_THREADS',
41
+ NAVIGATE_ACTIVITY = 'NAVIGATE_ACTIVITY',
42
+ NAVIGATE_DRAFTS = 'NAVIGATE_DRAFTS',
43
+ NAVIGATE_SAVED = 'NAVIGATE_SAVED',
44
+ NAVIGATE_FILES = 'NAVIGATE_FILES',
45
+ NAVIGATE_SEARCH = 'NAVIGATE_SEARCH',
46
+ NAVIGATE_INVITE = 'NAVIGATE_INVITE',
47
+ NAVIGATE_INVITE_CONTACTS = 'NAVIGATE_INVITE_CONTACTS',
48
+ NAVIGATE_INVITE_EMAIL = 'NAVIGATE_INVITE_EMAIL',
49
+ NAVIGATE_INVITE_LINK = 'NAVIGATE_INVITE_LINK',
50
+ UPDATE_FROM_PATHNAME = 'UPDATE_FROM_PATHNAME',
51
+ }
52
+
53
+ /**
54
+ * Route Context Type
55
+ */
56
+ export interface RouteContext {
57
+ orgSlug: string;
58
+ currentPath: string;
59
+ currentRouteKey: string | null;
60
+ channelName: string | null;
61
+ teamName: string | null;
62
+ previousPath: string | null;
63
+ }
64
+
65
+ /**
66
+ * Route Event Types
67
+ */
68
+ export type RouteEvent =
69
+ | { type: RouteAction.NAVIGATE_HOME }
70
+ | { type: RouteAction.NAVIGATE_CHANNEL; channelName: string }
71
+ | { type: RouteAction.NAVIGATE_CHANNEL_NEW }
72
+ | { type: RouteAction.NAVIGATE_MESSAGE; channelName: string }
73
+ | { type: RouteAction.NAVIGATE_MESSAGE_NEW }
74
+ | { type: RouteAction.NAVIGATE_TEAM; teamName: string }
75
+ | { type: RouteAction.NAVIGATE_TEAM_NEW }
76
+ | { type: RouteAction.NAVIGATE_THREADS }
77
+ | { type: RouteAction.NAVIGATE_ACTIVITY }
78
+ | { type: RouteAction.NAVIGATE_DRAFTS }
79
+ | { type: RouteAction.NAVIGATE_SAVED }
80
+ | { type: RouteAction.NAVIGATE_FILES }
81
+ | { type: RouteAction.NAVIGATE_SEARCH }
82
+ | { type: RouteAction.NAVIGATE_INVITE }
83
+ | { type: RouteAction.NAVIGATE_INVITE_CONTACTS }
84
+ | { type: RouteAction.NAVIGATE_INVITE_EMAIL }
85
+ | { type: RouteAction.NAVIGATE_INVITE_LINK }
86
+ | { type: RouteAction.UPDATE_FROM_PATHNAME; pathname: string };
87
+
88
+ /**
89
+ * Parse pathname to determine current route state and context
90
+ */
91
+ export function parsePathname(pathname: string, orgSlug: string): {
92
+ state: RouteState;
93
+ routeKey: string | null;
94
+ channelName: string | null;
95
+ teamName: string | null;
96
+ } {
97
+ const basePath = `/o/${orgSlug}/home`;
98
+
99
+ // Check each route pattern
100
+ if (pathname.endsWith('/channels/new')) {
101
+ return { state: RouteState.ChannelsNew, routeKey: SLACK_UI_ROUTE_KEYS.CHANNELS_NEW, channelName: null, teamName: null };
102
+ }
103
+ if (pathname.includes('/channels/')) {
104
+ const match = pathname.match(/\/channels\/([^/]+)$/);
105
+ return {
106
+ state: RouteState.ChannelsView,
107
+ routeKey: SLACK_UI_ROUTE_KEYS.CHANNELS,
108
+ channelName: match?.[1] || null,
109
+ teamName: null
110
+ };
111
+ }
112
+ if (pathname.endsWith('/messages/new')) {
113
+ return { state: RouteState.MessagesNew, routeKey: SLACK_UI_ROUTE_KEYS.MESSAGES_NEW, channelName: null, teamName: null };
114
+ }
115
+ if (pathname.includes('/messages/')) {
116
+ const match = pathname.match(/\/messages\/([^/]+)$/);
117
+ return {
118
+ state: RouteState.MessagesView,
119
+ routeKey: SLACK_UI_ROUTE_KEYS.MESSAGES,
120
+ channelName: match?.[1] || null,
121
+ teamName: null
122
+ };
123
+ }
124
+ if (pathname.endsWith('/teams/new')) {
125
+ return { state: RouteState.TeamsNew, routeKey: SLACK_UI_ROUTE_KEYS.TEAMS_NEW, channelName: null, teamName: null };
126
+ }
127
+ if (pathname.includes('/teams/')) {
128
+ const match = pathname.match(/\/teams\/([^/]+)$/);
129
+ return {
130
+ state: RouteState.TeamsView,
131
+ routeKey: SLACK_UI_ROUTE_KEYS.TEAMS,
132
+ channelName: null,
133
+ teamName: match?.[1] || null
134
+ };
135
+ }
136
+ if (pathname.endsWith('/invite/contacts')) {
137
+ return { state: RouteState.InviteContacts, routeKey: SLACK_UI_ROUTE_KEYS.INVITE_CONTACTS, channelName: null, teamName: null };
138
+ }
139
+ if (pathname.endsWith('/invite/email')) {
140
+ return { state: RouteState.InviteEmail, routeKey: SLACK_UI_ROUTE_KEYS.INVITE_EMAIL, channelName: null, teamName: null };
141
+ }
142
+ if (pathname.endsWith('/invite/link')) {
143
+ return { state: RouteState.InviteLink, routeKey: SLACK_UI_ROUTE_KEYS.INVITE_LINK, channelName: null, teamName: null };
144
+ }
145
+ if (pathname.includes('/invite')) {
146
+ return { state: RouteState.Invite, routeKey: SLACK_UI_ROUTE_KEYS.INVITE, channelName: null, teamName: null };
147
+ }
148
+ if (pathname.endsWith('/threads')) {
149
+ return { state: RouteState.Threads, routeKey: SLACK_UI_ROUTE_KEYS.THREADS, channelName: null, teamName: null };
150
+ }
151
+ if (pathname.endsWith('/activity')) {
152
+ return { state: RouteState.Activity, routeKey: SLACK_UI_ROUTE_KEYS.ACTIVITY, channelName: null, teamName: null };
153
+ }
154
+ if (pathname.endsWith('/drafts')) {
155
+ return { state: RouteState.Drafts, routeKey: SLACK_UI_ROUTE_KEYS.DRAFTS, channelName: null, teamName: null };
156
+ }
157
+ if (pathname.endsWith('/saved')) {
158
+ return { state: RouteState.Saved, routeKey: SLACK_UI_ROUTE_KEYS.SAVED, channelName: null, teamName: null };
159
+ }
160
+ if (pathname.endsWith('/files')) {
161
+ return { state: RouteState.Files, routeKey: SLACK_UI_ROUTE_KEYS.FILES, channelName: null, teamName: null };
162
+ }
163
+ if (pathname.endsWith('/search')) {
164
+ return { state: RouteState.Search, routeKey: SLACK_UI_ROUTE_KEYS.SEARCH, channelName: null, teamName: null };
165
+ }
166
+
167
+ // Default to Home
168
+ return { state: RouteState.Home, routeKey: SLACK_UI_ROUTE_KEYS.HOME, channelName: null, teamName: null };
169
+ }
170
+
171
+ /**
172
+ * Get the path for a given route state
173
+ */
174
+ export function getPathForRouteState(
175
+ state: RouteState,
176
+ orgSlug: string,
177
+ params?: { channelName?: string; teamName?: string }
178
+ ): string {
179
+ switch (state) {
180
+ case RouteState.Home:
181
+ case RouteState.Idle:
182
+ return slackUiRoutePaths.home(orgSlug);
183
+ case RouteState.ChannelsNew:
184
+ return slackUiRoutePaths.channelNew(orgSlug);
185
+ case RouteState.ChannelsView:
186
+ return slackUiRoutePaths.channel(orgSlug, params?.channelName || '');
187
+ case RouteState.MessagesNew:
188
+ return slackUiRoutePaths.messageNew(orgSlug);
189
+ case RouteState.MessagesView:
190
+ return slackUiRoutePaths.message(orgSlug, params?.channelName || '');
191
+ case RouteState.TeamsNew:
192
+ return slackUiRoutePaths.teamNew(orgSlug);
193
+ case RouteState.TeamsView:
194
+ return slackUiRoutePaths.team(orgSlug, params?.teamName || '');
195
+ case RouteState.Threads:
196
+ return slackUiRoutePaths.threads(orgSlug);
197
+ case RouteState.Activity:
198
+ return slackUiRoutePaths.activity(orgSlug);
199
+ case RouteState.Drafts:
200
+ return slackUiRoutePaths.drafts(orgSlug);
201
+ case RouteState.Saved:
202
+ return slackUiRoutePaths.saved(orgSlug);
203
+ case RouteState.Files:
204
+ return slackUiRoutePaths.files(orgSlug);
205
+ case RouteState.Search:
206
+ return slackUiRoutePaths.search(orgSlug);
207
+ case RouteState.Invite:
208
+ return slackUiRoutePaths.invite(orgSlug);
209
+ case RouteState.InviteContacts:
210
+ return slackUiRoutePaths.inviteContacts(orgSlug);
211
+ case RouteState.InviteEmail:
212
+ return slackUiRoutePaths.inviteEmail(orgSlug);
213
+ case RouteState.InviteLink:
214
+ return slackUiRoutePaths.inviteLink(orgSlug);
215
+ default:
216
+ return slackUiRoutePaths.home(orgSlug);
217
+ }
218
+ }
219
+
220
+ /**
221
+ * Slack UI Route Machine
222
+ * Manages navigation state for the slack-ui browser package
223
+ */
224
+ export const routeMachine = setup({
225
+ types: {
226
+ context: {} as RouteContext,
227
+ events: {} as RouteEvent,
228
+ },
229
+ actions: {
230
+ updateContext: assign(({ context, event }) => {
231
+ if (event.type === RouteAction.UPDATE_FROM_PATHNAME) {
232
+ const parsed = parsePathname(event.pathname, context.orgSlug);
233
+ return {
234
+ ...context,
235
+ previousPath: context.currentPath,
236
+ currentPath: event.pathname,
237
+ currentRouteKey: parsed.routeKey,
238
+ channelName: parsed.channelName,
239
+ teamName: parsed.teamName,
240
+ };
241
+ }
242
+ return context;
243
+ }),
244
+ setChannelName: assign(({ context, event }) => {
245
+ if (event.type === RouteAction.NAVIGATE_CHANNEL) {
246
+ return {
247
+ ...context,
248
+ channelName: event.channelName,
249
+ currentPath: slackUiRoutePaths.channel(context.orgSlug, event.channelName),
250
+ currentRouteKey: SLACK_UI_ROUTE_KEYS.CHANNELS,
251
+ };
252
+ }
253
+ return context;
254
+ }),
255
+ setMessageChannelName: assign(({ context, event }) => {
256
+ if (event.type === RouteAction.NAVIGATE_MESSAGE) {
257
+ return {
258
+ ...context,
259
+ channelName: event.channelName,
260
+ currentPath: slackUiRoutePaths.message(context.orgSlug, event.channelName),
261
+ currentRouteKey: SLACK_UI_ROUTE_KEYS.MESSAGES,
262
+ };
263
+ }
264
+ return context;
265
+ }),
266
+ setTeamName: assign(({ context, event }) => {
267
+ if (event.type === RouteAction.NAVIGATE_TEAM) {
268
+ return {
269
+ ...context,
270
+ teamName: event.teamName,
271
+ currentPath: slackUiRoutePaths.team(context.orgSlug, event.teamName),
272
+ currentRouteKey: SLACK_UI_ROUTE_KEYS.TEAMS,
273
+ };
274
+ }
275
+ return context;
276
+ }),
277
+ clearParams: assign(({ context }) => ({
278
+ ...context,
279
+ channelName: null,
280
+ teamName: null,
281
+ })),
282
+ updatePathToHome: assign(({ context }) => ({
283
+ ...context,
284
+ previousPath: context.currentPath,
285
+ currentPath: slackUiRoutePaths.home(context.orgSlug),
286
+ currentRouteKey: SLACK_UI_ROUTE_KEYS.HOME,
287
+ })),
288
+ updatePathToChannelNew: assign(({ context }) => ({
289
+ ...context,
290
+ previousPath: context.currentPath,
291
+ currentPath: slackUiRoutePaths.channelNew(context.orgSlug),
292
+ currentRouteKey: SLACK_UI_ROUTE_KEYS.CHANNELS_NEW,
293
+ channelName: null,
294
+ })),
295
+ updatePathToMessageNew: assign(({ context }) => ({
296
+ ...context,
297
+ previousPath: context.currentPath,
298
+ currentPath: slackUiRoutePaths.messageNew(context.orgSlug),
299
+ currentRouteKey: SLACK_UI_ROUTE_KEYS.MESSAGES_NEW,
300
+ channelName: null,
301
+ })),
302
+ updatePathToTeamNew: assign(({ context }) => ({
303
+ ...context,
304
+ previousPath: context.currentPath,
305
+ currentPath: slackUiRoutePaths.teamNew(context.orgSlug),
306
+ currentRouteKey: SLACK_UI_ROUTE_KEYS.TEAMS_NEW,
307
+ teamName: null,
308
+ })),
309
+ updatePathToThreads: assign(({ context }) => ({
310
+ ...context,
311
+ previousPath: context.currentPath,
312
+ currentPath: slackUiRoutePaths.threads(context.orgSlug),
313
+ currentRouteKey: SLACK_UI_ROUTE_KEYS.THREADS,
314
+ })),
315
+ updatePathToActivity: assign(({ context }) => ({
316
+ ...context,
317
+ previousPath: context.currentPath,
318
+ currentPath: slackUiRoutePaths.activity(context.orgSlug),
319
+ currentRouteKey: SLACK_UI_ROUTE_KEYS.ACTIVITY,
320
+ })),
321
+ updatePathToDrafts: assign(({ context }) => ({
322
+ ...context,
323
+ previousPath: context.currentPath,
324
+ currentPath: slackUiRoutePaths.drafts(context.orgSlug),
325
+ currentRouteKey: SLACK_UI_ROUTE_KEYS.DRAFTS,
326
+ })),
327
+ updatePathToSaved: assign(({ context }) => ({
328
+ ...context,
329
+ previousPath: context.currentPath,
330
+ currentPath: slackUiRoutePaths.saved(context.orgSlug),
331
+ currentRouteKey: SLACK_UI_ROUTE_KEYS.SAVED,
332
+ })),
333
+ updatePathToFiles: assign(({ context }) => ({
334
+ ...context,
335
+ previousPath: context.currentPath,
336
+ currentPath: slackUiRoutePaths.files(context.orgSlug),
337
+ currentRouteKey: SLACK_UI_ROUTE_KEYS.FILES,
338
+ })),
339
+ updatePathToSearch: assign(({ context }) => ({
340
+ ...context,
341
+ previousPath: context.currentPath,
342
+ currentPath: slackUiRoutePaths.search(context.orgSlug),
343
+ currentRouteKey: SLACK_UI_ROUTE_KEYS.SEARCH,
344
+ })),
345
+ updatePathToInvite: assign(({ context }) => ({
346
+ ...context,
347
+ previousPath: context.currentPath,
348
+ currentPath: slackUiRoutePaths.invite(context.orgSlug),
349
+ currentRouteKey: SLACK_UI_ROUTE_KEYS.INVITE,
350
+ })),
351
+ updatePathToInviteContacts: assign(({ context }) => ({
352
+ ...context,
353
+ previousPath: context.currentPath,
354
+ currentPath: slackUiRoutePaths.inviteContacts(context.orgSlug),
355
+ currentRouteKey: SLACK_UI_ROUTE_KEYS.INVITE_CONTACTS,
356
+ })),
357
+ updatePathToInviteEmail: assign(({ context }) => ({
358
+ ...context,
359
+ previousPath: context.currentPath,
360
+ currentPath: slackUiRoutePaths.inviteEmail(context.orgSlug),
361
+ currentRouteKey: SLACK_UI_ROUTE_KEYS.INVITE_EMAIL,
362
+ })),
363
+ updatePathToInviteLink: assign(({ context }) => ({
364
+ ...context,
365
+ previousPath: context.currentPath,
366
+ currentPath: slackUiRoutePaths.inviteLink(context.orgSlug),
367
+ currentRouteKey: SLACK_UI_ROUTE_KEYS.INVITE_LINK,
368
+ })),
369
+ },
370
+ guards: {
371
+ hasChannelName: ({ event }) => {
372
+ if (event.type === RouteAction.NAVIGATE_CHANNEL) {
373
+ return !!event.channelName;
374
+ }
375
+ return false;
376
+ },
377
+ hasTeamName: ({ event }) => {
378
+ if (event.type === RouteAction.NAVIGATE_TEAM) {
379
+ return !!event.teamName;
380
+ }
381
+ return false;
382
+ },
383
+ },
384
+ }).createMachine({
385
+ id: 'slack-ui-routes',
386
+ initial: RouteState.Idle,
387
+ context: {
388
+ orgSlug: '',
389
+ currentPath: '',
390
+ currentRouteKey: null,
391
+ channelName: null,
392
+ teamName: null,
393
+ previousPath: null,
394
+ },
395
+ states: {
396
+ [RouteState.Idle]: {
397
+ on: {
398
+ [RouteAction.UPDATE_FROM_PATHNAME]: {
399
+ actions: ['updateContext'],
400
+ },
401
+ [RouteAction.NAVIGATE_HOME]: {
402
+ target: RouteState.Home,
403
+ actions: ['clearParams', 'updatePathToHome'],
404
+ },
405
+ [RouteAction.NAVIGATE_CHANNEL]: {
406
+ target: RouteState.ChannelsView,
407
+ guard: 'hasChannelName',
408
+ actions: ['setChannelName'],
409
+ },
410
+ [RouteAction.NAVIGATE_CHANNEL_NEW]: {
411
+ target: RouteState.ChannelsNew,
412
+ actions: ['updatePathToChannelNew'],
413
+ },
414
+ [RouteAction.NAVIGATE_MESSAGE]: {
415
+ target: RouteState.MessagesView,
416
+ actions: ['setMessageChannelName'],
417
+ },
418
+ [RouteAction.NAVIGATE_MESSAGE_NEW]: {
419
+ target: RouteState.MessagesNew,
420
+ actions: ['updatePathToMessageNew'],
421
+ },
422
+ [RouteAction.NAVIGATE_TEAM]: {
423
+ target: RouteState.TeamsView,
424
+ guard: 'hasTeamName',
425
+ actions: ['setTeamName'],
426
+ },
427
+ [RouteAction.NAVIGATE_TEAM_NEW]: {
428
+ target: RouteState.TeamsNew,
429
+ actions: ['updatePathToTeamNew'],
430
+ },
431
+ [RouteAction.NAVIGATE_THREADS]: {
432
+ target: RouteState.Threads,
433
+ actions: ['updatePathToThreads'],
434
+ },
435
+ [RouteAction.NAVIGATE_ACTIVITY]: {
436
+ target: RouteState.Activity,
437
+ actions: ['updatePathToActivity'],
438
+ },
439
+ [RouteAction.NAVIGATE_DRAFTS]: {
440
+ target: RouteState.Drafts,
441
+ actions: ['updatePathToDrafts'],
442
+ },
443
+ [RouteAction.NAVIGATE_SAVED]: {
444
+ target: RouteState.Saved,
445
+ actions: ['updatePathToSaved'],
446
+ },
447
+ [RouteAction.NAVIGATE_FILES]: {
448
+ target: RouteState.Files,
449
+ actions: ['updatePathToFiles'],
450
+ },
451
+ [RouteAction.NAVIGATE_SEARCH]: {
452
+ target: RouteState.Search,
453
+ actions: ['updatePathToSearch'],
454
+ },
455
+ [RouteAction.NAVIGATE_INVITE]: {
456
+ target: RouteState.Invite,
457
+ actions: ['updatePathToInvite'],
458
+ },
459
+ [RouteAction.NAVIGATE_INVITE_CONTACTS]: {
460
+ target: RouteState.InviteContacts,
461
+ actions: ['updatePathToInviteContacts'],
462
+ },
463
+ [RouteAction.NAVIGATE_INVITE_EMAIL]: {
464
+ target: RouteState.InviteEmail,
465
+ actions: ['updatePathToInviteEmail'],
466
+ },
467
+ [RouteAction.NAVIGATE_INVITE_LINK]: {
468
+ target: RouteState.InviteLink,
469
+ actions: ['updatePathToInviteLink'],
470
+ },
471
+ },
472
+ },
473
+ [RouteState.Home]: {
474
+ on: {
475
+ [RouteAction.UPDATE_FROM_PATHNAME]: {
476
+ actions: ['updateContext'],
477
+ },
478
+ [RouteAction.NAVIGATE_CHANNEL]: {
479
+ target: RouteState.ChannelsView,
480
+ guard: 'hasChannelName',
481
+ actions: ['setChannelName'],
482
+ },
483
+ [RouteAction.NAVIGATE_CHANNEL_NEW]: {
484
+ target: RouteState.ChannelsNew,
485
+ actions: ['updatePathToChannelNew'],
486
+ },
487
+ [RouteAction.NAVIGATE_MESSAGE]: {
488
+ target: RouteState.MessagesView,
489
+ actions: ['setMessageChannelName'],
490
+ },
491
+ [RouteAction.NAVIGATE_MESSAGE_NEW]: {
492
+ target: RouteState.MessagesNew,
493
+ actions: ['updatePathToMessageNew'],
494
+ },
495
+ [RouteAction.NAVIGATE_TEAM]: {
496
+ target: RouteState.TeamsView,
497
+ guard: 'hasTeamName',
498
+ actions: ['setTeamName'],
499
+ },
500
+ [RouteAction.NAVIGATE_TEAM_NEW]: {
501
+ target: RouteState.TeamsNew,
502
+ actions: ['updatePathToTeamNew'],
503
+ },
504
+ [RouteAction.NAVIGATE_THREADS]: {
505
+ target: RouteState.Threads,
506
+ actions: ['updatePathToThreads'],
507
+ },
508
+ [RouteAction.NAVIGATE_ACTIVITY]: {
509
+ target: RouteState.Activity,
510
+ actions: ['updatePathToActivity'],
511
+ },
512
+ [RouteAction.NAVIGATE_DRAFTS]: {
513
+ target: RouteState.Drafts,
514
+ actions: ['updatePathToDrafts'],
515
+ },
516
+ [RouteAction.NAVIGATE_SAVED]: {
517
+ target: RouteState.Saved,
518
+ actions: ['updatePathToSaved'],
519
+ },
520
+ [RouteAction.NAVIGATE_FILES]: {
521
+ target: RouteState.Files,
522
+ actions: ['updatePathToFiles'],
523
+ },
524
+ [RouteAction.NAVIGATE_SEARCH]: {
525
+ target: RouteState.Search,
526
+ actions: ['updatePathToSearch'],
527
+ },
528
+ [RouteAction.NAVIGATE_INVITE]: {
529
+ target: RouteState.Invite,
530
+ actions: ['updatePathToInvite'],
531
+ },
532
+ [RouteAction.NAVIGATE_INVITE_CONTACTS]: {
533
+ target: RouteState.InviteContacts,
534
+ actions: ['updatePathToInviteContacts'],
535
+ },
536
+ [RouteAction.NAVIGATE_INVITE_EMAIL]: {
537
+ target: RouteState.InviteEmail,
538
+ actions: ['updatePathToInviteEmail'],
539
+ },
540
+ [RouteAction.NAVIGATE_INVITE_LINK]: {
541
+ target: RouteState.InviteLink,
542
+ actions: ['updatePathToInviteLink'],
543
+ },
544
+ },
545
+ },
546
+ [RouteState.ChannelsView]: {
547
+ on: {
548
+ [RouteAction.UPDATE_FROM_PATHNAME]: { actions: ['updateContext'] },
549
+ [RouteAction.NAVIGATE_HOME]: { target: RouteState.Home, actions: ['clearParams', 'updatePathToHome'] },
550
+ [RouteAction.NAVIGATE_CHANNEL]: { actions: ['setChannelName'] },
551
+ [RouteAction.NAVIGATE_CHANNEL_NEW]: { target: RouteState.ChannelsNew, actions: ['updatePathToChannelNew'] },
552
+ [RouteAction.NAVIGATE_MESSAGE]: { target: RouteState.MessagesView, actions: ['setMessageChannelName'] },
553
+ [RouteAction.NAVIGATE_MESSAGE_NEW]: { target: RouteState.MessagesNew, actions: ['updatePathToMessageNew'] },
554
+ },
555
+ },
556
+ [RouteState.ChannelsNew]: {
557
+ on: {
558
+ [RouteAction.UPDATE_FROM_PATHNAME]: { actions: ['updateContext'] },
559
+ [RouteAction.NAVIGATE_HOME]: { target: RouteState.Home, actions: ['clearParams', 'updatePathToHome'] },
560
+ [RouteAction.NAVIGATE_CHANNEL]: { target: RouteState.ChannelsView, actions: ['setChannelName'] },
561
+ },
562
+ },
563
+ [RouteState.MessagesView]: {
564
+ on: {
565
+ [RouteAction.UPDATE_FROM_PATHNAME]: { actions: ['updateContext'] },
566
+ [RouteAction.NAVIGATE_HOME]: { target: RouteState.Home, actions: ['clearParams', 'updatePathToHome'] },
567
+ [RouteAction.NAVIGATE_CHANNEL]: { target: RouteState.ChannelsView, actions: ['setChannelName'] },
568
+ [RouteAction.NAVIGATE_MESSAGE]: { actions: ['setMessageChannelName'] },
569
+ [RouteAction.NAVIGATE_MESSAGE_NEW]: { target: RouteState.MessagesNew, actions: ['updatePathToMessageNew'] },
570
+ },
571
+ },
572
+ [RouteState.MessagesNew]: {
573
+ on: {
574
+ [RouteAction.UPDATE_FROM_PATHNAME]: { actions: ['updateContext'] },
575
+ [RouteAction.NAVIGATE_HOME]: { target: RouteState.Home, actions: ['clearParams', 'updatePathToHome'] },
576
+ [RouteAction.NAVIGATE_MESSAGE]: { target: RouteState.MessagesView, actions: ['setMessageChannelName'] },
577
+ },
578
+ },
579
+ [RouteState.TeamsView]: {
580
+ on: {
581
+ [RouteAction.UPDATE_FROM_PATHNAME]: { actions: ['updateContext'] },
582
+ [RouteAction.NAVIGATE_HOME]: { target: RouteState.Home, actions: ['clearParams', 'updatePathToHome'] },
583
+ [RouteAction.NAVIGATE_TEAM]: { actions: ['setTeamName'] },
584
+ [RouteAction.NAVIGATE_TEAM_NEW]: { target: RouteState.TeamsNew, actions: ['updatePathToTeamNew'] },
585
+ },
586
+ },
587
+ [RouteState.TeamsNew]: {
588
+ on: {
589
+ [RouteAction.UPDATE_FROM_PATHNAME]: { actions: ['updateContext'] },
590
+ [RouteAction.NAVIGATE_HOME]: { target: RouteState.Home, actions: ['clearParams', 'updatePathToHome'] },
591
+ [RouteAction.NAVIGATE_TEAM]: { target: RouteState.TeamsView, actions: ['setTeamName'] },
592
+ },
593
+ },
594
+ [RouteState.Threads]: {
595
+ on: {
596
+ [RouteAction.UPDATE_FROM_PATHNAME]: { actions: ['updateContext'] },
597
+ [RouteAction.NAVIGATE_HOME]: { target: RouteState.Home, actions: ['clearParams', 'updatePathToHome'] },
598
+ [RouteAction.NAVIGATE_CHANNEL]: { target: RouteState.ChannelsView, actions: ['setChannelName'] },
599
+ [RouteAction.NAVIGATE_MESSAGE]: { target: RouteState.MessagesView, actions: ['setMessageChannelName'] },
600
+ },
601
+ },
602
+ [RouteState.Activity]: {
603
+ on: {
604
+ [RouteAction.UPDATE_FROM_PATHNAME]: { actions: ['updateContext'] },
605
+ [RouteAction.NAVIGATE_HOME]: { target: RouteState.Home, actions: ['clearParams', 'updatePathToHome'] },
606
+ },
607
+ },
608
+ [RouteState.Drafts]: {
609
+ on: {
610
+ [RouteAction.UPDATE_FROM_PATHNAME]: { actions: ['updateContext'] },
611
+ [RouteAction.NAVIGATE_HOME]: { target: RouteState.Home, actions: ['clearParams', 'updatePathToHome'] },
612
+ },
613
+ },
614
+ [RouteState.Saved]: {
615
+ on: {
616
+ [RouteAction.UPDATE_FROM_PATHNAME]: { actions: ['updateContext'] },
617
+ [RouteAction.NAVIGATE_HOME]: { target: RouteState.Home, actions: ['clearParams', 'updatePathToHome'] },
618
+ },
619
+ },
620
+ [RouteState.Files]: {
621
+ on: {
622
+ [RouteAction.UPDATE_FROM_PATHNAME]: { actions: ['updateContext'] },
623
+ [RouteAction.NAVIGATE_HOME]: { target: RouteState.Home, actions: ['clearParams', 'updatePathToHome'] },
624
+ },
625
+ },
626
+ [RouteState.Search]: {
627
+ on: {
628
+ [RouteAction.UPDATE_FROM_PATHNAME]: { actions: ['updateContext'] },
629
+ [RouteAction.NAVIGATE_HOME]: { target: RouteState.Home, actions: ['clearParams', 'updatePathToHome'] },
630
+ },
631
+ },
632
+ [RouteState.Invite]: {
633
+ on: {
634
+ [RouteAction.UPDATE_FROM_PATHNAME]: { actions: ['updateContext'] },
635
+ [RouteAction.NAVIGATE_HOME]: { target: RouteState.Home, actions: ['clearParams', 'updatePathToHome'] },
636
+ [RouteAction.NAVIGATE_INVITE_CONTACTS]: { target: RouteState.InviteContacts, actions: ['updatePathToInviteContacts'] },
637
+ [RouteAction.NAVIGATE_INVITE_EMAIL]: { target: RouteState.InviteEmail, actions: ['updatePathToInviteEmail'] },
638
+ [RouteAction.NAVIGATE_INVITE_LINK]: { target: RouteState.InviteLink, actions: ['updatePathToInviteLink'] },
639
+ },
640
+ },
641
+ [RouteState.InviteContacts]: {
642
+ on: {
643
+ [RouteAction.UPDATE_FROM_PATHNAME]: { actions: ['updateContext'] },
644
+ [RouteAction.NAVIGATE_HOME]: { target: RouteState.Home, actions: ['clearParams', 'updatePathToHome'] },
645
+ [RouteAction.NAVIGATE_INVITE]: { target: RouteState.Invite, actions: ['updatePathToInvite'] },
646
+ },
647
+ },
648
+ [RouteState.InviteEmail]: {
649
+ on: {
650
+ [RouteAction.UPDATE_FROM_PATHNAME]: { actions: ['updateContext'] },
651
+ [RouteAction.NAVIGATE_HOME]: { target: RouteState.Home, actions: ['clearParams', 'updatePathToHome'] },
652
+ [RouteAction.NAVIGATE_INVITE]: { target: RouteState.Invite, actions: ['updatePathToInvite'] },
653
+ },
654
+ },
655
+ [RouteState.InviteLink]: {
656
+ on: {
657
+ [RouteAction.UPDATE_FROM_PATHNAME]: { actions: ['updateContext'] },
658
+ [RouteAction.NAVIGATE_HOME]: { target: RouteState.Home, actions: ['clearParams', 'updatePathToHome'] },
659
+ [RouteAction.NAVIGATE_INVITE]: { target: RouteState.Invite, actions: ['updatePathToInvite'] },
660
+ },
661
+ },
662
+ },
663
+ });
664
+
665
+ /**
666
+ * Factory function to create a route machine with initial context
667
+ */
668
+ export function createRouteMachineWithContext(orgSlug: string, initialPathname: string) {
669
+ const parsed = parsePathname(initialPathname, orgSlug);
670
+
671
+ // In XState v5, we create a new machine with updated context via provide
672
+ return routeMachine.provide({
673
+ context: {
674
+ orgSlug,
675
+ currentPath: initialPathname,
676
+ currentRouteKey: parsed.routeKey,
677
+ channelName: parsed.channelName,
678
+ teamName: parsed.teamName,
679
+ previousPath: null,
680
+ } as RouteContext,
681
+ } as any);
682
+ }
package/src/module.tsx ADDED
@@ -0,0 +1,6 @@
1
+ import { Feature } from '@common-stack/client-react';
2
+ import { filteredRoutes } from './compute';
3
+
4
+ export default new Feature({
5
+ routeConfig: filteredRoutes as any,
6
+ });
@@ -0,0 +1 @@
1
+ export * from './slackuiQueries';