react-luminus-components 2.0.8 → 2.0.10
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.
- package/README.md +349 -349
- package/dist/.vite/manifest.json +44 -44
- package/dist/{FormDisabledProvider-DqonORhL.js → FormDisabledProvider-Bquj6x7m.js} +1 -1
- package/dist/FormDisabledProvider-D7QcTs-i.cjs +1 -0
- package/dist/contexts.cjs.js +1 -1
- package/dist/contexts.es.js +95 -95
- package/dist/hooks.cjs.js +1 -1
- package/dist/hooks.es.js +44 -44
- package/dist/layout.cjs.js +1 -1
- package/dist/layout.es.js +84 -84
- package/dist/{localStorageUtils-CZ4HDRzi.js → localStorageUtils-D2opn367.js} +2 -2
- package/dist/main.cjs.js +15 -15
- package/dist/main.es.js +10484 -10483
- package/dist/nivo-bar-Bak2bSwx.cjs +285 -0
- package/dist/{ShortcutLinksContext-JzYprDew.js → nivo-bar-D1U8PKC8.js} +20555 -20555
- package/dist/style.css +1 -1
- package/dist/{useIsFormDirty-Chttb_yH.js → useIsFormDirty-BBA_uA1C.js} +5 -5
- package/dist/useIsFormDirty-BvvK5I1M.cjs +1 -0
- package/dist/useLocalStorageState-CfodPjK7.cjs +1 -0
- package/dist/{useLocalStorageState-Bhv5Db7O.js → useLocalStorageState-FOtO1MEx.js} +20 -20
- package/dist/utils.cjs.js +1 -1
- package/dist/utils.es.js +22 -22
- package/dist/variables.scss +165 -165
- package/package.json +127 -127
- package/dist/FormDisabledProvider-BbyzT_Cv.cjs +0 -1
- package/dist/ShortcutLinksContext-Bn-HfyvV.cjs +0 -285
- package/dist/useIsFormDirty-Bxcm6YTp.cjs +0 -1
- package/dist/useLocalStorageState-bJ5LCIyw.cjs +0 -1
package/README.md
CHANGED
|
@@ -1,349 +1,349 @@
|
|
|
1
|
-
# React Luminus Components
|
|
2
|
-
|
|
3
|
-
Library of React Components reusable in Luminus projects (Fleetman, CAFM)
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Some Documentation
|
|
8
|
-
|
|
9
|
-
### Components
|
|
10
|
-
|
|
11
|
-
- **Typography**\
|
|
12
|
-
Encapsulated text styles
|
|
13
|
-
- variant: 'h1' | 'h3' | 'h6' | 'subtitle' | 'body' | 'body2' | 'caption'
|
|
14
|
-
***
|
|
15
|
-
- **Loading**\
|
|
16
|
-
Loading indicator
|
|
17
|
-
***
|
|
18
|
-
- **MonthPicker**\
|
|
19
|
-
Month picker, gives you the first day of the picked month
|
|
20
|
-
- month: Date
|
|
21
|
-
- onChangeMonth: (month: Date) => void
|
|
22
|
-
***
|
|
23
|
-
- **HomeDashboard**\
|
|
24
|
-
Dashboard which renders widgets, user can pick his own widgets, reorder them, make some of them full-width...
|
|
25
|
-
- availableWidgets: DashboardWidget[]
|
|
26
|
-
- _set of the widgets available for the specific app/user_
|
|
27
|
-
***
|
|
28
|
-
- **ApiFileDownloadButton**\
|
|
29
|
-
Button which downloads the file from the API and saves it on the device
|
|
30
|
-
- fileLoader: () => Promise<Blob | null>
|
|
31
|
-
- fileName: string
|
|
32
|
-
***
|
|
33
|
-
- **SimpleTooltip**\
|
|
34
|
-
Renders text in a basic tooltip
|
|
35
|
-
- text: string
|
|
36
|
-
- placement: 'top' | 'bottom' | 'left' | 'right'
|
|
37
|
-
***
|
|
38
|
-
- **HtmlTooltip**\
|
|
39
|
-
More advanced tooltip, renders whatever you send as the content, you can also specify the action triggering the tooltip and the header of the tooltip
|
|
40
|
-
- heading: string
|
|
41
|
-
- content: ReactElement
|
|
42
|
-
- placement: 'top' | 'bottom' | 'left' | 'right'
|
|
43
|
-
- trigger?: 'click' | 'hover' | 'focus'
|
|
44
|
-
***
|
|
45
|
-
- **AvatarIcon**\
|
|
46
|
-
Avatar icon with person's initials, generates custom background color based on the person's name
|
|
47
|
-
- name: string
|
|
48
|
-
- fontSize?: number
|
|
49
|
-
- size?: number
|
|
50
|
-
***
|
|
51
|
-
- **UserAvatarDropdown**\
|
|
52
|
-
Renders the AvatarIcon which opens a dropdown of actions on click (suitable for Logout button for example), you send the items as the children
|
|
53
|
-
- userName: string
|
|
54
|
-
***
|
|
55
|
-
- **EmployeeSearch**\
|
|
56
|
-
Searches employees based on the input query, fires onEmployeeSelected on employee click
|
|
57
|
-
- onEmployeeSelected: (employee: EmployeeIndexModel) => void
|
|
58
|
-
***
|
|
59
|
-
- **EmployeeSearchModal**\
|
|
60
|
-
Renders the EmployeeSearch inside of a modal
|
|
61
|
-
- show: boolean
|
|
62
|
-
- onCancel: () => void
|
|
63
|
-
- onEmployeeSelected: (employee: EmployeeIndexModel) => void
|
|
64
|
-
***
|
|
65
|
-
- **EmployeePicker**\
|
|
66
|
-
Renders an input select element with custom logic which opens the EmployeeSearchModal to pick an employee
|
|
67
|
-
- defaultSelection: NameIdIntModel | null
|
|
68
|
-
- onSelect?: (employee: NameIdIntModel | null) => void
|
|
69
|
-
- label?: string
|
|
70
|
-
- withoutLabel?: boolean
|
|
71
|
-
- _doesn't render the floating label when set_
|
|
72
|
-
- size?: 'sm' | 'lg'
|
|
73
|
-
- hidden?: boolean
|
|
74
|
-
- disabled?: boolean
|
|
75
|
-
***
|
|
76
|
-
- **CheckInput**\
|
|
77
|
-
Just a check input
|
|
78
|
-
- value: boolean
|
|
79
|
-
- onChange?: (value: boolean) => void
|
|
80
|
-
- label?: string
|
|
81
|
-
- hidden?: boolean
|
|
82
|
-
- disabled?: boolean
|
|
83
|
-
- type?: 'switch' | 'checkbox'
|
|
84
|
-
***
|
|
85
|
-
- **TextInput**\
|
|
86
|
-
Just a text input
|
|
87
|
-
- type: 'text' | 'number' | 'password' | 'date' | 'datetime-local'
|
|
88
|
-
- value: string | number | null
|
|
89
|
-
- onChange?: (value: string | number | null) => void
|
|
90
|
-
- debounceMs?: number
|
|
91
|
-
- _how long shoulud the input be unchanged before onChange fires_
|
|
92
|
-
- label?: string
|
|
93
|
-
- withoutLabel?: boolean
|
|
94
|
-
- _doesn't render the floating label when set_
|
|
95
|
-
- placeholder?: string
|
|
96
|
-
- size?: 'sm' | 'lg'
|
|
97
|
-
- hidden?: boolean
|
|
98
|
-
- disabled?: boolean
|
|
99
|
-
- showClearIcon?: boolean
|
|
100
|
-
- _renders an icon which clears the value on click_
|
|
101
|
-
- clearValue?: string | number
|
|
102
|
-
- _clear icon sets this value insted of a default one if specified_
|
|
103
|
-
***
|
|
104
|
-
- **SelectInput**\
|
|
105
|
-
Just a select input
|
|
106
|
-
- value: string | number | null
|
|
107
|
-
- options?: FormSelectOption[]
|
|
108
|
-
- _the options for the selection (dropdown list)_
|
|
109
|
-
- onChange?: (value: string | number | null) => void
|
|
110
|
-
- label?: string
|
|
111
|
-
- withoutLabel?: boolean
|
|
112
|
-
- _doesn't render the floating label when set_
|
|
113
|
-
- isNumber?: boolean
|
|
114
|
-
- _you must set this if the input value is numeric, it handles the parsing and sets null if the value is not a valid number_
|
|
115
|
-
- size?: 'sm' | 'lg'
|
|
116
|
-
- hidden?: boolean
|
|
117
|
-
- disabled?: boolean
|
|
118
|
-
- showClearIcon?: boolean
|
|
119
|
-
- _renders an icon which clears the value on click_
|
|
120
|
-
- clearValue?: string | number
|
|
121
|
-
- _clear icon sets this value insted of a default one if specified_
|
|
122
|
-
***
|
|
123
|
-
|
|
124
|
-
### Hook Form Inputs
|
|
125
|
-
|
|
126
|
-
Input elements to be used in the react-hook-form, they handle some additional logic.\
|
|
127
|
-
Each requires a hookFormProps prop which is of type HookFormInputProps and contains all the react-hook-form methods neccessary.
|
|
128
|
-
|
|
129
|
-
_register: UseFormRegister<FieldValues>_\
|
|
130
|
-
_formState: FormState<FieldValues>_\
|
|
131
|
-
_getValues: UseFormGetValues<FieldValues>_\
|
|
132
|
-
_setValue: UseFormSetValue<FieldValues>_\
|
|
133
|
-
_watch: UseFormWatch<FieldValues>_
|
|
134
|
-
|
|
135
|
-
Then each component also specifies it's own inputProps (similar to normal input components), listed below
|
|
136
|
-
|
|
137
|
-
- **HookFormEmployeePicker**\
|
|
138
|
-
Just like the EmployeePicker
|
|
139
|
-
- formField: string
|
|
140
|
-
- _the react-hook-form field you register the input to_
|
|
141
|
-
- label: string
|
|
142
|
-
- defaultSelection: NameIdIntModel | null
|
|
143
|
-
- size?: 'sm' | 'lg'
|
|
144
|
-
- resetsFields?: string[]
|
|
145
|
-
- _list of form fields you want to reset when this input's value is changed_
|
|
146
|
-
- hidden?: boolean
|
|
147
|
-
- disabled?: boolean
|
|
148
|
-
***
|
|
149
|
-
- **HookFormCheckInput**\
|
|
150
|
-
Just a check input
|
|
151
|
-
- formField: string
|
|
152
|
-
- _the react-hook-form field you register the input to_
|
|
153
|
-
- label: string
|
|
154
|
-
- resetsFields?: string[]
|
|
155
|
-
- _list of form fields you want to reset when this input's value is changed_
|
|
156
|
-
- type?: 'switch' | 'checkbox'
|
|
157
|
-
- hidden?: boolean
|
|
158
|
-
- disabled?: boolean
|
|
159
|
-
***
|
|
160
|
-
- **HookFormRadioInput**\
|
|
161
|
-
Just a radio input
|
|
162
|
-
- formField: string
|
|
163
|
-
- _the react-hook-form field you register the input to_
|
|
164
|
-
- options: NameIdStringModel[]
|
|
165
|
-
- _the radio options_
|
|
166
|
-
- resetsFields?: string[]
|
|
167
|
-
- _list of form fields you want to reset when this input's value is changed_
|
|
168
|
-
- hidden?: boolean
|
|
169
|
-
- disabled?: boolean
|
|
170
|
-
***
|
|
171
|
-
- **HookFormSelectInput**\
|
|
172
|
-
Just a select input
|
|
173
|
-
- formField: string
|
|
174
|
-
- _the react-hook-form field you register the input to_
|
|
175
|
-
- label: string
|
|
176
|
-
- options: FormSelectOption[]
|
|
177
|
-
- _the options for the selection (dropdown list)_
|
|
178
|
-
- isNumber?: boolean
|
|
179
|
-
- _you must set this if the input value is numeric, it handles the parsing and sets null if the value is not a valid number_
|
|
180
|
-
- size?: 'sm' | 'lg'
|
|
181
|
-
- resetsFields?: string[]
|
|
182
|
-
- _list of form fields you want to reset when this input's value is changed_
|
|
183
|
-
- showClearIcon?: boolean
|
|
184
|
-
- _renders an icon which clears the value on click_
|
|
185
|
-
- clearValue?: string | number
|
|
186
|
-
- _clear icon sets this value insted of a default one if specified_
|
|
187
|
-
- hidden?: boolean
|
|
188
|
-
- disabled?: boolean
|
|
189
|
-
***
|
|
190
|
-
- **HookFormTextInput**\
|
|
191
|
-
Just a text input
|
|
192
|
-
- formField: string
|
|
193
|
-
- _the react-hook-form field you register the input to_
|
|
194
|
-
- type: 'text' | 'number' | 'password' | 'date' | 'datetime-local'
|
|
195
|
-
- label: string
|
|
196
|
-
- placeholder?: string
|
|
197
|
-
- size?: 'sm' | 'lg'
|
|
198
|
-
- resetsFields?: string[]
|
|
199
|
-
- _list of form fields you want to reset when this input's value is changed_
|
|
200
|
-
- showClearIcon?: boolean
|
|
201
|
-
- _renders an icon which clears the value on click_
|
|
202
|
-
- clearValue?: string | number
|
|
203
|
-
- _clear icon sets this value insted of a default one if specified_
|
|
204
|
-
- hidden?: boolean
|
|
205
|
-
- disabled?: boolean
|
|
206
|
-
***
|
|
207
|
-
- **HookFormTextAreaInput**\
|
|
208
|
-
Just a text area input
|
|
209
|
-
- formField: string
|
|
210
|
-
- _the react-hook-form field you register the input to_
|
|
211
|
-
- label: string
|
|
212
|
-
- size?: 'sm' | 'lg'
|
|
213
|
-
- resetsFields?: string[]
|
|
214
|
-
- _list of form fields you want to reset when this input's value is changed_
|
|
215
|
-
- showClearIcon?: boolean
|
|
216
|
-
- _renders an icon which clears the value on click_
|
|
217
|
-
- clearValue?: string | number
|
|
218
|
-
- _clear icon sets this value insted of a default one if specified_
|
|
219
|
-
- hidden?: boolean
|
|
220
|
-
- disabled?: boolean
|
|
221
|
-
***
|
|
222
|
-
|
|
223
|
-
### Layout
|
|
224
|
-
|
|
225
|
-
Common layout components
|
|
226
|
-
|
|
227
|
-
- **SideMenu**\
|
|
228
|
-
Renders the side menu with navigation items
|
|
229
|
-
- headerItem: React.ReactNode
|
|
230
|
-
- _renders on top (intersection of SideMenu with TopBar)_
|
|
231
|
-
- mainItems: MenuItemType[]
|
|
232
|
-
- secondaryItems: MenuItemType[]
|
|
233
|
-
- expanded: boolean
|
|
234
|
-
- setExpanded: (expanded: boolean) => void
|
|
235
|
-
***
|
|
236
|
-
- **TopBar**\
|
|
237
|
-
Renders the top bar with the application name and child items
|
|
238
|
-
- appName: string
|
|
239
|
-
***
|
|
240
|
-
- **SideContentBar**\
|
|
241
|
-
Renders the side content bar on the right side, content is sent as children
|
|
242
|
-
- width: number
|
|
243
|
-
***
|
|
244
|
-
- **MainContainer**\
|
|
245
|
-
The main container for each page
|
|
246
|
-
- sideContent?: React.ReactNode
|
|
247
|
-
- _renders the SideContentBar with this content if specified_
|
|
248
|
-
***
|
|
249
|
-
- **FullScreenContainer**\
|
|
250
|
-
Container which always spans the whole screen with overflow hidden (you control the scrollbars in your content)
|
|
251
|
-
***
|
|
252
|
-
|
|
253
|
-
### Contexts
|
|
254
|
-
|
|
255
|
-
- **LuminusComponentsContext**\
|
|
256
|
-
The app context for this Luminus Components package, you need to include this in your application to work with the Luminus Components.\
|
|
257
|
-
You set all of the text variables displayed by the Luminus Components here, as well as the axiosOptions to enable communication between the API and the Luminus Components
|
|
258
|
-
- axiosOptions: axiosOptions
|
|
259
|
-
- language: string
|
|
260
|
-
***
|
|
261
|
-
- **LoadingContext**\
|
|
262
|
-
This context help you with the loading state visualisation, it keeps track of all of the loadings happening in the app and displays the Loading indicator whenever there's a loading running
|
|
263
|
-
- isLoading: boolean
|
|
264
|
-
- startLoading: (key: string) => void
|
|
265
|
-
- _you call this whenever you want some loading to start (key is the unique identifier for the loading in question (e.g. loadingVehicleDetail))_
|
|
266
|
-
- stopLoading: (key: string) => void
|
|
267
|
-
- _you call this whenever the loading you triggered previously ends to clear the loading state (you send the same key)_
|
|
268
|
-
***
|
|
269
|
-
- **UserContext**\
|
|
270
|
-
Keeps track of the currently logged-in user
|
|
271
|
-
- user: UserModel | null
|
|
272
|
-
- loginUser: () => Promise<boolean>
|
|
273
|
-
- logoutUser: () => void
|
|
274
|
-
***
|
|
275
|
-
|
|
276
|
-
### Hooks
|
|
277
|
-
|
|
278
|
-
- **useAuth**\
|
|
279
|
-
The authentication process
|
|
280
|
-
- isAuthenticated: () => boolean
|
|
281
|
-
- getToken: () => string | null
|
|
282
|
-
- authenticate: (kid: string, password: string): Promise<boolean>
|
|
283
|
-
- logout: () => void
|
|
284
|
-
***
|
|
285
|
-
- **useAxios**\
|
|
286
|
-
Creates the axios instance with some logic (e.g. displaying toasts whenever there's an error response)
|
|
287
|
-
- axiosInstance
|
|
288
|
-
- cancelToken: CancelTokenStatic
|
|
289
|
-
***
|
|
290
|
-
- **useConfirm**\
|
|
291
|
-
Custom confirm pop-up
|
|
292
|
-
- confirm: (t: string) => Promise<boolean>
|
|
293
|
-
***
|
|
294
|
-
- **useNotifications**\
|
|
295
|
-
Creates and shows custom toast notifications
|
|
296
|
-
- addNotification: (message: string, type: 'success' | 'warning' | 'danger') => void
|
|
297
|
-
***
|
|
298
|
-
- **useZodSchemaTypes**\
|
|
299
|
-
Common types for the zod schema you use with the react-hook-form for fluent validation
|
|
300
|
-
- zString
|
|
301
|
-
- _the field is any string_
|
|
302
|
-
- zStringRequired
|
|
303
|
-
- _the field is a required string_
|
|
304
|
-
- zNumber
|
|
305
|
-
- _the field is any number_
|
|
306
|
-
- zNumberRequired
|
|
307
|
-
- _the field is a required number_
|
|
308
|
-
- zBool
|
|
309
|
-
- _the field is a boolean_
|
|
310
|
-
- zDate
|
|
311
|
-
- _the field is a date-string in ISO format_
|
|
312
|
-
- zDateRequired
|
|
313
|
-
- _the field is a required date-string in ISO format_
|
|
314
|
-
- zEnum
|
|
315
|
-
- _the field is an enum value_
|
|
316
|
-
- zEnumRequired
|
|
317
|
-
- _the field is a required enum value_
|
|
318
|
-
- zObjectIdInt
|
|
319
|
-
- _the field is a numeric id of an object (most commonly NameIdIntModel)_
|
|
320
|
-
- zObjectIdIntRequired
|
|
321
|
-
- _the field is a required numeric id of an object (most commonly NameIdIntModel)_
|
|
322
|
-
- zObjectIdStr
|
|
323
|
-
- _the field is a string id of an object (most commonly NameIdStringModel)_
|
|
324
|
-
- zObjectIdStrRequired
|
|
325
|
-
- _the field is a required string id of an object (most commonly NameIdStringModel)_
|
|
326
|
-
***
|
|
327
|
-
|
|
328
|
-
### Utils
|
|
329
|
-
|
|
330
|
-
- **Text Utils**
|
|
331
|
-
- **truncateText**: (str: string) => string
|
|
332
|
-
- _truncates text to the first 300 characters_
|
|
333
|
-
***
|
|
334
|
-
- **Date Utils**
|
|
335
|
-
- **isISODate**: (dateString: string) => boolean
|
|
336
|
-
- _checks if the string is a valid ISO date-string_
|
|
337
|
-
***
|
|
338
|
-
- **Object Utils**
|
|
339
|
-
- **isPrimitive**: (val: any) => boolean
|
|
340
|
-
- _checks if the value is a primitive (is not object or a function)_
|
|
341
|
-
- **fixNameIdNulls**: (obj: any) => void
|
|
342
|
-
- _modifies the object, sets null where the value is { id = null }_
|
|
343
|
-
***
|
|
344
|
-
- **Api Error Fields Utils**
|
|
345
|
-
- **extractErrorsFromResponse**: (error: any): ErrorField[]
|
|
346
|
-
- _takes the error api response and return the validation errors as ErrorField[] (if any)_
|
|
347
|
-
- **hookFormSetServerErrors**: (formMethods: any, error: any) => void
|
|
348
|
-
- _sets manual errors to react-hook-form from the error api response_
|
|
349
|
-
***
|
|
1
|
+
# React Luminus Components
|
|
2
|
+
|
|
3
|
+
Library of React Components reusable in Luminus projects (Fleetman, CAFM)
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Some Documentation
|
|
8
|
+
|
|
9
|
+
### Components
|
|
10
|
+
|
|
11
|
+
- **Typography**\
|
|
12
|
+
Encapsulated text styles
|
|
13
|
+
- variant: 'h1' | 'h3' | 'h6' | 'subtitle' | 'body' | 'body2' | 'caption'
|
|
14
|
+
***
|
|
15
|
+
- **Loading**\
|
|
16
|
+
Loading indicator
|
|
17
|
+
***
|
|
18
|
+
- **MonthPicker**\
|
|
19
|
+
Month picker, gives you the first day of the picked month
|
|
20
|
+
- month: Date
|
|
21
|
+
- onChangeMonth: (month: Date) => void
|
|
22
|
+
***
|
|
23
|
+
- **HomeDashboard**\
|
|
24
|
+
Dashboard which renders widgets, user can pick his own widgets, reorder them, make some of them full-width...
|
|
25
|
+
- availableWidgets: DashboardWidget[]
|
|
26
|
+
- _set of the widgets available for the specific app/user_
|
|
27
|
+
***
|
|
28
|
+
- **ApiFileDownloadButton**\
|
|
29
|
+
Button which downloads the file from the API and saves it on the device
|
|
30
|
+
- fileLoader: () => Promise<Blob | null>
|
|
31
|
+
- fileName: string
|
|
32
|
+
***
|
|
33
|
+
- **SimpleTooltip**\
|
|
34
|
+
Renders text in a basic tooltip
|
|
35
|
+
- text: string
|
|
36
|
+
- placement: 'top' | 'bottom' | 'left' | 'right'
|
|
37
|
+
***
|
|
38
|
+
- **HtmlTooltip**\
|
|
39
|
+
More advanced tooltip, renders whatever you send as the content, you can also specify the action triggering the tooltip and the header of the tooltip
|
|
40
|
+
- heading: string
|
|
41
|
+
- content: ReactElement
|
|
42
|
+
- placement: 'top' | 'bottom' | 'left' | 'right'
|
|
43
|
+
- trigger?: 'click' | 'hover' | 'focus'
|
|
44
|
+
***
|
|
45
|
+
- **AvatarIcon**\
|
|
46
|
+
Avatar icon with person's initials, generates custom background color based on the person's name
|
|
47
|
+
- name: string
|
|
48
|
+
- fontSize?: number
|
|
49
|
+
- size?: number
|
|
50
|
+
***
|
|
51
|
+
- **UserAvatarDropdown**\
|
|
52
|
+
Renders the AvatarIcon which opens a dropdown of actions on click (suitable for Logout button for example), you send the items as the children
|
|
53
|
+
- userName: string
|
|
54
|
+
***
|
|
55
|
+
- **EmployeeSearch**\
|
|
56
|
+
Searches employees based on the input query, fires onEmployeeSelected on employee click
|
|
57
|
+
- onEmployeeSelected: (employee: EmployeeIndexModel) => void
|
|
58
|
+
***
|
|
59
|
+
- **EmployeeSearchModal**\
|
|
60
|
+
Renders the EmployeeSearch inside of a modal
|
|
61
|
+
- show: boolean
|
|
62
|
+
- onCancel: () => void
|
|
63
|
+
- onEmployeeSelected: (employee: EmployeeIndexModel) => void
|
|
64
|
+
***
|
|
65
|
+
- **EmployeePicker**\
|
|
66
|
+
Renders an input select element with custom logic which opens the EmployeeSearchModal to pick an employee
|
|
67
|
+
- defaultSelection: NameIdIntModel | null
|
|
68
|
+
- onSelect?: (employee: NameIdIntModel | null) => void
|
|
69
|
+
- label?: string
|
|
70
|
+
- withoutLabel?: boolean
|
|
71
|
+
- _doesn't render the floating label when set_
|
|
72
|
+
- size?: 'sm' | 'lg'
|
|
73
|
+
- hidden?: boolean
|
|
74
|
+
- disabled?: boolean
|
|
75
|
+
***
|
|
76
|
+
- **CheckInput**\
|
|
77
|
+
Just a check input
|
|
78
|
+
- value: boolean
|
|
79
|
+
- onChange?: (value: boolean) => void
|
|
80
|
+
- label?: string
|
|
81
|
+
- hidden?: boolean
|
|
82
|
+
- disabled?: boolean
|
|
83
|
+
- type?: 'switch' | 'checkbox'
|
|
84
|
+
***
|
|
85
|
+
- **TextInput**\
|
|
86
|
+
Just a text input
|
|
87
|
+
- type: 'text' | 'number' | 'password' | 'date' | 'datetime-local'
|
|
88
|
+
- value: string | number | null
|
|
89
|
+
- onChange?: (value: string | number | null) => void
|
|
90
|
+
- debounceMs?: number
|
|
91
|
+
- _how long shoulud the input be unchanged before onChange fires_
|
|
92
|
+
- label?: string
|
|
93
|
+
- withoutLabel?: boolean
|
|
94
|
+
- _doesn't render the floating label when set_
|
|
95
|
+
- placeholder?: string
|
|
96
|
+
- size?: 'sm' | 'lg'
|
|
97
|
+
- hidden?: boolean
|
|
98
|
+
- disabled?: boolean
|
|
99
|
+
- showClearIcon?: boolean
|
|
100
|
+
- _renders an icon which clears the value on click_
|
|
101
|
+
- clearValue?: string | number
|
|
102
|
+
- _clear icon sets this value insted of a default one if specified_
|
|
103
|
+
***
|
|
104
|
+
- **SelectInput**\
|
|
105
|
+
Just a select input
|
|
106
|
+
- value: string | number | null
|
|
107
|
+
- options?: FormSelectOption[]
|
|
108
|
+
- _the options for the selection (dropdown list)_
|
|
109
|
+
- onChange?: (value: string | number | null) => void
|
|
110
|
+
- label?: string
|
|
111
|
+
- withoutLabel?: boolean
|
|
112
|
+
- _doesn't render the floating label when set_
|
|
113
|
+
- isNumber?: boolean
|
|
114
|
+
- _you must set this if the input value is numeric, it handles the parsing and sets null if the value is not a valid number_
|
|
115
|
+
- size?: 'sm' | 'lg'
|
|
116
|
+
- hidden?: boolean
|
|
117
|
+
- disabled?: boolean
|
|
118
|
+
- showClearIcon?: boolean
|
|
119
|
+
- _renders an icon which clears the value on click_
|
|
120
|
+
- clearValue?: string | number
|
|
121
|
+
- _clear icon sets this value insted of a default one if specified_
|
|
122
|
+
***
|
|
123
|
+
|
|
124
|
+
### Hook Form Inputs
|
|
125
|
+
|
|
126
|
+
Input elements to be used in the react-hook-form, they handle some additional logic.\
|
|
127
|
+
Each requires a hookFormProps prop which is of type HookFormInputProps and contains all the react-hook-form methods neccessary.
|
|
128
|
+
|
|
129
|
+
_register: UseFormRegister<FieldValues>_\
|
|
130
|
+
_formState: FormState<FieldValues>_\
|
|
131
|
+
_getValues: UseFormGetValues<FieldValues>_\
|
|
132
|
+
_setValue: UseFormSetValue<FieldValues>_\
|
|
133
|
+
_watch: UseFormWatch<FieldValues>_
|
|
134
|
+
|
|
135
|
+
Then each component also specifies it's own inputProps (similar to normal input components), listed below
|
|
136
|
+
|
|
137
|
+
- **HookFormEmployeePicker**\
|
|
138
|
+
Just like the EmployeePicker
|
|
139
|
+
- formField: string
|
|
140
|
+
- _the react-hook-form field you register the input to_
|
|
141
|
+
- label: string
|
|
142
|
+
- defaultSelection: NameIdIntModel | null
|
|
143
|
+
- size?: 'sm' | 'lg'
|
|
144
|
+
- resetsFields?: string[]
|
|
145
|
+
- _list of form fields you want to reset when this input's value is changed_
|
|
146
|
+
- hidden?: boolean
|
|
147
|
+
- disabled?: boolean
|
|
148
|
+
***
|
|
149
|
+
- **HookFormCheckInput**\
|
|
150
|
+
Just a check input
|
|
151
|
+
- formField: string
|
|
152
|
+
- _the react-hook-form field you register the input to_
|
|
153
|
+
- label: string
|
|
154
|
+
- resetsFields?: string[]
|
|
155
|
+
- _list of form fields you want to reset when this input's value is changed_
|
|
156
|
+
- type?: 'switch' | 'checkbox'
|
|
157
|
+
- hidden?: boolean
|
|
158
|
+
- disabled?: boolean
|
|
159
|
+
***
|
|
160
|
+
- **HookFormRadioInput**\
|
|
161
|
+
Just a radio input
|
|
162
|
+
- formField: string
|
|
163
|
+
- _the react-hook-form field you register the input to_
|
|
164
|
+
- options: NameIdStringModel[]
|
|
165
|
+
- _the radio options_
|
|
166
|
+
- resetsFields?: string[]
|
|
167
|
+
- _list of form fields you want to reset when this input's value is changed_
|
|
168
|
+
- hidden?: boolean
|
|
169
|
+
- disabled?: boolean
|
|
170
|
+
***
|
|
171
|
+
- **HookFormSelectInput**\
|
|
172
|
+
Just a select input
|
|
173
|
+
- formField: string
|
|
174
|
+
- _the react-hook-form field you register the input to_
|
|
175
|
+
- label: string
|
|
176
|
+
- options: FormSelectOption[]
|
|
177
|
+
- _the options for the selection (dropdown list)_
|
|
178
|
+
- isNumber?: boolean
|
|
179
|
+
- _you must set this if the input value is numeric, it handles the parsing and sets null if the value is not a valid number_
|
|
180
|
+
- size?: 'sm' | 'lg'
|
|
181
|
+
- resetsFields?: string[]
|
|
182
|
+
- _list of form fields you want to reset when this input's value is changed_
|
|
183
|
+
- showClearIcon?: boolean
|
|
184
|
+
- _renders an icon which clears the value on click_
|
|
185
|
+
- clearValue?: string | number
|
|
186
|
+
- _clear icon sets this value insted of a default one if specified_
|
|
187
|
+
- hidden?: boolean
|
|
188
|
+
- disabled?: boolean
|
|
189
|
+
***
|
|
190
|
+
- **HookFormTextInput**\
|
|
191
|
+
Just a text input
|
|
192
|
+
- formField: string
|
|
193
|
+
- _the react-hook-form field you register the input to_
|
|
194
|
+
- type: 'text' | 'number' | 'password' | 'date' | 'datetime-local'
|
|
195
|
+
- label: string
|
|
196
|
+
- placeholder?: string
|
|
197
|
+
- size?: 'sm' | 'lg'
|
|
198
|
+
- resetsFields?: string[]
|
|
199
|
+
- _list of form fields you want to reset when this input's value is changed_
|
|
200
|
+
- showClearIcon?: boolean
|
|
201
|
+
- _renders an icon which clears the value on click_
|
|
202
|
+
- clearValue?: string | number
|
|
203
|
+
- _clear icon sets this value insted of a default one if specified_
|
|
204
|
+
- hidden?: boolean
|
|
205
|
+
- disabled?: boolean
|
|
206
|
+
***
|
|
207
|
+
- **HookFormTextAreaInput**\
|
|
208
|
+
Just a text area input
|
|
209
|
+
- formField: string
|
|
210
|
+
- _the react-hook-form field you register the input to_
|
|
211
|
+
- label: string
|
|
212
|
+
- size?: 'sm' | 'lg'
|
|
213
|
+
- resetsFields?: string[]
|
|
214
|
+
- _list of form fields you want to reset when this input's value is changed_
|
|
215
|
+
- showClearIcon?: boolean
|
|
216
|
+
- _renders an icon which clears the value on click_
|
|
217
|
+
- clearValue?: string | number
|
|
218
|
+
- _clear icon sets this value insted of a default one if specified_
|
|
219
|
+
- hidden?: boolean
|
|
220
|
+
- disabled?: boolean
|
|
221
|
+
***
|
|
222
|
+
|
|
223
|
+
### Layout
|
|
224
|
+
|
|
225
|
+
Common layout components
|
|
226
|
+
|
|
227
|
+
- **SideMenu**\
|
|
228
|
+
Renders the side menu with navigation items
|
|
229
|
+
- headerItem: React.ReactNode
|
|
230
|
+
- _renders on top (intersection of SideMenu with TopBar)_
|
|
231
|
+
- mainItems: MenuItemType[]
|
|
232
|
+
- secondaryItems: MenuItemType[]
|
|
233
|
+
- expanded: boolean
|
|
234
|
+
- setExpanded: (expanded: boolean) => void
|
|
235
|
+
***
|
|
236
|
+
- **TopBar**\
|
|
237
|
+
Renders the top bar with the application name and child items
|
|
238
|
+
- appName: string
|
|
239
|
+
***
|
|
240
|
+
- **SideContentBar**\
|
|
241
|
+
Renders the side content bar on the right side, content is sent as children
|
|
242
|
+
- width: number
|
|
243
|
+
***
|
|
244
|
+
- **MainContainer**\
|
|
245
|
+
The main container for each page
|
|
246
|
+
- sideContent?: React.ReactNode
|
|
247
|
+
- _renders the SideContentBar with this content if specified_
|
|
248
|
+
***
|
|
249
|
+
- **FullScreenContainer**\
|
|
250
|
+
Container which always spans the whole screen with overflow hidden (you control the scrollbars in your content)
|
|
251
|
+
***
|
|
252
|
+
|
|
253
|
+
### Contexts
|
|
254
|
+
|
|
255
|
+
- **LuminusComponentsContext**\
|
|
256
|
+
The app context for this Luminus Components package, you need to include this in your application to work with the Luminus Components.\
|
|
257
|
+
You set all of the text variables displayed by the Luminus Components here, as well as the axiosOptions to enable communication between the API and the Luminus Components
|
|
258
|
+
- axiosOptions: axiosOptions
|
|
259
|
+
- language: string
|
|
260
|
+
***
|
|
261
|
+
- **LoadingContext**\
|
|
262
|
+
This context help you with the loading state visualisation, it keeps track of all of the loadings happening in the app and displays the Loading indicator whenever there's a loading running
|
|
263
|
+
- isLoading: boolean
|
|
264
|
+
- startLoading: (key: string) => void
|
|
265
|
+
- _you call this whenever you want some loading to start (key is the unique identifier for the loading in question (e.g. loadingVehicleDetail))_
|
|
266
|
+
- stopLoading: (key: string) => void
|
|
267
|
+
- _you call this whenever the loading you triggered previously ends to clear the loading state (you send the same key)_
|
|
268
|
+
***
|
|
269
|
+
- **UserContext**\
|
|
270
|
+
Keeps track of the currently logged-in user
|
|
271
|
+
- user: UserModel | null
|
|
272
|
+
- loginUser: () => Promise<boolean>
|
|
273
|
+
- logoutUser: () => void
|
|
274
|
+
***
|
|
275
|
+
|
|
276
|
+
### Hooks
|
|
277
|
+
|
|
278
|
+
- **useAuth**\
|
|
279
|
+
The authentication process
|
|
280
|
+
- isAuthenticated: () => boolean
|
|
281
|
+
- getToken: () => string | null
|
|
282
|
+
- authenticate: (kid: string, password: string): Promise<boolean>
|
|
283
|
+
- logout: () => void
|
|
284
|
+
***
|
|
285
|
+
- **useAxios**\
|
|
286
|
+
Creates the axios instance with some logic (e.g. displaying toasts whenever there's an error response)
|
|
287
|
+
- axiosInstance
|
|
288
|
+
- cancelToken: CancelTokenStatic
|
|
289
|
+
***
|
|
290
|
+
- **useConfirm**\
|
|
291
|
+
Custom confirm pop-up
|
|
292
|
+
- confirm: (t: string) => Promise<boolean>
|
|
293
|
+
***
|
|
294
|
+
- **useNotifications**\
|
|
295
|
+
Creates and shows custom toast notifications
|
|
296
|
+
- addNotification: (message: string, type: 'success' | 'warning' | 'danger') => void
|
|
297
|
+
***
|
|
298
|
+
- **useZodSchemaTypes**\
|
|
299
|
+
Common types for the zod schema you use with the react-hook-form for fluent validation
|
|
300
|
+
- zString
|
|
301
|
+
- _the field is any string_
|
|
302
|
+
- zStringRequired
|
|
303
|
+
- _the field is a required string_
|
|
304
|
+
- zNumber
|
|
305
|
+
- _the field is any number_
|
|
306
|
+
- zNumberRequired
|
|
307
|
+
- _the field is a required number_
|
|
308
|
+
- zBool
|
|
309
|
+
- _the field is a boolean_
|
|
310
|
+
- zDate
|
|
311
|
+
- _the field is a date-string in ISO format_
|
|
312
|
+
- zDateRequired
|
|
313
|
+
- _the field is a required date-string in ISO format_
|
|
314
|
+
- zEnum
|
|
315
|
+
- _the field is an enum value_
|
|
316
|
+
- zEnumRequired
|
|
317
|
+
- _the field is a required enum value_
|
|
318
|
+
- zObjectIdInt
|
|
319
|
+
- _the field is a numeric id of an object (most commonly NameIdIntModel)_
|
|
320
|
+
- zObjectIdIntRequired
|
|
321
|
+
- _the field is a required numeric id of an object (most commonly NameIdIntModel)_
|
|
322
|
+
- zObjectIdStr
|
|
323
|
+
- _the field is a string id of an object (most commonly NameIdStringModel)_
|
|
324
|
+
- zObjectIdStrRequired
|
|
325
|
+
- _the field is a required string id of an object (most commonly NameIdStringModel)_
|
|
326
|
+
***
|
|
327
|
+
|
|
328
|
+
### Utils
|
|
329
|
+
|
|
330
|
+
- **Text Utils**
|
|
331
|
+
- **truncateText**: (str: string) => string
|
|
332
|
+
- _truncates text to the first 300 characters_
|
|
333
|
+
***
|
|
334
|
+
- **Date Utils**
|
|
335
|
+
- **isISODate**: (dateString: string) => boolean
|
|
336
|
+
- _checks if the string is a valid ISO date-string_
|
|
337
|
+
***
|
|
338
|
+
- **Object Utils**
|
|
339
|
+
- **isPrimitive**: (val: any) => boolean
|
|
340
|
+
- _checks if the value is a primitive (is not object or a function)_
|
|
341
|
+
- **fixNameIdNulls**: (obj: any) => void
|
|
342
|
+
- _modifies the object, sets null where the value is { id = null }_
|
|
343
|
+
***
|
|
344
|
+
- **Api Error Fields Utils**
|
|
345
|
+
- **extractErrorsFromResponse**: (error: any): ErrorField[]
|
|
346
|
+
- _takes the error api response and return the validation errors as ErrorField[] (if any)_
|
|
347
|
+
- **hookFormSetServerErrors**: (formMethods: any, error: any) => void
|
|
348
|
+
- _sets manual errors to react-hook-form from the error api response_
|
|
349
|
+
***
|