@bigbinary/neeto-fields-frontend 1.1.15 → 1.3.1
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 +16 -2
- package/dist/index.cjs.js +25 -27
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +27 -29
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useContext, useState, useRef, useEffect, useMemo, useLayoutEffect, useCallback, createContext, memo, useReducer } from 'react';
|
|
2
2
|
import { Checkbox as Checkbox$1, TimePicker, DatePicker, Select, Input, Textarea, Typography, Pane, Label, Button as Button$1, Dropdown, Tab, Alert, NoData, Table, Spinner } from '@bigbinary/neetoui';
|
|
3
|
-
import {
|
|
4
|
-
import { values,
|
|
3
|
+
import { isNotEmpty, renameKeys, capitalize as capitalize$1, findBy, filterBy, toLabelAndValue, slugify, humanize, truncate, countBy, noop as noop$2 } from '@bigbinary/neeto-commons-frontend/pure';
|
|
4
|
+
import { values, isNotNil, isNil, isEmpty, prop, pluck, clone as clone$1, pipe, mergeAll, omit, map, pick, assoc, any, head } from 'ramda';
|
|
5
5
|
import { useFormikContext, useField, FieldArray } from 'formik';
|
|
6
6
|
import { useFuncDebounce, useDebounce, handleMetaClick } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
7
7
|
import * as yup from 'yup';
|
|
@@ -13,6 +13,7 @@ import Container from '@bigbinary/neeto-molecules/Container';
|
|
|
13
13
|
import PageLoader from '@bigbinary/neeto-molecules/PageLoader';
|
|
14
14
|
import { useQuery, useQueryClient, useMutation } from 'react-query';
|
|
15
15
|
import axios from 'axios';
|
|
16
|
+
import { v4 } from 'uuid';
|
|
16
17
|
import { Link, useHistory } from 'react-router-dom';
|
|
17
18
|
import MenuBar from '@bigbinary/neeto-molecules/MenuBar';
|
|
18
19
|
import TableWrapper from '@bigbinary/neeto-molecules/TableWrapper';
|
|
@@ -5969,27 +5970,13 @@ var cleanedRegex = function cleanedRegex(regexCondition) {
|
|
|
5969
5970
|
}
|
|
5970
5971
|
return RegExp(conditionWithoutFlags, sanitizedFlags);
|
|
5971
5972
|
};
|
|
5972
|
-
var buildOptionsToLabelAndValue = function buildOptionsToLabelAndValue() {
|
|
5973
|
-
var optionObjects = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
5974
|
-
return optionObjects.map(function (_ref4) {
|
|
5975
|
-
var label = _ref4.label,
|
|
5976
|
-
value = _ref4.value;
|
|
5977
|
-
return {
|
|
5978
|
-
label: label,
|
|
5979
|
-
value: value || label
|
|
5980
|
-
};
|
|
5981
|
-
});
|
|
5982
|
-
};
|
|
5983
|
-
var buildArrayToLabelAndValues = function buildArrayToLabelAndValues(value) {
|
|
5984
|
-
return map(toLabelAndValue, value || []);
|
|
5985
|
-
};
|
|
5986
5973
|
var validateField = /*#__PURE__*/function () {
|
|
5987
|
-
var
|
|
5974
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref4) {
|
|
5988
5975
|
var fieldValue, fieldName, isRequired, kind, fieldData;
|
|
5989
5976
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
5990
5977
|
while (1) switch (_context.prev = _context.next) {
|
|
5991
5978
|
case 0:
|
|
5992
|
-
fieldValue =
|
|
5979
|
+
fieldValue = _ref4.fieldValue, fieldName = _ref4.fieldName, isRequired = _ref4.isRequired, kind = _ref4.kind, fieldData = _ref4.fieldData;
|
|
5993
5980
|
_context.prev = 1;
|
|
5994
5981
|
_context.next = 4;
|
|
5995
5982
|
return yup.object().shape(_defineProperty({}, fieldName, buildFieldValidationSchema({
|
|
@@ -6010,7 +5997,7 @@ var validateField = /*#__PURE__*/function () {
|
|
|
6010
5997
|
}, _callee, null, [[1, 7]]);
|
|
6011
5998
|
}));
|
|
6012
5999
|
return function validateField(_x) {
|
|
6013
|
-
return
|
|
6000
|
+
return _ref5.apply(this, arguments);
|
|
6014
6001
|
};
|
|
6015
6002
|
}();
|
|
6016
6003
|
var dateTimeToString = function dateTimeToString(dateTime) {
|
|
@@ -6039,6 +6026,9 @@ var useFormikFields = function useFormikFields(_ref) {
|
|
|
6039
6026
|
var fieldPath = escapeString("".concat(name, "-").concat(fieldId));
|
|
6040
6027
|
var fieldName = kind === KINDS.multiOption ? "values" : "value";
|
|
6041
6028
|
var fieldValuePath = "".concat(fieldPath, ".data.").concat(fieldName);
|
|
6029
|
+
isDropdown$1(kind) && (fieldData = renameKeys({
|
|
6030
|
+
id: "value"
|
|
6031
|
+
}, fieldData));
|
|
6042
6032
|
if (isNil(formRef) && isNotNil(formRefs)) {
|
|
6043
6033
|
formRefs.current[fieldValuePath] = formikContext;
|
|
6044
6034
|
} else if (isNil(formRefs) && isNotNil(formRef)) {
|
|
@@ -6067,9 +6057,15 @@ var useFormikFields = function useFormikFields(_ref) {
|
|
|
6067
6057
|
};
|
|
6068
6058
|
var getValueForField = function getValueForField(value) {
|
|
6069
6059
|
if (kind === KINDS.singleOption) {
|
|
6070
|
-
value =
|
|
6060
|
+
value = findBy({
|
|
6061
|
+
value: value
|
|
6062
|
+
}, fieldData);
|
|
6071
6063
|
} else if (kind === KINDS.multiOption) {
|
|
6072
|
-
value =
|
|
6064
|
+
value = value.map(function (optionId) {
|
|
6065
|
+
return findBy({
|
|
6066
|
+
value: optionId
|
|
6067
|
+
}, fieldData);
|
|
6068
|
+
});
|
|
6073
6069
|
}
|
|
6074
6070
|
return value || "";
|
|
6075
6071
|
};
|
|
@@ -6090,7 +6086,7 @@ var useFormikFields = function useFormikFields(_ref) {
|
|
|
6090
6086
|
},
|
|
6091
6087
|
disabled: disabled,
|
|
6092
6088
|
//conditional props
|
|
6093
|
-
options: isDropdown$1(kind) ?
|
|
6089
|
+
options: isDropdown$1(kind) ? fieldData : undefined,
|
|
6094
6090
|
getPopupContainer: isDateTime(kind) ? prop("parentElement") : undefined
|
|
6095
6091
|
})
|
|
6096
6092
|
};
|
|
@@ -6646,6 +6642,13 @@ var renderFormFooter = function renderFormFooter(_ref3) {
|
|
|
6646
6642
|
}
|
|
6647
6643
|
}));
|
|
6648
6644
|
};
|
|
6645
|
+
var getDefaultOption = function getDefaultOption() {
|
|
6646
|
+
return {
|
|
6647
|
+
id: v4(),
|
|
6648
|
+
label: "",
|
|
6649
|
+
displayOrder: 0
|
|
6650
|
+
};
|
|
6651
|
+
};
|
|
6649
6652
|
|
|
6650
6653
|
var PERMITTED_REGEX_PATTERN = /^\/.*\/[igmsyu]*$/;
|
|
6651
6654
|
var ADVANCED_REGEX_ASSERTION_PATTERN = /\(\?=[^)]*\)|\(\?![^)]*\)|\(\?<=[^)]*\)|\(\?<![^)]*\)/;
|
|
@@ -6771,11 +6774,6 @@ var INITIAL_FIELDS = {
|
|
|
6771
6774
|
kind: toLabelAndValue("text"),
|
|
6772
6775
|
isRequired: false
|
|
6773
6776
|
};
|
|
6774
|
-
var DEFAULT_OPTION = {
|
|
6775
|
-
label: "",
|
|
6776
|
-
displayOrder: 0
|
|
6777
|
-
};
|
|
6778
|
-
var DEFAULT_OPTIONS_DATA = [DEFAULT_OPTION];
|
|
6779
6777
|
var DEFAULT_REGEX_DATA = {
|
|
6780
6778
|
condition: "",
|
|
6781
6779
|
helpMessage: ""
|
|
@@ -6811,7 +6809,7 @@ var AdditionalInputs = function AdditionalInputs() {
|
|
|
6811
6809
|
return arrayHelpers.remove(index);
|
|
6812
6810
|
};
|
|
6813
6811
|
var addOption = function addOption(arrayHelpers) {
|
|
6814
|
-
return arrayHelpers.push(
|
|
6812
|
+
return arrayHelpers.push(getDefaultOption());
|
|
6815
6813
|
};
|
|
6816
6814
|
if (isDropdown(kind.value)) {
|
|
6817
6815
|
return /*#__PURE__*/React.createElement(FieldArray, {
|
|
@@ -6888,7 +6886,7 @@ var FieldForm = function FieldForm(_ref) {
|
|
|
6888
6886
|
var handleKindChange = function handleKindChange(kind) {
|
|
6889
6887
|
setFieldValue("kind", kind);
|
|
6890
6888
|
if (isDropdown(kind.value)) {
|
|
6891
|
-
setFieldValue("data", options !== null && options !== void 0 ? options :
|
|
6889
|
+
setFieldValue("data", options !== null && options !== void 0 ? options : [getDefaultOption()]);
|
|
6892
6890
|
} else if (isRegex(kind.value)) {
|
|
6893
6891
|
setFieldValue("data", options !== null && options !== void 0 ? options : DEFAULT_REGEX_DATA);
|
|
6894
6892
|
}
|