@arquimedes.co/eureka-forms 1.9.43-test → 1.9.44-test

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/App.js CHANGED
@@ -69,6 +69,8 @@ import InternalFormStyle from './constants/InternalFormStyle';
69
69
  import { calcCbrForm } from './utils/CbrFunctions';
70
70
  import CBRStepTypes from './constants/CBRFormStepTypes';
71
71
  import { nanoid } from 'nanoid';
72
+ import { EditorState, convertFromRaw } from 'draft-js';
73
+ import { stringToDraft, getRawText, } from './FormComponents/Step/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep';
72
74
  function App(_a) {
73
75
  var _this = this;
74
76
  var _b, _c, _d, _e;
@@ -374,7 +376,7 @@ var mapOriginalValues = function (originalValues, form) {
374
376
  var newIdStep = step.id + '-' + idStep + '-' + idElement;
375
377
  mappedElement.ids[idStep] = newIdStep;
376
378
  if (element[idStep] !== undefined) {
377
- var value = mapOriginalValue(step.steps[idStep], element[idStep]);
379
+ var value = mapOriginalValue(step.steps[idStep], element[idStep], form);
378
380
  if (value !== undefined) {
379
381
  newValues[newIdStep] = value;
380
382
  }
@@ -391,7 +393,7 @@ var mapOriginalValues = function (originalValues, form) {
391
393
  newValues[step.id] = mappedElements;
392
394
  }
393
395
  else {
394
- var value = mapOriginalValue(step, originalValues[step.id]);
396
+ var value = mapOriginalValue(step, originalValues[step.id], form);
395
397
  if (value !== undefined) {
396
398
  newValues[step.id] = value;
397
399
  }
@@ -400,11 +402,12 @@ var mapOriginalValues = function (originalValues, form) {
400
402
  }
401
403
  return newValues;
402
404
  };
403
- var mapOriginalValue = function (step, value) {
405
+ var mapOriginalValue = function (step, value, form) {
406
+ var _a;
404
407
  switch (step === null || step === void 0 ? void 0 : step.type) {
405
408
  case StepTypes.TEXTAREA: {
406
409
  if (step.hasTextEditor) {
407
- return;
410
+ return calcDefaultDraftValue(value);
408
411
  }
409
412
  return value.value;
410
413
  }
@@ -414,7 +417,24 @@ var mapOriginalValue = function (step, value) {
414
417
  return option;
415
418
  return value;
416
419
  }
420
+ case StepTypes.CLASSIFIER_SELECTOR: {
421
+ var classifier = form.classifiers[(_a = step.idClassifier) !== null && _a !== void 0 ? _a : ''];
422
+ if (classifier) {
423
+ var option = classifier.children.find(function (child) { return child._id == value; });
424
+ if (!(value === null || value === void 0 ? void 0 : value.value))
425
+ return { value: value, label: option === null || option === void 0 ? void 0 : option.name };
426
+ }
427
+ break;
428
+ }
417
429
  default:
418
430
  return value;
419
431
  }
420
432
  };
433
+ var calcDefaultDraftValue = function (defaultValue) {
434
+ if (typeof defaultValue === 'string') {
435
+ return EditorState.createWithContent(convertFromRaw(stringToDraft(defaultValue)));
436
+ }
437
+ else {
438
+ return EditorState.createWithContent(convertFromRaw(getRawText(defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.draft, defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.text)));
439
+ }
440
+ };
@@ -3,6 +3,10 @@ import 'react-draft-wysiwyg/dist/react-draft-wysiwyg.css';
3
3
  import './DraftEditor.css';
4
4
  import { RawDraftContentState } from 'draft-js';
5
5
  import { TextAreaStepProps } from '../TextAreaStep';
6
+ export interface Payload {
7
+ text: string;
8
+ draft: any;
9
+ }
6
10
  declare function TextAreaStep({ step, errors, partial, control, editable, postview, formStyle, maxLength, originalValues, backgroundColor, }: TextAreaStepProps): JSX.Element;
7
11
  export default TextAreaStep;
8
12
  export declare function stringToDraft(text: string): RawDraftContentState;
@@ -27,7 +27,7 @@ import { Controller } from 'react-hook-form';
27
27
  import { Editor } from 'react-draft-wysiwyg'; //Load programatically only if step has editor
28
28
  import 'react-draft-wysiwyg/dist/react-draft-wysiwyg.css';
29
29
  import './DraftEditor.css';
30
- import { convertFromRaw, EditorState } from 'draft-js';
30
+ import { EditorState } from 'draft-js';
31
31
  import React, { useState } from 'react';
32
32
  import { ClickAwayListener } from '@material-ui/core';
33
33
  function TextAreaStep(_a) {
@@ -67,14 +67,6 @@ function TextAreaStep(_a) {
67
67
  return (_a = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.text) !== null && _a !== void 0 ? _a : '';
68
68
  }
69
69
  };
70
- var calcDefaultDraftValue = function (defaultValue) {
71
- if (typeof defaultValue === 'string') {
72
- return EditorState.createWithContent(convertFromRaw(stringToDraft(defaultValue)));
73
- }
74
- else {
75
- return EditorState.createWithContent(convertFromRaw(getRawText(defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.draft, defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.text)));
76
- }
77
- };
78
70
  var canEdit = editable && !postview;
79
71
  if (step.hasTextEditor) {
80
72
  return (_jsxs("div", __assign({ className: styles.textEditorContainer, style: {
@@ -103,9 +95,7 @@ function TextAreaStep(_a) {
103
95
  if (canEdit) {
104
96
  setFocus(true);
105
97
  }
106
- } }, { children: _jsx(Controller, { name: step.id, control: control, defaultValue: originalValues[step.id]
107
- ? calcDefaultDraftValue(originalValues[step.id])
108
- : EditorState.createEmpty(), rules: step.required
98
+ } }, { children: _jsx(Controller, { name: step.id, control: control, defaultValue: EditorState.createEmpty(), rules: step.required
109
99
  ? {
110
100
  validate: function (editorState) {
111
101
  return editorState
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@arquimedes.co/eureka-forms",
3
3
  "repository": "git://github.com/Arquimede5/Eureka-Forms.git",
4
- "version":"1.9.43-test",
4
+ "version":"1.9.44-test",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
7
7
  "build": "react-scripts build",