@indietabletop/appkit 6.1.6 → 7.0.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.
Files changed (269) hide show
  1. package/dist/AppConfig/AppConfig.d.ts +29 -0
  2. package/dist/AuthCard/AuthCard.d.ts +10 -0
  3. package/dist/AuthCard/AuthCard.stories.d.ts +34 -0
  4. package/dist/AuthCard/style.css.d.ts +23 -0
  5. package/dist/DialogTrigger/index.d.ts +13 -0
  6. package/dist/DocumentTitle/DocumentTitle.d.ts +3 -0
  7. package/dist/EnumMapper.d.ts +25 -0
  8. package/dist/ExternalLink.d.ts +3 -0
  9. package/dist/FullscreenDismissBlocker.d.ts +5 -0
  10. package/{lib/HistoryState.ts → dist/HistoryState.d.ts} +2 -5
  11. package/dist/IndieTabletopClubLogo.d.ts +7 -0
  12. package/dist/IndieTabletopClubSymbol.d.ts +7 -0
  13. package/dist/InfoPage/index.d.ts +8 -0
  14. package/dist/InfoPage/pages.d.ts +2 -0
  15. package/dist/InfoPage/style.css.d.ts +5 -0
  16. package/dist/Letterhead/index.d.ts +19 -0
  17. package/dist/Letterhead/stories.d.ts +13 -0
  18. package/dist/Letterhead/style.css.d.ts +46 -0
  19. package/dist/LetterheadForm/LetterheadReadonlyTextField.stories.d.ts +17 -0
  20. package/dist/LetterheadForm/LetterheadSubmitError.stories.d.ts +11 -0
  21. package/dist/LetterheadForm/LetterheadTextField.stories.d.ts +336 -0
  22. package/dist/LetterheadForm/index.d.ts +44 -0
  23. package/dist/LetterheadForm/style.css.d.ts +8 -0
  24. package/dist/LoadingIndicator.d.ts +3 -0
  25. package/dist/MiddotSeparated/MiddotSeparated.d.ts +8 -0
  26. package/dist/MiddotSeparated/MiddotSeparated.stories.d.ts +586 -0
  27. package/dist/MiddotSeparated/style.css.d.ts +1 -0
  28. package/dist/ModalDialog/index.d.ts +12 -0
  29. package/dist/ModalDialog/style.css.d.ts +58 -0
  30. package/dist/ModernIDB/Cursor.d.ts +56 -0
  31. package/dist/ModernIDB/ModernIDB.d.ts +66 -0
  32. package/dist/ModernIDB/ModernIDBError.d.ts +3 -0
  33. package/dist/ModernIDB/ObjectStore.d.ts +112 -0
  34. package/dist/ModernIDB/ObjectStoreIndex.d.ts +53 -0
  35. package/dist/ModernIDB/Transaction.d.ts +16 -0
  36. package/dist/ModernIDB/VersionChangeManager.d.ts +30 -0
  37. package/dist/ModernIDB/bindings/factory.d.ts +12 -0
  38. package/dist/ModernIDB/bindings/index.d.ts +2 -0
  39. package/{lib/ModernIDB/bindings/types.ts → dist/ModernIDB/bindings/types.d.ts} +13 -32
  40. package/dist/ModernIDB/bindings/utils.d.ts +2 -0
  41. package/dist/ModernIDB/index.d.ts +10 -0
  42. package/dist/ModernIDB/types.d.ts +88 -0
  43. package/dist/ModernIDB/utils.d.ts +4 -0
  44. package/dist/QRCode/QRCode.d.ts +7 -0
  45. package/dist/QRCode/QRCode.stories.d.ts +33 -0
  46. package/dist/QRCode/style.css.d.ts +4 -0
  47. package/dist/ReleaseInfo/index.d.ts +5 -0
  48. package/dist/RulesetResolver.d.ts +87 -0
  49. package/dist/SafariCheck/SafariCheck.d.ts +23 -0
  50. package/dist/SafariCheck/SafariCheck.stories.d.ts +73 -0
  51. package/dist/SafariCheck/style.css.d.ts +17 -0
  52. package/dist/ServiceWorkerHandler.d.ts +11 -0
  53. package/dist/ShareButton/ShareButton.d.ts +57 -0
  54. package/dist/ShareButton/ShareButton.stories.d.ts +1577 -0
  55. package/dist/ShareButton/test.css.d.ts +1 -0
  56. package/dist/SubscribeCard/LetterheadInfoCard.d.ts +2 -0
  57. package/dist/SubscribeCard/SubscribeByEmailCard.d.ts +24 -0
  58. package/dist/SubscribeCard/SubscribeByEmailCard.stories.d.ts +10 -0
  59. package/dist/SubscribeCard/SubscribeByPledgeCard.d.ts +36 -0
  60. package/dist/SubscribeCard/SubscribeByPledgeCard.stories.d.ts +65 -0
  61. package/dist/SubscribeCard/style.css.d.ts +4 -0
  62. package/dist/account/AccountIssueView.d.ts +3 -0
  63. package/dist/account/AlreadyLoggedInView.d.ts +5 -0
  64. package/dist/account/CurrentUserFetcher.d.ts +20 -0
  65. package/dist/account/CurrentUserFetcher.stories.d.ts +136 -0
  66. package/dist/account/FailureFallbackView.d.ts +1 -0
  67. package/dist/account/JoinCard.d.ts +14 -0
  68. package/dist/account/JoinCard.stories.d.ts +143 -0
  69. package/dist/account/LoadingView.d.ts +1 -0
  70. package/dist/account/LoginCard.d.ts +39 -0
  71. package/dist/account/LoginCard.stories.d.ts +217 -0
  72. package/dist/account/LoginView.d.ts +10 -0
  73. package/dist/account/NoConnectionView.d.ts +4 -0
  74. package/dist/account/PasswordResetCard.d.ts +15 -0
  75. package/dist/account/PasswordResetCard.stories.d.ts +128 -0
  76. package/dist/account/UserMismatchView.d.ts +6 -0
  77. package/dist/account/VerifyPage.d.ts +13 -0
  78. package/dist/account/style.css.d.ts +10 -0
  79. package/{lib/account/types.ts → dist/account/types.d.ts} +3 -6
  80. package/dist/account/useFetchCurrentUser.d.ts +28 -0
  81. package/dist/account/useRedirectPath.d.ts +6 -0
  82. package/dist/animations.css.d.ts +3 -0
  83. package/dist/append-copy-to-text.d.ts +10 -0
  84. package/dist/append-copy-to-text.test.d.ts +1 -0
  85. package/dist/appkit.css +1 -0
  86. package/dist/appkit.js +10692 -0
  87. package/dist/async-op.d.ts +101 -0
  88. package/dist/atomic.css.d.ts +6 -0
  89. package/{lib/caught-value.ts → dist/caught-value.d.ts} +1 -11
  90. package/{lib/class-names.ts → dist/class-names.d.ts} +6 -17
  91. package/dist/client.d.ts +424 -0
  92. package/dist/common.css.d.ts +5 -0
  93. package/dist/copyrightRange.d.ts +1 -0
  94. package/dist/copyrightRange.test.d.ts +1 -0
  95. package/dist/createSafeStorage.d.ts +34 -0
  96. package/dist/failureMessages.d.ts +20 -0
  97. package/dist/failureMessages.test.d.ts +1 -0
  98. package/dist/form/FormSubmitButton.d.ts +17 -0
  99. package/dist/form/SubmitErrorAlert.d.ts +5 -0
  100. package/dist/form/style.css.d.ts +3 -0
  101. package/dist/globals.css.d.ts +0 -0
  102. package/dist/groupBy.d.ts +1 -0
  103. package/dist/groupBy.test.d.ts +1 -0
  104. package/dist/hrefs.d.ts +32 -0
  105. package/dist/hrefs.test.d.ts +1 -0
  106. package/dist/idToDate.d.ts +5 -0
  107. package/dist/idToDate.test.d.ts +1 -0
  108. package/dist/ids.d.ts +1 -0
  109. package/dist/ids.test.d.ts +1 -0
  110. package/dist/index.d.ts +64 -0
  111. package/dist/internal.css.d.ts +2 -0
  112. package/dist/mailto.d.ts +8 -0
  113. package/dist/mailto.test.d.ts +1 -0
  114. package/dist/media.d.ts +39 -0
  115. package/dist/random.d.ts +3 -0
  116. package/dist/result/swr.d.ts +4 -0
  117. package/{lib/sleep.ts → dist/sleep.d.ts} +1 -3
  118. package/dist/store/index.d.ts +237 -0
  119. package/dist/store/store.d.ts +144 -0
  120. package/dist/store/types.d.ts +49 -0
  121. package/dist/store/utils.d.ts +10 -0
  122. package/dist/storybook/decorators.d.ts +3 -0
  123. package/dist/structs.d.ts +1 -0
  124. package/{lib/typeguards.ts → dist/typeguards.d.ts} +1 -3
  125. package/dist/typeguards.test.d.ts +1 -0
  126. package/{lib/types.ts → dist/types.d.ts} +12 -23
  127. package/dist/unique.d.ts +10 -0
  128. package/dist/unique.test.d.ts +1 -0
  129. package/dist/use-async-op.d.ts +6 -0
  130. package/dist/use-document-background-color.d.ts +4 -0
  131. package/dist/use-form.d.ts +29 -0
  132. package/dist/use-is-installed.d.ts +8 -0
  133. package/dist/use-media-query.d.ts +1 -0
  134. package/dist/use-reverting-state.d.ts +5 -0
  135. package/dist/use-scroll-restoration.d.ts +25 -0
  136. package/dist/useEnsureValue.d.ts +6 -0
  137. package/dist/useInvokeClient.d.ts +25 -0
  138. package/dist/useIsVisible.d.ts +4 -0
  139. package/dist/utm.d.ts +58 -0
  140. package/dist/utm.test.d.ts +1 -0
  141. package/dist/validations.d.ts +3 -0
  142. package/dist/vars.css.d.ts +10 -0
  143. package/package.json +12 -5
  144. package/lib/AppConfig/AppConfig.tsx +0 -61
  145. package/lib/AuthCard/AuthCard.stories.ts +0 -34
  146. package/lib/AuthCard/AuthCard.tsx +0 -64
  147. package/lib/AuthCard/style.css.ts +0 -49
  148. package/lib/DialogTrigger/index.tsx +0 -36
  149. package/lib/DocumentTitle/DocumentTitle.tsx +0 -10
  150. package/lib/EnumMapper.ts +0 -50
  151. package/lib/ExternalLink.tsx +0 -10
  152. package/lib/FullscreenDismissBlocker.tsx +0 -23
  153. package/lib/IndieTabletopClubLogo.tsx +0 -44
  154. package/lib/IndieTabletopClubSymbol.tsx +0 -37
  155. package/lib/InfoPage/index.tsx +0 -46
  156. package/lib/InfoPage/pages.tsx +0 -36
  157. package/lib/InfoPage/style.css.ts +0 -36
  158. package/lib/Letterhead/index.tsx +0 -85
  159. package/lib/Letterhead/stories.tsx +0 -41
  160. package/lib/Letterhead/style.css.ts +0 -152
  161. package/lib/LetterheadForm/LetterheadReadonlyTextField.stories.tsx +0 -17
  162. package/lib/LetterheadForm/LetterheadSubmitError.stories.tsx +0 -19
  163. package/lib/LetterheadForm/LetterheadTextField.stories.tsx +0 -19
  164. package/lib/LetterheadForm/index.tsx +0 -137
  165. package/lib/LetterheadForm/style.css.ts +0 -89
  166. package/lib/LoadingIndicator.tsx +0 -40
  167. package/lib/MiddotSeparated/MiddotSeparated.stories.ts +0 -26
  168. package/lib/MiddotSeparated/MiddotSeparated.tsx +0 -26
  169. package/lib/MiddotSeparated/style.css.ts +0 -10
  170. package/lib/ModalDialog/index.tsx +0 -28
  171. package/lib/ModalDialog/style.css.ts +0 -88
  172. package/lib/ModernIDB/Cursor.ts +0 -91
  173. package/lib/ModernIDB/ModernIDB.ts +0 -337
  174. package/lib/ModernIDB/ModernIDBError.ts +0 -9
  175. package/lib/ModernIDB/ObjectStore.ts +0 -195
  176. package/lib/ModernIDB/ObjectStoreIndex.ts +0 -102
  177. package/lib/ModernIDB/README.md +0 -9
  178. package/lib/ModernIDB/Transaction.ts +0 -40
  179. package/lib/ModernIDB/VersionChangeManager.ts +0 -57
  180. package/lib/ModernIDB/bindings/factory.tsx +0 -165
  181. package/lib/ModernIDB/bindings/index.ts +0 -2
  182. package/lib/ModernIDB/bindings/utils.tsx +0 -32
  183. package/lib/ModernIDB/index.ts +0 -10
  184. package/lib/ModernIDB/types.ts +0 -120
  185. package/lib/ModernIDB/utils.ts +0 -51
  186. package/lib/QRCode/QRCode.stories.tsx +0 -41
  187. package/lib/QRCode/QRCode.tsx +0 -54
  188. package/lib/QRCode/style.css.ts +0 -23
  189. package/lib/ReleaseInfo/index.tsx +0 -29
  190. package/lib/RulesetResolver.ts +0 -214
  191. package/lib/SafariCheck/SafariCheck.stories.tsx +0 -99
  192. package/lib/SafariCheck/SafariCheck.tsx +0 -273
  193. package/lib/SafariCheck/addToDock.svg +0 -13
  194. package/lib/SafariCheck/addToHomeScreen.svg +0 -12
  195. package/lib/SafariCheck/safari.svg +0 -32
  196. package/lib/SafariCheck/shareIcon.svg +0 -11
  197. package/lib/SafariCheck/style.css.ts +0 -106
  198. package/lib/ServiceWorkerHandler.tsx +0 -53
  199. package/lib/ShareButton/ShareButton.stories.tsx +0 -58
  200. package/lib/ShareButton/ShareButton.tsx +0 -153
  201. package/lib/ShareButton/test.css.ts +0 -3
  202. package/lib/SubscribeCard/LetterheadInfoCard.tsx +0 -23
  203. package/lib/SubscribeCard/SubscribeByEmailCard.stories.tsx +0 -69
  204. package/lib/SubscribeCard/SubscribeByEmailCard.tsx +0 -183
  205. package/lib/SubscribeCard/SubscribeByPledgeCard.stories.tsx +0 -133
  206. package/lib/SubscribeCard/SubscribeByPledgeCard.tsx +0 -127
  207. package/lib/SubscribeCard/style.css.ts +0 -14
  208. package/lib/account/AccountIssueView.tsx +0 -44
  209. package/lib/account/AlreadyLoggedInView.tsx +0 -47
  210. package/lib/account/CurrentUserFetcher.stories.tsx +0 -292
  211. package/lib/account/CurrentUserFetcher.tsx +0 -118
  212. package/lib/account/FailureFallbackView.tsx +0 -36
  213. package/lib/account/JoinCard.stories.tsx +0 -257
  214. package/lib/account/JoinCard.tsx +0 -301
  215. package/lib/account/LoadingView.tsx +0 -14
  216. package/lib/account/LoginCard.stories.tsx +0 -288
  217. package/lib/account/LoginCard.tsx +0 -100
  218. package/lib/account/LoginView.tsx +0 -151
  219. package/lib/account/NoConnectionView.tsx +0 -34
  220. package/lib/account/PasswordResetCard.stories.tsx +0 -242
  221. package/lib/account/PasswordResetCard.tsx +0 -296
  222. package/lib/account/UserMismatchView.tsx +0 -62
  223. package/lib/account/VerifyPage.tsx +0 -195
  224. package/lib/account/style.css.ts +0 -57
  225. package/lib/account/useFetchCurrentUser.tsx +0 -63
  226. package/lib/account/useRedirectPath.ts +0 -21
  227. package/lib/animations.css.ts +0 -17
  228. package/lib/append-copy-to-text.ts +0 -35
  229. package/lib/async-op.ts +0 -286
  230. package/lib/atomic.css.ts +0 -11
  231. package/lib/client.ts +0 -662
  232. package/lib/common.css.ts +0 -48
  233. package/lib/copyrightRange.ts +0 -10
  234. package/lib/createSafeStorage.ts +0 -91
  235. package/lib/failureMessages.ts +0 -108
  236. package/lib/form/FormSubmitButton.tsx +0 -58
  237. package/lib/form/SubmitErrorAlert.tsx +0 -21
  238. package/lib/form/style.css.ts +0 -9
  239. package/lib/globals.css.ts +0 -62
  240. package/lib/groupBy.ts +0 -25
  241. package/lib/hrefs.ts +0 -48
  242. package/lib/idToDate.ts +0 -8
  243. package/lib/ids.ts +0 -6
  244. package/lib/index.ts +0 -71
  245. package/lib/internal.css.ts +0 -10
  246. package/lib/mailto.ts +0 -40
  247. package/lib/media.ts +0 -50
  248. package/lib/random.ts +0 -19
  249. package/lib/result/swr.ts +0 -18
  250. package/lib/store/index.tsx +0 -241
  251. package/lib/store/store.ts +0 -479
  252. package/lib/store/types.ts +0 -45
  253. package/lib/store/utils.ts +0 -54
  254. package/lib/storybook/decorators.tsx +0 -10
  255. package/lib/structs.ts +0 -3
  256. package/lib/unique.ts +0 -24
  257. package/lib/use-async-op.ts +0 -16
  258. package/lib/use-document-background-color.ts +0 -16
  259. package/lib/use-form.ts +0 -78
  260. package/lib/use-is-installed.ts +0 -17
  261. package/lib/use-media-query.ts +0 -21
  262. package/lib/use-reverting-state.ts +0 -32
  263. package/lib/use-scroll-restoration.ts +0 -99
  264. package/lib/useEnsureValue.ts +0 -31
  265. package/lib/useInvokeClient.ts +0 -54
  266. package/lib/useIsVisible.ts +0 -27
  267. package/lib/utm.ts +0 -92
  268. package/lib/validations.ts +0 -25
  269. package/lib/vars.css.ts +0 -13
