react-survey-builder 1.0.106 → 1.0.108

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.
@@ -138,9 +138,13 @@ var SurveyElementsEdit = function SurveyElementsEdit(_ref2) {
138
138
  var thisCheckedConditional = element.hasOwnProperty('conditional') ? element.conditional : false;
139
139
  var thisCheckedHideNextStepButton = element.hasOwnProperty('hideNextStepButton') ? element.hideNextStepButton : false;
140
140
  var thisCheckedSubmitOnSelection = element.hasOwnProperty('submitOnSelection') ? element.submitOnSelection : false;
141
+ var thisCheckedShowRadio = element.hasOwnProperty('showRadio') ? element.showRadio : false;
141
142
  var canHaveAnswer = ['NumberInput', 'EmailInput', 'TextInput', 'PhoneNumber', 'TextArea', 'DatePicker', 'Dropdown', 'Tags', 'Checkboxes', 'Checkbox', 'ButtonList', 'Rating', 'Range'].indexOf(element.element) !== -1;
142
143
  var canHaveOptionValue = ['Dropdown', 'Tags', 'Checkboxes', 'RadioButtons', 'ButtonList'].indexOf(element.element) !== -1;
143
144
  var canHaveOptionCorrect = canHaveAnswer && canHaveOptionValue;
145
+ var canHaveIcon = ['Checkboxes', 'RadioButtons', 'ButtonList'].indexOf(element.element) !== -1;
146
+ var canHaveImage = ['Checkboxes', 'RadioButtons', 'ButtonList'].indexOf(element.element) !== -1;
147
+ var canHaveDescription = ['Checkboxes', 'RadioButtons', 'ButtonList'].indexOf(element.element) !== -1;
144
148
  var thisFiles = isListNotEmpty(files) ? _toConsumableArray(files) : [];
145
149
  if (thisFiles.length < 1 || thisFiles.length > 0 && thisFiles[0].id !== '') {
146
150
  thisFiles.unshift({
@@ -587,7 +591,7 @@ var SurveyElementsEdit = function SurveyElementsEdit(_ref2) {
587
591
  value: "ABOVE"
588
592
  }, "Above Form Field"), /*#__PURE__*/React.createElement("option", {
589
593
  value: "FLOATING"
590
- }, "Floating Inside Form Field"))), element.hasOwnProperty('hideLabel') && /*#__PURE__*/React.createElement(Form.Group, {
594
+ }, "Floating Inside Form Field"))), (element.hasOwnProperty('hideLabel') || ['Dropdown', 'Tags', 'Checkboxes', 'Checkbox', 'RadioButtons', 'ButtonList', 'TextInput', 'EmailInput', 'PhoneNumber', 'DatePicker', 'TextArea', 'NumberInput', 'Rating', 'Range', 'Signature', 'Camera', 'FileUpload'].includes(element.element)) && /*#__PURE__*/React.createElement(Form.Group, {
591
595
  className: "form-group mb-5"
592
596
  }, /*#__PURE__*/React.createElement(Form.Label, {
593
597
  className: "fw-bold"
@@ -684,6 +688,137 @@ var SurveyElementsEdit = function SurveyElementsEdit(_ref2) {
684
688
  onChange: function onChange(e) {
685
689
  editElementProp('submitOnSelection', 'checked', e);
686
690
  }
691
+ })), element.element === 'RadioButtons' && /*#__PURE__*/React.createElement(Form.Group, {
692
+ className: "form-group mb-5"
693
+ }, /*#__PURE__*/React.createElement(Form.Label, {
694
+ className: "fw-bold"
695
+ }, "Show Radio by Default:"), /*#__PURE__*/React.createElement(Form.Check, {
696
+ id: "showRadio",
697
+ label: "Show Radio by Default:",
698
+ type: "checkbox",
699
+ checked: thisCheckedShowRadio,
700
+ value: true,
701
+ onBlur: onUpdateElement,
702
+ onChange: function onChange(e) {
703
+ editElementProp('showRadio', 'checked', e);
704
+ }
705
+ })), element.hasOwnProperty('bgColor') && /*#__PURE__*/React.createElement(Form.Group, {
706
+ className: "form-group mb-5"
707
+ }, /*#__PURE__*/React.createElement(Form.Label, {
708
+ className: "fw-bold",
709
+ htmlFor: "bgColor"
710
+ }, "Background Color:"), /*#__PURE__*/React.createElement(Form.Control, {
711
+ type: "text",
712
+ id: "bgColor",
713
+ defaultValue: element.bgColor,
714
+ onBlur: onUpdateElement,
715
+ onChange: function onChange(e) {
716
+ editElementProp('bgColor', 'value', e);
717
+ }
718
+ })), element.hasOwnProperty('textColor') && /*#__PURE__*/React.createElement(Form.Group, {
719
+ className: "form-group mb-5"
720
+ }, /*#__PURE__*/React.createElement(Form.Label, {
721
+ className: "fw-bold",
722
+ htmlFor: "textColor"
723
+ }, "Text Color:"), /*#__PURE__*/React.createElement(Form.Control, {
724
+ type: "text",
725
+ id: "textColor",
726
+ defaultValue: element.textColor,
727
+ onBlur: onUpdateElement,
728
+ onChange: function onChange(e) {
729
+ editElementProp('textColor', 'value', e);
730
+ }
731
+ })), element.hasOwnProperty('className') && /*#__PURE__*/React.createElement(Form.Group, {
732
+ className: "form-group mb-5"
733
+ }, /*#__PURE__*/React.createElement(Form.Label, {
734
+ className: "fw-bold",
735
+ htmlFor: "className"
736
+ }, "ClassName:"), /*#__PURE__*/React.createElement(Form.Control, {
737
+ type: "text",
738
+ id: "className",
739
+ defaultValue: element.className,
740
+ onBlur: onUpdateElement,
741
+ onChange: function onChange(e) {
742
+ editElementProp('className', 'value', e);
743
+ }
744
+ })), element.hasOwnProperty('fieldLabelClassName') && /*#__PURE__*/React.createElement(Form.Group, {
745
+ className: "form-group mb-5"
746
+ }, /*#__PURE__*/React.createElement(Form.Label, {
747
+ className: "fw-bold",
748
+ htmlFor: "fieldLabelClassName"
749
+ }, "Label ClassName:"), /*#__PURE__*/React.createElement(Form.Control, {
750
+ type: "text",
751
+ id: "fieldLabelClassName",
752
+ defaultValue: element.fieldLabelClassName,
753
+ onBlur: onUpdateElement,
754
+ onChange: function onChange(e) {
755
+ editElementProp('fieldLabelClassName', 'value', e);
756
+ }
757
+ })), element.hasOwnProperty('fieldDescriptionClassName') && /*#__PURE__*/React.createElement(Form.Group, {
758
+ className: "form-group mb-5"
759
+ }, /*#__PURE__*/React.createElement(Form.Label, {
760
+ className: "fw-bold",
761
+ htmlFor: "fieldDescriptionClassName"
762
+ }, "Description ClassName:"), /*#__PURE__*/React.createElement(Form.Control, {
763
+ type: "text",
764
+ id: "fieldDescriptionClassName",
765
+ defaultValue: element.fieldDescriptionClassName,
766
+ onBlur: onUpdateElement,
767
+ onChange: function onChange(e) {
768
+ editElementProp('fieldDescriptionClassName', 'value', e);
769
+ }
770
+ })), element.hasOwnProperty('selectedClassName') && /*#__PURE__*/React.createElement(Form.Group, {
771
+ className: "form-group mb-5"
772
+ }, /*#__PURE__*/React.createElement(Form.Label, {
773
+ className: "fw-bold",
774
+ htmlFor: "selectedClassName"
775
+ }, "Selected ClassName:"), /*#__PURE__*/React.createElement(Form.Control, {
776
+ type: "text",
777
+ id: "selectedClassName",
778
+ defaultValue: element.selectedClassName,
779
+ onBlur: onUpdateElement,
780
+ onChange: function onChange(e) {
781
+ editElementProp('selectedClassName', 'value', e);
782
+ }
783
+ })), element.hasOwnProperty('unselectedClassName') && /*#__PURE__*/React.createElement(Form.Group, {
784
+ className: "form-group mb-5"
785
+ }, /*#__PURE__*/React.createElement(Form.Label, {
786
+ className: "fw-bold",
787
+ htmlFor: "unselectedClassName"
788
+ }, "Unselected ClassName:"), /*#__PURE__*/React.createElement(Form.Control, {
789
+ type: "text",
790
+ id: "unselectedClassName",
791
+ defaultValue: element.unselectedClassName,
792
+ onBlur: onUpdateElement,
793
+ onChange: function onChange(e) {
794
+ editElementProp('unselectedClassName', 'value', e);
795
+ }
796
+ })), element.hasOwnProperty('selectedColor') && /*#__PURE__*/React.createElement(Form.Group, {
797
+ className: "form-group mb-5"
798
+ }, /*#__PURE__*/React.createElement(Form.Label, {
799
+ className: "fw-bold",
800
+ htmlFor: "selectedColor"
801
+ }, "Selected Color:"), /*#__PURE__*/React.createElement(Form.Control, {
802
+ type: "text",
803
+ id: "selectedColor",
804
+ defaultValue: element.selectedColor,
805
+ onBlur: onUpdateElement,
806
+ onChange: function onChange(e) {
807
+ editElementProp('selectedColor', 'value', e);
808
+ }
809
+ })), element.hasOwnProperty('unselectedColor') && /*#__PURE__*/React.createElement(Form.Group, {
810
+ className: "form-group mb-5"
811
+ }, /*#__PURE__*/React.createElement(Form.Label, {
812
+ className: "fw-bold",
813
+ htmlFor: "unselectedColor"
814
+ }, "Unselected Color:"), /*#__PURE__*/React.createElement(Form.Control, {
815
+ type: "text",
816
+ id: "unselectedColor",
817
+ defaultValue: element.unselectedColor,
818
+ onBlur: onUpdateElement,
819
+ onChange: function onChange(e) {
820
+ editElementProp('unselectedColor', 'value', e);
821
+ }
687
822
  })), element.hasOwnProperty('help') && /*#__PURE__*/React.createElement(Form.Group, {
688
823
  className: "form-group mb-5"
689
824
  }, /*#__PURE__*/React.createElement(Form.Label, {
@@ -748,6 +883,9 @@ var SurveyElementsEdit = function SurveyElementsEdit(_ref2) {
748
883
  showCorrectColumn: showCorrectColumn,
749
884
  canHaveOptionCorrect: canHaveOptionCorrect,
750
885
  canHaveOptionValue: canHaveOptionValue,
886
+ canHaveIcon: canHaveIcon,
887
+ canHaveImage: canHaveImage,
888
+ canHaveDescription: canHaveDescription,
751
889
  updateElement: updateElement,
752
890
  element: element,
753
891
  setElement: setElement,
package/lib/toolbar.js CHANGED
@@ -86,7 +86,18 @@ var _defaultItems = [{
86
86
  canHaveHelp: true,
87
87
  options: [],
88
88
  answerType: 'ARRAY',
89
- hideLabel: false
89
+ hideLabel: false,
90
+ canHaveDisplayHorizontal: true,
91
+ bgColor: 'light',
92
+ textColor: 'black',
93
+ className: "p-2 shadow-none rounded-3 text-black border border-2 w-100",
94
+ fieldLabelClassName: "text-start text-black fs-3",
95
+ fieldDescriptionClassName: "text-start text-muted fs-6",
96
+ selectedClassName: "",
97
+ unselectedClassName: "",
98
+ unselectedColor: "black",
99
+ selectedColor: "black",
100
+ inline: false
90
101
  }, {
91
102
  key: 'Checkbox',
92
103
  name: "Checkbox",
@@ -97,7 +108,10 @@ var _defaultItems = [{
97
108
  boxLabel: 'Pick me',
98
109
  answerType: 'BOOLEAN',
99
110
  canHideLabel: true,
100
- hideLabel: true
111
+ hideLabel: true,
112
+ bgColor: 'light',
113
+ textColor: 'black',
114
+ className: "p-2 shadow-none rounded-3 text-black border border-2 w-100"
101
115
  }, {
102
116
  key: 'RadioButtons',
103
117
  name: "Radio Buttons",
@@ -108,7 +122,19 @@ var _defaultItems = [{
108
122
  options: [],
109
123
  answerType: 'STRING',
110
124
  hideLabel: false,
111
- submitOnSelection: false
125
+ submitOnSelection: false,
126
+ canHaveDisplayHorizontal: true,
127
+ bgColor: 'light',
128
+ textColor: 'black',
129
+ className: "p-2 shadow-none rounded-3 text-black border border-2 w-100",
130
+ fieldLabelClassName: "text-start text-black fs-3",
131
+ fieldDescriptionClassName: "text-start text-muted fs-6",
132
+ selectedClassName: "",
133
+ unselectedClassName: "",
134
+ unselectedColor: "black",
135
+ selectedColor: "black",
136
+ showRadio: true,
137
+ inline: false
112
138
  }, {
113
139
  key: 'ButtonList',
114
140
  name: "Button List",
@@ -119,7 +145,18 @@ var _defaultItems = [{
119
145
  options: [],
120
146
  answerType: 'STRING',
121
147
  hideLabel: false,
122
- submitOnSelection: true
148
+ submitOnSelection: true,
149
+ bgColor: 'light',
150
+ textColor: 'black',
151
+ className: "p-2 shadow-none rounded-3 text-black border border-2 w-100",
152
+ fieldLabelClassName: "text-start text-black fs-3",
153
+ fieldDescriptionClassName: "text-start text-muted fs-6",
154
+ selectedClassName: "",
155
+ unselectedClassName: "",
156
+ unselectedColor: "black",
157
+ selectedColor: "black",
158
+ showRadio: false,
159
+ inline: false
123
160
  }, {
124
161
  key: 'TextInput',
125
162
  name: "Text Input",
@@ -620,6 +657,37 @@ var Toolbar = function Toolbar(_ref) {
620
657
  var _item$submitOnSelecti;
621
658
  elementOptions.submitOnSelection = (_item$submitOnSelecti = item.submitOnSelection) !== null && _item$submitOnSelecti !== void 0 ? _item$submitOnSelecti : false;
622
659
  }
660
+ if (element === 'RadioButtons') {
661
+ var _item$showRadio;
662
+ elementOptions.showRadio = (_item$showRadio = item.showRadio) !== null && _item$showRadio !== void 0 ? _item$showRadio : true;
663
+ }
664
+ if (item.bgColor) {
665
+ elementOptions.bgColor = item.bgColor;
666
+ }
667
+ if (item.textColor) {
668
+ elementOptions.textColor = item.textColor;
669
+ }
670
+ if (item.className) {
671
+ elementOptions.className = item.className;
672
+ }
673
+ if (item.fieldLabelClassName) {
674
+ elementOptions.fieldLabelClassName = item.fieldLabelClassName;
675
+ }
676
+ if (item.fieldDescriptionClassName) {
677
+ elementOptions.fieldDescriptionClassName = item.fieldDescriptionClassName;
678
+ }
679
+ if (item.selectedClassName) {
680
+ elementOptions.selectedClassName = item.selectedClassName;
681
+ }
682
+ if (item.unselectedClassName) {
683
+ elementOptions.unselectedClassName = item.unselectedClassName;
684
+ }
685
+ if (item.selectedColor) {
686
+ elementOptions.selectedColor = item.selectedColor;
687
+ }
688
+ if (item.unselectedColor) {
689
+ elementOptions.unselectedColor = item.unselectedColor;
690
+ }
623
691
  if (item.defaultValue) {
624
692
  elementOptions.defaultValue = item.defaultValue;
625
693
  }
@@ -20,6 +20,12 @@ export var replaceInText = function replaceInText(content) {
20
20
  export var isListNotEmpty = function isListNotEmpty(list) {
21
21
  return isArrayLikeObject(list) && list !== undefined && list !== null && list.length > 0;
22
22
  };
23
+ export var isNotNullOrUndefined = function isNotNullOrUndefined(obj) {
24
+ if (obj !== undefined && obj !== null) {
25
+ return true;
26
+ }
27
+ return false;
28
+ };
23
29
  export var isObjectNotEmpty = function isObjectNotEmpty(obj) {
24
30
  if (obj !== undefined && obj !== null && !isEmpty(obj)) {
25
31
  return true;
@@ -30,7 +36,7 @@ export var isTrueLike = function isTrueLike(value) {
30
36
  if (value !== undefined && value !== null) {
31
37
  if (typeof value === 'boolean' && value === true) {
32
38
  return true;
33
- } else if (typeof value === 'string' && (value === 'true' || value === 'True' || value === '1' || value === 'Yes' || value === 'yes')) {
39
+ } else if (typeof value === 'string' && (value === 'true' || value === 'True' || value === '1' || value === 'Yes' || value === 'yes' || value === 'YES')) {
34
40
  return true;
35
41
  } else if (typeof value === 'number' && value === 1) {
36
42
  return true;
@@ -42,7 +48,7 @@ export var isFalseLike = function isFalseLike(value) {
42
48
  if (value !== undefined && value !== null) {
43
49
  if (typeof value === 'boolean' && value === false) {
44
50
  return true;
45
- } else if (typeof value === 'string' && (value === 'false' || value === 'False' || value === '0' || value === 'No' || value === 'no')) {
51
+ } else if (typeof value === 'string' && (value === 'false' || value === 'False' || value === '0' || value === 'No' || value === 'no' || value === 'NO')) {
46
52
  return true;
47
53
  } else if (typeof value === 'number' && value === 0) {
48
54
  return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-survey-builder",
3
- "version": "1.0.106",
3
+ "version": "1.0.108",
4
4
  "description": "A complete survey builder for react.",
5
5
  "main": "lib/index.js",
6
6
  "types": "types/index.d.ts",
package/types/index.d.ts CHANGED
@@ -4,30 +4,30 @@ import * as React from 'react';
4
4
  type BaseElement = {
5
5
  id: string;
6
6
  element:
7
- | "Header Text"
8
- | "Label"
9
- | "Paragraph"
10
- | "Static Content"
11
- | "Line Break"
12
- | "Dropdown"
13
- | "Tags"
14
- | "Checkboxes"
15
- | "Multiple Choice"
16
- | "Text Input"
17
- | "Number Input"
18
- | "Multi-line Input"
19
- | "Two Column Row"
20
- | "Three Column Row"
21
- | "Multi Column Row"
22
- | "Image"
23
- | "Rating"
24
- | "Date"
25
- | "Signature"
26
- | "Web site"
27
- | "Fieldset"
28
- | "File Attachment"
29
- | "Range"
30
- | "Camera";
7
+ | "Header Text"
8
+ | "Label"
9
+ | "Paragraph"
10
+ | "Static Content"
11
+ | "Line Break"
12
+ | "Dropdown"
13
+ | "Tags"
14
+ | "Checkboxes"
15
+ | "Multiple Choice"
16
+ | "Text Input"
17
+ | "Number Input"
18
+ | "Multi-line Input"
19
+ | "Two Column Row"
20
+ | "Three Column Row"
21
+ | "Multi Column Row"
22
+ | "Image"
23
+ | "Rating"
24
+ | "Date"
25
+ | "Signature"
26
+ | "Web site"
27
+ | "Fieldset"
28
+ | "File Attachment"
29
+ | "Range"
30
+ | "Camera";
31
31
  canHaveLabelLocation?: boolean;
32
32
  labelLocation?: string;
33
33
  canHaveHelp?: boolean;
@@ -48,6 +48,16 @@ type BaseElement = {
48
48
  conditionalFieldValue?: string;
49
49
  hideNextStepButton?: boolean;
50
50
  rows?: number;
51
+ showRadio?: boolean;
52
+ bgColor?: string;
53
+ textColor?: string;
54
+ className?: string;
55
+ fieldLabelClassName?: string;
56
+ fieldDescriptionClassName?: string;
57
+ selectedClassName?: string;
58
+ unselectedClassName?: string;
59
+ selectedColor?: string;
60
+ unselectedColor?: string;
51
61
  };
52
62
  export type StaticElement = {
53
63
  bold: boolean;
@@ -65,6 +75,9 @@ export type Option = {
65
75
  label?: string;
66
76
  text: string;
67
77
  value: string;
78
+ icon?: string;
79
+ image?: string;
80
+ description?: string;
68
81
  };
69
82
  export type SelectableElement = {
70
83
  options: Option[];
@@ -150,7 +163,7 @@ export interface SurveyBuilderProps {
150
163
  helpClassName?: string;
151
164
  }
152
165
 
153
- export class ReactSurveyBuilder extends React.Component<SurveyBuilderProps> {}
166
+ export class ReactSurveyBuilder extends React.Component<SurveyBuilderProps> { }
154
167
 
155
168
  export interface SurveyGeneratorOnSubmitParams {
156
169
  id: number;
@@ -197,7 +210,7 @@ export interface SurveyGeneratorProps {
197
210
  print?: boolean;
198
211
  }
199
212
 
200
- export class ReactSurveyGenerator extends React.Component<SurveyGeneratorProps> {}
213
+ export class ReactSurveyGenerator extends React.Component<SurveyGeneratorProps> { }
201
214
 
202
215
  export type ActionType = "load" | "updateOrder" | "delete";
203
216