@bigbinary/neeto-form-frontend 1.2.22 → 1.2.24

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.
@@ -35,8 +35,8 @@
35
35
  "addAdditionalGuests": "Add additional guests"
36
36
  },
37
37
  "fields": {
38
- "mcf": "Checkbox",
39
- "scf": "Radio button",
38
+ "mcf": "Multiple choice",
39
+ "scf": "Single choice",
40
40
  "def": "Paragraph",
41
41
  "drf": "Dropdown",
42
42
  "qif": "Multiple lines text",
package/dist/index.cjs.js CHANGED
@@ -18,8 +18,8 @@ var reactI18next = require('react-i18next');
18
18
  var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
19
19
  var zustand = require('zustand');
20
20
  var classnames = require('classnames');
21
- var yup = require('yup');
22
21
  var neetoEditor = require('@bigbinary/neeto-editor');
22
+ var yup = require('yup');
23
23
  var utils = require('@bigbinary/neeto-commons-frontend/utils');
24
24
  var useHotkeys = require('@bigbinary/neeto-hotkeys');
25
25
  var dayjs = require('dayjs');
@@ -844,6 +844,7 @@ var THUMBS_UP = {
844
844
  icon: "👍",
845
845
  className: "w-20"
846
846
  };
847
+ var QUESTIONS_WITH_FIELD_CODE = ["paragraph", "termsandcondition", "condition", "file_upload"];
847
848
  var RESERVED_FIELD_CODES = ["month", "date", "time"];
848
849
 
849
850
  function _arrayWithHoles$3(arr) {
@@ -10174,41 +10175,6 @@ var TextAreaWithMaxLength = function TextAreaWithMaxLength(_ref) {
10174
10175
  }));
10175
10176
  };
10176
10177
 
10177
- var validateSchema = function validateSchema(schema) {
10178
- return function (values) {
10179
- try {
10180
- schema.validateSync(values, {
10181
- abortEarly: true
10182
- });
10183
- return undefined;
10184
- } catch (err) {
10185
- return err.errors[0];
10186
- }
10187
- };
10188
- };
10189
- var getActiveQuestionKindDetails = function getActiveQuestionKindDetails(_ref) {
10190
- var allQuestionKinds = _ref.allQuestionKinds,
10191
- item = _ref.item;
10192
- var kind = item.kind,
10193
- label = item.label;
10194
- var _findBy = neetoCist.findBy({
10195
- type: kind
10196
- }, allQuestionKinds),
10197
- FieldComponent = _findBy.component,
10198
- FieldIcon = _findBy.icon,
10199
- isSingular = _findBy.isSingular;
10200
- return {
10201
- kind: kind,
10202
- label: label,
10203
- FieldComponent: FieldComponent,
10204
- FieldIcon: FieldIcon,
10205
- isSingular: isSingular
10206
- };
10207
- };
10208
- var validateFieldCode = validateSchema(yup__namespace.string().trim().required(i18next.t("neetoForm.common.fieldReq", {
10209
- field: i18next.t("neetoForm.questions.common.questionFields.field.fieldCode")
10210
- })).notOneOf(RESERVED_FIELD_CODES, i18next.t("neetoForm.error.invalidFieldCode")));
10211
-
10212
10178
  var FieldCode = reactUtils.withT(function (_ref) {
10213
10179
  var t = _ref.t,
10214
10180
  name = _ref.name;
@@ -10217,7 +10183,6 @@ var FieldCode = reactUtils.withT(function (_ref) {
10217
10183
  className: "mt-14",
10218
10184
  label: t("neetoForm.questions.common.questionFields.field.fieldCode"),
10219
10185
  name: "".concat(name, ".fieldCode"),
10220
- validate: validateFieldCode,
10221
10186
  labelProps: {
10222
10187
  helpIconProps: {
10223
10188
  icon: neetoIcons.Info,
@@ -11182,7 +11147,7 @@ var QUESTION_KINDS = [{
11182
11147
  type: "checkbox",
11183
11148
  label: i18next.t("neetoForm.fields.mcf"),
11184
11149
  isSingular: false,
11185
- icon: neetoIcons.MultipleChoice,
11150
+ icon: neetoIcons.Checkbox,
11186
11151
  component: MultipleChoice,
11187
11152
  defaults: {
11188
11153
  label: "",
@@ -11195,7 +11160,7 @@ var QUESTION_KINDS = [{
11195
11160
  type: "radio",
11196
11161
  label: i18next.t("neetoForm.fields.scf"),
11197
11162
  isSingular: false,
11198
- icon: neetoIcons.ListDot,
11163
+ icon: neetoIcons.Radio,
11199
11164
  component: SingleChoice,
11200
11165
  defaults: {
11201
11166
  label: "",
@@ -11840,6 +11805,26 @@ var Form = function Form(_ref) {
11840
11805
  }))));
11841
11806
  };
11842
11807
 
11808
+ var getActiveQuestionKindDetails = function getActiveQuestionKindDetails(_ref) {
11809
+ var allQuestionKinds = _ref.allQuestionKinds,
11810
+ item = _ref.item;
11811
+ var kind = item.kind,
11812
+ label = item.label;
11813
+ var _findBy = neetoCist.findBy({
11814
+ type: kind
11815
+ }, allQuestionKinds),
11816
+ FieldComponent = _findBy.component,
11817
+ FieldIcon = _findBy.icon,
11818
+ isSingular = _findBy.isSingular;
11819
+ return {
11820
+ kind: kind,
11821
+ label: label,
11822
+ FieldComponent: FieldComponent,
11823
+ FieldIcon: FieldIcon,
11824
+ isSingular: isSingular
11825
+ };
11826
+ };
11827
+
11843
11828
  /* eslint-disable @bigbinary/neeto/file-name-and-export-name-standards */
11844
11829
  var requiredLabel = function requiredLabel() {
11845
11830
  var errorMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : i18next__default["default"].t("neetoForm.common.fieldReq", {
@@ -11854,6 +11839,11 @@ var formValidationSchema = yup.object().shape({
11854
11839
  then: requiredLabel(i18next__default["default"].t("neetoForm.common.paragraphCantBeEmpty"))
11855
11840
  }),
11856
11841
  kind: yup.string().required(),
11842
+ fieldCode: yup.string().trim().notOneOf(RESERVED_FIELD_CODES, i18next__default["default"].t("neetoForm.error.invalidFieldCode")).when("kind", function (kind, schema) {
11843
+ return QUESTIONS_WITH_FIELD_CODE.includes(kind) ? schema.notRequired() : schema.required(i18next__default["default"].t("neetoForm.common.fieldReq", {
11844
+ field: i18next__default["default"].t("neetoForm.questions.common.questionFields.field.fieldCode")
11845
+ }));
11846
+ }),
11857
11847
  optionsAttributes: yup.array().when("kind", function (kind, schema) {
11858
11848
  return ["radio", "checkbox", "dropdown"].includes(kind) ? schema.of(yup.object().shape({
11859
11849
  label: requiredLabel(i18next__default["default"].t("neetoForm.common.fieldReq", {