@siiway/ui-react 0.0.0 → 0.2.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 (258) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +19 -1
  3. package/dist/components/AppShell.d.ts +29 -0
  4. package/dist/components/AppShell.d.ts.map +1 -0
  5. package/dist/components/AppShell.js +220 -0
  6. package/dist/components/AppShell.js.map +1 -0
  7. package/dist/components/AuthShell.d.ts +21 -0
  8. package/dist/components/AuthShell.d.ts.map +1 -0
  9. package/dist/components/AuthShell.js +53 -0
  10. package/dist/components/AuthShell.js.map +1 -0
  11. package/dist/components/BrandMark.d.ts +11 -0
  12. package/dist/components/BrandMark.d.ts.map +1 -0
  13. package/dist/components/BrandMark.js +11 -0
  14. package/dist/components/BrandMark.js.map +1 -0
  15. package/dist/components/ButtonLink.d.ts +11 -0
  16. package/dist/components/ButtonLink.d.ts.map +1 -0
  17. package/dist/components/ButtonLink.js +15 -0
  18. package/dist/components/ButtonLink.js.map +1 -0
  19. package/dist/components/CheckboxField.d.ts +15 -0
  20. package/dist/components/CheckboxField.d.ts.map +1 -0
  21. package/dist/components/CheckboxField.js +23 -0
  22. package/dist/components/CheckboxField.js.map +1 -0
  23. package/dist/components/ColorPickerInput.d.ts +17 -0
  24. package/dist/components/ColorPickerInput.d.ts.map +1 -0
  25. package/dist/components/ColorPickerInput.js +97 -0
  26. package/dist/components/ColorPickerInput.js.map +1 -0
  27. package/dist/components/CommandPalette.d.ts +65 -0
  28. package/dist/components/CommandPalette.d.ts.map +1 -0
  29. package/dist/components/CommandPalette.js +269 -0
  30. package/dist/components/CommandPalette.js.map +1 -0
  31. package/dist/components/CopyButton.d.ts +27 -0
  32. package/dist/components/CopyButton.d.ts.map +1 -0
  33. package/dist/components/CopyButton.js +20 -0
  34. package/dist/components/CopyButton.js.map +1 -0
  35. package/dist/components/CopyIdTrigger.d.ts +31 -0
  36. package/dist/components/CopyIdTrigger.d.ts.map +1 -0
  37. package/dist/components/CopyIdTrigger.js +72 -0
  38. package/dist/components/CopyIdTrigger.js.map +1 -0
  39. package/dist/components/DataList.d.ts +78 -0
  40. package/dist/components/DataList.d.ts.map +1 -0
  41. package/dist/components/DataList.js +150 -0
  42. package/dist/components/DataList.js.map +1 -0
  43. package/dist/components/DetailHeader.d.ts +26 -0
  44. package/dist/components/DetailHeader.d.ts.map +1 -0
  45. package/dist/components/DetailHeader.js +49 -0
  46. package/dist/components/DetailHeader.js.map +1 -0
  47. package/dist/components/DurationInput.d.ts +25 -0
  48. package/dist/components/DurationInput.d.ts.map +1 -0
  49. package/dist/components/DurationInput.js +83 -0
  50. package/dist/components/DurationInput.js.map +1 -0
  51. package/dist/components/EmptyState.d.ts +14 -0
  52. package/dist/components/EmptyState.d.ts.map +1 -0
  53. package/dist/components/EmptyState.js +41 -0
  54. package/dist/components/EmptyState.js.map +1 -0
  55. package/dist/components/FormPage.d.ts +22 -0
  56. package/dist/components/FormPage.d.ts.map +1 -0
  57. package/dist/components/FormPage.js +65 -0
  58. package/dist/components/FormPage.js.map +1 -0
  59. package/dist/components/GetStartedPanel.d.ts +16 -0
  60. package/dist/components/GetStartedPanel.d.ts.map +1 -0
  61. package/dist/components/GetStartedPanel.js +96 -0
  62. package/dist/components/GetStartedPanel.js.map +1 -0
  63. package/dist/components/LabeledLine.d.ts +12 -0
  64. package/dist/components/LabeledLine.d.ts.map +1 -0
  65. package/dist/components/LabeledLine.js +6 -0
  66. package/dist/components/LabeledLine.js.map +1 -0
  67. package/dist/components/ListSearch.d.ts +15 -0
  68. package/dist/components/ListSearch.d.ts.map +1 -0
  69. package/dist/components/ListSearch.js +23 -0
  70. package/dist/components/ListSearch.js.map +1 -0
  71. package/dist/components/LoadingBar.d.ts +8 -0
  72. package/dist/components/LoadingBar.d.ts.map +1 -0
  73. package/dist/components/LoadingBar.js +55 -0
  74. package/dist/components/LoadingBar.js.map +1 -0
  75. package/dist/components/LoadingPage.d.ts +6 -0
  76. package/dist/components/LoadingPage.d.ts.map +1 -0
  77. package/dist/components/LoadingPage.js +25 -0
  78. package/dist/components/LoadingPage.js.map +1 -0
  79. package/dist/components/MenuPanel.d.ts +34 -0
  80. package/dist/components/MenuPanel.d.ts.map +1 -0
  81. package/dist/components/MenuPanel.js +98 -0
  82. package/dist/components/MenuPanel.js.map +1 -0
  83. package/dist/components/Outline.d.ts +23 -0
  84. package/dist/components/Outline.d.ts.map +1 -0
  85. package/dist/components/Outline.js +150 -0
  86. package/dist/components/Outline.js.map +1 -0
  87. package/dist/components/Overview.d.ts +103 -0
  88. package/dist/components/Overview.d.ts.map +1 -0
  89. package/dist/components/Overview.js +286 -0
  90. package/dist/components/Overview.js.map +1 -0
  91. package/dist/components/PageHeader.d.ts +19 -0
  92. package/dist/components/PageHeader.d.ts.map +1 -0
  93. package/dist/components/PageHeader.js +41 -0
  94. package/dist/components/PageHeader.js.map +1 -0
  95. package/dist/components/Pagination.d.ts +19 -0
  96. package/dist/components/Pagination.d.ts.map +1 -0
  97. package/dist/components/Pagination.js +47 -0
  98. package/dist/components/Pagination.js.map +1 -0
  99. package/dist/components/PasswordInput.d.ts +3 -0
  100. package/dist/components/PasswordInput.d.ts.map +1 -0
  101. package/dist/components/PasswordInput.js +29 -0
  102. package/dist/components/PasswordInput.js.map +1 -0
  103. package/dist/components/PrevNext.d.ts +16 -0
  104. package/dist/components/PrevNext.d.ts.map +1 -0
  105. package/dist/components/PrevNext.js +61 -0
  106. package/dist/components/PrevNext.js.map +1 -0
  107. package/dist/components/SearchButton.d.ts +16 -0
  108. package/dist/components/SearchButton.d.ts.map +1 -0
  109. package/dist/components/SearchButton.js +63 -0
  110. package/dist/components/SearchButton.js.map +1 -0
  111. package/dist/components/SearchField.d.ts +10 -0
  112. package/dist/components/SearchField.d.ts.map +1 -0
  113. package/dist/components/SearchField.js +67 -0
  114. package/dist/components/SearchField.js.map +1 -0
  115. package/dist/components/Segmented.d.ts +28 -0
  116. package/dist/components/Segmented.d.ts.map +1 -0
  117. package/dist/components/Segmented.js +74 -0
  118. package/dist/components/Segmented.js.map +1 -0
  119. package/dist/components/Select.d.ts +22 -0
  120. package/dist/components/Select.d.ts.map +1 -0
  121. package/dist/components/Select.js +50 -0
  122. package/dist/components/Select.js.map +1 -0
  123. package/dist/components/Settings.d.ts +103 -0
  124. package/dist/components/Settings.d.ts.map +1 -0
  125. package/dist/components/Settings.js +246 -0
  126. package/dist/components/Settings.js.map +1 -0
  127. package/dist/components/SideNav.d.ts +47 -0
  128. package/dist/components/SideNav.d.ts.map +1 -0
  129. package/dist/components/SideNav.js +125 -0
  130. package/dist/components/SideNav.js.map +1 -0
  131. package/dist/components/Skeletons.d.ts +37 -0
  132. package/dist/components/Skeletons.d.ts.map +1 -0
  133. package/dist/components/Skeletons.js +109 -0
  134. package/dist/components/Skeletons.js.map +1 -0
  135. package/dist/components/StatusPage.d.ts +49 -0
  136. package/dist/components/StatusPage.d.ts.map +1 -0
  137. package/dist/components/StatusPage.js +110 -0
  138. package/dist/components/StatusPage.js.map +1 -0
  139. package/dist/components/ThemeMenu.d.ts +13 -0
  140. package/dist/components/ThemeMenu.d.ts.map +1 -0
  141. package/dist/components/ThemeMenu.js +18 -0
  142. package/dist/components/ThemeMenu.js.map +1 -0
  143. package/dist/components/ThemeSwitch.d.ts +17 -0
  144. package/dist/components/ThemeSwitch.d.ts.map +1 -0
  145. package/dist/components/ThemeSwitch.js +25 -0
  146. package/dist/components/ThemeSwitch.js.map +1 -0
  147. package/dist/components/TopBar.d.ts +49 -0
  148. package/dist/components/TopBar.d.ts.map +1 -0
  149. package/dist/components/TopBar.js +146 -0
  150. package/dist/components/TopBar.js.map +1 -0
  151. package/dist/components/ViewBanner.d.ts +17 -0
  152. package/dist/components/ViewBanner.d.ts.map +1 -0
  153. package/dist/components/ViewBanner.js +14 -0
  154. package/dist/components/ViewBanner.js.map +1 -0
  155. package/dist/hooks/platform.d.ts +7 -0
  156. package/dist/hooks/platform.d.ts.map +1 -0
  157. package/dist/hooks/platform.js +19 -0
  158. package/dist/hooks/platform.js.map +1 -0
  159. package/dist/hooks/useConfirm.d.ts +23 -0
  160. package/dist/hooks/useConfirm.d.ts.map +1 -0
  161. package/dist/hooks/useConfirm.js +55 -0
  162. package/dist/hooks/useConfirm.js.map +1 -0
  163. package/dist/hooks/useCopy.d.ts +12 -0
  164. package/dist/hooks/useCopy.d.ts.map +1 -0
  165. package/dist/hooks/useCopy.js +39 -0
  166. package/dist/hooks/useCopy.js.map +1 -0
  167. package/dist/hooks/useDebouncedSearch.d.ts +8 -0
  168. package/dist/hooks/useDebouncedSearch.d.ts.map +1 -0
  169. package/dist/hooks/useDebouncedSearch.js +19 -0
  170. package/dist/hooks/useDebouncedSearch.js.map +1 -0
  171. package/dist/hooks/usePageClamp.d.ts +4 -0
  172. package/dist/hooks/usePageClamp.d.ts.map +1 -0
  173. package/dist/hooks/usePageClamp.js +17 -0
  174. package/dist/hooks/usePageClamp.js.map +1 -0
  175. package/dist/hooks/useSearchShortcut.d.ts +8 -0
  176. package/dist/hooks/useSearchShortcut.d.ts.map +1 -0
  177. package/dist/hooks/useSearchShortcut.js +38 -0
  178. package/dist/hooks/useSearchShortcut.js.map +1 -0
  179. package/dist/hooks/useThemeMode.d.ts +29 -0
  180. package/dist/hooks/useThemeMode.d.ts.map +1 -0
  181. package/dist/hooks/useThemeMode.js +111 -0
  182. package/dist/hooks/useThemeMode.js.map +1 -0
  183. package/dist/hooks/useToastMessage.d.ts +22 -0
  184. package/dist/hooks/useToastMessage.d.ts.map +1 -0
  185. package/dist/hooks/useToastMessage.js +26 -0
  186. package/dist/hooks/useToastMessage.js.map +1 -0
  187. package/dist/index.d.ts +50 -0
  188. package/dist/index.d.ts.map +1 -0
  189. package/dist/index.js +60 -0
  190. package/dist/index.js.map +1 -0
  191. package/dist/provider/UiProvider.d.ts +60 -0
  192. package/dist/provider/UiProvider.d.ts.map +1 -0
  193. package/dist/provider/UiProvider.js +144 -0
  194. package/dist/provider/UiProvider.js.map +1 -0
  195. package/dist/provider/canvas.d.ts +7 -0
  196. package/dist/provider/canvas.d.ts.map +1 -0
  197. package/dist/provider/canvas.js +30 -0
  198. package/dist/provider/canvas.js.map +1 -0
  199. package/dist/provider/context.d.ts +69 -0
  200. package/dist/provider/context.d.ts.map +1 -0
  201. package/dist/provider/context.js +84 -0
  202. package/dist/provider/context.js.map +1 -0
  203. package/dist/theme/createTheme.d.ts +13 -0
  204. package/dist/theme/createTheme.d.ts.map +1 -0
  205. package/dist/theme/createTheme.js +18 -0
  206. package/dist/theme/createTheme.js.map +1 -0
  207. package/package.json +42 -2
  208. package/src/components/AppShell.tsx +337 -0
  209. package/src/components/AuthShell.tsx +104 -0
  210. package/src/components/BrandMark.tsx +28 -0
  211. package/src/components/ButtonLink.tsx +40 -0
  212. package/src/components/CheckboxField.tsx +50 -0
  213. package/src/components/ColorPickerInput.tsx +190 -0
  214. package/src/components/CommandPalette.tsx +479 -0
  215. package/src/components/CopyButton.tsx +76 -0
  216. package/src/components/CopyIdTrigger.tsx +127 -0
  217. package/src/components/DataList.tsx +332 -0
  218. package/src/components/DetailHeader.tsx +108 -0
  219. package/src/components/DurationInput.tsx +133 -0
  220. package/src/components/EmptyState.tsx +67 -0
  221. package/src/components/FormPage.tsx +109 -0
  222. package/src/components/GetStartedPanel.tsx +132 -0
  223. package/src/components/LabeledLine.tsx +28 -0
  224. package/src/components/ListSearch.tsx +64 -0
  225. package/src/components/LoadingBar.tsx +81 -0
  226. package/src/components/LoadingPage.tsx +41 -0
  227. package/src/components/MenuPanel.tsx +163 -0
  228. package/src/components/Outline.tsx +208 -0
  229. package/src/components/Overview.tsx +448 -0
  230. package/src/components/PageHeader.tsx +69 -0
  231. package/src/components/Pagination.tsx +105 -0
  232. package/src/components/PasswordInput.tsx +50 -0
  233. package/src/components/PrevNext.tsx +98 -0
  234. package/src/components/SearchButton.tsx +90 -0
  235. package/src/components/SearchField.tsx +97 -0
  236. package/src/components/Segmented.tsx +136 -0
  237. package/src/components/Select.tsx +110 -0
  238. package/src/components/Settings.tsx +432 -0
  239. package/src/components/SideNav.tsx +258 -0
  240. package/src/components/Skeletons.tsx +233 -0
  241. package/src/components/StatusPage.tsx +212 -0
  242. package/src/components/ThemeMenu.tsx +51 -0
  243. package/src/components/ThemeSwitch.tsx +49 -0
  244. package/src/components/TopBar.tsx +293 -0
  245. package/src/components/ViewBanner.tsx +51 -0
  246. package/src/hooks/platform.ts +22 -0
  247. package/src/hooks/useConfirm.tsx +97 -0
  248. package/src/hooks/useCopy.ts +39 -0
  249. package/src/hooks/useDebouncedSearch.ts +19 -0
  250. package/src/hooks/usePageClamp.ts +20 -0
  251. package/src/hooks/useSearchShortcut.ts +49 -0
  252. package/src/hooks/useThemeMode.ts +168 -0
  253. package/src/hooks/useToastMessage.ts +38 -0
  254. package/src/index.ts +156 -0
  255. package/src/provider/UiProvider.tsx +256 -0
  256. package/src/provider/canvas.ts +31 -0
  257. package/src/provider/context.tsx +145 -0
  258. package/src/theme/createTheme.ts +29 -0
