@solidstarters/solid-core-ui 1.1.31 → 1.1.33

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 (86) hide show
  1. package/dist/components/core/extension/solid-core/emailTemplate/emailFormTypeChangeHandler.d.ts +7 -0
  2. package/dist/components/core/extension/solid-core/emailTemplate/emailFormTypeChangeHandler.d.ts.map +1 -0
  3. package/dist/components/core/extension/solid-core/emailTemplate/emailFormTypeChangeHandler.js +17 -0
  4. package/dist/components/core/extension/solid-core/emailTemplate/emailFormTypeChangeHandler.js.map +1 -0
  5. package/dist/components/core/extension/solid-core/emailTemplate/emailFormTypeLoad.d.ts +7 -0
  6. package/dist/components/core/extension/solid-core/emailTemplate/emailFormTypeLoad.d.ts.map +1 -0
  7. package/dist/components/core/extension/solid-core/emailTemplate/emailFormTypeLoad.js +17 -0
  8. package/dist/components/core/extension/solid-core/emailTemplate/emailFormTypeLoad.js.map +1 -0
  9. package/dist/components/core/extension/solid-core/roleMetadata/RolePermissionsManyToManyFieldWidget.d.ts +3 -0
  10. package/dist/components/core/extension/solid-core/roleMetadata/RolePermissionsManyToManyFieldWidget.d.ts.map +1 -0
  11. package/dist/components/core/extension/solid-core/roleMetadata/RolePermissionsManyToManyFieldWidget.js +78 -0
  12. package/dist/components/core/extension/solid-core/roleMetadata/RolePermissionsManyToManyFieldWidget.js.map +1 -0
  13. package/dist/components/core/form/SolidFormView.d.ts.map +1 -1
  14. package/dist/components/core/form/SolidFormView.js +89 -36
  15. package/dist/components/core/form/SolidFormView.js.map +1 -1
  16. package/dist/components/core/form/fields/SolidBooleanField.d.ts +1 -0
  17. package/dist/components/core/form/fields/SolidBooleanField.d.ts.map +1 -1
  18. package/dist/components/core/form/fields/SolidBooleanField.js +36 -8
  19. package/dist/components/core/form/fields/SolidBooleanField.js.map +1 -1
  20. package/dist/components/core/form/fields/SolidLongTextField.d.ts +2 -0
  21. package/dist/components/core/form/fields/SolidLongTextField.d.ts.map +1 -1
  22. package/dist/components/core/form/fields/SolidLongTextField.js +32 -3
  23. package/dist/components/core/form/fields/SolidLongTextField.js.map +1 -1
  24. package/dist/components/core/form/fields/SolidSelectionStaticField.d.ts +1 -0
  25. package/dist/components/core/form/fields/SolidSelectionStaticField.d.ts.map +1 -1
  26. package/dist/components/core/form/fields/SolidSelectionStaticField.js +19 -20
  27. package/dist/components/core/form/fields/SolidSelectionStaticField.js.map +1 -1
  28. package/dist/components/core/form/fields/relations/SolidRelationManyToManyField.d.ts +1 -3
  29. package/dist/components/core/form/fields/relations/SolidRelationManyToManyField.d.ts.map +1 -1
  30. package/dist/components/core/form/fields/relations/SolidRelationManyToManyField.js +19 -274
  31. package/dist/components/core/form/fields/relations/SolidRelationManyToManyField.js.map +1 -1
  32. package/dist/components/core/form/fields/relations/widgets/SolidRelationManyToManyAutocompleteWidget.d.ts +3 -0
  33. package/dist/components/core/form/fields/relations/widgets/SolidRelationManyToManyAutocompleteWidget.d.ts.map +1 -0
  34. package/dist/components/core/form/fields/relations/widgets/SolidRelationManyToManyAutocompleteWidget.js +38 -0
  35. package/dist/components/core/form/fields/relations/widgets/SolidRelationManyToManyAutocompleteWidget.js.map +1 -0
  36. package/dist/components/core/form/fields/relations/widgets/SolidRelationManyToManyCheckboxWidget.d.ts +3 -0
  37. package/dist/components/core/form/fields/relations/widgets/SolidRelationManyToManyCheckboxWidget.d.ts.map +1 -0
  38. package/dist/components/core/form/fields/relations/widgets/SolidRelationManyToManyCheckboxWidget.js +48 -0
  39. package/dist/components/core/form/fields/relations/widgets/SolidRelationManyToManyCheckboxWidget.js.map +1 -0
  40. package/dist/components/core/form/fields/relations/widgets/helpers/InlineRelationEntityDialog.d.ts +2 -0
  41. package/dist/components/core/form/fields/relations/widgets/helpers/InlineRelationEntityDialog.d.ts.map +1 -0
  42. package/dist/components/core/form/fields/relations/widgets/helpers/InlineRelationEntityDialog.js +35 -0
  43. package/dist/components/core/form/fields/relations/widgets/helpers/InlineRelationEntityDialog.js.map +1 -0
  44. package/dist/components/core/form/fields/relations/widgets/helpers/useRelationEntityHandler.d.ts +6 -0
  45. package/dist/components/core/form/fields/relations/widgets/helpers/useRelationEntityHandler.d.ts.map +1 -0
  46. package/dist/components/core/form/fields/relations/widgets/helpers/useRelationEntityHandler.js +119 -0
  47. package/dist/components/core/form/fields/relations/widgets/helpers/useRelationEntityHandler.js.map +1 -0
  48. package/dist/components/core/form/fields/widgets/SolidBooleanCheckboxFieldWidget.d.ts +3 -0
  49. package/dist/components/core/form/fields/widgets/SolidBooleanCheckboxFieldWidget.d.ts.map +1 -0
  50. package/dist/components/core/form/fields/widgets/SolidBooleanCheckboxFieldWidget.js +57 -0
  51. package/dist/components/core/form/fields/widgets/SolidBooleanCheckboxFieldWidget.js.map +1 -0
  52. package/dist/components/core/form/fields/widgets/SolidBooleanSelectFieldWidget.d.ts +3 -0
  53. package/dist/components/core/form/fields/widgets/SolidBooleanSelectFieldWidget.d.ts.map +1 -0
  54. package/dist/components/core/form/fields/widgets/SolidBooleanSelectFieldWidget.js +30 -0
  55. package/dist/components/core/form/fields/widgets/SolidBooleanSelectFieldWidget.js.map +1 -0
  56. package/dist/components/core/form/fields/widgets/SolidSelectionStaticAutocompleteFieldWidget.d.ts +3 -0
  57. package/dist/components/core/form/fields/widgets/SolidSelectionStaticAutocompleteFieldWidget.d.ts.map +1 -0
  58. package/dist/components/core/form/fields/widgets/SolidSelectionStaticAutocompleteFieldWidget.js +50 -0
  59. package/dist/components/core/form/fields/widgets/SolidSelectionStaticAutocompleteFieldWidget.js.map +1 -0
  60. package/dist/components/core/form/fields/widgets/SolidSelectionStaticRadioFieldWidget.d.ts +3 -0
  61. package/dist/components/core/form/fields/widgets/SolidSelectionStaticRadioFieldWidget.d.ts.map +1 -0
  62. package/dist/components/core/form/fields/widgets/SolidSelectionStaticRadioFieldWidget.js +32 -0
  63. package/dist/components/core/form/fields/widgets/SolidSelectionStaticRadioFieldWidget.js.map +1 -0
  64. package/dist/helpers/registry.d.ts +1 -1
  65. package/dist/helpers/registry.d.ts.map +1 -1
  66. package/dist/helpers/registry.js +27 -2
  67. package/dist/helpers/registry.js.map +1 -1
  68. package/package.json +1 -1
  69. package/src/components/core/extension/solid-core/emailTemplate/emailFormTypeChangeHandler.ts +18 -0
  70. package/src/components/core/extension/solid-core/emailTemplate/emailFormTypeLoad.ts +18 -0
  71. package/src/components/core/extension/solid-core/roleMetadata/RolePermissionsManyToManyFieldWidget.tsx +123 -0
  72. package/src/components/core/form/SolidFormView.tsx +75 -21
  73. package/src/components/core/form/fields/SolidBooleanField.tsx +45 -37
  74. package/src/components/core/form/fields/SolidLongTextField.tsx +79 -20
  75. package/src/components/core/form/fields/SolidSelectionStaticField.tsx +33 -46
  76. package/src/components/core/form/fields/relations/SolidRelationManyToManyField.tsx +20 -356
  77. package/src/components/core/form/fields/relations/widgets/SolidRelationManyToManyAutocompleteWidget.tsx +74 -0
  78. package/src/components/core/form/fields/relations/widgets/SolidRelationManyToManyCheckboxWidget.tsx +103 -0
  79. package/src/components/core/form/fields/relations/widgets/helpers/InlineRelationEntityDialog.tsx +33 -0
  80. package/src/components/core/form/fields/relations/widgets/helpers/useRelationEntityHandler.ts +64 -0
  81. package/src/components/core/form/fields/widgets/SolidBooleanCheckboxFieldWidget.tsx +79 -0
  82. package/src/components/core/form/fields/widgets/SolidBooleanSelectFieldWidget.tsx +68 -0
  83. package/src/components/core/form/fields/widgets/SolidSelectionStaticAutocompleteFieldWidget.tsx +72 -0
  84. package/src/components/core/form/fields/widgets/SolidSelectionStaticRadioFieldWidget.tsx +71 -0
  85. package/src/helpers/registry.ts +29 -2
  86. package/src/types/solid-core.d.ts +23 -1
