tp-react-elements-dev 1.4.10 → 1.4.11
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 +19 -8
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +18 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
|
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
|
|
|
@@ -52248,14 +52248,25 @@ const SingleSelectNonAutoComplete = ({ props }) => {
|
|
|
52248
52248
|
};
|
|
52249
52249
|
|
|
52250
52250
|
const FormActiveSwitch = ({ props }) => {
|
|
52251
|
-
const
|
|
52252
|
-
const
|
|
52253
|
-
|
|
52254
|
-
};
|
|
52251
|
+
const { getValues, setValue, item } = props;
|
|
52252
|
+
const [active, setActive] = useState(true);
|
|
52253
|
+
const data = getValues(item.name);
|
|
52255
52254
|
useEffect(() => {
|
|
52256
|
-
|
|
52257
|
-
|
|
52258
|
-
|
|
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) => {
|