@bigbinary/neeto-fields-frontend 1.0.7 → 1.1.0
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 +35 -18
- package/dist/index.cjs.js +1172 -1147
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +1177 -1152
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/types.d.ts +27 -20
package/README.md
CHANGED
|
@@ -169,7 +169,9 @@ default, but you can customize its behavior by passing optional props.
|
|
|
169
169
|
name as key and the corresponding yup validation schema as the value.
|
|
170
170
|
`initialValues` must also be provided as a map with the field name as key and
|
|
171
171
|
the corresponding value. Prop `hideRequiredSwitch` set to `true` hides the
|
|
172
|
-
toggle switch for `isRequried`.
|
|
172
|
+
toggle switch for `isRequried`. Also `onMutationSuccess`,a callback function
|
|
173
|
+
which is triggered on the success of mutation functions( create, update &
|
|
174
|
+
delete).
|
|
173
175
|
7. `showStateFilter`: Boolean value which specifies whether to show or hide
|
|
174
176
|
state filters.
|
|
175
177
|
8. `fieldStatesTaxonomy`: Specifies the names to be rendered for `active` and
|
|
@@ -251,23 +253,31 @@ import { FieldsDashboard } from "@bigbinary/neeto-fields-frontend";
|
|
|
251
253
|
/>;
|
|
252
254
|
```
|
|
253
255
|
|
|
254
|
-
## 2. `
|
|
256
|
+
## 2. `FieldsPane`
|
|
255
257
|
|
|
256
258
|
<div align="center">
|
|
257
259
|
<img src="https://s11.gifyu.com/images/SWngt.gif" alt="AddField component gif" width="700"/>
|
|
258
260
|
</div>
|
|
259
261
|
|
|
260
|
-
|
|
261
|
-
button is clicked.
|
|
262
|
+
This is the pane which handles the Add / Edit operations of the field.
|
|
262
263
|
|
|
263
264
|
#### Props:
|
|
264
265
|
|
|
265
|
-
1. `
|
|
266
|
+
1. `isOpen`: Boolean state which specifies the open/close state of the pane.
|
|
267
|
+
2. `onClose`: The function to be executed on closing the pane.
|
|
268
|
+
3. `resourceType`: Specifies the resource_type of the field to be created via
|
|
266
269
|
the pane.
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
270
|
+
4. `allowedKinds`: Specifies the list of field kinds allowed to be created.
|
|
271
|
+
5. `children`: Children components for the pane.
|
|
272
|
+
6. `additionalValidations`: Validations for the formik fields in `children`.
|
|
273
|
+
7. `initialValues`: Initial values for the formik fields in `children`.
|
|
274
|
+
8. `selectedField`: The field object whose editing is concerned with. If this
|
|
275
|
+
prop is given, the pane will act as an Edit pane. Else it act as Add pane.
|
|
276
|
+
9. `hideRequiredSwitch`: Specify whether to hide the `Is required` toggle switch
|
|
277
|
+
for field in pane.
|
|
278
|
+
10. `ownerId`: The ID of the owner in case the owner is not an organization.
|
|
279
|
+
11. `onMutationSuccess`: The callback function which is triggered on the success
|
|
280
|
+
of mutation functions( create, update & delete).
|
|
271
281
|
|
|
272
282
|
#### Usage:
|
|
273
283
|
|
|
@@ -300,11 +310,11 @@ specific resource.
|
|
|
300
310
|
1. `resourceType`: The type of resource.
|
|
301
311
|
2. `fieldValues`: Field values associated with the resource obtained from the
|
|
302
312
|
response.
|
|
303
|
-
3. `
|
|
304
|
-
|
|
313
|
+
3. `fields`: Fields associated with resource type. This is an optional prop. If
|
|
314
|
+
not provided the component will fetch the fields internally.
|
|
315
|
+
4. `resourceId`: The ID of the resource.
|
|
316
|
+
5. `ownerId`:The ID of the owner. This prop is required only if the owner is not
|
|
305
317
|
an organization.
|
|
306
|
-
5. `queryKeysToBeInvalidatedOnSuccess`: An array of queryKeys that should be
|
|
307
|
-
invalidated when changing the field value.
|
|
308
318
|
6. `customComponents`: If the host application has any extra `kind` other than
|
|
309
319
|
the supported ones, you can specify the component to be displayed
|
|
310
320
|
corresponding to that kind using this prop. It takes the `kind` name as the
|
|
@@ -323,6 +333,8 @@ specific resource.
|
|
|
323
333
|
input field.
|
|
324
334
|
13. `fieldClassName`: Class names for styling the field.
|
|
325
335
|
14. `labelClassName`: Class names for styling the label for fields.
|
|
336
|
+
15. `onMutationSuccess`: The callback function which is triggered on the success
|
|
337
|
+
of mutation functions( create, update & delete).
|
|
326
338
|
|
|
327
339
|
#### Usage:
|
|
328
340
|
|
|
@@ -332,13 +344,14 @@ Say the resource over here is a user.
|
|
|
332
344
|
import { FieldValuesContainer } from "@bigbinary/neeto-fields-frontend";
|
|
333
345
|
|
|
334
346
|
const formRefs = useRef({});
|
|
347
|
+
const queryClient = useQueryClient();
|
|
335
348
|
|
|
336
349
|
<FieldValuesContainer
|
|
337
350
|
formRefs={formRefs}
|
|
338
351
|
fieldValues={user.fieldValues} // We expect the user response from host's backend to send associated field_values with it.
|
|
339
|
-
queryKeysToBeInvalidatedOnSuccess={["users"]}
|
|
340
352
|
resourceId={user?.id}
|
|
341
353
|
resourceType="users"
|
|
354
|
+
onMutationSuccess={() => queryClient.invalidateQueries(["users"])}
|
|
342
355
|
customComponents={{
|
|
343
356
|
hostSpecificKindName: field => <HostSpecificInputFields />,
|
|
344
357
|
}}
|
|
@@ -511,13 +524,14 @@ This is a React Query hook for fetching details of a field.
|
|
|
511
524
|
#### Argument
|
|
512
525
|
|
|
513
526
|
- `fieldId`: The ID of field for fetching details.
|
|
527
|
+
- `ownerId`: The ID of the owner in case the owner is not an organization.
|
|
514
528
|
|
|
515
529
|
#### Usage
|
|
516
530
|
|
|
517
531
|
```jsx
|
|
518
532
|
const {
|
|
519
533
|
data: { field },
|
|
520
|
-
} = useShowField(fieldId);
|
|
534
|
+
} = useShowField({ fieldId, ownerId });
|
|
521
535
|
```
|
|
522
536
|
|
|
523
537
|
#### 3. `useCreateField`
|
|
@@ -528,7 +542,7 @@ This is a React Query hook for creating a field.
|
|
|
528
542
|
|
|
529
543
|
```jsx
|
|
530
544
|
const { mutate: create } = useCreateField();
|
|
531
|
-
const payload = { name, kind, resourceType, ownerId, data };
|
|
545
|
+
const payload = { field: { name, kind, resourceType, ownerId, data } };
|
|
532
546
|
create(payload);
|
|
533
547
|
```
|
|
534
548
|
|
|
@@ -540,7 +554,7 @@ This is a React Query hook for updating a field.
|
|
|
540
554
|
|
|
541
555
|
```jsx
|
|
542
556
|
const { mutate: update } = useUpdateField();
|
|
543
|
-
const payload = { name, kind, resourceType, ownerId, data };
|
|
557
|
+
const payload = { field: { name, kind, resourceType, ownerId, data } };
|
|
544
558
|
update({ fieldId, payload });
|
|
545
559
|
```
|
|
546
560
|
|
|
@@ -552,9 +566,12 @@ This is a React Query hook for deleting a field.
|
|
|
552
566
|
|
|
553
567
|
```jsx
|
|
554
568
|
const { mutate: delete } = useDestroyField();
|
|
555
|
-
delete(fieldId)
|
|
569
|
+
delete({ fieldId })
|
|
556
570
|
```
|
|
557
571
|
|
|
572
|
+
_Pass the `ownerId` too with the payload in case the owner is not an
|
|
573
|
+
organization._
|
|
574
|
+
|
|
558
575
|
# Customizability
|
|
559
576
|
|
|
560
577
|
## Engine customizability
|