@dashadmin/dash-auto-admin 1.3.25 → 1.3.28
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 +32 -6
- package/dist/DashAutoAdminComponentRegistry.js +64 -1
- package/dist/DashAutoAdminForm.js +137 -1
- package/dist/DashAutoAdminResizableDrawer.js +63 -1
- package/dist/DashAutoAdminSaveButton.js +57 -1
- package/dist/DashAutoCreate.js +102 -1
- package/dist/DashAutoDrawer.js +256 -1
- package/dist/DashAutoEdit.js +99 -1
- package/dist/DashAutoFiltersGenerator.js +193 -1
- package/dist/DashAutoFormGroups.js +118 -1
- package/dist/DashAutoFormLayout.js +68 -1
- package/dist/DashAutoFormMuiTabs.js +291 -1
- package/dist/DashAutoFormTabs.js +132 -1
- package/dist/DashAutoGroup.js +27 -1
- package/dist/DashAutoLayout.js +31 -1
- package/dist/DashAutoList.js +218 -1
- package/dist/DashAutoPostFilterForm.js +47 -1
- package/dist/DashAutoReferenceTab.js +10 -1
- package/dist/DashAutoResource.js +77 -1
- package/dist/DashAutoResourceLayout.js +16 -1
- package/dist/DashAutoShow.js +195 -1
- package/dist/DashAutoTabbedForm.js +244 -1
- package/dist/DashAutoTabbedForm.review.js +221 -1
- package/dist/DashAutoTabs.js +11 -1
- package/dist/DashFilterWrapper.js +62 -1
- package/dist/DashRedirect.js +56 -1
- package/dist/TabbedLayout.js +38 -1
- package/dist/common/DashAutoTitle.js +33 -1
- package/dist/common/components/FabButton.js +59 -1
- package/dist/common/components/TranslatedLabel.js +60 -1
- package/dist/common/settings/Settings.js +196 -1
- package/dist/common/settings/SettingsBarIcons.js +61 -1
- package/dist/context/DashAutoAdminFormContext.js +15 -1
- package/dist/hooks/useAutoAdminLoadingStateMediator.js +36 -1
- package/dist/hooks/useAutoAdminTranslate.js +61 -1
- package/dist/hooks/useHash.js +24 -1
- package/dist/hooks/useLogger.js +20 -1
- package/dist/hooks/useRoutePathPattern.js +20 -1
- package/dist/hooks/useVirtualHash.js +28 -1
- package/dist/index.js +77 -3406
- package/dist/list/DashAutoListActions.js +57 -1
- package/dist/list/DashAutoListDatagridWrapper.js +68 -1
- package/dist/list/DashAutoListDefaultActionsWrapper.js +14 -1
- package/dist/list/DashAutoListFilterFormWithButton.js +80 -1
- package/dist/list/DashAutoListTopToolbar.js +180 -1
- package/dist/mui/AttributeToField.js +576 -1
- package/dist/mui/AttributeToInput.js +630 -1
- package/dist/mui/AutoAdminResizableDrawer.js +63 -1
- package/dist/mui/AutoDataGrid.js +120 -1
- package/dist/mui/AutoReferenceFormTab.js +53 -1
- package/dist/mui/AutoReferenceTab.js +46 -1
- package/dist/mui/AutoTabs.js +19 -1
- package/dist/mui/components/ExtendedPagination.js +34 -1
- package/dist/mui/components/ListStringField.js +25 -1
- package/dist/providers/DashAuthProvider.js +215 -1
- package/dist/providers/DashDataProvider.js +310 -1
- package/dist/providers/index.js +10 -1
- package/dist/react-admin.d.js +0 -0
- package/dist/toolbar/buttons/BottomToolbarButtons.js +65 -1
- package/dist/toolbar/buttons/DashResourceButton.js +181 -1
- package/dist/toolbar/buttons/ListButtons.js +80 -1
- package/dist/toolbar/buttons/ToolbarButtons.js +135 -1
- package/dist/types/ActionCallback.d.js +0 -0
- package/dist/utils/SimpleLogger.js +52 -1
- package/dist/utils/enumToChoices.js +5 -1
- package/dist/utils/evalActionPermission.js +11 -1
- package/dist/utils/groupByTabs.js +21 -1
- package/dist/utils/hashedGroupByTabs.js +12 -1
- package/dist/utils/invertMap.js +12 -1
- package/dist/utils/isClassComponent.js +7 -1
- package/dist/utils/isComponent.js +29 -1
- package/dist/utils/isEnum.js +5 -1
- package/dist/utils/isFC.js +8 -1
- package/dist/utils/replaceParams.js +9 -1
- package/dist/utils/validate.js +19 -1
- package/dist/wrappers/UserAction.js +60 -1
- package/dist/wrappers/index.js +4 -1
- package/package.json +134 -120
- package/src/DashAutoAdminComponentRegistry.tsx +75 -0
- package/src/DashAutoAdminForm.tsx +155 -0
- package/src/DashAutoAdminResizableDrawer.tsx +69 -0
- package/src/DashAutoAdminSaveButton.tsx +116 -0
- package/src/DashAutoCreate.tsx +118 -0
- package/src/DashAutoDrawer.tsx +288 -0
- package/src/DashAutoEdit.tsx +109 -0
- package/src/DashAutoFiltersGenerator.tsx +208 -0
- package/src/DashAutoFormGroups.tsx +146 -0
- package/src/DashAutoFormLayout.tsx.review +113 -0
- package/src/DashAutoFormMuiTabs.tsx +368 -0
- package/src/DashAutoFormTabs.tsx +177 -0
- package/src/DashAutoGroup.tsx +42 -0
- package/src/DashAutoLayout.tsx +57 -0
- package/src/DashAutoList.tsx +237 -0
- package/src/DashAutoPostFilterForm.tsx +35 -0
- package/src/DashAutoReferenceTab.tsx +9 -0
- package/src/DashAutoResource.tsx +85 -0
- package/src/DashAutoResourceLayout.tsx +50 -0
- package/src/DashAutoShow.tsx +200 -0
- package/src/DashAutoTabbedForm.review.tsx +262 -0
- package/src/DashAutoTabbedForm.tsx +324 -0
- package/src/DashAutoTabs.tsx +19 -0
- package/src/DashFilterWrapper.tsx +43 -0
- package/src/DashRedirect.tsx +46 -0
- package/src/TabbedLayout.tsx +29 -0
- package/src/common/DashAutoTitle.tsx +24 -0
- package/src/common/components/FabButton.tsx +40 -0
- package/src/common/components/TranslatedLabel.tsx +81 -0
- package/src/common/settings/Settings.tsx +236 -0
- package/src/common/settings/SettingsBarIcons.tsx +72 -0
- package/src/context/DashAutoAdminFormContext.tsx +31 -0
- package/src/hooks/useAutoAdminLoadingStateMediator.tsx +42 -0
- package/src/hooks/useAutoAdminTranslate.tsx +106 -0
- package/src/hooks/useHash.tsx +27 -0
- package/src/hooks/useLogger.tsx +23 -0
- package/src/hooks/useRoutePathPattern.tsx +24 -0
- package/src/hooks/useVirtualHash.tsx +34 -0
- package/src/index.ts +85 -0
- package/src/interfaces/ICustomResourceSubComponent.ts +11 -0
- package/src/interfaces/IDashApplicationLayoutMainAction.ts +37 -0
- package/src/interfaces/IDashApplicationLayoutMenuItem.ts +24 -0
- package/src/interfaces/IDashAutoAdminAttribute.ts +104 -0
- package/src/interfaces/IDashAutoAdminCustomFieldComponent.ts +18 -0
- package/src/interfaces/IDashAutoAdminFormOptions.ts +22 -0
- package/src/interfaces/IDashAutoAdminListActions.ts +13 -0
- package/src/interfaces/IDashAutoAdminReference.ts +16 -0
- package/src/interfaces/IDashAutoAdminResourceConfig.ts +360 -0
- package/src/interfaces/IDashAutoForm.ts +24 -0
- package/src/interfaces/IDashAutoGridButton.ts +35 -0
- package/src/interfaces/IDashAutoShow.ts +12 -0
- package/src/interfaces/IGroupExtraData.ts +8 -0
- package/src/interfaces/IRecord.ts +7 -0
- package/src/interfaces/IReferenceFilter.ts +55 -0
- package/src/interfaces/IResourceComponent.ts +8 -0
- package/src/interfaces/IToolbarButton.ts +11 -0
- package/src/list/DashAutoListActions.tsx +88 -0
- package/src/list/DashAutoListDatagridWrapper.tsx +74 -0
- package/src/list/DashAutoListDefaultActionsWrapper.tsx +31 -0
- package/src/list/DashAutoListFilterFormWithButton.tsx +93 -0
- package/src/list/DashAutoListTopToolbar.tsx +240 -0
- package/src/mui/AttributeToField.tsx +657 -0
- package/src/mui/AttributeToInput.tsx +728 -0
- package/src/mui/AutoAdminResizableDrawer.tsx +69 -0
- package/src/mui/AutoDataGrid.tsx +127 -0
- package/src/mui/AutoReferenceFormTab.tsx +51 -0
- package/src/mui/AutoReferenceTab.tsx +45 -0
- package/src/mui/AutoTabs.tsx +32 -0
- package/src/mui/components/ExtendedPagination.tsx +23 -0
- package/src/mui/components/ListStringField.tsx +32 -0
- package/src/providers/DashAuthProvider.ts +341 -0
- package/src/providers/DashDataProvider.ts +466 -0
- package/src/providers/index.ts +17 -0
- package/src/toolbar/buttons/BottomToolbarButtons.tsx +59 -0
- package/src/toolbar/buttons/DashResourceButton.tsx +223 -0
- package/src/toolbar/buttons/ListButtons.tsx +137 -0
- package/src/toolbar/buttons/ToolbarButtons.tsx +186 -0
- package/src/utils/SimpleLogger.tsx +46 -0
- package/src/utils/enumToChoices.tsx +3 -0
- package/src/utils/evalActionPermission.tsx +14 -0
- package/src/utils/groupByTabs.tsx +23 -0
- package/src/utils/hashedGroupByTabs.tsx +16 -0
- package/src/utils/invertMap.tsx +10 -0
- package/src/utils/isClassComponent.tsx +9 -0
- package/src/utils/isComponent.tsx +45 -0
- package/src/utils/isEnum.tsx +3 -0
- package/src/utils/isFC.tsx +6 -0
- package/src/utils/replaceParams.tsx +6 -0
- package/src/utils/validate.tsx +24 -0
- package/src/wrappers/UserAction.tsx +67 -0
- package/src/wrappers/index.tsx +1 -0
- /package/{dist → src}/DashAutoAdminSaveButton.tsx.bkup +0 -0
- /package/{dist/DashAutoFormLayout.tsx.review → src/DashAutoFormLayout.tsx} +0 -0
- /package/{dist → src}/DashAutoFormTabs.review +0 -0
- /package/{dist → src}/DashAutoFormTabs.tsx.formcontext.wip +0 -0
- /package/{dist → src}/mui/AttributeToField.tsx.review +0 -0
- /package/{dist → src}/mui/AttributeToInput.tsx.review +0 -0
- /package/{dist → src}/react-admin.d.ts +0 -0
- /package/{dist → src}/types/ActionCallback.d.ts +0 -0
|
@@ -1 +1,57 @@
|
|
|
1
|
-
import{jsx
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import DashAutoListTopToolbar from "./DashAutoListTopToolbar";
|
|
3
|
+
import { useState, useEffect } from "react";
|
|
4
|
+
const getEnv = (key, defaultValue) => {
|
|
5
|
+
return process.env["VITE_" + key] || (defaultValue || null);
|
|
6
|
+
};
|
|
7
|
+
const FILTERS_COLLAPSE_COUNT = getEnv("FILTERS_COLLAPSE_COUNT");
|
|
8
|
+
const FILTERS_COLLAPSE_SIZE = getEnv("FILTERS_COLLAPSE_SIZE");
|
|
9
|
+
const DashAutoListActions = (props) => {
|
|
10
|
+
const { filters, resourceConfig, autoFilters, listProps } = props;
|
|
11
|
+
const sanitizedModel = resourceConfig.model.replace(/\//g, "_");
|
|
12
|
+
const storeKey = `filters.collapsed.${sanitizedModel}`;
|
|
13
|
+
const [expanded, setExpandedState] = useState(() => {
|
|
14
|
+
const stored = localStorage.getItem(storeKey);
|
|
15
|
+
return stored !== null ? JSON.parse(stored) : false;
|
|
16
|
+
});
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
localStorage.setItem(storeKey, JSON.stringify(expanded));
|
|
19
|
+
console.log("\u{1F4BE} Persisting filter state:", { storeKey, expanded });
|
|
20
|
+
}, [expanded, storeKey]);
|
|
21
|
+
const setExpanded = (value) => {
|
|
22
|
+
console.log("\u{1F504} Setting expanded:", { storeKey, value });
|
|
23
|
+
setExpandedState(value);
|
|
24
|
+
};
|
|
25
|
+
const countFilters = resourceConfig.referenceFilters && resourceConfig.referenceFilters.length ? resourceConfig.referenceFilters.length : 0;
|
|
26
|
+
let hasToolbarItems = filters || resourceConfig.create || resourceConfig.exporter || resourceConfig.customToolbarElements ? true : false;
|
|
27
|
+
if ((resourceConfig == null ? void 0 : resourceConfig.toolbar) === false) {
|
|
28
|
+
hasToolbarItems = false;
|
|
29
|
+
}
|
|
30
|
+
if (!hasToolbarItems) return null;
|
|
31
|
+
const toolbarComponent = /* @__PURE__ */ jsx(
|
|
32
|
+
DashAutoListTopToolbar,
|
|
33
|
+
{
|
|
34
|
+
resourceConfig,
|
|
35
|
+
autoFilters,
|
|
36
|
+
filters,
|
|
37
|
+
countFilters,
|
|
38
|
+
expanded,
|
|
39
|
+
setExpanded,
|
|
40
|
+
filterCountToCollapse: FILTERS_COLLAPSE_COUNT,
|
|
41
|
+
collapsedSize: FILTERS_COLLAPSE_SIZE
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
return resourceConfig.customListActions ? /* @__PURE__ */ jsx(
|
|
45
|
+
resourceConfig.customListActions,
|
|
46
|
+
{
|
|
47
|
+
resourceConfig,
|
|
48
|
+
listProps,
|
|
49
|
+
children: toolbarComponent
|
|
50
|
+
}
|
|
51
|
+
) : toolbarComponent;
|
|
52
|
+
};
|
|
53
|
+
var DashAutoListActions_default = DashAutoListActions;
|
|
54
|
+
export {
|
|
55
|
+
DashAutoListActions_default as default,
|
|
56
|
+
getEnv
|
|
57
|
+
};
|
|
@@ -1 +1,68 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
21
|
+
import { useLocation } from "react-router";
|
|
22
|
+
import { useUnselectAll, ListContext } from "react-admin";
|
|
23
|
+
import useAutoAdminLoadingStateMediator from "../hooks/useAutoAdminLoadingStateMediator";
|
|
24
|
+
import { useContext, useEffect, useState } from "react";
|
|
25
|
+
import AutoDataGrid from "../mui/AutoDataGrid";
|
|
26
|
+
import {
|
|
27
|
+
CircularProgress
|
|
28
|
+
} from "@mui/material";
|
|
29
|
+
const useSafeListContext = () => {
|
|
30
|
+
const context = useContext(ListContext);
|
|
31
|
+
return context != null ? context : null;
|
|
32
|
+
};
|
|
33
|
+
const DashAutoListDataGridWrapper = ({
|
|
34
|
+
resourceConfig,
|
|
35
|
+
dataGridProps,
|
|
36
|
+
locale
|
|
37
|
+
}) => {
|
|
38
|
+
var _a;
|
|
39
|
+
const listContext = useSafeListContext();
|
|
40
|
+
const setFilters = listContext == null ? void 0 : listContext.setFilters;
|
|
41
|
+
const location = useLocation();
|
|
42
|
+
const [currentLocation, setCurrentLocation] = useState(location.pathname);
|
|
43
|
+
const [loading] = useAutoAdminLoadingStateMediator("getList");
|
|
44
|
+
const unselectAll = useUnselectAll(((_a = resourceConfig.listProps) == null ? void 0 : _a.storeKey) || resourceConfig.model);
|
|
45
|
+
const clearFilters = () => {
|
|
46
|
+
unselectAll();
|
|
47
|
+
if (setFilters) {
|
|
48
|
+
setFilters({}, []);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (currentLocation !== location.pathname) {
|
|
53
|
+
if ((resourceConfig == null ? void 0 : resourceConfig.resetFiltersOnLocationChange) === true) {
|
|
54
|
+
console.info("Resetting Filters on Location change");
|
|
55
|
+
clearFilters();
|
|
56
|
+
}
|
|
57
|
+
setCurrentLocation(location.pathname);
|
|
58
|
+
}
|
|
59
|
+
}, [location, currentLocation]);
|
|
60
|
+
return /* @__PURE__ */ jsxs("div", { className: loading ? "loading-overlay" : "default-overlay", children: [
|
|
61
|
+
loading && /* @__PURE__ */ jsx(CircularProgress, { className: "datagrid-olverlay-loading" }),
|
|
62
|
+
/* @__PURE__ */ jsx(AutoDataGrid, __spreadProps(__spreadValues({ resourceConfig }, dataGridProps), { locale }))
|
|
63
|
+
] });
|
|
64
|
+
};
|
|
65
|
+
var DashAutoListDatagridWrapper_default = DashAutoListDataGridWrapper;
|
|
66
|
+
export {
|
|
67
|
+
DashAutoListDatagridWrapper_default as default
|
|
68
|
+
};
|
|
@@ -1 +1,14 @@
|
|
|
1
|
-
import{jsx
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
const DashAutoListDefaultListActionsWrapper = ({
|
|
3
|
+
resourceConfig,
|
|
4
|
+
autoFilters,
|
|
5
|
+
children
|
|
6
|
+
}) => {
|
|
7
|
+
const hasToolbarItems = autoFilters && autoFilters.length || resourceConfig.create || resourceConfig.exporter || resourceConfig.customToolbarElements ? true : false;
|
|
8
|
+
if (!hasToolbarItems) return children;
|
|
9
|
+
return /* @__PURE__ */ jsx("div", { className: "top-toolbar-default", children });
|
|
10
|
+
};
|
|
11
|
+
var DashAutoListDefaultActionsWrapper_default = DashAutoListDefaultListActionsWrapper;
|
|
12
|
+
export {
|
|
13
|
+
DashAutoListDefaultActionsWrapper_default as default
|
|
14
|
+
};
|
|
@@ -1 +1,80 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
21
|
+
import * as React from "react";
|
|
22
|
+
import { useForm, FormProvider } from "react-hook-form";
|
|
23
|
+
import { Box, Button } from "@mui/material";
|
|
24
|
+
import { FilterFormBase, ListContext } from "react-admin";
|
|
25
|
+
const useSafeListContext = () => {
|
|
26
|
+
const context = React.useContext(ListContext);
|
|
27
|
+
return context != null ? context : null;
|
|
28
|
+
};
|
|
29
|
+
const DashAutoListFilterFormWithButton = React.forwardRef((props, forwardedRef) => {
|
|
30
|
+
var _a, _b;
|
|
31
|
+
const { filters, resourceConfig } = props;
|
|
32
|
+
const listContext = useSafeListContext();
|
|
33
|
+
const displayedFilters = (_a = listContext == null ? void 0 : listContext.displayedFilters) != null ? _a : [];
|
|
34
|
+
const filterValues = (_b = listContext == null ? void 0 : listContext.filterValues) != null ? _b : {};
|
|
35
|
+
const setFilters = listContext == null ? void 0 : listContext.setFilters;
|
|
36
|
+
const form = useForm({
|
|
37
|
+
defaultValues: filterValues
|
|
38
|
+
});
|
|
39
|
+
const onSubmit = (values) => {
|
|
40
|
+
if (Object.keys(values).length > 0 && setFilters) {
|
|
41
|
+
setFilters(values, displayedFilters);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
React.useEffect(() => {
|
|
45
|
+
const keyDownHandler = (event) => {
|
|
46
|
+
if (event.key === "Enter") {
|
|
47
|
+
event.preventDefault();
|
|
48
|
+
form.handleSubmit(onSubmit)();
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
document.addEventListener("keydown", keyDownHandler);
|
|
52
|
+
return () => {
|
|
53
|
+
document.removeEventListener("keydown", keyDownHandler);
|
|
54
|
+
};
|
|
55
|
+
}, []);
|
|
56
|
+
const { reset } = form;
|
|
57
|
+
const handleSubmit = form.handleSubmit(onSubmit);
|
|
58
|
+
React.useImperativeHandle(forwardedRef, () => ({
|
|
59
|
+
submit() {
|
|
60
|
+
handleSubmit();
|
|
61
|
+
},
|
|
62
|
+
reset() {
|
|
63
|
+
reset();
|
|
64
|
+
}
|
|
65
|
+
}));
|
|
66
|
+
return /* @__PURE__ */ jsx(FormProvider, __spreadProps(__spreadValues({}, form), { children: /* @__PURE__ */ jsxs(Box, { mb: 1, children: [
|
|
67
|
+
/* @__PURE__ */ jsx(
|
|
68
|
+
FilterFormBase,
|
|
69
|
+
{
|
|
70
|
+
onSubmit,
|
|
71
|
+
filters
|
|
72
|
+
}
|
|
73
|
+
),
|
|
74
|
+
(resourceConfig == null ? void 0 : resourceConfig.filterButtonPosition) === "filters-container" && /* @__PURE__ */ jsx(Button, { className: "toolbar-filters-filter-button", onClick: () => form.handleSubmit(onSubmit)(), variant: "contained", color: "primary", type: "button", children: "Filtrar" })
|
|
75
|
+
] }) }));
|
|
76
|
+
});
|
|
77
|
+
var DashAutoListFilterFormWithButton_default = DashAutoListFilterFormWithButton;
|
|
78
|
+
export {
|
|
79
|
+
DashAutoListFilterFormWithButton_default as default
|
|
80
|
+
};
|
|
@@ -1 +1,180 @@
|
|
|
1
|
-
import{Fragment
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import FabButton from "../common/components/FabButton";
|
|
3
|
+
import { SavedQueriesList, useRefresh, useUnselectAll, ListContext } from "react-admin";
|
|
4
|
+
import { FilterForm } from "react-admin";
|
|
5
|
+
import { useContext } from "react";
|
|
6
|
+
import { Box, Button, Collapse, Fab } from "@mui/material";
|
|
7
|
+
import FilterAltOffIcon from "@mui/icons-material/FilterAltOff";
|
|
8
|
+
import DashAutoListFilterFormWithButton from "./DashAutoListFilterFormWithButton";
|
|
9
|
+
import React from "react";
|
|
10
|
+
import KeyboardArrowUp from "@mui/icons-material/KeyboardArrowUp";
|
|
11
|
+
import KeyboardArrowDown from "@mui/icons-material/KeyboardArrowDown";
|
|
12
|
+
import Search from "@mui/icons-material/Search";
|
|
13
|
+
import { ToolbarCreateButton, ToolbarExportButton } from "../toolbar/buttons/ToolbarButtons";
|
|
14
|
+
import { Refresh } from "@mui/icons-material";
|
|
15
|
+
const useSafeListContext = () => {
|
|
16
|
+
const context = useContext(ListContext);
|
|
17
|
+
return context != null ? context : null;
|
|
18
|
+
};
|
|
19
|
+
const ToolbarFilters = React.forwardRef((props, forwardedRef) => {
|
|
20
|
+
const handleSubmit = () => {
|
|
21
|
+
console.error("handleSubmit at ToolbarFilters not implemented");
|
|
22
|
+
};
|
|
23
|
+
const reset = () => {
|
|
24
|
+
console.error("reset at ToolbarFilters not implemented");
|
|
25
|
+
};
|
|
26
|
+
React.useImperativeHandle(forwardedRef, () => ({
|
|
27
|
+
submit() {
|
|
28
|
+
handleSubmit();
|
|
29
|
+
},
|
|
30
|
+
reset() {
|
|
31
|
+
reset();
|
|
32
|
+
}
|
|
33
|
+
}));
|
|
34
|
+
const { resourceConfig, filters } = props;
|
|
35
|
+
return resourceConfig.hideDefaultFilters !== true ? /* @__PURE__ */ jsx(FilterForm, { filters }) : /* @__PURE__ */ jsx(Fragment, {});
|
|
36
|
+
});
|
|
37
|
+
ToolbarFilters.displayName = "ToolbarFilters";
|
|
38
|
+
const DashAutoListTopToolbar = (props) => {
|
|
39
|
+
var _a;
|
|
40
|
+
const {
|
|
41
|
+
resourceConfig,
|
|
42
|
+
autoFilters,
|
|
43
|
+
filters,
|
|
44
|
+
countFilters,
|
|
45
|
+
expanded,
|
|
46
|
+
setExpanded,
|
|
47
|
+
filterCountToCollapse = 5,
|
|
48
|
+
collapsedSize = "60px",
|
|
49
|
+
fabButtonSize = "20px"
|
|
50
|
+
// Default to 20px as requested
|
|
51
|
+
} = props;
|
|
52
|
+
const listContext = useSafeListContext();
|
|
53
|
+
const setFilters = listContext == null ? void 0 : listContext.setFilters;
|
|
54
|
+
const unselectAll = useUnselectAll(((_a = resourceConfig.listProps) == null ? void 0 : _a.storeKey) || resourceConfig.model);
|
|
55
|
+
const FilterComponent = resourceConfig.FilterFormComponent ? resourceConfig.FilterFormComponent : resourceConfig.filterWithSubmit === true ? DashAutoListFilterFormWithButton : ToolbarFilters;
|
|
56
|
+
const ref = React.useRef(null);
|
|
57
|
+
const refresh = useRefresh();
|
|
58
|
+
const clearFilters = () => {
|
|
59
|
+
var _a2;
|
|
60
|
+
unselectAll();
|
|
61
|
+
if (setFilters) {
|
|
62
|
+
setFilters({}, []);
|
|
63
|
+
}
|
|
64
|
+
(_a2 = ref.current) == null ? void 0 : _a2.reset();
|
|
65
|
+
};
|
|
66
|
+
const refreshList = () => {
|
|
67
|
+
refresh();
|
|
68
|
+
};
|
|
69
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
70
|
+
/* @__PURE__ */ jsxs(
|
|
71
|
+
"div",
|
|
72
|
+
{
|
|
73
|
+
style: {
|
|
74
|
+
display: "flex",
|
|
75
|
+
justifyContent: "flex-start",
|
|
76
|
+
flexWrap: "wrap"
|
|
77
|
+
},
|
|
78
|
+
className: "toolbar-actions",
|
|
79
|
+
children: [
|
|
80
|
+
/* @__PURE__ */ jsx(ToolbarCreateButton, { mode: "create", resourceConfig }),
|
|
81
|
+
/* @__PURE__ */ jsx(ToolbarExportButton, { mode: "create", resourceConfig }),
|
|
82
|
+
typeof resourceConfig.customToolbarElements === "function" ? resourceConfig.customToolbarElements(filters) : resourceConfig.customToolbarElements,
|
|
83
|
+
typeof resourceConfig.customToolbarActions === "function" ? resourceConfig.customToolbarActions(filters) : resourceConfig.customToolbarActions,
|
|
84
|
+
!!resourceConfig.showSavedQueries && /* @__PURE__ */ jsx(SavedQueriesList, {})
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
),
|
|
88
|
+
countFilters ? /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
89
|
+
Collapse,
|
|
90
|
+
{
|
|
91
|
+
className: "toolbar-collapse",
|
|
92
|
+
orientation: "vertical",
|
|
93
|
+
collapsedSize,
|
|
94
|
+
in: expanded,
|
|
95
|
+
timeout: "auto",
|
|
96
|
+
children: /* @__PURE__ */ jsx("div", { className: "toolbar-filters", children: /* @__PURE__ */ jsx(FilterComponent, { ref, resourceConfig, filters }) })
|
|
97
|
+
}
|
|
98
|
+
) }) : /* @__PURE__ */ jsx(Fragment, {}),
|
|
99
|
+
countFilters && (resourceConfig == null ? void 0 : resourceConfig.filterWithSubmit) === true && (resourceConfig == null ? void 0 : resourceConfig.filterButtonPosition) !== "filters-container" ? /* @__PURE__ */ jsx(
|
|
100
|
+
"div",
|
|
101
|
+
{
|
|
102
|
+
style: {
|
|
103
|
+
display: "flex",
|
|
104
|
+
justifyContent: "flex-end",
|
|
105
|
+
flexWrap: "wrap"
|
|
106
|
+
},
|
|
107
|
+
className: "toolbar-buttons",
|
|
108
|
+
children: /* @__PURE__ */ jsx(
|
|
109
|
+
Button,
|
|
110
|
+
{
|
|
111
|
+
endIcon: /* @__PURE__ */ jsx(Search, {}),
|
|
112
|
+
variant: "contained",
|
|
113
|
+
onClick: () => {
|
|
114
|
+
var _a2;
|
|
115
|
+
(_a2 = ref.current) == null ? void 0 : _a2.submit();
|
|
116
|
+
},
|
|
117
|
+
children: "Filtrar"
|
|
118
|
+
}
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
) : /* @__PURE__ */ jsx(Fragment, {}),
|
|
122
|
+
/* @__PURE__ */ jsxs(Box, { className: "toolbar-right-buttons", sx: {
|
|
123
|
+
gap: 0.5,
|
|
124
|
+
padding: 0.5
|
|
125
|
+
}, children: [
|
|
126
|
+
/* @__PURE__ */ jsx(
|
|
127
|
+
FabButton,
|
|
128
|
+
{
|
|
129
|
+
onClick: refreshList,
|
|
130
|
+
size: "small",
|
|
131
|
+
"aria-label": "refresh",
|
|
132
|
+
color: "primary",
|
|
133
|
+
icon: /* @__PURE__ */ jsx(Refresh, { sx: { fontSize: "1rem" } }),
|
|
134
|
+
tooltip: "Refrescar",
|
|
135
|
+
style: {
|
|
136
|
+
width: fabButtonSize,
|
|
137
|
+
height: fabButtonSize,
|
|
138
|
+
minHeight: fabButtonSize
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
),
|
|
142
|
+
countFilters && autoFilters ? /* @__PURE__ */ jsx(
|
|
143
|
+
FabButton,
|
|
144
|
+
{
|
|
145
|
+
onClick: clearFilters,
|
|
146
|
+
size: "small",
|
|
147
|
+
"aria-label": "refresh",
|
|
148
|
+
color: "primary",
|
|
149
|
+
icon: /* @__PURE__ */ jsx(FilterAltOffIcon, { sx: { fontSize: "1rem" } }),
|
|
150
|
+
tooltip: "Borrar filtros",
|
|
151
|
+
style: {
|
|
152
|
+
width: fabButtonSize,
|
|
153
|
+
height: fabButtonSize,
|
|
154
|
+
minHeight: fabButtonSize
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
) : /* @__PURE__ */ jsx(Fragment, {}),
|
|
158
|
+
countFilters ? /* @__PURE__ */ jsx(
|
|
159
|
+
Fab,
|
|
160
|
+
{
|
|
161
|
+
size: "small",
|
|
162
|
+
"aria-label": "collapse",
|
|
163
|
+
color: "primary",
|
|
164
|
+
onClick: () => setExpanded(!expanded),
|
|
165
|
+
style: {
|
|
166
|
+
width: fabButtonSize,
|
|
167
|
+
height: fabButtonSize,
|
|
168
|
+
minHeight: fabButtonSize
|
|
169
|
+
},
|
|
170
|
+
className: "toolbar-collapse-button",
|
|
171
|
+
children: expanded ? /* @__PURE__ */ jsx(KeyboardArrowDown, { sx: { fontSize: "1rem" } }) : /* @__PURE__ */ jsx(KeyboardArrowUp, { sx: { fontSize: "1rem" } })
|
|
172
|
+
}
|
|
173
|
+
) : /* @__PURE__ */ jsx(Fragment, {})
|
|
174
|
+
] })
|
|
175
|
+
] });
|
|
176
|
+
};
|
|
177
|
+
var DashAutoListTopToolbar_default = DashAutoListTopToolbar;
|
|
178
|
+
export {
|
|
179
|
+
DashAutoListTopToolbar_default as default
|
|
180
|
+
};
|