@bsol-oss/react-datatable5 11.0.0-beta.8 → 11.0.0-beta.9

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/dist/index.d.ts CHANGED
@@ -467,6 +467,7 @@ interface FormProps<TData extends FieldValues> {
467
467
  translate: UseTranslationResponse<any, any>;
468
468
  order?: string[];
469
469
  ignore?: string[];
470
+ include?: string[];
470
471
  onSubmit?: SubmitHandler<TData>;
471
472
  rowNumber?: number | string;
472
473
  requestOptions?: AxiosRequestConfig;
@@ -485,7 +486,7 @@ declare const idPickerSanityCheck: (column: string, foreign_key?: {
485
486
  column?: string | undefined;
486
487
  display_column?: string | undefined;
487
488
  } | undefined) => void;
488
- declare const Form: <TData extends FieldValues>({ schema, idMap, setIdMap, form, serverUrl, translate, order, ignore, onSubmit, rowNumber, requestOptions, }: FormProps<TData>) => react_jsx_runtime.JSX.Element;
489
+ declare const Form: <TData extends FieldValues>({ schema, idMap, setIdMap, form, serverUrl, translate, order, ignore, include, onSubmit, rowNumber, requestOptions, }: FormProps<TData>) => react_jsx_runtime.JSX.Element;
489
490
 
490
491
  interface UseFormProps {
491
492
  preLoadedValues?: FieldValues | undefined;
package/dist/index.js CHANGED
@@ -3548,26 +3548,14 @@ const SchemaFormContext = React.createContext({
3548
3548
  requestUrl: "",
3549
3549
  order: [],
3550
3550
  ignore: [],
3551
+ include: [],
3551
3552
  onSubmit: async () => { },
3552
3553
  rowNumber: 0,
3553
3554
  requestOptions: {},
3554
3555
  });
3555
3556
 
3556
3557
  const useSchemaContext = () => {
3557
- const { schema, serverUrl, requestUrl, order, ignore, onSubmit, rowNumber, idMap, setIdMap, translate, requestOptions, } = React.useContext(SchemaFormContext);
3558
- return {
3559
- schema,
3560
- serverUrl,
3561
- requestUrl,
3562
- order,
3563
- ignore,
3564
- onSubmit,
3565
- rowNumber,
3566
- idMap,
3567
- setIdMap,
3568
- translate,
3569
- requestOptions,
3570
- };
3558
+ return React.useContext(SchemaFormContext);
3571
3559
  };
3572
3560
 
3573
3561
  const clearEmptyString = (object) => {
@@ -4950,7 +4938,7 @@ const idPickerSanityCheck = (column, foreign_key) => {
4950
4938
  }
4951
4939
  };
4952
4940
  const FormInternal = () => {
4953
- const { schema, requestUrl, order, onSubmit, rowNumber, translate, requestOptions, } = useSchemaContext();
4941
+ const { schema, requestUrl, order, ignore, include, onSubmit, rowNumber, translate, requestOptions, } = useSchemaContext();
4954
4942
  const methods = reactHookForm.useFormContext();
4955
4943
  const [isSuccess, setIsSuccess] = React.useState(false);
4956
4944
  const [isError, setIsError] = React.useState(false);
@@ -5009,11 +4997,19 @@ const FormInternal = () => {
5009
4997
  setIsError(false);
5010
4998
  setIsConfirming(true);
5011
4999
  };
5012
- const renderOrder = (order, origin_list) => {
5013
- const not_exist = origin_list.filter((columnA) => !order.some((columnB) => columnA === columnB));
5014
- return [...order, ...not_exist];
5000
+ const renderColumns = ({ order, keys, ignore, include, }) => {
5001
+ const included = include.length > 0 ? include : keys;
5002
+ const not_exist = included.filter((columnA) => !order.some((columnB) => columnA === columnB));
5003
+ const ordered = [...order, ...not_exist];
5004
+ const ignored = ordered.filter((column) => !ignore.some((shouldIgnore) => column === shouldIgnore));
5005
+ return ignored;
5015
5006
  };
5016
- const ordered = renderOrder(order, Object.keys(properties));
5007
+ const ordered = renderColumns({
5008
+ order,
5009
+ keys: Object.keys(properties),
5010
+ ignore,
5011
+ include,
5012
+ });
5017
5013
  if (isSuccess) {
5018
5014
  return (jsxRuntime.jsxs(react.Grid, { gap: 2, children: [jsxRuntime.jsx(react.Heading, { children: translate.t("title") }), jsxRuntime.jsxs(react.Alert.Root, { status: "success", children: [jsxRuntime.jsx(react.Alert.Indicator, {}), jsxRuntime.jsx(react.Alert.Title, { children: translate.t("submitSuccess") })] }), jsxRuntime.jsx(react.Flex, { justifyContent: "end", children: jsxRuntime.jsx(Button, { onClick: () => {
5019
5015
  setIsError(false);
@@ -5049,7 +5045,7 @@ const FormInternal = () => {
5049
5045
  methods.handleSubmit(onValid)();
5050
5046
  }, formNoValidate: true, children: translate.t("submit") })] })] }) }));
5051
5047
  };
5052
- const Form = ({ schema, idMap, setIdMap, form, serverUrl, translate, order = [], ignore = [], onSubmit = undefined, rowNumber = undefined, requestOptions = {}, }) => {
5048
+ const Form = ({ schema, idMap, setIdMap, form, serverUrl, translate, order = [], ignore = [], include = [], onSubmit = undefined, rowNumber = undefined, requestOptions = {}, }) => {
5053
5049
  const { properties } = schema;
5054
5050
  idListSanityCheck("order", order, properties);
5055
5051
  idListSanityCheck("ignore", ignore, properties);
@@ -5058,6 +5054,7 @@ const Form = ({ schema, idMap, setIdMap, form, serverUrl, translate, order = [],
5058
5054
  serverUrl,
5059
5055
  order,
5060
5056
  ignore,
5057
+ include,
5061
5058
  // @ts-expect-error TODO: find appropriate types
5062
5059
  onSubmit,
5063
5060
  rowNumber,
package/dist/index.mjs CHANGED
@@ -3528,26 +3528,14 @@ const SchemaFormContext = createContext({
3528
3528
  requestUrl: "",
3529
3529
  order: [],
3530
3530
  ignore: [],
3531
+ include: [],
3531
3532
  onSubmit: async () => { },
3532
3533
  rowNumber: 0,
3533
3534
  requestOptions: {},
3534
3535
  });
3535
3536
 
3536
3537
  const useSchemaContext = () => {
3537
- const { schema, serverUrl, requestUrl, order, ignore, onSubmit, rowNumber, idMap, setIdMap, translate, requestOptions, } = useContext(SchemaFormContext);
3538
- return {
3539
- schema,
3540
- serverUrl,
3541
- requestUrl,
3542
- order,
3543
- ignore,
3544
- onSubmit,
3545
- rowNumber,
3546
- idMap,
3547
- setIdMap,
3548
- translate,
3549
- requestOptions,
3550
- };
3538
+ return useContext(SchemaFormContext);
3551
3539
  };
3552
3540
 
3553
3541
  const clearEmptyString = (object) => {
@@ -4930,7 +4918,7 @@ const idPickerSanityCheck = (column, foreign_key) => {
4930
4918
  }
4931
4919
  };
4932
4920
  const FormInternal = () => {
4933
- const { schema, requestUrl, order, onSubmit, rowNumber, translate, requestOptions, } = useSchemaContext();
4921
+ const { schema, requestUrl, order, ignore, include, onSubmit, rowNumber, translate, requestOptions, } = useSchemaContext();
4934
4922
  const methods = useFormContext();
4935
4923
  const [isSuccess, setIsSuccess] = useState(false);
4936
4924
  const [isError, setIsError] = useState(false);
@@ -4989,11 +4977,19 @@ const FormInternal = () => {
4989
4977
  setIsError(false);
4990
4978
  setIsConfirming(true);
4991
4979
  };
4992
- const renderOrder = (order, origin_list) => {
4993
- const not_exist = origin_list.filter((columnA) => !order.some((columnB) => columnA === columnB));
4994
- return [...order, ...not_exist];
4980
+ const renderColumns = ({ order, keys, ignore, include, }) => {
4981
+ const included = include.length > 0 ? include : keys;
4982
+ const not_exist = included.filter((columnA) => !order.some((columnB) => columnA === columnB));
4983
+ const ordered = [...order, ...not_exist];
4984
+ const ignored = ordered.filter((column) => !ignore.some((shouldIgnore) => column === shouldIgnore));
4985
+ return ignored;
4995
4986
  };
4996
- const ordered = renderOrder(order, Object.keys(properties));
4987
+ const ordered = renderColumns({
4988
+ order,
4989
+ keys: Object.keys(properties),
4990
+ ignore,
4991
+ include,
4992
+ });
4997
4993
  if (isSuccess) {
4998
4994
  return (jsxs(Grid, { gap: 2, children: [jsx(Heading, { children: translate.t("title") }), jsxs(Alert.Root, { status: "success", children: [jsx(Alert.Indicator, {}), jsx(Alert.Title, { children: translate.t("submitSuccess") })] }), jsx(Flex, { justifyContent: "end", children: jsx(Button, { onClick: () => {
4999
4995
  setIsError(false);
@@ -5029,7 +5025,7 @@ const FormInternal = () => {
5029
5025
  methods.handleSubmit(onValid)();
5030
5026
  }, formNoValidate: true, children: translate.t("submit") })] })] }) }));
5031
5027
  };
5032
- const Form = ({ schema, idMap, setIdMap, form, serverUrl, translate, order = [], ignore = [], onSubmit = undefined, rowNumber = undefined, requestOptions = {}, }) => {
5028
+ const Form = ({ schema, idMap, setIdMap, form, serverUrl, translate, order = [], ignore = [], include = [], onSubmit = undefined, rowNumber = undefined, requestOptions = {}, }) => {
5033
5029
  const { properties } = schema;
5034
5030
  idListSanityCheck("order", order, properties);
5035
5031
  idListSanityCheck("ignore", ignore, properties);
@@ -5038,6 +5034,7 @@ const Form = ({ schema, idMap, setIdMap, form, serverUrl, translate, order = [],
5038
5034
  serverUrl,
5039
5035
  order,
5040
5036
  ignore,
5037
+ include,
5041
5038
  // @ts-expect-error TODO: find appropriate types
5042
5039
  onSubmit,
5043
5040
  rowNumber,
@@ -14,6 +14,7 @@ export interface FormProps<TData extends FieldValues> {
14
14
  translate: UseTranslationResponse<any, any>;
15
15
  order?: string[];
16
16
  ignore?: string[];
17
+ include?: string[];
17
18
  onSubmit?: SubmitHandler<TData>;
18
19
  rowNumber?: number | string;
19
20
  requestOptions?: AxiosRequestConfig;
@@ -32,4 +33,4 @@ export declare const idPickerSanityCheck: (column: string, foreign_key?: {
32
33
  column?: string | undefined;
33
34
  display_column?: string | undefined;
34
35
  } | undefined) => void;
35
- 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;
36
+ export declare const Form: <TData extends FieldValues>({ schema, idMap, setIdMap, form, serverUrl, translate, order, ignore, include, onSubmit, rowNumber, requestOptions, }: FormProps<TData>) => import("react/jsx-runtime").JSX.Element;
@@ -9,6 +9,7 @@ export interface SchemaFormContext<TData extends FieldValues> {
9
9
  requestUrl: string;
10
10
  order: string[];
11
11
  ignore: string[];
12
+ include: string[];
12
13
  onSubmit?: (data: TData) => Promise<void>;
13
14
  rowNumber?: number | string;
14
15
  idMap: Record<string, object>;
@@ -1,14 +1,2 @@
1
- /// <reference types="react" />
2
- export declare const useSchemaContext: () => {
3
- schema: import("json-schema").JSONSchema7;
4
- serverUrl: string;
5
- requestUrl: string;
6
- order: string[];
7
- ignore: string[];
8
- onSubmit: ((data: unknown) => Promise<void>) | undefined;
9
- rowNumber: string | number | undefined;
10
- idMap: Record<string, object>;
11
- setIdMap: import("react").Dispatch<import("react").SetStateAction<Record<string, object>>>;
12
- translate: import("react-i18next").UseTranslationResponse<any, any>;
13
- requestOptions: import("axios").AxiosRequestConfig<any>;
14
- };
1
+ import { SchemaFormContext } from "./SchemaFormContext";
2
+ export declare const useSchemaContext: () => SchemaFormContext<unknown>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsol-oss/react-datatable5",
3
- "version": "11.0.0-beta.8",
3
+ "version": "11.0.0-beta.9",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -49,12 +49,11 @@
49
49
  "react": "^19.0.0",
50
50
  "react-dom": "^19.0.0",
51
51
  "react-hook-form": "^7.54.2",
52
+ "react-i18next": "^15.4.1",
52
53
  "react-icons": "^5.4.0",
53
- "tiny-invariant": "^1.3.3",
54
- "react-i18next": "^15.4.1"
54
+ "tiny-invariant": "^1.3.3"
55
55
  },
56
56
  "devDependencies": {
57
- "@chromatic-com/storybook": "^3.2.3",
58
57
  "@rollup/plugin-alias": "^5.1.1",
59
58
  "@rollup/plugin-typescript": "^11.1.6",
60
59
  "@storybook/addon-essentials": "^8.4.7",