@@ -1,12 +1,9 @@
1
- import type { Infer } from "superstruct";
2
- import { currentUser, redeemedPledge, sessionInfo } from "./structs.js";
3
-
4
- // Generic type helpers
5
-
6
- type Brand<B> = { __brand: B };
7
-
1
+ import { Infer } from 'superstruct';
2
+ import { currentUser, redeemedPledge, sessionInfo } from './structs.js';
3
+ type Brand<B> = {
4
+ __brand: B;
5
+ };
8
6
  export type Branded<T, B> = T & Brand<B>;
9
-
10
7
  /**
11
8
  * Make properties in union K required in T.
12
9
  *
@@ -23,7 +20,6 @@ export type Branded<T, B> = T & Brand<B>;
23
20
  * ```
24
21
  */
25
22
  export type RequiredPick<T, K extends keyof T> = T & Required<Pick<T, K>>;
26
-
27
23
  /**
28
24
  * A branded string.
29
25
  *
@@ -32,20 +28,13 @@ export type RequiredPick<T, K extends keyof T> = T & Required<Pick<T, K>>;
32
28
  * that exists in our codebase) or sanitized user-generated content.
33
29
  */
34
30
  export type TrustedHtml = Branded<string, "TrustedHtml">;
35
-
36
- // Common ITC types
37
-
38
31
  export type CurrentUser = Infer<ReturnType<typeof currentUser>>;
