@brillout/docpress 0.9.7 → 0.10.0
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/Layout.tsx +102 -40
- package/{navigation → MenuModal}/Collapsible.css +7 -0
- package/MenuModal/NavigationWithColumnLayout.css +11 -0
- package/MenuModal/NavigationWithColumnLayout.tsx +253 -0
- package/MenuModal/toggleMenuModal.ts +132 -0
- package/MenuModal.tsx +68 -79
- package/{navigation/Navigation.css → NavItemComponent.css} +1 -23
- package/NavItemComponent.tsx +149 -0
- package/components/Note.css +0 -1
- package/config/resolveHeadingsData.ts +1 -1
- package/css/code/diff.css +10 -5
- package/css/code.css +1 -1
- package/css/colorize-on-hover.css +6 -7
- package/css/heading.css +9 -3
- package/css/index.css +1 -0
- package/dist/NavItemComponent.d.ts +39 -0
- package/dist/NavItemComponent.js +109 -0
- package/dist/config/resolveHeadingsData.d.ts +1 -1
- package/dist/config/resolvePageContext.d.ts +2 -2
- package/dist/renderer/determineNavItemsColumnLayout.d.ts +1 -1
- package/dist/renderer/usePageContext.js +4 -3
- package/docsearch/SearchLink.tsx +7 -3
- package/icons/books.svg +46 -0
- package/icons/gear.svg +35 -0
- package/icons/index.ts +5 -0
- package/icons/magnifying-glass.svg +31 -0
- package/icons/seedling.svg +24 -0
- package/index.ts +2 -0
- package/initKeyBindings.ts +1 -1
- package/package.json +1 -1
- package/renderer/determineNavItemsColumnLayout.ts +1 -1
- package/renderer/initOnNavigation.ts +1 -1
- package/renderer/onRenderClient.tsx +1 -1
- package/renderer/usePageContext.tsx +4 -3
- package/utils/css.ts +0 -6
- package/dist/Layout.d.ts +0 -15
- package/dist/Layout.js +0 -321
- package/dist/MenuModal.d.ts +0 -13
- package/dist/MenuModal.js +0 -124
- package/dist/NavSecondaryContent.d.ts +0 -6
- package/dist/NavSecondaryContent.js +0 -57
- package/dist/autoScrollNav.d.ts +0 -3
- package/dist/autoScrollNav.js +0 -35
- package/dist/components/EditPageNote.d.ts +0 -7
- package/dist/components/EditPageNote.js +0 -11
- package/dist/docsearch/SearchLink.d.ts +0 -4
- package/dist/docsearch/SearchLink.js +0 -25
- package/dist/docsearch/toggleDocsearchModal.d.ts +0 -4
- package/dist/docsearch/toggleDocsearchModal.js +0 -26
- package/dist/navigation/Collapsible.d.ts +0 -10
- package/dist/navigation/Collapsible.js +0 -35
- package/dist/navigation/Navigation.d.ts +0 -21
- package/dist/navigation/Navigation.js +0 -255
- package/dist/utils/PassTrough.d.ts +0 -3
- package/dist/utils/PassTrough.js +0 -6
- package/dist/utils/Style.d.ts +0 -5
- package/dist/utils/Style.js +0 -6
- package/dist/utils/css.d.ts +0 -1
- package/dist/utils/css.js +0 -27
- package/dist/utils/getViewportWidth.d.ts +0 -1
- package/dist/utils/getViewportWidth.js +0 -4
- package/dist/utils/throttle.d.ts +0 -1
- package/dist/utils/throttle.js +0 -14
- package/navigation/Navigation.tsx +0 -382
- /package/{navigation → MenuModal}/Collapsible.tsx +0 -0
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export { closeDocsearchModal };
|
|
2
|
-
export { openDocsearchModal };
|
|
3
|
-
import { assert } from '../utils/client';
|
|
4
|
-
function closeDocsearchModal() {
|
|
5
|
-
if (isClosed())
|
|
6
|
-
return;
|
|
7
|
-
toggle();
|
|
8
|
-
}
|
|
9
|
-
function openDocsearchModal() {
|
|
10
|
-
if (!isClosed())
|
|
11
|
-
return;
|
|
12
|
-
toggle();
|
|
13
|
-
}
|
|
14
|
-
// There doesn't seem be an official API to open/close the DocSearch modal:
|
|
15
|
-
// - https://github.com/algolia/docsearch/issues/2321
|
|
16
|
-
// - https://github.com/algolia/docsearch/blob/90f3c6aabbc324fe49e9a1dfe0906fcd4d90f27b/packages/docsearch-react/src/DocSearch.tsx#L52
|
|
17
|
-
function toggle() {
|
|
18
|
-
// Trigger https://github.com/algolia/docsearch/blob/90f3c6aabbc324fe49e9a1dfe0906fcd4d90f27b/packages/docsearch-react/src/useDocSearchKeyboardEvents.ts#L71
|
|
19
|
-
window.dispatchEvent(new KeyboardEvent('keydown', { key: 'k', ctrlKey: true }));
|
|
20
|
-
}
|
|
21
|
-
function isClosed() {
|
|
22
|
-
var test1 = !document.body.classList.contains('DocSearch--active');
|
|
23
|
-
var test2 = document.getElementsByClassName('DocSearch-Modal').length === 0;
|
|
24
|
-
assert(test1 === test2);
|
|
25
|
-
return test1 || test2;
|
|
26
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { Collapsible };
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import './Collapsible.css';
|
|
4
|
-
declare function Collapsible({ head, children, disabled, collapsedInit, marginBottomOnExpand, }: {
|
|
5
|
-
head: (onClick: () => void) => React.ReactNode;
|
|
6
|
-
children: React.ReactNode;
|
|
7
|
-
disabled: boolean;
|
|
8
|
-
collapsedInit: boolean;
|
|
9
|
-
marginBottomOnExpand?: number;
|
|
10
|
-
}): React.JSX.Element;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export { Collapsible };
|
|
2
|
-
import React, { useRef, useState } from 'react';
|
|
3
|
-
import { cls } from '../utils/cls';
|
|
4
|
-
import './Collapsible.css';
|
|
5
|
-
function Collapsible(_a) {
|
|
6
|
-
var head = _a.head, children = _a.children, _b = _a.disabled, disabled = _b === void 0 ? false : _b, collapsedInit = _a.collapsedInit, marginBottomOnExpand = _a.marginBottomOnExpand;
|
|
7
|
-
var _c = useState(collapsedInit), collapsed = _c[0], setCollapsed = _c[1];
|
|
8
|
-
var _d = useState(false), isAnimating = _d[0], setIsAnimating = _d[1];
|
|
9
|
-
var contentRef = useRef(null);
|
|
10
|
-
var onClick = function () {
|
|
11
|
-
if (!disabled) {
|
|
12
|
-
setIsAnimating(true);
|
|
13
|
-
if (!collapsed) {
|
|
14
|
-
// If expanding, set height to current scroll height before animation
|
|
15
|
-
contentRef.current.style.height = "".concat(contentRef.current.scrollHeight, "px");
|
|
16
|
-
// Force a reflow
|
|
17
|
-
contentRef.current.offsetHeight;
|
|
18
|
-
}
|
|
19
|
-
setCollapsed(function (prev) { return !prev; });
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
var onTransitionEnd = function () {
|
|
23
|
-
setIsAnimating(false);
|
|
24
|
-
};
|
|
25
|
-
var showContent = disabled ? true : !collapsed;
|
|
26
|
-
return (React.createElement("div", { className: cls(['collapsible', !disabled && (showContent ? 'collapsible-expanded' : 'collapsible-collapsed')]) },
|
|
27
|
-
head(onClick),
|
|
28
|
-
React.createElement("div", { ref: contentRef, onTransitionEnd: onTransitionEnd, style: {
|
|
29
|
-
height: !showContent ? 0 : isAnimating ? contentRef.current.scrollHeight : 'auto',
|
|
30
|
-
overflow: 'hidden',
|
|
31
|
-
transition: 'none 0.3s ease',
|
|
32
|
-
transitionProperty: 'height, margin-bottom',
|
|
33
|
-
marginBottom: (showContent && marginBottomOnExpand) || undefined,
|
|
34
|
-
}, "aria-expanded": showContent }, children)));
|
|
35
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export { NavigationContent };
|
|
2
|
-
export type { NavItem };
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import './Navigation.css';
|
|
5
|
-
import '@docsearch/css';
|
|
6
|
-
import '../global.d.ts';
|
|
7
|
-
type NavItem = {
|
|
8
|
-
level: number;
|
|
9
|
-
url?: string | null;
|
|
10
|
-
color?: string;
|
|
11
|
-
title: string;
|
|
12
|
-
titleInNav: string;
|
|
13
|
-
menuModalFullWidth?: true;
|
|
14
|
-
isColumnEntry?: ColumnMap;
|
|
15
|
-
};
|
|
16
|
-
declare function NavigationContent(props: {
|
|
17
|
-
navItems: NavItem[];
|
|
18
|
-
showOnlyRelevant?: true;
|
|
19
|
-
columnLayout?: true;
|
|
20
|
-
}): React.JSX.Element;
|
|
21
|
-
type ColumnMap = Record<number, number>;
|
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
// TODO/refactor: rename file and/or component
|
|
13
|
-
export { NavigationContent };
|
|
14
|
-
import React, { useEffect, useState } from 'react';
|
|
15
|
-
import { assert, assertWarning, jsxToTextContent } from '../utils/server';
|
|
16
|
-
import './Navigation.css';
|
|
17
|
-
import { parseTitle } from '../parseTitle';
|
|
18
|
-
import { usePageContext } from '../renderer/usePageContext';
|
|
19
|
-
import '@docsearch/css';
|
|
20
|
-
import '../global.d.ts';
|
|
21
|
-
import { getViewportWidth } from '../utils/getViewportWidth';
|
|
22
|
-
import { navLeftWidthMax, navLeftWidthMin } from '../Layout';
|
|
23
|
-
import { throttle } from '../utils/throttle';
|
|
24
|
-
import { Collapsible } from './Collapsible';
|
|
25
|
-
function NavigationContent(props) {
|
|
26
|
-
var pageContext = usePageContext();
|
|
27
|
-
var navItemsWithComputed = getNavItemsWithComputed(props.navItems, pageContext.urlPathname);
|
|
28
|
-
var navContent;
|
|
29
|
-
if (!props.columnLayout) {
|
|
30
|
-
var navItemsRelevant = navItemsWithComputed;
|
|
31
|
-
if (props.showOnlyRelevant)
|
|
32
|
-
navItemsRelevant = navItemsRelevant.filter(function (navItemGroup) { return navItemGroup.isRelevant; });
|
|
33
|
-
navContent = navItemsRelevant.map(function (navItem, i) { return React.createElement(NavItemComponent, { navItem: navItem, key: i }); });
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
assert(!props.showOnlyRelevant);
|
|
37
|
-
navContent = React.createElement(NavigationWithColumnLayout, { navItemsWithComputed: navItemsWithComputed });
|
|
38
|
-
}
|
|
39
|
-
return (React.createElement("div", { className: "navigation-content", style: { marginTop: 10 } }, navContent));
|
|
40
|
-
}
|
|
41
|
-
function NavigationWithColumnLayout(props) {
|
|
42
|
-
var _a = useState(), viewportWidth = _a[0], setViewportWidth = _a[1];
|
|
43
|
-
var updateviewportwidth = function () { return setViewportWidth(getViewportWidth()); };
|
|
44
|
-
useEffect(function () {
|
|
45
|
-
updateviewportwidth();
|
|
46
|
-
window.addEventListener('resize', throttle(updateviewportwidth, 300), { passive: true });
|
|
47
|
-
});
|
|
48
|
-
var navItemsByColumnLayouts = getNavItemsByColumnLayouts(props.navItemsWithComputed, viewportWidth);
|
|
49
|
-
return (React.createElement(React.Fragment, null, navItemsByColumnLayouts.map(function (columnLayout, i) { return (React.createElement("div", { key: i }, columnLayout.isFullWidthCategory ? (React.createElement("div", { style: { marginTop: 0 } },
|
|
50
|
-
React.createElement(ColumnsWrapper, { numberOfColumns: columnLayout.columns.length },
|
|
51
|
-
React.createElement(Collapsible, { head: function (onClick) { return React.createElement(NavItemComponent, { navItem: columnLayout.navItemLevel1, onClick: onClick }); }, disabled: columnLayout.columns.length > 1, collapsedInit: !columnLayout.navItemLevel1.isRelevant, marginBottomOnExpand: 10 },
|
|
52
|
-
React.createElement(ColumnsLayout, { className: "collapsible" },
|
|
53
|
-
columnLayout.columns.map(function (column, j) { return (React.createElement(Column, { key: j }, column.navItems.map(function (navItem, k) { return (React.createElement(NavItemComponent, { key: k, navItem: navItem })); }))); }),
|
|
54
|
-
React.createElement(CategoryBorder, { navItemLevel1: columnLayout.navItemLevel1 })))))) : (React.createElement(ColumnsWrapper, { numberOfColumns: columnLayout.columns.length },
|
|
55
|
-
React.createElement(ColumnsLayout, null, columnLayout.columns.map(function (column, j) { return (React.createElement(Column, { key: j }, column.categories.map(function (category, k) { return (React.createElement("div", { key: k, style: { marginBottom: 0 } },
|
|
56
|
-
React.createElement(Collapsible, { head: function (onClick) { return React.createElement(NavItemComponent, { navItem: category.navItemLevel1, onClick: onClick }); }, disabled: columnLayout.columns.length > 1, collapsedInit: !category.navItemLevel1.isRelevant, marginBottomOnExpand: 40 },
|
|
57
|
-
category.navItems.map(function (navItem, l) { return (React.createElement(NavItemComponent, { key: l, navItem: navItem })); }),
|
|
58
|
-
React.createElement(CategoryBorder, { navItemLevel1: category.navItemLevel1 })))); }))); })))))); })));
|
|
59
|
-
}
|
|
60
|
-
function Column(_a) {
|
|
61
|
-
var children = _a.children;
|
|
62
|
-
return (React.createElement("div", { style: {
|
|
63
|
-
flexGrow: 1,
|
|
64
|
-
maxWidth: navLeftWidthMax,
|
|
65
|
-
display: 'flex',
|
|
66
|
-
flexDirection: 'column',
|
|
67
|
-
} }, children));
|
|
68
|
-
}
|
|
69
|
-
function ColumnsWrapper(_a) {
|
|
70
|
-
var children = _a.children, numberOfColumns = _a.numberOfColumns;
|
|
71
|
-
return (React.createElement("div", { style: {
|
|
72
|
-
width: numberOfColumns * (navLeftWidthMax + 20),
|
|
73
|
-
maxWidth: '100%',
|
|
74
|
-
margin: 'auto',
|
|
75
|
-
} }, children));
|
|
76
|
-
}
|
|
77
|
-
function ColumnsLayout(_a) {
|
|
78
|
-
var children = _a.children, className = _a.className;
|
|
79
|
-
return (React.createElement("div", { className: className, style: {
|
|
80
|
-
display: 'flex',
|
|
81
|
-
justifyContent: 'space-between',
|
|
82
|
-
} }, children));
|
|
83
|
-
}
|
|
84
|
-
function CategoryBorder(_a) {
|
|
85
|
-
var navItemLevel1 = _a.navItemLevel1;
|
|
86
|
-
assert(navItemLevel1.level === 1);
|
|
87
|
-
return React.createElement("div", { className: "category-border", style: { background: navItemLevel1.color } });
|
|
88
|
-
}
|
|
89
|
-
function NavItemComponent(_a) {
|
|
90
|
-
var _b;
|
|
91
|
-
var _c;
|
|
92
|
-
var navItem = _a.navItem, onClick = _a.onClick;
|
|
93
|
-
assert([1, 2, 3, 4].includes(navItem.level), navItem);
|
|
94
|
-
var titleJsx = parseTitle(navItem.title);
|
|
95
|
-
var titleInNavJsx = parseTitle(navItem.titleInNav);
|
|
96
|
-
if (navItem.level === 1 || navItem.level === 4) {
|
|
97
|
-
assert(navItem.url === undefined);
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
var sectionTitle = jsxToTextContent(titleJsx);
|
|
101
|
-
assertWarning(navItem.url, [
|
|
102
|
-
"".concat(jsxToTextContent(titleInNavJsx), " is missing a URL hash."),
|
|
103
|
-
"Add a URL hash with: `## ".concat(sectionTitle, "{#some-hash}`."),
|
|
104
|
-
/* TODO/eventually: not implemented yet.
|
|
105
|
-
`Use \`<h2 id="url-hash">${sectionTitle}</h2>\` instead of \`## ${sectionTitle}\`.`,
|
|
106
|
-
*/
|
|
107
|
-
].join(' '));
|
|
108
|
-
}
|
|
109
|
-
var children = titleInNavJsx;
|
|
110
|
-
if (navItem.level === 1) {
|
|
111
|
-
children = (React.createElement(React.Fragment, null,
|
|
112
|
-
children,
|
|
113
|
-
React.createElement(Chevron, { className: "collapsible-icon", height: 9 })));
|
|
114
|
-
}
|
|
115
|
-
var props = {
|
|
116
|
-
href: (_c = navItem.url) !== null && _c !== void 0 ? _c : undefined,
|
|
117
|
-
children: children,
|
|
118
|
-
onClick: onClick,
|
|
119
|
-
className: [
|
|
120
|
-
'nav-item',
|
|
121
|
-
'nav-item-level-' + navItem.level,
|
|
122
|
-
navItem.url && navItem.isActive && ' is-active',
|
|
123
|
-
navItem.isFirstOfItsKind && 'nav-item-first-of-its-kind',
|
|
124
|
-
navItem.isLastOfItsKind && 'nav-item-last-of-its-kind',
|
|
125
|
-
]
|
|
126
|
-
.filter(Boolean)
|
|
127
|
-
.join(' '),
|
|
128
|
-
};
|
|
129
|
-
if (navItem.level === 1) {
|
|
130
|
-
props.style = (_b = {},
|
|
131
|
-
_b['--category-color'] = navItem.color,
|
|
132
|
-
_b);
|
|
133
|
-
}
|
|
134
|
-
if (navItem.level === 2 || navItem.level === 3) {
|
|
135
|
-
return React.createElement("a", __assign({}, props));
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
return React.createElement("span", __assign({}, props));
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
function getNavItemsByColumnLayouts(navItems, viewportWidth) {
|
|
142
|
-
if (viewportWidth === void 0) { viewportWidth = 0; }
|
|
143
|
-
var navItemsByColumnEntries = getNavItemsByColumnEntries(navItems);
|
|
144
|
-
var numberOfColumnsMax = Math.floor(viewportWidth / navLeftWidthMin) || 1;
|
|
145
|
-
var navItemsByColumnLayouts = navItemsByColumnEntries.map(function (_a) {
|
|
146
|
-
var columnEntries = _a.columnEntries, isFullWidthCategory = _a.isFullWidthCategory;
|
|
147
|
-
var numberOfColumns = Math.min(numberOfColumnsMax, columnEntries.length);
|
|
148
|
-
if (!isFullWidthCategory) {
|
|
149
|
-
var columns_1 = [];
|
|
150
|
-
columnEntries.forEach(function (columnEntry) {
|
|
151
|
-
var _a;
|
|
152
|
-
var idx = numberOfColumns === 1 ? 0 : columnEntry.columnMap[numberOfColumns];
|
|
153
|
-
assert(idx >= 0);
|
|
154
|
-
(_a = columns_1[idx]) !== null && _a !== void 0 ? _a : (columns_1[idx] = { categories: [] });
|
|
155
|
-
var navItemLevel1 = columnEntry.navItems[0];
|
|
156
|
-
var navItems = columnEntry.navItems.slice(1);
|
|
157
|
-
columns_1[idx].categories.push({ navItemLevel1: navItemLevel1, navItems: navItems });
|
|
158
|
-
});
|
|
159
|
-
var navItemsByColumnLayout = { columns: columns_1, isFullWidthCategory: isFullWidthCategory };
|
|
160
|
-
return navItemsByColumnLayout;
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
var navItemLevel1_1;
|
|
164
|
-
var columns_2 = [];
|
|
165
|
-
columnEntries.forEach(function (columnEntry, i) {
|
|
166
|
-
var _a;
|
|
167
|
-
var _b;
|
|
168
|
-
var idx = numberOfColumns === 1 ? 0 : columnEntry.columnMap[numberOfColumns];
|
|
169
|
-
assert(idx >= 0);
|
|
170
|
-
(_b = columns_2[idx]) !== null && _b !== void 0 ? _b : (columns_2[idx] = { navItems: [] });
|
|
171
|
-
var navItems = columnEntry.navItems;
|
|
172
|
-
if (i === 0) {
|
|
173
|
-
navItemLevel1_1 = navItems[0];
|
|
174
|
-
navItems = navItems.slice(1);
|
|
175
|
-
}
|
|
176
|
-
(_a = columns_2[idx].navItems).push.apply(_a, navItems);
|
|
177
|
-
});
|
|
178
|
-
var navItemsByColumnLayout = {
|
|
179
|
-
columns: columns_2,
|
|
180
|
-
navItemLevel1: navItemLevel1_1,
|
|
181
|
-
isFullWidthCategory: isFullWidthCategory,
|
|
182
|
-
};
|
|
183
|
-
return navItemsByColumnLayout;
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
return navItemsByColumnLayouts;
|
|
187
|
-
}
|
|
188
|
-
function getNavItemsByColumnEntries(navItems) {
|
|
189
|
-
var navItemsByColumnEntries = [];
|
|
190
|
-
var columnEntries = [];
|
|
191
|
-
var columnEntry;
|
|
192
|
-
var isFullWidthCategory;
|
|
193
|
-
navItems.forEach(function (navItem) {
|
|
194
|
-
if (navItem.level === 1) {
|
|
195
|
-
var isFullWidthCategoryPrevious = isFullWidthCategory;
|
|
196
|
-
isFullWidthCategory = !!navItem.menuModalFullWidth;
|
|
197
|
-
if (isFullWidthCategoryPrevious !== undefined && isFullWidthCategoryPrevious !== isFullWidthCategory) {
|
|
198
|
-
navItemsByColumnEntries.push({ columnEntries: columnEntries, isFullWidthCategory: isFullWidthCategoryPrevious });
|
|
199
|
-
columnEntries = [];
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
assert(isFullWidthCategory !== undefined);
|
|
203
|
-
if (navItem.isColumnEntry) {
|
|
204
|
-
assert(navItem.level === 1 || navItem.level === 4);
|
|
205
|
-
columnEntry = { navItems: [navItem], columnMap: navItem.isColumnEntry };
|
|
206
|
-
columnEntries.push(columnEntry);
|
|
207
|
-
}
|
|
208
|
-
else {
|
|
209
|
-
assert(navItem.level !== 1);
|
|
210
|
-
columnEntry.navItems.push(navItem);
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
assert(isFullWidthCategory !== undefined);
|
|
214
|
-
navItemsByColumnEntries.push({ columnEntries: columnEntries, isFullWidthCategory: isFullWidthCategory });
|
|
215
|
-
return navItemsByColumnEntries;
|
|
216
|
-
}
|
|
217
|
-
function getNavItemsWithComputed(navItems, currentUrl) {
|
|
218
|
-
var navItemIdx;
|
|
219
|
-
var navItemsWithComputed = navItems.map(function (navItem, i) {
|
|
220
|
-
assert([1, 2, 3, 4].includes(navItem.level), navItem);
|
|
221
|
-
var navItemPrevious = navItems[i - 1];
|
|
222
|
-
var navItemNext = navItems[i + 1];
|
|
223
|
-
var isActive = false;
|
|
224
|
-
if (navItem.url === currentUrl) {
|
|
225
|
-
assert(navItem.level === 2, { currentUrl: currentUrl });
|
|
226
|
-
assert(navItemIdx === undefined);
|
|
227
|
-
navItemIdx = i;
|
|
228
|
-
isActive = true;
|
|
229
|
-
}
|
|
230
|
-
var isFirstOfItsKind = navItem.level !== (navItemPrevious === null || navItemPrevious === void 0 ? void 0 : navItemPrevious.level);
|
|
231
|
-
var isLastOfItsKind = navItem.level !== (navItemNext === null || navItemNext === void 0 ? void 0 : navItemNext.level);
|
|
232
|
-
var navItemComputed = __assign(__assign({}, navItem), { isActive: isActive, isRelevant: false, isFirstOfItsKind: isFirstOfItsKind, isLastOfItsKind: isLastOfItsKind });
|
|
233
|
-
return navItemComputed;
|
|
234
|
-
});
|
|
235
|
-
// Set `isRelevant`
|
|
236
|
-
if (navItemIdx !== undefined) {
|
|
237
|
-
for (var i = navItemIdx; i >= 0; i--) {
|
|
238
|
-
var navItem = navItemsWithComputed[i];
|
|
239
|
-
navItem.isRelevant = true;
|
|
240
|
-
if (navItem.level === 1)
|
|
241
|
-
break;
|
|
242
|
-
}
|
|
243
|
-
for (var i = navItemIdx; i < navItemsWithComputed.length; i++) {
|
|
244
|
-
var navItem = navItemsWithComputed[i];
|
|
245
|
-
if (navItem.level === 1)
|
|
246
|
-
break;
|
|
247
|
-
navItem.isRelevant = true;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
return navItemsWithComputed;
|
|
251
|
-
}
|
|
252
|
-
function Chevron(props) {
|
|
253
|
-
return (React.createElement("svg", __assign({ viewBox: "0 0 512 292.52", xmlns: "http://www.w3.org/2000/svg" }, props),
|
|
254
|
-
React.createElement("path", { fill: "#aaa", d: "M10.725 82.42L230.125 261.82c6.8 6.8 16.2 10.7 25.9 10.7s19.1-3.9 25.9-10.7l219.4-179.4c14.3-14.3 14.3-37.4 0-51.7s-37.4-14.3-51.7 0l-193.6 153.6-193.6-153.6c-14.3-14.3-37.4-14.3-51.7 0s-14.3 37.5 0 51.7z" })));
|
|
255
|
-
}
|
package/dist/utils/PassTrough.js
DELETED
package/dist/utils/Style.d.ts
DELETED
package/dist/utils/Style.js
DELETED
package/dist/utils/css.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function css(strings: TemplateStringsArray | string[], ...values: (string | number)[]): string;
|
package/dist/utils/css.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export function css(strings) {
|
|
2
|
-
var values = [];
|
|
3
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
4
|
-
values[_i - 1] = arguments[_i];
|
|
5
|
-
}
|
|
6
|
-
// The boring part
|
|
7
|
-
var result = strings
|
|
8
|
-
.map(function (str, i) {
|
|
9
|
-
var s = str;
|
|
10
|
-
if (i !== strings.length - 1) {
|
|
11
|
-
s += values[i];
|
|
12
|
-
}
|
|
13
|
-
return s;
|
|
14
|
-
})
|
|
15
|
-
.join('');
|
|
16
|
-
// Remove comments
|
|
17
|
-
result = result
|
|
18
|
-
.split('\n')
|
|
19
|
-
.filter(function (line) { return !line.startsWith('// '); })
|
|
20
|
-
.join('\n');
|
|
21
|
-
// Minifiy
|
|
22
|
-
result = result
|
|
23
|
-
.replace(/\s+/g, ' ') // Replace all whitespace sequences with a single space
|
|
24
|
-
.replace(/\s*([{}:;])\s*/g, '$1') // Remove space around {, }, :, ;
|
|
25
|
-
.trim(); // Trim any leading/trailing whitespace
|
|
26
|
-
return result;
|
|
27
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getViewportWidth(): number;
|
package/dist/utils/throttle.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function throttle<T extends (...args: any[]) => void>(func: T, limit: number): T;
|
package/dist/utils/throttle.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export function throttle(func, limit) {
|
|
2
|
-
var inThrottle;
|
|
3
|
-
return function () {
|
|
4
|
-
var args = [];
|
|
5
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
6
|
-
args[_i] = arguments[_i];
|
|
7
|
-
}
|
|
8
|
-
if (!inThrottle) {
|
|
9
|
-
func.apply(this, args);
|
|
10
|
-
inThrottle = true;
|
|
11
|
-
setTimeout(function () { return (inThrottle = false); }, limit);
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
}
|