react-form-builder-more-flexibility 1.0.45 → 1.0.47
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 +4 -4
- package/lib/form-elements/component-label.js +3 -0
- package/lib/form-elements/index.js +24 -7
- package/lib/form-elements-edit.js +6 -2
- 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'
|
|
@@ -605,9 +605,6 @@ var Checkbox = /*#__PURE__*/function (_React$Component14) {
|
|
|
605
605
|
(0, _createClass2["default"])(Checkbox, [{
|
|
606
606
|
key: "render",
|
|
607
607
|
value: function render() {
|
|
608
|
-
var classNames = 'custom-control custom-checkbox';
|
|
609
|
-
// if (this.props.data.inline) { classNames += ' option-inline'; }
|
|
610
|
-
|
|
611
608
|
var baseClasses = 'SortableItem rfb-item';
|
|
612
609
|
if (this.props.data.pageBreakBefore) {
|
|
613
610
|
baseClasses += ' alwaysbreak';
|
|
@@ -623,20 +620,40 @@ var Checkbox = /*#__PURE__*/function (_React$Component14) {
|
|
|
623
620
|
if (this.props.read_only) {
|
|
624
621
|
props.disabled = 'disabled';
|
|
625
622
|
}
|
|
623
|
+
var hasPopUpBody;
|
|
624
|
+
if (this.props.data && this.props.data.hasPopUp) {
|
|
625
|
+
hasPopUpBody = true;
|
|
626
|
+
}
|
|
627
|
+
function clickDetected() {
|
|
628
|
+
console.log('CLICK DETECTED!!');
|
|
629
|
+
if (this.props.onCheckboxClick) {
|
|
630
|
+
this.props.onCheckboxClick(this.props.data); // Pass the field name or data to the parent component
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
function handleLabelClick(event) {
|
|
634
|
+
event.preventDefault();
|
|
635
|
+
if (hasPopUpBody) {
|
|
636
|
+
clickDetected();
|
|
637
|
+
}
|
|
638
|
+
}
|
|
626
639
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
627
640
|
style: _objectSpread({}, this.props.style),
|
|
628
641
|
className: baseClasses
|
|
629
642
|
}, /*#__PURE__*/_react["default"].createElement(_componentHeader["default"], this.props), /*#__PURE__*/_react["default"].createElement("div", {
|
|
630
643
|
className: "form-group"
|
|
631
644
|
}, /*#__PURE__*/_react["default"].createElement(_componentLabel["default"], (0, _extends2["default"])({
|
|
645
|
+
passUpClick: function passUpClick() {
|
|
646
|
+
return clickDetected();
|
|
647
|
+
},
|
|
632
648
|
className: "form-label"
|
|
633
649
|
}, this.props)), /*#__PURE__*/_react["default"].createElement("div", {
|
|
634
|
-
className:
|
|
650
|
+
className: "form-check form-check-inline"
|
|
635
651
|
}, /*#__PURE__*/_react["default"].createElement("input", (0, _extends2["default"])({
|
|
636
|
-
|
|
637
|
-
|
|
652
|
+
className: "form-check-input",
|
|
653
|
+
id: this.props.data.field_name
|
|
638
654
|
}, props)), /*#__PURE__*/_react["default"].createElement("label", {
|
|
639
|
-
className: "
|
|
655
|
+
className: "form-check-label",
|
|
656
|
+
onClick: handleLabelClick,
|
|
640
657
|
htmlFor: this.props.data.field_name,
|
|
641
658
|
dangerouslySetInnerHTML: {
|
|
642
659
|
__html: this.props.data.boxLabel
|
|
@@ -158,6 +158,7 @@ var FormElementsEdit = exports["default"] = /*#__PURE__*/function (_React$Compon
|
|
|
158
158
|
}
|
|
159
159
|
var editorState;
|
|
160
160
|
var secondaryEditorState;
|
|
161
|
+
var thirdEditorState;
|
|
161
162
|
if (this.props.element.hasOwnProperty('content')) {
|
|
162
163
|
editorState = this.convertFromHTML(this.props.element.content);
|
|
163
164
|
}
|
|
@@ -167,6 +168,9 @@ var FormElementsEdit = exports["default"] = /*#__PURE__*/function (_React$Compon
|
|
|
167
168
|
if (this.props.element.hasOwnProperty('boxLabel')) {
|
|
168
169
|
secondaryEditorState = this.convertFromHTML(this.props.element.boxLabel);
|
|
169
170
|
}
|
|
171
|
+
if (this.props.element.hasOwnProperty('popUpBody')) {
|
|
172
|
+
thirdEditorState = this.convertFromHTML(this.props.element.popUpBody);
|
|
173
|
+
}
|
|
170
174
|
return /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("div", {
|
|
171
175
|
className: "clearfix"
|
|
172
176
|
}, /*#__PURE__*/_react["default"].createElement("h4", {
|
|
@@ -323,9 +327,9 @@ var FormElementsEdit = exports["default"] = /*#__PURE__*/function (_React$Compon
|
|
|
323
327
|
className: "form-group"
|
|
324
328
|
}, /*#__PURE__*/_react["default"].createElement("label", {
|
|
325
329
|
className: "control-label"
|
|
326
|
-
}, "Pop Up
|
|
330
|
+
}, "Pop Up:"), /*#__PURE__*/_react["default"].createElement(_reactDraftWysiwyg.Editor, {
|
|
327
331
|
toolbar: toolbar,
|
|
328
|
-
defaultEditorState:
|
|
332
|
+
defaultEditorState: thirdEditorState,
|
|
329
333
|
onBlur: this.updateElement.bind(this),
|
|
330
334
|
onEditorStateChange: this.onEditorStateChange.bind(this, 0, 'popUpBody'),
|
|
331
335
|
stripPastedStyles: true
|
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;
|