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
@@ -0,0 +1,36 @@
1
+ import { type KeyboardEvent, type MouseEvent, type ReactNode, type RefObject } from "react";
2
+ import { type PopoverAlign } from "../../Helpers/PopoverHelpers.ts";
3
+ export interface ReadOnlyNoticeOptions {
4
+ /** The element the note goes under, for the element the user acted on. Default: the field's box (`.nx-field__box`). */
5
+ anchor?: (target: Element) => Element | null;
6
+ /** Lines the note up with the anchor's `start` (default) or `end` edge, e.g. `end` under a switch at the end of its row. */
7
+ align?: PopoverAlign;
8
+ /** Typed text, Backspace, Delete, Ctrl+V, and Ctrl+X count as attempts. Default true; off for a slider. */
9
+ typing?: boolean;
10
+ /** Other keys that would change the value: `["ArrowDown"]` opens a date picker's calendar. */
11
+ keys?: readonly string[];
12
+ /** `box` (default): a lock the size of a field's buttons, for the end of its box. `label`: a small lock after a label. */
13
+ lock?: "box" | "label";
14
+ }
15
+ export interface ReadOnlyNotice {
16
+ /** The lock: in the field's `actions` for `box`, or after the label text for `label`. `null` unless read-only. */
17
+ lock: ReactNode;
18
+ /** The note. Render it after the field; it shows nothing until an attempt. `null` unless read-only. */
19
+ notice: ReactNode;
20
+ /** Call from `onKeyDown`: a key that would change the value shows the note, and Esc hides it. */
21
+ onKeyDown: (event: KeyboardEvent<HTMLElement>) => void;
22
+ /** Call from `onClick`: a click shows the note under the anchor of its target, unless it selected text to copy. */
23
+ onClick: (event: MouseEvent<HTMLElement>) => void;
24
+ /** Shows the note under the anchor of this element, e.g. on a slider's pointer press. */
25
+ show: (target: Element | null) => void;
26
+ /** Hides the note, e.g. when focus leaves the field. */
27
+ hide: () => void;
28
+ }
29
+ /**
30
+ * Feedback for a read-only field, so a click or a key that does nothing does not look like a bug: a lock, and a
31
+ * short note under the field when the user tries to change it anyway. Nothing renders until an attempt, and an
32
+ * attempt re-renders only the note, so a large form or a group of many options costs nothing extra.
33
+ *
34
+ * @example const readOnlyNotice = useReadOnlyNotice(Boolean(readOnly) && !disabled, field.elementRef, "Read-only: this date cannot be changed.", { keys: ["ArrowDown"] });
35
+ */
36
+ export declare function useReadOnlyNotice(enabled: boolean, controlRef: RefObject<HTMLElement | null>, message: ReactNode, options?: ReadOnlyNoticeOptions): ReadOnlyNotice;
@@ -0,0 +1,116 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { iconLock, InlineIcon } from "nexus-icons";
4
+ import { useEffect, useImperativeHandle, useLayoutEffect, useRef, useState, } from "react";
5
+ import { followAnchor, isPopoverOpen, placeUnderAnchor } from "../../Helpers/PopoverHelpers.js";
6
+ /** How long the note stays up after the last attempt, in milliseconds. */
7
+ const NOTICE_MS = 2500;
8
+ /**
9
+ * Feedback for a read-only field, so a click or a key that does nothing does not look like a bug: a lock, and a
10
+ * short note under the field when the user tries to change it anyway. Nothing renders until an attempt, and an
11
+ * attempt re-renders only the note, so a large form or a group of many options costs nothing extra.
12
+ *
13
+ * @example const readOnlyNotice = useReadOnlyNotice(Boolean(readOnly) && !disabled, field.elementRef, "Read-only: this date cannot be changed.", { keys: ["ArrowDown"] });
14
+ */
15
+ export function useReadOnlyNotice(enabled, controlRef, message, options = {}) {
16
+ const { anchor = fieldBox, align = "start", typing = true, keys, lock: lockDesign = "box" } = options;
17
+ const noteRef = useRef(null);
18
+ const lockRef = useRef(null);
19
+ const timerRef = useRef(0);
20
+ const shownRef = useRef(false);
21
+ function show(target) {
22
+ const element = enabled && target ? anchor(target) : null;
23
+ if (!element)
24
+ return;
25
+ window.clearTimeout(timerRef.current);
26
+ timerRef.current = window.setTimeout(hide, NOTICE_MS);
27
+ shownRef.current = true;
28
+ noteRef.current?.show(element, align);
29
+ // Each attempt restarts the lock's nudge.
30
+ const lock = lockRef.current;
31
+ if (lock) {
32
+ lock.removeAttribute("data-nudge");
33
+ void lock.offsetWidth;
34
+ lock.setAttribute("data-nudge", "");
35
+ }
36
+ }
37
+ function hide() {
38
+ window.clearTimeout(timerRef.current);
39
+ if (!shownRef.current)
40
+ return;
41
+ shownRef.current = false;
42
+ noteRef.current?.hide();
43
+ lockRef.current?.removeAttribute("data-nudge");
44
+ }
45
+ useEffect(() => {
46
+ if (!enabled)
47
+ hide();
48
+ }, [enabled]);
49
+ useEffect(() => () => window.clearTimeout(timerRef.current), []);
50
+ function onKeyDown(event) {
51
+ if (!enabled)
52
+ return;
53
+ if (event.key === "Escape") {
54
+ if (!shownRef.current)
55
+ return;
56
+ event.stopPropagation();
57
+ hide();
58
+ }
59
+ else if (isChangeKey(event, typing, keys)) {
60
+ show(event.target);
61
+ }
62
+ }
63
+ function onClick(event) {
64
+ const target = event.target;
65
+ if (enabled && target instanceof Element && !hasSelection(target))
66
+ show(target);
67
+ }
68
+ const lock = !enabled ? null : lockDesign === "box" ? (_jsx("span", { ref: lockRef, className: "nx-field__lock", title: "Read-only", "aria-hidden": "true",
69
+ // The box keeps focus and any selected text.
70
+ onMouseDown: event => {
71
+ event.preventDefault();
72
+ controlRef.current?.focus();
73
+ show(controlRef.current);
74
+ }, children: _jsx(InlineIcon, { icon: iconLock }) })) : (_jsx("span", { ref: lockRef, className: "nx-field__lock nx-field__lock--label", title: "Read-only", "aria-hidden": "true", children: _jsx(InlineIcon, { icon: iconLock }) }));
75
+ return { lock, notice: enabled ? _jsx(ReadOnlyNote, { ref: noteRef, message: message }) : null, onKeyDown, onClick, show, hide };
76
+ }
77
+ /**
78
+ * The note itself, with its own state, so showing it re-renders only the note. It is a manual popover in the top
79
+ * layer, so a table cell or a dialog does not clip it, and it follows its anchor while the page scrolls.
80
+ */
81
+ function ReadOnlyNote({ ref, message }) {
82
+ const [shown, setShown] = useState(null);
83
+ const noteRef = useRef(null);
84
+ useImperativeHandle(ref, () => ({ show: (anchor, align) => setShown({ anchor, align }), hide: () => setShown(null) }), []);
85
+ useLayoutEffect(() => {
86
+ const note = noteRef.current;
87
+ if (!shown || !note)
88
+ return;
89
+ if (!isPopoverOpen(note))
90
+ note.showPopover?.();
91
+ const place = () => placeUnderAnchor(note, shown.anchor.getBoundingClientRect(), { align: shown.align });
92
+ place();
93
+ return followAnchor(place);
94
+ }, [shown]);
95
+ if (!shown)
96
+ return null;
97
+ return (_jsxs("div", { ref: noteRef, popover: "manual", role: "status", className: "nx-field-notice", children: [_jsx(InlineIcon, { icon: iconLock }), _jsx("span", { children: message })] }));
98
+ }
99
+ const fieldBox = (target) => target.closest(".nx-field__box");
100
+ /** Whether a text box has selected text, as after dragging across it to copy. */
101
+ function hasSelection(target) {
102
+ return (target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement) && target.selectionStart !== target.selectionEnd;
103
+ }
104
+ /** Keys that would change the value. Copying, selecting, and moving the caret are not. */
105
+ function isChangeKey(event, typing, keys = []) {
106
+ const { key, ctrlKey, metaKey } = event;
107
+ if (keys.includes(key))
108
+ return true;
109
+ if (!typing)
110
+ return false;
111
+ if (key === "Backspace" || key === "Delete")
112
+ return true;
113
+ if (ctrlKey || metaKey)
114
+ return key === "v" || key === "V" || key === "x" || key === "X";
115
+ return key.length === 1;
116
+ }
@@ -0,0 +1,103 @@
1
+ import { type CSSProperties, type FocusEvent, type ReactNode, type Ref } from "react";
2
+ import { type RichTextRules, type RichTextToken, type RichTextTokenFormat } from "../../Helpers/RichTextHelpers.ts";
3
+ import type { ValidateOn } from "../../Interfaces/InputInterfaces.ts";
4
+ /** `edit`: the formatted text, edited in place. `html`: its HTML source, one block per line. */
5
+ export type RichTextEditorMode = "edit" | "html";
6
+ export type RichTextTool = "undo" | "redo" | "block" | "bold" | "italic" | "underline" | "strikethrough" | "code" | "subscript" | "superscript" | "color" | "link" | "bulletList" | "numberedList" | "quote" | "align" | "table" | "rule" | "clear" | "token";
7
+ /** A toolbar button, or `"|"` for a divider between groups. */
8
+ export type RichTextToolbarItem = RichTextTool | "|";
9
+ /** The default toolbar. `token` shows only when the editor has `tokens`. */
10
+ export declare const RICH_TEXT_TOOLBAR: readonly RichTextToolbarItem[];
11
+ export interface RichTextEditorProps extends RichTextRules {
12
+ id?: string;
13
+ /** Form field name: the form's data gets the sanitized HTML under it. */
14
+ name?: string;
15
+ /** Id of the form the editor belongs to, when it sits outside it. */
16
+ form?: string;
17
+ label?: ReactNode;
18
+ /** Help text under the editor. */
19
+ hint?: ReactNode;
20
+ /** An error from outside, such as a server message. Shown before the field's own message. */
21
+ error?: string | null;
22
+ /** Shown while the editor is empty. */
23
+ placeholder?: string;
24
+ /** The HTML it starts with. It is sanitized first. */
25
+ defaultValue?: string;
26
+ /** The HTML, when the page controls it; pair it with `onValueChange`. Passing back the value it gave does nothing. */
27
+ value?: string;
28
+ /** The sanitized HTML after each change: typed, pasted, from the toolbar, or from the HTML view. */
29
+ onValueChange?: (html: string) => void;
30
+ /** The view it opens in. Default `edit`. */
31
+ defaultMode?: RichTextEditorMode;
32
+ /** The view, when the page controls it; use with `onModeChange`. */
33
+ mode?: RichTextEditorMode;
34
+ onModeChange?: (mode: RichTextEditorMode) => void;
35
+ /** The views to switch between. Default both; `["edit"]` hides the switch and the HTML. */
36
+ modes?: readonly RichTextEditorMode[];
37
+ /** Toolbar buttons in order, `"|"` for a divider. Default `RICH_TEXT_TOOLBAR`; `[]` hides them. Shortcuts work for the tools listed. */
38
+ toolbar?: readonly RichTextToolbarItem[];
39
+ /** Values a template fills in, such as the guest's name: a menu inserts them as chips, and the HTML holds them as `tokenFormat` text. */
40
+ tokens?: readonly RichTextToken[];
41
+ /** How tokens are written in the HTML: `{{key}}` (default, messages) or `|key|` (reports). */
42
+ tokenFormat?: RichTextTokenFormat;
43
+ /** Height of the text, in pixels. Default 280. A double-click on the handle goes back to it. */
44
+ height?: number;
45
+ /** Smallest height the handle allows. Default 120. */
46
+ minHeight?: number;
47
+ /** Largest height the handle allows. Default 960. */
48
+ maxHeight?: number;
49
+ /** The handle under the editor that drags its height. Default true. */
50
+ resizable?: boolean;
51
+ /** Remembers the height the user picks, in local storage under `nx-rte-height:<heightKey>`. */
52
+ heightKey?: string;
53
+ /** A button that opens the editor over the whole window. Default true. */
54
+ fullscreen?: boolean;
55
+ /** Word and character counts in the status bar. Default true. */
56
+ showCount?: boolean;
57
+ /** Spelling check while typing. Default true. */
58
+ spellCheck?: boolean;
59
+ autoFocus?: boolean;
60
+ readOnly?: boolean;
61
+ disabled?: boolean;
62
+ /** What a read-only editor says when someone tries to change it. Default "Read-only: this text cannot be changed." */
63
+ readOnlyMessage?: string;
64
+ /** Name used in messages. Default: the label, when it is text. */
65
+ fieldName?: string;
66
+ /** When the field shows its own message. Default `blur`; submitting a form always shows it. */
67
+ validateOn?: ValidateOn;
68
+ /** Name of the editor for screen readers, when there is no `label`. */
69
+ "aria-label"?: string;
70
+ "aria-describedby"?: string;
71
+ onFocus?: (event: FocusEvent<HTMLDivElement>) => void;
72
+ onBlur?: (event: FocusEvent<HTMLDivElement>) => void;
73
+ /** Class of the outer field. */
74
+ className?: string;
75
+ style?: CSSProperties;
76
+ ref?: Ref<RichTextEditorHandle>;
77
+ }
78
+ /** What `ref` gives on a rich text editor. */
79
+ export interface RichTextEditorHandle {
80
+ /** The sanitized HTML. */
81
+ getValue: () => string;
82
+ /** Replaces the content, e.g. with a template loaded from a server. It becomes what a form reset returns to. */
83
+ setValue: (html: string) => void;
84
+ /** Inserts text at the caret, replacing the selection. */
85
+ insertText: (text: string) => void;
86
+ /** Inserts HTML at the caret, sanitized first. */
87
+ insertHtml: (html: string) => void;
88
+ /** Inserts a token (a value the template fills in) at the caret, as a chip. */
89
+ insertToken: (key: string) => void;
90
+ focus: () => void;
91
+ /** The editable element. */
92
+ element: HTMLDivElement | null;
93
+ }
94
+ /**
95
+ * A rich text editor: formatted text edited in place, with a toolbar and shortcuts, text colors and highlights, links,
96
+ * lists, alignment, tables, template tokens as chips, an HTML view, a height handle, and full screen. The value is
97
+ * HTML, sanitized on every change (`sanitizeRichText`), so a page can store it and show it with `RichTextView`.
98
+ * Editing goes through the browser, so Ctrl+Z undoes typing and toolbar changes alike, and typing re-renders nothing.
99
+ * Pastes from Word, Google Docs, and web pages keep their formatting and lose everything else.
100
+ *
101
+ * @example <RichTextEditor name="description" label="Room description" heightKey="room-description" maxLength={5000} />
102
+ */
103
+ export declare function RichTextEditor(props: RichTextEditorProps): import("react").JSX.Element;