39
-
40
32
  export type SessionInfo = Infer<ReturnType<typeof sessionInfo>>;
41
-
42
33
  export type RedeemedPledge = Infer<ReturnType<typeof redeemedPledge>>;
43
-
44
- export type FailurePayload =
45
- | {
46
- type: "API_ERROR";
47
- code: number;
48
- }
49
- | {
50
- type: "NETWORK_ERROR" | "UNKNOWN_ERROR" | "VALIDATION_ERROR";
51
- };
34
+ export type FailurePayload = {
35
+ type: "API_ERROR";
36
+ code: number;
37
+ } | {
38
+ type: "NETWORK_ERROR" | "UNKNOWN_ERROR" | "VALIDATION_ERROR";
39
+ };
40
+ export {};
@@ -0,0 +1,10 @@
1
+ type UniqueKey = string | number;
2
+ /**
3
+ * Returns an array of unique items, determining uniqueness via the getKey
4
+ * function.
5
+ *
6
+ * Note that the first unique item is returned, all others are omitted
7
+ * (assuming that they are unique, so it shouldn't matter).
8
+ */
9
+ export declare function uniqueBy<T>(items: T[], getKey: (item: T) => UniqueKey): T[];
10
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import { AsyncOp } from './async-op.js';
2
+ export declare function useAsyncOp<T, E>(): {
3
+ op: AsyncOp<T, E>;
4
+ setSuccess: (value: T) => void;
5
+ setFailure: (failure: E) => void;
6
+ };
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Sets document background color, reverting it to previous color on unmount.
3
+ */
4
+ export declare function useDocumentBackgroundColor(bodyColor: string): void;
@@ -0,0 +1,29 @@
1
+ import { FormStoreState } from '@ariakit/react';
2
+ import { Failure, Success } from './async-op.ts';
3
+ type Validator<T> = (value: T) => string | null;
4
+ type MaybePromise<T> = T | Promise<T>;
5
+ export declare function useForm<T extends object, R>(props: {
6
+ defaultValues: T;
7
+ validate?: {
8
+ [K in keyof T]?: Validator<T[K]>;
9
+ };
10
+ /**
11
+ * Handles form submission login.
12
+ *
13
+ * This function should return a Success or Failure. Failures should always contain a string
14
+ * which will be used as the form error message.
15
+ */
16
+ onSubmit: (state: FormStoreState<T>) => MaybePromise<Success<R> | Failure<string>>;
17
+ /**
18
+ * If submission was successful (i.e. onSubmit returned a Success), will be run to perform any
19
+ * side-effect necessary.
20
+ *
21
+ * Typically this is used for navigation on mutating some local state.
22
+ */
23
+ onSuccess?: (value: R, state: FormStoreState<T>) => MaybePromise<void>;
24
+ }): {
25
+ form: import('@ariakit/react').FormStore<T>;
26
+ submitName: string;
27
+ op: Failure<string> | Success<R> | null;
28
+ };
29
+ export {};
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Checks whether the app is installed.
3
+ *
4
+ * Note that this doesn't check whether the app is installed on the device at
5
+ * all, only whether the currently running process is within an installed window
6
+ * or running within a browser.
7
+ */
8
+ export declare function useIsInstalled(): boolean;
@@ -0,0 +1 @@
1
+ export declare function useMediaQuery(query: string): boolean;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Sets a state that will automatically revert to null after specified number
3
+ * of milliseconds.
4
+ */
5
+ export declare function useRevertingState<T>(initialState: T, revertAfterMs: number): readonly [T | null, import('react').Dispatch<import('react').SetStateAction<T | null>>];
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Handles scroll restoration on window.
3
+ *
4
+ * This hook behaves a little differently than the default browser scroll
5
+ * restoration. This is due to limitations of Wouter (our router of choice)
6
+ * as well the need to make the app feel more app-like.
7
+ *
8
+ * Every scroll position is remembered however the user has got to it (we
9
+ * don't differentiate between new entries in browser history and back
10
+ * navigation), but they are only restored if the user last visited the
11
+ * location less than 60 minutes ago.
12
+ */
13
+ export declare function useScrollRestoration(
14
+ /**
15
+ * The current path, provided by your router of choice.
16
+ */
17
+ pathname: string, options?: {
18
+ /**
19
+ * A list of paths where scroll restoration should never be performed.
20
+ *
21
+ * This list should have stable identity for optimal performance. Make
22
+ * sure to use `useMemo` or define the list in module scope.
23
+ */
24
+ neverRestore?: string[];
25
+ }): void;
@@ -0,0 +1,6 @@
1
+ import { Failure, Success, AsyncOp } from './async-op.ts';
2
+ /**
3
+ * Checks if the provided value is non-nullish, otherwise calls provided
4
+ * getValue function to obtain the value (presumably from some remote location).
5
+ */
6
+ export declare function useEnsureValue<T>(value: T | null | undefined, getValue: () => Promise<Success<T> | Failure<string>>): AsyncOp<T, string>;
@@ -0,0 +1,25 @@
1
+ import { SWRConfiguration, SWRResponse } from 'swr';
2
+ import { Pending } from './async-op.ts';
3
+ import { IndieTabletopClient } from './client.ts';
4
+ /**
5
+ * Creates a `useInvokeClient` hook that makes it ergonomic to invoke
6
+ * client methods.
7
+ *
8
+ * Note that only methods starting with `get` are picked up. This hook is
9
+ * intended for making easy fetches, not for form submissions.
10
+ */
11
+ export declare function createUseInvokeClient<C extends IndieTabletopClient>(c: C): <K extends keyof C & `get${string}`>(
12
+ /**
13
+ * ITC Client's method name.
14
+ */
15
+ method: K,
16
+ /**
17
+ * Method's arguments.
18
+ *
19
+ * **IMPORTANT**: Must be an array or primitive values as it is directly
20
+ * used as a `useCallback` dependecy array.
21
+ */
22
+ args: C[K] extends (...args: any) => any ? Parameters<C[K]> : never, options?: {
23
+ performFetch?: boolean;
24
+ swr?: SWRConfiguration;
25
+ }) => C[K] extends (...args: any) => any ? [Awaited<ReturnType<C[K]>> | Pending, SWRResponse<unknown, unknown>] : never;
@@ -0,0 +1,4 @@
1
+ export declare function useIsVisible<T extends HTMLElement>(initialState?: boolean, options?: IntersectionObserverInit): {
2
+ ref: import('react').RefObject<T | null>;
3
+ isVisible: boolean;
4
+ };
package/dist/utm.d.ts ADDED
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Full UTM configuration object.
3
+ */
4
+ export type UtmParams = {
5
+ /**
6
+ * The website/platform the visitor is coming from.
7
+ */
8
+ source: string;
9
+ /**
10
+ * The type of marketing channel (e.g. cpc, email, affiliate, social,
11
+ * or similar).
12
+ */
13
+ medium: string;
14
+ /**
15
+ * The name of the campaign or product description. In our case, this is
16
+ * usually the name of the app.
17
+ */
18
+ campaign: string;
19
+ /**
20
+ * Optionally, provide an identifier for the place from which the link was
21
+ * clicked. E.g. footer, join, etc.
22
+ */
23
+ content?: string;
24
+ /**
25
+ * Optionally, identify paid keywords. We usually do not use this.
26
+ */
27
+ term?: string;
28
+ };
29
+ /**
30
+ * UTM Params configuration that is appropriate to set at the link level,
31
+ * if app-level defaults have been set.
32
+ */
33
+ export type LinkUtmParams = Pick<UtmParams, "content" | "term">;
34
+ /**
35
+ * Returns URL Search params with provided UTM configuration.
36
+ *
37
+ * Most of the time, you probably want to set up some defaults using
38
+ * {@link createUtm}. This function is intended for special cases.
39
+ */
40
+ export declare function utm(params: UtmParams): URLSearchParams;
41
+ /**
42
+ * A factory for the {@link utm} function. Use it to set sensible defaults for
43
+ * further use of the returned function.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * const utm = createUtm({
48
+ * source: "indietabletopclub",
49
+ * medium: "referral",
50
+ * campaign: "spacegitsapp",
51
+ * });
52
+ *
53
+ * utm() // => URLSearchParams that inlude the above config
54
+ *
55
+ * utm({ campaign: "foo", content: "bar" }) // Sets optional fiels and overrides
56
+ * ```
57
+ */
58
+ export declare function createUtm(defaults: UtmParams): (params?: Partial<UtmParams>) => URLSearchParams;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ export declare const EMAIL_REGEX: RegExp;
2
+ export declare const validEmail: (value: string) => "This doesn't look like a valid email." | null;
3
+ export declare const validPassword: (value: string) => "A password has to be at least 8 characters long." | "A password cannot be longer than 256 characters." | null;
@@ -0,0 +1,10 @@
1
+ export declare const Color: {
2
+ GRAY: `var(--${string})`;
3
+ MID_GRAY: `var(--${string})`;
4
+ LIGHT_GRAY: `var(--${string})`;
5
+ PALE_GRAY: `var(--${string})`;
6
+ PURPLE: `var(--${string})`;
7
+ };
8
+ export declare const ZIndex: {
9
+ DIALOG: `var(--${string})`;
10
+ };
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@indietabletop/appkit",
3
- "version": "6.1.6",
3
+ "version": "7.0.0-0",
4
4
  "description": "A collection of modules used in apps built by Indie Tabletop Club",
