@m4l/components 0.1.8 → 0.1.10
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/commonjs.js +1 -1
- package/components/CommonActions/components/Actions/index.js +42 -41
- package/components/DataGrid/formatters/columnBooleanFormatter/index.d.ts +3 -0
- package/components/DataGrid/formatters/columnBooleanFormatter/types.d.ts +7 -0
- package/components/DataGrid/formatters/columnDateFormatter/index.d.ts +3 -0
- package/components/DataGrid/formatters/columnDateFormatter/types.d.ts +8 -0
- package/components/DataGrid/formatters/columnNestedValueFormatter/index.d.ts +3 -0
- package/components/DataGrid/formatters/columnNestedValueFormatter/types.d.ts +5 -0
- package/components/DataGrid/formatters/columnPointsFormatter/index.d.ts +3 -0
- package/components/DataGrid/formatters/columnPointsFormatter/types.d.ts +6 -0
- package/components/DataGrid/formatters/columnUncertaintyFormatter/index.d.ts +3 -0
- package/components/DataGrid/formatters/columnUncertaintyFormatter/types.d.ts +7 -0
- package/components/DataGrid/formatters/index.d.ts +6 -0
- package/components/DataGrid/index.js +3 -0
- package/components/DataGrid/types.d.ts +3 -1
- package/components/DynamicFilter/index.js +11 -9
- package/components/ErrorLabel/index.d.ts +4 -0
- package/components/ErrorLabel/styles.d.ts +2 -0
- package/components/ErrorLabel/types.d.ts +3 -0
- package/components/Icon/index.js +1 -1
- package/components/LanguagePopover/index.js +1 -0
- package/components/PaperForm/components/Header.d.ts +3 -0
- package/components/PaperForm/index.js +37 -46
- package/components/PaperForm/styles.d.ts +2 -3
- package/components/PaperForm/types.d.ts +1 -0
- package/components/PropertyValue/index.js +35 -24
- package/components/PropertyValue/styles.d.ts +3 -4
- package/components/PropertyValue/types.d.ts +8 -8
- package/components/animate/variants/bounce.d.ts +1 -1
- package/components/animate/variants/container.d.ts +1 -1
- package/components/animate/variants/fade.d.ts +1 -1
- package/components/animate/variants/transition.d.ts +3 -3
- package/components/formatters/BooleanFormatter/index.js +33 -13
- package/components/formatters/BooleanFormatter/types.d.ts +3 -3
- package/components/formatters/DateFormatter/index.js +20 -16
- package/components/formatters/DateFormatter/types.d.ts +2 -2
- package/components/formatters/PointsFormatter/index.d.ts +3 -0
- package/components/formatters/PointsFormatter/types.d.ts +7 -0
- package/components/formatters/PriceFormatter/index.d.ts +3 -0
- package/components/formatters/PriceFormatter/types.d.ts +5 -0
- package/components/formatters/UncertaintyFormatter/index.d.ts +3 -0
- package/components/formatters/UncertaintyFormatter/types.d.ts +14 -0
- package/components/formatters/index.d.ts +4 -0
- package/components/formatters/index.js +102 -5
- package/components/hook-form/FormProvider/index.js +19 -7
- package/components/hook-form/FormProvider/types.d.ts +4 -1
- package/components/hook-form/RHFAutocompleteAsync/index.js +0 -1
- package/components/hook-form/RHFCheckbox/index.js +34 -29
- package/components/hook-form/RHFCheckbox/styles.d.ts +12 -1
- package/components/hook-form/RHFPeriod/dictionary.d.ts +3 -0
- package/components/hook-form/RHFPeriod/index.d.ts +3 -0
- package/components/hook-form/RHFPeriod/index.js +227 -0
- package/components/hook-form/RHFPeriod/styles.d.ts +6 -0
- package/components/hook-form/RHFPeriod/types.d.ts +29 -0
- package/components/hook-form/RHFUpload/index.js +2 -3
- package/components/hook-form/index.d.ts +4 -0
- package/components/index.d.ts +4 -1
- package/components/mui_extended/Accordion/components/AccordionLabel.d.ts +3 -0
- package/components/mui_extended/Accordion/index.js +68 -8
- package/components/mui_extended/Accordion/styles.d.ts +4 -0
- package/components/mui_extended/Accordion/types.d.ts +4 -0
- package/components/mui_extended/Tab/index.d.ts +2 -1
- package/components/mui_extended/Tab/types.d.ts +5 -0
- package/hooks/index.d.ts +2 -0
- package/hooks/useFormAddEdit/index.d.ts +6 -0
- package/hooks/useFormAddEdit/types.d.ts +8 -0
- package/index.d.ts +1 -1
- package/index.js +76 -20
- package/package.json +3 -3
- package/react-draggable.js +3 -3
- package/react-json-view.js +2 -2
- package/react-lazy-load-image-component.js +2 -2
- package/react-resizable.js +3 -3
- package/react-splitter-layout.js +2 -2
- package/utils/index.js +2 -2
- package/components/PaperForm/skeleton.d.ts +0 -6
- package/components/hook-form/RHFCheckbox/skeleton.d.ts +0 -2
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { useModuleDictionary, useModuleSkeleton, useEnvironment } from "@m4l/core";
|
|
2
|
+
import { styled, Skeleton, Autocomplete, TextField } from "@mui/material";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { useFormContext, Controller } from "react-hook-form";
|
|
5
|
+
import { I as Icon } from "../../Icon/index.js";
|
|
6
|
+
import { ErrorLabel } from "../../../index.js";
|
|
7
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
8
|
+
import { g as getCommonActionsDictionary } from "../../CommonActions/components/Actions/index.js";
|
|
9
|
+
import "@mui/material/Button";
|
|
10
|
+
import "../../mui_extended/Button/index.js";
|
|
11
|
+
import "react-router-dom";
|
|
12
|
+
import "../../../contexts/ModalContext/index.js";
|
|
13
|
+
import "@mui/lab";
|
|
14
|
+
const Wrapper = styled("div")(({
|
|
15
|
+
theme
|
|
16
|
+
}) => ({
|
|
17
|
+
width: "100%",
|
|
18
|
+
display: "flex",
|
|
19
|
+
flexDirection: "column",
|
|
20
|
+
justifyContent: "center",
|
|
21
|
+
alignItems: "flex-start",
|
|
22
|
+
gap: theme.spacing(1)
|
|
23
|
+
}));
|
|
24
|
+
const ContainerPeriod = styled("div")(({
|
|
25
|
+
theme,
|
|
26
|
+
error
|
|
27
|
+
}) => ({
|
|
28
|
+
display: "flex",
|
|
29
|
+
width: "100%",
|
|
30
|
+
height: "auto",
|
|
31
|
+
alignItems: "center",
|
|
32
|
+
gap: theme.spacing(1),
|
|
33
|
+
border: error ? `1px solid ${theme.palette.error.main}` : `1px solid ${theme.palette.divider}`,
|
|
34
|
+
padding: theme.spacing(0.5, 1),
|
|
35
|
+
borderRadius: "4px",
|
|
36
|
+
"& .MuiAutocomplete-root, & .MuiTextField-root": {
|
|
37
|
+
width: "100%"
|
|
38
|
+
},
|
|
39
|
+
"& .MuiAutocomplete-root .MuiTextField-root": {
|
|
40
|
+
width: "100%"
|
|
41
|
+
},
|
|
42
|
+
"& .MuiTextField-root .MuiInput-input": {
|
|
43
|
+
padding: "5px!important"
|
|
44
|
+
}
|
|
45
|
+
}));
|
|
46
|
+
const SKTWrapper = styled("div")(({
|
|
47
|
+
theme
|
|
48
|
+
}) => ({
|
|
49
|
+
display: "flex",
|
|
50
|
+
width: "auto",
|
|
51
|
+
height: "37.5px",
|
|
52
|
+
alignItems: "center",
|
|
53
|
+
gap: theme.spacing(1),
|
|
54
|
+
border: `1px solid ${theme.palette.divider}`,
|
|
55
|
+
padding: theme.spacing(0.5, 1),
|
|
56
|
+
borderRadius: "4px"
|
|
57
|
+
}));
|
|
58
|
+
const Gap = styled("div")(({
|
|
59
|
+
theme
|
|
60
|
+
}) => ({
|
|
61
|
+
width: "1px",
|
|
62
|
+
height: "20px",
|
|
63
|
+
backgroundColor: theme.palette.divider
|
|
64
|
+
}));
|
|
65
|
+
var ETimePeriods = /* @__PURE__ */ ((ETimePeriods2) => {
|
|
66
|
+
ETimePeriods2[ETimePeriods2["YEARS"] = 0] = "YEARS";
|
|
67
|
+
ETimePeriods2[ETimePeriods2["MONTHS"] = 1] = "MONTHS";
|
|
68
|
+
ETimePeriods2[ETimePeriods2["DAYS"] = 2] = "DAYS";
|
|
69
|
+
return ETimePeriods2;
|
|
70
|
+
})(ETimePeriods || {});
|
|
71
|
+
const getSelPeriodTime = (period) => {
|
|
72
|
+
if (!period)
|
|
73
|
+
return ETimePeriods.YEARS;
|
|
74
|
+
if (period.selPeriodTime)
|
|
75
|
+
return period.selPeriodTime;
|
|
76
|
+
if (period.years && period.years > 0)
|
|
77
|
+
return ETimePeriods.YEARS;
|
|
78
|
+
if (period.months && period.months > 0)
|
|
79
|
+
return ETimePeriods.MONTHS;
|
|
80
|
+
if (period.days && period.days > 0)
|
|
81
|
+
return ETimePeriods.DAYS;
|
|
82
|
+
return ETimePeriods.YEARS;
|
|
83
|
+
};
|
|
84
|
+
const getSingleValue = (period) => {
|
|
85
|
+
if (!period)
|
|
86
|
+
return "";
|
|
87
|
+
if (period.singleValue !== void 0)
|
|
88
|
+
return period.singleValue;
|
|
89
|
+
if (period.years && period.years > 0)
|
|
90
|
+
return period.years;
|
|
91
|
+
if (period.months && period.months > 0)
|
|
92
|
+
return period.months;
|
|
93
|
+
if (period.days && period.days > 0)
|
|
94
|
+
return period.days;
|
|
95
|
+
return "";
|
|
96
|
+
};
|
|
97
|
+
const RHFPeriod = (props) => {
|
|
98
|
+
const {
|
|
99
|
+
name,
|
|
100
|
+
variant = "monoperiod"
|
|
101
|
+
} = props;
|
|
102
|
+
const {
|
|
103
|
+
getLabel
|
|
104
|
+
} = useModuleDictionary();
|
|
105
|
+
const isSkeleton = useModuleSkeleton();
|
|
106
|
+
const {
|
|
107
|
+
control
|
|
108
|
+
} = useFormContext();
|
|
109
|
+
const {
|
|
110
|
+
host_static_assets,
|
|
111
|
+
environment_assets
|
|
112
|
+
} = useEnvironment();
|
|
113
|
+
const options = useMemo(() => [{
|
|
114
|
+
id: 0,
|
|
115
|
+
label: getLabel("period.years")
|
|
116
|
+
}, {
|
|
117
|
+
id: 1,
|
|
118
|
+
label: getLabel("period.months")
|
|
119
|
+
}, {
|
|
120
|
+
id: 2,
|
|
121
|
+
label: getLabel("period.days")
|
|
122
|
+
}], [getLabel]);
|
|
123
|
+
if (isSkeleton) {
|
|
124
|
+
return /* @__PURE__ */ jsxs(SKTWrapper, {
|
|
125
|
+
children: [/* @__PURE__ */ jsx(Skeleton, {
|
|
126
|
+
variant: "rounded",
|
|
127
|
+
width: "100%"
|
|
128
|
+
}), /* @__PURE__ */ jsx(Gap, {}), /* @__PURE__ */ jsx(Skeleton, {
|
|
129
|
+
variant: "rounded",
|
|
130
|
+
width: "100%"
|
|
131
|
+
}), /* @__PURE__ */ jsx(Skeleton, {
|
|
132
|
+
variant: "circular",
|
|
133
|
+
width: 20,
|
|
134
|
+
sx: {
|
|
135
|
+
minWidth: "20px",
|
|
136
|
+
minHeight: "20px"
|
|
137
|
+
}
|
|
138
|
+
})]
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
return /* @__PURE__ */ jsx(Controller, {
|
|
142
|
+
name,
|
|
143
|
+
control,
|
|
144
|
+
render: ({
|
|
145
|
+
field: {
|
|
146
|
+
onChange,
|
|
147
|
+
value
|
|
148
|
+
},
|
|
149
|
+
fieldState: {
|
|
150
|
+
error
|
|
151
|
+
}
|
|
152
|
+
}) => {
|
|
153
|
+
const selPeriodTime = getSelPeriodTime(value);
|
|
154
|
+
const singleValue = getSingleValue(value);
|
|
155
|
+
const onTotalChange = (newPeriodTime, newValue) => {
|
|
156
|
+
const newPeriod = {
|
|
157
|
+
selPeriodTime: newPeriodTime,
|
|
158
|
+
singleValue: newValue,
|
|
159
|
+
variant
|
|
160
|
+
};
|
|
161
|
+
if (newValue !== "" && newValue > 0) {
|
|
162
|
+
newPeriod.years = 0;
|
|
163
|
+
newPeriod.months = 0;
|
|
164
|
+
newPeriod.days = 0;
|
|
165
|
+
if (newPeriodTime === ETimePeriods.YEARS)
|
|
166
|
+
newPeriod.years = newValue;
|
|
167
|
+
if (newPeriodTime === ETimePeriods.MONTHS)
|
|
168
|
+
newPeriod.months = newValue;
|
|
169
|
+
if (newPeriodTime === ETimePeriods.DAYS)
|
|
170
|
+
newPeriod.days = newValue;
|
|
171
|
+
}
|
|
172
|
+
onChange(newPeriod);
|
|
173
|
+
};
|
|
174
|
+
const onChangeTime = (newPeriodTime) => {
|
|
175
|
+
if (newPeriodTime) {
|
|
176
|
+
onTotalChange(newPeriodTime.id, singleValue);
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
return /* @__PURE__ */ jsxs(Wrapper, {
|
|
180
|
+
children: [/* @__PURE__ */ jsxs(ContainerPeriod, {
|
|
181
|
+
error: !!error,
|
|
182
|
+
children: [/* @__PURE__ */ jsx(Autocomplete, {
|
|
183
|
+
options,
|
|
184
|
+
value: options[selPeriodTime],
|
|
185
|
+
disableClearable: true,
|
|
186
|
+
onChange: (_event, autcValue) => {
|
|
187
|
+
onChangeTime(autcValue);
|
|
188
|
+
},
|
|
189
|
+
renderInput: (params) => {
|
|
190
|
+
return /* @__PURE__ */ jsx(TextField, {
|
|
191
|
+
...params,
|
|
192
|
+
fullWidth: true,
|
|
193
|
+
variant: "standard",
|
|
194
|
+
SelectProps: {
|
|
195
|
+
native: true
|
|
196
|
+
},
|
|
197
|
+
InputProps: {
|
|
198
|
+
disableUnderline: true,
|
|
199
|
+
...params.InputProps
|
|
200
|
+
},
|
|
201
|
+
autoComplete: "off"
|
|
202
|
+
}, `tx_async_${params.id}`);
|
|
203
|
+
}
|
|
204
|
+
}), /* @__PURE__ */ jsx(Gap, {}), /* @__PURE__ */ jsx(TextField, {
|
|
205
|
+
type: "number",
|
|
206
|
+
variant: "standard",
|
|
207
|
+
value: singleValue,
|
|
208
|
+
InputProps: {
|
|
209
|
+
disableUnderline: true
|
|
210
|
+
},
|
|
211
|
+
onChange: (e) => {
|
|
212
|
+
onTotalChange(selPeriodTime, e.target.value === "" ? "" : parseInt(e.target.value));
|
|
213
|
+
}
|
|
214
|
+
}), /* @__PURE__ */ jsx(Icon, {
|
|
215
|
+
src: `${host_static_assets}/${environment_assets}/frontend/components/period/assets/icons/clock.svg`
|
|
216
|
+
})]
|
|
217
|
+
}), error && /* @__PURE__ */ jsx(ErrorLabel, {
|
|
218
|
+
message: error.message || ""
|
|
219
|
+
})]
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
};
|
|
224
|
+
function getPeriodComponetsDictionary() {
|
|
225
|
+
return ["period"].concat(getCommonActionsDictionary());
|
|
226
|
+
}
|
|
227
|
+
export { RHFPeriod as R, getPeriodComponetsDictionary as g };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { WrapperProps } from './types';
|
|
3
|
+
export declare const Wrapper: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
4
|
+
export declare const ContainerPeriod: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & WrapperProps, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
5
|
+
export declare const SKTWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
6
|
+
export declare const Gap: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export declare type PeriodProps = {
|
|
2
|
+
name: string;
|
|
3
|
+
variant?: 'single';
|
|
4
|
+
};
|
|
5
|
+
export declare enum ETimePeriods {
|
|
6
|
+
YEARS = 0,
|
|
7
|
+
MONTHS = 1,
|
|
8
|
+
DAYS = 2
|
|
9
|
+
}
|
|
10
|
+
export declare type PeriodVariant = 'monoperiod' | 'multiperiod';
|
|
11
|
+
export declare type PeriodTime = {
|
|
12
|
+
id: number;
|
|
13
|
+
label: string;
|
|
14
|
+
};
|
|
15
|
+
export declare type PeriodType = {
|
|
16
|
+
variant: PeriodVariant;
|
|
17
|
+
selPeriodTime: ETimePeriods;
|
|
18
|
+
singleValue: number | '';
|
|
19
|
+
years?: number;
|
|
20
|
+
months?: number;
|
|
21
|
+
days?: number;
|
|
22
|
+
};
|
|
23
|
+
export interface WrapperProps {
|
|
24
|
+
error: boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare type RHFPeriodProps = {
|
|
27
|
+
name: string;
|
|
28
|
+
variant?: PeriodVariant;
|
|
29
|
+
};
|
|
@@ -219,10 +219,9 @@ function RHFUploadImage({
|
|
|
219
219
|
const handleDrop = useCallback((acceptedFiles) => {
|
|
220
220
|
const file = acceptedFiles[0];
|
|
221
221
|
if (file) {
|
|
222
|
-
setValue(name, {
|
|
223
|
-
...file,
|
|
222
|
+
setValue(name, Object.assign(file, {
|
|
224
223
|
preview: URL.createObjectURL(file)
|
|
225
|
-
});
|
|
224
|
+
}));
|
|
226
225
|
}
|
|
227
226
|
}, [setValue]);
|
|
228
227
|
return /* @__PURE__ */ jsx(Controller, {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { FormProvider } from './FormProvider';
|
|
2
|
+
export type { FormInitialValues, FormStatusLoad } from './FormProvider/types';
|
|
2
3
|
export { RHFAutocomplete } from './RHFAutocomplete';
|
|
3
4
|
export { RHFAutocompleteAsync } from './RHFAutocompleteAsync';
|
|
4
5
|
export { RHFCheckbox } from './RHFCheckbox';
|
|
@@ -7,4 +8,7 @@ export { RHFMultiCheckbox } from './RHFMultiCheckbox';
|
|
|
7
8
|
export { RHFSelect } from './RHFSelect';
|
|
8
9
|
export { RHFTextField } from './RHFTextField';
|
|
9
10
|
export { RHFRadioGroup } from './RHFRadioGroup';
|
|
11
|
+
export { RHFPeriod } from './RHFPeriod';
|
|
12
|
+
export type { PeriodType } from './RHFPeriod/types';
|
|
13
|
+
export { getPeriodComponetsDictionary } from './RHFPeriod/dictionary';
|
|
10
14
|
export * from './RHFUpload';
|
package/components/index.d.ts
CHANGED
|
@@ -3,14 +3,17 @@ export * from '../components/hook-form';
|
|
|
3
3
|
export * from '../components/mui_extended';
|
|
4
4
|
export * from '../components/CompanyLogo';
|
|
5
5
|
export * from './formatters';
|
|
6
|
+
export * from './formatters/types';
|
|
6
7
|
export * from './formatters/dicctionary';
|
|
7
8
|
export { DataGrid } from '../components/DataGrid';
|
|
8
|
-
export
|
|
9
|
+
export * from '../components/DataGrid/formatters';
|
|
10
|
+
export type { Column, EditorProps, FormatterProps } from 'react-data-grid';
|
|
9
11
|
export type { RowKey } from '../components/DataGrid/types';
|
|
10
12
|
export { getDataGridComponentsDictionary as getGridComponentsDictionary } from '../components/DataGrid/dictionary';
|
|
11
13
|
export { TextEditor, NumberEditor } from '../components/DataGrid/components/editors/TextEditor';
|
|
12
14
|
export * from '../components/DynamicFilter';
|
|
13
15
|
export * from '../components/DynamicFilter/dictionary';
|
|
16
|
+
export * from '../components/ErrorLabel';
|
|
14
17
|
export type { FilterFieldApply, RawFilterFieldApply, InitialFilterFieldApply, } from '../components/DynamicFilter/types';
|
|
15
18
|
export * from './CommonActions/';
|
|
16
19
|
export * from './CommonActions/dictionary';
|
|
@@ -1,7 +1,64 @@
|
|
|
1
|
-
import { Accordion as Accordion$1, AccordionSummary,
|
|
1
|
+
import { Skeleton, Accordion as Accordion$1, AccordionSummary, AccordionDetails } from "@mui/material";
|
|
2
2
|
import { I as IconButton } from "../IconButton/index.js";
|
|
3
3
|
import { useEnvironment, useModuleSkeleton } from "@m4l/core";
|
|
4
|
-
import {
|
|
4
|
+
import { I as Icon } from "../../Icon/index.js";
|
|
5
|
+
import { styled } from "@mui/material/styles";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
styled("div")(({
|
|
8
|
+
theme
|
|
9
|
+
}) => ({
|
|
10
|
+
display: "flex",
|
|
11
|
+
justifyContent: "space-between",
|
|
12
|
+
alignItems: "center",
|
|
13
|
+
borderRadius: theme.spacing(0.5),
|
|
14
|
+
height: theme.spacing(4.5),
|
|
15
|
+
minHeight: theme.spacing(4.5),
|
|
16
|
+
backgroundColor: theme.palette.background.header,
|
|
17
|
+
paddingLeft: theme.spacing(2),
|
|
18
|
+
paddingRight: theme.spacing(2),
|
|
19
|
+
marginBottom: "0px"
|
|
20
|
+
}));
|
|
21
|
+
const WrapperAccordionLabel = styled("div")(({
|
|
22
|
+
theme
|
|
23
|
+
}) => ({
|
|
24
|
+
display: "flex",
|
|
25
|
+
justifyContent: "flex-start",
|
|
26
|
+
alignItems: "center",
|
|
27
|
+
gap: theme.spacing(2)
|
|
28
|
+
}));
|
|
29
|
+
const Label = styled("span")(({
|
|
30
|
+
theme
|
|
31
|
+
}) => ({
|
|
32
|
+
...theme.typography.subtitle2
|
|
33
|
+
}));
|
|
34
|
+
const AccordionLabel = (props) => {
|
|
35
|
+
const {
|
|
36
|
+
isSkeleton,
|
|
37
|
+
label,
|
|
38
|
+
SKTWidht,
|
|
39
|
+
SKTHeight,
|
|
40
|
+
labelIcon
|
|
41
|
+
} = props;
|
|
42
|
+
return /* @__PURE__ */ jsx("div", {
|
|
43
|
+
children: isSkeleton ? /* @__PURE__ */ jsxs(WrapperAccordionLabel, {
|
|
44
|
+
children: [labelIcon && /* @__PURE__ */ jsx(Skeleton, {
|
|
45
|
+
variant: "circular",
|
|
46
|
+
width: "16px",
|
|
47
|
+
height: "16px"
|
|
48
|
+
}), /* @__PURE__ */ jsx(Skeleton, {
|
|
49
|
+
variant: "text",
|
|
50
|
+
width: SKTWidht,
|
|
51
|
+
height: SKTHeight
|
|
52
|
+
})]
|
|
53
|
+
}) : /* @__PURE__ */ jsxs(WrapperAccordionLabel, {
|
|
54
|
+
children: [labelIcon && /* @__PURE__ */ jsx(Icon, {
|
|
55
|
+
src: labelIcon
|
|
56
|
+
}), /* @__PURE__ */ jsx(Label, {
|
|
57
|
+
children: label
|
|
58
|
+
})]
|
|
59
|
+
})
|
|
60
|
+
});
|
|
61
|
+
};
|
|
5
62
|
function Accordion(props) {
|
|
6
63
|
const {
|
|
7
64
|
label,
|
|
@@ -9,7 +66,8 @@ function Accordion(props) {
|
|
|
9
66
|
SKTHeight,
|
|
10
67
|
children,
|
|
11
68
|
accordionProps,
|
|
12
|
-
summaryProps
|
|
69
|
+
summaryProps,
|
|
70
|
+
labelIcon
|
|
13
71
|
} = props;
|
|
14
72
|
const {
|
|
15
73
|
host_static_assets,
|
|
@@ -32,11 +90,13 @@ function Accordion(props) {
|
|
|
32
90
|
src: `${host_static_assets}/${environment_assets}/frontend/components/accordion/assets/icons/expanded.svg`
|
|
33
91
|
}),
|
|
34
92
|
...summaryProps,
|
|
35
|
-
children:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
93
|
+
children: /* @__PURE__ */ jsx(AccordionLabel, {
|
|
94
|
+
isSkeleton,
|
|
95
|
+
label,
|
|
96
|
+
SKTWidht,
|
|
97
|
+
SKTHeight,
|
|
98
|
+
labelIcon
|
|
99
|
+
})
|
|
40
100
|
}), /* @__PURE__ */ jsx(AccordionDetails, {
|
|
41
101
|
children
|
|
42
102
|
})]
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const SKTAccordionWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
3
|
+
export declare const WrapperAccordionLabel: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
4
|
+
export declare const Label: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
@@ -5,6 +5,10 @@ export declare type AccordionProps = {
|
|
|
5
5
|
children: ReactNode;
|
|
6
6
|
accordionProps?: MUIAccordionProps;
|
|
7
7
|
summaryProps?: AccordionSummaryProps;
|
|
8
|
+
labelIcon?: string;
|
|
8
9
|
SKTWidht?: string | number;
|
|
9
10
|
SKTHeight?: string | number;
|
|
10
11
|
};
|
|
12
|
+
export interface AccordionLabelProps extends Pick<AccordionProps, 'label' | 'SKTWidht' | 'SKTHeight' | 'labelIcon'> {
|
|
13
|
+
isSkeleton: boolean;
|
|
14
|
+
}
|
package/hooks/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FormStatusLoad } from '../../components/hook-form/FormProvider/types';
|
|
2
|
+
import { UseFormAddEditProps } from './types';
|
|
3
|
+
export declare const useFormAddEdit: (props: UseFormAddEditProps) => {
|
|
4
|
+
formValues: import("react-hook-form").FieldValues;
|
|
5
|
+
statusLoad: FormStatusLoad;
|
|
6
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FieldValues } from 'react-hook-form';
|
|
2
|
+
import { FormInitialValues } from '../../components/hook-form/FormProvider/types';
|
|
3
|
+
export interface UseFormAddEditProps {
|
|
4
|
+
objectId?: number;
|
|
5
|
+
endPoint: string;
|
|
6
|
+
initialValues: FormInitialValues;
|
|
7
|
+
formatDataEnpoint?: (data: FieldValues) => FormInitialValues;
|
|
8
|
+
}
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1,32 +1,35 @@
|
|
|
1
1
|
export { I as IconButton, a as IconButtonAnimate } from "./components/mui_extended/IconButton/index.js";
|
|
2
2
|
import "framer-motion";
|
|
3
|
-
import "@mui/material";
|
|
4
|
-
import "react/jsx-runtime";
|
|
3
|
+
import { styled } from "@mui/material";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
export { L as LoadingScreen } from "./components/animate/LoadingScreen/index.js";
|
|
6
|
-
import "react";
|
|
6
|
+
import { useState, useEffect } from "react";
|
|
7
7
|
import "react-hook-form";
|
|
8
8
|
export { F as FormProvider } from "./components/hook-form/FormProvider/index.js";
|
|
9
|
-
import "@m4l/core";
|
|
9
|
+
import { useNetwork, useFlags } from "@m4l/core";
|
|
10
10
|
export { R as RHFAutocomplete } from "./components/hook-form/RHFAutocomplete/index.js";
|
|
11
11
|
export { R as RHFAutocompleteAsync } from "./components/hook-form/RHFAutocompleteAsync/index.js";
|
|
12
12
|
export { R as RHFCheckbox } from "./components/hook-form/RHFCheckbox/index.js";
|
|
13
13
|
export { R as RHFDateTime } from "./components/hook-form/RHFDateTime/index.js";
|
|
14
14
|
import "@mui/x-date-pickers";
|
|
15
15
|
export { R as RHFTextField } from "./components/hook-form/RHFTextField/index.js";
|
|
16
|
+
export { R as RHFPeriod, g as getPeriodComponetsDictionary } from "./components/hook-form/RHFPeriod/index.js";
|
|
17
|
+
export { I as Icon } from "./components/Icon/index.js";
|
|
18
|
+
import "@mui/material/styles";
|
|
19
|
+
export { b as Actions, M as MenuActions, d as defaultCommonActionsDictionary, g as getCommonActionsDictionary } from "./components/CommonActions/components/Actions/index.js";
|
|
20
|
+
import "@mui/material/Button";
|
|
21
|
+
export { B as Button, L as LoadingButton } from "./components/mui_extended/Button/index.js";
|
|
22
|
+
import "react-router-dom";
|
|
23
|
+
export { M as ModalContext, a as ModalProvider } from "./contexts/ModalContext/index.js";
|
|
24
|
+
import "@mui/lab";
|
|
16
25
|
import "./lodash.js";
|
|
17
26
|
import "react-dropzone";
|
|
18
|
-
import "@mui/material/styles";
|
|
19
27
|
import "./react-lazy-load-image-component.js";
|
|
20
28
|
export { I as Image } from "./components/Image/index.js";
|
|
21
29
|
export { R as RHFUploadImage } from "./components/hook-form/RHFUpload/index.js";
|
|
22
|
-
export {
|
|
30
|
+
export { A as Accordion } from "./components/mui_extended/Accordion/index.js";
|
|
23
31
|
export { A as Avatar } from "./components/mui_extended/Avatar/index.js";
|
|
24
|
-
import "react-router-dom";
|
|
25
|
-
import "@mui/material/Button";
|
|
26
|
-
export { B as Button, L as LoadingButton } from "./components/mui_extended/Button/index.js";
|
|
27
|
-
import "@mui/lab";
|
|
28
32
|
export { M as MenuPopover } from "./components/mui_extended/MenuPopover/index.js";
|
|
29
|
-
export { b as Actions, M as MenuActions, d as defaultCommonActionsDictionary, g as getCommonActionsDictionary } from "./components/CommonActions/components/Actions/index.js";
|
|
30
33
|
export { P as Pager, g as getPagerComponentsDictionary } from "./components/mui_extended/Pager/index.js";
|
|
31
34
|
export { T as Tab } from "./components/mui_extended/Tab/index.js";
|
|
32
35
|
import "@m4l/graphics";
|
|
@@ -34,7 +37,6 @@ export { C as CompanyLogo } from "./components/CompanyLogo/index.js";
|
|
|
34
37
|
export { D as DataGrid, N as NumberEditor, T as TextEditor, g as getGridComponentsDictionary } from "./components/DataGrid/index.js";
|
|
35
38
|
import "react-dnd";
|
|
36
39
|
import "react-dnd-html5-backend";
|
|
37
|
-
export { M as ModalContext, a as ModalProvider } from "./contexts/ModalContext/index.js";
|
|
38
40
|
export { S as ScrollBar } from "./components/ScrollBar/index.js";
|
|
39
41
|
export { D as DynamicFilter, d as defaultDynamicFilterDictionary, g as getDynamicFilterComponentsDictionary } from "./components/DynamicFilter/index.js";
|
|
40
42
|
import "simplebar/dist/simplebar.min.css";
|
|
@@ -59,14 +61,13 @@ export { M as MotionLazyContainer } from "./components/animate/MotionLazyContain
|
|
|
59
61
|
export { R as RHFMultiCheckbox } from "./components/hook-form/RHFMultiCheckbox/index.js";
|
|
60
62
|
export { R as RHFSelect } from "./components/hook-form/RHFSelect/index.js";
|
|
61
63
|
export { R as RHFRadioGroup } from "./components/hook-form/RHFRadioGroup/index.js";
|
|
62
|
-
export { A as Accordion } from "./components/mui_extended/Accordion/index.js";
|
|
63
64
|
export { B as BoxIcon } from "./components/mui_extended/BoxIcon/index.js";
|
|
64
65
|
export { B as Breadcrumbs } from "./components/mui_extended/Breadcrumbs/index.js";
|
|
65
66
|
export { L as LinkWithRoute } from "./components/mui_extended/LinkWithRoute/index.js";
|
|
66
67
|
export { T as Typography } from "./components/mui_extended/Typography/index.js";
|
|
67
|
-
export { B as BooleanFormatter } from "./components/formatters/BooleanFormatter/index.js";
|
|
68
|
-
export { D as DateFormatter } from "./components/formatters/DateFormatter/index.js";
|
|
69
|
-
export { d as defaultFormattersDictionary, g as getFormattersComponentsDictionary } from "./components/formatters/index.js";
|
|
68
|
+
export { B as BooleanFormatter, c as columnBooleanFormatter } from "./components/formatters/BooleanFormatter/index.js";
|
|
69
|
+
export { D as DateFormatter, c as columnDateFormatter } from "./components/formatters/DateFormatter/index.js";
|
|
70
|
+
export { P as PointsFormatter, a as PriceFormatter, U as UncertaintyFormatter, e as columnNestedValueFormatter, b as columnPointsFormatter, c as columnUncertaintyFormatter, d as defaultFormattersDictionary, g as getFormattersComponentsDictionary } from "./components/formatters/index.js";
|
|
70
71
|
export { A as ActionCancel } from "./components/CommonActions/components/ActionCancel/index.js";
|
|
71
72
|
export { A as ActionIntro } from "./components/CommonActions/components/ActionIntro/index.js";
|
|
72
73
|
export { A as ActionFormCancel } from "./components/CommonActions/components/ActionFormCancel/index.js";
|
|
@@ -76,13 +77,68 @@ export { S as ScrollToTop } from "./components/ScrollToTop/index.js";
|
|
|
76
77
|
export { u as useModal } from "./hooks/useModal/index.js";
|
|
77
78
|
export { L as Logo } from "./assets/Logo/index.js";
|
|
78
79
|
import "./node_modules.js";
|
|
79
|
-
import "./
|
|
80
|
-
import "react-dom";
|
|
81
|
-
import "prop-types";
|
|
82
|
-
import "clsx";
|
|
80
|
+
import "./index.js";
|
|
83
81
|
import "./utils/index.js";
|
|
84
82
|
import "./react-data-grid.js";
|
|
83
|
+
import "clsx";
|
|
84
|
+
import "./commonjs.js";
|
|
85
|
+
import "prop-types";
|
|
86
|
+
import "react-dom";
|
|
85
87
|
import "simplebar-react";
|
|
86
88
|
import "yup";
|
|
87
89
|
import "./react-resizable.js";
|
|
88
90
|
import "react-helmet-async";
|
|
91
|
+
const Wrapper = styled("p")(({
|
|
92
|
+
theme
|
|
93
|
+
}) => ({
|
|
94
|
+
...theme.typography.caption,
|
|
95
|
+
color: theme.palette.error.main
|
|
96
|
+
}));
|
|
97
|
+
const ErrorLabel = (props) => {
|
|
98
|
+
const {
|
|
99
|
+
message
|
|
100
|
+
} = props;
|
|
101
|
+
return /* @__PURE__ */ jsx(Wrapper, {
|
|
102
|
+
children: message
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
const useFormAddEdit = (props) => {
|
|
106
|
+
const { initialValues, objectId, endPoint, formatDataEnpoint } = props;
|
|
107
|
+
const [formValues, setFormValues] = useState(initialValues);
|
|
108
|
+
const [statusLoad, setStatusLoad] = useState(
|
|
109
|
+
objectId === void 0 ? "new" : "edit"
|
|
110
|
+
);
|
|
111
|
+
const { networkOperation } = useNetwork();
|
|
112
|
+
const { addFlag } = useFlags();
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
let mounted = true;
|
|
115
|
+
if (statusLoad === "edit") {
|
|
116
|
+
networkOperation({
|
|
117
|
+
method: "GET",
|
|
118
|
+
endPoint: `${endPoint}/${objectId}`
|
|
119
|
+
}).then(
|
|
120
|
+
(response) => {
|
|
121
|
+
if (mounted) {
|
|
122
|
+
if (formatDataEnpoint) {
|
|
123
|
+
setFormValues(formatDataEnpoint(response));
|
|
124
|
+
} else {
|
|
125
|
+
setFormValues(response);
|
|
126
|
+
}
|
|
127
|
+
setStatusLoad("reload_values_provider");
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
() => {
|
|
131
|
+
setStatusLoad("error");
|
|
132
|
+
}
|
|
133
|
+
);
|
|
134
|
+
} else if (statusLoad === "new" || statusLoad === "reload_values_provider") {
|
|
135
|
+
addFlag("form_loaded");
|
|
136
|
+
setStatusLoad("ready");
|
|
137
|
+
}
|
|
138
|
+
return () => {
|
|
139
|
+
mounted = false;
|
|
140
|
+
};
|
|
141
|
+
}, [statusLoad]);
|
|
142
|
+
return { formValues, statusLoad };
|
|
143
|
+
};
|
|
144
|
+
export { ErrorLabel, useFormAddEdit };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m4l/components",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@m4l/core": "*",
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
"react-helmet-async": "^1.3.0",
|
|
9
9
|
"react-hook-form": "^7.33.1",
|
|
10
10
|
"react-router-dom": "^6.3.0",
|
|
11
|
-
"
|
|
12
|
-
"
|
|
11
|
+
"simplebar-react": "2.4.1",
|
|
12
|
+
"yup": "^0.32.11"
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
15
|
"@mui/lab": "^5.0.0-alpha.89",
|
package/react-draggable.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React$1 from "react";
|
|
2
2
|
import require$$1 from "prop-types";
|
|
3
3
|
import require$$2 from "react-dom";
|
|
4
4
|
import clsx from "clsx";
|
|
@@ -18,7 +18,7 @@ Object.defineProperty(DraggableCore$2, "__esModule", {
|
|
|
18
18
|
value: true
|
|
19
19
|
});
|
|
20
20
|
DraggableCore$2.default = void 0;
|
|
21
|
-
var React = _interopRequireWildcard(
|
|
21
|
+
var React = _interopRequireWildcard(React$1);
|
|
22
22
|
var _propTypes = _interopRequireDefault(require$$1);
|
|
23
23
|
var _reactDom = _interopRequireDefault(require$$2);
|
|
24
24
|
var _domFns = domFns;
|
|
@@ -480,7 +480,7 @@ _defineProperty(DraggableCore$1, "defaultProps", {
|
|
|
480
480
|
}
|
|
481
481
|
});
|
|
482
482
|
exports.default = void 0;
|
|
483
|
-
var React2 = _interopRequireWildcard2(
|
|
483
|
+
var React2 = _interopRequireWildcard2(React$1);
|
|
484
484
|
var _propTypes2 = _interopRequireDefault2(require$$1);
|
|
485
485
|
var _reactDom2 = _interopRequireDefault2(require$$2);
|
|
486
486
|
var _clsx2 = _interopRequireDefault2(clsx);
|