@goldenpine/react-form-builder2 0.20.3-build.31 → 0.20.3-build.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.
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+
3
+ (function (window, document) {
4
+ 'use strict';
5
+
6
+ var CSS_ID = 'sensitive-input-styles';
7
+ function injectStyles() {
8
+ if (document.getElementById(CSS_ID)) return;
9
+ var css = "\n.sensitive-wrapper { position: relative; }\n.sensitive-wrapper .toggle-password{\n position: absolute;\n right: .75rem;\n top: 50%;\n transform: translateY(-50%);\n cursor: pointer;\n color: #6c757d;\n background: transparent;\n border: none;\n padding: 0;\n font-size: 1rem;\n}\n.sensitive-wrapper input.form-control{\n padding-right: 2.5rem;\n}\n";
10
+ var style = document.createElement('style');
11
+ style.id = CSS_ID;
12
+ style.type = 'text/css';
13
+ style.appendChild(document.createTextNode(css));
14
+ (document.head || document.documentElement).appendChild(style);
15
+ }
16
+ function processWrapper(wrapper) {
17
+ if (!wrapper) return;
18
+ var input = wrapper.querySelector('input');
19
+ if (!input) return;
20
+
21
+ // ensure initial type is password unless explicitly text
22
+ try {
23
+ if (!input.getAttribute('data-initial-type')) {
24
+ input.setAttribute('data-initial-type', input.type || 'password');
25
+ }
26
+ if (!input.type) input.type = 'password';
27
+ } catch (e) {
28
+ // ignore
29
+ }
30
+
31
+ // find existing toggle or create one
32
+ var toggle = wrapper.querySelector('.toggle-password');
33
+ if (!toggle) {
34
+ toggle = document.createElement('button');
35
+ toggle.type = 'button';
36
+ toggle.className = 'toggle-password';
37
+ toggle.setAttribute('aria-pressed', 'false');
38
+ toggle.setAttribute('title', 'Show password');
39
+ // prefer icon if FontAwesome present
40
+ toggle.innerHTML = '<i class="fas fa-eye" aria-hidden="true"></i>';
41
+ wrapper.appendChild(toggle);
42
+ }
43
+ function setShown(shown) {
44
+ try {
45
+ input.type = shown ? 'text' : 'password';
46
+ } catch (err) {
47
+ // some browsers don't allow changing type — replace element as fallback
48
+ var newInput = input.cloneNode(true);
49
+ newInput.type = shown ? 'text' : 'password';
50
+ input.parentNode.replaceChild(newInput, input);
51
+ }
52
+ toggle.setAttribute('aria-pressed', shown ? 'true' : 'false');
53
+ toggle.setAttribute('title', shown ? 'Hide password' : 'Show password');
54
+ // update icon if present
55
+ var i = toggle.querySelector('i');
56
+ if (i) {
57
+ if (shown) {
58
+ i.classList.remove('fa-eye');
59
+ i.classList.add('fa-eye-slash');
60
+ } else {
61
+ i.classList.remove('fa-eye-slash');
62
+ i.classList.add('fa-eye');
63
+ }
64
+ }
65
+ }
66
+ toggle.addEventListener('click', function (e) {
67
+ e.preventDefault();
68
+ e.stopPropagation();
69
+ var currentlyShown = toggle.getAttribute('aria-pressed') === 'true';
70
+ setShown(!currentlyShown);
71
+ // keep focus in the input for accessibility
72
+ try {
73
+ input.focus();
74
+ } catch (err) {}
75
+ });
76
+
77
+ // initialize state
78
+ setShown(false);
79
+ }
80
+ function init(options) {
81
+ options = options || {};
82
+ if (options.injectStyles !== false) injectStyles();
83
+ var wrappers = document.querySelectorAll('.sensitive-wrapper');
84
+ wrappers.forEach(processWrapper);
85
+ }
86
+
87
+ // auto init on DOM ready
88
+ if (document.readyState === 'loading') {
89
+ document.addEventListener('DOMContentLoaded', function () {
90
+ return init();
91
+ });
92
+ } else {
93
+ setTimeout(function () {
94
+ return init();
95
+ }, 0);
96
+ }
97
+ window.SensitiveInput = {
98
+ init: init
99
+ };
100
+ })(window, document);
@@ -173,7 +173,7 @@ var FormElementsEdit = exports["default"] = /*#__PURE__*/function (_React$Compon
173
173
  canHaveOptionValue = _this$props$element.canHaveOptionValue;
174
174
  var canHaveImageSize = this.state.element.element === 'Image' || this.state.element.element === 'Camera';
175
175
  var canHaveUploadLayout = this.state.element.element === 'Camera' || this.state.element.element === 'FileUpload';
176
- var canHavePlaceholder = this.props.element.element === 'TextInput' || this.props.element.element === 'TextArea' || this.props.element.element === 'EmailInput' || this.props.element.element === 'NumberInput' || this.props.element.element === 'PhoneNumber';
176
+ var canHavePlaceholder = this.props.element.element === 'TextInput' || this.props.element.element === 'TextArea' || this.props.element.element === 'EmailInput' || this.props.element.element === 'NumberInput' || this.props.element.element === 'PhoneNumber' || this.props.element.element === 'SensitiveInput';
177
177
  var this_files = this.props.files.length ? this.props.files : [];
178
178
  if (this_files.length < 1 || this_files.length > 0 && this_files[0].id !== '') {
179
179
  this_files.unshift({
package/lib/form.js CHANGED
@@ -456,6 +456,7 @@ var ReactForm = /*#__PURE__*/function (_React$Component) {
456
456
  if (!item) return null;
457
457
  switch (item.element) {
458
458
  case 'TextInput':
459
+ case 'SensitiveInput':
459
460
  case 'EmailInput':
460
461
  case 'PhoneNumber':
461
462
  case 'NumberInput':
@@ -79,6 +79,7 @@
79
79
  "checkboxes" : "Checkboxes",
80
80
  "multiple-choice":"Multiple Choice",
81
81
  "text-input":"Text Input",
82
+ "sensitive-input":"Sensitive Input",
82
83
  "email-input":"Email",
83
84
  "phone-input":"Phone Number",
84
85
  "number-input":"Number Input",
@@ -79,6 +79,7 @@
79
79
  "checkboxes": "چک‌ باکس‌ها",
80
80
  "multiple-choice": "چند گزینه‌ای",
81
81
  "text-input": "ورودی متن",
82
+ "sensitive-input": "ورودی حساس",
82
83
  "email-input": "ایمیل",
83
84
  "phone-input": "شماره تلفن",
84
85
  "number-input": "ورودی عدد",
@@ -79,6 +79,7 @@
79
79
  "checkboxes" : "Checkboxes",
80
80
  "multiple-choice":"Scelta multipla",
81
81
  "text-input":"Input testo",
82
+ "sensitive-input":"Input sensibile",
82
83
  "email-input":"Email",
83
84
  "phone-input":"Numero di telefono",
84
85
  "number-input":"Input numerico",
@@ -79,6 +79,7 @@
79
79
  "checkboxes" : "Hộp chọn",
80
80
  "multiple-choice":"Nhiều lựa chọn",
81
81
  "text-input":"Nhập chữ",
82
+ "sensitive-input":"Nhập dữ liệu nhạy cảm",
82
83
  "email-input": "Email",
83
84
  "phone-input": "Số điện thoại",
84
85
  "number-input":"Nhập số",
@@ -16,6 +16,7 @@ var Header = _formElements["default"].Header,
16
16
  Label = _formElements["default"].Label,
17
17
  LineBreak = _formElements["default"].LineBreak,
18
18
  TextInput = _formElements["default"].TextInput,
19
+ SensitiveInput = _formElements["default"].SensitiveInput,
19
20
  EmailInput = _formElements["default"].EmailInput,
20
21
  PhoneNumber = _formElements["default"].PhoneNumber,
21
22
  NumberInput = _formElements["default"].NumberInput,
@@ -39,6 +40,7 @@ FormElements.Paragraph = (0, _sortableElement["default"])(Paragraph);
39
40
  FormElements.Label = (0, _sortableElement["default"])(Label);
40
41
  FormElements.LineBreak = (0, _sortableElement["default"])(LineBreak);
41
42
  FormElements.TextInput = (0, _sortableElement["default"])(TextInput);
43
+ FormElements.SensitiveInput = (0, _sortableElement["default"])(SensitiveInput);
42
44
  FormElements.EmailInput = (0, _sortableElement["default"])(EmailInput);
43
45
  FormElements.PhoneNumber = (0, _sortableElement["default"])(PhoneNumber);
44
46
  FormElements.NumberInput = (0, _sortableElement["default"])(NumberInput);
package/lib/toolbar.js CHANGED
@@ -245,6 +245,17 @@ var Toolbar = /*#__PURE__*/function (_React$Component) {
245
245
  }),
246
246
  icon: 'fas fa-phone',
247
247
  field_name: 'phone_input_'
248
+ }, {
249
+ key: 'SensitiveInput',
250
+ canHaveAnswer: true,
251
+ name: intl.formatMessage({
252
+ id: 'sensitive-input'
253
+ }),
254
+ label: intl.formatMessage({
255
+ id: 'place-holder-label'
256
+ }),
257
+ icon: 'fas fa-lock',
258
+ field_name: 'sensitive_input_'
248
259
  }, {
249
260
  key: 'TextArea',
250
261
  canHaveAnswer: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goldenpine/react-form-builder2",
3
- "version": "0.20.3-build.31",
3
+ "version": "0.20.3-build.33",
4
4
  "description": "A complete form builder for react.",
5
5
  "main": "lib/index.js",
6
6
  "types": "types/index.d.ts",
package/types/index.d.ts CHANGED
@@ -13,6 +13,9 @@ type BaseElement = {
13
13
  | "Checkboxes"
14
14
  | "Multiple Choice"
15
15
  | "Text Input"
16
+ | "Sensitive Input"
17
+ | "Email Input"
18
+ | "Phone Number"
16
19
  | "Number Input"
17
20
  | "Multi-line Input"
18
21
  | "Two Column Row"