@backstage/plugin-techdocs-module-addons-contrib 1.1.30-next.0 → 1.1.30-next.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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @backstage/plugin-techdocs-module-addons-contrib
|
|
2
2
|
|
|
3
|
+
## 1.1.30-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 6929480: ExpandableCollapse Techdocs Addon was breaking native sidebar collapse on Firefox
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/core-components@0.18.3-next.1
|
|
10
|
+
- @backstage/core-plugin-api@1.11.2-next.1
|
|
11
|
+
- @backstage/frontend-plugin-api@0.12.2-next.1
|
|
12
|
+
|
|
3
13
|
## 1.1.30-next.0
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import { useState,
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
3
3
|
import { useLocalStorageValue } from '@react-hookz/web';
|
|
4
4
|
import { withStyles, Button } from '@material-ui/core';
|
|
5
5
|
import ChevronRightIcon from '@material-ui/icons/ChevronRight';
|
|
@@ -41,69 +41,41 @@ const ExpandableNavigationAddon = () => {
|
|
|
41
41
|
const [...checkboxToggles] = useShadowRootElements([
|
|
42
42
|
NESTED_LIST_TOGGLE
|
|
43
43
|
]);
|
|
44
|
-
|
|
45
|
-
(item) => {
|
|
46
|
-
const isExpanded = item.checked;
|
|
47
|
-
const shouldExpand = expanded?.expandAllNestedNavs;
|
|
48
|
-
if (shouldExpand && !isExpanded) {
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
if (!shouldExpand && isExpanded) {
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
return false;
|
|
55
|
-
},
|
|
56
|
-
[expanded]
|
|
57
|
-
);
|
|
58
|
-
const handleKeyPass = (event, toggleAction) => {
|
|
44
|
+
function handleKeyPass(event, toggleAction) {
|
|
59
45
|
if (event.key === "Enter" || event.key === " ") {
|
|
60
46
|
event.preventDefault();
|
|
61
47
|
toggleAction();
|
|
62
48
|
}
|
|
63
|
-
}
|
|
49
|
+
}
|
|
64
50
|
useEffect(() => {
|
|
65
51
|
if (!checkboxToggles?.length) return;
|
|
66
52
|
setHasNavSubLevels(true);
|
|
67
|
-
|
|
68
|
-
item.tabIndex = 0;
|
|
69
|
-
const toggleAction = () => {
|
|
70
|
-
if (shouldToggle(item)) {
|
|
71
|
-
item.click();
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
const keydownHandler = (event) => {
|
|
75
|
-
handleKeyPass(
|
|
76
|
-
event,
|
|
77
|
-
toggleAction
|
|
78
|
-
);
|
|
79
|
-
};
|
|
80
|
-
item.addEventListener("keydown", keydownHandler);
|
|
81
|
-
item.addEventListener("click", toggleAction);
|
|
82
|
-
return () => {
|
|
83
|
-
item.removeEventListener("keydown", keydownHandler);
|
|
84
|
-
item.removeEventListener("click", toggleAction);
|
|
85
|
-
};
|
|
86
|
-
});
|
|
87
|
-
}, [checkboxToggles, shouldToggle]);
|
|
53
|
+
}, [checkboxToggles]);
|
|
88
54
|
useEffect(() => {
|
|
89
55
|
if (!checkboxToggles?.length) return;
|
|
90
|
-
|
|
56
|
+
function shouldToggle(item) {
|
|
57
|
+
return expanded?.expandAllNestedNavs !== item.checked;
|
|
58
|
+
}
|
|
59
|
+
for (const item of checkboxToggles) {
|
|
91
60
|
if (shouldToggle(item)) {
|
|
92
61
|
item.click();
|
|
93
62
|
}
|
|
94
|
-
}
|
|
95
|
-
}, [expanded, checkboxToggles
|
|
63
|
+
}
|
|
64
|
+
}, [expanded, checkboxToggles]);
|
|
96
65
|
const handleState = () => {
|
|
97
66
|
setExpanded((prevState) => ({
|
|
98
67
|
expandAllNestedNavs: !prevState?.expandAllNestedNavs
|
|
99
68
|
}));
|
|
100
69
|
};
|
|
70
|
+
function handleButtonKeyDown(event) {
|
|
71
|
+
handleKeyPass(event, handleState);
|
|
72
|
+
}
|
|
101
73
|
return /* @__PURE__ */ jsx(Fragment, { children: hasNavSubLevels ? /* @__PURE__ */ jsx(
|
|
102
74
|
StyledButton,
|
|
103
75
|
{
|
|
104
76
|
size: "small",
|
|
105
77
|
onClick: handleState,
|
|
106
|
-
onKeyDown:
|
|
78
|
+
onKeyDown: handleButtonKeyDown,
|
|
107
79
|
tabIndex: 0,
|
|
108
80
|
"aria-expanded": expanded?.expandAllNestedNavs,
|
|
109
81
|
"aria-label": expanded?.expandAllNestedNavs ? "collapse-nav" : "expand-nav",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpandableNavigation.esm.js","sources":["../../src/ExpandableNavigation/ExpandableNavigation.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect,
|
|
1
|
+
{"version":3,"file":"ExpandableNavigation.esm.js","sources":["../../src/ExpandableNavigation/ExpandableNavigation.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect, useState } from 'react';\nimport { useLocalStorageValue } from '@react-hookz/web';\nimport { Button, withStyles } from '@material-ui/core';\nimport ChevronRightIcon from '@material-ui/icons/ChevronRight';\nimport ExpandMoreIcon from '@material-ui/icons/ExpandMore';\n\nimport { useShadowRootElements } from '@backstage/plugin-techdocs-react';\n\nconst NESTED_LIST_TOGGLE = '.md-nav__item--nested .md-toggle';\n\nconst EXPANDABLE_NAVIGATION_LOCAL_STORAGE =\n '@backstage/techdocs-addons/nav-expanded';\n\nconst StyledButton = withStyles({\n root: {\n position: 'absolute',\n left: '13.7rem', // Sidebar inner width (15.1em) minus the different margins/paddings\n top: '19px',\n zIndex: 2,\n padding: 0,\n minWidth: 0,\n },\n})(Button);\n\nconst CollapsedIcon = withStyles({\n root: {\n height: '20px',\n width: '20px',\n },\n})(ChevronRightIcon);\n\nconst ExpandedIcon = withStyles({\n root: {\n height: '20px',\n width: '20px',\n },\n})(ExpandMoreIcon);\n\ntype expandableNavigationLocalStorage = {\n expandAllNestedNavs: boolean;\n};\n\n/**\n * Show expand/collapse navigation button next to site name in main\n * navigation menu if documentation site has nested navigation.\n */\nexport const ExpandableNavigationAddon = () => {\n const defaultValue = { expandAllNestedNavs: false };\n const { value: expanded, set: setExpanded } =\n useLocalStorageValue<expandableNavigationLocalStorage>(\n EXPANDABLE_NAVIGATION_LOCAL_STORAGE,\n { defaultValue },\n );\n const [hasNavSubLevels, setHasNavSubLevels] = useState<boolean>(false);\n\n const [...checkboxToggles] = useShadowRootElements<HTMLInputElement>([\n NESTED_LIST_TOGGLE,\n ]);\n\n // Define handleKeyPass as a named function\n function handleKeyPass(\n event: React.KeyboardEvent<HTMLElement>,\n toggleAction: () => void,\n ) {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n toggleAction();\n }\n }\n\n useEffect(() => {\n if (!checkboxToggles?.length) return;\n setHasNavSubLevels(true);\n }, [checkboxToggles]);\n\n useEffect(() => {\n if (!checkboxToggles?.length) return;\n function shouldToggle(item: HTMLInputElement) {\n return expanded?.expandAllNestedNavs !== item.checked;\n }\n for (const item of checkboxToggles) {\n if (shouldToggle(item)) {\n item.click();\n }\n }\n }, [expanded, checkboxToggles]);\n\n const handleState = () => {\n setExpanded(prevState => ({\n expandAllNestedNavs: !prevState?.expandAllNestedNavs,\n }));\n };\n\n function handleButtonKeyDown(event: React.KeyboardEvent<HTMLElement>) {\n handleKeyPass(event, handleState);\n }\n\n return (\n <>\n {hasNavSubLevels ? (\n <StyledButton\n size=\"small\"\n onClick={handleState}\n onKeyDown={handleButtonKeyDown}\n tabIndex={0} // Ensuring keyboard focus\n aria-expanded={expanded?.expandAllNestedNavs} // Accessibility\n aria-label={\n expanded?.expandAllNestedNavs ? 'collapse-nav' : 'expand-nav'\n }\n >\n {expanded?.expandAllNestedNavs ? <ExpandedIcon /> : <CollapsedIcon />}\n </StyledButton>\n ) : null}\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AAwBA,MAAM,kBAAA,GAAqB,kCAAA;AAE3B,MAAM,mCAAA,GACJ,yCAAA;AAEF,MAAM,eAAe,UAAA,CAAW;AAAA,EAC9B,IAAA,EAAM;AAAA,IACJ,QAAA,EAAU,UAAA;AAAA,IACV,IAAA,EAAM,SAAA;AAAA;AAAA,IACN,GAAA,EAAK,MAAA;AAAA,IACL,MAAA,EAAQ,CAAA;AAAA,IACR,OAAA,EAAS,CAAA;AAAA,IACT,QAAA,EAAU;AAAA;AAEd,CAAC,EAAE,MAAM,CAAA;AAET,MAAM,gBAAgB,UAAA,CAAW;AAAA,EAC/B,IAAA,EAAM;AAAA,IACJ,MAAA,EAAQ,MAAA;AAAA,IACR,KAAA,EAAO;AAAA;AAEX,CAAC,EAAE,gBAAgB,CAAA;AAEnB,MAAM,eAAe,UAAA,CAAW;AAAA,EAC9B,IAAA,EAAM;AAAA,IACJ,MAAA,EAAQ,MAAA;AAAA,IACR,KAAA,EAAO;AAAA;AAEX,CAAC,EAAE,cAAc,CAAA;A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AA,MACxB,mBAAA,EAAqB,CAAC,SAAA,EAAW;AAAA,KACnC,CAAE,CAAA;AAAA,EACJ,CAAA;AAEA,EAAA,SAAS,oBAAoB,KAAA,EAAyC;AACpE,IAAA,aAAA,CAAc,OAAO,WAAW,CAAA;AAAA,EAClC;AAEA,EAAA,uCAEK,QAAA,EAAA,eAAA,mBACC,GAAA;AAAA,IAAC,YAAA;AAAA,IAAA;AAAA,MACC,IAAA,EAAK,OAAA;AAAA,MACL,OAAA,EAAS,WAAA;AAAA,MACT,SAAA,EAAW,mBAAA;AAAA,MACX,QAAA,EAAU,CAAA;AAAA,MACV,iBAAe,QAAA,EAAU,mBAAA;AAAA,MACzB,YAAA,EACE,QAAA,EAAU,mBAAA,GAAsB,cAAA,GAAiB,YAAA;AAAA,MAGlD,oBAAU,mBAAA,mBAAsB,GAAA,CAAC,YAAA,EAAA,EAAa,CAAA,uBAAM,aAAA,EAAA,EAAc;AAAA;AAAA,MAEnE,IAAA,EACN,CAAA;AAEJ;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-techdocs-module-addons-contrib",
|
|
3
|
-
"version": "1.1.30-next.
|
|
3
|
+
"version": "1.1.30-next.1",
|
|
4
4
|
"description": "Plugin module for contributed TechDocs Addons",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "frontend-plugin-module",
|
|
@@ -60,9 +60,9 @@
|
|
|
60
60
|
"test": "backstage-cli package test"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@backstage/core-components": "0.18.3-next.
|
|
64
|
-
"@backstage/core-plugin-api": "1.11.2-next.
|
|
65
|
-
"@backstage/frontend-plugin-api": "0.12.2-next.
|
|
63
|
+
"@backstage/core-components": "0.18.3-next.1",
|
|
64
|
+
"@backstage/core-plugin-api": "1.11.2-next.1",
|
|
65
|
+
"@backstage/frontend-plugin-api": "0.12.2-next.1",
|
|
66
66
|
"@backstage/integration": "1.18.2-next.0",
|
|
67
67
|
"@backstage/integration-react": "1.2.12-next.0",
|
|
68
68
|
"@backstage/plugin-techdocs-react": "1.3.5-next.0",
|
|
@@ -73,9 +73,9 @@
|
|
|
73
73
|
"photoswipe": "^5.3.7"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
|
-
"@backstage/cli": "0.34.5-next.
|
|
77
|
-
"@backstage/plugin-catalog-react": "1.21.3-next.
|
|
78
|
-
"@backstage/plugin-techdocs-addons-test-utils": "1.1.2-next.
|
|
76
|
+
"@backstage/cli": "0.34.5-next.1",
|
|
77
|
+
"@backstage/plugin-catalog-react": "1.21.3-next.1",
|
|
78
|
+
"@backstage/plugin-techdocs-addons-test-utils": "1.1.2-next.1",
|
|
79
79
|
"@backstage/test-utils": "1.7.13-next.0",
|
|
80
80
|
"@testing-library/dom": "^10.0.0",
|
|
81
81
|
"@testing-library/jest-dom": "^6.0.0",
|