@@ -0,0 +1,448 @@
1
+ // Building blocks for overview pages (the account dashboard and the admin
2
+ // overview), laid out like the Cloudflare account home: attention callouts,
3
+ // short linked lists side by side, plain metric cards and a settings
4
+ // summary. Every row and card links through to the full page.
5
+
6
+ import { Text, makeStyles, mergeClasses, tokens } from "@fluentui/react-components";
7
+ import { ChevronRightRegular } from "@fluentui/react-icons";
8
+ import type { ReactNode } from "react";
9
+ import { UiLink } from "../provider/context.js";
10
+
11
+ const useStyles = makeStyles({
12
+ callouts: {
13
+ display: "flex",
14
+ flexDirection: "column",
15
+ gap: "12px",
16
+ marginBottom: "28px",
17
+ },
18
+ callout: {
19
+ display: "flex",
20
+ alignItems: "center",
21
+ gap: "12px",
22
+ padding: "12px 16px",
23
+ borderRadius: tokens.borderRadiusLarge,
24
+ border: `1px solid ${tokens.colorNeutralStroke1}`,
25
+ background: tokens.colorNeutralBackground1,
26
+ flexWrap: "wrap",
27
+ },
28
+ calloutIcon: {
29
+ display: "inline-flex",
30
+ color: tokens.colorStatusWarningForeground3,
31
+ fontSize: "20px",
32
+ flexShrink: 0,
33
+ },
34
+ calloutText: {
35
+ display: "flex",
36
+ flexDirection: "column",
37
+ gap: "2px",
38
+ flex: 1,
39
+ minWidth: "200px",
40
+ },
41
+ muted: {
42
+ color: tokens.colorNeutralForeground3,
43
+ },
44
+ lists: {
45
+ display: "grid",
46
+ gridTemplateColumns: "repeat(3, minmax(0, 1fr))",
47
+ gap: "32px",
48
+ "@media (max-width: 900px)": {
49
+ gridTemplateColumns: "minmax(0, 1fr)",
50
+ gap: "28px",
51
+ },
52
+ },
53
+ listHead: {
54
+ display: "flex",
55
+ alignItems: "center",
56
+ gap: "6px",
57
+ paddingBottom: "8px",
58
+ fontSize: "13px",
59
+ color: tokens.colorNeutralForeground3,
60
+ },
61
+ listHeadLink: {
62
+ display: "inline-flex",
63
+ alignItems: "center",
64
+ gap: "6px",
65
+ color: "inherit",
66
+ ":hover": { color: tokens.colorNeutralForeground1 },
67
+ },
68
+ count: {
69
+ padding: "0 6px",
70
+ borderRadius: "4px",
71
+ background: tokens.colorNeutralBackground3,
72
+ fontSize: "11px",
73
+ lineHeight: "18px",
74
+ color: tokens.colorNeutralForeground2,
75
+ },
76
+ row: {
77
+ display: "flex",
78
+ alignItems: "center",
79
+ gap: "10px",
80
+ minHeight: "44px",
81
+ padding: "0 4px",
82
+ borderBottom: `1px solid ${tokens.colorNeutralStroke2}`,
83
+ color: tokens.colorNeutralForeground1,
84
+ fontSize: "13px",
85
+ fontWeight: tokens.fontWeightMedium,
86
+ ":hover": {
87
+ background: tokens.colorNeutralBackground1Hover,
88
+ },
89
+ ":focus-visible": {
90
+ outline: `2px solid ${tokens.colorStrokeFocus2}`,
91
+ outlineOffset: "-2px",
92
+ },
93
+ },
94
+ rowIcon: {
95
+ display: "inline-flex",
96
+ fontSize: "16px",
97
+ color: tokens.colorNeutralForeground3,
98
+ flexShrink: 0,
99
+ },
100
+ rowLabel: {
101
+ flex: 1,
102
+ minWidth: 0,
103
+ overflow: "hidden",
104
+ textOverflow: "ellipsis",
105
+ whiteSpace: "nowrap",
106
+ },
107
+ rowMeta: {
108
+ fontSize: "12px",
109
+ fontWeight: tokens.fontWeightRegular,
110
+ color: tokens.colorNeutralForeground3,
111
+ whiteSpace: "nowrap",
112
+ flexShrink: 0,
113
+ },
114
+ chevron: {
115
+ fontSize: "12px",
116
+ color: tokens.colorNeutralForeground3,
117
+ flexShrink: 0,
118
+ },
119
+ empty: {
120
+ padding: "12px 4px",
121
+ fontSize: "13px",
122
+ color: tokens.colorNeutralForeground3,
123
+ borderBottom: `1px solid ${tokens.colorNeutralStroke2}`,
124
+ },
125
+ // Reserves roughly the height of a short list while it loads, so the
126
+ // page doesn't jump when rows arrive.
127
+ listLoading: {
128
+ height: "132px",
129
+ borderBottom: `1px solid ${tokens.colorNeutralStroke2}`,
130
+ },
131
+ sectionTitle: {
132
+ display: "block",
133
+ margin: "40px 0 12px",
134
+ },
135
+ metrics: {
136
+ display: "grid",
137
+ gridTemplateColumns: "repeat(4, minmax(0, 1fr))",
138
+ gap: "12px",
139
+ "@media (max-width: 900px)": {
140
+ gridTemplateColumns: "repeat(2, minmax(0, 1fr))",
141
+ },
142
+ },
143
+ metrics3: {
144
+ gridTemplateColumns: "repeat(3, minmax(0, 1fr))",
145
+ },
146
+ metric: {
147
+ display: "flex",
148
+ flexDirection: "column",
149
+ gap: "4px",
150
+ padding: "14px 16px",
151
+ borderRadius: tokens.borderRadiusLarge,
152
+ border: `1px solid ${tokens.colorNeutralStroke1}`,
153
+ background: tokens.colorNeutralBackground1,
154
+ color: tokens.colorNeutralForeground1,
155
+ ":hover": {
156
+ borderTopColor: tokens.colorNeutralStroke1Pressed,
157
+ borderRightColor: tokens.colorNeutralStroke1Pressed,
158
+ borderBottomColor: tokens.colorNeutralStroke1Pressed,
159
+ borderLeftColor: tokens.colorNeutralStroke1Pressed,
160
+ },
161
+ ":focus-visible": {
162
+ outline: `2px solid ${tokens.colorStrokeFocus2}`,
163
+ outlineOffset: "2px",
164
+ },
165
+ },
166
+ metricLabel: {
167
+ fontSize: "12px",
168
+ color: tokens.colorNeutralForeground3,
169
+ },
170
+ metricValue: {
171
+ fontSize: "26px",
172
+ lineHeight: "34px",
173
+ fontWeight: tokens.fontWeightSemibold,
174
+ fontVariantNumeric: "tabular-nums",
175
+ },
176
+ metricSuffix: {
177
+ fontSize: tokens.fontSizeBase300,
178
+ fontWeight: tokens.fontWeightRegular,
179
+ color: tokens.colorNeutralForeground3,
180
+ },
181
+ metricFooter: {
182
+ marginTop: "auto",
183
+ paddingTop: "8px",
184
+ },
185
+ // Settings summary: a bordered list of label/value rows, two columns wide.
186
+ summary: {
187
+ display: "grid",
188
+ gridTemplateColumns: "repeat(2, minmax(0, 1fr))",
189
+ columnGap: "32px",
190
+ padding: "4px 16px",
191
+ borderRadius: tokens.borderRadiusLarge,
192
+ border: `1px solid ${tokens.colorNeutralStroke1}`,
193
+ background: tokens.colorNeutralBackground1,
194
+ "@media (max-width: 900px)": {
195
+ gridTemplateColumns: "minmax(0, 1fr)",
196
+ },
197
+ },
198
+ summaryRow: {
199
+ display: "flex",
200
+ alignItems: "center",
201
+ gap: "12px",
202
+ minHeight: "44px",
203
+ fontSize: "13px",
204
+ color: tokens.colorNeutralForeground2,
205
+ borderBottom: `1px solid ${tokens.colorNeutralStroke2}`,
206
+ // No divider under the last row of each column; the card edge is there.
207
+ ":last-child": { borderBottomStyle: "none" },
208
+ "@media (min-width: 901px)": {
209
+ ":nth-last-child(2):nth-child(odd)": { borderBottomStyle: "none" },
210
+ },
211
+ ":hover": { color: tokens.colorNeutralForeground1 },
212
+ ":focus-visible": {
213
+ outline: `2px solid ${tokens.colorStrokeFocus2}`,
214
+ outlineOffset: "-2px",
215
+ },
216
+ },
217
+ summaryValue: {
218
+ marginLeft: "auto",
219
+ minWidth: 0,
220
+ overflow: "hidden",
221
+ textOverflow: "ellipsis",
222
+ whiteSpace: "nowrap",
223
+ color: tokens.colorNeutralForeground1,
224
+ fontWeight: tokens.fontWeightMedium,
225
+ },
226
+ summaryValueMuted: {
227
+ color: tokens.colorNeutralForeground3,
228
+ fontWeight: tokens.fontWeightRegular,
229
+ },
230
+ });
231
+
232
+ /** A stack of `Callout`s. */
233
+ export function Callouts({
234
+ children,
235
+ }: {
236
+ /** The `Callout`s, one under another. */
237
+ children: ReactNode;
238
+ }) {
239
+ const styles = useStyles();
240
+ return <div className={styles.callouts}>{children}</div>;
241
+ }
242
+
243
+ interface CalloutProps {
244
+ /** Shown in the warning colour, before the text. */
245
+ icon: ReactNode;
246
+ /** The callout's heading. */
247
+ title: string;
248
+ /** A muted line under the title. */
249
+ description: string;
250
+ /** Shown on the right, e.g. a button. */
251
+ action?: ReactNode;
252
+ }
253
+
254
+ /** A bordered notice with a warning icon and an optional action button. */
255
+ export function Callout({ icon, title, description, action }: CalloutProps) {
256
+ const styles = useStyles();
257
+ return (
258
+ <div className={styles.callout}>
259
+ <span className={styles.calloutIcon}>{icon}</span>
260
+ <div className={styles.calloutText}>
261
+ <Text weight="semibold">{title}</Text>
262
+ <Text size={200} className={styles.muted}>
263
+ {description}
264
+ </Text>
265
+ </div>
266
+ {action}
267
+ </div>
268
+ );
269
+ }
270
+
271
+ /** Short lists side by side, three to a row; one under another on narrow
272
+ * screens. */
273
+ export function ListGrid({
274
+ children,
275
+ }: {
276
+ /** The `ListColumn`s. */
277
+ children: ReactNode;
278
+ }) {
279
+ const styles = useStyles();
280
+ return <div className={styles.lists}>{children}</div>;
281
+ }
282
+
283
+ interface ListColumnProps {
284
+ /** The list's heading, a link to the full page. */
285
+ title: string;
286
+ /** Where the heading links. */
287
+ to: string;
288
+ /** Shown beside the title, e.g. the total. */
289
+ count?: number;
290
+ /** Shown when there are no rows. */
291
+ empty: string;
292
+ /** While true, reserves space instead of showing the empty message. */
293
+ loading?: boolean;
294
+ /** The `ListRow`s, as an array. An empty one shows `empty`. */
295
+ children: ReactNode[];
296
+ }
297
+
298
+ /** One short list under a linked heading. */
299
+ export function ListColumn({ title, to, count, empty, loading, children }: ListColumnProps) {
300
+ const styles = useStyles();
301
+ return (
302
+ <section>
303
+ <div className={styles.listHead}>
304
+ <UiLink to={to} className={styles.listHeadLink}>
305
+ {title}
306
+ {count !== undefined && <span className={styles.count}>{count}</span>}
307
+ <ChevronRightRegular className={styles.chevron} />
308
+ </UiLink>
309
+ </div>
310
+ {children.length > 0 ? (
311
+ children
312
+ ) : loading ? (
313
+ <div className={styles.listLoading} aria-busy="true" />
314
+ ) : (
315
+ <div className={styles.empty}>{empty}</div>
316
+ )}
317
+ </section>
318
+ );
319
+ }
320
+
321
+ interface ListRowProps {
322
+ /** Where the row links. */
323
+ to: string;
324
+ /** Shown before the label. */
325
+ icon: ReactNode;
326
+ /** The row's text, cut short with an ellipsis when too long. */
327
+ label: string;
328
+ /** Muted text on the right, e.g. a date. */
329
+ meta?: string;
330
+ }
331
+
332
+ /** One row in a `ListColumn`, linking to its item. */
333
+ export function ListRow({ to, icon, label, meta }: ListRowProps) {
334
+ const styles = useStyles();
335
+ return (
336
+ <UiLink to={to} className={styles.row}>
337
+ <span className={styles.rowIcon}>{icon}</span>
338
+ <span className={styles.rowLabel}>{label}</span>
339
+ {meta && <span className={styles.rowMeta}>{meta}</span>}
340
+ <ChevronRightRegular className={styles.chevron} />
341
+ </UiLink>
342
+ );
343
+ }
344
+
345
+ /** A heading between overview sections. */
346
+ export function SectionTitle({
347
+ children,
348
+ }: {
349
+ /** The heading's text. */
350
+ children: ReactNode;
351
+ }) {
352
+ const styles = useStyles();
353
+ return (
354
+ <Text as="h2" weight="semibold" size={400} className={styles.sectionTitle}>
355
+ {children}
356
+ </Text>
357
+ );
358
+ }
359
+
360
+ /** A grid of `Metric` tiles. */
361
+ export function MetricGrid({
362
+ columns = 4,
363
+ children,
364
+ }: {
365
+ /** Tiles per row. Narrow screens show two. */
366
+ columns?: 3 | 4;
367
+ /** The `Metric`s. */
368
+ children: ReactNode;
369
+ }) {
370
+ const styles = useStyles();
371
+ return (
372
+ <div className={mergeClasses(styles.metrics, columns === 3 && styles.metrics3)}>{children}</div>
373
+ );
374
+ }
375
+
376
+ interface MetricProps {
377
+ /** Where the tile links. */
378
+ to: string;
379
+ /** What the number counts, above it. */
380
+ label: string;
381
+ /** The number, large. Put a `MetricSuffix` after it for "/ 10". */
382
+ value: ReactNode;
383
+ /** A muted line under the value. */
384
+ caption?: string;
385
+ /** Pinned to the card's bottom edge, e.g. a sparkline. */
386
+ footer?: ReactNode;
387
+ }
388
+
389
+ /** A number tile that links to its page. */
390
+ export function Metric({ to, label, value, caption, footer }: MetricProps) {
391
+ const styles = useStyles();
392
+ return (
393
+ <UiLink to={to} className={styles.metric}>
394
+ <span className={styles.metricLabel}>{label}</span>
395
+ <span className={styles.metricValue}>{value}</span>
396
+ {caption && <span className={styles.metricLabel}>{caption}</span>}
397
+ {footer && <span className={styles.metricFooter}>{footer}</span>}
398
+ </UiLink>
399
+ );
400
+ }
401
+
402
+ /** The smaller "/ 12" after a metric value. */
403
+ export function MetricSuffix({
404
+ children,
405
+ }: {
406
+ /** The text, e.g. "/ 10". */
407
+ children: ReactNode;
408
+ }) {
409
+ const styles = useStyles();
410
+ return <span className={styles.metricSuffix}>{children}</span>;
411
+ }
412
+
413
+ /** Label and value rows in a bordered box, two columns wide; one on narrow
414
+ * screens. */
415
+ export function SummaryList({
416
+ children,
417
+ }: {
418
+ /** The `SummaryRow`s. */
419
+ children: ReactNode;
420
+ }) {
421
+ const styles = useStyles();
422
+ return <div className={styles.summary}>{children}</div>;
423
+ }
424
+
425
+ interface SummaryRowProps {
426
+ /** Where the row links. */
427
+ to: string;
428
+ /** What the value is, on the left. */
429
+ label: string;
430
+ /** The value, on the right. */
431
+ value: string;
432
+ /** Render the value muted, for "off" or "not set". */
433
+ dim?: boolean;
434
+ }
435
+
436
+ /** One label and value in a `SummaryList`, linking to its page. */
437
+ export function SummaryRow({ to, label, value, dim }: SummaryRowProps) {
438
+ const styles = useStyles();
439
+ return (
440
+ <UiLink to={to} className={styles.summaryRow}>
441
+ <span>{label}</span>
442
+ <span className={mergeClasses(styles.summaryValue, dim && styles.summaryValueMuted)}>
443
+ {value}
444
+ </span>
445
+ <ChevronRightRegular className={styles.chevron} />
446
+ </UiLink>
447
+ );
448
+ }
@@ -0,0 +1,69 @@
1
+ // Shared page header: title + optional subtitle on the left, optional
2
+ // action buttons on the right. Keeps spacing and typography consistent
3
+ // across pages instead of each one rolling its own header row.
4
+
5
+ import { Text, Title2, makeStyles, tokens } from "@fluentui/react-components";
6
+ import type { CSSProperties, ReactNode } from "react";
7
+ import { useTabTitle } from "../provider/context.js";
8
+
9
+ const useStyles = makeStyles({
10
+ root: {
11
+ display: "flex",
12
+ alignItems: "flex-start",
13
+ justifyContent: "space-between",
14
+ flexWrap: "wrap",
15
+ gap: "12px",
16
+ marginBottom: "24px",
17
+ },
18
+ titles: {
19
+ display: "flex",
20
+ flexDirection: "column",
21
+ gap: "6px",
22
+ minWidth: 0,
23
+ },
24
+ title: {
25
+ margin: 0,
26
+ letterSpacing: "-0.015em",
27
+ },
28
+ subtitle: {
29
+ color: tokens.colorNeutralForeground3,
30
+ },
31
+ actions: {
32
+ display: "flex",
33
+ alignItems: "center",
34
+ gap: "8px",
35
+ flexShrink: 0,
36
+ },
37
+ });
38
+
39
+ interface PageHeaderProps {
40
+ /** The page's heading, its `h1`. */
41
+ title: ReactNode;
42
+ /** A line under the title. */
43
+ subtitle?: ReactNode;
44
+ /** Buttons on the right; they wrap under the title on narrow screens. */
45
+ actions?: ReactNode;
46
+ /** Browser tab title when the visible title doesn't suit one, e.g. a
47
+ * greeting. Defaults to the title when it is a plain string. Goes to
48
+ * `<UiProvider onPageTitle>`. */
49
+ tabTitle?: string;
50
+ /** On the header's root, to override spacing, e.g. `marginBottom: 0` inside
51
+ * flex-gap layouts. */
52
+ style?: CSSProperties;
53
+ }
54
+
55
+ export function PageHeader({ title, subtitle, actions, tabTitle, style }: PageHeaderProps) {
56
+ const styles = useStyles();
57
+ useTabTitle(title, tabTitle);
58
+ return (
59
+ <div className={styles.root} style={style}>
60
+ <div className={styles.titles}>
61
+ <Title2 as="h1" className={styles.title}>
62
+ {title}
63
+ </Title2>
64
+ {subtitle && <Text className={styles.subtitle}>{subtitle}</Text>}
65
+ </div>
66
+ {actions && <div className={styles.actions}>{actions}</div>}
67
+ </div>
68
+ );
69
+ }
@@ -0,0 +1,105 @@
1
+ // Shared pagination bar: the item count, previous / next and jump-to-page
2
+ // with the current and total page count. Hidden while every row fits on the
3
+ // first page.
4
+
5
+ import { Button, Input, Text, makeStyles, tokens } from "@fluentui/react-components";
6
+ import { useState } from "react";
7
+ import { useUiStrings } from "../provider/context.js";
8
+ import { SettingsFooter } from "./Settings.js";
9
+
10
+ const useStyles = makeStyles({
11
+ pager: {
12
+ display: "flex",
13
+ alignItems: "center",
14
+ justifyContent: "flex-end",
15
+ gap: "8px",
16
+ flexWrap: "wrap",
17
+ // Directly under the list it pages, not pinned to the window bottom
18
+ // where it ends up far from a short list.
19
+ paddingTop: "12px",
20
+ },
21
+ pageCount: {
22
+ color: tokens.colorNeutralForeground3,
23
+ whiteSpace: "nowrap",
24
+ },
25
+ jump: { width: "64px" },
26
+ });
27
+
28
+ interface PaginationProps {
29
+ /** The page shown, from 1. */
30
+ page: number;
31
+ /** Rows across all pages. */
32
+ total: number;
33
+ /** Rows per page. */
34
+ pageSize: number;
35
+ /** Called with the page to show. */
36
+ onChange: (page: number) => void;
37
+ /** Disables Previous and Next while a fetch is in flight. */
38
+ disabled?: boolean;
39
+ /** Sit in a `SettingsFooter`, for a list inside a settings card. */
40
+ footer?: boolean;
41
+ }
42
+
43
+ /** Previous and next, the page as "2 / 5", the total, and a box to jump to a
44
+ * page. Hidden while every row fits on the first page. */
45
+ export function Pagination({ page, total, pageSize, onChange, disabled, footer }: PaginationProps) {
46
+ const styles = useStyles();
47
+ const strings = useUiStrings();
48
+ const [jump, setJump] = useState("");
49
+ const pageCount = Math.max(1, Math.ceil(total / pageSize));
50
+
51
+ const goToPage = () => {
52
+ const n = Number.parseInt(jump, 10);
53
+ if (!Number.isNaN(n)) {
54
+ onChange(Math.min(pageCount, Math.max(1, n)));
55
+ setJump("");
56
+ }
57
+ };
58
+
59
+ // A list that shrank under a later page (e.g. after deleting its last row)
60
+ // keeps the controls, so Previous still leads back to the rows.
61
+ if (pageCount <= 1 && page <= 1) return null;
62
+
63
+ const bar = (
64
+ <div className={styles.pager}>
65
+ <Text size={200} className={styles.pageCount}>
66
+ {strings.totalItems(total)}
67
+ </Text>
68
+ <Button
69
+ size="small"
70
+ appearance="subtle"
71
+ disabled={disabled || page <= 1}
72
+ onClick={() => onChange(page - 1)}
73
+ >
74
+ {strings.previous}
75
+ </Button>
76
+ <Text size={200} className={styles.pageCount}>
77
+ {strings.pageOf(page, pageCount)}
78
+ </Text>
79
+ <Button
80
+ size="small"
81
+ appearance="subtle"
82
+ disabled={disabled || page >= pageCount}
83
+ onClick={() => onChange(page + 1)}
84
+ >
85
+ {strings.next}
86
+ </Button>
87
+ <Input
88
+ className={styles.jump}
89
+ size="small"
90
+ type="number"
91
+ min={1}
92
+ max={pageCount}
93
+ value={jump}
94
+ onChange={(_, d) => setJump(d.value)}
95
+ onKeyDown={(e) => e.key === "Enter" && goToPage()}
96
+ placeholder={strings.pageNumber}
97
+ aria-label={strings.goToPage}
98
+ />
99
+ <Button size="small" appearance="subtle" onClick={goToPage}>
100
+ {strings.go}
101
+ </Button>
102
+ </div>
103
+ );
104
+ return footer ? <SettingsFooter>{bar}</SettingsFooter> : bar;
105
+ }
@@ -0,0 +1,50 @@
1
+ // Password field with a show/hide toggle. Drop-in replacement for
2
+ // <Input type="password">; all other InputProps pass through.
3
+
4
+ import { Button, Input, Tooltip, makeStyles, mergeClasses } from "@fluentui/react-components";
5
+ import type { InputProps } from "@fluentui/react-components";
6
+ import { EyeOffRegular, EyeRegular } from "@fluentui/react-icons";
7
+ import { useState } from "react";
8
+ import { useUiStrings } from "../provider/context.js";
9
+
10
+ const useStyles = makeStyles({
11
+ // Edge draws its own reveal button in a password field, and a clear button
12
+ // once the text shows, beside the toggle here. Other browsers reject these
13
+ // selectors, and Griffel logs each rejected rule in development: @supports
14
+ // keeps the rules from them.
15
+ root: {
16
+ "@supports selector(::-ms-reveal)": {
17
+ "& input::-ms-reveal": { display: "none" },
18
+ "& input::-ms-clear": { display: "none" },
19
+ },
20
+ },
21
+ });
22
+
23
+ export function PasswordInput(props: Omit<InputProps, "type">) {
24
+ const styles = useStyles();
25
+ const strings = useUiStrings();
26
+ const [visible, setVisible] = useState(false);
27
+ return (
28
+ <Input
29
+ {...props}
30
+ className={mergeClasses(styles.root, props.className)}
31
+ type={visible ? "text" : "password"}
32
+ contentAfter={
33
+ <Tooltip
34
+ content={visible ? strings.hidePassword : strings.showPassword}
35
+ relationship="label"
36
+ >
37
+ <Button
38
+ appearance="transparent"
39
+ size="small"
40
+ icon={visible ? <EyeOffRegular /> : <EyeRegular />}
41
+ onClick={() => setVisible((v) => !v)}
42
+ // Keep the toggle out of the tab order so Tab moves between
43
+ // form fields; the tooltip still labels it for pointer users.
44
+ tabIndex={-1}
45
+ />
46
+ </Tooltip>
47
+ }
48
+ />
49
+ );
50
+ }