@solidstarters/solid-core-ui 1.1.47 → 1.1.49

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 (166) hide show
  1. package/dist/components/core/common/FilterComponent.d.ts.map +1 -1
  2. package/dist/components/core/common/FilterComponent.js +26 -10
  3. package/dist/components/core/common/FilterComponent.js.map +1 -1
  4. package/dist/components/core/common/SolidGlobalSearchElement.d.ts.map +1 -1
  5. package/dist/components/core/common/SolidGlobalSearchElement.js +160 -94
  6. package/dist/components/core/common/SolidGlobalSearchElement.js.map +1 -1
  7. package/dist/components/core/form/SolidFormView.d.ts.map +1 -1
  8. package/dist/components/core/form/SolidFormView.js +43 -16
  9. package/dist/components/core/form/SolidFormView.js.map +1 -1
  10. package/dist/components/core/form/fields/ISolidField.d.ts +1 -0
  11. package/dist/components/core/form/fields/ISolidField.d.ts.map +1 -1
  12. package/dist/components/core/form/fields/SolidBooleanField.d.ts.map +1 -1
  13. package/dist/components/core/form/fields/SolidBooleanField.js +9 -2
  14. package/dist/components/core/form/fields/SolidBooleanField.js.map +1 -1
  15. package/dist/components/core/form/fields/SolidDateField.d.ts.map +1 -1
  16. package/dist/components/core/form/fields/SolidDateField.js +27 -11
  17. package/dist/components/core/form/fields/SolidDateField.js.map +1 -1
  18. package/dist/components/core/form/fields/SolidDateTimeField.d.ts.map +1 -1
  19. package/dist/components/core/form/fields/SolidDateTimeField.js +28 -11
  20. package/dist/components/core/form/fields/SolidDateTimeField.js.map +1 -1
  21. package/dist/components/core/form/fields/SolidDecimalField.d.ts.map +1 -1
  22. package/dist/components/core/form/fields/SolidDecimalField.js +24 -5
  23. package/dist/components/core/form/fields/SolidDecimalField.js.map +1 -1
  24. package/dist/components/core/form/fields/SolidEmailField.d.ts.map +1 -1
  25. package/dist/components/core/form/fields/SolidEmailField.js +24 -5
  26. package/dist/components/core/form/fields/SolidEmailField.js.map +1 -1
  27. package/dist/components/core/form/fields/SolidIntegerField.d.ts.map +1 -1
  28. package/dist/components/core/form/fields/SolidIntegerField.js +24 -5
  29. package/dist/components/core/form/fields/SolidIntegerField.js.map +1 -1
  30. package/dist/components/core/form/fields/SolidJsonField.d.ts.map +1 -1
  31. package/dist/components/core/form/fields/SolidJsonField.js +22 -3
  32. package/dist/components/core/form/fields/SolidJsonField.js.map +1 -1
  33. package/dist/components/core/form/fields/SolidLongTextField.d.ts.map +1 -1
  34. package/dist/components/core/form/fields/SolidLongTextField.js +30 -4
  35. package/dist/components/core/form/fields/SolidLongTextField.js.map +1 -1
  36. package/dist/components/core/form/fields/SolidMediaMultipleField.d.ts.map +1 -1
  37. package/dist/components/core/form/fields/SolidMediaMultipleField.js +52 -29
  38. package/dist/components/core/form/fields/SolidMediaMultipleField.js.map +1 -1
  39. package/dist/components/core/form/fields/SolidMediaSingleField.d.ts.map +1 -1
  40. package/dist/components/core/form/fields/SolidMediaSingleField.js +39 -16
  41. package/dist/components/core/form/fields/SolidMediaSingleField.js.map +1 -1
  42. package/dist/components/core/form/fields/SolidPasswordField.d.ts.map +1 -1
  43. package/dist/components/core/form/fields/SolidPasswordField.js +23 -3
  44. package/dist/components/core/form/fields/SolidPasswordField.js.map +1 -1
  45. package/dist/components/core/form/fields/SolidRichTextField.d.ts.map +1 -1
  46. package/dist/components/core/form/fields/SolidRichTextField.js +23 -3
  47. package/dist/components/core/form/fields/SolidRichTextField.js.map +1 -1
  48. package/dist/components/core/form/fields/SolidSelectionDynamicField.d.ts.map +1 -1
  49. package/dist/components/core/form/fields/SolidSelectionDynamicField.js +14 -5
  50. package/dist/components/core/form/fields/SolidSelectionDynamicField.js.map +1 -1
  51. package/dist/components/core/form/fields/SolidSelectionStaticField.d.ts.map +1 -1
  52. package/dist/components/core/form/fields/SolidSelectionStaticField.js +10 -2
  53. package/dist/components/core/form/fields/SolidSelectionStaticField.js.map +1 -1
  54. package/dist/components/core/form/fields/SolidShortTextField.d.ts.map +1 -1
  55. package/dist/components/core/form/fields/SolidShortTextField.js +28 -8
  56. package/dist/components/core/form/fields/SolidShortTextField.js.map +1 -1
  57. package/dist/components/core/form/fields/SolidTimeField.d.ts.map +1 -1
  58. package/dist/components/core/form/fields/SolidTimeField.js +27 -8
  59. package/dist/components/core/form/fields/SolidTimeField.js.map +1 -1
  60. package/dist/components/core/form/fields/relations/SolidRelationManyToManyField.d.ts.map +1 -1
  61. package/dist/components/core/form/fields/relations/SolidRelationManyToManyField.js +15 -4
  62. package/dist/components/core/form/fields/relations/SolidRelationManyToManyField.js.map +1 -1
  63. package/dist/components/core/form/fields/relations/SolidRelationManyToOneField.d.ts.map +1 -1
  64. package/dist/components/core/form/fields/relations/SolidRelationManyToOneField.js +13 -4
  65. package/dist/components/core/form/fields/relations/SolidRelationManyToOneField.js.map +1 -1
  66. package/dist/components/core/form/fields/relations/SolidRelationOneToManyField.d.ts.map +1 -1
  67. package/dist/components/core/form/fields/relations/SolidRelationOneToManyField.js +17 -5
  68. package/dist/components/core/form/fields/relations/SolidRelationOneToManyField.js.map +1 -1
  69. package/dist/components/core/form/fields/widgets/SolidBooleanCheckboxFieldWidget.js +1 -1
  70. package/dist/components/core/form/fields/widgets/SolidBooleanCheckboxFieldWidget.js.map +1 -1
  71. package/dist/components/core/form/fields/widgets/SolidBooleanSelectFieldWidget.js +1 -1
  72. package/dist/components/core/form/fields/widgets/SolidBooleanSelectFieldWidget.js.map +1 -1
  73. package/dist/components/core/form/fields/widgets/SolidFormFieldJsonViewModeWidget.d.ts +2 -0
  74. package/dist/components/core/form/fields/widgets/SolidFormFieldJsonViewModeWidget.d.ts.map +1 -0
  75. package/dist/components/core/form/fields/widgets/SolidFormFieldJsonViewModeWidget.js +9 -0
  76. package/dist/components/core/form/fields/widgets/SolidFormFieldJsonViewModeWidget.js.map +1 -0
  77. package/dist/components/core/form/fields/widgets/SolidFormFieldMediaViewModeWidget.d.ts +2 -0
  78. package/dist/components/core/form/fields/widgets/SolidFormFieldMediaViewModeWidget.d.ts.map +1 -0
  79. package/dist/components/core/form/fields/widgets/SolidFormFieldMediaViewModeWidget.js +8 -0
  80. package/dist/components/core/form/fields/widgets/SolidFormFieldMediaViewModeWidget.js.map +1 -0
  81. package/dist/components/core/form/fields/widgets/SolidFormFieldPasswordViewModeWidget.d.ts +2 -0
  82. package/dist/components/core/form/fields/widgets/SolidFormFieldPasswordViewModeWidget.d.ts.map +1 -0
  83. package/dist/components/core/form/fields/widgets/SolidFormFieldPasswordViewModeWidget.js +9 -0
  84. package/dist/components/core/form/fields/widgets/SolidFormFieldPasswordViewModeWidget.js.map +1 -0
  85. package/dist/components/core/form/fields/widgets/SolidFormFieldRelationViewModeWidget.d.ts +2 -0
  86. package/dist/components/core/form/fields/widgets/SolidFormFieldRelationViewModeWidget.d.ts.map +1 -0
  87. package/dist/components/core/form/fields/widgets/SolidFormFieldRelationViewModeWidget.js +20 -0
  88. package/dist/components/core/form/fields/widgets/SolidFormFieldRelationViewModeWidget.js.map +1 -0
  89. package/dist/components/core/form/fields/widgets/SolidFormFieldRichTextViewModeWidget.d.ts +2 -0
  90. package/dist/components/core/form/fields/widgets/SolidFormFieldRichTextViewModeWidget.d.ts.map +1 -0
  91. package/dist/components/core/form/fields/widgets/SolidFormFieldRichTextViewModeWidget.js +7 -0
  92. package/dist/components/core/form/fields/widgets/SolidFormFieldRichTextViewModeWidget.js.map +1 -0
  93. package/dist/components/core/form/fields/widgets/SolidFormFieldViewMediaMultipleWidget.d.ts +3 -0
  94. package/dist/components/core/form/fields/widgets/SolidFormFieldViewMediaMultipleWidget.d.ts.map +1 -0
  95. package/dist/components/core/form/fields/widgets/SolidFormFieldViewMediaMultipleWidget.js +74 -0
  96. package/dist/components/core/form/fields/widgets/SolidFormFieldViewMediaMultipleWidget.js.map +1 -0
  97. package/dist/components/core/form/fields/widgets/SolidFormFieldViewMediaSingleWidget.d.ts +3 -0
  98. package/dist/components/core/form/fields/widgets/SolidFormFieldViewMediaSingleWidget.d.ts.map +1 -0
  99. package/dist/components/core/form/fields/widgets/SolidFormFieldViewMediaSingleWidget.js +58 -0
  100. package/dist/components/core/form/fields/widgets/SolidFormFieldViewMediaSingleWidget.js.map +1 -0
  101. package/dist/components/core/form/fields/widgets/SolidFormFieldViewModeWidget.d.ts +2 -0
  102. package/dist/components/core/form/fields/widgets/SolidFormFieldViewModeWidget.d.ts.map +1 -0
  103. package/dist/components/core/form/fields/widgets/SolidFormFieldViewModeWidget.js +6 -0
  104. package/dist/components/core/form/fields/widgets/SolidFormFieldViewModeWidget.js.map +1 -0
  105. package/dist/components/core/form/fields/widgets/SolidSelectionStaticAutocompleteFieldWidget.js +1 -1
  106. package/dist/components/core/form/fields/widgets/SolidSelectionStaticAutocompleteFieldWidget.js.map +1 -1
  107. package/dist/components/core/form/fields/widgets/SolidSelectionStaticRadioFieldWidget.js +1 -1
  108. package/dist/components/core/form/fields/widgets/SolidSelectionStaticRadioFieldWidget.js.map +1 -1
  109. package/dist/components/core/kanban/SolidKanbanView.d.ts.map +1 -1
  110. package/dist/components/core/kanban/SolidKanbanView.js +37 -14
  111. package/dist/components/core/kanban/SolidKanbanView.js.map +1 -1
  112. package/dist/components/core/list/SolidListView.d.ts +3 -0
  113. package/dist/components/core/list/SolidListView.d.ts.map +1 -1
  114. package/dist/components/core/list/SolidListView.js +167 -95
  115. package/dist/components/core/list/SolidListView.js.map +1 -1
  116. package/dist/components/core/model/FieldMetaDataForm.js +1 -1
  117. package/dist/components/core/model/FieldMetaDataForm.js.map +1 -1
  118. package/dist/components/core/users/CreateUser.js +1 -3
  119. package/dist/components/core/users/CreateUser.js.map +1 -1
  120. package/dist/helpers/registry.d.ts.map +1 -1
  121. package/dist/helpers/registry.js +16 -0
  122. package/dist/helpers/registry.js.map +1 -1
  123. package/dist/resources/globals.css +15 -2
  124. package/package.json +1 -1
  125. package/src/components/core/common/FilterComponent.tsx +39 -10
  126. package/src/components/core/common/SolidGlobalSearchElement.tsx +228 -135
  127. package/src/components/core/form/SolidFormView.tsx +69 -21
  128. package/src/components/core/form/fields/ISolidField.tsx +1 -0
  129. package/src/components/core/form/fields/SolidBooleanField.tsx +39 -25
  130. package/src/components/core/form/fields/SolidDateField.tsx +46 -32
  131. package/src/components/core/form/fields/SolidDateTimeField.tsx +47 -34
  132. package/src/components/core/form/fields/SolidDecimalField.tsx +42 -26
  133. package/src/components/core/form/fields/SolidEmailField.tsx +43 -27
  134. package/src/components/core/form/fields/SolidIntegerField.tsx +42 -25
  135. package/src/components/core/form/fields/SolidJsonField.tsx +40 -23
  136. package/src/components/core/form/fields/SolidLongTextField.tsx +86 -53
  137. package/src/components/core/form/fields/SolidMediaMultipleField.tsx +170 -139
  138. package/src/components/core/form/fields/SolidMediaSingleField.tsx +124 -93
  139. package/src/components/core/form/fields/SolidPasswordField.tsx +42 -25
  140. package/src/components/core/form/fields/SolidRichTextField.tsx +41 -24
  141. package/src/components/core/form/fields/SolidSelectionDynamicField.tsx +46 -28
  142. package/src/components/core/form/fields/SolidSelectionStaticField.tsx +38 -22
  143. package/src/components/core/form/fields/SolidShortTextField.tsx +63 -47
  144. package/src/components/core/form/fields/SolidTimeField.tsx +47 -30
  145. package/src/components/core/form/fields/relations/SolidRelationManyToManyField.tsx +30 -8
  146. package/src/components/core/form/fields/relations/SolidRelationManyToOneField.tsx +49 -31
  147. package/src/components/core/form/fields/relations/SolidRelationOneToManyField.tsx +38 -19
  148. package/src/components/core/form/fields/widgets/SolidBooleanCheckboxFieldWidget.tsx +1 -1
  149. package/src/components/core/form/fields/widgets/SolidBooleanSelectFieldWidget.tsx +1 -1
  150. package/src/components/core/form/fields/widgets/SolidFormFieldJsonViewModeWidget.tsx +23 -0
  151. package/src/components/core/form/fields/widgets/SolidFormFieldMediaViewModeWidget.tsx +13 -0
  152. package/src/components/core/form/fields/widgets/SolidFormFieldPasswordViewModeWidget.tsx +23 -0
  153. package/src/components/core/form/fields/widgets/SolidFormFieldRelationViewModeWidget.tsx +32 -0
  154. package/src/components/core/form/fields/widgets/SolidFormFieldRichTextViewModeWidget.tsx +17 -0
  155. package/src/components/core/form/fields/widgets/SolidFormFieldViewMediaMultipleWidget.tsx +157 -0
  156. package/src/components/core/form/fields/widgets/SolidFormFieldViewMediaSingleWidget.tsx +98 -0
  157. package/src/components/core/form/fields/widgets/SolidFormFieldViewModeWidget.tsx +11 -0
  158. package/src/components/core/form/fields/widgets/SolidSelectionStaticAutocompleteFieldWidget.tsx +1 -1
  159. package/src/components/core/form/fields/widgets/SolidSelectionStaticRadioFieldWidget.tsx +1 -1
  160. package/src/components/core/kanban/SolidKanbanView.tsx +26 -5
  161. package/src/components/core/list/SolidListView.tsx +166 -105
  162. package/src/components/core/model/FieldMetaDataForm.tsx +1 -1
  163. package/src/components/core/users/CreateUser.tsx +5 -5
  164. package/src/helpers/registry.ts +16 -0
  165. package/src/resources/globals.css +15 -2
  166. package/src/types/solid-core.d.ts +6 -1
