@indietabletop/appkit 3.2.0-1 → 3.2.0-11

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 (97) hide show
  1. package/lib/ExternalLink.tsx +10 -0
  2. package/lib/FormSubmitButton.tsx +58 -0
  3. package/lib/FullscreenDismissBlocker.tsx +23 -0
  4. package/lib/IndieTabletopClubLogo.tsx +44 -0
  5. package/lib/IndieTabletopClubSymbol.tsx +37 -0
  6. package/lib/Letterhead/index.tsx +85 -0
  7. package/lib/Letterhead/stories.tsx +45 -0
  8. package/lib/Letterhead/style.css.ts +141 -0
  9. package/lib/LetterheadForm/LetterheadReadonlyTextField.stories.tsx +21 -0
  10. package/lib/LetterheadForm/LetterheadSubmitError.stories.tsx +23 -0
  11. package/lib/LetterheadForm/LetterheadTextField.stories.tsx +23 -0
  12. package/lib/LetterheadForm/index.tsx +94 -0
  13. package/lib/LetterheadForm/style.css.ts +85 -0
  14. package/lib/LoadingIndicator.tsx +39 -0
  15. package/lib/ServiceWorkerHandler.tsx +53 -0
  16. package/lib/animations.css.ts +17 -0
  17. package/lib/append-copy-to-text.test.ts +29 -0
  18. package/lib/append-copy-to-text.ts +35 -0
  19. package/lib/async-op.ts +246 -0
  20. package/lib/atomic.css.ts +11 -0
  21. package/{dist/caught-value.js → lib/caught-value.ts} +10 -8
  22. package/lib/class-names.ts +33 -0
  23. package/lib/client.ts +288 -0
  24. package/lib/common.css.ts +48 -0
  25. package/lib/failureMessages.test.ts +169 -0
  26. package/lib/failureMessages.ts +97 -0
  27. package/lib/globals.css.ts +45 -0
  28. package/{dist/index.d.ts → lib/index.ts} +9 -1
  29. package/lib/internal.css.ts +10 -0
  30. package/lib/media.ts +50 -0
  31. package/lib/storybook/decorators.tsx +10 -0
  32. package/lib/structs.ts +17 -0
  33. package/{dist/types.d.ts → lib/types.ts} +11 -6
  34. package/lib/use-async-op.ts +16 -0
  35. package/lib/use-document-background-color.ts +16 -0
  36. package/lib/use-form.ts +73 -0
  37. package/{dist/use-is-installed.js → lib/use-is-installed.ts} +7 -3
  38. package/lib/use-media-query.ts +21 -0
  39. package/lib/use-reverting-state.ts +32 -0
  40. package/lib/use-scroll-restoration.ts +99 -0
  41. package/lib/validations.ts +25 -0
  42. package/lib/vars.css.ts +9 -0
  43. package/package.json +13 -6
  44. package/dist/ExternalLink.d.ts +0 -3
  45. package/dist/ExternalLink.js +0 -4
  46. package/dist/FormSubmitButton.d.ts +0 -7
  47. package/dist/FormSubmitButton.js +0 -16
  48. package/dist/FullscreenDismissBlocker.d.ts +0 -5
  49. package/dist/FullscreenDismissBlocker.js +0 -19
  50. package/dist/IndieTabletopClubLogo.d.ts +0 -7
  51. package/dist/IndieTabletopClubLogo.js +0 -6
  52. package/dist/IndieTabletopClubSymbol.d.ts +0 -7
  53. package/dist/IndieTabletopClubSymbol.js +0 -5
  54. package/dist/Letterhead.d.ts +0 -6
  55. package/dist/Letterhead.js +0 -14
  56. package/dist/LetterheadFooter.d.ts +0 -1
  57. package/dist/LetterheadFooter.js +0 -17
  58. package/dist/LoadingIndicator.d.ts +0 -3
  59. package/dist/LoadingIndicator.js +0 -17
  60. package/dist/ServiceWorkerHandler.d.ts +0 -11
  61. package/dist/ServiceWorkerHandler.js +0 -42
  62. package/dist/animations.css.d.ts +0 -3
  63. package/dist/animations.css.js +0 -14
  64. package/dist/append-copy-to-text.d.ts +0 -10
  65. package/dist/append-copy-to-text.js +0 -29
  66. package/dist/async-op.d.ts +0 -87
  67. package/dist/async-op.js +0 -223
  68. package/dist/caught-value.d.ts +0 -15
  69. package/dist/class-names.d.ts +0 -4
  70. package/dist/class-names.js +0 -6
  71. package/dist/client.d.ts +0 -117
  72. package/dist/client.js +0 -201
  73. package/dist/common.css.d.ts +0 -5
  74. package/dist/common.css.js +0 -38
  75. package/dist/globals.css.d.ts +0 -1
  76. package/dist/globals.css.js +0 -35
  77. package/dist/index.js +0 -25
  78. package/dist/internal.css.d.ts +0 -4
  79. package/dist/internal.css.js +0 -21
  80. package/dist/media.d.ts +0 -39
  81. package/dist/media.js +0 -49
  82. package/dist/structs.d.ts +0 -20
  83. package/dist/structs.js +0 -15
  84. package/dist/types.js +0 -1
  85. package/dist/use-async-op.d.ts +0 -6
  86. package/dist/use-async-op.js +0 -12
  87. package/dist/use-document-background-color.d.ts +0 -4
  88. package/dist/use-document-background-color.js +0 -14
  89. package/dist/use-form.d.ts +0 -29
  90. package/dist/use-form.js +0 -33
  91. package/dist/use-is-installed.d.ts +0 -8
  92. package/dist/use-media-query.d.ts +0 -1
  93. package/dist/use-media-query.js +0 -15
  94. package/dist/use-reverting-state.d.ts +0 -5
  95. package/dist/use-reverting-state.js +0 -26
  96. package/dist/use-scroll-restoration.d.ts +0 -25
  97. package/dist/use-scroll-restoration.js +0 -67
