@bsol-oss/react-datatable5 10.0.0 → 11.0.0-beta.1
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 +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +10 -14
- package/dist/index.mjs +10 -14
- package/dist/types/components/Form/Form.d.ts +4 -2
- package/dist/types/components/Form/SchemaFormContext.d.ts +3 -0
- package/dist/types/components/Form/useSchemaContext.d.ts +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { RankingInfo } from '@tanstack/match-sorter-utils';
|
|
|
11
11
|
import { UseQueryResult } from '@tanstack/react-query';
|
|
12
12
|
import { JSONSchema7 } from 'json-schema';
|
|
13
13
|
import { ForeignKeyProps } from '@/components/Form/components/StringInputField';
|
|
14
|
+
import { AxiosRequestConfig } from 'axios';
|
|
14
15
|
import * as react_hook_form from 'react-hook-form';
|
|
15
16
|
import { FieldValues, UseFormReturn, SubmitHandler } from 'react-hook-form';
|
|
16
17
|
import { RenderProps, Props } from '@bsol-oss/dayzed-react19';
|
|
@@ -458,6 +459,7 @@ declare const GlobalFilter: () => react_jsx_runtime.JSX.Element;
|
|
|
458
459
|
interface FormProps<TData extends FieldValues> {
|
|
459
460
|
schema: JSONSchema7;
|
|
460
461
|
serverUrl: string;
|
|
462
|
+
requestUrl?: string;
|
|
461
463
|
idMap: Record<string, object>;
|
|
462
464
|
setIdMap: Dispatch<SetStateAction<Record<string, object>>>;
|
|
463
465
|
form: UseFormReturn;
|
|
@@ -465,8 +467,8 @@ interface FormProps<TData extends FieldValues> {
|
|
|
465
467
|
order?: string[];
|
|
466
468
|
ignore?: string[];
|
|
467
469
|
onSubmit?: SubmitHandler<TData>;
|
|
468
|
-
preLoadedValues?: object;
|
|
469
470
|
rowNumber?: number | string;
|
|
471
|
+
requestOptions?: AxiosRequestConfig;
|
|
470
472
|
}
|
|
471
473
|
interface CustomJSONSchema7Definition extends JSONSchema7 {
|
|
472
474
|
variant: string;
|
|
@@ -477,7 +479,7 @@ interface CustomJSONSchema7Definition extends JSONSchema7 {
|
|
|
477
479
|
gridRow: string;
|
|
478
480
|
foreign_key: ForeignKeyProps;
|
|
479
481
|
}
|
|
480
|
-
declare const Form: <TData extends FieldValues>({ schema, idMap, setIdMap, form, serverUrl, translate, order, ignore, onSubmit,
|
|
482
|
+
declare const Form: <TData extends FieldValues>({ schema, idMap, setIdMap, form, serverUrl, translate, order, ignore, onSubmit, rowNumber, requestOptions, }: FormProps<TData>) => react_jsx_runtime.JSX.Element;
|
|
481
483
|
|
|
482
484
|
interface UseFormProps {
|
|
483
485
|
preLoadedValues?: FieldValues | undefined;
|
package/dist/index.js
CHANGED
|
@@ -3555,11 +3555,12 @@ const ErrorAlert = ({ showMessage = true }) => {
|
|
|
3555
3555
|
const SchemaFormContext = React.createContext({
|
|
3556
3556
|
schema: {},
|
|
3557
3557
|
serverUrl: "",
|
|
3558
|
+
requestUrl: "",
|
|
3558
3559
|
order: [],
|
|
3559
3560
|
ignore: [],
|
|
3560
3561
|
onSubmit: async () => { },
|
|
3561
3562
|
rowNumber: 0,
|
|
3562
|
-
|
|
3563
|
+
requestOptions: {},
|
|
3563
3564
|
});
|
|
3564
3565
|
|
|
3565
3566
|
const PopoverContent = React__namespace.forwardRef(function PopoverContent(props, ref) {
|
|
@@ -3586,10 +3587,11 @@ const Field = React__namespace.forwardRef(function Field(props, ref) {
|
|
|
3586
3587
|
});
|
|
3587
3588
|
|
|
3588
3589
|
const useSchemaContext = () => {
|
|
3589
|
-
const { schema, serverUrl, order, ignore, onSubmit, rowNumber, idMap, setIdMap, translate, } = React.useContext(SchemaFormContext);
|
|
3590
|
+
const { schema, serverUrl, requestUrl, order, ignore, onSubmit, rowNumber, idMap, setIdMap, translate, requestOptions, } = React.useContext(SchemaFormContext);
|
|
3590
3591
|
return {
|
|
3591
3592
|
schema,
|
|
3592
3593
|
serverUrl,
|
|
3594
|
+
requestUrl,
|
|
3593
3595
|
order,
|
|
3594
3596
|
ignore,
|
|
3595
3597
|
onSubmit,
|
|
@@ -3597,6 +3599,7 @@ const useSchemaContext = () => {
|
|
|
3597
3599
|
idMap,
|
|
3598
3600
|
setIdMap,
|
|
3599
3601
|
translate,
|
|
3602
|
+
requestOptions,
|
|
3600
3603
|
};
|
|
3601
3604
|
};
|
|
3602
3605
|
|
|
@@ -3610,10 +3613,6 @@ const getTableData = async ({ serverUrl, in_table, searching = "", where = [], l
|
|
|
3610
3613
|
const options = {
|
|
3611
3614
|
method: "GET",
|
|
3612
3615
|
url: `${serverUrl}/api/g/${in_table}`,
|
|
3613
|
-
headers: {
|
|
3614
|
-
Apikey: "YOUR_SECRET_TOKEN",
|
|
3615
|
-
"Content-Type": "application/json",
|
|
3616
|
-
},
|
|
3617
3616
|
params: {
|
|
3618
3617
|
searching,
|
|
3619
3618
|
where,
|
|
@@ -4541,7 +4540,7 @@ const idPickerSanityCheck = (column, foreign_key) => {
|
|
|
4541
4540
|
}
|
|
4542
4541
|
};
|
|
4543
4542
|
const FormInternal = () => {
|
|
4544
|
-
const { schema,
|
|
4543
|
+
const { schema, requestUrl, order, ignore, onSubmit, rowNumber, idMap, translate, requestOptions, } = useSchemaContext();
|
|
4545
4544
|
const methods = reactHookForm.useFormContext();
|
|
4546
4545
|
const [isSuccess, setIsSuccess] = React.useState(false);
|
|
4547
4546
|
const [isError, setIsError] = React.useState(false);
|
|
@@ -4580,12 +4579,9 @@ const FormInternal = () => {
|
|
|
4580
4579
|
const defaultSubmitPromise = (data) => {
|
|
4581
4580
|
const options = {
|
|
4582
4581
|
method: "POST",
|
|
4583
|
-
url: `${
|
|
4584
|
-
headers: {
|
|
4585
|
-
Apikey: "YOUR_SECRET_TOKEN",
|
|
4586
|
-
"Content-Type": "application/json",
|
|
4587
|
-
},
|
|
4582
|
+
url: `${requestUrl}`,
|
|
4588
4583
|
data: clearEmptyString(data),
|
|
4584
|
+
...requestOptions,
|
|
4589
4585
|
};
|
|
4590
4586
|
return axios.request(options);
|
|
4591
4587
|
};
|
|
@@ -4772,11 +4768,10 @@ const FormInternal = () => {
|
|
|
4772
4768
|
methods.handleSubmit(onValid)();
|
|
4773
4769
|
}, formNoValidate: true, children: translate.t("submit") })] }), isError && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: ["isError", jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [" ", `${error}`] })] }))] }));
|
|
4774
4770
|
};
|
|
4775
|
-
const Form = ({ schema, idMap, setIdMap, form, serverUrl, translate, order = [], ignore = [], onSubmit = undefined,
|
|
4771
|
+
const Form = ({ schema, idMap, setIdMap, form, serverUrl, translate, order = [], ignore = [], onSubmit = undefined, rowNumber = undefined, requestOptions = {}, }) => {
|
|
4776
4772
|
const { properties } = schema;
|
|
4777
4773
|
idListSanityCheck("order", order, properties);
|
|
4778
4774
|
idListSanityCheck("ignore", ignore, properties);
|
|
4779
|
-
idListSanityCheck("preLoadedValues", Object.keys(preLoadedValues), properties);
|
|
4780
4775
|
return (jsxRuntime.jsx(SchemaFormContext.Provider, { value: {
|
|
4781
4776
|
schema,
|
|
4782
4777
|
serverUrl,
|
|
@@ -4788,6 +4783,7 @@ const Form = ({ schema, idMap, setIdMap, form, serverUrl, translate, order = [],
|
|
|
4788
4783
|
idMap,
|
|
4789
4784
|
setIdMap,
|
|
4790
4785
|
translate,
|
|
4786
|
+
requestOptions,
|
|
4791
4787
|
}, children: jsxRuntime.jsx(reactHookForm.FormProvider, { ...form, children: jsxRuntime.jsx(FormInternal, {}) }) }));
|
|
4792
4788
|
};
|
|
4793
4789
|
|
package/dist/index.mjs
CHANGED
|
@@ -3535,11 +3535,12 @@ const ErrorAlert = ({ showMessage = true }) => {
|
|
|
3535
3535
|
const SchemaFormContext = createContext({
|
|
3536
3536
|
schema: {},
|
|
3537
3537
|
serverUrl: "",
|
|
3538
|
+
requestUrl: "",
|
|
3538
3539
|
order: [],
|
|
3539
3540
|
ignore: [],
|
|
3540
3541
|
onSubmit: async () => { },
|
|
3541
3542
|
rowNumber: 0,
|
|
3542
|
-
|
|
3543
|
+
requestOptions: {},
|
|
3543
3544
|
});
|
|
3544
3545
|
|
|
3545
3546
|
const PopoverContent = React.forwardRef(function PopoverContent(props, ref) {
|
|
@@ -3566,10 +3567,11 @@ const Field = React.forwardRef(function Field(props, ref) {
|
|
|
3566
3567
|
});
|
|
3567
3568
|
|
|
3568
3569
|
const useSchemaContext = () => {
|
|
3569
|
-
const { schema, serverUrl, order, ignore, onSubmit, rowNumber, idMap, setIdMap, translate, } = useContext(SchemaFormContext);
|
|
3570
|
+
const { schema, serverUrl, requestUrl, order, ignore, onSubmit, rowNumber, idMap, setIdMap, translate, requestOptions, } = useContext(SchemaFormContext);
|
|
3570
3571
|
return {
|
|
3571
3572
|
schema,
|
|
3572
3573
|
serverUrl,
|
|
3574
|
+
requestUrl,
|
|
3573
3575
|
order,
|
|
3574
3576
|
ignore,
|
|
3575
3577
|
onSubmit,
|
|
@@ -3577,6 +3579,7 @@ const useSchemaContext = () => {
|
|
|
3577
3579
|
idMap,
|
|
3578
3580
|
setIdMap,
|
|
3579
3581
|
translate,
|
|
3582
|
+
requestOptions,
|
|
3580
3583
|
};
|
|
3581
3584
|
};
|
|
3582
3585
|
|
|
@@ -3590,10 +3593,6 @@ const getTableData = async ({ serverUrl, in_table, searching = "", where = [], l
|
|
|
3590
3593
|
const options = {
|
|
3591
3594
|
method: "GET",
|
|
3592
3595
|
url: `${serverUrl}/api/g/${in_table}`,
|
|
3593
|
-
headers: {
|
|
3594
|
-
Apikey: "YOUR_SECRET_TOKEN",
|
|
3595
|
-
"Content-Type": "application/json",
|
|
3596
|
-
},
|
|
3597
3596
|
params: {
|
|
3598
3597
|
searching,
|
|
3599
3598
|
where,
|
|
@@ -4521,7 +4520,7 @@ const idPickerSanityCheck = (column, foreign_key) => {
|
|
|
4521
4520
|
}
|
|
4522
4521
|
};
|
|
4523
4522
|
const FormInternal = () => {
|
|
4524
|
-
const { schema,
|
|
4523
|
+
const { schema, requestUrl, order, ignore, onSubmit, rowNumber, idMap, translate, requestOptions, } = useSchemaContext();
|
|
4525
4524
|
const methods = useFormContext();
|
|
4526
4525
|
const [isSuccess, setIsSuccess] = useState(false);
|
|
4527
4526
|
const [isError, setIsError] = useState(false);
|
|
@@ -4560,12 +4559,9 @@ const FormInternal = () => {
|
|
|
4560
4559
|
const defaultSubmitPromise = (data) => {
|
|
4561
4560
|
const options = {
|
|
4562
4561
|
method: "POST",
|
|
4563
|
-
url: `${
|
|
4564
|
-
headers: {
|
|
4565
|
-
Apikey: "YOUR_SECRET_TOKEN",
|
|
4566
|
-
"Content-Type": "application/json",
|
|
4567
|
-
},
|
|
4562
|
+
url: `${requestUrl}`,
|
|
4568
4563
|
data: clearEmptyString(data),
|
|
4564
|
+
...requestOptions,
|
|
4569
4565
|
};
|
|
4570
4566
|
return axios.request(options);
|
|
4571
4567
|
};
|
|
@@ -4752,11 +4748,10 @@ const FormInternal = () => {
|
|
|
4752
4748
|
methods.handleSubmit(onValid)();
|
|
4753
4749
|
}, formNoValidate: true, children: translate.t("submit") })] }), isError && (jsxs(Fragment, { children: ["isError", jsxs(Fragment, { children: [" ", `${error}`] })] }))] }));
|
|
4754
4750
|
};
|
|
4755
|
-
const Form = ({ schema, idMap, setIdMap, form, serverUrl, translate, order = [], ignore = [], onSubmit = undefined,
|
|
4751
|
+
const Form = ({ schema, idMap, setIdMap, form, serverUrl, translate, order = [], ignore = [], onSubmit = undefined, rowNumber = undefined, requestOptions = {}, }) => {
|
|
4756
4752
|
const { properties } = schema;
|
|
4757
4753
|
idListSanityCheck("order", order, properties);
|
|
4758
4754
|
idListSanityCheck("ignore", ignore, properties);
|
|
4759
|
-
idListSanityCheck("preLoadedValues", Object.keys(preLoadedValues), properties);
|
|
4760
4755
|
return (jsx(SchemaFormContext.Provider, { value: {
|
|
4761
4756
|
schema,
|
|
4762
4757
|
serverUrl,
|
|
@@ -4768,6 +4763,7 @@ const Form = ({ schema, idMap, setIdMap, form, serverUrl, translate, order = [],
|
|
|
4768
4763
|
idMap,
|
|
4769
4764
|
setIdMap,
|
|
4770
4765
|
translate,
|
|
4766
|
+
requestOptions,
|
|
4771
4767
|
}, children: jsx(FormProvider, { ...form, children: jsx(FormInternal, {}) }) }));
|
|
4772
4768
|
};
|
|
4773
4769
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ForeignKeyProps } from "@/components/Form/components/StringInputField";
|
|
2
|
+
import { AxiosRequestConfig } from "axios";
|
|
2
3
|
import { JSONSchema7 } from "json-schema";
|
|
3
4
|
import { Dispatch, SetStateAction } from "react";
|
|
4
5
|
import { FieldValues, SubmitHandler, UseFormReturn } from "react-hook-form";
|
|
@@ -6,6 +7,7 @@ import { UseTranslationResponse } from "react-i18next";
|
|
|
6
7
|
export interface FormProps<TData extends FieldValues> {
|
|
7
8
|
schema: JSONSchema7;
|
|
8
9
|
serverUrl: string;
|
|
10
|
+
requestUrl?: string;
|
|
9
11
|
idMap: Record<string, object>;
|
|
10
12
|
setIdMap: Dispatch<SetStateAction<Record<string, object>>>;
|
|
11
13
|
form: UseFormReturn;
|
|
@@ -13,8 +15,8 @@ export interface FormProps<TData extends FieldValues> {
|
|
|
13
15
|
order?: string[];
|
|
14
16
|
ignore?: string[];
|
|
15
17
|
onSubmit?: SubmitHandler<TData>;
|
|
16
|
-
preLoadedValues?: object;
|
|
17
18
|
rowNumber?: number | string;
|
|
19
|
+
requestOptions?: AxiosRequestConfig;
|
|
18
20
|
}
|
|
19
21
|
export interface CustomJSONSchema7Definition extends JSONSchema7 {
|
|
20
22
|
variant: string;
|
|
@@ -25,4 +27,4 @@ export interface CustomJSONSchema7Definition extends JSONSchema7 {
|
|
|
25
27
|
gridRow: string;
|
|
26
28
|
foreign_key: ForeignKeyProps;
|
|
27
29
|
}
|
|
28
|
-
export declare const Form: <TData extends FieldValues>({ schema, idMap, setIdMap, form, serverUrl, translate, order, ignore, onSubmit,
|
|
30
|
+
export declare const Form: <TData extends FieldValues>({ schema, idMap, setIdMap, form, serverUrl, translate, order, ignore, onSubmit, rowNumber, requestOptions, }: FormProps<TData>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from "axios";
|
|
1
2
|
import { JSONSchema7 } from "json-schema";
|
|
2
3
|
import { Dispatch, SetStateAction } from "react";
|
|
3
4
|
import { FieldValues } from "react-hook-form";
|
|
@@ -5,6 +6,7 @@ import { UseTranslationResponse } from "react-i18next";
|
|
|
5
6
|
export interface SchemaFormContext<TData extends FieldValues> {
|
|
6
7
|
schema: JSONSchema7;
|
|
7
8
|
serverUrl: string;
|
|
9
|
+
requestUrl: string;
|
|
8
10
|
order: string[];
|
|
9
11
|
ignore: string[];
|
|
10
12
|
onSubmit?: (data: TData) => Promise<void>;
|
|
@@ -12,5 +14,6 @@ export interface SchemaFormContext<TData extends FieldValues> {
|
|
|
12
14
|
idMap: Record<string, object>;
|
|
13
15
|
setIdMap: Dispatch<SetStateAction<Record<string, object>>>;
|
|
14
16
|
translate: UseTranslationResponse<any, any>;
|
|
17
|
+
requestOptions: AxiosRequestConfig;
|
|
15
18
|
}
|
|
16
19
|
export declare const SchemaFormContext: import("react").Context<SchemaFormContext<unknown>>;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
export declare const useSchemaContext: () => {
|
|
3
3
|
schema: import("json-schema").JSONSchema7;
|
|
4
4
|
serverUrl: string;
|
|
5
|
+
requestUrl: string;
|
|
5
6
|
order: string[];
|
|
6
7
|
ignore: string[];
|
|
7
8
|
onSubmit: ((data: unknown) => Promise<void>) | undefined;
|
|
@@ -9,4 +10,5 @@ export declare const useSchemaContext: () => {
|
|
|
9
10
|
idMap: Record<string, object>;
|
|
10
11
|
setIdMap: import("react").Dispatch<import("react").SetStateAction<Record<string, object>>>;
|
|
11
12
|
translate: import("react-i18next").UseTranslationResponse<any, any>;
|
|
13
|
+
requestOptions: import("axios").AxiosRequestConfig<any>;
|
|
12
14
|
};
|