tp-react-elements-dev 1.4.10 → 1.4.13

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/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React$1 from 'react';
2
- import React__default, { forwardRef, useContext, Children, isValidElement, cloneElement, useState, useRef, useEffect, createContext, useMemo, useCallback } from 'react';
2
+ import React__default, { forwardRef, useContext, Children, isValidElement, cloneElement, useState, useRef, useEffect, useCallback, createContext, useMemo } from 'react';
3
3
  import * as ReactDOM from 'react-dom';
4
4
  import ReactDOM__default from 'react-dom';
5
5
 
@@ -52082,7 +52082,7 @@ const PasswordField = ({ props }) => {
52082
52082
  const handleTogglePasswordVisibility = () => {
52083
52083
  setShowPassword((prevShowPassword) => !prevShowPassword);
52084
52084
  };
52085
- return (jsxRuntimeExports.jsxs(FormControl, Object.assign({ fullWidth: true }, { children: [" ", jsxRuntimeExports.jsx(Controller, { control: props.control, name: props.item.name, render: ({ field }) => (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsxs(Box, Object.assign({ sx: { position: "relative" } }, { children: [" ", jsxRuntimeExports.jsx(TextField, Object.assign({ size: "small", type: showPassword ? "text" : "password" }, field, { label: `${props.item.label}${props.item.required ? ' *' : ''}`, sx: {
52085
+ return (jsxRuntimeExports.jsxs(FormControl, Object.assign({ fullWidth: true }, { children: [" ", jsxRuntimeExports.jsx(Controller, { control: props.control, name: props.item.name, render: ({ field }) => (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsxs(Box, Object.assign({ sx: { position: "relative" } }, { children: [" ", jsxRuntimeExports.jsx(TextField, Object.assign({ size: "small", type: showPassword ? "text" : "password", placeholder: props.item.placeholder || "" }, field, { label: `${props.item.label}${props.item.required ? ' *' : ''}`, sx: {
52086
52086
  width: "100%",
52087
52087
  "& .css-kichxs-MuiFormLabel-root-MuiInputLabel-root,.css-1holvmy": {
52088
52088
  top: "-8px",
@@ -52248,14 +52248,25 @@ const SingleSelectNonAutoComplete = ({ props }) => {
52248
52248
  };
52249
52249
 
52250
52250
  const FormActiveSwitch = ({ props }) => {
52251
- const [active, setActive] = useState(props.getValues(props.item.name)); // Assuming "Active" is the default
52252
- const handleSwitchChange = () => {
52253
- setActive(!active);
52254
- };
52251
+ const { getValues, setValue, item } = props;
52252
+ const [active, setActive] = useState(true);
52253
+ const data = getValues(item.name);
52255
52254
  useEffect(() => {
52256
- props.setValue(props.item.name, active);
52257
- }, [active]);
52258
- return (jsxRuntimeExports.jsx("div", { children: jsxRuntimeExports.jsxs("div", Object.assign({ className: "m-form__input" }, { children: [props.item.label && jsxRuntimeExports.jsx("span", Object.assign({ style: { fontSize: "12px", fontWeight: 400, paddingRight: 10 } }, { children: props.item.label })), jsxRuntimeExports.jsxs("span", Object.assign({ className: "switch prestashop-switch fixed-width-lg" }, { children: [jsxRuntimeExports.jsx("input", { checked: active, id: props.item.name + '_on', name: props.item.name, type: "radio", value: "Active", onChange: handleSwitchChange }), jsxRuntimeExports.jsx("label", Object.assign({ htmlFor: props.item.name + '_on', style: { fontFamily: "Roboto-Reg", textTransform: "none" } }, { children: props.item.label1 ? props.item.label1 : 'Active' })), jsxRuntimeExports.jsx("input", { id: props.item.name + '_off', checked: !active, name: props.item.name, type: "radio", value: "In Active", onChange: handleSwitchChange }), jsxRuntimeExports.jsx("label", Object.assign({ htmlFor: props.item.name + '_off', style: { fontFamily: "Roboto-Reg", textTransform: "none" } }, { children: props.item.label2 ? props.item.label2 : 'In Active' })), jsxRuntimeExports.jsx("a", { className: "slide-button btn" })] }))] })) }));
52255
+ if (data === undefined || data === null) {
52256
+ setActive(false);
52257
+ }
52258
+ else {
52259
+ setActive(data);
52260
+ }
52261
+ }, [data]);
52262
+ const handleSwitchChange = useCallback(() => {
52263
+ setActive(prevActive => {
52264
+ // const newValue = !prevActive ? "A" : "I";
52265
+ setValue(item.name, !prevActive);
52266
+ return !prevActive;
52267
+ });
52268
+ }, [setValue, item.name]);
52269
+ 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: { fontFamily: "Roboto-Reg", 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: { fontFamily: "Roboto-Reg", textTransform: "none" } }, { children: item.label2 ? item.label2 : "In Active" })), jsxRuntimeExports.jsx("a", { className: "slide-button btn" })] }))] })) }));
52259
52270
  };
52260
52271
 
52261
52272
  const renderLabel = (label, isRequired, alignRight) => {
@@ -52282,7 +52293,7 @@ const RenderForm = (props) => {
52282
52293
  var _a, _b;
52283
52294
  return (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(TextField, Object.assign({}, field, { fullWidth: true,
52284
52295
  // error={props.errors}
52285
- label: `${props.item.label}${props.item.required ? ' *' : ''}`, InputProps: {
52296
+ label: `${props.item.label}${props.item.required ? ' *' : ''}`, placeholder: props.item.placeholder || "", InputProps: {
52286
52297
  style: {
52287
52298
  fontFamily: "Roboto-Reg",
52288
52299
  border: "none",
@@ -55113,6 +55124,14 @@ const useFormValidatingContext = (formArray) => {
55113
55124
  .required(field.errorMessage);
55114
55125
  }
55115
55126
  break;
55127
+ case "password":
55128
+ initialValues[field.name] = "";
55129
+ if (field.required && field.errorMessage) {
55130
+ validationShape[field.name] = create$6()
55131
+ .typeError(field.errorMessage)
55132
+ .required(field.errorMessage);
55133
+ }
55134
+ break;
55116
55135
  case "email":
55117
55136
  initialValues[field.name] = "";
55118
55137
  if (field.required && field.errorMessage) {
@@ -55192,15 +55211,6 @@ const useFormValidatingContext = (formArray) => {
55192
55211
  });
55193
55212
  }
55194
55213
  break;
55195
- case "password":
55196
- initialValues[field.name] = "";
55197
- if (field.required && field.errorMessage) {
55198
- validationShape[field.name] = create$5()
55199
- .nullable()
55200
- .typeError(`Please enter ${field.label}`)
55201
- .required(field.errorMessage);
55202
- }
55203
- break;
55204
55214
  case "select":
55205
55215
  initialValues[field.name] = "";
55206
55216
  if (field.required && field.errorMessage) {