@experium/findy-form 1.3.6 → 1.3.8

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.
@@ -85,21 +85,21 @@ var styles = {
85
85
  "modalButtonGroup": "index__modalButtonGroup"
86
86
  };
87
87
 
88
- var getConstructorOpd = function getConstructorOpd(opdSettings, language) {
88
+ var getConstructorOpd = function getConstructorOpd(opdSettings, pdaLanguage, language) {
89
89
  var opdConstructor = (0, _ramda.pathOr)([], ['data', 'opdConstructor'], opdSettings);
90
90
  var text = (opdConstructor || []).reduce(function (res, cur) {
91
91
  switch (cur.type) {
92
92
  case 'question':
93
- return "".concat(res, "<input name=\"").concat(cur.question, "\" placeholder=\"").concat((0, _ramda.path)(['translations', language], cur) || cur.placeholder || '', "\" type=\"text\" ").concat(cur.required ? 'required' : '', " /> ");
93
+ return "".concat(res, "<input name=\"").concat(cur.question, "\" placeholder=\"").concat((0, _ramda.path)(['translations', pdaLanguage], cur) || (0, _ramda.path)(['translations', language], cur) || cur.placeholder || '', "\" type=\"text\" ").concat(cur.required ? 'required' : '', " /> ");
94
94
 
95
95
  case 'formated':
96
- return res + ((0, _ramda.path)(['translations', language], cur) || cur.text || '');
96
+ return res + ((0, _ramda.path)(['translations', pdaLanguage], cur) || (0, _ramda.path)(['translations', language], cur) || cur.text || '');
97
97
 
98
98
  case 'checkbox':
99
- return "".concat(res, "<div>\n <input type=\"checkbox\" id=\"", "checkbox-".concat(cur.id), "\" ").concat(cur.required ? 'required="required"' : '', " />\n <label for=\"", "checkbox-".concat(cur.id), "\">").concat((0, _ramda.path)(['translations', language], cur) || cur.label || '', "</label>\n </div>");
99
+ return "".concat(res, "<div>\n <input type=\"checkbox\" id=\"", "checkbox-".concat(cur.id), "\" ").concat(cur.required ? 'required="required"' : '', " />\n <label for=\"", "checkbox-".concat(cur.id), "\">").concat((0, _ramda.path)(['translations', pdaLanguage], cur) || (0, _ramda.path)(['translations', language], cur) || cur.label || '', "</label>\n </div>");
100
100
 
101
101
  case 'opdCheckbox':
102
- return "".concat(res, "<div>\n <input type=\"checkbox\" id=\"").concat(cur.opdType, "\" name=\"").concat(cur.opdType, "\" data-separate-field=\"").concat(cur.opdType, "\" ").concat((0, _ramda.path)([cur.opdType, 'required'], opdSettings) ? 'required="required"' : '', " />\n <label for=\"").concat(cur.opdType, "\">").concat((0, _ramda.pathOr)('', [cur.opdType, 'translations', language], opdSettings) || (0, _ramda.pathOr)('', [cur.opdType, 'label'], opdSettings), "</label>\n </div>");
102
+ return "".concat(res, "<div>\n <input type=\"checkbox\" id=\"").concat(cur.opdType, "\" name=\"").concat(cur.opdType, "\" data-separate-field=\"").concat(cur.opdType, "\" ").concat((0, _ramda.path)([cur.opdType, 'required'], opdSettings) ? 'required="required"' : '', " />\n <label for=\"").concat(cur.opdType, "\">").concat((0, _ramda.pathOr)('', [cur.opdType, 'translations', pdaLanguage], opdSettings) || (0, _ramda.pathOr)('', [cur.opdType, 'translations', language], opdSettings) || (0, _ramda.pathOr)('', [cur.opdType, 'label'], opdSettings), "</label>\n </div>");
103
103
 
104
104
  default:
105
105
  return res;
@@ -152,20 +152,21 @@ var PersonalDataAgreementComponent = /*#__PURE__*/function (_Component) {
152
152
  renderOpdLabel = _this$props.renderOpdLabel,
153
153
  opd = _this$props.opd,
154
154
  opdSettings = _this$props.opdSettings,
155
- language = _this$props.pdaLanguage;
155
+ pdaLanguage = _this$props.pdaLanguage,
156
+ language = _this$props.language;
156
157
  var label = t('opdLabelCustom');
157
158
  var modalLinkProps = {
158
159
  className: opd ? styles.formLink : styles.withoutOpd,
159
160
  onClick: _this.open
160
161
  };
161
- var linkText = (0, _ramda.pathOr)((0, _ramda.pathOr)(t('opdLink'), ['labelLink'], opdSettings), ['translations', 'labelLink', language], opdSettings);
162
- var link = (0, _ramda.pathOr)((0, _ramda.path)(['link'], opdSettings), ['translations', 'link', language], opdSettings);
163
- var opdText = (0, _ramda.pathOr)(opd, ['translations', 'text', language], opdSettings);
162
+ var linkText = (0, _ramda.path)(['translations', 'labelLink', pdaLanguage], opdSettings) || (0, _ramda.pathOr)((0, _ramda.pathOr)(t('opdLink'), ['labelLink'], opdSettings), ['translations', 'labelLink', language], opdSettings);
163
+ var link = (0, _ramda.path)(['translations', 'link', pdaLanguage], opdSettings) || (0, _ramda.pathOr)((0, _ramda.path)(['link'], opdSettings), ['translations', 'link', language], opdSettings);
164
+ var opdText = (0, _ramda.pathOr)(['translations', 'text', pdaLanguage], opdSettings) || (0, _ramda.pathOr)(opd, ['translations', 'text', language], opdSettings);
164
165
  var opdType = (0, _ramda.pathOr)('modal', ['linkType'], opdSettings);
165
- return /*#__PURE__*/_react["default"].createElement("span", null, renderOpdLabel ? renderOpdLabel(modalLinkProps) : label !== 'opdLabelCustom' ? label : /*#__PURE__*/_react["default"].createElement(_react.Fragment, null, (0, _ramda.pathOr)((0, _ramda.pathOr)(t('opdLabel'), ['labelStart'], opdSettings), ['translations', 'labelStart', language], opdSettings), ' ', opdType === 'modal' ? /*#__PURE__*/_react["default"].createElement("span", modalLinkProps, linkText) : /*#__PURE__*/_react["default"].createElement("a", {
166
+ return /*#__PURE__*/_react["default"].createElement("span", null, renderOpdLabel ? renderOpdLabel(modalLinkProps) : label !== 'opdLabelCustom' ? label : /*#__PURE__*/_react["default"].createElement(_react.Fragment, null, (0, _ramda.path)(['translations', 'labelStart', pdaLanguage], opdSettings) || (0, _ramda.pathOr)((0, _ramda.pathOr)(t('opdLabel'), ['labelStart'], opdSettings), ['translations', 'labelStart', language], opdSettings), ' ', opdType === 'modal' ? /*#__PURE__*/_react["default"].createElement("span", modalLinkProps, linkText) : /*#__PURE__*/_react["default"].createElement("a", {
166
167
  href: "//".concat(link),
167
168
  target: "_blank"
168
- }, linkText), ' ', (0, _ramda.pathOr)((0, _ramda.pathOr)('.', ['labelEnd'], opdSettings), ['translations', 'labelEnd', language], opdSettings)), /*#__PURE__*/_react["default"].createElement(_reactResponsiveModal["default"], {
169
+ }, linkText), ' ', (0, _ramda.path)(['translations', 'labelEnd', pdaLanguage], opdSettings) || (0, _ramda.pathOr)((0, _ramda.pathOr)('.', ['labelEnd'], opdSettings), ['translations', 'labelEnd', language], opdSettings)), /*#__PURE__*/_react["default"].createElement(_reactResponsiveModal["default"], {
169
170
  open: _this.state.opened,
170
171
  onClose: _this.close,
171
172
  classNames: {
@@ -216,7 +217,7 @@ var PersonalDataAgreementComponent = /*#__PURE__*/function (_Component) {
216
217
  return {};
217
218
  });
218
219
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "isHtmlOpd", function () {
219
- var constructorOpd = (0, _ramda.path)(['useConstructor'], _this.props.opdSettings) ? getConstructorOpd(_this.props.opdSettings, _this.props.language) : null;
220
+ var constructorOpd = (0, _ramda.path)(['useConstructor'], _this.props.opdSettings) ? getConstructorOpd(_this.props.opdSettings, _this.props.pdaLanguage, _this.props.language) : null;
220
221
  return !!(_this.props.htmlOpd || constructorOpd);
221
222
  });
222
223
  return _this;
@@ -229,9 +230,10 @@ var PersonalDataAgreementComponent = /*#__PURE__*/function (_Component) {
229
230
 
230
231
  var _this$props3 = this.props,
231
232
  opdSettings = _this$props3.opdSettings,
232
- language = _this$props3.pdaLanguage;
233
+ pdaLanguage = _this$props3.pdaLanguage,
234
+ language = _this$props3.language;
233
235
  var isHtmlOpd = this.isHtmlOpd();
234
- var constructorOpd = (0, _ramda.path)(['useConstructor'], opdSettings) ? getConstructorOpd(opdSettings, language) : null;
236
+ var constructorOpd = (0, _ramda.path)(['useConstructor'], opdSettings) ? getConstructorOpd(opdSettings, pdaLanguage, language) : null;
235
237
  return /*#__PURE__*/_react["default"].createElement(_FormContext.FormContext.Consumer, null, function (_ref) {
236
238
  var htmlAttrs = _ref.htmlAttrs;
237
239
  return /*#__PURE__*/_react["default"].createElement(_react.Fragment, null, /*#__PURE__*/_react["default"].createElement(_Checkbox.Checkbox, (0, _extends2["default"])({
@@ -275,7 +277,7 @@ var PersonalDataAgreementComponent = /*#__PURE__*/function (_Component) {
275
277
  htmlAttrs: htmlAttrs,
276
278
  html: _this2.props.htmlOpd || constructorOpd,
277
279
  htmlOpdStyles: _this2.props.htmlOpdStyles,
278
- acceptBtn: (0, _ramda.pathOr)((0, _ramda.path)(['acceptButtonLabel'], opdSettings), ['translations', 'acceptButtonLabel', language], opdSettings)
280
+ acceptBtn: (0, _ramda.path)(['translations', 'acceptButtonLabel', pdaLanguage], opdSettings) || (0, _ramda.pathOr)((0, _ramda.path)(['acceptButtonLabel'], opdSettings), ['translations', 'acceptButtonLabel', language], opdSettings)
279
281
  });
280
282
  }))));
281
283
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@experium/findy-form",
3
- "version": "1.3.6",
3
+ "version": "1.3.8",
4
4
  "main": "./lib/index.js",
5
5
  "homepage": "https://experium.github.io/findy-form",
6
6
  "repository": "https://github.com/experium/findy-form",
@@ -10,24 +10,24 @@ import HtmlOpdForm, { HtmlOpdFormClear } from './HtmlOpdForm';
10
10
  import { FormContext } from '../../context/FormContext';
11
11
  import { getAttrs } from '../../utils/attrs';
12
12
 
13
- const getConstructorOpd = (opdSettings, language) => {
13
+ const getConstructorOpd = (opdSettings, pdaLanguage, language) => {
14
14
  const opdConstructor = pathOr([], ['data', 'opdConstructor'], opdSettings);
15
15
 
16
16
  const text = (opdConstructor || []).reduce((res, cur) => {
17
17
  switch (cur.type) {
18
18
  case 'question':
19
- return `${res}<input name="${cur.question}" placeholder="${path(['translations', language], cur) || cur.placeholder || ''}" type="text" ${cur.required ? 'required' : ''} /> `;
19
+ return `${res}<input name="${cur.question}" placeholder="${path(['translations', pdaLanguage], cur) || path(['translations', language], cur) || cur.placeholder || ''}" type="text" ${cur.required ? 'required' : ''} /> `;
20
20
  case 'formated':
21
- return res + (path(['translations', language], cur) || cur.text || '');
21
+ return res + (path(['translations', pdaLanguage], cur) || path(['translations', language], cur) || cur.text || '');
22
22
  case 'checkbox':
23
23
  return `${res}<div>
24
24
  <input type="checkbox" id="${`checkbox-${cur.id}`}" ${cur.required ? 'required="required"' : ''} />
25
- <label for="${`checkbox-${cur.id}`}">${path(['translations', language], cur) || cur.label || ''}</label>
25
+ <label for="${`checkbox-${cur.id}`}">${path(['translations', pdaLanguage], cur) || path(['translations', language], cur) || cur.label || ''}</label>
26
26
  </div>`;
27
27
  case 'opdCheckbox':
28
28
  return `${res}<div>
29
29
  <input type="checkbox" id="${cur.opdType}" name="${cur.opdType}" data-separate-field="${cur.opdType}" ${path([cur.opdType, 'required'], opdSettings) ? 'required="required"' : ''} />
30
- <label for="${cur.opdType}">${pathOr('', [cur.opdType, 'translations', language], opdSettings) || pathOr('', [cur.opdType, 'label'], opdSettings)}</label>
30
+ <label for="${cur.opdType}">${pathOr('', [cur.opdType, 'translations', pdaLanguage], opdSettings) || pathOr('', [cur.opdType, 'translations', language], opdSettings) || pathOr('', [cur.opdType, 'label'], opdSettings)}</label>
31
31
  </div>`;
32
32
  default:
33
33
  return res;
@@ -61,15 +61,15 @@ class PersonalDataAgreementComponent extends Component {
61
61
  closeHtml = () => this.setState({ openedHtml: false });
62
62
 
63
63
  getLabel = () => {
64
- const { t, renderOpdLabel, opd, opdSettings, pdaLanguage: language } = this.props;
64
+ const { t, renderOpdLabel, opd, opdSettings, pdaLanguage, language } = this.props;
65
65
  const label = t('opdLabelCustom');
66
66
  const modalLinkProps = {
67
67
  className: opd ? styles.formLink : styles.withoutOpd,
68
68
  onClick: this.open
69
69
  };
70
- const linkText = pathOr(pathOr(t('opdLink'), ['labelLink'], opdSettings), ['translations', 'labelLink', language], opdSettings);
71
- const link = pathOr(path(['link'], opdSettings), ['translations', 'link', language], opdSettings);
72
- const opdText = pathOr(opd, ['translations', 'text', language], opdSettings);
70
+ const linkText = path(['translations', 'labelLink', pdaLanguage], opdSettings) || pathOr(pathOr(t('opdLink'), ['labelLink'], opdSettings), ['translations', 'labelLink', language], opdSettings);
71
+ const link = path(['translations', 'link', pdaLanguage], opdSettings) || pathOr(path(['link'], opdSettings), ['translations', 'link', language], opdSettings);
72
+ const opdText = pathOr(['translations', 'text', pdaLanguage], opdSettings) || pathOr(opd, ['translations', 'text', language], opdSettings);
73
73
  const opdType = pathOr('modal', ['linkType'], opdSettings);
74
74
 
75
75
  return <span>
@@ -78,14 +78,14 @@ class PersonalDataAgreementComponent extends Component {
78
78
  label
79
79
  ) : (
80
80
  <Fragment>
81
- { pathOr(pathOr(t('opdLabel'), ['labelStart'], opdSettings), ['translations', 'labelStart', language], opdSettings) }
81
+ { path(['translations', 'labelStart', pdaLanguage], opdSettings) || pathOr(pathOr(t('opdLabel'), ['labelStart'], opdSettings), ['translations', 'labelStart', language], opdSettings) }
82
82
  { ' ' }
83
83
  { opdType === 'modal' ?
84
84
  <span {...modalLinkProps}>{ linkText }</span> :
85
85
  <a href={`//${link}`} target='_blank'>{ linkText }</a>
86
86
  }
87
87
  { ' ' }
88
- { pathOr(pathOr('.', ['labelEnd'], opdSettings), ['translations', 'labelEnd', language], opdSettings) }
88
+ { path(['translations', 'labelEnd', pdaLanguage], opdSettings) || pathOr(pathOr('.', ['labelEnd'], opdSettings), ['translations', 'labelEnd', language], opdSettings) }
89
89
  </Fragment>
90
90
  )
91
91
  }
@@ -140,14 +140,14 @@ class PersonalDataAgreementComponent extends Component {
140
140
  }
141
141
 
142
142
  isHtmlOpd = () => {
143
- const constructorOpd = path(['useConstructor'], this.props.opdSettings) ? getConstructorOpd(this.props.opdSettings, this.props.language) : null;
143
+ const constructorOpd = path(['useConstructor'], this.props.opdSettings) ? getConstructorOpd(this.props.opdSettings, this.props.pdaLanguage, this.props.language) : null;
144
144
  return !!(this.props.htmlOpd || constructorOpd);
145
145
  }
146
146
 
147
147
  render() {
148
- const { opdSettings, pdaLanguage: language } = this.props;
148
+ const { opdSettings, pdaLanguage, language } = this.props;
149
149
  const isHtmlOpd = this.isHtmlOpd();
150
- const constructorOpd = path(['useConstructor'], opdSettings) ? getConstructorOpd(opdSettings, language) : null;
150
+ const constructorOpd = path(['useConstructor'], opdSettings) ? getConstructorOpd(opdSettings, pdaLanguage, language) : null;
151
151
 
152
152
  return <FormContext.Consumer>{ ({ htmlAttrs }) => (
153
153
  <Fragment>
@@ -196,7 +196,10 @@ class PersonalDataAgreementComponent extends Component {
196
196
  htmlAttrs={htmlAttrs}
197
197
  html={this.props.htmlOpd || constructorOpd}
198
198
  htmlOpdStyles={this.props.htmlOpdStyles}
199
- acceptBtn={pathOr(path(['acceptButtonLabel'], opdSettings), ['translations', 'acceptButtonLabel', language], opdSettings)} />
199
+ acceptBtn={
200
+ path(['translations', 'acceptButtonLabel', pdaLanguage], opdSettings)
201
+ || pathOr(path(['acceptButtonLabel'], opdSettings), ['translations', 'acceptButtonLabel', language], opdSettings)
202
+ } />
200
203
  )}
201
204
  </FormSpy>
202
205
  </Modal>