@solidstarters/solid-core-ui 1.1.57 → 1.1.58

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 (58) hide show
  1. package/dist/components/core/form/SolidFormUserViewLayout.d.ts.map +1 -1
  2. package/dist/components/core/form/SolidFormUserViewLayout.js +7 -11
  3. package/dist/components/core/form/SolidFormUserViewLayout.js.map +1 -1
  4. package/dist/components/core/form/SolidFormView.d.ts +2 -0
  5. package/dist/components/core/form/SolidFormView.d.ts.map +1 -1
  6. package/dist/components/core/form/SolidFormView.js +33 -27
  7. package/dist/components/core/form/SolidFormView.js.map +1 -1
  8. package/dist/components/core/form/fields/SolidMediaMultipleField.d.ts +6 -1
  9. package/dist/components/core/form/fields/SolidMediaMultipleField.d.ts.map +1 -1
  10. package/dist/components/core/form/fields/SolidMediaMultipleField.js +36 -14
  11. package/dist/components/core/form/fields/SolidMediaMultipleField.js.map +1 -1
  12. package/dist/components/core/form/fields/SolidMediaSingleField.d.ts +6 -1
  13. package/dist/components/core/form/fields/SolidMediaSingleField.d.ts.map +1 -1
  14. package/dist/components/core/form/fields/SolidMediaSingleField.js +25 -3
  15. package/dist/components/core/form/fields/SolidMediaSingleField.js.map +1 -1
  16. package/dist/components/core/form/fields/relations/SolidRelationOneToManyField.d.ts.map +1 -1
  17. package/dist/components/core/form/fields/relations/SolidRelationOneToManyField.js +7 -6
  18. package/dist/components/core/form/fields/relations/SolidRelationOneToManyField.js.map +1 -1
  19. package/dist/components/core/form/fields/widgets/SolidFormFieldViewMediaMultipleWidget.d.ts +1 -1
  20. package/dist/components/core/form/fields/widgets/SolidFormFieldViewMediaMultipleWidget.d.ts.map +1 -1
  21. package/dist/components/core/form/fields/widgets/SolidFormFieldViewMediaMultipleWidget.js +23 -7
  22. package/dist/components/core/form/fields/widgets/SolidFormFieldViewMediaMultipleWidget.js.map +1 -1
  23. package/dist/components/core/form/fields/widgets/SolidFormFieldViewMediaSingleWidget.d.ts +1 -1
  24. package/dist/components/core/form/fields/widgets/SolidFormFieldViewMediaSingleWidget.d.ts.map +1 -1
  25. package/dist/components/core/form/fields/widgets/SolidFormFieldViewMediaSingleWidget.js +19 -3
  26. package/dist/components/core/form/fields/widgets/SolidFormFieldViewMediaSingleWidget.js.map +1 -1
  27. package/dist/components/core/kanban/KanbanUserViewLayout.d.ts.map +1 -1
  28. package/dist/components/core/kanban/KanbanUserViewLayout.js +7 -11
  29. package/dist/components/core/kanban/KanbanUserViewLayout.js.map +1 -1
  30. package/dist/components/core/kanban/SolidKanbanView.d.ts.map +1 -1
  31. package/dist/components/core/kanban/SolidKanbanView.js +34 -36
  32. package/dist/components/core/kanban/SolidKanbanView.js.map +1 -1
  33. package/dist/components/core/kanban/SolidKanbanViewConfigure.js +1 -1
  34. package/dist/components/core/kanban/SolidKanbanViewConfigure.js.map +1 -1
  35. package/dist/components/core/list/SolidListColumnSelector.d.ts.map +1 -1
  36. package/dist/components/core/list/SolidListColumnSelector.js +9 -12
  37. package/dist/components/core/list/SolidListColumnSelector.js.map +1 -1
  38. package/dist/components/core/list/SolidListView.d.ts.map +1 -1
  39. package/dist/components/core/list/SolidListView.js +43 -45
  40. package/dist/components/core/list/SolidListView.js.map +1 -1
  41. package/dist/components/core/list/columns/SolidMediaSingleColumn.d.ts.map +1 -1
  42. package/dist/components/core/list/columns/SolidMediaSingleColumn.js +2 -4
  43. package/dist/components/core/list/columns/SolidMediaSingleColumn.js.map +1 -1
  44. package/package.json +1 -1
  45. package/src/components/core/form/SolidFormUserViewLayout.tsx +0 -2
  46. package/src/components/core/form/SolidFormView.tsx +24 -10
  47. package/src/components/core/form/fields/SolidMediaMultipleField.tsx +28 -4
  48. package/src/components/core/form/fields/SolidMediaSingleField.tsx +26 -3
  49. package/src/components/core/form/fields/relations/SolidRelationOneToManyField.tsx +7 -1
  50. package/src/components/core/form/fields/widgets/SolidFormFieldViewMediaMultipleWidget.tsx +20 -3
  51. package/src/components/core/form/fields/widgets/SolidFormFieldViewMediaSingleWidget.tsx +19 -2
  52. package/src/components/core/kanban/KanbanUserViewLayout.tsx +0 -2
  53. package/src/components/core/kanban/SolidKanbanView.tsx +1 -3
  54. package/src/components/core/kanban/SolidKanbanViewConfigure.tsx +1 -1
  55. package/src/components/core/list/SolidListColumnSelector.tsx +0 -3
  56. package/src/components/core/list/SolidListView.tsx +1 -4
  57. package/src/components/core/list/columns/SolidMediaSingleColumn.tsx +6 -3
  58. package/src/types/solid-core.d.ts +3 -1
