@bigbinary/neeto-fields-frontend 1.1.15 → 1.3.0

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/README.md CHANGED
@@ -7,9 +7,12 @@ referred as custom fields) for the resources across neeto products.
7
7
 
8
8
  - [General information](#general-information)
9
9
  - [Installation instructions](#installation-instructions)
10
+
10
11
  - [Engine Installation](#engine-installation)
11
12
  - [Frontend package Installation](#frontend-package-installation)
12
- - Frontend package exports
13
+ - [Dependency](#dependency)
14
+
15
+ - [Frontend package exports](#frontend-package-exports)
13
16
  - [Components](#components)
14
17
  - [FieldsDashBoard](#1-fieldsdashboard)
15
18
  - [FieldsPane](#2-fieldspane)
@@ -136,6 +139,17 @@ Install the latest `neetoFields nano` package using the below command:
136
139
  yarn add @bigbinary/neeto-fields-frontend
137
140
  ```
138
141
 
142
+ ## Dependency
143
+
144
+ `neeto-fields-nano` has a peer dependency which is required to use the nano
145
+ properly. Install the peer dependency using the below command:
146
+
147
+ ```shell
148
+ yarn add uuid
149
+ ```
150
+
151
+ # Frontend package exports
152
+
139
153
  The frontend package exports 4 components, 2 utility functions and a hook.
140
154
 
141
155
  ## Components
@@ -655,7 +669,7 @@ The usage of `yalc` is explained in this video:
655
669
  https://www.youtube.com/watch?v=QBiYGP0Rhe0
656
670
 
657
671
  1. See the changes in the host app by executing the following command \
658
- <br/> Use this command if releasing package for the first time.
672
+ <br/> Use this command if releasing a package for the first time.
659
673
 
660
674
  ```shell
661
675
  yarn build && yalc publish
package/dist/index.cjs.js CHANGED
@@ -17,6 +17,7 @@ var Container = require('@bigbinary/neeto-molecules/Container');
17
17
  var PageLoader = require('@bigbinary/neeto-molecules/PageLoader');
18
18
  var reactQuery = require('react-query');
19
19
  var axios = require('axios');
20
+ var uuid = require('uuid');
20
21
  var reactRouterDom = require('react-router-dom');
21
22
  var MenuBar = require('@bigbinary/neeto-molecules/MenuBar');
22
23
  var TableWrapper = require('@bigbinary/neeto-molecules/TableWrapper');
@@ -6004,27 +6005,13 @@ var cleanedRegex = function cleanedRegex(regexCondition) {
6004
6005
  }
6005
6006
  return RegExp(conditionWithoutFlags, sanitizedFlags);
6006
6007
  };
6007
- var buildOptionsToLabelAndValue = function buildOptionsToLabelAndValue() {
6008
- var optionObjects = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
6009
- return optionObjects.map(function (_ref4) {
6010
- var label = _ref4.label,
6011
- value = _ref4.value;
6012
- return {
6013
- label: label,
6014
- value: value || label
6015
- };
6016
- });
6017
- };
6018
- var buildArrayToLabelAndValues = function buildArrayToLabelAndValues(value) {
6019
- return ramda.map(pure.toLabelAndValue, value || []);
6020
- };
6021
6008
  var validateField = /*#__PURE__*/function () {
6022
- var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref5) {
6009
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref4) {
6023
6010
  var fieldValue, fieldName, isRequired, kind, fieldData;
6024
6011
  return _regeneratorRuntime.wrap(function _callee$(_context) {
6025
6012
  while (1) switch (_context.prev = _context.next) {
6026
6013
  case 0:
6027
- fieldValue = _ref5.fieldValue, fieldName = _ref5.fieldName, isRequired = _ref5.isRequired, kind = _ref5.kind, fieldData = _ref5.fieldData;
6014
+ fieldValue = _ref4.fieldValue, fieldName = _ref4.fieldName, isRequired = _ref4.isRequired, kind = _ref4.kind, fieldData = _ref4.fieldData;
6028
6015
  _context.prev = 1;
6029
6016
  _context.next = 4;
6030
6017
  return yup__namespace.object().shape(_defineProperty({}, fieldName, buildFieldValidationSchema({
@@ -6045,7 +6032,7 @@ var validateField = /*#__PURE__*/function () {
6045
6032
  }, _callee, null, [[1, 7]]);
6046
6033
  }));
6047
6034
  return function validateField(_x) {
6048
- return _ref6.apply(this, arguments);
6035
+ return _ref5.apply(this, arguments);
6049
6036
  };
6050
6037
  }();
6051
6038
  var dateTimeToString = function dateTimeToString(dateTime) {
@@ -6074,6 +6061,9 @@ var useFormikFields = function useFormikFields(_ref) {
6074
6061
  var fieldPath = escapeString("".concat(name, "-").concat(fieldId));
6075
6062
  var fieldName = kind === KINDS.multiOption ? "values" : "value";
6076
6063
  var fieldValuePath = "".concat(fieldPath, ".data.").concat(fieldName);
6064
+ isDropdown$1(kind) && (fieldData = pure.renameKeys({
6065
+ id: "value"
6066
+ }, fieldData));
6077
6067
  if (ramda.isNil(formRef) && ramda.isNotNil(formRefs)) {
6078
6068
  formRefs.current[fieldValuePath] = formikContext;
6079
6069
  } else if (ramda.isNil(formRefs) && ramda.isNotNil(formRef)) {
@@ -6102,9 +6092,15 @@ var useFormikFields = function useFormikFields(_ref) {
6102
6092
  };
6103
6093
  var getValueForField = function getValueForField(value) {
6104
6094
  if (kind === KINDS.singleOption) {
6105
- value = pure.toLabelAndValue(value);
6095
+ value = pure.findBy({
6096
+ value: value
6097
+ }, fieldData);
6106
6098
  } else if (kind === KINDS.multiOption) {
6107
- value = buildArrayToLabelAndValues(value);
6099
+ value = value.map(function (optionId) {
6100
+ return pure.findBy({
6101
+ value: optionId
6102
+ }, fieldData);
6103
+ });
6108
6104
  }
6109
6105
  return value || "";
6110
6106
  };
@@ -6125,7 +6121,7 @@ var useFormikFields = function useFormikFields(_ref) {
6125
6121
  },
6126
6122
  disabled: disabled,
6127
6123
  //conditional props
6128
- options: isDropdown$1(kind) ? buildOptionsToLabelAndValue(fieldData) : undefined,
6124
+ options: isDropdown$1(kind) ? fieldData : undefined,
6129
6125
  getPopupContainer: isDateTime(kind) ? ramda.prop("parentElement") : undefined
6130
6126
  })
6131
6127
  };
@@ -6681,6 +6677,13 @@ var renderFormFooter = function renderFormFooter(_ref3) {
6681
6677
  }
6682
6678
  }));
6683
6679
  };
6680
+ var getDefaultOption = function getDefaultOption() {
6681
+ return {
6682
+ id: uuid.v4(),
6683
+ label: "",
6684
+ displayOrder: 0
6685
+ };
6686
+ };
6684
6687
 
6685
6688
  var PERMITTED_REGEX_PATTERN = /^\/.*\/[igmsyu]*$/;
6686
6689
  var ADVANCED_REGEX_ASSERTION_PATTERN = /\(\?=[^)]*\)|\(\?![^)]*\)|\(\?<=[^)]*\)|\(\?<![^)]*\)/;
@@ -6806,11 +6809,6 @@ var INITIAL_FIELDS = {
6806
6809
  kind: pure.toLabelAndValue("text"),
6807
6810
  isRequired: false
6808
6811
  };
6809
- var DEFAULT_OPTION = {
6810
- label: "",
6811
- displayOrder: 0
6812
- };
6813
- var DEFAULT_OPTIONS_DATA = [DEFAULT_OPTION];
6814
6812
  var DEFAULT_REGEX_DATA = {
6815
6813
  condition: "",
6816
6814
  helpMessage: ""
@@ -6846,7 +6844,7 @@ var AdditionalInputs = function AdditionalInputs() {
6846
6844
  return arrayHelpers.remove(index);
6847
6845
  };
6848
6846
  var addOption = function addOption(arrayHelpers) {
6849
- return arrayHelpers.push(DEFAULT_OPTION);
6847
+ return arrayHelpers.push(getDefaultOption());
6850
6848
  };
6851
6849
  if (isDropdown(kind.value)) {
6852
6850
  return /*#__PURE__*/React__default["default"].createElement(formik.FieldArray, {
@@ -6923,7 +6921,7 @@ var FieldForm = function FieldForm(_ref) {
6923
6921
  var handleKindChange = function handleKindChange(kind) {
6924
6922
  setFieldValue("kind", kind);
6925
6923
  if (isDropdown(kind.value)) {
6926
- setFieldValue("data", options !== null && options !== void 0 ? options : DEFAULT_OPTIONS_DATA);
6924
+ setFieldValue("data", options !== null && options !== void 0 ? options : [getDefaultOption()]);
6927
6925
  } else if (isRegex(kind.value)) {
6928
6926
  setFieldValue("data", options !== null && options !== void 0 ? options : DEFAULT_REGEX_DATA);
6929
6927
  }