react-form-builder-more-flexibility 1.0.46 → 1.0.48
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/1.app.js +1 -1
- package/dist/app.js +6 -6
- package/lib/form-elements/component-label.js +3 -0
- package/lib/form-elements/index.js +17 -7
- package/lib/form-elements-edit.js +1 -1
- package/lib/form.js +25 -2
- package/lib/index.js +10 -1
- package/package.json +1 -1
|
@@ -13,7 +13,10 @@ var ComponentLabel = function ComponentLabel(props) {
|
|
|
13
13
|
if (!labelText || !labelText.trim()) {
|
|
14
14
|
return null;
|
|
15
15
|
}
|
|
16
|
+
var hasPopUp = !!props.data.hasPopUp;
|
|
16
17
|
return /*#__PURE__*/_react["default"].createElement("label", {
|
|
18
|
+
onClick: hasPopUp ? props.passUpClick : undefined // Pass the function reference instead of invoking it
|
|
19
|
+
,
|
|
17
20
|
className: props.className || 'form-label',
|
|
18
21
|
style: {
|
|
19
22
|
marginTop: '0.5rem'
|
|
@@ -599,15 +599,23 @@ var Checkbox = /*#__PURE__*/function (_React$Component14) {
|
|
|
599
599
|
var _this11;
|
|
600
600
|
(0, _classCallCheck2["default"])(this, Checkbox);
|
|
601
601
|
_this11 = _super14.call(this, props);
|
|
602
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this11), "clickDetected", function () {
|
|
603
|
+
if (_this11.props.onCheckboxClick) {
|
|
604
|
+
_this11.props.onCheckboxClick(_this11.props.data); // Pass the field name or data to the parent component
|
|
605
|
+
}
|
|
606
|
+
});
|
|
607
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this11), "handleLabelClick", function (event) {
|
|
608
|
+
event.preventDefault();
|
|
609
|
+
if (_this11.props.data && _this11.props.data.hasPopUp) {
|
|
610
|
+
_this11.clickDetected();
|
|
611
|
+
}
|
|
612
|
+
});
|
|
602
613
|
_this11.inputField = /*#__PURE__*/_react["default"].createRef();
|
|
603
614
|
return _this11;
|
|
604
615
|
}
|
|
605
616
|
(0, _createClass2["default"])(Checkbox, [{
|
|
606
617
|
key: "render",
|
|
607
618
|
value: function render() {
|
|
608
|
-
var classNames = 'custom-control custom-checkbox';
|
|
609
|
-
// if (this.props.data.inline) { classNames += ' option-inline'; }
|
|
610
|
-
|
|
611
619
|
var baseClasses = 'SortableItem rfb-item';
|
|
612
620
|
if (this.props.data.pageBreakBefore) {
|
|
613
621
|
baseClasses += ' alwaysbreak';
|
|
@@ -629,14 +637,16 @@ var Checkbox = /*#__PURE__*/function (_React$Component14) {
|
|
|
629
637
|
}, /*#__PURE__*/_react["default"].createElement(_componentHeader["default"], this.props), /*#__PURE__*/_react["default"].createElement("div", {
|
|
630
638
|
className: "form-group"
|
|
631
639
|
}, /*#__PURE__*/_react["default"].createElement(_componentLabel["default"], (0, _extends2["default"])({
|
|
640
|
+
passUpClick: this.clickDetected,
|
|
632
641
|
className: "form-label"
|
|
633
642
|
}, this.props)), /*#__PURE__*/_react["default"].createElement("div", {
|
|
634
|
-
className:
|
|
643
|
+
className: "form-check form-check-inline"
|
|
635
644
|
}, /*#__PURE__*/_react["default"].createElement("input", (0, _extends2["default"])({
|
|
636
|
-
|
|
637
|
-
|
|
645
|
+
className: "form-check-input",
|
|
646
|
+
id: this.props.data.field_name
|
|
638
647
|
}, props)), /*#__PURE__*/_react["default"].createElement("label", {
|
|
639
|
-
className: "
|
|
648
|
+
className: "form-check-label",
|
|
649
|
+
onClick: this.handleLabelClick,
|
|
640
650
|
htmlFor: this.props.data.field_name,
|
|
641
651
|
dangerouslySetInnerHTML: {
|
|
642
652
|
__html: this.props.data.boxLabel
|
|
@@ -327,7 +327,7 @@ var FormElementsEdit = exports["default"] = /*#__PURE__*/function (_React$Compon
|
|
|
327
327
|
className: "form-group"
|
|
328
328
|
}, /*#__PURE__*/_react["default"].createElement("label", {
|
|
329
329
|
className: "control-label"
|
|
330
|
-
}, "Pop Up
|
|
330
|
+
}, "Pop Up:"), /*#__PURE__*/_react["default"].createElement(_reactDraftWysiwyg.Editor, {
|
|
331
331
|
toolbar: toolbar,
|
|
332
332
|
defaultEditorState: thirdEditorState,
|
|
333
333
|
onBlur: this.updateElement.bind(this),
|
package/lib/form.js
CHANGED
|
@@ -370,6 +370,23 @@ var ReactForm = /*#__PURE__*/function (_React$Component) {
|
|
|
370
370
|
return x.id === id;
|
|
371
371
|
});
|
|
372
372
|
}
|
|
373
|
+
|
|
374
|
+
// getInputElement(item) {
|
|
375
|
+
// if (item.custom) {
|
|
376
|
+
// return this.getCustomElement(item);
|
|
377
|
+
// }
|
|
378
|
+
// console.log("FORM: ", item);
|
|
379
|
+
// const Input = FormElements[item.element];
|
|
380
|
+
// return (<Input
|
|
381
|
+
// handleChange={this.handleChange}
|
|
382
|
+
// ref={c => this.inputs[item.field_name] = c}
|
|
383
|
+
// mutable={true}
|
|
384
|
+
// key={`form_${item.id}`}
|
|
385
|
+
// data={item}
|
|
386
|
+
// read_only={this.props.read_only}
|
|
387
|
+
// hide_required_alert={this.props.hide_required_alert}
|
|
388
|
+
// defaultValue={this._getDefaultValue(item)} />);
|
|
389
|
+
// }
|
|
373
390
|
}, {
|
|
374
391
|
key: "getInputElement",
|
|
375
392
|
value: function getInputElement(item) {
|
|
@@ -378,7 +395,7 @@ var ReactForm = /*#__PURE__*/function (_React$Component) {
|
|
|
378
395
|
return this.getCustomElement(item);
|
|
379
396
|
}
|
|
380
397
|
var Input = _formElements["default"][item.element];
|
|
381
|
-
|
|
398
|
+
var props = {
|
|
382
399
|
handleChange: this.handleChange,
|
|
383
400
|
ref: function ref(c) {
|
|
384
401
|
return _this5.inputs[item.field_name] = c;
|
|
@@ -389,7 +406,13 @@ var ReactForm = /*#__PURE__*/function (_React$Component) {
|
|
|
389
406
|
read_only: this.props.read_only,
|
|
390
407
|
hide_required_alert: this.props.hide_required_alert,
|
|
391
408
|
defaultValue: this._getDefaultValue(item)
|
|
392
|
-
}
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
// Check if the element is a Checkbox and pass the event handler
|
|
412
|
+
if (item.element === 'Checkbox') {
|
|
413
|
+
props.onCheckboxClick = this.props.onCheckboxClick;
|
|
414
|
+
}
|
|
415
|
+
return /*#__PURE__*/_react["default"].createElement(Input, props);
|
|
393
416
|
}
|
|
394
417
|
}, {
|
|
395
418
|
key: "getContainerElement",
|
package/lib/index.js
CHANGED
|
@@ -126,10 +126,19 @@ var ReactFormBuilder = exports.ReactFormBuilder = /*#__PURE__*/function (_React$
|
|
|
126
126
|
function ReactFormGenerator(props) {
|
|
127
127
|
var language = props.locale ? props.locale : 'en';
|
|
128
128
|
var currentAppLocale = _languageProvider["default"][language];
|
|
129
|
+
var handleCheckboxClick = function handleCheckboxClick(fieldName, isChecked) {
|
|
130
|
+
console.log("Checkbox clicked: ".concat(fieldName, ", Checked: ").concat(isChecked));
|
|
131
|
+
// Handle the checkbox click event here or pass it up to a parent
|
|
132
|
+
if (props.onCheckboxClick) {
|
|
133
|
+
props.onCheckboxClick(fieldName, isChecked);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
129
136
|
return /*#__PURE__*/_react["default"].createElement(_reactIntl.IntlProvider, {
|
|
130
137
|
locale: currentAppLocale.locale,
|
|
131
138
|
messages: currentAppLocale.messages
|
|
132
|
-
}, /*#__PURE__*/_react["default"].createElement(_form["default"], props
|
|
139
|
+
}, /*#__PURE__*/_react["default"].createElement(_form["default"], (0, _extends2["default"])({}, props, {
|
|
140
|
+
onCheckboxClick: handleCheckboxClick
|
|
141
|
+
})));
|
|
133
142
|
}
|
|
134
143
|
var FormBuilders = {};
|
|
135
144
|
FormBuilders.ReactFormBuilder = ReactFormBuilder;
|