@visns-studio/visns-components 3.3.4 → 3.3.6

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.
@@ -3,6 +3,7 @@ import DatePicker from 'react-datepicker';
3
3
  import _ from 'lodash';
4
4
  import Toggle from 'react-toggle';
5
5
  import moment from 'moment';
6
+ import parse from 'html-react-parser';
6
7
  import { BlockPicker } from 'react-color';
7
8
  import { CopyToClipboard } from 'react-copy-to-clipboard';
8
9
  import { NumericFormat, PatternFormat } from 'react-number-format';
@@ -28,6 +29,7 @@ function Field({
28
29
  inputClass,
29
30
  mapbox,
30
31
  onChange,
32
+ onChangeCheckbox,
31
33
  onChangeColour,
32
34
  onChangeDate,
33
35
  onChangeSelect,
@@ -226,7 +228,6 @@ function Field({
226
228
  [
227
229
  'address',
228
230
  'async-dropdown-ajax',
229
- 'checkbox',
230
231
  'colour',
231
232
  'copytoclipboard',
232
233
  'date',
@@ -238,8 +239,6 @@ function Field({
238
239
  'plaindatetime',
239
240
  'plainrelation',
240
241
  'plainrelationarray',
241
- 'plaintext',
242
- 'plaintextheading',
243
242
  'richeditor',
244
243
  'time',
245
244
  ].includes(settings.type)
@@ -249,6 +248,31 @@ function Field({
249
248
  {settings.label} {settings.required ? '*' : ''}
250
249
  </span>
251
250
  );
251
+ } else if (['plaintext'].includes(settings.type)) {
252
+ if (settings.description) {
253
+ return (
254
+ <span>
255
+ {settings.description
256
+ ? parse(settings.description)
257
+ : ''}
258
+ </span>
259
+ );
260
+ } else {
261
+ return (
262
+ <span className="fi__span prefocus">
263
+ {settings.label} {settings.required ? '*' : ''}
264
+ </span>
265
+ );
266
+ }
267
+ } else if (['plaintextheading'].includes(settings.type)) {
268
+ return <h2>{settings.label ? settings.label : ''}</h2>;
269
+ } else if (['checkbox'].includes(settings.type)) {
270
+ return (
271
+ <span className="fi__spancheckbox">
272
+ {settings.label ? settings.label : ''}{' '}
273
+ {settings.required ? '*' : ''}
274
+ </span>
275
+ );
252
276
  }
253
277
  };
254
278
 
@@ -290,6 +314,29 @@ function Field({
290
314
 
291
315
  const renderInput = () => {
292
316
  switch (settings.type) {
317
+ case 'checkbox':
318
+ return settings.options.length > 0 ? (
319
+ <div className="fi__optionscontainer">
320
+ {settings.options.map((option, index) => (
321
+ <div
322
+ key={`${settings.id}-checkbox-option-${index}`}
323
+ className="fi__checkboxcontainer"
324
+ >
325
+ <input
326
+ name={settings.id}
327
+ type="checkbox"
328
+ className="fi__customcheckbox"
329
+ value={option.label}
330
+ checked={inputValue[index]}
331
+ onChange={onChangeCheckbox}
332
+ />
333
+ <label className="fi__checkboxlabel">
334
+ {option.label}
335
+ </label>{' '}
336
+ </div>
337
+ ))}
338
+ </div>
339
+ ) : null;
293
340
  case 'text':
294
341
  case 'json':
295
342
  case 'password':
@@ -719,6 +766,15 @@ function Field({
719
766
  }
720
767
 
721
768
  return htmlContainer;
769
+ case 'image':
770
+ return (
771
+ <input
772
+ type="file"
773
+ data-name={settings.id}
774
+ className={inputClass[settings.id]}
775
+ onChange={onChange}
776
+ />
777
+ );
722
778
  case 'richeditor':
723
779
  return (
724
780
  <Editor
@@ -128,6 +128,18 @@ function Form({
128
128
  }
129
129
  };
130
130
 
131
+ const handleChangeCheckbox = (e) => {
132
+ const { checked, name, value } = e.target;
133
+
134
+ // If the checkbox is checked and not already in the array, add it to the state
135
+ setFormData((prevFormData) => ({
136
+ ...prevFormData,
137
+ [name]: checked
138
+ ? [...prevFormData.options, value] // Add value if checked
139
+ : prevFormData.options.filter((item) => item !== value), // Remove value if unchecked
140
+ }));
141
+ };
142
+
131
143
  const handleChangeColour = (event, color, id) => {
132
144
  if (color && event && id) {
133
145
  setFormData((prevState) => ({
@@ -1084,6 +1096,7 @@ function Form({
1084
1096
  }
1085
1097
  mapbox={mapbox}
1086
1098
  onChange={handleChange}
1099
+ onChangeCheckbox={handleChangeCheckbox}
1087
1100
  onChangeDate={handleChangeDate}
1088
1101
  onChangeNumberFormat={
1089
1102
  handleChangeNumberFormat
@@ -1191,6 +1204,9 @@ function Form({
1191
1204
  }
1192
1205
  mapbox={mapbox}
1193
1206
  onChange={handleChange}
1207
+ onChangeCheckbox={
1208
+ handleChangeCheckbox
1209
+ }
1194
1210
  onChangeColour={handleChangeColour}
1195
1211
  onChangeDate={handleChangeDate}
1196
1212
  onChangeNumberFormat={
package/package.json CHANGED
@@ -49,7 +49,7 @@
49
49
  "react-dom": "^17.0.1"
50
50
  },
51
51
  "name": "@visns-studio/visns-components",
52
- "version": "3.3.4",
52
+ "version": "3.3.6",
53
53
  "description": "Various packages to assist in the development of our Custom Applications.",
54
54
  "main": "index.js",
55
55
  "scripts": {