@bigbinary/neeto-form-frontend 1.2.23 → 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.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as React$2 from 'react';
2
2
  import React__default, { useState, useRef, useEffect, useContext, useLayoutEffect as useLayoutEffect$1, memo, forwardRef, useImperativeHandle, Fragment, useReducer, useCallback as useCallback$1, useMemo as useMemo$1, createContext, createElement } from 'react';
3
3
  import { useField, useFormikContext, FieldArray, Form as Form$1, Formik, Field, FastField } from 'formik';
4
- import { noop as noop$4, slugify, findBy, filterBy, removeBy, isPresent as isPresent$1, isNotEmpty, findById, notEqualsDeep } from '@bigbinary/neeto-cist';
4
+ import { noop as noop$4, slugify, filterBy, findBy, removeBy, isPresent as isPresent$1, isNotEmpty, findById, notEqualsDeep } from '@bigbinary/neeto-cist';
5
5
  import PageLoader from '@bigbinary/neeto-molecules/PageLoader';
6
6
  import { Typography, Dropdown as Dropdown$2, Tooltip, Button as Button$1, Label, Checkbox as Checkbox$1, Alert, Toastr, MultiEmailInput, DatePicker, Radio as Radio$1, Select, Textarea as Textarea$1, Input as Input$2, Spinner as Spinner$2 } from '@bigbinary/neetoui';
7
7
  import { assoc, prop, isEmpty, path, values, compose as compose$1, trim, useWith, split, either, isNil, equals, difference, reject, pluck, keys, pick, omit, insert, not, pipe as pipe$1, toLower, map, includes, isNotNil, times } from 'ramda';
@@ -15,9 +15,9 @@ import { useTranslation, Trans } from 'react-i18next';
15
15
  import { withImmutableActions, withT, useDebounce } from '@bigbinary/neeto-commons-frontend/react-utils';
16
16
  import { create as create$1 } from 'zustand';
17
17
  import classnames from 'classnames';
18
+ import { Editor as Editor$1, isEditorEmpty, EditorContent } from '@bigbinary/neeto-editor';
18
19
  import * as yup from 'yup';
19
20
  import { object, array, string } from 'yup';
20
- import { Editor as Editor$1, isEditorEmpty, EditorContent } from '@bigbinary/neeto-editor';
21
21
  import { withEventTargetValue, getQueryParams, dateFormat } from '@bigbinary/neeto-commons-frontend/utils';
22
22
  import useHotkeys from '@bigbinary/neeto-hotkeys';
23
23
  import dayjs from 'dayjs';
@@ -806,6 +806,7 @@ var THUMBS_UP = {
806
806
  icon: "👍",
807
807
  className: "w-20"
808
808
  };
809
+ var QUESTIONS_WITH_FIELD_CODE = ["paragraph", "termsandcondition", "condition", "file_upload"];
809
810
  var RESERVED_FIELD_CODES = ["month", "date", "time"];
810
811
 
811
812
  function _arrayWithHoles$3(arr) {
@@ -10136,41 +10137,6 @@ var TextAreaWithMaxLength = function TextAreaWithMaxLength(_ref) {
10136
10137
  }));
10137
10138
  };
10138
10139
 
10139
- var validateSchema = function validateSchema(schema) {
10140
- return function (values) {
10141
- try {
10142
- schema.validateSync(values, {
10143
- abortEarly: true
10144
- });
10145
- return undefined;
10146
- } catch (err) {
10147
- return err.errors[0];
10148
- }
10149
- };
10150
- };
10151
- var getActiveQuestionKindDetails = function getActiveQuestionKindDetails(_ref) {
10152
- var allQuestionKinds = _ref.allQuestionKinds,
10153
- item = _ref.item;
10154
- var kind = item.kind,
10155
- label = item.label;
10156
- var _findBy = findBy({
10157
- type: kind
10158
- }, allQuestionKinds),
10159
- FieldComponent = _findBy.component,
10160
- FieldIcon = _findBy.icon,
10161
- isSingular = _findBy.isSingular;
10162
- return {
10163
- kind: kind,
10164
- label: label,
10165
- FieldComponent: FieldComponent,
10166
- FieldIcon: FieldIcon,
10167
- isSingular: isSingular
10168
- };
10169
- };
10170
- var validateFieldCode = validateSchema(yup.string().trim().required(t$4("neetoForm.common.fieldReq", {
10171
- field: t$4("neetoForm.questions.common.questionFields.field.fieldCode")
10172
- })).notOneOf(RESERVED_FIELD_CODES, t$4("neetoForm.error.invalidFieldCode")));
10173
-
10174
10140
  var FieldCode = withT(function (_ref) {
10175
10141
  var t = _ref.t,
10176
10142
  name = _ref.name;
@@ -10179,7 +10145,6 @@ var FieldCode = withT(function (_ref) {
10179
10145
  className: "mt-14",
10180
10146
  label: t("neetoForm.questions.common.questionFields.field.fieldCode"),
10181
10147
  name: "".concat(name, ".fieldCode"),
10182
- validate: validateFieldCode,
10183
10148
  labelProps: {
10184
10149
  helpIconProps: {
10185
10150
  icon: Info,
@@ -11802,6 +11767,26 @@ var Form = function Form(_ref) {
11802
11767
  }))));
11803
11768
  };
11804
11769
 
11770
+ var getActiveQuestionKindDetails = function getActiveQuestionKindDetails(_ref) {
11771
+ var allQuestionKinds = _ref.allQuestionKinds,
11772
+ item = _ref.item;
11773
+ var kind = item.kind,
11774
+ label = item.label;
11775
+ var _findBy = findBy({
11776
+ type: kind
11777
+ }, allQuestionKinds),
11778
+ FieldComponent = _findBy.component,
11779
+ FieldIcon = _findBy.icon,
11780
+ isSingular = _findBy.isSingular;
11781
+ return {
11782
+ kind: kind,
11783
+ label: label,
11784
+ FieldComponent: FieldComponent,
11785
+ FieldIcon: FieldIcon,
11786
+ isSingular: isSingular
11787
+ };
11788
+ };
11789
+
11805
11790
  /* eslint-disable @bigbinary/neeto/file-name-and-export-name-standards */
11806
11791
  var requiredLabel = function requiredLabel() {
11807
11792
  var errorMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : i18next.t("neetoForm.common.fieldReq", {
@@ -11816,6 +11801,11 @@ var formValidationSchema = object().shape({
11816
11801
  then: requiredLabel(i18next.t("neetoForm.common.paragraphCantBeEmpty"))
11817
11802
  }),
11818
11803
  kind: string().required(),
11804
+ fieldCode: string().trim().notOneOf(RESERVED_FIELD_CODES, i18next.t("neetoForm.error.invalidFieldCode")).when("kind", function (kind, schema) {
11805
+ return QUESTIONS_WITH_FIELD_CODE.includes(kind) ? schema.notRequired() : schema.required(i18next.t("neetoForm.common.fieldReq", {
11806
+ field: i18next.t("neetoForm.questions.common.questionFields.field.fieldCode")
11807
+ }));
11808
+ }),
11819
11809
  optionsAttributes: array().when("kind", function (kind, schema) {
11820
11810
  return ["radio", "checkbox", "dropdown"].includes(kind) ? schema.of(object().shape({
11821
11811
  label: requiredLabel(i18next.t("neetoForm.common.fieldReq", {