tp-react-elements-dev 1.4.4 → 1.4.5

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/README.md CHANGED
@@ -1,46 +1,96 @@
1
- # Getting Started with Create React App
2
-
3
- This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4
-
5
- ## Available Scripts
6
-
7
- In the project directory, you can run:
8
-
9
- ### `npm start`
10
-
11
- Runs the app in the development mode.\
12
- Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
13
-
14
- The page will reload if you make edits.\
15
- You will also see any lint errors in the console.
16
-
17
- ### `npm test`
18
-
19
- Launches the test runner in the interactive watch mode.\
20
- See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21
-
22
- ### `npm run build`
23
-
24
- Builds the app for production to the `build` folder.\
25
- It correctly bundles React in production mode and optimizes the build for the best performance.
26
-
27
- The build is minified and the filenames include the hashes.\
28
- Your app is ready to be deployed!
29
-
30
- See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31
-
32
- ### `npm run eject`
33
-
34
- **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
35
-
36
- If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37
-
38
- Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
39
-
40
- You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
41
-
42
- ## Learn More
43
-
44
- You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45
-
46
- To learn React, check out the [React documentation](https://reactjs.org/).
1
+ ## How to use the Library
2
+ This Library is a reusable component gives intialvalues and validation schema for useForm and you can render Form Field Components without adding any text fields.
3
+
4
+ ```js
5
+ import { yupResolver } from "@hookform/resolvers/yup";
6
+ import { useForm } from "react-hook-form";
7
+ import { RenderForm, useFormValidatingContext } from "tp-react-elements-dev";
8
+ import { FormSectionPropsItem } from "tp-react-elements-dev/dist/components/Form/FormRender";
9
+ const App = () => {
10
+ const formArray:FormSectionPropsItem[]= [
11
+ {
12
+ name: "userName",
13
+ label: "User Name",
14
+ inputType: "text",
15
+ required: true,
16
+ errorMessage: "Please enter",
17
+ },
18
+ {
19
+ name: "password",
20
+ label: "Password",
21
+ inputType: "number",
22
+ required: true,
23
+ errorMessage: "Please enter",
24
+ },
25
+ {
26
+ name: "date",
27
+ label: "Password",
28
+ inputType: "datepicker",
29
+ required: true,
30
+ errorMessage: "Please select message",
31
+ minDate:'30/06/2024',
32
+ maxDate:'22/07/2024'
33
+ },
34
+ {
35
+ name: "password1",
36
+ label: "Password New",
37
+ inputType: "password",
38
+ required: true,
39
+ errorMessage: "Please select message",
40
+ },
41
+ {
42
+ name: "daterange",
43
+ label: "Password",
44
+ required:true,
45
+ inputType: "multiselect",
46
+ options:[]
47
+ },
48
+ {
49
+ name: "daterangepicker",
50
+ label: "Date range Picker",
51
+ required:true,
52
+ inputType: "dateRangePicker",
53
+ monthSpan:1
54
+ },
55
+ {
56
+ name: "status",
57
+ label: "sdf",
58
+ inputType: "toggleSwitch",
59
+ monthSpan:1
60
+ },
61
+ {
62
+ name: "yearpicker",
63
+ label: "Year",
64
+ required:true,
65
+ inputType: "yearpicker",
66
+ monthSpan:1
67
+ },
68
+ {
69
+ name: "monthpicker",
70
+ label: "Month Picker",
71
+ required:true,
72
+ inputType: "monthpicker",
73
+ monthSpan:1
74
+ },
75
+ {
76
+ name: "file",
77
+ label: "File Upload",
78
+ required:true,
79
+ inputType: "file",
80
+ monthSpan:1
81
+ },
82
+ ];
83
+ const { initialValues, validationSchema } = useFormValidatingContext(
84
+ formArray
85
+ );
86
+ const form=useForm({
87
+ defaultValues:initialValues,
88
+ resolver:yupResolver(validationSchema)
89
+ })
90
+ return (
91
+ <RenderForm formArray={formArray} name={"form1"} form={form} numberOfColumns={2} />
92
+ )
93
+ }
94
+
95
+ export default App
96
+ ```
@@ -14,11 +14,12 @@ export interface FormSectionPropsItem {
14
14
  helperText?: string;
15
15
  disable?: boolean;
16
16
  onChangeFn?: (e: string | number | undefined | null | boolean) => void;
17
+ onBlurFn?: (e: string | number | undefined | null | boolean) => void;
17
18
  maxLength?: number;
18
19
  minDate?: string;
19
20
  maxDate?: string;
20
21
  placeholder?: string;
21
- minRows?: string;
22
+ minRows?: string | number;
22
23
  CustomProps?: string;
23
24
  numberOfColumns?: number;
24
25
  monthSpan?: number;
package/dist/index.esm.js CHANGED
@@ -41035,11 +41035,11 @@ styled$1(Button)(() => ({
41035
41035
  backgroundColor: ' #343a40',
41036
41036
  borderColor: '#343a40'
41037
41037
  }));
41038
- styled$1(Grid)(() => ({
41038
+ const LabelComponent = styled$1(Grid)(() => ({
41039
41039
  alignItems: 'start',
41040
41040
  gap: '1px'
41041
41041
  }));
41042
- styled$1('text')(() => ({
41042
+ const ImportantMark = styled$1('text')(() => ({
41043
41043
  color: 'red'
41044
41044
  }));
41045
41045
  styled$1(Box)(() => ({
@@ -50377,6 +50377,9 @@ const SingleSelect = ({ props }) => {
50377
50377
  ((_a = props === null || props === void 0 ? void 0 : props.item) === null || _a === void 0 ? void 0 : _a.onChangeFn) &&
50378
50378
  ((_b = props === null || props === void 0 ? void 0 : props.item) === null || _b === void 0 ? void 0 : _b.onChangeFn(newValue === null || newValue === void 0 ? void 0 : newValue.value));
50379
50379
  (props === null || props === void 0 ? void 0 : props.clearErrors) && (props === null || props === void 0 ? void 0 : props.clearErrors((_c = props === null || props === void 0 ? void 0 : props.item) === null || _c === void 0 ? void 0 : _c.name));
50380
+ }, onBlur: (e) => {
50381
+ var _a, _b;
50382
+ ((_a = props === null || props === void 0 ? void 0 : props.item) === null || _a === void 0 ? void 0 : _a.onBlurFn) && ((_b = props === null || props === void 0 ? void 0 : props.item) === null || _b === void 0 ? void 0 : _b.onBlurFn(e));
50380
50383
  }, size: "small", sx: {
50381
50384
  "& .MuiAutocomplete-input": {
50382
50385
  padding: "0px 0px 0px 5px !important",
@@ -50520,6 +50523,10 @@ const DatepickerWrapperV2 = ({ props }) => {
50520
50523
  // style: { input: { cursor: "pointer" } },
50521
50524
  onClick: () => handleToggle(),
50522
50525
  inputRef: inputTextRef,
50526
+ onBlur: (e) => {
50527
+ var _a, _b;
50528
+ ((_a = props === null || props === void 0 ? void 0 : props.item) === null || _a === void 0 ? void 0 : _a.onBlurFn) && ((_b = props === null || props === void 0 ? void 0 : props.item) === null || _b === void 0 ? void 0 : _b.onBlurFn(e));
50529
+ }
50523
50530
  // onFocus: () => inputTextRef.current?.blur(),
50524
50531
  },
50525
50532
  }, sx: {
@@ -50538,23 +50545,20 @@ const DatepickerWrapperV2 = ({ props }) => {
50538
50545
  };
50539
50546
 
50540
50547
  const FormRenderFileUpload = ({ props }) => {
50548
+ var _a, _b, _c;
50541
50549
  // const getDocument:any=document;
50542
50550
  // useEffect(()=>{
50543
50551
  // if(props.getValues(props.item.name)===null || props.getValues(props.item.name)==undefined){
50544
50552
  // // getDocument.getElementById(props.item.name)?.value=''
50545
50553
  // }
50546
50554
  // },[props.getValues(props.item.name)])
50547
- return (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(Box, Object.assign({ paddingLeft: "4px" }, { children: jsxRuntimeExports.jsx(TextField, { type: "file", id: props.item.name, inputProps: { accept: props.item.fileType === 'excel' ? ".xls, .xlsx" : '' }, onChange: (event) => {
50548
- var _a, _b, _c;
50549
- const file = (_a = event.target) === null || _a === void 0 ? void 0 : _a.files[0];
50550
- const fileName = file ? file.name : null;
50551
- props.setValue((_b = props.item) === null || _b === void 0 ? void 0 : _b.name, file);
50552
- props.setValue(((_c = props.item) === null || _c === void 0 ? void 0 : _c.name) + "Name", fileName);
50553
- // props?.item?.onChangeInput({
50554
- // [props.item.name]: file,
50555
- // [props.item.name + "Name"]: fileName,
50556
- // });
50557
- }, sx: { width: "100%" } }) })), jsxRuntimeExports.jsx(ErrorMessageComponent, { children: jsxRuntimeExports.jsx(s, { errors: props.errors, name: props.item.name }) })] }));
50555
+ 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((_b = props.item) === null || _b === void 0 ? void 0 : _b.label, (_c = props.item) === null || _c === void 0 ? void 0 : _c.required) })), jsxRuntimeExports.jsx(TextField, { type: "file", id: props.item.name, inputProps: { accept: props.item.fileType === 'excel' ? ".xls, .xlsx" : '' }, onChange: (event) => {
50556
+ var _a, _b, _c;
50557
+ const file = (_a = event.target) === null || _a === void 0 ? void 0 : _a.files[0];
50558
+ const fileName = file ? file.name : null;
50559
+ props.setValue((_b = props.item) === null || _b === void 0 ? void 0 : _b.name, file);
50560
+ props.setValue(((_c = props.item) === null || _c === void 0 ? void 0 : _c.name) + "Name", fileName);
50561
+ }, sx: { width: "100%" } })] })), jsxRuntimeExports.jsx(ErrorMessageComponent, { children: jsxRuntimeExports.jsx(s, { errors: props.errors, name: props.item.name }) })] }));
50558
50562
  };