@@ -14,6 +14,7 @@ import { ProgressBar } from "primereact/progressbar";
14
14
  import Link from "next/link";
15
15
  import getAcceptedFileTypes from "@/helpers/getAcceptedFileTypes";
16
16
  import { downloadMediaFile } from "@/helpers/downloadMediaFile";
17
+ import { getExtensionComponent } from "@/helpers/registry";
17
18
 
18
19
  export class SolidMediaSingleField implements ISolidField {
19
20
 
@@ -84,12 +85,14 @@ export class SolidMediaSingleField implements ISolidField {
84
85
  const solidFormViewMetaData = this.fieldContext.solidFormViewMetaData;
85
86
  const showFieldLabel = fieldLayoutInfo?.attrs?.showLabel;
86
87
  const readOnlyPermission = this.fieldContext.readOnly;
88
+ const viewMode: string = this.fieldContext.viewMode;
87
89
 
88
90
  const [isDeleteImageDialogVisible, setDeleteImageDialogVisible] = useState(false);
89
91
  const [imageToBeDeletedData, setImageToBeDeletedData] = useState<any>();
90
92
  const [fileDetails, setFileDetails] = useState<{ name: string; type: string, fileUrl: string, fileSize: number } | null>(null);
91
93
  const [isReplaceImageDialogVisible, setReplaceImageDialogVisible] = useState(false);
92
94
  const [newFileToUpload, setNewFileToUpload] = useState<any>(null);
95
+ const [fileSizeError, setFileSizeError] = useState<string | null>(null);
93
96
 
94
97
  const formatFileSize = (size: number) => {
95
98
  return size >= 1024 * 1024
@@ -116,6 +119,7 @@ export class SolidMediaSingleField implements ISolidField {
116
119
  const handleDropImage = (acceptedFiles: any[]) => {
117
120
  const file = acceptedFiles[0];
118
121
  if (!file) return;
122
+ setFileSizeError(null);
119
123
  if (fileDetails) {
120
124
  // If a file is already uploaded, show the confirmation dialog
121
125
  setNewFileToUpload(file);
@@ -195,113 +199,140 @@ export class SolidMediaSingleField implements ISolidField {
195
199
  isDragActive: isDragActive,
196
200
  } = useDropzone({
197
201
  onDrop: handleDropImage,
202
+ onDropRejected: (fileRejections) => {
203
+ const rejection = fileRejections[0];
204
+ const sizeError = rejection.errors.find(err => err.code === 'file-too-large');
205
+ if (sizeError) {
206
+ setFileSizeError(`File is too large. Max size is ${fieldMetadata.mediaMaxSizeKb} KB.`);
207
+ } else {
208
+ setFileSizeError(rejection.errors[0]?.message || "File not accepted.");
209
+ }
210
+ },
198
211
  accept: getAcceptedFileTypes(fieldMetadata.mediaTypes),
199
212
  maxSize: fieldMetadata.mediaMaxSizeKb * 1024,
200
213
  });
201
214
 
202
215
  const isFormFieldValid = (formik: any, fieldName: string) => formik.touched[fieldName] && formik.errors[fieldName];
216
+ let DynamicWidget = getExtensionComponent("SolidFormFieldViewMediaSingleWidget");
217
+ const widgetProps = {
218
+ formik: formik,
219
+ fieldContext: this.fieldContext,
220
+ }
203
221
 
204
222
  return (
205
- <div className={className} style={readOnlyPermission === true ? { filter: 'opacity(50%)', pointerEvents: 'none' } : {}}>
206
- <div className="flex flex-column gap-2 mt-4 relative">
207
- {showFieldLabel != false &&
208
- <label htmlFor={fieldLayoutInfo.attrs.name} className="form-field-label">{fieldLabel}
209
- {fieldMetadata.required && <span className="text-red-500"> *</span>}
210
- {/* &nbsp; {fieldDescription && <span className="form_field_help">({fieldDescription}) </span>} */}
211
- </label>
212
- }
213
- <div
214
- {...getRootProps()}
215
- className="solid-dropzone-wrapper"
216
- >
217
- <input {...getInputProps()} />
218
- <DropzonePlaceholder
219
- mediaTypes={fieldMetadata.mediaTypes}
220
- mediaMaxSizeKb={fieldMetadata.mediaMaxSizeKb}
221
- />
223
+ <>
224
+ {viewMode === "view" &&
225
+ <div className={className}>
226
+ {DynamicWidget && <DynamicWidget {...widgetProps} />}
222
227
  </div>
223
- {isFormFieldValid(formik, fieldLayoutInfo.attrs.name) && (
224
- <div className="absolute mt-1">
225
- <Message severity="error" text={formik?.errors[fieldLayoutInfo.attrs.name]?.toString()} />
226
- </div>
227
- )}
228
- {fileDetails && (
229
- <div className="solid-file-upload-wrapper mt-4">
230
- <div className="flex align-items-center gap-2">
231
- <FileReaderExt fileDetails={fileDetails} />
232
- <div className="w-full flex flex-column gap-1">
233
- <div className="flex align-items-start justify-content-between">
234
- <Link className="font-normal w-9 text-primary" href={fileDetails.fileUrl} target="_blank">{fileDetails.name}</Link>
235
- <div className="flex align-items-center gap-2">
236
- <div>
237
- <Button
238
- type="button"
239
- text
240
- icon={"pi pi-download"}
241
- size="small"
242
- severity="secondary"
243
- // className="p-2"
244
- style={{
245
- height: 16,
246
- width: 16
247
- }}
248
- onClick={() => downloadMediaFile(fileDetails?.fileUrl, fileDetails?.name)}
249
- />
228
+ }
229
+ {viewMode === "edit" &&
230
+ <div className={className} style={readOnlyPermission === true ? { filter: 'opacity(50%)', pointerEvents: 'none' } : {}}>
231
+ <div className="flex flex-column gap-2 mt-4 relative">
232
+ {showFieldLabel != false &&
233
+ <label htmlFor={fieldLayoutInfo.attrs.name} className="form-field-label">{fieldLabel}
234
+ {fieldMetadata.required && <span className="text-red-500"> *</span>}
235
+ {/* &nbsp; {fieldDescription && <span className="form_field_help">({fieldDescription}) </span>} */}
236
+ </label>
237
+ }
238
+ <div
239
+ {...getRootProps()}
240
+ className="solid-dropzone-wrapper"
241
+ >
242
+ <input {...getInputProps()} />
243
+ <DropzonePlaceholder
244
+ mediaTypes={fieldMetadata.mediaTypes}
245
+ mediaMaxSizeKb={fieldMetadata.mediaMaxSizeKb}
246
+ />
247
+ </div>
248
+ {isFormFieldValid(formik, fieldLayoutInfo.attrs.name) && (
249
+ <div className="absolute mt-1">
250
+ <Message severity="error" text={formik?.errors[fieldLayoutInfo.attrs.name]?.toString()} />
251
+ </div>
252
+ )}
253
+ {
254
+ fileSizeError &&
255
+ <Message severity="error" text={fileSizeError?.toString()} />
256
+ }
257
+ {fileDetails && (
258
+ <div className="solid-file-upload-wrapper mt-4">
259
+ <div className="flex align-items-center gap-2">
260
+ <FileReaderExt fileDetails={fileDetails} />
261
+ <div className="w-full flex flex-column gap-1">
262
+ <div className="flex align-items-start justify-content-between">
263
+ <Link className="font-normal w-9 text-primary" href={fileDetails.fileUrl} target="_blank">{fileDetails.name}</Link>
264
+ <div className="flex align-items-center gap-2">
265
+ <div>
266
+ <Button
267
+ type="button"
268
+ text
269
+ icon={"pi pi-download"}
270
+ size="small"
271
+ severity="secondary"
272
+ // className="p-2"
273
+ style={{
274
+ height: 16,
275
+ width: 16
276
+ }}
277
+ onClick={() => downloadMediaFile(fileDetails?.fileUrl, fileDetails?.name)}
278
+ />
279
+ </div>
280
+ <div>
281
+ <Button
282
+ type="button"
283
+ text
284
+ icon={"pi pi-times"}
285
+ size="small"
286
+ severity="secondary"
287
+ // className="p-2"
288
+ style={{
289
+ height: 16,
290
+ width: 16
291
+ }}
292
+ onClick={() => setDeleteImageDialogVisible(true)}
293
+ />
294
+ </div>
295
+ </div>
250
296
  </div>
251
- <div>
252
- <Button
253
- type="button"
254
- text
255
- icon={"pi pi-times"}
256
- size="small"
257
- severity="secondary"
258
- // className="p-2"
259
- style={{
260
- height: 16,
261
- width: 16
262
- }}
263
- onClick={() => setDeleteImageDialogVisible(true)}
264
- />
297
+ <div className="flex align-items-center gap-2 text-sm">
298
+ {fileDetails && formatFileSize(fileDetails.fileSize)}
265
299
  </div>
266
300
  </div>
267
301
  </div>
268
- <div className="flex align-items-center gap-2 text-sm">
269
- {fileDetails && formatFileSize(fileDetails.fileSize)}
270
- </div>
271
302
  </div>
272
- </div>
273
- </div>
274
- )}
275
- </div>
276
- <Dialog
277
- visible={isDeleteImageDialogVisible}
278
- header="Confirm Delete"
279
- modal
280
- footer={() => (
281
- <div className="flex justify-content-center">
282
- <Button type="button" label="Yes" icon="pi pi-check" className='small-button' severity="danger" autoFocus onClick={handleCancelUpload} />
283
- <Button type="button" label="No" icon="pi pi-times" className='small-button' onClick={() => setDeleteImageDialogVisible(false)} />
303
+ )}
284
304
  </div>
285
- )}
286
- onHide={() => setDeleteImageDialogVisible(false)}
287
- >
288
- <p>Are you sure you want to delete media?</p>
289
- </Dialog>
290
- <Dialog
291
- visible={isReplaceImageDialogVisible}
292
- header="Replace Image"
293
- modal
294
- footer={() => (
295
- <div className="flex justify-content-center">
296
- <Button type="button" label="Yes, Replace" icon="pi pi-check" className='small-button' severity="danger" onClick={handleReplaceFile} />
297
- <Button type="button" label="Cancel" icon="pi pi-times" className='small-button' onClick={() => setReplaceImageDialogVisible(false)} />
298
- </div>
299
- )}
300
- onHide={() => setReplaceImageDialogVisible(false)}
301
- >
302
- <p>An media is already uploaded. Do you want to delete it and upload a new one?</p>
303
- </Dialog>
304
- </div>
305
+ <Dialog
306
+ visible={isDeleteImageDialogVisible}
307
+ header="Confirm Delete"
308
+ modal
309
+ footer={() => (
310
+ <div className="flex justify-content-center">
311
+ <Button type="button" label="Yes" icon="pi pi-check" className='small-button' severity="danger" autoFocus onClick={handleCancelUpload} />
312
+ <Button type="button" label="No" icon="pi pi-times" className='small-button' onClick={() => setDeleteImageDialogVisible(false)} />
313
+ </div>
314
+ )}
315
+ onHide={() => setDeleteImageDialogVisible(false)}
316
+ >
317
+ <p>Are you sure you want to delete media?</p>
318
+ </Dialog>
319
+ <Dialog
320
+ visible={isReplaceImageDialogVisible}
321
+ header="Replace Image"
322
+ modal
323
+ footer={() => (
324
+ <div className="flex justify-content-center">
325
+ <Button type="button" label="Yes, Replace" icon="pi pi-check" className='small-button' severity="danger" onClick={handleReplaceFile} />
326
+ <Button type="button" label="Cancel" icon="pi pi-times" className='small-button' onClick={() => setReplaceImageDialogVisible(false)} />
327
+ </div>
328
+ )}
329
+ onHide={() => setReplaceImageDialogVisible(false)}
330
+ >
331
+ <p>An media is already uploaded. Do you want to delete it and upload a new one?</p>
332
+ </Dialog>
333
+ </div>
334
+ }
335
+ </>
305
336
  );
306
337
  }
307
338
  }
@@ -5,6 +5,7 @@ import * as Yup from 'yup';
5
5
  import { Schema } from "yup";
6
6
  import { FormikObject, ISolidField, SolidFieldProps } from "./ISolidField";
7
7
  import { Password } from "primereact/password";
8
+ import { getExtensionComponent } from "@/helpers/registry";
8
9
 
9
10
  export class SolidPasswordField implements ISolidField {
10
11
 
@@ -79,35 +80,51 @@ export class SolidPasswordField implements ISolidField {
79
80
  const formDisabled = solidFormViewMetaData.data.solidView?.layout?.attrs?.disabled;
80
81
  const formReadonly = solidFormViewMetaData.data.solidView?.layout?.attrs?.readonly;
81
82
 
83
+ const viewMode: string = this.fieldContext.viewMode;
84
+ let DynamicWidget = getExtensionComponent("SolidFormFieldPasswordViewModeWidget");
85
+ const widgetProps = {
86
+ label: fieldLabel,
87
+ value: formik.values[fieldLayoutInfo.attrs.name],
88
+ }
82
89
  return (
83
- <div className={className}>
84
- <div className="relative">
85
- <div className="flex flex-column gap-2 mt-4">
86
- {showFieldLabel != false &&
87
- <label htmlFor={fieldLayoutInfo.attrs.name} className="form-field-label">
88
- {fieldLabel}
89
- {fieldMetadata.required && <span className="text-red-500"> *</span>}
90
- </label>
91
- }
92
- <Password
93
- id={fieldLayoutInfo.attrs.name}
94
- name={fieldMetadata.name}
95
- value={formik.values[fieldLayoutInfo.attrs.name] || ''}
96
- onChange={(e) => this.fieldContext.onChange(e, 'onFieldChange')}
97
- onBlur={(e) => this.fieldContext.onBlur(e, 'onFieldBlur')}
98
- readOnly={formReadonly || fieldReadonly || readOnlyPermission}
99
- disabled={formDisabled || fieldDisabled}
100
- toggleMask
101
- />
102
-
90
+ <>
91
+ {viewMode === "view" &&
92
+ <div className={className}>
93
+ {DynamicWidget && <DynamicWidget {...widgetProps} />}
103
94
  </div>
104
- {isFormFieldValid(formik, fieldLayoutInfo.attrs.name) && (
105
- <div className="absolute mt-1">
106
- <Message severity="error" text={formik?.errors[fieldLayoutInfo.attrs.name]?.toString()} />
95
+ }
96
+ {viewMode === "edit" &&
97
+ (
98
+ <div className={className}>
99
+ <div className="relative">
100
+ <div className="flex flex-column gap-2 mt-4">
101
+ {showFieldLabel != false &&
102
+ <label htmlFor={fieldLayoutInfo.attrs.name} className="form-field-label">
103
+ {fieldLabel}
104
+ {fieldMetadata.required && <span className="text-red-500"> *</span>}
105
+ </label>
106
+ }
107
+ <Password
108
+ id={fieldLayoutInfo.attrs.name}
109
+ name={fieldMetadata.name}
110
+ value={formik.values[fieldLayoutInfo.attrs.name] || ''}
111
+ onChange={(e) => this.fieldContext.onChange(e, 'onFieldChange')}
112
+ onBlur={(e) => this.fieldContext.onBlur(e, 'onFieldBlur')}
113
+ readOnly={formReadonly || fieldReadonly || readOnlyPermission}
114
+ disabled={formDisabled || fieldDisabled}
115
+ toggleMask
116
+ />
117
+
118
+ </div>
119
+ {isFormFieldValid(formik, fieldLayoutInfo.attrs.name) && (
120
+ <div className="absolute mt-1">
121
+ <Message severity="error" text={formik?.errors[fieldLayoutInfo.attrs.name]?.toString()} />
122
+ </div>
123
+ )}
124
+ </div>
107
125
  </div>
108
126
  )}
109
- </div>
110
- </div>
127
+ </>
111
128
  );
112
129
  }
113
130
  }
@@ -5,6 +5,7 @@ import { useState } from "react";
5
5
  import * as Yup from 'yup';
6
6
  import { Schema } from "yup";
7
7
  import { FormikObject, ISolidField, SolidFieldProps } from "./ISolidField";
8
+ import { getExtensionComponent } from "@/helpers/registry";
8
9
 
9
10
  export class SolidRichTextField implements ISolidField {
10
11
 
@@ -74,34 +75,50 @@ export class SolidRichTextField implements ISolidField {
74
75
  const formDisabled = solidFormViewMetaData.data.solidView?.layout?.attrs?.disabled;
75
76
  const formReadonly = solidFormViewMetaData.data.solidView?.layout?.attrs?.readonly;
76
77
 
78
+ const viewMode: string = this.fieldContext.viewMode;
79
+ let DynamicWidget = getExtensionComponent("SolidFormFieldRichTextViewModeWidget");
80
+ const widgetProps = {
81
+ label: fieldLabel,
82
+ value: formik.values[fieldLayoutInfo.attrs.name],
83
+ }
77
84
  return (
78
- <div className={className}>
79
- <div className="relative">
80
- <div className="flex flex-column gap-2 mt-4">
81
- {showFieldLabel != false &&
82
- <label htmlFor={fieldLayoutInfo.attrs.name} className="form-field-label">{fieldLabel}
83
- {fieldMetadata.required && <span className="text-red-500"> *</span>}
84
- {/* &nbsp; {fieldDescription && <span className="form_field_help">({fieldDescription}) </span>} */}
85
- </label>
86
- }
87
- <Editor
88
- readOnly={formReadonly || fieldReadonly || readOnlyPermission}
89
- disabled={formDisabled || fieldDisabled}
90
- key={fieldLayoutInfo.attrs.name} // React will re-render the component whenever this value changes
91
- id={fieldLayoutInfo.attrs.name}
92
- value={formik.values[fieldLayoutInfo.attrs.name]}
93
- onTextChange={e => formik.setFieldValue(fieldLayoutInfo.attrs.name, e.htmlValue)}
94
- style={{ height: "320px" }}
95
- className="solid-custom-editor"
96
- />
85
+ <>
86
+ {viewMode === "view" &&
87
+ <div className={className}>
88
+ {DynamicWidget && <DynamicWidget {...widgetProps} />}
97
89
  </div>
98
- {isFormFieldValid(formik, fieldLayoutInfo.attrs.name) && (
99
- <div className="absolute mt-1">
100
- <Message severity="error" text={formik?.errors[fieldLayoutInfo.attrs.name]?.toString()} />
90
+ }
91
+ {viewMode === "edit" &&
92
+ (
93
+ <div className={className}>
94
+ <div className="relative">
95
+ <div className="flex flex-column gap-2 mt-4">
96
+ {showFieldLabel != false &&
97
+ <label htmlFor={fieldLayoutInfo.attrs.name} className="form-field-label">{fieldLabel}
98
+ {fieldMetadata.required && <span className="text-red-500"> *</span>}
99
+ {/* &nbsp; {fieldDescription && <span className="form_field_help">({fieldDescription}) </span>} */}
100
+ </label>
101
+ }
102
+ <Editor
103
+ readOnly={formReadonly || fieldReadonly || readOnlyPermission}
104
+ disabled={formDisabled || fieldDisabled}
105
+ key={fieldLayoutInfo.attrs.name} // React will re-render the component whenever this value changes
106
+ id={fieldLayoutInfo.attrs.name}
107
+ value={formik.values[fieldLayoutInfo.attrs.name]}
108
+ onTextChange={e => formik.setFieldValue(fieldLayoutInfo.attrs.name, e.htmlValue)}
109
+ style={{ height: "320px" }}
110
+ className="solid-custom-editor"
111
+ />
112
+ </div>
113
+ {isFormFieldValid(formik, fieldLayoutInfo.attrs.name) && (
114
+ <div className="absolute mt-1">
115
+ <Message severity="error" text={formik?.errors[fieldLayoutInfo.attrs.name]?.toString()} />
116
+ </div>
117
+ )}
118
+ </div>
101
119
  </div>
102
120
  )}
103
- </div>
104
- </div>
121
+ </>
105
122
  );
106
123
  }
107
124
  }
@@ -7,6 +7,7 @@ import { useState } from "react";
7
7
  import * as Yup from 'yup';
8
8
  import { Schema } from "yup";
9
9
  import { FormikObject, ISolidField, SolidFieldProps } from "./ISolidField";
10
+ import { getExtensionComponent } from "@/helpers/registry";
10
11
 
11
12
 
12
13
  export class SolidSelectionDynamicField implements ISolidField {
@@ -93,38 +94,55 @@ export class SolidSelectionDynamicField implements ISolidField {
93
94
 
94
95
  const isFormFieldValid = (formik: any, fieldName: string) => formik.touched[fieldName] && formik.errors[fieldName];
95
96
 
97
+ const viewMode: string = this.fieldContext.viewMode;
98
+ let DynamicWidget = getExtensionComponent("SolidFormFieldViewModeWidget");
99
+ const widgetProps = {
100
+ label: fieldLabel,
101
+ value: formik.values[fieldLayoutInfo.attrs.name],
102
+ }
96
103
  return (
97
- <div className={className}>
98
- <div className="relative">
99
- <div className="flex flex-column gap-2 mt-4">
100
- {showFieldLabel != false &&
101
- <label htmlFor={fieldLayoutInfo.attrs.name} className="form-field-label">{fieldLabel}
102
- {fieldMetadata.required && <span className="text-red-500"> *</span>}
103
- {/* &nbsp; {fieldDescription && <span className="form_field_help">({fieldDescription}) </span>} */}
104
- </label>
105
- }
106
- <AutoComplete
107
- readOnly={formReadonly || fieldReadonly || readOnlyPermission}
108
- disabled={formDisabled || fieldDisabled}
109
- {...formik.getFieldProps(fieldLayoutInfo.attrs.name)}
110
- id={fieldLayoutInfo.attrs.name}
111
- field="label"
112
- value={formik.values[fieldLayoutInfo.attrs.name] || ''}
113
- dropdown
114
- suggestions={selectionDynamicItems}
115
- completeMethod={selectionDynamicSearch}
116
- // onChange={(e) => updateInputs(index, e.value)} />
117
- onChange={(e) => this.fieldContext.onChange(e, 'onFieldChange')}
118
- className="solid-standard-autocomplete"
119
- />
104
+ <>
105
+ {viewMode === "view" &&
106
+ <div className={className}>
107
+ {DynamicWidget && <DynamicWidget {...widgetProps} />}
120
108
  </div>
121
- {isFormFieldValid(formik, fieldLayoutInfo.attrs.name) && (
122
- <div className="absolute mt-1">
123
- <Message severity="error" text={formik?.errors[fieldLayoutInfo.attrs.name]?.toString()} />
109
+ }
110
+ {viewMode === "edit" &&
111
+ (
112
+
113
+ <div className={className}>
114
+ <div className="relative">
115
+ <div className="flex flex-column gap-2 mt-4">
116
+ {showFieldLabel != false &&
117
+ <label htmlFor={fieldLayoutInfo.attrs.name} className="form-field-label">{fieldLabel}
118
+ {fieldMetadata.required && <span className="text-red-500"> *</span>}
119
+ {/* &nbsp; {fieldDescription && <span className="form_field_help">({fieldDescription}) </span>} */}
120
+ </label>
121
+ }
122
+ <AutoComplete
123
+ readOnly={formReadonly || fieldReadonly || readOnlyPermission}
124
+ disabled={formDisabled || fieldDisabled}
125
+ {...formik.getFieldProps(fieldLayoutInfo.attrs.name)}
126
+ id={fieldLayoutInfo.attrs.name}
127
+ field="label"
128
+ value={formik.values[fieldLayoutInfo.attrs.name] || ''}
129
+ dropdown
130
+ suggestions={selectionDynamicItems}
131
+ completeMethod={selectionDynamicSearch}
132
+ // onChange={(e) => updateInputs(index, e.value)} />
133
+ onChange={formik.handleChange}
134
+ className="solid-standard-autocomplete"
135
+ />
136
+ </div>
137
+ {isFormFieldValid(formik, fieldLayoutInfo.attrs.name) && (
138
+ <div className="absolute mt-1">
139
+ <Message severity="error" text={formik?.errors[fieldLayoutInfo.attrs.name]?.toString()} />
140
+ </div>
141
+ )}
142
+ </div>
124
143
  </div>
125
144
  )}
126
- </div>
127
- </div>
145
+ </>
128
146
  );
129
147
  }
130
148
  }
@@ -91,34 +91,50 @@ export class SolidSelectionStaticField implements ISolidField {
91
91
  if (!renderMode) {
92
92
  renderMode = 'field-autocomplete';
93
93
  }
94
+ const viewMode: string = this.fieldContext.viewMode;
95
+ let DynamicWidget = getExtensionComponent("SolidFormFieldViewModeWidget");
96
+ const widgetProps = {
97
+ label: fieldLabel,
98
+ value: formik.values[fieldLayoutInfo.attrs.name] && formik.values[fieldLayoutInfo.attrs.name].value,
99
+ }
94
100
  return (
95
101
  <>
96
- {renderMode &&
97
- this.renderExtensionRenderMode(renderMode, formik)
98
- }
99
- {isFormFieldValid(formik, fieldLayoutInfo.attrs.name) && (
100
- <div className="absolute mt-1">
101
- <Message severity="error" text={formik?.errors[fieldLayoutInfo.attrs.name]?.toString()} />
102
+ {viewMode === "view" &&
103
+ <div className={className}>
104
+ {DynamicWidget && <DynamicWidget {...widgetProps} />}
102
105
  </div>
103
- )}
106
+ }
107
+ {viewMode === "edit" &&
108
+ (
109
+ <>
110
+ {renderMode &&
111
+ this.renderExtensionRenderMode(renderMode, formik)
112
+ }
113
+ {isFormFieldValid(formik, fieldLayoutInfo.attrs.name) && (
114
+ <div className="absolute mt-1">
115
+ <Message severity="error" text={formik?.errors[fieldLayoutInfo.attrs.name]?.toString()} />
116
+ </div>
117
+ )}
118
+ </>)
119
+ }
104
120
  </>
105
121
  );
106
122
  }
107
123
 
108
- renderExtensionRenderMode(widgetName: string, formik: FormikObject) {
109
- let DynamicWidget = getExtensionComponent(widgetName);
110
- if (!DynamicWidget) {
111
- DynamicWidget = getExtensionComponent('field-autocomplete');
112
- }
113
- const widgetProps: SolidSelectionStaticFieldWidgetProps = {
114
- formik: formik,
115
- fieldContext: this.fieldContext,
116
- }
117
- return (
118
- <>
119
- {DynamicWidget && <DynamicWidget {...widgetProps} />}
120
- </>
121
- )
124
+ renderExtensionRenderMode(widgetName: string, formik: FormikObject) {
125
+ let DynamicWidget = getExtensionComponent(widgetName);
126
+ if (!DynamicWidget) {
127
+ DynamicWidget = getExtensionComponent('field-autocomplete');
122
128
  }
123
-
129
+ const widgetProps: SolidSelectionStaticFieldWidgetProps = {
130
+ formik: formik,
131
+ fieldContext: this.fieldContext,
132
+ }
133
+ return (
134
+ <>
135
+ {DynamicWidget && <DynamicWidget {...widgetProps} />}
136
+ </>
137
+ )
124
138
  }
139
+
140
+ }