@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.
- package/dist/components/core/form/SolidFormView.d.ts.map +1 -1
- package/dist/components/core/form/SolidFormView.js +51 -36
- package/dist/components/core/form/SolidFormView.js.map +1 -1
- package/dist/components/core/form/fields/SolidBooleanField.d.ts +1 -0
- package/dist/components/core/form/fields/SolidBooleanField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidBooleanField.js +36 -8
- package/dist/components/core/form/fields/SolidBooleanField.js.map +1 -1
- package/dist/components/core/form/fields/SolidSelectionStaticField.d.ts +1 -0
- package/dist/components/core/form/fields/SolidSelectionStaticField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidSelectionStaticField.js +19 -20
- package/dist/components/core/form/fields/SolidSelectionStaticField.js.map +1 -1
- package/dist/components/core/form/fields/widgets/SolidBooleanCheckboxFieldWidget.d.ts +3 -0
- package/dist/components/core/form/fields/widgets/SolidBooleanCheckboxFieldWidget.d.ts.map +1 -0
- package/dist/components/core/form/fields/widgets/SolidBooleanCheckboxFieldWidget.js +57 -0
- package/dist/components/core/form/fields/widgets/SolidBooleanCheckboxFieldWidget.js.map +1 -0
- package/dist/components/core/form/fields/widgets/SolidBooleanSelectFieldWidget.d.ts +3 -0
- package/dist/components/core/form/fields/widgets/SolidBooleanSelectFieldWidget.d.ts.map +1 -0
- package/dist/components/core/form/fields/widgets/SolidBooleanSelectFieldWidget.js +30 -0
- package/dist/components/core/form/fields/widgets/SolidBooleanSelectFieldWidget.js.map +1 -0
- package/dist/components/core/form/fields/widgets/SolidSelectionStaticAutocompleteFieldWidget.d.ts +3 -0
- package/dist/components/core/form/fields/widgets/SolidSelectionStaticAutocompleteFieldWidget.d.ts.map +1 -0
- package/dist/components/core/form/fields/widgets/SolidSelectionStaticAutocompleteFieldWidget.js +50 -0
- package/dist/components/core/form/fields/widgets/SolidSelectionStaticAutocompleteFieldWidget.js.map +1 -0
- package/dist/components/core/form/fields/widgets/SolidSelectionStaticRadioFieldWidget.d.ts +3 -0
- package/dist/components/core/form/fields/widgets/SolidSelectionStaticRadioFieldWidget.d.ts.map +1 -0
- package/dist/components/core/form/fields/widgets/SolidSelectionStaticRadioFieldWidget.js +32 -0
- package/dist/components/core/form/fields/widgets/SolidSelectionStaticRadioFieldWidget.js.map +1 -0
- package/dist/helpers/registry.d.ts.map +1 -1
- package/dist/helpers/registry.js +8 -0
- package/dist/helpers/registry.js.map +1 -1
- package/package.json +1 -1
- package/src/components/core/form/SolidFormView.tsx +29 -19
- package/src/components/core/form/fields/SolidBooleanField.tsx +45 -37
- package/src/components/core/form/fields/SolidSelectionStaticField.tsx +33 -46
- package/src/components/core/form/fields/widgets/SolidBooleanCheckboxFieldWidget.tsx +79 -0
- package/src/components/core/form/fields/widgets/SolidBooleanSelectFieldWidget.tsx +68 -0
- package/src/components/core/form/fields/widgets/SolidSelectionStaticAutocompleteFieldWidget.tsx +72 -0
- package/src/components/core/form/fields/widgets/SolidSelectionStaticRadioFieldWidget.tsx +71 -0
- package/src/helpers/registry.ts +8 -0
- package/src/types/solid-core.d.ts +9 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect } from "react";
|
|
4
|
+
import { Message } from "primereact/message";
|
|
5
|
+
import { classNames } from "primereact/utils";
|
|
6
|
+
import { SelectButton } from "primereact/selectbutton";
|
|
7
|
+
export var SolidBooleanFieldSelectWidget = function (_a) {
|
|
8
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
9
|
+
var formik = _a.formik, fieldContext = _a.fieldContext;
|
|
10
|
+
var fieldMetadata = fieldContext.fieldMetadata;
|
|
11
|
+
var fieldLayoutInfo = fieldContext.field;
|
|
12
|
+
var className = ((_b = fieldLayoutInfo.attrs) === null || _b === void 0 ? void 0 : _b.className) || 'field col-12';
|
|
13
|
+
var fieldLabel = (_c = fieldLayoutInfo.attrs.label) !== null && _c !== void 0 ? _c : fieldMetadata.displayName;
|
|
14
|
+
var fieldDescription = (_d = fieldLayoutInfo.attrs.description) !== null && _d !== void 0 ? _d : fieldMetadata.description;
|
|
15
|
+
var booleanOptions = ["false", "true"];
|
|
16
|
+
var solidFormViewMetaData = fieldContext.solidFormViewMetaData;
|
|
17
|
+
var showFieldLabel = (_e = fieldLayoutInfo === null || fieldLayoutInfo === void 0 ? void 0 : fieldLayoutInfo.attrs) === null || _e === void 0 ? void 0 : _e.showLabel;
|
|
18
|
+
var readOnlyPermission = fieldContext.readOnly;
|
|
19
|
+
useEffect(function () { formik.setFieldValue(fieldLayoutInfo.attrs.name, "false"); }, []);
|
|
20
|
+
var isFormFieldValid = function (formik, fieldName) { return formik.touched[fieldName] && formik.errors[fieldName]; };
|
|
21
|
+
var fieldDisabled = (_f = fieldLayoutInfo.attrs) === null || _f === void 0 ? void 0 : _f.disabled;
|
|
22
|
+
var fieldReadonly = (_g = fieldLayoutInfo.attrs) === null || _g === void 0 ? void 0 : _g.readonly;
|
|
23
|
+
var formDisabled = (_k = (_j = (_h = solidFormViewMetaData.data.solidView) === null || _h === void 0 ? void 0 : _h.layout) === null || _j === void 0 ? void 0 : _j.attrs) === null || _k === void 0 ? void 0 : _k.disabled;
|
|
24
|
+
var formReadonly = (_o = (_m = (_l = solidFormViewMetaData.data.solidView) === null || _l === void 0 ? void 0 : _l.layout) === null || _m === void 0 ? void 0 : _m.attrs) === null || _o === void 0 ? void 0 : _o.readonly;
|
|
25
|
+
return (_jsx("div", { className: className, children: _jsxs("div", { className: "relative", children: [_jsxs("div", { className: "flex flex-column gap-2 mt-4", children: [showFieldLabel != false &&
|
|
26
|
+
_jsxs("label", { htmlFor: fieldLayoutInfo.attrs.name, className: "form-field-label", children: [fieldLabel, fieldMetadata.required && _jsx("span", { className: "text-red-500", children: " *" })] }), _jsx(SelectButton, { readOnly: formReadonly || fieldReadonly || readOnlyPermission, disabled: formDisabled || fieldDisabled, id: fieldLayoutInfo.attrs.name, "aria-describedby": "".concat(fieldLayoutInfo.attrs.name, "-help"), onChange: function (e) { formik.setFieldValue(fieldLayoutInfo.attrs.name, e.value); console.log("value is", e.value); }, value: formik.values[fieldLayoutInfo.attrs.name] ? formik.values[fieldLayoutInfo.attrs.name].toString() : "false", options: booleanOptions, className: classNames("", {
|
|
27
|
+
"p-invalid": isFormFieldValid(formik, "defaultValue"),
|
|
28
|
+
}) })] }), isFormFieldValid(formik, fieldLayoutInfo.attrs.name) && (_jsx("div", { className: "absolute mt-1", children: _jsx(Message, { severity: "error", text: (_p = formik === null || formik === void 0 ? void 0 : formik.errors[fieldLayoutInfo.attrs.name]) === null || _p === void 0 ? void 0 : _p.toString() }) }))] }) }));
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=SolidBooleanSelectFieldWidget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SolidBooleanSelectFieldWidget.js","sourceRoot":"","sources":["../../../../../../src/components/core/form/fields/widgets/SolidBooleanSelectFieldWidget.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,MAAM,CAAC,IAAM,6BAA6B,GAAG,UAAC,EAAsD;;QAApD,MAAM,YAAA,EAAE,YAAY,kBAAA;IAChE,IAAM,aAAa,GAAG,YAAY,CAAC,aAAa,CAAC;IACjD,IAAM,eAAe,GAAG,YAAY,CAAC,KAAK,CAAC;IAC3C,IAAM,SAAS,GAAG,CAAA,MAAA,eAAe,CAAC,KAAK,0CAAE,SAAS,KAAI,cAAc,CAA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EAAE,GAAI,GACxF,CACT,IACC,GACJ,CACT,CAAC;AACN,CAAC,CAAA"}
|
package/dist/components/core/form/fields/widgets/SolidSelectionStaticAutocompleteFieldWidget.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { SolidSelectionStaticFieldWidgetProps } from "@/types/solid-core";
|
|
2
|
+
export declare const SolidSelectionStaticAutocompleteWidget: ({ formik, fieldContext }: SolidSelectionStaticFieldWidgetProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
//# sourceMappingURL=SolidSelectionStaticAutocompleteFieldWidget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SolidSelectionStaticAutocompleteFieldWidget.d.ts","sourceRoot":"","sources":["../../../../../../src/components/core/form/fields/widgets/SolidSelectionStaticAutocompleteFieldWidget.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,oCAAoC,EAAE,MAAM,oBAAoB,CAAC;AAO1E,eAAO,MAAM,sCAAsC,6BAA8B,oCAAoC,4CA+DpH,CAAA"}
|
package/dist/components/core/form/fields/widgets/SolidSelectionStaticAutocompleteFieldWidget.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { useState } from "react";
|
|
15
|
+
import { Message } from "primereact/message";
|
|
16
|
+
import { AutoComplete } from "primereact/autocomplete";
|
|
17
|
+
export var SolidSelectionStaticAutocompleteWidget = function (_a) {
|
|
18
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
19
|
+
var formik = _a.formik, fieldContext = _a.fieldContext;
|
|
20
|
+
var fieldMetadata = fieldContext.fieldMetadata;
|
|
21
|
+
var fieldLayoutInfo = fieldContext.field;
|
|
22
|
+
var className = ((_b = fieldLayoutInfo.attrs) === null || _b === void 0 ? void 0 : _b.className) || 'field col-12';
|
|
23
|
+
var fieldLabel = (_c = fieldLayoutInfo.attrs.label) !== null && _c !== void 0 ? _c : fieldMetadata.displayName;
|
|
24
|
+
var fieldDescription = (_d = fieldLayoutInfo.attrs.description) !== null && _d !== void 0 ? _d : fieldMetadata.description;
|
|
25
|
+
var solidFormViewMetaData = fieldContext.solidFormViewMetaData;
|
|
26
|
+
var showFieldLabel = (_e = fieldLayoutInfo === null || fieldLayoutInfo === void 0 ? void 0 : fieldLayoutInfo.attrs) === null || _e === void 0 ? void 0 : _e.showLabel;
|
|
27
|
+
var readOnlyPermission = fieldContext.readOnly;
|
|
28
|
+
var fieldDisabled = (_f = fieldLayoutInfo.attrs) === null || _f === void 0 ? void 0 : _f.disabled;
|
|
29
|
+
var fieldReadonly = (_g = fieldLayoutInfo.attrs) === null || _g === void 0 ? void 0 : _g.readonly;
|
|
30
|
+
var formDisabled = (_k = (_j = (_h = solidFormViewMetaData.data.solidView) === null || _h === void 0 ? void 0 : _h.layout) === null || _j === void 0 ? void 0 : _j.attrs) === null || _k === void 0 ? void 0 : _k.disabled;
|
|
31
|
+
var formReadonly = (_o = (_m = (_l = solidFormViewMetaData.data.solidView) === null || _l === void 0 ? void 0 : _l.layout) === null || _m === void 0 ? void 0 : _m.attrs) === null || _o === void 0 ? void 0 : _o.readonly;
|
|
32
|
+
var _q = useState([]), selectionStaticItems = _q[0], setSelectionStaticItems = _q[1];
|
|
33
|
+
var selectionStaticSearch = function (event) {
|
|
34
|
+
var selectionStaticData = fieldMetadata.selectionStaticValues.map(function (i) {
|
|
35
|
+
return {
|
|
36
|
+
label: i.split(":")[1],
|
|
37
|
+
value: i.split(":")[0]
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
var suggestionData = selectionStaticData.filter(function (t) { return t.value.toLowerCase().startsWith(event.query.toLowerCase()); });
|
|
41
|
+
setSelectionStaticItems(suggestionData);
|
|
42
|
+
};
|
|
43
|
+
var isFormFieldValid = function (formik, fieldName) { return formik.touched[fieldName] && formik.errors[fieldName]; };
|
|
44
|
+
return (_jsx("div", { className: className, children: _jsxs("div", { className: "relative", children: [_jsxs("div", { className: "flex flex-column gap-2 mt-4", children: [showFieldLabel != false &&
|
|
45
|
+
_jsxs("label", { htmlFor: fieldLayoutInfo.attrs.name, className: "form-field-label", children: [fieldLabel, fieldMetadata.required && _jsx("span", { className: "text-red-500", children: " *" })] }), _jsx(AutoComplete, __assign({ readOnly: formReadonly || fieldReadonly || readOnlyPermission, disabled: formDisabled || fieldDisabled }, formik.getFieldProps(fieldLayoutInfo.attrs.name), { id: fieldLayoutInfo.attrs.name, name: fieldLayoutInfo.attrs.name, field: "label", value: formik.values[fieldLayoutInfo.attrs.name] || '', dropdown: true, suggestions: selectionStaticItems, completeMethod: selectionStaticSearch,
|
|
46
|
+
// onChange={(e) => updateInputs(index, e.value)} />
|
|
47
|
+
// onChange={formik.handleChange}
|
|
48
|
+
onChange: function (e) { return fieldContext.onChange(e, 'onFieldChange'); }, className: "solid-standard-autocomplete" }))] }), isFormFieldValid(formik, fieldLayoutInfo.attrs.name) && (_jsx("div", { className: "absolute mt-1", children: _jsx(Message, { severity: "error", text: (_p = formik === null || formik === void 0 ? void 0 : formik.errors[fieldLayoutInfo.attrs.name]) === null || _p === void 0 ? void 0 : _p.toString() }) }))] }) }));
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=SolidSelectionStaticAutocompleteFieldWidget.js.map
|
package/dist/components/core/form/fields/widgets/SolidSelectionStaticAutocompleteFieldWidget.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SolidSelectionStaticAutocompleteFieldWidget.js","sourceRoot":"","sources":["../../../../../../src/components/core/form/fields/widgets/SolidSelectionStaticAutocompleteFieldWidget.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;AAEb,OAAO,EAAa,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAG7C,OAAO,EAAE,YAAY,EAA6B,MAAM,yBAAyB,CAAC;AAElF,MAAM,CAAC,IAAM,sCAAsC,GAAG,UAAC,EAA8D;;QAA5D,MAAM,YAAA,EAAE,YAAY,kBAAA;IACzE,IAAM,aAAa,GAAG,YAAY,CAAC,aAAa,CAAC;IACjD,IAAM,eAAe,GAAG,YAAY,CAAC,KAAK,CAAC;IAC3C,IAAM,SAAS,GAAG,CAAA,MAAA,eAAe,CAAC,KAAK,0CAAE,SAAS,KAAI,cAAc,CAAC;IACrE,IAAM,UAAU,GAAG,MAAA,eAAe,CAAC,KAAK,CAAC,KAAK,mCAAI,aAAa,CAAC,WAAW,CAAC;IAC5E,IAAM,gBAAgB,GAAG,MAAA,eAAe,CAAC,KAAK,CAAC,WAAW,mCAAI,aAAa,CAAC,WAAW,CAAC;IACxF,IAAM,qBAAqB,GAAG,YAAY,CAAC,qBAAqB,CAAC;IACjE,IAAM,cAAc,GAAG,MAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,KAAK,0CAAE,SAAS,CAAC;IACzD,IAAM,kBAAkB,GAAG,YAAY,CAAC,QAAQ,CAAC;IACjD,IAAM,aAAa,GAAG,MAAA,eAAe,CAAC,KAAK,0CAAE,QAAQ,CAAC;IACtD,IAAM,aAAa,GAAG,MAAA,eAAe,CAAC,KAAK,0CAAE,QAAQ,CAAC;IAEtD,IAAM,YAAY,GAAG,MAAA,MAAA,MAAA,qBAAqB,CAAC,IAAI,CAAC,SAAS,0CAAE,MAAM,0CAAE,KAAK,0CAAE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cAAc,mBAAU,IAE/D,EAEZ,KAAC,YAAY,aACT,QAAQ,EAAE,YAAY,IAAI,aAAa,IAAI,kBAAkB,EAC7D,QAAQ,EAAE,YAAY,IAAI,aAAa,IACnC,MAAM,CAAC,aAAa,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,IACpD,EAAE,EAAE,eAAe,CAAC,KAAK,CAAC,IAAI,EAC9B,IAAI,EAAE,eAAe,CAAC,KAAK,CAAC,IAAI,EAChC,KAAK,EAAC,OAAO,EACb,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,EACtD,QAAQ,QACR,WAAW,EAAE,oBAAoB,EACjC,cAAc,EAAE,qBAAqB;4BACrC,oDAAoD;4BACpD,iCAAiC;4BACjC,QAAQ,EAAE,UAAC,CAAC,IAAK,OAAA,YAAY,CAAC,QAAQ,CAAC,CAAC,EAAE,eAAe,CAAC,EAAzC,CAAyC,EAC1D,SAAS,EAAC,6BAA6B,IACzC,IACA,EACL,gBAAgB,CAAC,MAAM,EAAE,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CACrD,cAAK,SAAS,EAAC,eAAe,YAC1B,KAAC,OAAO,IAAC,QAAQ,EAAC,OAAO,EAAC,IAAI,EAAE,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,0CAAE,QAAQ,EAAE,GAAI,GACxF,CACT,IACC,GACJ,CACT,CAAC;AACN,CAAC,CAAA"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { SolidSelectionStaticFieldWidgetProps } from "@/types/solid-core";
|
|
2
|
+
export declare const SolidSelectionStaticRadioWidget: ({ formik, fieldContext }: SolidSelectionStaticFieldWidgetProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
//# sourceMappingURL=SolidSelectionStaticRadioFieldWidget.d.ts.map
|
package/dist/components/core/form/fields/widgets/SolidSelectionStaticRadioFieldWidget.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SolidSelectionStaticRadioFieldWidget.d.ts","sourceRoot":"","sources":["../../../../../../src/components/core/form/fields/widgets/SolidSelectionStaticRadioFieldWidget.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,oCAAoC,EAAE,MAAM,oBAAoB,CAAC;AAQ1E,eAAO,MAAM,+BAA+B,6BAA8B,oCAAoC,4CA6D7G,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Message } from "primereact/message";
|
|
4
|
+
import { RadioButton } from "primereact/radiobutton";
|
|
5
|
+
export var SolidSelectionStaticRadioWidget = function (_a) {
|
|
6
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
7
|
+
var formik = _a.formik, fieldContext = _a.fieldContext;
|
|
8
|
+
var fieldMetadata = fieldContext.fieldMetadata;
|
|
9
|
+
var fieldLayoutInfo = fieldContext.field;
|
|
10
|
+
var className = ((_b = fieldLayoutInfo.attrs) === null || _b === void 0 ? void 0 : _b.className) || 'field col-12';
|
|
11
|
+
var fieldLabel = (_c = fieldLayoutInfo.attrs.label) !== null && _c !== void 0 ? _c : fieldMetadata.displayName;
|
|
12
|
+
var showFieldLabel = (_d = fieldLayoutInfo === null || fieldLayoutInfo === void 0 ? void 0 : fieldLayoutInfo.attrs) === null || _d === void 0 ? void 0 : _d.showLabel;
|
|
13
|
+
var readOnlyPermission = fieldContext.readOnly;
|
|
14
|
+
var fieldDisabled = (_e = fieldLayoutInfo.attrs) === null || _e === void 0 ? void 0 : _e.disabled;
|
|
15
|
+
var fieldReadonly = (_f = fieldLayoutInfo.attrs) === null || _f === void 0 ? void 0 : _f.readonly;
|
|
16
|
+
var formDisabled = (_j = (_h = (_g = fieldContext.solidFormViewMetaData.data.solidView) === null || _g === void 0 ? void 0 : _g.layout) === null || _h === void 0 ? void 0 : _h.attrs) === null || _j === void 0 ? void 0 : _j.disabled;
|
|
17
|
+
var formReadonly = (_m = (_l = (_k = fieldContext.solidFormViewMetaData.data.solidView) === null || _k === void 0 ? void 0 : _k.layout) === null || _l === void 0 ? void 0 : _l.attrs) === null || _m === void 0 ? void 0 : _m.readonly;
|
|
18
|
+
var fieldName = fieldLayoutInfo.attrs.name;
|
|
19
|
+
// Convert selectionStaticValues to usable radio options
|
|
20
|
+
var radioOptions = fieldMetadata.selectionStaticValues.map(function (i) {
|
|
21
|
+
var _a = i.split(":"), value = _a[0], label = _a[1];
|
|
22
|
+
return { label: label, value: value };
|
|
23
|
+
});
|
|
24
|
+
var isFormFieldValid = function (formik, fieldName) {
|
|
25
|
+
return formik.touched[fieldName] && formik.errors[fieldName];
|
|
26
|
+
};
|
|
27
|
+
return (_jsx("div", { className: className, children: _jsxs("div", { className: "relative", children: [_jsxs("div", { className: "flex flex-column gap-2 mt-4", children: [showFieldLabel !== false && (_jsxs("label", { htmlFor: fieldName, className: "form-field-label", children: [fieldLabel, fieldMetadata.required && _jsx("span", { className: "text-red-500", children: " *" })] })), _jsx("div", { className: "flex flex-wrap gap-3", children: radioOptions.map(function (option) {
|
|
28
|
+
var _a;
|
|
29
|
+
return (_jsxs("div", { className: "flex items-center", children: [_jsx(RadioButton, { id: "".concat(fieldName, "-").concat(option.value), name: fieldName, value: option, checked: ((_a = formik.values[fieldName]) === null || _a === void 0 ? void 0 : _a.value) === option.value, onChange: function (e) { return formik.setFieldValue(fieldName, e.value); }, disabled: formReadonly || fieldReadonly || readOnlyPermission || formDisabled || fieldDisabled, className: "mr-2" }), _jsx("label", { htmlFor: "".concat(fieldName, "-").concat(option.value), className: "cursor-pointer", children: option.label })] }, option.value));
|
|
30
|
+
}) })] }), isFormFieldValid(formik, fieldName) && (_jsx("div", { className: "absolute mt-1", children: _jsx(Message, { severity: "error", text: (_o = formik === null || formik === void 0 ? void 0 : formik.errors[fieldName]) === null || _o === void 0 ? void 0 : _o.toString() }) }))] }) }));
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=SolidSelectionStaticRadioFieldWidget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SolidSelectionStaticRadioFieldWidget.js","sourceRoot":"","sources":["../../../../../../src/components/core/form/fields/widgets/SolidSelectionStaticRadioFieldWidget.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAI7C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,MAAM,CAAC,IAAM,+BAA+B,GAAG,UAAC,EAA8D;;QAA5D,MAAM,YAAA,EAAE,YAAY,kBAAA;IAClE,IAAM,aAAa,GAAG,YAAY,CAAC,aAAa,CAAC;IACjD,IAAM,eAAe,GAAG,YAAY,CAAC,KAAK,CAAC;IAC3C,IAAM,SAAS,GAAG,CAAA,MAAA,eAAe,CAAC,KAAK,0CAAE,SAAS,KAAI,cAAc,CAAC;IACrE,IAAM,UAAU,GAAG,MAAA,eAAe,CAAC,KAAK,CAAC,KAAK,mCAAI,aAAa,CAAC,WAAW,CAAC;IAC5E,IAAM,cAAc,GAAG,MAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,KAAK,0CAAE,SAAS,CAAC;IACzD,IAAM,kBAAkB,GAAG,YAAY,CAAC,QAAQ,CAAC;IAEjD,IAAM,aAAa,GAAG,MAAA,eAAe,CAAC,KAAK,0CAAE,QAAQ,CAAC;IACtD,IAAM,aAAa,GAAG,MAAA,eAAe,CAAC,KAAK,0CAAE,QAAQ,CAAC;IACtD,IAAM,YAAY,GAAG,MAAA,MAAA,MAAA,YAAY,CAAC,qBAAqB,CAAC,IAAI,CAAC,SAAS,0CAAE,MAAM,0CAAE,KAAK,0CAAE,QAAQ,CAAC;IAChG,IAAM,YAAY,GAAG,M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K,EACzD,QAAQ,EAAE,UAAC,CAAC,IAAK,OAAA,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,EAAxC,CAAwC,EACzD,QAAQ,EAAE,YAAY,IAAI,aAAa,IAAI,kBAAkB,IAAI,YAAY,IAAI,aAAa,EAC9F,SAAS,EAAC,MAAM,GAClB,EACF,gBAAO,OAAO,EAAE,UAAG,SAAS,cAAI,MAAM,CAAC,KAAK,CAAE,EAAE,SAAS,EAAC,gBAAgB,YACrE,MAAM,CAAC,KAAK,GACT,KAZF,MAAM,CAAC,KAAK,CAahB,CACT,CAAA;6BAAA,CAAC,GACI,IACJ,EACL,gBAAgB,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI,CACpC,cAAK,SAAS,EAAC,eAAe,YAC1B,KAAC,OAAO,IAAC,QAAQ,EAAC,OAAO,EAAC,IAAI,EAAE,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,CAAC,SAAS,CAAC,0CAAE,QAAQ,EAAE,GAAI,GACvE,CACT,IACC,GACJ,CACT,CAAC;AACN,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/helpers/registry.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/helpers/registry.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,MAAM,OAAO,CAAC;AAgB1B,eAAO,MAAM,0BAA0B,SAAU,MAAM,aAAa,MAAM,aAAa,CAAC,GAAG,CAAC,YAAW,MAAM,EAAE,SAO9G,CAAC;AAEF,eAAO,MAAM,yBAAyB,SAAU,MAAM,gBAAgB,GAAG,EAAE,KAAK,GAAG,SAGlF,CAAC;AAEF,eAAO,MAAM,qBAAqB,SAAU,MAAM,KAAG,MAAM,aAAa,CAAC,GAAG,CAAC,GAAG,IAwB/E,CAAC;AAEF,eAAO,MAAM,oBAAoB,SAAU,MAAM,eAhDT,GAAG,EAAE,KAAK,GAmDjD,CAAC"}
|
package/dist/helpers/registry.js
CHANGED
|
@@ -4,6 +4,10 @@ import { RolePermissionsManyToManyFieldWidget } from "../components/core/extensi
|
|
|
4
4
|
import { SolidRelationManyToManyAutocompleteWidget } from "../components/core/form/fields/relations/widgets/SolidRelationManyToManyAutocompleteWidget";
|
|
5
5
|
import { SolidRelationManyToManyCheckboxWidget } from "../components/core/form/fields/relations/widgets/SolidRelationManyToManyCheckboxWidget";
|
|
6
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";
|
|
7
11
|
var extensionRegistry = {
|
|
8
12
|
components: {},
|
|
9
13
|
functions: {},
|
|
@@ -50,6 +54,10 @@ export var getExtensionFunction = function (name) {
|
|
|
50
54
|
registerExtensionComponent("CustomHtml", CustomHtml, []);
|
|
51
55
|
registerExtensionComponent("SolidRelationManyToManyCheckboxWidget", SolidRelationManyToManyCheckboxWidget, ["checkbox"]);
|
|
52
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"]);
|
|
53
61
|
// ModuleMetadata
|
|
54
62
|
// ModelMetadata
|
|
55
63
|
// Email Template
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/helpers/registry.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,MAAM,iFAAiF,CAAC;AACxH,OAAO,uBAAuB,MAAM,wEAAwE,CAAC;AAC7G,OAAO,EAAE,oCAAoC,EAAE,MAAM,0FAA0F,CAAC;AAChJ,OAAO,EAAE,yCAAyC,EAAE,MAAM,2FAA2F,CAAC;AACtJ,OAAO,EAAE,qCAAqC,EAAE,MAAM,uFAAuF,CAAC;AAC9I,OAAO,EAAE,UAAU,EAAE,MAAM,2CAA2C,CAAC;
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/helpers/registry.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,MAAM,iFAAiF,CAAC;AACxH,OAAO,uBAAuB,MAAM,wEAAwE,CAAC;AAC7G,OAAO,EAAE,oCAAoC,EAAE,MAAM,0FAA0F,CAAC;AAChJ,OAAO,EAAE,yCAAyC,EAAE,MAAM,2FAA2F,CAAC;AACtJ,OAAO,EAAE,qCAAqC,EAAE,MAAM,uFAAuF,CAAC;AAC9I,OAAO,EAAE,UAAU,EAAE,MAAM,2CAA2C,CAAC;AAEvE,OAAO,EAAE,+BAA+B,EAAE,MAAM,uEAAuE,CAAC;AACxH,OAAO,EAAE,6BAA6B,EAAE,MAAM,qEAAqE,CAAC;AACpH,OAAO,EAAE,sCAAsC,EAAE,MAAM,mFAAmF,CAAC;AAC3I,OAAO,EAAE,+BAA+B,EAAE,MAAM,4EAA4E,CAAC;AAO7H,IAAM,iBAAiB,GAAsB;IAC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BAA0B,CAAC,YAAY,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC;AACzD,0BAA0B,CAAC,uCAAuC,EAAE,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
|
@@ -654,26 +654,36 @@ const SolidFormView = (params: SolidFormViewProps) => {
|
|
|
654
654
|
}, [solidFormViewMetaData, solidFormViewData]);
|
|
655
655
|
|
|
656
656
|
useEffect(() => {
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
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
|
+
}
|
|
673
681
|
}
|
|
682
|
+
setInitialEntityData(formViewData);
|
|
674
683
|
}
|
|
675
|
-
|
|
676
|
-
|
|
684
|
+
};
|
|
685
|
+
|
|
686
|
+
handleDynamicFunction();
|
|
677
687
|
}, [solidFormViewData]);
|
|
678
688
|
|
|
679
689
|
let formik: FormikObject;
|
|
@@ -770,7 +780,7 @@ const SolidFormView = (params: SolidFormViewProps) => {
|
|
|
770
780
|
|
|
771
781
|
// Invoke the dynamic change handler:
|
|
772
782
|
// TODO: encapsulate in try/catch, catch the exception render in the UI as an error & stop form rendering.
|
|
773
|
-
const updatedFormInfo = dynamicChangeHandler(event);
|
|
783
|
+
const updatedFormInfo = await dynamicChangeHandler(event);
|
|
774
784
|
// console.log(`${eventType}: formFieldOnXXX response received: `, updatedFormInfo);
|
|
775
785
|
|
|
776
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
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
117
|
-
|
|
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
|
}
|
|
@@ -5,6 +5,8 @@ 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";
|
|
9
|
+
import { SolidSelectionStaticFieldWidgetProps } from "@/types/solid-core";
|
|
8
10
|
|
|
9
11
|
export class SolidSelectionStaticField implements ISolidField {
|
|
10
12
|
|
|
@@ -84,54 +86,39 @@ export class SolidSelectionStaticField implements ISolidField {
|
|
|
84
86
|
|
|
85
87
|
const formDisabled = solidFormViewMetaData.data.solidView?.layout?.attrs?.disabled;
|
|
86
88
|
const formReadonly = solidFormViewMetaData.data.solidView?.layout?.attrs?.readonly;
|
|
87
|
-
|
|
88
|
-
const [selectionStaticItems, setSelectionStaticItems] = useState([]);
|
|
89
|
-
const selectionStaticSearch = (event: AutoCompleteCompleteEvent) => {
|
|
90
|
-
const selectionStaticData = fieldMetadata.selectionStaticValues.map((i: string) => {
|
|
91
|
-
return {
|
|
92
|
-
label: i.split(":")[1],
|
|
93
|
-
value: i.split(":")[0]
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
const suggestionData = selectionStaticData.filter((t: any) => t.value.toLowerCase().startsWith(event.query.toLowerCase()));
|
|
97
|
-
setSelectionStaticItems(suggestionData)
|
|
98
|
-
}
|
|
99
89
|
const isFormFieldValid = (formik: any, fieldName: string) => formik.touched[fieldName] && formik.errors[fieldName];
|
|
100
|
-
|
|
90
|
+
let renderMode = fieldLayoutInfo.attrs.renderMode;
|
|
91
|
+
if (!renderMode) {
|
|
92
|
+
renderMode = 'field-autocomplete';
|
|
93
|
+
}
|
|
101
94
|
return (
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
</label>
|
|
110
|
-
}
|
|
111
|
-
<AutoComplete
|
|
112
|
-
readOnly={formReadonly || fieldReadonly || readOnlyPermission}
|
|
113
|
-
disabled={formDisabled || fieldDisabled}
|
|
114
|
-
{...formik.getFieldProps(fieldLayoutInfo.attrs.name)}
|
|
115
|
-
id={fieldLayoutInfo.attrs.name}
|
|
116
|
-
name={fieldLayoutInfo.attrs.name}
|
|
117
|
-
field="label"
|
|
118
|
-
value={formik.values[fieldLayoutInfo.attrs.name] || ''}
|
|
119
|
-
dropdown
|
|
120
|
-
suggestions={selectionStaticItems}
|
|
121
|
-
completeMethod={selectionStaticSearch}
|
|
122
|
-
// onChange={(e) => updateInputs(index, e.value)} />
|
|
123
|
-
// onChange={formik.handleChange}
|
|
124
|
-
onChange={(e) => this.fieldContext.onChange(e, 'onFieldChange')}
|
|
125
|
-
className="solid-standard-autocomplete"
|
|
126
|
-
/>
|
|
95
|
+
<>
|
|
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()} />
|
|
127
102
|
</div>
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
<Message severity="error" text={formik?.errors[fieldLayoutInfo.attrs.name]?.toString()} />
|
|
131
|
-
</div>
|
|
132
|
-
)}
|
|
133
|
-
</div>
|
|
134
|
-
</div>
|
|
103
|
+
)}
|
|
104
|
+
</>
|
|
135
105
|
);
|
|
136
106
|
}
|
|
137
|
-
|
|
107
|
+
|
|
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
|
+
)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { SolidBooleanFieldWidgetProps } from "@/types/solid-core";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { Checkbox, CheckboxChangeEvent } from "primereact/checkbox";
|
|
5
|
+
import { Message } from "primereact/message";
|
|
6
|
+
import { classNames } from "primereact/utils";
|
|
7
|
+
|
|
8
|
+
export const SolidBooleanFieldCheckboxWidget = ({ 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 solidFormViewMetaData = fieldContext.solidFormViewMetaData;
|
|
14
|
+
const showFieldLabel = fieldLayoutInfo?.attrs?.showLabel;
|
|
15
|
+
const readOnlyPermission = fieldContext.readOnly;
|
|
16
|
+
|
|
17
|
+
// Set default value to false on mount
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (formik.values[fieldLayoutInfo.attrs.name] === undefined) {
|
|
20
|
+
console.log("Setting default value:", false);
|
|
21
|
+
formik.setFieldValue(fieldLayoutInfo.attrs.name, false);
|
|
22
|
+
}
|
|
23
|
+
}, []);
|
|
24
|
+
|
|
25
|
+
const handleChange = (e: CheckboxChangeEvent) => {
|
|
26
|
+
const newValue = e.checked; // This returns `true` or `false`
|
|
27
|
+
console.log(`${fieldLayoutInfo.attrs.name}, new value:`, newValue);
|
|
28
|
+
|
|
29
|
+
formik.setFieldValue(fieldLayoutInfo.attrs.name, newValue === true ? 'true' : 'false');
|
|
30
|
+
formik.setTouched({ ...formik.touched, [fieldLayoutInfo.attrs.name]: true }); // Ensure Formik registers the change
|
|
31
|
+
// ✅ Check if Formik updated the value correctly
|
|
32
|
+
setTimeout(() => {
|
|
33
|
+
console.log("Formik values after update:", formik.values);
|
|
34
|
+
}, 0);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const isFormFieldValid = (formik:any, fieldName:any) =>
|
|
38
|
+
formik.touched[fieldName] && formik.errors[fieldName];
|
|
39
|
+
|
|
40
|
+
const fieldDisabled = fieldLayoutInfo.attrs?.disabled;
|
|
41
|
+
const fieldReadonly = fieldLayoutInfo.attrs?.readonly;
|
|
42
|
+
const formDisabled = solidFormViewMetaData.data.solidView?.layout?.attrs?.disabled;
|
|
43
|
+
const formReadonly = solidFormViewMetaData.data.solidView?.layout?.attrs?.readonly;
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<div className={className}>
|
|
47
|
+
<div className="relative">
|
|
48
|
+
<div className="flex flex-column gap-2 mt-4">
|
|
49
|
+
{showFieldLabel !== false && (
|
|
50
|
+
<label htmlFor={fieldLayoutInfo.attrs.name} className="form-field-label">
|
|
51
|
+
{fieldLabel}
|
|
52
|
+
{fieldMetadata.required && <span className="text-red-500"> *</span>}
|
|
53
|
+
</label>
|
|
54
|
+
)}
|
|
55
|
+
|
|
56
|
+
<div className="flex align-items-center">
|
|
57
|
+
<Checkbox
|
|
58
|
+
id={fieldLayoutInfo.attrs.name}
|
|
59
|
+
checked={formik.values[fieldLayoutInfo.attrs.name] === 'true' || formik.initialValues[fieldLayoutInfo.attrs.name] === 'true'}
|
|
60
|
+
onChange={handleChange}
|
|
61
|
+
disabled={formDisabled || fieldDisabled}
|
|
62
|
+
readOnly={formReadonly || fieldReadonly || readOnlyPermission}
|
|
63
|
+
className={classNames("", {
|
|
64
|
+
"p-invalid": isFormFieldValid(formik, fieldLayoutInfo.attrs.name),
|
|
65
|
+
})}
|
|
66
|
+
/>
|
|
67
|
+
<span className="ml-2">{fieldLabel || "Yes"}</span>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
{isFormFieldValid(formik, fieldLayoutInfo.attrs.name) && (
|
|
72
|
+
<div className="absolute mt-1">
|
|
73
|
+
<Message severity="error" text={formik.errors[fieldLayoutInfo.attrs.name]?.toString()} />
|
|
74
|
+
</div>
|
|
75
|
+
)}
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
);
|
|
79
|
+
}
|