50559
50563
 
50560
50564
  const useStyles = makeStyles((theme) => ({
@@ -50573,7 +50577,10 @@ const SingleSelectNonAutoComplete = ({ props }) => {
50573
50577
  useStyles();
50574
50578
  return (jsxRuntimeExports.jsxs(FormControl, Object.assign({ fullWidth: true, sx: { position: "relative" } }, { children: [jsxRuntimeExports.jsx(InputLabel, Object.assign({ id: "demo-simple-select-label" }, { children: props.item.label })), jsxRuntimeExports.jsx(Select, Object.assign({ labelId: "demo-simple-select-label", id: "demo-simple-select",
50575
50579
  // {...props.register(props.item.name)}
50576
- value: props.getValues(props.item.name), label: `${props.item.label}${props.item.required ? ' *' : ''}`, onChange: (e) => props.setValue(props.item.name, e.target.value) }, { children: props.item.options.map((item) => (jsxRuntimeExports.jsx(MenuItem, Object.assign({ sx: {
50580
+ value: props.getValues(props.item.name), label: `${props.item.label}${props.item.required ? ' *' : ''}`, onChange: (e) => props.setValue(props.item.name, e.target.value), onBlur: (e) => {
50581
+ var _a, _b;
50582
+ ((_a = props === null || props === void 0 ? void 0 : props.item) === null || _a === void 0 ? void 0 : _a.onBlurFn) && ((_b = props === null || props === void 0 ? void 0 : props.item) === null || _b === void 0 ? void 0 : _b.onBlurFn(e));
50583
+ } }, { children: props.item.options.map((item) => (jsxRuntimeExports.jsx(MenuItem, Object.assign({ sx: {
50577
50584
  fontSize: "11px",
50578
50585
  fontFamily: "Roboto-Reg",
50579
50586
  zIndex: 2000,
@@ -50591,6 +50598,9 @@ const FormActiveSwitch = ({ props }) => {
50591
50598
  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" })] }))] })) }));
50592
50599
  };
50593
50600
 
50601
+ const renderLabel = (label, isRequired, alignRight) => {
50602
+ return (jsxRuntimeExports.jsx(LabelComponent, Object.assign({ container: true, style: { justifyContent: "normal" } }, { children: jsxRuntimeExports.jsxs(Box, Object.assign({ fontSize: "12px", fontFamily: "Roboto-Reg" }, { children: [label, isRequired ? jsxRuntimeExports.jsx(ImportantMark, { children: " *" }) : ""] })) })));
50603
+ };
50594
50604
  function formatDateMonthAndYear(date) {
50595
50605
  // Check if date is a string
50596
50606
  if (typeof date !== 'string') {
@@ -50639,7 +50649,10 @@ const RenderForm = (props) => {
50639
50649
  },
50640
50650
  },
50641
50651
  // classes={{ option: { color: "red !important" } }}
50642
- value: field.value || "", size: "small", disabled: props.item.disable })), ((_a = props === null || props === void 0 ? void 0 : props.item) === null || _a === void 0 ? void 0 : _a.helperText) && (jsxRuntimeExports.jsxs("span", Object.assign({ style: {
50652
+ value: field.value || "", size: "small", disabled: props.item.disable, onBlur: (e) => {
50653
+ var _a, _b;
50654
+ ((_a = props === null || props === void 0 ? void 0 : props.item) === null || _a === void 0 ? void 0 : _a.onBlurFn) && ((_b = props === null || props === void 0 ? void 0 : props.item) === null || _b === void 0 ? void 0 : _b.onBlurFn(e));
50655
+ } })), ((_a = props === null || props === void 0 ? void 0 : props.item) === null || _a === void 0 ? void 0 : _a.helperText) && (jsxRuntimeExports.jsxs("span", Object.assign({ style: {
50643
50656
  fontFamily: "Roboto-Reg",
50644
50657
  fontSize: "11px",
50645
50658
  color: "#3651d3",
@@ -50648,7 +50661,10 @@ const RenderForm = (props) => {
50648
50661
  case "register-number":
50649
50662
  return (jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: jsxRuntimeExports.jsx(Controller, { control: props.control, name: props.item.name, render: ({ field }) => {
50650
50663
  var _a, _b;
50651
- return (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(TextField, Object.assign({}, field, { fullWidth: true, label: `${props.item.label}${props.item.required ? ' *' : ''}`, InputProps: {
50664
+ return (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(TextField, Object.assign({}, field, { fullWidth: true, onBlur: (e) => {
50665
+ var _a, _b;
50666
+ ((_a = props === null || props === void 0 ? void 0 : props.item) === null || _a === void 0 ? void 0 : _a.onBlurFn) && ((_b = props === null || props === void 0 ? void 0 : props.item) === null || _b === void 0 ? void 0 : _b.onBlurFn(e));
50667
+ }, label: `${props.item.label}${props.item.required ? ' *' : ''}`, InputProps: {
50652
50668
  style: {
50653
50669
  fontFamily: "Roboto-Reg",
50654
50670
  border: "none",
@@ -50706,6 +50722,9 @@ const RenderForm = (props) => {
50706
50722
  ((_a = props === null || props === void 0 ? void 0 : props.item) === null || _a === void 0 ? void 0 : _a.onChangeFn) &&
50707
50723
  ((_b = props === null || props === void 0 ? void 0 : props.item) === null || _b === void 0 ? void 0 : _b.onChangeFn(e.target.value));
50708
50724
  (props === null || props === void 0 ? void 0 : props.clearErrors) && (props === null || props === void 0 ? void 0 : props.clearErrors(props.item.name));
50725
+ }, onBlur: (e) => {
50726
+ var _a, _b;
50727
+ ((_a = props === null || props === void 0 ? void 0 : props.item) === null || _a === void 0 ? void 0 : _a.onBlurFn) && ((_b = props === null || props === void 0 ? void 0 : props.item) === null || _b === void 0 ? void 0 : _b.onBlurFn(e));
50709
50728
  }, sx: {
50710
50729
  "& .css-1holvmy,.css-lqj8pz-MuiFormLabel-root-MuiInputLabel-root,.css-kichxs-MuiFormLabel-root-MuiInputLabel-root": {
50711
50730
  top: "-10px",
@@ -50723,6 +50742,9 @@ const RenderForm = (props) => {
50723
50742
  "& .css-16hdwvj,.css-1idq7r3-MuiFormLabel-root-MuiInputLabel-root": {
50724
50743
  top: "-5px",
50725
50744
  },
50745
+ }, onBlur: (e) => {
50746
+ var _a, _b;
50747
+ ((_a = props === null || props === void 0 ? void 0 : props.item) === null || _a === void 0 ? void 0 : _a.onBlurFn) && ((_b = props === null || props === void 0 ? void 0 : props.item) === null || _b === void 0 ? void 0 : _b.onBlurFn(e));
50726
50748
  }, onInput: (e) => {
50727
50749
  // Allow numbers, a single decimal point, and negation in the input
50728
50750
  e.target.value = e.target.value.replace(/[^0-9.-]/g, "");