@redocly/theme 0.56.0-next.2 → 0.56.0-next.3
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/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityDefaultRelations.d.ts +1 -0
- package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityDefaultRelations.js +9 -0
- package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations.js +31 -6
- package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable.d.ts +0 -1
- package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityTeamRelations.d.ts +2 -1
- package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityTeamRelations.js +11 -5
- package/lib/components/Catalog/CatalogEntityIcon.js +6 -0
- package/lib/components/Catalog/CatalogTableView/CatalogEntityCell.d.ts +6 -4
- package/lib/components/Catalog/CatalogTableView/CatalogEntityRelationCell.d.ts +3 -0
- package/lib/components/Catalog/CatalogTableView/CatalogEntityRelationCell.js +11 -0
- package/lib/components/Catalog/CatalogTableView/CatalogTableView.js +4 -0
- package/lib/components/Catalog/CatalogTableView/CatalogTableViewRow.js +4 -0
- package/lib/components/Catalog/CatalogTagsWithTooltip.js +2 -3
- package/lib/components/Catalog/variables.js +2 -2
- package/lib/components/Tags/CounterTag.d.ts +1 -1
- package/lib/components/Tags/HttpTag.d.ts +1 -1
- package/lib/core/constants/catalog.d.ts +3 -0
- package/lib/core/constants/catalog.js +55 -1
- package/lib/core/constants/index.d.ts +5 -5
- package/lib/core/constants/index.js +5 -5
- package/lib/core/constants/search.d.ts +1 -1
- package/lib/core/contexts/CodeWalkthrough/CodeWalkthroughControlsContext.d.ts +1 -1
- package/lib/core/contexts/CodeWalkthrough/CodeWalkthroughStepsContext.d.ts +1 -1
- package/lib/core/contexts/ThemeDataContext.d.ts +1 -1
- package/lib/core/contexts/index.d.ts +3 -3
- package/lib/core/contexts/index.js +3 -3
- package/lib/core/hoc/index.d.ts +1 -1
- package/lib/core/hoc/index.js +1 -1
- package/lib/core/hooks/__mocks__/index.d.ts +28 -28
- package/lib/core/hooks/__mocks__/index.js +28 -28
- package/lib/core/hooks/catalog/useCatalogEntities.d.ts +1 -1
- package/lib/core/hooks/catalog/useCatalogTableViewRow.js +2 -2
- package/lib/core/hooks/code-walkthrough/use-code-panel.js +6 -5
- package/lib/core/hooks/code-walkthrough/use-code-walkthrough-controls.js +8 -5
- package/lib/core/hooks/code-walkthrough/use-code-walkthrough-steps.d.ts +1 -1
- package/lib/core/hooks/code-walkthrough/use-code-walkthrough-steps.js +9 -9
- package/lib/core/hooks/code-walkthrough/use-code-walkthrough.d.ts +2 -2
- package/lib/core/hooks/code-walkthrough/use-code-walkthrough.js +4 -3
- package/lib/core/hooks/code-walkthrough/use-renderable-files.js +6 -4
- package/lib/core/hooks/feedback/use-report-dialog.js +4 -3
- package/lib/core/hooks/index.d.ts +42 -42
- package/lib/core/hooks/index.js +42 -42
- package/lib/core/hooks/menu/use-menu-item-expanded.d.ts +1 -1
- package/lib/core/hooks/menu/use-mobile-menu-items.d.ts +1 -1
- package/lib/core/hooks/menu/use-mobile-menu-items.js +13 -12
- package/lib/core/hooks/menu/use-mobile-menu-levels.d.ts +1 -1
- package/lib/core/hooks/menu/use-mobile-menu-levels.js +8 -7
- package/lib/core/hooks/menu/use-nested-menu.d.ts +1 -1
- package/lib/core/hooks/menu/use-nested-menu.js +8 -6
- package/lib/core/hooks/search/use-recent-searches.js +3 -3
- package/lib/core/hooks/search/use-search-dialog.js +4 -3
- package/lib/core/hooks/search/use-search-filter.d.ts +1 -1
- package/lib/core/hooks/search/use-suggested-pages.js +2 -2
- package/lib/core/hooks/use-active-page-version.js +2 -2
- package/lib/core/hooks/use-active-section-id.js +2 -2
- package/lib/core/hooks/use-color-switcher.js +4 -3
- package/lib/core/hooks/use-input-key-commands.js +2 -2
- package/lib/core/hooks/use-language-picker.d.ts +1 -1
- package/lib/core/hooks/use-language-picker.js +4 -4
- package/lib/core/hooks/use-mobile-menu.js +2 -2
- package/lib/core/hooks/use-navbar-height.js +3 -3
- package/lib/core/hooks/use-page-versions.js +2 -2
- package/lib/core/hooks/use-product-picker.js +2 -2
- package/lib/core/hooks/use-theme-config.js +2 -2
- package/lib/core/hooks/use-theme-hooks.d.ts +1 -1
- package/lib/core/hooks/use-theme-hooks.js +2 -2
- package/lib/core/hooks/use-time-ago.js +2 -2
- package/lib/core/hooks/use-user-teams.js +2 -2
- package/lib/core/index.d.ts +7 -7
- package/lib/core/index.js +7 -7
- package/lib/core/openapi/index.d.ts +18 -0
- package/lib/core/openapi/index.js +48 -0
- package/lib/core/styles/global.js +1 -1
- package/lib/core/styles/index.d.ts +2 -2
- package/lib/core/styles/index.js +2 -2
- package/lib/core/templates/Markdown.d.ts +1 -1
- package/lib/core/templates/Markdown.js +8 -6
- package/lib/core/types/catalog.d.ts +6 -2
- package/lib/core/types/code-walkthrough.d.ts +1 -1
- package/lib/core/types/feedback.d.ts +1 -1
- package/lib/core/types/filter.d.ts +1 -1
- package/lib/core/types/hooks.d.ts +11 -3
- package/lib/core/types/index.d.ts +18 -18
- package/lib/core/types/index.js +18 -18
- package/lib/core/types/search.d.ts +1 -1
- package/lib/core/types/sidebar.d.ts +1 -1
- package/lib/core/utils/download-code-walkthrough.js +6 -4
- package/lib/core/utils/get-code-walkthrough-file-text.js +4 -3
- package/lib/core/utils/index.d.ts +35 -35
- package/lib/core/utils/index.js +35 -35
- package/lib/core/utils/load-and-navigate.js +2 -2
- package/lib/core/utils/match-code-walkthrough-conditions.js +3 -3
- package/lib/core/utils/menu.d.ts +3 -2
- package/lib/core/utils/menu.js +12 -12
- package/lib/core/utils/toc.d.ts +1 -1
- package/lib/core/utils/type-guards.d.ts +1 -1
- package/lib/core/utils/type-guards.js +5 -5
- package/lib/core/utils/urls.d.ts +1 -1
- package/lib/core/utils/urls.js +2 -2
- package/lib/markdoc/components/Tabs/TabList.js +2 -0
- package/package.json +1 -1
- package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityDefaultRelations.tsx +15 -0
- package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations.tsx +8 -2
- package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable.tsx +0 -1
- package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityTeamRelations.tsx +16 -3
- package/src/components/Catalog/CatalogEntityIcon.tsx +6 -0
- package/src/components/Catalog/CatalogTableView/CatalogEntityCell.tsx +5 -4
- package/src/components/Catalog/CatalogTableView/CatalogEntityRelationCell.tsx +19 -0
- package/src/components/Catalog/CatalogTableView/CatalogTableView.tsx +4 -0
- package/src/components/Catalog/CatalogTableView/CatalogTableViewRow.tsx +4 -0
- package/src/components/Catalog/CatalogTagsWithTooltip.tsx +7 -15
- package/src/components/Catalog/variables.ts +2 -2
- package/src/core/constants/catalog.ts +58 -0
- package/src/core/constants/index.ts +5 -5
- package/src/core/constants/search.ts +1 -1
- package/src/core/contexts/CodeWalkthrough/CodeWalkthroughControlsContext.tsx +1 -1
- package/src/core/contexts/CodeWalkthrough/CodeWalkthroughStepsContext.tsx +1 -1
- package/src/core/contexts/ThemeDataContext.tsx +3 -3
- package/src/core/contexts/index.ts +3 -3
- package/src/core/hoc/index.ts +1 -1
- package/src/core/hooks/__mocks__/index.ts +28 -28
- package/src/core/hooks/catalog/useCatalogEntities.ts +1 -1
- package/src/core/hooks/catalog/useCatalogTableViewRow.ts +1 -1
- package/src/core/hooks/code-walkthrough/use-code-panel.ts +3 -5
- package/src/core/hooks/code-walkthrough/use-code-walkthrough-controls.ts +4 -6
- package/src/core/hooks/code-walkthrough/use-code-walkthrough-steps.ts +4 -3
- package/src/core/hooks/code-walkthrough/use-code-walkthrough.ts +3 -3
- package/src/core/hooks/code-walkthrough/use-renderable-files.ts +4 -6
- package/src/core/hooks/feedback/use-report-dialog.ts +3 -2
- package/src/core/hooks/index.ts +42 -42
- package/src/core/hooks/menu/use-menu-item-expanded.ts +1 -1
- package/src/core/hooks/menu/use-mobile-menu-items.ts +4 -7
- package/src/core/hooks/menu/use-mobile-menu-levels.ts +3 -2
- package/src/core/hooks/menu/use-nested-menu.ts +5 -3
- package/src/core/hooks/search/use-recent-searches.ts +1 -1
- package/src/core/hooks/search/use-search-dialog.ts +2 -1
- package/src/core/hooks/search/use-search-filter.ts +1 -1
- package/src/core/hooks/search/use-suggested-pages.ts +1 -1
- package/src/core/hooks/use-active-page-version.ts +1 -1
- package/src/core/hooks/use-active-section-id.ts +1 -1
- package/src/core/hooks/use-codeblock-tabs-controls.ts +1 -1
- package/src/core/hooks/use-color-switcher.ts +2 -1
- package/src/core/hooks/use-input-key-commands.ts +1 -1
- package/src/core/hooks/use-language-picker.ts +3 -3
- package/src/core/hooks/use-mobile-menu.ts +1 -1
- package/src/core/hooks/use-navbar-height.ts +1 -1
- package/src/core/hooks/use-page-versions.ts +1 -1
- package/src/core/hooks/use-product-picker.ts +1 -1
- package/src/core/hooks/use-theme-config.ts +2 -2
- package/src/core/hooks/use-theme-hooks.ts +2 -2
- package/src/core/hooks/use-time-ago.ts +3 -2
- package/src/core/hooks/use-user-teams.ts +1 -1
- package/src/core/index.ts +7 -7
- package/src/core/openapi/index.ts +31 -0
- package/src/core/styles/global.ts +2 -1
- package/src/core/styles/index.ts +2 -2
- package/src/core/templates/Markdown.tsx +8 -4
- package/src/core/types/catalog.ts +15 -2
- package/src/core/types/code-walkthrough.ts +1 -1
- package/src/core/types/feedback.ts +6 -6
- package/src/core/types/filter.ts +1 -1
- package/src/core/types/hooks.ts +17 -16
- package/src/core/types/index.ts +18 -18
- package/src/core/types/search.ts +1 -1
- package/src/core/types/sidebar.ts +1 -1
- package/src/core/utils/download-code-walkthrough.ts +3 -5
- package/src/core/utils/get-code-walkthrough-file-text.ts +2 -1
- package/src/core/utils/index.ts +35 -35
- package/src/core/utils/load-and-navigate.ts +1 -1
- package/src/core/utils/match-code-walkthrough-conditions.ts +1 -1
- package/src/core/utils/menu.ts +4 -3
- package/src/core/utils/toc.ts +1 -1
- package/src/core/utils/type-guards.ts +2 -2
- package/src/core/utils/urls.ts +2 -2
- package/src/markdoc/components/Tabs/TabList.tsx +1 -0
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useCodePanel = useCodePanel;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const CodeWalkthroughControlsContext_1 = require("../../contexts/CodeWalkthrough/CodeWalkthroughControlsContext");
|
|
6
|
+
const CodeWalkthroughStepsContext_1 = require("../../contexts/CodeWalkthrough/CodeWalkthroughStepsContext");
|
|
7
|
+
const use_theme_hooks_1 = require("../use-theme-hooks");
|
|
7
8
|
const ACTIVE_FILE_MOCK = {
|
|
8
9
|
content: [],
|
|
9
10
|
path: '',
|
|
@@ -12,9 +13,9 @@ const ACTIVE_FILE_MOCK = {
|
|
|
12
13
|
language: '',
|
|
13
14
|
};
|
|
14
15
|
function useCodePanel(files) {
|
|
15
|
-
const { activeStep } = (0, react_1.useContext)(
|
|
16
|
-
const { areConditionsMet, populateInputsWithValue } = (0, react_1.useContext)(
|
|
17
|
-
const { useCodeHighlight } = (0,
|
|
16
|
+
const { activeStep } = (0, react_1.useContext)(CodeWalkthroughStepsContext_1.CodeWalkthroughStepsContext);
|
|
17
|
+
const { areConditionsMet, populateInputsWithValue } = (0, react_1.useContext)(CodeWalkthroughControlsContext_1.CodeWalkthroughControlsStateContext);
|
|
18
|
+
const { useCodeHighlight } = (0, use_theme_hooks_1.useThemeHooks)();
|
|
18
19
|
const { highlight } = useCodeHighlight();
|
|
19
20
|
const findFileIndexByName = (0, react_1.useCallback)((name) => {
|
|
20
21
|
return files.findIndex((file) => file.path === name);
|
|
@@ -3,7 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useCodeWalkthroughControls = useCodeWalkthroughControls;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const react_router_dom_1 = require("react-router-dom");
|
|
6
|
-
const
|
|
6
|
+
const download_code_walkthrough_1 = require("../../utils/download-code-walkthrough");
|
|
7
|
+
const match_code_walkthrough_conditions_1 = require("../../utils/match-code-walkthrough-conditions");
|
|
8
|
+
const get_code_walkthrough_file_text_1 = require("../../utils/get-code-walkthrough-file-text");
|
|
9
|
+
const replace_inputs_with_value_1 = require("../../utils/replace-inputs-with-value");
|
|
7
10
|
const defaultControlsValues = {
|
|
8
11
|
input: '',
|
|
9
12
|
toggle: false,
|
|
@@ -102,7 +105,7 @@ function useCodeWalkthroughControls(filters, inputs, toggles, enableDeepLink) {
|
|
|
102
105
|
}
|
|
103
106
|
};
|
|
104
107
|
const walkthroughContext = (0, react_1.useMemo)(() => {
|
|
105
|
-
const areConditionsMet = (conditions) => (0,
|
|
108
|
+
const areConditionsMet = (conditions) => (0, match_code_walkthrough_conditions_1.matchCodeWalkthroughConditions)(conditions, controlsState);
|
|
106
109
|
// reset controls
|
|
107
110
|
for (const control of Object.values(controlsState)) {
|
|
108
111
|
control.render = true;
|
|
@@ -142,9 +145,9 @@ function useCodeWalkthroughControls(filters, inputs, toggles, enableDeepLink) {
|
|
|
142
145
|
});
|
|
143
146
|
}
|
|
144
147
|
const inputsState = Object.fromEntries(Object.entries(controlsState).filter(([_, controlState]) => controlState.type === 'input'));
|
|
145
|
-
const handleDownloadCode = (files) => (0,
|
|
146
|
-
const getFileText = (file) => (0,
|
|
147
|
-
const populateInputsWithValue = (node) => (0,
|
|
148
|
+
const handleDownloadCode = (files) => (0, download_code_walkthrough_1.downloadCodeWalkthrough)(files, controlsState, inputsState);
|
|
149
|
+
const getFileText = (file) => (0, get_code_walkthrough_file_text_1.getCodeWalkthroughFileText)(file, controlsState, inputsState);
|
|
150
|
+
const populateInputsWithValue = (node) => (0, replace_inputs_with_value_1.replaceInputsWithValue)(node, inputsState);
|
|
148
151
|
return {
|
|
149
152
|
activeFilters,
|
|
150
153
|
areConditionsMet,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CodeWalkthroughStepAttr } from '@redocly/config';
|
|
2
|
-
import type { WalkthroughStepsState } from '
|
|
2
|
+
import type { WalkthroughStepsState } from '../../types/code-walkthrough';
|
|
3
3
|
type CodeWalkthroughStep = CodeWalkthroughStepAttr & {
|
|
4
4
|
compRef?: HTMLElement;
|
|
5
5
|
markerRef?: HTMLElement;
|
|
@@ -4,8 +4,8 @@ exports.useCodeWalkthroughSteps = useCodeWalkthroughSteps;
|
|
|
4
4
|
exports.getGroupMarkers = getGroupMarkers;
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const react_router_dom_1 = require("react-router-dom");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
7
|
+
const js_utils_1 = require("../../utils/js-utils");
|
|
8
|
+
const code_walkthrough_1 = require("../../constants/code-walkthrough");
|
|
9
9
|
function useCodeWalkthroughSteps({ steps, enableDeepLink, root, }) {
|
|
10
10
|
const location = (0, react_router_dom_1.useLocation)();
|
|
11
11
|
const navigate = (0, react_router_dom_1.useNavigate)();
|
|
@@ -15,7 +15,7 @@ function useCodeWalkthroughSteps({ steps, enableDeepLink, root, }) {
|
|
|
15
15
|
const lockObserver = (0, react_1.useRef)(false);
|
|
16
16
|
// Track observed elements in case new observer needs to be created
|
|
17
17
|
const observedElementsRef = (0, react_1.useRef)(new Set());
|
|
18
|
-
const [activeStep, setActiveStep] = (0, react_1.useState)(enableDeepLink ? searchParams.get(
|
|
18
|
+
const [activeStep, setActiveStep] = (0, react_1.useState)(enableDeepLink ? searchParams.get(code_walkthrough_1.ACTIVE_STEP_QUERY_PARAM) : null);
|
|
19
19
|
const stepsMap = (0, react_1.useMemo)(() => {
|
|
20
20
|
const map = new Map();
|
|
21
21
|
steps.forEach((step, index) => {
|
|
@@ -26,7 +26,7 @@ function useCodeWalkthroughSteps({ steps, enableDeepLink, root, }) {
|
|
|
26
26
|
}, [JSON.stringify(steps)]);
|
|
27
27
|
const options = (0, react_1.useMemo)(() => {
|
|
28
28
|
var _a, _b;
|
|
29
|
-
if (!(0,
|
|
29
|
+
if (!(0, js_utils_1.isBrowser)()) {
|
|
30
30
|
return null;
|
|
31
31
|
}
|
|
32
32
|
const filtersElementHeight = ((_a = filtersElementRef.current) === null || _a === void 0 ? void 0 : _a.clientHeight) || 0;
|
|
@@ -97,7 +97,7 @@ function useCodeWalkthroughSteps({ steps, enableDeepLink, root, }) {
|
|
|
97
97
|
return;
|
|
98
98
|
}
|
|
99
99
|
step.compRef = element;
|
|
100
|
-
setVisibleSteps((prevSteps) => (0,
|
|
100
|
+
setVisibleSteps((prevSteps) => (0, js_utils_1.insertAt)(prevSteps, step.index, step));
|
|
101
101
|
}, [stepsMap]);
|
|
102
102
|
const removeStep = (0, react_1.useCallback)((stepId) => {
|
|
103
103
|
const step = stepsMap.get(stepId);
|
|
@@ -105,7 +105,7 @@ function useCodeWalkthroughSteps({ steps, enableDeepLink, root, }) {
|
|
|
105
105
|
return;
|
|
106
106
|
}
|
|
107
107
|
step.compRef = undefined;
|
|
108
|
-
setVisibleSteps((prevSteps) => (0,
|
|
108
|
+
setVisibleSteps((prevSteps) => (0, js_utils_1.removeElement)(prevSteps, step));
|
|
109
109
|
setActiveStep((prevStep) => (prevStep === stepId ? null : prevStep));
|
|
110
110
|
}, [stepsMap]);
|
|
111
111
|
const observerCallback = (0, react_1.useCallback)((entries) => {
|
|
@@ -128,7 +128,7 @@ function useCodeWalkthroughSteps({ steps, enableDeepLink, root, }) {
|
|
|
128
128
|
continue;
|
|
129
129
|
}
|
|
130
130
|
const stepIndex = visibleSteps.findIndex((renderedStep) => renderedStep.id === stepId);
|
|
131
|
-
const { next } = (0,
|
|
131
|
+
const { next } = (0, js_utils_1.getAdjacentValues)(visibleSteps, stepIndex);
|
|
132
132
|
const intersectionAtTop = (rootBounds === null || rootBounds === void 0 ? void 0 : rootBounds.bottom) !== undefined && boundingClientRect.top < rootBounds.top;
|
|
133
133
|
const stepGoesIn = isIntersecting;
|
|
134
134
|
if (intersectionRatio > 0.8 && intersectionRatio < 1 && intersectionAtTop) {
|
|
@@ -183,10 +183,10 @@ function useCodeWalkthroughSteps({ steps, enableDeepLink, root, }) {
|
|
|
183
183
|
}
|
|
184
184
|
const newSearchParams = new URLSearchParams(Array.from(searchParams.entries()));
|
|
185
185
|
if (activeStep) {
|
|
186
|
-
newSearchParams.set(
|
|
186
|
+
newSearchParams.set(code_walkthrough_1.ACTIVE_STEP_QUERY_PARAM, activeStep);
|
|
187
187
|
}
|
|
188
188
|
else {
|
|
189
|
-
newSearchParams.delete(
|
|
189
|
+
newSearchParams.delete(code_walkthrough_1.ACTIVE_STEP_QUERY_PARAM);
|
|
190
190
|
}
|
|
191
191
|
const newSearch = newSearchParams.toString();
|
|
192
192
|
if (newSearch === location.search.substring(1))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CodeWalkthroughFile, CodeWalkthroughStepAttr, CodeWalkthroughAttr } from '@redocly/config';
|
|
2
|
-
import type { WalkthroughStepsState } from '
|
|
3
|
-
import { type WalkthroughControlsState } from '
|
|
2
|
+
import type { WalkthroughStepsState } from '../../types/code-walkthrough';
|
|
3
|
+
import { type WalkthroughControlsState } from './use-code-walkthrough-controls';
|
|
4
4
|
export type WalkthroughState = {
|
|
5
5
|
stepsState: WalkthroughStepsState;
|
|
6
6
|
controlsState: WalkthroughControlsState;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useCodeWalkthrough = useCodeWalkthrough;
|
|
4
|
-
const
|
|
4
|
+
const use_code_walkthrough_controls_1 = require("./use-code-walkthrough-controls");
|
|
5
|
+
const use_code_walkthrough_steps_1 = require("./use-code-walkthrough-steps");
|
|
5
6
|
function useCodeWalkthrough({ steps, attributes, root }) {
|
|
6
7
|
const { filters, filesets, inputs, toggles, __idx } = attributes;
|
|
7
8
|
/*
|
|
@@ -11,8 +12,8 @@ function useCodeWalkthrough({ steps, attributes, root }) {
|
|
|
11
12
|
collisions/conflicts in the URL.
|
|
12
13
|
*/
|
|
13
14
|
const enableDeepLink = __idx === 1;
|
|
14
|
-
const stepsState = (0,
|
|
15
|
-
const controlsState = (0,
|
|
15
|
+
const stepsState = (0, use_code_walkthrough_steps_1.useCodeWalkthroughSteps)({ steps, enableDeepLink, root });
|
|
16
|
+
const controlsState = (0, use_code_walkthrough_controls_1.useCodeWalkthroughControls)(filters, inputs, toggles, enableDeepLink);
|
|
16
17
|
const files = filesets
|
|
17
18
|
.filter((fileset) => controlsState.areConditionsMet(fileset))
|
|
18
19
|
.flatMap((fileset) => fileset.files || []);
|
|
@@ -2,16 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useRenderableFiles = useRenderableFiles;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
-
const
|
|
5
|
+
const find_closest_common_directory_1 = require("../../utils/find-closest-common-directory");
|
|
6
|
+
const get_file_icon_1 = require("../../utils/get-file-icon");
|
|
7
|
+
const urls_1 = require("../../utils/urls");
|
|
6
8
|
function useRenderableFiles(files) {
|
|
7
9
|
return (0, react_1.useMemo)(function () {
|
|
8
10
|
const filePaths = files.map(({ path }) => path);
|
|
9
|
-
const rootDir = (0,
|
|
11
|
+
const rootDir = (0, find_closest_common_directory_1.findClosestCommonDirectory)(filePaths);
|
|
10
12
|
const renderableFiles = files.map((file) => {
|
|
11
13
|
const FileIcon = getFileTypeIcon(file.basename);
|
|
12
14
|
const parentFolder = file.path.split('/').slice(-2, -1)[0];
|
|
13
15
|
const isNameDuplicate = files.some((_file) => file.basename === _file.basename && file.path !== _file.path);
|
|
14
|
-
const inRootDir = file.path === `${(0,
|
|
16
|
+
const inRootDir = file.path === `${(0, urls_1.removeLeadingSlash)(rootDir)}/${file.basename}`;
|
|
15
17
|
return Object.assign(Object.assign({}, file), { FileIcon,
|
|
16
18
|
inRootDir,
|
|
17
19
|
parentFolder,
|
|
@@ -23,6 +25,6 @@ function useRenderableFiles(files) {
|
|
|
23
25
|
function getFileTypeIcon(basename) {
|
|
24
26
|
var _a;
|
|
25
27
|
const extension = ((_a = basename.split('.').pop()) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || '';
|
|
26
|
-
return (0,
|
|
28
|
+
return (0, get_file_icon_1.getFileIconByExt)(extension);
|
|
27
29
|
}
|
|
28
30
|
//# sourceMappingURL=use-renderable-files.js.map
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useReportDialog = useReportDialog;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
-
const
|
|
5
|
+
const use_theme_hooks_1 = require("../use-theme-hooks");
|
|
6
|
+
const use_theme_config_1 = require("../use-theme-config");
|
|
6
7
|
function useReportDialog() {
|
|
7
|
-
const { codeSnippet: { report = {} } = {} } = (0,
|
|
8
|
+
const { codeSnippet: { report = {} } = {} } = (0, use_theme_config_1.useThemeConfig)();
|
|
8
9
|
const [isReportDialogShown, setIsReportDialogShown] = (0, react_1.useState)(false);
|
|
9
10
|
const { tooltipText, buttonText, label } = report;
|
|
10
|
-
const { useTranslate, useSubmitFeedback } = (0,
|
|
11
|
+
const { useTranslate, useSubmitFeedback } = (0, use_theme_hooks_1.useThemeHooks)();
|
|
11
12
|
const { translate } = useTranslate();
|
|
12
13
|
const { submitFeedback } = useSubmitFeedback();
|
|
13
14
|
const showReportDialog = () => {
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
export * from '
|
|
2
|
-
export * from '
|
|
3
|
-
export * from '
|
|
4
|
-
export * from '
|
|
5
|
-
export * from '
|
|
6
|
-
export * from '
|
|
7
|
-
export * from '
|
|
8
|
-
export * from '
|
|
9
|
-
export * from '
|
|
10
|
-
export * from '
|
|
11
|
-
export * from '
|
|
12
|
-
export * from '
|
|
13
|
-
export * from '
|
|
14
|
-
export * from '
|
|
15
|
-
export * from '
|
|
16
|
-
export * from '
|
|
17
|
-
export * from '
|
|
18
|
-
export * from '
|
|
19
|
-
export * from '
|
|
20
|
-
export * from '
|
|
21
|
-
export * from '
|
|
22
|
-
export * from '
|
|
23
|
-
export * from '
|
|
24
|
-
export * from '
|
|
25
|
-
export * from '
|
|
26
|
-
export * from '
|
|
27
|
-
export * from '
|
|
28
|
-
export * from '
|
|
29
|
-
export * from '
|
|
30
|
-
export * from '
|
|
31
|
-
export * from '
|
|
32
|
-
export * from '
|
|
33
|
-
export * from '
|
|
34
|
-
export * from '
|
|
35
|
-
export * from '
|
|
36
|
-
export * from '
|
|
37
|
-
export * from '
|
|
38
|
-
export * from '
|
|
39
|
-
export * from '
|
|
40
|
-
export * from '
|
|
41
|
-
export * from '
|
|
42
|
-
export * from '
|
|
1
|
+
export * from './use-theme-config';
|
|
2
|
+
export * from './use-control';
|
|
3
|
+
export * from './use-mount';
|
|
4
|
+
export * from './use-unmount';
|
|
5
|
+
export * from './use-active-heading';
|
|
6
|
+
export * from './use-active-section-id';
|
|
7
|
+
export * from './use-dialog-hotkeys';
|
|
8
|
+
export * from './use-full-height';
|
|
9
|
+
export * from './use-navbar-height';
|
|
10
|
+
export * from './use-outside-click';
|
|
11
|
+
export * from './use-theme-hooks';
|
|
12
|
+
export * from './use-mobile-menu';
|
|
13
|
+
export * from './use-modal-scroll-lock';
|
|
14
|
+
export * from './use-color-switcher';
|
|
15
|
+
export * from './search/use-recent-searches';
|
|
16
|
+
export * from './search/use-suggested-pages';
|
|
17
|
+
export * from './menu/use-nested-menu';
|
|
18
|
+
export * from './menu/use-menu-item-expanded';
|
|
19
|
+
export * from './menu/use-mobile-menu-items';
|
|
20
|
+
export * from './menu/use-mobile-menu-levels';
|
|
21
|
+
export * from './menu/use-collapse';
|
|
22
|
+
export * from './feedback/use-report-dialog';
|
|
23
|
+
export * from './use-tabs';
|
|
24
|
+
export * from './use-focus-trap';
|
|
25
|
+
export * from './use-language-picker';
|
|
26
|
+
export * from './use-product-picker';
|
|
27
|
+
export * from './search/use-search-dialog';
|
|
28
|
+
export * from './search/use-search-filter';
|
|
29
|
+
export * from './use-controlled-state';
|
|
30
|
+
export * from './use-codeblock-tabs-controls';
|
|
31
|
+
export * from './code-walkthrough/use-code-walkthrough';
|
|
32
|
+
export * from './code-walkthrough/use-code-walkthrough-steps';
|
|
33
|
+
export * from './code-walkthrough/use-code-walkthrough-controls';
|
|
34
|
+
export * from './code-walkthrough/use-code-panel';
|
|
35
|
+
export * from './code-walkthrough/use-renderable-files';
|
|
36
|
+
export * from './use-element-size';
|
|
37
|
+
export * from './use-time-ago';
|
|
38
|
+
export * from './use-input-key-commands';
|
|
39
|
+
export * from './catalog/useCatalogEntities';
|
|
40
|
+
export * from './use-active-page-version';
|
|
41
|
+
export * from './use-page-versions';
|
|
42
|
+
export * from './use-user-teams';
|
package/lib/core/hooks/index.js
CHANGED
|
@@ -14,46 +14,46 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("
|
|
18
|
-
__exportStar(require("
|
|
19
|
-
__exportStar(require("
|
|
20
|
-
__exportStar(require("
|
|
21
|
-
__exportStar(require("
|
|
22
|
-
__exportStar(require("
|
|
23
|
-
__exportStar(require("
|
|
24
|
-
__exportStar(require("
|
|
25
|
-
__exportStar(require("
|
|
26
|
-
__exportStar(require("
|
|
27
|
-
__exportStar(require("
|
|
28
|
-
__exportStar(require("
|
|
29
|
-
__exportStar(require("
|
|
30
|
-
__exportStar(require("
|
|
31
|
-
__exportStar(require("
|
|
32
|
-
__exportStar(require("
|
|
33
|
-
__exportStar(require("
|
|
34
|
-
__exportStar(require("
|
|
35
|
-
__exportStar(require("
|
|
36
|
-
__exportStar(require("
|
|
37
|
-
__exportStar(require("
|
|
38
|
-
__exportStar(require("
|
|
39
|
-
__exportStar(require("
|
|
40
|
-
__exportStar(require("
|
|
41
|
-
__exportStar(require("
|
|
42
|
-
__exportStar(require("
|
|
43
|
-
__exportStar(require("
|
|
44
|
-
__exportStar(require("
|
|
45
|
-
__exportStar(require("
|
|
46
|
-
__exportStar(require("
|
|
47
|
-
__exportStar(require("
|
|
48
|
-
__exportStar(require("
|
|
49
|
-
__exportStar(require("
|
|
50
|
-
__exportStar(require("
|
|
51
|
-
__exportStar(require("
|
|
52
|
-
__exportStar(require("
|
|
53
|
-
__exportStar(require("
|
|
54
|
-
__exportStar(require("
|
|
55
|
-
__exportStar(require("
|
|
56
|
-
__exportStar(require("
|
|
57
|
-
__exportStar(require("
|
|
58
|
-
__exportStar(require("
|
|
17
|
+
__exportStar(require("./use-theme-config"), exports);
|
|
18
|
+
__exportStar(require("./use-control"), exports);
|
|
19
|
+
__exportStar(require("./use-mount"), exports);
|
|
20
|
+
__exportStar(require("./use-unmount"), exports);
|
|
21
|
+
__exportStar(require("./use-active-heading"), exports);
|
|
22
|
+
__exportStar(require("./use-active-section-id"), exports);
|
|
23
|
+
__exportStar(require("./use-dialog-hotkeys"), exports);
|
|
24
|
+
__exportStar(require("./use-full-height"), exports);
|
|
25
|
+
__exportStar(require("./use-navbar-height"), exports);
|
|
26
|
+
__exportStar(require("./use-outside-click"), exports);
|
|
27
|
+
__exportStar(require("./use-theme-hooks"), exports);
|
|
28
|
+
__exportStar(require("./use-mobile-menu"), exports);
|
|
29
|
+
__exportStar(require("./use-modal-scroll-lock"), exports);
|
|
30
|
+
__exportStar(require("./use-color-switcher"), exports);
|
|
31
|
+
__exportStar(require("./search/use-recent-searches"), exports);
|
|
32
|
+
__exportStar(require("./search/use-suggested-pages"), exports);
|
|
33
|
+
__exportStar(require("./menu/use-nested-menu"), exports);
|
|
34
|
+
__exportStar(require("./menu/use-menu-item-expanded"), exports);
|
|
35
|
+
__exportStar(require("./menu/use-mobile-menu-items"), exports);
|
|
36
|
+
__exportStar(require("./menu/use-mobile-menu-levels"), exports);
|
|
37
|
+
__exportStar(require("./menu/use-collapse"), exports);
|
|
38
|
+
__exportStar(require("./feedback/use-report-dialog"), exports);
|
|
39
|
+
__exportStar(require("./use-tabs"), exports);
|
|
40
|
+
__exportStar(require("./use-focus-trap"), exports);
|
|
41
|
+
__exportStar(require("./use-language-picker"), exports);
|
|
42
|
+
__exportStar(require("./use-product-picker"), exports);
|
|
43
|
+
__exportStar(require("./search/use-search-dialog"), exports);
|
|
44
|
+
__exportStar(require("./search/use-search-filter"), exports);
|
|
45
|
+
__exportStar(require("./use-controlled-state"), exports);
|
|
46
|
+
__exportStar(require("./use-codeblock-tabs-controls"), exports);
|
|
47
|
+
__exportStar(require("./code-walkthrough/use-code-walkthrough"), exports);
|
|
48
|
+
__exportStar(require("./code-walkthrough/use-code-walkthrough-steps"), exports);
|
|
49
|
+
__exportStar(require("./code-walkthrough/use-code-walkthrough-controls"), exports);
|
|
50
|
+
__exportStar(require("./code-walkthrough/use-code-panel"), exports);
|
|
51
|
+
__exportStar(require("./code-walkthrough/use-renderable-files"), exports);
|
|
52
|
+
__exportStar(require("./use-element-size"), exports);
|
|
53
|
+
__exportStar(require("./use-time-ago"), exports);
|
|
54
|
+
__exportStar(require("./use-input-key-commands"), exports);
|
|
55
|
+
__exportStar(require("./catalog/useCatalogEntities"), exports);
|
|
56
|
+
__exportStar(require("./use-active-page-version"), exports);
|
|
57
|
+
__exportStar(require("./use-page-versions"), exports);
|
|
58
|
+
__exportStar(require("./use-user-teams"), exports);
|
|
59
59
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Dispatch, SetStateAction } from 'react';
|
|
2
|
-
import type { ItemState } from '
|
|
2
|
+
import type { ItemState } from '../../types/sidebar';
|
|
3
3
|
export declare function useMenuItemExpanded(item: ItemState): [boolean, Dispatch<SetStateAction<boolean>>];
|
|
@@ -2,16 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useMobileMenuItems = void 0;
|
|
4
4
|
const react_router_dom_1 = require("react-router-dom");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
5
|
+
const use_theme_hooks_1 = require("../use-theme-hooks");
|
|
6
|
+
const use_theme_config_1 = require("../use-theme-config");
|
|
7
|
+
const common_1 = require("../../constants/common");
|
|
8
|
+
const menu_1 = require("../../utils/menu");
|
|
8
9
|
const MENU_SEPARATOR = {
|
|
9
10
|
type: 'separator',
|
|
10
11
|
separatorLine: true,
|
|
11
12
|
};
|
|
12
13
|
const useMobileMenuItems = (menuType) => {
|
|
13
14
|
var _a, _b, _c;
|
|
14
|
-
const { useTranslate, useL10nConfig, useCurrentProduct, usePageVersions, useSidebarItems } = (0,
|
|
15
|
+
const { useTranslate, useL10nConfig, useCurrentProduct, usePageVersions, useSidebarItems } = (0, use_theme_hooks_1.useThemeHooks)();
|
|
15
16
|
const { versions = [] } = usePageVersions() || {};
|
|
16
17
|
const { defaultLocale, currentLocale, locales } = useL10nConfig();
|
|
17
18
|
const { translate } = useTranslate();
|
|
@@ -20,15 +21,15 @@ const useMobileMenuItems = (menuType) => {
|
|
|
20
21
|
const location = (0, react_router_dom_1.useLocation)();
|
|
21
22
|
const currentProduct = useCurrentProduct();
|
|
22
23
|
const hasProductNavbarOverride = (_a = currentProduct === null || currentProduct === void 0 ? void 0 : currentProduct.configOverride) === null || _a === void 0 ? void 0 : _a.navbar;
|
|
23
|
-
const productThemeConfig = (0,
|
|
24
|
-
const baseThemeConfig = (0,
|
|
24
|
+
const productThemeConfig = (0, use_theme_config_1.useThemeConfig)();
|
|
25
|
+
const baseThemeConfig = (0, use_theme_config_1.useThemeConfig)(false);
|
|
25
26
|
const baseNavItems = (((_b = baseThemeConfig.navbar) === null || _b === void 0 ? void 0 : _b.items) || []);
|
|
26
27
|
const productNavItems = (hasProductNavbarOverride ? ((_c = productThemeConfig.navbar) === null || _c === void 0 ? void 0 : _c.items) || [] : []);
|
|
27
28
|
const menuItems = [];
|
|
28
|
-
if (menuType ===
|
|
29
|
+
if (menuType === common_1.MobileMenuType.PAGE) {
|
|
29
30
|
if (activeVersion) {
|
|
30
31
|
// TODO: consider to refactor
|
|
31
|
-
const versionsSection = (0,
|
|
32
|
+
const versionsSection = (0, menu_1.buildVersionSection)(translate, versions, activeVersion);
|
|
32
33
|
menuItems.push(...versionsSection);
|
|
33
34
|
}
|
|
34
35
|
if (menuItems.length && sidebarItems.length) {
|
|
@@ -36,7 +37,7 @@ const useMobileMenuItems = (menuType) => {
|
|
|
36
37
|
}
|
|
37
38
|
menuItems.push(...sidebarItems);
|
|
38
39
|
}
|
|
39
|
-
else if (menuType ===
|
|
40
|
+
else if (menuType === common_1.MobileMenuType.PRODUCT) {
|
|
40
41
|
menuItems.push(...productNavItems);
|
|
41
42
|
if (menuItems.length && baseNavItems.length) {
|
|
42
43
|
menuItems.push(MENU_SEPARATOR);
|
|
@@ -45,7 +46,7 @@ const useMobileMenuItems = (menuType) => {
|
|
|
45
46
|
menuItems.push(...baseNavItems);
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
|
-
else if (menuType ===
|
|
49
|
+
else if (menuType === common_1.MobileMenuType.MAIN_MENU) {
|
|
49
50
|
const productMenuItems = Object.values(baseThemeConfig.products || {}).map((product) => ({
|
|
50
51
|
label: product.name,
|
|
51
52
|
link: product.link,
|
|
@@ -66,7 +67,7 @@ const useMobileMenuItems = (menuType) => {
|
|
|
66
67
|
menuItems.push(...baseNavItems);
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
|
-
const languagesMenu = (0,
|
|
70
|
+
const languagesMenu = (0, menu_1.buildLanguagesGroup)(locales, defaultLocale, currentLocale);
|
|
70
71
|
if (menuItems.length && languagesMenu) {
|
|
71
72
|
menuItems.push(MENU_SEPARATOR);
|
|
72
73
|
}
|
|
@@ -74,7 +75,7 @@ const useMobileMenuItems = (menuType) => {
|
|
|
74
75
|
menuItems.push(languagesMenu);
|
|
75
76
|
}
|
|
76
77
|
return {
|
|
77
|
-
items: (0,
|
|
78
|
+
items: (0, menu_1.mapNavbarItems)(menuItems, defaultLocale, currentLocale, locales, location),
|
|
78
79
|
popDrilldownState,
|
|
79
80
|
pushDrilldownState,
|
|
80
81
|
backLink,
|
|
@@ -3,17 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useMobileMenuLevels = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const react_router_dom_1 = require("react-router-dom");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
6
|
+
const use_theme_hooks_1 = require("../use-theme-hooks");
|
|
7
|
+
const use_theme_config_1 = require("../use-theme-config");
|
|
8
|
+
const common_1 = require("../../constants/common");
|
|
8
9
|
const useMobileMenuLevels = () => {
|
|
9
10
|
var _a, _b;
|
|
10
|
-
const { useTranslate, useCurrentProduct, usePageVersions, useSidebarItems } = (0,
|
|
11
|
+
const { useTranslate, useCurrentProduct, usePageVersions, useSidebarItems } = (0, use_theme_hooks_1.useThemeHooks)();
|
|
11
12
|
const { versions = [] } = usePageVersions() || {};
|
|
12
13
|
const activeVersion = versions.find((version) => version === null || version === void 0 ? void 0 : version.active);
|
|
13
14
|
const { currentItems: sidebarItems } = useSidebarItems(activeVersion);
|
|
14
15
|
const { translate } = useTranslate();
|
|
15
16
|
const currentProduct = useCurrentProduct();
|
|
16
|
-
const productThemeConfig = (0,
|
|
17
|
+
const productThemeConfig = (0, use_theme_config_1.useThemeConfig)();
|
|
17
18
|
const location = (0, react_router_dom_1.useLocation)();
|
|
18
19
|
const hasProductNavbarOverride = (_a = currentProduct === null || currentProduct === void 0 ? void 0 : currentProduct.configOverride) === null || _a === void 0 ? void 0 : _a.navbar;
|
|
19
20
|
const productNavItems = (hasProductNavbarOverride ? ((_b = productThemeConfig.navbar) === null || _b === void 0 ? void 0 : _b.items) || [] : []);
|
|
@@ -21,19 +22,19 @@ const useMobileMenuLevels = () => {
|
|
|
21
22
|
const menuLevels = [
|
|
22
23
|
{
|
|
23
24
|
label: translate('mobileMenu.mainMenu', 'Main menu'),
|
|
24
|
-
type:
|
|
25
|
+
type: common_1.MobileMenuType.MAIN_MENU,
|
|
25
26
|
},
|
|
26
27
|
];
|
|
27
28
|
if (currentProduct && productNavItems.length) {
|
|
28
29
|
menuLevels.push({
|
|
29
30
|
label: currentProduct.name,
|
|
30
|
-
type:
|
|
31
|
+
type: common_1.MobileMenuType.PRODUCT,
|
|
31
32
|
});
|
|
32
33
|
}
|
|
33
34
|
if (sidebarItems.length || activeVersion) {
|
|
34
35
|
menuLevels.push({
|
|
35
36
|
label: translate('mobileMenu.previous', 'Previous'),
|
|
36
|
-
type:
|
|
37
|
+
type: common_1.MobileMenuType.PAGE,
|
|
37
38
|
});
|
|
38
39
|
}
|
|
39
40
|
return menuLevels;
|
|
@@ -12,15 +12,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.useNestedMenu = useNestedMenu;
|
|
13
13
|
const react_router_dom_1 = require("react-router-dom");
|
|
14
14
|
const react_1 = require("react");
|
|
15
|
-
const
|
|
16
|
-
const
|
|
15
|
+
const use_menu_item_expanded_1 = require("./use-menu-item-expanded");
|
|
16
|
+
const use_collapse_1 = require("./use-collapse");
|
|
17
|
+
const load_and_navigate_1 = require("../../utils/load-and-navigate");
|
|
18
|
+
const urls_1 = require("../../utils/urls");
|
|
17
19
|
function useNestedMenu({ item, labelRef, nestedMenuRef }) {
|
|
18
|
-
const [isExpanded, setIsExpanded] = (0,
|
|
20
|
+
const [isExpanded, setIsExpanded] = (0, use_menu_item_expanded_1.useMenuItemExpanded)(item);
|
|
19
21
|
// we need to know when the item is collapsed after transition to remove children from DOM
|
|
20
22
|
const [canUnmount, setCanUnmount] = (0, react_1.useState)(!isExpanded);
|
|
21
23
|
const navigate = (0, react_router_dom_1.useNavigate)();
|
|
22
24
|
const location = (0, react_router_dom_1.useLocation)();
|
|
23
|
-
const { style } = (0,
|
|
25
|
+
const { style } = (0, use_collapse_1.useCollapse)({
|
|
24
26
|
isExpanded,
|
|
25
27
|
collapseElRef: nestedMenuRef || { current: null },
|
|
26
28
|
onTransitionStateChange: (state) => {
|
|
@@ -64,12 +66,12 @@ function useNestedMenu({ item, labelRef, nestedMenuRef }) {
|
|
|
64
66
|
}, [labelRef, isExpanded, item.active]);
|
|
65
67
|
const handleExpand = (0, react_1.useCallback)(() => __awaiter(this, void 0, void 0, function* () {
|
|
66
68
|
if (item.expanded === 'always' ||
|
|
67
|
-
(item.link && item.hasActiveSubItem && item.link !== (0,
|
|
69
|
+
(item.link && item.hasActiveSubItem && item.link !== (0, urls_1.withoutPathPrefix)(location.pathname))) {
|
|
68
70
|
return;
|
|
69
71
|
}
|
|
70
72
|
const [firstChild] = item.items;
|
|
71
73
|
if (!isExpanded && item.selectFirstItemOnExpand && firstChild.link) {
|
|
72
|
-
yield (0,
|
|
74
|
+
yield (0, load_and_navigate_1.loadAndNavigate)({ navigate, to: firstChild.link });
|
|
73
75
|
}
|
|
74
76
|
setIsExpanded(!isExpanded);
|
|
75
77
|
}), [item, isExpanded, navigate, location.pathname, setIsExpanded]);
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useRecentSearches = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
-
const
|
|
5
|
+
const js_utils_1 = require("../../utils/js-utils");
|
|
6
6
|
const RECENT_SEARCHES_KEY = 'recentSearches';
|
|
7
7
|
const RECENT_SEARCHES_LIMIT = 5;
|
|
8
8
|
const createRecentSearchesStore = () => {
|
|
9
9
|
const subscribers = new Set();
|
|
10
10
|
let cachedSnapshot;
|
|
11
11
|
const getSnapshot = () => {
|
|
12
|
-
if (!(0,
|
|
12
|
+
if (!(0, js_utils_1.isBrowser)())
|
|
13
13
|
return [];
|
|
14
14
|
if (cachedSnapshot)
|
|
15
15
|
return cachedSnapshot;
|
|
@@ -24,7 +24,7 @@ const createRecentSearchesStore = () => {
|
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
const updateItems = (value, isAdd) => {
|
|
27
|
-
if (!(0,
|
|
27
|
+
if (!(0, js_utils_1.isBrowser)())
|
|
28
28
|
return;
|
|
29
29
|
const currentItems = getSnapshot();
|
|
30
30
|
const valueIndex = currentItems.indexOf(value);
|