nexus-shared 3.2.0 → 4.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 (187) hide show
  1. package/CHANGELOG.md +1564 -0
  2. package/README.md +1705 -1123
  3. package/dist/Client.Index.d.ts +14 -0
  4. package/dist/Client.Index.js +14 -0
  5. package/dist/Components/Documents/DocumentFrame.d.ts +50 -0
  6. package/dist/Components/Documents/DocumentFrame.js +83 -0
  7. package/dist/Components/Documents/Menu.d.ts +4 -0
  8. package/dist/Components/Documents/Menu.js +40 -24
  9. package/dist/Components/Documents/PrintDocument.d.ts +95 -0
  10. package/dist/Components/Documents/PrintDocument.js +62 -0
  11. package/dist/Components/Documents/Tabs.d.ts +59 -0
  12. package/dist/Components/Documents/Tabs.js +70 -0
  13. package/dist/Components/Forms/ApiForm.js +19 -2
  14. package/dist/Components/Forms/Crud.d.ts +2 -2
  15. package/dist/Components/Forms/Crud.js +576 -243
  16. package/dist/Components/Forms/CrudActions.d.ts +136 -0
  17. package/dist/Components/Forms/CrudActions.js +184 -0
  18. package/dist/Components/Forms/CrudNarrowPicker.d.ts +31 -0
  19. package/dist/Components/Forms/CrudNarrowPicker.js +180 -0
  20. package/dist/Components/Forms/CrudParts.d.ts +30 -2
  21. package/dist/Components/Forms/CrudParts.js +55 -5
  22. package/dist/Components/Forms/CrudRowForms.d.ts +26 -0
  23. package/dist/Components/Forms/CrudRowForms.js +114 -0
  24. package/dist/Components/Forms/CrudScopes.d.ts +28 -0
  25. package/dist/Components/Forms/CrudScopes.js +76 -0
  26. package/dist/Components/Forms/CrudTree.d.ts +90 -0
  27. package/dist/Components/Forms/CrudTree.js +363 -0
  28. package/dist/Components/Forms/CrudWorkspace.d.ts +63 -0
  29. package/dist/Components/Forms/CrudWorkspace.js +169 -0
  30. package/dist/Components/Forms/ExcelImport.js +3 -3
  31. package/dist/Components/Forms/Form.d.ts +4 -4
  32. package/dist/Components/Forms/Form.js +123 -17
  33. package/dist/Components/Forms/FormLeaveGuard.d.ts +44 -0
  34. package/dist/Components/Forms/FormLeaveGuard.js +65 -0
  35. package/dist/Components/Forms/RecordFlows.d.ts +50 -0
  36. package/dist/Components/Forms/RecordFlows.js +282 -0
  37. package/dist/Components/Forms/SubmitForm.d.ts +37 -2
  38. package/dist/Components/Forms/SubmitForm.js +195 -10
  39. package/dist/Components/Inputs/CheckBox.js +1 -1
  40. package/dist/Components/Inputs/ChoiceField.d.ts +21 -1
  41. package/dist/Components/Inputs/ChoiceField.js +28 -2
  42. package/dist/Components/Inputs/Dropdown.d.ts +13 -0
  43. package/dist/Components/Inputs/Dropdown.js +5 -5
  44. package/dist/Components/Inputs/DropdownParts.d.ts +3 -1
  45. package/dist/Components/Inputs/DropdownParts.js +16 -4
  46. package/dist/Components/Inputs/Field.d.ts +7 -1
  47. package/dist/Components/Inputs/Field.js +2 -2
  48. package/dist/Components/Inputs/GroupForm.d.ts +6 -6
  49. package/dist/Components/Inputs/GroupForm.js +10 -11
  50. package/dist/Components/Inputs/InputRenderer.d.ts +9 -6
  51. package/dist/Components/Inputs/InputRenderer.js +37 -32
  52. package/dist/Components/Inputs/PictureInput.d.ts +41 -0
  53. package/dist/Components/Inputs/PictureInput.js +70 -0
  54. package/dist/Components/Inputs/RadioGroup.d.ts +16 -3
  55. package/dist/Components/Inputs/RadioGroup.js +8 -3
  56. package/dist/Components/Inputs/RowsInput.d.ts +1 -1
  57. package/dist/Components/Inputs/RowsInput.js +18 -3
  58. package/dist/Components/Inputs/TabularForm.d.ts +5 -5
  59. package/dist/Components/Inputs/TabularForm.js +29 -29
  60. package/dist/Components/Inputs/TextArea.d.ts +6 -0
  61. package/dist/Components/Inputs/TextArea.js +11 -2
  62. package/dist/Components/Inputs/TextBoxTypes.d.ts +6 -0
  63. package/dist/Components/Inputs/TextBoxTypes.js +17 -0
  64. package/dist/Components/Inputs/TreeView.d.ts +53 -2
  65. package/dist/Components/Inputs/TreeView.js +147 -13
  66. package/dist/Components/Layouts/MessageBox.d.ts +15 -2
  67. package/dist/Components/Layouts/MessageBox.js +56 -7
  68. package/dist/Components/Layouts/Popup.d.ts +13 -6
  69. package/dist/Components/Layouts/Popup.js +37 -9
  70. package/dist/Components/Layouts/PopupDock.d.ts +3 -1
  71. package/dist/Components/Layouts/PopupDock.js +2 -1
  72. package/dist/Components/Layouts/PopupHost.js +5 -4
  73. package/dist/Components/Viewers/DataTable.js +150 -48
  74. package/dist/Components/Viewers/DataTableFilters.d.ts +1 -1
  75. package/dist/Components/Viewers/DataTableFilters.js +17 -2
  76. package/dist/Components/Viewers/DataTableParts.d.ts +21 -5
  77. package/dist/Components/Viewers/DataTableParts.js +26 -14
  78. package/dist/Components/Viewers/OwnerFiles.d.ts +175 -0
  79. package/dist/Components/Viewers/OwnerFiles.js +589 -0
  80. package/dist/Components/Viewers/QrCodeImage.d.ts +22 -0
  81. package/dist/Components/Viewers/QrCodeImage.js +15 -0
  82. package/dist/Components/Viewers/RecordCards.d.ts +16 -0
  83. package/dist/Components/Viewers/RecordCards.js +509 -0
  84. package/dist/Helpers/BusyHooks.d.ts +6 -0
  85. package/dist/Helpers/BusyHooks.js +39 -0
  86. package/dist/Helpers/CrudBackend.d.ts +20 -2
  87. package/dist/Helpers/CrudBackend.js +46 -2
  88. package/dist/Helpers/CrudColumns.d.ts +53 -6
  89. package/dist/Helpers/CrudColumns.js +98 -7
  90. package/dist/Helpers/CrudDetailsTabs.d.ts +58 -0
  91. package/dist/Helpers/CrudDetailsTabs.js +126 -0
  92. package/dist/Helpers/CrudHelpers.d.ts +81 -2
  93. package/dist/Helpers/CrudHelpers.js +195 -0
  94. package/dist/Helpers/CrudNarrowPick.d.ts +83 -0
  95. package/dist/Helpers/CrudNarrowPick.js +157 -0
  96. package/dist/Helpers/CrudRowForms.d.ts +15 -0
  97. package/dist/Helpers/CrudRowForms.js +43 -0
  98. package/dist/Helpers/CrudScopes.d.ts +32 -0
  99. package/dist/Helpers/CrudScopes.js +79 -0
  100. package/dist/Helpers/DropdownHelpers.d.ts +3 -1
  101. package/dist/Helpers/DropdownHelpers.js +6 -2
  102. package/dist/Helpers/ExcelHelpers.d.ts +1 -1
  103. package/dist/Helpers/ExcelHelpers.js +12 -11
  104. package/dist/Helpers/FileAdapter.d.ts +78 -0
  105. package/dist/Helpers/FileAdapter.js +102 -0
  106. package/dist/Helpers/FilePrimaries.d.ts +48 -0
  107. package/dist/Helpers/FilePrimaries.js +138 -0
  108. package/dist/Helpers/FormConfirm.d.ts +32 -0
  109. package/dist/Helpers/FormConfirm.js +40 -0
  110. package/dist/Helpers/FormStore.d.ts +90 -5
  111. package/dist/Helpers/FormStore.js +318 -22
  112. package/dist/Helpers/InputConditions.d.ts +50 -0
  113. package/dist/Helpers/InputConditions.js +168 -0
  114. package/dist/Helpers/InputMemory.d.ts +106 -0
  115. package/dist/Helpers/InputMemory.js +385 -0
  116. package/dist/Helpers/InputNarrowing.d.ts +18 -0
  117. package/dist/Helpers/InputNarrowing.js +67 -0
  118. package/dist/Helpers/InputParamsHelpers.d.ts +44 -1
  119. package/dist/Helpers/InputParamsHelpers.js +157 -74
  120. package/dist/Helpers/NexusDriveAdapter.d.ts +55 -0
  121. package/dist/Helpers/NexusDriveAdapter.js +207 -0
  122. package/dist/Helpers/NumberHelpers.d.ts +95 -0
  123. package/dist/Helpers/NumberHelpers.js +126 -0
  124. package/dist/Helpers/Permissions.js +2 -1
  125. package/dist/Helpers/QrCode.d.ts +26 -0
  126. package/dist/Helpers/QrCode.js +463 -0
  127. package/dist/Helpers/RecordCards.d.ts +205 -0
  128. package/dist/Helpers/RecordCards.js +378 -0
  129. package/dist/Helpers/RequestCache.d.ts +14 -2
  130. package/dist/Helpers/RequestCache.js +22 -3
  131. package/dist/Helpers/RowsStore.d.ts +37 -2
  132. package/dist/Helpers/RowsStore.js +128 -10
  133. package/dist/Helpers/ServerPreview.d.ts +69 -0
  134. package/dist/Helpers/ServerPreview.js +99 -0
  135. package/dist/Helpers/TableColumns.js +4 -3
  136. package/dist/Helpers/TableExport.d.ts +7 -1
  137. package/dist/Helpers/TableExport.js +9 -3
  138. package/dist/Helpers/TableFilters.d.ts +1 -1
  139. package/dist/Helpers/TableFilters.js +24 -23
  140. package/dist/Helpers/TableHelpers.d.ts +23 -2
  141. package/dist/Helpers/TableHelpers.js +51 -10
  142. package/dist/Helpers/TableJoins.d.ts +13 -0
  143. package/dist/Helpers/TableJoins.js +34 -0
  144. package/dist/Helpers/TableStore.d.ts +21 -1
  145. package/dist/Helpers/TableStore.js +64 -7
  146. package/dist/Helpers/TreeStore.d.ts +81 -0
  147. package/dist/Helpers/TreeStore.js +365 -0
  148. package/dist/Interfaces/CrudInterfaces.d.ts +465 -5
  149. package/dist/Interfaces/FileInterfaces.d.ts +162 -0
  150. package/dist/Interfaces/FileInterfaces.js +4 -0
  151. package/dist/Interfaces/FormInterfaces.d.ts +391 -30
  152. package/dist/Interfaces/FormInterfaces.js +79 -1
  153. package/dist/Interfaces/InputInterfaces.d.ts +15 -3
  154. package/dist/Interfaces/RecordInterfaces.d.ts +367 -0
  155. package/dist/Interfaces/RecordInterfaces.js +1 -0
  156. package/dist/Interfaces/TableInterfaces.d.ts +74 -1
  157. package/dist/Services/ExcelApi.js +5 -0
  158. package/dist/Services/FileApi.d.ts +13 -0
  159. package/dist/Services/FileApi.js +29 -0
  160. package/dist/Services/ImageEditorLoader.d.ts +14 -0
  161. package/dist/Services/ImageEditorLoader.js +51 -0
  162. package/dist/Services/JoinSources.d.ts +37 -5
  163. package/dist/Services/JoinSources.js +90 -14
  164. package/dist/Services/ModuleImport.d.ts +7 -0
  165. package/dist/Services/ModuleImport.js +22 -0
  166. package/dist/Shared.Index.d.ts +16 -0
  167. package/dist/Shared.Index.js +16 -0
  168. package/package.json +7 -2
  169. package/src/Styles/Nexus.Avatar.css +6 -5
  170. package/src/Styles/Nexus.Button.css +10 -4
  171. package/src/Styles/Nexus.Choice.css +16 -0
  172. package/src/Styles/Nexus.Crud.css +383 -9
  173. package/src/Styles/Nexus.Dropdown.css +8 -0
  174. package/src/Styles/Nexus.Files.css +410 -0
  175. package/src/Styles/Nexus.Form.css +5 -2
  176. package/src/Styles/Nexus.Index.css +4 -0
  177. package/src/Styles/Nexus.Input.css +42 -0
  178. package/src/Styles/Nexus.Menu.css +10 -1
  179. package/src/Styles/Nexus.Popup.css +77 -1
  180. package/src/Styles/Nexus.Print.css +288 -0
  181. package/src/Styles/Nexus.QrCode.css +12 -0
  182. package/src/Styles/Nexus.Record.css +430 -0
  183. package/src/Styles/Nexus.Tab.Buttons.css +87 -22
  184. package/src/Styles/Nexus.Table.css +67 -5
  185. package/src/Styles/Nexus.Themes.css +12 -6
  186. package/src/Styles/Nexus.Tokens.css +8 -3
  187. package/src/Styles/Nexus.Tree.css +31 -1