@@ -1,67 +0,0 @@
1
- import { useEffect, useLayoutEffect, useMemo } from "react";
2
- const scrollPositions = new Map();
3
- /**
4
- * Handles scroll restoration on window.
5
- *
6
- * This hook behaves a little differently than the default browser scroll
7
- * restoration. This is due to limitations of Wouter (our router of choice)
8
- * as well the need to make the app feel more app-like.
9
- *
10
- * Every scroll position is remembered however the user has got to it (we
11
- * don't differentiate between new entries in browser history and back
12
- * navigation), but they are only restored if the user last visited the
13
- * location less than 60 minutes ago.
14
- */
15
- export function useScrollRestoration(
16
- /**
17
- * The current path, provided by your router of choice.
18
- */
19
- pathname, options) {
20
- // Standardise pathname, making sure that paths ending with and without
21
- // a slash are treated equally
22
- const normalizedPathname = pathname.replace(/\/$/, "") || "/";
23
- const neverRestore = useMemo(() => new Set(options?.neverRestore), [options?.neverRestore]);
24
- // Record scroll position for given pathname on pushState/replaceState.
25
- useEffect(() => {
26
- const handleEvent = () => {
27
- const x = window.scrollX;
28
- const y = window.scrollY;
29
- scrollPositions.set(normalizedPathname, [Date.now(), x, y]);
30
- console.info(`Set scroll position for '${normalizedPathname}' (x: ${x}, y: ${y}).`);
31
- };
32
- // These events are provided by Wouter. They are not native browser events!
33
- window.addEventListener("pushState", handleEvent);
34
- window.addEventListener("replaceState", handleEvent);
35
- return () => {
36
- window.removeEventListener("pushState", handleEvent);
37
- window.removeEventListener("replaceState", handleEvent);
38
- };
39
- }, [normalizedPathname]);
40
- // Restore scroll position if last visit was less than 60 minutes ago.
41
- useLayoutEffect(() => {
42
- const maxDiff = 60000 * 60; // 60 minutes
43
- const coordinates = scrollPositions.get(normalizedPathname);
44
- if (coordinates) {
45
- if (!neverRestore.has(normalizedPathname)) {
46
- const now = Date.now();
47
- const [ts, x, y] = coordinates;
48
- if (now - ts < maxDiff) {
49
- window.scrollTo(x, y);
50
- console.info(`Restoring scroll position for '${normalizedPathname}' (x: ${x}, y: ${y}).`);
51
- }
52
- else {
53
- window.scrollTo(0, 0);
54
- console.info(`Not restoring scroll position for '${normalizedPathname}'. Last visit >60 min ago.`);
55
- }
56
- }
57
- else {
58
- window.scrollTo(0, 0);
59
- console.info(`Not restoring scroll position for '${normalizedPathname}'. Page is set never to restore.`);
60
- }
61
- }
62
- else {
63
- window.scrollTo(0, 0);
64
- console.info(`Not restoring scroll position for '${normalizedPathname}'. Page not visited yet.`);
65
- }
66
- }, [normalizedPathname]);
67
- }