@solidstarters/solid-core-ui 1.1.32 → 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 (40) hide show
  1. package/dist/components/core/form/SolidFormView.d.ts.map +1 -1
  2. package/dist/components/core/form/SolidFormView.js +51 -36
  3. package/dist/components/core/form/SolidFormView.js.map +1 -1
  4. package/dist/components/core/form/fields/SolidBooleanField.d.ts +1 -0
  5. package/dist/components/core/form/fields/SolidBooleanField.d.ts.map +1 -1
  6. package/dist/components/core/form/fields/SolidBooleanField.js +36 -8
  7. package/dist/components/core/form/fields/SolidBooleanField.js.map +1 -1
  8. package/dist/components/core/form/fields/SolidSelectionStaticField.d.ts +1 -0
  9. package/dist/components/core/form/fields/SolidSelectionStaticField.d.ts.map +1 -1
  10. package/dist/components/core/form/fields/SolidSelectionStaticField.js +19 -20
  11. package/dist/components/core/form/fields/SolidSelectionStaticField.js.map +1 -1
  12. package/dist/components/core/form/fields/widgets/SolidBooleanCheckboxFieldWidget.d.ts +3 -0
  13. package/dist/components/core/form/fields/widgets/SolidBooleanCheckboxFieldWidget.d.ts.map +1 -0
  14. package/dist/components/core/form/fields/widgets/SolidBooleanCheckboxFieldWidget.js +57 -0
  15. package/dist/components/core/form/fields/widgets/SolidBooleanCheckboxFieldWidget.js.map +1 -0
  16. package/dist/components/core/form/fields/widgets/SolidBooleanSelectFieldWidget.d.ts +3 -0
  17. package/dist/components/core/form/fields/widgets/SolidBooleanSelectFieldWidget.d.ts.map +1 -0
  18. package/dist/components/core/form/fields/widgets/SolidBooleanSelectFieldWidget.js +30 -0
  19. package/dist/components/core/form/fields/widgets/SolidBooleanSelectFieldWidget.js.map +1 -0
  20. package/dist/components/core/form/fields/widgets/SolidSelectionStaticAutocompleteFieldWidget.d.ts +3 -0
  21. package/dist/components/core/form/fields/widgets/SolidSelectionStaticAutocompleteFieldWidget.d.ts.map +1 -0
  22. package/dist/components/core/form/fields/widgets/SolidSelectionStaticAutocompleteFieldWidget.js +50 -0
  23. package/dist/components/core/form/fields/widgets/SolidSelectionStaticAutocompleteFieldWidget.js.map +1 -0
  24. package/dist/components/core/form/fields/widgets/SolidSelectionStaticRadioFieldWidget.d.ts +3 -0
  25. package/dist/components/core/form/fields/widgets/SolidSelectionStaticRadioFieldWidget.d.ts.map +1 -0
  26. package/dist/components/core/form/fields/widgets/SolidSelectionStaticRadioFieldWidget.js +32 -0
  27. package/dist/components/core/form/fields/widgets/SolidSelectionStaticRadioFieldWidget.js.map +1 -0
  28. package/dist/helpers/registry.d.ts.map +1 -1
  29. package/dist/helpers/registry.js +8 -0
  30. package/dist/helpers/registry.js.map +1 -1
  31. package/package.json +1 -1
  32. package/src/components/core/form/SolidFormView.tsx +29 -19
  33. package/src/components/core/form/fields/SolidBooleanField.tsx +45 -37
  34. package/src/components/core/form/fields/SolidSelectionStaticField.tsx +33 -46
  35. package/src/components/core/form/fields/widgets/SolidBooleanCheckboxFieldWidget.tsx +79 -0
  36. package/src/components/core/form/fields/widgets/SolidBooleanSelectFieldWidget.tsx +68 -0
  37. package/src/components/core/form/fields/widgets/SolidSelectionStaticAutocompleteFieldWidget.tsx +72 -0
  38. package/src/components/core/form/fields/widgets/SolidSelectionStaticRadioFieldWidget.tsx +71 -0
  39. package/src/helpers/registry.ts +8 -0
  40. package/src/types/solid-core.d.ts +9 -0