@@ -0,0 +1,162 @@
1
+ import type { ApiModuleValue, AppModule } from "./ApiInterfaces.ts";
2
+ /**
3
+ * Whose files: the module that owns the row, the category, and the row's id. The module decides who may change them
4
+ * (with Nexus, its `Files/Ticket` signs the change), so it is the owner's module, not the one that stores the bytes.
5
+ *
6
+ * @example
7
+ * { module: NexusModule.Enterprise, category: "branch-picture", ownerId: branch.id }
8
+ * { module: NexusModule.Enterprise, category: "user-picture", ownerId: "me" } // the person's own
9
+ */
10
+ export interface FileOwner<TModule extends ApiModuleValue = AppModule> {
11
+ module: TModule;
12
+ /** The category's code: `branch-picture`, `subscriber-document`. */
13
+ category: string;
14
+ /** The owner row's id, as the module answers it; `me` for the person's own. */
15
+ ownerId: string;
16
+ }
17
+ /** Which copy of a stored file: the file itself, or its small picture. */
18
+ export type FileCopy = "original" | "thumbnail";
19
+ /** One stored file, as the adapter reads it. */
20
+ export interface StoredFile {
21
+ /** Its id, as the backend answers it (with Nexus, encrypted for the person asking). */
22
+ id: string;
23
+ /** The name it is shown by, with the extension of what it really is. */
24
+ name: string;
25
+ /** What its bytes are: `image/png`, `image/jpeg`, `image/webp`, `application/pdf`. */
26
+ contentType: string;
27
+ /** Its size in bytes. */
28
+ size: number;
29
+ /** A picture's size in pixels; null for a document. */
30
+ width: number | null;
31
+ height: number | null;
32
+ /** Whether a thumbnail was stored with it. Without one, the thumbnail copy is the file itself (pictures only). */
33
+ hasThumbnail: boolean;
34
+ /** Whether it is the owner's picture: at most one per owner and category. */
35
+ isPrimary: boolean;
36
+ /** When it was stored: an ISO UTC moment, or null when the backend does not say. */
37
+ createdAt: string | null;
38
+ }
39
+ /** What a category takes, as the backend says: what a gallery tells the person before an upload is refused. */
40
+ export interface FileCategoryInfo {
41
+ /** The category's code. */
42
+ code: string;
43
+ /** Its name: "Branch picture". */
44
+ name: string;
45
+ /** The MIME types it takes: `["image/png", "image/jpeg", "image/webp"]`. */
46
+ types: readonly string[];
47
+ /** The largest file it takes, in bytes. */
48
+ maxBytes: number;
49
+ /** How many files one owner keeps. */
50
+ maxCount: number;
51
+ /** The longest side of a thumbnail in pixels; 0 when it keeps none. */
52
+ thumbnailSize: number;
53
+ /** Whether this person may change the files: upload, make primary, rename, delete. */
54
+ canWrite: boolean;
55
+ /**
56
+ * The longest side a stored picture may have, in pixels: Drive's `Nexus:Drive:Pictures:MaxSide`. Every picture is
57
+ * made to fit it in the browser before it is sent. Default `PICTURE_LIMITS.maxSide` (1920) when the backend does not say.
58
+ */
59
+ pictureMaxSide?: number;
60
+ /** The highest quality a picture is written at, in percent: Drive's `Quality`. Default `PICTURE_LIMITS.quality` (80). */
61
+ pictureQuality?: number;
62
+ /**
63
+ * The most bytes a stored picture may hold: Drive's `MaxKilobytes`, never above `maxBytes`. The browser writes every
64
+ * picture under it (a lower quality, then a smaller size). Default `PICTURE_LIMITS.maxBytes` (300 KB), at most `maxBytes`.
65
+ */
66
+ pictureMaxBytes?: number;
67
+ }
68
+ /** An owner's files and what their category takes. */
69
+ export interface OwnerFiles {
70
+ category: FileCategoryInfo;
71
+ /** The live files, in their order. */
72
+ files: StoredFile[];
73
+ /**
74
+ * Why this person may only look (`category.canWrite` false), in the backend's words when it gave them: the refusal of
75
+ * the write ticket ("You do not hold the key to change this branch").
76
+ */
77
+ readOnlyReason?: string;
78
+ }
79
+ /** What an upload sends: the file the browser made, and for a picture its thumbnail. */
80
+ export interface FileUpload {
81
+ file: Blob;
82
+ /** The name to keep: "Front desk.jpg". The backend keeps the real kind's extension whatever it says. */
83
+ name: string;
84
+ thumbnail?: Blob | null;
85
+ }
86
+ /** What every call of the adapter takes. */
87
+ export interface FileCallOptions {
88
+ signal?: AbortSignal;
89
+ /** Shows no toast for this call: the panel says what happened. */
90
+ toast?: false;
91
+ }
92
+ /** Picture kinds a browser canvas writes, and so the ones the editor saves. */
93
+ export type PictureType = "image/jpeg" | "image/png" | "image/webp";
94
+ /** The MIME types of pictures (what a canvas can read back), in the order a file picker offers them. */
95
+ export declare const PICTURE_TYPES: readonly PictureType[];
96
+ /** Whether a MIME type is a picture this package can show and edit. */
97
+ export declare const isPictureType: (type: string | null | undefined) => type is PictureType;
98
+ /** What the editor is opened with (a part of `nexus-image-editor`'s `ImageEditorOptions`). */
99
+ export interface ImageEditorOptions {
100
+ src?: File | Blob | string;
101
+ /** A number locks the shape (1 for a logo or an avatar); `free` lets the person choose. */
102
+ aspect?: number | "free" | "original" | Array<number | "free" | "original">;
103
+ /** A round guide over a square crop, for a person's picture. */
104
+ shape?: "rect" | "circle";
105
+ maxWidth?: number;
106
+ maxHeight?: number;
107
+ minWidth?: number;
108
+ minHeight?: number;
109
+ type?: PictureType;
110
+ /**
111
+ * The kinds the place the picture goes to takes (a file category's): the only ones the editor offers and saves - a
112
+ * picture too large as a PNG becomes a JPEG or a WebP only when one of them is taken, else stays a PNG, made smaller.
113
+ */
114
+ types?: readonly PictureType[];
115
+ /** 0-1. */
116
+ quality?: number;
117
+ /** 0-1: the highest quality written (the slider's top, where it starts at most). */
118
+ maxQuality?: number;
119
+ /** The most bytes the saved file may hold: a lower quality, then a smaller picture, until it fits. */
120
+ maxBytes?: number;
121
+ /** The longest side of a thumbnail made with the picture, in pixels. */
122
+ thumbnail?: number | boolean;
123
+ title?: string;
124
+ fileName?: string;
125
+ signal?: AbortSignal;
126
+ }
127
+ /** What the editor answers on Save. */
128
+ export interface ImageEditorResult {
129
+ blob: Blob;
130
+ width: number;
131
+ height: number;
132
+ type: string;
133
+ thumbnail: Blob | null;
134
+ name: string;
135
+ /** What `maxBytes` took (another type, a lower quality 0-1, the size it would have had), or null when nothing. */
136
+ fitted?: {
137
+ maxBytes: number;
138
+ type?: string;
139
+ quality?: number;
140
+ from?: {
141
+ width: number;
142
+ height: number;
143
+ };
144
+ } | null;
145
+ }
146
+ /** One picture of the viewer. */
147
+ export interface ImageViewerItem {
148
+ src: string | Blob;
149
+ title?: string;
150
+ }
151
+ /** The parts of `nexus-image-editor` this package calls. */
152
+ export interface ImageEditorModule {
153
+ openImageEditor(options?: ImageEditorOptions): Promise<ImageEditorResult | null>;
154
+ openImageViewer(options: {
155
+ images: ImageViewerItem[];
156
+ index?: number;
157
+ title?: string;
158
+ }): Promise<void>;
159
+ /** Makes the stored picture without opening the editor: the size clamped, the thumbnail made. `null` edits: as it is. */
160
+ renderImage(src: File | Blob | string, edits: null, options?: Pick<ImageEditorOptions, "maxWidth" | "maxHeight" | "type" | "types" | "quality" | "maxQuality" | "maxBytes" | "thumbnail">): Promise<Omit<ImageEditorResult, "name">>;
161
+ readonly VERSION: string;
162
+ }
@@ -0,0 +1,4 @@
1
+ /** The MIME types of pictures (what a canvas can read back), in the order a file picker offers them. */
2
+ export const PICTURE_TYPES = ["image/jpeg", "image/png", "image/webp"];
3
+ /** Whether a MIME type is a picture this package can show and edit. */
4
+ export const isPictureType = (type) => PICTURE_TYPES.includes(type);