5
5
  "private": false,
6
6
  "type": "module",
7
7
  "scripts": {
8
8
  "release": "np",
9
- "build": "tsc",
9
+ "build": "vite build",
10
+ "prepare": "vite build",
10
11
  "dev": "tsc --watch",
11
12
  "test": "vitest run",
12
13
  "test:dev": "vitest watch",
@@ -15,11 +16,14 @@
15
16
  "typecheck": "tsc --noEmit"
16
17
  },
17
18
  "exports": {
18
- ".": "./lib/index.ts",
19
- "./*.css.ts": "./lib/*.css.ts"
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "import": "./dist/appkit.js"
22
+ },
23
+ "./style.css": "./dist/appkit.css"
20
24
  },
21
25
  "files": [
22
- "/lib"
26
+ "/dist"
23
27
  ],
24
28
  "author": "Artur Müller",
25
29
  "repository": {
@@ -35,12 +39,15 @@
35
39
  "@storybook/addon-links": "^10.1.11",
36
40
  "@storybook/react-vite": "^10.1.11",
37
41
  "@types/react": "^19.2.8",
42
+ "@vanilla-extract/vite-plugin": "^5.1.4",
43
+ "@vitejs/plugin-react": "^5.1.4",
38
44
  "msw": "^2.12.7",
39
45
  "msw-storybook-addon": "^2.0.6",
40
46
  "np": "^10.2.0",
41
47
  "storybook": "^10.1.11",
42
48
  "typescript": "^5.9.3",
43
49
  "vite": "^7.3.1",
50
+ "vite-plugin-dts": "^4.5.4",
44
51
  "vitest": "^4.0.17"
45
52
  },
