@visns-studio/visns-components 5.11.21 → 5.11.22

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.
Files changed (159) hide show
  1. package/package.json +5 -5
  2. package/src/components/{crm/Autocomplete.jsx → Autocomplete.jsx} +1 -1
  3. package/src/components/{crm/BusinessCardOcr.jsx → BusinessCardOcr.jsx} +1 -1
  4. package/src/components/{crm/DataGrid.jsx → DataGrid.jsx} +18 -4
  5. package/src/components/{crm/Download.jsx → Download.jsx} +1 -1
  6. package/src/components/{cms/DropZone.jsx → DropZone.jsx} +1 -1
  7. package/src/components/{crm/Field.jsx → Field.jsx} +2 -2
  8. package/src/components/{crm/Form.jsx → Form.jsx} +1 -1
  9. package/src/components/{crm/auth → auth}/ClientLogin.jsx +2 -2
  10. package/src/components/{crm/auth → auth}/ClientOTPVerify.jsx +2 -2
  11. package/src/components/{crm/auth → auth}/Login.jsx +2 -2
  12. package/src/components/{crm/auth → auth}/Profile.jsx +3 -3
  13. package/src/components/{crm/auth → auth}/Reset.jsx +2 -2
  14. package/src/components/{crm/auth → auth}/TwoFactorAuth.jsx +2 -2
  15. package/src/components/{crm/auth → auth}/Verify.jsx +2 -2
  16. package/src/components/{crm/client → client}/ClientDashboard.jsx +1 -1
  17. package/src/components/{crm/client → client}/ClientPortal.jsx +1 -1
  18. package/src/components/{crm/columns → columns}/ColumnRenderers.jsx +31 -20
  19. package/src/components/{crm/generic → generic}/ActionButtons.jsx +1 -1
  20. package/src/components/{crm/generic → generic}/AlternativeActionModal.jsx +2 -2
  21. package/src/components/{crm/generic → generic}/AuditLog.jsx +1 -1
  22. package/src/components/{crm/generic → generic}/AuditLogs.jsx +1 -1
  23. package/src/components/{cms/generic → generic}/CmsDetail.jsx +2 -2
  24. package/src/components/{cms/generic → generic}/CmsSort.jsx +1 -1
  25. package/src/components/{crm/generic → generic}/ConfirmationDialog.jsx +1 -1
  26. package/src/components/{crm/generic → generic}/ContactSelectorModal.jsx +2 -2
  27. package/src/components/{crm/generic → generic}/DatePickerDialog.jsx +2 -2
  28. package/src/components/{crm/generic → generic}/DateRangeSelectorModal.jsx +2 -2
  29. package/src/components/{crm/generic → generic}/GenericClientPortal.jsx +1 -1
  30. package/src/components/{crm/generic → generic}/GenericDashboard.jsx +4 -4
  31. package/src/components/{crm/generic → generic}/GenericDetail.jsx +5 -5
  32. package/src/components/{crm/generic → generic}/GenericDynamic.jsx +1 -1
  33. package/src/components/{crm/generic → generic}/GenericEditableTable.jsx +1 -1
  34. package/src/components/{crm/generic → generic}/GenericFormBuilder.jsx +2 -2
  35. package/src/components/{crm/generic → generic}/GenericGrid.jsx +2 -2
  36. package/src/components/{crm/generic → generic}/GenericIndex.jsx +2 -2
  37. package/src/components/{crm/generic → generic}/GenericMain.jsx +2 -2
  38. package/src/components/{crm/generic → generic}/GenericQuote.jsx +4 -4
  39. package/src/components/{crm/generic → generic}/GenericReport.jsx +2 -2
  40. package/src/components/{crm/generic → generic}/GenericReportForm.jsx +1 -1
  41. package/src/components/{crm/generic → generic}/GenericSort.jsx +2 -2
  42. package/src/components/{crm/generic → generic}/NotificationList.jsx +1 -1
  43. package/src/components/{crm/generic → generic}/ReasonCollectorModal.jsx +2 -2
  44. package/src/components/{crm/generic → generic}/SortableQuoteItems.jsx +1 -1
  45. package/src/components/proposal/SectionEditor.jsx +1 -1
  46. package/src/components/{crm/sorting → sorting}/Item.jsx +1 -1
  47. package/src/components/{crm/sorting → sorting}/List.jsx +1 -1
  48. package/src/index.js +57 -59
  49. package/src/components/cms/DataGrid.jsx +0 -1652
  50. package/src/components/cms/Field.jsx +0 -802
  51. package/src/components/cms/Form.jsx +0 -475
  52. package/src/components/cms/sorting/Item.jsx +0 -121
  53. package/src/components/cms/sorting/List.jsx +0 -32
  54. package/src/components/cms/sorting/styles/Item.module.scss +0 -38
  55. package/src/components/crm/sorting/styles/List.module.scss +0 -74
  56. /package/src/components/{crm/AssociationManager.jsx → AssociationManager.jsx} +0 -0
  57. /package/src/components/{crm/AsyncSelect.jsx → AsyncSelect.jsx} +0 -0
  58. /package/src/components/{crm/Breadcrumb.jsx → Breadcrumb.jsx} +0 -0
  59. /package/src/components/{crm/Call.jsx → Call.jsx} +0 -0
  60. /package/src/components/{crm/ClientAssociationManager.jsx → ClientAssociationManager.jsx} +0 -0
  61. /package/src/components/{crm/Fetch.jsx → Fetch.jsx} +0 -0
  62. /package/src/components/{cms/Gallery.jsx → Gallery.jsx} +0 -0
  63. /package/src/components/{crm/Loader.jsx → Loader.jsx} +0 -0
  64. /package/src/components/{crm/MergeEntity.jsx → MergeEntity.jsx} +0 -0
  65. /package/src/components/{crm/MultiSelect.jsx → MultiSelect.jsx} +0 -0
  66. /package/src/components/{crm/Navigation.jsx → Navigation.jsx} +0 -0
  67. /package/src/components/{crm/Notification.jsx → Notification.jsx} +0 -0
  68. /package/src/components/{crm/QrCode.jsx → QrCode.jsx} +0 -0
  69. /package/src/components/{crm/QuickAction.jsx → QuickAction.jsx} +0 -0
  70. /package/src/components/{crm/SectionHeader.jsx → SectionHeader.jsx} +0 -0
  71. /package/src/components/{crm/Select.jsx → Select.jsx} +0 -0
  72. /package/src/components/{crm/SelectList.jsx → SelectList.jsx} +0 -0
  73. /package/src/components/{crm/SwitchAccount.jsx → SwitchAccount.jsx} +0 -0
  74. /package/src/components/{crm/TableFilter.jsx → TableFilter.jsx} +0 -0
  75. /package/src/components/{crm/cells → cells}/CellWithTooltip.jsx +0 -0
  76. /package/src/components/{crm/controls → controls}/AudioPlayer.jsx +0 -0
  77. /package/src/components/{crm/controls → controls}/AutoRefreshControls.jsx +0 -0
  78. /package/src/components/{crm/controls → controls}/DataGridSearch.jsx +0 -0
  79. /package/src/components/{crm/examples → examples}/FilterExample.jsx +0 -0
  80. /package/src/components/{crm/examples → examples}/FormStylingGuide.md +0 -0
  81. /package/src/components/{crm/examples → examples}/FormWithSectionHeaders.jsx +0 -0
  82. /package/src/components/{crm/examples → examples}/README.md +0 -0
  83. /package/src/components/{cms/generic → generic}/CmsIndex.jsx +0 -0
  84. /package/src/components/{crm/generic → generic}/GenericAuth.jsx +0 -0
  85. /package/src/components/{crm/generic → generic}/shared/formatters.js +0 -0
  86. /package/src/components/{crm/generic → generic}/shared/gridUtils.js +0 -0
  87. /package/src/components/{crm/generic → generic}/utils/formatters.js +0 -0
  88. /package/src/components/{crm/modals → modals}/GalleryModal.jsx +0 -0
  89. /package/src/components/{crm/sketch → sketch}/SketchField.jsx +0 -0
  90. /package/src/components/{crm/sketch → sketch}/arrow.jsx +0 -0
  91. /package/src/components/{crm/sketch → sketch}/circle.jsx +0 -0
  92. /package/src/components/{crm/sketch → sketch}/default-tool.jsx +0 -0
  93. /package/src/components/{crm/sketch → sketch}/fabrictool.jsx +0 -0
  94. /package/src/components/{crm/sketch → sketch}/history.jsx +0 -0
  95. /package/src/components/{crm/sketch → sketch}/json/config.json +0 -0
  96. /package/src/components/{crm/sketch → sketch}/line.jsx +0 -0
  97. /package/src/components/{crm/sketch → sketch}/pan.jsx +0 -0
  98. /package/src/components/{crm/sketch → sketch}/pencil.jsx +0 -0
  99. /package/src/components/{crm/sketch → sketch}/rectangle-label-object.jsx +0 -0
  100. /package/src/components/{crm/sketch → sketch}/rectangle-label.jsx +0 -0
  101. /package/src/components/{crm/sketch → sketch}/rectangle.jsx +0 -0
  102. /package/src/components/{crm/sketch → sketch}/select.jsx +0 -0
  103. /package/src/components/{crm/sketch → sketch}/tools.jsx +0 -0
  104. /package/src/components/{crm/sketch → sketch}/utils.jsx +0 -0
  105. /package/src/components/{crm/generic/styles → styles}/ActionButtons.module.scss +0 -0
  106. /package/src/components/{crm/generic/styles → styles}/AlternativeActionModal.css +0 -0
  107. /package/src/components/{crm/styles → styles}/AssociationManager.module.scss +0 -0
  108. /package/src/components/{crm/styles → styles}/AsyncSelect.module.scss +0 -0
  109. /package/src/components/{crm/generic/styles → styles}/AuditLog.module.scss +0 -0
  110. /package/src/components/{crm/generic/styles → styles}/AuditLogs.module.scss +0 -0
  111. /package/src/components/{crm/auth/styles → styles}/AuthForm.module.scss +0 -0
  112. /package/src/components/{crm/styles → styles}/Autocomplete.module.scss +0 -0
  113. /package/src/components/{crm/styles → styles}/BusinessCardOcr.module.scss +0 -0
  114. /package/src/components/{crm/styles → styles}/ClientAssociationManager.module.scss +0 -0
  115. /package/src/components/{crm/auth/styles → styles}/ClientAuth.module.scss +0 -0
  116. /package/src/components/{crm/client/styles → styles}/ClientDashboard.module.scss +0 -0
  117. /package/src/components/{crm/client/styles → styles}/ClientPortal.module.scss +0 -0
  118. /package/src/components/{crm/generic/styles → styles}/ContactSelectorModal.css +0 -0
  119. /package/src/components/{crm/styles → styles}/DataGrid.module.scss +0 -0
  120. /package/src/components/{crm/generic/styles → styles}/DatePickerDialog.css +0 -0
  121. /package/src/components/{crm/generic/styles → styles}/DateRangeSelectorModal.css +0 -0
  122. /package/src/components/{cms/styles → styles}/DropZone.module.css +0 -0
  123. /package/src/components/{crm/styles → styles}/Field.module.scss +0 -0
  124. /package/src/components/{crm/styles → styles}/Form.module.scss +0 -0
  125. /package/src/components/{cms/styles → styles}/Gallery.module.css +0 -0
  126. /package/src/components/{crm/generic/styles → styles}/GenericClientPortal.module.scss +0 -0
  127. /package/src/components/{crm/generic/styles → styles}/GenericDashboard.module.scss +0 -0
  128. /package/src/components/{crm/generic/styles → styles}/GenericDetail.module.scss +0 -0
  129. /package/src/components/{crm/generic/styles → styles}/GenericDynamic.module.scss +0 -0
  130. /package/src/components/{crm/generic/styles → styles}/GenericEditableTable.module.scss +0 -0
  131. /package/src/components/{crm/generic/styles → styles}/GenericFormBuilder.module.scss +0 -0
  132. /package/src/components/{crm/generic/styles → styles}/GenericIndex.module.scss +0 -0
  133. /package/src/components/{crm/generic/styles → styles}/GenericMain.module.scss +0 -0
  134. /package/src/components/{crm/generic/styles → styles}/GenericQuote.module.scss +0 -0
  135. /package/src/components/{crm/generic/styles → styles}/GenericReport.module.scss +0 -0
  136. /package/src/components/{crm/generic/styles → styles}/GenericSort.module.scss +0 -0
  137. /package/src/components/{crm/sorting/styles → styles}/Item.module.scss +0 -0
  138. /package/src/components/{cms/sorting/styles → styles}/List.module.scss +0 -0
  139. /package/src/components/{crm/styles → styles}/Loader.module.scss +0 -0
  140. /package/src/components/{crm/auth/styles → styles}/Login.module.scss +0 -0
  141. /package/src/components/{crm/styles → styles}/MergeEntity.module.scss +0 -0
  142. /package/src/components/{crm/styles → styles}/MultiSelect.module.scss +0 -0
  143. /package/src/components/{crm/styles → styles}/Navigation.module.scss +0 -0
  144. /package/src/components/{crm/styles → styles}/Notification.module.scss +0 -0
  145. /package/src/components/{crm/generic/styles → styles}/NotificationList.module.scss +0 -0
  146. /package/src/components/{crm/auth/styles → styles}/Profile.module.scss +0 -0
  147. /package/src/components/{crm/styles → styles}/QrCode.module.scss +0 -0
  148. /package/src/components/{crm/styles → styles}/QuickAction.module.scss +0 -0
  149. /package/src/components/{crm/generic/styles → styles}/ReasonCollectorModal.css +0 -0
  150. /package/src/components/{crm/generic/styles → styles}/ReportForm.module.scss +0 -0
  151. /package/src/components/{crm/auth/styles → styles}/Reset.module.scss +0 -0
  152. /package/src/components/{crm/generic/styles → styles}/SortableQuoteItems.module.scss +0 -0
  153. /package/src/components/{crm/generic/styles → styles}/SweetAlert.module.css +0 -0
  154. /package/src/components/{crm/styles → styles}/SwitchAccount.module.scss +0 -0
  155. /package/src/components/{crm/styles → styles}/TableFilter.module.scss +0 -0
  156. /package/src/components/{crm/auth/styles → styles}/TwoFactorAuth.module.scss +0 -0
  157. /package/src/components/{crm/auth/styles → styles}/Verify.module.scss +0 -0
  158. /package/src/components/{crm/styles → styles}/global-datagrid.css +0 -0
  159. /package/src/utils/{ConfirmDialog.js → ConfirmDialog.jsx} +0 -0
