tp-react-elements-dev 1.8.0 → 1.8.2

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.
@@ -42,6 +42,10 @@ export interface FormSectionPropsItem {
42
42
  removeButtons?: string;
43
43
  Fonts?: number[];
44
44
  FontFamily?: any;
45
+ value1?: string | number;
46
+ value2?: string | number;
47
+ label1?: string | number;
48
+ label2?: string | number;
45
49
  }
46
50
  export interface FormRenderProps {
47
51
  item: FormSectionPropsItem;
@@ -5,6 +5,7 @@ export interface FormRenderWrapperProps {
5
5
  name: string;
6
6
  numberOfColumns?: number;
7
7
  form: UseFormReturn<FieldValues, any, undefined>;
8
+ variant?: "standard" | "outlined" | "";
8
9
  }
9
- declare const FormRenderWrapper: ({ formArray, name, numberOfColumns, form, }: FormRenderWrapperProps) => import("react/jsx-runtime").JSX.Element;
10
+ declare const FormRenderWrapper: ({ formArray, name, numberOfColumns, form, variant }: FormRenderWrapperProps) => import("react/jsx-runtime").JSX.Element;
10
11
  export default FormRenderWrapper;
package/dist/index.esm.js CHANGED
@@ -53844,7 +53844,7 @@ const SingleSelect = ({ props, variant }) => {
53844
53844
  },
53845
53845
  },
53846
53846
  }, getOptionLabel: (option) => option.label, renderInput: (params) => {
53847
- return (jsxRuntimeExports.jsx(Tooltip, Object.assign({ title: params.inputProps.value && params.inputProps.value }, { children: jsxRuntimeExports.jsx(TextField, Object.assign({}, params, { placeholder: props.item.Placeholder, label: variant !== "standard" ? `${props.item.label}${props.item.required ? " *" : ""}` : '' })) })));
53847
+ return (jsxRuntimeExports.jsx(Tooltip, Object.assign({ title: params.inputProps.value && params.inputProps.value }, { children: jsxRuntimeExports.jsx(TextField, Object.assign({}, params, { placeholder: props.item.placeholder, label: variant !== "standard" ? `${props.item.label}${props.item.required ? " *" : ""}` : '' })) })));
53848
53848
  }, isOptionEqualToValue: isOptionEqualToValue })), jsxRuntimeExports.jsx(ErrorMessageComponent, { children: jsxRuntimeExports.jsx(s, { errors: props.errors, name: props.item.name }) })] }));
53849
53849
  } }, props.item.name));
53850
53850
  };
@@ -53965,9 +53965,9 @@ const DatepickerWrapperV2 = ({ props, variant }) => {
53965
53965
  };
