@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,195 +0,0 @@
1
- import { Button, Form } from "@ariakit/react";
2
- import { useState, type Dispatch, type SetStateAction } from "react";
3
- import { Link } from "wouter";
4
- import { useAppConfig, useClient } from "../AppConfig/AppConfig.tsx";
5
- import { interactiveText } from "../common.css.ts";
6
- import { getSubmitFailureMessage } from "../failureMessages.ts";
7
- import {
8
- Letterhead,
9
- LetterheadHeading,
10
- LetterheadParagraph,
11
- LetterheadSubmitButton,
12
- } from "../Letterhead/index.tsx";
13
- import { button } from "../Letterhead/style.css.ts";
14
- import {
15
- LetterheadFormActions,
16
- LetterheadHeader,
17
- LetterheadSubmitError,
18
- LetterheadTextField,
19
- } from "../LetterheadForm/index.tsx";
20
- import { useAppActions } from "../store/index.tsx";
21
- import type { CurrentUser } from "../types.ts";
22
- import { useForm } from "../use-form.ts";
23
- import type { AuthEventHandler } from "./types.ts";
24
-
25
- type SetStep = Dispatch<SetStateAction<VerifyStep>>;
26
-
27
- function InitialStep(props: {
28
- setStep: SetStep;
29
- currentUser: CurrentUser;
30
- reload: () => void;
31
- }) {
32
- const { setStep, currentUser, reload } = props;
33
- const { email } = currentUser;
34
- const { logout } = useAppActions();
35
-
36
- const client = useClient();
37
- const { form, submitName } = useForm({
38
- defaultValues: {},
39
- async onSubmit() {
40
- const op = await client.requestUserVerification();
41
- return op.mapFailure(getSubmitFailureMessage);
42
- },
43
- onSuccess(value) {
44
- setStep({ type: "SUBMIT_CODE", tokenId: value.tokenId });
45
- },
46
- });
47
-
48
- return (
49
- <Form store={form}>
50
- <Letterhead>
51
- <LetterheadHeader>
52
- <LetterheadHeading>Verify account</LetterheadHeading>
53
- <LetterheadParagraph>
54
- Your account is currently not verified. We will send a one-time code
55
- to your email ({email}) to complete the verification.
56
- </LetterheadParagraph>
57
- </LetterheadHeader>
58
-
59
- <LetterheadFormActions>
60
- <LetterheadSubmitError name={submitName} />
61
- <LetterheadSubmitButton>Send code</LetterheadSubmitButton>
62
- <LetterheadParagraph>
63
- Cannot complete verification?{" "}
64
- <Button
65
- className={interactiveText}
66
- onClick={async () => {
67
- await logout();
68
- reload();
69
- }}
70
- >
71
- Log out
72
- </Button>
73
- .
74
- </LetterheadParagraph>
75
- </LetterheadFormActions>
76
- </Letterhead>
77
- </Form>
78
- );
79
- }
80
-
81
- function SubmitCodeStep(props: {
82
- tokenId: string;
83
- setStep: SetStep;
84
- currentUser: CurrentUser;
85
- }) {
86
- const client = useClient();
87
- const { email } = props.currentUser;
88
- const { form, submitName } = useForm({
89
- defaultValues: {
90
- code: "",
91
- },
92
- async onSubmit({ values }) {
93
- const op = await client.verifyUser({
94
- ...values,
95
- tokenId: props.tokenId,
96
- });
97
-
98
- return op.mapFailure((failure) => {
99
- return getSubmitFailureMessage(failure, {
100
- 404: "🚫 This code is incorrect or expired. Please try again.",
101
- });
102
- });
103
- },
104
- onSuccess() {
105
- props.setStep({ type: "SUCCESS" });
106
- },
107
- });
108
-
109
- return (
110
- <Form store={form}>
111
- <Letterhead>
112
- <LetterheadHeader>
113
- <LetterheadHeading>Verify Account</LetterheadHeading>
114
- <LetterheadParagraph>
115
- We've sent a one-time code to {email}. Please, enter the code in the
116
- field below to complete verification.
117
- </LetterheadParagraph>
118
- </LetterheadHeader>
119
-
120
- <LetterheadTextField
121
- name={form.names.code}
122
- label="Code"
123
- placeholder="E.g. 123123"
124
- autoComplete="one-time-code"
125
- required
126
- />
127
-
128
- <LetterheadFormActions>
129
- <LetterheadSubmitError name={submitName} />
130
- <LetterheadSubmitButton>Verify</LetterheadSubmitButton>
131
- </LetterheadFormActions>
132
- </Letterhead>
133
- </Form>
134
- );
135
- }
136
-
137
- function SuccessStep(props: { onClose?: AuthEventHandler }) {
138
- const { onClose } = props;
139
- const { hrefs } = useAppConfig();
140
-
141
- return (
142
- <Letterhead>
143
- <LetterheadHeader>
144
- <LetterheadHeading>Success!</LetterheadHeading>
145
- <LetterheadParagraph>
146
- Your Indie Tabletop Club account has been verified. Yay!
147
- </LetterheadParagraph>
148
- </LetterheadHeader>
149
-
150
- {onClose ? (
151
- <Button onClick={() => onClose()} className={button()}>
152
- Done
153
- </Button>
154
- ) : (
155
- <Link href={hrefs.dashboard()} className={button()}>
156
- Go to dashboard
157
- </Link>
158
- )}
159
- </Letterhead>
160
- );
161
- }
162
-
163
- type VerifyStep =
164
- | { type: "INITIAL" }
165
- | { type: "SUBMIT_CODE"; tokenId: string }
166
- | { type: "SUCCESS" };
167
-
168
- export function VerifyAccountView(props: {
169
- currentUser: CurrentUser;
170
- reload: () => void;
171
-
172
- /**
173
- * If provided, will cause the success step to render a close dialog button
174
- * instead of "Go to Dashboard" button.
175
- *
176
- * This is useful if this view is used within a modal dialog context.
177
- */
178
- onClose?: AuthEventHandler;
179
- }) {
180
- const [step, setStep] = useState<VerifyStep>({ type: "INITIAL" });
181
-
182
- switch (step.type) {
183
- case "INITIAL": {
184
- return <InitialStep {...props} setStep={setStep} />;
185
- }
186
-
187
- case "SUBMIT_CODE": {
188
- return <SubmitCodeStep {...props} {...step} setStep={setStep} />;
189
- }
190
-
191
- case "SUCCESS": {
192
- return <SuccessStep {...props} />;
193
- }
194
- }
195
- }
@@ -1,57 +0,0 @@
1
- import { style } from "@vanilla-extract/css";
2
- import { Hover, MinWidth } from "../media.ts";
3
-
4
- export const page = style({
5
- backgroundColor: "white",
6
-
7
- "@media": {
8
- [MinWidth.SMALL]: {
9
- backgroundColor: "transparent",
10
- padding: "clamp(1rem, 5vw, 5rem)",
11
- },
12
- },
13
- });
14
-
15
- export const accountPicker = {
16
- container: style({
17
- backgroundColor: "#fafafa",
18
- borderRadius: "0.5rem",
19
- }),
20
-
21
- button: style({
22
- padding: "1rem 1.5rem",
23
- textAlign: "start",
24
- inlineSize: "100%",
25
- borderRadius: "inherit",
26
-
27
- "@media": {
28
- [Hover.HOVER]: {
29
- transition: "200ms background-color",
30
-
31
- ":hover": {
32
- backgroundColor: "hsl(from #fafafa h s calc(l - 3))",
33
- },
34
- },
35
- },
36
- }),
37
-
38
- buttonLabel: style({
39
- fontWeight: 600,
40
- fontSize: "1.125rem",
41
- }),
42
-
43
- divider: style({
44
- marginInline: "1.5rem",
45
- backgroundColor: "#e2e2e2",
46
- blockSize: "1px",
47
- }),
48
- };
49
-
50
- export const loadingView = {
51
- container: style({
52
- display: "flex",
53
- justifyContent: "center",
54
- alignItems: "center",
55
- height: "12rem",
56
- }),
57
- };
@@ -1,63 +0,0 @@
1
- import { useEffect, useState } from "react";
2
- import { useClient } from "../AppConfig/AppConfig.tsx";
3
- import { type Failure, Pending, type Success } from "../async-op.ts";
4
- import type { CurrentUser, FailurePayload } from "../types.ts";
5
-
6
- export function useFetchCurrentUser(options?: {
7
- /**
8
- * Optionally disable immediate fetch action.
9
- *
10
- * @default true
11
- */
12
- performFetch?: boolean;
13
-
14
- /**
15
- * Fetch new data every time the window is focused.
16
- *
17
- * Note that `performFetch` has to be enabled for this option to have an
18
- * effect — we are not revalidating when there is no fetch to do!
19
- *
20
- * @default false
21
- */
22
- revalidateOnFocus?: boolean;
23
- }) {
24
- const { performFetch = true, revalidateOnFocus = false } = options ?? {};
25
- const client = useClient();
26
- const [latestAttemptTs, setLatestAttemptTs] = useState(Date.now());
27
-
28
- const [result, setResult] = useState<
29
- Success<CurrentUser> | Failure<FailurePayload> | Pending
30
- >(new Pending());
31
-
32
- // We are intentionally not using SWR in this case, as we don't want to deal
33
- // with caching or any of that business.
34
- useEffect(() => {
35
- if (performFetch) {
36
- const fetchUserAndStoreResult = async () => {
37
- const result = await client.getCurrentUser();
38
- setResult(result);
39
- };
40
-
41
- // Invoke the fetch action
42
- fetchUserAndStoreResult();
43
-
44
- if (revalidateOnFocus) {
45
- const controller = new AbortController();
46
- window.addEventListener("focus", fetchUserAndStoreResult, controller);
47
-
48
- return () => {
49
- controller.abort();
50
- };
51
- }
52
- }
53
- }, [client, latestAttemptTs, performFetch]);
54
-
55
- return {
56
- result,
57
- latestAttemptTs,
58
- reload: () => {
59
- setResult(new Pending());
60
- setLatestAttemptTs(Date.now());
61
- },
62
- };
63
- }
@@ -1,21 +0,0 @@
1
- import { useSearchParams } from "wouter";
2
-
3
- function isValidRedirect(value: string | null | undefined): value is string {
4
- return !!(value && /^[~/]/.test(value));
5
- }
6
-
7
- /**
8
- * Gets redirect path from query params and validates it.
9
- *
10
- * Returns `null` if no path is found, or it is invalid.
11
- */
12
- export function useRedirectPath() {
13
- const [params] = useSearchParams();
14
- const redirectTo = params.get("redirectTo");
15
-
16
- if (isValidRedirect(redirectTo)) {
17
- return redirectTo;
18
- }
19
-
20
- return null;
21
- }
@@ -1,17 +0,0 @@
1
- import { keyframes } from "@vanilla-extract/css";
2
-
3
- export const fadeIn = keyframes({
4
- from: { opacity: 0 },
5
- to: { opacity: 1 },
6
- });
7
-
8
- export const slideUp = keyframes({
9
- from: { transform: `translateY(100%)` },
10
- to: { transform: `translateY(0)` },
11
- });
12
-
13
- export const bounce = keyframes({
14
- "0%": { transform: "translateY(0)" },
15
- "20%": { transform: "translateY(-20%)" },
16
- "50%": { transform: "translateY(0)" },
17
- });
@@ -1,35 +0,0 @@
1
- /**
2
- * Appends " (Copy)" to the end of the input string if it doesn't already end
3
- * with " (Copy)", otherwise it appends a number after "Copy", incrementing it
4
- * if necessary.
5
- */
6
- export function appendCopyToText(input: string): string {
7
- const regex = /^(?<value>.*) \(Copy(?: (?<count>\d+))?\)$/;
8
- const match = input.match(regex);
9
-
10
- // If there isn't a match, we directly append to the input.
11
- if (!match) {
12
- return `${input.trim()} (Copy)`;
13
- }
14
-
15
- const { value, count } = match.groups ?? {};
16
-
17
- // If `count` capturing group is not present, it means that the input ends
18
- // with the copy suffix, but it doesn't contain count.
19
- const nextCount = !count ? 2 : parseInt(count, 10) + 1;
20
-
21
- return `${value?.trim()} (Copy ${nextCount})`;
22
- }
23
-
24
- /**
25
- * Works like {@link appendCopyToText}, but ignores empty strings.
26
- */
27
- export function maybeAppendCopyToText(input: string) {
28
- // If input is falsy (i.e. empty string) then we don't want to append
29
- // anything to it.
30
- if (!input) {
31
- return "";
32
- }
33
-
34
- return appendCopyToText(input);
35
- }
package/lib/async-op.ts DELETED
@@ -1,286 +0,0 @@
1
- type Falsy = null | undefined | false | 0 | 0n | "";
2
-
3
- type Truthy<T> = Exclude<T, Falsy>;
4
-
5
- interface Operation<SuccessValue, FailureValue> {
6
- readonly type: "SUCCESS" | "FAILURE" | "PENDING";
7
- readonly isPending: boolean;
8
- readonly isSuccess: boolean;
9
- readonly isFailure: boolean;
10
-
11
- val: SuccessValue | FailureValue | null;
12
-
13
- valueOrNull(): SuccessValue | null;
14
- valueOrThrow(): SuccessValue;
15
- hasTruthyValue(): boolean;
16
- failureValueOrNull(): FailureValue | null;
17
- failureValueOrThrow(): FailureValue;
18
-
19
- flatMap<T extends AsyncOp<unknown, unknown>>(
20
- mappingFn: (value: SuccessValue) => T,
21
- ): T | Failure<FailureValue> | Pending;
22
-
23
- mapSuccess<MappedSuccess>(
24
- mappingFn: (value: SuccessValue) => MappedSuccess,
25
- ): Operation<MappedSuccess, FailureValue>;
26
-
27
- mapFailure<MappedFailure>(
28
- mappingFn: (value: FailureValue) => MappedFailure,
29
- ): Operation<SuccessValue, MappedFailure>;
30
-
31
- unpack<S, F, P>(
32
- mapS: (value: SuccessValue) => S,
33
- mapF: (failure: FailureValue) => F,
34
- mapP: () => P,
35
- ): S | F | P;
36
-
37
- toJSON(): object;
38
- }
39
-
40
- export class Pending implements Operation<never, never> {
41
- readonly type = "PENDING" as const;
42
- readonly isPending = true as const;
43
- readonly isSuccess = false as const;
44
- readonly isFailure = false as const;
45
-
46
- val = null;
47
-
48
- valueOrNull(): null {
49
- return null;
50
- }
51
-
52
- valueOrThrow(): never {
53
- throw new Error(
54
- `AsyncOp value was accessed but the op is in Pending state.`,
55
- { cause: this },
56
- );
57
- }
58
-
59
- hasTruthyValue(): false {
60
- return false;
61
- }
62
-
63
- failureValueOrNull(): null {
64
- return null;
65
- }
66
-
67
- failureValueOrThrow(): never {
68
- throw new Error(
69
- `AsyncOp failure value was accessed but the op is in Pending state.`,
70
- { cause: this },
71
- );
72
- }
73
-
74
- flatMap() {
75
- return new Pending();
76
- }
77
-
78
- mapSuccess() {
79
- return new Pending();
80
- }
81
-
82
- mapFailure() {
83
- return new Pending();
84
- }
85
-
86
- unpack<S, F, P>(
87
- _mapS: (value: never) => S,
88
- _mapF: (failure: never) => F,
89
- mapP: () => P,
90
- ): S | F | P {
91
- return mapP();
92
- }
93
-
94
- toJSON() {
95
- return { type: this.type };
96
- }
97
- }
98
-
99
- export class Success<SuccessValue> implements Operation<SuccessValue, never> {
100
- readonly type = "SUCCESS" as const;
101
- readonly isPending = false as const;
102
- readonly isSuccess = true as const;
103
- readonly isFailure = false as const;
104
- readonly value: SuccessValue;
105
- readonly val: SuccessValue;
106
-
107
- constructor(value: SuccessValue) {
108
- this.value = value;
109
- this.val = value;
110
- }
111
-
112
- valueOrNull(): SuccessValue {
113
- return this.value;
114
- }
115
-
116
- valueOrThrow(): SuccessValue {
117
- return this.value;
118
- }
119
-
120
- hasTruthyValue(): this is Success<Truthy<SuccessValue>> {
121
- return !!this.value;
122
- }
123
-
124
- failureValueOrNull(): null {
125
- return null;
126
- }
127
-
128
- failureValueOrThrow(): never {
129
- throw new Error(
130
- `AsyncOp failure value was accessed but the op is in Success state.`,
131
- { cause: this },
132
- );
133
- }
134
-
135
- flatMap<T extends AsyncOp<unknown, unknown>>(
136
- mappingFn: (value: SuccessValue) => T,
137
- ) {
138
- return mappingFn(this.value);
139
- }
140
-
141
- mapSuccess<MappedValue>(mappingFn: (value: SuccessValue) => MappedValue) {
142
- return new Success(mappingFn(this.value));
143
- }
144
-
145
- mapFailure() {
146
- return new Success(this.value);
147
- }
148
-
149
- unpack<S, F, P>(
150
- mapS: (value: SuccessValue) => S,
151
- _mapF: (failure: never) => F,
152
- _mapP: () => P,
153
- ): S | F | P {
154
- return mapS(this.value);
155
- }
156
-
157
- toJSON() {
158
- return {
159
- type: this.type,
160
- value: this.value,
161
- };
162
- }
163
- }
164
-
165
- export class Failure<FailureValue> implements Operation<never, FailureValue> {
166
- readonly type = "FAILURE" as const;
167
- readonly isPending = false as const;
168
- readonly isSuccess = false as const;
169
- readonly isFailure = true as const;
170
- readonly failure: FailureValue;
171
- readonly val: FailureValue;
172
-
173
- constructor(failure: FailureValue) {
174
- this.failure = failure;
175
- this.val = failure;
176
- }
177
-
178
- valueOrNull(): null {
179
- return null;
180
- }
181
-
182
- valueOrThrow(): never {
183
- throw new Error(
184
- `AsyncOp value was accessed but the op is in Failure state.`,
185
- { cause: this },
186
- );
187
- }
188
-
189
- hasTruthyValue(): false {
190
- return false;
191
- }
192
-
193
- failureValueOrNull(): FailureValue {
194
- return this.failure;
195
- }
196
-
197
- failureValueOrThrow(): FailureValue {
198
- return this.failure;
199
- }
200
-
201
- flatMap() {
202
- return new Failure(this.failure);
203
- }
204
-
205
- mapSuccess() {
206
- return new Failure(this.failure);
207
- }
208
-
209
- mapFailure<MappedFailure>(mappingFn: (value: FailureValue) => MappedFailure) {
210
- return new Failure(mappingFn(this.failure));
211
- }
212
-
213
- unpack<S, F, P>(
214
- _mapS: (value: never) => S,
215
- mapF: (failure: FailureValue) => F,
216
- _mapP: () => P,
217
- ): S | F | P {
218
- return mapF(this.failure);
219
- }
220
-
221
- toJSON() {
222
- return {
223
- type: this.type,
224
- failure: this.failure,
225
- };
226
- }
227
- }
228
-
229
- /**
230
- * Folds multiple ops into a single op.
231
- *
232
- * To return a Success, all ops provided must be a Success. If any Failures are
233
- * encountered, will return the first one found.
234
- *
235
- * If neither of these conditions is true, will return Pending.
236
- *
237
- * Note that if passed an empty array, will always return a Success (with an
238
- * empty array as value). This mimics the semantics of many JS constructs, like
239
- * Promise.all or Array.prototype.every.
240
- */
241
- export function fold<Ops extends readonly AsyncOp<unknown, unknown>[] | []>(
242
- ops: Ops,
243
- ): AsyncOp<
244
- {
245
- -readonly [Index in keyof Ops]: Ops[Index] extends AsyncOp<infer S, unknown>
246
- ? S
247
- : never;
248
- },
249
- Ops[number] extends AsyncOp<unknown, infer F> ? F : never
250
- > {
251
- // Note that due to the semantics of `every`, if the array provided to `fold`
252
- // is empty, the result will be a Success with an empty array.
253
- if (ops.every((v) => v.isSuccess)) {
254
- return new Success(
255
- (ops as Success<unknown>[]).map((op) => op.value),
256
- ) as never;
257
- }
258
-
259
- const firstFail = ops.find((op) => op.isFailure);
260
- if (firstFail) {
261
- return firstFail as never;
262
- }
263
-
264
- return new Pending() as never;
265
- }
266
-
267
- export function isAsyncOp(value: unknown): value is AsyncOp<unknown, unknown> {
268
- return (
269
- value instanceof Pending ||
270
- value instanceof Success ||
271
- value instanceof Failure
272
- );
273
- }
274
-
275
- export type AsyncOp<SuccessValue, FailureValue> =
276
- | Pending
277
- | Success<SuccessValue>
278
- | Failure<FailureValue>;
279
-
280
- export function fromTryCatch<T>(callback: () => T) {
281
- try {
282
- return new Success(callback());
283
- } catch (cause) {
284
- return new Failure(cause);
285
- }
286
- }
package/lib/atomic.css.ts DELETED
@@ -1,11 +0,0 @@
1
- import { createSprinkles, defineProperties } from "@vanilla-extract/sprinkles";
2
-
3
- const atomic = defineProperties({
4
- properties: {
5
- textAlign: ["start", "center", "end"],
6
- },
7
- });
8
-
9
- export const textVariants = createSprinkles(atomic);
10
-
11
- export type TextVariants = Parameters<typeof textVariants>[0];