nexus-shared 1.1.20 → 2.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 (332) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +903 -0
  3. package/dist/Client.Index.d.ts +44 -0
  4. package/dist/Client.Index.js +49 -0
  5. package/dist/Components/Documents/Button.d.ts +29 -0
  6. package/dist/Components/Documents/Button.js +11 -0
  7. package/dist/Components/Documents/Menu.d.ts +102 -0
  8. package/dist/Components/Documents/Menu.js +238 -0
  9. package/dist/Components/Documents/SplitButton.d.ts +64 -0
  10. package/dist/Components/Documents/SplitButton.js +127 -0
  11. package/dist/Components/Documents/TabButtons.d.ts +62 -0
  12. package/dist/Components/Documents/TabButtons.js +19 -0
  13. package/dist/Components/Forms/ApiForm.d.ts +21 -0
  14. package/dist/Components/Forms/ApiForm.js +99 -0
  15. package/dist/Components/Forms/Crud.d.ts +17 -0
  16. package/dist/Components/Forms/Crud.js +556 -0
  17. package/dist/Components/Forms/CrudParts.d.ts +15 -0
  18. package/dist/Components/Forms/CrudParts.js +36 -0
  19. package/dist/Components/Forms/Form.d.ts +52 -0
  20. package/dist/Components/Forms/Form.js +319 -0
  21. package/dist/Components/Forms/SubmitForm.d.ts +65 -0
  22. package/dist/Components/Forms/SubmitForm.js +198 -0
  23. package/dist/Components/Inputs/Calendar.d.ts +69 -0
  24. package/dist/Components/Inputs/Calendar.js +258 -0
  25. package/dist/Components/Inputs/CheckBox.d.ts +53 -0
  26. package/dist/Components/Inputs/CheckBox.js +87 -0
  27. package/dist/Components/Inputs/CheckBoxGroup.d.ts +20 -0
  28. package/dist/Components/Inputs/CheckBoxGroup.js +80 -0
  29. package/dist/Components/Inputs/ChoiceField.d.ts +122 -0
  30. package/dist/Components/Inputs/ChoiceField.js +169 -0
  31. package/dist/Components/Inputs/DatePicker.d.ts +54 -0
  32. package/dist/Components/Inputs/DatePicker.js +246 -0
  33. package/dist/Components/Inputs/DateRangePicker.d.ts +62 -0
  34. package/dist/Components/Inputs/DateRangePicker.js +283 -0
  35. package/dist/Components/Inputs/DateTimePicker.d.ts +75 -0
  36. package/dist/Components/Inputs/DateTimePicker.js +399 -0
  37. package/dist/Components/Inputs/Dropdown.d.ts +117 -0
  38. package/dist/Components/Inputs/Dropdown.js +839 -0
  39. package/dist/Components/Inputs/DropdownParts.d.ts +84 -0
  40. package/dist/Components/Inputs/DropdownParts.js +102 -0
  41. package/dist/Components/Inputs/EditorShell.d.ts +45 -0
  42. package/dist/Components/Inputs/EditorShell.js +214 -0
  43. package/dist/Components/Inputs/Field.d.ts +53 -0
  44. package/dist/Components/Inputs/Field.js +16 -0
  45. package/dist/Components/Inputs/GroupForm.d.ts +20 -0
  46. package/dist/Components/Inputs/GroupForm.js +170 -0
  47. package/dist/Components/Inputs/InputField.d.ts +59 -0
  48. package/dist/Components/Inputs/InputField.js +169 -0
  49. package/dist/Components/Inputs/InputRenderer.d.ts +35 -0
  50. package/dist/Components/Inputs/InputRenderer.js +99 -0
  51. package/dist/Components/Inputs/MarkdownEditor.d.ts +67 -0
  52. package/dist/Components/Inputs/MarkdownEditor.js +289 -0
  53. package/dist/Components/Inputs/NumberBox.d.ts +53 -0
  54. package/dist/Components/Inputs/NumberBox.js +228 -0
  55. package/dist/Components/Inputs/RadioGroup.d.ts +20 -0
  56. package/dist/Components/Inputs/RadioGroup.js +43 -0
  57. package/dist/Components/Inputs/ReadOnlyNotice.d.ts +36 -0
  58. package/dist/Components/Inputs/ReadOnlyNotice.js +116 -0
  59. package/dist/Components/Inputs/RichTextEditor.d.ts +103 -0
  60. package/dist/Components/Inputs/RichTextEditor.js +1170 -0
  61. package/dist/Components/Inputs/RichTextParts.d.ts +63 -0
  62. package/dist/Components/Inputs/RichTextParts.js +157 -0
  63. package/dist/Components/Inputs/RowsInput.d.ts +104 -0
  64. package/dist/Components/Inputs/RowsInput.js +259 -0
  65. package/dist/Components/Inputs/Slider.d.ts +87 -0
  66. package/dist/Components/Inputs/Slider.js +216 -0
  67. package/dist/Components/Inputs/TabularForm.d.ts +23 -0
  68. package/dist/Components/Inputs/TabularForm.js +283 -0
  69. package/dist/Components/Inputs/TextArea.d.ts +43 -0
  70. package/dist/Components/Inputs/TextArea.js +31 -0
  71. package/dist/Components/Inputs/TextBox.d.ts +52 -0
  72. package/dist/Components/Inputs/TextBox.js +58 -0
  73. package/dist/Components/Inputs/TextField.d.ts +31 -0
  74. package/dist/Components/Inputs/TextField.js +35 -0
  75. package/dist/Components/Inputs/TimePanel.d.ts +34 -0
  76. package/dist/Components/Inputs/TimePanel.js +288 -0
  77. package/dist/Components/Inputs/TimePicker.d.ts +54 -0
  78. package/dist/Components/Inputs/TimePicker.js +239 -0
  79. package/dist/Components/Inputs/TreeView.d.ts +160 -0
  80. package/dist/Components/Inputs/TreeView.js +947 -0
  81. package/dist/Components/Layouts/MessageBox.d.ts +71 -0
  82. package/dist/Components/Layouts/MessageBox.js +104 -0
  83. package/dist/Components/Layouts/Popup.d.ts +92 -0
  84. package/dist/Components/Layouts/Popup.js +376 -0
  85. package/dist/Components/Layouts/PopupContext.d.ts +2 -0
  86. package/dist/Components/Layouts/PopupContext.js +4 -0
  87. package/dist/Components/Layouts/PopupDock.d.ts +22 -0
  88. package/dist/Components/Layouts/PopupDock.js +121 -0
  89. package/dist/Components/Layouts/PopupHost.d.ts +56 -0
  90. package/dist/Components/Layouts/PopupHost.js +163 -0
  91. package/dist/Components/Layouts/PopupRules.d.ts +30 -0
  92. package/dist/Components/Layouts/PopupRules.js +63 -0
  93. package/dist/Components/Layouts/ThemePicker.d.ts +13 -0
  94. package/dist/Components/Layouts/ThemePicker.js +22 -0
  95. package/dist/Components/Layouts/ThemeScript.d.ts +14 -0
  96. package/dist/Components/Layouts/ThemeScript.js +13 -0
  97. package/dist/Components/Layouts/ThemeSwitcher.d.ts +13 -0
  98. package/dist/Components/Layouts/ThemeSwitcher.js +29 -0
  99. package/dist/Components/Layouts/Toaster.d.ts +76 -0
  100. package/dist/Components/Layouts/Toaster.js +172 -0
  101. package/dist/Components/Viewers/DataTable.d.ts +25 -0
  102. package/dist/Components/Viewers/DataTable.js +542 -0
  103. package/dist/Components/Viewers/DataTableParts.d.ts +134 -0
  104. package/dist/Components/Viewers/DataTableParts.js +145 -0
  105. package/dist/Components/Viewers/MarkdownView.d.ts +26 -0
  106. package/dist/Components/Viewers/MarkdownView.js +79 -0
  107. package/dist/Components/Viewers/RichTextView.d.ts +18 -0
  108. package/dist/Components/Viewers/RichTextView.js +17 -0
  109. package/dist/Helpers/AnimationHelpers.d.ts +6 -0
  110. package/dist/Helpers/AnimationHelpers.js +35 -0
  111. package/dist/Helpers/ApiClient.d.ts +74 -0
  112. package/dist/Helpers/ApiClient.js +197 -0
  113. package/dist/Helpers/ApiFormHelpers.d.ts +26 -0
  114. package/dist/Helpers/ApiFormHelpers.js +56 -0
  115. package/dist/Helpers/ApiModules.d.ts +135 -0
  116. package/dist/Helpers/ApiModules.js +194 -0
  117. package/dist/Helpers/ApiResponses.d.ts +41 -0
  118. package/dist/Helpers/ApiResponses.js +159 -0
  119. package/dist/Helpers/ApiRoutes.d.ts +150 -0
  120. package/dist/Helpers/ApiRoutes.js +191 -0
  121. package/dist/Helpers/ApiToasts.d.ts +21 -0
  122. package/dist/Helpers/ApiToasts.js +22 -0
  123. package/dist/Helpers/ClassHelpers.d.ts +3 -0
  124. package/dist/Helpers/ClassHelpers.js +4 -0
  125. package/dist/Helpers/CrudBackend.d.ts +56 -0
  126. package/dist/Helpers/CrudBackend.js +119 -0
  127. package/dist/Helpers/CrudHelpers.d.ts +76 -0
  128. package/dist/Helpers/CrudHelpers.js +202 -0
  129. package/dist/Helpers/DateHelpers.d.ts +88 -0
  130. package/dist/Helpers/DateHelpers.js +363 -0
  131. package/dist/Helpers/DatePreferences.d.ts +14 -0
  132. package/dist/Helpers/DatePreferences.js +94 -0
  133. package/dist/Helpers/DateTimeHelpers.d.ts +87 -0
  134. package/dist/Helpers/DateTimeHelpers.js +286 -0
  135. package/dist/Helpers/DragHelpers.d.ts +129 -0
  136. package/dist/Helpers/DragHelpers.js +281 -0
  137. package/dist/Helpers/DropdownHelpers.d.ts +56 -0
  138. package/dist/Helpers/DropdownHelpers.js +180 -0
  139. package/dist/Helpers/FormDrafts.d.ts +18 -0
  140. package/dist/Helpers/FormDrafts.js +76 -0
  141. package/dist/Helpers/FormStore.d.ts +231 -0
  142. package/dist/Helpers/FormStore.js +734 -0
  143. package/dist/Helpers/InputParamsHelpers.d.ts +79 -0
  144. package/dist/Helpers/InputParamsHelpers.js +388 -0
  145. package/dist/Helpers/MarkdownEditing.d.ts +27 -0
  146. package/dist/Helpers/MarkdownEditing.js +250 -0
  147. package/dist/Helpers/MarkdownHelpers.d.ts +82 -0
  148. package/dist/Helpers/MarkdownHelpers.js +775 -0
  149. package/dist/Helpers/MessageBuilder.d.ts +74 -0
  150. package/dist/Helpers/MessageBuilder.js +254 -0
  151. package/dist/Helpers/NepaliCalendar.d.ts +25 -0
  152. package/dist/Helpers/NepaliCalendar.js +107 -0
  153. package/dist/Helpers/NumberHelpers.d.ts +71 -0
  154. package/dist/Helpers/NumberHelpers.js +202 -0
  155. package/dist/Helpers/Permissions.d.ts +62 -0
  156. package/dist/Helpers/Permissions.js +133 -0
  157. package/dist/Helpers/PopoverHelpers.d.ts +43 -0
  158. package/dist/Helpers/PopoverHelpers.js +91 -0
  159. package/dist/Helpers/RichTextHelpers.d.ts +77 -0
  160. package/dist/Helpers/RichTextHelpers.js +1072 -0
  161. package/dist/Helpers/RowsStore.d.ts +160 -0
  162. package/dist/Helpers/RowsStore.js +584 -0
  163. package/dist/Helpers/TableColumns.d.ts +40 -0
  164. package/dist/Helpers/TableColumns.js +254 -0
  165. package/dist/Helpers/TableExport.d.ts +30 -0
  166. package/dist/Helpers/TableExport.js +97 -0
  167. package/dist/Helpers/TableHelpers.d.ts +102 -0
  168. package/dist/Helpers/TableHelpers.js +281 -0
  169. package/dist/Helpers/TableStore.d.ts +142 -0
  170. package/dist/Helpers/TableStore.js +530 -0
  171. package/dist/Helpers/ThemeHelpers.d.ts +15 -0
  172. package/dist/Helpers/ThemeHelpers.js +16 -0
  173. package/dist/Helpers/TimeHelpers.d.ts +73 -0
  174. package/dist/Helpers/TimeHelpers.js +253 -0
  175. package/dist/Helpers/TreeStore.d.ts +188 -0
  176. package/dist/Helpers/TreeStore.js +577 -0
  177. package/dist/Helpers/ValidationHelpers.d.ts +124 -0
  178. package/dist/Helpers/ValidationHelpers.js +301 -0
  179. package/dist/Interfaces/ApiInterfaces.d.ts +149 -0
  180. package/dist/Interfaces/ApiInterfaces.js +24 -0
  181. package/dist/Interfaces/CrudInterfaces.d.ts +171 -0
  182. package/{src/sso-client.tsx → dist/Interfaces/CrudInterfaces.js} +1 -1
  183. package/dist/Interfaces/DateInterfaces.d.ts +154 -0
  184. package/dist/Interfaces/DateInterfaces.js +29 -0
  185. package/dist/Interfaces/FormInterfaces.d.ts +352 -0
  186. package/dist/Interfaces/FormInterfaces.js +1 -0
  187. package/dist/Interfaces/InputInterfaces.d.ts +141 -0
  188. package/dist/Interfaces/InputInterfaces.js +1 -0
  189. package/dist/Interfaces/MessageInterfaces.d.ts +111 -0
  190. package/dist/Interfaces/MessageInterfaces.js +5 -0
  191. package/dist/Interfaces/TableInterfaces.d.ts +291 -0
  192. package/dist/Interfaces/TableInterfaces.js +1 -0
  193. package/dist/Interfaces/ThemeInterfaces.d.ts +17 -0
  194. package/dist/Interfaces/ThemeInterfaces.js +17 -0
  195. package/dist/Interfaces/TypeInterfaces.d.ts +4 -0
  196. package/dist/Interfaces/TypeInterfaces.js +1 -0
  197. package/dist/Server.Index.d.ts +2 -0
  198. package/dist/Server.Index.js +5 -0
  199. package/dist/Services/ApiProxy.d.ts +32 -0
  200. package/dist/Services/ApiProxy.js +111 -0
  201. package/dist/Services/BrowserApi.d.ts +78 -0
  202. package/dist/Services/BrowserApi.js +111 -0
  203. package/dist/Services/ServerApi.d.ts +49 -0
  204. package/dist/Services/ServerApi.js +75 -0
  205. package/dist/Services/ThemeService.d.ts +17 -0
  206. package/dist/Services/ThemeService.js +83 -0
  207. package/dist/Shared.Index.d.ts +43 -0
  208. package/dist/Shared.Index.js +47 -0
  209. package/package.json +82 -33
  210. package/src/Styles/Nexus.Base.css +70 -0
  211. package/src/Styles/Nexus.Button.css +151 -0
  212. package/src/Styles/Nexus.Calendar.css +275 -0
  213. package/src/Styles/Nexus.Choice.css +345 -0
  214. package/src/Styles/Nexus.Crud.css +84 -0
  215. package/src/Styles/Nexus.DateTime.css +81 -0
  216. package/src/Styles/Nexus.Dropdown.css +774 -0
  217. package/src/Styles/Nexus.Editor.css +297 -0
  218. package/src/Styles/Nexus.Form.css +298 -0
  219. package/src/Styles/Nexus.Index.css +34 -0
  220. package/src/Styles/Nexus.Input.css +637 -0
  221. package/src/Styles/Nexus.Markdown.css +265 -0
  222. package/src/Styles/Nexus.Menu.css +249 -0
  223. package/src/Styles/Nexus.Popup.css +731 -0
  224. package/src/Styles/Nexus.RichText.css +463 -0
  225. package/src/Styles/Nexus.Rows.css +566 -0
  226. package/src/Styles/Nexus.Slider.css +278 -0
  227. package/src/Styles/Nexus.Tab.Buttons.css +364 -0
  228. package/src/Styles/Nexus.Table.css +1014 -0
  229. package/src/Styles/Nexus.Theme.Picker.css +159 -0
  230. package/src/Styles/Nexus.Themes.css +194 -0
  231. package/src/Styles/Nexus.Time.css +147 -0
  232. package/src/Styles/Nexus.Toast.css +265 -0
  233. package/src/Styles/Nexus.Tokens.css +72 -0
  234. package/src/Styles/Nexus.Tree.css +435 -0
  235. package/src/api-services/authentication-service.tsx +0 -23
  236. package/src/api-services/preference-service.tsx +0 -5
  237. package/src/api-services/system-service.tsx +0 -34
  238. package/src/client.ts +0 -31
  239. package/src/components/documents/button.tsx +0 -142
  240. package/src/components/documents/icon-box.tsx +0 -93
  241. package/src/components/documents/page-title.tsx +0 -7
  242. package/src/components/documents/tab-button.tsx +0 -172
  243. package/src/components/documents/tag.tsx +0 -30
  244. package/src/components/index.js +0 -0
  245. package/src/components/inputs/checkbox-input.tsx +0 -66
  246. package/src/components/inputs/input-box.tsx +0 -48
  247. package/src/components/inputs/input-element.tsx +0 -65
  248. package/src/components/inputs/input-form.tsx +0 -164
  249. package/src/components/inputs/input.tsx +0 -181
  250. package/src/components/inputs/number-input.tsx +0 -108
  251. package/src/components/inputs/radiobox-input.tsx +0 -53
  252. package/src/components/inputs/textarea-input.tsx +0 -47
  253. package/src/components/inputs/textbox-input.tsx +0 -45
  254. package/src/components/layouts/global-dialogbox.tsx +0 -431
  255. package/src/components/layouts/global-layout.tsx +0 -59
  256. package/src/components/layouts/layout-helpers.tsx +0 -20
  257. package/src/components/layouts/panels/user-panel.tsx +0 -112
  258. package/src/components/layouts/utility-menu.tsx +0 -49
  259. package/src/components/panels/theme-panel.tsx +0 -46
  260. package/src/helpers/bitwise-helpers.tsx +0 -11
  261. package/src/helpers/browser-helpers.tsx +0 -156
  262. package/src/helpers/datasource-helpers.tsx +0 -99
  263. package/src/helpers/element-helpers.tsx +0 -57
  264. package/src/helpers/input-helpers.tsx +0 -74
  265. package/src/helpers/string-helpers.tsx +0 -28
  266. package/src/helpers/utility-helpers.tsx +0 -45
  267. package/src/helpers/validation-helpers.tsx +0 -302
  268. package/src/index.ts +0 -26
  269. package/src/interface.ts +0 -19
  270. package/src/interfaces/auth-token-interfaces.tsx +0 -6
  271. package/src/interfaces/browser-interfaces.tsx +0 -36
  272. package/src/interfaces/button-interfaces.tsx +0 -63
  273. package/src/interfaces/datasource-interfaces.tsx +0 -22
  274. package/src/interfaces/datatable-interfaces.tsx +0 -25
  275. package/src/interfaces/dialogbox-interfaces.tsx +0 -5
  276. package/src/interfaces/exception-interfaces.tsx +0 -99
  277. package/src/interfaces/http-interfaces.tsx +0 -129
  278. package/src/interfaces/icon-interfaces.tsx +0 -129
  279. package/src/interfaces/input-interfaces.tsx +0 -410
  280. package/src/interfaces/layout-interfaces.tsx +0 -191
  281. package/src/interfaces/menu-interfaces.tsx +0 -49
  282. package/src/interfaces/message-interfaces.tsx +0 -32
  283. package/src/interfaces/permission-interfaces.tsx +0 -9
  284. package/src/interfaces/storage-interfaces.tsx +0 -5
  285. package/src/interfaces/system-interfaces.tsx +0 -22
  286. package/src/interfaces/theme-interfaces.tsx +0 -123
  287. package/src/interfaces/type-interfaces.tsx +0 -28
  288. package/src/interfaces/user-interfaces.tsx +0 -47
  289. package/src/nexus-client.tsx +0 -21
  290. package/src/nexus.environments.tsx +0 -66
  291. package/src/proxy-api/proxy-backend.tsx +0 -60
  292. package/src/proxy-api/proxy-constants.tsx +0 -28
  293. package/src/proxy-api/proxy-helpers.tsx +0 -91
  294. package/src/proxy-api-client.tsx +0 -1
  295. package/src/proxy-api-server.tsx +0 -2
  296. package/src/services/http-client-services.tsx +0 -75
  297. package/src/services/http-services.tsx +0 -158
  298. package/src/services/loader-service.tsx +0 -185
  299. package/src/services/localstorage-service.tsx +0 -119
  300. package/src/services/message-services.tsx +0 -383
  301. package/src/services/theme-service.tsx +0 -161
  302. package/src/services/user-services.tsx +0 -10
  303. package/src/sso-config/auth-token-validation.ts +0 -16
  304. package/src/sso-config/callback-route.tsx +0 -35
  305. package/src/sso-config/cookie-encryption.ts +0 -51
  306. package/src/sso-config/cookie-helpers.tsx +0 -102
  307. package/src/sso-config/forgot-password-route.tsx +0 -36
  308. package/src/sso-config/oauth-callback-state.ts +0 -61
  309. package/src/sso-config/pkce-helpers.ts +0 -9
  310. package/src/sso-config/provider-complete-route.tsx +0 -18
  311. package/src/sso-config/redirect-context-actions.tsx +0 -45
  312. package/src/sso-config/redirect-context-helpers.tsx +0 -159
  313. package/src/sso-config/redirect-context-persist.tsx +0 -18
  314. package/src/sso-config/redirect-context-route.tsx +0 -45
  315. package/src/sso-config/refresh-route.tsx +0 -23
  316. package/src/sso-config/sign-in-route.tsx +0 -74
  317. package/src/sso-config/sign-out-route.tsx +0 -57
  318. package/src/sso-config/sign-up-route.tsx +0 -57
  319. package/src/sso-config/sso-backend-flow.ts +0 -38
  320. package/src/sso-config/sso-complete-route.tsx +0 -50
  321. package/src/sso-config/sso-config.ts +0 -59
  322. package/src/sso-config/sso-interfaces.tsx +0 -99
  323. package/src/sso-config/sso-response-helpers.tsx +0 -20
  324. package/src/sso-server.tsx +0 -21
  325. package/src/styles/nexus.animation.css +0 -269
  326. package/src/styles/nexus.core.css +0 -119
  327. package/src/styles/nexus.dialog.css +0 -144
  328. package/src/styles/nexus.icon.css +0 -51
  329. package/src/styles/nexus.input.css +0 -207
  330. package/src/styles/nexus.loader.css +0 -11
  331. package/src/styles/nexus.logic.css +0 -47
  332. package/src/styles/nexus.utility.css +0 -347
