drf-react-by-schema 0.28.2 → 0.28.3
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 +11 -0
- package/dist/components/DataGridBySchemaEditable/GeoEditCell.d.ts.map +1 -1
- package/dist/components/DataGridBySchemaEditable/GeoEditCell.js +7 -3
- package/dist/components/DataGridBySchemaEditable/GeoThumbCell.d.ts.map +1 -1
- package/dist/components/DataGridBySchemaEditable/GeoThumbCell.js +3 -0
- package/dist/components/DialogActions.d.ts.map +1 -1
- package/dist/components/DialogActions.js +8 -3
- package/dist/components/forms/DialogFormBySchema.d.ts.map +1 -1
- package/dist/components/forms/DialogFormBySchema.js +7 -4
- package/dist/components/forms/FormActions.d.ts.map +1 -1
- package/dist/components/forms/FormActions.js +13 -9
- package/dist/components/forms/inputs/MapGeometryPicker.d.ts.map +1 -1
- package/dist/components/forms/inputs/MapGeometryPicker.js +8 -3
- package/dist/components/forms/inputs/leafletMarker.d.ts +12 -0
- package/dist/components/forms/inputs/leafletMarker.d.ts.map +1 -0
- package/dist/components/forms/inputs/leafletMarker.js +52 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/styles/texts.d.ts +27 -0
- package/dist/styles/texts.d.ts.map +1 -0
- package/dist/styles/texts.js +34 -0
- package/dist/styles/theme.d.ts +7 -0
- package/dist/styles/theme.d.ts.map +1 -1
- package/dist/styles/theme.js +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -45,6 +45,17 @@ read-only thumbnail map in the DataGrid.
|
|
|
45
45
|
See the complete table of field types and their widgets (including the geometry
|
|
46
46
|
behaviours — add/move/remove rules, GeoJSON text sync and fallbacks) in
|
|
47
47
|
**[`docs/FIELD_TYPES.md`](docs/FIELD_TYPES.md)**.
|
|
48
|
+
|
|
49
|
+
## Localization & theming
|
|
50
|
+
|
|
51
|
+
User-facing strings (geometry picker, form/dialog action buttons, …) are exposed through
|
|
52
|
+
the **MUI theme** (`theme.texts`), so you can localize every widget in your own `theme.ts`
|
|
53
|
+
— no provider changes. The package ships with sensible defaults and also localizes the
|
|
54
|
+
MUI components it renders (DataGrid, date pickers) to pt-BR.
|
|
55
|
+
|
|
56
|
+
See the full reference (namespaces, precedence, MUI locale setup, custom markers) in
|
|
57
|
+
**[`docs/localization.md`](docs/localization.md)**.
|
|
58
|
+
|
|
48
59
|
## Getting started
|
|
49
60
|
|
|
50
61
|
1. Build the Django model (a guide is available at https://pypi.org/project/drf-react-by-schema/)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GeoEditCell.d.ts","sourceRoot":"","sources":["../../../src/components/DataGridBySchemaEditable/GeoEditCell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"GeoEditCell.d.ts","sourceRoot":"","sources":["../../../src/components/DataGridBySchemaEditable/GeoEditCell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAQxC,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAKjD,UAAU,gBAAiB,SAAQ,wBAAwB;IACzD,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,EAAE,EACF,KAAK,EACL,GAAG,EACH,KAAK,EACL,QAAQ,EACR,MAAY,GACb,EAAE,gBAAgB,qBA4DlB"}
|
|
@@ -44,9 +44,13 @@ const Button_1 = __importDefault(require("@mui/material/Button"));
|
|
|
44
44
|
const IconButton_1 = __importDefault(require("@mui/material/IconButton"));
|
|
45
45
|
const Modal_1 = __importDefault(require("@mui/material/Modal"));
|
|
46
46
|
const Close_1 = __importDefault(require("@mui/icons-material/Close"));
|
|
47
|
+
const styles_1 = require("@mui/material/styles");
|
|
47
48
|
const utils_1 = require("../../utils");
|
|
48
49
|
const MapGeometryPicker_1 = __importDefault(require("../forms/inputs/MapGeometryPicker"));
|
|
50
|
+
const texts_1 = require("../../styles/texts");
|
|
49
51
|
function GeoEditCell({ id, field, api, value, geometry, height = 360, }) {
|
|
52
|
+
const texts = (0, texts_1.getThemeTexts)((0, styles_1.useTheme)());
|
|
53
|
+
const geometryTexts = texts.geometry;
|
|
50
54
|
const [open, setOpen] = (0, react_1.useState)(false);
|
|
51
55
|
const [draft, setDraft] = (0, react_1.useState)((0, utils_1.geometryValueToString)(value));
|
|
52
56
|
const handleOpen = () => {
|
|
@@ -60,7 +64,7 @@ function GeoEditCell({ id, field, api, value, geometry, height = 360, }) {
|
|
|
60
64
|
api.setEditCellValue({ id, field, value: (0, utils_1.parseGeoJSON)(geometry, geoJSON) });
|
|
61
65
|
};
|
|
62
66
|
return (react_1.default.createElement(Box_1.default, { sx: { display: 'flex', alignItems: 'center' } },
|
|
63
|
-
react_1.default.createElement(Button_1.default, { size: "small", variant: "outlined", onClick: handleOpen }, value ?
|
|
67
|
+
react_1.default.createElement(Button_1.default, { size: "small", variant: "outlined", onClick: handleOpen }, value ? geometryTexts.edit : geometryTexts.define),
|
|
64
68
|
react_1.default.createElement(Modal_1.default, { open: open, onClose: () => setOpen(false), sx: { display: 'flex', alignItems: 'center', justifyContent: 'center', p: 2 } },
|
|
65
69
|
react_1.default.createElement(Box_1.default, { sx: {
|
|
66
70
|
width: '100%',
|
|
@@ -74,8 +78,8 @@ function GeoEditCell({ id, field, api, value, geometry, height = 360, }) {
|
|
|
74
78
|
outline: 'none',
|
|
75
79
|
} },
|
|
76
80
|
react_1.default.createElement(Box_1.default, { sx: { display: 'flex', justifyContent: 'space-between', alignItems: 'center', mb: 1 } },
|
|
77
|
-
react_1.default.createElement(Typography_1.default, { variant: "h6" },
|
|
78
|
-
react_1.default.createElement(IconButton_1.default, { onClick: () => setOpen(false), "aria-label":
|
|
81
|
+
react_1.default.createElement(Typography_1.default, { variant: "h6" }, geometryTexts.drawSelectTitle),
|
|
82
|
+
react_1.default.createElement(IconButton_1.default, { onClick: () => setOpen(false), "aria-label": geometryTexts.close, size: "small" },
|
|
79
83
|
react_1.default.createElement(Close_1.default, null))),
|
|
80
84
|
react_1.default.createElement(MapGeometryPicker_1.default, { geometry: geometry, value: draft, onChange: handleChange, height: height })))));
|
|
81
85
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GeoThumbCell.d.ts","sourceRoot":"","sources":["../../../src/components/DataGridBySchemaEditable/GeoThumbCell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"GeoThumbCell.d.ts","sourceRoot":"","sources":["../../../src/components/DataGridBySchemaEditable/GeoThumbCell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAOzC,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AA8B/D,UAAU,iBAAiB;IACzB,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,KAAK,EAAE,YAAY,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,QAAQ,EACR,KAAK,EACL,KAAwB,EACxB,MAAyB,GAC1B,EAAE,iBAAiB,qBAqCnB"}
|
|
@@ -41,8 +41,11 @@ const react_1 = __importStar(require("react"));
|
|
|
41
41
|
const Box_1 = __importDefault(require("@mui/material/Box"));
|
|
42
42
|
const react_leaflet_1 = require("react-leaflet");
|
|
43
43
|
const leaflet_1 = __importDefault(require("leaflet"));
|
|
44
|
+
const leafletMarker_1 = require("../forms/inputs/leafletMarker");
|
|
44
45
|
const utils_1 = require("../../utils");
|
|
45
46
|
const geoConstants_1 = require("./geoConstants");
|
|
47
|
+
// L.geoJSON point markers use L.Icon.Default; ensure it points at a servable icon.
|
|
48
|
+
(0, leafletMarker_1.applyDefaultLeafletIcon)();
|
|
46
49
|
// Fits the rendered geometry and keeps the thumb static (no pan/zoom).
|
|
47
50
|
function FitGeometry({ data }) {
|
|
48
51
|
const map = (0, react_leaflet_1.useMap)();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DialogActions.d.ts","sourceRoot":"","sources":["../../src/components/DialogActions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"DialogActions.d.ts","sourceRoot":"","sources":["../../src/components/DialogActions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAG1D,UAAU,kBAAkB;IAC1B,SAAS,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;IAC5C,UAAU,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AACD,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,SAAS,EACT,UAAU,EACV,SAAS,EACT,UAAU,GACX,EAAE,kBAAkB,qBAepB"}
|
|
@@ -6,10 +6,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.default = DialogActions;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const Button_1 = __importDefault(require("@mui/material/Button"));
|
|
9
|
-
|
|
9
|
+
const styles_1 = require("@mui/material/styles");
|
|
10
|
+
const texts_1 = require("../styles/texts");
|
|
11
|
+
function DialogActions({ setDialog, handleSave, btnCancel, btnConfirm, }) {
|
|
12
|
+
const formTexts = (0, texts_1.getThemeTexts)((0, styles_1.useTheme)()).forms;
|
|
13
|
+
const cancelLabel = btnCancel !== null && btnCancel !== void 0 ? btnCancel : formTexts.dialogCancel;
|
|
14
|
+
const confirmLabel = btnConfirm !== null && btnConfirm !== void 0 ? btnConfirm : formTexts.dialogSave;
|
|
10
15
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
11
16
|
react_1.default.createElement(Button_1.default, { onClick: () => {
|
|
12
17
|
setDialog({ open: false });
|
|
13
|
-
} },
|
|
14
|
-
handleSave && react_1.default.createElement(Button_1.default, { onClick: handleSave },
|
|
18
|
+
} }, cancelLabel),
|
|
19
|
+
handleSave && react_1.default.createElement(Button_1.default, { onClick: handleSave }, confirmLabel)));
|
|
15
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DialogFormBySchema.d.ts","sourceRoot":"","sources":["../../../src/components/forms/DialogFormBySchema.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiC,MAAM,OAAO,CAAC;AACtD,OAAc,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,EAAE,eAAe,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"DialogFormBySchema.d.ts","sourceRoot":"","sources":["../../../src/components/forms/DialogFormBySchema.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiC,MAAM,OAAO,CAAC;AACtD,OAAc,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,EAAE,eAAe,EAAE,MAAM,KAAK,CAAC;AAMtC,OAAO,EACL,gBAAgB,EAChB,SAAS,EACT,eAAe,EACf,IAAI,EACJ,SAAS,EACT,UAAU,EACV,MAAM,EACP,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAI7D,UAAU,uBAAuB,CAAC,CAAC,SAAS,MAAM,GAAG,IAAI;IACvD,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACtB,gBAAgB,EAAE,eAAe,CAAC;IAClC,aAAa,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IACvB,eAAe,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,OAAO,GAAG,UAAU,CAAC,CAAC;IAC/D,SAAS,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;IAC5C,eAAe,EAAE,CACf,KAAK,EAAE,MAAM,EACb,WAAW,CAAC,EAAE,MAAM,EAAE,KACnB,OAAO,CAAC,gBAAgB,EAAE,GAAG,UAAU,CAAC,CAAC;IAC9C,YAAY,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;IACpC,YAAY,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IAC5B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,SAAS,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACzB,YAAY,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;CAClD;AAED,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,CAAC,SAAS,MAAM,GAAG,IAAI,EAAE,EAClE,MAAM,EACN,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,SAAS,EACT,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,SAAS,GACV,EAAE,uBAAuB,CAAC,CAAC,CAAC,qBAwF5B"}
|
|
@@ -52,10 +52,13 @@ const react_hook_form_1 = require("react-hook-form");
|
|
|
52
52
|
const yup_1 = require("@hookform/resolvers/yup");
|
|
53
53
|
const Box_1 = __importDefault(require("@mui/material/Box"));
|
|
54
54
|
const Button_1 = __importDefault(require("@mui/material/Button"));
|
|
55
|
-
const styles_1 = require("
|
|
55
|
+
const styles_1 = require("@mui/material/styles");
|
|
56
|
+
const styles_2 = require("../../styles");
|
|
56
57
|
const FormBySchema_1 = __importDefault(require("./FormBySchema"));
|
|
57
58
|
const utils_1 = require("../../utils");
|
|
59
|
+
const texts_1 = require("../../styles/texts");
|
|
58
60
|
function DialogFormBySchema({ schema, validationSchema, initialValues, onEditModelSave, setDialog, getAutoComplete, fieldsLayout, hiddenFields, isCancelDisabled, forceSaveEnabled, optionsAC, }) {
|
|
61
|
+
const formTexts = (0, texts_1.getThemeTexts)((0, styles_1.useTheme)()).forms;
|
|
59
62
|
const { control, handleSubmit, reset, getValues, setValue, setError, formState: { errors, isDirty }, } = (0, react_hook_form_1.useForm)({
|
|
60
63
|
mode: 'onBlur',
|
|
61
64
|
resolver: validationSchema ? (0, yup_1.yupResolver)(validationSchema) : undefined,
|
|
@@ -84,11 +87,11 @@ function DialogFormBySchema({ schema, validationSchema, initialValues, onEditMod
|
|
|
84
87
|
return (react_1.default.createElement(react_1.default.Fragment, null, initialValues && control && (react_1.default.createElement("form", { onSubmit: handleSubmit(handleSubmitWrapper) },
|
|
85
88
|
react_1.default.createElement(Box_1.default, null,
|
|
86
89
|
react_1.default.createElement(FormBySchema_1.default, { control: control, errors: errors, schema: schema, getValues: getValues, setValue: setValue, optionsAC: optionsAC, isolatedGetAutoComplete: getAutoComplete, fieldsLayout: fieldsLayout, hiddenFields: hiddenFields, relatedEditable: false })),
|
|
87
|
-
react_1.default.createElement(Box_1.default, { sx:
|
|
90
|
+
react_1.default.createElement(Box_1.default, { sx: styles_2.Layout.flexRow },
|
|
88
91
|
!isCancelDisabled && (react_1.default.createElement(Button_1.default, { variant: "contained", color: "primary", size: "small", sx: { ml: 1 }, onClick: () => {
|
|
89
92
|
setDialog({
|
|
90
93
|
open: false,
|
|
91
94
|
});
|
|
92
|
-
} },
|
|
93
|
-
react_1.default.createElement(Button_1.default, { variant: "contained", name: "exitOnSave", disabled: !forceSaveEnabled && !isDirty, type: "submit", color: "primary", size: "small" },
|
|
95
|
+
} }, formTexts.dialogCancel)),
|
|
96
|
+
react_1.default.createElement(Button_1.default, { variant: "contained", name: "exitOnSave", disabled: !forceSaveEnabled && !isDirty, type: "submit", color: "primary", size: "small" }, formTexts.dialogSave))))));
|
|
94
97
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormActions.d.ts","sourceRoot":"","sources":["../../../src/components/forms/FormActions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,OAAO,EAAmB,EAAE,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"FormActions.d.ts","sourceRoot":"","sources":["../../../src/components/forms/FormActions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,OAAO,EAAmB,EAAE,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAI3D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,EAAE,CAAC;IACX,QAAQ,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IACtD,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,EAAE,KAAK,IAAI,CAAC;IACnC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,KAAK,IAAI,CAAC;IACxB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,CAAC,SAAS,MAAM,GAAG,IAAI,EAAE,EAC3D,YAAY,EACZ,KAAK,EACL,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,eAAe,EACf,KAAK,EACL,SAAS,EACT,oBAAoB,EACpB,qBAAqB,EACrB,WAAW,EACX,WAAW,GACZ,EAAE,gBAAgB,qBAiHlB"}
|
|
@@ -8,16 +8,20 @@ const react_1 = __importDefault(require("react"));
|
|
|
8
8
|
const Box_1 = __importDefault(require("@mui/material/Box"));
|
|
9
9
|
const Button_1 = __importDefault(require("@mui/material/Button"));
|
|
10
10
|
const Typography_1 = __importDefault(require("@mui/material/Typography"));
|
|
11
|
-
const styles_1 = require("
|
|
11
|
+
const styles_1 = require("@mui/material/styles");
|
|
12
|
+
const styles_2 = require("../../styles");
|
|
12
13
|
const utils_1 = require("../../utils");
|
|
13
14
|
const _types_1 = require("../../@types");
|
|
14
15
|
const APIWrapperContext_1 = require("../../context/APIWrapperContext");
|
|
16
|
+
const texts_1 = require("../../styles/texts");
|
|
15
17
|
function FormActions({ formDisabled, model, objId, onCancel, onDelete, exit, bottom, saveAndContinue, title, labelSave, labelSaveAndContinue, labelSaveAndCreateNew, labelCancel, labelRemove, }) {
|
|
16
18
|
const { onDeleteModel, isMobile } = (0, APIWrapperContext_1.useAPIWrapper)();
|
|
19
|
+
const texts = (0, texts_1.getThemeTexts)((0, styles_1.useTheme)());
|
|
20
|
+
const formTexts = texts.forms;
|
|
17
21
|
if (isMobile && !bottom) {
|
|
18
22
|
return react_1.default.createElement(react_1.default.Fragment, null);
|
|
19
23
|
}
|
|
20
|
-
const finalSx = Object.assign(Object.assign({},
|
|
24
|
+
const finalSx = Object.assign(Object.assign({}, styles_2.Layout.flexRowGrow), (bottom && !(0, utils_1.isTmpId)(objId)
|
|
21
25
|
? {
|
|
22
26
|
mb: 5,
|
|
23
27
|
pb: 2,
|
|
@@ -40,12 +44,12 @@ function FormActions({ formDisabled, model, objId, onCancel, onDelete, exit, bot
|
|
|
40
44
|
exit(objId);
|
|
41
45
|
};
|
|
42
46
|
return (react_1.default.createElement(Box_1.default, { sx: finalSx },
|
|
43
|
-
bottom ? (react_1.default.createElement(Button_1.default, { variant: "contained", type: "button", color: "error", size: "small", disabled: (0, utils_1.isTmpId)(objId) || !onDeleteModel, onClick: handleDelete }, labelRemove ||
|
|
44
|
-
isMobile ? (react_1.default.createElement(Box_1.default, { sx:
|
|
45
|
-
react_1.default.createElement(Button_1.default, { variant: "contained", name: _types_1.FormSaveActions.EXIT_ON_SAVE, type: "submit", color: "primary", size: "small", sx: { ml: 1 }, disabled: formDisabled }, labelSave ||
|
|
46
|
-
react_1.default.createElement(Button_1.default, { variant: "contained", color: "primary", size: "small", sx: { ml: 1 }, onClick: handleCancel }, labelCancel ||
|
|
47
|
+
bottom ? (react_1.default.createElement(Button_1.default, { variant: "contained", type: "button", color: "error", size: "small", disabled: (0, utils_1.isTmpId)(objId) || !onDeleteModel, onClick: handleDelete }, labelRemove || formTexts.remove)) : title ? (react_1.default.createElement(Typography_1.default, { variant: "h5" }, title)) : (react_1.default.createElement(Box_1.default, null)),
|
|
48
|
+
isMobile ? (react_1.default.createElement(Box_1.default, { sx: styles_2.Layout.flexRow },
|
|
49
|
+
react_1.default.createElement(Button_1.default, { variant: "contained", name: _types_1.FormSaveActions.EXIT_ON_SAVE, type: "submit", color: "primary", size: "small", sx: { ml: 1 }, disabled: formDisabled }, labelSave || formTexts.save))) : (react_1.default.createElement(Box_1.default, { sx: styles_2.Layout.flexRow },
|
|
50
|
+
react_1.default.createElement(Button_1.default, { variant: "contained", color: "primary", size: "small", sx: { ml: 1 }, onClick: handleCancel }, labelCancel || formTexts.cancel),
|
|
47
51
|
!isMobile && saveAndContinue && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
48
|
-
react_1.default.createElement(Button_1.default, { variant: "contained", name: _types_1.FormSaveActions.SAVE_AND_CREATE_NEW, type: "submit", color: "secondary", size: "small", sx: { ml: 1 }, disabled: formDisabled }, labelSaveAndCreateNew ||
|
|
49
|
-
react_1.default.createElement(Button_1.default, { variant: "contained", name: _types_1.FormSaveActions.SAVE_AND_CONTINUE, type: "submit", color: "secondary", size: "small", sx: { ml: 1 }, disabled: formDisabled }, labelSaveAndContinue ||
|
|
50
|
-
react_1.default.createElement(Button_1.default, { variant: "contained", name: _types_1.FormSaveActions.EXIT_ON_SAVE, type: "submit", color: "primary", size: "small", sx: { ml: 1 }, disabled: formDisabled }, labelSave ||
|
|
52
|
+
react_1.default.createElement(Button_1.default, { variant: "contained", name: _types_1.FormSaveActions.SAVE_AND_CREATE_NEW, type: "submit", color: "secondary", size: "small", sx: { ml: 1 }, disabled: formDisabled }, labelSaveAndCreateNew || formTexts.saveAndCreateNew),
|
|
53
|
+
react_1.default.createElement(Button_1.default, { variant: "contained", name: _types_1.FormSaveActions.SAVE_AND_CONTINUE, type: "submit", color: "secondary", size: "small", sx: { ml: 1 }, disabled: formDisabled }, labelSaveAndContinue || formTexts.saveAndContinue))),
|
|
54
|
+
react_1.default.createElement(Button_1.default, { variant: "contained", name: _types_1.FormSaveActions.EXIT_ON_SAVE, type: "submit", color: "primary", size: "small", sx: { ml: 1 }, disabled: formDisabled }, labelSave || formTexts.save)))));
|
|
51
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapGeometryPicker.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/inputs/MapGeometryPicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAIjD,OAAO,EAAE,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"MapGeometryPicker.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/inputs/MapGeometryPicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAIjD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAY,MAAM,sBAAsB,CAAC;AAGhE,OAAO,0BAA0B,CAAC;AAElC,OAAO,cAAc,CAAC;AACtB,OAAO,oCAAoC,CAAC;AAI5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAMpD,UAAU,sBAAsB;IAC9B,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC3C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,EAAE,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AA4LD,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,QAAQ,EACR,KAAK,EACL,KAAK,EACL,QAAQ,EACR,KAAK,EACL,UAAU,EACV,EAAE,EACF,MAAY,GACb,EAAE,sBAAsB,qBAsDxB"}
|
|
@@ -41,13 +41,18 @@ const react_1 = __importStar(require("react"));
|
|
|
41
41
|
const Box_1 = __importDefault(require("@mui/material/Box"));
|
|
42
42
|
const TextField_1 = __importDefault(require("@mui/material/TextField"));
|
|
43
43
|
const FormHelperText_1 = __importDefault(require("@mui/material/FormHelperText"));
|
|
44
|
+
const styles_1 = require("@mui/material/styles");
|
|
44
45
|
const react_leaflet_1 = require("react-leaflet");
|
|
45
46
|
const leaflet_1 = __importDefault(require("leaflet"));
|
|
46
47
|
require("leaflet/dist/leaflet.css");
|
|
47
48
|
// leaflet-draw does not export; augments global L with Control.Draw.
|
|
48
49
|
require("leaflet-draw");
|
|
49
50
|
require("leaflet-draw/dist/leaflet.draw.css");
|
|
51
|
+
const leafletMarker_1 = require("./leafletMarker");
|
|
52
|
+
const texts_1 = require("../../../styles/texts");
|
|
50
53
|
const utils_1 = require("../../../utils");
|
|
54
|
+
// Markers need a servable icon; leaflet's stock icons 404 inside an SPA.
|
|
55
|
+
(0, leafletMarker_1.applyDefaultLeafletIcon)();
|
|
51
56
|
// Build the drf-react-by-schema geometry out of leaflet-draw features. Leaflet
|
|
52
57
|
// already parses/produces GeoJSON (L.geoJSON, FeatureGroup.toGeoJSON), so here
|
|
53
58
|
// we only reshape the resulting features into the right geometry type.
|
|
@@ -224,6 +229,8 @@ function DrawEditor({ geometry, value, onChange, }) {
|
|
|
224
229
|
return null;
|
|
225
230
|
}
|
|
226
231
|
function MapGeometryPicker({ geometry, value, label, onChange, error, helperText, sx, height = 340, }) {
|
|
232
|
+
const texts = (0, texts_1.getThemeTexts)((0, styles_1.useTheme)());
|
|
233
|
+
const geometryTexts = texts.geometry;
|
|
227
234
|
const valueText = value || '';
|
|
228
235
|
// Malformed detection: non-empty text that isn't GeoJSON (or of the wrong
|
|
229
236
|
// geometry type). Invalid input is flagged as an error instead of silently
|
|
@@ -241,9 +248,7 @@ function MapGeometryPicker({ geometry, value, label, onChange, error, helperText
|
|
|
241
248
|
react_1.default.createElement(react_leaflet_1.MapContainer, { center: [-14.235, -51.9253], zoom: 4, style: { height: '100%', width: '100%' }, zoomControl: true },
|
|
242
249
|
react_1.default.createElement(react_leaflet_1.TileLayer, { attribution: "\u00A9 OpenStreetMap contributors", url: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" }),
|
|
243
250
|
react_1.default.createElement(DrawEditor, { geometry: geometry, value: value, onChange: onChange }))),
|
|
244
|
-
react_1.default.createElement(TextField_1.default, { value: value, onChange: (e) => onChange(e.target.value || null), variant: "outlined", margin: "dense", fullWidth: true, size: "small", label: geometry === 'point' ?
|
|
245
|
-
? 'Dados malformados, corrija o GeoJSON para refletir no mapa.'
|
|
246
|
-
: 'O GeoJSON abaixo é sincronizado com o mapa.' }),
|
|
251
|
+
react_1.default.createElement(TextField_1.default, { value: value, onChange: (e) => onChange(e.target.value || null), variant: "outlined", margin: "dense", fullWidth: true, size: "small", label: geometry === 'point' ? geometryTexts.labelPoint : geometryTexts.labelOther, multiline: geometry !== 'point', minRows: geometry !== 'point' ? 3 : 1, sx: { mt: 1 }, error: malformed, helperText: malformed ? geometryTexts.malformed : geometryTexts.synced }),
|
|
247
252
|
label && react_1.default.createElement(FormHelperText_1.default, { sx: { mt: 0.5 } }, label),
|
|
248
253
|
(helperText || error) && (react_1.default.createElement(FormHelperText_1.default, { error: error, sx: { mt: 0.5 } }, helperText))));
|
|
249
254
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import L from 'leaflet';
|
|
2
|
+
export declare const DEFAULT_MARKER_PIN_SVG: string;
|
|
3
|
+
export declare const DEFAULT_MARKER_SHADOW_SVG: string;
|
|
4
|
+
export declare const DEFAULT_MARKER_ICON_URL: string;
|
|
5
|
+
export declare const DEFAULT_MARKER_SHADOW_URL: string;
|
|
6
|
+
/**
|
|
7
|
+
* Point L.Icon.Default at a servable marker so geometry widgets render points.
|
|
8
|
+
* No args: apply the built-in SVG icon once; skip if any icon is already set.
|
|
9
|
+
* With `userOptions`: always merge (custom marker wins).
|
|
10
|
+
*/
|
|
11
|
+
export declare function applyDefaultLeafletIcon(userOptions?: Partial<L.IconOptions>): void;
|
|
12
|
+
//# sourceMappingURL=leafletMarker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"leafletMarker.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/inputs/leafletMarker.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,SAAS,CAAC;AAKxB,eAAO,MAAM,sBAAsB,QAIzB,CAAC;AAEX,eAAO,MAAM,yBAAyB,QAG5B,CAAC;AAIX,eAAO,MAAM,uBAAuB,QAAoC,CAAC;AACzE,eAAO,MAAM,yBAAyB,QAAuC,CAAC;AAgB9E;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,IAAI,CAalF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DEFAULT_MARKER_SHADOW_URL = exports.DEFAULT_MARKER_ICON_URL = exports.DEFAULT_MARKER_SHADOW_SVG = exports.DEFAULT_MARKER_PIN_SVG = void 0;
|
|
7
|
+
exports.applyDefaultLeafletIcon = applyDefaultLeafletIcon;
|
|
8
|
+
const leaflet_1 = __importDefault(require("leaflet"));
|
|
9
|
+
// Leaflet's stock icons are page-relative PNGs that 404 inside an SPA. Use an
|
|
10
|
+
// inline-SVG data-URI default so markers render under any bundler with no assets.
|
|
11
|
+
exports.DEFAULT_MARKER_PIN_SVG = '<svg xmlns="http://www.w3.org/2000/svg" width="25" height="41" viewBox="0 0 25 41">' +
|
|
12
|
+
'<path d="M12.5 0C6.7 0 2.1 4.2 2.1 9.4c0 7.7 10.4 31.6 10.4 31.6S22.9 17.1 22.9 9.4C22.9 4.2 18.3 0 12.5 0z" fill="#3388ff" stroke="#ffffff" stroke-width="1.5" stroke-linejoin="round"/>' +
|
|
13
|
+
'<circle cx="12.5" cy="9" r="6.2" fill="#ffffff"/>' +
|
|
14
|
+
'</svg>';
|
|
15
|
+
exports.DEFAULT_MARKER_SHADOW_SVG = '<svg xmlns="http://www.w3.org/2000/svg" width="41" height="41" viewBox="0 0 41 41">' +
|
|
16
|
+
'<path d="M20.5 38c-5.4 0-9.7-1-9.9-2.2-.2-1.2 4.1-2.1 9.6-2.1 5.6 0 10.2 1 10 2.2-.2 1.2-4.3 2.1-9.7 2.1z" fill="rgba(0,0,0,0.4)"/>' +
|
|
17
|
+
'</svg>';
|
|
18
|
+
const toDataUri = (svg) => `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`;
|
|
19
|
+
exports.DEFAULT_MARKER_ICON_URL = toDataUri(exports.DEFAULT_MARKER_PIN_SVG);
|
|
20
|
+
exports.DEFAULT_MARKER_SHADOW_URL = toDataUri(exports.DEFAULT_MARKER_SHADOW_SVG);
|
|
21
|
+
let applied = false;
|
|
22
|
+
const DEFAULT_ICON_OPTIONS = {
|
|
23
|
+
iconUrl: exports.DEFAULT_MARKER_ICON_URL,
|
|
24
|
+
iconRetinaUrl: exports.DEFAULT_MARKER_ICON_URL, // SVG scales; stays crisp on retina
|
|
25
|
+
shadowUrl: exports.DEFAULT_MARKER_SHADOW_URL,
|
|
26
|
+
iconSize: leaflet_1.default.point(25, 41),
|
|
27
|
+
iconAnchor: leaflet_1.default.point(12, 41),
|
|
28
|
+
popupAnchor: leaflet_1.default.point(1, -34),
|
|
29
|
+
tooltipAnchor: leaflet_1.default.point(16, -28),
|
|
30
|
+
shadowSize: leaflet_1.default.point(41, 41),
|
|
31
|
+
shadowAnchor: leaflet_1.default.point(12, 41),
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Point L.Icon.Default at a servable marker so geometry widgets render points.
|
|
35
|
+
* No args: apply the built-in SVG icon once; skip if any icon is already set.
|
|
36
|
+
* With `userOptions`: always merge (custom marker wins).
|
|
37
|
+
*/
|
|
38
|
+
function applyDefaultLeafletIcon(userOptions) {
|
|
39
|
+
if (userOptions) {
|
|
40
|
+
leaflet_1.default.Icon.Default.mergeOptions(userOptions); // explicit custom icon wins
|
|
41
|
+
applied = true;
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (applied)
|
|
45
|
+
return;
|
|
46
|
+
if (leaflet_1.default.Icon.Default.prototype.options.iconUrl) {
|
|
47
|
+
applied = true; // consumer already picked their own icon; keep it
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
leaflet_1.default.Icon.Default.mergeOptions(DEFAULT_ICON_OPTIONS);
|
|
51
|
+
applied = true;
|
|
52
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -25,6 +25,9 @@ import DesktopDateTimePickerBySchema from './components/forms/inputs/DesktopDate
|
|
|
25
25
|
import EditableAutocompleteFieldBySchema from './components/forms/inputs/EditableAutocompleteFieldBySchema';
|
|
26
26
|
import AutocompleteFieldBySchema from './components/forms/inputs/AutocompleteFieldBySchema';
|
|
27
27
|
import FloatFieldBySchema from './components/forms/inputs/FloatFieldBySchema';
|
|
28
|
+
export { applyDefaultLeafletIcon } from './components/forms/inputs/leafletMarker';
|
|
29
|
+
export { getThemeTexts } from './styles/texts';
|
|
30
|
+
export type { DRFReactBySchemaTexts, GeometryTexts, FormTexts } from './styles/texts';
|
|
28
31
|
import DetailBySchema from './components/details/DetailBySchema';
|
|
29
32
|
import DetailFieldBySchema from './components/details/DetailFieldBySchema';
|
|
30
33
|
export { DRFReactBySchemaProvider, useAPIWrapper, Form, DialogFormBySchema, DataGridBySchemaEditable, GenericModelList, GenericRelatedModelList, DataTotals, DialogActions, FileTypeIcon, SelectEditInputCell, GridDateInput, GridDecimalInput, GridPatternInput, BooleanInputCell, FormWatcher, FormBySchema, FieldBySchema, TextFieldBySchema, BooleanFieldBySchema, DesktopDatePickerBySchema, DesktopDateTimePickerBySchema, EditableAutocompleteFieldBySchema, AutocompleteFieldBySchema, FloatFieldBySchema, DetailBySchema, DetailFieldBySchema, setAuthToken, emptyByType, getChoiceByValue, populateValues, buildGenericYupValidationSchema, errorProps, getFieldErrorsFromResponse, getTmpId, isTmpId, getPatternFormat, clearJWT, hasJWT, slugToCamelCase, AUTH_EXPIRED_EVENT, };
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAC3E,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,+BAA+B,EAC/B,UAAU,EACV,0BAA0B,EAC1B,QAAQ,EACR,OAAO,EACP,gBAAgB,EAChB,eAAe,EAChB,MAAM,SAAS,CAAC;AAGjB,OAAO,wBAAwB,MAAM,oCAAoC,CAAC;AAG1E,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAG5D,OAAO,IAAI,MAAM,yBAAyB,CAAC;AAC3C,OAAO,kBAAkB,MAAM,uCAAuC,CAAC;AAGvE,OAAO,wBAAwB,MAAM,uCAAuC,CAAC;AAC7E,OAAO,gBAAgB,MAAM,+BAA+B,CAAC;AAC7D,OAAO,uBAAuB,MAAM,sCAAsC,CAAC;AAC3E,OAAO,UAAU,MAAM,yBAAyB,CAAC;AACjD,OAAO,aAAa,MAAM,4BAA4B,CAAC;AACvD,OAAO,YAAY,MAAM,2BAA2B,CAAC;AAGrD,OAAO,mBAAmB,MAAM,2DAA2D,CAAC;AAC5F,OAAO,aAAa,MAAM,qDAAqD,CAAC;AAChF,OAAO,gBAAgB,MAAM,wDAAwD,CAAC;AACtF,OAAO,gBAAgB,MAAM,wDAAwD,CAAC;AACtF,OAAO,gBAAgB,MAAM,wDAAwD,CAAC;AAGtF,OAAO,WAAW,MAAM,gCAAgC,CAAC;AACzD,OAAO,YAAY,MAAM,iCAAiC,CAAC;AAC3D,OAAO,aAAa,MAAM,kCAAkC,CAAC;AAC7D,OAAO,iBAAiB,MAAM,6CAA6C,CAAC;AAC5E,OAAO,oBAAoB,MAAM,gDAAgD,CAAC;AAClF,OAAO,yBAAyB,MAAM,qDAAqD,CAAC;AAC5F,OAAO,6BAA6B,MAAM,yDAAyD,CAAC;AACpG,OAAO,iCAAiC,MAAM,6DAA6D,CAAC;AAC5G,OAAO,yBAAyB,MAAM,qDAAqD,CAAC;AAC5F,OAAO,kBAAkB,MAAM,8CAA8C,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAC3E,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,+BAA+B,EAC/B,UAAU,EACV,0BAA0B,EAC1B,QAAQ,EACR,OAAO,EACP,gBAAgB,EAChB,eAAe,EAChB,MAAM,SAAS,CAAC;AAGjB,OAAO,wBAAwB,MAAM,oCAAoC,CAAC;AAG1E,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAG5D,OAAO,IAAI,MAAM,yBAAyB,CAAC;AAC3C,OAAO,kBAAkB,MAAM,uCAAuC,CAAC;AAGvE,OAAO,wBAAwB,MAAM,uCAAuC,CAAC;AAC7E,OAAO,gBAAgB,MAAM,+BAA+B,CAAC;AAC7D,OAAO,uBAAuB,MAAM,sCAAsC,CAAC;AAC3E,OAAO,UAAU,MAAM,yBAAyB,CAAC;AACjD,OAAO,aAAa,MAAM,4BAA4B,CAAC;AACvD,OAAO,YAAY,MAAM,2BAA2B,CAAC;AAGrD,OAAO,mBAAmB,MAAM,2DAA2D,CAAC;AAC5F,OAAO,aAAa,MAAM,qDAAqD,CAAC;AAChF,OAAO,gBAAgB,MAAM,wDAAwD,CAAC;AACtF,OAAO,gBAAgB,MAAM,wDAAwD,CAAC;AACtF,OAAO,gBAAgB,MAAM,wDAAwD,CAAC;AAGtF,OAAO,WAAW,MAAM,gCAAgC,CAAC;AACzD,OAAO,YAAY,MAAM,iCAAiC,CAAC;AAC3D,OAAO,aAAa,MAAM,kCAAkC,CAAC;AAC7D,OAAO,iBAAiB,MAAM,6CAA6C,CAAC;AAC5E,OAAO,oBAAoB,MAAM,gDAAgD,CAAC;AAClF,OAAO,yBAAyB,MAAM,qDAAqD,CAAC;AAC5F,OAAO,6BAA6B,MAAM,yDAAyD,CAAC;AACpG,OAAO,iCAAiC,MAAM,6DAA6D,CAAC;AAC5G,OAAO,yBAAyB,MAAM,qDAAqD,CAAC;AAC5F,OAAO,kBAAkB,MAAM,8CAA8C,CAAC;AAC9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAClF,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,YAAY,EAAE,qBAAqB,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGtF,OAAO,cAAc,MAAM,qCAAqC,CAAC;AACjE,OAAO,mBAAmB,MAAM,0CAA0C,CAAC;AAE3E,OAAO,EAEL,wBAAwB,EAGxB,aAAa,EAGb,IAAI,EACJ,kBAAkB,EAGlB,wBAAwB,EACxB,gBAAgB,EAChB,uBAAuB,EACvB,UAAU,EACV,aAAa,EAGb,YAAY,EAGZ,mBAAmB,EACnB,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAGhB,WAAW,EACX,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,oBAAoB,EACpB,yBAAyB,EACzB,6BAA6B,EAC7B,iCAAiC,EACjC,yBAAyB,EACzB,kBAAkB,EAGlB,cAAc,EACd,mBAAmB,EAGnB,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,+BAA+B,EAC/B,UAAU,EACV,0BAA0B,EAC1B,QAAQ,EACR,OAAO,EACP,gBAAgB,EAChB,QAAQ,EACR,MAAM,EACN,eAAe,EACf,kBAAkB,GACnB,CAAC;AAEF,cAAc,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.AUTH_EXPIRED_EVENT = exports.slugToCamelCase = exports.hasJWT = exports.clearJWT = exports.getPatternFormat = exports.isTmpId = exports.getTmpId = exports.getFieldErrorsFromResponse = exports.errorProps = exports.buildGenericYupValidationSchema = exports.populateValues = exports.getChoiceByValue = exports.emptyByType = exports.setAuthToken = exports.DetailFieldBySchema = exports.DetailBySchema = exports.FloatFieldBySchema = exports.AutocompleteFieldBySchema = exports.EditableAutocompleteFieldBySchema = exports.DesktopDateTimePickerBySchema = exports.DesktopDatePickerBySchema = exports.BooleanFieldBySchema = exports.TextFieldBySchema = exports.FieldBySchema = exports.FormBySchema = exports.FormWatcher = exports.BooleanInputCell = exports.GridPatternInput = exports.GridDecimalInput = exports.GridDateInput = exports.SelectEditInputCell = exports.FileTypeIcon = exports.DialogActions = exports.DataTotals = exports.GenericRelatedModelList = exports.GenericModelList = exports.DataGridBySchemaEditable = exports.DialogFormBySchema = exports.Form = exports.useAPIWrapper = exports.DRFReactBySchemaProvider = void 0;
|
|
20
|
+
exports.AUTH_EXPIRED_EVENT = exports.slugToCamelCase = exports.hasJWT = exports.clearJWT = exports.getPatternFormat = exports.isTmpId = exports.getTmpId = exports.getFieldErrorsFromResponse = exports.errorProps = exports.buildGenericYupValidationSchema = exports.populateValues = exports.getChoiceByValue = exports.emptyByType = exports.setAuthToken = exports.DetailFieldBySchema = exports.DetailBySchema = exports.FloatFieldBySchema = exports.AutocompleteFieldBySchema = exports.EditableAutocompleteFieldBySchema = exports.DesktopDateTimePickerBySchema = exports.DesktopDatePickerBySchema = exports.BooleanFieldBySchema = exports.TextFieldBySchema = exports.FieldBySchema = exports.FormBySchema = exports.FormWatcher = exports.BooleanInputCell = exports.GridPatternInput = exports.GridDecimalInput = exports.GridDateInput = exports.SelectEditInputCell = exports.FileTypeIcon = exports.DialogActions = exports.DataTotals = exports.GenericRelatedModelList = exports.GenericModelList = exports.DataGridBySchemaEditable = exports.DialogFormBySchema = exports.Form = exports.useAPIWrapper = exports.DRFReactBySchemaProvider = exports.getThemeTexts = exports.applyDefaultLeafletIcon = void 0;
|
|
21
21
|
// Methods:
|
|
22
22
|
const api_1 = require("./api");
|
|
23
23
|
Object.defineProperty(exports, "setAuthToken", { enumerable: true, get: function () { return api_1.setAuthToken; } });
|
|
@@ -91,6 +91,10 @@ const AutocompleteFieldBySchema_1 = __importDefault(require("./components/forms/
|
|
|
91
91
|
exports.AutocompleteFieldBySchema = AutocompleteFieldBySchema_1.default;
|
|
92
92
|
const FloatFieldBySchema_1 = __importDefault(require("./components/forms/inputs/FloatFieldBySchema"));
|
|
93
93
|
exports.FloatFieldBySchema = FloatFieldBySchema_1.default;
|
|
94
|
+
var leafletMarker_1 = require("./components/forms/inputs/leafletMarker");
|
|
95
|
+
Object.defineProperty(exports, "applyDefaultLeafletIcon", { enumerable: true, get: function () { return leafletMarker_1.applyDefaultLeafletIcon; } });
|
|
96
|
+
var texts_1 = require("./styles/texts");
|
|
97
|
+
Object.defineProperty(exports, "getThemeTexts", { enumerable: true, get: function () { return texts_1.getThemeTexts; } });
|
|
94
98
|
// DetailComponents
|
|
95
99
|
const DetailBySchema_1 = __importDefault(require("./components/details/DetailBySchema"));
|
|
96
100
|
exports.DetailBySchema = DetailBySchema_1.default;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Theme } from '@mui/material/styles';
|
|
2
|
+
export interface GeometryTexts {
|
|
3
|
+
labelPoint: string;
|
|
4
|
+
labelOther: string;
|
|
5
|
+
malformed: string;
|
|
6
|
+
synced: string;
|
|
7
|
+
edit: string;
|
|
8
|
+
define: string;
|
|
9
|
+
drawSelectTitle: string;
|
|
10
|
+
close: string;
|
|
11
|
+
}
|
|
12
|
+
export interface FormTexts {
|
|
13
|
+
save: string;
|
|
14
|
+
saveAndContinue: string;
|
|
15
|
+
saveAndCreateNew: string;
|
|
16
|
+
cancel: string;
|
|
17
|
+
remove: string;
|
|
18
|
+
dialogCancel: string;
|
|
19
|
+
dialogSave: string;
|
|
20
|
+
}
|
|
21
|
+
export interface DRFReactBySchemaTexts {
|
|
22
|
+
geometry: GeometryTexts;
|
|
23
|
+
forms: FormTexts;
|
|
24
|
+
}
|
|
25
|
+
export declare const DEFAULT_TEXTS: DRFReactBySchemaTexts;
|
|
26
|
+
export declare function getThemeTexts(theme: Theme): DRFReactBySchemaTexts;
|
|
27
|
+
//# sourceMappingURL=texts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"texts.d.ts","sourceRoot":"","sources":["../../src/styles/texts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE7C,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,aAAa,CAAC;IACxB,KAAK,EAAE,SAAS,CAAC;CAClB;AAGD,eAAO,MAAM,aAAa,EAAE,qBAoB3B,CAAC;AAGF,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,qBAAqB,CAMjE"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_TEXTS = void 0;
|
|
4
|
+
exports.getThemeTexts = getThemeTexts;
|
|
5
|
+
// Default widget strings (en). Apps override any namespace via their MUI theme.
|
|
6
|
+
exports.DEFAULT_TEXTS = {
|
|
7
|
+
geometry: {
|
|
8
|
+
labelPoint: 'Coordinates (GeoJSON)',
|
|
9
|
+
labelOther: 'GeoJSON (paste here)',
|
|
10
|
+
malformed: 'Malformed data, fix the GeoJSON to reflect on the map.',
|
|
11
|
+
synced: 'The GeoJSON below is synchronized with the map.',
|
|
12
|
+
edit: 'Edit geometry',
|
|
13
|
+
define: 'Define geometry',
|
|
14
|
+
drawSelectTitle: 'Draw / select geometry',
|
|
15
|
+
close: 'Close',
|
|
16
|
+
},
|
|
17
|
+
forms: {
|
|
18
|
+
save: 'Save',
|
|
19
|
+
saveAndContinue: 'Save and Continue',
|
|
20
|
+
saveAndCreateNew: 'Save and Create New',
|
|
21
|
+
cancel: 'Cancel',
|
|
22
|
+
remove: 'Remove',
|
|
23
|
+
dialogCancel: 'Cancel',
|
|
24
|
+
dialogSave: 'Save',
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
// Merge theme.texts over the defaults; theme.texts is absent under a bare ThemeProvider.
|
|
28
|
+
function getThemeTexts(theme) {
|
|
29
|
+
const custom = theme.texts;
|
|
30
|
+
return {
|
|
31
|
+
geometry: Object.assign(Object.assign({}, exports.DEFAULT_TEXTS.geometry), ((custom === null || custom === void 0 ? void 0 : custom.geometry) || {})),
|
|
32
|
+
forms: Object.assign(Object.assign({}, exports.DEFAULT_TEXTS.forms), ((custom === null || custom === void 0 ? void 0 : custom.forms) || {})),
|
|
33
|
+
};
|
|
34
|
+
}
|
package/dist/styles/theme.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DRFReactBySchemaTexts } from './texts';
|
|
1
2
|
declare module '@mui/material/styles' {
|
|
2
3
|
interface Palette {
|
|
3
4
|
avatars: string[];
|
|
@@ -13,6 +14,12 @@ declare module '@mui/material/styles' {
|
|
|
13
14
|
tableColumnHeader: Palette['primary'];
|
|
14
15
|
formCard: Palette['primary'];
|
|
15
16
|
}
|
|
17
|
+
interface Theme {
|
|
18
|
+
texts: DRFReactBySchemaTexts;
|
|
19
|
+
}
|
|
20
|
+
interface ThemeOptions {
|
|
21
|
+
texts?: Partial<DRFReactBySchemaTexts>;
|
|
22
|
+
}
|
|
16
23
|
interface PaletteColor {
|
|
17
24
|
semaphoric?: string;
|
|
18
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/styles/theme.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/styles/theme.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,qBAAqB,EAAiB,MAAM,SAAS,CAAC;AAE/D,OAAO,QAAQ,sBAAsB,CAAC;IAMpC,UAAU,OAAO;QACf,OAAO,EAAE,MAAM,EAAE,CAAC;QAClB,WAAW,EAAE,MAAM,EAAE,CAAC;QACtB,YAAY,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;QACjC,QAAQ,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;QAC7B,cAAc,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;QACnC,eAAe,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;QACpC,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;QAC5B,YAAY,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;QACjC,aAAa,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;QAClC,YAAY,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;QACjC,iBAAiB,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;QACtC,QAAQ,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;KAC9B;IAED,UAAU,KAAK;QACb,KAAK,EAAE,qBAAqB,CAAC;KAC9B;IACD,UAAU,YAAY;QACpB,KAAK,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,CAAC;KACxC;IAKD,UAAU,YAAY;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB;CASF;AA4GD,QAAA,MAAM,YAAY,sCA2HjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
package/dist/styles/theme.js
CHANGED
|
@@ -4,6 +4,7 @@ const styles_1 = require("@mui/material/styles");
|
|
|
4
4
|
const locale_1 = require("@mui/material/locale");
|
|
5
5
|
const locales_1 = require("@mui/x-data-grid/locales");
|
|
6
6
|
const locales_2 = require("@mui/x-date-pickers/locales");
|
|
7
|
+
const texts_1 = require("./texts");
|
|
7
8
|
locales_1.ptBR.components.MuiDataGrid.defaultProps.localeText = Object.assign(Object.assign({}, locales_1.ptBR.components.MuiDataGrid.defaultProps.localeText), { toolbarQuickFilterPlaceholder: 'Buscar...', toolbarQuickFilterLabel: 'Buscar', toolbarQuickFilterDeleteIconLabel: 'Limpar busca' });
|
|
8
9
|
const palette = {
|
|
9
10
|
avatars: [
|
|
@@ -105,6 +106,7 @@ const palette = {
|
|
|
105
106
|
};
|
|
106
107
|
const defaultTheme = (0, styles_1.createTheme)({
|
|
107
108
|
palette,
|
|
109
|
+
texts: texts_1.DEFAULT_TEXTS,
|
|
108
110
|
components: {
|
|
109
111
|
MuiButton: {
|
|
110
112
|
styleOverrides: {
|
package/package.json
CHANGED