aidos-ui 4.0.4 → 4.0.6

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 (376) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +23 -3
  3. package/dist/index.d.ts +801 -68
  4. package/dist/index.js +3934 -68
  5. package/dist/index.js.map +1 -1
  6. package/dist/jsx-dev-runtime.d.ts +6 -2
  7. package/dist/jsx-dev-runtime.js +87 -42
  8. package/dist/jsx-dev-runtime.js.map +1 -1
  9. package/dist/jsx-runtime.d.ts +1 -1
  10. package/dist/jsx-runtime.js +2 -2
  11. package/dist/jsx-runtime.js.map +1 -1
  12. package/dist/vite-plugin-jss-debug.d.ts +3 -1
  13. package/dist/vite-plugin-jss-debug.js +57 -74
  14. package/dist/vite-plugin-jss-debug.js.map +1 -1
  15. package/package.json +61 -27
  16. package/.prettierrc +0 -4
  17. package/CLAUDE.md +0 -72
  18. package/dist/Badge.d.ts +0 -6
  19. package/dist/Badge.js +0 -22
  20. package/dist/Badge.js.map +0 -1
  21. package/dist/BaseButton.d.ts +0 -14
  22. package/dist/BaseButton.js +0 -23
  23. package/dist/BaseButton.js.map +0 -1
  24. package/dist/BaseInput.d.ts +0 -14
  25. package/dist/BaseInput.js +0 -15
  26. package/dist/BaseInput.js.map +0 -1
  27. package/dist/BaseLink.d.ts +0 -18
  28. package/dist/BaseLink.js +0 -29
  29. package/dist/BaseLink.js.map +0 -1
  30. package/dist/BaseList.d.ts +0 -6
  31. package/dist/BaseList.js +0 -14
  32. package/dist/BaseList.js.map +0 -1
  33. package/dist/BaseListAddOn.d.ts +0 -5
  34. package/dist/BaseListAddOn.js +0 -7
  35. package/dist/BaseListAddOn.js.map +0 -1
  36. package/dist/BaseListItem.d.ts +0 -26
  37. package/dist/BaseListItem.js +0 -29
  38. package/dist/BaseListItem.js.map +0 -1
  39. package/dist/BaseView.d.ts +0 -12
  40. package/dist/BaseView.js +0 -26
  41. package/dist/BaseView.js.map +0 -1
  42. package/dist/Box.d.ts +0 -4
  43. package/dist/Box.js +0 -6
  44. package/dist/Box.js.map +0 -1
  45. package/dist/Button.d.ts +0 -20
  46. package/dist/Button.js +0 -19
  47. package/dist/Button.js.map +0 -1
  48. package/dist/Calendar.d.ts +0 -18
  49. package/dist/Calendar.js +0 -57
  50. package/dist/Calendar.js.map +0 -1
  51. package/dist/Card.d.ts +0 -4
  52. package/dist/Card.js +0 -14
  53. package/dist/Card.js.map +0 -1
  54. package/dist/Checkbox.d.ts +0 -11
  55. package/dist/Checkbox.js +0 -32
  56. package/dist/Checkbox.js.map +0 -1
  57. package/dist/Circle.d.ts +0 -5
  58. package/dist/Circle.js +0 -12
  59. package/dist/Circle.js.map +0 -1
  60. package/dist/Column.d.ts +0 -6
  61. package/dist/Column.js +0 -7
  62. package/dist/Column.js.map +0 -1
  63. package/dist/DarkMode.d.ts +0 -13
  64. package/dist/DarkMode.js +0 -62
  65. package/dist/DarkMode.js.map +0 -1
  66. package/dist/DateInput.d.ts +0 -13
  67. package/dist/DateInput.js +0 -29
  68. package/dist/DateInput.js.map +0 -1
  69. package/dist/DatePicker.d.ts +0 -11
  70. package/dist/DatePicker.js +0 -34
  71. package/dist/DatePicker.js.map +0 -1
  72. package/dist/DatetimeInput.d.ts +0 -13
  73. package/dist/DatetimeInput.js +0 -31
  74. package/dist/DatetimeInput.js.map +0 -1
  75. package/dist/DesignBook.d.ts +0 -1
  76. package/dist/DesignBook.js +0 -55
  77. package/dist/DesignBook.js.map +0 -1
  78. package/dist/Dialog.d.ts +0 -17
  79. package/dist/Dialog.js +0 -92
  80. package/dist/Dialog.js.map +0 -1
  81. package/dist/Dropdown.d.ts +0 -14
  82. package/dist/Dropdown.js +0 -65
  83. package/dist/Dropdown.js.map +0 -1
  84. package/dist/Emitter.d.ts +0 -6
  85. package/dist/Emitter.js +0 -19
  86. package/dist/Emitter.js.map +0 -1
  87. package/dist/FlexLayout.d.ts +0 -11
  88. package/dist/FlexLayout.js +0 -18
  89. package/dist/FlexLayout.js.map +0 -1
  90. package/dist/Icon.d.ts +0 -12
  91. package/dist/Icon.js +0 -60
  92. package/dist/Icon.js.map +0 -1
  93. package/dist/IconButton.d.ts +0 -11
  94. package/dist/IconButton.js +0 -34
  95. package/dist/IconButton.js.map +0 -1
  96. package/dist/IconLink.d.ts +0 -9
  97. package/dist/IconLink.js +0 -32
  98. package/dist/IconLink.js.map +0 -1
  99. package/dist/IconType.d.ts +0 -1
  100. package/dist/IconType.js +0 -2
  101. package/dist/IconType.js.map +0 -1
  102. package/dist/Interactable.d.ts +0 -50
  103. package/dist/Interactable.js +0 -169
  104. package/dist/Interactable.js.map +0 -1
  105. package/dist/JSSComment.d.ts +0 -10
  106. package/dist/JSSComment.js +0 -52
  107. package/dist/JSSComment.js.map +0 -1
  108. package/dist/Link.d.ts +0 -22
  109. package/dist/Link.js +0 -29
  110. package/dist/Link.js.map +0 -1
  111. package/dist/List.d.ts +0 -15
  112. package/dist/List.js +0 -29
  113. package/dist/List.js.map +0 -1
  114. package/dist/ListButtonItem.d.ts +0 -14
  115. package/dist/ListButtonItem.js +0 -11
  116. package/dist/ListButtonItem.js.map +0 -1
  117. package/dist/ListDivider.d.ts +0 -1
  118. package/dist/ListDivider.js +0 -12
  119. package/dist/ListDivider.js.map +0 -1
  120. package/dist/ListHeaderItem.d.ts +0 -10
  121. package/dist/ListHeaderItem.js +0 -15
  122. package/dist/ListHeaderItem.js.map +0 -1
  123. package/dist/ListItem.d.ts +0 -9
  124. package/dist/ListItem.js +0 -9
  125. package/dist/ListItem.js.map +0 -1
  126. package/dist/ListLinkItem.d.ts +0 -16
  127. package/dist/ListLinkItem.js +0 -11
  128. package/dist/ListLinkItem.js.map +0 -1
  129. package/dist/ListSpacer.d.ts +0 -1
  130. package/dist/ListSpacer.js +0 -13
  131. package/dist/ListSpacer.js.map +0 -1
  132. package/dist/MenuIcon.d.ts +0 -5
  133. package/dist/MenuIcon.js +0 -31
  134. package/dist/MenuIcon.js.map +0 -1
  135. package/dist/NextJSRouter.d.ts +0 -1
  136. package/dist/NextJSRouter.js +0 -37
  137. package/dist/NextJSRouter.js.map +0 -1
  138. package/dist/NextJSRouterState.d.ts +0 -38
  139. package/dist/NextJSRouterState.js +0 -111
  140. package/dist/NextJSRouterState.js.map +0 -1
  141. package/dist/OnVisible.d.ts +0 -5
  142. package/dist/OnVisible.js +0 -28
  143. package/dist/OnVisible.js.map +0 -1
  144. package/dist/Popover.d.ts +0 -22
  145. package/dist/Popover.js +0 -90
  146. package/dist/Popover.js.map +0 -1
  147. package/dist/ProgressBar.d.ts +0 -7
  148. package/dist/ProgressBar.js +0 -42
  149. package/dist/ProgressBar.js.map +0 -1
  150. package/dist/ProgressCircle.d.ts +0 -5
  151. package/dist/ProgressCircle.js +0 -12
  152. package/dist/ProgressCircle.js.map +0 -1
  153. package/dist/Providers.d.ts +0 -9
  154. package/dist/Providers.js +0 -16
  155. package/dist/Providers.js.map +0 -1
  156. package/dist/RangeInput.d.ts +0 -14
  157. package/dist/RangeInput.js +0 -32
  158. package/dist/RangeInput.js.map +0 -1
  159. package/dist/ResultOrError.d.ts +0 -13
  160. package/dist/ResultOrError.js +0 -7
  161. package/dist/ResultOrError.js.map +0 -1
  162. package/dist/RootView.d.ts +0 -5
  163. package/dist/RootView.js +0 -35
  164. package/dist/RootView.js.map +0 -1
  165. package/dist/Row.d.ts +0 -6
  166. package/dist/Row.js +0 -7
  167. package/dist/Row.js.map +0 -1
  168. package/dist/Select.d.ts +0 -9
  169. package/dist/Select.js +0 -17
  170. package/dist/Select.js.map +0 -1
  171. package/dist/StackContext.d.ts +0 -8
  172. package/dist/StackContext.js +0 -25
  173. package/dist/StackContext.js.map +0 -1
  174. package/dist/StaticCheckbox.d.ts +0 -16
  175. package/dist/StaticCheckbox.js +0 -48
  176. package/dist/StaticCheckbox.js.map +0 -1
  177. package/dist/Storage.d.ts +0 -13
  178. package/dist/Storage.js +0 -146
  179. package/dist/Storage.js.map +0 -1
  180. package/dist/Stream.d.ts +0 -9
  181. package/dist/Stream.js +0 -36
  182. package/dist/Stream.js.map +0 -1
  183. package/dist/Sublist.d.ts +0 -12
  184. package/dist/Sublist.js +0 -18
  185. package/dist/Sublist.js.map +0 -1
  186. package/dist/SubmitIconInput.d.ts +0 -8
  187. package/dist/SubmitIconInput.js +0 -25
  188. package/dist/SubmitIconInput.js.map +0 -1
  189. package/dist/Tabs.d.ts +0 -23
  190. package/dist/Tabs.js +0 -39
  191. package/dist/Tabs.js.map +0 -1
  192. package/dist/Text.d.ts +0 -25
  193. package/dist/Text.js +0 -52
  194. package/dist/Text.js.map +0 -1
  195. package/dist/TextArea.d.ts +0 -11
  196. package/dist/TextArea.js +0 -27
  197. package/dist/TextArea.js.map +0 -1
  198. package/dist/TextInput.d.ts +0 -15
  199. package/dist/TextInput.js +0 -61
  200. package/dist/TextInput.js.map +0 -1
  201. package/dist/TextInputWithState.d.ts +0 -8
  202. package/dist/TextInputWithState.js +0 -14
  203. package/dist/TextInputWithState.js.map +0 -1
  204. package/dist/TextPairing.d.ts +0 -21
  205. package/dist/TextPairing.js +0 -26
  206. package/dist/TextPairing.js.map +0 -1
  207. package/dist/TimeInput.d.ts +0 -15
  208. package/dist/TimeInput.js +0 -58
  209. package/dist/TimeInput.js.map +0 -1
  210. package/dist/Tooltip.d.ts +0 -11
  211. package/dist/Tooltip.js +0 -73
  212. package/dist/Tooltip.js.map +0 -1
  213. package/dist/aria.d.ts +0 -8
  214. package/dist/aria.js +0 -42
  215. package/dist/aria.js.map +0 -1
  216. package/dist/guid.d.ts +0 -1
  217. package/dist/guid.js +0 -7
  218. package/dist/guid.js.map +0 -1
  219. package/dist/hash.d.ts +0 -1
  220. package/dist/hash.js +0 -20
  221. package/dist/hash.js.map +0 -1
  222. package/dist/isServer.d.ts +0 -1
  223. package/dist/isServer.js +0 -4
  224. package/dist/isServer.js.map +0 -1
  225. package/dist/jss.d.ts +0 -122
  226. package/dist/jss.js +0 -515
  227. package/dist/jss.js.map +0 -1
  228. package/dist/numberToBase.d.ts +0 -1
  229. package/dist/numberToBase.js +0 -44
  230. package/dist/numberToBase.js.map +0 -1
  231. package/dist/stateMachineContextFactory.d.ts +0 -36
  232. package/dist/stateMachineContextFactory.js +0 -48
  233. package/dist/stateMachineContextFactory.js.map +0 -1
  234. package/dist/useCookie.d.ts +0 -9
  235. package/dist/useCookie.js +0 -67
  236. package/dist/useCookie.js.map +0 -1
  237. package/dist/useKeyboard.d.ts +0 -8
  238. package/dist/useKeyboard.js +0 -26
  239. package/dist/useKeyboard.js.map +0 -1
  240. package/dist/useNavigation.d.ts +0 -5
  241. package/dist/useNavigation.js +0 -79
  242. package/dist/useNavigation.js.map +0 -1
  243. package/dist/usePromise.d.ts +0 -1
  244. package/dist/usePromise.js +0 -12
  245. package/dist/usePromise.js.map +0 -1
  246. package/dist/useRefEffect.d.ts +0 -1
  247. package/dist/useRefEffect.js +0 -15
  248. package/dist/useRefEffect.js.map +0 -1
  249. package/jss-debug-loader.mjs +0 -44
  250. package/next-env.d.ts +0 -6
  251. package/next.config.js +0 -33
  252. package/scripts/embeddings.js +0 -93
  253. package/scripts/openai_embeddings.js +0 -100
  254. package/scripts/publish.js +0 -28
  255. package/scripts/test_embeddings.js +0 -47
  256. package/src/Badge.tsx +0 -36
  257. package/src/BaseButton.tsx +0 -62
  258. package/src/BaseInput.tsx +0 -63
  259. package/src/BaseLink.tsx +0 -80
  260. package/src/BaseList.tsx +0 -26
  261. package/src/BaseListAddOn.tsx +0 -10
  262. package/src/BaseListItem.tsx +0 -119
  263. package/src/BaseView.tsx +0 -57
  264. package/src/Box.tsx +0 -20
  265. package/src/Button.tsx +0 -90
  266. package/src/Calendar.tsx +0 -123
  267. package/src/Card.tsx +0 -30
  268. package/src/Checkbox.tsx +0 -63
  269. package/src/Circle.tsx +0 -24
  270. package/src/Column.tsx +0 -12
  271. package/src/DarkMode.tsx +0 -100
  272. package/src/DateInput.tsx +0 -63
  273. package/src/DatePicker.tsx +0 -67
  274. package/src/DatetimeInput.tsx +0 -64
  275. package/src/DesignBook.tsx +0 -677
  276. package/src/Dialog.tsx +0 -150
  277. package/src/Dropdown.tsx +0 -146
  278. package/src/Emitter.ts +0 -26
  279. package/src/FlexLayout.tsx +0 -53
  280. package/src/Icon.tsx +0 -80
  281. package/src/IconButton.tsx +0 -81
  282. package/src/IconLink.tsx +0 -59
  283. package/src/IconType.ts +0 -787
  284. package/src/Interactable.tsx +0 -210
  285. package/src/JSSComment.tsx +0 -56
  286. package/src/Link.tsx +0 -110
  287. package/src/List.tsx +0 -58
  288. package/src/ListButtonItem.tsx +0 -69
  289. package/src/ListDivider.tsx +0 -13
  290. package/src/ListHeaderItem.tsx +0 -45
  291. package/src/ListItem.tsx +0 -24
  292. package/src/ListLinkItem.tsx +0 -76
  293. package/src/ListSpacer.tsx +0 -14
  294. package/src/MenuIcon.tsx +0 -50
  295. package/src/NextJSRouter.tsx +0 -60
  296. package/src/NextJSRouterState.tsx +0 -154
  297. package/src/OnVisible.tsx +0 -42
  298. package/src/Popover.tsx +0 -145
  299. package/src/ProgressBar.tsx +0 -63
  300. package/src/ProgressCircle.tsx +0 -38
  301. package/src/Providers.tsx +0 -33
  302. package/src/RangeInput.tsx +0 -82
  303. package/src/ResultOrError.ts +0 -15
  304. package/src/RootView.tsx +0 -55
  305. package/src/Row.tsx +0 -12
  306. package/src/Select.tsx +0 -39
  307. package/src/StackContext.tsx +0 -52
  308. package/src/StaticCheckbox.tsx +0 -72
  309. package/src/Storage.tsx +0 -198
  310. package/src/Stream.tsx +0 -50
  311. package/src/Sublist.tsx +0 -61
  312. package/src/SubmitIconInput.tsx +0 -45
  313. package/src/Tabs.tsx +0 -110
  314. package/src/Text.tsx +0 -111
  315. package/src/TextArea.tsx +0 -58
  316. package/src/TextInput.tsx +0 -123
  317. package/src/TextInputWithState.tsx +0 -32
  318. package/src/TextPairing.tsx +0 -115
  319. package/src/TimeInput.tsx +0 -109
  320. package/src/Tooltip.tsx +0 -109
  321. package/src/aria.ts +0 -72
  322. package/src/docs/mdx.tsx +0 -137
  323. package/src/docs/pages.ts +0 -115
  324. package/src/docs/searchIndex.ts +0 -1
  325. package/src/examples/ExampleDialog.tsx +0 -28
  326. package/src/guid.ts +0 -7
  327. package/src/hash.ts +0 -21
  328. package/src/index.ts +0 -68
  329. package/src/isServer.ts +0 -3
  330. package/src/jss.tsx +0 -712
  331. package/src/jsx-dev-runtime.ts +0 -74
  332. package/src/jsx-runtime.ts +0 -2
  333. package/src/numberToBase.ts +0 -52
  334. package/src/pages/Badge.mdx +0 -152
  335. package/src/pages/Button.mdx +0 -163
  336. package/src/pages/Calendar.mdx +0 -254
  337. package/src/pages/Card.mdx +0 -147
  338. package/src/pages/Checkbox.mdx +0 -131
  339. package/src/pages/Dialog.mdx +0 -197
  340. package/src/pages/FlexLayout.mdx +0 -211
  341. package/src/pages/Hashing.mdx +0 -211
  342. package/src/pages/Icon.mdx +0 -171
  343. package/src/pages/IconButton.mdx +0 -155
  344. package/src/pages/Link.mdx +0 -160
  345. package/src/pages/List.mdx +0 -262
  346. package/src/pages/ListHeader.mdx +0 -220
  347. package/src/pages/Popover.mdx +0 -223
  348. package/src/pages/ProgressBar.mdx +0 -200
  349. package/src/pages/ProgressCircle.mdx +0 -218
  350. package/src/pages/RangeInput.mdx +0 -237
  351. package/src/pages/Tabs.mdx +0 -281
  352. package/src/pages/Text.mdx +0 -154
  353. package/src/pages/TextInput.mdx +0 -235
  354. package/src/pages/TextPairing.mdx +0 -204
  355. package/src/pages/TimeInput.mdx +0 -178
  356. package/src/pages/Tooltip.mdx +0 -115
  357. package/src/pages/_app.tsx +0 -466
  358. package/src/pages/_document.tsx +0 -30
  359. package/src/pages/css-in-js.mdx +0 -240
  360. package/src/pages/index.mdx +0 -58
  361. package/src/pages/navigation.mdx +0 -158
  362. package/src/pages/prism.css +0 -3
  363. package/src/pages/useCookie.mdx +0 -176
  364. package/src/pages/useKeyboard.mdx +0 -257
  365. package/src/pages/useNavigation.mdx +0 -258
  366. package/src/pages/usePromise.mdx +0 -280
  367. package/src/pages/useRefEffect.mdx +0 -251
  368. package/src/stateMachineContextFactory.tsx +0 -111
  369. package/src/useCookie.tsx +0 -95
  370. package/src/useKeyboard.tsx +0 -43
  371. package/src/useNavigation.tsx +0 -89
  372. package/src/usePromise.tsx +0 -18
  373. package/src/useRefEffect.tsx +0 -18
  374. package/src/vite-plugin-jss-debug.ts +0 -77
  375. package/tsconfig.build.json +0 -23
  376. package/tsconfig.json +0 -38