53966
53966
  return (jsxRuntimeExports.jsx(Controller, { control: props.control, name: props.item.name, render: ({ field }) => {
53967
53967
  var _a, _b, _c, _d, _e, _f;
53968
- return (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsxs(LocalizationProvider, Object.assign({ dateAdapter: AdapterDayjs }, { children: [renderLabel(variant, props), jsxRuntimeExports.jsx(DatePicker, { label: `${props.item.label}${props.item.required ? ' *' : ''}`, value: variant !== "standard" ? typeof field.value === "string"
53968
+ return (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsxs(LocalizationProvider, Object.assign({ dateAdapter: AdapterDayjs }, { children: [renderLabel(variant, props), jsxRuntimeExports.jsx(DatePicker, { label: variant !== "standard" ? `${props.item.label}${props.item.required ? ' *' : ''}` : '', value: typeof field.value === "string"
53969
53969
  ? dayjs(field.value, "DD/MM/YYYY")
53970
- : (field.value === null || field.value === undefined) && null : '', open: open, className: "read-only", format: "DD/MM/YYYY", disabled: props.item.disable || false, onChange: (date) => {
53970
+ : (field.value === null || field.value === undefined) && null, open: open, className: "read-only", format: "DD/MM/YYYY", disabled: props.item.disable || false, onChange: (date) => {
53971
53971
  var _a, _b;
53972
53972
  field.onChange(dayjs(date).format("DD/MM/YYYY"));
53973
53973
  ((_a = props === null || props === void 0 ? void 0 : props.item) === null || _a === void 0 ? void 0 : _a.onChangeFn) && ((_b = props === null || props === void 0 ? void 0 : props.item) === null || _b === void 0 ? void 0 : _b.onChangeFn());
@@ -54008,7 +54008,7 @@ const FormRenderFileUpload = ({ props, variant }) => {
54008
54008
  }
54009
54009
  }
54010
54010
  }, [props.getValues(props.item.name)]);
54011
- return (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsxs(Box, Object.assign({ paddingLeft: "4px" }, { children: [((_a = props.item) === null || _a === void 0 ? void 0 : _a.label) && (jsxRuntimeExports.jsx(Box, Object.assign({ sx: { fontSize: "10px;" } }, { children: renderLabel(variant, props) }))), jsxRuntimeExports.jsx(TextField, { type: "file", id: props.item.name, inputProps: {
54011
+ return (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsxs(Box, Object.assign({ paddingLeft: "4px", sx: Object.assign({}, props.item.sx) }, { children: [((_a = props.item) === null || _a === void 0 ? void 0 : _a.label) && (jsxRuntimeExports.jsx(Box, Object.assign({ sx: { fontSize: "10px;" } }, { children: renderLabel(variant, props) }))), jsxRuntimeExports.jsx(TextField, { type: "file", id: props.item.name, inputProps: {
54012
54012
  accept: props.item.fileType === "excel"
54013
54013
  ? ".xls, .xlsx"
54014
54014
  : props.item.fileType === "pdf"
@@ -54091,26 +54091,40 @@ const SingleSelectNonAutoComplete = ({ props, variant }) => {
54091
54091
  }, value: item.value }, { children: item.label })))) })), jsxRuntimeExports.jsx(ErrorMessageComponent, { children: jsxRuntimeExports.jsx(s, { errors: props.errors, name: props.item.name }) })] }), props.item.name));
54092
54092
  };
54093
54093
 
54094
+ // interface FormActiveSwitchProps {
54095
+ // getValues: (name: string) => string;
54096
+ // setValue: (name: string, value: string) => void;
54097
+ // item: {
54098
+ // name: string;
54099
+ // label?: string;
54100
+ // label1?: string;
54101
+ // label2?: string;
54102
+ // value1?: string;
54103
+ // value2?: string;
54104
+ // };
54105
+ // }
54094
54106
  const FormActiveSwitch = ({ props }) => {
54095
- const { getValues, setValue, item } = props;
54107
+ var _a, _b, _c, _d;
54096
54108
  const [active, setActive] = useState(true);
54097
- const data = getValues(item.name);
54109
+ const { getValues, setValue, item } = props;
54110
+ const defaultValue1 = (_a = item.value1) !== null && _a !== void 0 ? _a : "A";
54111
+ const defaultValue2 = (_b = item.value2) !== null && _b !== void 0 ? _b : "I";
54098
54112
  useEffect(() => {
54099
- if (data === undefined || data === null) {
54100
- setActive(false);
54101
- }
54102
- else {
54103
- setActive(data);
54104
- }
54105
- }, [data]);
54113
+ const currentValue = getValues(item.name);
54114
+ setActive(currentValue === defaultValue1);
54115
+ }, [getValues, item.name, defaultValue1]);
54106
54116
  const handleSwitchChange = useCallback(() => {
54107
54117
  setActive(prevActive => {
54108
- // const newValue = !prevActive ? "A" : "I";
54109
- setValue(item.name, !prevActive);
54118
+ const newValue = !prevActive ? defaultValue1 : defaultValue2;
54119
+ setValue(item.name, newValue);
54110
54120
  return !prevActive;
54111
54121
  });
54112
- }, [setValue, item.name]);
54113
- return (jsxRuntimeExports.jsx("div", { children: jsxRuntimeExports.jsxs("div", Object.assign({ className: "m-form__input" }, { children: [item.label && (jsxRuntimeExports.jsx("span", Object.assign({ style: { fontSize: "12px", fontWeight: 400, paddingRight: 10 } }, { children: item.label }))), jsxRuntimeExports.jsxs("span", Object.assign({ className: "switch prestashop-switch fixed-width-lg" }, { children: [jsxRuntimeExports.jsx("input", { checked: active, id: `${item.name}_on`, name: item.name, type: "radio", value: "Active", onChange: handleSwitchChange }), jsxRuntimeExports.jsx("label", Object.assign({ htmlFor: `${item.name}_on`, style: { textTransform: "none" } }, { children: item.label1 ? item.label1 : "Active" })), jsxRuntimeExports.jsx("input", { checked: !active, id: `${item.name}_off`, name: item.name, type: "radio", value: "In Active", onChange: handleSwitchChange }), jsxRuntimeExports.jsx("label", Object.assign({ htmlFor: `${item.name}_off`, style: { textTransform: "none" } }, { children: item.label2 ? item.label2 : "In Active" })), jsxRuntimeExports.jsx("a", { className: "slide-button btn" })] }))] })) }));
54122
+ }, [setValue, item.name, defaultValue1, defaultValue2]);
54123
+ return (jsxRuntimeExports.jsxs("div", Object.assign({ className: "m-form__input" }, { children: [item.label && (jsxRuntimeExports.jsx("span", Object.assign({ style: {
54124
+ fontSize: "12px",
54125
+ fontWeight: 400,
54126
+ paddingRight: 10
54127
+ } }, { children: item.label }))), jsxRuntimeExports.jsxs("span", Object.assign({ className: "switch prestashop-switch fixed-width-lg" }, { children: [jsxRuntimeExports.jsx("input", { checked: active, id: `${item.name}_on`, name: item.name, type: "radio", value: "Active", onChange: handleSwitchChange }), jsxRuntimeExports.jsx("label", Object.assign({ htmlFor: `${item.name}_on`, style: { textTransform: "none", fontFamily: 'Vietnam' } }, { children: (_c = item.label1) !== null && _c !== void 0 ? _c : "Active" })), jsxRuntimeExports.jsx("input", { checked: !active, id: `${item.name}_off`, name: item.name, type: "radio", value: "In Active", onChange: handleSwitchChange }), jsxRuntimeExports.jsx("label", Object.assign({ htmlFor: `${item.name}_off`, style: { textTransform: "none", fontFamily: 'Vietnam' } }, { children: (_d = item.label2) !== null && _d !== void 0 ? _d : "In Active" })), jsxRuntimeExports.jsx("a", { className: "slide-button btn" })] }))] })));
54114
54128
  };
54115
54129
 
54116
54130
  var joditReact = {exports: {}};
@@ -54795,14 +54809,14 @@ const customTheme = createTheme({
54795
54809
  }
54796
54810
  });
54797
54811
 
54798
- const FormRenderWrapper = ({ formArray, name, numberOfColumns = 3, form, }) => {
54812
+ const FormRenderWrapper = ({ formArray, name, numberOfColumns = 3, form, variant = '' }) => {
54799
54813
  // const formContext=useFormControl({
54800
54814
  // })
54801
54815
  // useEffect(() => {
54802
54816
  // // form.reset(initialValues, { resolver: yupResolver(validationSchema) });
54803
54817
  // }, [formArray, validationSchema, initialValues]);
54804
54818
  return (jsxRuntimeExports.jsx(ThemeProvider$3, Object.assign({ theme: customTheme }, { children: jsxRuntimeExports.jsx(FormComponent, Object.assign({ container: true, margin: "auto" }, { children: formArray.map((item, i) => {
54805
- return (jsxRuntimeExports.jsx(Formitem, Object.assign({ container: true, sx: item.CustomProps, noOfColumn: item.numberOfColumns || numberOfColumns }, { children: jsxRuntimeExports.jsx(RenderForm, { item: item, register: form.register, control: form.control, errors: form.formState.errors, getValues: form.getValues, clearErrors: form.clearErrors, setValue: form.setValue }) }), i));
54819
+ return (jsxRuntimeExports.jsx(Formitem, Object.assign({ container: true, sx: item.CustomProps, noOfColumn: item.numberOfColumns || numberOfColumns }, { children: jsxRuntimeExports.jsx(RenderForm, { item: item, register: form.register, control: form.control, errors: form.formState.errors, getValues: form.getValues, clearErrors: form.clearErrors, setValue: form.setValue, variant: variant }) }), i));
54806
54820
  }) })) })));
54807
54821
  };
54808
54822