@redocly/theme 0.51.0-next.4 → 0.51.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.
@@ -10,12 +10,13 @@ const styled_components_1 = __importDefault(require("styled-components"));
10
10
  const utils_1 = require("../../core/utils");
11
11
  const hooks_1 = require("../../core/hooks");
12
12
  const H2_1 = require("../../components/Typography/H2");
13
+ const CatalogCard_1 = require("../../components/Catalog/CatalogCard");
13
14
  const FilterContent_1 = require("../../components/Filter/FilterContent");
14
15
  const FilterPopover_1 = require("../../components/Filter/FilterPopover");
15
16
  const CatalogHighlight_1 = require("../../components/Catalog/CatalogHighlight");
16
17
  const CatalogActions_1 = require("../../components/Catalog/CatalogActions");
17
18
  const Sidebar_1 = require("../../components/Sidebar/Sidebar");
18
- const CatalogVirtualizedGroups_1 = require("../../components/Catalog/CatalogVirtualizedGroups");
19
+ const CounterTag_1 = require("../../components/Tags/CounterTag");
19
20
  function Catalog(props) {
20
21
  const { catalogConfig } = props.pageProps;
21
22
  const { useTranslate, useCatalog } = (0, hooks_1.useThemeHooks)();
@@ -38,8 +39,25 @@ function Catalog(props) {
38
39
  ' ',
39
40
  translate(catalogConfig.descriptionTranslationKey, catalogConfig.description),
40
41
  ' ')) : null),
41
- react_1.default.createElement(CatalogVirtualizedGroups_1.CatalogVirtualizedGroups, { groups: groups })))));
42
+ groups.map((group) => (react_1.default.createElement(react_1.default.Fragment, { key: group.title },
43
+ react_1.default.createElement(CatalogSeparator, { "data-testid": "catalog-separator" },
44
+ react_1.default.createElement(CatalogSeparatorLabel, null, group.title),
45
+ react_1.default.createElement(CounterTag_1.CounterTag, { borderless: true }, group.items.length)),
46
+ react_1.default.createElement(CatalogCards, null, group.items.map((item) => (react_1.default.createElement(CatalogCard_1.CatalogCard, { item: item, key: item.link })))))))))));
42
47
  }
48
+ const CatalogSeparator = styled_components_1.default.div `
49
+ display: flex;
50
+ align-items: center;
51
+ color: var(--catalog-separator-color);
52
+ font-size: var(--catalog-separator-font-size);
53
+ font-weight: var(--catalog-separator-font-weight);
54
+ border-top: 1px solid var(--catalog-separator-border-color);
55
+ margin: var(--catalog-separator-margin);
56
+ padding: var(--catalog-separator-padding);
57
+ `;
58
+ const CatalogSeparatorLabel = styled_components_1.default.div `
59
+ margin: var(--catalog-separator-label-margin);
60
+ `;
43
61
  exports.CatalogPageContent = styled_components_1.default.main `
44
62
  flex: 1;
45
63
  width: 90%;
@@ -50,6 +68,12 @@ exports.CatalogPageContent = styled_components_1.default.main `
50
68
  padding: var(--catalog-page-padding);
51
69
  }
52
70
  `;
71
+ const CatalogCards = styled_components_1.default.div `
72
+ display: grid;
73
+ grid-template-columns: repeat(auto-fill, minmax(var(--api-catalog-card-min-width), 1fr));
74
+ gap: 32px;
75
+ margin: var(--catalog-cards-group-margin);
76
+ `;
53
77
  exports.CatalogTitle = (0, styled_components_1.default)(H2_1.H2) `
54
78
  color: var(--catalog-title-text-color);
55
79
  font-weight: var(--catalog-title-font-weight);
@@ -33,4 +33,3 @@ export * from '../../core/hooks/code-walkthrough/use-code-walkthrough-steps';
33
33
  export * from '../../core/hooks/code-walkthrough/use-code-walkthrough-controls';
34
34
  export * from '../../core/hooks/code-walkthrough/use-code-panel';
35
35
  export * from '../../core/hooks/code-walkthrough/use-renderable-files';
