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/cjs/index.js
CHANGED
|
@@ -1924,24 +1924,25 @@ const CopiableBox = (props) => {
|
|
|
1924
1924
|
/**
|
|
1925
1925
|
* Reusable nested item picker
|
|
1926
1926
|
* @author Yuen Ler Chow
|
|
1927
|
+
* @author Gabe Abrams
|
|
1927
1928
|
*/
|
|
1928
1929
|
/* ------------- Actions ------------ */
|
|
1929
1930
|
// Types of actions
|
|
1930
1931
|
var ActionType$2;
|
|
1931
1932
|
(function (ActionType) {
|
|
1932
|
-
// Toggle whether
|
|
1933
|
-
ActionType["
|
|
1933
|
+
// Toggle whether a child are being shown
|
|
1934
|
+
ActionType["ToggleChild"] = "toggle-child";
|
|
1934
1935
|
})(ActionType$2 || (ActionType$2 = {}));
|
|
1935
1936
|
/**
|
|
1936
1937
|
* Reducer that executes actions
|
|
1937
|
-
* @author
|
|
1938
|
+
* @author Gabe Abrams
|
|
1938
1939
|
* @param state current state
|
|
1939
1940
|
* @param action action to execute
|
|
1940
1941
|
*/
|
|
1941
1942
|
const reducer$2 = (state, action) => {
|
|
1942
1943
|
switch (action.type) {
|
|
1943
|
-
case ActionType$2.
|
|
1944
|
-
return {
|
|
1944
|
+
case ActionType$2.ToggleChild: {
|
|
1945
|
+
return Object.assign(Object.assign({}, state), { childExpanded: Object.assign(Object.assign({}, state.childExpanded), { [String(action.id)]: !state.childExpanded[String(action.id)] }) });
|
|
1945
1946
|
}
|
|
1946
1947
|
default: {
|
|
1947
1948
|
return state;
|
|
@@ -1959,14 +1960,19 @@ const NestableItemList = (props) => {
|
|
|
1959
1960
|
// Destructure all props
|
|
1960
1961
|
const { items, onChanged, } = props;
|
|
1961
1962
|
/* -------------- State ------------- */
|
|
1963
|
+
// Create initial map of child expanded booleans
|
|
1964
|
+
const initChildExpanded = {};
|
|
1965
|
+
items.forEach((item) => {
|
|
1966
|
+
initChildExpanded[String(item.id)] = false;
|
|
1967
|
+
});
|
|
1962
1968
|
// Initial state
|
|
1963
1969
|
const initialState = {
|
|
1964
|
-
|
|
1970
|
+
childExpanded: initChildExpanded,
|
|
1965
1971
|
};
|
|
1966
1972
|
// Initialize state
|
|
1967
1973
|
const [state, dispatch] = React.useReducer(reducer$2, initialState);
|
|
1968
1974
|
// Destructure common state
|
|
1969
|
-
const {
|
|
1975
|
+
const { childExpanded, } = state;
|
|
1970
1976
|
/*------------------------------------------------------------------------*/
|
|
1971
1977
|
/* Component Functions */
|
|
1972
1978
|
/*------------------------------------------------------------------------*/
|
|
@@ -2054,14 +2060,15 @@ const NestableItemList = (props) => {
|
|
|
2054
2060
|
backgroundColor: 'transparent',
|
|
2055
2061
|
}, type: "button", onClick: () => {
|
|
2056
2062
|
dispatch({
|
|
2057
|
-
type: ActionType$2.
|
|
2063
|
+
type: ActionType$2.ToggleChild,
|
|
2064
|
+
id: item.id,
|
|
2058
2065
|
});
|
|
2059
|
-
}, "aria-label": `${
|
|
2060
|
-
React__default["default"].createElement(reactFontawesome.FontAwesomeIcon, { icon:
|
|
2066
|
+
}, "aria-label": `${childExpanded[item.id] ? 'Hide' : 'Show'} items in ${item.name}` },
|
|
2067
|
+
React__default["default"].createElement(reactFontawesome.FontAwesomeIcon, { icon: childExpanded[item.id] ? freeSolidSvgIcons.faChevronDown : freeSolidSvgIcons.faChevronRight })))),
|
|
2061
2068
|
React__default["default"].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) => {
|
|
2062
2069
|
onChanged(changeChecked(item.id, checked, items));
|
|
2063
2070
|
}, ariaLabel: `Select ${item.name}`, checkedVariant: Variant$1.Light }),
|
|
2064
|
-
item.isGroup &&
|
|
2071
|
+
(item.isGroup && childExpanded[item.id]) && (React__default["default"].createElement("div", { className: "NestableItemList-children-container", style: {
|
|
2065
2072
|
paddingLeft: '2.2rem',
|
|
2066
2073
|
} },
|
|
2067
2074
|
React__default["default"].createElement(NestableItemList, { items: item.children, onChanged: (updatedItems) => {
|
|
@@ -3114,7 +3121,7 @@ const LogReviewer = (props) => {
|
|
|
3114
3121
|
})
|
|
3115
3122
|
.map((subcontext) => {
|
|
3116
3123
|
return {
|
|
3117
|
-
id:
|
|
3124
|
+
id: subcontext,
|
|
3118
3125
|
name: genHumanReadableName(subcontext),
|
|
3119
3126
|
isGroup: false,
|
|
3120
3127
|
checked: !!value[subcontext],
|
|
@@ -3137,7 +3144,10 @@ const LogReviewer = (props) => {
|
|
|
3137
3144
|
if (pickableItem.isGroup) {
|
|
3138
3145
|
// Has subcontexts
|
|
3139
3146
|
pickableItem.children.forEach((subcontextItem) => {
|
|
3140
|
-
|
|
3147
|
+
if (!subcontextItem.isGroup) {
|
|
3148
|
+
contextFilterState[pickableItem.id][subcontextItem.id] = (subcontextItem.checked);
|
|
3149
|
+
console.log('Update child:', pickableItem.id, subcontextItem.id, subcontextItem.checked);
|
|
3150
|
+
}
|
|
3141
3151
|
});
|
|
3142
3152
|
}
|
|
3143
3153
|
else {
|