@irontec/ivoz-ui 1.3.20 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/hygen/templates/entity/new/Entity.ejs.t +7 -4
- package/hygen/templates/entity/new/Form.ejs.t +2 -12
- package/package.json +1 -1
- package/services/form/Field/FileUploader/FileUploader.d.ts +4 -4
- package/services/form/Field/FileUploader/FileUploader.styles.js +1 -0
- package/services/form/Field/FileUploader/Variant/ImageFileUploader.js +21 -2
- package/services/form/Field/TextField/TextField.styles.d.ts +1 -0
- package/services/form/Field/TextField/TextField.styles.js +8 -0
|
@@ -6,7 +6,6 @@ import EntityInterface from '@irontec-voip/ivoz-ui/entities/EntityInterface';
|
|
|
6
6
|
import _ from '@irontec-voip/ivoz-ui/services/translations/translate';
|
|
7
7
|
import defaultEntityBehavior from '@irontec-voip/ivoz-ui/entities/DefaultEntityBehavior';
|
|
8
8
|
import { EntityValue } from '@irontec-voip/ivoz-ui';
|
|
9
|
-
import selectOptions from './SelectOptions';
|
|
10
9
|
import { <%= Name %>Properties, <%= Name %>PropertyList } from './<%= Name %>Properties';
|
|
11
10
|
|
|
12
11
|
const properties: <%= Name %>Properties = {
|
|
@@ -19,9 +18,13 @@ const <%= Name %>: EntityInterface = {
|
|
|
19
18
|
iden: '<%= Name %>',
|
|
20
19
|
title: _('<%= Name %>', { count: 2 }),
|
|
21
20
|
path: '/<%= h.inflection.pluralize(name) %>',
|
|
22
|
-
toStr: (row: <%= Name %>PropertyList<EntityValue>) => row.id
|
|
21
|
+
toStr: (row: <%= Name %>PropertyList<EntityValue>) => String(row.id),
|
|
23
22
|
properties,
|
|
24
|
-
selectOptions
|
|
23
|
+
selectOptions: async () => {
|
|
24
|
+
const module = await import('./SelectOptions');
|
|
25
|
+
|
|
26
|
+
return module.default;
|
|
27
|
+
},
|
|
25
28
|
foreignKeyResolver: async () => {
|
|
26
29
|
const module = await import('./ForeignKeyResolver');
|
|
27
30
|
|
|
@@ -30,7 +33,7 @@ const <%= Name %>: EntityInterface = {
|
|
|
30
33
|
foreignKeyGetter: async () => {
|
|
31
34
|
const module = await import('./ForeignKeyGetter');
|
|
32
35
|
|
|
33
|
-
return module.
|
|
36
|
+
return module.foreignKeyGetter;
|
|
34
37
|
},
|
|
35
38
|
Form: async () => {
|
|
36
39
|
const module = await import('./Form');
|
|
@@ -1,22 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
to: src/entities/<%= Name %>/Form.tsx
|
|
3
3
|
---
|
|
4
|
-
import
|
|
5
|
-
import defaultEntityBehavior, { EntityFormProps, FieldsetGroups } from '@irontec-voip/ivoz-ui/entities/DefaultEntityBehavior';
|
|
4
|
+
import { EntityFormProps, FieldsetGroups } from '@irontec-voip/ivoz-ui/entities/DefaultEntityBehavior';
|
|
6
5
|
import _ from '@irontec-voip/ivoz-ui/services/translations/translate';
|
|
7
6
|
import { Form as DefaultEntityForm } from '@irontec-voip/ivoz-ui/entities/DefaultEntityBehavior/Form';
|
|
8
|
-
import { foreignKeyGetter } from './ForeignKeyGetter';
|
|
9
7
|
|
|
10
8
|
const Form = (props: EntityFormProps): JSX.Element => {
|
|
11
9
|
|
|
12
|
-
const { entityService, row, match } = props;
|
|
13
|
-
const fkChoices = useFkChoices({
|
|
14
|
-
foreignKeyGetter,
|
|
15
|
-
entityService,
|
|
16
|
-
row,
|
|
17
|
-
match,
|
|
18
|
-
});
|
|
19
|
-
|
|
20
10
|
const groups: Array<FieldsetGroups | false> = [
|
|
21
11
|
{
|
|
22
12
|
legend: _('Main'),
|
|
@@ -27,7 +17,7 @@ const Form = (props: EntityFormProps): JSX.Element => {
|
|
|
27
17
|
];
|
|
28
18
|
|
|
29
19
|
return (
|
|
30
|
-
<DefaultEntityForm {...props}
|
|
20
|
+
<DefaultEntityForm {...props} groups={groups} />
|
|
31
21
|
);
|
|
32
22
|
};
|
|
33
23
|
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { PropertyCustomFunctionComponentProps } from '../CustomComponentWrapper';
|
|
3
3
|
export interface FileProps {
|
|
4
|
-
file?: File;
|
|
5
|
-
baseName?: string;
|
|
6
|
-
fileSize?: number;
|
|
7
|
-
mimeType?: string;
|
|
4
|
+
file?: File | null;
|
|
5
|
+
baseName?: string | null;
|
|
6
|
+
fileSize?: number | null;
|
|
7
|
+
mimeType?: string | null;
|
|
8
8
|
}
|
|
9
9
|
export interface ChangeEventValues {
|
|
10
10
|
name: string;
|
|
@@ -13,9 +13,12 @@ import { useEffect, useState } from 'react';
|
|
|
13
13
|
import _ from '../../../../translations/translate';
|
|
14
14
|
import { StyledFileUploaderContainer, StyledImageContainer, StyledImagePreview, StyledTextContainer, StyledUploadButtonLabel, } from '../FileUploader.styles';
|
|
15
15
|
import { useStoreActions } from '../../../../../store';
|
|
16
|
+
import { StyledImageFileUpladerTextDield } from '../../TextField/TextField.styles';
|
|
17
|
+
import { IconButton, InputAdornment } from '@mui/material';
|
|
18
|
+
import CancelIcon from '@mui/icons-material/Cancel';
|
|
16
19
|
export const ImageFileUploader = (props) => {
|
|
17
20
|
var _a, _b;
|
|
18
|
-
const { _columnName, accept, values, disabled, handleDownload, changeHandler, onBlur, downloadPath, } = props;
|
|
21
|
+
const { _columnName, accept, values, disabled, handleDownload, changeHandler, onBlur, downloadPath, property, } = props;
|
|
19
22
|
const fileValue = values[_columnName];
|
|
20
23
|
const id = `${_columnName}-file-upload`;
|
|
21
24
|
const fileName = (fileValue === null || fileValue === void 0 ? void 0 : fileValue.file) ? (_a = fileValue.file) === null || _a === void 0 ? void 0 : _a.name : fileValue === null || fileValue === void 0 ? void 0 : fileValue.baseName;
|
|
@@ -57,5 +60,21 @@ export const ImageFileUploader = (props) => {
|
|
|
57
60
|
};
|
|
58
61
|
changeHandler(changeEvent);
|
|
59
62
|
onBlur(changeEvent);
|
|
60
|
-
} }), fileName && (_jsx(StyledImageContainer, Object.assign({ className: disabled ? 'disabled' : '' }, { children: imageSrc ? (_jsx(StyledImagePreview, { src: imageSrc, onClick: handleDownload })) : (values.id && _jsx(AccountCircleIcon, { onClick: handleDownload })) }))), _jsxs(StyledTextContainer, { children: [_jsx("span", { children: "JPG, JPEG, PNG format" }), _jsx("span", { children: "Maximum 500KB" }), !disabled && (_jsx(StyledUploadButtonLabel, Object.assign({ htmlFor: id }, { children: _('Upload image') }))), fileName && (_jsxs("span", { children: [fileName, " (", fileSizeMb, "MB)"] }))
|
|
63
|
+
} }), fileName && (_jsx(StyledImageContainer, Object.assign({ className: disabled ? 'disabled' : '' }, { children: imageSrc ? (_jsx(StyledImagePreview, { src: imageSrc, onClick: handleDownload })) : (values.id && _jsx(AccountCircleIcon, { onClick: handleDownload })) }))), _jsxs(StyledTextContainer, { children: [_jsx("span", { children: "JPG, JPEG, PNG format" }), _jsx("span", { children: "Maximum 500KB" }), !disabled && (_jsx(StyledUploadButtonLabel, Object.assign({ htmlFor: id }, { children: _('Upload image') }))), fileName && (_jsxs("span", { children: [fileName, " (", fileSizeMb, "MB)"] })), fileName && !property.required && (_jsx(StyledImageFileUpladerTextDield, { type: 'text', multiline: false, value: fileName, hasChanged: false, disabled: true, InputProps: {
|
|
64
|
+
endAdornment: (_jsx(InputAdornment, Object.assign({ position: 'end' }, { children: _jsx(IconButton, Object.assign({ "aria-label": 'delete image', onClick: () => {
|
|
65
|
+
setImageSrc(null);
|
|
66
|
+
const changeEvent = {
|
|
67
|
+
target: {
|
|
68
|
+
name: _columnName,
|
|
69
|
+
value: {
|
|
70
|
+
baseName: null,
|
|
71
|
+
file: null,
|
|
72
|
+
fileSize: null,
|
|
73
|
+
mimeType: null,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
changeHandler(changeEvent);
|
|
78
|
+
} }, { children: _jsx(CancelIcon, {}) })) }))),
|
|
79
|
+
} }))] })] }), _jsx("div", Object.assign({ className: 'uploader-backdrop' }, { children: "Image" }))] }));
|
|
61
80
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const StyledTextField: import("@emotion/styled").StyledComponent<import("./TextField").TextFieldProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
2
2
|
export declare const StyledColorField: import("@emotion/styled").StyledComponent<((import("./TextField").TextFieldProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>) & {}) & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
3
|
+
export declare const StyledImageFileUpladerTextDield: import("@emotion/styled").StyledComponent<((import("./TextField").TextFieldProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>) & {}) & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
3
4
|
export declare const StyledAutocompleteTextField: import("@emotion/styled").StyledComponent<((import("./TextField").TextFieldProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>) & {}) & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
4
5
|
export declare const StyledMultilangTextField: import("@emotion/styled").StyledComponent<((import("./TextField").TextFieldProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>) & {}) & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
5
6
|
export declare const StyledSearchTextField: import("@emotion/styled").StyledComponent<((import("./TextField").TextFieldProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>) & {}) & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
@@ -91,6 +91,14 @@ export const StyledColorField = styled(StyledTextField)(() => {
|
|
|
91
91
|
},
|
|
92
92
|
};
|
|
93
93
|
});
|
|
94
|
+
export const StyledImageFileUpladerTextDield = styled(StyledTextField)(() => {
|
|
95
|
+
return {
|
|
96
|
+
'& .MuiInputBase-input': {
|
|
97
|
+
overflow: 'hidden',
|
|
98
|
+
textOverflow: 'ellipsis',
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
});
|
|
94
102
|
export const StyledAutocompleteTextField = styled(StyledTextField)(() => {
|
|
95
103
|
return {
|
|
96
104
|
'& .input-field': {
|