@@ -0,0 +1,68 @@
1
+ "use client";
2
+ import { SolidBooleanFieldWidgetProps } from "@/types/solid-core";
3
+ import { useEffect, useState } from "react";
4
+ import { Message } from "primereact/message";
5
+ import { classNames } from "primereact/utils";
6
+ import { SelectButton } from "primereact/selectbutton";
7
+
8
+ export const SolidBooleanFieldSelectWidget = ({ formik, fieldContext }: SolidBooleanFieldWidgetProps) => {
9
+ const fieldMetadata = fieldContext.fieldMetadata;
10
+ const fieldLayoutInfo = fieldContext.field;
11
+ const className = fieldLayoutInfo.attrs?.className || 'field col-12';
12
+ const fieldLabel = fieldLayoutInfo.attrs.label ?? fieldMetadata.displayName;
13
+ const fieldDescription = fieldLayoutInfo.attrs.description ?? fieldMetadata.description;
14
+ const booleanOptions = ["false", "true"];
15
+ const solidFormViewMetaData = fieldContext.solidFormViewMetaData;
16
+ const showFieldLabel = fieldLayoutInfo?.attrs?.showLabel;
17
+ const readOnlyPermission = fieldContext.readOnly;
18
+
19
+ useEffect(() => { formik.setFieldValue(fieldLayoutInfo.attrs.name, "false") }, [])
20
+
21
+ const isFormFieldValid = (formik: any, fieldName: string) => formik.touched[fieldName] && formik.errors[fieldName];
22
+
23
+ const fieldDisabled = fieldLayoutInfo.attrs?.disabled;
24
+ const fieldReadonly = fieldLayoutInfo.attrs?.readonly;
25
+
26
+ const formDisabled = solidFormViewMetaData.data.solidView?.layout?.attrs?.disabled;
27
+ const formReadonly = solidFormViewMetaData.data.solidView?.layout?.attrs?.readonly;
28
+
29
+ return (
30
+ <div className={className}>
31
+ <div className="relative">
32
+ <div className="flex flex-column gap-2 mt-4">
33
+ {showFieldLabel != false &&
34
+ <label htmlFor={fieldLayoutInfo.attrs.name} className="form-field-label">{fieldLabel}
35
+ {fieldMetadata.required && <span className="text-red-500"> *</span>}
36
+ {/* &nbsp; {fieldDescription && <span className="form_field_help">({fieldDescription}) </span>} */}
37
+ </label>
38
+ }
39
+ {/* <InputText
40
+ id={fieldLayoutInfo.attrs.name}
41
+ className="small-input"
42
+ aria-describedby={`${fieldLayoutInfo.attrs.name}-help`}
43
+ onChange={formik.handleChange}
44
+ value={formik.values[fieldLayoutInfo.attrs.name] || ''}
45
+ /> */}
46
+ <SelectButton
47
+ readOnly={formReadonly || fieldReadonly || readOnlyPermission}
48
+ disabled={formDisabled || fieldDisabled}
49
+ id={fieldLayoutInfo.attrs.name}
50
+ aria-describedby={`${fieldLayoutInfo.attrs.name}-help`}
51
+ onChange={(e) => {formik.setFieldValue(fieldLayoutInfo.attrs.name, e.value); console.log("value is",e.value)}} // Custom handling for boolean input
52
+ value={formik.values[fieldLayoutInfo.attrs.name] ? formik.values[fieldLayoutInfo.attrs.name].toString() : "false"}
53
+ options={booleanOptions}
54
+ className={classNames("", {
55
+ "p-invalid": isFormFieldValid(formik, "defaultValue"),
56
+ })}
57
+
58
+ />
59
+ </div>
60
+ {isFormFieldValid(formik, fieldLayoutInfo.attrs.name) && (
61
+ <div className="absolute mt-1">
62
+ <Message severity="error" text={formik?.errors[fieldLayoutInfo.attrs.name]?.toString()} />
63
+ </div>
64
+ )}
65
+ </div>
66
+ </div>
67
+ );
68
+ }
@@ -0,0 +1,72 @@
1
+ "use client";
2
+ import { SolidSelectionStaticFieldWidgetProps } from "@/types/solid-core";
3
+ import { useEffect, useState } from "react";
4
+ import { Message } from "primereact/message";
5
+ import { classNames } from "primereact/utils";
6
+ import { SelectButton } from "primereact/selectbutton";
7
+ import { AutoComplete, AutoCompleteCompleteEvent } from "primereact/autocomplete";
8
+
9
+ export const SolidSelectionStaticAutocompleteWidget = ({ formik, fieldContext }: SolidSelectionStaticFieldWidgetProps) => {
10
+ const fieldMetadata = fieldContext.fieldMetadata;
11
+ const fieldLayoutInfo = fieldContext.field;
12
+ const className = fieldLayoutInfo.attrs?.className || 'field col-12';
13
+ const fieldLabel = fieldLayoutInfo.attrs.label ?? fieldMetadata.displayName;
14
+ const fieldDescription = fieldLayoutInfo.attrs.description ?? fieldMetadata.description;
15
+ const solidFormViewMetaData = fieldContext.solidFormViewMetaData;
16
+ const showFieldLabel = fieldLayoutInfo?.attrs?.showLabel;
17
+ const readOnlyPermission = fieldContext.readOnly;
18
+ const fieldDisabled = fieldLayoutInfo.attrs?.disabled;
19
+ const fieldReadonly = fieldLayoutInfo.attrs?.readonly;
20
+
21
+ const formDisabled = solidFormViewMetaData.data.solidView?.layout?.attrs?.disabled;
22
+ const formReadonly = solidFormViewMetaData.data.solidView?.layout?.attrs?.readonly;
23
+
24
+ const [selectionStaticItems, setSelectionStaticItems] = useState([]);
25
+ const selectionStaticSearch = (event: AutoCompleteCompleteEvent) => {
26
+ const selectionStaticData = fieldMetadata.selectionStaticValues.map((i: string) => {
27
+ return {
28
+ label: i.split(":")[1],
29
+ value: i.split(":")[0]
30
+ }
31
+ });
32
+ const suggestionData = selectionStaticData.filter((t: any) => t.value.toLowerCase().startsWith(event.query.toLowerCase()));
33
+ setSelectionStaticItems(suggestionData)
34
+ }
35
+ const isFormFieldValid = (formik: any, fieldName: string) => formik.touched[fieldName] && formik.errors[fieldName];
36
+
37
+ return (
38
+ <div className={className}>
39
+ <div className="relative">
40
+ <div className="flex flex-column gap-2 mt-4">
41
+ {showFieldLabel != false &&
42
+ <label htmlFor={fieldLayoutInfo.attrs.name} className="form-field-label">{fieldLabel}
43
+ {fieldMetadata.required && <span className="text-red-500"> *</span>}
44
+ {/* &nbsp; {fieldDescription && <span className="form_field_help">({fieldDescription}) </span>} */}
45
+ </label>
46
+ }
47
+ <AutoComplete
48
+ readOnly={formReadonly || fieldReadonly || readOnlyPermission}
49
+ disabled={formDisabled || fieldDisabled}
50
+ {...formik.getFieldProps(fieldLayoutInfo.attrs.name)}
51
+ id={fieldLayoutInfo.attrs.name}
52
+ name={fieldLayoutInfo.attrs.name}
53
+ field="label"
54
+ value={formik.values[fieldLayoutInfo.attrs.name] || ''}
55
+ dropdown
56
+ suggestions={selectionStaticItems}
57
+ completeMethod={selectionStaticSearch}
58
+ // onChange={(e) => updateInputs(index, e.value)} />
59
+ // onChange={formik.handleChange}
60
+ onChange={(e) => fieldContext.onChange(e, 'onFieldChange')}
61
+ className="solid-standard-autocomplete"
62
+ />
63
+ </div>
64
+ {isFormFieldValid(formik, fieldLayoutInfo.attrs.name) && (
65
+ <div className="absolute mt-1">
66
+ <Message severity="error" text={formik?.errors[fieldLayoutInfo.attrs.name]?.toString()} />
67
+ </div>
68
+ )}
69
+ </div>
70
+ </div>
71
+ );
72
+ }
@@ -0,0 +1,71 @@
1
+ "use client";
2
+ import { SolidSelectionStaticFieldWidgetProps } from "@/types/solid-core";
3
+ import { useEffect, useState } from "react";
4
+ import { Message } from "primereact/message";
5
+ import { classNames } from "primereact/utils";
6
+ import { SelectButton } from "primereact/selectbutton";
7
+ import { AutoComplete, AutoCompleteCompleteEvent } from "primereact/autocomplete";
8
+ import { RadioButton } from "primereact/radiobutton";
9
+
10
+ export const SolidSelectionStaticRadioWidget = ({ formik, fieldContext }: SolidSelectionStaticFieldWidgetProps) => {
11
+ const fieldMetadata = fieldContext.fieldMetadata;
12
+ const fieldLayoutInfo = fieldContext.field;
13
+ const className = fieldLayoutInfo.attrs?.className || 'field col-12';
14
+ const fieldLabel = fieldLayoutInfo.attrs.label ?? fieldMetadata.displayName;
15
+ const showFieldLabel = fieldLayoutInfo?.attrs?.showLabel;
16
+ const readOnlyPermission = fieldContext.readOnly;
17
+
18
+ const fieldDisabled = fieldLayoutInfo.attrs?.disabled;
19
+ const fieldReadonly = fieldLayoutInfo.attrs?.readonly;
20
+ const formDisabled = fieldContext.solidFormViewMetaData.data.solidView?.layout?.attrs?.disabled;
21
+ const formReadonly = fieldContext.solidFormViewMetaData.data.solidView?.layout?.attrs?.readonly;
22
+
23
+ const fieldName = fieldLayoutInfo.attrs.name;
24
+
25
+ // Convert selectionStaticValues to usable radio options
26
+ const radioOptions = fieldMetadata.selectionStaticValues.map((i: string) => {
27
+ const [value, label] = i.split(":");
28
+ return { label, value };
29
+ });
30
+
31
+ const isFormFieldValid = (formik: any, fieldName: string) =>
32
+ formik.touched[fieldName] && formik.errors[fieldName];
33
+
34
+ return (
35
+ <div className={className}>
36
+ <div className="relative">
37
+ <div className="flex flex-column gap-2 mt-4">
38
+ {showFieldLabel !== false && (
39
+ <label htmlFor={fieldName} className="form-field-label">
40
+ {fieldLabel}
41
+ {fieldMetadata.required && <span className="text-red-500"> *</span>}
42
+ </label>
43
+ )}
44
+ <div className="flex flex-wrap gap-3">
45
+ {radioOptions.map((option: any) => (
46
+ <div key={option.value} className="flex items-center">
47
+ <RadioButton
48
+ id={`${fieldName}-${option.value}`}
49
+ name={fieldName}
50
+ value={option}
51
+ checked={formik.values[fieldName]?.value === option.value}
52
+ onChange={(e) => formik.setFieldValue(fieldName, e.value)}
53
+ disabled={formReadonly || fieldReadonly || readOnlyPermission || formDisabled || fieldDisabled}
54
+ className="mr-2"
55
+ />
56
+ <label htmlFor={`${fieldName}-${option.value}`} className="cursor-pointer">
57
+ {option.label}
58
+ </label>
59
+ </div>
60
+ ))}
61
+ </div>
62
+ </div>
63
+ {isFormFieldValid(formik, fieldName) && (
64
+ <div className="absolute mt-1">
65
+ <Message severity="error" text={formik?.errors[fieldName]?.toString()} />
66
+ </div>
67
+ )}
68
+ </div>
69
+ </div>
70
+ );
71
+ }
@@ -5,6 +5,10 @@ import { SolidRelationManyToManyAutocompleteWidget } from "@/components/core/for
5
5
  import { SolidRelationManyToManyCheckboxWidget } from "@/components/core/form/fields/relations/widgets/SolidRelationManyToManyCheckboxWidget";
