@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.
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
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
- import { Typography, Dropdown as Dropdown$2, Tooltip, Button as Button$1, Label, Checkbox as Checkbox$1, Alert, Toastr, MultiEmailInput, DatePicker, Radio, Select, Textarea as Textarea$1, Input as Input$2, Spinner as Spinner$2 } from '@bigbinary/neetoui';
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';
8
8
  import { useQuery, useQueryClient, useMutation } from 'react-query';
9
9
  import i18next, { t as t$4 } from 'i18next';
10
- import { Input, Email as Email$2, Phone as Phone$2, Up, Down, MenuHorizontal, Info, Delete, Plus, NeetoInvisible, MultipleChoice as MultipleChoice$2, ListDot, Dropdown as Dropdown$3, Rating as Rating$4, Smiley, Checkbox as Checkbox$2, Calendar, Upload, Check, Close, FileGeneric } from '@bigbinary/neeto-icons';
10
+ import { Input, Email as Email$2, Phone as Phone$2, Up, Down, MenuHorizontal, Info, Delete, Plus, NeetoInvisible, Checkbox as Checkbox$2, Radio, Dropdown as Dropdown$3, Rating as Rating$4, Smiley, Calendar, Upload, Check, Close, FileGeneric } from '@bigbinary/neeto-icons';
11
11
  import axios from 'axios';
12
12
  import ReactDOM, { unstable_batchedUpdates, flushSync as flushSync$1 } from 'react-dom';
13
13
  import { Input as Input$1, Textarea, Checkbox, ActionBlock } from '@bigbinary/neetoui/formik';
@@ -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,
@@ -11144,7 +11109,7 @@ var QUESTION_KINDS = [{
11144
11109
  type: "checkbox",
11145
11110
  label: t$4("neetoForm.fields.mcf"),
11146
11111
  isSingular: false,
11147
- icon: MultipleChoice$2,
11112
+ icon: Checkbox$2,
11148
11113
  component: MultipleChoice,
11149
11114
  defaults: {
11150
11115
  label: "",
@@ -11157,7 +11122,7 @@ var QUESTION_KINDS = [{
11157
11122
  type: "radio",
11158
11123
  label: t$4("neetoForm.fields.scf"),
11159
11124
  isSingular: false,
11160
- icon: ListDot,
11125
+ icon: Radio,
11161
11126
  component: SingleChoice,
11162
11127
  defaults: {
11163
11128
  label: "",
@@ -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", {
@@ -26301,8 +26291,8 @@ var Choices = function Choices(_ref) {
26301
26291
  onChange = _ref.onChange,
26302
26292
  error = _ref.error;
26303
26293
  var isCheckBox = type === "checkbox";
26304
- var ChoiceWrapper = isCheckBox ? "div" : Radio;
26305
- var Component = isCheckBox ? Checkbox$1 : Radio.Item;
26294
+ var ChoiceWrapper = isCheckBox ? "div" : Radio$1;
26295
+ var Component = isCheckBox ? Checkbox$1 : Radio$1.Item;
26306
26296
  return /*#__PURE__*/React__default.createElement("div", {
26307
26297
  className: "neeto-form-engine-choices__wrapper"
26308
26298
  }, /*#__PURE__*/React__default.createElement("label", {