tp-react-elements-dev 1.4.9 → 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 +32 -9
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +31 -8
- 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) => {
|
|
@@ -52700,7 +52711,19 @@ const RenderForm = (props) => {
|
|
|
52700
52711
|
},
|
|
52701
52712
|
}, minRows: props.item.minRows || 1,
|
|
52702
52713
|
// maxRows={2}
|
|
52703
|
-
placeholder: props.item.placeholder || "Type Something..." }, field, { label: `${props.item.label}${props.item.required ? ' *' : ''}`, value: field.value || "", disabled: props.item.disable
|
|
52714
|
+
placeholder: props.item.placeholder || "Type Something..." }, field, { label: `${props.item.label}${props.item.required ? ' *' : ''}`, value: field.value || "", disabled: props.item.disable, inputProps: {
|
|
52715
|
+
onInput: (e) => {
|
|
52716
|
+
var _a;
|
|
52717
|
+
if (!((_a = props === null || props === void 0 ? void 0 : props.item) === null || _a === void 0 ? void 0 : _a.allowSpecialChars)) {
|
|
52718
|
+
const value = e.target.value;
|
|
52719
|
+
e.target.value = value.replace(/[^a-zA-Z0-9 ]/g, "");
|
|
52720
|
+
} // Allow only alphanumeric and space
|
|
52721
|
+
if (e.target.value.length === 1 &&
|
|
52722
|
+
e.target.value === " ") {
|
|
52723
|
+
e.target.value = "";
|
|
52724
|
+
}
|
|
52725
|
+
},
|
|
52726
|
+
} })), jsxRuntimeExports.jsx(ErrorMessageComponent, { children: jsxRuntimeExports.jsx(s, { errors: props.errors, name: props.item.name }) })] })) }) }));
|
|
52704
52727
|
// case "textarea-normal":
|
|
52705
52728
|
// return (
|
|
52706
52729
|
// <>
|