impaktapps-jsonforms 5.425.778 → 5.425.779

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impaktapps-jsonforms",
3
- "version": "5.425.778",
3
+ "version": "5.425.779",
4
4
  "scripts": {
5
5
  "dev": "vite",
6
6
  "build": "tsc && vite build",
@@ -0,0 +1,154 @@
1
+ import React, { memo, useContext, useEffect, useState } from "react";
2
+ import {
3
+ Autocomplete,
4
+ MenuItem,
5
+ SelectChangeEvent,
6
+ TextField,
7
+ } from "@mui/material";
8
+ import { DataContext } from "../../context/Context";
9
+ import { useJsonForms, withJsonFormsControlProps } from "@jsonforms/react";
10
+ import ComponentWrapper from "../../common/ComponentWrapper";
11
+ import { getFieldName } from "../../permissions/getFieldName";
12
+ import { inputProps } from "../../interface/inputfieldProps";
13
+ import { getComponentProps } from "../../common/getComponentProps";
14
+ export const FreeSoloSelect = memo(function CustomAutoComplete(
15
+ props: inputProps
16
+ ) {
17
+ const { errors, uischema,rootSchema, data, required, handleChange, path, schema } =
18
+ props;
19
+ const uischemaData = uischema?.config?.main;
20
+ const { pageName, permissions, theme,setSchema,serviceProvider } = useContext(DataContext);
21
+ const fieldName = getFieldName(path);
22
+ const [options, setOptions] = useState(
23
+ schema?.oneOf || uischemaData.options || []
24
+ );
25
+ useEffect(() => {
26
+ if(uischemaData.multiple){
27
+ setOptions(schema?.default || uischemaData.options || []);
28
+ }else{
29
+ setOptions(schema?.oneOf || uischemaData.options || []);
30
+ }
31
+
32
+ }, [path, schema?.oneOf?.length, uischemaData?.options?.length]);
33
+ const ctx = useJsonForms();
34
+ function throttle(fn: any, delay: any) {
35
+ let timer: any;
36
+ return function (...args) {
37
+ clearTimeout(timer);
38
+ timer = setTimeout(() => fn(...args), delay);
39
+ };
40
+ }
41
+ const throttledFunction = throttle((value) => {
42
+ serviceProvider(
43
+ ctx,
44
+ { ...uischemaData, onClick: "getSelectOptions" },
45
+ {
46
+ event: { _reactName: "onClick" },
47
+ path,
48
+ ...uischemaData.additionalData,
49
+ paramValue: {
50
+ path,
51
+ },
52
+ }
53
+ ).then((res:any) => {
54
+ if (uischemaData.multiple) {
55
+ setSchema((pre:any) => {
56
+ return {
57
+ ...pre,
58
+ properties: {
59
+ ...pre.properties,
60
+ [path]: {
61
+ default: res,
62
+ type: "array",
63
+ uniqueItems: true,
64
+ },
65
+ },
66
+ };
67
+ });
68
+ setOptions((pre:any) => {
69
+ return res;
70
+ });
71
+ } else {
72
+ setSchema((pre:any) => {
73
+ return {
74
+ ...pre,
75
+ properties: {
76
+ ...pre.properties,
77
+ [path]: {
78
+ oneOf: res || [],
79
+ },
80
+ },
81
+ };
82
+ });
83
+ setOptions((pre) => {
84
+ return res;
85
+ });
86
+ }
87
+ });
88
+ }, 1000);
89
+ return (
90
+ <ComponentWrapper
91
+ {...getComponentProps(`${pageName}:${fieldName}`,permissions,schema,rootSchema)} >
92
+ <Autocomplete
93
+ onChange={(event, newValue) => {
94
+ handleChange(path, newValue);
95
+ }}
96
+ onInputChange={(event, newInputValue) => {
97
+ throttledFunction(newInputValue);
98
+ }}
99
+ filterOptions={(x) => x}
100
+ filterSelectedOptions
101
+ sx={{
102
+ ...theme.InputFieldStyle,
103
+ ...uischema?.config?.style,
104
+ ".MuiAutocomplete-tag": {
105
+ backgroundColor: theme.myTheme.palette.background.input,
106
+ color: theme.myTheme.palette.text.input,
107
+ border: `0.5px solid ${theme.myTheme.palette.text.input}`,
108
+ },
109
+
110
+ ".MuiAutocomplete-clearIndicator": {
111
+ color: theme.myTheme.palette.text.input, // Change this to the desired color for the close button
112
+ },
113
+ }}
114
+ freeSolo={uischemaData.freeSolo?true:false}
115
+ multiple={uischemaData.multiple?true:false}
116
+ id="tags-standard"
117
+ options={options?.map((option:any) => option.title)}
118
+ value={uischemaData.multiple?data??[]:data ?? ""}
119
+ renderInput={(params) => {
120
+ return (
121
+ <TextField
122
+ {...params}
123
+ size={uischemaData?.size ?? "medium"}
124
+ helperText={
125
+ errors !== ""
126
+ ? uischemaData?.errorMessage
127
+ ? uischemaData?.errorMessage
128
+ : errors
129
+ : ""
130
+ }
131
+ error={errors !== "" ? true : false}
132
+ sx={{
133
+ ...theme.InputFieldStyle,
134
+ fontSize:
135
+ theme.myTheme.palette.typography.autoCompleteFontSize,
136
+ ...uischema?.config?.TextFieldStyle,
137
+ }}
138
+ variant="outlined"
139
+ label={uischemaData?.label}
140
+ disabled={uischemaData?.disabled}
141
+ required={required}
142
+ placeholder={uischemaData?.placeholder}
143
+ onChange={uischemaData.freeSole?(newValue) => {
144
+ handleChange(path, newValue.target.value)}
145
+ :()=>console.log("Runnning")}
146
+ />
147
+ );
148
+ }}
149
+ />
150
+ </ComponentWrapper>
151
+ );
152
+ });
153
+
154
+ export default withJsonFormsControlProps(FreeSoloSelect);
@@ -0,0 +1,262 @@
1
+ import React, { memo, useContext, useEffect, useState } from "react";
2
+ import { Autocomplete, MenuItem, TextField } from "@mui/material";
3
+ import { DataContext } from "../../context/Context";
4
+ import { useJsonForms } from "@jsonforms/react";
5
+ import ComponentWrapper from "../../common/ComponentWrapper";
6
+ import { getFieldName } from "../../permissions/getFieldName";
7
+ import { inputProps } from "../../interface/inputfieldProps";
8
+ import { getComponentProps } from "../../common/getComponentProps";
9
+ export const AutoComplete = memo(function CustomAutoComplete(
10
+ props: inputProps
11
+ ) {
12
+ const {
13
+ errors,
14
+ uischema,
15
+ rootSchema,
16
+ data,
17
+ required,
18
+ handleChange,
19
+ path,
20
+ schema,
21
+ } = props;
22
+ const uischemaData = uischema?.config?.main;
23
+ const { pageName, permissions, theme, serviceProvider, setSchema } =
24
+ useContext(DataContext);
25
+ const fieldName = getFieldName(path);
26
+ const [options, setOptions] = useState(
27
+ schema?.default || uischemaData.options || []
28
+ );
29
+ const [loading, setLoading] = useState(false);
30
+ const ctx = useJsonForms();
31
+ useEffect(() => {
32
+ if (uischemaData.multiple){
33
+ setOptions(schema?.default || uischemaData.options || []);
34
+ }else{
35
+ setOptions(schema?.oneOf || uischemaData.options || []);
36
+ }
37
+ }, [
38
+ path,
39
+ schema?.default,
40
+ schema?.default?.length,
41
+ schema?.oneOf,
42
+ schema?.oneOf?.length,
43
+ uischemaData?.options?.length,
44
+ ]);
45
+ function throttle(fn: any, delay: any) {
46
+ let timer: any;
47
+ return function (...args) {
48
+ clearTimeout(timer);
49
+ timer = setTimeout(() => fn(...args), delay);
50
+ };
51
+ }
52
+ const throttledFunction = throttle((value) => {
53
+ setLoading(true);
54
+ serviceProvider(
55
+ ctx,
56
+ { ...uischemaData, onClick: "getSelectOptions" },
57
+ {
58
+ event: { _reactName: "onClick" },
59
+ path,
60
+ ...uischemaData.additionalData,
61
+ paramValue: {
62
+ path,
63
+ },
64
+ }
65
+ ).then((res) => {
66
+ if (uischemaData.multiple) {
67
+ setSchema((pre) => {
68
+ return {
69
+ ...pre,
70
+ properties: {
71
+ ...pre.properties,
72
+ [path]: {
73
+ default: res,
74
+ type: "array",
75
+ uniqueItems: true,
76
+ },
77
+ },
78
+ };
79
+ });
80
+ setOptions((pre) => {
81
+ return res;
82
+ });
83
+ } else {
84
+ setSchema((pre) => {
85
+ return {
86
+ ...pre,
87
+ properties: {
88
+ ...pre.properties,
89
+ [path]: {
90
+ oneOf: res || [],
91
+ },
92
+ },
93
+ };
94
+ });
95
+ setOptions((pre) => {
96
+ return res;
97
+ });
98
+ }
99
+ setLoading(false);
100
+ });
101
+ }, 1000);
102
+ return (
103
+ <ComponentWrapper
104
+ {...getComponentProps(
105
+ `${pageName}:${fieldName}`,
106
+ permissions,
107
+ schema,
108
+ rootSchema
109
+ )}
110
+ >
111
+ {uischemaData.multiple ? (
112
+ <Autocomplete
113
+ loading={loading}
114
+ onChange={(event, newValue) => {
115
+ if (newValue.length === 0) {
116
+ handleChange(path, undefined);
117
+ } else {
118
+ console.log(newValue);
119
+
120
+ handleChange(path, newValue);
121
+ }
122
+ }}
123
+ onInputChange={(event, newInputValue) => {
124
+ throttledFunction(newInputValue);
125
+ }}
126
+ filterOptions={(x) => x}
127
+ filterSelectedOptions
128
+ multiple={true}
129
+ sx={{
130
+ ...theme.InputFieldStyle,
131
+ ...uischema?.config?.style,
132
+ ".MuiAutocomplete-tag": {
133
+ backgroundColor: theme.myTheme.palette.background.input,
134
+ color: theme.myTheme.palette.text.input,
135
+ border: `0.5px solid ${theme.myTheme.palette.text.input}`,
136
+ },
137
+
138
+ ".MuiAutocomplete-clearIndicator": {
139
+ color: theme.myTheme.palette.text.input, // Change this to the desired color for the close button
140
+ },
141
+ }}
142
+ disableCloseOnSelect
143
+ id="tags-standard"
144
+ options={options || []}
145
+ getOptionLabel={(option: any) => {
146
+ return option?.title;
147
+ }}
148
+ value={data ?? []}
149
+ // renderOption={(props, option, { selected }) => (
150
+ // <MenuItem
151
+ // sx={{
152
+ // color: theme.myTheme.palette.text.primary,
153
+ // background: theme.myTheme.palette.secondary.main,
154
+ // marginTop: "-6.5px",
155
+ // marginBottom: "-7px",
156
+
157
+ // "&:hover": {
158
+ // backgroundColor: `${theme.myTheme.palette.primary.main} !important`,
159
+ // },
160
+ // "&:focus": {
161
+ // color: `${theme.myTheme.palette.action.active} ! important`,
162
+ // background: `${theme.myTheme.palette.action.focusBackground} !important`,
163
+ // },
164
+ // }}
165
+ // {...props}
166
+ // >
167
+ // {option.title}
168
+ // </MenuItem>
169
+ // )}
170
+ renderInput={(params) => {
171
+ return (
172
+ <TextField
173
+ {...params}
174
+ size={uischemaData?.size ?? "medium"}
175
+ helperText={
176
+ errors !== ""
177
+ ? uischemaData?.errorMessage
178
+ ? uischemaData?.errorMessage
179
+ : errors
180
+ : ""
181
+ }
182
+ error={errors !== "" ? true : false}
183
+ sx={{
184
+ ...theme.InputFieldStyle,
185
+ fontSize:
186
+ theme.myTheme.palette.typography.autoCompleteFontSize,
187
+ ...uischema?.config?.TextFieldStyle,
188
+ }}
189
+ variant="outlined"
190
+ label={uischemaData?.label}
191
+ disabled={uischemaData?.disabled}
192
+ required={required}
193
+ placeholder={uischemaData?.placeholder}
194
+ />
195
+ );
196
+ }}
197
+ />
198
+ ) : (
199
+ <Autocomplete
200
+ onChange={(event, newValue) => {
201
+ handleChange(path, newValue);
202
+ }}
203
+ filterOptions={(x) => x}
204
+ multiple={false}
205
+ filterSelectedOptions
206
+ loading={loading}
207
+ onInputChange={
208
+ uischemaData.LazyLoading
209
+ ? (event, newInputValue) => {
210
+ throttledFunction(newInputValue);
211
+ }
212
+ : () => {}
213
+ }
214
+ sx={{
215
+ ...theme.InputFieldStyle,
216
+ ...uischema?.config?.style,
217
+ ".MuiAutocomplete-tag": {
218
+ backgroundColor: theme.myTheme.palette.background.input,
219
+ border: `0.5px solid ${theme.myTheme.palette.text.input}`,
220
+ },
221
+
222
+ ".MuiAutocomplete-clearIndicator": {
223
+ color: theme.myTheme.palette.text.input, // Change this to the desired color for the close button
224
+ },
225
+ }}
226
+ id="tags-standard"
227
+ options={options.map((option) => option?.title)}
228
+ value={data ?? ""}
229
+ renderInput={(params) => {
230
+ return (
231
+ <TextField
232
+ {...params}
233
+ size={uischemaData?.size ?? "medium"}
234
+ helperText={
235
+ errors !== ""
236
+ ? uischemaData?.errorMessage
237
+ ? uischemaData?.errorMessage
238
+ : errors
239
+ : ""
240
+ }
241
+ error={errors !== "" ? true : false}
242
+ sx={{
243
+ ...theme.InputFieldStyle,
244
+ fontSize:
245
+ theme.myTheme.palette.typography.autoCompleteFontSize,
246
+ ...uischema?.config?.TextFieldStyle,
247
+ }}
248
+ variant="outlined"
249
+ label={uischemaData?.label}
250
+ disabled={uischemaData?.disabled}
251
+ required={required}
252
+ placeholder={uischemaData?.placeholder}
253
+ />
254
+ );
255
+ }}
256
+ />
257
+ )}
258
+ </ComponentWrapper>
259
+ );
260
+ });
261
+
262
+ export default AutoComplete;
@@ -0,0 +1,143 @@
1
+ import React, { memo, useContext, useEffect, useState } from "react";
2
+ import { Autocomplete, MenuItem, TextField } from "@mui/material";
3
+ import { DataContext } from "../../context/Context";
4
+ import { useJsonForms } from "@jsonforms/react";
5
+ import ComponentWrapper from "../../common/ComponentWrapper";
6
+ import { getFieldName } from "../../permissions/getFieldName";
7
+ import { inputProps } from "../../interface/inputfieldProps";
8
+ import { getComponentProps } from "../../common/getComponentProps";
9
+ export const ImpaktAppsSelect = memo(function CustomAutoComplete(
10
+ props: inputProps
11
+ ) {
12
+ const {
13
+ errors,
14
+ uischema,
15
+ rootSchema,
16
+ data,
17
+ required,
18
+ handleChange,
19
+ path,
20
+ schema,
21
+ } = props;
22
+ const uischemaData = uischema?.config?.main;
23
+ const { pageName, permissions, theme, serviceProvider, setSchema } =
24
+ useContext(DataContext);
25
+ const fieldName = getFieldName(path);
26
+ const [options, setOptions] = useState(
27
+ schema?.oneOf || uischemaData.options || []
28
+ );
29
+ const [loading, setLoading] = useState(false);
30
+ const ctx = useJsonForms();
31
+ useEffect(() => {
32
+ setOptions(schema?.oneOf || uischemaData.options || []);
33
+ }, [schema?.oneOf,schema?.oneOf?.length, uischemaData?.options, uischemaData?.options?.length]);
34
+ function throttle(fn: any, delay: any) {
35
+ let timer: any;
36
+ return function (...args) {
37
+ clearTimeout(timer);
38
+ timer = setTimeout(() => fn(...args), delay);
39
+ };
40
+ }
41
+ const throttledFunction = throttle((value) => {
42
+ setLoading(true)
43
+ serviceProvider(
44
+ ctx,
45
+ { ...uischemaData, onClick: "getSelectOptions" },
46
+ {
47
+ event: { _reactName: "onClick" },
48
+ path,
49
+ ...uischemaData.additionalData,
50
+ paramValue: {
51
+ path,
52
+ },
53
+ }
54
+ ).then((res) => {
55
+ setSchema((pre) => {
56
+ return {
57
+ ...pre,
58
+ properties: {
59
+ ...pre.properties,
60
+ [path]: {
61
+ oneOf: res || [],
62
+ },
63
+ },
64
+ };
65
+ });
66
+ setOptions((pre)=> {return res});
67
+ setLoading(false)
68
+ });
69
+ }, 1000);
70
+ return (
71
+ <ComponentWrapper
72
+ {...getComponentProps(
73
+ `${pageName}:${fieldName}`,
74
+ permissions,
75
+ schema,
76
+ rootSchema
77
+ )}
78
+ >
79
+ <Autocomplete
80
+ onChange={(event, newValue) => {
81
+ handleChange(path, newValue);
82
+ }}
83
+ filterOptions={(x) => x}
84
+ multiple={false}
85
+ filterSelectedOptions
86
+ loading={loading}
87
+ onInputChange={
88
+ uischemaData.LazyLoading
89
+ ? (event, newInputValue) => {
90
+ throttledFunction(newInputValue);
91
+ }
92
+ : () => {}
93
+ }
94
+ sx={{
95
+ ...theme.InputFieldStyle,
96
+ ...uischema?.config?.style,
97
+ ".MuiAutocomplete-tag": {
98
+ backgroundColor: theme.myTheme.palette.background.input,
99
+ border: `0.5px solid ${theme.myTheme.palette.text.input}`,
100
+ },
101
+
102
+ ".MuiAutocomplete-clearIndicator": {
103
+ color: theme.myTheme.palette.text.input, // Change this to the desired color for the close button
104
+ },
105
+ }}
106
+ id="tags-standard"
107
+ // isOptionEqualToValue={(option, value) => option.title === value.title}
108
+ // getOptionLabel={(option) => option.title||""}
109
+ options={options.map((option) => option?.title)
110
+ }
111
+ value={data ?? ""}
112
+ renderInput={(params) => {
113
+ return (
114
+ <TextField
115
+ {...params}
116
+ size={uischemaData?.size ?? "medium"}
117
+ helperText={
118
+ errors !== ""
119
+ ? uischemaData?.errorMessage
120
+ ? uischemaData?.errorMessage
121
+ : errors
122
+ : ""
123
+ }
124
+ error={errors !== "" ? true : false}
125
+ sx={{
126
+ ...theme.InputFieldStyle,
127
+ fontSize: theme.myTheme.palette.typography.autoCompleteFontSize,
128
+ ...uischema?.config?.TextFieldStyle,
129
+ }}
130
+ variant="outlined"
131
+ label={uischemaData?.label}
132
+ disabled={uischemaData?.disabled}
133
+ required={required}
134
+ placeholder={uischemaData?.placeholder}
135
+ />
136
+ );
137
+ }}
138
+ />
139
+ </ComponentWrapper>
140
+ );
141
+ });
142
+
143
+ export default ImpaktAppsSelect;