package/README.md ADDED
@@ -0,0 +1,903 @@
1
+ # nexus-shared
2
+
3
+ Lightweight React components, helpers, and design tokens for Nexus apps. No runtime dependencies besides
4
+ React and `nexus-icons`.
5
+
6
+ ```
7
+ npm install nexus-shared nexus-icons
8
+ ```
9
+
10
+ ```tsx
11
+ // Once, in the root layout
12
+ import "nexus-shared/styles.css";
13
+
14
+ import { Button } from "nexus-shared";
15
+ import { InlineIcon, iconPlus } from "nexus-icons";
16
+
17
+ <Button variant="primary" icon={<InlineIcon icon={iconPlus} />}>New booking</Button>
18
+ ```
19
+
20
+ ## Entry points
21
+
22
+ | Import | Contains |
23
+ |---|---|
24
+ | `nexus-shared` | Components and helpers that work in server and client components |
25
+ | `nexus-shared/client` | Client components and browser services |
26
+ | `nexus-shared/server` | Server-only code |
27
+ | `nexus-shared/styles.css` | Tokens, base styles, and component styles |
28
+
29
+ ## Themes
30
+
31
+ Seven themes, each with a light and a dark palette that meets WCAG AA contrast:
32
+ **Nexus** (default), **GitHub**, **Nord**, **Dracula**, **Solarized**, **Catppuccin**, and **Rosé Pine**.
33
+ The mode is Light, Dark, or System (follows the operating system).
34
+
35
+ ```tsx
36
+ // app/layout.tsx
37
+ import "nexus-shared/styles.css";
38
+ import { ThemeScript } from "nexus-shared";
39
+ import { ThemeSwitcher } from "nexus-shared/client";
40
+
41
+ export default function RootLayout({ children }) {
42
+ return (
43
+ <html lang="en" suppressHydrationWarning>
44
+ <head>
45
+ <ThemeScript />
46
+ </head>
47
+ <body>
48
+ <header>… <ThemeSwitcher /></header>
49
+ {children}
50
+ </body>
51
+ </html>
52
+ );
53
+ }
54
+ ```
55
+
56
+ - `ThemeScript` applies the saved choice before the page paints, so there is no flash of the default theme.
57
+ Options: `defaultTheme`, `defaultMode`, `themes`, `nonce`. It sets attributes on `<html>`, hence `suppressHydrationWarning`.
58
+ - `ThemeSwitcher` is a palette button with a popover; `ThemePicker` is the same picker placed in a page.
59
+ - `useTheme()` returns `{ theme, mode, resolvedMode, setTheme, setMode }` for custom controls.
60
+ - The choice is saved in `localStorage` (`nx-theme`, `nx-mode`) and shared by open tabs.
61
+
62
+ Without JavaScript, set the attributes yourself: `<html data-nx-theme="nord" data-nx-mode="dark">`.
63
+ Without `data-nx-mode`, the system setting applies. `data-nx-theme` also works on any element, which then
64
+ draws in that theme (the picker's previews use this).
65
+
66
+ ### How it works
67
+
68
+ - `Nexus.Themes.css` gives each theme its colors once, as `light-dark(light, dark)`; the page's `color-scheme` picks the side.
69
+ - `Nexus.Tokens.css` holds sizes, spacing, and type, and derives hover colors, soft backgrounds, and the focus ring from the palette.
70
+ - Components use only `--nx-*` variables, so every component follows the theme with no extra code.
71
+ - `npm run check:themes` checks every theme in both modes against WCAG contrast. Run it after changing a color.
72
+
73
+ ### Custom themes
74
+
75
+ A theme is one CSS block. List it for the script and the picker:
76
+
77
+ ```css
78
+ [data-nx-theme="brand"] {
79
+ --nx-primary: light-dark(#0f766e, #2dd4bf); /* the accent as text and lines */
80
+ --nx-primary-solid: light-dark(#0f766e, #0d7a70); /* the accent as a fill behind white text: buttons, checks */
81
+ --nx-primary-text: light-dark(#ffffff, #ffffff);
82
+ /* …any other --nx-* color: bg, surface, surface-2, surface-hover, border, border-strong,
83
+ text, text-muted, text-subtle, danger, danger-solid, danger-text, success, warning, info */
84
+ }
85
+ ```
86
+
87
+ ```tsx
88
+ const themes = [...NEXUS_THEMES, { id: "brand", name: "Brand", description: "Our colors" }];
89
+ <ThemeScript themes={themes} defaultTheme="brand" />
90
+ <ThemeSwitcher themes={themes} />
91
+ ```
92
+
93
+ All styles sit in `@layer nexus.*`, so an app's own CSS overrides any token or component style without `!important`.
94
+
95
+ ## Components
96
+
97
+ | Component | Import | Notes |
98
+ |---|---|---|
99
+ | `Button` | `nexus-shared` | Variants `primary`, `secondary`, `ghost`, `danger`; sizes `sm`, `md`, `lg`; `icon`, `iconEnd`, `loading`, `block`; `hoverTone` |
100
+ | `TabButtons` | `nexus-shared/client` | Pick one option; sliding indicator; sizes, `tone="primary"`, `labels="selected"` (icons, label on the selected option), `block`, disabled options; `design="list"` for a vertical list with descriptions and badges |
101
+ | `SplitButton` | `nexus-shared/client` | A main action with a menu of alternatives; the pick becomes the main button, and `storageKey` remembers it for the next visit |
102
+ | `Menu`, `ContextMenu` | `nexus-shared/client` | A dropdown menu under a button, and a right-click menu: icons, shortcuts, descriptions, `tone="danger"`, links, `kind="radio"` or `"checkbox"` |
103
+ | `Toaster`, `toast` | `nexus-shared/client` | Toast messages from anywhere: `toast.success(title, message)`, `toast.promise`, `toast.loading`, actions, positions; one `<Toaster />` in the layout |
104
+ | `Popup` | `nexus-shared/client` | A modal window on the native dialog, with the buttons of a desktop window: minimize (a bar at the bottom right, content kept), maximize, close; moved by its title bar inside the window; title, description, scrolling body, footer, sizes `xs` to `full`, close reasons |
105
+ | `PopupHost`, `openPopup` | `nexus-shared/client` | Popups opened from code with a handle (`close`, `update`, `minimize`, `maximize`, `restore`, `windowState`, `closed`), one per `key` (replaced or restored); one `<PopupHost />` in the layout, which also shows the minimized popups |
106
+ | `definePopupRules` | `nexus-shared/client` | Rules for popups by key or `prefix-*` pattern, set once: `reopen` (replace or restore), `minimizable`, `maximizable`, `movable`, how it closes, `size`, `defaultWindowState` |
107
+ | `useDraggable`, `makeDraggable`, `startDrag`, `moveWithin`, `clampToBounds` | `nexus-shared/client` | Move any element with the pointer (or the keyboard), kept inside bounds: the window, the parent, an element, or a box; by a handle, along one axis, partly outside; Esc puts it back |
108
+ | `messageBox` | `nexus-shared/client` | `alert`, `confirm`, `prompt`, and `show` with any buttons, each returning a promise |
109
+ | `TextBox` | `nexus-shared/client` | Text input: label designs `standard`, `outlined`, `inbox`; sizes; icons; `prefix`, `suffix`; `clearable`; show password; `showCount`; validation |
110
+ | `TextArea` | `nexus-shared/client` | Multi-line text with the same field features; `autoResize` between `rows` and `maxRows` |
111
+ | `CheckBox`, `Switch` | `nexus-shared/client` | One checkbox or on/off switch: `label`, `description`, `required` (must be checked), `indeterminate`, `readOnly`, `labelPosition` |
112
+ | `CheckBoxGroup` | `nexus-shared/client` | Many choices from `options`: `min`, `max` (disables the rest at the limit), `selectAll`, `columns`, `design="cards"` |
113
+ | `RadioGroup` | `nexus-shared/client` | One choice from `options`: arrow keys, `orientation`, `columns`, `design="cards"` |
114
+ | `Dropdown` | `nexus-shared/client` | One value, or several with `multiple`, from `options` or server pages (`loadOptions`: search, infinite scroll, loaders, Retry); rows as `columns` like a data table (avatar, image, icon, code); saved values the list no longer offers (`selectedOptions`, `resolveOptions`, inactive items) show and cannot be picked again |
115
+ | `Slider`, `RangeSlider` | `nexus-shared/client` | Pick a number or a range: `min`, `max`, `step`, number format with `prefix`/`suffix`, `marks`, `tooltip`, `minDistance`, `onValueCommit` |
116
+ | `NumberBox` | `nexus-shared/client` | Numbers only: `min`, `max`, `decimals`, `fixedDecimals`, `grouping` by `locale`, `prefix`, `suffix`, `stepper`, `clamp`; the same field shell |
117
+ | `DatePicker` | `nexus-shared/client` | Type or pick a date in the English (AD) or Nepali (BS) calendar from the user's settings; `min`, `max`, `isDateDisabled`; the value is always a Gregorian ISO date |
118
+ | `DateRangePicker` | `nexus-shared/client` | A start and an end in one box, picked in a two-month calendar or typed; `startName` and `endName` send two fields; `minDistance`, `maxDistance` in days; booked nights cannot be included |
119
+ | `TimePicker` | `nexus-shared/client` | Type or pick a time on a 12- or 24-hour clock from the user's settings: columns of hours and minutes or `view="list"` slots; `min`, `max` (past midnight too), `step` in seconds, `isTimeDisabled`; the value is always an ISO time |
120
+ | `DateTimePicker` | `nexus-shared/client` | Type or pick a day and a time: each user sees their own local time in their date and time settings, and the value is always the UTC moment; `timeZone` for a place's zone, `min`, `max`, `minTime`, `maxTime`, `step`, `isDateDisabled`, `isTimeDisabled` |
121
+ | `Calendar` | `nexus-shared/client` | The month grid on its own: single or `mode="range"`, `months={2}` side by side, month and year menus, arrow keys, `renderDay` for event markers, `weekStart` |
122
+ | `useDatePreferences`, `setDatePreferences` | `nexus-shared/client` | The user's calendar, format, script, and time format, saved in local storage and followed by every date and time component |
123
+ | `Form` | `nexus-shared/client` | A list of input params (`InputParams[]`) on a 12-column grid (`span`), with the values in a store outside React; `onFieldChange` for derived values, `validate` for rules across inputs, `draftKey` for unsaved changes that survive a reload, `loading` placeholders |
124
+ | `SubmitForm` | `nexus-shared/client` | A `Form` that checks every value on Save and focuses the first problem, then runs `onSubmit` once at a time; a status line with links to what needs attention; Save, Cancel (asks first), Reset; Ctrl+S |
125
+ | `ApiForm` | `nexus-shared/client` | A `SubmitForm` that sends to an API (an endpoint such as `ROOMS.update`, `{ url, method }`, or the app's own client), loads the record first (`loadValue`), and shows the server's messages on their inputs: Nexus responses and ASP.NET Core problem details |
126
+ | `FormButtons` | `nexus-shared/client` | A form's status line and buttons on their own, such as in a popup's footer |
127
+ | `useForm`, `useFormValue`, `useFormValues`, `useFormStatus` | `nexus-shared/client` | A store for the page to hold, and hooks that render again when a value, any value, or the status changes |
128
+ | `FormStore` | `nexus-shared` | The store and the form's handle: `getValue`, `getChanges`, `set`, `load` (with `keepChanged`), `reset`, `validate`, `setErrors`, `focus`, `submit` |
129
+ | `DataTable`, `useTable` | `nexus-shared/client` | Rows with a search (rows per page inside it), sorting by column, pages, a selection with one split button of actions over the headings, icon buttons and a menu per row, columns the user orders, resizes, pins, and hides, an options menu (CSV, print, import), and loading, empty, and failed states; rows given, loaded once, or a page per query from a server; page size, sort, and the columns remembered with `stateKey` |
130
+ | `TableStore` | `nexus-shared` | The table's state and handle, outside React: `reload`, `upsert`, `patch`, `remove`, `select`, `getSelected`, `setSearch`, `setSort`, `setPage` |
131
+ | `Crud` | `nexus-shared/client` | A module's records in one component: a controller's endpoints, the table's columns, and the form's input params in; the lists (all, flagged, archived, trash, deleted) and actions the user may use, the records the user pinned above the list, Add and Edit popups on `ApiForm`, details, actions on one record or many, and a cache of lists while the page is open |
132
+ | `Permissions`, `NexusPermissions`, `definePermissions`, `canCall` | `nexus-shared` | May the user call this endpoint? The app registers its rules once; `NexusPermissions` reads the Nexus backend's access actions. Everything is allowed until then |
133
+ | `CrudBackend`, `NexusCrudBackend`, `defineCrudBackend` | `nexus-shared` | How a CRUD talks to a backend beyond its endpoints: page requests and answers, mass action bodies, flag and pin marks. Nexus's by default |
134
+ | `configureCrud`, `getCrudSettings` | `nexus-shared` | What every CRUD in the app follows: how many records a user may pin (100 by default) |
135
+ | `queryRows`, `formatCellText`, `sortRows`, `pageButtons`, `CrudCache`, `crudRowActions` | `nexus-shared` | Pure helpers behind the table and the CRUD: search, sort, and page rows as the table does, a value as its cell writes it, the page buttons, the cache, and which actions a list offers |
136
+ | `readApiResponse`, `sendApiRequest`, `matchFieldErrors` | `nexus-shared` | Pure helpers behind the API form: read an answer as success or failure, send a URL as it is, and match server field names to inputs |
137
+ | `api`, `apiOptionsLoader`, `configureApi` | `nexus-shared/client` | API calls from the browser, through the app's proxy or straight to a module: toasts worded by the message builder, `api.confirm` to ask first, one request for the same GET at once; a dropdown's `loadOptions` from a pagination endpoint |
138
+ | `serverApi`, `configureServerApi`, `createApiProxy` | `nexus-shared/server` | API calls from the server, straight to each module's root, with the user's token and Next.js caching; the proxy route the browser calls |
139
+ | `ApiModules`, `NexusApiModules`, `defineApiModules`, `ApiRegister` | `nexus-shared` | An app's API modules: its own module enum (named once in `ApiRegister`, so endpoints take only those), where each root is, and the proxy on or off. Extend `ApiModules` for another backend |
140
+ | `apiController`, `apiEndpoint`, `unwrapApiResult` | `nexus-shared` | Endpoints defined once by module: a controller's standard actions (`NormalListing`, `Detail/{id}`, `Create`, `Update`, `Delete/{id}`, each list's `lists.trash` and `pages.trash`, …); an answer's result, or an `ApiError` |
141
+ | `messages`, `buildMessage`, `configureMessages` | `nexus-shared` | Every success, failure, reason, loading, question, and button text from one table: "3 rooms deleted.", "You do not have permission to delete Room 204."; reworded all at once |
142
+ | `createApiClient` | `nexus-shared` | The engine behind `api` and `serverApi`, for an API of another shape |
143
+ | `Field` | `nexus-shared` | The frame of every input (label, box, icons, hint or error), for building custom inputs |
144
+ | `validateText`, `TEXT_PATTERNS` | `nexus-shared` | Pure text validation and common patterns with their messages |
145
+ | `validateCheck`, `validateSelection` | `nexus-shared` | Pure checks for a checkbox and for chosen values (`required`, `min`, `max`) |
146
+ | `validateNumber`, `formatNumber`, `parseNumber` | `nexus-shared` | Pure number validation, and number text in any locale (`roundDecimal`, `stepNumber` too) |
147
+ | `formatDate`, `parseDateText`, `toIsoDate`, `validateDate` | `nexus-shared` | Pure date helpers: ISO dates in and out, either calendar, any format, Devanagari digits; `toCalendar` and `fromCalendar` convert AD and BS |
148
+ | `formatDateRange`, `parseDateRangeText`, `toDateRange`, `validateDateRange` | `nexus-shared` | The same for a range: "2026-09-17 – 2026-09-24" in and out, typed with a dash, an arrow, or "to"; rules on both ends and on the days between |
149
+ | `filterItems`, `matchesSearch`, `indexItems`, `optionKey`, `initials` | `nexus-shared` | Pure helpers behind the dropdown: search every word with or without accents, index items by value, compare ids from APIs and forms, and initials for avatars |
150
+ | `formatTime`, `parseTimeText`, `toIsoTime`, `validateTime` | `nexus-shared` | Pure time helpers: ISO times in and out, 12- or 24-hour formats, Devanagari digits, typed text on either clock; `addMinutes`, `isTimeInRange`, `listTimeSlots` |
151
+ | `toUtcDateTime`, `toLocalDateTime`, `fromLocalDateTime`, `formatDateTime`, `parseDateTimeText`, `validateDateTime` | `nexus-shared` | Pure date-time helpers: UTC values in and out, the date and time a moment shows in any IANA zone (daylight saving included), typed text in both calendars; `describeTimeZone`, `getBrowserTimeZone` |
152
+ | `ThemeScript` | `nexus-shared` | Applies the saved theme before paint; goes in `<head>` |
153
+ | `ThemeSwitcher` | `nexus-shared/client` | Palette button with the theme picker in a popover |
154
+ | `ThemePicker` | `nexus-shared/client` | Mode control and theme cards with live previews |
155
+
156
+ ### Tab buttons
157
+
158
+ ```tsx
159
+ import { TabButtons } from "nexus-shared/client";
160
+
161
+ <TabButtons
162
+ aria-label="View"
163
+ value={view}
164
+ onChange={setView}
165
+ options={[
166
+ { value: "grid", label: "Grid", icon: <InlineIcon icon={iconLayoutGrid} /> },
167
+ { value: "list", label: "List", icon: <InlineIcon icon={iconList} /> },
168
+ ]}
169
+ />
170
+ ```
171
+
172
+ - An indicator slides to the selected option. In light mode the track is a soft tint with no frame and the indicator
173
+ is lifted by a shadow; in dark mode the indicator is lighter than the track, with a visible edge. The selected icon
174
+ takes the primary color, so the choice is clear in every theme.
175
+ - `size` (`sm`, `md`, `lg`), `tone="primary"` for a solid primary indicator, `block` to fill the width, `disabled` per option.
176
+ - `labels="selected"`: icons only, and the selected option grows to show its label. Every option needs an icon;
177
+ hidden labels are still read by screen readers and shown as tooltips.
178
+ - `design="list"`: the options stacked as full-width rows, for settings pages and side panels. Each row takes an
179
+ `icon`, a `description` on a second line, and a `badge` (a count) at the end. The selected row is tinted, marked
180
+ by a bar at its start, and its label turns bold; `tone="primary"` tints it with the primary color. ↑ and ↓ move
181
+ the selection. The nav design is the old project's `nav-tabs`, this one its `list-tabs`.
182
+ - Native radio buttons: arrow keys move the selection, and `name` makes it part of a form. Needs `aria-label` or `aria-labelledby`.
183
+ `form` sets the form the choice belongs to, as in HTML; an id that matches no form keeps a switch that is not a
184
+ value (the Markdown editor's views) out of the form around it.
185
+ - For choosing a value. For switching page panels, use tabs with panels (planned).
186
+
187
+ ### Split button
188
+
189
+ ```tsx
190
+ import { SplitButton } from "nexus-shared/client";
191
+
192
+ <SplitButton storageKey="pull-request" onAction={value => create(value)} options={[
193
+ { value: "create", label: "Create pull request", description: "Open a pull request that is ready for review" },
194
+ { value: "draft", label: "Create draft pull request", description: "Cannot be merged until marked ready for review" },
195
+ ]} />
196
+ ```
197
+
198
+ - The main button runs the chosen action; the arrow opens the alternatives as a radio menu. Picking one makes it the
199
+ main button, and with `storageKey` the browser remembers it (`localStorage`, `nx-split:<key>`), so the next visit
200
+ starts with it. `runOnSelect` also runs the pick at once, for Save / Save and close.
201
+ - `variant`, `size`, `loading`, `disabled`, `block` as `Button`; `type="submit"` with `name` submits a form and sends
202
+ the chosen value; `value` and `onValueChange` for a controlled choice; `align` and `menuLabel` for the menu.
203
+
204
+ ### Menus
205
+
206
+ ```tsx
207
+ import { ContextMenu, Menu } from "nexus-shared/client";
208
+
209
+ <Menu items={[
210
+ { value: "edit", label: "Edit", icon: <InlineIcon icon={iconPencil} />, shortcut: "Ctrl+E" },
211
+ { separator: true },
212
+ { value: "delete", label: "Delete", icon: <InlineIcon icon={iconTrash} />, tone: "danger" },
213
+ ]} onSelect={value => run(value)}>
214
+ <Button iconEnd={<InlineIcon icon={iconChevronDown} />}>Actions</Button>
215
+ </Menu>
216
+
217
+ <ContextMenu items={rowItems} onSelect={value => run(value, row)}>
218
+ <table>…</table>
219
+ </ContextMenu>
220
+ ```
221
+
222
+ - **Native popovers.** The list is a `[popover]` element: it sits above everything, closes with Esc or a click
223
+ outside, and needs no library. It opens under its button (above it when there is no room), lined up with the
224
+ button's `align="start"` or `"end"` edge, and follows the page as it scrolls.
225
+ - **Items are params:** `{ value, label, description?, icon?, shortcut?, tone?: "danger", disabled?, href?, target?, checked?, title? }`,
226
+ plus `{ separator: true }` and `{ heading }`. An item with `href` is a link. The trigger is any element that
227
+ renders a button and passes its props on, such as `Button`.
228
+ - `kind="radio"` or `"checkbox"` adds a check column and `aria-checked`; `closeOnSelect={false}` keeps a checkbox
229
+ menu open while options are toggled.
230
+ - **Keys:** arrows move between items (wrapping, skipping disabled ones), Home and End jump, a letter jumps to the
231
+ next item starting with it, Enter or Space chooses, Esc closes and returns focus to the button, Tab closes and
232
+ moves on. Focus follows a moving pointer, so the keys carry on from the hovered item.
233
+ - `ContextMenu` opens at the pointer on right-click, or under the focused element on Shift+F10. Its wrapper takes no
234
+ space (`display: contents`), so wrap a table once and note the clicked row in the row's own `onContextMenu`.
235
+ - `placeUnderAnchor`, `placeAtPoint`, and `followAnchor` (`nexus-shared/client`) place custom popovers the same way.
236
+
237
+ ### Toast messages
238
+
239
+ ```tsx
240
+ import { Toaster, toast } from "nexus-shared/client";
241
+
242
+ // Once, in the root layout
243
+ <Toaster position="top-right" />
244
+
245
+ // Anywhere: components, services, fetch helpers
246
+ toast.success("Booking confirmed", "Room 204, 3 nights");
247
+ toast.error("Could not save", { message: error.message, action: { label: "Retry", onClick: save } });
248
+ toast.promise(saveBooking(), { loading: "Saving…", success: "Saved", error: e => `Not saved: ${e.message}` });
249
+ ```
250
+
251
+ - `toast(title, options?)`, `toast.info`, `.success`, `.warning`, `.error`, `.loading` (spinner, no timer), and
252
+ `.promise`. Options: `message`, `duration` (default 5000 ms, 0 keeps it; pauses while hovered or focused), `action`,
253
+ `closable`, `icon`, `position`, `onClose`, and `id` to update a toast in place. `toast.dismiss(id?)` closes one or all.
254
+ - Each toast is a native popover of its own, so it sits above open dialogs; the newest is nearest the edge, and at
255
+ most `max` (default 5) show per position. Warnings and errors use `role="alert"`, the rest `role="status"`.
256
+
257
+ ### Popup
258
+
259
+ ```tsx
260
+ import { Popup, definePopupRules, openPopup } from "nexus-shared/client";
261
+
262
+ <Popup open={open} onClose={() => setOpen(false)} title="Edit booking" description="NX-2048 · Room 204"
263
+ footer={<><Button onClick={() => setOpen(false)}>Cancel</Button><Button type="submit" form="booking" variant="primary">Save</Button></>}>
264
+ <form id="booking" onSubmit={save}>…</form>
265
+ </Popup>
266
+
267
+ // From code, with a handle; needs <PopupHost /> in the layout. Never two popups with one key: opening the key again
268
+ // replaces its popup (a fresh one), or with reopen: "restore" brings it back as it was.
269
+ const popup = openPopup({ key: "room-edit-204", reopen: "restore", title: "Room 204", content: <RoomDetails id={204} />, footer: p => <Button onClick={() => p.close()}>Close</Button> });
270
+ popup.minimize(); popup.restore(); popup.maximize();
271
+ await popup.closed;
272
+
273
+ // Rules by key, once, in a client module; options given to openPopup win over them
274
+ definePopupRules({
275
+ "room-new": { reopen: "replace" }, // Add: a fresh form every time (the default)
276
+ "room-edit-*": { reopen: "restore" }, // Edit: back as it was, with what was typed
277
+ "night-report": { minimizable: false, maximizable: false, movable: false },
278
+ });
279
+
280
+ // The page in charge of the window state
281
+ <Popup open={open} windowState={state} onWindowStateChange={setState} … />
282
+ ```
283
+
284
+ - Built on the native `<dialog>` shown modally: above everything, the page behind dimmed and locked (without a layout
285
+ shift), Tab kept inside, focus returned on close. `onClose(reason)` says whether the close button, Esc, the
286
+ backdrop, or code asked; the page decides by setting `open`. `closable`, `closeOnEscape`, `closeOnBackdrop` turn
287
+ those off for a popup that must be answered.
288
+ - `size`: `xs` 360, `sm` 440, `md` 560, `lg` 720, `xl` 960, `full`. The body scrolls while the title and footer
289
+ stay; `flush` removes the body padding for tables. `initialFocus` picks the first focused element (default: the
290
+ first control in the body or footer). The content mounts only while open, so forms start fresh.
291
+ - Popups open other popups and message boxes above themselves; Esc closes the top one.
292
+ - A **title bar** like a desktop window's: 32px high (40px on touch screens), the icon, the title, and the description
293
+ on one line (cut with …), and the window buttons filling its top right corner, 46 x 32 each: **minimize**,
294
+ **maximize** (restore down when maximized), **close** (red on hover). `variant="dialog"` gives the larger heading
295
+ instead (the icon in a circle, the description under the title), which message boxes use. `minimizable` (default: when `closable`, so a popup that must be answered cannot be put aside),
296
+ `maximizable` and `movable` (default true); message boxes have only close.
297
+ - **Minimized**, the dialog closes so the page can be used, and a bar waits at the bottom right with the popup's icon and
298
+ title; its content stays mounted, so typed text, scroll, and the focused field are there when the bar brings it back
299
+ (maximized again if it was). Several stack behind the newest with a count that opens the whole list (Esc or a press
300
+ elsewhere closes it). An open popup's backdrop covers the dock. `<PopupHost />` renders the dock; without a host
301
+ there is no minimize button. Bottom-right toasts stack above it (`--nx-dock-space`).
302
+ - **Maximized**, it fills the window edge to edge; a double-click on the title bar does the same, and restore down puts
303
+ it back where it was.
304
+ - **Moved** by its title bar (not its buttons), kept inside the window, pulled back in when the window shrinks; Esc
305
+ during a drag puts it back; dragging a maximized popup restores it under the pointer, as desktop windows do. Each
306
+ opening starts centered in `defaultWindowState`.
307
+ - **Opened again** while it is still open or minimized, a popup never doubles up. `openPopup` with a `key` whose popup
308
+ is there closes that popup (`onClose` and `closed` say `replaced`) and opens a fresh one: `reopen: "replace"`, the
309
+ default, right for an Add form, so Add, minimize, Add again cannot pile up popups. `reopen: "restore"` brings the
310
+ old one back as it was and returns its handle, right for editing one record. A page popup opens again through the
311
+ button that opened it, with the same `reopen` choice. Popups without a key are separate every time.
312
+ - **Asking before a close**: `openPopup({ beforeClose })` runs when the user closes the popup (its close button, Esc,
313
+ the backdrop, or its bar on the dock); return `false`, or a promise of it, to keep it open, such as after
314
+ `confirmDiscard(form)` asked "Discard your changes?". Closing from code does not ask.
315
+ - **Rules by key**: `definePopupRules({ "booking-new": {…}, "booking-edit-*": {…} })` sets `reopen`, `minimizable`,
316
+ `maximizable`, `movable`, `closable`, `closeOnEscape`, `closeOnBackdrop`, `size`, and `defaultWindowState` for every
317
+ `openPopup` with that key. A name ending in `*` matches keys that start with the rest (`*` alone, every key); all
318
+ matching rules apply, an exact key over a pattern and a longer pattern over a shorter one; options given to
319
+ `openPopup` win. It returns a function that removes the rules; `popupRuleFor(key)` shows what a key gets.
320
+ - With motion, minimize flies to the dock and maximize grows from the old box; with reduced motion, both happen in the
321
+ same frame.
322
+
323
+ ### Drag helpers
324
+
325
+ ```tsx
326
+ import { clampToBounds, makeDraggable, moveWithin, useDraggable, viewportBounds } from "nexus-shared/client";
327
+
328
+ useDraggable(cardRef, { bounds: "parent" }); // the card moves, kept inside its positioned parent
329
+ useDraggable(barRef, { target: () => cardRef.current, bounds: "parent", axis: "x", keepVisible: 40 });
330
+ const stop = makeDraggable(titleBar, { target: panel, bounds: document.querySelector(".board") }); // without React
331
+ moveWithin(card, { x: 10, y: 0 }, { bounds: "parent" }); // the keyboard way
332
+ clampToBounds({ left: -20, top: 40, width: 300, height: 200 }, viewportBounds()); // { x: 0, y: 40 }
333
+ ```
334
+
335
+ - The popup's title bar is built on these; any component can use them. `bounds`: `viewport` (default), `parent`,
336
+ an element (inside its borders), a box, a function, or `null`. `margin`, `keepVisible` (how much must stay
337
+ inside when it may partly leave), `axis`, `threshold` (default 3 px, so clicks stay clicks), `cancel` (controls in
338
+ the handle that do not drag).
339
+ - The position is an offset from the element's place in the layout, written to CSS `translate` by default, or to CSS
340
+ variables (`cssVariablePosition`), or anywhere through `position: { get, set }`, so a move never shifts the layout.
341
+ - `onStart` may cancel or change the target first; `onEnd` says whether Esc cancelled. A drag selects no text, and
342
+ the click that ends it does not reach what lies under the pointer. The handle needs `touch-action: none`
343
+ (`makeDraggable` and `useDraggable` set it).
344
+
345
+ ### Message box
346
+
347
+ ```tsx
348
+ import { messageBox } from "nexus-shared/client";
349
+
350
+ if (await messageBox.confirm({ title: "Delete booking NX-2048?", message: "This cannot be undone.", tone: "danger", confirmLabel: "Delete" })) …
351
+ await messageBox.alert({ title: "Saved", tone: "success" });
352
+ const name = await messageBox.prompt({ title: "Rename the room", label: "Name", defaultValue: room.name });
353
+ const choice = await messageBox.show({ title: "Unsaved changes", tone: "warning", buttons: [{ value: "discard", label: "Don't save" }, { value: "save", label: "Save" }] });
354
+ ```
355
+
356
+ - Small popups through `<PopupHost />`, the tone in the icon: `info` (alert default), `question` (confirm default),
357
+ `success`, `warning`, `danger`, or `neutral` for none. A danger box makes the last button red and focuses the first
358
+ one, so Enter cannot delete by accident.
359
+ - `confirm` resolves `false` and `show` resolves `null` when the box is dismissed with Esc, the close button, or a
360
+ click outside; `prompt` resolves `null` when cancelled and refuses an empty answer while `required` (the default).
361
+
362
+ ### Button hover tones
363
+
364
+ `hoverTone` keeps a `secondary` or `ghost` button neutral until it is hovered or focused from the keyboard, then
365
+ colors its border, a light background, and its text. Tones: `primary`, `danger`, `success`, `warning`, `info`.
366
+ Good for rows of actions, where full-color buttons would be too loud:
367
+
368
+ ```tsx
369
+ <Button hoverTone="danger" icon={<InlineIcon icon={iconTrash} />}>Delete</Button>
370
+ <Button variant="ghost" size="sm" hoverTone="primary" aria-label="Edit" icon={<InlineIcon icon={iconPencil} />} />
371
+ ```
372
+
373
+ Every tone meets WCAG AA contrast on its light background in all themes.
374
+
375
+ ### Text box
376
+
377
+ ```tsx
378
+ import { TEXT_PATTERNS } from "nexus-shared";
379
+ import { TextBox, TextArea } from "nexus-shared/client";
380
+
381
+ <form onSubmit={save}>
382
+ <TextBox name="email" type="email" label="Email" required pattern={TEXT_PATTERNS.email} icon={<InlineIcon icon={iconMail} />} />
383
+ <TextBox name="password" type="password" label="Password" required minLength={8} />
384
+ <TextArea name="notes" label="Notes" maxLength={500} showCount autoResize />
385
+ <Button type="submit" variant="primary">Save</Button>
386
+ </form>
387
+ ```
388
+
389
+ - **Uncontrolled by default**, so typing re-renders nothing. `onValueChange(value)` reports each change; `value` makes it controlled.
390
+ - **Validation:** `required`, `minLength`, `maxLength`, `pattern` (a `TEXT_PATTERNS` entry carries its own message), and
391
+ `validate(value)` for custom rules. Messages show after a field is left with text in it (`validateOn`: `blur`, `change`,
392
+ `submit`). Inside a `<form>`, an invalid field blocks submit, every message shows, and the first invalid field takes focus.
393
+ `error` shows a message from outside, such as the server.
394
+ - **Read-only says why.** Every input with `readOnly` shows a lock, and a short note for 2.5 seconds when someone tries
395
+ to change it anyway, so a click that does nothing does not look like a bug. The value is still sent with a form, and
396
+ selecting and copying text work as usual. Esc, leaving the field, or the timeout hide the note; `readOnlyMessage`
397
+ changes its text.
398
+
399
+ | Input | Lock | Tries that show the note | Default note |
400
+ |---|---|---|---|
401
+ | `TextBox`, `TextArea` | End of the box | A click, typing, Backspace, Delete, Ctrl+V, Ctrl+X (and Enter in a text area) | Read-only: this field cannot be changed. |
402
+ | `NumberBox` | In place of the − and + buttons | The same, and ↑ ↓ Page Up Page Down | Read-only: this number cannot be changed. |
403
+ | `DatePicker`, `DateRangePicker` | In place of the calendar button | The same as a text box, and ↓ | Read-only: this date (these dates) cannot be changed. |
404
+ | `TimePicker` | In place of the clock button | The same as a text box, and ↓ | Read-only: this time cannot be changed. |
405
+ | `DateTimePicker` | In place of the calendar and clock button | The same as a text box, and ↓ | Read-only: this date and time cannot be changed. |
406
+ | `Dropdown` | In place of the list button; chips lose their remove buttons | A click on the box or a chip, a typed key, ↓ or ↑ | Read-only: this choice (these choices) cannot be changed. |
407
+ | `CheckBox`, `Switch` | After the label | A click or Space | Read-only: this option (this setting) cannot be changed. |
408
+ | `CheckBoxGroup`, `RadioGroup` | After the group label | A click, Space, or an arrow key, under that option | Read-only: these options (this choice) cannot be changed. |
409
+ | `Slider`, `RangeSlider` | After the label | A press on the track or a mark, the arrow keys, Page Up/Down, Home, End | Read-only: this value (this range) cannot be changed. |
410
+
411
+ Nothing renders until an attempt, and an attempt re-renders only the note, so read-only forms of any size cost
412
+ nothing extra. `useReadOnlyNotice` gives a custom control the same lock and note.
413
+ - **Props are params:** plain, named like HTML attributes, and serializable, so forms and CRUD pages can describe
414
+ fields as objects. Design notes for inputs, forms, and CRUD: [src/Components/Inputs/README.md](src/Components/Inputs/README.md).
415
+
416
+ ### Number box
417
+
418
+ ```tsx
419
+ import { NumberBox } from "nexus-shared/client";
420
+
421
+ <NumberBox name="nights" label="Nights" stepper="split" required min={1} max={30} defaultValue={1} />
422
+ <NumberBox name="rate" label="Rate per night" prefix="Rs" required min={500} decimals={2} fixedDecimals grouping locale="en-IN" />
423
+ <NumberBox name="discount" label="Discount" suffix="%" stepper min={0} max={50} step={5} />
424
+ ```
425
+
426
+ - **Only a number gets in.** Typing accepts digits, one decimal separator, and a minus sign when `min` is below 0 (or
427
+ not set). `decimals` stops typing after that many decimals; pasted text such as "Rs 1,250.50" keeps its number, and
428
+ text with no single clear number is ignored rather than guessed at.
429
+ - **Formats by locale:** `grouping` shows 12,50,000.00 (`en-IN`) or 1.250.000,00 (`de-DE`) while the box is not
430
+ being edited; separators come off on focus. The default locale is `en-US`, so server and browser render the same text.
431
+ Inside a `<form>`, a grouped box sends the plain number through a hidden input with its `name`.
432
+ - **Steps:** ↑ and ↓ (Shift or Page Up/Down for ten), and `stepper` buttons that repeat while held. Values move along
433
+ the grid of `step` from `min` and stay within the limits.
434
+ - **Values:** `onValueChange(value)` gets a `number`, or `null` when empty; `validate(value)` too. `clamp` moves an
435
+ out-of-range value to the nearest limit on blur instead of showing a message.
436
+ - `npm run test:numbers` checks the number helpers (formatting, parsing, paste, rounding, stepping, messages).
437
+
438
+ ### Checkbox and radio
439
+
440
+ ```tsx
441
+ import { CheckBox, CheckBoxGroup, RadioGroup, Switch } from "nexus-shared/client";
442
+
443
+ <RadioGroup name="roomType" label="Room type" required design="cards" columns={3} options={roomTypes} />
444
+ <CheckBoxGroup name="amenityIds" label="Amenities" columns={3} selectAll options={amenities.map(a => ({ value: a.id, label: a.name }))} />
445
+ <Switch name="breakfast" label="Breakfast included" labelPosition="start" />
446
+ <CheckBox name="terms" label="I accept the booking terms" required />
447
+ ```
448
+
449
+ - **Native inputs, drawn with CSS.** Each option is one `<input>`, so forms, arrow keys (radios), and screen readers
450
+ work as usual. Box edges use the subtle text color, which meets 3:1 contrast on panels in every theme.
451
+ - **Options are params:** `{ value, label, description?, icon?, disabled? }`. Values can be strings or numbers and
452
+ come back from `onValueChange` with their type.
453
+ - **Limits:** `required`, `min`, `max`, `validate`. At `max` a checkbox group disables the other options and shows a
454
+ count. Messages follow the text box: after leaving a changed group, or on submit, where the first invalid option takes focus.
455
+ - **Fast:** uncontrolled by default, so clicking re-renders nothing; 10,000 checkboxes mount in 0.5 to 0.7 s
456
+ in the development build.
457
+
458
+ ### Slider
459
+
460
+ ```tsx
461
+ import { RangeSlider, Slider } from "nexus-shared/client";
462
+
463
+ <Slider name="discount" label="Discount" max={50} suffix="%" defaultValue={10} />
464
+ <RangeSlider name="price" label="Price per night" min={1000} max={30000} step={500} minDistance={1000}
465
+ prefix="Rs " grouping locale="en-IN" onValueCommit={([from, to]) => loadRooms(from, to)} />
466
+ ```
467
+
468
+ - **Native range inputs** under a drawn track, so arrow keys, Page Up/Down, Home/End, touch, and screen readers work.
469
+ Each thumb announces its formatted value (`aria-valuetext`).
470
+ - **Values read like a number box:** `prefix`, `suffix`, `decimals`, `grouping`, `locale`, or a `format` function.
471
+ - **`onValueChange`** follows every step; **`onValueCommit`** fires once when a thumb is released or a key step ends,
472
+ the moment to call an API from a filter.
473
+ - **Range:** two thumbs that never cross and keep `minDistance` apart; a click on the track moves the nearer thumb.
474
+ A form receives two values under the name.
475
+ - **Marks** label points under the track and move the thumb when clicked; **`tooltip`** shows the value above the thumb.
476
+ - Dragging writes the fill and the text straight to the DOM, so nothing re-renders.
477
+
478
+ ### Date picker and date range picker
479
+
480
+ ```tsx
481
+ import { todayIsoDate } from "nexus-shared";
482
+ import { Calendar, DatePicker, DateRangePicker, setDatePreferences } from "nexus-shared/client";
483
+
484
+ <DatePicker name="checkIn" label="Check-in" required min={todayIsoDate()} onValueChange={iso => …} />
485
+ <DatePicker name="fiscalYearStart" label="Fiscal year start" calendar="bs" format="YYYY/MM/DD" />
486
+ <DateRangePicker startName="checkIn" endName="checkOut" label="Stay" required min={todayIsoDate()} minDistance={1} maxDistance={30} />
487
+ <Calendar mode="range" months={2} range={range} onRangeChange={setRange} min={todayIsoDate()} />
488
+
489
+ // A settings page
490
+ setDatePreferences({ calendar: "bs", format: "D MMMM YYYY", script: "devanagari" });
491
+ ```
492
+
493
+ - **The value is a day, not a time.** An ISO date `"2026-09-17"` in the Gregorian calendar, whatever calendar is
494
+ shown: what a form sends (through a hidden input with the field's `name`), what an API stores (`DateOnly`), and
495
+ what means the same day in every time zone. `toIsoDate` reads a `Date` in local time and an ISO date-time with a
496
+ zone as the local day of that instant; `isoDateToDate(iso)` gives UTC midnight, `isoDateToDate(iso, "local")` local midnight.
497
+ - **English or Nepali from the user's settings.** `useDatePreferences` reads `nx-date-calendar` (`ad` or `bs`),
498
+ `nx-date-format`, and `nx-date-script` (`latin` or `devanagari`) from local storage, with the English calendar in
499
+ `YYYY-MM-DD` as the default; `setDatePreferences` changes every date component on the page, and other tabs follow.
500
+ A box can fix its own `calendar`, `format`, or `script`.
501
+ - **Formats** use the tokens `YYYY` `YY` `MMMM` `MMM` `MM` `M` `DD` `D` `dddd` `ddd`. Typing follows the format's
502
+ order and is lenient: `17/9/2026`, `Sep 17, 2026`, `1 asoj 2083`, `२०८३-०६-०१`; a four-digit number is the year wherever it stands.
503
+ - **Bikram Sambat** covers BS 1975 to 2100 (AD 1918 to 2044), as the majority of five published tables
504
+ (`NepaliCalendar.ts`), converted through day numbers with no `Date` objects. `npm run test:dates` checks known
505
+ dates and round-trips every day.
506
+ - **DateRangePicker** holds a start and an end in one box, written as "2026-09-17 – 2026-09-24" in the user's
507
+ format. Pick the start and then the end in a calendar of two months (one when the window is narrow), with the
508
+ days between lit as the pointer moves, or type both dates around a dash, an arrow, or "to". The values are two
509
+ ISO dates: `onValueChange` gives `[start, end]` (`null` for an end not chosen yet), and a form sends `startName`
510
+ and `endName` as two fields, or both under `name`. Rules: `required`, `min`, `max`, `minDistance` and
511
+ `maxDistance` (days from start to end, the nights of a stay), and `isDateDisabled`, which also refuses a range
512
+ that includes such a day (a booked night). `validateDateRange` is the pure check behind it.
513
+ - **Read-only** boxes have no calendar: a lock sits where the calendar button was, and a click, a typed key, or ↓
514
+ shows a note under the box, as in every read-only input (see [Text box](#text-box)).
515
+ - **Calendar** is the pickers' panel and a component of its own: month and year menus, arrow keys (Page Up and Page
516
+ Down for months, with Shift for years), `min`, `max`, `isDateDisabled`, `weekStart`, `weekendDays` (Saturday is
517
+ red in the Nepali calendar), `mode="range"` with a live preview, `months={2}` side by side (a page passes 1 on
518
+ a phone; the calendar does not measure), `month` and `onMonthChange` to load a month's events, and `renderDay`
519
+ to draw markers in a cell.
520
+
521
+ ### Time picker
522
+
523
+ ```tsx
524
+ import { TimePicker, setDatePreferences } from "nexus-shared/client";
525
+
526
+ <TimePicker name="arrival" label="Arrival" required min="14:00" max="22:00" step={1800} view="list" onValueChange={iso => …} />
527
+ <TimePicker name="shiftStart" label="Shift start" min="22:00" max="06:00" format="HH:mm" />
528
+ <TimePicker name="spa" label="Spa slot" view="list" step={1800} isTimeDisabled={iso => booked.has(iso)} />
529
+
530
+ // A settings page
531
+ setDatePreferences({ timeFormat: "HH:mm" });
532
+ ```
533
+
534
+ - **The value is a time of day, not an instant.** An ISO time on a 24-hour clock, `"14:30"` (`"14:30:15"` when
535
+ `step` has seconds), with no date and no zone: what a form sends through a hidden input with the field's `name`,
536
+ and what a .NET `TimeOnly` stores. `toIsoTime` reads `"9:05"`, `"14:30:00.000"`, a `Date` (its local time), and an
537
+ ISO date-time (with a zone, the local time of that instant; without one, its time part).
538
+ - **12 or 24 hours from the user's settings.** `nx-time-format` in local storage, next to the date settings, holds
539
+ a format of tokens `HH` `H` `hh` `h` `mm` `m` `ss` `s` `A` `a`; the default is `hh:mm A` (02:30 PM).
540
+ `useDatePreferences` returns it as `timeFormat`, and `setDatePreferences({ timeFormat })` changes every time picker
541
+ on the page. Nepali dates in Devanagari bring Nepali digits and पूर्वाह्न/अपराह्न. A box can fix its own `format` or `script`.
542
+ - **Typing** works on either clock: `2:30 pm`, `2.30p`, `230pm`, `14:30`, `1430`, `9`, `१४:३०`. Without AM or PM the
543
+ hours are read on a 24-hour clock. Leaving the box writes the time in the format.
544
+ - **Columns** (the default) show hours, minutes, seconds when the step needs them, and AM/PM; the chosen items line
545
+ up on the middle row, a pick in any column changes the time at once, and ↑ ↓ ← → Home End Page Up/Down move through
546
+ them. **`view="list"`** shows one slot per `step` (every 30 minutes for steps under 5 minutes); a click or Enter
547
+ picks and closes.
548
+ - **Rules:** `required`, `min` and `max` (with `max` earlier than `min` the range runs past midnight, 22:00 to 06:00),
549
+ `step` in seconds counted from midnight as in HTML, `isTimeDisabled` for booked slots, and `validate`. Items outside
550
+ the rules are dimmed in the panel; a typed time outside them gets a message such as "Arrival must be in steps of 30
551
+ minutes, like 02:00 PM or 02:30 PM." `validateTime` is the pure check behind it. `npm run test:times` checks the helpers.
552
+ - **Read-only** boxes have no panel: a lock sits where the clock button was, as in every read-only input.
553
+
554
+ ### Date and time picker
555
+
556
+ ```tsx
557
+ import { DateTimePicker } from "nexus-shared/client";
558
+
559
+ <DateTimePicker name="pickupAt" label="Airport pickup" required min={new Date()} step={900} minTime="05:00" maxTime="23:00" />
560
+ <DateTimePicker name="checkInAt" label="Check-in" timeZone="Asia/Kathmandu" defaultTime="14:00" />
561
+ <DateTimePicker name="spaAt" label="Spa slot" view="list" step={1800} isTimeDisabled={(time, date) => booked.has(`${date} ${time}`)} />
562
+ ```
563
+
564
+ - **The value is a moment, in UTC.** `"2026-09-17T08:45:00.000Z"`, the shape `toISOString` writes, is what the hidden
565
+ input sends and `onValueChange` gives, whatever the user sees; the same moment is 02:30 PM in Kathmandu and 04:45 AM
566
+ in New York, so no time zone can move a saved value. Store it as UTC: a .NET `DateTimeOffset`, or a `DateTime` of
567
+ kind `Utc`. For a day with no time use `DatePicker`; for a time of day with no date, `TimePicker`.
568
+ - **Values in** (`toUtcDateTime`): an ISO date-time with `Z` or an offset is that moment; one **without a zone is read
569
+ as UTC**, the way a UTC `DateTime` loaded from a database often arrives without its `Z`; a date alone is the first
570
+ moment of that day where the user is; a `Date` or milliseconds are that moment. .NET's seven digits of fractions are read.
571
+ - **Shown in the user's zone and settings.** The browser's time zone, and the date (`nx-date-calendar`,
572
+ `nx-date-format`, `nx-date-script`) and time (`nx-time-format`) settings of the other pickers: "2026-09-17 02:30 PM",
573
+ or "२०८३-०६-०१ ०२:३० अपराह्न". The panel names the zone ("Kathmandu · UTC+05:45"). `timeZone` fixes a zone, such as a
574
+ hotel's, and writes its city in the box. The server does not know the user's zone, so a box shows its text right
575
+ after hydration rather than another zone's time for a moment; the hidden input holds the value from the start.
576
+ - **No data loss.** A value changes only when the user changes what it shows: seconds and milliseconds the box does not
577
+ show stay as they came (a stamp from the server is sent back exactly), and retyping or re-picking what it shows keeps
578
+ the moment. Where clocks go back, one hour happens twice: a box holds whichever it was given, an edit inside that hour
579
+ keeps its offset, and a new pick is the first of the two. Where clocks go forward, a skipped time moves on (02:30
580
+ becomes 03:30), as `Date` and Temporal do.
581
+ - **Typing:** a date in the user's format, then a time on either clock: `2026-09-17 2:30 pm`, `17/09/2026 14:30`,
582
+ `Sep 17, 2026 at 2:30 PM`, `2026-09-17T14:30`, `२०८३-०६-०१ १४:३०`. A date alone takes `defaultTime` (default
583
+ `minTime`, or midnight). Leaving the box writes it in the settings.
584
+ - **The panel** is the calendar and the time columns (or `view="list"` slots) side by side, as tall as each other, with
585
+ Now, the zone, and Done. A picked day keeps the time; ↓ opens it on the chosen day, Enter on a day moves on to the
586
+ hours, and Tab runs through the calendar, the columns, and the buttons. On a phone the time goes under the calendar,
587
+ and a panel taller than the room scrolls, moving to the time once a day is picked.
588
+ - **Rules:** `required`; `min` and `max` as moments (days outside are dimmed, and times outside on the first and last
589
+ day); `minTime` and `maxTime` as opening hours on every day (past midnight when `maxTime` is earlier); `step` in
590
+ seconds from each midnight; `isDateDisabled(date)` and `isTimeDisabled(time, date)` with ISO dates and times where the
591
+ user is; `validate`. Messages read like the box: "Airport pickup must be between 05:00 AM and 11:00 PM."
592
+ `validateDateTime(value, rules, fieldName, options)` is the pure check. `npm run test:datetimes` checks the helpers
593
+ against `Date` in eight zones, including half-hour daylight saving and a skipped day.
594
+ - **Read-only** boxes have no panel: a lock sits where the button was, as in every read-only input.
595
+
596
+ ### Dropdown
597
+
598
+ ```tsx
599
+ import { Dropdown } from "nexus-shared/client";
600
+
601
+ <Dropdown name="roomType" label="Room type" required options={roomTypes} />
602
+ <Dropdown name="amenities" label="Amenities" multiple max={6} options={amenities} /> // { value, label, icon: "wifi" }
603
+
604
+ // Rows like a data table
605
+ <Dropdown name="assignee" label="Assign to" options={staff} valueKey="id" labelKey="fullName"
606
+ columns={[{ key: "photo", type: "avatar" }, { key: "username", header: "Username" }, { key: "fullName", header: "Full name" }]} />
607
+ <Dropdown name="country" label="Country" options={countries} valueKey="code" labelKey="name"
608
+ columns={[{ key: "flag", type: "image" }, { key: "code", header: "Code", type: "code" }, { key: "name", header: "Country" }]} />
609
+
610
+ // A server list, editing a saved value
611
+ <Dropdown name="guestId" label="Guest" valueKey="id" labelKey="fullName" defaultValue={booking.guestId} selectedOptions={[booking.guest]}
612
+ loadOptions={({ search, skip, pageSize, signal }) => api.guests({ search, skip, take: pageSize }, signal)} /> // { items, total }
613
+ ```
614
+
615
+ - **Options are any objects.** `{ value, label, description, icon, disabled }` by default (a `ChoiceOption`), or API rows
616
+ read through `valueKey`, `labelKey`, `descriptionKey`, and `iconKey`. Values keep their type; a number and its text
617
+ are the same value, so id 7 from an API matches "7" from a form. A form gets hidden inputs named `name`, one per value.
618
+ - **Columns** turn rows into cells that line up down the list (one grid with subgrid rows), with headings that stay on top.
619
+ Types: `text`, `muted`, `code`, `avatar` (a photo URL, or initials of the label on a soft tone), `image` (4:3: flags,
620
+ logos), and `icon` (a Tabler name); `width`, `align`, and `render` for the rest. The first picture leads the value in
621
+ the box and in chips.
622
+ - **Search** matches every typed word in any order, with or without Latin accents, in the label, description, value, and
623
+ text columns (`searchKeys` to change). It is on with `loadOptions` or more than 8 options; without it, letters jump to
624
+ an option as in a native select. A local list renders 100 rows and adds more while it scrolls: 10,000 options open in
625
+ about 30 ms.
626
+ - **Server pages:** `loadOptions({ search, page, pageSize, skip, signal })` returns `{ items, total?, hasMore? }`. The first
627
+ page loads when the list opens (placeholder rows, a spinner in the box), the next near the end ("Loading more…"), a new
628
+ search 250 ms after typing stops, aborting the request before it. A failure shows Retry. `loadKey` drops the loaded
629
+ pages, for a list that depends on another field. `loading` shows the same loaders when the page fetches `options` itself.
630
+ - **Saved values the list can no longer offer** always show, and are never offered again once removed:
631
+ - on a server page not loaded: `selectedOptions` gives their items (a record usually carries the name), or
632
+ `resolveOptions(values)` looks them up (a placeholder shows until it answers);
633
+ - inactive items (`inactive: true` or `isActive: false`, or `isOptionInactive`): never in the list, shown only as a value;
634
+ - values missing from `options`: tagged **Unavailable**, or **Not found** when nothing is known but the value.
635
+
636
+ In the list they sit on top under **Selected** with their tag; in the box they carry the tag, or show as dashed chips.
637
+ A value only on another server page has no tag: a search finds it as a normal option.
638
+ - **Rules:** `required`, `min` and `max` for several (at `max` the other options are disabled), and `validate`, through
639
+ `validateSelection`. A pick follows the same message timing as typing. `npm run test:dropdown` checks the helpers.
640
+ - **Keys:** ↓ ↑ Page Up/Down Home End move past rows that cannot be picked, Enter picks, Space picks without search,
641
+ Backspace in an empty box removes the last value, Esc closes (then clears the search), Tab closes and moves on.
642
+ - **Read-only** boxes have no list: a lock sits where the list button was, chips lose their remove buttons, and a click or
643
+ a key shows the note, as in every read-only input.
644
+
645
+ ### Markdown editor
646
+
647
+ ```tsx
648
+ import { MarkdownView } from "nexus-shared";
649
+ import { MarkdownEditor } from "nexus-shared/client";
650
+
651
+ <MarkdownEditor name="description" label="Room description" defaultValue={room.description} defaultMode="split"
652
+ height={320} heightKey="room-description" maxLength={5000} required />
653
+
654
+ // Wherever the text is shown, also in a server component
655
+ <MarkdownView value={room.description} />
656
+ ```
657
+
658
+ - **Write, split, and preview.** `defaultMode` (or `mode` with `onModeChange`) picks the view, and `modes` the views
659
+ offered. The switch is small tab buttons with `labels="selected"`: icons, and the label of the selected view. Split puts the preview beside the text and keeps the two scrolled together; under 560 px wide it stacks
660
+ them. The preview renders as a React transition, so typing stays within a frame in a 2,000-line document.
661
+ - **Toolbar and shortcuts:** heading, bold (Ctrl+B), italic (Ctrl+I), strikethrough (Ctrl+Shift+X), quote
662
+ (Ctrl+Shift+.), code (Ctrl+E), code block, link (Ctrl+K), image, bulleted, numbered, and task lists (Ctrl+Shift+8,
663
+ 7, L), table, and horizontal line. Marks wrap the selection or the word at the caret and come off when applied
664
+ again. Edits go through the browser's own editing, so Ctrl+Z undoes them. `toolbar` picks and orders the buttons.
665
+ - **While typing:** Enter continues a list (the next number, an empty task box) and ends it on an empty item; a URL
666
+ pasted over selected text links it; a task ticked in the preview is ticked in the text.
667
+ - **Height handle:** the status bar under the editor drags the height between `minHeight` and `maxHeight`, showing
668
+ the height as it changes; its grip takes ↑ ↓ (Shift for more), Page Up/Down, Home, and End; a double-click goes back
669
+ to `height`. `heightKey` remembers the user's height in local storage. Dragging writes straight to the DOM.
670
+ - **Full screen** (`fullscreen`, on by default) lifts the editor into the top layer over a dimmed page, without
671
+ moving it in the DOM, so undo history and the form stay. Tab stays inside, and Esc closes it.
672
+ - **A form field like `TextArea`:** `name`, `required`, `minLength`, `maxLength`, `pattern`, `validate`, the status bar's
673
+ word and character count, and read-only (a lock in the bar and a note under it). An invalid submit while the preview
674
+ shows brings the text back and focuses it. The view switch belongs to no form (`TabButtons` `form`), so it is never sent.
675
+ - **Safe to show anyone's text.** `parseMarkdown` (GitHub-flavored: tables, tasks, strikethrough, autolinks) never
676
+ renders raw HTML, and `safeUrl` keeps only http, https, mailto, tel, and relative addresses for links, and raster
677
+ data URLs for images. Links to other sites get `rel="nofollow noopener noreferrer"`.
678
+ - **Helpers:** `markdownToPlainText` for excerpts and search, and the editing commands `applyMarkdownTool`,
679
+ `continueMarkdownList`, `toggleMarkdownTask`, and `linkPastedUrl` for a custom editor. `npm run test:markdown`
680
+ checks the parser and every command.
681
+
682
+ ### Forms
683
+
684
+ ```tsx
685
+ import { TEXT_PATTERNS, type InputParams } from "nexus-shared";
686
+ import { ApiForm, SubmitForm } from "nexus-shared/client";
687
+
688
+ const ROOM_INPUTS: InputParams[] = [
689
+ { type: "text", name: "number", label: "Room number", required: true, pattern: TEXT_PATTERNS.digits, span: 4 },
690
+ { type: "number", name: "floor", label: "Floor", required: true, min: 0, span: 4 },
691
+ { type: "dropdown", name: "type", label: "Type", required: true, options: ROOM_TYPES, span: 4 },
692
+ { type: "tabular", name: "beds", label: "Beds", itemLabel: "Bed", inputs: BED_INPUTS }, // a list is an input too
693
+ ];
694
+
695
+ <ApiForm
696
+ inputs={ROOM_INPUTS}
697
+ loadValue={signal => api.get(ROOMS.details, { params: { id }, signal, toast: false }).then(unwrapApiResult)}
698
+ api={ROOMS.update} // or in place: { module: NexusModule.Reservation, path: "Room/Update", method: "PUT" }
699
+ draftKey={`hotel-3:user-8:room:${id}`}
700
+ onSuccess={room => table.updateRow(room)}
701
+ onCancel={close}
702
+ />
703
+ ```
704
+
705
+ - **Params in, values out.** Every input is an entry of `inputs`, so a page, a CRUD component, or a server can describe a
706
+ form with plain objects. Values come in as each input reports them (a date-time from an API becomes a date, "12.5"
707
+ becomes 12.5), and fields the record came with (an `id`) stay in the values.
708
+ - **Fast at any size.** The values live in a `FormStore` outside React. Typing renders only the input typed in; an input
709
+ renders again only when a message it shows changes, or code sets its value. A keystroke costs about 5 µs in the store
710
+ for a form of 200 inputs, and a list of 10,000 rows is not checked again on each keystroke (it checks itself).
711
+ - **Checks on Save.** Each input's own rules (they also catch text that is not a date yet), the form's `validate` across
712
+ inputs, and rows not on the page. Every message shows, the first problem takes focus (a table scrolls to its row), and
713
+ the status line lists what needs attention, each name a link to its input. A rule message on an input shows once the
714
+ input was left, and on Save.
715
+ - **One save at a time.** Save waits with a spinner; another click, Enter, or Ctrl+S does nothing until it ends. A save
716
+ makes the values the form's own ("Unsaved changes" clears; values typed meanwhile stay changes). `onSubmit` returns
717
+ `{ ok: false, errors, message }` to say why not, and a thrown error shows its message.
718
+ - **Server messages.** `ApiForm` reads Nexus answers (`inputName` names the inputs) and ASP.NET Core problem details
719
+ (`errors` by field), matched to inputs without case and by the first part of a path (`Addresses[1].City`). Names that
720
+ match no input, and failures without fields, show beside the buttons. An input's message clears when its value changes.
721
+ - **Nothing lost.** `draftKey` keeps unsaved changes in IndexedDB (after a 600 ms pause, and at once when the page hides
722
+ or the form leaves) and brings them back with a note and Discard; drafts changed on the server since are named. Cancel
723
+ asks before it drops changes, and the page asks before it closes with some (`confirmLeave`, on without a draft).
724
+ `form.load(values, { keepChanged: true })` refreshes a record without touching what the user changed.
725
+ - `npm run test:forms` checks the store and the API helpers; `scripts/browser-checks/forms.cjs` in the template checks the
726
+ three demo pages.
727
+
728
+ ### API calls
729
+
730
+ ```ts
731
+ // api-modules.ts: the app's modules and where each one's root is (shared by the browser and the server)
732
+ import { defineApiModules, NexusApiModules, NexusModule } from "nexus-shared";
733
+
734
+ export const MODULES = defineApiModules(new NexusApiModules({ useProxy: process.env.NEXT_PUBLIC_API_PROXY !== "false" }));
735
+ export const ROOMS = MODULES.controller(NexusModule.Reservation, "Room", "room");
736
+
737
+ // In the browser
738
+ import { api } from "nexus-shared/client";
739
+ const rooms = await api.get<Room[]>(ROOMS.listing); // GET /api/app/reservation/Room/NormalListing
740
+ await api.put(ROOMS.update, values, { subject: "Room 204" }); // toast: "Room 204 saved." or what failed and why
741
+ await api.confirm(ROOMS.delete, { params: { id }, subject: "Room 204" }); // asks "Delete Room 204?" first
742
+
743
+ // On the server (a server component, a route handler, a server action)
744
+ import { serverApi } from "nexus-shared/server";
745
+ const list = await serverApi.get<Room[]>(ROOMS.listing, { revalidate: 60, tags: ["rooms"] }); // straight to API_RESERVATION
746
+
747
+ // app/api/app/[module]/[...path]/route.ts: the browser's way to every module
748
+ export const { GET, HEAD, POST, PUT, PATCH, DELETE } = createApiProxy({ token: readAccessToken });
749
+ ```
750
+
751
+ - **Modules are the app's.** `ApiModules<TModule>` is an abstract class over the app's own module enum: implement
752
+ `modules` (each module's value, its key in proxy URLs, its label for messages, where its root comes from) and
753
+ `serverRoot(module)` (from the environment, a settings service, anything; may be async). Register it once with
754
+ `defineApiModules`, and define endpoints through it (`MODULES.controller`, `MODULES.endpoint`), so a file that calls
755
+ an endpoint has registered the modules on either side. `NexusApiModules` is the Nexus set (roots from `API_<MODULE>`,
756
+ as in the previous project; `NexusModule.None` for the app's own `/api` routes) and runs when nothing is registered.
757
+ The list is checked: keys and values must be unique, and keys fit in a URL.
758
+ - **Module types from one place.** An app names its enum once, next to `defineApiModules`:
759
+ `declare module "nexus-shared" { interface ApiRegister { module: HrModule } }`. Every endpoint, call, `ApiForm`,
760
+ and CRUD then takes only those modules (`AppModule`), so `{ module: NexusModule.Reservation, … }` in an HR app is a
761
+ type error. Without it, the modules are `NexusModule`.
762
+ - **The proxy, on or off.** With `useProxy` (the default), the browser calls `/api/app/<module>/<path>` and the proxy
763
+ route sends it on to the module's root with the user's token, which never reaches the browser; it strips the app's
764
+ cookies and the backend's hop headers, refuses `..`, rewrites the backend's redirects, and answers failures the way
765
+ the backend does. Off, the browser calls each module's `browserRoot` (public) and the proxy serves none.
766
+ `proxies(module)` mixes the two, such as uploads straight to the Drive module and the rest through the proxy.
767
+ - **One engine, two clients.** `api` and `serverApi` are two settings of `createApiClient`: it fills `{id}` in the path
768
+ from `params` or the body, adds the query, headers, and token, waits up to `timeout` (60 s), tries a failed GET once
769
+ more (a save never twice), and reads every answer as an `ApiResult` (`ok`, `status`, `result`, `message`, `errors`,
770
+ `messageCode`, `errorCode`, `network`, `timeout`, `aborted`). A failed call is an answer, never a throw; an aborted one
771
+ shows nothing. Next.js's own signals (`headers()` while prerendering, `redirect()`) pass through untouched.
772
+ - **Toasts in the browser.** Errors always, successes for POST, PUT, PATCH, and DELETE; the same failure twice at once
773
+ shows once; `toast: false`, `true`, or `{ success, error, loading }` per call; `configureApi({ toast, headers,
774
+ onSignedOut })` for the app. The server shows nothing and logs network failures, timeouts, and 5xx.
775
+ - **One message builder.** `buildMessage(kind, { action, subject, count, status })` words every message, and
776
+ `messages.success`, `.failure`, `.reason`, `.loading`, `.confirm`, `.label`, and `.forResult` are short ways to call
777
+ it: "3 rooms deleted.", "Could not move Room 204 to the trash.", "You do not have permission to delete Room 204.". The
778
+ texts and action words are one table: `configureMessages` rewords or translates all of them at once, and an action
779
+ of the app's own is its words (`{ verb: "check in", done: "checked in", doing: "Checking in", object: "the guest" }`).
780
+ - **A controller's lists.** `apiController` names the lists as the Nexus backend does: `listing` and `pagination` are the
781
+ active records' (`NormalListing`, `NormalPagination`), and `lists.flag`, `lists.trash`, `pages.archive`, … the others
782
+ (`FlagListing`, `TrashListing`, `ArchivePagination`, …), for the CRUD component.
783
+ - `npm run test:api` checks the builder, routes, modules (another app's enum, the proxy on and off), the engine, the
784
+ server client, and the proxy; `scripts/browser-checks/api-calls.cjs` in the template checks `/demo/api`.
785
+
786
+ ### Data table
787
+
788
+ ```tsx
789
+ import type { TableColumn } from "nexus-shared";
790
+ import { DataTable, useTable } from "nexus-shared/client";
791
+
792
+ const COLUMNS: TableColumn<Booking>[] = [
793
+ { key: "no", label: "Booking", width: "7rem", movable: false, pinnable: false }, // stays first, and stays put
794
+ { key: "guest.name", label: "Guest" }, // a path into the row
795
+ { key: "amount", label: "Amount", format: "money", prefix: "Rs. " }, // number, money, percent, date, time, date-time, boolean
796
+ { key: "status", label: "Status", options: [{ value: 1, label: "Confirmed", tone: "success" }] }, // a tag
797
+ { key: "paid", label: "Paid", format: "boolean", resizable: false }, // keeps its width
798
+ { key: "created", label: "Booked", format: "date-time", hidden: true }, // shown from the Columns menu
799
+ ];
800
+
801
+ const table = useTable<Booking>();
802
+ <DataTable table={table} aria-label="Bookings" columns={COLUMNS} rows={bookings} selectable massActions={MASS} rowActions={row => ACTIONS(row)} stateKey="bookings" />
803
+ <DataTable columns={COLUMNS} paging="server" load={(query, signal) => fetchPage(query, signal)} /> // { search, sort, page, pageSize }
804
+ <DataTable columns={COLUMNS} rows={bookings} onImport={askForFile} moreActions={[{ id: "report", label: "Monthly report", onSelect: open }]} />
805
+
806
+ table.upsert(saved); table.patch(7, { paid: true }, { flash: true }); table.remove([7, 8]); await table.reload();
807
+ ```
808
+
809
+ - **Columns are params**, one plain object each, as inputs are: `key` (a field or a path), `label`, `format`, `decimals`,
810
+ `prefix`, `suffix`, `options` (labels for an enum's values; a `tone` draws a tag with a dot of its color), `value`,
811
+ `render`, `text`, `width`, `minWidth`, `align`, `wrap`, `sortable`, `sortKey`, `searchable`, `hidden`, `hideable`,
812
+ `movable`, `resizable`, `pinnable`, `pinned`. Numbers line up at the end in tabular figures; dates and times follow the
813
+ user's settings; moments show in the user's zone once the page has hydrated; long text ends in … at the column's width.
814
+ - **Rows three ways.** Given (`rows`) or loaded once (`load`), the table searches, sorts, and pages them itself: every word
815
+ must match, in any column, with or without accents, and 10,000 rows search in about 0.5 ms a keystroke. A page at a time
816
+ (`load` with `paging="server"`), each search (after 300 ms without typing, or Enter), sort, and page is one request; a
817
+ newer query stops the one before, so a late answer never shows. A loader may answer without a promise (a cache), and
818
+ the rows then paint with the table. `loadKey` starts over for another list behind the same table.
819
+ - **What it shows while it waits.** Placeholders in the shape of the rows for the first rows; afterwards the rows stay,
820
+ with a thin bar under the headings, and dim only if a load takes a moment. A failed load says why, with Retry; an empty
821
+ list has its own message and action; a search that finds nothing offers Clear search.
822
+ - **The columns are the user's.** Drag a heading to another place, drag its right edge for its width (double-click the
823
+ edge, or "Fit to content", to fit it, never under the column's `minWidth`), and use the caret on the heading to sort,
824
+ pin it left or right, move it, or hide it; the Columns menu shows and hides them. A column opts out with
825
+ `movable`, `resizable`, or `pinnable: false`, and `pinned` starts it on a side. The table itself can refuse all three
826
+ (`reorderable`, `resizable`, `pinnable`). Once a width is set the columns are laid out from those widths, so one edge
827
+ moves alone; "Reset columns" in the options menu puts everything back.
828
+ - **One options menu (⋮)**: the columns shown as a CSV (`exportable`, named by `exportName` or the table's label), a
829
+ print view of the same in a frame of its own (`printable`), Import (`onImport`), and any `moreActions` of the page.
830
+ A client table writes every row the search left; a server table writes the page it has, and says so.
831
+ - **Selection.** The first column counts the rows (`numbered`, on by default when `selectable`) and turns into the row's
832
+ checkbox under the pointer; once anything is selected every row shows its checkbox and the heading shows the box that
833
+ selects the page (partly checked when some are). Shift+click selects a range, up to `maxSelection` (500). While rows
834
+ are selected, a bar with the count, one split button holding every `massAction`, and Clear covers the headings, so
835
+ nothing moves: the menu makes the action picked the button, and the next click runs it, with a spinner while it does.
836
+ - **Row actions**: `inline` ones as icon buttons, the rest in the row's menu; while one runs (a promise), the row is busy.
837
+ `onRowOpen` for a double-click. A row added or saved is highlighted for a moment (steadily, with reduced motion).
838
+ - **A pinned section.** `pinnedRows` puts rows in a band above the page with a button that folds them open and shut
839
+ (`pinnedLabel`, `pinnedMax` beside the count, `pinnedLoading` while they come); with a `stateKey` the choice is
840
+ remembered on the device. They are the same records as in the list below, and each wears a pin where the rows of the
841
+ page show their number.
842
+ - **Wide tables** scroll inside their frame, with the numbers and checkbox column on the left, the actions on the right,
843
+ any pinned columns beside them, and the headings on top staying in place, and a soft shadow where columns scroll under
844
+ them. Under the table: "Showing 41–50 of 234" (and how many the search left out) on the left, "Page 5 of 24" and the
845
+ pager on the right; rows per page sits inside the search box. At 520px and less the page buttons go; at 560px the
846
+ search takes its own line.
847
+ - `npm run test:table` checks the helpers, the store, and the CRUD rules; `scripts/browser-checks/data-table.cjs` in the
848
+ template checks `/demo/data-table`.
849
+
850
+ ### CRUD
851
+
852
+ ```tsx
853
+ import { Crud } from "nexus-shared/client";
854
+
855
+ export const GUESTS = MODULES.controller(NexusModule.Reservation, "Guest", "guest"); // every list and action
856
+
857
+ <Crud<Guest>
858
+ api={GUESTS}
859
+ columns={GUEST_COLUMNS} // as a DataTable takes them
860
+ inputs={GUEST_INPUTS} // or { create, edit }, or (action, row) => inputs
861
+ paging="server" // default "client": each list loaded once
862
+ form={{ load: "details", newValues: { country: "Nepal" } }}
863
+ details={{ columns: GUEST_DETAILS }}
864
+ onChange={({ action, rows, mode }) => audit(action, rows)}
865
+ />
866
+ ```
867
+
868
+ - **Lists.** All (`NormalListing` or `NormalPagination`), Flagged, Archived, Trash, and Deleted, as icon tabs with the
869
+ chosen one named. A list shows when it is in `modes`, has its endpoint, and the user may call it.
870
+ - **Pinned records.** `PinListing` answers the records the user pinned: they sit in a section above the active list that
871
+ folds open and shut, and in the list and its pages as well. One limit holds for every CRUD in the app
872
+ (`configureCrud({ maxPins: 100 })`, 100 by default). Pinning a selection bigger than the room left pins as many as fit,
873
+ in the order they were picked, and says so; lowering the limit never unpins anything, so a user over it can still
874
+ unpin and can pin again once they are under it.
875
+ - **Actions.** On a record in the lists of active records: View details, Edit (an icon on the row), Flag, Pin,
876
+ Archive, Move to trash; in the archive: Restore; in the trash: Recover, Delete permanently; in the deleted list: Move
877
+ back to trash. On selected records: the same, plus a new Description for all of them. Each shows only when it is in
878
+ `actions`, has its endpoint, and is allowed. A controller without a trash (no endpoint, or left out of `actions`) offers
879
+ Delete where Move to trash would be; a trash the user may not use never becomes Delete.
880
+ - **Questions and messages.** Archive, Move to trash, and Delete ask first ("Move 3 guests to the trash?", "This cannot be
881
+ undone."); Flag, Pin, Restore, and Recover are undone by a click and do not ask. Toasts come from the message
882
+ builder ("Sita Sharma archived.", "3 guests unpinned.").
883
+ - **Rows from the answers.** A record that moves to another list leaves the one in view (and the pinned section); flags,
884
+ pins, and saved values change in place; a new record goes first; a server page loads again in the background to fill up. When a mass
885
+ answer lists the records it changed, only those change.
886
+ - **Add and Edit** open popups built on `ApiForm`, with the Save bar in the footer and the server's messages on their
887
+ inputs. Keys keep them one each: pressing Add again brings back an Add form with changes (minimized or not), or opens a
888
+ fresh one; Edit of a record already open brings that popup back as it was. Closing a form with changes (its close
889
+ button, Esc, the dock) asks "Discard your changes?". Edit opens with the row, the `details` endpoint's record
890
+ (`form.load: "details"`, for fields a list leaves out), or a loader of your own.
891
+ - **Details** (View, or a double-click) shows every column, hidden ones too, and the full record once `details` answers,
892
+ with Edit in its footer.
893
+ - **Cache.** Lists are kept for 5 minutes while the page is open (`cache={{ lifetime }}`, or `false`): going back to a
894
+ list paints it at once. After a change, the list in view keeps its rows and the others load again when shown; Reload
895
+ and the handle's `reload()` go past the cache. The cache goes when the page does.
896
+ - **Permissions** come from the app's rules: `definePermissions(new NexusPermissions())` once, then `setActions(accessActions)`
897
+ after sign-in. While the rules load, the table shows placeholders; a user with no list sees a message. Rules for
898
+ another backend extend `Permissions` (`can(endpoint)`), and its page and mass shapes extend `CrudBackend`.
899
+ - `ref` gives `table`, `mode`, `setMode`, `reload`, `create(values)`, `edit(row)`, and `view(row)`.
900
+ - `scripts/browser-checks/crud.cjs` in the template checks `/demo/crud`: every list and action, the popups, the roles, the
901
+ cache, a phone, and contrast in every theme.
902
+
903
+ Planned, following the previous Nexus project: a page status layout, and in the CRUD, audit logs in the details view.