36
- export * from '../../core/hooks/use-element-size';
@@ -49,5 +49,4 @@ __exportStar(require("../../core/hooks/code-walkthrough/use-code-walkthrough-ste
49
49
  __exportStar(require("../../core/hooks/code-walkthrough/use-code-walkthrough-controls"), exports);
50
50
  __exportStar(require("../../core/hooks/code-walkthrough/use-code-panel"), exports);
51
51
  __exportStar(require("../../core/hooks/code-walkthrough/use-renderable-files"), exports);
52
- __exportStar(require("../../core/hooks/use-element-size"), exports);
53
52
  //# sourceMappingURL=index.js.map
package/lib/index.d.ts CHANGED
@@ -102,7 +102,6 @@ export * from './components/Catalog/CatalogCard';
102
102
  export * from './components/Catalog/CatalogActions';
103
103
  export * from './components/Catalog/CatalogHighlight';
104
104
  export * from './components/Catalog/CatalogInfoBlock';
105
- export * from './components/Catalog/CatalogVirtualizedGroups';
106
105
  export * from './components/Product/Product';
107
106
  export * from './components/Product/ProductPicker';
108
107
  export * from './components/StatusCode/StatusCode';
@@ -222,8 +221,6 @@ export * from './icons/DraggableIcon/DraggableIcon';
222
221
  export * from './icons/WarningAltFilledIcon/WarningAltFilledIcon';
223
222
  export * from './icons/ErrorFilledIcon/ErrorFilledIcon';
224
223
  export * from './icons/SettingsCogIcon/SettingsCogIcon';
225
- export * from './icons/CheckboxFilledIcon/CheckboxFilledIcon';
226
- export * from './icons/WarningAltFilled/WarningAltFilled';
227
224
  export * from './layouts/RootLayout';
228
225
  export * from './layouts/PageLayout';
229
226
  export * from './layouts/NotFound';
package/lib/index.js CHANGED
@@ -150,7 +150,6 @@ __exportStar(require("./components/Catalog/CatalogCard"), exports);
150
150
  __exportStar(require("./components/Catalog/CatalogActions"), exports);
151
151
  __exportStar(require("./components/Catalog/CatalogHighlight"), exports);
152
152
  __exportStar(require("./components/Catalog/CatalogInfoBlock"), exports);
153
- __exportStar(require("./components/Catalog/CatalogVirtualizedGroups"), exports);
154
153
  /* Product */
155
154
  __exportStar(require("./components/Product/Product"), exports);
156
155
  __exportStar(require("./components/Product/ProductPicker"), exports);
@@ -274,8 +273,6 @@ __exportStar(require("./icons/DraggableIcon/DraggableIcon"), exports);
274
273
  __exportStar(require("./icons/WarningAltFilledIcon/WarningAltFilledIcon"), exports);
275
274
  __exportStar(require("./icons/ErrorFilledIcon/ErrorFilledIcon"), exports);
276
275
  __exportStar(require("./icons/SettingsCogIcon/SettingsCogIcon"), exports);
277
- __exportStar(require("./icons/CheckboxFilledIcon/CheckboxFilledIcon"), exports);
278
- __exportStar(require("./icons/WarningAltFilled/WarningAltFilled"), exports);
279
276
  /* Layouts */
280
277
  __exportStar(require("./layouts/RootLayout"), exports);
281
278
  __exportStar(require("./layouts/PageLayout"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/theme",
3
- "version": "0.51.0-next.4",
3
+ "version": "0.51.0",
4
4
  "description": "Shared UI components lib",
5
5
  "keywords": [
6
6
  "theme",
@@ -87,7 +87,6 @@
87
87
  "timeago.js": "4.0.2",
88
88
  "i18next": "22.4.15",
89
89
  "nprogress": "0.2.0",
90
- "@tanstack/react-virtual": "3.13.0",
91
90
  "@redocly/config": "0.22.0"
92
91
  },
93
92
  "scripts": {
@@ -6,12 +6,13 @@ import type { CatalogConfig } from '@redocly/theme/config';
6
6
  import { breakpoints } from '@redocly/theme/core/utils';
7
7
  import { useThemeHooks, useModalScrollLock } from '@redocly/theme/core/hooks';
8
8
  import { H2 } from '@redocly/theme/components/Typography/H2';
9
+ import { CatalogCard } from '@redocly/theme/components/Catalog/CatalogCard';
9
10
  import { FilterContent } from '@redocly/theme/components/Filter/FilterContent';
10
11
  import { FilterPopover } from '@redocly/theme/components/Filter/FilterPopover';
11
12
  import { HighlightContext } from '@redocly/theme/components/Catalog/CatalogHighlight';
12
13
  import { CatalogActions } from '@redocly/theme/components/Catalog/CatalogActions';
13
14
  import { Sidebar } from '@redocly/theme/components/Sidebar/Sidebar';
14
- import { CatalogVirtualizedGroups } from '@redocly/theme/components/Catalog/CatalogVirtualizedGroups';
15
+ import { CounterTag } from '@redocly/theme/components/Tags/CounterTag';
15
16
 
16
17
  export type CatalogProps = {
17
18
  pageProps: {
@@ -72,14 +73,40 @@ export default function Catalog(props: CatalogProps): JSX.Element {
72
73
  </CatalogDescription>
73
74
  ) : null}
74
75
  </CatalogPageDescriptionWrapper>
75
-
76
- <CatalogVirtualizedGroups groups={groups} />
76
+ {groups.map((group) => (
77
+ <React.Fragment key={group.title}>
78
+ <CatalogSeparator data-testid="catalog-separator">
79
+ <CatalogSeparatorLabel>{group.title}</CatalogSeparatorLabel>
80
+ <CounterTag borderless>{group.items.length}</CounterTag>
81
+ </CatalogSeparator>
82
+ <CatalogCards>
83
+ {group.items.map((item) => (
84
+ <CatalogCard item={item} key={item.link} />
85
+ ))}
86
+ </CatalogCards>
87
+ </React.Fragment>
88
+ ))}
77
89
  </CatalogPageContent>
78
90
  </CatalogPageWrapper>
79
91
  </HighlightContext.Provider>
80
92
  );
81
93
  }
82
94
 
95
+ const CatalogSeparator = styled.div`
96
+ display: flex;
97
+ align-items: center;
98
+ color: var(--catalog-separator-color);
99
+ font-size: var(--catalog-separator-font-size);
100
+ font-weight: var(--catalog-separator-font-weight);
101
+ border-top: 1px solid var(--catalog-separator-border-color);
102
+ margin: var(--catalog-separator-margin);
103
+ padding: var(--catalog-separator-padding);
104
+ `;
105
+
106
+ const CatalogSeparatorLabel = styled.div`
107
+ margin: var(--catalog-separator-label-margin);
108
+ `;
109
+
83
110
  export const CatalogPageContent = styled.main`
84
111
  flex: 1;
85
112
  width: 90%;
@@ -91,6 +118,13 @@ export const CatalogPageContent = styled.main`
91
118
  }
92
119
  `;
93
120
 
121
+ const CatalogCards = styled.div`
122
+ display: grid;
123
+ grid-template-columns: repeat(auto-fill, minmax(var(--api-catalog-card-min-width), 1fr));
124
+ gap: 32px;
125
+ margin: var(--catalog-cards-group-margin);
126
+ `;
127
+
94
128
  export const CatalogTitle = styled(H2)`
95
129
  color: var(--catalog-title-text-color);
96
130
  font-weight: var(--catalog-title-font-weight);
@@ -33,4 +33,3 @@ export * from '@redocly/theme/core/hooks/code-walkthrough/use-code-walkthrough-s
33
33
  export * from '@redocly/theme/core/hooks/code-walkthrough/use-code-walkthrough-controls';
34
34
  export * from '@redocly/theme/core/hooks/code-walkthrough/use-code-panel';
35
35
  export * from '@redocly/theme/core/hooks/code-walkthrough/use-renderable-files';
36
- export * from '@redocly/theme/core/hooks/use-element-size';
package/src/index.ts CHANGED
@@ -122,7 +122,6 @@ export * from '@redocly/theme/components/Catalog/CatalogCard';
122
122
  export * from '@redocly/theme/components/Catalog/CatalogActions';
123
123
  export * from '@redocly/theme/components/Catalog/CatalogHighlight';
124
124
  export * from '@redocly/theme/components/Catalog/CatalogInfoBlock';
125
- export * from '@redocly/theme/components/Catalog/CatalogVirtualizedGroups';
126
125
  /* Product */
127
126
  export * from '@redocly/theme/components/Product/Product';
128
127
  export * from '@redocly/theme/components/Product/ProductPicker';
@@ -246,8 +245,6 @@ export * from '@redocly/theme/icons/DraggableIcon/DraggableIcon';
246
245
  export * from '@redocly/theme/icons/WarningAltFilledIcon/WarningAltFilledIcon';
247
246
  export * from '@redocly/theme/icons/ErrorFilledIcon/ErrorFilledIcon';
248
247
  export * from '@redocly/theme/icons/SettingsCogIcon/SettingsCogIcon';
249
- export * from '@redocly/theme/icons/CheckboxFilledIcon/CheckboxFilledIcon';
250
- export * from '@redocly/theme/icons/WarningAltFilled/WarningAltFilled';
251
248
  /* Layouts */
252
249
  export * from '@redocly/theme/layouts/RootLayout';
253
250
  export * from '@redocly/theme/layouts/PageLayout';
@@ -1,11 +0,0 @@
1
- import React from 'react';
2
- import { CatalogItem } from '../../core/types';
3
- type Group = {
4
- title: string;
5
- items: CatalogItem[];
6
- };
7
- type CatalogVirtualizedGroupsProps = {
8
- groups: Group[];
9
- };
10
- export declare function CatalogVirtualizedGroups({ groups }: CatalogVirtualizedGroupsProps): React.JSX.Element;
11
- export {};
@@ -1,125 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.CatalogVirtualizedGroups = CatalogVirtualizedGroups;
30
- const react_1 = __importStar(require("react"));
31
- const react_virtual_1 = require("@tanstack/react-virtual");
32
- const styled_components_1 = __importDefault(require("styled-components"));
33
- const use_element_size_1 = require("../../core/hooks/use-element-size");
34
- const CatalogCard_1 = require("../../components/Catalog/CatalogCard");
35
- const CounterTag_1 = require("../../components/Tags/CounterTag");
36
- const GAP_SIZE = 32;
37
- const CARD_MIN_WIDTH_VAR = '--api-catalog-card-min-width';
38
- function CatalogVirtualizedGroups({ groups }) {
39
- var _a, _b;
40
- const parentRef = (0, react_1.useRef)(null);
41
- const [isClient, setIsClient] = (0, react_1.useState)(typeof window !== 'undefined');
42
- const { width } = (0, use_element_size_1.useElementSize)(parentRef);
43
- (0, react_1.useEffect)(() => {
44
- setIsClient(true);
45
- }, []);
46
- const columnCount = (0, react_1.useMemo)(() => {
47
- if (!isClient)
48
- return 1;
49
- const cardMinWidth = parseInt(getComputedStyle(document.documentElement).getPropertyValue(CARD_MIN_WIDTH_VAR), 10);
50
- return Math.max(1, Math.floor((width + GAP_SIZE) / (cardMinWidth + GAP_SIZE)));
51
- }, [width, isClient]);
52
- const flatRows = (0, react_1.useMemo)(() => {
53
- const rows = [];
54
- groups.forEach((group) => {
55
- rows.push({
56
- type: 'header',
57
- groupTitle: group.title,
58
- groupCount: group.items.length,
59
- key: `header-${group.title}`,
60
- });
61
- const numRows = Math.ceil(group.items.length / columnCount);
62
- for (let rowIndex = 0; rowIndex < numRows; rowIndex++) {
63
- const startIndex = rowIndex * columnCount;
64
- const rowItems = group.items.slice(startIndex, startIndex + columnCount);
65
- rows.push({
66
- type: 'cardRow',
67
- groupTitle: group.title,
68
- items: rowItems,
69
- key: `${group.title}-row-${rowIndex}`,
70
- });
71
- }
72
- });
73
- return rows;
74
- }, [groups, columnCount]);
75
- const estimateSize = (0, react_1.useCallback)((index) => {
76
- const row = flatRows[index];
77
- return row.type === 'header' ? 50 : 250;
78
- }, [flatRows]);
79
- const virtualizer = (0, react_virtual_1.useWindowVirtualizer)({
80
- count: flatRows.length,
81
- estimateSize,
82
- overscan: 5,
83
- initialOffset: (_b = (_a = parentRef.current) === null || _a === void 0 ? void 0 : _a.offsetTop) !== null && _b !== void 0 ? _b : 0,
84
- });
85
- return (react_1.default.createElement("div", { ref: parentRef },
86
- react_1.default.createElement("div", { style: {
87
- position: 'relative',
88
- height: isClient ? `${virtualizer.getTotalSize()}px` : 'auto',
89
- } }, isClient &&
90
- virtualizer.getVirtualItems().map((virtualRow) => {
91
- const rowData = flatRows[virtualRow.index];
92
- if (rowData.type === 'header') {
93
- return (react_1.default.createElement(HeaderRow, { key: rowData.key, ref: virtualizer.measureElement, "data-index": virtualRow.index, style: { transform: `translateY(${virtualRow.start}px)` } },
94
- react_1.default.createElement(CatalogSeparatorLabel, null, rowData.groupTitle),
95
- react_1.default.createElement(CounterTag_1.CounterTag, { borderless: true }, rowData.groupCount)));
96
- }
97
- return (react_1.default.createElement(VirtualRow, { key: rowData.key, ref: virtualizer.measureElement, "data-index": virtualRow.index, style: { transform: `translateY(${virtualRow.start}px)` } }, rowData.items.map((item) => (react_1.default.createElement(CatalogCard_1.CatalogCard, { key: item.link, item: item })))));
98
- }))));
99
- }
100
- const VirtualRow = styled_components_1.default.div `
101
- position: absolute;
102
- left: 0;
103
- width: 100%;
104
- display: grid;
105
- grid-template-columns: repeat(auto-fill, minmax(var(${CARD_MIN_WIDTH_VAR}), 1fr));
106
- gap: ${GAP_SIZE}px;
107
- padding-bottom: 32px;
108
- `;
109
- const HeaderRow = styled_components_1.default.div `
110
- position: absolute;
111
- left: 0;
112
- width: 100%;
113
- display: flex;
114
- align-items: center;
115
- padding: var(--catalog-separator-padding);
116
- border-top: 1px solid var(--catalog-separator-border-color);
117
- padding-bottom: calc(4px * 4);
118
- color: var(--catalog-separator-color);
119
- font-size: var(--catalog-separator-font-size);
120
- font-weight: var(--catalog-separator-font-weight);
121
- `;
122
- const CatalogSeparatorLabel = styled_components_1.default.div `
123
- margin: var(--catalog-separator-label-margin);
124
- `;
125
- //# sourceMappingURL=CatalogVirtualizedGroups.js.map
@@ -1,7 +0,0 @@
1
- import { RefObject } from 'react';
2
- type Size = {
3
- width: number;
4
- height: number;
5
- };
6
- export declare const useElementSize: <T extends HTMLElement = HTMLElement>(ref?: RefObject<T>, delay?: number) => Size;
7
- export {};
@@ -1,51 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useElementSize = void 0;
4
- const react_1 = require("react");
5
- const getInitialSize = (ref) => {
6
- if (ref === null || ref === void 0 ? void 0 : ref.current) {
7
- return {
8
- width: ref.current.offsetWidth,
9
- height: ref.current.offsetHeight,
10
- };
11
- }
12
- return {
13
- width: typeof window !== 'undefined' ? window.innerWidth : 0,
14
- height: typeof window !== 'undefined' ? window.innerHeight : 0,
15
- };
16
- };
17
- const useElementSize = (ref, delay = 100) => {
18
- const [size, setSize] = (0, react_1.useState)(getInitialSize(ref));
19
- const updateSize = (0, react_1.useCallback)((newSize) => {
20
- setSize(newSize);
21
- }, []);
22
- (0, react_1.useEffect)(() => {
23
- let timeoutId = null;
24
- const triggerUpdateWithThrottling = (newSize) => {
25
- if (timeoutId !== null)
26
- return;
27
- timeoutId = window.setTimeout(() => {
28
- updateSize(newSize);
29
- timeoutId = null;
30
- }, delay);
31
- };
32
- if ((ref === null || ref === void 0 ? void 0 : ref.current) && typeof ResizeObserver !== 'undefined') {
33
- const observer = new ResizeObserver((entries) => {
34
- for (const entry of entries) {
35
- const { width, height } = entry.contentRect;
36
- triggerUpdateWithThrottling({ width, height });
37
- }
38
- });
39
- observer.observe(ref.current);
40
- return () => {
41
- observer.disconnect();
42
- if (timeoutId !== null) {
43
- clearTimeout(timeoutId);
44
- }
45
- };
46
- }
47
- }, [ref, updateSize, delay]);
48
- return size;
49
- };
50
- exports.useElementSize = useElementSize;
51
- //# sourceMappingURL=use-element-size.js.map
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
- import type { IconProps } from '../../icons/types';
3
- export declare const CheckboxFilledIcon: import("styled-components").StyledComponent<(props: IconProps) => React.JSX.Element, any, {
4
- 'data-component-name': string;
5
- } & {
6
- color?: string;
7
- size?: string;
8
- className?: string;
9
- } & React.SVGProps<SVGSVGElement>, "data-component-name">;
@@ -1,22 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.CheckboxFilledIcon = void 0;
7
- const react_1 = __importDefault(require("react"));
8
- const styled_components_1 = __importDefault(require("styled-components"));
9
- const utils_1 = require("../../core/utils");
10
- const Icon = (props) => (react_1.default.createElement("svg", Object.assign({ viewBox: "0 0 16 17", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, props),
11
- react_1.default.createElement("path", { d: "M13 2.51172H3C2.73478 2.51172 2.48043 2.61708 2.29289 2.80461C2.10536 2.99215 2 3.2465 2 3.51172V13.5117C2 13.7769 2.10536 14.0313 2.29289 14.2188C2.48043 14.4064 2.73478 14.5117 3 14.5117H13C13.2652 14.5117 13.5196 14.4064 13.7071 14.2188C13.8946 14.0313 14 13.7769 14 13.5117V3.51172C14 3.2465 13.8946 2.99215 13.7071 2.80461C13.5196 2.61708 13.2652 2.51172 13 2.51172ZM7 11.2617L4.5 8.78307L5.2954 8.01172L7 9.68452L10.7044 6.01172L11.5002 6.80032L7 11.2617Z" })));
12
- exports.CheckboxFilledIcon = (0, styled_components_1.default)(Icon).attrs(() => ({
13
- 'data-component-name': 'icons/CheckboxFilledIcon/CheckboxFilledIcon',
14
- })) `
15
- path {
16
- fill: ${({ color }) => (0, utils_1.getCssColorVariable)(color)};
17
- }
18
-
19
- height: ${({ size }) => size || '16px'};
20
- width: ${({ size }) => size || '16px'};
21
- `;
22
- //# sourceMappingURL=CheckboxFilledIcon.js.map
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
- import type { IconProps } from '../../icons/types';
3
- export declare const WarningAltFilled: import("styled-components").StyledComponent<(props: IconProps) => React.JSX.Element, any, {
4
- 'data-component-name': string;
5
- } & {
6
- color?: string;
7
- size?: string;
8
- className?: string;
9
- } & React.SVGProps<SVGSVGElement>, "data-component-name">;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.WarningAltFilled = void 0;
7
- const react_1 = __importDefault(require("react"));
8
- const styled_components_1 = __importDefault(require("styled-components"));
9
- const utils_1 = require("../../core/utils");
10
- const Icon = (props) => (react_1.default.createElement("svg", Object.assign({ viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, props),
11
- react_1.default.createElement("path", { d: "M8.001 3.08571H7.999L2.32435 13.9983L2.3253 14H13.6747L13.6757 13.9983L8.001 3.08571ZM7.4375 6.00001H8.5625V10.5H7.4375V6.00001ZM8 13C7.85167 13 7.70666 12.956 7.58333 12.8736C7.45999 12.7912 7.36386 12.6741 7.30709 12.537C7.25033 12.4 7.23548 12.2492 7.26441 12.1037C7.29335 11.9582 7.36478 11.8246 7.46967 11.7197C7.57456 11.6148 7.7082 11.5434 7.85369 11.5144C7.99917 11.4855 8.14997 11.5003 8.28702 11.5571C8.42406 11.6139 8.54119 11.71 8.62361 11.8333C8.70602 11.9567 8.75 12.1017 8.75 12.25C8.75 12.4489 8.67099 12.6397 8.53033 12.7803C8.38968 12.921 8.19892 13 8 13Z" }),
12
- react_1.default.createElement("path", { d: "M14.5 15H1.5C1.4141 15 1.32965 14.9779 1.25478 14.9357C1.17992 14.8936 1.11718 14.8329 1.0726 14.7595C1.02802 14.686 1.00311 14.6024 1.00027 14.5165C0.997436 14.4307 1.01677 14.3455 1.0564 14.2693L7.5564 1.76931C7.59862 1.68812 7.66231 1.62008 7.74053 1.5726C7.81875 1.52511 7.9085 1.5 8 1.5C8.09151 1.5 8.18126 1.52511 8.25948 1.5726C8.3377 1.62008 8.40138 1.68812 8.4436 1.76931L14.9436 14.2693C14.9832 14.3455 15.0026 14.4307 14.9997 14.5165C14.9969 14.6024 14.972 14.686 14.9274 14.7595C14.8828 14.8329 14.8201 14.8936 14.7452 14.9357C14.6704 14.9779 14.5859 15 14.5 15ZM2.3253 14H13.6747L13.6757 13.9983L8.001 3.08571H7.999L2.32435 13.9983L2.3253 14Z" })));
13
- exports.WarningAltFilled = (0, styled_components_1.default)(Icon).attrs(() => ({
14
- 'data-component-name': 'icons/WarningAltFilled/WarningAltFilled',
15
- })) `
16
- path {
17
- fill: ${({ color }) => (0, utils_1.getCssColorVariable)(color)};
18
- }
19
-
20
- height: ${({ size }) => size || '16px'};
21
- width: ${({ size }) => size || '16px'};
22
- `;
23
- //# sourceMappingURL=WarningAltFilled.js.map
@@ -1,152 +0,0 @@
1
- import React, { useEffect, useMemo, useRef, useState, useCallback } from 'react';
2
- import { useWindowVirtualizer } from '@tanstack/react-virtual';
3
- import styled from 'styled-components';
4
-
5
- import { CatalogItem } from '@redocly/theme/core/types';
6
- import { useElementSize } from '@redocly/theme/core/hooks/use-element-size';
7
- import { CatalogCard } from '@redocly/theme/components/Catalog/CatalogCard';
8
- import { CounterTag } from '@redocly/theme/components/Tags/CounterTag';
9
-
10
- const GAP_SIZE = 32;
11
- const CARD_MIN_WIDTH_VAR = '--api-catalog-card-min-width';
12
-
13
- type Group = {
14
- title: string;
15
- items: CatalogItem[];
16
- };
17
-
18
- type VirtualRowData =
19
- | { type: 'header'; groupTitle: string; groupCount: number; key: string }
20
- | { type: 'cardRow'; groupTitle: string; items: CatalogItem[]; key: string };
21
-
22
- type CatalogVirtualizedGroupsProps = {
23
- groups: Group[];
24
- };
25
-
26
- export function CatalogVirtualizedGroups({ groups }: CatalogVirtualizedGroupsProps) {
27
- const parentRef = useRef<HTMLDivElement>(null);
28
- const [isClient, setIsClient] = useState(typeof window !== 'undefined');
29
- const { width } = useElementSize(parentRef);
30
-
31
- useEffect(() => {
32
- setIsClient(true);
33
- }, []);
34
-
35
- const columnCount = useMemo(() => {
36
- if (!isClient) return 1;
37
- const cardMinWidth = parseInt(
38
- getComputedStyle(document.documentElement).getPropertyValue(CARD_MIN_WIDTH_VAR),
39
- 10,
40
- );
41
- return Math.max(1, Math.floor((width + GAP_SIZE) / (cardMinWidth + GAP_SIZE)));
42
- }, [width, isClient]);
43
-
44
- const flatRows: VirtualRowData[] = useMemo(() => {
45
- const rows: VirtualRowData[] = [];
46
- groups.forEach((group) => {
47
- rows.push({
48
- type: 'header',
49
- groupTitle: group.title,
50
- groupCount: group.items.length,
51
- key: `header-${group.title}`,
52
- });
53
- const numRows = Math.ceil(group.items.length / columnCount);
54
- for (let rowIndex = 0; rowIndex < numRows; rowIndex++) {
55
- const startIndex = rowIndex * columnCount;
56
- const rowItems = group.items.slice(startIndex, startIndex + columnCount);
57
- rows.push({
58
- type: 'cardRow',
59
- groupTitle: group.title,
60
- items: rowItems,
61
- key: `${group.title}-row-${rowIndex}`,
62
- });
63
- }
64
- });
65
- return rows;
66
- }, [groups, columnCount]);
67
-
68
- const estimateSize = useCallback(
69
- (index: number) => {
70
- const row = flatRows[index];
71
- return row.type === 'header' ? 50 : 250;
72
- },
73
- [flatRows],
74
- );
75
-
76
- const virtualizer = useWindowVirtualizer({
77
- count: flatRows.length,
78
- estimateSize,
79
- overscan: 5,
80
- initialOffset: parentRef.current?.offsetTop ?? 0,
81
- });
82
-
83
- return (
84
- <div ref={parentRef}>
85
- <div
86
- style={{
87
- position: 'relative',
88
- height: isClient ? `${virtualizer.getTotalSize()}px` : 'auto',
89
- }}
90
- >
91
- {isClient &&
92
- virtualizer.getVirtualItems().map((virtualRow) => {
93
- const rowData = flatRows[virtualRow.index];
94
- if (rowData.type === 'header') {
95
- return (
96
- <HeaderRow
97
- key={rowData.key}
98
- ref={virtualizer.measureElement}
99
- data-index={virtualRow.index}
100
- style={{ transform: `translateY(${virtualRow.start}px)` }}
101
- >
102
- <CatalogSeparatorLabel>{rowData.groupTitle}</CatalogSeparatorLabel>
103
- <CounterTag borderless>{rowData.groupCount}</CounterTag>
104
- </HeaderRow>
105
- );
106
- }
107
-
108
- return (
109
- <VirtualRow
110
- key={rowData.key}
111
- ref={virtualizer.measureElement}
112
- data-index={virtualRow.index}
113
- style={{ transform: `translateY(${virtualRow.start}px)` }}
114
- >
115
- {rowData.items.map((item) => (
116
- <CatalogCard key={item.link} item={item} />
117
- ))}
118
- </VirtualRow>
119
- );
120
- })}
121
- </div>
122
- </div>
123
- );
124
- }
125
-
126
- const VirtualRow = styled.div`
127
- position: absolute;
128
- left: 0;
129
- width: 100%;
130
- display: grid;
131
- grid-template-columns: repeat(auto-fill, minmax(var(${CARD_MIN_WIDTH_VAR}), 1fr));
132
- gap: ${GAP_SIZE}px;
133
- padding-bottom: 32px;
134
- `;
135
-
136
- const HeaderRow = styled.div`
137
- position: absolute;
138
- left: 0;
139
- width: 100%;
140
- display: flex;
141
- align-items: center;
142
- padding: var(--catalog-separator-padding);
143
- border-top: 1px solid var(--catalog-separator-border-color);
144
- padding-bottom: calc(4px * 4);
145
- color: var(--catalog-separator-color);
146
- font-size: var(--catalog-separator-font-size);
147
- font-weight: var(--catalog-separator-font-weight);
148
- `;
149
-
150
- const CatalogSeparatorLabel = styled.div`
151
- margin: var(--catalog-separator-label-margin);
152
- `;
@@ -1,61 +0,0 @@
1
- import { useState, useEffect, useCallback, RefObject } from 'react';
2
-
3
- type Size = {
4
- width: number;
5
- height: number;
6
- };
7
-
8
- const getInitialSize = (ref?: RefObject<HTMLElement>): Size => {
9
- if (ref?.current) {
10
- return {
11
- width: ref.current.offsetWidth,
12
- height: ref.current.offsetHeight,
13
- };
14
- }
15
- return {
16
- width: typeof window !== 'undefined' ? window.innerWidth : 0,
17
- height: typeof window !== 'undefined' ? window.innerHeight : 0,
18
- };
19
- };
20
-
21
- export const useElementSize = <T extends HTMLElement = HTMLElement>(
22
- ref?: RefObject<T>,
23
- delay: number = 100,
24
- ): Size => {
25
- const [size, setSize] = useState<Size>(getInitialSize(ref));
26
-
27
- const updateSize = useCallback((newSize: Size) => {
28
- setSize(newSize);
29
- }, []);
30
-
31
- useEffect(() => {
32
- let timeoutId: number | null = null;
33
-
34
- const triggerUpdateWithThrottling = (newSize: Size) => {
35
- if (timeoutId !== null) return;
36
- timeoutId = window.setTimeout(() => {
37
- updateSize(newSize);
38
- timeoutId = null;
39
- }, delay);
40
- };
41
-
42
- if (ref?.current && typeof ResizeObserver !== 'undefined') {
43
- const observer = new ResizeObserver((entries) => {
44
- for (const entry of entries) {
45
- const { width, height } = entry.contentRect;
46
- triggerUpdateWithThrottling({ width, height });
47
- }
48
- });
49
- observer.observe(ref.current);
50
-
51
- return () => {
52
- observer.disconnect();
53
- if (timeoutId !== null) {
54
- clearTimeout(timeoutId);
55
- }
56
- };
57
- }
58
- }, [ref, updateSize, delay]);
59
-
60
- return size;
61
- };
@@ -1,23 +0,0 @@
1
- import React from 'react';
2
- import styled from 'styled-components';
3
-
4
- import type { IconProps } from '@redocly/theme/icons/types';
5
-
6
- import { getCssColorVariable } from '@redocly/theme/core/utils';
7
-
8
- const Icon = (props: IconProps) => (
9
- <svg viewBox="0 0 16 17" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
10
- <path d="M13 2.51172H3C2.73478 2.51172 2.48043 2.61708 2.29289 2.80461C2.10536 2.99215 2 3.2465 2 3.51172V13.5117C2 13.7769 2.10536 14.0313 2.29289 14.2188C2.48043 14.4064 2.73478 14.5117 3 14.5117H13C13.2652 14.5117 13.5196 14.4064 13.7071 14.2188C13.8946 14.0313 14 13.7769 14 13.5117V3.51172C14 3.2465 13.8946 2.99215 13.7071 2.80461C13.5196 2.61708 13.2652 2.51172 13 2.51172ZM7 11.2617L4.5 8.78307L5.2954 8.01172L7 9.68452L10.7044 6.01172L11.5002 6.80032L7 11.2617Z" />
11
- </svg>
12
- );
13
-
14
- export const CheckboxFilledIcon = styled(Icon).attrs(() => ({
15
- 'data-component-name': 'icons/CheckboxFilledIcon/CheckboxFilledIcon',
16
- }))<IconProps>`
17
- path {
18
- fill: ${({ color }) => getCssColorVariable(color)};
19
- }
20
-
21
- height: ${({ size }) => size || '16px'};
22
- width: ${({ size }) => size || '16px'};
23
- `;
@@ -1,24 +0,0 @@
1
- import React from 'react';
2
- import styled from 'styled-components';
3
-
4
- import type { IconProps } from '@redocly/theme/icons/types';
5
-
6
- import { getCssColorVariable } from '@redocly/theme/core/utils';
7
-
8
- const Icon = (props: IconProps) => (
9
- <svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
10
- <path d="M8.001 3.08571H7.999L2.32435 13.9983L2.3253 14H13.6747L13.6757 13.9983L8.001 3.08571ZM7.4375 6.00001H8.5625V10.5H7.4375V6.00001ZM8 13C7.85167 13 7.70666 12.956 7.58333 12.8736C7.45999 12.7912 7.36386 12.6741 7.30709 12.537C7.25033 12.4 7.23548 12.2492 7.26441 12.1037C7.29335 11.9582 7.36478 11.8246 7.46967 11.7197C7.57456 11.6148 7.7082 11.5434 7.85369 11.5144C7.99917 11.4855 8.14997 11.5003 8.28702 11.5571C8.42406 11.6139 8.54119 11.71 8.62361 11.8333C8.70602 11.9567 8.75 12.1017 8.75 12.25C8.75 12.4489 8.67099 12.6397 8.53033 12.7803C8.38968 12.921 8.19892 13 8 13Z" />
11
- <path d="M14.5 15H1.5C1.4141 15 1.32965 14.9779 1.25478 14.9357C1.17992 14.8936 1.11718 14.8329 1.0726 14.7595C1.02802 14.686 1.00311 14.6024 1.00027 14.5165C0.997436 14.4307 1.01677 14.3455 1.0564 14.2693L7.5564 1.76931C7.59862 1.68812 7.66231 1.62008 7.74053 1.5726C7.81875 1.52511 7.9085 1.5 8 1.5C8.09151 1.5 8.18126 1.52511 8.25948 1.5726C8.3377 1.62008 8.40138 1.68812 8.4436 1.76931L14.9436 14.2693C14.9832 14.3455 15.0026 14.4307 14.9997 14.5165C14.9969 14.6024 14.972 14.686 14.9274 14.7595C14.8828 14.8329 14.8201 14.8936 14.7452 14.9357C14.6704 14.9779 14.5859 15 14.5 15ZM2.3253 14H13.6747L13.6757 13.9983L8.001 3.08571H7.999L2.32435 13.9983L2.3253 14Z" />
12
- </svg>
13
- );
14
-
15
- export const WarningAltFilled = styled(Icon).attrs(() => ({
16
- 'data-component-name': 'icons/WarningAltFilled/WarningAltFilled',
17
- }))<IconProps>`
18
- path {
19
- fill: ${({ color }) => getCssColorVariable(color)};
20
- }
21
-
22
- height: ${({ size }) => size || '16px'};
23
- width: ${({ size }) => size || '16px'};
24
- `;