dce-reactkit 3.2.2-beta.20 → 3.2.2-beta.22
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/cjs/index.js +23 -13
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/ItemPicker/NestableItemList.d.ts +1 -0
- package/dist/esm/index.js +23 -13
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/ItemPicker/NestableItemList.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/ItemPicker/NestableItemList.tsx +32 -14
- package/src/components/LogReviewer.tsx +9 -4
package/dist/esm/index.js
CHANGED
|
@@ -1916,24 +1916,25 @@ const CopiableBox = (props) => {
|
|
|
1916
1916
|
/**
|
|
1917
1917
|
* Reusable nested item picker
|
|
1918
1918
|
* @author Yuen Ler Chow
|
|
1919
|
+
* @author Gabe Abrams
|
|
1919
1920
|
*/
|
|
1920
1921
|
/* ------------- Actions ------------ */
|
|
1921
1922
|
// Types of actions
|
|
1922
1923
|
var ActionType$2;
|
|
1923
1924
|
(function (ActionType) {
|
|
1924
|
-
// Toggle whether
|
|
1925
|
-
ActionType["
|
|
1925
|
+
// Toggle whether a child are being shown
|
|
1926
|
+
ActionType["ToggleChild"] = "toggle-child";
|
|
1926
1927
|
})(ActionType$2 || (ActionType$2 = {}));
|
|
1927
1928
|
/**
|
|
1928
1929
|
* Reducer that executes actions
|
|
1929
|
-
* @author
|
|
1930
|
+
* @author Gabe Abrams
|
|
1930
1931
|
* @param state current state
|
|
1931
1932
|
* @param action action to execute
|
|
1932
1933
|
*/
|
|
1933
1934
|
const reducer$2 = (state, action) => {
|
|
1934
1935
|
switch (action.type) {
|
|
1935
|
-
case ActionType$2.
|
|
1936
|
-
return {
|
|
1936
|
+
case ActionType$2.ToggleChild: {
|
|
1937
|
+
return Object.assign(Object.assign({}, state), { childExpanded: Object.assign(Object.assign({}, state.childExpanded), { [String(action.id)]: !state.childExpanded[String(action.id)] }) });
|
|
1937
1938
|
}
|
|
1938
1939
|
default: {
|
|
1939
1940
|
return state;
|
|
@@ -1951,14 +1952,19 @@ const NestableItemList = (props) => {
|
|
|
1951
1952
|
// Destructure all props
|
|
1952
1953
|
const { items, onChanged, } = props;
|
|
1953
1954
|
/* -------------- State ------------- */
|
|
1955
|
+
// Create initial map of child expanded booleans
|
|
1956
|
+
const initChildExpanded = {};
|
|
1957
|
+
items.forEach((item) => {
|
|
1958
|
+
initChildExpanded[String(item.id)] = false;
|
|
1959
|
+
});
|
|
1954
1960
|
// Initial state
|
|
1955
1961
|
const initialState = {
|
|
1956
|
-
|
|
1962
|
+
childExpanded: initChildExpanded,
|
|
1957
1963
|
};
|
|
1958
1964
|
// Initialize state
|
|
1959
1965
|
const [state, dispatch] = useReducer(reducer$2, initialState);
|
|
1960
1966
|
// Destructure common state
|
|
1961
|
-
const {
|
|
1967
|
+
const { childExpanded, } = state;
|
|
1962
1968
|
/*------------------------------------------------------------------------*/
|
|
1963
1969
|
/* Component Functions */
|
|
1964
1970
|
/*------------------------------------------------------------------------*/
|
|
@@ -2046,14 +2052,15 @@ const NestableItemList = (props) => {
|
|
|
2046
2052
|
backgroundColor: 'transparent',
|
|
2047
2053
|
}, type: "button", onClick: () => {
|
|
2048
2054
|
dispatch({
|
|
2049
|
-
type: ActionType$2.
|
|
2055
|
+
type: ActionType$2.ToggleChild,
|
|
2056
|
+
id: item.id,
|
|
2050
2057
|
});
|
|
2051
|
-
}, "aria-label": `${
|
|
2052
|
-
React.createElement(FontAwesomeIcon, { icon:
|
|
2058
|
+
}, "aria-label": `${childExpanded[item.id] ? 'Hide' : 'Show'} items in ${item.name}` },
|
|
2059
|
+
React.createElement(FontAwesomeIcon, { icon: childExpanded[item.id] ? faChevronDown : faChevronRight })))),
|
|
2053
2060
|
React.createElement(CheckboxButton, { className: `NestableItemList-CheckboxButton-${item.id}`, text: item.name, checked: item.isGroup ? allChecked(item.children) : item.checked, dashed: item.isGroup ? !noneChecked(item.children) : false, onChanged: (checked) => {
|
|
2054
2061
|
onChanged(changeChecked(item.id, checked, items));
|
|
2055
2062
|
}, ariaLabel: `Select ${item.name}`, checkedVariant: Variant$1.Light }),
|
|
2056
|
-
item.isGroup &&
|
|
2063
|
+
(item.isGroup && childExpanded[item.id]) && (React.createElement("div", { className: "NestableItemList-children-container", style: {
|
|
2057
2064
|
paddingLeft: '2.2rem',
|
|
2058
2065
|
} },
|
|
2059
2066
|
React.createElement(NestableItemList, { items: item.children, onChanged: (updatedItems) => {
|
|
@@ -3106,7 +3113,7 @@ const LogReviewer = (props) => {
|
|
|
3106
3113
|
})
|
|
3107
3114
|
.map((subcontext) => {
|
|
3108
3115
|
return {
|
|
3109
|
-
id:
|
|
3116
|
+
id: subcontext,
|
|
3110
3117
|
name: genHumanReadableName(subcontext),
|
|
3111
3118
|
isGroup: false,
|
|
3112
3119
|
checked: !!value[subcontext],
|
|
@@ -3129,7 +3136,10 @@ const LogReviewer = (props) => {
|
|
|
3129
3136
|
if (pickableItem.isGroup) {
|
|
3130
3137
|
// Has subcontexts
|
|
3131
3138
|
pickableItem.children.forEach((subcontextItem) => {
|
|
3132
|
-
|
|
3139
|
+
if (!subcontextItem.isGroup) {
|
|
3140
|
+
contextFilterState[pickableItem.id][subcontextItem.id] = (subcontextItem.checked);
|
|
3141
|
+
console.log('Update child:', pickableItem.id, subcontextItem.id, subcontextItem.checked);
|
|
3142
|
+
}
|
|
3133
3143
|
});
|
|
3134
3144
|
}
|
|
3135
3145
|
else {
|