react-luminus-components 1.0.1 → 1.0.3

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 CHANGED
@@ -1,3 +1,354 @@
1
- ## React Bnf Components
1
+ # React Luminus Components
2
2
 
3
- Library of React Components reusable in bnf projects (Fleetman, CAFM)
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
+ - label?: string
91
+ - withoutLabel?: boolean
92
+ - _doesn't render the floating label when set_
93
+ - placeholder?: string
94
+ - size?: 'sm' | 'lg'
95
+ - hidden?: boolean
96
+ - disabled?: boolean
97
+ - showClearIcon?: boolean
98
+ - _renders an icon which clears the value on click_
99
+ - clearValue?: string | number
100
+ - _clear icon sets this value insted of a default one if specified_
101
+ ***
102
+ - **SelectInput**\
103
+ Just a select input
104
+ - value: string | number | null
105
+ - options?: FormSelectOption[]
106
+ - _the options for the selection (dropdown list)_
107
+ - onChange?: (value: string | number | null) => void
108
+ - label?: string
109
+ - withoutLabel?: boolean
110
+ - _doesn't render the floating label when set_
111
+ - isNumber?: boolean
112
+ - _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_
113
+ - size?: 'sm' | 'lg'
114
+ - hidden?: boolean
115
+ - disabled?: boolean
116
+ - showClearIcon?: boolean
117
+ - _renders an icon which clears the value on click_
118
+ - clearValue?: string | number
119
+ - _clear icon sets this value insted of a default one if specified_
120
+ ***
121
+
122
+ ### Hook Form Inputs
123
+
124
+ Input elements to be used in the react-hook-form, they handle some additional logic.\
125
+ Each requires a hookFormProps prop which is of type HookFormInputProps and contains all the react-hook-form methods neccessary.
126
+
127
+ _register: UseFormRegister<FieldValues>_\
128
+ _formState: FormState<FieldValues>_\
129
+ _getValues: UseFormGetValues<FieldValues>_\
130
+ _setValue: UseFormSetValue<FieldValues>_\
131
+ _watch: UseFormWatch<FieldValues>_
132
+
133
+ Then each component also specifies it's own inputProps (similar to normal input components), listed below
134
+
135
+ - **HookFormEmployeePicker**\
136
+ Just like the EmployeePicker
137
+ - formField: string
138
+ - _the react-hook-form field you register the input to_
139
+ - label: string
140
+ - defaultSelection: NameIdIntModel | null
141
+ - size?: 'sm' | 'lg'
142
+ - resetsFields?: string[]
143
+ - _list of form fields you want to reset when this input's value is changed_
144
+ - hidden?: boolean
145
+ - disabled?: boolean
146
+ ***
147
+ - **HookFormCheckInput**\
148
+ Just a check input
149
+ - formField: string
150
+ - _the react-hook-form field you register the input to_
151
+ - label: string
152
+ - resetsFields?: string[]
153
+ - _list of form fields you want to reset when this input's value is changed_
154
+ - type?: 'switch' | 'checkbox'
155
+ - hidden?: boolean
156
+ - disabled?: boolean
157
+ ***
158
+ - **HookFormRadioInput**\
159
+ Just a radio input
160
+ - formField: string
161
+ - _the react-hook-form field you register the input to_
162
+ - options: NameIdStringModel[]
163
+ - _the radio options_
164
+ - resetsFields?: string[]
165
+ - _list of form fields you want to reset when this input's value is changed_
166
+ - hidden?: boolean
167
+ - disabled?: boolean
168
+ ***
169
+ - **HookFormSelectInput**\
170
+ Just a select input
171
+ - formField: string
172
+ - _the react-hook-form field you register the input to_
173
+ - label: string
174
+ - options: FormSelectOption[]
175
+ - _the options for the selection (dropdown list)_
176
+ - isNumber?: boolean
177
+ - _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_
178
+ - size?: 'sm' | 'lg'
179
+ - resetsFields?: string[]
180
+ - _list of form fields you want to reset when this input's value is changed_
181
+ - showClearIcon?: boolean
182
+ - _renders an icon which clears the value on click_
183
+ - clearValue?: string | number
184
+ - _clear icon sets this value insted of a default one if specified_
185
+ - hidden?: boolean
186
+ - disabled?: boolean
187
+ ***
188
+ - **HookFormTextInput**\
189
+ Just a text input
190
+ - formField: string
191
+ - _the react-hook-form field you register the input to_
192
+ - type: 'text' | 'number' | 'password' | 'date' | 'datetime-local'
193
+ - label: string
194
+ - placeholder?: string
195
+ - size?: 'sm' | 'lg'
196
+ - resetsFields?: string[]
197
+ - _list of form fields you want to reset when this input's value is changed_
198
+ - showClearIcon?: boolean
199
+ - _renders an icon which clears the value on click_
200
+ - clearValue?: string | number
201
+ - _clear icon sets this value insted of a default one if specified_
202
+ - hidden?: boolean
203
+ - disabled?: boolean
204
+ ***
205
+ - **HookFormTextAreaInput**\
206
+ Just a text area input
207
+ - formField: string
208
+ - _the react-hook-form field you register the input to_
209
+ - label: string
210
+ - size?: 'sm' | 'lg'
211
+ - resetsFields?: string[]
212
+ - _list of form fields you want to reset when this input's value is changed_
213
+ - showClearIcon?: boolean
214
+ - _renders an icon which clears the value on click_
215
+ - clearValue?: string | number
216
+ - _clear icon sets this value insted of a default one if specified_
217
+ - hidden?: boolean
218
+ - disabled?: boolean
219
+ ***
220
+
221
+ ### Layout
222
+
223
+ Common layout components
224
+
225
+ - **SideMenu**\
226
+ Renders the side menu with navigation items
227
+ - headerItem: React.ReactNode
228
+ - _renders on top (intersection of SideMenu with TopBar)_
229
+ - mainItems: MenuItemType[]
230
+ - secondaryItems: MenuItemType[]
231
+ - expanded: boolean
232
+ - setExpanded: (expanded: boolean) => void
233
+ ***
234
+ - **TopBar**\
235
+ Renders the top bar with the application name and child items
236
+ - appName: string
237
+ - sideMenuExpanded: boolean
238
+ ***
239
+ - **SideContentBar**\
240
+ Renders the side content bar on the right side, content is sent as children
241
+ - width: number
242
+ ***
243
+ - **MainContainer**\
244
+ The main container for each page
245
+ - sideContent?: React.ReactNode
246
+ - _renders the SideContentBar with this content if specified_
247
+ ***
248
+ - **FullScreenContainer**\
249
+ Container which always spans the whole screen with overflow hidden (you control the scrollbars in your content)
250
+ ***
251
+
252
+ ### Contexts
253
+
254
+ - **LuminusComponentsContext**\
255
+ The app context for this Luminus Components package, you need to include this in your application to work with the Luminus Components.\
256
+ You set all of the text variables displayed by the Luminus Components here, as well as the axiosInstance to enable communication between the API and the Luminus Components
257
+ - axiosInstance: AxiosInstance
258
+ - LinkComponent: React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLAnchorElement>>
259
+ - language: string
260
+ - axiosTexts: AxiosTexts
261
+ - confirmTexts: ConfirmTexts
262
+ - formValidationTexts: FormValidationTexts
263
+ - employeePickerModalTexts: EmployeeSearchModalTexts
264
+ - homeDashboardTexts: HomeDashboardTexts
265
+ ***
266
+ - **LoadingContext**\
267
+ 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
268
+ - isLoading: boolean
269
+ - startLoading: (key: string) => void
270
+ - _you call this whenever you want some loading to start (key is the unique identifier for the loading in question (e.g. loadingVehicleDetail))_
271
+ - stopLoading: (key: string) => void
272
+ - _you call this whenever the loading you triggered previously ends to clear the loading state (you send the same key)_
273
+ ***
274
+ - **UserContext**\
275
+ Keeps track of the currently logged-in user
276
+ - user: UserModel | null
277
+ - loginUser: () => Promise<boolean>
278
+ - logoutUser: () => void
279
+ ***
280
+
281
+ ### Hooks
282
+
283
+ - **useAuth**\
284
+ The authentication process
285
+ - isAuthenticated: () => boolean
286
+ - getToken: () => string | null
287
+ - authenticate: (kid: string, password: string): Promise<boolean>
288
+ - logout: () => void
289
+ ***
290
+ - **useAxios**\
291
+ Sets the axios instance up with some logic (e.g. displaying toasts whenever there's an error response)
292
+ - axiosInstance
293
+ - cancelToken: CancelTokenStatic
294
+ ***
295
+ - **useConfirm**\
296
+ Custom confirm pop-up
297
+ - confirm: (t: string) => Promise<boolean>
298
+ ***
299
+ - **useNotifications**\
300
+ Creates and shows custom toast notifications
301
+ - addNotification: (message: string, type: 'success' | 'warning' | 'danger') => void
302
+ ***
303
+ - **useZodSchemaTypes**\
304
+ Common types for the zod schema you use with the react-hook-form for fluent validation
305
+ - zString
306
+ - _the field is any string_
307
+ - zStringRequired
308
+ - _the field is a required string_
309
+ - zNumber
310
+ - _the field is any number_
311
+ - zNumberRequired
312
+ - _the field is a required number_
313
+ - zBool
314
+ - _the field is a boolean_
315
+ - zDate
316
+ - _the field is a date-string in ISO format_
317
+ - zDateRequired
318
+ - _the field is a required date-string in ISO format_
319
+ - zEnum
320
+ - _the field is an enum value_
321
+ - zEnumRequired
322
+ - _the field is a required enum value_
323
+ - zObjectIdInt
324
+ - _the field is a numeric id of an object (most commonly NameIdIntModel)_
325
+ - zObjectIdIntRequired
326
+ - _the field is a required numeric id of an object (most commonly NameIdIntModel)_
327
+ - zObjectIdStr
328
+ - _the field is a string id of an object (most commonly NameIdStringModel)_
329
+ - zObjectIdStrRequired
330
+ - _the field is a required string id of an object (most commonly NameIdStringModel)_
331
+ ***
332
+
333
+ ### Utils
334
+
335
+ - **Text Utils**
336
+ - **truncateText**: (str: string) => string
337
+ - _truncates text to the first 300 characters_
338
+ ***
339
+ - **Date Utils**
340
+ - **isISODate**: (dateString: string) => boolean
341
+ - _checks if the string is a valid ISO date-string_
342
+ ***
343
+ - **Object Utils**
344
+ - **isPrimitive**: (val: any) => boolean
345
+ - _checks if the value is a primitive (is not object or a function)_
346
+ - **fixNameIdNulls**: (obj: any) => void
347
+ - _modifies the object, sets null where the value is { id = null }_
348
+ ***
349
+ - **Api Error Fields Utils**
350
+ - **extractErrorsFromResponse**: (error: any): ErrorField[]
351
+ - _takes the error api response and return the validation errors as ErrorField[] (if any)_
352
+ - **hookFormSetServerErrors**: (formMethods: any, error: any) => void
353
+ - _sets manual errors to react-hook-form from the error api response_
354
+ ***
@@ -25,18 +25,18 @@
25
25
  "_hasClass-D3KZs5y_.mjs"
26
26
  ]
