@bigbinary/neeto-fields-frontend 1.0.5 → 1.0.7
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 +82 -6
- package/dist/index.cjs.js +371 -265
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +355 -253
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/types.d.ts +64 -13
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`, `
|
|
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,18 @@ 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
|
|
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.
|
|
322
|
+
12. `fieldContainerClassName`: Class names for styling the `div` containing the
|
|
323
|
+
input field.
|
|
324
|
+
13. `fieldClassName`: Class names for styling the field.
|
|
325
|
+
14. `labelClassName`: Class names for styling the label for fields.
|
|
311
326
|
|
|
312
327
|
#### Usage:
|
|
313
328
|
|
|
@@ -316,7 +331,10 @@ Say the resource over here is a user.
|
|
|
316
331
|
```jsx
|
|
317
332
|
import { FieldValuesContainer } from "@bigbinary/neeto-fields-frontend";
|
|
318
333
|
|
|
334
|
+
const formRefs = useRef({});
|
|
335
|
+
|
|
319
336
|
<FieldValuesContainer
|
|
337
|
+
formRefs={formRefs}
|
|
320
338
|
fieldValues={user.fieldValues} // We expect the user response from host's backend to send associated field_values with it.
|
|
321
339
|
queryKeysToBeInvalidatedOnSuccess={["users"]}
|
|
322
340
|
resourceId={user?.id}
|
|
@@ -344,6 +362,11 @@ the following props:
|
|
|
344
362
|
to that kind using this prop. It takes the kind name as the key and the
|
|
345
363
|
component rendering callback function as the value. The callback function can
|
|
346
364
|
expect the `field` object.
|
|
365
|
+
3. `formRefs`: A React Ref object that can be used to access the Formik context
|
|
366
|
+
of the form.
|
|
367
|
+
4. `disabled`: Boolean value to specify whether to disable all fields.
|
|
368
|
+
5. `isRequiredColumnName`: The name of column which holds the value which
|
|
369
|
+
suggests if a field value is a `required` one or not.
|
|
347
370
|
|
|
348
371
|
> :memo: **_Note:_**
|
|
349
372
|
>
|
|
@@ -363,6 +386,8 @@ import {
|
|
|
363
386
|
neetoFieldsUtils,
|
|
364
387
|
} from "@bigbinary/neeto-fields-frontend";
|
|
365
388
|
|
|
389
|
+
const formRef = useRef();
|
|
390
|
+
|
|
366
391
|
const HostForm = () => {
|
|
367
392
|
const {
|
|
368
393
|
data: { fields },
|
|
@@ -386,7 +411,7 @@ const HostForm = () => {
|
|
|
386
411
|
>
|
|
387
412
|
{/* Other host specific input fields */}
|
|
388
413
|
|
|
389
|
-
<FieldInputs fields={fields} />
|
|
414
|
+
<FieldInputs formRef={formRef} fields={fields} />
|
|
390
415
|
|
|
391
416
|
<Button type="submit" label="Submit" />
|
|
392
417
|
</Form>
|
|
@@ -472,13 +497,64 @@ This is a React Query hook for fetching all the fields.
|
|
|
472
497
|
|
|
473
498
|
```jsx
|
|
474
499
|
const {
|
|
475
|
-
data: { fields },
|
|
500
|
+
data: { fields, count, activeFieldsCount, inactiveFieldsCount },
|
|
476
501
|
} = useFetchFields({
|
|
477
502
|
resourceType: "users",
|
|
478
503
|
ownerId: "ownerId",
|
|
479
504
|
});
|
|
480
505
|
```
|
|
481
506
|
|
|
507
|
+
#### 2. `useShowField`
|
|
508
|
+
|
|
509
|
+
This is a React Query hook for fetching details of a field.
|
|
510
|
+
|
|
511
|
+
#### Argument
|
|
512
|
+
|
|
513
|
+
- `fieldId`: The ID of field for fetching details.
|
|
514
|
+
|
|
515
|
+
#### Usage
|
|
516
|
+
|
|
517
|
+
```jsx
|
|
518
|
+
const {
|
|
519
|
+
data: { field },
|
|
520
|
+
} = useShowField(fieldId);
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
#### 3. `useCreateField`
|
|
524
|
+
|
|
525
|
+
This is a React Query hook for creating a field.
|
|
526
|
+
|
|
527
|
+
#### Usage
|
|
528
|
+
|
|
529
|
+
```jsx
|
|
530
|
+
const { mutate: create } = useCreateField();
|
|
531
|
+
const payload = { name, kind, resourceType, ownerId, data };
|
|
532
|
+
create(payload);
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
#### 4. `useUpdateField`
|
|
536
|
+
|
|
537
|
+
This is a React Query hook for updating a field.
|
|
538
|
+
|
|
539
|
+
#### Usage
|
|
540
|
+
|
|
541
|
+
```jsx
|
|
542
|
+
const { mutate: update } = useUpdateField();
|
|
543
|
+
const payload = { name, kind, resourceType, ownerId, data };
|
|
544
|
+
update({ fieldId, payload });
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
#### 5. `useDestroyField`
|
|
548
|
+
|
|
549
|
+
This is a React Query hook for deleting a field.
|
|
550
|
+
|
|
551
|
+
#### Usage
|
|
552
|
+
|
|
553
|
+
```jsx
|
|
554
|
+
const { mutate: delete } = useDestroyField();
|
|
555
|
+
delete(fieldId)
|
|
556
|
+
```
|
|
557
|
+
|
|
482
558
|
# Customizability
|
|
483
559
|
|
|
484
560
|
## Engine customizability
|