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 @@
1
+ {"version":3,"file":"useCookie.js","sourceRoot":"","sources":["../src/useCookie.tsx"],"names":[],"mappings":"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"}
@@ -0,0 +1,8 @@
1
+ export type KeyboardShortcut<T> = {
2
+ key: string;
3
+ metaKey?: boolean;
4
+ ctrlKey?: boolean;
5
+ action: (root: T) => void;
6
+ onlyWhenFocused?: boolean;
7
+ };
8
+ export declare function useKeyboard<T extends HTMLElement>(shortcuts: Array<KeyboardShortcut<T>>): (root: T) => void;
@@ -0,0 +1,26 @@
1
+ import { useRefEffect } from "./useRefEffect";
2
+ export function useKeyboard(shortcuts) {
3
+ return useRefEffect((root) => {
4
+ const onKeyDown = (e) => {
5
+ for (const { metaKey, key, action, ctrlKey, onlyWhenFocused, } of shortcuts) {
6
+ if (metaKey && e.metaKey !== true) {
7
+ continue;
8
+ }
9
+ else if (ctrlKey && e.ctrlKey !== true) {
10
+ continue;
11
+ }
12
+ else if (onlyWhenFocused && document.activeElement !== root) {
13
+ continue;
14
+ }
15
+ if (e.key.toLowerCase() === key.toLowerCase()) {
16
+ action(root);
17
+ }
18
+ }
19
+ };
20
+ window.addEventListener("keydown", onKeyDown);
21
+ return () => {
22
+ window.removeEventListener("keydown", onKeyDown);
23
+ };
24
+ });
25
+ }
26
+ //# sourceMappingURL=useKeyboard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useKeyboard.js","sourceRoot":"","sources":["../src/useKeyboard.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAU9C,MAAM,UAAU,WAAW,CACzB,SAAqC;IAErC,OAAO,YAAY,CAAI,CAAC,IAAO,EAAE,EAAE;QACjC,MAAM,SAAS,GAAG,CAAC,CAAgB,EAAE,EAAE;YACrC,KAAK,MAAM,EACT,OAAO,EACP,GAAG,EACH,MAAM,EACN,OAAO,EACP,eAAe,GAChB,IAAI,SAAS,EAAE;gBACd,IAAI,OAAO,IAAI,CAAC,CAAC,OAAO,KAAK,IAAI,EAAE;oBACjC,SAAS;iBACV;qBAAM,IAAI,OAAO,IAAI,CAAC,CAAC,OAAO,KAAK,IAAI,EAAE;oBACxC,SAAS;iBACV;qBAAM,IAAI,eAAe,IAAI,QAAQ,CAAC,aAAa,KAAK,IAAI,EAAE;oBAC7D,SAAS;iBACV;gBAED,IAAI,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,GAAG,CAAC,WAAW,EAAE,EAAE;oBAC7C,MAAM,CAAC,IAAI,CAAC,CAAC;iBACd;aACF;QACH,CAAC,CAAC;QAEF,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAE9C,OAAO,GAAG,EAAE;YACV,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACnD,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare function useNavigation({ autofocus, rowLength, enabled, }?: {
2
+ autofocus?: boolean;
3
+ rowLength?: number;
4
+ enabled?: boolean;
5
+ }): (root: HTMLElement) => void;
@@ -0,0 +1,79 @@
1
+ import { queryFocusables, focusElement, normalizeElements } from "./aria";
2
+ import { useRefEffect } from "./useRefEffect";
3
+ export function useNavigation({ autofocus = false, rowLength = 1, enabled = true, } = {}) {
4
+ return useRefEffect((root) => {
5
+ if (!enabled) {
6
+ return;
7
+ }
8
+ let index = 0;
9
+ const elements = queryFocusables(root);
10
+ if (elements.length === 0) {
11
+ return;
12
+ }
13
+ if (elements.length !== 0 && autofocus) {
14
+ focusElement(elements, index);
15
+ }
16
+ else {
17
+ normalizeElements(elements, index);
18
+ }
19
+ const onKeyDown = (e) => {
20
+ const elements = queryFocusables(root);
21
+ if (elements.length === 0) {
22
+ return;
23
+ }
24
+ let newIndex = -1;
25
+ if (e.code === "ArrowUp") {
26
+ if (index - rowLength < 0) {
27
+ newIndex = elements.length - (elements.length % rowLength) + index;
28
+ }
29
+ else {
30
+ newIndex = index - rowLength;
31
+ }
32
+ }
33
+ else if (e.code === "ArrowLeft") {
34
+ if (index <= 0) {
35
+ newIndex = elements.length - 1;
36
+ }
37
+ else {
38
+ newIndex = index - 1;
39
+ }
40
+ }
41
+ else if (e.code === "ArrowRight") {
42
+ if (index >= elements.length - 1) {
43
+ newIndex = 0;
44
+ }
45
+ else {
46
+ newIndex = index + 1;
47
+ }
48
+ }
49
+ else if (e.code === "ArrowDown") {
50
+ if (index + rowLength > elements.length - 1) {
51
+ newIndex = (index + rowLength) % rowLength;
52
+ }
53
+ else {
54
+ newIndex = index + rowLength;
55
+ }
56
+ }
57
+ if (newIndex !== -1 && index !== newIndex) {
58
+ index = newIndex;
59
+ focusElement(elements, index);
60
+ e.preventDefault();
61
+ e.stopPropagation();
62
+ }
63
+ };
64
+ root.addEventListener("keydown", onKeyDown);
65
+ const observer = new MutationObserver((mutationList) => {
66
+ if (mutationList.filter((m) => m.type === "childList").length > 0) {
67
+ const elements = queryFocusables(root);
68
+ if (elements.length > 0) {
69
+ normalizeElements(elements, index);
70
+ }
71
+ }
72
+ });
73
+ observer.observe(root, { childList: true });
74
+ return () => {
75
+ root.removeEventListener("keydown", onKeyDown);
76
+ };
77
+ });
78
+ }
79
+ //# sourceMappingURL=useNavigation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useNavigation.js","sourceRoot":"","sources":["../src/useNavigation.tsx"],"names":[],"mappings":"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"}
@@ -0,0 +1 @@
1
+ export declare function usePromise<T>(promiseFactory: () => Promise<T>, inputs: Array<any>, initialValue: T): [T | null, any];
@@ -0,0 +1,12 @@
1
+ import { useState, useEffect } from "react";
2
+ export function usePromise(promiseFactory, inputs, initialValue) {
3
+ const [value, setValue] = useState(initialValue);
4
+ const [error, setError] = useState(null);
5
+ useEffect(() => {
6
+ promiseFactory()
7
+ .then((value) => setValue(value))
8
+ .catch((error) => setError(error));
9
+ }, inputs);
10
+ return [value, error];
11
+ }
12
+ //# sourceMappingURL=usePromise.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePromise.js","sourceRoot":"","sources":["../src/usePromise.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5C,MAAM,UAAU,UAAU,CACxB,cAAgC,EAChC,MAAkB,EAClB,YAAe;IAEf,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC;IACjD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAEzC,SAAS,CAAC,GAAG,EAAE;QACb,cAAc,EAAE;aACb,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;aAChC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IACvC,CAAC,EAAE,MAAM,CAAC,CAAC;IAEX,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AACxB,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function useRefEffect<T>(callback: (root: T) => (() => void) | void): (root: T) => void;
@@ -0,0 +1,15 @@
1
+ import { useRef, useCallback } from "react";
2
+ export function useRefEffect(callback) {
3
+ const unsubscribeRef = useRef(null);
4
+ const refCallback = useCallback((root) => {
5
+ if (root === null) {
6
+ unsubscribeRef.current && unsubscribeRef.current();
7
+ }
8
+ else {
9
+ const unsubscribe = callback(root);
10
+ unsubscribeRef.current = unsubscribe;
11
+ }
12
+ }, []);
13
+ return refCallback;
14
+ }
15
+ //# sourceMappingURL=useRefEffect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRefEffect.js","sourceRoot":"","sources":["../src/useRefEffect.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAE5C,MAAM,UAAU,YAAY,CAC1B,QAA0C;IAE1C,MAAM,cAAc,GAAG,MAAM,CAAsB,IAAI,CAAC,CAAC;IAEzD,MAAM,WAAW,GAAG,WAAW,CAAC,CAAC,IAAc,EAAE,EAAE;QACjD,IAAI,IAAI,KAAK,IAAI,EAAE;YACjB,cAAc,CAAC,OAAO,IAAI,cAAc,CAAC,OAAO,EAAE,CAAC;SACpD;aAAM;YACL,MAAM,WAAW,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;YACnC,cAAc,CAAC,OAAO,GAAG,WAAW,CAAC;SACtC;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,WAAW,CAAC;AACrB,CAAC"}
package/next-env.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /// <reference types="next" />
2
+ /// <reference types="next/image-types/global" />
3
+
4
+ // NOTE: This file should not be edited
5
+ // see https://nextjs.org/docs/basic-features/typescript for more information.
package/next.config.js ADDED
@@ -0,0 +1,21 @@
1
+ // next.config.js
2
+
3
+ import mdx from "@next/mdx";
4
+
5
+ const withMDX = mdx({
6
+ extension: /\.mdx?$/,
7
+ options: {
8
+ remarkPlugins: [],
9
+ rehypePlugins: [],
10
+ providerImportSource: "@mdx-js/react",
11
+ },
12
+ });
13
+
14
+ /** @type {import('next').NextConfig} */
15
+ const nextConfig = {
16
+ pageExtensions: ["ts", "tsx", "js", "jsx", "md", "mdx"],
17
+ reactStrictMode: true,
18
+ };
19
+
20
+ // Merge MDX config with Next.js config
21
+ export default withMDX(nextConfig);
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "aidos-ui",
3
+ "version": "3.0.0",
4
+ "description": "A simple UI framework",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "scripts": {
8
+ "dev": "next dev",
9
+ "publish:patch": "node ./scripts/publish.js --patch",
10
+ "build": "next build",
11
+ "build:lib": "rimraf ./dist && tsc --project tsconfig.build.json",
12
+ "tsc": "tsc --watch",
13
+ "start": "next start",
14
+ "lint": "next lint"
15
+ },
16
+ "type": "module",
17
+ "author": "Gerard Moreno-Torres Bertran",
18
+ "license": "ISC",
19
+ "devDependencies": {
20
+ "@mdx-js/loader": "^2.3.0",
21
+ "@mdx-js/react": "^2.3.0",
22
+ "@next/mdx": "^13.4.9",
23
+ "@types/prismjs": "^1.26.0",
24
+ "@types/react": "^18.0.26",
25
+ "@types/react-dom": "^18.0.10",
26
+ "csstype": "^3.1.1",
27
+ "install": "^0.13.0",
28
+ "next": "latest",
29
+ "npm": "^9.8.0",
30
+ "prismjs": "^1.29.0",
31
+ "process": "^0.11.10",
32
+ "react-dom": "latest",
33
+ "rimraf": "^5.0.1",
34
+ "ts-node": "^10.9.1",
35
+ "typescript": "^4.9.4"
36
+ },
37
+ "peerDependencies": {
38
+ "react": "latest"
39
+ }
40
+ }
@@ -0,0 +1,27 @@
1
+ import { spawnSync } from "child_process";
2
+
3
+ async function run() {
4
+ const commands = [
5
+ ["npm", ["run", "build:lib"]],
6
+ ["git", ["add", "--all"]],
7
+ ["git", ["commit", "-m", "build:lib"]],
8
+ ["npm", ["version", "patch"]],
9
+ ["npm", ["publish"]],
10
+ ["git", ["push"]],
11
+ ].reverse();
12
+
13
+ while (commands.length) {
14
+ const [command, args = []] = commands.pop();
15
+ console.log(`Executing ${command} ${args.join(" ")}`);
16
+ const { error, stdout } = spawnSync(command, args);
17
+
18
+ if (error) {
19
+ console.error(error);
20
+ break;
21
+ } else {
22
+ process.stdout.write(stdout);
23
+ }
24
+ }
25
+ }
26
+
27
+ run();
package/src/Badge.tsx ADDED
@@ -0,0 +1,36 @@
1
+ import React from "react";
2
+
3
+ import { BaseView } from "./BaseView";
4
+ import { Color, JSStyle, Size, getBackground } from "./jss";
5
+
6
+ const sizes = {
7
+ xsmall: 4,
8
+ small: 6,
9
+ medium: 12,
10
+ large: 18,
11
+ xlarge: 24,
12
+ };
13
+
14
+ export function Badge({
15
+ size = "medium",
16
+ color = "highlight",
17
+ jsStyle,
18
+ }: {
19
+ size?: Size;
20
+ color?: Color;
21
+ jsStyle?: JSStyle;
22
+ }) {
23
+ return (
24
+ <BaseView
25
+ jsStyle={[
26
+ {
27
+ width: sizes[size],
28
+ height: sizes[size],
29
+ borderRadius: sizes[size] / 2,
30
+ },
31
+ getBackground(color),
32
+ jsStyle,
33
+ ]}
34
+ />
35
+ );
36
+ }
@@ -0,0 +1,58 @@
1
+ import React from "react";
2
+ import { InteractableColor, getInteractableJSStyles } from "./Interactable";
3
+ import { JSStyle, Padding, jss } from "./jss";
4
+
5
+ export interface BaseButtonProps
6
+ extends React.ButtonHTMLAttributes<HTMLButtonElement> {
7
+ onClick: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
8
+ jsStyle?: JSStyle;
9
+ color: InteractableColor;
10
+ bare?: boolean;
11
+ className?: undefined;
12
+ animateInteraction?: boolean;
13
+ padding?: Padding;
14
+ }
15
+
16
+ export const BaseButton = React.forwardRef(
17
+ (
18
+ {
19
+ onClick,
20
+ children,
21
+ jsStyle,
22
+ color,
23
+ bare = false,
24
+ disabled,
25
+ animateInteraction = true,
26
+ padding,
27
+ ...otherProps
28
+ }: BaseButtonProps,
29
+ ref?: React.Ref<HTMLButtonElement>
30
+ ) => {
31
+ return (
32
+ <button
33
+ {...otherProps}
34
+ aria-disabled={disabled ? true : undefined}
35
+ ref={ref}
36
+ onClick={(event) => {
37
+ if (disabled) {
38
+ return;
39
+ }
40
+
41
+ onClick(event);
42
+ }}
43
+ className={jss([
44
+ ...getInteractableJSStyles({
45
+ color,
46
+ bare,
47
+ disabled,
48
+ animateInteraction,
49
+ padding,
50
+ }),
51
+ jsStyle,
52
+ ])}
53
+ >
54
+ {children}
55
+ </button>
56
+ );
57
+ }
58
+ );
@@ -0,0 +1,57 @@
1
+ import React, { ReactNode, useId } from "react";
2
+ import { JSStyle, Size, TextColor, jss } from "./jss";
3
+ import { Label } from "./Text";
4
+
5
+ export interface BaseInputProps
6
+ extends React.InputHTMLAttributes<HTMLInputElement> {
7
+ jsStyle?: JSStyle;
8
+ className?: undefined;
9
+ size?: undefined;
10
+ children?: undefined;
11
+ id?: undefined;
12
+ label?: ReactNode;
13
+ labelSize?: Size;
14
+ labelColor?: TextColor;
15
+ labelBold?: boolean;
16
+ labelPosition?: "start" | "end";
17
+ }
18
+
19
+ export const BaseInput = React.forwardRef(
20
+ (
21
+ {
22
+ jsStyle,
23
+ label,
24
+ labelPosition = "end",
25
+ labelSize,
26
+ labelColor,
27
+ labelBold,
28
+ ...otherProps
29
+ }: BaseInputProps,
30
+ ref?: React.Ref<HTMLInputElement>
31
+ ) => {
32
+ const id = useId();
33
+ const labelElement = (
34
+ <Label
35
+ size={labelSize}
36
+ bold={labelBold}
37
+ color={labelColor}
38
+ jsStyle={{
39
+ display: "flex",
40
+ alignItems: "center",
41
+ justifyContent: "center",
42
+ }}
43
+ htmlFor={id}
44
+ >
45
+ {label}
46
+ </Label>
47
+ );
48
+
49
+ return (
50
+ <>
51
+ {label && labelPosition === "start" && labelElement}
52
+ <input id={id} ref={ref} className={jss(jsStyle)} {...otherProps} />
53
+ {label && labelPosition === "end" && labelElement}
54
+ </>
55
+ );
56
+ }
57
+ );
@@ -0,0 +1,77 @@
1
+ import React, { useContext } from "react";
2
+ import { InteractableColor, getInteractableJSStyles } from "./Interactable";
3
+ import { JSStyle, Padding, jss } from "./jss";
4
+
5
+ export interface BaseLinkProps
6
+ extends React.LinkHTMLAttributes<HTMLAnchorElement> {
7
+ onClick?: (e: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => void;
8
+ target?: string;
9
+ jsStyle?: JSStyle;
10
+ color: InteractableColor;
11
+ href: string;
12
+ disabled?: boolean;
13
+ bare?: boolean;
14
+ className?: undefined;
15
+ animateInteraction?: boolean;
16
+ padding?: Padding;
17
+ }
18
+
19
+ // This only exists to make NextJS happy, it should not be used in any other case
20
+ export const BaseLinkComponentOverrideContext = React.createContext((props) => (
21
+ <a {...props} />
22
+ ));
23
+
24
+ export const BaseLink = React.forwardRef(
25
+ (
26
+ {
27
+ onClick,
28
+ children,
29
+ jsStyle,
30
+ color,
31
+ bare = false,
32
+ disabled,
33
+ animateInteraction = true,
34
+ padding,
35
+ href,
36
+ role = "link",
37
+ ...otherProps
38
+ }: BaseLinkProps,
39
+ ref?: React.Ref<HTMLAnchorElement>
40
+ ) => {
41
+ const Link = useContext(BaseLinkComponentOverrideContext);
42
+
43
+ return (
44
+ <Link
45
+ {...otherProps}
46
+ aria-disabled={disabled ? true : undefined}
47
+ href={href}
48
+ role={role}
49
+ ref={ref}
50
+ onClick={
51
+ onClick
52
+ ? (event) => {
53
+ if (disabled) {
54
+ return;
55
+ }
56
+
57
+ onClick(event);
58
+ }
59
+ : undefined
60
+ }
61
+ className={jss([
62
+ ...getInteractableJSStyles({
63
+ color,
64
+ bare,
65
+ disabled,
66
+ animateInteraction,
67
+ padding,
68
+ }),
69
+ disabled && { pointerEvents: "none" },
70
+ jsStyle,
71
+ ])}
72
+ >
73
+ {children}
74
+ </Link>
75
+ );
76
+ }
77
+ );
@@ -0,0 +1,29 @@
1
+ import React from "react";
2
+ import { Column, ColumnProps } from "./Column";
3
+
4
+ export interface BaseListProps extends ColumnProps {
5
+ tag?: undefined;
6
+ }
7
+
8
+ export const BaseList = React.forwardRef(
9
+ (
10
+ { jsStyle, ...otherProps }: BaseListProps,
11
+ ref?: React.Ref<HTMLDivElement>
12
+ ) => {
13
+ return (
14
+ <Column
15
+ {...otherProps}
16
+ tag="ul"
17
+ jsStyle={[
18
+ {
19
+ listStyle: "none",
20
+ margin: 0,
21
+ padding: 0,
22
+ },
23
+ jsStyle,
24
+ ]}
25
+ ref={ref}
26
+ />
27
+ );
28
+ }
29
+ );
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import { BaseView, BaseViewProps } from "./BaseView";
3
+
4
+ export interface BaseListAddOnProps extends BaseViewProps {}
5
+
6
+ export const BaseListAddOn = React.forwardRef(
7
+ (props: BaseListAddOnProps, ref?: React.Ref<HTMLDivElement>) => {
8
+ return <BaseView {...props} ref={ref} />;
9
+ }
10
+ );
@@ -0,0 +1,117 @@
1
+ import React, { ReactNode } from "react";
2
+
3
+ import { ListDivider } from "./ListDivider";
4
+ import { Row, RowProps } from "./Row";
5
+ import { JSStyle, Size, Position, Spacing, TextColor, cssVar } from "./jss";
6
+ import { InteractableColor } from "./Interactable";
7
+ import { TextPairing } from "./TextPairing";
8
+ import { BaseView } from "./BaseView";
9
+
10
+ // @ts-ignore
11
+ export interface BaseListItemProps extends RowProps {
12
+ children: (elements: { content: JSX.Element }) => ReactNode;
13
+ jsStyle?: JSStyle;
14
+ withDivider?: boolean;
15
+ headline: string;
16
+ headlineSize?: Size;
17
+ headlineColor?: TextColor;
18
+ headlineAddOn?: ReactNode;
19
+ headlineBold?: boolean;
20
+ body?: string;
21
+ bodySize?: Size;
22
+ bodyColor?: TextColor;
23
+ addOn?: ReactNode;
24
+ addOnPosition?: Position;
25
+ outerAddOn?: ReactNode;
26
+ disabled?: boolean;
27
+ role?: undefined;
28
+ gap?: Spacing;
29
+ selected?: boolean;
30
+ bare?: boolean;
31
+ }
32
+
33
+ export const BaseListItem = React.forwardRef(
34
+ (
35
+ {
36
+ children,
37
+ jsStyle,
38
+ withDivider = true,
39
+ headline,
40
+ headlineSize = "medium",
41
+ headlineColor = "primary",
42
+ headlineAddOn,
43
+ body,
44
+ bodySize = "small",
45
+ bodyColor = "secondary",
46
+ addOn,
47
+ addOnPosition,
48
+ outerAddOn,
49
+ disabled = false,
50
+ padding = "medium",
51
+ gap = "medium",
52
+ selected,
53
+ bare,
54
+ headlineBold,
55
+ ...otherProps
56
+ }: BaseListItemProps,
57
+ ref?: React.Ref<HTMLElement>
58
+ ) => {
59
+ const content = (
60
+ <TextPairing
61
+ headlineBold={headlineBold}
62
+ padding={padding}
63
+ gap={gap}
64
+ addOn={addOn}
65
+ addOnPosition={addOnPosition}
66
+ headline={headline}
67
+ headlineSize={headlineSize}
68
+ headlineColor={
69
+ disabled ? "subtle" : bare && selected ? "highlight" : headlineColor
70
+ }
71
+ headlineAddOn={headlineAddOn}
72
+ body={body}
73
+ bodySize={bodySize}
74
+ bodyColor={disabled ? "subtle" : bodyColor}
75
+ grow={true}
76
+ shrink={false}
77
+ />
78
+ );
79
+
80
+ return (
81
+ <>
82
+ <Row
83
+ {...otherProps}
84
+ ref={ref}
85
+ relative
86
+ tag="li"
87
+ role="row"
88
+ jsStyle={[
89
+ !bare && {
90
+ [":first-child *"]: {
91
+ borderTopLeftRadius: cssVar("--border-radius-l"),
92
+ borderTopRightRadius: cssVar("--border-radius-l"),
93
+ },
94
+ [":last-child *"]: {
95
+ borderBottomLeftRadius: cssVar("--border-radius-l"),
96
+ borderBottomRightRadius: cssVar("--border-radius-l"),
97
+ },
98
+ },
99
+ jsStyle,
100
+ ]}
101
+ >
102
+ <Row
103
+ grow
104
+ role="gridcell"
105
+ jsStyle={{
106
+ overflow: "hidden",
107
+ }}
108
+ >
109
+ {children({ content })}
110
+ </Row>
111
+ {outerAddOn && <BaseView role="gridcell">{outerAddOn}</BaseView>}
112
+ </Row>
113
+ {withDivider && <ListDivider />}
114
+ </>
115
+ );
116
+ }
117
+ );