@redocly/theme 0.1.27 → 0.1.28
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/Button/Button.js +3 -3
- package/CodeBlock/CodeBlock.js +1 -1
- package/CopyButton/CopyButton.js +17 -1
- package/Footer/Footer.js +2 -1
- package/Footer/FooterColumn.js +1 -1
- package/Footer/FooterColumns.d.ts +2 -2
- package/Footer/FooterColumns.js +1 -1
- package/JsonViewer/JsonViewer.d.ts +2 -0
- package/JsonViewer/JsonViewer.js +53 -22
- package/Markdown/Admonition.js +1 -1
- package/Markdown/CodeSample/CodeSample.js +17 -1
- package/Markdown/Heading.js +1 -1
- package/Markdown/Mermaid.js +1 -1
- package/Markdown/Sup.d.ts +2 -0
- package/Markdown/Sup.js +19 -0
- package/Markdown/Tabs/Tabs.js +17 -1
- package/Markdown/index.d.ts +4 -3
- package/Markdown/index.js +4 -3
- package/Navbar/MobileNavbarDropdown.d.ts +8 -0
- package/Navbar/MobileNavbarDropdown.js +21 -0
- package/Navbar/MobileNavbarItem.d.ts +15 -0
- package/Navbar/MobileNavbarItem.js +102 -0
- package/Navbar/MobileNavbarMenu.d.ts +6 -0
- package/Navbar/MobileNavbarMenu.js +32 -0
- package/Navbar/MobileNavbarMenuButton.d.ts +4 -0
- package/Navbar/MobileNavbarMenuButton.js +19 -0
- package/Navbar/Navbar.js +26 -4
- package/Navbar/NavbarDropdown.js +1 -1
- package/Navbar/NavbarItem.d.ts +9 -3
- package/Navbar/NavbarItem.js +9 -9
- package/Navbar/NavbarMenu.js +3 -2
- package/PageNavigation/NextPageLink.js +4 -4
- package/PageNavigation/PreviousPageLink.js +4 -4
- package/Panel/PanelComponent.js +18 -2
- package/Search/Autocomplete.js +18 -2
- package/Search/utils.js +17 -1
- package/Sidebar/SidebarLayout.js +17 -1
- package/SourceCode/SourceCode.d.ts +10 -3
- package/SourceCode/SourceCode.js +10 -5
- package/TableOfContent/TableOfContent.js +4 -4
- package/globalStyle.js +2 -2
- package/hooks/useActiveHeading.js +17 -1
- package/hooks/useActiveSectionId.js +17 -1
- package/hooks/useControl.js +17 -1
- package/hooks/useMobileMenu.js +17 -1
- package/hooks/useNavbarHeight.js +17 -1
- package/package.json +1 -1
- package/src/Button/Button.tsx +5 -1
- package/src/CodeBlock/CodeBlock.ts +12 -0
- package/src/Footer/Footer.tsx +4 -3
- package/src/Footer/FooterColumn.tsx +3 -1
- package/src/Footer/FooterColumns.tsx +3 -3
- package/src/JsonViewer/JsonViewer.tsx +55 -40
- package/src/Markdown/Admonition.tsx +1 -1
- package/src/Markdown/Heading.tsx +1 -1
- package/src/Markdown/Mermaid.tsx +1 -1
- package/src/Markdown/Sup.tsx +8 -0
- package/src/Markdown/index.ts +4 -3
- package/src/Navbar/MobileNavbarDropdown.tsx +37 -0
- package/src/Navbar/MobileNavbarItem.tsx +116 -0
- package/src/Navbar/MobileNavbarMenu.tsx +106 -0
- package/src/Navbar/MobileNavbarMenuButton.tsx +13 -0
- package/src/Navbar/Navbar.tsx +11 -3
- package/src/Navbar/NavbarDropdown.tsx +1 -1
- package/src/Navbar/NavbarItem.tsx +9 -8
- package/src/Navbar/NavbarMenu.tsx +9 -4
- package/src/PageNavigation/NextPageLink.tsx +3 -3
- package/src/PageNavigation/PreviousPageLink.tsx +3 -3
- package/src/SourceCode/SourceCode.tsx +32 -5
- package/src/TableOfContent/TableOfContent.tsx +3 -3
- package/src/globalStyle.ts +2 -0
- package/src/types/portal/src/client/app/Sidebar/types.d.ts +2 -1
- package/src/types/portal/src/server/constants.d.ts +2 -0
- package/src/types/portal/src/server/dev-server/types.d.ts +22 -0
- package/src/types/portal/src/server/plugins/markdown/types.d.ts +15 -5
- package/src/types/portal/src/server/plugins/portal-config/get-frontmatter-keys-to-resolve.d.ts +2 -0
- package/src/types/portal/src/server/plugins/portal-config/types.d.ts +6 -2
- package/src/types/portal/src/server/plugins/reference-docs/utils.d.ts +26 -0
- package/src/types/portal/src/server/plugins/types.d.ts +29 -12
- package/src/types/portal/src/server/store.d.ts +16 -16
- package/src/types/portal/src/server/utils/fs.d.ts +2 -1
- package/src/types/portal/src/server/utils/index.d.ts +1 -0
- package/src/types/portal/src/server/utils/paths.d.ts +4 -0
- package/src/types/portal/src/server/utils/rbac.d.ts +15 -0
- package/src/types/portal/src/shared/constants.d.ts +7 -0
- package/src/types/portal/src/shared/models/config.d.ts +24 -12
- package/src/types/portal/src/shared/types.d.ts +17 -4
- package/src/types/portal/src/shared/urls.d.ts +1 -1
- package/src/types/portal/src/shared/utils.d.ts +2 -0
- package/src/ui/Burger.tsx +36 -0
- package/src/ui/Flex.tsx +1 -0
- package/src/utils/args-typecheck.ts +9 -0
- package/src/utils/highlight.ts +11 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/jsonToHtml.ts +171 -59
- package/ui/Burger.d.ts +8 -0
- package/ui/Burger.js +23 -0
- package/ui/Dropdown.js +17 -1
- package/ui/Flex.js +1 -1
- package/ui/UniversalLink.js +17 -1
- package/utils/args-typecheck.d.ts +2 -0
- package/utils/args-typecheck.js +13 -0
- package/utils/highlight.d.ts +1 -0
- package/utils/highlight.js +12 -1
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/jsonToHtml.d.ts +4 -1
- package/utils/jsonToHtml.js +287 -83
- package/utils/media-css.js +40 -3
- package/utils/theme-helpers.js +56 -9
package/ui/Dropdown.js
CHANGED
|
@@ -26,6 +26,22 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
26
26
|
__setModuleDefault(result, mod);
|
|
27
27
|
return result;
|
|
28
28
|
};
|
|
29
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
30
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
31
|
+
if (!m) return o;
|
|
32
|
+
var i = m.call(o), r, ar = [], e;
|
|
33
|
+
try {
|
|
34
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
35
|
+
}
|
|
36
|
+
catch (error) { e = { error: error }; }
|
|
37
|
+
finally {
|
|
38
|
+
try {
|
|
39
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
40
|
+
}
|
|
41
|
+
finally { if (e) throw e.error; }
|
|
42
|
+
}
|
|
43
|
+
return ar;
|
|
44
|
+
};
|
|
29
45
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
30
46
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
31
47
|
};
|
|
@@ -45,7 +61,7 @@ var DropDownLink = (0, styled_components_1.default)(Link_1.Link)(templateObject_
|
|
|
45
61
|
function Dropdown(_a) {
|
|
46
62
|
var items = _a.items, activeItem = _a.activeItem;
|
|
47
63
|
var ref = (0, react_1.useRef)(null);
|
|
48
|
-
var _b = (0, react_1.useState)(false), isOpen = _b[0], setIsOpen = _b[1];
|
|
64
|
+
var _b = __read((0, react_1.useState)(false), 2), isOpen = _b[0], setIsOpen = _b[1];
|
|
49
65
|
var toggling = function () { return setIsOpen(!isOpen); };
|
|
50
66
|
(0, react_1.useEffect)(function () {
|
|
51
67
|
var checkIfClickedOutside = function (e) {
|
package/ui/Flex.js
CHANGED
|
@@ -23,7 +23,7 @@ var react_1 = __importDefault(require("react"));
|
|
|
23
23
|
var styled_components_1 = __importDefault(require("styled-components"));
|
|
24
24
|
var styled_system_1 = require("styled-system");
|
|
25
25
|
var Box_1 = require("../ui/Box");
|
|
26
|
-
exports.Flex = (0, styled_components_1.default)(Box_1.Box).attrs({ 'data-component-name': 'ui/Flex' })(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n ", "\n ", "\n"], ["\n display: flex;\n ", "\n ", "\n"])), styled_system_1.flexbox, styled_system_1.width);
|
|
26
|
+
exports.Flex = (0, styled_components_1.default)(Box_1.Box).attrs({ 'data-component-name': 'ui/Flex' })(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n flex-wrap: wrap;\n ", "\n ", "\n"], ["\n display: flex;\n flex-wrap: wrap;\n ", "\n ", "\n"])), styled_system_1.flexbox, styled_system_1.width);
|
|
27
27
|
function FlexSection(props) {
|
|
28
28
|
return (react_1.default.createElement(exports.Flex, __assign({}, props, { width: props.width || { xs: '90%', large: 910 } }), props.children));
|
|
29
29
|
}
|
package/ui/UniversalLink.js
CHANGED
|
@@ -37,6 +37,22 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
37
37
|
__setModuleDefault(result, mod);
|
|
38
38
|
return result;
|
|
39
39
|
};
|
|
40
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
41
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
42
|
+
if (!m) return o;
|
|
43
|
+
var i = m.call(o), r, ar = [], e;
|
|
44
|
+
try {
|
|
45
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
46
|
+
}
|
|
47
|
+
catch (error) { e = { error: error }; }
|
|
48
|
+
finally {
|
|
49
|
+
try {
|
|
50
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
51
|
+
}
|
|
52
|
+
finally { if (e) throw e.error; }
|
|
53
|
+
}
|
|
54
|
+
return ar;
|
|
55
|
+
};
|
|
40
56
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
41
57
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
42
58
|
};
|
|
@@ -66,7 +82,7 @@ var propsList = [
|
|
|
66
82
|
var withPropsFilter = function (filterList) { return function (WrappedComponent) {
|
|
67
83
|
return function WithPropsFilter(props) {
|
|
68
84
|
var filteredProps = Object.fromEntries(Object.entries(props).filter(function (_a) {
|
|
69
|
-
var key =
|
|
85
|
+
var _b = __read(_a, 1), key = _b[0];
|
|
70
86
|
return !filterList.includes(key);
|
|
71
87
|
}));
|
|
72
88
|
return React.createElement(WrappedComponent, __assign({}, filteredProps));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isPrimitive = exports.isEmptyArray = void 0;
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
5
|
+
function isEmptyArray(items) {
|
|
6
|
+
return Array.isArray(items) && !(items === null || items === void 0 ? void 0 : items.length);
|
|
7
|
+
}
|
|
8
|
+
exports.isEmptyArray = isEmptyArray;
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
10
|
+
function isPrimitive(arg) {
|
|
11
|
+
return ['string', 'boolean', 'number'].includes(typeof arg);
|
|
12
|
+
}
|
|
13
|
+
exports.isPrimitive = isPrimitive;
|
package/utils/highlight.d.ts
CHANGED
|
@@ -30,3 +30,4 @@ export declare function mapLang(lang: string): string;
|
|
|
30
30
|
* @return highlighted source code as **html string**
|
|
31
31
|
*/
|
|
32
32
|
export declare function highlight(source: string | number | boolean, lang?: string): string;
|
|
33
|
+
export declare function addLineNumbers(highlightedCode: string, start?: number): string;
|
package/utils/highlight.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.highlight = exports.mapLang = void 0;
|
|
26
|
+
exports.addLineNumbers = exports.highlight = exports.mapLang = void 0;
|
|
27
27
|
var Prism = __importStar(require("prismjs"));
|
|
28
28
|
require("prismjs/components/prism-bash.js");
|
|
29
29
|
require("prismjs/components/prism-c.js");
|
|
@@ -47,6 +47,7 @@ require("prismjs/components/prism-sql.js");
|
|
|
47
47
|
require("prismjs/components/prism-swift.js");
|
|
48
48
|
require("prismjs/components/prism-graphql.js");
|
|
49
49
|
var DEFAULT_LANG = 'clike';
|
|
50
|
+
var NEW_LINE_EXP = /\n(?!$)/g;
|
|
50
51
|
Prism.languages.insertBefore('javascript', 'string', {
|
|
51
52
|
'property string': {
|
|
52
53
|
pattern: /([{,]\s*)"(?:\\.|[^\\"\r\n])*"(?=\s*:)/i,
|
|
@@ -91,3 +92,13 @@ function highlight(source, lang) {
|
|
|
91
92
|
return Prism.highlight(source.toString(), grammar, lang);
|
|
92
93
|
}
|
|
93
94
|
exports.highlight = highlight;
|
|
95
|
+
function addLineNumbers(highlightedCode, start) {
|
|
96
|
+
if (start === void 0) { start = 1; }
|
|
97
|
+
var codeLines = highlightedCode.split(NEW_LINE_EXP);
|
|
98
|
+
return codeLines
|
|
99
|
+
.map(function (line, i) {
|
|
100
|
+
return "<span class=\"code-line\" data-line-number=".concat(start + i, ">").concat(line, "</span>");
|
|
101
|
+
})
|
|
102
|
+
.join('\n');
|
|
103
|
+
}
|
|
104
|
+
exports.addLineNumbers = addLineNumbers;
|
package/utils/index.d.ts
CHANGED
package/utils/index.js
CHANGED
package/utils/jsonToHtml.d.ts
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
declare type JsonValue = JSON | Record<string, unknown>;
|
|
2
|
+
export declare function jsonToHTML(json: JsonValue, maxExpandLevel: number, startLine?: number): string;
|
|
3
|
+
export declare function getLines(json: JsonValue, maxExpandLevel: number): string;
|
|
4
|
+
export {};
|
package/utils/jsonToHtml.js
CHANGED
|
@@ -1,14 +1,57 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
3
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
4
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
5
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
6
|
+
function step(op) {
|
|
7
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
8
|
+
while (_) try {
|
|
9
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
10
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
11
|
+
switch (op[0]) {
|
|
12
|
+
case 0: case 1: t = op; break;
|
|
13
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
14
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
15
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
16
|
+
default:
|
|
17
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
18
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
19
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
20
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
21
|
+
if (t[2]) _.ops.pop();
|
|
22
|
+
_.trys.pop(); continue;
|
|
23
|
+
}
|
|
24
|
+
op = body.call(thisArg, _);
|
|
25
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
26
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var __values = (this && this.__values) || function(o) {
|
|
30
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
31
|
+
if (m) return m.call(o);
|
|
32
|
+
if (o && typeof o.length === "number") return {
|
|
33
|
+
next: function () {
|
|
34
|
+
if (o && i >= o.length) o = void 0;
|
|
35
|
+
return { value: o && o[i++], done: !o };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
39
|
+
};
|
|
2
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.jsonToHTML = void 0;
|
|
41
|
+
exports.getLines = exports.jsonToHTML = void 0;
|
|
4
42
|
// Moved from reference-docs
|
|
5
|
-
var level =
|
|
6
|
-
|
|
7
|
-
|
|
43
|
+
var level = 0;
|
|
44
|
+
var line = 1;
|
|
45
|
+
var ellipsis = '<span class="ellipsis"></span>';
|
|
46
|
+
var colon = '<span class="colon">: </span>';
|
|
47
|
+
function jsonToHTML(json, maxExpandLevel, startLine) {
|
|
48
|
+
if (startLine === void 0) { startLine = 1; }
|
|
49
|
+
level = 0;
|
|
50
|
+
line = startLine;
|
|
8
51
|
var output = '';
|
|
9
52
|
output += '<div data-cy="json-sample" class="redoc-json">';
|
|
10
53
|
output += '<code>';
|
|
11
|
-
output +=
|
|
54
|
+
output += getLines(json, maxExpandLevel);
|
|
12
55
|
output += '</code>';
|
|
13
56
|
output += '</div>';
|
|
14
57
|
return output;
|
|
@@ -33,88 +76,249 @@ function decorateWithSpan(value, className) {
|
|
|
33
76
|
function punctuation(val) {
|
|
34
77
|
return '<span class="token punctuation">' + val + '</span>';
|
|
35
78
|
}
|
|
36
|
-
function
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
else if (value && value.constructor === Date) {
|
|
48
|
-
output += decorateWithSpan('"' + value.toISOString() + '"', 'token string');
|
|
49
|
-
}
|
|
50
|
-
else if (valueType === 'object') {
|
|
51
|
-
level++;
|
|
52
|
-
output += objectToHTML(value, maxExpandLevel);
|
|
53
|
-
level--;
|
|
54
|
-
}
|
|
55
|
-
else if (valueType === 'number') {
|
|
56
|
-
output += decorateWithSpan(value, 'token number');
|
|
79
|
+
function collapser(maxExpandLevel) {
|
|
80
|
+
var collapsed = level > maxExpandLevel ? 'expand' : 'collapse';
|
|
81
|
+
return "<button class=\"collapser\" aria-label=\"".concat(collapsed, "\"></button>");
|
|
82
|
+
}
|
|
83
|
+
function getLines(json, maxExpandLevel) {
|
|
84
|
+
var collapsibleLines = [];
|
|
85
|
+
var lines = valueToHTML(json, maxExpandLevel, 'root');
|
|
86
|
+
var nextLine = lines.next();
|
|
87
|
+
while (!nextLine.done) {
|
|
88
|
+
collapsibleLines.push(nextLine.value);
|
|
89
|
+
nextLine = lines.next();
|
|
57
90
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
91
|
+
collapsibleLines.push(nextLine.value);
|
|
92
|
+
return collapsibleLines.join('\n');
|
|
93
|
+
}
|
|
94
|
+
exports.getLines = getLines;
|
|
95
|
+
function valueToHTML(value, maxExpandLevel, context) {
|
|
96
|
+
var valueType, length_1, _a, _b, line_1, e_1_1, keys, _c, _d, line_2, e_2_1;
|
|
97
|
+
var e_1, _e, e_2, _f;
|
|
98
|
+
return __generator(this, function (_g) {
|
|
99
|
+
switch (_g.label) {
|
|
100
|
+
case 0:
|
|
101
|
+
valueType = typeof value;
|
|
102
|
+
if (!(value === undefined || value === null)) return [3 /*break*/, 1];
|
|
103
|
+
return [2 /*return*/, decorateWithSpan('null', 'token keyword')];
|
|
104
|
+
case 1:
|
|
105
|
+
if (!(value && value.constructor === Array)) return [3 /*break*/, 11];
|
|
106
|
+
length_1 = typeof value.length === 'number' ? value.length : 0;
|
|
107
|
+
if (!length_1) {
|
|
108
|
+
return [2 /*return*/, punctuation('[ ]')];
|
|
109
|
+
}
|
|
110
|
+
level++;
|
|
111
|
+
return [4 /*yield*/, context === 'root'
|
|
112
|
+
? "<span data-line=\"".concat(line++, "\">").concat(punctuation('['), "</span>")
|
|
113
|
+
: punctuation('[')];
|
|
114
|
+
case 2:
|
|
115
|
+
_g.sent();
|
|
116
|
+
_g.label = 3;
|
|
117
|
+
case 3:
|
|
118
|
+
_g.trys.push([3, 8, 9, 10]);
|
|
119
|
+
_a = __values(arrayToHTML(value, length_1, maxExpandLevel)), _b = _a.next();
|
|
120
|
+
_g.label = 4;
|
|
121
|
+
case 4:
|
|
122
|
+
if (!!_b.done) return [3 /*break*/, 7];
|
|
123
|
+
line_1 = _b.value;
|
|
124
|
+
return [4 /*yield*/, line_1];
|
|
125
|
+
case 5:
|
|
126
|
+
_g.sent();
|
|
127
|
+
_g.label = 6;
|
|
128
|
+
case 6:
|
|
129
|
+
_b = _a.next();
|
|
130
|
+
return [3 /*break*/, 4];
|
|
131
|
+
case 7: return [3 /*break*/, 10];
|
|
132
|
+
case 8:
|
|
133
|
+
e_1_1 = _g.sent();
|
|
134
|
+
e_1 = { error: e_1_1 };
|
|
135
|
+
return [3 /*break*/, 10];
|
|
136
|
+
case 9:
|
|
137
|
+
try {
|
|
138
|
+
if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
|
|
139
|
+
}
|
|
140
|
+
finally { if (e_1) throw e_1.error; }
|
|
141
|
+
return [7 /*endfinally*/];
|
|
142
|
+
case 10:
|
|
143
|
+
level--;
|
|
144
|
+
return [2 /*return*/, "<span data-line=\"".concat(line++, "\">").concat(punctuation(']'), "</span>")];
|
|
145
|
+
case 11:
|
|
146
|
+
if (!(value && value.constructor === Date)) return [3 /*break*/, 12];
|
|
147
|
+
return [2 /*return*/, decorateWithSpan('"' + value.toISOString() + '"', 'token string')];
|
|
148
|
+
case 12:
|
|
149
|
+
if (!(valueType === 'object')) return [3 /*break*/, 22];
|
|
150
|
+
keys = Object.keys(value);
|
|
151
|
+
if (!keys.length) {
|
|
152
|
+
return [2 /*return*/, punctuation('{ }')];
|
|
153
|
+
}
|
|
154
|
+
level++;
|
|
155
|
+
return [4 /*yield*/, context === 'root'
|
|
156
|
+
? "<span data-line=\"".concat(line++, "\">").concat(punctuation('{'), "</span>")
|
|
157
|
+
: punctuation('{')];
|
|
158
|
+
case 13:
|
|
159
|
+
_g.sent();
|
|
160
|
+
_g.label = 14;
|
|
161
|
+
case 14:
|
|
162
|
+
_g.trys.push([14, 19, 20, 21]);
|
|
163
|
+
_c = __values(objectToHTML(value, keys, maxExpandLevel)), _d = _c.next();
|
|
164
|
+
_g.label = 15;
|
|
165
|
+
case 15:
|
|
166
|
+
if (!!_d.done) return [3 /*break*/, 18];
|
|
167
|
+
line_2 = _d.value;
|
|
168
|
+
return [4 /*yield*/, line_2];
|
|
169
|
+
case 16:
|
|
170
|
+
_g.sent();
|
|
171
|
+
_g.label = 17;
|
|
172
|
+
case 17:
|
|
173
|
+
_d = _c.next();
|
|
174
|
+
return [3 /*break*/, 15];
|
|
175
|
+
case 18: return [3 /*break*/, 21];
|
|
176
|
+
case 19:
|
|
177
|
+
e_2_1 = _g.sent();
|
|
178
|
+
e_2 = { error: e_2_1 };
|
|
179
|
+
return [3 /*break*/, 21];
|
|
180
|
+
case 20:
|
|
181
|
+
try {
|
|
182
|
+
if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
|
|
183
|
+
}
|
|
184
|
+
finally { if (e_2) throw e_2.error; }
|
|
185
|
+
return [7 /*endfinally*/];
|
|
186
|
+
case 21:
|
|
187
|
+
level--;
|
|
188
|
+
return [2 /*return*/, "<span data-line=\"".concat(line++, "\">").concat(punctuation('}'), "</span>")];
|
|
189
|
+
case 22:
|
|
190
|
+
if (valueType === 'number') {
|
|
191
|
+
return [2 /*return*/, decorateWithSpan(value, 'token number')];
|
|
192
|
+
}
|
|
193
|
+
else if (valueType === 'string') {
|
|
194
|
+
if (/^(http|https):\/\/[^\s]+$/.test(value)) {
|
|
195
|
+
return [2 /*return*/, (decorateWithSpan('"', 'token string') +
|
|
196
|
+
"<a href=\"".concat(encodeURI(value), "\">") +
|
|
197
|
+
htmlEncode(stringifyStringLiteral(value)) +
|
|
198
|
+
'</a>' +
|
|
199
|
+
decorateWithSpan('"', 'token string'))];
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
return [2 /*return*/, decorateWithSpan('"' + stringifyStringLiteral(value) + '"', 'token string')];
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
else if (valueType === 'boolean') {
|
|
206
|
+
return [2 /*return*/, decorateWithSpan(value, 'token boolean')];
|
|
207
|
+
}
|
|
208
|
+
_g.label = 23;
|
|
209
|
+
case 23: return [2 /*return*/];
|
|
71
210
|
}
|
|
72
|
-
}
|
|
73
|
-
else if (valueType === 'boolean') {
|
|
74
|
-
output += decorateWithSpan(value, 'token boolean');
|
|
75
|
-
}
|
|
76
|
-
return output;
|
|
211
|
+
});
|
|
77
212
|
}
|
|
78
|
-
function
|
|
79
|
-
var
|
|
80
|
-
var
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
213
|
+
function getLineTemplate(_a) {
|
|
214
|
+
var isFirstKey = _a.isFirstKey, isLastKey = _a.isLastKey, nextLine = _a.nextLine, context = _a.context, lineTemplate = _a.lineTemplate, maxExpandLevel = _a.maxExpandLevel;
|
|
215
|
+
var lineValue = isFirstKey ? "".concat(ellipsis, "<span class=\"").concat(context, " collapsible\">") : '';
|
|
216
|
+
// Create hoverable
|
|
217
|
+
lineValue += "<span data-line=\"".concat(line++, "\" class=\"").concat(level > maxExpandLevel ? 'hoverable collapsed' : 'hoverable', "\">");
|
|
218
|
+
// Add collapser button if item has nested lines
|
|
219
|
+
lineValue += (!nextLine.done && collapser(maxExpandLevel)) || '';
|
|
220
|
+
lineValue += lineTemplate;
|
|
221
|
+
lineValue += nextLine.value;
|
|
222
|
+
// Add punctuation in case we dont have more nested lines and it is not last item
|
|
223
|
+
lineValue += nextLine.done && !isLastKey ? punctuation(',') : '';
|
|
224
|
+
// Close hoverable if we dont have nested lines
|
|
225
|
+
lineValue += nextLine.done ? '</span>' : '';
|
|
226
|
+
// Close collapsible if value is single line and we are on last item
|
|
227
|
+
lineValue += nextLine.done && isLastKey ? '</span>' : '';
|
|
228
|
+
return lineValue;
|
|
229
|
+
}
|
|
230
|
+
function arrayToHTML(array, arrayLength, maxExpandLevel) {
|
|
231
|
+
var i, lines, isFirstKey, isLastKey, nextLine;
|
|
232
|
+
return __generator(this, function (_a) {
|
|
233
|
+
switch (_a.label) {
|
|
234
|
+
case 0:
|
|
235
|
+
i = 0;
|
|
236
|
+
_a.label = 1;
|
|
237
|
+
case 1:
|
|
238
|
+
if (!(i < arrayLength)) return [3 /*break*/, 8];
|
|
239
|
+
lines = valueToHTML(array[i], maxExpandLevel, 'array');
|
|
240
|
+
isFirstKey = i === 0;
|
|
241
|
+
isLastKey = i === arrayLength - 1;
|
|
242
|
+
nextLine = lines.next();
|
|
243
|
+
return [4 /*yield*/, getLineTemplate({
|
|
244
|
+
context: 'array',
|
|
245
|
+
isFirstKey: isFirstKey,
|
|
246
|
+
isLastKey: isLastKey,
|
|
247
|
+
nextLine: nextLine,
|
|
248
|
+
lineTemplate: '',
|
|
249
|
+
maxExpandLevel: maxExpandLevel,
|
|
250
|
+
})];
|
|
251
|
+
case 2:
|
|
252
|
+
_a.sent();
|
|
253
|
+
nextLine = lines.next();
|
|
254
|
+
_a.label = 3;
|
|
255
|
+
case 3:
|
|
256
|
+
if (!!nextLine.done) return [3 /*break*/, 5];
|
|
257
|
+
return [4 /*yield*/, nextLine.value];
|
|
258
|
+
case 4:
|
|
259
|
+
_a.sent();
|
|
260
|
+
nextLine = lines.next();
|
|
261
|
+
return [3 /*break*/, 3];
|
|
262
|
+
case 5:
|
|
263
|
+
if (!nextLine.value) return [3 /*break*/, 7];
|
|
264
|
+
// Close hoverable and collapsible (if last array item)
|
|
265
|
+
return [4 /*yield*/, "".concat(nextLine.value).concat(i < arrayLength - 1 ? punctuation(',') : '</span>', "</span>")];
|
|
266
|
+
case 6:
|
|
267
|
+
// Close hoverable and collapsible (if last array item)
|
|
268
|
+
_a.sent();
|
|
269
|
+
_a.label = 7;
|
|
270
|
+
case 7:
|
|
271
|
+
i++;
|
|
272
|
+
return [3 /*break*/, 1];
|
|
273
|
+
case 8: return [2 /*return*/];
|
|
89
274
|
}
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
output += "</ul>".concat(punctuation(']'));
|
|
93
|
-
if (!hasContents) {
|
|
94
|
-
output = punctuation('[ ]');
|
|
95
|
-
}
|
|
96
|
-
return output;
|
|
275
|
+
});
|
|
97
276
|
}
|
|
98
|
-
function objectToHTML(
|
|
99
|
-
var
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
277
|
+
function objectToHTML(object, keys, maxExpandLevel) {
|
|
278
|
+
var i, key, lines, isFirstKey, isLastKey, nextLine;
|
|
279
|
+
return __generator(this, function (_a) {
|
|
280
|
+
switch (_a.label) {
|
|
281
|
+
case 0:
|
|
282
|
+
i = 0;
|
|
283
|
+
_a.label = 1;
|
|
284
|
+
case 1:
|
|
285
|
+
if (!(i < keys.length)) return [3 /*break*/, 8];
|
|
286
|
+
key = keys[i];
|
|
287
|
+
lines = valueToHTML(object[key], maxExpandLevel, 'object');
|
|
288
|
+
isFirstKey = i === 0;
|
|
289
|
+
isLastKey = i === keys.length - 1;
|
|
290
|
+
nextLine = lines.next();
|
|
291
|
+
return [4 /*yield*/, getLineTemplate({
|
|
292
|
+
context: 'obj',
|
|
293
|
+
isFirstKey: isFirstKey,
|
|
294
|
+
isLastKey: isLastKey,
|
|
295
|
+
nextLine: nextLine,
|
|
296
|
+
lineTemplate: "<span class=\"property token string\">\"".concat(htmlEncode(key), "\"</span>").concat(colon),
|
|
297
|
+
maxExpandLevel: maxExpandLevel,
|
|
298
|
+
})];
|
|
299
|
+
case 2:
|
|
300
|
+
_a.sent();
|
|
301
|
+
nextLine = lines.next();
|
|
302
|
+
_a.label = 3;
|
|
303
|
+
case 3:
|
|
304
|
+
if (!!nextLine.done) return [3 /*break*/, 5];
|
|
305
|
+
return [4 /*yield*/, nextLine.value];
|
|
306
|
+
case 4:
|
|
307
|
+
_a.sent();
|
|
308
|
+
nextLine = lines.next();
|
|
309
|
+
return [3 /*break*/, 3];
|
|
310
|
+
case 5:
|
|
311
|
+
if (!nextLine.value) return [3 /*break*/, 7];
|
|
312
|
+
// Close hoverable and collapsible (if last field)
|
|
313
|
+
return [4 /*yield*/, "".concat(nextLine.value).concat(isLastKey ? '</span>' : punctuation(','), "</span>")];
|
|
314
|
+
case 6:
|
|
315
|
+
// Close hoverable and collapsible (if last field)
|
|
316
|
+
_a.sent();
|
|
317
|
+
_a.label = 7;
|
|
318
|
+
case 7:
|
|
319
|
+
i++;
|
|
320
|
+
return [3 /*break*/, 1];
|
|
321
|
+
case 8: return [2 /*return*/];
|
|
112
322
|
}
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
output += "</ul>".concat(punctuation('}'));
|
|
116
|
-
if (!hasContents) {
|
|
117
|
-
output = punctuation('{ }');
|
|
118
|
-
}
|
|
119
|
-
return output;
|
|
323
|
+
});
|
|
120
324
|
}
|
package/utils/media-css.js
CHANGED
|
@@ -1,12 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __values = (this && this.__values) || function(o) {
|
|
3
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
4
|
+
if (m) return m.call(o);
|
|
5
|
+
if (o && typeof o.length === "number") return {
|
|
6
|
+
next: function () {
|
|
7
|
+
if (o && i >= o.length) o = void 0;
|
|
8
|
+
return { value: o && o[i++], done: !o };
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
12
|
+
};
|
|
13
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
14
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
15
|
+
if (!m) return o;
|
|
16
|
+
var i = m.call(o), r, ar = [], e;
|
|
17
|
+
try {
|
|
18
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
19
|
+
}
|
|
20
|
+
catch (error) { e = { error: error }; }
|
|
21
|
+
finally {
|
|
22
|
+
try {
|
|
23
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
24
|
+
}
|
|
25
|
+
finally { if (e) throw e.error; }
|
|
26
|
+
}
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
2
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
30
|
exports.generateMediaQueries = exports.breakpoints = void 0;
|
|
4
31
|
exports.breakpoints = { small: '50rem', medium: '85rem', large: '105rem' };
|
|
5
32
|
function generateMediaQueries(breakpoints) {
|
|
33
|
+
var e_1, _a;
|
|
6
34
|
var result = { print: '@media print' };
|
|
7
|
-
|
|
8
|
-
var _b =
|
|
9
|
-
|
|
35
|
+
try {
|
|
36
|
+
for (var _b = __values(Object.entries(breakpoints)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
37
|
+
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
|
|
38
|
+
result[key] = "@media screen and (min-width: ".concat(value, ")");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
42
|
+
finally {
|
|
43
|
+
try {
|
|
44
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
45
|
+
}
|
|
46
|
+
finally { if (e_1) throw e_1.error; }
|
|
10
47
|
}
|
|
11
48
|
return result;
|
|
12
49
|
}
|