package/src/jss.tsx DELETED
@@ -1,712 +0,0 @@
1
- import CSS from "csstype";
2
- import React, { useRef } from "react";
3
-
4
- import { hash } from "./hash";
5
- import { numberToBase } from "./numberToBase";
6
- import { isServer } from "./isServer";
7
-
8
- type StylesValueType = string | number | CSS.Properties<string | number>;
9
-
10
- export type Styles = CSS.Properties<
11
- string | number | CSS.Properties<string | number>
12
- >;
13
-
14
- export type JSS =
15
- | Styles
16
- | null
17
- | false
18
- | undefined
19
- | { [key: string]: Styles }
20
- | Array<JSS>;
21
-
22
- const aliases: {
23
- [alias: string]: (value: StylesValueType) => [string, StylesValueType][];
24
- } = {
25
- margin: (value: string) => {
26
- if (value == null) {
27
- return [];
28
- }
29
-
30
- const matches =
31
- typeof value === "string"
32
- ? Array.from(value.matchAll(/(.+) (.+)$/g))[0]
33
- : null;
34
- if (matches) {
35
- return [
36
- ["margin-top", matches[1]],
37
- ["margin-bottom", matches[1]],
38
- ["margin-left", matches[2]],
39
- ["margin-right", matches[2]],
40
- ];
41
- } else {
42
- return [
43
- ["margin-top", value],
44
- ["margin-bottom", value],
45
- ["margin-left", value],
46
- ["margin-right", value],
47
- ];
48
- }
49
- },
50
- padding: (value: string) => {
51
- if (value == null) {
52
- return [];
53
- }
54
-
55
- const matches =
56
- typeof value === "string"
57
- ? Array.from(value.matchAll(/(.+) (.+)$/g))[0]
58
- : null;
59
-
60
- if (matches) {
61
- return [
62
- ["padding-top", matches[1]],
63
- ["padding-bottom", matches[1]],
64
- ["padding-left", matches[2]],
65
- ["padding-right", matches[2]],
66
- ];
67
- } else {
68
- return [
69
- ["padding-top", value],
70
- ["padding-bottom", value],
71
- ["padding-left", value],
72
- ["padding-right", value],
73
- ];
74
- }
75
- },
76
- };
77
-
78
- const rawHashMap = new Map<string, { selector: string; key: string }>();
79
-
80
- function createStyleNode(content: string) {
81
- if (isServer()) {
82
- serverStyles.push(content);
83
- } else {
84
- const style = document.createElement("style");
85
- style.appendChild(document.createTextNode(content));
86
- document.head.appendChild(style);
87
- }
88
- }
89
-
90
- const pixelStyles = new Set([
91
- "min-height",
92
- "height",
93
- "max-height",
94
- "min-width",
95
- "width",
96
- "max-width",
97
- "margin",
98
- "margin-top",
99
- "margin-bottom",
100
- "margin-left",
101
- "margin-right",
102
- "padding",
103
- "padding-top",
104
- "padding-bottom",
105
- "padding-left",
106
- "padding-right",
107
- "border-radius",
108
- "font-size",
109
- "top",
110
- "bottom",
111
- "left",
112
- "right",
113
- "outline-offset",
114
- "gap",
115
- "row-gap",
116
- "column-gap",
117
- ]);
118
-
119
- const toPixelValue = (key: string, value): string => {
120
- const sValue = value.toString();
121
-
122
- if (
123
- sValue.includes("%") ||
124
- sValue.includes("v") ||
125
- sValue.includes("px") ||
126
- sValue.includes("em") ||
127
- sValue.includes("rem")
128
- ) {
129
- return sValue;
130
- }
131
-
132
- return pixelStyles.has(key) && Number.isInteger(parseInt(value, 10))
133
- ? `${value}px`
134
- : value;
135
- };
136
-
137
- const getCSS = (key: string, value): [string, string] => {
138
- const cssProp = key.replace(/[A-Z]/g, (m) => "-" + m.toLowerCase());
139
- const cssValue = toPixelValue(cssProp, value);
140
- return [cssProp, cssValue];
141
- };
142
-
143
- const flattenJSS = (jss: JSS): Styles => {
144
- if (!jss) {
145
- return {};
146
- } else if (Array.isArray(jss)) {
147
- const result: Styles = {};
148
- for (const item of jss) {
149
- Object.assign(result, flattenJSS(item));
150
- }
151
- return result;
152
- } else {
153
- return jss;
154
- }
155
- };
156
-
157
- export const toClassnames = (jss: JSS, componentName?: string): string => {
158
- jss = flattenJSS(jss);
159
-
160
- const stylesStack = Object.entries(jss);
161
- const classNames: string[] = [];
162
-
163
- if (componentName) {
164
- classNames.push(componentName);
165
- }
166
-
167
- while (stylesStack.length) {
168
- const [key, value] = stylesStack.pop();
169
-
170
- if (aliases[key]) {
171
- stylesStack.push(...aliases[key](value));
172
- continue;
173
- }
174
-
175
- const inputKey = key + JSON.stringify(value);
176
- const rawHash = hash(inputKey).toString(32);
177
- const cached = rawHashMap.get(rawHash);
178
-
179
- if (cached != null) {
180
- if (cached.key !== inputKey) {
181
- console.warn(
182
- `[jss] Hash collision detected: "${inputKey}" collides with "${cached.key}"`
183
- );
184
- }
185
- classNames.push(cached.selector);
186
- continue;
187
- }
188
-
189
- const selector = `x${rawHash}`;
190
- rawHashMap.set(rawHash, { selector, key: inputKey });
191
- classNames.push(selector);
192
-
193
- if (typeof value === "number" || typeof value === "string") {
194
- const [cssProp, cssValue] = getCSS(key, value);
195
- createStyleNode(`.${selector} { ${cssProp}: ${cssValue}; }`);
196
- } else if (typeof value === "object" && key.startsWith("@media")) {
197
- const media = key;
198
- const cssValue = Object.entries(value)
199
- .map(([key, value]) => {
200
- const [cssProp, cssValue] = getCSS(key, value);
201
- return `${cssProp}: ${cssValue}; `;
202
- })
203
- .join(" ");
204
- createStyleNode(`${media} { .${selector} { ${cssValue} } }`);
205
- } else if (typeof value === "object" && value != null) {
206
- const cssValue = Object.entries(value)
207
- .map(([key, value]) => {
208
- const [cssProp, cssValue] = getCSS(key, value);
209
- return `${cssProp}: ${cssValue}; `;
210
- })
211
- .join(" ");
212
- createStyleNode(`.${selector}${key} { ${cssValue} }`);
213
- }
214
- }
215
-
216
- return classNames.join(" ");
217
- };
218
-
219
- const serverStyles = [];
220
-
221
- export function JSSProvider({
222
- themes,
223
- children,
224
- }: {
225
- themes: { dark: Theme; light: Theme };
226
- children: React.JSX.Element;
227
- }) {
228
- const stylesRef = useRef<string[] | null>(null);
229
-
230
- if (stylesRef.current == null) {
231
- stylesRef.current = getBaseStyles(themes);
232
- }
233
-
234
- return (
235
- <>
236
- {stylesRef.current.map((style, i) => (
237
- <style key={i} dangerouslySetInnerHTML={{ __html: style }} />
238
- ))}
239
- {children}
240
- </>
241
- );
242
- }
243
-
244
- export function JSServerStyles() {
245
- const stylesRef = useRef<string[] | null>(null);
246
-
247
- if (stylesRef.current == null) {
248
- stylesRef.current = serverStyles;
249
- }
250
-
251
- return (
252
- <>
253
- {stylesRef.current.map((style, i) => (
254
- <style key={i} dangerouslySetInnerHTML={{ __html: style }} />
255
- ))}
256
- </>
257
- );
258
- }
259
-
260
- export type Size =
261
- | "xsmall"
262
- | "small"
263
- | "medium"
264
- | "large"
265
- | "xlarge"
266
- | "xxlarge"
267
- | "xxxlarge";
268
-
269
- export type Spacing = "none" | Size;
270
-
271
- export type Gap = Spacing;
272
-
273
- export type Padding = Spacing | [Spacing, Spacing];
274
-
275
- export type Margin = Spacing | [Spacing, Spacing];
276
-
277
- export type Direction = "horizontal" | "vertical";
278
-
279
- export type Position = "start" | "end";
280
-
281
- export type Justify =
282
- | "none"
283
- | "center"
284
- | "flex-start"
285
- | "space-between"
286
- | "flex-end"
287
- | "stretch";
288
-
289
- export type Align = "none" | "center" | "stretch" | "flex-start" | "flex-end";
290
-
291
- export type FlexDirection = "row" | "column";
292
-
293
- export type Color =
294
- | "none"
295
- | "light"
296
- | "dark"
297
- | "negative"
298
- | "warning"
299
- | "highlight"
300
- | "primary-background"
301
- | "secondary-background"
302
- | "divider"
303
- | "inherit";
304
-
305
- export type TextColor =
306
- | "primary"
307
- | "secondary"
308
- | "highlight"
309
- | "negative"
310
- | "subtle"
311
- | "light"
312
- | "inherit";
313
-
314
- export function cssVar(string: keyof Theme): string {
315
- return `var(${string})`;
316
- }
317
-
318
- const sizes: { [size in Size]: string } = {
319
- xsmall: cssVar("--spacing-xs"),
320
- small: cssVar("--spacing-s"),
321
- medium: cssVar("--spacing-m"),
322
- large: cssVar("--spacing-l"),
323
- xlarge: cssVar("--spacing-xl"),
324
- xxlarge: cssVar("--spacing-xxl"),
325
- xxxlarge: cssVar("--spacing-xxxl"),
326
- };
327
-
328
- export function getSize(size: Size): string {
329
- return sizes[size];
330
- }
331
-
332
- export function getSpacing(spacing: Spacing): string {
333
- if (spacing === "none") {
334
- return "0px";
335
- } else {
336
- return getSize(spacing);
337
- }
338
- }
339
-
340
- export function getPadding(padding: Padding): JSS {
341
- if (Array.isArray(padding)) {
342
- const [vertical, horizontal] = padding;
343
- return {
344
- paddingTop: getSpacing(vertical),
345
- paddingBottom: getSpacing(vertical),
346
- paddingLeft: getSpacing(horizontal),
347
- paddingRight: getSpacing(horizontal),
348
- };
349
- } else {
350
- return {
351
- padding: getSpacing(padding),
352
- };
353
- }
354
- }
355
-
356
- export function getMargin(margin: Margin): JSS {
357
- if (Array.isArray(margin)) {
358
- const [vertical, horizontal] = margin;
359
- return {
360
- marginTop: getSpacing(vertical),
361
- marginBottom: getSpacing(vertical),
362
- marginLeft: getSpacing(horizontal),
363
- marginRight: getSpacing(horizontal),
364
- };
365
- } else {
366
- return {
367
- margin: getSpacing(margin),
368
- };
369
- }
370
- }
371
-
372
- export type Theme = {
373
- /* Background */
374
- ["--overlay-background"]: string;
375
- ["--primary-background"]: string;
376
- ["--secondary-background"]: string;
377
- ["--divider"]: string;
378
- ["--strong-divider"]: string;
379
- ["--pressed-background"]: string;
380
- ["--hovered-background"]: string;
381
- ["--selected-background"]: string;
382
- ["--nav-bar"]: string;
383
- /* Effects */
384
- ["--warning"]: string;
385
- ["--highlight"]: string;
386
- ["--outline"]: string;
387
- ["--light-highlight"]: string;
388
- /* Text */
389
- ["--primary-text"]: string;
390
- ["--secondary-text"]: string;
391
- ["--subtle-text"]: string;
392
- ["--highlight-text"]: string;
393
- ["--negative-text"]: string;
394
- ["--light-text"]: string;
395
-
396
- ["--font-xsmall"]: string;
397
- ["--font-small"]: string;
398
- ["--font-medium"]: string;
399
- ["--font-large"]: string;
400
- ["--font-xlarge"]: string;
401
- ["--font-xxlarge"]: string;
402
- ["--font-xxxlarge"]: string;
403
-
404
- /* Buttons */
405
- ["--background-button-positive"]: string;
406
- ["--background-button-secondary"]: string;
407
- ["--background-button-negative"]: string;
408
- ["--background-button-disabled"]: string;
409
- /* Spacing */
410
- ["--spacing-xs"]: string;
411
- ["--spacing-s"]: string;
412
- ["--spacing-m"]: string;
413
- ["--spacing-l"]: string;
414
- ["--spacing-xl"]: string;
415
- ["--spacing-xxl"]: string;
416
- ["--spacing-xxxl"]: string;
417
- ["--border-radius-s"]: string;
418
- ["--border-radius-m"]: string;
419
- ["--border-radius-l"]: string;
420
- ["--nav-bar-height"]: string;
421
- /* Shadows */
422
- ["--shadow-sm"]: string;
423
- ["--shadow-md"]: string;
424
- ["--shadow-lg"]: string;
425
- /* Transitions */
426
- ["--transition-fast"]: string;
427
- ["--transition-normal"]: string;
428
- };
429
-
430
- export const lightTheme: Theme = {
431
- /* Background */
432
- ["--overlay-background"]: "rgb(245, 246, 250)",
433
- ["--primary-background"]: "rgb(239, 239, 244)",
434
- ["--secondary-background"]: "rgb(232, 232, 234)",
435
- ["--divider"]: "rgb(200, 200, 200)",
436
- ["--strong-divider"]: "rgb(100, 100, 100)",
437
- ["--pressed-background"]: "rgb(220, 222, 224)",
438
- ["--hovered-background"]: "rgb(232, 235, 237)",
439
- ["--selected-background"]: "rgb(227, 230, 232)",
440
- ["--nav-bar"]: "rgb(232, 232, 234)",
441
- /* Effects */
442
- ["--warning"]: "rgb(255, 204, 0)",
443
- ["--highlight"]: "rgb(0, 122, 255)",
444
- ["--outline"]: "rgb(103, 176, 255)",
445
- ["--light-highlight"]: "rgb(220, 232, 245)",
446
- /* Text */
447
- ["--primary-text"]: "rgb(0, 0, 0)",
448
- ["--secondary-text"]: "rgb(100, 100, 100)",
449
- ["--subtle-text"]: "rgb(180, 180, 180)",
450
- ["--highlight-text"]: "rgb(0, 122, 255)",
451
- ["--negative-text"]: "rgb(255, 59, 48)",
452
- ["--light-text"]: "rgb(255, 255, 255)",
453
- ["--font-xsmall"]: "8px",
454
- ["--font-small"]: "12px",
455
- ["--font-medium"]: "14px",
456
- ["--font-large"]: "18px",
457
- ["--font-xlarge"]: "22px",
458
- ["--font-xxlarge"]: "26px",
459
- ["--font-xxxlarge"]: "34px",
460
- /* Buttons */
461
- ["--background-button-positive"]: "rgb(0, 122, 255)",
462
- ["--background-button-secondary"]: "rgb(218, 218, 223)",
463
- ["--background-button-negative"]: "rgb(255, 59, 48)",
464
- ["--background-button-disabled"]: "rgb(218, 218, 223)",
465
- /* Spacing */
466
- ["--spacing-xs"]: "2px",
467
- ["--spacing-s"]: "4px",
468
- ["--spacing-m"]: "8px",
469
- ["--spacing-l"]: "12px",
470
- ["--spacing-xl"]: "16px",
471
- ["--spacing-xxl"]: "24px",
472
- ["--spacing-xxxl"]: "32px",
473
- ["--border-radius-s"]: "2px",
474
- ["--border-radius-m"]: "4px",
475
- ["--border-radius-l"]: "8px",
476
- ["--nav-bar-height"]: "50px",
477
- /* Shadows */
478
- ["--shadow-sm"]: "0 1px 2px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.1)",
479
- ["--shadow-md"]: "0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.05)",
480
- ["--shadow-lg"]: "0 10px 25px rgba(0, 0, 0, 0.15), 0 4px 10px rgba(0, 0, 0, 0.1)",
481
- /* Transitions */
482
- ["--transition-fast"]: "0.15s ease",
483
- ["--transition-normal"]: "0.2s ease",
484
- };
485
-
486
- export const darkTheme: Theme = {
487
- /* Background */
488
- ["--overlay-background"]: "rgb(35, 36, 37)",
489
- ["--primary-background"]: "rgb(42, 43, 46)",
490
- ["--secondary-background"]: "rgb(65, 66, 67)",
491
- ["--divider"]: "rgb(70, 72, 73)",
492
- ["--strong-divider"]: "rgb(100, 100, 100)",
493
- ["--pressed-background"]: "rgb(90, 92, 93)",
494
- ["--hovered-background"]: "rgb(50, 53, 54)",
495
- ["--selected-background"]: "rgb(65, 68, 69)",
496
- ["--nav-bar"]: "rgb(34, 35, 36)",
497
- /* Effects */
498
- ["--warning"]: "rgb(255, 204, 0)",
499
- ["--highlight"]: "rgb(50, 140, 220)",
500
- ["--outline"]: "rgb(91, 170, 255)",
501
- ["--light-highlight"]: "rgba(49, 57, 63)",
502
- /* Text */
503
- ["--primary-text"]: "rgb(255, 255, 255)",
504
- ["--secondary-text"]: "rgb(200, 200, 200)",
505
- ["--subtle-text"]: "rgb(140, 140, 140)",
506
- ["--highlight-text"]: "#4ca7f8",
507
- ["--negative-text"]: "rgb(255, 59, 48)",
508
- ["--light-text"]: "rgb(255, 255, 255)",
509
- ["--font-xsmall"]: "8px",
510
- ["--font-small"]: "12px",
511
- ["--font-medium"]: "14px",
512
- ["--font-large"]: "18px",
513
- ["--font-xlarge"]: "22px",
514
- ["--font-xxlarge"]: "26px",
515
- ["--font-xxxlarge"]: "34px",
516
- /* Buttons */
517
- ["--background-button-positive"]: "rgb(50, 140, 220)",
518
- ["--background-button-secondary"]: "rgb(82, 83, 86)",
519
- ["--background-button-negative"]: "rgb(255, 59, 48)",
520
- ["--background-button-disabled"]: "rgb(70, 72, 73)",
521
- /* Spacing */
522
- ["--spacing-xs"]: "2px",
523
- ["--spacing-s"]: "4px",
524
- ["--spacing-m"]: "8px",
525
- ["--spacing-l"]: "12px",
526
- ["--spacing-xl"]: "16px",
527
- ["--spacing-xxl"]: "24px",
528
- ["--spacing-xxxl"]: "32px",
529
- ["--border-radius-s"]: "2px",
530
- ["--border-radius-m"]: "4px",
531
- ["--border-radius-l"]: "8px",
532
- ["--nav-bar-height"]: "50px",
533
- /* Shadows - stronger for dark mode to be visible */
534
- ["--shadow-sm"]: "0 1px 2px rgba(0, 0, 0, 0.2), 0 1px 3px rgba(0, 0, 0, 0.3)",
535
- ["--shadow-md"]: "0 4px 6px rgba(0, 0, 0, 0.25), 0 2px 4px rgba(0, 0, 0, 0.2)",
536
- ["--shadow-lg"]: "0 10px 25px rgba(0, 0, 0, 0.35), 0 4px 10px rgba(0, 0, 0, 0.25)",
537
- /* Transitions */
538
- ["--transition-fast"]: "0.15s ease",
539
- ["--transition-normal"]: "0.2s ease",
540
- };
541
-
542
- export const baseStyles = `
543
- * {
544
- box-sizing: border-box;
545
- border: none;
546
- touch-action: manipulation;
547
- -webkit-font-smoothing: antialiased;
548
- -moz-osx-font-smoothing: grayscale;
549
- }
550
-
551
- *:focus {
552
- outline-color: ${cssVar("--highlight")};
553
- }
554
-
555
- html,
556
- body {
557
- margin: 0;
558
- height: 100%;
559
- width: 100%;
560
- overflow: hidden;
561
- background-color: ${cssVar("--primary-background")};
562
- }
563
-
564
- @keyframes dialogFadeIn {
565
- from {
566
- opacity: 0;
567
- transform: scale(0.95) translateY(-10px);
568
- }
569
- to {
570
- opacity: 1;
571
- transform: scale(1) translateY(0);
572
- }
573
- }
574
-
575
- @keyframes backdropFadeIn {
576
- from {
577
- opacity: 0;
578
- }
579
- to {
580
- opacity: 1;
581
- }
582
- }
583
-
584
- @keyframes popoverFadeIn {
585
- from {
586
- opacity: 0;
587
- transform: scale(0.95);
588
- }
589
- to {
590
- opacity: 1;
591
- transform: scale(1);
592
- }
593
- }
594
-
595
- `;
596
-
597
- const backgroundStyles = {
598
- highlight: {
599
- backgroundColor: cssVar("--highlight"),
600
- },
601
- light: {
602
- backgroundColor: cssVar("--light-text"),
603
- },
604
- dark: {
605
- backgroundColor: cssVar("--primary-text"),
606
- },
607
- warning: {
608
- backgroundColor: cssVar("--warning"),
609
- },
610
- "primary-background": {
611
- backgroundColor: cssVar("--primary-background"),
612
- },
613
- negative: {
614
- backgroundColor: cssVar("--negative-text"),
615
- },
616
- "secondary-background": {
617
- backgroundColor: cssVar("--secondary-background"),
618
- },
619
- divider: {
620
- backgroundColor: cssVar("--divider"),
621
- },
622
- inherit: {
623
- backgroundColor: "inherit",
624
- },
625
- };
626
-
627
- export const getBackground = (color: Color): JSS => {
628
- return backgroundStyles[color];
629
- };
630
-
631
- export const MOBILE = 750;
632
- export const TABLET = 1000;
633
- export const LAPTOP = 1200;
634
-
635
- export const MOBILE_MEDIA = `@media (min-width: 0px) and (max-width: ${MOBILE}px)`;
636
- export const TABLET_MEDIA = `@media (min-width: ${MOBILE}px) and (max-width: ${TABLET}px)`;
637
- export const LAPTOP_MEDIA = `@media (min-width: ${TABLET}px) and (max-width: ${LAPTOP}px)`;
638
- export const DESKTOP_MEDIA = `@media (min-width: ${LAPTOP}px)`;
639
-
640
- export function mobile(jss: JSS): { [key: string]: JSS } {
641
- return {
642
- [MOBILE_MEDIA]: jss,
643
- };
644
- }
645
-
646
- export function tablet(jss: JSS): { [key: string]: JSS } {
647
- return {
648
- [TABLET_MEDIA]: jss,
649
- };
650
- }
651
-
652
- export function laptop(jss: JSS): { [key: string]: JSS } {
653
- return {
654
- [LAPTOP_MEDIA]: jss,
655
- };
656
- }
657
-
658
- export function desktop(jss: JSS): { [key: string]: JSS } {
659
- return {
660
- [DESKTOP_MEDIA]: jss,
661
- };
662
- }
663
-
664
- const textColorStyles = {
665
- primary: {
666
- color: cssVar("--primary-text"),
667
- },
668
- secondary: {
669
- color: cssVar("--secondary-text"),
670
- },
671
- highlight: {
672
- color: cssVar("--highlight-text"),
673
- },
674
- negative: {
675
- color: cssVar("--negative-text"),
676
- },
677
- subtle: {
678
- color: cssVar("--subtle-text"),
679
- },
680
- light: {
681
- color: cssVar("--light-text"),
682
- },
683
- inherit: {
684
- color: "inherit",
685
- },
686
- };
687
-
688
- export const getTextColor = (color: TextColor) => {
689
- return textColorStyles[color];
690
- };
691
-
692
- export function getBaseStyles(themes: { light: Theme; dark: Theme }): string[] {
693
- const css: string[] = [];
694
-
695
- css.push(baseStyles);
696
-
697
- css.push(`body {
698
- color-scheme: light;
699
- ${Object.entries(themes.light)
700
- .map(([key, value]) => `${key}: ${value};`)
701
- .join("\n ")}
702
- }`);
703
-
704
- css.push(`body.dark-mode {
705
- color-scheme: dark;
706
- ${Object.entries(themes.dark)
707
- .map(([key, value]) => `${key}: ${value};`)
708
- .join("\n ")}
709
- }`);
710
-
711
- return css;
712
- }