@@ -1,11 +1,25 @@
1
+ import hanldeEmailFormTypeChange from "../components/core/extension/solid-core/emailTemplate/emailFormTypeChangeHandler";
2
+ import hanldeEmailFormTypeLoad from "../components/core/extension/solid-core/emailTemplate/emailFormTypeLoad";
3
+ import { RolePermissionsManyToManyFieldWidget } from "../components/core/extension/solid-core/roleMetadata/RolePermissionsManyToManyFieldWidget";
4
+ import { SolidRelationManyToManyAutocompleteWidget } from "../components/core/form/fields/relations/widgets/SolidRelationManyToManyAutocompleteWidget";
5
+ import { SolidRelationManyToManyCheckboxWidget } from "../components/core/form/fields/relations/widgets/SolidRelationManyToManyCheckboxWidget";
1
6
  import { CustomHtml } from "../components/core/form/widgets/CustomHtml";
7
+ import { SolidBooleanFieldCheckboxWidget } from "../components/core/form/fields/widgets/SolidBooleanCheckboxFieldWidget";
8
+ import { SolidBooleanFieldSelectWidget } from "../components/core/form/fields/widgets/SolidBooleanSelectFieldWidget";
9
+ import { SolidSelectionStaticAutocompleteWidget } from "../components/core/form/fields/widgets/SolidSelectionStaticAutocompleteFieldWidget";
10
+ import { SolidSelectionStaticRadioWidget } from "../components/core/form/fields/widgets/SolidSelectionStaticRadioFieldWidget";
2
11
  var extensionRegistry = {
3
12
  components: {},
4
13
  functions: {},
5
14
  };
