@redocly/theme 0.1.26 → 0.1.29

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.
Files changed (135) hide show
  1. package/Button/Button.js +3 -3
  2. package/CodeBlock/CodeBlock.js +1 -1
  3. package/CopyButton/CopyButton.js +17 -1
  4. package/CopyButton/CopyButtonWrapper.js +1 -1
  5. package/Footer/Footer.js +2 -1
  6. package/Footer/FooterColumn.js +1 -1
  7. package/Footer/FooterColumns.d.ts +2 -2
  8. package/Footer/FooterColumns.js +1 -1
  9. package/JsonViewer/JsonViewer.d.ts +2 -0
  10. package/JsonViewer/JsonViewer.js +53 -22
  11. package/Markdown/Admonition.js +1 -1
  12. package/Markdown/CodeSample/CodeSample.js +17 -1
  13. package/Markdown/Heading.js +11 -2
  14. package/Markdown/MarkdownWrapper.js +2 -2
  15. package/Markdown/Mermaid.js +1 -1
  16. package/Markdown/Sup.d.ts +2 -0
  17. package/Markdown/Sup.js +19 -0
  18. package/Markdown/Tabs/Tabs.js +17 -1
  19. package/Markdown/index.d.ts +4 -3
  20. package/Markdown/index.js +4 -3
  21. package/Navbar/MobileNavbarDropdown.d.ts +8 -0
  22. package/Navbar/MobileNavbarDropdown.js +21 -0
  23. package/Navbar/MobileNavbarItem.d.ts +15 -0
  24. package/Navbar/MobileNavbarItem.js +102 -0
  25. package/Navbar/MobileNavbarMenu.d.ts +6 -0
  26. package/Navbar/MobileNavbarMenu.js +32 -0
  27. package/Navbar/MobileNavbarMenuButton.d.ts +4 -0
  28. package/Navbar/MobileNavbarMenuButton.js +19 -0
  29. package/Navbar/Navbar.js +26 -4
  30. package/Navbar/NavbarDropdown.js +1 -1
  31. package/Navbar/NavbarItem.d.ts +9 -3
  32. package/Navbar/NavbarItem.js +9 -9
  33. package/Navbar/NavbarMenu.js +3 -2
  34. package/PageNavigation/NextPageLink.js +4 -4
  35. package/PageNavigation/PreviousPageLink.js +4 -4
  36. package/Panel/PanelComponent.js +18 -2
  37. package/Profile/Profile.d.ts +8 -0
  38. package/Profile/Profile.js +60 -0
  39. package/Profile/index.d.ts +2 -0
  40. package/Profile/index.js +5 -0
  41. package/Search/Autocomplete.js +18 -2
  42. package/Search/utils.js +17 -1
  43. package/Sidebar/SidebarLayout.js +17 -1
  44. package/SourceCode/SourceCode.d.ts +10 -3
  45. package/SourceCode/SourceCode.js +10 -5
  46. package/TableOfContent/TableOfContent.js +4 -4
  47. package/Tooltip/Tooltip.d.ts +5 -4
  48. package/Tooltip/Tooltip.js +43 -21
  49. package/globalStyle.js +2 -2
  50. package/hooks/useActiveHeading.js +17 -1
  51. package/hooks/useActiveSectionId.d.ts +1 -1
  52. package/hooks/useActiveSectionId.js +17 -1
  53. package/hooks/useControl.js +17 -1
  54. package/hooks/useMobileMenu.js +17 -1
  55. package/hooks/useNavbarHeight.js +17 -1
  56. package/index.d.ts +1 -0
  57. package/index.js +1 -0
  58. package/package.json +1 -1
  59. package/src/Button/Button.tsx +5 -1
  60. package/src/CodeBlock/CodeBlock.ts +12 -0
  61. package/src/CopyButton/CopyButtonWrapper.tsx +1 -1
  62. package/src/Footer/Footer.tsx +4 -3
  63. package/src/Footer/FooterColumn.tsx +3 -1
  64. package/src/Footer/FooterColumns.tsx +3 -3
  65. package/src/JsonViewer/JsonViewer.tsx +55 -40
  66. package/src/Markdown/Admonition.tsx +1 -1
  67. package/src/Markdown/Heading.tsx +13 -2
  68. package/src/Markdown/MarkdownWrapper.tsx +58 -58
  69. package/src/Markdown/Mermaid.tsx +1 -1
  70. package/src/Markdown/Sup.tsx +8 -0
  71. package/src/Markdown/index.ts +4 -3
  72. package/src/Navbar/MobileNavbarDropdown.tsx +37 -0
  73. package/src/Navbar/MobileNavbarItem.tsx +116 -0
  74. package/src/Navbar/MobileNavbarMenu.tsx +106 -0
  75. package/src/Navbar/MobileNavbarMenuButton.tsx +13 -0
  76. package/src/Navbar/Navbar.tsx +11 -3
  77. package/src/Navbar/NavbarDropdown.tsx +1 -1
  78. package/src/Navbar/NavbarItem.tsx +9 -8
  79. package/src/Navbar/NavbarMenu.tsx +9 -4
  80. package/src/PageNavigation/NextPageLink.tsx +3 -3
  81. package/src/PageNavigation/PreviousPageLink.tsx +3 -3
  82. package/src/Profile/Profile.tsx +91 -0
  83. package/src/Profile/index.ts +2 -0
  84. package/src/SourceCode/SourceCode.tsx +32 -5
  85. package/src/TableOfContent/TableOfContent.tsx +3 -3
  86. package/src/Tooltip/Tooltip.tsx +87 -63
  87. package/src/globalStyle.ts +2 -0
  88. package/src/hooks/useActiveSectionId.ts +1 -1
  89. package/src/index.ts +1 -0
  90. package/src/types/portal/src/client/app/Sidebar/types.d.ts +2 -1
  91. package/src/types/portal/src/server/constants.d.ts +2 -0
  92. package/src/types/portal/src/server/dev-server/types.d.ts +22 -0
  93. package/src/types/portal/src/server/plugins/markdown/types.d.ts +15 -5
  94. package/src/types/portal/src/server/plugins/portal-config/get-frontmatter-keys-to-resolve.d.ts +2 -0
  95. package/src/types/portal/src/server/plugins/portal-config/types.d.ts +6 -2
  96. package/src/types/portal/src/server/plugins/reference-docs/utils.d.ts +26 -0
  97. package/src/types/portal/src/server/plugins/types.d.ts +29 -12
  98. package/src/types/portal/src/server/store.d.ts +16 -16
  99. package/src/types/portal/src/server/utils/fs.d.ts +2 -1
  100. package/src/types/portal/src/server/utils/index.d.ts +1 -0
  101. package/src/types/portal/src/server/utils/paths.d.ts +4 -0
  102. package/src/types/portal/src/server/utils/rbac.d.ts +15 -0
  103. package/src/types/portal/src/shared/constants.d.ts +7 -0
  104. package/src/types/portal/src/shared/models/config.d.ts +24 -12
  105. package/src/types/portal/src/shared/types.d.ts +17 -4
  106. package/src/types/portal/src/shared/urls.d.ts +1 -1
  107. package/src/types/portal/src/shared/utils.d.ts +2 -0
  108. package/src/ui/Burger.tsx +36 -0
  109. package/src/ui/Flex.tsx +1 -0
  110. package/src/utils/args-typecheck.ts +9 -0
  111. package/src/utils/class-names.ts +8 -0
  112. package/src/utils/color.ts +9 -0
  113. package/src/utils/highlight.ts +11 -0
  114. package/src/utils/index.ts +3 -0
  115. package/src/utils/jsonToHtml.ts +171 -59
  116. package/src/utils/theme-helpers.ts +3 -1
  117. package/ui/Burger.d.ts +8 -0
  118. package/ui/Burger.js +23 -0
  119. package/ui/Dropdown.js +17 -1
  120. package/ui/Flex.js +1 -1
  121. package/ui/UniversalLink.js +17 -1
  122. package/utils/args-typecheck.d.ts +2 -0
  123. package/utils/args-typecheck.js +13 -0
  124. package/utils/class-names.d.ts +1 -0
  125. package/utils/class-names.js +15 -0
  126. package/utils/color.d.ts +2 -0
  127. package/utils/color.js +12 -0
  128. package/utils/highlight.d.ts +1 -0
  129. package/utils/highlight.js +12 -1
  130. package/utils/index.d.ts +3 -0
  131. package/utils/index.js +3 -0
  132. package/utils/jsonToHtml.d.ts +4 -1
  133. package/utils/jsonToHtml.js +287 -83
  134. package/utils/media-css.js +40 -3
  135. package/utils/theme-helpers.js +59 -10
