datastake-daf 0.6.261 → 0.6.263
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/.env +8 -0
- package/.vscode/settings.json +13 -0
- package/dist/components/index.js +325 -155
- package/dist/utils/index.js +34 -34
- package/package.json +1 -1
- package/src/@daf/core/components/EditForm/components/ajaxSelect.js +1 -1
- package/src/@daf/core/components/EditForm/form.jsx +621 -551
- package/src/@daf/core/components/EditForm/storyConfig1.js +155 -249
- package/src/@daf/core/components/EditForm/storyConfig2.js +378 -20
- package/src/helpers/Forms.js +522 -443
package/dist/utils/index.js
CHANGED
|
@@ -4007,36 +4007,36 @@ function _checkValue(wantedValue, match, fieldValue) {
|
|
|
4007
4007
|
if (!match) {
|
|
4008
4008
|
return propHasValue(fieldValue) || Array.isArray(fieldValue) && fieldValue.length > 0 ? true : false;
|
|
4009
4009
|
} else {
|
|
4010
|
-
const values = wantedValue.split(
|
|
4011
|
-
if (match ===
|
|
4010
|
+
const values = wantedValue.split(",");
|
|
4011
|
+
if (match === "is") {
|
|
4012
4012
|
if (values.length === 1) {
|
|
4013
4013
|
return Array.isArray(fieldValue) ? fieldValue.includes(values[0]) : String(fieldValue) === values[0];
|
|
4014
4014
|
} else {
|
|
4015
4015
|
return false;
|
|
4016
4016
|
}
|
|
4017
4017
|
}
|
|
4018
|
-
if (match ===
|
|
4018
|
+
if (match === "includes") {
|
|
4019
4019
|
if (values.length) {
|
|
4020
4020
|
return Array.isArray(fieldValue) ? values.filter(v => fieldValue.includes(v)).length > 0 : values.includes(String(fieldValue));
|
|
4021
4021
|
} else {
|
|
4022
4022
|
return false;
|
|
4023
4023
|
}
|
|
4024
4024
|
}
|
|
4025
|
-
if (match ===
|
|
4025
|
+
if (match === "not") {
|
|
4026
4026
|
if (values.length && propHasValue(fieldValue)) {
|
|
4027
4027
|
return Array.isArray(fieldValue) ? values.filter(v => fieldValue.includes(v)).length === 0 : !values.includes(String(fieldValue));
|
|
4028
4028
|
} else {
|
|
4029
4029
|
return false;
|
|
4030
4030
|
}
|
|
4031
4031
|
}
|
|
4032
|
-
if (match ===
|
|
4032
|
+
if (match === "notOnly") {
|
|
4033
4033
|
if (values.length) {
|
|
4034
4034
|
return Array.isArray(fieldValue) ? values.filter(v => fieldValue.includes(v)).length === 0 : !values.includes(String(fieldValue));
|
|
4035
4035
|
} else {
|
|
4036
4036
|
return false;
|
|
4037
4037
|
}
|
|
4038
4038
|
}
|
|
4039
|
-
if (match ===
|
|
4039
|
+
if (match === "notEmpty") {
|
|
4040
4040
|
return fieldValue && Object.keys(fieldValue).includes(wantedValue) && (!Array.isArray(fieldValue[wantedValue]) || Array.isArray(fieldValue[wantedValue]) && fieldValue[wantedValue].length > 0);
|
|
4041
4041
|
}
|
|
4042
4042
|
}
|
|
@@ -4057,8 +4057,8 @@ function _checkValue(wantedValue, match, fieldValue) {
|
|
|
4057
4057
|
* filterString('h ll ', 'll') // true
|
|
4058
4058
|
*/
|
|
4059
4059
|
const filterString = (str1, str2) => {
|
|
4060
|
-
str1 = typeof str1 ===
|
|
4061
|
-
str2 = typeof str2 ===
|
|
4060
|
+
str1 = typeof str1 === "string" ? str1.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "") : "";
|
|
4061
|
+
str2 = typeof str2 === "string" ? str2.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "") : "";
|
|
4062
4062
|
return str1.toLowerCase().indexOf(str2.toLowerCase()) >= 0;
|
|
4063
4063
|
};
|
|
4064
4064
|
|
|
@@ -4076,12 +4076,12 @@ const filterString = (str1, str2) => {
|
|
|
4076
4076
|
* filterSelectOptions('hello', { label: 'goodbye world' }) // false
|
|
4077
4077
|
*/
|
|
4078
4078
|
const filterSelectOptions = (inputValue, option) => {
|
|
4079
|
-
return filterString(typeof option.children ===
|
|
4079
|
+
return filterString(typeof option.children === "string" ? option.children : typeof option.label === "string" ? option.label : "", inputValue);
|
|
4080
4080
|
};
|
|
4081
4081
|
|
|
4082
4082
|
/**
|
|
4083
4083
|
* Filters select options based on the given filters. Used in filterOptions of ant select
|
|
4084
|
-
*
|
|
4084
|
+
*
|
|
4085
4085
|
* @param {Object[]} options - Options to filter.
|
|
4086
4086
|
* @param {string[]} filters - Filters to apply.
|
|
4087
4087
|
* @param {Object} [formsValue={}] - Form values.
|
|
@@ -4090,17 +4090,17 @@ const filterSelectOptions = (inputValue, option) => {
|
|
|
4090
4090
|
* @returns {Object[]} - Filtered options.
|
|
4091
4091
|
*/
|
|
4092
4092
|
function filterOptions(options, filters, formsValue = {}, repeatValues = {}, filterCond = null) {
|
|
4093
|
-
const isOrCond = filterCond !==
|
|
4093
|
+
const isOrCond = filterCond !== "and";
|
|
4094
4094
|
const objFilter = {};
|
|
4095
4095
|
filters.forEach(f => {
|
|
4096
|
-
const [name, p] = f.split(
|
|
4097
|
-
const [path, delimeter] = p.split(/( as )/
|
|
4096
|
+
const [name, p] = f.split("|");
|
|
4097
|
+
const [path, delimeter] = p.split(/( as )/gim);
|
|
4098
4098
|
let value;
|
|
4099
4099
|
let isRepeatable = false;
|
|
4100
|
-
if (delimeter && delimeter.trim() ===
|
|
4100
|
+
if (delimeter && delimeter.trim() === "as") {
|
|
4101
4101
|
value = path;
|
|
4102
4102
|
} else {
|
|
4103
|
-
const pathInsideRepeatValues = path.split(
|
|
4103
|
+
const pathInsideRepeatValues = path.split("./");
|
|
4104
4104
|
isRepeatable = pathInsideRepeatValues.length > 1;
|
|
4105
4105
|
value = deepFind(isRepeatable ? repeatValues : formsValue, pathInsideRepeatValues[pathInsideRepeatValues.length - 1]);
|
|
4106
4106
|
}
|
|
@@ -4120,7 +4120,7 @@ function filterOptions(options, filters, formsValue = {}, repeatValues = {}, fil
|
|
|
4120
4120
|
const parts = opFilters.map(fi => {
|
|
4121
4121
|
const filter = objFilter[fi.name];
|
|
4122
4122
|
const value = Array.isArray(filter.value) ? filter.value : [filter.value];
|
|
4123
|
-
return _checkValue(value.join(
|
|
4123
|
+
return _checkValue(value.join(","), fi.condition, fi.value);
|
|
4124
4124
|
});
|
|
4125
4125
|
return parts.length > 0 && (isOrCond && parts.filter(p => p).length >= 1 || parts.filter(p => !p).length === 0);
|
|
4126
4126
|
// if (!filter) {
|
|
@@ -4157,15 +4157,15 @@ function filterOptions(options, filters, formsValue = {}, repeatValues = {}, fil
|
|
|
4157
4157
|
* @param {Array} arr - The array to check.
|
|
4158
4158
|
* @returns {boolean} - True if the array contains only objects, false otherwise.
|
|
4159
4159
|
*/
|
|
4160
|
-
const isArrayOfObjects = arr => Array.isArray(arr) && arr.map(i => typeof i ===
|
|
4160
|
+
const isArrayOfObjects = arr => Array.isArray(arr) && arr.map(i => typeof i === "object").every(i => i);
|
|
4161
4161
|
|
|
4162
4162
|
/**
|
|
4163
4163
|
* Determines if two sets of data have not changed. Used to show Save button disabled or not.
|
|
4164
|
-
*
|
|
4164
|
+
*
|
|
4165
4165
|
* @param {Object} old - The original data set.
|
|
4166
4166
|
* @param {Object} newData - The new data set to compare against the original.
|
|
4167
4167
|
* @returns {boolean} - True if the data sets have not changed, false otherwise.
|
|
4168
|
-
*
|
|
4168
|
+
*
|
|
4169
4169
|
* This function compares two objects by iterating over the union of their keys.
|
|
4170
4170
|
* For each key, it checks the type of the value in newData:
|
|
4171
4171
|
* - If undefined, it considers it unchanged.
|
|
@@ -4181,13 +4181,13 @@ const hasNotChanged = (old, newData) => {
|
|
|
4181
4181
|
switch (typeof newData[key]) {
|
|
4182
4182
|
case undefined:
|
|
4183
4183
|
return true;
|
|
4184
|
-
case
|
|
4184
|
+
case "object":
|
|
4185
4185
|
try {
|
|
4186
4186
|
if (moment__default["default"].isMoment(newData[key])) {
|
|
4187
|
-
if (typeof newData[key].format ===
|
|
4188
|
-
return old[key] === newData[key].format(
|
|
4187
|
+
if (typeof newData[key].format === "function") {
|
|
4188
|
+
return old[key] === newData[key].format("YYYY-MM-DD");
|
|
4189
4189
|
}
|
|
4190
|
-
return old[key] === moment__default["default"](newData[key]._d).format(
|
|
4190
|
+
return old[key] === moment__default["default"](newData[key]._d).format("YYYY-MM-DD");
|
|
4191
4191
|
} else if (isArrayOfObjects(newData[key])) {
|
|
4192
4192
|
return newData[key].length === (old[key] || []).length && newData[key].map((oKey, i) => hasNotChanged((old[key] || [])[i] || {}, oKey || {})).every(i => i);
|
|
4193
4193
|
}
|
|
@@ -4195,9 +4195,9 @@ const hasNotChanged = (old, newData) => {
|
|
|
4195
4195
|
// console.log(e, data[key], key);
|
|
4196
4196
|
}
|
|
4197
4197
|
return ___default["default"].isEqual(old[key], newData[key]);
|
|
4198
|
-
case
|
|
4199
|
-
case
|
|
4200
|
-
case
|
|
4198
|
+
case "number":
|
|
4199
|
+
case "string":
|
|
4200
|
+
case "boolean":
|
|
4201
4201
|
return old[key] === newData[key];
|
|
4202
4202
|
default:
|
|
4203
4203
|
return false;
|
|
@@ -4207,14 +4207,14 @@ const hasNotChanged = (old, newData) => {
|
|
|
4207
4207
|
|
|
4208
4208
|
/**
|
|
4209
4209
|
* Maps sub groups in the form data structure for submission. This is mainly created for ajaxSubGroup input type.
|
|
4210
|
-
*
|
|
4210
|
+
*
|
|
4211
4211
|
* This function takes a form data structure and maps its sub groups to
|
|
4212
4212
|
* the format expected by the server. It does this by iterating over the
|
|
4213
4213
|
* form definition and checking if any of the inputs have the type 'ajaxSubGroup'
|
|
4214
4214
|
* with either yearRecords or checkboxRecords set. If they do, it aggregates
|
|
4215
4215
|
* the data from the corresponding year-specific keys and sets it as an array
|
|
4216
4216
|
* on the key specified in the form definition.
|
|
4217
|
-
*
|
|
4217
|
+
*
|
|
4218
4218
|
* @param {{ data: Object, form: Object }} - The form data structure.
|
|
4219
4219
|
* @returns {Object} - The mapped form data structure.
|
|
4220
4220
|
*/
|
|
@@ -4229,7 +4229,7 @@ const mapSubGroupsInSubmit = ({
|
|
|
4229
4229
|
Object.keys(form).forEach(k => {
|
|
4230
4230
|
Object.keys(form[k]).forEach(key => {
|
|
4231
4231
|
const input = form[k][key];
|
|
4232
|
-
if (input?.type ===
|
|
4232
|
+
if (input?.type === "ajaxSubGroup" && (typeof input?.meta?.yearRecords === "number" || typeof input?.meta?.checkboxRecords === "string")) {
|
|
4233
4233
|
ajaxSubGroupsWithPeridicity.push(key);
|
|
4234
4234
|
}
|
|
4235
4235
|
});
|
|
@@ -4277,13 +4277,13 @@ const mapSubGroupsInGet = ({
|
|
|
4277
4277
|
Object.keys(form).forEach(k => {
|
|
4278
4278
|
if (form[k]?.type && form[k]?.dataId) {
|
|
4279
4279
|
const input = form[k];
|
|
4280
|
-
if (input?.type ===
|
|
4280
|
+
if (input?.type === "ajaxSubGroup" && (typeof input?.meta?.yearRecords === "number" || typeof input?.meta?.checkboxRecords === "string")) {
|
|
4281
4281
|
ajaxSubGroupsWithPeridicity.push(k);
|
|
4282
4282
|
}
|
|
4283
4283
|
} else {
|
|
4284
4284
|
Object.keys(form[k]).forEach(key => {
|
|
4285
4285
|
const input = form[k][key];
|
|
4286
|
-
if (input?.type ===
|
|
4286
|
+
if (input?.type === "ajaxSubGroup" && (typeof input?.meta?.yearRecords === "number" || typeof input?.meta?.checkboxRecords === "string")) {
|
|
4287
4287
|
ajaxSubGroupsWithPeridicity.push(key);
|
|
4288
4288
|
}
|
|
4289
4289
|
});
|
|
@@ -4301,7 +4301,7 @@ const mapSubGroupsInGet = ({
|
|
|
4301
4301
|
return _data;
|
|
4302
4302
|
};
|
|
4303
4303
|
const isObjectEmpty = obj => {
|
|
4304
|
-
if (obj === null || typeof obj !==
|
|
4304
|
+
if (obj === null || typeof obj !== "object") {
|
|
4305
4305
|
return false;
|
|
4306
4306
|
}
|
|
4307
4307
|
if (Object.keys(obj).length === 0) {
|
|
@@ -4419,8 +4419,8 @@ const changeInputMeta = ({
|
|
|
4419
4419
|
* @returns {string} - The formatted date string.
|
|
4420
4420
|
*/
|
|
4421
4421
|
|
|
4422
|
-
const renderDateFormatted = (value, format =
|
|
4423
|
-
return dayjs__default["default"].utc(value,
|
|
4422
|
+
const renderDateFormatted = (value, format = "DD MMM YYYY", locale = "en") => {
|
|
4423
|
+
return dayjs__default["default"].utc(value, "YYYY-MM-DD").locale(locale).format(format);
|
|
4424
4424
|
};
|
|
4425
4425
|
|
|
4426
4426
|
({
|
package/package.json
CHANGED
|
@@ -71,7 +71,7 @@ export function AjaxSelectMain({
|
|
|
71
71
|
const [isFetchWithThisFilter, setIsFetchWithThisFilter] = useState(false);
|
|
72
72
|
const url = getApiBaseUrl();
|
|
73
73
|
|
|
74
|
-
const queryOptionsApps = ["kota", "nashiriki", "straatos"
|
|
74
|
+
const queryOptionsApps = ["kota", "nashiriki", "straatos"];
|
|
75
75
|
const queryOptionsAppEndpoints = {
|
|
76
76
|
kota: `query/options`,
|
|
77
77
|
nashiriki: "query",
|