@bigbinary/neeto-fields-frontend 1.0.4 → 1.0.6

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
@@ -20,6 +20,10 @@ referred as custom fields) for the resources across neeto products.
20
20
  - [transformValues](#2-neetofieldsutilstransformvalues)
21
21
  - [Hooks](#hooks)
22
22
  - [useFetchFields](#1-usefetchfields)
23
+ - [useShowFields](#2-useshowfield)
24
+ - [useCreateField](#3-usecreatefield)
25
+ - [useUpdateField](#4-useupdatefield)
26
+ - [useDestroyField](#5-usedestroyfield)
23
27
  - [Customizability](#customizability)
24
28
  - [Engine customizability](#engine-customizability)
25
29
  - [Development instructions](#development-instructions)
@@ -45,7 +49,7 @@ referred as custom fields) for the resources across neeto products.
45
49
  `kinds` are:
46
50
 
47
51
  `text`, `number`, `monetary`, `single_option`, `multi_option`, `date`, `time`,
48
- `date_range`, `time_range`, `text_area`, `person`, `checkbox`, `regex`,
52
+ `date_range`, `time_range`, `textarea`, `person`, `checkbox`, `regex`,
49
53
  `integer`, `decimal`, `datetime`.
50
54
 
51
55
  # Installation instructions
@@ -163,6 +167,9 @@ default, but you can customize its behavior by passing optional props.
163
167
  to be rendered inside the pane and `validations` for the formik input fields
164
168
  in the `children`. `validations` must be provided as a map with the field
165
169
  name as key and the corresponding yup validation schema as the value.
170
+ `initialValues` must also be provided as a map with the field name as key and
171
+ the corresponding value. Prop `hideRequiredSwitch` set to `true` hides the
172
+ toggle switch for `isRequried`.
166
173
  7. `showStateFilter`: Boolean value which specifies whether to show or hide
167
174
  state filters.
168
175
  8. `fieldStatesTaxonomy`: Specifies the names to be rendered for `active` and
@@ -194,6 +201,9 @@ import { FieldsDashboard } from "@bigbinary/neeto-fields-frontend";
194
201
  validations: {
195
202
  hostSpecificInputName: validationSchema,
196
203
  },
204
+ initialValues: {
205
+ hostSpecificInputName: initialValue,
206
+ },
197
207
  }}
198
208
  breadcrumbs={[
199
209
  {
@@ -224,6 +234,9 @@ import { FieldsDashboard } from "@bigbinary/neeto-fields-frontend";
224
234
  validations: {
225
235
  hostSpecificInputName: validationSchema,
226
236
  },
237
+ initialValues: {
238
+ hostSpecificInputName: initialValue,
239
+ },
227
240
  }}
228
241
  breadcrumbs={[
229
242
  {
@@ -254,6 +267,7 @@ button is clicked.
254
267
  2. `allowedKinds`: Specifies the list of field kinds allowed to be created.
255
268
  3. `children`: Children components for the pane.
256
269
  4. `additionalValidations`: Validations for the formik fields in `children`.
270
+ 5. `initialValues`: Initial values for the formik fields in `children`.
257
271
 
258
272
  #### Usage:
259
273
 
@@ -266,6 +280,7 @@ import { AddField } from "@biginary/neeto-fields-frontend";
266
280
  additionalValidations={{
267
281
  hostSpecificInputName: validationSchema,
268
282
  }}
283
+ initialValues={{ hostSpecificInputName: initialValue }}
269
284
  >
270
285
  <HostSpecificInputFields />
271
286
  </AddField>;
@@ -296,6 +311,14 @@ specific resource.
296
311
  key and the component rendering callback function as the value. The callback
297
312
  function can expect the `field` object as argument.
298
313
  7. `className`: Class names for styling.
314
+ 8. `showBorder`: Boolean value to specify whether to show or hide borders.
315
+ Default true.
316
+ 9. `formRefs`: A React Ref object that can be used to access the Formik context
317
+ of the forms corresponding to each field as key value pairs.
318
+ 10. `disabled`: Boolean value to specify whether to disable all fields.
319
+ 11. `isRequiredColumnName`: The name of column which holds the value which
320
+ suggests if a field value is a `required` one or not. Default is
321
+ `isRequired` column.
299
322
 
300
323
  #### Usage:
301
324
 
@@ -304,7 +327,10 @@ Say the resource over here is a user.
304
327
  ```jsx
305
328
  import { FieldValuesContainer } from "@bigbinary/neeto-fields-frontend";
306
329
 
330
+ const formRefs = useRef({});
331
+
307
332
  <FieldValuesContainer
333
+ formRefs={formRefs}
308
334
  fieldValues={user.fieldValues} // We expect the user response from host's backend to send associated field_values with it.
309
335
  queryKeysToBeInvalidatedOnSuccess={["users"]}
310
336
  resourceId={user?.id}
@@ -332,6 +358,11 @@ the following props:
332
358
  to that kind using this prop. It takes the kind name as the key and the
333
359
  component rendering callback function as the value. The callback function can
334
360
  expect the `field` object.
361
+ 3. `formRefs`: A React Ref object that can be used to access the Formik context
362
+ of the form.
363
+ 4. `disabled`: Boolean value to specify whether to disable all fields.
364
+ 5. `isRequiredColumnName`: The name of column which holds the value which
365
+ suggests if a field value is a `required` one or not.
335
366
 
336
367
  > :memo: **_Note:_**
337
368
  >
@@ -351,6 +382,8 @@ import {
351
382
  neetoFieldsUtils,
352
383
  } from "@bigbinary/neeto-fields-frontend";
353
384
 
385
+ const formRef = useRef();
386
+
354
387
  const HostForm = () => {
355
388
  const {
356
389
  data: { fields },
@@ -374,7 +407,7 @@ const HostForm = () => {
374
407
  >
375
408
  {/* Other host specific input fields */}
376
409
 
377
- <FieldInputs fields={fields} />
410
+ <FieldInputs formRef={formRef} fields={fields} />
378
411
 
379
412
  <Button type="submit" label="Submit" />
380
413
  </Form>
@@ -460,13 +493,64 @@ This is a React Query hook for fetching all the fields.
460
493
 
461
494
  ```jsx
462
495
  const {
463
- data: { fields },
496
+ data: { fields, count, activeFieldsCount, inactiveFieldsCount },
464
497
  } = useFetchFields({
465
498
  resourceType: "users",
466
499
  ownerId: "ownerId",
467
500
  });
468
501
  ```
469
502
 
503
+ #### 2. `useShowField`
504
+
505
+ This is a React Query hook for fetching details of a field.
506
+
507
+ #### Argument
508
+
509
+ - `fieldId`: The ID of field for fetching details.
510
+
511
+ #### Usage
512
+
513
+ ```jsx
514
+ const {
515
+ data: { field },
516
+ } = useShowField(fieldId);
517
+ ```
518
+
519
+ #### 3. `useCreateField`
520
+
521
+ This is a React Query hook for creating a field.
522
+
523
+ #### Usage
524
+
525
+ ```jsx
526
+ const { mutate: create } = useCreateField();
527
+ const payload = { name, kind, resourceType, ownerId, data };
528
+ create(payload);
529
+ ```
530
+
531
+ #### 4. `useUpdateField`
532
+
533
+ This is a React Query hook for updating a field.
534
+
535
+ #### Usage
536
+
537
+ ```jsx
538
+ const { mutate: update } = useUpdateField();
539
+ const payload = { name, kind, resourceType, ownerId, data };
540
+ update({ fieldId, payload });
541
+ ```
542
+
543
+ #### 5. `useDestroyField`
544
+
545
+ This is a React Query hook for deleting a field.
546
+
547
+ #### Usage
548
+
549
+ ```jsx
550
+ const { mutate: delete } = useDestroyField();
551
+ delete(fieldId)
552
+ ```
553
+
470
554
  # Customizability
471
555
 
472
556
  ## Engine customizability