@redocly/theme 0.1.27 → 0.1.30
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/CopyButton/CopyButtonWrapper.js +1 -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/Profile/Profile.d.ts +8 -0
- package/Profile/Profile.js +60 -0
- package/Profile/index.d.ts +2 -0
- package/Profile/index.js +5 -0
- 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 +13 -5
- package/Tooltip/Tooltip.d.ts +5 -4
- package/Tooltip/Tooltip.js +43 -21
- package/globalStyle.js +2 -2
- package/hooks/__tests__/mocks/MockIntersectionObserver.d.ts +15 -0
- package/hooks/__tests__/mocks/MockIntersectionObserver.js +39 -0
- package/hooks/useActiveHeading.d.ts +1 -1
- package/hooks/useActiveHeading.js +86 -21
- 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/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +1 -1
- package/src/Button/Button.tsx +5 -1
- package/src/CodeBlock/CodeBlock.ts +12 -0
- package/src/CopyButton/CopyButtonWrapper.tsx +1 -1
- 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/Profile/Profile.tsx +91 -0
- package/src/Profile/index.ts +2 -0
- package/src/SourceCode/SourceCode.tsx +32 -5
- package/src/TableOfContent/TableOfContent.tsx +14 -4
- package/src/Tooltip/Tooltip.tsx +87 -63
- package/src/globalStyle.ts +2 -0
- package/src/hooks/useActiveHeading.ts +92 -28
- package/src/index.ts +1 -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/color.ts +9 -0
- package/src/utils/highlight.ts +11 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/jsonToHtml.ts +171 -59
- package/src/utils/theme-helpers.ts +3 -1
- 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/color.d.ts +2 -0
- package/utils/color.js +12 -0
- package/utils/highlight.d.ts +1 -0
- package/utils/highlight.js +12 -1
- package/utils/index.d.ts +2 -0
- package/utils/index.js +2 -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 +59 -10
package/src/utils/jsonToHtml.ts
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
// Moved from reference-docs
|
|
2
|
-
let level =
|
|
2
|
+
let level = 0;
|
|
3
|
+
let line = 1;
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
type ValueContext = 'array' | 'object' | 'root';
|
|
6
|
+
type LineGenerator = Generator<string, string | void, void>;
|
|
7
|
+
type JsonValue = JSON | Record<string, unknown>;
|
|
8
|
+
|
|
9
|
+
const ellipsis = '<span class="ellipsis"></span>';
|
|
10
|
+
const colon = '<span class="colon">: </span>';
|
|
11
|
+
|
|
12
|
+
export function jsonToHTML(json: JsonValue, maxExpandLevel: number, startLine = 1): string {
|
|
13
|
+
level = 0;
|
|
14
|
+
line = startLine;
|
|
6
15
|
let output = '';
|
|
7
16
|
output += '<div data-cy="json-sample" class="redoc-json">';
|
|
8
17
|
output += '<code>';
|
|
9
|
-
output +=
|
|
18
|
+
output += getLines(json, maxExpandLevel);
|
|
10
19
|
output += '</code>';
|
|
11
20
|
output += '</div>';
|
|
12
21
|
return output;
|
|
@@ -35,88 +44,191 @@ function punctuation(val: any) {
|
|
|
35
44
|
return '<span class="token punctuation">' + val + '</span>';
|
|
36
45
|
}
|
|
37
46
|
|
|
38
|
-
function
|
|
47
|
+
function collapser(maxExpandLevel: number): string {
|
|
48
|
+
const collapsed = level > maxExpandLevel ? 'expand' : 'collapse';
|
|
49
|
+
|
|
50
|
+
return `<button class="collapser" aria-label="${collapsed}"></button>`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function getLines(json: JsonValue, maxExpandLevel: number): string {
|
|
54
|
+
const collapsibleLines = [];
|
|
55
|
+
const lines = valueToHTML(json, maxExpandLevel, 'root');
|
|
56
|
+
|
|
57
|
+
let nextLine = lines.next();
|
|
58
|
+
|
|
59
|
+
while (!nextLine.done) {
|
|
60
|
+
collapsibleLines.push(nextLine.value);
|
|
61
|
+
nextLine = lines.next();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
collapsibleLines.push(nextLine.value);
|
|
65
|
+
|
|
66
|
+
return collapsibleLines.join('\n');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function* valueToHTML(value: any, maxExpandLevel: number, context: ValueContext) {
|
|
39
70
|
const valueType = typeof value;
|
|
40
|
-
|
|
71
|
+
|
|
41
72
|
if (value === undefined || value === null) {
|
|
42
|
-
|
|
73
|
+
return decorateWithSpan('null', 'token keyword');
|
|
43
74
|
} else if (value && value.constructor === Array) {
|
|
75
|
+
const length = typeof value.length === 'number' ? value.length : 0;
|
|
76
|
+
|
|
77
|
+
if (!length) {
|
|
78
|
+
return punctuation('[ ]');
|
|
79
|
+
}
|
|
80
|
+
|
|
44
81
|
level++;
|
|
45
|
-
|
|
82
|
+
|
|
83
|
+
yield context === 'root'
|
|
84
|
+
? `<span data-line="${line++}">${punctuation('[')}</span>`
|
|
85
|
+
: punctuation('[');
|
|
86
|
+
|
|
87
|
+
for (const line of arrayToHTML(value, length, maxExpandLevel)) {
|
|
88
|
+
yield line;
|
|
89
|
+
}
|
|
90
|
+
|
|
46
91
|
level--;
|
|
92
|
+
|
|
93
|
+
return `<span data-line="${line++}">${punctuation(']')}</span>`;
|
|
47
94
|
} else if (value && value.constructor === Date) {
|
|
48
|
-
|
|
95
|
+
return decorateWithSpan('"' + value.toISOString() + '"', 'token string');
|
|
49
96
|
} else if (valueType === 'object') {
|
|
97
|
+
const keys = Object.keys(value);
|
|
98
|
+
|
|
99
|
+
if (!keys.length) {
|
|
100
|
+
return punctuation('{ }');
|
|
101
|
+
}
|
|
102
|
+
|
|
50
103
|
level++;
|
|
51
|
-
|
|
104
|
+
|
|
105
|
+
yield context === 'root'
|
|
106
|
+
? `<span data-line="${line++}">${punctuation('{')}</span>`
|
|
107
|
+
: punctuation('{');
|
|
108
|
+
|
|
109
|
+
for (const line of objectToHTML(value, keys, maxExpandLevel)) {
|
|
110
|
+
yield line;
|
|
111
|
+
}
|
|
112
|
+
|
|
52
113
|
level--;
|
|
114
|
+
|
|
115
|
+
return `<span data-line="${line++}">${punctuation('}')}</span>`;
|
|
53
116
|
} else if (valueType === 'number') {
|
|
54
|
-
|
|
117
|
+
return decorateWithSpan(value, 'token number');
|
|
55
118
|
} else if (valueType === 'string') {
|
|
56
119
|
if (/^(http|https):\/\/[^\s]+$/.test(value)) {
|
|
57
|
-
|
|
120
|
+
return (
|
|
58
121
|
decorateWithSpan('"', 'token string') +
|
|
59
|
-
|
|
60
|
-
encodeURI(value) +
|
|
61
|
-
'">' +
|
|
122
|
+
`<a href="${encodeURI(value)}">` +
|
|
62
123
|
htmlEncode(stringifyStringLiteral(value)) +
|
|
63
124
|
'</a>' +
|
|
64
|
-
decorateWithSpan('"', 'token string')
|
|
125
|
+
decorateWithSpan('"', 'token string')
|
|
126
|
+
);
|
|
65
127
|
} else {
|
|
66
|
-
|
|
128
|
+
return decorateWithSpan('"' + stringifyStringLiteral(value) + '"', 'token string');
|
|
67
129
|
}
|
|
68
130
|
} else if (valueType === 'boolean') {
|
|
69
|
-
|
|
131
|
+
return decorateWithSpan(value, 'token boolean');
|
|
70
132
|
}
|
|
133
|
+
}
|
|
71
134
|
|
|
72
|
-
|
|
135
|
+
function getLineTemplate({
|
|
136
|
+
isFirstKey,
|
|
137
|
+
isLastKey,
|
|
138
|
+
nextLine,
|
|
139
|
+
context,
|
|
140
|
+
lineTemplate,
|
|
141
|
+
maxExpandLevel,
|
|
142
|
+
}: {
|
|
143
|
+
isFirstKey: boolean;
|
|
144
|
+
isLastKey: boolean;
|
|
145
|
+
nextLine: IteratorResult<string, string | undefined>;
|
|
146
|
+
maxExpandLevel: number;
|
|
147
|
+
lineTemplate: string;
|
|
148
|
+
context: 'array' | 'obj';
|
|
149
|
+
}) {
|
|
150
|
+
let lineValue = isFirstKey ? `${ellipsis}<span class="${context} collapsible">` : '';
|
|
151
|
+
// Create hoverable
|
|
152
|
+
lineValue += `<span data-line="${line++}" class="${
|
|
153
|
+
level > maxExpandLevel ? 'hoverable collapsed' : 'hoverable'
|
|
154
|
+
}">`;
|
|
155
|
+
// Add collapser button if item has nested lines
|
|
156
|
+
lineValue += (!nextLine.done && collapser(maxExpandLevel)) || '';
|
|
157
|
+
lineValue += lineTemplate;
|
|
158
|
+
lineValue += nextLine.value;
|
|
159
|
+
// Add punctuation in case we dont have more nested lines and it is not last item
|
|
160
|
+
lineValue += nextLine.done && !isLastKey ? punctuation(',') : '';
|
|
161
|
+
// Close hoverable if we dont have nested lines
|
|
162
|
+
lineValue += nextLine.done ? '</span>' : '';
|
|
163
|
+
// Close collapsible if value is single line and we are on last item
|
|
164
|
+
lineValue += nextLine.done && isLastKey ? '</span>' : '';
|
|
165
|
+
|
|
166
|
+
return lineValue;
|
|
73
167
|
}
|
|
74
168
|
|
|
75
|
-
function arrayToHTML(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
169
|
+
function* arrayToHTML(array: any[], arrayLength: number, maxExpandLevel: number): LineGenerator {
|
|
170
|
+
for (let i = 0; i < arrayLength; i++) {
|
|
171
|
+
const lines = valueToHTML(array[i], maxExpandLevel, 'array');
|
|
172
|
+
const isFirstKey = i === 0;
|
|
173
|
+
const isLastKey = i === arrayLength - 1;
|
|
174
|
+
let nextLine = lines.next();
|
|
175
|
+
|
|
176
|
+
yield getLineTemplate({
|
|
177
|
+
context: 'array',
|
|
178
|
+
isFirstKey,
|
|
179
|
+
isLastKey,
|
|
180
|
+
nextLine,
|
|
181
|
+
lineTemplate: '',
|
|
182
|
+
maxExpandLevel,
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
nextLine = lines.next();
|
|
186
|
+
|
|
187
|
+
while (!nextLine.done) {
|
|
188
|
+
yield nextLine.value;
|
|
189
|
+
|
|
190
|
+
nextLine = lines.next();
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (nextLine.value) {
|
|
194
|
+
// Close hoverable and collapsible (if last array item)
|
|
195
|
+
yield `${nextLine.value}${i < arrayLength - 1 ? punctuation(',') : '</span>'}</span>`;
|
|
88
196
|
}
|
|
89
|
-
output += '</div></li>';
|
|
90
|
-
}
|
|
91
|
-
output += `</ul>${punctuation(']')}`;
|
|
92
|
-
if (!hasContents) {
|
|
93
|
-
output = punctuation('[ ]');
|
|
94
197
|
}
|
|
95
|
-
return output;
|
|
96
198
|
}
|
|
97
199
|
|
|
98
|
-
function objectToHTML(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}"></button>${punctuation('{')}<span class="ellipsis"></span><ul class="obj collapsible">`;
|
|
105
|
-
let hasContents = false;
|
|
106
|
-
for (let i = 0; i < length; i++) {
|
|
200
|
+
function* objectToHTML(
|
|
201
|
+
object: Record<any, any>,
|
|
202
|
+
keys: any[],
|
|
203
|
+
maxExpandLevel: number,
|
|
204
|
+
): LineGenerator {
|
|
205
|
+
for (let i = 0; i < keys.length; i++) {
|
|
107
206
|
const key = keys[i];
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
207
|
+
const lines = valueToHTML(object[key], maxExpandLevel, 'object');
|
|
208
|
+
const isFirstKey = i === 0;
|
|
209
|
+
const isLastKey = i === keys.length - 1;
|
|
210
|
+
|
|
211
|
+
let nextLine = lines.next();
|
|
212
|
+
|
|
213
|
+
yield getLineTemplate({
|
|
214
|
+
context: 'obj',
|
|
215
|
+
isFirstKey,
|
|
216
|
+
isLastKey,
|
|
217
|
+
nextLine,
|
|
218
|
+
lineTemplate: `<span class="property token string">"${htmlEncode(key)}"</span>${colon}`,
|
|
219
|
+
maxExpandLevel,
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
nextLine = lines.next();
|
|
223
|
+
|
|
224
|
+
while (!nextLine.done) {
|
|
225
|
+
yield nextLine.value;
|
|
226
|
+
nextLine = lines.next();
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (nextLine.value) {
|
|
230
|
+
// Close hoverable and collapsible (if last field)
|
|
231
|
+
yield `${nextLine.value}${isLastKey ? '</span>' : punctuation(',')}</span>`;
|
|
114
232
|
}
|
|
115
|
-
output += '</div></li>';
|
|
116
|
-
}
|
|
117
|
-
output += `</ul>${punctuation('}')}`;
|
|
118
|
-
if (!hasContents) {
|
|
119
|
-
output = punctuation('{ }');
|
|
120
233
|
}
|
|
121
|
-
return output;
|
|
122
234
|
}
|
|
@@ -7,7 +7,7 @@ enum Token {
|
|
|
7
7
|
Doctype = 'doctype',
|
|
8
8
|
Cdata = 'cdata',
|
|
9
9
|
Punctuation = 'punctuation',
|
|
10
|
-
|
|
10
|
+
Property = 'property',
|
|
11
11
|
Tag = 'tag',
|
|
12
12
|
Number = 'number',
|
|
13
13
|
Constant = 'constant',
|
|
@@ -23,6 +23,8 @@ enum Token {
|
|
|
23
23
|
Url = 'url',
|
|
24
24
|
Variable = 'variable',
|
|
25
25
|
Atrule = 'atrule',
|
|
26
|
+
AttrValue = 'attr-value',
|
|
27
|
+
AttrName = 'attr-name',
|
|
26
28
|
Keyword = 'keyword',
|
|
27
29
|
Regex = 'regex',
|
|
28
30
|
Important = 'important',
|
package/ui/Burger.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MouseEventHandler } from 'react';
|
|
2
|
+
export interface BurgerProps {
|
|
3
|
+
onClick: MouseEventHandler;
|
|
4
|
+
className?: string;
|
|
5
|
+
}
|
|
6
|
+
declare function BurgerComponent({ onClick, className }: BurgerProps): JSX.Element;
|
|
7
|
+
export declare const Burger: import("styled-components").StyledComponent<typeof BurgerComponent, any, {}, never>;
|
|
8
|
+
export {};
|
package/ui/Burger.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
+
return cooked;
|
|
5
|
+
};
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.Burger = void 0;
|
|
11
|
+
var react_1 = __importDefault(require("react"));
|
|
12
|
+
var styled_components_1 = __importDefault(require("styled-components"));
|
|
13
|
+
function BurgerComponent(_a) {
|
|
14
|
+
var onClick = _a.onClick, className = _a.className;
|
|
15
|
+
return (react_1.default.createElement(Button, { onClick: onClick, className: className, "data-component-name": "ui/Burger" },
|
|
16
|
+
react_1.default.createElement(Line, null),
|
|
17
|
+
react_1.default.createElement(Line, null),
|
|
18
|
+
react_1.default.createElement(Line, null)));
|
|
19
|
+
}
|
|
20
|
+
var Button = styled_components_1.default.button(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n all: unset;\n max-width: 30px;\n width: 100%;\n min-width: 10px;\n display: block;\n cursor: pointer;\n"], ["\n all: unset;\n max-width: 30px;\n width: 100%;\n min-width: 10px;\n display: block;\n cursor: pointer;\n"])));
|
|
21
|
+
var Line = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n margin: 4px 0;\n width: 100%;\n height: 2px;\n background: #fff;\n border-radius: 1px;\n"], ["\n margin: 4px 0;\n width: 100%;\n height: 2px;\n background: #fff;\n border-radius: 1px;\n"])));
|
|
22
|
+
exports.Burger = (0, styled_components_1.default)(BurgerComponent)(templateObject_3 || (templateObject_3 = __makeTemplateObject([""], [""])));
|
|
23
|
+
var templateObject_1, templateObject_2, templateObject_3;
|
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/color.d.ts
ADDED
package/utils/color.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRandomColor = exports.getRandomNumber = void 0;
|
|
4
|
+
var getRandomNumber = function (limit) { return Math.floor(Math.random() * limit); };
|
|
5
|
+
exports.getRandomNumber = getRandomNumber;
|
|
6
|
+
function getRandomColor() {
|
|
7
|
+
var h = (0, exports.getRandomNumber)(360);
|
|
8
|
+
var s = (0, exports.getRandomNumber)(100);
|
|
9
|
+
var l = (0, exports.getRandomNumber)(100);
|
|
10
|
+
return "hsl(".concat(h, "deg, ").concat(s, "%, ").concat(l, "%)");
|
|
11
|
+
}
|
|
12
|
+
exports.getRandomColor = getRandomColor;
|
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
|
@@ -21,3 +21,5 @@ __exportStar(require("./jsonToHtml"), exports);
|
|
|
21
21
|
__exportStar(require("./media-css"), exports);
|
|
22
22
|
__exportStar(require("./theme-helpers"), exports);
|
|
23
23
|
__exportStar(require("./class-names"), exports);
|
|
24
|
+
__exportStar(require("./args-typecheck"), exports);
|
|
25
|
+
__exportStar(require("./color"), exports);
|
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 {};
|