6
- export var registerExtensionComponent = function (name, component) {
15
+ export var registerExtensionComponent = function (name, component, aliases) {
16
+ if (aliases === void 0) { aliases = []; }
7
17
  // console.log(`registerExtensionComponent invoked... ${name}`);
8
18
  extensionRegistry.components[name] = component;
19
+ for (var i = 0; i < aliases.length; i++) {
20
+ var alias = aliases[i];
21
+ extensionRegistry.components[alias] = component;
22
+ }
9
23
  };
10
24
  export var registerExtensionFunction = function (name, fn) {
11
25
  // console.log(`registerExtensionFunction invoked... ${name}`);
@@ -37,7 +51,18 @@ export var getExtensionFunction = function (name) {
37
51
  };
38
52
  // Register all the dynamic widget & functions from inside solid-core-ui
39
53
  // Common
40
- registerExtensionComponent("CustomHtml", CustomHtml);
54
+ registerExtensionComponent("CustomHtml", CustomHtml, []);
55
+ registerExtensionComponent("SolidRelationManyToManyCheckboxWidget", SolidRelationManyToManyCheckboxWidget, ["checkbox"]);
56
+ registerExtensionComponent("SolidRelationManyToManyAutocompleteWidget", SolidRelationManyToManyAutocompleteWidget, ["autocomplete"]);
57
+ registerExtensionComponent("SolidBooleanFieldCheckboxWidget", SolidBooleanFieldCheckboxWidget, ["field-checkbox"]);
58
+ registerExtensionComponent("SolidBooleanFieldSelectWidget", SolidBooleanFieldSelectWidget, ["field-selectbox"]);
59
+ registerExtensionComponent("SolidSelectionStaticAutocompleteWidget", SolidSelectionStaticAutocompleteWidget, ["field-autocomplete"]);
60
+ registerExtensionComponent("SolidSelectionStaticRadioWidget", SolidSelectionStaticRadioWidget, ["field-radio"]);
41
61
  // ModuleMetadata
42
62
  // ModelMetadata
63
+ // Email Template
64
+ registerExtensionFunction("emailFormTypeChangeHandler", hanldeEmailFormTypeChange);
65
+ registerExtensionFunction("emailFormTypeLoad", hanldeEmailFormTypeLoad);
66
+ // RoleMetadata
67
+ registerExtensionComponent("RolePermissionsManyToManyFieldWidget", RolePermissionsManyToManyFieldWidget, ["inputSwitch"]);
43
68
  //# sourceMappingURL=registry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/helpers/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2CAA2C,CAAC;AAQvE,IAAM,iBAAiB,GAAsB;IACzC,UAAU,EAAE,EAAE;IACd,SAAS,EAAE,EAAE;CAChB,CAAC;AAEF,MAAM,CAAC,IAAM,0BAA0B,GAAG,UAAC,IAAY,EAAE,SAAmC;IACxF,gEAAgE;IAChE,iBAAiB,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;AACnD,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,yBAAyB,GAAG,UAAC,IAAY,EAAE,EAA2B;IAC/E,+DAA+D;IAC/D,iBAAiB,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;AAC3C,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,qBAAqB,GAAG,UAAC,IAAY;IAC9C,IAAI,iBAAiB,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;QACpC,OAAO,iBAAiB,CAAC,UA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AE,qCAAqC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;AACzH,0BAA0B,CAAC,2CAA2C,EAAE,yCAAyC,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;AACrI,0BAA0B,CAAC,iCAAiC,EAAE,+BAA+B,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC;AACnH,0BAA0B,CAAC,+BAA+B,EAAE,6BAA6B,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC;AAChH,0BAA0B,CAAC,wCAAwC,EAAE,sCAAsC,EAAE,CAAC,oBAAoB,CAAC,CAAC,CAAC;AACrI,0BAA0B,CAAC,iCAAiC,EAAE,+BAA+B,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;AAGhH,iBAAiB;AAGjB,gBAAgB;AAGhB,iBAAiB;AACjB,yBAAyB,CAAC,4BAA4B,EAAE,yBAAyB,CAAC,CAAC;AACnF,yBAAyB,CAAC,mBAAmB,EAAE,uBAAuB,CAAC,CAAC;AAExE,eAAe;AACf,0BAA0B,CAAC,sCAAsC,EAAE,oCAAoC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidstarters/solid-core-ui",
3
- "version": "1.1.31",
3
+ "version": "1.1.33",
4
4
  "scripts": {
5
5
  "prebuild": "npm run copy-styles",
6
6
  "build": "tsc && tsc-alias",
@@ -0,0 +1,18 @@
1
+ import { SolidViewLayoutManager } from "@/components/core/common/SolidViewLayoutManager";
2
+
3
+ const hanldeEmailFormTypeChange = (event: any) => {
4
+
5
+ const { modifiedField, modifiedFieldValue, viewMetadata, } = event;
6
+ const layout = viewMetadata.layout;
7
+ if (modifiedField === 'type') {
8
+ const layoutManager = new SolidViewLayoutManager(layout);
9
+ const renderMode = modifiedFieldValue.value === 'text' ? 'longText' : 'richText';
10
+ layoutManager.updateNodeAttributes('body', { "renderMode": renderMode});
11
+ return {
12
+ layoutChanged: true,
13
+ dataChanged: false,
14
+ newLayout: layoutManager.getLayout(),
15
+ }
16
+ }
17
+ }
18
+ export default hanldeEmailFormTypeChange;
@@ -0,0 +1,18 @@
1
+ import { SolidViewLayoutManager } from "@/components/core/common/SolidViewLayoutManager";
2
+
3
+ const hanldeEmailFormTypeLoad = (event: any) => {
4
+
5
+ const { formData, type, viewMetadata } = event;
6
+ const layout = viewMetadata.layout;
7
+ if (formData?.type && type === 'onFormLayoutLoad') {
8
+ const layoutManager = new SolidViewLayoutManager(layout);
9
+ const renderMode = formData.type === 'text' ? 'longText' : 'richText';
10
+ layoutManager.updateNodeAttributes('body', { "renderMode": renderMode});
11
+ return {
12
+ layoutChanged: true,
13
+ dataChanged: false,
14
+ newLayout: layoutManager.getLayout(),
15
+ }
16
+ }
17
+ }
18
+ export default hanldeEmailFormTypeLoad;
@@ -0,0 +1,123 @@
1
+ "use client";
2
+ import { SolidRelationManyToManyFieldWidgetProps } from "@/types/solid-core";
3
+ import { capitalize } from "lodash";
4
+ import { Panel } from "primereact/panel";
5
+ import { useEffect, useState } from "react";
6
+ import { Button } from "primereact/button";
7
+ import { InputSwitch } from "primereact/inputswitch";
8
+ import { useRelationEntityHandler } from "@/components/core/form/fields/relations/widgets/helpers/useRelationEntityHandler";
9
+ import { InlineRelationEntityDialog } from "@/components/core/form/fields/relations/widgets/helpers/InlineRelationEntityDialog";
10
+ import { Checkbox } from "primereact/checkbox";
11
+
12
+ const groupByController = (items: any[]) => {
13
+ const grouped: { [key: string]: any[] } = {};
14
+ items.forEach((item) => {
15
+ const controllerName = item.label.split(".")[0];
16
+ if (!grouped[controllerName]) {
17
+ grouped[controllerName] = [];
18
+ }
19
+ grouped[controllerName].push(item);
20
+ });
21
+ return grouped;
22
+ };
23
+
24
+ export const RolePermissionsManyToManyFieldWidget = ({ formik, fieldContext }: SolidRelationManyToManyFieldWidgetProps) => {
25
+ const fieldLayoutInfo = fieldContext.field;
26
+
27
+ const readOnlyPermission = fieldContext.readOnly;
28
+ const [visibleCreateDialog, setVisibleCreateDialog] = useState(false);
29
+ const { autoCompleteItems, fetchRelationEntities, addNewRelation } = useRelationEntityHandler({ fieldContext, formik });
30
+ const [visibleDialogs, setVisibleDialogs] = useState<{ [key: string]: boolean }>({});
31
+
32
+ useEffect(() => {
33
+ fetchRelationEntities();
34
+ }, []);
35
+
36
+ const handleCheckboxChange = (e: any) => {
37
+ if (formik.values[fieldLayoutInfo.attrs.name].some((item: any) => item.value === e.value)) {
38
+ formik.setFieldValue(fieldLayoutInfo.attrs.name, formik.values[fieldLayoutInfo.attrs.name].filter((s: any) => s.value !== e.value));
39
+ } else {
40
+ formik.setFieldValue(fieldLayoutInfo.attrs.name, [...formik.values[fieldLayoutInfo.attrs.name], e]);
41
+ }
42
+ };
43
+
44
+ const getHeaderTemplate = (controllerName: string) => (options: any) => {
45
+ const className = `${options.className} justify-content-space-between`;
46
+
47
+ return (
48
+ <div className={className}>
49
+ <div className="flex align-items-center gap-3">
50
+ <label className="form-field-label text-lg font-bold">
51
+ {controllerName}
52
+ </label>
53
+ {fieldContext.field.attrs.inlineCreate && (
54
+ <>
55
+ <Button
56
+ icon="pi pi-plus"
57
+ rounded
58
+ outlined
59
+ aria-label="Add"
60
+ type="button"
61
+ size="small"
62
+ onClick={() =>
63
+ setVisibleDialogs((prev) => ({
64
+ ...prev,
65
+ [controllerName]: true,
66
+ }))
67
+ }
68
+ className="custom-add-button"
69
+ />
70
+ <InlineRelationEntityDialog
71
+ visible={visibleCreateDialog}
72
+ setVisible={setVisibleCreateDialog}
73
+ fieldContext={fieldContext}
74
+ onCreate={addNewRelation}
75
+ />
76
+ </>
77
+ )}
78
+ </div>
79
+ <div>{options.togglerElement}</div>
80
+ </div>
81
+ );
82
+ };
83
+
84
+ const groupedEntities = groupByController(autoCompleteItems || []);
85
+ return (
86
+ <div>
87
+ {Object.keys(groupedEntities).map((controllerName) => (
88
+ <Panel toggleable headerTemplate={getHeaderTemplate(controllerName)} key={controllerName} className="mt-4">
89
+ <div className="formgrid grid">
90
+ {groupedEntities[controllerName].map((entity: any, i: number) => {
91
+ const isChecked = formik.values[fieldLayoutInfo.attrs.name].some((item: any) => item.value === entity.value);
92
+ return (
93
+ <div key={entity.label} className={`field col-6 flex gap-2 ${i >= 2 ? 'mt-3' : ''}`}>
94
+ <Checkbox
95
+ readOnly={readOnlyPermission}
96
+ inputId={entity.label}
97
+ checked={isChecked}
98
+ onChange={() => handleCheckboxChange(entity)}
99
+ />
100
+ <label htmlFor={entity.label} className="form-field-label m-0"> {entity.label}</label>
101
+ </div>
102
+ )
103
+ })}
104
+ </div>
105
+ </Panel>
106
+ ))}
107
+ {Object.keys(groupedEntities).map((controllerName) => (
108
+ <InlineRelationEntityDialog
109
+ key={`dialog-${controllerName}`}
110
+ visible={visibleDialogs[controllerName] || false}
111
+ setVisible={(visible: any) =>
112
+ setVisibleDialogs((prev) => ({
113
+ ...prev,
114
+ [controllerName]: visible,
115
+ }))
116
+ }
117
+ fieldContext={fieldContext}
118
+ onCreate={addNewRelation}
119
+ />
120
+ ))}
121
+ </div>
122
+ )
123
+ };
@@ -37,7 +37,7 @@ import { OverlayPanel } from "primereact/overlaypanel";
37
37
  import { SolidBreadcrumb } from "@/components/common/SolidBreadcrumb";
38
38
  import { SolidUiEvent } from "@/types";
39
39
  import { getExtensionComponent, getExtensionFunction } from "@/helpers/registry";
40
- import { SolidFormWidgetProps } from "@/types/solid-core";
40
+ import { SolidFormWidgetProps, SolidLoadForm } from "@/types/solid-core";
41
41
  import { SolidPasswordField } from "./fields/SolidPasswordField";
42
42
  import { SolidEmailField } from "./fields/SolidEmailField";
43
43
  import { Panel } from "primereact/panel";
@@ -417,17 +417,6 @@ const SolidFormView = (params: SolidFormViewProps) => {
417
417
  isLoading: solidFormViewMetaDataIsLoading
418
418
  } = useGetSolidViewLayoutQuery(formViewMetaDataQs);
419
419
 
420
- useEffect(() => {
421
- if (solidFormViewMetaData) {
422
- setFormViewMetaData(solidFormViewMetaData);
423
- if (params.customLayout) {
424
- setFormViewLayout(params.customLayout);
425
- } else {
426
- setFormViewLayout(solidFormViewMetaData.data.solidView.layout);
427
- }
428
- }
429
- }, [solidFormViewMetaData]);
430
-
431
420
  useEffect(() => {
432
421
  if (
433
422
  isEntityCreateSuccess == true ||
@@ -579,11 +568,11 @@ const SolidFormView = (params: SolidFormViewProps) => {
579
568
 
580
569
  // errorFields.length = 0;
581
570
  };
582
- useEffect(() => {
583
- if (errorFields?.length > 0) {
584
- showFieldError();
585
- }
586
- }, [errorFields])
571
+ // useEffect(() => {
572
+ // if (errorFields?.length > 0) {
573
+ // showFieldError();
574
+ // }
575
+ // }, [errorFields])
587
576
 
588
577
  // - - - - - - - - - - - -- - - - - - - - - - - - DATA here
589
578
  // Fetch the actual data here.
@@ -625,11 +614,76 @@ const SolidFormView = (params: SolidFormViewProps) => {
625
614
  }
626
615
  }, [formViewDataQs])
627
616
 
628
-
629
617
  useEffect(() => {
630
- if (solidFormViewData) {
631
- setInitialEntityData(solidFormViewData.data);
618
+ if (solidFormViewMetaData) {
619
+ let formLayout = solidFormViewMetaData;
620
+ const dynamicHeader = solidFormViewMetaData?.data?.solidView?.layout?.onFormLayoutLoad;
621
+ let DynamicFunctionComponent = null;
622
+ const event: SolidLoadForm = {
623
+ fieldsMetadata: solidFormViewMetaData,
624
+ formData: solidFormViewData?.data,
625
+ type: dynamicHeader,
626
+ viewMetadata: solidFormViewMetaData?.data?.solidView
627
+ }
628
+ if (dynamicHeader) {
629
+ DynamicFunctionComponent = getExtensionFunction(dynamicHeader);
630
+ if (DynamicFunctionComponent) {
631
+ const updatedFormLayout = DynamicFunctionComponent(event);
632
+ if (updatedFormLayout && updatedFormLayout?.layoutChanged && updatedFormLayout?.newLayout) {
633
+ const newFormLayout = {
634
+ ...formLayout,
635
+ data : {
636
+ ...formLayout.data,
637
+ solidView: {
638
+ ...formLayout.data.solidView,
639
+ layout: updatedFormLayout.newLayout
640
+ }
641
+ }
642
+ };
643
+ formLayout = newFormLayout;
644
+ }
645
+ }
646
+ }
647
+ setFormViewMetaData(formLayout);
648
+ if (params.customLayout) {
649
+ setFormViewLayout(params.customLayout);
650
+ } else {
651
+ setFormViewLayout(formLayout.data.solidView.layout);
652
+ }
632
653
  }
654
+ }, [solidFormViewMetaData, solidFormViewData]);
655
+
656
+ useEffect(() => {
657
+ const handleDynamicFunction = async () => {
658
+ if (solidFormViewData) {
659
+ const dynamicHeader = solidFormViewMetaData?.data?.solidView?.layout?.onFormDataLoad;
660
+
661
+ let DynamicFunctionComponent = null;
662
+ let formViewData = solidFormViewData?.data;
663
+
664
+ const event: SolidLoadForm = {
665
+ fieldsMetadata: solidFormViewMetaData,
666
+ formData: solidFormViewData?.data,
667
+ type: dynamicHeader,
668
+ viewMetadata: solidFormViewMetaData?.data?.solidView
669
+ };
670
+
671
+ if (dynamicHeader) {
672
+ DynamicFunctionComponent = getExtensionFunction(dynamicHeader);
673
+
674
+ if (DynamicFunctionComponent) {
675
+ const updatedFormData = await DynamicFunctionComponent(event);
676
+
677
+ if (updatedFormData && updatedFormData?.dataChanged && updatedFormData?.newFormData) {
678
+ formViewData = updatedFormData.newFormData;
679
+ }
680
+ }
681
+ }
682
+ setInitialEntityData(formViewData);
683
+ }
684
+ };
685
+
686
+ handleDynamicFunction();
633
687
  }, [solidFormViewData]);
634
688
 
635
689
  let formik: FormikObject;
@@ -726,7 +780,7 @@ const SolidFormView = (params: SolidFormViewProps) => {
726
780
 
727
781
  // Invoke the dynamic change handler:
728
782
  // TODO: encapsulate in try/catch, catch the exception render in the UI as an error & stop form rendering.
729
- const updatedFormInfo = dynamicChangeHandler(event);
783
+ const updatedFormInfo = await dynamicChangeHandler(event);
730
784
  // console.log(`${eventType}: formFieldOnXXX response received: `, updatedFormInfo);
731
785
 
732
786
  // If dataChanged is true, update Formik values
@@ -6,6 +6,10 @@ import { useEffect } from "react";
6
6
  import * as Yup from 'yup';
7
7
  import { Schema } from "yup";
8
8
  import { FormikObject, ISolidField, SolidFieldProps } from "./ISolidField";
9
+ import { Panel } from "primereact/panel";
10
+ import { Checkbox, CheckboxChangeEvent } from "primereact/checkbox";
11
+ import { getExtensionComponent } from "@/helpers/registry";
12
+ import { SolidBooleanFieldWidgetProps } from "@/types/solid-core";
9
13
 
10
14
  export class SolidBooleanField implements ISolidField {
11
15
 
@@ -28,7 +32,13 @@ export class SolidBooleanField implements ISolidField {
28
32
 
29
33
  const existingValue = this.fieldContext.data[fieldName];
30
34
 
31
- return existingValue !== undefined && existingValue !== null ? existingValue : fieldDefaultValue || '';
35
+ // return existingValue !== undefined && existingValue !== null ? existingValue : fieldDefaultValue || '';
36
+
37
+ // Ensure the value is always a string "true" or "false"
38
+ const result = existingValue
39
+ ? (existingValue === true || existingValue === "true" ? "true" : "false")
40
+ : (fieldDefaultValue === true || fieldDefaultValue === "true" ? "true" : "false");
41
+ return result;
32
42
  }
33
43
 
34
44
  validationSchema(): Schema {
@@ -82,44 +92,42 @@ export class SolidBooleanField implements ISolidField {
82
92
  const formDisabled = solidFormViewMetaData.data.solidView?.layout?.attrs?.disabled;
83
93
  const formReadonly = solidFormViewMetaData.data.solidView?.layout?.attrs?.readonly;
84
94
 
95
+ let renderMode = fieldLayoutInfo.attrs.renderMode;
96
+ if (!renderMode) {
97
+ renderMode = 'field-selectbox';
98
+ }
85
99
  return (
86
- <div className={className}>
87
- <div className="relative">
88
- <div className="flex flex-column gap-2 mt-4">
89
- {showFieldLabel != false &&
90
- <label htmlFor={fieldLayoutInfo.attrs.name} className="form-field-label">{fieldLabel}
91
- {fieldMetadata.required && <span className="text-red-500"> *</span>}
92
- {/* &nbsp; {fieldDescription && <span className="form_field_help">({fieldDescription}) </span>} */}
93
- </label>
94
- }
95
- {/* <InputText
96
- id={fieldLayoutInfo.attrs.name}
97
- className="small-input"
98
- aria-describedby={`${fieldLayoutInfo.attrs.name}-help`}
99
- onChange={formik.handleChange}
100
- value={formik.values[fieldLayoutInfo.attrs.name] || ''}
101
- /> */}
102
- <SelectButton
103
- readOnly={formReadonly || fieldReadonly || readOnlyPermission}
104
- disabled={formDisabled || fieldDisabled}
105
- id={fieldLayoutInfo.attrs.name}
106
- aria-describedby={`${fieldLayoutInfo.attrs.name}-help`}
107
- onChange={(e) => formik.setFieldValue(fieldLayoutInfo.attrs.name, e.value)} // Custom handling for boolean input
108
- value={formik.values[fieldLayoutInfo.attrs.name] ? formik.values[fieldLayoutInfo.attrs.name].toString() : "false"}
109
- options={booleanOptions}
110
- className={classNames("", {
111
- "p-invalid": isFormFieldValid(formik, "defaultValue"),
112
- })}
113
-
114
- />
100
+ <>
101
+ {renderMode &&
102
+ this.renderExtensionRenderMode(renderMode, formik)
103
+ }
104
+ {isFormFieldValid(formik, fieldLayoutInfo.attrs.name) && (
105
+ <div className="absolute mt-1">
106
+ <Message severity="error" text={formik?.errors[fieldLayoutInfo.attrs.name]?.toString()} />
115
107
  </div>
116
- {isFormFieldValid(formik, fieldLayoutInfo.attrs.name) && (
117
- <div className="absolute mt-1">
118
- <Message severity="error" text={formik?.errors[fieldLayoutInfo.attrs.name]?.toString()} />
119
- </div>
120
- )}
121
- </div>
122
- </div>
108
+ )}
109
+ </>
123
110
  );
111
+
112
+
124
113
  }
114
+
115
+
116
+ renderExtensionRenderMode(widgetName: string, formik: FormikObject) {
117
+ let DynamicWidget = getExtensionComponent(widgetName);
118
+ if (!DynamicWidget) {
119
+ DynamicWidget = getExtensionComponent('field-selectbox');
120
+ }
121
+ const widgetProps: SolidBooleanFieldWidgetProps = {
122
+ formik: formik,
123
+ fieldContext: this.fieldContext,
124
+ }
125
+ return (
126
+ <>
127
+ {DynamicWidget && <DynamicWidget {...widgetProps} />}
128
+ </>
129
+ )
130
+ }
131
+
132
+
125
133
  }
@@ -4,6 +4,8 @@ import { Message } from "primereact/message";
4
4
  import * as Yup from 'yup';
5
5
  import { Schema } from "yup";
6
6
  import { FormikObject, ISolidField, SolidFieldProps } from "./ISolidField";
7
+ import { Editor } from "primereact/editor";
8
+ import { useState } from "react";
7
9
 
8
10
  export class SolidLongTextField implements ISolidField {
9
11
 
@@ -59,6 +61,64 @@ export class SolidLongTextField implements ISolidField {
59
61
  }
60
62
 
61
63
  render(formik: FormikObject) {
64
+ const fieldLayoutInfo = this.fieldContext.field;
65
+ const className = fieldLayoutInfo.attrs?.className || 'field col-12';
66
+ return (
67
+ <>
68
+ {(!fieldLayoutInfo.attrs.renderMode ||fieldLayoutInfo.attrs.renderMode === 'longText') &&
69
+ <div className={className}>
70
+ {this.renderLongText(formik)}
71
+ </div>
72
+ }
73
+ {fieldLayoutInfo.attrs.renderMode === 'richText' &&
74
+ <div className={className}>
75
+ {this.renderRichText(formik)}
76
+ </div>
77
+ }
78
+ </>
79
+ );
80
+ }
81
+
82
+ renderLongText(formik: FormikObject) {
83
+ const fieldMetadata = this.fieldContext.fieldMetadata;
84
+ const fieldLayoutInfo = this.fieldContext.field;
85
+ const className = fieldLayoutInfo.attrs?.className || 'field col-12';
86
+ const fieldLabel = fieldLayoutInfo.attrs.label ?? fieldMetadata.displayName;
87
+ const fieldDescription = fieldLayoutInfo.attrs.description ?? fieldMetadata.description;
88
+ const solidFormViewMetaData = this.fieldContext.solidFormViewMetaData;
89
+ const showFieldLabel = fieldLayoutInfo?.attrs?.showLabel;
90
+ const readOnlyPermission = this.fieldContext.readOnly;
91
+
92
+ const isFormFieldValid = (formik: any, fieldName: string) => formik.touched[fieldName] && formik.errors[fieldName];
93
+
94
+ const fieldDisabled = fieldLayoutInfo.attrs?.disabled;
95
+ const fieldReadonly = fieldLayoutInfo.attrs?.readonly;
96
+
97
+ const formDisabled = solidFormViewMetaData.data.solidView?.layout?.attrs?.disabled;
98
+ const formReadonly = solidFormViewMetaData.data.solidView?.layout?.attrs?.readonly;
99
+ return (
100
+ <div className="flex flex-column gap-2 mt-4">
101
+ {showFieldLabel != false &&
102
+ <label htmlFor={fieldLayoutInfo.attrs.name} className="form-field-label">{fieldLabel}
103
+ {fieldMetadata.required && <span className="text-red-500"> *</span>}
104
+ {/* &nbsp; {fieldDescription && <span>({fieldDescription}) </span>} */}
105
+ </label>
106
+ }
107
+ <InputTextarea
108
+ readOnly={formReadonly || fieldReadonly || readOnlyPermission}
109
+ disabled={formDisabled || fieldDisabled}
110
+ id={fieldLayoutInfo.attrs.name}
111
+ aria-describedby={`${fieldLayoutInfo.attrs.name}-help`}
112
+ onChange={formik.handleChange}
113
+ value={formik.values[fieldLayoutInfo.attrs.name] || ''}
114
+ rows={5}
115
+ cols={30}
116
+ />
117
+ </div>
118
+ )
119
+ }
120
+
121
+ renderRichText(formik: FormikObject) {
62
122
  const fieldMetadata = this.fieldContext.fieldMetadata;
63
123
  const fieldLayoutInfo = this.fieldContext.field;
64
124
  const className = fieldLayoutInfo.attrs?.className || 'field col-12';
@@ -68,6 +128,8 @@ export class SolidLongTextField implements ISolidField {
68
128
  const showFieldLabel = fieldLayoutInfo?.attrs?.showLabel;
69
129
  const readOnlyPermission = this.fieldContext.readOnly;
70
130
 
131
+ const [text, setText] = useState();
132
+
71
133
  const isFormFieldValid = (formik: any, fieldName: string) => formik.touched[fieldName] && formik.errors[fieldName];
72
134
 
73
135
  const fieldDisabled = fieldLayoutInfo.attrs?.disabled;
@@ -78,31 +140,28 @@ export class SolidLongTextField implements ISolidField {
78
140
 
79
141
  return (
80
142
  <div className={className}>
81
- <div className="relative">
82
- <div className="flex flex-column gap-2 mt-4">
83
- {showFieldLabel != false &&
84
- <label htmlFor={fieldLayoutInfo.attrs.name} className="form-field-label">{fieldLabel}
85
- {fieldMetadata.required && <span className="text-red-500"> *</span>}
86
- {/* &nbsp; {fieldDescription && <span>({fieldDescription}) </span>} */}
87
- </label>
88
- }
89
- <InputTextarea
90
- readOnly={formReadonly || fieldReadonly || readOnlyPermission}
91
- disabled={formDisabled || fieldDisabled}
92
- id={fieldLayoutInfo.attrs.name}
93
- aria-describedby={`${fieldLayoutInfo.attrs.name}-help`}
94
- onChange={formik.handleChange}
95
- value={formik.values[fieldLayoutInfo.attrs.name] || ''}
96
- rows={5}
97
- cols={30}
98
- />
99
- </div>
143
+ <div className="flex flex-column gap-2 mt-4">
144
+ {showFieldLabel != false &&
145
+ <label htmlFor={fieldLayoutInfo.attrs.name} className="form-field-label">{fieldLabel}
146
+ {fieldMetadata.required && <span className="text-red-500"> *</span>}
147
+ {/* &nbsp; {fieldDescription && <span className="form_field_help">({fieldDescription}) </span>} */}
148
+ </label>
149
+ }
150
+ <Editor
151
+ readOnly={formReadonly || fieldReadonly || readOnlyPermission}
152
+ disabled={formDisabled || fieldDisabled}
153
+ key={fieldLayoutInfo.attrs.name} // React will re-render the component whenever this value changes
154
+ id={fieldLayoutInfo.attrs.name}
155
+ value={formik.values[fieldLayoutInfo.attrs.name]}
156
+ onTextChange={e => formik.setFieldValue(fieldLayoutInfo.attrs.name, e.htmlValue)}
157
+ style={{ height: "320px" }}
158
+ />
159
+ </div>
100
160
  {isFormFieldValid(formik, fieldLayoutInfo.attrs.name) && (
101
161
  <div className="absolute mt-1">
102
162
  <Message severity="error" text={formik?.errors[fieldLayoutInfo.attrs.name]?.toString()} />
103
163
  </div>
104
164
  )}
105
- </div>
106
165
  </div>
107
166
  );
108
167
  }