46
53
  "dependencies": {
@@ -1,61 +0,0 @@
1
- import { createContext, type ReactNode, useContext } from "react";
2
- import type { IndieTabletopClient } from "../client.ts";
3
- import type { AppHrefs } from "../hrefs.ts";
4
-
5
- export type AppConfig = {
6
- app: {
7
- /**
8
- * The app's name, e.g. Space Gits. Do not include the word App in this
9
- * title -- it will be added automatically in places where it's needed.
10
- */
11
- name: string;
12
-
13
- /**
14
- * The URL to the app's icon. This should be a maskable-style icon. In
15
- * other words, it should not include its own transparency.
16
- */
17
- icon: string;
18
- };
19
- isDev: boolean;
20
- client: IndieTabletopClient;
21
- hrefs: AppHrefs;
22
- placeholders: {
23
- email: string;
24
- };
25
- };
26
-
27
- const AppConfigContext = createContext<AppConfig | null>(null);
28
-
29
- export function AppConfigProvider(props: {
30
- config: AppConfig;
31
- children: ReactNode;
32
- }) {
33
- const { config, children } = props;
34
- return <AppConfigContext value={config}>{children}</AppConfigContext>;
35
- }
36
-
37
- export function useAppConfig() {
38
- const config = useContext(AppConfigContext);
39
-
40
- if (!config) {
41
- throw new Error(
42
- `Attempting to retrieve app config, but none was found within context. ` +
43
- `Make sure that AppConfigProvider is used in the component hierarchy.`,
44
- );
45
- }
46
-
47
- return config;
48
- }
49
-
50
- export function useClient() {
51
- const config = useContext(AppConfigContext);
52
-
53
- if (!config?.client) {
54
- throw new Error(
55
- `Attempting to retrieve ITC client, but none was found within context. ` +
56
- `Make sure that AppConfigProvider is used in the component hierarchy.`,
57
- );
58
- }
59
-
60
- return config.client;
61
- }
@@ -1,34 +0,0 @@
1
- import { fn } from "storybook/test";
2
- import preview from "../../.storybook/preview.tsx";
3
- import { AuthCard } from "./AuthCard.tsx";
4
-
5
- const meta = preview.meta({
6
- title: "Account/Auth Card",
7
- component: AuthCard,
8
- tags: ["autodocs"],
9
- args: {
10
- onLogout: fn(),
11
- },
12
- });
13
-
14
- /**
15
- * The default case where elements are correctly separated with middots.
16
- */
17
- export const Authenticated = meta.story({
18
- args: {
19
- currentUser: {
20
- id: "martin",
21
- email: "martin@example.com",
22
- isVerified: true,
23
- },
24
- },
25
- });
26
-
27
- /**
28
- * The default case in which all steps of the flow succeed.
29
- */
30
- export const Anonymous = meta.story({
31
- args: {
32
- currentUser: null,
33
- },
34
- });
@@ -1,64 +0,0 @@
1
- import { Button } from "@ariakit/react";
2
- import { Link } from "wouter";
3
- import { useAppConfig } from "../AppConfig/AppConfig.tsx";
4
- import { interactiveText } from "../common.css.ts";
5
- import { IndieTabletopClubLogo } from "../IndieTabletopClubLogo.tsx";
6
- import { LetterheadParagraph } from "../Letterhead/index.tsx";
7
- import { button } from "../Letterhead/style.css.ts";
8
- import { MiddotSeparated } from "../MiddotSeparated/MiddotSeparated.tsx";
9
- import type { CurrentUser } from "../types.ts";
10
- import { card } from "./style.css.ts";
11
-
12
- /**
13
- * Small, ITC-branded card that shows authentication status.
14
- *
15
- * Primarily intended to be used within the sidenav.
16
- */
17
- export function AuthCard(props: {
18
- onLogout: () => void;
19
- currentUser: CurrentUser | null;
20
- }) {
21
- const { currentUser, onLogout } = props;
22
- const { hrefs } = useAppConfig();
23
- const align = !currentUser ? "center" : "start";
24
-
25
- return (
26
- <div className={card.container({ align })}>
27
- <IndieTabletopClubLogo className={card.logo({ align })} />
28
-
29
- {currentUser ? (
30
- <>
31
- <LetterheadParagraph>{currentUser.email}</LetterheadParagraph>
32
-
33
- <MiddotSeparated className={card.loggedInAction}>
34
- <Link className={interactiveText} href={hrefs.account()}>
35
- Account
36
- </Link>
37
-
38
- <Button className={interactiveText} onClick={() => onLogout()}>
39
- Log out
40
- </Button>
41
- </MiddotSeparated>
42
- </>
43
- ) : (
44
- <>
45
- <LetterheadParagraph size="small">
46
- Enable backup & sync, access your pledge data, and more!
47
- </LetterheadParagraph>
48
-
49
- <Link href={hrefs.join()} className={button()}>
50
- Join
51
- </Link>
52
-
53
- <LetterheadParagraph size="small">
54
- {"Already have an account? "}
55
- <Link href={hrefs.login()} className={interactiveText}>
56
- Log in
57
- </Link>
58
- {"."}
59
- </LetterheadParagraph>
60
- </>
61
- )}
62
- </div>
63
- );
64
- }
@@ -1,49 +0,0 @@
1
- import { style } from "@vanilla-extract/css";
2
- import { recipe } from "@vanilla-extract/recipes";
3
-
4
- export const card = {
5
- container: recipe({
6
- base: {
7
- display: "flex",
8
- flexDirection: "column",
9
- gap: "0.75rem",
10
- backgroundColor: "white",
11
- padding: "1.5rem",
12
- borderRadius: "0.5rem",
13
- color: "black",
14
- },
15
-
16
- variants: {
17
- align: {
18
- center: {
19
- textAlign: "center",
20
- },
21
- start: {
22
- textAlign: "start",
23
- },
24
- },
25
- },
26
- }),
27
-
28
- logo: recipe({
29
- base: {
30
- maxInlineSize: "11rem",
31
- },
32
-
33
- variants: {
34
- align: {
35
- center: {
36
- marginInline: "auto",
37
- },
38
- start: {
39
- marginInline: "0",
40
- },
41
- },
42
- },
43
- }),
44
-
45
- loggedInAction: style({
46
- borderBlockStart: "1px solid hsl(0 0% 0% / 0.1)",
47
- paddingBlockStart: "0.75rem",
48
- }),
49
- };
@@ -1,36 +0,0 @@
1
- import {
2
- DialogProvider,
3
- useDialogContext,
4
- useStoreState,
5
- } from "@ariakit/react";
6
- import type { ReactElement, ReactNode } from "react";
7
-
8
- function DialogGuard(props: { children: ReactNode }) {
9
- const dialog = useDialogContext();
10
- const isMounted = useStoreState(dialog, (store) => store?.mounted);
11
- if (!isMounted) {
12
- return null;
13
- }
14
- return props.children;
15
- }
16
-
17
- /**
18
- * Wraps AriaKit's DialogProvider, but takes a tuple of Dialog a DialogDisclosure
19
- * elements as children, and makes sure that the Dialog component is not
20
- * rendered when it is hidden.
21
- *
22
- * This is important in cases where the dialog contains a form that should only
23
- * be initialized and re-initialized when the dialog opens, not when it is first
24
- * rendered.
25
- */
26
- export function DialogTrigger(props: {
27
- children: [ReactElement, ReactElement];
28
- }) {
29
- const [dialog, button] = props.children;
30
- return (
31
- <DialogProvider>
32
- <DialogGuard>{dialog}</DialogGuard>
33
- {button}
34
- </DialogProvider>
35
- );
36
- }
@@ -1,10 +0,0 @@
1
- import { useAppConfig } from "../AppConfig/AppConfig.tsx";
2
-
3
- export function DocumentTitle(props: { children: string }) {
4
- const { children: children } = props;
5
- const { app, isDev } = useAppConfig();
6
- const itc = `${app.name} · Indie Tabletop Club`;
7
- const title = children ? `${children} | ${itc}` : itc;
8
-
9
- return <title>{isDev ? `[DEV] ${title}` : title}</title>;
10
- }
package/lib/EnumMapper.ts DELETED
@@ -1,50 +0,0 @@
1
- type InputValues<K extends string | number, V> = Record<K, V> | Array<[K, V]>;
2
-
3
- /**
4
- * Handles mapping enums to arbitrary values.
5
- */
6
- export class EnumMapper<K extends string | number, V> {
7
- private map: Map<K, V>;
8
- private fallback: V;
9
-
10
- constructor(values: InputValues<K, V>, fallback: V) {
11
- const entries = Array.isArray(values)
12
- ? values
13
- : (Object.entries(values) as Array<[K, V]>);
14
- this.map = new Map(entries);
15
- this.fallback = fallback;
16
- }
17
-
18
- /**
19
- * Returns a value corresponding to the provided key.
20
- *
21
- * If no match is found, returns the fallback value provided in the constructor.
22
- *
23
- * Note that TypeScript will make sure that we only ever use the right types
24
- * as the enum param, but it can still happen at runtime that different
25
- * values are provided.
26
- */
27
- get(key: K | undefined): V {
28
- if (key === undefined) {
29
- return this.fallback;
30
- }
31
-
32
- const value = this.map.get(key);
33
- if (value === undefined) {
34
- return this.fallback;
35
- }
36
-
37
- return value;
38
- }
39
-
40
- /**
41
- * All enums known by this mapper.
42
- */
43
- get enums() {
44
- return Array.from(this.map.keys());
45
- }
46
-
47
- static from<K extends string>(values: InputValues<K, string>) {
48
- return new EnumMapper(values, "Unknown");
49
- }
50
- }
@@ -1,10 +0,0 @@
1
- import type { AnchorHTMLAttributes } from "react";
2
-
3
- export type ExternalLinkProps = Omit<
4
- AnchorHTMLAttributes<HTMLAnchorElement>,
5
- "rel" | "target"
6
- >;
7
-
8
- export function ExternalLink(props: ExternalLinkProps) {
9
- return <a {...props} target="_blank" rel="noreferrer noopener" />;
10
- }
@@ -1,23 +0,0 @@
1
- import { useEffect } from "react";
2
-
3
- function preventDefaultEscHandling(event: KeyboardEvent) {
4
- if (event.key === "Escape") {
5
- event.preventDefault();
6
- }
7
- }
8
-
9
- /**
10
- * This component prevents the default MacOS behaviour where a fullscreen window
11
- * gets minimized by pressing Escape.
12
- */
13
- export function FullscreenDismissBlocker() {
14
- useEffect(() => {
15
- window.addEventListener("keydown", preventDefaultEscHandling);
16
-
17
- return () => {
18
- window.removeEventListener("keydown", preventDefaultEscHandling);
19
- };
20
- }, []);
21
-
22
- return null;
23
- }