6
6
  import { CustomHtml } from "@/components/core/form/widgets/CustomHtml";
7
7
  import React from "react";
8
+ import { SolidBooleanFieldCheckboxWidget } from "@/components/core/form/fields/widgets/SolidBooleanCheckboxFieldWidget";
9
+ import { SolidBooleanFieldSelectWidget } from "@/components/core/form/fields/widgets/SolidBooleanSelectFieldWidget";
10
+ import { SolidSelectionStaticAutocompleteWidget } from "@/components/core/form/fields/widgets/SolidSelectionStaticAutocompleteFieldWidget";
11
+ import { SolidSelectionStaticRadioWidget } from "@/components/core/form/fields/widgets/SolidSelectionStaticRadioFieldWidget";
8
12
 
9
13
  type ExtensionRegistry = {
10
14
  components: Record<string, React.ComponentType<any>>;
@@ -67,6 +71,10 @@ export const getExtensionFunction = (name: string) => {
67
71
  registerExtensionComponent("CustomHtml", CustomHtml, []);
68
72
  registerExtensionComponent("SolidRelationManyToManyCheckboxWidget", SolidRelationManyToManyCheckboxWidget, ["checkbox"]);
69
73
  registerExtensionComponent("SolidRelationManyToManyAutocompleteWidget", SolidRelationManyToManyAutocompleteWidget, ["autocomplete"]);
74
+ registerExtensionComponent("SolidBooleanFieldCheckboxWidget", SolidBooleanFieldCheckboxWidget, ["field-checkbox"]);
75
+ registerExtensionComponent("SolidBooleanFieldSelectWidget", SolidBooleanFieldSelectWidget, ["field-selectbox"]);
76
+ registerExtensionComponent("SolidSelectionStaticAutocompleteWidget", SolidSelectionStaticAutocompleteWidget, ["field-autocomplete"]);
77
+ registerExtensionComponent("SolidSelectionStaticRadioWidget", SolidSelectionStaticRadioWidget, ["field-radio"]);
70
78
 
71
79
 
72
80
  // ModuleMetadata
@@ -109,3 +109,12 @@ export type SolidRelationManyToManyFieldWidgetProps = {
109
109
  formik: any;
110
110
  fieldContext?: SolidFieldProps;
111
111
  };
112
+
113
+ export type SolidBooleanFieldWidgetProps = {
114
+ formik: any;
115
+ fieldContext?: SolidFieldProps;
116
+ };
117
+ export type SolidSelectionStaticFieldWidgetProps = {
118
+ formik: any;
119
+ fieldContext?: SolidFieldProps;
120
+ };