@bigbinary/neeto-fields-frontend 1.0.5 → 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
@@ -164,7 +168,8 @@ default, but you can customize its behavior by passing optional props.
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.
166
170
  `initialValues` must also be provided as a map with the field name as key and
167
- the corresponding value.
171
+ the corresponding value. Prop `hideRequiredSwitch` set to `true` hides the
172
+ toggle switch for `isRequried`.
168
173
  7. `showStateFilter`: Boolean value which specifies whether to show or hide
169
174
  state filters.
170
175
  8. `fieldStatesTaxonomy`: Specifies the names to be rendered for `active` and
@@ -306,8 +311,14 @@ specific resource.
306
311
  key and the component rendering callback function as the value. The callback
307
312
  function can expect the `field` object as argument.
308
313
  7. `className`: Class names for styling.
309
- 8. showBorder: Boolean value to specify whether to show or hide borders. Default
310
- true.
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.
311
322
 
312
323
  #### Usage:
313
324
 
@@ -316,7 +327,10 @@ Say the resource over here is a user.
316
327
  ```jsx
317
328
  import { FieldValuesContainer } from "@bigbinary/neeto-fields-frontend";
318
329
 
330
+ const formRefs = useRef({});
331
+
319
332
  <FieldValuesContainer
333
+ formRefs={formRefs}
320
334
  fieldValues={user.fieldValues} // We expect the user response from host's backend to send associated field_values with it.
321
335
  queryKeysToBeInvalidatedOnSuccess={["users"]}
322
336
  resourceId={user?.id}
@@ -344,6 +358,11 @@ the following props:
344
358
  to that kind using this prop. It takes the kind name as the key and the
345
359
  component rendering callback function as the value. The callback function can
346
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.
347
366
 
348
367
  > :memo: **_Note:_**
349
368
  >
@@ -363,6 +382,8 @@ import {
363
382
  neetoFieldsUtils,
364
383
  } from "@bigbinary/neeto-fields-frontend";
365
384
 
385
+ const formRef = useRef();
386
+
366
387
  const HostForm = () => {
367
388
  const {
368
389
  data: { fields },
@@ -386,7 +407,7 @@ const HostForm = () => {
386
407
  >
387
408
  {/* Other host specific input fields */}
388
409
 
389
- <FieldInputs fields={fields} />
410
+ <FieldInputs formRef={formRef} fields={fields} />
390
411
 
391
412
  <Button type="submit" label="Submit" />
392
413
  </Form>
@@ -472,13 +493,64 @@ This is a React Query hook for fetching all the fields.
472
493
 
473
494
  ```jsx
474
495
  const {
475
- data: { fields },
496
+ data: { fields, count, activeFieldsCount, inactiveFieldsCount },
476
497
  } = useFetchFields({
477
498
  resourceType: "users",
478
499
  ownerId: "ownerId",
479
500
  });
480
501
  ```
481
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
+
482
554
  # Customizability
483
555
 
484
556
  ## Engine customizability