@redocly/theme 0.61.0 → 0.62.0-custom.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/Admonition/Admonition.js +14 -18
- package/lib/components/Admonition/variables.dark.d.ts +1 -0
- package/lib/components/Admonition/variables.dark.js +18 -0
- package/lib/components/Admonition/variables.js +24 -28
- package/lib/components/AsyncApiDocs/hooks/AfterAsyncApiChannelDescription.d.ts +1 -0
- package/lib/components/AsyncApiDocs/hooks/AfterAsyncApiChannelDescription.js +12 -0
- package/lib/components/Badge/Badge.d.ts +2 -1
- package/lib/components/Badge/Badge.js +24 -2
- package/lib/components/Banner/Banner.js +19 -1
- package/lib/components/Banner/variables.js +1 -0
- package/lib/components/Breadcrumbs/Breadcrumb.js +1 -1
- package/lib/components/Breadcrumbs/BreadcrumbDropdown.js +9 -6
- package/lib/components/Breadcrumbs/Breadcrumbs.js +24 -15
- package/lib/components/Buttons/AIAssistantButton.js +7 -4
- package/lib/components/Catalog/CatalogEntities.js +10 -8
- package/lib/components/Catalog/CatalogEntity/CatalogEntity.js +2 -2
- package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityHistorySidebar.js +5 -3
- package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/TagsProperty.js +2 -2
- package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable.js +13 -11
- package/lib/components/Catalog/CatalogEntity/CatalogEntitySchema.js +7 -5
- package/lib/components/Catalog/CatalogFilter/CatalogFilterCheckboxes.js +9 -7
- package/lib/components/Catalog/CatalogTableView/CatalogTableViewRow.js +1 -1
- package/lib/components/Catalog/CatalogTagsWithTooltip.js +2 -2
- package/lib/components/CatalogClassic/CatalogClassicInfoBlock.js +1 -1
- package/lib/components/CodeBlock/CodeBlockControls.js +8 -6
- package/lib/components/Filter/FilterCheckboxes.js +1 -1
- package/lib/components/JsonViewer/JsonViewer.js +2 -2
- package/lib/components/JsonViewer/{Helpers.js → helpers.js} +2 -1
- package/lib/components/LanguagePicker/LanguagePicker.js +1 -1
- package/lib/components/Markdown/Markdown.js +2 -2
- package/lib/components/Menu/MenuItem.js +41 -15
- package/lib/components/Navbar/NavbarItem.js +1 -1
- package/lib/components/OpenApiDocs/hooks/AdditionalOverviewInfo.d.ts +1 -0
- package/lib/components/OpenApiDocs/hooks/AdditionalOverviewInfo.js +12 -0
- package/lib/components/OpenApiDocs/hooks/AfterOpenApiDescription.d.ts +1 -0
- package/lib/components/OpenApiDocs/hooks/AfterOpenApiDescription.js +6 -0
- package/lib/components/PageActions/PageActions.js +25 -8
- package/lib/components/Search/SearchAiDialog.d.ts +4 -2
- package/lib/components/Search/SearchAiDialog.js +23 -4
- package/lib/components/Search/SearchAiMessage.d.ts +4 -2
- package/lib/components/Search/SearchAiMessage.js +82 -23
- package/lib/components/Search/SearchDialog.js +50 -25
- package/lib/components/Select/variables.js +2 -2
- package/lib/components/SvgViewer/SvgViewer.d.ts +15 -0
- package/lib/components/SvgViewer/SvgViewer.js +312 -0
- package/lib/components/SvgViewer/variables.d.ts +1 -0
- package/lib/components/SvgViewer/variables.dark.d.ts +1 -0
- package/lib/components/SvgViewer/variables.dark.js +8 -0
- package/lib/components/SvgViewer/variables.js +17 -0
- package/lib/components/Tag/Tag.js +1 -1
- package/lib/components/Tag/variables.dark.js +6 -0
- package/lib/components/Tag/variables.js +6 -0
- package/lib/components/Tooltip/Tooltip.d.ts +2 -3
- package/lib/components/Tooltip/Tooltip.js +66 -113
- package/lib/components/Tooltip/variables.dark.js +4 -0
- package/lib/components/Tooltip/variables.js +3 -3
- package/lib/components/UserMenu/LoginButton.d.ts +8 -2
- package/lib/components/UserMenu/LoginButton.js +4 -3
- package/lib/core/constants/search.d.ts +5 -1
- package/lib/core/constants/search.js +24 -1
- package/lib/core/hooks/search/use-search-dialog.js +2 -2
- package/lib/core/hooks/use-color-switcher.d.ts +1 -0
- package/lib/core/hooks/use-color-switcher.js +8 -1
- package/lib/core/hooks/use-mcp-config.js +2 -1
- package/lib/core/hooks/use-modal-scroll-lock.js +24 -10
- package/lib/core/hooks/use-outside-click.d.ts +3 -1
- package/lib/core/hooks/use-outside-click.js +8 -4
- package/lib/core/hooks/use-page-actions.d.ts +1 -1
- package/lib/core/hooks/use-page-actions.js +44 -11
- package/lib/core/hooks/use-product-picker.js +1 -1
- package/lib/core/hooks/use-unique-svg-ids.d.ts +6 -0
- package/lib/core/hooks/use-unique-svg-ids.js +15 -0
- package/lib/core/openapi/index.d.ts +1 -0
- package/lib/core/openapi/index.js +3 -1
- package/lib/core/styles/dark.js +4 -0
- package/lib/core/styles/global.js +31 -15
- package/lib/core/types/catalog.d.ts +1 -1
- package/lib/core/types/hooks.d.ts +23 -2
- package/lib/core/types/l10n.d.ts +1 -1
- package/lib/core/types/search.d.ts +24 -0
- package/lib/core/types/search.js +9 -1
- package/lib/core/utils/content-segments.d.ts +2 -0
- package/lib/core/utils/content-segments.js +22 -0
- package/lib/core/utils/index.d.ts +1 -0
- package/lib/core/utils/index.js +1 -0
- package/lib/core/utils/transform-revisions-to-version-history.js +8 -51
- package/lib/ext/process-scorecard.d.ts +5 -0
- package/lib/ext/process-scorecard.js +11 -0
- package/lib/icons/FitToViewIcon/FitToViewIcon.d.ts +9 -0
- package/lib/icons/FitToViewIcon/FitToViewIcon.js +25 -0
- package/lib/icons/WarningCycleIcon/WarningCycleIcon.d.ts +9 -0
- package/lib/icons/WarningCycleIcon/WarningCycleIcon.js +24 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.js +9 -0
- package/lib/layouts/DocumentationLayout.js +4 -25
- package/lib/layouts/DocumentationLayoutBottom.d.ts +11 -0
- package/lib/layouts/DocumentationLayoutBottom.js +28 -0
- package/lib/layouts/DocumentationLayoutTop.d.ts +13 -0
- package/lib/layouts/DocumentationLayoutTop.js +33 -0
- package/lib/layouts/Forbidden.js +22 -18
- package/lib/markdoc/components/Cards/Card.js +1 -0
- package/lib/markdoc/components/CodeWalkthrough/CodeFilters.js +1 -1
- package/lib/markdoc/components/Heading/Heading.js +40 -2
- package/lib/markdoc/components/LoginButton/LoginButton.d.ts +9 -0
- package/lib/markdoc/components/LoginButton/LoginButton.js +48 -0
- package/lib/markdoc/components/Mermaid/Mermaid.js +70 -2
- package/lib/markdoc/components/default.d.ts +1 -0
- package/lib/markdoc/components/default.js +1 -0
- package/lib/markdoc/default.d.ts +6 -0
- package/lib/markdoc/default.js +2 -0
- package/lib/markdoc/tags/login-button.d.ts +2 -0
- package/lib/markdoc/tags/login-button.js +32 -0
- package/package.json +9 -9
- package/src/components/Admonition/Admonition.tsx +14 -18
- package/src/components/Admonition/variables.dark.ts +15 -0
- package/src/components/Admonition/variables.ts +24 -28
- package/src/components/AsyncApiDocs/hooks/AfterAsyncApiChannelDescription.tsx +10 -0
- package/src/components/Badge/Badge.tsx +18 -2
- package/src/components/Banner/Banner.tsx +23 -1
- package/src/components/Banner/variables.ts +1 -0
- package/src/components/Breadcrumbs/Breadcrumb.tsx +3 -3
- package/src/components/Breadcrumbs/BreadcrumbDropdown.tsx +11 -8
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +24 -15
- package/src/components/Buttons/AIAssistantButton.tsx +7 -4
- package/src/components/Catalog/CatalogEntities.tsx +10 -8
- package/src/components/Catalog/CatalogEntity/CatalogEntity.tsx +1 -1
- package/src/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityHistorySidebar.tsx +7 -4
- package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/TagsProperty.tsx +1 -1
- package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable.tsx +13 -11
- package/src/components/Catalog/CatalogEntity/CatalogEntitySchema.tsx +7 -5
- package/src/components/Catalog/CatalogFilter/CatalogFilterCheckboxes.tsx +9 -7
- package/src/components/Catalog/CatalogTableView/CatalogTableViewRow.tsx +1 -2
- package/src/components/Catalog/CatalogTagsWithTooltip.tsx +9 -5
- package/src/components/CatalogClassic/CatalogClassicInfoBlock.tsx +3 -1
- package/src/components/CodeBlock/CodeBlockControls.tsx +16 -10
- package/src/components/Filter/FilterCheckboxes.tsx +1 -1
- package/src/components/JsonViewer/JsonViewer.tsx +1 -2
- package/src/components/JsonViewer/{Helpers.tsx → helpers.tsx} +1 -0
- package/src/components/LanguagePicker/LanguagePicker.tsx +1 -1
- package/src/components/Markdown/Markdown.tsx +2 -2
- package/src/components/Menu/MenuItem.tsx +61 -16
- package/src/components/Navbar/NavbarItem.tsx +3 -1
- package/src/components/OpenApiDocs/hooks/AdditionalOverviewInfo.tsx +10 -0
- package/src/components/OpenApiDocs/hooks/AfterOpenApiDescription.tsx +2 -0
- package/src/components/PageActions/PageActions.tsx +38 -15
- package/src/components/Search/SearchAiDialog.tsx +31 -2
- package/src/components/Search/SearchAiMessage.tsx +103 -17
- package/src/components/Search/SearchDialog.tsx +70 -37
- package/src/components/Select/variables.ts +2 -2
- package/src/components/SvgViewer/SvgViewer.tsx +405 -0
- package/src/components/SvgViewer/variables.dark.ts +5 -0
- package/src/components/SvgViewer/variables.ts +14 -0
- package/src/components/Tag/Tag.tsx +2 -1
- package/src/components/Tag/variables.dark.ts +6 -0
- package/src/components/Tag/variables.ts +6 -0
- package/src/components/Tooltip/Tooltip.tsx +77 -120
- package/src/components/Tooltip/variables.dark.ts +4 -0
- package/src/components/Tooltip/variables.ts +3 -3
- package/src/components/UserMenu/LoginButton.tsx +23 -8
- package/src/core/constants/search.ts +27 -1
- package/src/core/hooks/__mocks__/use-theme-hooks.ts +10 -1
- package/src/core/hooks/search/use-search-dialog.ts +2 -2
- package/src/core/hooks/use-color-switcher.ts +10 -2
- package/src/core/hooks/use-mcp-config.ts +2 -1
- package/src/core/hooks/use-modal-scroll-lock.ts +29 -10
- package/src/core/hooks/use-outside-click.ts +16 -5
- package/src/core/hooks/use-page-actions.ts +66 -25
- package/src/core/hooks/use-product-picker.ts +1 -1
- package/src/core/hooks/use-unique-svg-ids.ts +12 -0
- package/src/core/openapi/index.ts +1 -0
- package/src/core/styles/dark.ts +4 -0
- package/src/core/styles/global.ts +31 -15
- package/src/core/types/catalog.ts +1 -1
- package/src/core/types/hooks.ts +29 -1
- package/src/core/types/l10n.ts +12 -1
- package/src/core/types/search.ts +19 -0
- package/src/core/utils/content-segments.ts +27 -0
- package/src/core/utils/index.ts +1 -0
- package/src/core/utils/transform-revisions-to-version-history.ts +8 -80
- package/src/ext/process-scorecard.ts +14 -0
- package/src/icons/FitToViewIcon/FitToViewIcon.tsx +26 -0
- package/src/icons/WarningCycleIcon/WarningCycleIcon.tsx +32 -0
- package/src/index.ts +9 -0
- package/src/layouts/DocumentationLayout.tsx +4 -30
- package/src/layouts/DocumentationLayoutBottom.tsx +42 -0
- package/src/layouts/DocumentationLayoutTop.tsx +52 -0
- package/src/layouts/Forbidden.tsx +36 -21
- package/src/markdoc/components/Cards/Card.tsx +1 -0
- package/src/markdoc/components/CodeWalkthrough/CodeFilters.tsx +1 -1
- package/src/markdoc/components/Heading/Heading.tsx +52 -4
- package/src/markdoc/components/LoginButton/LoginButton.tsx +38 -0
- package/src/markdoc/components/Mermaid/Mermaid.tsx +57 -8
- package/src/markdoc/components/default.ts +1 -0
- package/src/markdoc/default.ts +2 -0
- package/src/markdoc/tags/login-button.ts +30 -0
- package/lib/components/Tooltip/TooltipWrapper.d.ts +0 -12
- package/lib/components/Tooltip/TooltipWrapper.js +0 -34
- package/src/components/Tooltip/TooltipWrapper.tsx +0 -70
- /package/lib/components/JsonViewer/{Helpers.d.ts → helpers.d.ts} +0 -0
|
@@ -0,0 +1,312 @@
|
|
|
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 () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.SvgViewer = SvgViewer;
|
|
37
|
+
const react_1 = __importStar(require("react"));
|
|
38
|
+
const styled_components_1 = __importStar(require("styled-components"));
|
|
39
|
+
const hooks_1 = require("../../core/hooks");
|
|
40
|
+
const Button_1 = require("../../components/Button/Button");
|
|
41
|
+
const Tooltip_1 = require("../../components/Tooltip/Tooltip");
|
|
42
|
+
const AddIcon_1 = require("../../icons/AddIcon/AddIcon");
|
|
43
|
+
const SubtractIcon_1 = require("../../icons/SubtractIcon/SubtractIcon");
|
|
44
|
+
const CloseIcon_1 = require("../../icons/CloseIcon/CloseIcon");
|
|
45
|
+
const FitToViewIcon_1 = require("../../icons/FitToViewIcon/FitToViewIcon");
|
|
46
|
+
const MIN_SCALE_FACTOR = 0.1;
|
|
47
|
+
const MAX_SCALE_FACTOR = 5;
|
|
48
|
+
const ZOOM_STEP = 0.1;
|
|
49
|
+
const WHEEL_SENSITIVITY = 0.002;
|
|
50
|
+
const VIEWPORT_PADDING = 60;
|
|
51
|
+
const FIT_SCALE_FACTOR = 0.9;
|
|
52
|
+
function SvgViewer({ isOpen, onClose, children, labels = {}, }) {
|
|
53
|
+
const [scale, setScale] = (0, react_1.useState)(1);
|
|
54
|
+
const [baseScale, setBaseScale] = (0, react_1.useState)(1);
|
|
55
|
+
const [position, setPosition] = (0, react_1.useState)({ x: 0, y: 0 });
|
|
56
|
+
const [isDragging, setIsDragging] = (0, react_1.useState)(false);
|
|
57
|
+
const [dragStart, setDragStart] = (0, react_1.useState)({ x: 0, y: 0 });
|
|
58
|
+
const [pinchState, setPinchState] = (0, react_1.useState)(null);
|
|
59
|
+
const [isWheelZooming, setIsWheelZooming] = (0, react_1.useState)(false);
|
|
60
|
+
const wheelTimeoutRef = (0, react_1.useRef)(null);
|
|
61
|
+
const overlayRef = (0, react_1.useRef)(null);
|
|
62
|
+
const viewportRef = (0, react_1.useRef)(null);
|
|
63
|
+
const contentRef = (0, react_1.useRef)(null);
|
|
64
|
+
const renderedScaleRef = (0, react_1.useRef)(scale);
|
|
65
|
+
(0, hooks_1.useModalScrollLock)(isOpen);
|
|
66
|
+
// Keep track of the actually rendered scale for accurate measurements
|
|
67
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
68
|
+
renderedScaleRef.current = scale;
|
|
69
|
+
}, [scale]);
|
|
70
|
+
const minScale = baseScale * MIN_SCALE_FACTOR;
|
|
71
|
+
const maxScale = baseScale * MAX_SCALE_FACTOR;
|
|
72
|
+
const clampScale = (0, react_1.useCallback)((value) => Math.min(maxScale, Math.max(minScale, value)), [minScale, maxScale]);
|
|
73
|
+
const calculateFitScale = (0, react_1.useCallback)(() => {
|
|
74
|
+
if (!viewportRef.current || !contentRef.current)
|
|
75
|
+
return 1;
|
|
76
|
+
const viewport = viewportRef.current.getBoundingClientRect();
|
|
77
|
+
const svg = contentRef.current.querySelector('svg');
|
|
78
|
+
if (!svg)
|
|
79
|
+
return 1;
|
|
80
|
+
const svgRect = svg.getBoundingClientRect();
|
|
81
|
+
if (!svgRect.width || !svgRect.height)
|
|
82
|
+
return 1;
|
|
83
|
+
// getBoundingClientRect returns transformed size, so compensate for current scale
|
|
84
|
+
const currentScale = renderedScaleRef.current || 1;
|
|
85
|
+
const naturalWidth = svgRect.width / currentScale;
|
|
86
|
+
const naturalHeight = svgRect.height / currentScale;
|
|
87
|
+
const availableWidth = viewport.width - VIEWPORT_PADDING * 2;
|
|
88
|
+
const availableHeight = viewport.height - VIEWPORT_PADDING * 2;
|
|
89
|
+
return (Math.min(availableWidth / naturalWidth, availableHeight / naturalHeight) * FIT_SCALE_FACTOR);
|
|
90
|
+
}, []);
|
|
91
|
+
const resetView = (0, react_1.useCallback)(() => {
|
|
92
|
+
setScale(baseScale);
|
|
93
|
+
setPosition({ x: 0, y: 0 });
|
|
94
|
+
}, [baseScale]);
|
|
95
|
+
const zoomIn = (0, react_1.useCallback)(() => {
|
|
96
|
+
setScale((s) => clampScale(s + baseScale * ZOOM_STEP));
|
|
97
|
+
}, [baseScale, clampScale]);
|
|
98
|
+
const zoomOut = (0, react_1.useCallback)(() => {
|
|
99
|
+
setScale((s) => clampScale(s - baseScale * ZOOM_STEP));
|
|
100
|
+
}, [baseScale, clampScale]);
|
|
101
|
+
const handleKeyDown = (0, react_1.useCallback)((e) => {
|
|
102
|
+
switch (e.key) {
|
|
103
|
+
case 'Escape':
|
|
104
|
+
onClose();
|
|
105
|
+
break;
|
|
106
|
+
case '+':
|
|
107
|
+
case '=':
|
|
108
|
+
zoomIn();
|
|
109
|
+
break;
|
|
110
|
+
case '-':
|
|
111
|
+
zoomOut();
|
|
112
|
+
break;
|
|
113
|
+
case '0':
|
|
114
|
+
resetView();
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
}, [onClose, zoomIn, zoomOut, resetView]);
|
|
118
|
+
const handleWheel = (0, react_1.useCallback)((e) => {
|
|
119
|
+
e.preventDefault();
|
|
120
|
+
e.stopPropagation();
|
|
121
|
+
setIsWheelZooming(true);
|
|
122
|
+
if (wheelTimeoutRef.current)
|
|
123
|
+
clearTimeout(wheelTimeoutRef.current);
|
|
124
|
+
wheelTimeoutRef.current = setTimeout(() => setIsWheelZooming(false), 150);
|
|
125
|
+
const delta = -e.deltaY * WHEEL_SENSITIVITY;
|
|
126
|
+
setScale((s) => clampScale(s + s * delta));
|
|
127
|
+
}, [clampScale]);
|
|
128
|
+
const handleMouseDown = (0, react_1.useCallback)((e) => {
|
|
129
|
+
if (e.button !== 0)
|
|
130
|
+
return;
|
|
131
|
+
e.preventDefault();
|
|
132
|
+
setIsDragging(true);
|
|
133
|
+
setDragStart({ x: e.clientX - position.x, y: e.clientY - position.y });
|
|
134
|
+
}, [position]);
|
|
135
|
+
const handleMouseMove = (0, react_1.useCallback)((e) => {
|
|
136
|
+
if (!isDragging)
|
|
137
|
+
return;
|
|
138
|
+
setPosition({ x: e.clientX - dragStart.x, y: e.clientY - dragStart.y });
|
|
139
|
+
}, [isDragging, dragStart]);
|
|
140
|
+
const handleMouseUp = (0, react_1.useCallback)(() => setIsDragging(false), []);
|
|
141
|
+
const getTouchDistance = (touches) => {
|
|
142
|
+
if (touches.length !== 2)
|
|
143
|
+
return 0;
|
|
144
|
+
const dx = touches[0].clientX - touches[1].clientX;
|
|
145
|
+
const dy = touches[0].clientY - touches[1].clientY;
|
|
146
|
+
return Math.hypot(dx, dy);
|
|
147
|
+
};
|
|
148
|
+
const handleTouchStart = (0, react_1.useCallback)((e) => {
|
|
149
|
+
if (e.touches.length === 2) {
|
|
150
|
+
setPinchState({ distance: getTouchDistance(e.touches), scale });
|
|
151
|
+
}
|
|
152
|
+
else if (e.touches.length === 1) {
|
|
153
|
+
setIsDragging(true);
|
|
154
|
+
setDragStart({
|
|
155
|
+
x: e.touches[0].clientX - position.x,
|
|
156
|
+
y: e.touches[0].clientY - position.y,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}, [position, scale]);
|
|
160
|
+
const handleTouchMove = (0, react_1.useCallback)((e) => {
|
|
161
|
+
e.preventDefault();
|
|
162
|
+
if (e.touches.length === 2 && pinchState) {
|
|
163
|
+
const distance = getTouchDistance(e.touches);
|
|
164
|
+
setScale(clampScale(pinchState.scale * (distance / pinchState.distance)));
|
|
165
|
+
}
|
|
166
|
+
else if (e.touches.length === 1 && isDragging) {
|
|
167
|
+
setPosition({
|
|
168
|
+
x: e.touches[0].clientX - dragStart.x,
|
|
169
|
+
y: e.touches[0].clientY - dragStart.y,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}, [pinchState, isDragging, dragStart, clampScale]);
|
|
173
|
+
const handleTouchEnd = (0, react_1.useCallback)(() => {
|
|
174
|
+
setIsDragging(false);
|
|
175
|
+
setPinchState(null);
|
|
176
|
+
}, []);
|
|
177
|
+
(0, react_1.useEffect)(() => {
|
|
178
|
+
var _a;
|
|
179
|
+
if (!isOpen)
|
|
180
|
+
return;
|
|
181
|
+
setPosition({ x: 0, y: 0 });
|
|
182
|
+
(_a = overlayRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
183
|
+
// Wait for DOM to be ready before measuring
|
|
184
|
+
requestAnimationFrame(() => {
|
|
185
|
+
const fitScale = calculateFitScale();
|
|
186
|
+
setBaseScale(fitScale);
|
|
187
|
+
setScale(fitScale);
|
|
188
|
+
});
|
|
189
|
+
}, [isOpen, calculateFitScale]);
|
|
190
|
+
if (!isOpen)
|
|
191
|
+
return null;
|
|
192
|
+
const zoomPercentage = baseScale > 0 ? Math.round((scale / baseScale) * 100) : 100;
|
|
193
|
+
const isAnimating = !isDragging && !isWheelZooming && !pinchState;
|
|
194
|
+
return (react_1.default.createElement(Overlay, { ref: overlayRef, onClick: onClose, onKeyDown: handleKeyDown, tabIndex: 0, "aria-modal": "true", role: "dialog", "aria-label": labels.dialogLabel || 'SVG viewer' },
|
|
195
|
+
react_1.default.createElement(Viewport, { ref: viewportRef, onClick: (e) => e.stopPropagation(), onWheel: handleWheel, onMouseDown: handleMouseDown, onMouseMove: handleMouseMove, onMouseUp: handleMouseUp, onMouseLeave: handleMouseUp, onTouchStart: handleTouchStart, onTouchMove: handleTouchMove, onTouchEnd: handleTouchEnd, "$isDragging": isDragging },
|
|
196
|
+
react_1.default.createElement(Content, { ref: contentRef, "$isAnimating": isAnimating, style: {
|
|
197
|
+
transform: `translate(calc(-50% + ${position.x}px), calc(-50% + ${position.y}px)) scale(${scale})`,
|
|
198
|
+
} }, children),
|
|
199
|
+
react_1.default.createElement(Controls, null,
|
|
200
|
+
react_1.default.createElement(ControlGroup, null,
|
|
201
|
+
react_1.default.createElement(Tooltip_1.Tooltip, { tip: labels.zoomOut || 'Zoom out', placement: "top" },
|
|
202
|
+
react_1.default.createElement(ControlButton, { variant: "text", size: "small", icon: react_1.default.createElement(SubtractIcon_1.SubtractIcon, null), onClick: zoomOut, disabled: scale <= minScale })),
|
|
203
|
+
react_1.default.createElement(ZoomLabel, null,
|
|
204
|
+
zoomPercentage,
|
|
205
|
+
"%"),
|
|
206
|
+
react_1.default.createElement(Tooltip_1.Tooltip, { tip: labels.zoomIn || 'Zoom in', placement: "top" },
|
|
207
|
+
react_1.default.createElement(ControlButton, { variant: "text", size: "small", icon: react_1.default.createElement(AddIcon_1.AddIcon, null), onClick: zoomIn, disabled: scale >= maxScale })),
|
|
208
|
+
react_1.default.createElement(Divider, null),
|
|
209
|
+
react_1.default.createElement(Tooltip_1.Tooltip, { tip: labels.fitToView || 'Fit to view', placement: "top" },
|
|
210
|
+
react_1.default.createElement(ControlButton, { variant: "text", size: "small", icon: react_1.default.createElement(FitToViewIcon_1.FitToViewIcon, null), onClick: resetView })),
|
|
211
|
+
react_1.default.createElement(Tooltip_1.Tooltip, { tip: labels.close || 'Close', placement: "top" },
|
|
212
|
+
react_1.default.createElement(ControlButton, { variant: "text", size: "small", icon: react_1.default.createElement(CloseIcon_1.CloseIcon, null), onClick: onClose })))))));
|
|
213
|
+
}
|
|
214
|
+
const scaleIn = (0, styled_components_1.keyframes) `
|
|
215
|
+
from {
|
|
216
|
+
transform: scale(0.9);
|
|
217
|
+
}
|
|
218
|
+
to {
|
|
219
|
+
transform: scale(1);
|
|
220
|
+
}
|
|
221
|
+
`;
|
|
222
|
+
const slideUp = (0, styled_components_1.keyframes) `
|
|
223
|
+
from {
|
|
224
|
+
opacity: 0;
|
|
225
|
+
transform: translateX(-50%) translateY(10px);
|
|
226
|
+
}
|
|
227
|
+
to {
|
|
228
|
+
opacity: 1;
|
|
229
|
+
transform: translateX(-50%) translateY(0);
|
|
230
|
+
}
|
|
231
|
+
`;
|
|
232
|
+
const Overlay = styled_components_1.default.div `
|
|
233
|
+
position: fixed;
|
|
234
|
+
inset: 0;
|
|
235
|
+
background-color: var(--svg-viewer-overlay-bg-color);
|
|
236
|
+
backdrop-filter: blur(var(--spacing-unit));
|
|
237
|
+
z-index: var(--z-index-overlay, 1000);
|
|
238
|
+
display: flex;
|
|
239
|
+
align-items: center;
|
|
240
|
+
justify-content: center;
|
|
241
|
+
padding: var(--spacing-xxl);
|
|
242
|
+
|
|
243
|
+
&:focus {
|
|
244
|
+
outline: none;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
@media (max-width: 768px) {
|
|
248
|
+
padding: var(--spacing-md);
|
|
249
|
+
}
|
|
250
|
+
`;
|
|
251
|
+
const Viewport = styled_components_1.default.div `
|
|
252
|
+
position: relative;
|
|
253
|
+
width: 100%;
|
|
254
|
+
height: 100%;
|
|
255
|
+
background-color: var(--svg-viewer-bg-color);
|
|
256
|
+
border-radius: var(--svg-viewer-border-radius);
|
|
257
|
+
overflow: hidden;
|
|
258
|
+
cursor: ${({ $isDragging }) => ($isDragging ? 'grabbing' : 'grab')};
|
|
259
|
+
touch-action: none;
|
|
260
|
+
box-shadow: var(--svg-viewer-box-shadow);
|
|
261
|
+
animation: ${scaleIn} 0.25s ease-in-out forwards;
|
|
262
|
+
`;
|
|
263
|
+
const Content = styled_components_1.default.div `
|
|
264
|
+
position: absolute;
|
|
265
|
+
top: 50%;
|
|
266
|
+
left: 50%;
|
|
267
|
+
transform-origin: center center;
|
|
268
|
+
user-select: none;
|
|
269
|
+
pointer-events: none;
|
|
270
|
+
transition: ${({ $isAnimating }) => ($isAnimating ? 'transform 0.25s ease-in-out' : 'none')};
|
|
271
|
+
|
|
272
|
+
svg {
|
|
273
|
+
display: block;
|
|
274
|
+
max-width: none !important;
|
|
275
|
+
}
|
|
276
|
+
`;
|
|
277
|
+
const Controls = styled_components_1.default.div `
|
|
278
|
+
position: absolute;
|
|
279
|
+
bottom: var(--spacing-sm);
|
|
280
|
+
left: 50%;
|
|
281
|
+
transform: translateX(-50%);
|
|
282
|
+
z-index: 10;
|
|
283
|
+
animation: ${slideUp} 0.3s ease-out 0.1s backwards;
|
|
284
|
+
`;
|
|
285
|
+
const ControlGroup = styled_components_1.default.div `
|
|
286
|
+
display: flex;
|
|
287
|
+
align-items: center;
|
|
288
|
+
gap: 2px;
|
|
289
|
+
padding: var(--spacing-xxs);
|
|
290
|
+
background: var(--bg-color-raised);
|
|
291
|
+
border: 1px solid var(--border-color-primary);
|
|
292
|
+
border-radius: var(--border-radius-lg);
|
|
293
|
+
box-shadow: var(--bg-raised-shadow);
|
|
294
|
+
`;
|
|
295
|
+
const ControlButton = (0, styled_components_1.default)(Button_1.Button) `
|
|
296
|
+
--button-icon-size: 16px;
|
|
297
|
+
`;
|
|
298
|
+
const ZoomLabel = styled_components_1.default.span `
|
|
299
|
+
min-width: 40px;
|
|
300
|
+
font-size: var(--font-size-sm);
|
|
301
|
+
font-weight: var(--font-weight-semibold);
|
|
302
|
+
color: var(--text-color-secondary);
|
|
303
|
+
text-align: center;
|
|
304
|
+
font-variant-numeric: tabular-nums;
|
|
305
|
+
`;
|
|
306
|
+
const Divider = styled_components_1.default.div `
|
|
307
|
+
width: 1px;
|
|
308
|
+
height: var(--spacing-base);
|
|
309
|
+
background: var(--border-color-primary);
|
|
310
|
+
margin: 0 var(--spacing-xxs);
|
|
311
|
+
`;
|
|
312
|
+
//# sourceMappingURL=SvgViewer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const svgViewer: import("styled-components").FlattenSimpleInterpolation;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const svgViewerDarkMode: import("styled-components").FlattenSimpleInterpolation;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.svgViewerDarkMode = void 0;
|
|
4
|
+
const styled_components_1 = require("styled-components");
|
|
5
|
+
exports.svgViewerDarkMode = (0, styled_components_1.css) `
|
|
6
|
+
--svg-viewer-bg-color: var(--color-warm-grey-9);
|
|
7
|
+
`;
|
|
8
|
+
//# sourceMappingURL=variables.dark.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.svgViewer = void 0;
|
|
4
|
+
const styled_components_1 = require("styled-components");
|
|
5
|
+
exports.svgViewer = (0, styled_components_1.css) `
|
|
6
|
+
/**
|
|
7
|
+
* @tokens SVG Viewer
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
--svg-viewer-overlay-bg-color: var(--bg-color-modal-overlay); // @presenter Color
|
|
11
|
+
--svg-viewer-bg-color: var(--bg-color); // @presenter Color
|
|
12
|
+
--svg-viewer-border-radius: var(--border-radius-xl); // @presenter BorderRadius
|
|
13
|
+
--svg-viewer-box-shadow: var(--bg-raised-shadow); // @presenter BoxShadow
|
|
14
|
+
|
|
15
|
+
// @tokens End
|
|
16
|
+
`;
|
|
17
|
+
//# sourceMappingURL=variables.js.map
|
|
@@ -177,7 +177,7 @@ const TagWrapper = styled_components_1.default.div.attrs(({ className, color, si
|
|
|
177
177
|
${({ textTransform }) => `text-transform: ${textTransform ? `${textTransform}` : 'var(--tag-text-transform)'};`}
|
|
178
178
|
|
|
179
179
|
color: var(--tag-color);
|
|
180
|
-
background-color: var(--tag-bg-color);
|
|
180
|
+
background-color: ${({ variant }) => variant === 'filled' ? 'var(--tag-bg-color)' : 'transparent'};
|
|
181
181
|
${({ borderless }) => borderless
|
|
182
182
|
? ''
|
|
183
183
|
: `border: var(--tag-border-width) var(--tag-border-style) var(--tag-border-color);`}
|
|
@@ -184,6 +184,12 @@ exports.tagDarkMode = (0, styled_components_1.css) `
|
|
|
184
184
|
--tag-bg-color-hover: #3A465F; // @presenter Color
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
+
.tag-query {
|
|
188
|
+
--tag-color: #68cc97; // @presenter Color
|
|
189
|
+
--tag-bg-color: #1F3D2D; // @presenter Color
|
|
190
|
+
--tag-bg-color-hover: #34654B; // @presenter Color
|
|
191
|
+
}
|
|
192
|
+
|
|
187
193
|
.tag-put {
|
|
188
194
|
--tag-color: #e0a663; // @presenter Color
|
|
189
195
|
--tag-bg-color: #3D2D1B; // @presenter Color
|
|
@@ -297,6 +297,12 @@ exports.tag = (0, styled_components_1.css) `
|
|
|
297
297
|
--tag-bg-color-hover: #CEDDFD; // @presenter Color
|
|
298
298
|
}
|
|
299
299
|
|
|
300
|
+
.tag-query {
|
|
301
|
+
--tag-color: #25b869; // @presenter Color
|
|
302
|
+
--tag-bg-color: #e5faef; // @presenter Color
|
|
303
|
+
--tag-bg-color-hover: #D4F7E5; // @presenter Color
|
|
304
|
+
}
|
|
305
|
+
|
|
300
306
|
.tag-put {
|
|
301
307
|
--tag-color: #f5901d; // @presenter Color
|
|
302
308
|
--tag-bg-color: #fef1e2; // @presenter Color
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
3
|
export type TooltipProps = {
|
|
4
4
|
tip: string | ReactNode;
|
|
5
5
|
isOpen?: boolean;
|
|
@@ -9,7 +9,6 @@ export type TooltipProps = {
|
|
|
9
9
|
width?: string;
|
|
10
10
|
dataTestId?: string;
|
|
11
11
|
disabled?: boolean;
|
|
12
|
-
arrowPosition?: '
|
|
12
|
+
arrowPosition?: 'left' | 'right' | 'center';
|
|
13
13
|
};
|
|
14
|
-
export declare function TooltipComponent({ children, isOpen, tip, withArrow, placement, className, width, dataTestId, disabled, arrowPosition, }: PropsWithChildren<TooltipProps>): JSX.Element;
|
|
15
14
|
export declare const Tooltip: React.NamedExoticComponent<React.PropsWithChildren<TooltipProps>>;
|