@m4l/components 0.1.7 → 0.1.9
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/components/editors/TextEditor/index.d.ts +6 -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 +4 -0
- package/components/DataGrid/index.js +66 -4
- package/components/DataGrid/types.d.ts +5 -2
- package/components/DynamicFilter/index.js +8 -7
- package/components/ErrorLabel/index.d.ts +3 -0
- package/components/ErrorLabel/styles.d.ts +2 -0
- package/components/ErrorLabel/types.d.ts +3 -0
- package/components/LanguagePopover/index.js +3 -1
- package/components/ModalDialog/index.js +1 -1
- package/components/NoItemSelected/index.d.ts +1 -2
- package/components/NoItemSelected/index.js +3 -5
- package/components/PaperForm/components/Header.d.ts +3 -0
- package/components/PaperForm/index.js +39 -47
- package/components/PaperForm/styles.d.ts +2 -3
- package/components/PaperForm/types.d.ts +2 -2
- package/components/PropertyValue/index.js +38 -26
- package/components/PropertyValue/styles.d.ts +3 -4
- package/components/PropertyValue/types.d.ts +8 -9
- 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 +4 -3
- package/components/formatters/BooleanFormatter/types.d.ts +1 -1
- 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 +100 -4
- package/components/hook-form/FormProvider/index.js +19 -7
- package/components/hook-form/FormProvider/types.d.ts +4 -1
- package/components/hook-form/RHFAutocomplete/index.js +4 -2
- package/components/hook-form/RHFAutocomplete/types.d.ts +0 -1
- package/components/hook-form/RHFAutocompleteAsync/index.js +15 -5
- package/components/hook-form/RHFAutocompleteAsync/types.d.ts +1 -2
- package/components/hook-form/RHFCheckbox/index.d.ts +2 -1
- package/components/hook-form/RHFCheckbox/index.js +51 -30
- package/components/hook-form/RHFCheckbox/styles.d.ts +12 -1
- package/components/hook-form/RHFCheckbox/types.d.ts +0 -1
- package/components/hook-form/RHFDateTime/index.js +2 -2
- package/components/hook-form/RHFDateTime/types.d.ts +0 -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/styles.d.ts +6 -0
- package/components/hook-form/RHFPeriod/types.d.ts +29 -0
- package/components/hook-form/RHFTextField/index.js +41 -17
- package/components/hook-form/RHFTextField/types.d.ts +0 -1
- package/components/hook-form/RHFUpload/index.js +5 -5
- package/components/hook-form/index.d.ts +4 -0
- package/components/index.d.ts +5 -1
- package/components/mui_extended/Accordion/components/AccordionLabel.d.ts +3 -0
- package/components/mui_extended/Accordion/index.js +74 -14
- package/components/mui_extended/Accordion/styles.d.ts +4 -0
- package/components/mui_extended/Accordion/types.d.ts +4 -1
- package/components/mui_extended/Button/index.js +25 -25
- package/components/mui_extended/Tab/index.d.ts +2 -1
- package/components/mui_extended/Tab/index.js +2 -1
- package/components/mui_extended/Tab/types.d.ts +5 -0
- package/components/mui_extended/index.d.ts +1 -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 +290 -20
- package/package.json +3 -3
- package/utils/index.js +0 -1
- package/components/NoItemSelected/types.d.ts +0 -10
- package/components/PaperForm/skeleton.d.ts +0 -6
- package/components/hook-form/RHFCheckbox/skeleton.d.ts +0 -2
|
@@ -2,53 +2,62 @@ import { styled } from "@mui/material/styles";
|
|
|
2
2
|
import { Skeleton } from "@mui/material";
|
|
3
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { useResponsiveDesktop } from "@m4l/graphics";
|
|
5
|
+
import { useModuleSkeleton } from "@m4l/core";
|
|
5
6
|
const WrapperPropertyValue = styled("div", {
|
|
6
7
|
shouldForwardProp: (prop) => prop !== "propertyWidth" && prop !== "propertyHeight" && prop !== "isForm"
|
|
7
8
|
})(({
|
|
8
|
-
|
|
9
|
+
propertyWidth,
|
|
9
10
|
isForm,
|
|
10
11
|
theme
|
|
11
12
|
}) => ({
|
|
12
|
-
display: "
|
|
13
|
+
display: "grid",
|
|
14
|
+
gridTemplateColumns: "1fr",
|
|
13
15
|
alignItems: "flex-start",
|
|
14
16
|
width: "100%",
|
|
15
17
|
padding: `${theme.spacing(1)} ${theme.spacing(2)}`,
|
|
16
|
-
maxHeight: propertyHeight || "auto",
|
|
17
18
|
":hover": {
|
|
18
19
|
backgroundColor: isForm ? "unset" : theme.palette.grid?.rowHover
|
|
19
20
|
},
|
|
20
21
|
borderBottom: isForm ? "none" : `1px solid ${theme.palette.divider}`,
|
|
21
22
|
flexDirection: "column",
|
|
22
23
|
[theme.breakpoints.up("sm")]: {
|
|
23
|
-
|
|
24
|
+
gridTemplateColumns: propertyWidth ? `${propertyWidth}px 1fr` : "150px 1fr",
|
|
25
|
+
gap: theme.spacing(2),
|
|
24
26
|
alignItems: "center"
|
|
25
27
|
}
|
|
26
28
|
}));
|
|
27
|
-
const Property = styled("
|
|
29
|
+
const Property = styled("div", {
|
|
28
30
|
shouldForwardProp: (prop) => prop !== "propertyWidth" && prop !== "propertyHeight" && prop !== "isForm"
|
|
29
31
|
})(({
|
|
30
32
|
propertyWidth,
|
|
31
33
|
isForm,
|
|
32
34
|
theme
|
|
33
35
|
}) => ({
|
|
34
|
-
width:
|
|
35
|
-
minWidth:
|
|
36
|
+
width: "100%",
|
|
37
|
+
minWidth: "100%",
|
|
36
38
|
...theme.typography.subtitle2,
|
|
37
39
|
color: theme.palette.text.primary,
|
|
40
|
+
height: "100%",
|
|
41
|
+
display: "flex",
|
|
42
|
+
alignItems: "center",
|
|
43
|
+
justifyContent: "flex-start",
|
|
38
44
|
position: "relative",
|
|
39
45
|
[theme.breakpoints.up("sm")]: {
|
|
40
46
|
borderRight: isForm ? "none" : `1px solid ${theme.palette.divider}`,
|
|
41
47
|
paddingRight: theme.spacing(2),
|
|
42
|
-
textAlign: "right"
|
|
48
|
+
textAlign: "right",
|
|
49
|
+
width: propertyWidth || "150px",
|
|
50
|
+
minWidth: propertyWidth || "150px",
|
|
51
|
+
justifyContent: "flex-end"
|
|
43
52
|
},
|
|
44
53
|
overflow: "hidden",
|
|
45
54
|
overflowWrap: "break-word"
|
|
46
55
|
}));
|
|
47
56
|
const Value = styled("div", {
|
|
48
|
-
shouldForwardProp: (prop) => prop !== "
|
|
57
|
+
shouldForwardProp: (prop) => prop !== "valueWidth" && prop !== "valueHeight" && prop !== "withGrid"
|
|
49
58
|
})(({
|
|
50
|
-
|
|
51
|
-
|
|
59
|
+
valueWidth,
|
|
60
|
+
valueHeight,
|
|
52
61
|
theme
|
|
53
62
|
}) => ({
|
|
54
63
|
flexGrow: "1",
|
|
@@ -56,11 +65,12 @@ const Value = styled("div", {
|
|
|
56
65
|
color: theme.palette.text.secondary,
|
|
57
66
|
position: "relative",
|
|
58
67
|
padding: "1px",
|
|
59
|
-
|
|
60
|
-
|
|
68
|
+
maxWidth: `${valueWidth}%`,
|
|
69
|
+
width: `${valueWidth}%`,
|
|
70
|
+
height: valueHeight,
|
|
61
71
|
marginTop: theme.spacing(1),
|
|
62
72
|
[theme.breakpoints.up("sm")]: {
|
|
63
|
-
marginLeft: theme.spacing(
|
|
73
|
+
marginLeft: theme.spacing(0),
|
|
64
74
|
marginTop: "0px"
|
|
65
75
|
},
|
|
66
76
|
overflow: "hidden",
|
|
@@ -83,13 +93,13 @@ function PropertyValue(props) {
|
|
|
83
93
|
const {
|
|
84
94
|
property,
|
|
85
95
|
value,
|
|
86
|
-
propertyWidth,
|
|
87
|
-
|
|
96
|
+
propertyWidth = 200,
|
|
97
|
+
valueHeight = "auto",
|
|
88
98
|
valueWidth = "100",
|
|
89
|
-
isForm
|
|
90
|
-
isSkeleton = false
|
|
99
|
+
isForm
|
|
91
100
|
} = props;
|
|
92
101
|
const isDesktop = useResponsiveDesktop();
|
|
102
|
+
const isSkeleton = useModuleSkeleton();
|
|
93
103
|
const getValueW = () => {
|
|
94
104
|
if (valueWidth === "75" && isDesktop) {
|
|
95
105
|
return "75";
|
|
@@ -102,28 +112,30 @@ function PropertyValue(props) {
|
|
|
102
112
|
return "100";
|
|
103
113
|
}
|
|
104
114
|
if (valueWidth === "25" && isDesktop || valueWidth === "12.5" && isDesktop) {
|
|
105
|
-
return
|
|
106
|
-
}
|
|
107
|
-
|
|
115
|
+
return `${valueWidth}`;
|
|
116
|
+
}
|
|
117
|
+
if (valueWidth === "25" && !isDesktop) {
|
|
118
|
+
return "50";
|
|
119
|
+
}
|
|
120
|
+
if (valueWidth === "12.5" && !isDesktop) {
|
|
121
|
+
return "25";
|
|
108
122
|
}
|
|
109
123
|
return "100";
|
|
110
124
|
};
|
|
111
125
|
const valueW = getValueW();
|
|
112
126
|
return /* @__PURE__ */ jsxs(WrapperPropertyValue, {
|
|
113
|
-
id: "
|
|
127
|
+
id: "WrapperPropertyValue",
|
|
114
128
|
isForm,
|
|
115
129
|
propertyWidth,
|
|
116
|
-
propertyHeight,
|
|
117
130
|
children: [/* @__PURE__ */ jsx(Property, {
|
|
118
131
|
id: "Property",
|
|
119
132
|
isForm,
|
|
120
133
|
propertyWidth,
|
|
121
|
-
propertyHeight,
|
|
122
134
|
children: isSkeleton ? /* @__PURE__ */ jsx(SKTProperty, {}) : property
|
|
123
135
|
}), /* @__PURE__ */ jsx(Value, {
|
|
124
136
|
id: "Value",
|
|
125
|
-
|
|
126
|
-
|
|
137
|
+
valueWidth: valueW,
|
|
138
|
+
valueHeight,
|
|
127
139
|
children: value
|
|
128
140
|
})]
|
|
129
141
|
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const Value: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & ValueProps, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
2
|
+
export declare const WrapperPropertyValue: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & import("./types").PropertyProps & Pick<import("./types").PropertyValueProps, "isForm">, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
3
|
+
export declare const Property: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & import("./types").PropertyProps & Pick<import("./types").PropertyValueProps, "isForm">, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
4
|
+
export declare const Value: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & import("./types").ValueProps, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
6
5
|
export declare const SKTWrapperProperty: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
export interface PropertyProps {
|
|
3
3
|
propertyWidth?: number;
|
|
4
|
-
propertyHeight?: number | string;
|
|
5
|
-
isForm?: boolean;
|
|
6
4
|
}
|
|
7
5
|
export interface ValueProps {
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
valueHeight?: number | string;
|
|
7
|
+
valueWidth?: valueWidthType;
|
|
10
8
|
}
|
|
11
|
-
export
|
|
9
|
+
export declare type valueWidthType = '100' | '75' | '50' | '25' | '12.5';
|
|
10
|
+
export interface PropertyValueProps extends PropertyProps, ValueProps {
|
|
12
11
|
property: string;
|
|
13
|
-
isSkeleton?: boolean;
|
|
14
12
|
value: number | string | ReactNode;
|
|
13
|
+
isForm?: boolean;
|
|
15
14
|
}
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
export declare type WrapperProps = PropertyProps & Pick<PropertyValueProps, 'isForm'>;
|
|
16
|
+
export declare type WrapperPropertyProps = WrapperProps;
|
|
17
|
+
export declare type WrapperValueProps = ValueProps;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { TranHoverType, TranEnterType, TranExitType } from '../type';
|
|
2
|
-
export declare const varTranHover: (props?: TranHoverType
|
|
2
|
+
export declare const varTranHover: (props?: TranHoverType) => {
|
|
3
3
|
duration: number;
|
|
4
4
|
ease: "linear" | number[] | "easeIn" | "easeOut" | "easeInOut" | "circIn" | "circOut" | "circInOut" | "backIn" | "backOut" | "backInOut" | "anticipate";
|
|
5
5
|
};
|
|
6
|
-
export declare const varTranEnter: (props?: TranEnterType
|
|
6
|
+
export declare const varTranEnter: (props?: TranEnterType) => {
|
|
7
7
|
duration: number;
|
|
8
8
|
ease: "linear" | number[] | "easeIn" | "easeOut" | "easeInOut" | "circIn" | "circOut" | "circInOut" | "backIn" | "backOut" | "backInOut" | "anticipate";
|
|
9
9
|
};
|
|
10
|
-
export declare const varTranExit: (props?: TranExitType
|
|
10
|
+
export declare const varTranExit: (props?: TranExitType) => {
|
|
11
11
|
duration: number;
|
|
12
12
|
ease: "linear" | number[] | "easeIn" | "easeOut" | "easeInOut" | "circIn" | "circOut" | "circInOut" | "backIn" | "backOut" | "backInOut" | "anticipate";
|
|
13
13
|
};
|
|
@@ -11,18 +11,19 @@ function BooleanFormatter(props) {
|
|
|
11
11
|
const {
|
|
12
12
|
getLabel
|
|
13
13
|
} = useModuleDictionary();
|
|
14
|
+
const final_value = value ?? false;
|
|
14
15
|
if (presentationType === "string_yes_no") {
|
|
15
16
|
return /* @__PURE__ */ jsx(Component, {
|
|
16
|
-
children:
|
|
17
|
+
children: final_value ? getLabel("formatters.boolean_yes") : getLabel("formatters.boolean_no")
|
|
17
18
|
});
|
|
18
19
|
}
|
|
19
20
|
if (presentationType === "string_true_false") {
|
|
20
21
|
return /* @__PURE__ */ jsx(Component, {
|
|
21
|
-
children:
|
|
22
|
+
children: final_value ? getLabel("formatters.boolean_true") : getLabel("formatters.boolean_false")
|
|
22
23
|
});
|
|
23
24
|
}
|
|
24
25
|
return /* @__PURE__ */ jsx(Checkbox, {
|
|
25
|
-
checked:
|
|
26
|
+
checked: final_value,
|
|
26
27
|
size: "small",
|
|
27
28
|
readOnly: true,
|
|
28
29
|
disableFocusRipple: true,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
export interface UncertaintyRange {
|
|
3
|
+
cmc_min_closed: boolean;
|
|
4
|
+
cmc_min: number;
|
|
5
|
+
cmc_max_closed: boolean;
|
|
6
|
+
cmc_max: number;
|
|
7
|
+
cmc_uncertainty: number;
|
|
8
|
+
}
|
|
9
|
+
export interface UncertaintyFormatterProps {
|
|
10
|
+
Component?: ComponentType;
|
|
11
|
+
symbol?: string;
|
|
12
|
+
unit?: string;
|
|
13
|
+
value?: Array<UncertaintyRange>;
|
|
14
|
+
}
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
export { BooleanFormatter } from './BooleanFormatter';
|
|
2
2
|
export { DateFormatter } from './DateFormatter';
|
|
3
|
+
export { UncertaintyFormatter } from './UncertaintyFormatter';
|
|
4
|
+
export { PointsFormatter } from './PointsFormatter';
|
|
5
|
+
export { PriceFormatter } from './PriceFormatter';
|
|
6
|
+
export type { UncertaintyRange } from './UncertaintyFormatter/types';
|
|
@@ -1,7 +1,61 @@
|
|
|
1
|
-
import "react";
|
|
2
|
-
import "
|
|
1
|
+
import require$$0 from "react";
|
|
2
|
+
import { jsx, Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { getPropertyByString } from "@m4l/core";
|
|
3
4
|
import "@mui/material";
|
|
4
|
-
|
|
5
|
+
function UncertaintyFormatter(props) {
|
|
6
|
+
const {
|
|
7
|
+
value,
|
|
8
|
+
unit,
|
|
9
|
+
symbol,
|
|
10
|
+
Component = require$$0.Fragment
|
|
11
|
+
} = props;
|
|
12
|
+
if (value === void 0 || value === null || !Array.isArray(value)) {
|
|
13
|
+
return /* @__PURE__ */ jsx(Fragment, {
|
|
14
|
+
children: ""
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
let result = "";
|
|
18
|
+
value.map((obj, idx) => {
|
|
19
|
+
const cmc_min_closed = obj.cmc_min_closed != true ? "<" : "\u2264";
|
|
20
|
+
const cmc_max_closed = obj.cmc_max_closed != true ? "<" : "\u2264";
|
|
21
|
+
result = result.concat(`${idx > 0 ? " " : ""}`, obj.cmc_min !== obj.cmc_max ? `[${obj.cmc_min}${unit} ${cmc_min_closed} ${symbol} ${cmc_max_closed} ${obj.cmc_max}${unit} \xB1 ${obj.cmc_uncertainty}]` : `[${obj.cmc_min}${unit} \xB1 ${obj.cmc_uncertainty}]`);
|
|
22
|
+
});
|
|
23
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
24
|
+
children: result
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function PointsFormatter(props) {
|
|
28
|
+
const {
|
|
29
|
+
value,
|
|
30
|
+
unit,
|
|
31
|
+
Component = require$$0.Fragment
|
|
32
|
+
} = props;
|
|
33
|
+
console.log("points", value);
|
|
34
|
+
if (value === void 0 || value === null || !Array.isArray(value)) {
|
|
35
|
+
return /* @__PURE__ */ jsx(Fragment, {
|
|
36
|
+
children: "[]"
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
let result = "";
|
|
40
|
+
value.map((point) => {
|
|
41
|
+
if (point) {
|
|
42
|
+
console.log("point", point);
|
|
43
|
+
result = result.concat(`[${point}${unit}]`);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
47
|
+
children: result
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function PriceFormatter(props) {
|
|
51
|
+
const {
|
|
52
|
+
value,
|
|
53
|
+
Component = require$$0.Fragment
|
|
54
|
+
} = props;
|
|
55
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
56
|
+
children: `${value}$Cop`
|
|
57
|
+
});
|
|
58
|
+
}
|
|
5
59
|
function getFormattersComponentsDictionary() {
|
|
6
60
|
return ["formatters"];
|
|
7
61
|
}
|
|
@@ -13,4 +67,46 @@ const defaultFormattersDictionary = {
|
|
|
13
67
|
boolean_false: "False"
|
|
14
68
|
}
|
|
15
69
|
};
|
|
16
|
-
|
|
70
|
+
function columnUncertaintyFormatter(props) {
|
|
71
|
+
const {
|
|
72
|
+
fieldUnit,
|
|
73
|
+
fieldValue,
|
|
74
|
+
fieldSymbol,
|
|
75
|
+
Component
|
|
76
|
+
} = props;
|
|
77
|
+
return (obProps) => {
|
|
78
|
+
return /* @__PURE__ */ jsx(UncertaintyFormatter, {
|
|
79
|
+
Component,
|
|
80
|
+
value: getPropertyByString(obProps, fieldValue),
|
|
81
|
+
unit: getPropertyByString(obProps, fieldUnit),
|
|
82
|
+
symbol: getPropertyByString(obProps, fieldSymbol)
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function columnPointsFormatter(props) {
|
|
87
|
+
const {
|
|
88
|
+
fieldUnit,
|
|
89
|
+
fieldValue,
|
|
90
|
+
Component
|
|
91
|
+
} = props;
|
|
92
|
+
return (obProps) => {
|
|
93
|
+
return /* @__PURE__ */ jsx(PointsFormatter, {
|
|
94
|
+
Component,
|
|
95
|
+
value: getPropertyByString(obProps, fieldValue),
|
|
96
|
+
unit: getPropertyByString(obProps, fieldUnit)
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function columnNestedValueFormatter(props) {
|
|
101
|
+
const {
|
|
102
|
+
fieldValue,
|
|
103
|
+
Component = require$$0.Fragment
|
|
104
|
+
} = props;
|
|
105
|
+
return (obProps) => {
|
|
106
|
+
console.log("columnNestedValueFormatter", obProps, fieldValue);
|
|
107
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
108
|
+
children: getPropertyByString(obProps, fieldValue)
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
export { PointsFormatter as P, UncertaintyFormatter as U, PriceFormatter as a, columnPointsFormatter as b, columnUncertaintyFormatter as c, defaultFormattersDictionary as d, columnNestedValueFormatter as e, getFormattersComponentsDictionary as g };
|
|
@@ -18,25 +18,37 @@ function FormProvider(props) {
|
|
|
18
18
|
children,
|
|
19
19
|
onSubmit,
|
|
20
20
|
values,
|
|
21
|
-
validationSchema
|
|
21
|
+
validationSchema,
|
|
22
|
+
statusLoad = "ready"
|
|
22
23
|
} = props;
|
|
23
24
|
const methods = useForm({
|
|
24
25
|
resolver: o(validationSchema),
|
|
25
26
|
defaultValues: values
|
|
26
27
|
});
|
|
27
28
|
useEffect(() => {
|
|
28
|
-
|
|
29
|
+
console.log("useEffect FormProvider reload_values_provider===", statusLoad);
|
|
30
|
+
if (statusLoad === "reload_values_provider") {
|
|
31
|
+
const keys = Object.keys(values);
|
|
32
|
+
keys.forEach((key) => {
|
|
33
|
+
methods.setValue(key, values[key], {
|
|
34
|
+
shouldValidate: false,
|
|
35
|
+
shouldDirty: false,
|
|
36
|
+
shouldTouch: false
|
|
37
|
+
});
|
|
38
|
+
});
|
|
29
39
|
return;
|
|
30
40
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
41
|
+
}, [methods, statusLoad, values]);
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (statusLoad === "ready") {
|
|
44
|
+
console.log("useEffect FormProvider Ready", statusLoad);
|
|
45
|
+
methods.setValue("statusLoad", "ready", {
|
|
34
46
|
shouldValidate: false,
|
|
35
47
|
shouldDirty: false,
|
|
36
48
|
shouldTouch: false
|
|
37
49
|
});
|
|
38
|
-
}
|
|
39
|
-
}, [
|
|
50
|
+
}
|
|
51
|
+
}, [statusLoad]);
|
|
40
52
|
return /* @__PURE__ */ jsx(FormProvider$1, {
|
|
41
53
|
...methods,
|
|
42
54
|
children: /* @__PURE__ */ jsx(WrapperFormProvider, {
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { FieldValues } from 'react-hook-form';
|
|
3
|
+
export declare type FormStatusLoad = 'initial' | 'new' | 'edit' | 'reload_values_provider' | 'ready' | 'error';
|
|
4
|
+
export declare type FormInitialValues = FieldValues;
|
|
3
5
|
export interface FormProviderProps {
|
|
4
6
|
children: ReactNode;
|
|
5
7
|
onSubmit: (data: FieldValues) => void;
|
|
6
|
-
values:
|
|
8
|
+
values: FormInitialValues;
|
|
7
9
|
validationSchema: any;
|
|
10
|
+
statusLoad?: FormStatusLoad;
|
|
8
11
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useModuleDictionary } from "@m4l/core";
|
|
1
|
+
import { useModuleDictionary, useModuleSkeleton } from "@m4l/core";
|
|
2
2
|
import { useFormContext, Controller } from "react-hook-form";
|
|
3
3
|
import { Skeleton, Autocomplete, TextField } from "@mui/material";
|
|
4
4
|
import { styled } from "@mui/material/styles";
|
|
@@ -49,16 +49,17 @@ function RHFAutocomplete(props) {
|
|
|
49
49
|
label,
|
|
50
50
|
skeletonProps = {},
|
|
51
51
|
options,
|
|
52
|
+
disabled,
|
|
52
53
|
...other
|
|
53
54
|
} = props;
|
|
54
55
|
const {
|
|
55
|
-
isSkeleton = false,
|
|
56
56
|
width = 100,
|
|
57
57
|
height = "18px"
|
|
58
58
|
} = skeletonProps;
|
|
59
59
|
const {
|
|
60
60
|
getLabel
|
|
61
61
|
} = useModuleDictionary();
|
|
62
|
+
const isSkeleton = useModuleSkeleton();
|
|
62
63
|
const {
|
|
63
64
|
control,
|
|
64
65
|
getValues
|
|
@@ -116,6 +117,7 @@ function RHFAutocomplete(props) {
|
|
|
116
117
|
onChange(val);
|
|
117
118
|
},
|
|
118
119
|
loadingText: "",
|
|
120
|
+
disabled,
|
|
119
121
|
noOptionsText: getLabel("rhf_autocomplete.component_no_options"),
|
|
120
122
|
renderInput: (params) => {
|
|
121
123
|
return /* @__PURE__ */ jsx(TextField, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState, useEffect, Fragment } from "react";
|
|
2
|
-
import { useModuleDictionary, useNetwork, getPropertyByString } from "@m4l/core";
|
|
2
|
+
import { useModuleDictionary, useModuleSkeleton, useNetwork, getPropertyByString } from "@m4l/core";
|
|
3
3
|
import { useFormContext, Controller } from "react-hook-form";
|
|
4
4
|
import { Skeleton, Autocomplete, TextField, CircularProgress } from "@mui/material";
|
|
5
5
|
import { styled } from "@mui/material/styles";
|
|
@@ -43,23 +43,25 @@ function RHFAutocompleteAsync(props) {
|
|
|
43
43
|
label,
|
|
44
44
|
endPoint,
|
|
45
45
|
timeout = 5e3,
|
|
46
|
-
parms
|
|
46
|
+
parms,
|
|
47
47
|
resultField = "data",
|
|
48
48
|
skeletonProps = {},
|
|
49
49
|
isRemote = true,
|
|
50
|
+
disabled,
|
|
50
51
|
...other
|
|
51
52
|
} = props;
|
|
52
53
|
const {
|
|
53
|
-
isSkeleton = false,
|
|
54
54
|
width = 100,
|
|
55
55
|
height = "18px"
|
|
56
56
|
} = skeletonProps;
|
|
57
57
|
const {
|
|
58
58
|
getLabel
|
|
59
59
|
} = useModuleDictionary();
|
|
60
|
+
const isSkeleton = useModuleSkeleton();
|
|
60
61
|
const {
|
|
61
62
|
control,
|
|
62
|
-
getValues
|
|
63
|
+
getValues,
|
|
64
|
+
setValue
|
|
63
65
|
} = useFormContext();
|
|
64
66
|
const {
|
|
65
67
|
networkOperation
|
|
@@ -68,7 +70,14 @@ function RHFAutocompleteAsync(props) {
|
|
|
68
70
|
const [options, setOptions] = useState(initialValue === null ? [] : [initialValue]);
|
|
69
71
|
const [open, setOpen] = useState(false);
|
|
70
72
|
const [optionsLoaded, setOptionsLoaded] = useState(false);
|
|
71
|
-
const loading = open && !optionsLoaded;
|
|
73
|
+
const loading = open && !optionsLoaded && !!endPoint && !isSkeleton;
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
if (optionsLoaded) {
|
|
76
|
+
setOptionsLoaded(false);
|
|
77
|
+
setOptions([]);
|
|
78
|
+
setValue(name, null);
|
|
79
|
+
}
|
|
80
|
+
}, [parms, endPoint]);
|
|
72
81
|
useEffect(() => {
|
|
73
82
|
if (!optionsLoaded && initialValue) {
|
|
74
83
|
setOptions([initialValue]);
|
|
@@ -149,6 +158,7 @@ function RHFAutocompleteAsync(props) {
|
|
|
149
158
|
onChange: (_e, val) => {
|
|
150
159
|
onChange(val);
|
|
151
160
|
},
|
|
161
|
+
disabled,
|
|
152
162
|
loading,
|
|
153
163
|
loadingText: "",
|
|
154
164
|
noOptionsText: getLabel("rhf_autocomplete.component_no_options"),
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export interface SkeletonProps {
|
|
2
|
-
isSkeleton?: boolean;
|
|
3
2
|
width?: string | number;
|
|
4
3
|
height?: string | number;
|
|
5
4
|
}
|
|
@@ -10,7 +9,7 @@ export interface RHFAutocompleteAsyncProps<T> {
|
|
|
10
9
|
skeletonProps?: SkeletonProps;
|
|
11
10
|
endPoint: string;
|
|
12
11
|
timeout?: number;
|
|
13
|
-
parms?: any
|
|
12
|
+
parms?: Record<string, any>;
|
|
14
13
|
resultField?: string;
|
|
15
14
|
label: string;
|
|
16
15
|
isRemote?: boolean;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { RHFCheckboxProps } from './types';
|
|
3
|
-
export declare
|
|
3
|
+
export declare const ErrorLabel: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, {}>;
|
|
4
|
+
export declare function RHFCheckbox({ name, sizeCheck, ...other }: RHFCheckboxProps): JSX.Element;
|