@acvl/frontend-components 0.0.29 → 0.0.31
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/dist/cjs/index.js +35 -25
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/src/components/v1/forms/utils.d.ts +2 -2
- package/dist/esm/index.js +35 -25
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/src/components/v1/forms/utils.d.ts +2 -2
- package/dist/index.d.ts +2 -2
- package/package.json +1 -1
|
@@ -13,6 +13,6 @@ export interface JSONFormProps {
|
|
|
13
13
|
useLabel?: boolean;
|
|
14
14
|
props?: JSONParserProps;
|
|
15
15
|
}
|
|
16
|
-
export declare const jsonForm: ({ submitData, data, useLabel, props
|
|
17
|
-
export declare const formDataForm: ({ submitData, data, useLabel, props
|
|
16
|
+
export declare const jsonForm: ({ submitData, data, useLabel, props }: JSONFormProps) => any;
|
|
17
|
+
export declare const formDataForm: ({ submitData, data, useLabel, props }: JSONFormProps) => FormData;
|
|
18
18
|
export declare const setErrors: (form: any, error: any) => void;
|
package/dist/esm/index.js
CHANGED
|
@@ -25686,7 +25686,7 @@ const typeSwitch = ({ base_object, base_key, response, submitData, useLabel, dat
|
|
|
25686
25686
|
else if (object instanceof File) {
|
|
25687
25687
|
setValue(response, key, object);
|
|
25688
25688
|
}
|
|
25689
|
-
else if (object
|
|
25689
|
+
else if (dayjs.isDayjs(object)) {
|
|
25690
25690
|
setValue(response, key, object.format(get$1(props, `${key}.format`, "YYYY-MM-DD")));
|
|
25691
25691
|
}
|
|
25692
25692
|
else if ("label" in object && "value" in object) {
|
|
@@ -25762,7 +25762,7 @@ const typeSwitch = ({ base_object, base_key, response, submitData, useLabel, dat
|
|
|
25762
25762
|
break;
|
|
25763
25763
|
}
|
|
25764
25764
|
};
|
|
25765
|
-
const jsonForm = ({ submitData, data, useLabel, props
|
|
25765
|
+
const jsonForm = ({ submitData, data, useLabel, props }) => {
|
|
25766
25766
|
const response = {};
|
|
25767
25767
|
forEach(submitData, function (value, key) {
|
|
25768
25768
|
if (key != "id" && isEqual(get$1(data, key), value))
|
|
@@ -25780,7 +25780,7 @@ const jsonForm = ({ submitData, data, useLabel, props, }) => {
|
|
|
25780
25780
|
});
|
|
25781
25781
|
return response;
|
|
25782
25782
|
};
|
|
25783
|
-
const formDataForm = ({ submitData, data, useLabel, props
|
|
25783
|
+
const formDataForm = ({ submitData, data, useLabel, props }) => {
|
|
25784
25784
|
const formData = new FormData();
|
|
25785
25785
|
forEach(submitData, function (value, key) {
|
|
25786
25786
|
if (key != "id" && isEqual(get$1(data, key), value))
|
|
@@ -27975,32 +27975,38 @@ function ContentLayout({ children, button, badge }) {
|
|
|
27975
27975
|
}
|
|
27976
27976
|
|
|
27977
27977
|
const LinkField = ({ url, value, text }) => {
|
|
27978
|
-
return
|
|
27978
|
+
return jsx(Link, { href: `${url}/${value}`, children: text });
|
|
27979
27979
|
};
|
|
27980
27980
|
const DetailField = (props) => {
|
|
27981
27981
|
const hasLinkToViewPermission = useHasPermission(`${props.navigation?.permission}.view`);
|
|
27982
27982
|
const value = useCallback(() => {
|
|
27983
|
-
if (typeof
|
|
27983
|
+
if (typeof props.fieldData == "boolean") {
|
|
27984
27984
|
if (props.fieldData)
|
|
27985
|
-
return
|
|
27986
|
-
return
|
|
27985
|
+
return "Si";
|
|
27986
|
+
return "No";
|
|
27987
27987
|
}
|
|
27988
|
-
else if (typeof
|
|
27988
|
+
else if (typeof props.fieldData == "number") {
|
|
27989
27989
|
return props.fieldData.toString();
|
|
27990
27990
|
}
|
|
27991
|
-
else if (props.type.displayName ==
|
|
27991
|
+
else if (props.type.displayName == "ControlledSelect") {
|
|
27992
27992
|
if (props.fieldData)
|
|
27993
|
-
return map(props.fieldData, function (item) {
|
|
27993
|
+
return map(props.fieldData, function (item) {
|
|
27994
|
+
return item.label;
|
|
27995
|
+
}).join(", ");
|
|
27994
27996
|
}
|
|
27995
|
-
else if (props.type.displayName ==
|
|
27997
|
+
else if (props.type.displayName == "ControlledDate") {
|
|
27996
27998
|
if (props.fieldData) {
|
|
27997
|
-
|
|
27998
|
-
|
|
27999
|
+
switch (props.extraProps.type) {
|
|
28000
|
+
case "date":
|
|
28001
|
+
return dayjs(props.fieldData).format("YYYY-MM-DD");
|
|
28002
|
+
case "datetime":
|
|
28003
|
+
return dayjs(props.fieldData).format("YYYY-MM-DD HH:mm");
|
|
28004
|
+
}
|
|
27999
28005
|
}
|
|
28000
28006
|
}
|
|
28001
|
-
else if (props.type.displayName ==
|
|
28007
|
+
else if (props.type.displayName == "ControlledPhotoField") {
|
|
28002
28008
|
if (props.fieldData)
|
|
28003
|
-
return
|
|
28009
|
+
return "Imagen";
|
|
28004
28010
|
}
|
|
28005
28011
|
else {
|
|
28006
28012
|
if (props.fieldData) {
|
|
@@ -28010,24 +28016,27 @@ const DetailField = (props) => {
|
|
|
28010
28016
|
return props.fieldData;
|
|
28011
28017
|
}
|
|
28012
28018
|
}
|
|
28013
|
-
return
|
|
28019
|
+
return "N/A";
|
|
28014
28020
|
}, [props.detail_name, props.fieldData, props.type.displayName]);
|
|
28015
|
-
const content = `${props.detailFieldProps?.preValue ? props.detailFieldProps.preValue :
|
|
28016
|
-
if (props.navigation &&
|
|
28021
|
+
const content = `${props.detailFieldProps?.preValue ? props.detailFieldProps.preValue : ""} ${value()} ${props.detailFieldProps?.postValue ? props.detailFieldProps.postValue : ""}`;
|
|
28022
|
+
if (props.navigation &&
|
|
28023
|
+
hasLinkToViewPermission &&
|
|
28024
|
+
props.fieldData &&
|
|
28025
|
+
typeof props.fieldData == "object") {
|
|
28017
28026
|
if (Array.isArray(props.fieldData)) {
|
|
28018
|
-
return
|
|
28027
|
+
return props.fieldData.map((item, index) => (jsx(LinkField, { url: props.navigation?.url, value: get(item, "value"), text: `${get(item, "label")}${index < props.fieldData.length - 1 ? ", " : ""}` }, `${props.name}-link-${index}`)));
|
|
28019
28028
|
}
|
|
28020
|
-
return (jsx(LinkField, { url: props.navigation.url, value: get(props.fieldData,
|
|
28029
|
+
return (jsx(LinkField, { url: props.navigation.url, value: get(props.fieldData, "value"), text: content }));
|
|
28021
28030
|
}
|
|
28022
|
-
else if (props.type.displayName ==
|
|
28031
|
+
else if (props.type.displayName == "ControlledPhotoField") {
|
|
28023
28032
|
return (jsx(Link, { href: props.fieldData, download: "filename.pdf", children: content }));
|
|
28024
28033
|
}
|
|
28025
28034
|
else {
|
|
28026
28035
|
if (Array.isArray(props.fieldData)) {
|
|
28027
|
-
return
|
|
28036
|
+
return props.fieldData.map((item, index) => (jsx(Typography$1, { children: `${get(item, "label")}${index < props.fieldData.length - 1 ? ", " : ""}` }, `${props.name}-link-${index}`)));
|
|
28028
28037
|
}
|
|
28029
28038
|
else {
|
|
28030
|
-
return
|
|
28039
|
+
return jsx(Typography$1, { children: content });
|
|
28031
28040
|
}
|
|
28032
28041
|
}
|
|
28033
28042
|
};
|
|
@@ -28065,12 +28074,13 @@ const EditField = (props) => {
|
|
|
28065
28074
|
};
|
|
28066
28075
|
|
|
28067
28076
|
const Field = (props) => {
|
|
28077
|
+
const formData = props.form.watch();
|
|
28068
28078
|
const show = useMemo(() => {
|
|
28069
28079
|
if (props.dependantOn) {
|
|
28070
|
-
return props.dependantOn.method(get(props.data, props.dependantOn.fieldName), props.dependantOn.value);
|
|
28080
|
+
return props.dependantOn.method(get(props.data || formData, props.dependantOn.fieldName), props.dependantOn.value);
|
|
28071
28081
|
}
|
|
28072
28082
|
return true;
|
|
28073
|
-
}, [props.data, props.dependantOn]);
|
|
28083
|
+
}, [props.data, formData, props.dependantOn]);
|
|
28074
28084
|
const renderField = useCallback(() => {
|
|
28075
28085
|
if (!props.pageType || props.pageType == "list")
|
|
28076
28086
|
return;
|