aidos-ui 3.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 (339) hide show
  1. package/.prettierrc +4 -0
  2. package/LICENSE +21 -0
  3. package/README.md +55 -0
  4. package/dist/Badge.d.ts +7 -0
  5. package/dist/Badge.js +22 -0
  6. package/dist/Badge.js.map +1 -0
  7. package/dist/BaseButton.d.ts +13 -0
  8. package/dist/BaseButton.js +22 -0
  9. package/dist/BaseButton.js.map +1 -0
  10. package/dist/BaseInput.d.ts +15 -0
  11. package/dist/BaseInput.js +14 -0
  12. package/dist/BaseInput.js.map +1 -0
  13. package/dist/BaseLink.d.ts +17 -0
  14. package/dist/BaseLink.js +28 -0
  15. package/dist/BaseLink.js.map +1 -0
  16. package/dist/BaseList.d.ts +6 -0
  17. package/dist/BaseList.js +14 -0
  18. package/dist/BaseList.js.map +1 -0
  19. package/dist/BaseListAddOn.d.ts +5 -0
  20. package/dist/BaseListAddOn.js +7 -0
  21. package/dist/BaseListAddOn.js.map +1 -0
  22. package/dist/BaseListItem.d.ts +27 -0
  23. package/dist/BaseListItem.js +26 -0
  24. package/dist/BaseListItem.js.map +1 -0
  25. package/dist/BaseView.d.ts +12 -0
  26. package/dist/BaseView.js +26 -0
  27. package/dist/BaseView.js.map +1 -0
  28. package/dist/Box.d.ts +5 -0
  29. package/dist/Box.js +6 -0
  30. package/dist/Box.js.map +1 -0
  31. package/dist/Button.d.ts +20 -0
  32. package/dist/Button.js +20 -0
  33. package/dist/Button.js.map +1 -0
  34. package/dist/Calendar.d.ts +18 -0
  35. package/dist/Calendar.js +57 -0
  36. package/dist/Calendar.js.map +1 -0
  37. package/dist/Card.d.ts +4 -0
  38. package/dist/Card.js +12 -0
  39. package/dist/Card.js.map +1 -0
  40. package/dist/Checkbox.d.ts +12 -0
  41. package/dist/Checkbox.js +32 -0
  42. package/dist/Checkbox.js.map +1 -0
  43. package/dist/Circle.d.ts +6 -0
  44. package/dist/Circle.js +12 -0
  45. package/dist/Circle.js.map +1 -0
  46. package/dist/Column.d.ts +6 -0
  47. package/dist/Column.js +7 -0
  48. package/dist/Column.js.map +1 -0
  49. package/dist/DarkMode.d.ts +13 -0
  50. package/dist/DarkMode.js +61 -0
  51. package/dist/DarkMode.js.map +1 -0
  52. package/dist/DateInput.d.ts +13 -0
  53. package/dist/DateInput.js +29 -0
  54. package/dist/DateInput.js.map +1 -0
  55. package/dist/DatePicker.d.ts +12 -0
  56. package/dist/DatePicker.js +34 -0
  57. package/dist/DatePicker.js.map +1 -0
  58. package/dist/DatetimeInput.d.ts +13 -0
  59. package/dist/DatetimeInput.js +31 -0
  60. package/dist/DatetimeInput.js.map +1 -0
  61. package/dist/DesignBook.d.ts +2 -0
  62. package/dist/DesignBook.js +55 -0
  63. package/dist/DesignBook.js.map +1 -0
  64. package/dist/Dialog.d.ts +17 -0
  65. package/dist/Dialog.js +86 -0
  66. package/dist/Dialog.js.map +1 -0
  67. package/dist/Dropdown.d.ts +10 -0
  68. package/dist/Dropdown.js +64 -0
  69. package/dist/Dropdown.js.map +1 -0
  70. package/dist/Emitter.d.ts +6 -0
  71. package/dist/Emitter.js +19 -0
  72. package/dist/Emitter.js.map +1 -0
  73. package/dist/FlexLayout.d.ts +11 -0
  74. package/dist/FlexLayout.js +18 -0
  75. package/dist/FlexLayout.js.map +1 -0
  76. package/dist/Icon.d.ts +12 -0
  77. package/dist/Icon.js +69 -0
  78. package/dist/Icon.js.map +1 -0
  79. package/dist/IconButton.d.ts +9 -0
  80. package/dist/IconButton.js +31 -0
  81. package/dist/IconButton.js.map +1 -0
  82. package/dist/IconLink.d.ts +9 -0
  83. package/dist/IconLink.js +31 -0
  84. package/dist/IconLink.js.map +1 -0
  85. package/dist/IconType.d.ts +1 -0
  86. package/dist/IconType.js +2 -0
  87. package/dist/IconType.js.map +1 -0
  88. package/dist/Interactable.d.ts +48 -0
  89. package/dist/Interactable.js +131 -0
  90. package/dist/Interactable.js.map +1 -0
  91. package/dist/Link.d.ts +20 -0
  92. package/dist/Link.js +22 -0
  93. package/dist/Link.js.map +1 -0
  94. package/dist/List.d.ts +11 -0
  95. package/dist/List.js +17 -0
  96. package/dist/List.js.map +1 -0
  97. package/dist/ListButtonItem.d.ts +15 -0
  98. package/dist/ListButtonItem.js +9 -0
  99. package/dist/ListButtonItem.js.map +1 -0
  100. package/dist/ListDivider.d.ts +2 -0
  101. package/dist/ListDivider.js +12 -0
  102. package/dist/ListDivider.js.map +1 -0
  103. package/dist/ListHeaderItem.d.ts +11 -0
  104. package/dist/ListHeaderItem.js +13 -0
  105. package/dist/ListHeaderItem.js.map +1 -0
  106. package/dist/ListItem.d.ts +10 -0
  107. package/dist/ListItem.js +7 -0
  108. package/dist/ListItem.js.map +1 -0
  109. package/dist/ListLinkItem.d.ts +17 -0
  110. package/dist/ListLinkItem.js +9 -0
  111. package/dist/ListLinkItem.js.map +1 -0
  112. package/dist/ListSpacer.d.ts +2 -0
  113. package/dist/ListSpacer.js +13 -0
  114. package/dist/ListSpacer.js.map +1 -0
  115. package/dist/OnVisible.d.ts +5 -0
  116. package/dist/OnVisible.js +28 -0
  117. package/dist/OnVisible.js.map +1 -0
  118. package/dist/Popover.d.ts +21 -0
  119. package/dist/Popover.js +88 -0
  120. package/dist/Popover.js.map +1 -0
  121. package/dist/ProgressBar.d.ts +8 -0
  122. package/dist/ProgressBar.js +42 -0
  123. package/dist/ProgressBar.js.map +1 -0
  124. package/dist/ProgressCircle.d.ts +6 -0
  125. package/dist/ProgressCircle.js +12 -0
  126. package/dist/ProgressCircle.js.map +1 -0
  127. package/dist/Providers.d.ts +9 -0
  128. package/dist/Providers.js +16 -0
  129. package/dist/Providers.js.map +1 -0
  130. package/dist/RangeInput.d.ts +14 -0
  131. package/dist/RangeInput.js +32 -0
  132. package/dist/RangeInput.js.map +1 -0
  133. package/dist/ResultOrError.d.ts +13 -0
  134. package/dist/ResultOrError.js +7 -0
  135. package/dist/ResultOrError.js.map +1 -0
  136. package/dist/RootView.d.ts +5 -0
  137. package/dist/RootView.js +35 -0
  138. package/dist/RootView.js.map +1 -0
  139. package/dist/Router.d.ts +2 -0
  140. package/dist/Router.js +37 -0
  141. package/dist/Router.js.map +1 -0
  142. package/dist/RouterState.d.ts +38 -0
  143. package/dist/RouterState.js +111 -0
  144. package/dist/RouterState.js.map +1 -0
  145. package/dist/Row.d.ts +6 -0
  146. package/dist/Row.js +7 -0
  147. package/dist/Row.js.map +1 -0
  148. package/dist/StackContext.d.ts +8 -0
  149. package/dist/StackContext.js +25 -0
  150. package/dist/StackContext.js.map +1 -0
  151. package/dist/StaticCheckbox.d.ts +17 -0
  152. package/dist/StaticCheckbox.js +48 -0
  153. package/dist/StaticCheckbox.js.map +1 -0
  154. package/dist/Storage.d.ts +12 -0
  155. package/dist/Storage.js +148 -0
  156. package/dist/Storage.js.map +1 -0
  157. package/dist/Stream.d.ts +9 -0
  158. package/dist/Stream.js +36 -0
  159. package/dist/Stream.js.map +1 -0
  160. package/dist/Sublist.d.ts +12 -0
  161. package/dist/Sublist.js +18 -0
  162. package/dist/Sublist.js.map +1 -0
  163. package/dist/SubmitIconInput.d.ts +9 -0
  164. package/dist/SubmitIconInput.js +25 -0
  165. package/dist/SubmitIconInput.js.map +1 -0
  166. package/dist/Tabs.d.ts +20 -0
  167. package/dist/Tabs.js +35 -0
  168. package/dist/Tabs.js.map +1 -0
  169. package/dist/Text.d.ts +25 -0
  170. package/dist/Text.js +50 -0
  171. package/dist/Text.js.map +1 -0
  172. package/dist/TextArea.d.ts +10 -0
  173. package/dist/TextArea.js +22 -0
  174. package/dist/TextArea.js.map +1 -0
  175. package/dist/TextInput.d.ts +14 -0
  176. package/dist/TextInput.js +52 -0
  177. package/dist/TextInput.js.map +1 -0
  178. package/dist/TextInputWithState.d.ts +10 -0
  179. package/dist/TextInputWithState.js +14 -0
  180. package/dist/TextInputWithState.js.map +1 -0
  181. package/dist/TextPairing.d.ts +21 -0
  182. package/dist/TextPairing.js +26 -0
  183. package/dist/TextPairing.js.map +1 -0
  184. package/dist/TimeInput.d.ts +15 -0
  185. package/dist/TimeInput.js +58 -0
  186. package/dist/TimeInput.js.map +1 -0
  187. package/dist/Tooltip.d.ts +11 -0
  188. package/dist/Tooltip.js +72 -0
  189. package/dist/Tooltip.js.map +1 -0
  190. package/dist/aria.d.ts +8 -0
  191. package/dist/aria.js +42 -0
  192. package/dist/aria.js.map +1 -0
  193. package/dist/guid.d.ts +1 -0
  194. package/dist/guid.js +7 -0
  195. package/dist/guid.js.map +1 -0
  196. package/dist/hash.d.ts +1 -0
  197. package/dist/hash.js +20 -0
  198. package/dist/hash.js.map +1 -0
  199. package/dist/index.d.ts +65 -0
  200. package/dist/index.js +66 -0
  201. package/dist/index.js.map +1 -0
  202. package/dist/jss.d.ts +110 -0
  203. package/dist/jss.js +438 -0
  204. package/dist/jss.js.map +1 -0
  205. package/dist/numberToBase.d.ts +1 -0
  206. package/dist/numberToBase.js +44 -0
  207. package/dist/numberToBase.js.map +1 -0
  208. package/dist/stateMachineContextFactory.d.ts +36 -0
  209. package/dist/stateMachineContextFactory.js +48 -0
  210. package/dist/stateMachineContextFactory.js.map +1 -0
  211. package/dist/useCookie.d.ts +9 -0
  212. package/dist/useCookie.js +65 -0
  213. package/dist/useCookie.js.map +1 -0
  214. package/dist/useKeyboard.d.ts +8 -0
  215. package/dist/useKeyboard.js +26 -0
  216. package/dist/useKeyboard.js.map +1 -0
  217. package/dist/useNavigation.d.ts +5 -0
  218. package/dist/useNavigation.js +79 -0
  219. package/dist/useNavigation.js.map +1 -0
  220. package/dist/usePromise.d.ts +1 -0
  221. package/dist/usePromise.js +12 -0
  222. package/dist/usePromise.js.map +1 -0
  223. package/dist/useRefEffect.d.ts +1 -0
  224. package/dist/useRefEffect.js +15 -0
  225. package/dist/useRefEffect.js.map +1 -0
  226. package/next-env.d.ts +5 -0
  227. package/next.config.js +21 -0
  228. package/package.json +40 -0
  229. package/scripts/publish.js +27 -0
  230. package/src/Badge.tsx +36 -0
  231. package/src/BaseButton.tsx +58 -0
  232. package/src/BaseInput.tsx +57 -0
  233. package/src/BaseLink.tsx +77 -0
  234. package/src/BaseList.tsx +29 -0
  235. package/src/BaseListAddOn.tsx +10 -0
  236. package/src/BaseListItem.tsx +117 -0
  237. package/src/BaseView.tsx +57 -0
  238. package/src/Box.tsx +20 -0
  239. package/src/Button.tsx +84 -0
  240. package/src/Calendar.tsx +125 -0
  241. package/src/Card.tsx +17 -0
  242. package/src/Checkbox.tsx +63 -0
  243. package/src/Circle.tsx +24 -0
  244. package/src/Column.tsx +12 -0
  245. package/src/DarkMode.tsx +99 -0
  246. package/src/DateInput.tsx +63 -0
  247. package/src/DatePicker.tsx +67 -0
  248. package/src/DatetimeInput.tsx +71 -0
  249. package/src/DesignBook.tsx +697 -0
  250. package/src/Dialog.tsx +144 -0
  251. package/src/Dropdown.tsx +129 -0
  252. package/src/Emitter.ts +26 -0
  253. package/src/FlexLayout.tsx +53 -0
  254. package/src/Icon.tsx +96 -0
  255. package/src/IconButton.tsx +66 -0
  256. package/src/IconLink.tsx +58 -0
  257. package/src/IconType.ts +787 -0
  258. package/src/Interactable.tsx +159 -0
  259. package/src/Link.tsx +86 -0
  260. package/src/List.tsx +41 -0
  261. package/src/ListButtonItem.tsx +69 -0
  262. package/src/ListDivider.tsx +13 -0
  263. package/src/ListHeaderItem.tsx +45 -0
  264. package/src/ListItem.tsx +27 -0
  265. package/src/ListLinkItem.tsx +76 -0
  266. package/src/ListSpacer.tsx +14 -0
  267. package/src/OnVisible.tsx +42 -0
  268. package/src/Popover.tsx +141 -0
  269. package/src/ProgressBar.tsx +63 -0
  270. package/src/ProgressCircle.tsx +38 -0
  271. package/src/Providers.tsx +33 -0
  272. package/src/RangeInput.tsx +82 -0
  273. package/src/ResultOrError.ts +15 -0
  274. package/src/RootView.tsx +55 -0
  275. package/src/Router.tsx +62 -0
  276. package/src/RouterState.tsx +154 -0
  277. package/src/Row.tsx +12 -0
  278. package/src/StackContext.tsx +52 -0
  279. package/src/StaticCheckbox.tsx +74 -0
  280. package/src/Storage.tsx +200 -0
  281. package/src/Stream.tsx +50 -0
  282. package/src/Sublist.tsx +62 -0
  283. package/src/SubmitIconInput.tsx +45 -0
  284. package/src/Tabs.tsx +103 -0
  285. package/src/Text.tsx +102 -0
  286. package/src/TextArea.tsx +45 -0
  287. package/src/TextInput.tsx +111 -0
  288. package/src/TextInputWithState.tsx +35 -0
  289. package/src/TextPairing.tsx +115 -0
  290. package/src/TimeInput.tsx +109 -0
  291. package/src/Tooltip.tsx +108 -0
  292. package/src/aria.ts +72 -0
  293. package/src/examples/ExampleDialog.tsx +28 -0
  294. package/src/guid.ts +7 -0
  295. package/src/hash.ts +21 -0
  296. package/src/index.ts +65 -0
  297. package/src/jss.tsx +607 -0
  298. package/src/numberToBase.ts +52 -0
  299. package/src/pages/Badge.mdx +30 -0
  300. package/src/pages/Button.mdx +57 -0
  301. package/src/pages/Calendar.mdx +60 -0
  302. package/src/pages/Checkbox.mdx +56 -0
  303. package/src/pages/Dialog.mdx +32 -0
  304. package/src/pages/FlexLayout.mdx +77 -0
  305. package/src/pages/Hashing.mdx +20 -0
  306. package/src/pages/Icon.mdx +63 -0
  307. package/src/pages/IconButton.mdx +144 -0
  308. package/src/pages/Link.mdx +57 -0
  309. package/src/pages/List.mdx +292 -0
  310. package/src/pages/ListHeader.mdx +94 -0
  311. package/src/pages/Popover.mdx +101 -0
  312. package/src/pages/ProgressBar.mdx +20 -0
  313. package/src/pages/ProgressCircle.mdx +35 -0
  314. package/src/pages/RangeInput.mdx +109 -0
  315. package/src/pages/Tabs.mdx +168 -0
  316. package/src/pages/Text.mdx +133 -0
  317. package/src/pages/TextInput.mdx +110 -0
  318. package/src/pages/TextPairing.mdx +155 -0
  319. package/src/pages/TimeInput.mdx +73 -0
  320. package/src/pages/Tooltip.mdx +28 -0
  321. package/src/pages/_app.tsx +561 -0
  322. package/src/pages/_document.tsx +30 -0
  323. package/src/pages/css-in-js.mdx +127 -0
  324. package/src/pages/index.mdx +58 -0
  325. package/src/pages/navigation.mdx +56 -0
  326. package/src/pages/prism.css +3 -0
  327. package/src/pages/useCookie.mdx +15 -0
  328. package/src/pages/useKeyboard.mdx +20 -0
  329. package/src/pages/useNavigation.mdx +30 -0
  330. package/src/pages/usePromise.mdx +15 -0
  331. package/src/pages/useRefEffect.mdx +49 -0
  332. package/src/stateMachineContextFactory.tsx +111 -0
  333. package/src/useCookie.tsx +89 -0
  334. package/src/useKeyboard.tsx +43 -0
  335. package/src/useNavigation.tsx +89 -0
  336. package/src/usePromise.tsx +18 -0
  337. package/src/useRefEffect.tsx +18 -0
  338. package/tsconfig.build.json +23 -0
  339. package/tsconfig.json +23 -0
