aefis-core-ui 2.3.0-rc39 → 2.3.0-rc40
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.modern.js +156 -81
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.modern.js
CHANGED
|
@@ -67,11 +67,11 @@ import Nouislider from 'nouislider-react';
|
|
|
67
67
|
import 'lodash/camelCase';
|
|
68
68
|
import debounce from 'lodash/debounce';
|
|
69
69
|
import StepConnector, { stepConnectorClasses } from '@mui/material/StepConnector';
|
|
70
|
-
import { v4 } from 'uuid';
|
|
71
|
-
import produce from 'immer';
|
|
72
70
|
import DeleteOutlineOutlinedIcon from '@mui/icons-material/DeleteOutlineOutlined';
|
|
73
71
|
import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp';
|
|
74
72
|
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
|
|
73
|
+
import { v4 } from 'uuid';
|
|
74
|
+
import produce from 'immer';
|
|
75
75
|
import { MuiForm5 } from '@rjsf/material-ui';
|
|
76
76
|
import isEmpty from 'lodash/isEmpty';
|
|
77
77
|
import compose from 'lodash/fp/compose';
|
|
@@ -15821,6 +15821,9 @@ const RuleGroupIndex = /*#__PURE__*/memo(({
|
|
|
15821
15821
|
isLast
|
|
15822
15822
|
}) => /*#__PURE__*/jsx(Box$1, {
|
|
15823
15823
|
sx: {
|
|
15824
|
+
display: "flex",
|
|
15825
|
+
flexDirection: "column",
|
|
15826
|
+
alignItems: "center",
|
|
15824
15827
|
width: "40px",
|
|
15825
15828
|
height: "88px"
|
|
15826
15829
|
},
|
|
@@ -15907,6 +15910,122 @@ var store = {
|
|
|
15907
15910
|
useSetState: useSetState
|
|
15908
15911
|
};
|
|
15909
15912
|
|
|
15913
|
+
const mutateFunctions = {
|
|
15914
|
+
addGroup: (state, {
|
|
15915
|
+
defaultRule
|
|
15916
|
+
}) => {
|
|
15917
|
+
state.push({
|
|
15918
|
+
groupId: v4(),
|
|
15919
|
+
rules: [_extends({
|
|
15920
|
+
id: v4()
|
|
15921
|
+
}, defaultRule)]
|
|
15922
|
+
});
|
|
15923
|
+
},
|
|
15924
|
+
deleteGroup: (state, {
|
|
15925
|
+
groupIndex
|
|
15926
|
+
}) => {
|
|
15927
|
+
state.splice(groupIndex, 1);
|
|
15928
|
+
},
|
|
15929
|
+
deleteRule: (state, {
|
|
15930
|
+
index,
|
|
15931
|
+
ruleId
|
|
15932
|
+
}) => {
|
|
15933
|
+
state[index].rules = state[index].rules.filter(rule => rule.id !== ruleId);
|
|
15934
|
+
},
|
|
15935
|
+
moveRule: (state, {
|
|
15936
|
+
isUp,
|
|
15937
|
+
index,
|
|
15938
|
+
ruleIndex
|
|
15939
|
+
}) => {
|
|
15940
|
+
// INFO: abort if moving up for item already on top
|
|
15941
|
+
if (isUp && ruleIndex === 0) return;
|
|
15942
|
+
|
|
15943
|
+
// INFO: abort if moving down for item already on bottom
|
|
15944
|
+
if (!isUp && state[index].rules.length - 1 === ruleIndex) return;
|
|
15945
|
+
const nextRow = isUp ? ruleIndex - 1 : ruleIndex + 1;
|
|
15946
|
+
[state[index].rules[ruleIndex], state[index].rules[nextRow]] = [state[index].rules[nextRow], state[index].rules[ruleIndex]];
|
|
15947
|
+
},
|
|
15948
|
+
createRuleBelow: (state, {
|
|
15949
|
+
index,
|
|
15950
|
+
ruleIndex,
|
|
15951
|
+
defaultRule
|
|
15952
|
+
}) => {
|
|
15953
|
+
const newRule = _extends({
|
|
15954
|
+
id: v4()
|
|
15955
|
+
}, defaultRule);
|
|
15956
|
+
state[index].rules = [...state[index].rules.slice(0, ruleIndex + 1), newRule, ...state[index].rules.slice(ruleIndex + 1)];
|
|
15957
|
+
},
|
|
15958
|
+
selectRootInput: (state, {
|
|
15959
|
+
index,
|
|
15960
|
+
ruleIndex,
|
|
15961
|
+
templateCode
|
|
15962
|
+
}) => {
|
|
15963
|
+
state[index].rules[ruleIndex].name = templateCode || null;
|
|
15964
|
+
state[index].rules[ruleIndex].value = null;
|
|
15965
|
+
state[index].rules[ruleIndex].template = null;
|
|
15966
|
+
},
|
|
15967
|
+
changeRuleValue: (state, {
|
|
15968
|
+
value,
|
|
15969
|
+
template,
|
|
15970
|
+
groupId,
|
|
15971
|
+
ruleId
|
|
15972
|
+
}) => {
|
|
15973
|
+
const rule = state.find(group => group.groupId === groupId).rules.find(rule => rule.id === ruleId);
|
|
15974
|
+
rule.value = value;
|
|
15975
|
+
rule.template = template;
|
|
15976
|
+
},
|
|
15977
|
+
moveGroup: (state, {
|
|
15978
|
+
isUp,
|
|
15979
|
+
index
|
|
15980
|
+
}) => {
|
|
15981
|
+
const nextRow = isUp ? index - 1 : index + 1;
|
|
15982
|
+
[state[index], state[nextRow]] = [state[nextRow], state[index]];
|
|
15983
|
+
},
|
|
15984
|
+
addRule: (state, {
|
|
15985
|
+
groupIndex,
|
|
15986
|
+
defaultRule
|
|
15987
|
+
}) => {
|
|
15988
|
+
state[groupIndex].rules.push(_extends({
|
|
15989
|
+
id: v4()
|
|
15990
|
+
}, defaultRule));
|
|
15991
|
+
}
|
|
15992
|
+
};
|
|
15993
|
+
|
|
15994
|
+
/**
|
|
15995
|
+
* This hook is similar to useState, but allows update functions to be defined
|
|
15996
|
+
* outside of component, and also allow these functions to mutate the state via
|
|
15997
|
+
* immer.js library.
|
|
15998
|
+
*
|
|
15999
|
+
* Example:
|
|
16000
|
+
*
|
|
16001
|
+
* const mutateFunctions = { pushArray: (state, { param }) => state.push(param)
|
|
16002
|
+
* )}
|
|
16003
|
+
*
|
|
16004
|
+
* Component() { const { state, mutate } = useMutateState() const handle =>
|
|
16005
|
+
* (param) => { mutate.pushArray({ param }) }
|
|
16006
|
+
*
|
|
16007
|
+
* return ...
|
|
16008
|
+
* }
|
|
16009
|
+
*
|
|
16010
|
+
*
|
|
16011
|
+
* @param {object} mutateFunctions maps the functions to mutate state
|
|
16012
|
+
* @param {*} initialState
|
|
16013
|
+
* @returns { state, setState, mutate }
|
|
16014
|
+
*/
|
|
16015
|
+
const useMutateState = (mutateFunctions, initialState) => {
|
|
16016
|
+
const [state, setState] = useState(initialState);
|
|
16017
|
+
const mutateState = useCallback(setterFn => setState(state => produce(state, setterFn)), []);
|
|
16018
|
+
const mutate = useMemo(() => Object.entries(mutateFunctions).reduce((acc, [fnName, fn]) => {
|
|
16019
|
+
acc[fnName] = actionData => mutateState(state => fn(state, actionData));
|
|
16020
|
+
return acc;
|
|
16021
|
+
}, {}), [mutateFunctions]);
|
|
16022
|
+
return {
|
|
16023
|
+
state,
|
|
16024
|
+
setState,
|
|
16025
|
+
mutate
|
|
16026
|
+
};
|
|
16027
|
+
};
|
|
16028
|
+
|
|
15910
16029
|
const _excluded$4 = ["code"];
|
|
15911
16030
|
const TextBuilder = /*#__PURE__*/memo(({
|
|
15912
16031
|
renderHeader,
|
|
@@ -15924,110 +16043,65 @@ const TextBuilder = /*#__PURE__*/memo(({
|
|
|
15924
16043
|
[code]: rest
|
|
15925
16044
|
});
|
|
15926
16045
|
}, {}), [templateOptions]);
|
|
15927
|
-
const
|
|
16046
|
+
const {
|
|
16047
|
+
state: rows,
|
|
16048
|
+
mutate
|
|
16049
|
+
} = useMutateState(mutateFunctions, _defaultValue);
|
|
15928
16050
|
|
|
15929
16051
|
// TODO: think on better implementation
|
|
15930
16052
|
useSkipOnMount(() => {
|
|
15931
16053
|
_onChange(rows);
|
|
15932
16054
|
}, [rows]);
|
|
15933
|
-
const setMutatableRows = useCallback(setterFn => setRows(rows => produce(rows, setterFn)), []);
|
|
15934
16055
|
const handleAddGroup = useCallback(() => {
|
|
15935
|
-
|
|
15936
|
-
|
|
15937
|
-
groupId: v4(),
|
|
15938
|
-
rules: [_extends({
|
|
15939
|
-
id: v4()
|
|
15940
|
-
}, defaultRule)]
|
|
15941
|
-
});
|
|
16056
|
+
mutate.addGroup({
|
|
16057
|
+
defaultRule
|
|
15942
16058
|
});
|
|
15943
16059
|
}, [defaultRule]);
|
|
15944
|
-
const handleGroupDelete = useCallback(({
|
|
15945
|
-
groupIndex
|
|
15946
|
-
}) => {
|
|
15947
|
-
setMutatableRows(groups => {
|
|
15948
|
-
groups.splice(groupIndex, 1);
|
|
15949
|
-
});
|
|
15950
|
-
}, []);
|
|
15951
|
-
const handleRuleDelete = useCallback(({
|
|
15952
|
-
index,
|
|
15953
|
-
ruleId
|
|
15954
|
-
}) => {
|
|
15955
|
-
setMutatableRows(groups => {
|
|
15956
|
-
groups[index].rules = groups[index].rules.filter(rule => rule.id !== ruleId);
|
|
15957
|
-
});
|
|
15958
|
-
}, []);
|
|
15959
16060
|
const handleRuleMoveUp = useCallback(({
|
|
15960
16061
|
index,
|
|
15961
16062
|
ruleIndex
|
|
15962
16063
|
}) => {
|
|
15963
|
-
|
|
15964
|
-
|
|
15965
|
-
|
|
15966
|
-
|
|
16064
|
+
mutate.moveRule({
|
|
16065
|
+
isUp: true,
|
|
16066
|
+
index,
|
|
16067
|
+
ruleIndex
|
|
15967
16068
|
});
|
|
15968
16069
|
}, []);
|
|
15969
16070
|
const handleRuleMoveDown = useCallback(({
|
|
15970
16071
|
index,
|
|
15971
16072
|
ruleIndex
|
|
15972
16073
|
}) => {
|
|
15973
|
-
|
|
15974
|
-
|
|
15975
|
-
|
|
15976
|
-
|
|
16074
|
+
mutate.moveRule({
|
|
16075
|
+
isUp: false,
|
|
16076
|
+
index,
|
|
16077
|
+
ruleIndex
|
|
15977
16078
|
});
|
|
15978
16079
|
}, []);
|
|
15979
16080
|
const handleCreateRuleBelow = useCallback(({
|
|
15980
16081
|
index,
|
|
15981
16082
|
ruleIndex
|
|
15982
16083
|
}) => {
|
|
15983
|
-
|
|
15984
|
-
|
|
15985
|
-
|
|
15986
|
-
|
|
15987
|
-
groups[index].rules = [...groups[index].rules.slice(0, ruleIndex + 1), newRule, ...groups[index].rules.slice(ruleIndex + 1)];
|
|
15988
|
-
});
|
|
15989
|
-
}, []);
|
|
15990
|
-
const handleRuleTemplateSelect = useCallback(({
|
|
15991
|
-
index,
|
|
15992
|
-
ruleIndex,
|
|
15993
|
-
templateCode
|
|
15994
|
-
}) => {
|
|
15995
|
-
setMutatableRows(groups => {
|
|
15996
|
-
groups[index].rules[ruleIndex].name = templateCode || null;
|
|
15997
|
-
groups[index].rules[ruleIndex].value = null;
|
|
15998
|
-
groups[index].rules[ruleIndex].template = null;
|
|
15999
|
-
});
|
|
16000
|
-
}, []);
|
|
16001
|
-
const handleRuleTemplateValueChange = useCallback(({
|
|
16002
|
-
value,
|
|
16003
|
-
template,
|
|
16004
|
-
groupId,
|
|
16005
|
-
ruleId
|
|
16006
|
-
}) => {
|
|
16007
|
-
setMutatableRows(groups => {
|
|
16008
|
-
const rule = groups.find(group => group.groupId === groupId).rules.find(rule => rule.id === ruleId);
|
|
16009
|
-
rule.value = value;
|
|
16010
|
-
rule.template = template;
|
|
16084
|
+
mutate.createRuleBelow({
|
|
16085
|
+
index,
|
|
16086
|
+
ruleIndex,
|
|
16087
|
+
defaultRule
|
|
16011
16088
|
});
|
|
16012
|
-
}, []);
|
|
16089
|
+
}, [defaultRule]);
|
|
16013
16090
|
const moveGroupPosition = useCallback(({
|
|
16014
16091
|
index
|
|
16015
16092
|
}, isUp) => {
|
|
16016
|
-
|
|
16017
|
-
|
|
16018
|
-
|
|
16093
|
+
mutate.moveGroup({
|
|
16094
|
+
isUp,
|
|
16095
|
+
index
|
|
16019
16096
|
});
|
|
16020
16097
|
}, []);
|
|
16021
16098
|
const handleAddRule = useCallback(({
|
|
16022
16099
|
groupIndex
|
|
16023
|
-
}) => {
|
|
16024
|
-
|
|
16025
|
-
|
|
16026
|
-
|
|
16027
|
-
|
|
16028
|
-
});
|
|
16029
|
-
}, []);
|
|
16030
|
-
return /*#__PURE__*/jsxs(ContentBox, {
|
|
16100
|
+
}) => mutate.addRule({
|
|
16101
|
+
groupIndex,
|
|
16102
|
+
defaultRule
|
|
16103
|
+
}), [defaultRule]);
|
|
16104
|
+
return /*#__PURE__*/jsxs(Box$1, {
|
|
16031
16105
|
sx: {
|
|
16032
16106
|
".MuiFormControl-root": {
|
|
16033
16107
|
background: "white"
|
|
@@ -16047,8 +16121,7 @@ const TextBuilder = /*#__PURE__*/memo(({
|
|
|
16047
16121
|
children: /*#__PURE__*/jsxs(Box$1, {
|
|
16048
16122
|
sx: {
|
|
16049
16123
|
display: "flex",
|
|
16050
|
-
flexWrap: "no-wrap"
|
|
16051
|
-
border: "1px solid transparent"
|
|
16124
|
+
flexWrap: "no-wrap"
|
|
16052
16125
|
},
|
|
16053
16126
|
children: [/*#__PURE__*/jsx(RuleGroupIndex, {
|
|
16054
16127
|
onMovePosition: moveGroupPosition,
|
|
@@ -16066,16 +16139,18 @@ const TextBuilder = /*#__PURE__*/memo(({
|
|
|
16066
16139
|
groupId: groupId,
|
|
16067
16140
|
templateOptions: templateOptions,
|
|
16068
16141
|
templateInputMap: templateInputMap,
|
|
16069
|
-
onRuleDelete:
|
|
16142
|
+
onRuleDelete: mutate.deleteRule,
|
|
16070
16143
|
onRuleMoveUp: handleRuleMoveUp,
|
|
16071
16144
|
onRuleMoveDown: handleRuleMoveDown,
|
|
16072
|
-
onCreateRuleBelow: handleCreateRuleBelow
|
|
16073
|
-
|
|
16074
|
-
|
|
16145
|
+
onCreateRuleBelow: handleCreateRuleBelow
|
|
16146
|
+
// TODO: change handleRuleTemplateSelect to handleSelectRootInput
|
|
16147
|
+
,
|
|
16148
|
+
onTemplateSelect: mutate.selectRootInput,
|
|
16149
|
+
onTemplateValueChange: mutate.changeRuleValue
|
|
16075
16150
|
}), /*#__PURE__*/jsx(RuleGroupFooter, {
|
|
16076
16151
|
groupIndex: index,
|
|
16077
16152
|
groupId: groupId,
|
|
16078
|
-
onGroupDelete:
|
|
16153
|
+
onGroupDelete: mutate.deleteGroup,
|
|
16079
16154
|
onRuleAdd: handleAddRule
|
|
16080
16155
|
})]
|
|
16081
16156
|
})]
|