fastapi-rtk 0.2.6 → 0.2.8
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/.bundled/jsonforms/cjs/packages/jsonforms/src/hooks/useContextProps.cjs +1 -1
- package/dist/.bundled/jsonforms/cjs/packages/jsonforms/src/layouts/MantineCategorizationLayoutRenderer.cjs +63 -0
- package/dist/.bundled/jsonforms/cjs/packages/jsonforms/src/layouts/MantineGroupLayoutRenderer.cjs +3 -3
- package/dist/.bundled/jsonforms/cjs/packages/jsonforms/src/layouts/MantineHotizontalLayoutRenderer.cjs +2 -2
- package/dist/.bundled/jsonforms/cjs/packages/jsonforms/src/layouts/MantineVerticalLayoutRenderer.cjs +3 -3
- package/dist/.bundled/jsonforms/cjs/packages/jsonforms/src/renderers/mantineRenderers.cjs +2 -0
- package/dist/.bundled/jsonforms/esm/packages/jsonforms/src/hooks/useContextProps.mjs +1 -1
- package/dist/.bundled/jsonforms/esm/packages/jsonforms/src/layouts/MantineCategorizationLayoutRenderer.mjs +63 -0
- package/dist/.bundled/jsonforms/esm/packages/jsonforms/src/layouts/MantineGroupLayoutRenderer.mjs +3 -3
- package/dist/.bundled/jsonforms/esm/packages/jsonforms/src/layouts/MantineHotizontalLayoutRenderer.mjs +2 -2
- package/dist/.bundled/jsonforms/esm/packages/jsonforms/src/layouts/MantineVerticalLayoutRenderer.mjs +3 -3
- package/dist/.bundled/jsonforms/esm/packages/jsonforms/src/renderers/mantineRenderers.mjs +2 -0
- package/dist/core/cjs/Tables/NextGenDataGrid/NextGenDataGrid.cjs +1 -2
- package/dist/core/cjs/Tables/NextGenDataGrid/hooks/useColumns/Body.cjs +4 -5
- package/dist/core/cjs/Tables/NextGenDataGrid/hooks/useColumns/ColumnHeaderFilterInput/ColumnHeaderFilterInput.cjs +1 -2
- package/dist/core/cjs/Tables/NextGenDataGrid/hooks/useColumns/FilterModeDescription.cjs +2 -2
- package/dist/core/cjs/Tables/NextGenDataGrid/hooks/useColumns/useColumns.cjs +9 -9
- package/dist/core/cjs/Tables/NextGenDataGrid/utils.cjs +0 -3
- package/dist/core/cjs/Wrappers/ApiProvider/ApiProvider.cjs +1 -1
- package/dist/core/cjs/Wrappers/ApiProvider/Contexts/ApiContext.cjs +4 -40
- package/dist/core/cjs/Wrappers/ApiProvider/Contexts/BulkActionsContext.cjs +6 -11
- package/dist/core/cjs/Wrappers/ApiProvider/Contexts/FormContext.cjs +11 -38
- package/dist/core/cjs/Wrappers/Provider/Contexts/AuthContext.cjs +4 -19
- package/dist/core/cjs/Wrappers/Provider/Contexts/InfoContext.cjs +4 -14
- package/dist/core/cjs/Wrappers/Provider/Provider.cjs +1 -1
- package/dist/core/cjs/hooks/api/useApi.cjs +1 -8
- package/dist/core/cjs/hooks/api/useBulkActions.cjs +1 -8
- package/dist/core/cjs/hooks/api/useForms.cjs +4 -8
- package/dist/core/cjs/hooks/auth/useAuth.cjs +1 -4
- package/dist/core/cjs/hooks/auth/useInfo.cjs +1 -4
- package/dist/core/esm/Tables/NextGenDataGrid/NextGenDataGrid.mjs +2 -3
- package/dist/core/esm/Tables/NextGenDataGrid/hooks/useColumns/Body.mjs +2 -3
- package/dist/core/esm/Tables/NextGenDataGrid/hooks/useColumns/ColumnHeaderFilterInput/ColumnHeaderFilterInput.mjs +2 -3
- package/dist/core/esm/Tables/NextGenDataGrid/hooks/useColumns/FilterModeDescription.mjs +2 -2
- package/dist/core/esm/Tables/NextGenDataGrid/hooks/useColumns/useColumns.mjs +5 -5
- package/dist/core/esm/Tables/NextGenDataGrid/utils.mjs +1 -4
- package/dist/core/esm/Wrappers/ApiProvider/ApiProvider.mjs +4 -4
- package/dist/core/esm/Wrappers/ApiProvider/Contexts/ApiContext.mjs +4 -40
- package/dist/core/esm/Wrappers/ApiProvider/Contexts/BulkActionsContext.mjs +6 -11
- package/dist/core/esm/Wrappers/ApiProvider/Contexts/FormContext.mjs +11 -38
- package/dist/core/esm/Wrappers/Provider/Contexts/AuthContext.mjs +4 -19
- package/dist/core/esm/Wrappers/Provider/Contexts/InfoContext.mjs +4 -14
- package/dist/core/esm/Wrappers/Provider/Provider.mjs +3 -3
- package/dist/core/esm/hooks/api/useApi.mjs +2 -9
- package/dist/core/esm/hooks/api/useBulkActions.mjs +2 -9
- package/dist/core/esm/hooks/api/useForms.mjs +5 -9
- package/dist/core/esm/hooks/auth/useAuth.mjs +2 -5
- package/dist/core/esm/hooks/auth/useInfo.mjs +2 -5
- package/dist/core/lib/Tables/NextGenDataGrid/hooks/useData.d.ts +1 -1
- package/dist/core/lib/Tables/NextGenDataGrid/utils.d.ts +0 -1
- package/dist/core/lib/Wrappers/ApiProvider/Contexts/ApiContext.d.ts +4 -131
- package/dist/core/lib/Wrappers/ApiProvider/Contexts/BulkActionsContext.d.ts +4 -27
- package/dist/core/lib/Wrappers/ApiProvider/Contexts/FormContext.d.ts +8 -28
- package/dist/core/lib/Wrappers/Provider/Contexts/AuthContext.d.ts +4 -28
- package/dist/core/lib/Wrappers/Provider/Contexts/InfoContext.d.ts +4 -21
- package/dist/core/lib/hooks/api/useApi.d.ts +415 -61
- package/dist/core/lib/hooks/api/useBulkActions.d.ts +25 -8
- package/dist/core/lib/hooks/api/useForms.d.ts +72 -13
- package/dist/core/lib/hooks/auth/useAuth.d.ts +80 -17
- package/dist/core/lib/hooks/auth/useInfo.d.ts +51 -9
- package/dist/jsonforms/cjs/hooks/useContextProps.cjs +1 -1
- package/dist/jsonforms/cjs/layouts/MantineCategorizationLayoutRenderer.cjs +63 -0
- package/dist/jsonforms/cjs/layouts/MantineGroupLayoutRenderer.cjs +3 -3
- package/dist/jsonforms/cjs/layouts/MantineHotizontalLayoutRenderer.cjs +2 -2
- package/dist/jsonforms/cjs/layouts/MantineVerticalLayoutRenderer.cjs +3 -3
- package/dist/jsonforms/cjs/renderers/mantineRenderers.cjs +2 -0
- package/dist/jsonforms/esm/hooks/useContextProps.mjs +1 -1
- package/dist/jsonforms/esm/layouts/MantineCategorizationLayoutRenderer.mjs +63 -0
- package/dist/jsonforms/esm/layouts/MantineGroupLayoutRenderer.mjs +3 -3
- package/dist/jsonforms/esm/layouts/MantineHotizontalLayoutRenderer.mjs +2 -2
- package/dist/jsonforms/esm/layouts/MantineVerticalLayoutRenderer.mjs +3 -3
- package/dist/jsonforms/esm/renderers/mantineRenderers.mjs +2 -0
- package/dist/jsonforms/lib/layouts/MantineCategorizationLayoutRenderer.d.ts +2 -0
- package/dist/jsonforms/lib/renderers/mantineRenderers.d.ts +3 -9
- package/dist/utils/cjs/createSafeContext/createSafeContext.cjs +17 -0
- package/dist/utils/cjs/getByPath/getByPath.cjs +4 -0
- package/dist/utils/cjs/index.cjs +6 -0
- package/dist/utils/cjs/mergeProps/mergeProps.cjs +6 -0
- package/dist/utils/esm/createSafeContext/createSafeContext.mjs +17 -0
- package/dist/utils/esm/getByPath/getByPath.mjs +4 -0
- package/dist/utils/esm/index.mjs +6 -0
- package/dist/utils/esm/mergeProps/mergeProps.mjs +6 -0
- package/dist/utils/lib/createSafeContext/createSafeContext.d.ts +14 -0
- package/dist/utils/lib/createSafeContext/index.d.ts +1 -0
- package/dist/utils/lib/getByPath/getByPath.d.ts +1 -0
- package/dist/utils/lib/getByPath/index.d.ts +1 -0
- package/dist/utils/lib/index.d.ts +3 -0
- package/dist/utils/lib/mergeProps/index.d.ts +1 -0
- package/dist/utils/lib/mergeProps/mergeProps.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,23 +1,86 @@
|
|
|
1
|
-
export function useAuth():
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
export function useAuth(options: SafeContextOptions): AuthContext;
|
|
2
|
+
export type SafeContextOptions = {
|
|
3
|
+
/**
|
|
4
|
+
* - Whether to throw an error if the context is not provided.
|
|
5
|
+
*/
|
|
6
|
+
throwOnError?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* - The default value to return if the context is not provided.
|
|
9
|
+
*/
|
|
10
|
+
defaultValue?: any;
|
|
11
|
+
};
|
|
12
|
+
export type AuthUser = {
|
|
13
|
+
/**
|
|
14
|
+
* - The unique identifier of the authenticated user.
|
|
15
|
+
*/
|
|
16
|
+
id: number;
|
|
17
|
+
/**
|
|
18
|
+
* - The username of the authenticated user.
|
|
19
|
+
*/
|
|
20
|
+
username: string;
|
|
21
|
+
/**
|
|
22
|
+
* - The email of the authenticated user.
|
|
23
|
+
*/
|
|
24
|
+
email: string;
|
|
25
|
+
/**
|
|
26
|
+
* - The first name of the authenticated user.
|
|
27
|
+
*/
|
|
28
|
+
first_name: string;
|
|
29
|
+
/**
|
|
30
|
+
* - The last name of the authenticated user.
|
|
31
|
+
*/
|
|
32
|
+
last_name: string;
|
|
33
|
+
/**
|
|
34
|
+
* - Indicates whether the user account is active.
|
|
35
|
+
*/
|
|
36
|
+
is_active: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* - An array of permissions assigned to the user.
|
|
39
|
+
*/
|
|
40
|
+
permissions: string[];
|
|
41
|
+
/**
|
|
42
|
+
* - An array of roles assigned to the user.
|
|
43
|
+
*/
|
|
44
|
+
roles: string[];
|
|
45
|
+
};
|
|
46
|
+
export type AuthContext = {
|
|
47
|
+
/**
|
|
48
|
+
* - The authenticated user object, or null if not authenticated.
|
|
49
|
+
*/
|
|
50
|
+
user: AuthUser | null;
|
|
51
|
+
/**
|
|
52
|
+
* - Indicates whether the authentication state is currently loading.
|
|
53
|
+
*/
|
|
12
54
|
loading: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* - An error object if the authentication request failed.
|
|
57
|
+
*/
|
|
13
58
|
error: {
|
|
14
59
|
message: string;
|
|
15
60
|
originalError: Error;
|
|
16
61
|
} | null;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
62
|
+
/**
|
|
63
|
+
* - A function to sign in the user with a username and password.
|
|
64
|
+
*/
|
|
65
|
+
signin: (username: string, password: string) => Promise<AuthUser | null>;
|
|
66
|
+
/**
|
|
67
|
+
* - A function to sign out the user.
|
|
68
|
+
*/
|
|
69
|
+
signout: () => Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* - A function to update the authenticated user's data.
|
|
72
|
+
*/
|
|
73
|
+
update: (data: Record<string, any>) => Promise<AuthUser>;
|
|
74
|
+
/**
|
|
75
|
+
* - A function to reset the user's password.
|
|
76
|
+
*/
|
|
77
|
+
resetPassword: (password: string) => Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* - A function to sign in the user using OAuth with a specified provider. If `popup` is true, it opens a popup window for the OAuth flow.
|
|
80
|
+
*/
|
|
81
|
+
oauth_signin: (provider: string, popup?: boolean) => Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* - A function to refetch the authenticated user's data.
|
|
84
|
+
*/
|
|
85
|
+
refetch: () => Promise<void>;
|
|
23
86
|
};
|
|
@@ -1,14 +1,56 @@
|
|
|
1
|
-
export function useInfo():
|
|
1
|
+
export function useInfo(options: SafeContextOptions): InfoContext;
|
|
2
|
+
export type SafeContextOptions = {
|
|
3
|
+
/**
|
|
4
|
+
* - Whether to throw an error if the context is not provided.
|
|
5
|
+
*/
|
|
6
|
+
throwOnError?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* - The default value to return if the context is not provided.
|
|
9
|
+
*/
|
|
10
|
+
defaultValue?: any;
|
|
11
|
+
};
|
|
12
|
+
export type Info = {
|
|
13
|
+
/**
|
|
14
|
+
* - The icon associated with the API.
|
|
15
|
+
*/
|
|
16
|
+
icon: string;
|
|
17
|
+
/**
|
|
18
|
+
* - The level of the API.
|
|
19
|
+
*/
|
|
20
|
+
level: string;
|
|
21
|
+
/**
|
|
22
|
+
* - The name of the API.
|
|
23
|
+
*/
|
|
24
|
+
name: string;
|
|
25
|
+
/**
|
|
26
|
+
* - The path of the API.
|
|
27
|
+
*/
|
|
28
|
+
path: string;
|
|
29
|
+
/**
|
|
30
|
+
* - The permission name associated with the API.
|
|
31
|
+
*/
|
|
32
|
+
permission_name: string;
|
|
33
|
+
/**
|
|
34
|
+
* - The type of the API.
|
|
35
|
+
*/
|
|
36
|
+
type: string;
|
|
37
|
+
};
|
|
38
|
+
export type InfoContext = {
|
|
39
|
+
/**
|
|
40
|
+
* - The base URL for the API.
|
|
41
|
+
*/
|
|
2
42
|
baseUrl: string;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}[] | null;
|
|
43
|
+
/**
|
|
44
|
+
* - An array of Info objects or null if not available.
|
|
45
|
+
*/
|
|
46
|
+
info: Info[] | null;
|
|
47
|
+
/**
|
|
48
|
+
* - Indicates whether the info is currently loading.
|
|
49
|
+
*/
|
|
11
50
|
loading: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* - An error object if the info request failed.
|
|
53
|
+
*/
|
|
12
54
|
error: {
|
|
13
55
|
message: string;
|
|
14
56
|
originalError: Error;
|
|
@@ -5,7 +5,7 @@ const utils = require("fastapi-rtk/utils");
|
|
|
5
5
|
const core$1 = require("@mantine/core");
|
|
6
6
|
const React = require("react");
|
|
7
7
|
function useContextProps(name, path, componentProps, jsonFormsProps, withAllProps = true) {
|
|
8
|
-
const { specialKey } = core.useApi();
|
|
8
|
+
const { specialKey } = core.useApi({ throwOnError: false });
|
|
9
9
|
const allProps = core$1.useProps((specialKey == null ? void 0 : specialKey.all) || "all", {}, {});
|
|
10
10
|
const _componentProps = core$1.useProps(name, {}, {});
|
|
11
11
|
const contextProps = core$1.useProps(path, {}, {});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const utils = require("fastapi-rtk/utils");
|
|
5
|
+
const core = require("@jsonforms/core");
|
|
6
|
+
const react = require("@jsonforms/react");
|
|
7
|
+
const core$1 = require("@mantine/core");
|
|
8
|
+
const React = require("react");
|
|
9
|
+
const useContextProps = require("../hooks/useContextProps.cjs");
|
|
10
|
+
const layout = require("../utils/layout.cjs");
|
|
11
|
+
const ComponentTab = ({ value, jsonFormsProps, ...props }) => {
|
|
12
|
+
const [, _props] = useContextProps.useContextProps(
|
|
13
|
+
`Categorization.Tab`,
|
|
14
|
+
`Categorization.Tab.${value}`,
|
|
15
|
+
{ value },
|
|
16
|
+
jsonFormsProps,
|
|
17
|
+
false
|
|
18
|
+
);
|
|
19
|
+
const mergedProps = React.useMemo(() => utils.deepMerge(props, _props), [props, _props]);
|
|
20
|
+
return /* @__PURE__ */ jsxRuntime.jsx(core$1.Tabs.Tab, { value, ...mergedProps, children: value });
|
|
21
|
+
};
|
|
22
|
+
const ComponentPanel = ({ value, jsonFormsProps, children, ...props }) => {
|
|
23
|
+
const [, _props] = useContextProps.useContextProps(
|
|
24
|
+
`Categorization.Panel`,
|
|
25
|
+
`Categorization.Panel.${value}`,
|
|
26
|
+
{ value },
|
|
27
|
+
jsonFormsProps,
|
|
28
|
+
false
|
|
29
|
+
);
|
|
30
|
+
const mergedProps = React.useMemo(() => utils.deepMerge(props, _props), [props, _props]);
|
|
31
|
+
return /* @__PURE__ */ jsxRuntime.jsx(core$1.Tabs.Panel, { value, ...mergedProps, children });
|
|
32
|
+
};
|
|
33
|
+
const Component = (props) => {
|
|
34
|
+
var _a;
|
|
35
|
+
const { schema, uischema, path, enabled, visible, renderers, cells, data } = props;
|
|
36
|
+
const _categorization = uischema;
|
|
37
|
+
const _categories = React.useMemo(
|
|
38
|
+
() => _categorization.elements.filter((category) => core.isVisible(category, data)),
|
|
39
|
+
[_categorization.elements, data]
|
|
40
|
+
);
|
|
41
|
+
const [_value, setValue] = React.useState(((_a = _categories == null ? void 0 : _categories[0]) == null ? void 0 : _a.label) ?? "");
|
|
42
|
+
let componentProps = { categorization: _categorization, categories: _categories, value: _value, onChange: setValue };
|
|
43
|
+
const contextPath = `Categorization.[${componentProps.categorization.elements.map((c) => c.label).join("|")}]`;
|
|
44
|
+
const [, _props] = useContextProps.useContextProps(`Categorization`, contextPath, componentProps, props, false);
|
|
45
|
+
componentProps = { ...componentProps, ..._props };
|
|
46
|
+
const { categorization, categories, value, onChange, listProps, tabProps, panelProps, ...rest } = componentProps;
|
|
47
|
+
const categoryLabels = React.useMemo(() => categories.map((category) => category.label), [categories]);
|
|
48
|
+
React.useEffect(() => {
|
|
49
|
+
var _a2;
|
|
50
|
+
if (!categoryLabels.includes(value)) {
|
|
51
|
+
onChange(((_a2 = categories == null ? void 0 : categories[0]) == null ? void 0 : _a2.label) ?? "");
|
|
52
|
+
}
|
|
53
|
+
}, [categoryLabels]);
|
|
54
|
+
const childProps = { schema, path, enabled, visible, direction: "column" };
|
|
55
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(core$1.Tabs, { value, onChange, m: "0.5rem", mx: "calc(0.5rem + 2px)", ...rest, children: [
|
|
56
|
+
/* @__PURE__ */ jsxRuntime.jsx(core$1.Tabs.List, { ...listProps, children: categoryLabels.map((label) => /* @__PURE__ */ jsxRuntime.jsx(ComponentTab, { value: label, jsonFormsProps: props, ...tabProps }, label)) }),
|
|
57
|
+
categories.map((category) => /* @__PURE__ */ jsxRuntime.jsx(ComponentPanel, { value: category.label, jsonFormsProps: props, ...panelProps, children: /* @__PURE__ */ jsxRuntime.jsx(layout.MantineLayoutRenderer, { ...childProps, elements: category.elements, renderers, cells }) }, category.label))
|
|
58
|
+
] });
|
|
59
|
+
};
|
|
60
|
+
const MantineCategorizationLayoutTester = core.rankWith(1, core.uiTypeIs("Categorization"));
|
|
61
|
+
const MantineCategorizationLayoutRenderer = react.withJsonFormsLayoutProps(Component);
|
|
62
|
+
exports.MantineCategorizationLayoutRenderer = MantineCategorizationLayoutRenderer;
|
|
63
|
+
exports.MantineCategorizationLayoutTester = MantineCategorizationLayoutTester;
|
|
@@ -5,9 +5,9 @@ const core = require("@jsonforms/core");
|
|
|
5
5
|
const react = require("@jsonforms/react");
|
|
6
6
|
const core$1 = require("@mantine/core");
|
|
7
7
|
const layout = require("../utils/layout.cjs");
|
|
8
|
-
const Component = ({
|
|
9
|
-
const
|
|
10
|
-
const childProps = { visible, elements:
|
|
8
|
+
const Component = ({ schema, uischema, path, enabled, visible, renderers, cells, label }) => {
|
|
9
|
+
const layout$1 = uischema;
|
|
10
|
+
const childProps = { schema, path, enabled, visible, elements: layout$1.elements, direction: "column" };
|
|
11
11
|
return /* @__PURE__ */ jsxRuntime.jsx(core$1.Fieldset, { legend: label, m: "0.5rem", mx: "calc(0.5rem + 2px)", children: /* @__PURE__ */ jsxRuntime.jsx(layout.MantineLayoutRenderer, { ...childProps, renderers, cells }) });
|
|
12
12
|
};
|
|
13
13
|
const MantineGroupLayoutTester = core.rankWith(1, core.uiTypeIs("Group"));
|
|
@@ -4,9 +4,9 @@ const jsxRuntime = require("react/jsx-runtime");
|
|
|
4
4
|
const core = require("@jsonforms/core");
|
|
5
5
|
const react = require("@jsonforms/react");
|
|
6
6
|
const layout = require("../utils/layout.cjs");
|
|
7
|
-
const Component = ({
|
|
7
|
+
const Component = ({ schema, uischema, path, enabled, visible, renderers, cells }) => {
|
|
8
8
|
const layout$1 = uischema;
|
|
9
|
-
const childProps = { visible, elements: layout$1.elements,
|
|
9
|
+
const childProps = { schema, path, enabled, visible, elements: layout$1.elements, direction: "row" };
|
|
10
10
|
return /* @__PURE__ */ jsxRuntime.jsx(layout.MantineLayoutRenderer, { ...childProps, renderers, cells });
|
|
11
11
|
};
|
|
12
12
|
const mantineHorizontalLayoutTester = core.rankWith(1, core.uiTypeIs("HorizontalLayout"));
|
|
@@ -4,9 +4,9 @@ const jsxRuntime = require("react/jsx-runtime");
|
|
|
4
4
|
const core = require("@jsonforms/core");
|
|
5
5
|
const react = require("@jsonforms/react");
|
|
6
6
|
const layout = require("../utils/layout.cjs");
|
|
7
|
-
const Component = ({
|
|
8
|
-
const
|
|
9
|
-
const childProps = { visible, elements:
|
|
7
|
+
const Component = ({ schema, uischema, path, enabled, visible, renderers, cells }) => {
|
|
8
|
+
const layout$1 = uischema;
|
|
9
|
+
const childProps = { schema, path, enabled, visible, elements: layout$1.elements, direction: "column" };
|
|
10
10
|
return /* @__PURE__ */ jsxRuntime.jsx(layout.MantineLayoutRenderer, { ...childProps, renderers, cells });
|
|
11
11
|
};
|
|
12
12
|
const mantineVerticalLayoutTester = core.rankWith(1, core.uiTypeIs("VerticalLayout"));
|
|
@@ -16,6 +16,7 @@ const MantineOneOfEnumControl = require("../controls/MantineOneOfEnumControl.cjs
|
|
|
16
16
|
const MantineTextControl = require("../controls/MantineTextControl.cjs");
|
|
17
17
|
const MantineTimeControl = require("../controls/MantineTimeControl.cjs");
|
|
18
18
|
const MantineLabelRenderer = require("../labels/MantineLabelRenderer.cjs");
|
|
19
|
+
const MantineCategorizationLayoutRenderer = require("../layouts/MantineCategorizationLayoutRenderer.cjs");
|
|
19
20
|
const MantineGroupLayoutRenderer = require("../layouts/MantineGroupLayoutRenderer.cjs");
|
|
20
21
|
const MantineHotizontalLayoutRenderer = require("../layouts/MantineHotizontalLayoutRenderer.cjs");
|
|
21
22
|
const MantineVerticalLayoutRenderer = require("../layouts/MantineVerticalLayoutRenderer.cjs");
|
|
@@ -41,6 +42,7 @@ const mantineRenderers = [
|
|
|
41
42
|
{ tester: MantineHotizontalLayoutRenderer.mantineHorizontalLayoutTester, renderer: MantineHotizontalLayoutRenderer.MantineHorizontalLayoutRenderer },
|
|
42
43
|
{ tester: MantineVerticalLayoutRenderer.mantineVerticalLayoutTester, renderer: MantineVerticalLayoutRenderer.MantineVerticalLayoutRenderer },
|
|
43
44
|
{ tester: MantineGroupLayoutRenderer.MantineGroupLayoutTester, renderer: MantineGroupLayoutRenderer.MantineGroupLayoutRenderer },
|
|
45
|
+
{ tester: MantineCategorizationLayoutRenderer.MantineCategorizationLayoutTester, renderer: MantineCategorizationLayoutRenderer.MantineCategorizationLayoutRenderer },
|
|
44
46
|
// Labels
|
|
45
47
|
{ tester: MantineLabelRenderer.MantineLabelTester, renderer: MantineLabelRenderer.MantineLabelRenderer }
|
|
46
48
|
];
|
|
@@ -3,7 +3,7 @@ import { deepMerge, parseFromValuesOrFunc } from "fastapi-rtk/utils";
|
|
|
3
3
|
import { useProps } from "@mantine/core";
|
|
4
4
|
import { useMemo } from "react";
|
|
5
5
|
function useContextProps(name, path, componentProps, jsonFormsProps, withAllProps = true) {
|
|
6
|
-
const { specialKey } = useApi();
|
|
6
|
+
const { specialKey } = useApi({ throwOnError: false });
|
|
7
7
|
const allProps = useProps((specialKey == null ? void 0 : specialKey.all) || "all", {}, {});
|
|
8
8
|
const _componentProps = useProps(name, {}, {});
|
|
9
9
|
const contextProps = useProps(path, {}, {});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { deepMerge } from "fastapi-rtk/utils";
|
|
3
|
+
import { rankWith, uiTypeIs, isVisible } from "@jsonforms/core";
|
|
4
|
+
import { withJsonFormsLayoutProps } from "@jsonforms/react";
|
|
5
|
+
import { Tabs } from "@mantine/core";
|
|
6
|
+
import { useMemo, useState, useEffect } from "react";
|
|
7
|
+
import { useContextProps } from "../hooks/useContextProps.mjs";
|
|
8
|
+
import { MantineLayoutRenderer } from "../utils/layout.mjs";
|
|
9
|
+
const ComponentTab = ({ value, jsonFormsProps, ...props }) => {
|
|
10
|
+
const [, _props] = useContextProps(
|
|
11
|
+
`Categorization.Tab`,
|
|
12
|
+
`Categorization.Tab.${value}`,
|
|
13
|
+
{ value },
|
|
14
|
+
jsonFormsProps,
|
|
15
|
+
false
|
|
16
|
+
);
|
|
17
|
+
const mergedProps = useMemo(() => deepMerge(props, _props), [props, _props]);
|
|
18
|
+
return /* @__PURE__ */ jsx(Tabs.Tab, { value, ...mergedProps, children: value });
|
|
19
|
+
};
|
|
20
|
+
const ComponentPanel = ({ value, jsonFormsProps, children, ...props }) => {
|
|
21
|
+
const [, _props] = useContextProps(
|
|
22
|
+
`Categorization.Panel`,
|
|
23
|
+
`Categorization.Panel.${value}`,
|
|
24
|
+
{ value },
|
|
25
|
+
jsonFormsProps,
|
|
26
|
+
false
|
|
27
|
+
);
|
|
28
|
+
const mergedProps = useMemo(() => deepMerge(props, _props), [props, _props]);
|
|
29
|
+
return /* @__PURE__ */ jsx(Tabs.Panel, { value, ...mergedProps, children });
|
|
30
|
+
};
|
|
31
|
+
const Component = (props) => {
|
|
32
|
+
var _a;
|
|
33
|
+
const { schema, uischema, path, enabled, visible, renderers, cells, data } = props;
|
|
34
|
+
const _categorization = uischema;
|
|
35
|
+
const _categories = useMemo(
|
|
36
|
+
() => _categorization.elements.filter((category) => isVisible(category, data)),
|
|
37
|
+
[_categorization.elements, data]
|
|
38
|
+
);
|
|
39
|
+
const [_value, setValue] = useState(((_a = _categories == null ? void 0 : _categories[0]) == null ? void 0 : _a.label) ?? "");
|
|
40
|
+
let componentProps = { categorization: _categorization, categories: _categories, value: _value, onChange: setValue };
|
|
41
|
+
const contextPath = `Categorization.[${componentProps.categorization.elements.map((c) => c.label).join("|")}]`;
|
|
42
|
+
const [, _props] = useContextProps(`Categorization`, contextPath, componentProps, props, false);
|
|
43
|
+
componentProps = { ...componentProps, ..._props };
|
|
44
|
+
const { categorization, categories, value, onChange, listProps, tabProps, panelProps, ...rest } = componentProps;
|
|
45
|
+
const categoryLabels = useMemo(() => categories.map((category) => category.label), [categories]);
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
var _a2;
|
|
48
|
+
if (!categoryLabels.includes(value)) {
|
|
49
|
+
onChange(((_a2 = categories == null ? void 0 : categories[0]) == null ? void 0 : _a2.label) ?? "");
|
|
50
|
+
}
|
|
51
|
+
}, [categoryLabels]);
|
|
52
|
+
const childProps = { schema, path, enabled, visible, direction: "column" };
|
|
53
|
+
return /* @__PURE__ */ jsxs(Tabs, { value, onChange, m: "0.5rem", mx: "calc(0.5rem + 2px)", ...rest, children: [
|
|
54
|
+
/* @__PURE__ */ jsx(Tabs.List, { ...listProps, children: categoryLabels.map((label) => /* @__PURE__ */ jsx(ComponentTab, { value: label, jsonFormsProps: props, ...tabProps }, label)) }),
|
|
55
|
+
categories.map((category) => /* @__PURE__ */ jsx(ComponentPanel, { value: category.label, jsonFormsProps: props, ...panelProps, children: /* @__PURE__ */ jsx(MantineLayoutRenderer, { ...childProps, elements: category.elements, renderers, cells }) }, category.label))
|
|
56
|
+
] });
|
|
57
|
+
};
|
|
58
|
+
const MantineCategorizationLayoutTester = rankWith(1, uiTypeIs("Categorization"));
|
|
59
|
+
const MantineCategorizationLayoutRenderer = withJsonFormsLayoutProps(Component);
|
|
60
|
+
export {
|
|
61
|
+
MantineCategorizationLayoutRenderer,
|
|
62
|
+
MantineCategorizationLayoutTester
|
|
63
|
+
};
|
|
@@ -3,9 +3,9 @@ import { rankWith, uiTypeIs } from "@jsonforms/core";
|
|
|
3
3
|
import { withJsonFormsLayoutProps } from "@jsonforms/react";
|
|
4
4
|
import { Fieldset } from "@mantine/core";
|
|
5
5
|
import { MantineLayoutRenderer } from "../utils/layout.mjs";
|
|
6
|
-
const Component = ({
|
|
7
|
-
const
|
|
8
|
-
const childProps = { visible, elements:
|
|
6
|
+
const Component = ({ schema, uischema, path, enabled, visible, renderers, cells, label }) => {
|
|
7
|
+
const layout = uischema;
|
|
8
|
+
const childProps = { schema, path, enabled, visible, elements: layout.elements, direction: "column" };
|
|
9
9
|
return /* @__PURE__ */ jsx(Fieldset, { legend: label, m: "0.5rem", mx: "calc(0.5rem + 2px)", children: /* @__PURE__ */ jsx(MantineLayoutRenderer, { ...childProps, renderers, cells }) });
|
|
10
10
|
};
|
|
11
11
|
const MantineGroupLayoutTester = rankWith(1, uiTypeIs("Group"));
|
|
@@ -2,9 +2,9 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { rankWith, uiTypeIs } from "@jsonforms/core";
|
|
3
3
|
import { withJsonFormsLayoutProps } from "@jsonforms/react";
|
|
4
4
|
import { MantineLayoutRenderer } from "../utils/layout.mjs";
|
|
5
|
-
const Component = ({
|
|
5
|
+
const Component = ({ schema, uischema, path, enabled, visible, renderers, cells }) => {
|
|
6
6
|
const layout = uischema;
|
|
7
|
-
const childProps = { visible, elements: layout.elements,
|
|
7
|
+
const childProps = { schema, path, enabled, visible, elements: layout.elements, direction: "row" };
|
|
8
8
|
return /* @__PURE__ */ jsx(MantineLayoutRenderer, { ...childProps, renderers, cells });
|
|
9
9
|
};
|
|
10
10
|
const mantineHorizontalLayoutTester = rankWith(1, uiTypeIs("HorizontalLayout"));
|
|
@@ -2,9 +2,9 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { rankWith, uiTypeIs } from "@jsonforms/core";
|
|
3
3
|
import { withJsonFormsLayoutProps } from "@jsonforms/react";
|
|
4
4
|
import { MantineLayoutRenderer } from "../utils/layout.mjs";
|
|
5
|
-
const Component = ({
|
|
6
|
-
const
|
|
7
|
-
const childProps = { visible, elements:
|
|
5
|
+
const Component = ({ schema, uischema, path, enabled, visible, renderers, cells }) => {
|
|
6
|
+
const layout = uischema;
|
|
7
|
+
const childProps = { schema, path, enabled, visible, elements: layout.elements, direction: "column" };
|
|
8
8
|
return /* @__PURE__ */ jsx(MantineLayoutRenderer, { ...childProps, renderers, cells });
|
|
9
9
|
};
|
|
10
10
|
const mantineVerticalLayoutTester = rankWith(1, uiTypeIs("VerticalLayout"));
|
|
@@ -14,6 +14,7 @@ import { MantineOneOfEnumControl, mantineOneOfEnumControlTester } from "../contr
|
|
|
14
14
|
import { MantineTextControl, mantineTextControlTester } from "../controls/MantineTextControl.mjs";
|
|
15
15
|
import { MantineTimeControl, mantineTimeControlTester } from "../controls/MantineTimeControl.mjs";
|
|
16
16
|
import { MantineLabelRenderer, MantineLabelTester } from "../labels/MantineLabelRenderer.mjs";
|
|
17
|
+
import { MantineCategorizationLayoutRenderer, MantineCategorizationLayoutTester } from "../layouts/MantineCategorizationLayoutRenderer.mjs";
|
|
17
18
|
import { MantineGroupLayoutRenderer, MantineGroupLayoutTester } from "../layouts/MantineGroupLayoutRenderer.mjs";
|
|
18
19
|
import { MantineHorizontalLayoutRenderer, mantineHorizontalLayoutTester } from "../layouts/MantineHotizontalLayoutRenderer.mjs";
|
|
19
20
|
import { MantineVerticalLayoutRenderer, mantineVerticalLayoutTester } from "../layouts/MantineVerticalLayoutRenderer.mjs";
|
|
@@ -39,6 +40,7 @@ const mantineRenderers = [
|
|
|
39
40
|
{ tester: mantineHorizontalLayoutTester, renderer: MantineHorizontalLayoutRenderer },
|
|
40
41
|
{ tester: mantineVerticalLayoutTester, renderer: MantineVerticalLayoutRenderer },
|
|
41
42
|
{ tester: MantineGroupLayoutTester, renderer: MantineGroupLayoutRenderer },
|
|
43
|
+
{ tester: MantineCategorizationLayoutTester, renderer: MantineCategorizationLayoutRenderer },
|
|
42
44
|
// Labels
|
|
43
45
|
{ tester: MantineLabelTester, renderer: MantineLabelRenderer }
|
|
44
46
|
];
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export const MantineCategorizationLayoutTester: (uischema: import('@jsonforms/core').UISchemaElement, schema: import('@jsonforms/core').JsonSchema, context: import('@jsonforms/core').TesterContext) => number;
|
|
2
|
+
export const MantineCategorizationLayoutRenderer: import('react').ComponentType<any>;
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
export const mantineRenderers:
|
|
1
|
+
export const mantineRenderers: {
|
|
2
2
|
tester: (uischema: import('@jsonforms/core').UISchemaElement, schema: import('@jsonforms/core').JsonSchema, context: import('@jsonforms/core').TesterContext) => number;
|
|
3
|
-
renderer: import('react').ComponentType<
|
|
4
|
-
}
|
|
5
|
-
tester: (uischema: import('@jsonforms/core').UISchemaElement, schema: import('@jsonforms/core').JsonSchema, context: import('@jsonforms/core').TesterContext) => number;
|
|
6
|
-
renderer: import('react').ComponentType<import('@jsonforms/core').LayoutProps & import('@jsonforms/core').OwnPropsOfLayout>;
|
|
7
|
-
} | {
|
|
8
|
-
tester: (uischema: import('@jsonforms/core').UISchemaElement, schema: import('@jsonforms/core').JsonSchema, context: import('@jsonforms/core').TesterContext) => number;
|
|
9
|
-
renderer: import('react').ComponentType<import('@jsonforms/core').OwnPropsOfLabel>;
|
|
10
|
-
})[];
|
|
3
|
+
renderer: import('react').ComponentType<any>;
|
|
4
|
+
}[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const react = require("react");
|
|
4
|
+
const createSafeContext = (errorMessage) => {
|
|
5
|
+
const Context = react.createContext(null);
|
|
6
|
+
const useSafeContext = ({ throwOnError = true, defaultValue = {} } = {}) => {
|
|
7
|
+
const ctx = react.useContext(Context);
|
|
8
|
+
if (ctx === null) {
|
|
9
|
+
if (throwOnError) {
|
|
10
|
+
throw new Error(errorMessage);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return ctx ?? defaultValue;
|
|
14
|
+
};
|
|
15
|
+
return [Context.Provider, useSafeContext];
|
|
16
|
+
};
|
|
17
|
+
exports.createSafeContext = createSafeContext;
|
package/dist/utils/cjs/index.cjs
CHANGED
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const createFetchParams = require("./createFetchParams/createFetchParams.cjs");
|
|
4
|
+
const createSafeContext = require("./createSafeContext/createSafeContext.cjs");
|
|
4
5
|
const deepMerge = require("./deepMerge/deepMerge.cjs");
|
|
6
|
+
const getByPath = require("./getByPath/getByPath.cjs");
|
|
5
7
|
const getItemId = require("./getItemId/getItemId.cjs");
|
|
6
8
|
const getItemName = require("./getItemName/getItemName.cjs");
|
|
7
9
|
const getValue = require("./getValue/getValue.cjs");
|
|
8
10
|
const getValueOrDefault = require("./getValueOrDefault/getValueOrDefault.cjs");
|
|
9
11
|
const isTruthy = require("./isTruthy/isTruthy.cjs");
|
|
12
|
+
const mergeProps = require("./mergeProps/mergeProps.cjs");
|
|
10
13
|
const parseFromValuesOrFunc = require("./parseFromValuesOrFunc/parseFromValuesOrFunc.cjs");
|
|
11
14
|
const parseValue = require("./parseValue/parseValue.cjs");
|
|
12
15
|
const urlJoin = require("./urlJoin/urlJoin.cjs");
|
|
13
16
|
exports.createFetchParams = createFetchParams.createFetchParams;
|
|
17
|
+
exports.createSafeContext = createSafeContext.createSafeContext;
|
|
14
18
|
exports.deepMerge = deepMerge.deepMerge;
|
|
19
|
+
exports.getByPath = getByPath.getByPath;
|
|
15
20
|
exports.getItemId = getItemId.getItemId;
|
|
16
21
|
exports.getItemName = getItemName.getItemName;
|
|
17
22
|
exports.getValue = getValue.getValue;
|
|
18
23
|
exports.getValueOrDefault = getValueOrDefault.getValueOrDefault;
|
|
19
24
|
exports.isTruthy = isTruthy.isTruthy;
|
|
25
|
+
exports.mergeProps = mergeProps.mergeProps;
|
|
20
26
|
exports.parseFromValuesOrFunc = parseFromValuesOrFunc.parseFromValuesOrFunc;
|
|
21
27
|
exports.parseValue = parseValue.parseValue;
|
|
22
28
|
exports.normalize = urlJoin.normalize;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const deepMerge = require("../deepMerge/deepMerge.cjs");
|
|
4
|
+
const getByPath = require("../getByPath/getByPath.cjs");
|
|
5
|
+
const mergeProps = (obj, ...keys) => deepMerge.deepMerge(...keys.map((key) => getByPath.getByPath(obj, key)));
|
|
6
|
+
exports.mergeProps = mergeProps;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
const createSafeContext = (errorMessage) => {
|
|
3
|
+
const Context = createContext(null);
|
|
4
|
+
const useSafeContext = ({ throwOnError = true, defaultValue = {} } = {}) => {
|
|
5
|
+
const ctx = useContext(Context);
|
|
6
|
+
if (ctx === null) {
|
|
7
|
+
if (throwOnError) {
|
|
8
|
+
throw new Error(errorMessage);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return ctx ?? defaultValue;
|
|
12
|
+
};
|
|
13
|
+
return [Context.Provider, useSafeContext];
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
createSafeContext
|
|
17
|
+
};
|
package/dist/utils/esm/index.mjs
CHANGED
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
import { createFetchParams } from "./createFetchParams/createFetchParams.mjs";
|
|
2
|
+
import { createSafeContext } from "./createSafeContext/createSafeContext.mjs";
|
|
2
3
|
import { deepMerge } from "./deepMerge/deepMerge.mjs";
|
|
4
|
+
import { getByPath } from "./getByPath/getByPath.mjs";
|
|
3
5
|
import { getItemId } from "./getItemId/getItemId.mjs";
|
|
4
6
|
import { getItemName } from "./getItemName/getItemName.mjs";
|
|
5
7
|
import { getValue } from "./getValue/getValue.mjs";
|
|
6
8
|
import { getValueOrDefault } from "./getValueOrDefault/getValueOrDefault.mjs";
|
|
7
9
|
import { isTruthy } from "./isTruthy/isTruthy.mjs";
|
|
10
|
+
import { mergeProps } from "./mergeProps/mergeProps.mjs";
|
|
8
11
|
import { parseFromValuesOrFunc } from "./parseFromValuesOrFunc/parseFromValuesOrFunc.mjs";
|
|
9
12
|
import { parseValue } from "./parseValue/parseValue.mjs";
|
|
10
13
|
import { normalize, urlJoin } from "./urlJoin/urlJoin.mjs";
|
|
11
14
|
export {
|
|
12
15
|
createFetchParams,
|
|
16
|
+
createSafeContext,
|
|
13
17
|
deepMerge,
|
|
18
|
+
getByPath,
|
|
14
19
|
getItemId,
|
|
15
20
|
getItemName,
|
|
16
21
|
getValue,
|
|
17
22
|
getValueOrDefault,
|
|
18
23
|
isTruthy,
|
|
24
|
+
mergeProps,
|
|
19
25
|
normalize,
|
|
20
26
|
parseFromValuesOrFunc,
|
|
21
27
|
parseValue,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function createSafeContext(errorMessage: string): [React.ComponentType<{
|
|
2
|
+
value: any;
|
|
3
|
+
children: any;
|
|
4
|
+
}>, (options?: SafeContextOptions) => any];
|
|
5
|
+
export type SafeContextOptions = {
|
|
6
|
+
/**
|
|
7
|
+
* - Whether to throw an error if the context is not provided.
|
|
8
|
+
*/
|
|
9
|
+
throwOnError?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* - The default value to return if the context is not provided.
|
|
12
|
+
*/
|
|
13
|
+
defaultValue?: any;
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './createSafeContext';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function getByPath(obj: Record<string, any>, path: string, separator?: string): any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './getByPath';
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
export * from './createFetchParams/index';
|
|
2
|
+
export * from './createSafeContext/index';
|
|
2
3
|
export * from './deepMerge/index';
|
|
4
|
+
export * from './getByPath/index';
|
|
3
5
|
export * from './getItemId/index';
|
|
4
6
|
export * from './getItemName/index';
|
|
5
7
|
export * from './getValue/index';
|
|
6
8
|
export * from './getValueOrDefault/index';
|
|
7
9
|
export * from './isTruthy/index';
|
|
10
|
+
export * from './mergeProps/index';
|
|
8
11
|
export * from './parseFromValuesOrFunc/index';
|
|
9
12
|
export * from './parseValue/index';
|
|
10
13
|
export * from './urlJoin/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './mergeProps';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function mergeProps(obj: Record<string, any>, ...keys: string[]): Record<string, any>;
|
package/package.json
CHANGED