@@ -0,0 +1,159 @@
1
+ import { JSStyle, Padding, TextColor, cssVar, getPadding } from "./jss";
2
+
3
+ export type InteractableColor = "positive" | "secondary" | "negative";
4
+
5
+ const jsStyles = {
6
+ root: {
7
+ cursor: "pointer",
8
+ display: "inline-flex",
9
+ alignItems: "center",
10
+ transition: "opacity 0.1s ease-in",
11
+ outlineColor: "var(--outline)",
12
+ "[aria-disabled=true]": {
13
+ color: "var(--secondary-text)",
14
+ backgroundColor: "var(--background-button-secondary)",
15
+ },
16
+ ":focus-visible": {
17
+ outlineWidth: "2px",
18
+ outlineStyle: "solid",
19
+ outlineOffset: -2,
20
+ },
21
+ },
22
+ positive: {
23
+ backgroundColor: "var(--background-button-positive)",
24
+ "[aria-disabled=true]": {
25
+ backgroundColor: "var(--background-button-disabled)",
26
+ },
27
+ },
28
+ secondary: {
29
+ backgroundColor: "var(--background-button-secondary)",
30
+ "[aria-disabled=true]": {
31
+ backgroundColor: "var(--background-button-disabled)",
32
+ },
33
+ },
34
+ negative: {
35
+ backgroundColor: "var(--background-button-negative)",
36
+ "[aria-disabled=true]": {
37
+ backgroundColor: "var(--background-button-disabled)",
38
+ },
39
+ },
40
+ disabled: {
41
+ cursor: "default",
42
+ },
43
+ bare: {
44
+ backgroundColor: "inherit",
45
+ outlineColor: "var(--outline)",
46
+ "[aria-disabled=true]": {
47
+ backgroundColor: "inherit",
48
+ },
49
+ "[aria-disabled=true]:hover": {
50
+ backgroundColor: "inherit",
51
+ },
52
+ },
53
+ opacityHover: {
54
+ ":hover": {
55
+ opacity: 0.8,
56
+ },
57
+ "[aria-disabled=true]:hover": {
58
+ opacity: 1,
59
+ },
60
+ },
61
+ colorHover: {},
62
+ };
63
+
64
+ export function getInteractableJSStyles({
65
+ color,
66
+ bare,
67
+ disabled,
68
+ animateInteraction,
69
+ padding,
70
+ }: {
71
+ color: InteractableColor;
72
+ bare: boolean;
73
+ disabled: boolean;
74
+ animateInteraction: boolean;
75
+ padding: Padding;
76
+ }): Array<JSStyle> {
77
+ return [
78
+ jsStyles.root,
79
+ color === "positive" && jsStyles.positive,
80
+ color === "secondary" && jsStyles.secondary,
81
+ color === "negative" && jsStyles.negative,
82
+ bare && jsStyles.bare,
83
+ disabled && jsStyles.disabled,
84
+ !bare && jsStyles.opacityHover,
85
+ animateInteraction &&
86
+ !disabled && {
87
+ position: "relative",
88
+ ":active": {
89
+ opacity: 0.95,
90
+ top: 1,
91
+ },
92
+ "[aria-disabled=true]:active": {
93
+ top: 0,
94
+ opacity: 1,
95
+ },
96
+ },
97
+ getPadding(padding),
98
+ ];
99
+ }
100
+
101
+ export const getGlyphColor = (
102
+ color: InteractableColor,
103
+ disabled: boolean | undefined,
104
+ bare: boolean | undefined
105
+ ): TextColor => {
106
+ if (disabled) {
107
+ return "subtle";
108
+ }
109
+
110
+ switch (color) {
111
+ case "positive":
112
+ return bare ? "highlight" : "light";
113
+ case "negative":
114
+ return bare ? "negative" : "light";
115
+ case "secondary":
116
+ return bare ? "primary" : "secondary";
117
+ }
118
+ };
119
+
120
+ export const getInteractableListItemJSStyles = ({
121
+ bare,
122
+ selected,
123
+ }: {
124
+ bare: boolean;
125
+ selected: boolean;
126
+ }) => {
127
+ return [
128
+ {
129
+ overflow: "hidden",
130
+ flexGrow: 1,
131
+ borderRadius: bare ? cssVar("--border-radius-m") : null,
132
+ textDecoration: "none",
133
+ ":hover": {
134
+ backgroundColor: "var(--hovered-background)",
135
+ },
136
+ ":active:hover": {
137
+ backgroundColor: "var(--pressed-background)",
138
+ },
139
+ "[aria-disabled=true]": {
140
+ backgroundColor: "var(--primary-background)",
141
+ },
142
+ "[aria-disabled=true]:active:hover": {
143
+ backgroundColor: "var(--primary-background)",
144
+ },
145
+ },
146
+ selected && {
147
+ backgroundColor: bare
148
+ ? cssVar("--light-highlight")
149
+ : cssVar("--selected-background"),
150
+ boxShadow: bare ? "" : "inset 1px 1px 2px -1px #0000004a",
151
+ ":hover": {
152
+ backgroundColor: "var(--hovered-background)",
153
+ },
154
+ ":active:hover": {
155
+ backgroundColor: "var(--pressed-background)",
156
+ },
157
+ },
158
+ ];
159
+ };
package/src/Link.tsx ADDED
@@ -0,0 +1,86 @@
1
+ import React from "react";
2
+
3
+ import { BaseLink, BaseLinkProps } from "./BaseLink";
4
+ import { Text } from "./Text";
5
+ import { IconType } from "./IconType";
6
+ import { Row } from "./Row";
7
+ import { Icon } from "./Icon";
8
+ import { FlexLayoutProps } from "./FlexLayout";
9
+ import { InteractableColor, getGlyphColor } from "./Interactable";
10
+ import { Size, Align, Gap, Justify, cssVar } from "./jss";
11
+
12
+ export interface LinkProps extends BaseLinkProps {
13
+ label: string;
14
+ color: InteractableColor;
15
+ size?: Size;
16
+ icon?: IconType;
17
+ iconSize?: Size;
18
+ children?: undefined;
19
+ iconPosition?: "left" | "right";
20
+ rowProps?: FlexLayoutProps;
21
+ align?: Align;
22
+ gap?: Gap;
23
+ justify?: Justify;
24
+ }
25
+
26
+ export const Link = React.forwardRef(
27
+ (
28
+ {
29
+ label,
30
+ color,
31
+ bare,
32
+ disabled,
33
+ icon,
34
+ iconSize = "medium",
35
+ iconPosition = "left",
36
+ align = "center",
37
+ gap = "small",
38
+ justify = "center",
39
+ jsStyle,
40
+ size = "medium",
41
+ ...otherProps
42
+ }: LinkProps,
43
+ ref?: React.Ref<HTMLAnchorElement>
44
+ ) => {
45
+ return (
46
+ <BaseLink
47
+ {...otherProps}
48
+ bare={bare}
49
+ ref={ref}
50
+ color={color}
51
+ disabled={disabled}
52
+ jsStyle={[
53
+ {
54
+ borderRadius: "var(--border-radius-m)",
55
+ justifyContent: "center",
56
+ userSelect: "none",
57
+ padding: cssVar("--spacing-m"),
58
+ display: "inline-flex",
59
+ textDecoration: "none",
60
+ },
61
+ jsStyle,
62
+ ]}
63
+ >
64
+ <Row grow={true} align={align} gap={gap} justify={justify}>
65
+ {icon && iconPosition === "left" && (
66
+ <Icon
67
+ icon={icon}
68
+ size={iconSize}
69
+ color={getGlyphColor(color, disabled, bare)}
70
+ />
71
+ )}
72
+ <Text size={size} color={getGlyphColor(color, disabled, bare)}>
73
+ {label}
74
+ </Text>
75
+ {icon && iconPosition === "right" && (
76
+ <Icon
77
+ icon={icon}
78
+ size={iconSize}
79
+ color={getGlyphColor(color, disabled, bare)}
80
+ />
81
+ )}
82
+ </Row>
83
+ </BaseLink>
84
+ );
85
+ }
86
+ );
package/src/List.tsx ADDED
@@ -0,0 +1,41 @@
1
+ import React from "react";
2
+ import { BaseList, BaseListProps } from "./BaseList";
3
+ import { useNavigation } from "./useNavigation";
4
+ import { cssVar } from "./jss";
5
+
6
+ interface ListProps extends BaseListProps {
7
+ ariaLabel: string;
8
+ bare?: boolean;
9
+ autofocus?: boolean;
10
+ role?: undefined;
11
+ navigation?: boolean;
12
+ }
13
+
14
+ export function List({
15
+ ariaLabel,
16
+ jsStyle,
17
+ autofocus = false,
18
+ navigation = true,
19
+ bare,
20
+ ...otherProps
21
+ }: ListProps) {
22
+ const rootRef = useNavigation({ autofocus, enabled: navigation });
23
+
24
+ return (
25
+ <BaseList
26
+ role="grid"
27
+ aria-label={ariaLabel}
28
+ ref={rootRef}
29
+ jsStyle={[
30
+ { overflow: "hidden" },
31
+ !bare && {
32
+ border: `1px solid ${cssVar("--divider")}`,
33
+ borderRadius: cssVar("--border-radius-l"),
34
+ backgroundColor: cssVar("--overlay-background"),
35
+ },
36
+ jsStyle,
37
+ ]}
38
+ {...otherProps}
39
+ />
40
+ );
41
+ }
@@ -0,0 +1,69 @@
1
+ import React from "react";
2
+
3
+ import { BaseListItem, BaseListItemProps } from "./BaseListItem";
4
+ import {
5
+ InteractableColor,
6
+ getGlyphColor,
7
+ getInteractableListItemJSStyles,
8
+ } from "./Interactable";
9
+ import { BaseButton } from "./BaseButton";
10
+
11
+ // @ts-ignore
12
+ interface ListButtonItemProps extends BaseListItemProps {
13
+ color: InteractableColor;
14
+ onClick: () => void;
15
+ headline: string;
16
+ body?: string;
17
+ disabled?: boolean;
18
+ selected?: boolean;
19
+ bare?: boolean;
20
+ children?: void;
21
+ }
22
+
23
+ export const ListButtonItem = React.forwardRef(
24
+ (
25
+ {
26
+ onClick,
27
+ color = "secondary",
28
+ disabled = false,
29
+ padding = "medium",
30
+ jsStyle,
31
+ gap,
32
+ selected,
33
+ bare,
34
+ ...otherProps
35
+ }: ListButtonItemProps,
36
+ ref?: React.Ref<HTMLButtonElement>
37
+ ) => {
38
+ return (
39
+ <BaseListItem
40
+ withDivider={!bare}
41
+ disabled={disabled}
42
+ padding="none"
43
+ gap={gap}
44
+ headlineColor={getGlyphColor(color, disabled, true)}
45
+ bodyColor={getGlyphColor(color, disabled, true)}
46
+ selected={selected}
47
+ aria-selected={selected}
48
+ bare={bare}
49
+ {...otherProps}
50
+ jsStyle={jsStyle}
51
+ >
52
+ {({ content }) => (
53
+ <BaseButton
54
+ padding={padding}
55
+ disabled={disabled}
56
+ animateInteraction={false}
57
+ bare={true}
58
+ color={bare ? "secondary" : color}
59
+ ref={ref}
60
+ jsStyle={getInteractableListItemJSStyles({ bare, selected })}
61
+ onClick={onClick}
62
+ >
63
+ {content}
64
+ </BaseButton>
65
+ )}
66
+ </BaseListItem>
67
+ );
68
+ }
69
+ );
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ import { BaseView } from "./BaseView";
3
+
4
+ const jsStyles = {
5
+ root: {
6
+ width: "100%",
7
+ borderBottom: "1px solid var(--divider)",
8
+ },
9
+ };
10
+
11
+ export function ListDivider() {
12
+ return <BaseView jsStyle={jsStyles.root} />;
13
+ }
@@ -0,0 +1,45 @@
1
+ import React, { ReactNode } from "react";
2
+ import { BaseListItem } from "./BaseListItem";
3
+ import { Position, cssVar } from "./jss";
4
+
5
+ export function ListHeaderItem({
6
+ bare,
7
+ highlight,
8
+ headline,
9
+ body,
10
+ withDivider,
11
+ addOn,
12
+ addOnPosition,
13
+ }: {
14
+ bare?: boolean;
15
+ highlight?: boolean;
16
+ headline: string;
17
+ body?: string;
18
+ withDivider?: boolean;
19
+ addOn?: ReactNode;
20
+ addOnPosition?: Position;
21
+ }) {
22
+ return (
23
+ <BaseListItem
24
+ bare={bare}
25
+ headline={headline}
26
+ headlineColor={highlight ? (bare ? "highlight" : "light") : "primary"}
27
+ headlineBold={true}
28
+ body={body}
29
+ addOn={addOn}
30
+ addOnPosition={addOnPosition}
31
+ withDivider={bare ? false : withDivider}
32
+ jsStyle={
33
+ bare
34
+ ? null
35
+ : {
36
+ backgroundColor: highlight
37
+ ? cssVar("--highlight")
38
+ : cssVar("--secondary-background"),
39
+ }
40
+ }
41
+ >
42
+ {({ content }) => content}
43
+ </BaseListItem>
44
+ );
45
+ }
@@ -0,0 +1,27 @@
1
+ import React from "react";
2
+
3
+ import { BaseListItem, BaseListItemProps } from "./BaseListItem";
4
+ import { cssVar } from "./jss";
5
+
6
+ // @ts-ignore
7
+ interface ListItemProps extends BaseListItemProps {
8
+ headline: string;
9
+ body?: string;
10
+ bare?: boolean;
11
+ children?: void;
12
+ }
13
+
14
+ export const ListItem = React.forwardRef(
15
+ (props: ListItemProps, ref?: React.Ref<HTMLLIElement>) => {
16
+ return (
17
+ <BaseListItem
18
+ withDivider={!props.bare}
19
+ {...props}
20
+ jsStyle={props.jsStyle}
21
+ ref={ref}
22
+ >
23
+ {({ content }) => content}
24
+ </BaseListItem>
25
+ );
26
+ }
27
+ );
@@ -0,0 +1,76 @@
1
+ import React from "react";
2
+
3
+ import { BaseListItem, BaseListItemProps } from "./BaseListItem";
4
+ import {
5
+ InteractableColor,
6
+ getGlyphColor,
7
+ getInteractableListItemJSStyles,
8
+ } from "./Interactable";
9
+ import { BaseLink } from "./BaseLink";
10
+
11
+ // @ts-ignore
12
+ interface ListLinkItemProps extends BaseListItemProps {
13
+ color?: InteractableColor;
14
+ children?: void;
15
+ onClick?: () => void;
16
+ href: string;
17
+ headline: string;
18
+ body?: string;
19
+ disabled?: boolean;
20
+ selected?: boolean;
21
+ bare?: boolean;
22
+ target?: string;
23
+ }
24
+
25
+ export const ListLinkItem = React.forwardRef(
26
+ (
27
+ {
28
+ onClick,
29
+ href,
30
+ disabled = false,
31
+ padding = "medium",
32
+ jsStyle,
33
+ gap,
34
+ selected,
35
+ bare,
36
+ color = "secondary",
37
+ target,
38
+ ...otherProps
39
+ }: ListLinkItemProps,
40
+ ref?: React.Ref<HTMLAnchorElement>
41
+ ) => {
42
+ return (
43
+ <BaseListItem
44
+ withDivider={!bare}
45
+ disabled={disabled}
46
+ aria-selected={selected}
47
+ padding="none"
48
+ gap={gap}
49
+ headlineColor={getGlyphColor(color, disabled, true)}
50
+ bodyColor={getGlyphColor(color, disabled, true)}
51
+ selected={selected}
52
+ bare={bare}
53
+ {...otherProps}
54
+ jsStyle={jsStyle}
55
+ >
56
+ {({ content }) => (
57
+ <BaseLink
58
+ target={target}
59
+ padding={padding}
60
+ aria-current={selected ? "page" : undefined}
61
+ disabled={disabled}
62
+ animateInteraction={false}
63
+ bare={true}
64
+ color={color}
65
+ href={href}
66
+ ref={ref}
67
+ jsStyle={getInteractableListItemJSStyles({ bare, selected })}
68
+ onClick={onClick}
69
+ >
70
+ {content}
71
+ </BaseLink>
72
+ )}
73
+ </BaseListItem>
74
+ );
75
+ }
76
+ );
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import { BaseView } from "./BaseView";
3
+
4
+ const jsStyles = {
5
+ root: {
6
+ height: "var(--spacing-xl)",
7
+ backgroundColor: "var(--secondary-background)",
8
+ width: "100%",
9
+ },
10
+ };
11
+
12
+ export function ListSpacer() {
13
+ return <BaseView jsStyle={jsStyles.root} />;
14
+ }
@@ -0,0 +1,42 @@
1
+ import React, { useRef, useCallback, ReactElement } from "react";
2
+
3
+ export function OnVisible({
4
+ children,
5
+ onVisible,
6
+ }: {
7
+ children: (refCallback: React.RefCallback<HTMLElement>) => ReactElement;
8
+ onVisible: () => void;
9
+ }) {
10
+ const intersectionObserverRef = useRef<IntersectionObserver | null>(null);
11
+
12
+ const refCallback = useCallback((element) => {
13
+ if (element == null) {
14
+ return;
15
+ }
16
+
17
+ const intersectionObserver = new IntersectionObserver(
18
+ (entries) => {
19
+ entries.forEach((entry) => {
20
+ if (entry.isIntersecting || entry.intersectionRatio > 0) {
21
+ onVisible();
22
+ }
23
+ });
24
+ },
25
+ {
26
+ root: null,
27
+ rootMargin: "0px",
28
+ }
29
+ );
30
+
31
+ intersectionObserverRef.current = intersectionObserver;
32
+ intersectionObserver.observe(element);
33
+
34
+ return () => {
35
+ intersectionObserver.unobserve(element);
36
+ intersectionObserverRef.current = null;
37
+ };
38
+ // eslint-disable-next-line
39
+ }, []);
40
+
41
+ return children(refCallback);
42
+ }