@@ -1,802 +0,0 @@
1
- import React, { useState, useEffect, useRef } from 'react';
2
- import DatePicker from 'react-datepicker';
3
- import _ from 'lodash';
4
- import ReactQuill, { Quill } from 'react-quill';
5
- import { Editor } from '@tinymce/tinymce-react';
6
- import ImageUploader from 'quill-image-uploader';
7
- import Toggle from 'react-toggle';
8
- import { NumericFormat, PatternFormat } from 'react-number-format';
9
- import { motion } from 'framer-motion';
10
- import { toast } from 'react-toastify';
11
-
12
- import 'react-toggle/style.css';
13
- import 'react-quill/dist/quill.snow.css';
14
- import 'react-datepicker/dist/react-datepicker.css';
15
- import 'quill-image-uploader/dist/quill.imageUploader.min.css';
16
-
17
- import CustomFetch from '../crm/Fetch';
18
- import Select from '../crm/Select';
19
- import MultiSelect from '../crm/MultiSelect';
20
- import VisnsAutocomplete from '../crm/Autocomplete';
21
- import VisnsDropZone from './DropZone';
22
- import moment from 'moment';
23
-
24
- Quill.register('modules/imageUploader', ImageUploader);
25
-
26
- const modules = {
27
- toolbar: {
28
- container: [
29
- [{ header: [1, 2, false] }],
30
- ['bold', 'italic', 'underline', 'strike', 'blockquote'],
31
- [{ list: 'ordered' }, { list: 'bullet' }],
32
- ['link', 'image'],
33
- ['clean'],
34
- ],
35
- },
36
- imageUploader: {
37
- upload: async (file) => {
38
- return new Promise((resolve, reject) => {
39
- Vapor.store(file, {
40
- progress: (progress) => {
41
- console.info(progress * 100);
42
- },
43
- }).then((response) => {
44
- CustomFetch(
45
- '/ajax/files/upload',
46
- 'POST',
47
- response,
48
- function (res) {
49
- if (res.error === '') {
50
- resolve(res.path);
51
- } else {
52
- toast.error(
53
- res.error !== undefined ? res.error : ''
54
- );
55
- }
56
- }
57
- );
58
- });
59
- });
60
- },
61
- },
62
- };
63
-
64
- const Field = ({
65
- baseData,
66
- fetchData,
67
- inputValue,
68
- inputClass,
69
- onChange,
70
- onChangeDate,
71
- onChangeFile,
72
- onChangeRicheditor,
73
- onChangeSelect,
74
- onChangeToggle,
75
- setFormData,
76
- settings,
77
- uploadProgress,
78
- }) => {
79
- const editorRef = useRef(null);
80
- const inputFile = useRef(null);
81
- const [options, setOptions] = useState([]);
82
- const [dataOptions, setDataOptions] = useState([]);
83
- const [formItemStyle, setFormItemStyle] = useState({});
84
- const [formItemClass, setFormItemClass] = useState('formItem');
85
-
86
- useEffect(() => {
87
- switch (settings.type) {
88
- case 'hidden':
89
- setFormItemStyle({
90
- display: 'none',
91
- });
92
- break;
93
- case 'dropdown-ajax':
94
- let filter = {};
95
-
96
- if (
97
- settings.hasOwnProperty('where') &&
98
- settings.where.length > 0
99
- ) {
100
- filter = {
101
- where: settings.where,
102
- };
103
- }
104
-
105
- CustomFetch(settings.url, 'POST', filter, function (result) {
106
- setOptions(result.data);
107
-
108
- let dataArray = [];
109
-
110
- result.data.forEach((a) => {
111
- let _tempObject = a;
112
-
113
- if (!_.isEmpty(_tempObject)) {
114
- let modifiedObject = {};
115
-
116
- Object.keys(_tempObject).forEach(function (c) {
117
- if (c !== 'id' && c !== 'label') {
118
- modifiedObject['data-' + c] =
119
- _tempObject[c];
120
- }
121
- });
122
-
123
- dataArray.push(modifiedObject);
124
- }
125
- });
126
-
127
- if (dataArray.length > 0) {
128
- setDataOptions(dataArray);
129
- }
130
- });
131
- break;
132
- case 'multi-dropdown-ajax':
133
- let multiFilter = {};
134
-
135
- if (
136
- settings.hasOwnProperty('where') &&
137
- settings.where.length > 0
138
- ) {
139
- multiFilter = {
140
- where: settings.where,
141
- };
142
- }
143
-
144
- CustomFetch(
145
- settings.url,
146
- 'POST',
147
- multiFilter,
148
- function (result) {
149
- setOptions(result.data);
150
-
151
- let dataArray = [];
152
-
153
- result.data.forEach((a) => {
154
- let _tempObject = a;
155
-
156
- if (!_.isEmpty(_tempObject)) {
157
- let modifiedObject = {};
158
-
159
- Object.keys(_tempObject).forEach(function (c) {
160
- if (c !== 'id' && c !== 'label') {
161
- modifiedObject['data-' + c] =
162
- _tempObject[c];
163
- }
164
- });
165
-
166
- dataArray.push(modifiedObject);
167
- }
168
- });
169
-
170
- if (dataArray.length > 0) {
171
- setDataOptions(dataArray);
172
- }
173
- }
174
- );
175
- break;
176
- default:
177
- break;
178
- }
179
-
180
- if (settings.size === 'full') {
181
- setFormItemClass('formItem fwItem');
182
- }
183
- }, [settings]);
184
-
185
- useEffect(() => {
186
- let filter = {};
187
-
188
- if (settings.hasOwnProperty('child')) {
189
- if (inputValue > 0) {
190
- filter = {
191
- where: [
192
- {
193
- id: settings.id,
194
- value: inputValue,
195
- },
196
- ],
197
- };
198
-
199
- CustomFetch(
200
- settings.child.url,
201
- 'POST',
202
- filter,
203
- function (result) {
204
- childDropdownCallback({
205
- id: settings.child.id,
206
- data: result.data,
207
- });
208
- }
209
- );
210
- }
211
- }
212
- }, [inputValue, settings]);
213
-
214
- useEffect(() => {
215
- if (settings.hasOwnProperty('options')) {
216
- if (settings.options.length > 0) {
217
- let dataArray = [];
218
-
219
- settings.options.forEach((a) => {
220
- let _tempObject = a;
221
-
222
- if (!_.isEmpty(_tempObject)) {
223
- let modifiedObject = {};
224
-
225
- Object.keys(_tempObject).forEach(function (c) {
226
- if (c !== 'id' && c !== 'label') {
227
- modifiedObject['data-' + c] = _tempObject[c];
228
- }
229
- });
230
-
231
- dataArray.push(modifiedObject);
232
- }
233
- });
234
-
235
- if (dataArray.length > 0) {
236
- setDataOptions(dataArray);
237
- }
238
- }
239
- }
240
- }, [settings.options, settings]);
241
-
242
- return (
243
- <div className={formItemClass} style={formItemStyle}>
244
- <label
245
- className={
246
- settings.type === 'image' ||
247
- settings.type === 'richeditor' ||
248
- settings.type === 'gallery'
249
- ? 'fi__flabel'
250
- : 'fi__label'
251
- }
252
- >
253
- {(() => {
254
- if (
255
- settings.type === 'address' ||
256
- settings.type === 'date' ||
257
- settings.type === 'datetime' ||
258
- settings.type === 'checkbox' ||
259
- settings.type === 'multi-dropdown' ||
260
- settings.type === 'multi-dropdown-ajax'
261
- ) {
262
- return (
263
- <span className="fi__span prefocus">
264
- {settings.label}{' '}
265
- {settings.required === true ? '*' : ''}
266
- </span>
267
- );
268
- }
269
- })()}
270
-
271
- {(() => {
272
- if (
273
- settings.type === 'image' ||
274
- settings.type === 'richeditor' ||
275
- settings.type === 'gallery'
276
- ) {
277
- return (
278
- <>
279
- {settings.label}{' '}
280
- {settings.required === true ? '*' : ''}
281
- </>
282
- );
283
- }
284
- })()}
285
-
286
- {(() => {
287
- let htmlContainer;
288
- switch (settings.type) {
289
- case 'text':
290
- htmlContainer = (
291
- <input
292
- type="text"
293
- name={settings.id}
294
- readOnly={
295
- settings.hasOwnProperty('readOnly')
296
- ? settings.readOnly
297
- : false
298
- }
299
- className={inputClass[settings.id]}
300
- placeholder=" "
301
- onChange={onChange}
302
- value={
303
- inputValue && inputValue !== 'null'
304
- ? inputValue
305
- : ''
306
- }
307
- />
308
- );
309
- break;
310
- case 'json':
311
- htmlContainer = (
312
- <input
313
- type="text"
314
- name={settings.id}
315
- data-jsonkey={settings.key}
316
- className={inputClass[settings.id]}
317
- placeholder=" "
318
- onChange={onChange}
319
- value={
320
- inputValue && inputValue !== 'null'
321
- ? inputValue
322
- : ''
323
- }
324
- />
325
- );
326
- break;
327
- case 'password':
328
- htmlContainer = (
329
- <input
330
- type="password"
331
- name={settings.id}
332
- className={inputClass[settings.id]}
333
- placeholder=" "
334
- onChange={onChange}
335
- value={
336
- inputValue && inputValue !== 'null'
337
- ? inputValue
338
- : ''
339
- }
340
- />
341
- );
342
- break;
343
- case 'phone':
344
- htmlContainer = (
345
- <PatternFormat
346
- name={settings.id}
347
- className={inputClass[settings.id]}
348
- onValueChange={(values) => {
349
- onChangeNumberFormat(
350
- values,
351
- settings.id
352
- );
353
- }}
354
- format="## #### ####"
355
- allowEmptyFormatting
356
- mask="_"
357
- value={
358
- inputValue && inputValue !== 'null'
359
- ? inputValue
360
- : ''
361
- }
362
- />
363
- );
364
- break;
365
- case 'mobile':
366
- htmlContainer = (
367
- <PatternFormat
368
- className={inputClass[settings.id]}
369
- onValueChange={(values) => {
370
- onChangeNumberFormat(
371
- values,
372
- settings.id
373
- );
374
- }}
375
- format="#### ### ###"
376
- allowEmptyFormatting
377
- mask="_"
378
- value={
379
- inputValue && inputValue !== 'null'
380
- ? inputValue
381
- : ''
382
- }
383
- />
384
- );
385
- break;
386
- case 'currency':
387
- htmlContainer = (
388
- <NumericFormat
389
- name={settings.id}
390
- className={inputClass[settings.id]}
391
- onValueChange={(values) => {
392
- onChangeNumberFormat(
393
- values,
394
- settings.id
395
- );
396
- }}
397
- thousandSeparator={true}
398
- prefix={'$'}
399
- value={
400
- inputValue && inputValue !== 'null'
401
- ? inputValue
402
- : ''
403
- }
404
- />
405
- );
406
- break;
407
- case 'textarea':
408
- htmlContainer = (
409
- <textarea
410
- name={settings.id}
411
- className={inputClass[settings.id]}
412
- onChange={onChange}
413
- value={
414
- inputValue && inputValue !== 'null'
415
- ? inputValue
416
- : ''
417
- }
418
- style={{ height: '200px' }}
419
- ></textarea>
420
- );
421
- break;
422
- case 'address':
423
- htmlContainer = (
424
- <VisnsAutocomplete
425
- onSelect={(place) =>
426
- autocompleteCallback(place)
427
- }
428
- field={settings.id}
429
- setFormData={setFormData}
430
- api="pk.eyJ1IjoidmlzbnMtc3R1ZGlvIiwiYSI6ImNrbGlraW5vZDBhMDYycHBsdmk5b3ljbGQifQ.ZGUBk0PWac5GahUeVHdTpg"
431
- inputValue={inputValue}
432
- />
433
- );
434
- break;
435
- case 'dropdown':
436
- htmlContainer = (
437
- <Select
438
- settings={settings}
439
- className={inputClass[settings.id]}
440
- onChange={onChange}
441
- inputValue={
442
- inputValue === null ? '' : inputValue
443
- }
444
- options={settings.options}
445
- dataOptions={dataOptions}
446
- />
447
- );
448
- break;
449
- case 'dropdown-ajax':
450
- htmlContainer = (
451
- <Select
452
- settings={settings}
453
- className={inputClass[settings.id]}
454
- onChange={onChange}
455
- inputValue={
456
- inputValue === null ? '' : inputValue
457
- }
458
- options={options}
459
- dataOptions={dataOptions}
460
- />
461
- );
462
- break;
463
- case 'multi-dropdown':
464
- htmlContainer = (
465
- <MultiSelect
466
- settings={settings}
467
- className={inputClass[settings.id]}
468
- onChange={onChangeSelect}
469
- inputValue={
470
- inputValue === null ? '' : inputValue
471
- }
472
- options={settings.options}
473
- multi={
474
- settings.multiple
475
- ? settings.multiple
476
- : false
477
- }
478
- />
479
- );
480
- break;
481
- case 'multi-dropdown-ajax':
482
- htmlContainer = (
483
- <MultiSelect
484
- settings={settings}
485
- className={inputClass[settings.id]}
486
- onChange={onChangeSelect}
487
- inputValue={
488
- inputValue === null ? '' : inputValue
489
- }
490
- options={options}
491
- multi={
492
- settings.multiple
493
- ? settings.multiple
494
- : false
495
- }
496
- />
497
- );
498
- break;
499
- case 'file':
500
- htmlContainer = (
501
- <input
502
- type="file"
503
- name={settings.id}
504
- className={inputClass[settings.id]}
505
- onChange={onChangeFile}
506
- />
507
- );
508
- break;
509
-
510
- case 'line-break':
511
- htmlContainer = (
512
- <div className="formbreak">
513
- <span>
514
- {settings.label}{' '}
515
- {settings.required === true ? '*' : ''}
516
- </span>
517
- </div>
518
- );
519
- break;
520
- case 'checkbox':
521
- htmlContainer = (
522
- <input
523
- type="checkbox"
524
- name={settings.id}
525
- className={inputClass[settings.id]}
526
- placeholder=" "
527
- onChange={onChange}
528
- value={inputValue || ''}
529
- />
530
- );
531
- break;
532
- default:
533
- htmlContainer = '';
534
- break;
535
- }
536
-
537
- return htmlContainer;
538
- })()}
539
-
540
- {(() => {
541
- if (
542
- settings.type !== 'address' &&
543
- settings.type !== 'date' &&
544
- settings.type !== 'datetime' &&
545
- settings.type !== 'line-break' &&
546
- settings.type !== 'checkbox' &&
547
- settings.type !== 'multi-dropdown' &&
548
- settings.type !== 'multi-dropdown-ajax' &&
549
- settings.type !== 'toggle' &&
550
- settings.type !== 'richeditor' &&
551
- settings.type !== 'image' &&
552
- settings.type !== 'gallery'
553
- ) {
554
- return (
555
- <span className="fi__span">
556
- {settings.label}{' '}
557
- {settings.required === true ? '*' : ''}
558
- </span>
559
- );
560
- }
561
- })()}
562
- </label>
563
-
564
- {(() => {
565
- let htmlContainer;
566
- switch (settings.type) {
567
- case 'date':
568
- htmlContainer = (
569
- <DatePicker
570
- dateFormat={
571
- settings.format
572
- ? settings.format
573
- : 'dd-MM-yyyy'
574
- }
575
- className={inputClass[settings.id]}
576
- selected={
577
- inputValue
578
- ? moment(inputValue).toDate()
579
- : ''
580
- }
581
- showMonthDropdown
582
- showYearDropdown
583
- dropdownMode="select"
584
- onChange={(date) =>
585
- onChangeDate(date, settings.id)
586
- }
587
- />
588
- );
589
- break;
590
- case 'datetime':
591
- htmlContainer = (
592
- <DatePicker
593
- dateFormat={
594
- settings.format
595
- ? settings.format
596
- : 'dd-MM-yyyy hh:mm aa'
597
- }
598
- showTimeSelect
599
- className={inputClass[settings.id]}
600
- selected={
601
- inputValue
602
- ? moment(inputValue).toDate()
603
- : ''
604
- }
605
- showMonthDropdown
606
- showYearDropdown
607
- dropdownMode="select"
608
- onChange={(date) =>
609
- onChangeDate(date, settings.id)
610
- }
611
- shouldCloseOnSelect={true}
612
- />
613
- );
614
- break;
615
- case 'time':
616
- htmlContainer = (
617
- <DatePicker
618
- dateFormat={
619
- settings.format
620
- ? settings.format
621
- : 'hh:mm aa'
622
- }
623
- showTimeSelect
624
- showTimeSelectOnly
625
- timeIntervals={15}
626
- timeCaption="Time"
627
- className={inputClass[settings.id]}
628
- selected={
629
- inputValue
630
- ? moment(inputValue).toDate()
631
- : ''
632
- }
633
- onChange={(date) =>
634
- onChangeDate(date, settings.id)
635
- }
636
- shouldCloseOnSelect={true}
637
- />
638
- );
639
- break;
640
- case 'toggle':
641
- htmlContainer = (
642
- <div>
643
- <Toggle
644
- name={settings.id}
645
- data-show={
646
- settings.show
647
- ? JSON.stringify(settings.show)
648
- : ''
649
- }
650
- checked={
651
- inputValue !== undefined
652
- ? inputValue === ''
653
- ? false
654
- : inputValue === 'on'
655
- ? false
656
- : Boolean(inputValue)
657
- : false
658
- }
659
- onChange={onChangeToggle}
660
- />
661
- <span className="fi__toggletxt">
662
- {settings.label}{' '}
663
- {settings.required === true ? '*' : ''}
664
- </span>
665
- </div>
666
- );
667
- break;
668
- case 'richeditor':
669
- htmlContainer = (
670
- <Editor
671
- tinymceScriptSrc="https://d16lktya8ojp5z.cloudfront.net/generic/packages/tinymce_v701/tinymce.min.js"
672
- licenseKey="gpl"
673
- onEditorChange={(value, e) => {
674
- onChangeRicheditor(e, value, settings.id);
675
- }}
676
- onInit={(evt, editor) =>
677
- (editorRef.current = editor)
678
- }
679
- value={inputValue || ''}
680
- init={{
681
- branding: false,
682
- height: 500,
683
- menubar: false,
684
- plugins: [
685
- 'advlist',
686
- 'autolink',
687
- 'lists',
688
- 'link',
689
- 'image',
690
- 'charmap',
691
- 'preview',
692
- 'anchor',
693
- 'searchreplace',
694
- 'visualblocks',
695
- 'code',
696
- 'fullscreen',
697
- 'insertdatetime',
698
- 'media',
699
- 'table',
700
- 'code',
701
- ],
702
- toolbar:
703
- 'undo redo | blocks | ' +
704
- 'bold italic forecolor | alignleft aligncenter ' +
705
- 'alignright alignjustify | bullist numlist outdent indent | ' +
706
- 'removeformat | table',
707
- content_style:
708
- 'body { font-family:Helvetica,Arial,sans-serif; font-size:14px }',
709
- }}
710
- />
711
- );
712
- break;
713
- case 'image':
714
- htmlContainer = (
715
- <>
716
- <motion.div
717
- className="progress__bar"
718
- initial={{ width: '0%' }}
719
- animate={{
720
- width:
721
- uploadProgress[settings.id] + '%',
722
- }}
723
- transition={{
724
- duration: 3,
725
- ease: [0.165, 0.84, 0.44, 1.0],
726
- }}
727
- />
728
- <input
729
- type="file"
730
- name={settings.id}
731
- className={inputClass[settings.id]}
732
- onChange={onChangeFile}
733
- ref={inputFile}
734
- style={{ display: 'none' }}
735
- />
736
- <div
737
- onClick={() => {
738
- inputFile.current.click();
739
- }}
740
- >
741
- {inputValue && inputValue !== '' ? (
742
- <>
743
- {inputValue.file_url &&
744
- inputValue.file_url !== '' ? (
745
- <img
746
- src={inputValue.file_url}
747
- width="200"
748
- />
749
- ) : (
750
- <img
751
- src={URL.createObjectURL(
752
- inputValue
753
- )}
754
- width="200"
755
- />
756
- )}
757
- </>
758
- ) : (
759
- <div className="imageupload">
760
- <span>
761
- Click here to upload an image
762
- </span>
763
- </div>
764
- )}
765
- </div>
766
- </>
767
- );
768
- break;
769
- case 'gallery':
770
- if (
771
- baseData[settings.key] &&
772
- baseData[settings.key] > 0
773
- ) {
774
- const dropzoneUrl = `${settings.url}/${
775
- baseData[settings.key]
776
- }`;
777
-
778
- htmlContainer = (
779
- <VisnsDropZone
780
- fetchData={fetchData}
781
- files={baseData[settings.id]}
782
- settings={{
783
- url: dropzoneUrl,
784
- method: settings.method,
785
- type: 'gallery',
786
- }}
787
- />
788
- );
789
- }
790
- break;
791
- default:
792
- htmlContainer = '';
793
- break;
794
- }
795
-
796
- return htmlContainer;
797
- })()}
798
- </div>
799
- );
800
- };
801
-
802
- export default Field;