27
27
  },
28
- "_SimpleTooltip-CqpIzhpc.js": {
29
- "file": "SimpleTooltip-CqpIzhpc.js",
28
+ "_SimpleTooltip-C8wTRZNZ.mjs": {
29
+ "file": "SimpleTooltip-C8wTRZNZ.mjs",
30
30
  "imports": [
31
- "_HomeDashboard.module-BI8obEZ_.js",
32
- "_hasClass-DABt6TfW.js"
31
+ "_HomeDashboard.module-CuVVnp4t.mjs",
32
+ "_hasClass-D3KZs5y_.mjs"
33
33
  ]
34
34
  },
35
- "_SimpleTooltip-vqBAkdBP.mjs": {
36
- "file": "SimpleTooltip-vqBAkdBP.mjs",
35
+ "_SimpleTooltip-HYwwaCn4.js": {
36
+ "file": "SimpleTooltip-HYwwaCn4.js",
37
37
  "imports": [
38
- "_HomeDashboard.module-CuVVnp4t.mjs",
39
- "_hasClass-D3KZs5y_.mjs"
38
+ "_HomeDashboard.module-BI8obEZ_.js",
39
+ "_hasClass-DABt6TfW.js"
40
40
  ]
41
41
  },
42
42
  "_constants-CT2hnPeO.js": {
@@ -101,7 +101,7 @@
101
101
  "isEntry": true,
102
102
  "imports": [
103
103
  "_HomeDashboard.module-BI8obEZ_.js",
104
- "_SimpleTooltip-CqpIzhpc.js",
104
+ "_SimpleTooltip-HYwwaCn4.js",
105
105
  "_hasClass-DABt6TfW.js"
106
106
  ]
107
107
  },
@@ -112,7 +112,7 @@
112
112
  "imports": [
113
113
  "_HomeDashboard.module-BI8obEZ_.js",
114
114
  "_Modal-DmUjIS_Q.js",
115
- "_SimpleTooltip-CqpIzhpc.js",
115
+ "_SimpleTooltip-HYwwaCn4.js",
116
116
  "_constants-CT2hnPeO.js",
117
117
  "_hasClass-DABt6TfW.js"
118
118
  ]