@@ -19,9 +19,13 @@ import { getExtensionComponent } from "@/helpers/registry";
19
19
  export class SolidMediaSingleField implements ISolidField {
20
20
 
21
21
  private fieldContext: SolidFieldProps;
22
-
23
- constructor(fieldContext: SolidFieldProps) {
22
+ private setLightboxUrls?: (urls: { src: string; downloadUrl: string }[]) => void;
23
+ private setOpenLightbox?: (open: boolean) => void;
24
+ constructor(fieldContext: SolidFieldProps, setLightboxUrls?: (urls: { src: string; downloadUrl: string }[]) => void,
25
+ setOpenLightbox?: (open: boolean) => void) {
24
26
  this.fieldContext = fieldContext;
27
+ this.setLightboxUrls = setLightboxUrls;
28
+ this.setOpenLightbox = setOpenLightbox;
25
29
  }
26
30
 
27
31
  updateFormData(value: any, formData: FormData): any {
@@ -217,6 +221,25 @@ export class SolidMediaSingleField implements ISolidField {
217
221
  const widgetProps = {
218
222
  formik: formik,
219
223
  fieldContext: this.fieldContext,
224
+ setLightboxUrls: this.setLightboxUrls,
225
+ setOpenLightbox: this.setOpenLightbox
226
+ }
227
+
228
+ const handleFileView = (url: any) => {
229
+ if (url?.type.includes('image/')) {
230
+ this.setLightboxUrls?.([
231
+ { src: url.fileUrl, downloadUrl: url.fileUrl },
232
+ ]);
233
+ this.setOpenLightbox?.(true);
234
+ } else {
235
+ const link = document.createElement('a');
236
+ link.href = url.fileUrl;
237
+ link.download = ''; // or specify a file name like 'file.pdf'
238
+ link.target = '_blank';
239
+ document.body.appendChild(link);
240
+ link.click();
241
+ document.body.removeChild(link);
242
+ }
220
243
  }
221
244
 
222
245
  return (
@@ -262,7 +285,7 @@ export class SolidMediaSingleField implements ISolidField {
262
285
  <FileReaderExt fileDetails={fileDetails} />
263
286
  <div className="w-full flex flex-column gap-1">
264
287
  <div className="flex align-items-start justify-content-between">
265
- <Link className="font-normal w-9 text-primary" href={fileDetails.fileUrl} target="_blank">{fileDetails.name}</Link>
288
+ <p className="font-normal w-9 text-primary m-0" style={{ cursor: 'pointer' }} onClick={() => handleFileView(fileDetails)}>{fileDetails.name}</p>
266
289
  <div className="flex align-items-center gap-2">
267
290
  <div>
268
291
  <Button
@@ -144,12 +144,18 @@ export class SolidRelationOneToManyField implements ISolidField {
144
144
 
145
145
  const isFormFieldValid = (formik: any, fieldName: string) => formik.touched[fieldName] && formik.errors[fieldName];
146
146
  const viewMode: string = this.fieldContext.viewMode;
147
+
148
+ const userKeyFieldName = fieldMetadata.relationModel?.userKeyField?.name;
149
+
147
150
  let DynamicWidget = getExtensionComponent("SolidFormFieldRelationViewModeWidget");
148
151
  const widgetProps = {
149
152
  label: fieldLabel,
150
- value: formik.values[fieldLayoutInfo.attrs.name],
153
+ value: (this.fieldContext.data[fieldLayoutInfo.attrs.name] || []).map(
154
+ (item: any) => ({ label: item[userKeyFieldName] ?? '' })
155
+ )
151
156
  }
152
157
 
158
+
153
159
  return (
154
160
  <>
155
161
  {viewMode === "view" &&
@@ -7,7 +7,7 @@ import { downloadMediaFile } from "@/helpers/downloadMediaFile";
7
7
  import { SolidMediaSingleFieldWidgetProps } from "@/types/solid-core";
8
8
  import { Dialog } from "primereact/dialog";
9
9
 
10
- export const SolidFormFieldViewMediaMultipleWidget = ({ formik, fieldContext }: SolidMediaSingleFieldWidgetProps) => {
10
+ export const SolidFormFieldViewMediaMultipleWidget = ({ formik, fieldContext, setLightboxUrls, setOpenLightbox }: SolidMediaSingleFieldWidgetProps) => {
11
11
  const [fileDetails, setFileDetails] = useState<{ name: string; type: string; size: number, id: number, fileUrl: string }[]>([]);
12
12
  const [isShowAllFiles, setShowAllFiles] = useState(false);
13
13
  const fieldMetadata = fieldContext.fieldMetadata;
@@ -60,6 +60,23 @@ export const SolidFormFieldViewMediaMultipleWidget = ({ formik, fieldContext }:
60
60
  }
61
61
  }, [formik.values, fieldLayoutInfo.attrs.name]);
62
62
 
63
+ const handleFileView = (url: any) => {
64
+ if (url?.type.includes('image/')) {
65
+ setLightboxUrls?.([
66
+ { src: url.fileUrl, downloadUrl: url.fileUrl },
67
+ ]);
68
+ setOpenLightbox?.(true);
69
+ } else {
70
+ const link = document.createElement('a');
71
+ link.href = url.fileUrl;
72
+ link.download = ''; // or specify a file name like 'file.pdf'
73
+ link.target = '_blank';
74
+ document.body.appendChild(link);
75
+ link.click();
76
+ document.body.removeChild(link);
77
+ }
78
+ }
79
+
63
80
  return (
64
81
  <div className={className}>
65
82
  {showFieldLabel != false &&
@@ -72,7 +89,7 @@ export const SolidFormFieldViewMediaMultipleWidget = ({ formik, fieldContext }:
72
89
  <FileReaderExt fileDetails={fileDetails[0]} />
73
90
  <div className="w-full flex flex-column gap-1">
74
91
  <div className="flex align-items-center justify-content-between">
75
- <Link className="font-normal w-11" href={`${fileDetails[0]?.fileUrl}`} target="_blank">{fileDetails[0].name}</Link>
92
+ <p className="font-normal w-11 text-primary m-0" style={{ cursor: 'pointer' }} onClick={() => handleFileView(fileDetails[0])}>{fileDetails[0].name}</p>
76
93
  <div className="flex align-items-center gap-2">
77
94
  <div>
78
95
  <Button
@@ -124,7 +141,7 @@ export const SolidFormFieldViewMediaMultipleWidget = ({ formik, fieldContext }:
124
141
  <FileReaderExt fileDetails={file} />
125
142
  <div className="w-full flex flex-column gap-1">
126
143
  <div className="flex align-items-center justify-content-between">
127
- <Link className="font-normal w-11" href={file?.fileUrl} target="_blank">{file.name}</Link>
144
+ <p className="font-normal w-11" style={{ cursor: 'pointer' }} onClick={() => handleFileView(file)}>{file.name}</p>
128
145
  <div className="flex align-items-center gap-2">
129
146
  <div>
130
147
  <Button
@@ -6,7 +6,7 @@ import Link from "next/link";
6
6
  import { downloadMediaFile } from "@/helpers/downloadMediaFile";
7
7
  import { SolidMediaSingleFieldWidgetProps } from "@/types/solid-core";
8
8
 
9
- export const SolidFormFieldViewMediaSingleWidget = ({ formik, fieldContext }: SolidMediaSingleFieldWidgetProps) => {
9
+ export const SolidFormFieldViewMediaSingleWidget = ({ formik, fieldContext, setLightboxUrls, setOpenLightbox }: SolidMediaSingleFieldWidgetProps) => {
10
10
  const [fileDetails, setFileDetails] = useState<{ name: string; type: string, fileUrl: string, fileSize: number } | null>(null);
11
11
  const fieldMetadata = fieldContext.fieldMetadata;
12
12
  const fieldLayoutInfo = fieldContext.field;
@@ -52,6 +52,23 @@ export const SolidFormFieldViewMediaSingleWidget = ({ formik, fieldContext }: So
52
52
  }
53
53
  }, [formik.values, fieldLayoutInfo.attrs.name]);
54
54
 
55
+ const handleFileView = (url: any) => {
56
+ if (url?.type.includes('image/')) {
57
+ setLightboxUrls?.([
58
+ { src: url.fileUrl, downloadUrl: url.fileUrl },
59
+ ]);
60
+ setOpenLightbox?.(true);
61
+ } else {
62
+ const link = document.createElement('a');
63
+ link.href = url.fileUrl;
64
+ link.download = ''; // or specify a file name like 'file.pdf'
65
+ link.target = '_blank';
66
+ document.body.appendChild(link);
67
+ link.click();
68
+ document.body.removeChild(link);
69
+ }
70
+ }
71
+
55
72
  return (
56
73
  <div className={className}>
57
74
  <div className="flex flex-column gap-2 mt-4 relative">
@@ -66,7 +83,7 @@ export const SolidFormFieldViewMediaSingleWidget = ({ formik, fieldContext }: So
66
83
  <FileReaderExt fileDetails={fileDetails} />
67
84
  <div className="w-full flex flex-column gap-1">
68
85
  <div className="flex align-items-start justify-content-between">
69
- <Link className="font-normal w-9 text-primary" href={fileDetails.fileUrl} target="_blank">{fileDetails.name}</Link>
86
+ <p className="font-normal w-9 text-primary m-0" style={{ cursor: 'pointer' }} onClick={() => handleFileView(fileDetails)}>{fileDetails.name}</p>
70
87
  <div className="flex align-items-center gap-2">
71
88
  <div>
72
89
  <Button
@@ -11,7 +11,6 @@ import { Toast } from "primereact/toast";
11
11
 
12
12
  export const KanbanUserViewLayout = ({ solidKanbanViewMetaData, setLayoutDialogVisible }: any) => {
13
13
  const toast = useRef<Toast>(null);
14
- const { user } = useSelector((state: any) => state.auth);
15
14
  const entityApi = createSolidEntityApi("userViewMetadata");
16
15
  const { useUpsertSolidEntityMutation } = entityApi;
17
16
  const [upsertUserView] = useUpsertSolidEntityMutation();
@@ -40,7 +39,6 @@ export const KanbanUserViewLayout = ({ solidKanbanViewMetaData, setLayoutDialogV
40
39
  try {
41
40
  if (solidView.id) {
42
41
  const response = await upsertUserView({
43
- userId: user?.user?.id,
44
42
  viewMetadataId: solidView.id,
45
43
  layout: JSON.stringify(parsedLayout),
46
44
  }).unwrap();
@@ -29,7 +29,6 @@ import "yet-another-react-lightbox/plugins/counter.css";
29
29
  import { useRouter, useSearchParams } from "next/navigation";
30
30
  import { SolidKanbanViewConfigure } from "./SolidKanbanViewConfigure";
31
31
  import { KanbanUserViewLayout } from "./KanbanUserViewLayout";
32
- import { useSelector } from "react-redux";
33
32
 
34
33
 
35
34
 
@@ -41,7 +40,6 @@ type SolidKanbanViewParams = {
41
40
 
42
41
 
43
42
  export const SolidKanbanView = (params: SolidKanbanViewParams) => {
44
- const { user } = useSelector((state: any) => state.auth);
45
43
  const solidGlobalSearchElementRef = useRef();
46
44
  const searchParams = useSearchParams().toString(); // Converts the query params to a string
47
45
  const router = useRouter();
@@ -121,7 +119,7 @@ export const SolidKanbanView = (params: SolidKanbanViewParams) => {
121
119
  } = entityApi;
122
120
 
123
121
  // Get the kanban view layout & metadata first.
124
- const kanbanViewMetaDataQs = qs.stringify({ ...params, viewType: 'kanban', userId: user?.user?.id }, {
122
+ const kanbanViewMetaDataQs = qs.stringify({ ...params, viewType: 'kanban' }, {
125
123
  encodeValuesOnly: true,
126
124
  });
127
125
  const [kanbanViewMetaData, setKanbanViewMetaData] = useState<any>({});
@@ -71,7 +71,7 @@ export const SolidKanbanViewConfigure = ({ solidKanbanViewMetaData, actionsAllow
71
71
  <Button
72
72
  text
73
73
  type="button"
74
- className="w-8rem text-left gap-2 purple-200"
74
+ className="w-8rem text-left text-base gap-2 purple-200"
75
75
  label="Layout"
76
76
  size="small"
77
77
  iconPos="left"
@@ -4,7 +4,6 @@ import { Button } from 'primereact/button';
4
4
  import { Checkbox, CheckboxChangeEvent } from 'primereact/checkbox';
5
5
  import React, { useEffect, useRef, useState } from 'react'
6
6
  import qs from "qs";
7
- import { useSelector } from 'react-redux';
8
7
  import { createSolidEntityApi } from '@/redux/api/solidEntityApi';
9
8
  import { Toast } from "primereact/toast";
10
9
 
@@ -20,7 +19,6 @@ interface FilterColumns {
20
19
  export const SolidListColumnSelector = ({ listViewMetaData }: any) => {
21
20
  const toast = useRef<Toast>(null);
22
21
 
23
- const { user } = useSelector((state: any) => state.auth);
24
22
  const entityApi = createSolidEntityApi('userViewMetadata');
25
23
  const {
26
24
  useUpsertSolidEntityMutation
@@ -104,7 +102,6 @@ export const SolidListColumnSelector = ({ listViewMetaData }: any) => {
104
102
  if (listViewMetaData?.data?.solidView?.id) {
105
103
  // Update existing user view
106
104
  const response = await upsertUserView({
107
- userId: user?.user?.id,
108
105
  viewMetadataId: listViewMetaData?.data?.solidView?.id,
109
106
  layout: JSON.stringify(updatedView.layout),
110
107
  }).unwrap();
@@ -43,7 +43,6 @@ import Download from "yet-another-react-lightbox/plugins/download";
43
43
  import "yet-another-react-lightbox/styles.css";
44
44
  import "yet-another-react-lightbox/plugins/counter.css";
45
45
  import { SolidListViewConfigure } from "./SolidListViewConfigure";
46
- import { useSelector } from "react-redux";
47
46
 
48
47
 
49
48
  const getRandomInt = (min: number, max: number) => {
@@ -92,8 +91,6 @@ type SolidListViewParams = {
92
91
  export const SolidListView = (params: SolidListViewParams) => {
93
92
 
94
93
  const solidGlobalSearchElementRef = useRef();
95
- const { user } = useSelector((state: any) => state.auth);
96
-
97
94
 
98
95
  const router = useRouter()
99
96
  const searchParams = useSearchParams().toString(); // Converts the query params to a string
@@ -150,7 +147,7 @@ export const SolidListView = (params: SolidListViewParams) => {
150
147
  } = entityApi;
151
148
 
152
149
  // Get the list view layout & metadata first.
153
- const listViewMetaDataQs = qs.stringify({ modelName: params.modelName, moduleName: params.moduleName, viewType: 'list', userId: user?.user?.id }, {
150
+ const listViewMetaDataQs = qs.stringify({ modelName: params.modelName, moduleName: params.moduleName, viewType: 'list'}, {
154
151
  encodeValuesOnly: true,
155
152
  });
156
153
  const [listViewMetaData, setListViewMetaData] = useState({});
@@ -21,11 +21,11 @@ const MediaWithFallback = ({ src, alt, onClick }: { src: string; alt: string; on
21
21
  width={40}
22
22
  height={40}
23
23
  style={{ objectFit: "cover" }}
24
- onError={() => setIsBroken(true)} // Handle broken image
24
+ onError={() => setIsBroken(true)}
25
25
  onClick={onClick}
26
26
  />
27
27
  ) : (
28
- <i className={classNames(isImageFile(src) ? "pi pi-image" : "pi pi-file", "text-3xl text-gray-400")}></i> // Image or file icon
28
+ <i className={classNames(isImageFile(src) ? "pi pi-image" : "pi pi-file", "text-3xl text-gray-400")}></i>
29
29
  )}
30
30
  </div>
31
31
  );
@@ -50,7 +50,10 @@ const SolidMediaSingleColumn = ({ solidListViewMetaData, fieldMetadata, column,
50
50
  }}
51
51
  />
52
52
  ) : (
53
- <i className="pi pi-image text-3xl text-gray-400"></i> // Default fallback icon
53
+ <div
54
+ style={{ height: 40, width: 40 }}
55
+ >
56
+ </div>
54
57
  )
55
58
  );
56
59
  };
@@ -120,10 +120,12 @@ export type SolidSelectionStaticFieldWidgetProps = {
120
120
  };
121
121
 
122
122
  export type SolidShortTextImageRenderModeWidgetProps = {
123
- data: string;
123
+ data: string;
124
124
  }
125
125
 
126
126
  export type SolidMediaSingleFieldWidgetProps = {
127
127
  formik: any;
128
128
  fieldContext?: SolidFieldProps;
129
+ setLightboxUrls?: any,
130
+ setOpenLightbox?: any
129
131
  };