@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 CHANGED
@@ -25706,7 +25706,7 @@ const typeSwitch = ({ base_object, base_key, response, submitData, useLabel, dat
25706
25706
  else if (object instanceof File) {
25707
25707
  setValue(response, key, object);
25708
25708
  }
25709
- else if (object instanceof dayjs) {
25709
+ else if (dayjs.isDayjs(object)) {
25710
25710
  setValue(response, key, object.format(get(props, `${key}.format`, "YYYY-MM-DD")));
25711
25711
  }
25712
25712
  else if ("label" in object && "value" in object) {
@@ -25782,7 +25782,7 @@ const typeSwitch = ({ base_object, base_key, response, submitData, useLabel, dat
25782
25782
  break;
25783
25783
  }
25784
25784
  };
25785
- const jsonForm = ({ submitData, data, useLabel, props, }) => {
25785
+ const jsonForm = ({ submitData, data, useLabel, props }) => {
25786
25786
  const response = {};
25787
25787
  forEach(submitData, function (value, key) {
25788
25788
  if (key != "id" && isEqual(get(data, key), value))
@@ -25800,7 +25800,7 @@ const jsonForm = ({ submitData, data, useLabel, props, }) => {
25800
25800
  });
25801
25801
  return response;
25802
25802
  };
25803
- const formDataForm = ({ submitData, data, useLabel, props, }) => {
25803
+ const formDataForm = ({ submitData, data, useLabel, props }) => {
25804
25804
  const formData = new FormData();
25805
25805
  forEach(submitData, function (value, key) {
25806
25806
  if (key != "id" && isEqual(get(data, key), value))
@@ -27995,32 +27995,38 @@ function ContentLayout({ children, button, badge }) {
27995
27995
  }
27996
27996
 
27997
27997
  const LinkField = ({ url, value, text }) => {
27998
- return (jsxRuntime.jsx(material.Link, { href: `${url}/${value}`, children: text }));
27998
+ return jsxRuntime.jsx(material.Link, { href: `${url}/${value}`, children: text });
27999
27999
  };
28000
28000
  const DetailField = (props) => {
28001
28001
  const hasLinkToViewPermission = useHasPermission(`${props.navigation?.permission}.view`);
28002
28002
  const value = React.useCallback(() => {
28003
- if (typeof (props.fieldData) == 'boolean') {
28003
+ if (typeof props.fieldData == "boolean") {
28004
28004
  if (props.fieldData)
28005
- return 'Si';
28006
- return 'No';
28005
+ return "Si";
28006
+ return "No";
28007
28007
  }
28008
- else if (typeof (props.fieldData) == 'number') {
28008
+ else if (typeof props.fieldData == "number") {
28009
28009
  return props.fieldData.toString();
28010
28010
  }
28011
- else if (props.type.displayName == 'ControlledSelect') {
28011
+ else if (props.type.displayName == "ControlledSelect") {
28012
28012
  if (props.fieldData)
28013
- return lodash.map(props.fieldData, function (item) { return item.label; }).join(', ');
28013
+ return lodash.map(props.fieldData, function (item) {
28014
+ return item.label;
28015
+ }).join(", ");
28014
28016
  }
28015
- else if (props.type.displayName == 'ControlledDate') {
28017
+ else if (props.type.displayName == "ControlledDate") {
28016
28018
  if (props.fieldData) {
28017
- if (props.extraProps.type == 'datetime')
28018
- return dayjs(props.fieldData).format('YYYY-MM-DD HH:mm');
28019
+ switch (props.extraProps.type) {
28020
+ case "date":
28021
+ return dayjs(props.fieldData).format("YYYY-MM-DD");
28022
+ case "datetime":
28023
+ return dayjs(props.fieldData).format("YYYY-MM-DD HH:mm");
28024
+ }
28019
28025
  }
28020
28026
  }
28021
- else if (props.type.displayName == 'ControlledPhotoField') {
28027
+ else if (props.type.displayName == "ControlledPhotoField") {
28022
28028
  if (props.fieldData)
28023
- return 'Imagen';
28029
+ return "Imagen";
28024
28030
  }
28025
28031
  else {
28026
28032
  if (props.fieldData) {
@@ -28030,24 +28036,27 @@ const DetailField = (props) => {
28030
28036
  return props.fieldData;
28031
28037
  }
28032
28038
  }
28033
- return 'N/A';
28039
+ return "N/A";
28034
28040
  }, [props.detail_name, props.fieldData, props.type.displayName]);
28035
- const content = `${props.detailFieldProps?.preValue ? props.detailFieldProps.preValue : ''} ${value()} ${props.detailFieldProps?.postValue ? props.detailFieldProps.postValue : ''}`;
28036
- if (props.navigation && hasLinkToViewPermission && props.fieldData && typeof props.fieldData == 'object') {
28041
+ const content = `${props.detailFieldProps?.preValue ? props.detailFieldProps.preValue : ""} ${value()} ${props.detailFieldProps?.postValue ? props.detailFieldProps.postValue : ""}`;
28042
+ if (props.navigation &&
28043
+ hasLinkToViewPermission &&
28044
+ props.fieldData &&
28045
+ typeof props.fieldData == "object") {
28037
28046
  if (Array.isArray(props.fieldData)) {
28038
- return (props.fieldData.map((item, index) => (jsxRuntime.jsx(LinkField, { url: props.navigation?.url, value: lodash.get(item, 'value'), text: `${lodash.get(item, 'label')}${index < props.fieldData.length - 1 ? ', ' : ''}` }, `${props.name}-link-${index}`))));
28047
+ return props.fieldData.map((item, index) => (jsxRuntime.jsx(LinkField, { url: props.navigation?.url, value: lodash.get(item, "value"), text: `${lodash.get(item, "label")}${index < props.fieldData.length - 1 ? ", " : ""}` }, `${props.name}-link-${index}`)));
28039
28048
  }
28040
- return (jsxRuntime.jsx(LinkField, { url: props.navigation.url, value: lodash.get(props.fieldData, 'value'), text: content }));
28049
+ return (jsxRuntime.jsx(LinkField, { url: props.navigation.url, value: lodash.get(props.fieldData, "value"), text: content }));
28041
28050
  }
28042
- else if (props.type.displayName == 'ControlledPhotoField') {
28051
+ else if (props.type.displayName == "ControlledPhotoField") {
28043
28052
  return (jsxRuntime.jsx(material.Link, { href: props.fieldData, download: "filename.pdf", children: content }));
28044
28053
  }
28045
28054
  else {
28046
28055
  if (Array.isArray(props.fieldData)) {
28047
- return (props.fieldData.map((item, index) => (jsxRuntime.jsx(material.Typography, { children: `${lodash.get(item, 'label')}${index < props.fieldData.length - 1 ? ', ' : ''}` }, `${props.name}-link-${index}`))));
28056
+ return props.fieldData.map((item, index) => (jsxRuntime.jsx(material.Typography, { children: `${lodash.get(item, "label")}${index < props.fieldData.length - 1 ? ", " : ""}` }, `${props.name}-link-${index}`)));
28048
28057
  }
28049
28058
  else {
28050
- return (jsxRuntime.jsx(material.Typography, { children: content }));
28059
+ return jsxRuntime.jsx(material.Typography, { children: content });
28051
28060
  }
28052
28061
  }
28053
28062
  };
@@ -28085,12 +28094,13 @@ const EditField = (props) => {
28085
28094
  };
28086
28095
 
28087
28096
  const Field = (props) => {
28097
+ const formData = props.form.watch();
28088
28098
  const show = React.useMemo(() => {
28089
28099
  if (props.dependantOn) {
28090
- return props.dependantOn.method(lodash.get(props.data, props.dependantOn.fieldName), props.dependantOn.value);
28100
+ return props.dependantOn.method(lodash.get(props.data || formData, props.dependantOn.fieldName), props.dependantOn.value);
28091
28101
  }
28092
28102
  return true;
28093
- }, [props.data, props.dependantOn]);
28103
+ }, [props.data, formData, props.dependantOn]);
28094
28104
  const renderField = React.useCallback(() => {
28095
28105
  if (!props.pageType || props.pageType == "list")
28096
28106
  return;