@@ -1,12 +1,21 @@
1
1
  // Moved from reference-docs
2
- let level = 1;
2
+ let level = 0;
3
+ let line = 1;
3
4
 
4
- export function jsonToHTML(json: JSON | Record<string, unknown>, maxExpandLevel: number): string {
5
- level = 1;
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 += valueToHTML(json, maxExpandLevel);
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 valueToHTML(value: any, maxExpandLevel: number) {
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
- let output = '';
71
+
41
72
  if (value === undefined || value === null) {
42
- output += decorateWithSpan('null', 'token keyword');
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
- output += arrayToHTML(value, maxExpandLevel);
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
- output += decorateWithSpan('"' + value.toISOString() + '"', 'token string');
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
- output += objectToHTML(value, maxExpandLevel);
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
- output += decorateWithSpan(value, 'token number');
117
+ return decorateWithSpan(value, 'token number');
55
118
  } else if (valueType === 'string') {
56
119
  if (/^(http|https):\/\/[^\s]+$/.test(value)) {
57
- output +=
120
+ return (
58
121
  decorateWithSpan('"', 'token string') +
59
- '<a href="' +
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
- output += decorateWithSpan('"' + stringifyStringLiteral(value) + '"', 'token string');
128
+ return decorateWithSpan('"' + stringifyStringLiteral(value) + '"', 'token string');
67
129
  }
68
130
  } else if (valueType === 'boolean') {
69
- output += decorateWithSpan(value, 'token boolean');
131
+ return decorateWithSpan(value, 'token boolean');
70
132
  }
133
+ }
71
134
 
72
- return output;
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(json: any, maxExpandLevel: number) {
76
- const collapsed = level > maxExpandLevel ? 'collapsed' : '';
77
- let output = `<button class="collapser" aria-label="${
78
- level > maxExpandLevel + 1 ? 'expand' : 'collapse'
79
- }"></button>${punctuation('[')}<span class="ellipsis"></span><ul class="array collapsible">`;
80
- let hasContents = false;
81
- const length = json.length;
82
- for (let i = 0; i < length; i++) {
83
- hasContents = true;
84
- output += '<li><div class="hoverable ' + collapsed + '">';
85
- output += valueToHTML(json[i], maxExpandLevel);
86
- if (i < length - 1) {
87
- output += ',';
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(json: any, maxExpandLevel: number) {
99
- const collapsed = level > maxExpandLevel ? 'collapsed' : '';
100
- const keys = Object.keys(json);
101
- const length = keys.length;
102
- let output = `<button class="collapser" aria-label="${
103
- level > maxExpandLevel + 1 ? 'expand' : 'collapse'
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
- hasContents = true;
109
- output += '<li><div class="hoverable ' + collapsed + '">';
110
- output += '<span class="property token string">"' + htmlEncode(key) + '"</span>: ';
111
- output += valueToHTML(json[key], maxExpandLevel);
112
- if (i < length - 1) {
113
- output += punctuation(',');
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
- property = 'property',
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
  }
@@ -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 = _a[0];
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,2 @@
1
+ export declare function isEmptyArray(items: any): boolean;
2
+ export declare function isPrimitive(arg: any): boolean;
@@ -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;
@@ -0,0 +1 @@
1
+ export declare function concatClassNames(...args: Array<string | undefined>): string;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.concatClassNames = void 0;
4
+ var SPACE_DELIMITER = ' ';
5
+ function concatClassNames() {
6
+ var args = [];
7
+ for (var _i = 0; _i < arguments.length; _i++) {
8
+ args[_i] = arguments[_i];
9
+ }
10
+ return args
11
+ .map(function (className) { return (className ? className.trim() : className); })
12
+ .filter(Boolean)
13
+ .join(SPACE_DELIMITER);
14
+ }
15
+ exports.concatClassNames = concatClassNames;
@@ -0,0 +1,2 @@
1
+ export declare const getRandomNumber: (limit: number) => number;
2
+ export declare function getRandomColor(): string;
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;
@@ -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;
@@ -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
@@ -4,3 +4,6 @@ export * from './highlight';
4
4
  export * from './jsonToHtml';
5
5
  export * from './media-css';
6
6
  export * from './theme-helpers';
7
+ export * from './class-names';
8
+ export * from './args-typecheck';
9
+ export * from './color';
package/utils/index.js CHANGED
@@ -20,3 +20,6 @@ __exportStar(require("./highlight"), exports);
20
20
  __exportStar(require("./jsonToHtml"), exports);
21
21
  __exportStar(require("./media-css"), exports);
22
22
  __exportStar(require("./theme-helpers"), exports);
23
+ __exportStar(require("./class-names"), exports);
24
+ __exportStar(require("./args-typecheck"), exports);
25
+ __exportStar(require("./color"), exports);
@@ -1 +1,4 @@
1
- export declare function jsonToHTML(json: JSON | Record<string, unknown>, maxExpandLevel: number): string;
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 {};