@redocly/theme 0.64.0-next.2 → 0.64.0-next.4
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.d.ts +1 -1
- package/lib/components/Admonition/Admonition.js +2 -0
- package/lib/components/Admonition/variables.dark.js +3 -0
- package/lib/components/Admonition/variables.js +13 -0
- package/lib/components/Button/variables.dark.js +2 -2
- package/lib/components/Button/variables.js +3 -3
- package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityVersionItem.js +3 -1
- package/lib/components/Catalog/CatalogTags.js +5 -2
- package/lib/components/Filter/variables.js +1 -1
- package/lib/components/LanguagePicker/LanguagePicker.js +5 -6
- package/lib/components/Link/Link.js +2 -2
- package/lib/components/Menu/MenuItem.js +1 -0
- package/lib/components/Menu/variables.dark.js +2 -0
- package/lib/components/Menu/variables.js +4 -3
- package/lib/components/Search/SearchAiMessage.js +9 -6
- package/lib/components/SvgViewer/SvgViewer.js +0 -3
- package/lib/components/SvgViewer/variables.js +1 -1
- package/lib/components/Switch/variables.dark.js +2 -2
- package/lib/components/Switch/variables.js +1 -1
- package/lib/components/TableOfContent/TableOfContent.js +1 -0
- package/lib/components/TableOfContent/variables.js +3 -2
- package/lib/components/Toast/Toast.d.ts +14 -0
- package/lib/components/Toast/Toast.js +239 -0
- package/lib/components/Toast/variables.d.ts +1 -0
- package/lib/components/Toast/variables.js +64 -0
- package/lib/components/Tooltip/JsTooltip.js +1 -1
- package/lib/core/constants/search.d.ts +3 -3
- package/lib/core/constants/toast.d.ts +1 -0
- package/lib/core/constants/toast.js +5 -0
- package/lib/core/contexts/MarkdownLinkContext.d.ts +5 -0
- package/lib/core/contexts/MarkdownLinkContext.js +6 -0
- package/lib/core/contexts/Toast/ToastContext.d.ts +2 -0
- package/lib/core/contexts/Toast/ToastContext.js +6 -0
- package/lib/core/contexts/Toast/ToastProvider.d.ts +3 -0
- package/lib/core/contexts/Toast/ToastProvider.js +156 -0
- package/lib/core/contexts/index.d.ts +3 -0
- package/lib/core/contexts/index.js +3 -0
- package/lib/core/hooks/index.d.ts +2 -0
- package/lib/core/hooks/index.js +2 -0
- package/lib/core/hooks/use-toast-logic.d.ts +18 -0
- package/lib/core/hooks/use-toast-logic.js +141 -0
- package/lib/core/hooks/use-toast.d.ts +11 -0
- package/lib/core/hooks/use-toast.js +17 -0
- package/lib/core/styles/dark.js +33 -40
- package/lib/core/styles/global.js +56 -54
- package/lib/core/styles/palette.dark.js +15 -30
- package/lib/core/styles/palette.js +130 -134
- package/lib/core/types/hooks.d.ts +2 -9
- package/lib/core/types/index.d.ts +1 -0
- package/lib/core/types/l10n.d.ts +1 -1
- package/lib/core/types/search.d.ts +2 -1
- package/lib/core/types/toast.d.ts +23 -0
- package/lib/core/types/toast.js +3 -0
- package/lib/core/utils/get-auto-dismiss-duration.d.ts +2 -0
- package/lib/core/utils/get-auto-dismiss-duration.js +15 -0
- package/lib/core/utils/index.d.ts +1 -0
- package/lib/core/utils/index.js +1 -0
- package/lib/icons/CheckboxIcon/CheckboxIcon.js +6 -4
- package/lib/icons/CheckboxIcon/variables.dark.js +2 -1
- package/lib/icons/CheckboxIcon/variables.js +3 -3
- package/lib/icons/IdeaIcon/IdeaIcon.d.ts +9 -0
- package/lib/icons/IdeaIcon/IdeaIcon.js +24 -0
- package/lib/icons/NewChatIcon/NewChatIcon.d.ts +11 -0
- package/lib/icons/NewChatIcon/NewChatIcon.js +25 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +4 -0
- package/lib/markdoc/attributes/diagram-file.d.ts +5 -0
- package/lib/markdoc/attributes/diagram-file.js +16 -0
- package/lib/markdoc/components/Diagram/Diagram.d.ts +15 -0
- package/lib/markdoc/components/Diagram/Diagram.js +135 -0
- package/lib/markdoc/components/Diagram/variables.d.ts +1 -0
- package/lib/markdoc/components/Diagram/variables.js +15 -0
- package/lib/markdoc/components/MarkdownLink/MarkdownLink.d.ts +7 -0
- package/lib/markdoc/components/MarkdownLink/MarkdownLink.js +61 -0
- package/lib/markdoc/components/Tabs/variables.js +3 -3
- package/lib/markdoc/components/default.d.ts +2 -2
- package/lib/markdoc/components/default.js +2 -2
- package/lib/markdoc/default.d.ts +7 -0
- package/lib/markdoc/default.js +3 -0
- package/lib/markdoc/tags/admonition.js +1 -1
- package/lib/markdoc/tags/diagram.d.ts +2 -0
- package/lib/markdoc/tags/diagram.js +63 -0
- package/package.json +3 -3
- package/src/components/Admonition/Admonition.tsx +3 -1
- package/src/components/Admonition/variables.dark.ts +3 -0
- package/src/components/Admonition/variables.ts +13 -0
- package/src/components/Button/variables.dark.ts +2 -2
- package/src/components/Button/variables.ts +3 -3
- package/src/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityVersionItem.tsx +3 -1
- package/src/components/Catalog/CatalogTags.tsx +6 -1
- package/src/components/Filter/variables.ts +1 -1
- package/src/components/LanguagePicker/LanguagePicker.tsx +5 -5
- package/src/components/Link/Link.tsx +1 -1
- package/src/components/Menu/MenuItem.tsx +5 -1
- package/src/components/Menu/variables.dark.ts +2 -0
- package/src/components/Menu/variables.ts +4 -3
- package/src/components/Search/SearchAiMessage.tsx +15 -10
- package/src/components/SvgViewer/SvgViewer.tsx +0 -4
- package/src/components/SvgViewer/variables.ts +1 -1
- package/src/components/Switch/variables.dark.ts +2 -2
- package/src/components/Switch/variables.ts +1 -1
- package/src/components/TableOfContent/TableOfContent.tsx +1 -0
- package/src/components/TableOfContent/variables.ts +3 -2
- package/src/components/Toast/Toast.tsx +289 -0
- package/src/components/Toast/variables.ts +61 -0
- package/src/components/Tooltip/JsTooltip.tsx +1 -1
- package/src/core/constants/search.ts +2 -3
- package/src/core/constants/toast.ts +1 -0
- package/src/core/contexts/MarkdownLinkContext.tsx +9 -0
- package/src/core/contexts/Toast/ToastContext.tsx +5 -0
- package/src/core/contexts/Toast/ToastProvider.tsx +206 -0
- package/src/core/contexts/index.ts +3 -0
- package/src/core/hooks/index.ts +2 -0
- package/src/core/hooks/use-toast-logic.ts +203 -0
- package/src/core/hooks/use-toast.ts +47 -0
- package/src/core/styles/dark.ts +5 -12
- package/src/core/styles/global.ts +28 -26
- package/src/core/styles/palette.dark.ts +15 -30
- package/src/core/styles/palette.ts +130 -134
- package/src/core/types/hooks.ts +2 -7
- package/src/core/types/index.ts +1 -0
- package/src/core/types/l10n.ts +9 -9
- package/src/core/types/search.ts +2 -1
- package/src/core/types/toast.ts +28 -0
- package/src/core/utils/get-auto-dismiss-duration.ts +20 -0
- package/src/core/utils/index.ts +1 -0
- package/src/icons/CheckboxIcon/CheckboxIcon.tsx +26 -17
- package/src/icons/CheckboxIcon/variables.dark.ts +2 -1
- package/src/icons/CheckboxIcon/variables.ts +3 -3
- package/src/icons/IdeaIcon/IdeaIcon.tsx +32 -0
- package/src/icons/NewChatIcon/NewChatIcon.tsx +39 -0
- package/src/index.ts +4 -0
- package/src/markdoc/attributes/diagram-file.ts +9 -0
- package/src/markdoc/components/Diagram/Diagram.tsx +173 -0
- package/src/markdoc/components/Diagram/variables.ts +12 -0
- package/src/markdoc/components/MarkdownLink/MarkdownLink.tsx +21 -0
- package/src/markdoc/components/Tabs/variables.ts +3 -3
- package/src/markdoc/components/default.ts +2 -2
- package/src/markdoc/default.ts +3 -0
- package/src/markdoc/tags/admonition.ts +1 -1
- package/src/markdoc/tags/diagram.ts +73 -0
- package/lib/components/SvgViewer/variables.dark.d.ts +0 -1
- package/lib/components/SvgViewer/variables.dark.js +0 -8
- package/lib/markdoc/components/ExcalidrawDiagram/ExcalidrawDiagram.d.ts +0 -7
- package/lib/markdoc/components/ExcalidrawDiagram/ExcalidrawDiagram.js +0 -95
- package/lib/markdoc/components/ExcalidrawDiagram/variables.d.ts +0 -1
- package/lib/markdoc/components/ExcalidrawDiagram/variables.dark.d.ts +0 -1
- package/lib/markdoc/components/ExcalidrawDiagram/variables.dark.js +0 -8
- package/lib/markdoc/components/ExcalidrawDiagram/variables.js +0 -15
- package/lib/markdoc/components/Mermaid/Mermaid.d.ts +0 -9
- package/lib/markdoc/components/Mermaid/Mermaid.js +0 -96
- package/lib/markdoc/components/Mermaid/variables.d.ts +0 -1
- package/lib/markdoc/components/Mermaid/variables.dark.d.ts +0 -1
- package/lib/markdoc/components/Mermaid/variables.dark.js +0 -8
- package/lib/markdoc/components/Mermaid/variables.js +0 -16
- package/src/components/SvgViewer/variables.dark.ts +0 -5
- package/src/markdoc/components/ExcalidrawDiagram/ExcalidrawDiagram.tsx +0 -85
- package/src/markdoc/components/ExcalidrawDiagram/variables.dark.ts +0 -5
- package/src/markdoc/components/ExcalidrawDiagram/variables.ts +0 -12
- package/src/markdoc/components/Mermaid/Mermaid.tsx +0 -95
- package/src/markdoc/components/Mermaid/variables.dark.ts +0 -5
- package/src/markdoc/components/Mermaid/variables.ts +0 -13
|
@@ -269,7 +269,7 @@ const TooltipBody = styled_components_1.default.span `
|
|
|
269
269
|
var(--tooltip-border-color, transparent);
|
|
270
270
|
box-shadow: var(--bg-raised-shadow);
|
|
271
271
|
|
|
272
|
-
width: ${({ width }) => width || '
|
|
272
|
+
width: ${({ width }) => width || 'max-content'};
|
|
273
273
|
${({ placement }) => (0, styled_components_1.css) `
|
|
274
274
|
${PLACEMENTS[placement]};
|
|
275
275
|
`}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AiSearchErrorConfig
|
|
1
|
+
import { type AiSearchErrorConfig } from '../types/search';
|
|
2
2
|
export declare enum AiSearchError {
|
|
3
3
|
Unauthorized = "ai_search_unauthorized",
|
|
4
4
|
Forbidden = "ai_search_forbidden",
|
|
@@ -14,7 +14,7 @@ export type AiSearchConversationRole = (typeof AiSearchConversationRole)[keyof t
|
|
|
14
14
|
export declare const AI_SEARCH_ERROR_CONFIG: Record<AiSearchError, AiSearchErrorConfig>;
|
|
15
15
|
export declare const AI_SEARCH_MAX_MESSAGE_LENGTH = 45000;
|
|
16
16
|
export declare const SEARCH_DEBOUNCE_TIME_MS = 300;
|
|
17
|
-
export declare const TOOL_CALL_DISPLAY_TEXT: Record<
|
|
17
|
+
export declare const TOOL_CALL_DISPLAY_TEXT: Partial<Record<string, {
|
|
18
18
|
inProgressText: string;
|
|
19
19
|
completedText: string;
|
|
20
|
-
}
|
|
20
|
+
}>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const TOAST_SLIDE_DURATION_MS = 300;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MarkdownLinkContext = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
exports.MarkdownLinkContext = (0, react_1.createContext)(null);
|
|
6
|
+
//# sourceMappingURL=MarkdownLinkContext.js.map
|
|
@@ -0,0 +1,156 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.ToastProvider = ToastProvider;
|
|
40
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
41
|
+
const react_1 = __importStar(require("react"));
|
|
42
|
+
const Portal_1 = require("../../../components/Portal/Portal");
|
|
43
|
+
const Toast_1 = require("../../../components/Toast/Toast");
|
|
44
|
+
const ToastContext_1 = require("../../../core/contexts/Toast/ToastContext");
|
|
45
|
+
const toast_1 = require("../../../core/constants/toast");
|
|
46
|
+
function toastReducer(state, action) {
|
|
47
|
+
switch (action.type) {
|
|
48
|
+
case 'add':
|
|
49
|
+
return [action.payload, ...state];
|
|
50
|
+
case 'startExit':
|
|
51
|
+
return state.map((toast) => toast.id === action.payload.id ? Object.assign(Object.assign({}, toast), { isExiting: true }) : toast);
|
|
52
|
+
case 'remove':
|
|
53
|
+
return state.filter((toast) => toast.id !== action.payload.id);
|
|
54
|
+
case 'update':
|
|
55
|
+
return state.map((toast) => {
|
|
56
|
+
var _a;
|
|
57
|
+
return toast.id === action.payload.id
|
|
58
|
+
? Object.assign(Object.assign(Object.assign({}, toast), action.payload.updates), { type: (_a = action.payload.updates.type) !== null && _a !== void 0 ? _a : toast.type }) : toast;
|
|
59
|
+
});
|
|
60
|
+
default:
|
|
61
|
+
return state;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function getToastType(type) {
|
|
65
|
+
return type !== null && type !== void 0 ? type : 'info';
|
|
66
|
+
}
|
|
67
|
+
function createToastId() {
|
|
68
|
+
if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {
|
|
69
|
+
return crypto.randomUUID();
|
|
70
|
+
}
|
|
71
|
+
return `toast-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;
|
|
72
|
+
}
|
|
73
|
+
function ToastProvider({ children, mountId }) {
|
|
74
|
+
const [toasts, dispatch] = (0, react_1.useReducer)(toastReducer, []);
|
|
75
|
+
const toastsRef = (0, react_1.useRef)([]);
|
|
76
|
+
const removeTimeoutsRef = (0, react_1.useRef)(new Map());
|
|
77
|
+
(0, react_1.useEffect)(() => {
|
|
78
|
+
toastsRef.current = toasts;
|
|
79
|
+
}, [toasts]);
|
|
80
|
+
(0, react_1.useEffect)(() => {
|
|
81
|
+
const timeoutsMap = removeTimeoutsRef.current;
|
|
82
|
+
return () => {
|
|
83
|
+
timeoutsMap.forEach((timeoutId) => {
|
|
84
|
+
clearTimeout(timeoutId);
|
|
85
|
+
});
|
|
86
|
+
timeoutsMap.clear();
|
|
87
|
+
};
|
|
88
|
+
}, []);
|
|
89
|
+
const dismissToast = (0, react_1.useCallback)((id) => {
|
|
90
|
+
var _a;
|
|
91
|
+
const currentToast = toastsRef.current.find((toast) => toast.id === id);
|
|
92
|
+
if (!currentToast || currentToast.isExiting) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
(_a = currentToast.onClose) === null || _a === void 0 ? void 0 : _a.call(currentToast);
|
|
96
|
+
dispatch({ type: 'startExit', payload: { id } });
|
|
97
|
+
const existingTimeout = removeTimeoutsRef.current.get(id);
|
|
98
|
+
if (existingTimeout) {
|
|
99
|
+
clearTimeout(existingTimeout);
|
|
100
|
+
}
|
|
101
|
+
const timeoutId = setTimeout(() => {
|
|
102
|
+
dispatch({ type: 'remove', payload: { id } });
|
|
103
|
+
removeTimeoutsRef.current.delete(id);
|
|
104
|
+
}, toast_1.TOAST_SLIDE_DURATION_MS);
|
|
105
|
+
removeTimeoutsRef.current.set(id, timeoutId);
|
|
106
|
+
}, []);
|
|
107
|
+
const showToast = (0, react_1.useCallback)((options) => {
|
|
108
|
+
const id = createToastId();
|
|
109
|
+
dispatch({
|
|
110
|
+
type: 'add',
|
|
111
|
+
payload: Object.assign(Object.assign({}, options), { id, type: getToastType(options.type), isExiting: false }),
|
|
112
|
+
});
|
|
113
|
+
return id;
|
|
114
|
+
}, []);
|
|
115
|
+
const updateToast = (0, react_1.useCallback)((id, updates) => {
|
|
116
|
+
dispatch({
|
|
117
|
+
type: 'update',
|
|
118
|
+
payload: {
|
|
119
|
+
id,
|
|
120
|
+
updates,
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
}, []);
|
|
124
|
+
const contextValue = (0, react_1.useMemo)(() => ({
|
|
125
|
+
showToast,
|
|
126
|
+
dismissToast,
|
|
127
|
+
updateToast,
|
|
128
|
+
}), [dismissToast, showToast, updateToast]);
|
|
129
|
+
return (react_1.default.createElement(ToastContext_1.ToastContext.Provider, { value: contextValue },
|
|
130
|
+
children,
|
|
131
|
+
toasts.length > 0 ? (react_1.default.createElement(Portal_1.Portal, { mountId: mountId },
|
|
132
|
+
react_1.default.createElement(ToastViewport, { "aria-label": "Notifications" }, toasts.map((toast, index) => (react_1.default.createElement(Toast_1.Toast, { key: toast.id, stackIndex: index, stackZIndex: toasts.length - index, toast: toast, onDismiss: dismissToast })))))) : null));
|
|
133
|
+
}
|
|
134
|
+
const ToastViewport = styled_components_1.default.div `
|
|
135
|
+
position: fixed;
|
|
136
|
+
right: var(--spacing-md);
|
|
137
|
+
bottom: var(--spacing-md);
|
|
138
|
+
z-index: 1100;
|
|
139
|
+
display: flex;
|
|
140
|
+
flex-direction: column-reverse;
|
|
141
|
+
gap: var(--spacing-sm);
|
|
142
|
+
width: 320px;
|
|
143
|
+
min-width: 240px;
|
|
144
|
+
max-width: 360px;
|
|
145
|
+
pointer-events: none;
|
|
146
|
+
|
|
147
|
+
@media (max-width: 480px) {
|
|
148
|
+
left: 50%;
|
|
149
|
+
right: auto;
|
|
150
|
+
transform: translateX(-50%);
|
|
151
|
+
width: calc(100vw - var(--spacing-md) * 2);
|
|
152
|
+
min-width: 0;
|
|
153
|
+
max-width: none;
|
|
154
|
+
}
|
|
155
|
+
`;
|
|
156
|
+
//# sourceMappingURL=ToastProvider.js.map
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export * from './ThemeDataContext';
|
|
2
|
+
export * from './MarkdownLinkContext';
|
|
2
3
|
export * from './CodeWalkthrough/CodeWalkthroughControlsContext';
|
|
3
4
|
export * from './CodeWalkthrough/CodeWalkthroughStepsContext';
|
|
4
5
|
export * from './CodeSnippetContext';
|
|
5
6
|
export * from './SearchContext';
|
|
7
|
+
export * from './Toast/ToastContext';
|
|
8
|
+
export * from './Toast/ToastProvider';
|
|
@@ -15,8 +15,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./ThemeDataContext"), exports);
|
|
18
|
+
__exportStar(require("./MarkdownLinkContext"), exports);
|
|
18
19
|
__exportStar(require("./CodeWalkthrough/CodeWalkthroughControlsContext"), exports);
|
|
19
20
|
__exportStar(require("./CodeWalkthrough/CodeWalkthroughStepsContext"), exports);
|
|
20
21
|
__exportStar(require("./CodeSnippetContext"), exports);
|
|
21
22
|
__exportStar(require("./SearchContext"), exports);
|
|
23
|
+
__exportStar(require("./Toast/ToastContext"), exports);
|
|
24
|
+
__exportStar(require("./Toast/ToastProvider"), exports);
|
|
22
25
|
//# sourceMappingURL=index.js.map
|
package/lib/core/hooks/index.js
CHANGED
|
@@ -67,4 +67,6 @@ __exportStar(require("./catalog/use-catalog-entity-schema"), exports);
|
|
|
67
67
|
__exportStar(require("./catalog/use-catalog-table-header-cell-actions"), exports);
|
|
68
68
|
__exportStar(require("./use-store"), exports);
|
|
69
69
|
__exportStar(require("./use-is-truncated"), exports);
|
|
70
|
+
__exportStar(require("./use-toast"), exports);
|
|
71
|
+
__exportStar(require("./use-toast-logic"), exports);
|
|
70
72
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { RefObject } from 'react';
|
|
2
|
+
import type { ToastItem } from '../types/toast';
|
|
3
|
+
interface UseToastLogicOptions {
|
|
4
|
+
toast: ToastItem;
|
|
5
|
+
onDismiss: (id: string) => void;
|
|
6
|
+
stackIndex: number;
|
|
7
|
+
}
|
|
8
|
+
interface UseToastLogicReturn {
|
|
9
|
+
wrapperRef: RefObject<HTMLDivElement | null>;
|
|
10
|
+
hasDetails: boolean;
|
|
11
|
+
dismissToast: () => void;
|
|
12
|
+
handleMouseEnter: () => void;
|
|
13
|
+
handleMouseLeave: () => void;
|
|
14
|
+
ariaRole: 'alert' | 'status';
|
|
15
|
+
ariaLive: 'assertive' | 'polite';
|
|
16
|
+
}
|
|
17
|
+
export declare function useToastLogic({ toast, onDismiss, stackIndex, }: UseToastLogicOptions): UseToastLogicReturn;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useToastLogic = useToastLogic;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const STACK_SHIFT_ENTER_DURATION_MS = 280;
|
|
7
|
+
const STACK_SHIFT_EXIT_DURATION_MS = 200;
|
|
8
|
+
function useToastLogic({ toast, onDismiss, stackIndex, }) {
|
|
9
|
+
const wrapperRef = (0, react_1.useRef)(null);
|
|
10
|
+
const previousTopRef = (0, react_1.useRef)(null);
|
|
11
|
+
const previousStackIndexRef = (0, react_1.useRef)(null);
|
|
12
|
+
const timerRef = (0, react_1.useRef)(null);
|
|
13
|
+
const startedAtRef = (0, react_1.useRef)(null);
|
|
14
|
+
const remainingTimeRef = (0, react_1.useRef)(0);
|
|
15
|
+
const animationFrameRef = (0, react_1.useRef)(null);
|
|
16
|
+
const isHoveredRef = (0, react_1.useRef)(false);
|
|
17
|
+
const hasDetails = Boolean(toast.description);
|
|
18
|
+
const resolvedDuration = (0, react_1.useMemo)(() => (0, utils_1.getAutoDismissDuration)(hasDetails, toast.type, toast.duration), [hasDetails, toast.duration, toast.type]);
|
|
19
|
+
const ariaRole = toast.type === 'error' ? 'alert' : 'status';
|
|
20
|
+
const ariaLive = toast.type === 'error' ? 'assertive' : 'polite';
|
|
21
|
+
const clearTimer = (0, react_1.useCallback)(() => {
|
|
22
|
+
if (timerRef.current) {
|
|
23
|
+
clearTimeout(timerRef.current);
|
|
24
|
+
timerRef.current = null;
|
|
25
|
+
}
|
|
26
|
+
startedAtRef.current = null;
|
|
27
|
+
}, []);
|
|
28
|
+
const dismissToast = (0, react_1.useCallback)(() => {
|
|
29
|
+
onDismiss(toast.id);
|
|
30
|
+
}, [onDismiss, toast.id]);
|
|
31
|
+
const startTimer = (0, react_1.useCallback)((delay) => {
|
|
32
|
+
clearTimer();
|
|
33
|
+
if (delay <= 0) {
|
|
34
|
+
dismissToast();
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
remainingTimeRef.current = delay;
|
|
38
|
+
startedAtRef.current = Date.now();
|
|
39
|
+
timerRef.current = setTimeout(() => {
|
|
40
|
+
dismissToast();
|
|
41
|
+
}, delay);
|
|
42
|
+
}, [clearTimer, dismissToast]);
|
|
43
|
+
(0, react_1.useEffect)(() => {
|
|
44
|
+
if (toast.isExiting || resolvedDuration === null) {
|
|
45
|
+
clearTimer();
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
if (!isHoveredRef.current) {
|
|
49
|
+
startTimer(resolvedDuration);
|
|
50
|
+
}
|
|
51
|
+
return () => {
|
|
52
|
+
clearTimer();
|
|
53
|
+
};
|
|
54
|
+
}, [
|
|
55
|
+
clearTimer,
|
|
56
|
+
resolvedDuration,
|
|
57
|
+
startTimer,
|
|
58
|
+
toast.description,
|
|
59
|
+
toast.isExiting,
|
|
60
|
+
toast.title,
|
|
61
|
+
toast.type,
|
|
62
|
+
]);
|
|
63
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
64
|
+
const node = wrapperRef.current;
|
|
65
|
+
if (!node) {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
node.style.transition = 'none';
|
|
69
|
+
node.style.transform = '';
|
|
70
|
+
const currentTop = node.getBoundingClientRect().top;
|
|
71
|
+
const previousTop = previousTopRef.current;
|
|
72
|
+
const previousStackIndex = previousStackIndexRef.current;
|
|
73
|
+
if (toast.isExiting) {
|
|
74
|
+
previousTopRef.current = currentTop;
|
|
75
|
+
previousStackIndexRef.current = stackIndex;
|
|
76
|
+
return () => {
|
|
77
|
+
if (animationFrameRef.current !== null) {
|
|
78
|
+
window.cancelAnimationFrame(animationFrameRef.current);
|
|
79
|
+
animationFrameRef.current = null;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
const didStackIndexChange = previousStackIndex !== null && previousStackIndex !== stackIndex;
|
|
84
|
+
if (didStackIndexChange && previousTop !== null && previousTop !== currentTop) {
|
|
85
|
+
const delta = previousTop - currentTop;
|
|
86
|
+
const shiftDuration = delta > 0 ? STACK_SHIFT_ENTER_DURATION_MS : STACK_SHIFT_EXIT_DURATION_MS;
|
|
87
|
+
node.style.transform = `translateY(${delta}px)`;
|
|
88
|
+
node.getBoundingClientRect();
|
|
89
|
+
animationFrameRef.current = window.requestAnimationFrame(() => {
|
|
90
|
+
animationFrameRef.current = null;
|
|
91
|
+
if (!wrapperRef.current) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
wrapperRef.current.style.transition = `transform ${shiftDuration}ms ease-out`;
|
|
95
|
+
wrapperRef.current.style.transform = 'translateY(0)';
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
previousTopRef.current = currentTop;
|
|
99
|
+
previousStackIndexRef.current = stackIndex;
|
|
100
|
+
return () => {
|
|
101
|
+
if (animationFrameRef.current !== null) {
|
|
102
|
+
window.cancelAnimationFrame(animationFrameRef.current);
|
|
103
|
+
animationFrameRef.current = null;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
});
|
|
107
|
+
(0, react_1.useEffect)(() => {
|
|
108
|
+
return () => {
|
|
109
|
+
clearTimer();
|
|
110
|
+
if (animationFrameRef.current !== null) {
|
|
111
|
+
window.cancelAnimationFrame(animationFrameRef.current);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}, [clearTimer]);
|
|
115
|
+
const handleMouseEnter = (0, react_1.useCallback)(() => {
|
|
116
|
+
isHoveredRef.current = true;
|
|
117
|
+
if (resolvedDuration === null || startedAtRef.current === null) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const elapsed = Date.now() - startedAtRef.current;
|
|
121
|
+
remainingTimeRef.current = Math.max(remainingTimeRef.current - elapsed, 0);
|
|
122
|
+
clearTimer();
|
|
123
|
+
}, [clearTimer, resolvedDuration]);
|
|
124
|
+
const handleMouseLeave = (0, react_1.useCallback)(() => {
|
|
125
|
+
isHoveredRef.current = false;
|
|
126
|
+
if (toast.isExiting || resolvedDuration === null) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
startTimer(remainingTimeRef.current || resolvedDuration);
|
|
130
|
+
}, [resolvedDuration, startTimer, toast.isExiting]);
|
|
131
|
+
return {
|
|
132
|
+
wrapperRef,
|
|
133
|
+
hasDetails,
|
|
134
|
+
dismissToast,
|
|
135
|
+
handleMouseEnter,
|
|
136
|
+
handleMouseLeave,
|
|
137
|
+
ariaRole,
|
|
138
|
+
ariaLive,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=use-toast-logic.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ToastContextValue, ToastOptions } from '../types/toast';
|
|
2
|
+
type TypedToastOptions = Omit<ToastOptions, 'title' | 'type'>;
|
|
3
|
+
interface UseToastReturn extends ToastContextValue {
|
|
4
|
+
info: (title: string, options?: TypedToastOptions) => string;
|
|
5
|
+
success: (title: string, options?: TypedToastOptions) => string;
|
|
6
|
+
warning: (title: string, options?: TypedToastOptions) => string;
|
|
7
|
+
error: (title: string, options?: TypedToastOptions) => string;
|
|
8
|
+
loading: (title: string, options?: TypedToastOptions) => string;
|
|
9
|
+
}
|
|
10
|
+
export declare function useToast(): UseToastReturn;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useToast = useToast;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const ToastContext_1 = require("../contexts/Toast/ToastContext");
|
|
6
|
+
function createTypedToast(showToast, type) {
|
|
7
|
+
return (title, options) => showToast(Object.assign(Object.assign({}, options), { title,
|
|
8
|
+
type }));
|
|
9
|
+
}
|
|
10
|
+
function useToast() {
|
|
11
|
+
const context = (0, react_1.useContext)(ToastContext_1.ToastContext);
|
|
12
|
+
if (!context) {
|
|
13
|
+
throw new Error('useToast must be used within a ToastProvider');
|
|
14
|
+
}
|
|
15
|
+
return (0, react_1.useMemo)(() => (Object.assign(Object.assign({}, context), { info: createTypedToast(context.showToast, 'info'), success: createTypedToast(context.showToast, 'success'), warning: createTypedToast(context.showToast, 'warning'), error: createTypedToast(context.showToast, 'error'), loading: createTypedToast(context.showToast, 'loading') })), [context]);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=use-toast.js.map
|
package/lib/core/styles/dark.js
CHANGED
|
@@ -3,23 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.darkMode = void 0;
|
|
4
4
|
const styled_components_1 = require("styled-components");
|
|
5
5
|
const variables_dark_1 = require("../../components/Scorecard/variables.dark");
|
|
6
|
-
const variables_dark_2 = require("../../
|
|
7
|
-
const variables_dark_3 = require("../../
|
|
8
|
-
const variables_dark_4 = require("../../components/
|
|
9
|
-
const variables_dark_5 = require("../../components/
|
|
10
|
-
const variables_dark_6 = require("../../
|
|
11
|
-
const variables_dark_7 = require("../../components/
|
|
12
|
-
const variables_dark_8 = require("../../
|
|
13
|
-
const variables_dark_9 = require("../../components/
|
|
14
|
-
const variables_dark_10 = require("../../components/
|
|
15
|
-
const variables_dark_11 = require("../../components/
|
|
16
|
-
const variables_dark_12 = require("../../
|
|
17
|
-
const variables_dark_13 = require("../../components/
|
|
18
|
-
const variables_dark_14 = require("../../components/
|
|
19
|
-
const variables_dark_15 = require("../../components/
|
|
20
|
-
const variables_dark_16 = require("../../components/Banner/variables.dark");
|
|
21
|
-
const variables_dark_17 = require("../../components/Admonition/variables.dark");
|
|
22
|
-
const variables_dark_18 = require("../../components/SvgViewer/variables.dark");
|
|
6
|
+
const variables_dark_2 = require("../../components/Menu/variables.dark");
|
|
7
|
+
const variables_dark_3 = require("../../components/Button/variables.dark");
|
|
8
|
+
const variables_dark_4 = require("../../components/Buttons/variables.dark");
|
|
9
|
+
const variables_dark_5 = require("../../components/Segmented/variables.dark");
|
|
10
|
+
const variables_dark_6 = require("../../icons/CheckboxIcon/variables.dark");
|
|
11
|
+
const variables_dark_7 = require("../../components/Tag/variables.dark");
|
|
12
|
+
const variables_dark_8 = require("../../components/StatusCode/variables.dark");
|
|
13
|
+
const variables_dark_9 = require("../../components/Switch/variables.dark");
|
|
14
|
+
const variables_dark_10 = require("../../markdoc/components/Cards/variables.dark");
|
|
15
|
+
const variables_dark_11 = require("../../components/Catalog/variables.dark");
|
|
16
|
+
const variables_dark_12 = require("../../components/PageActions/variables.dark");
|
|
17
|
+
const variables_dark_13 = require("../../components/Tooltip/variables.dark");
|
|
18
|
+
const variables_dark_14 = require("../../components/Banner/variables.dark");
|
|
19
|
+
const variables_dark_15 = require("../../components/Admonition/variables.dark");
|
|
23
20
|
const palette_dark_1 = require("./palette.dark");
|
|
24
21
|
const replayDarkMode = (0, styled_components_1.css) `
|
|
25
22
|
/**
|
|
@@ -243,12 +240,6 @@ exports.darkMode = (0, styled_components_1.css) `
|
|
|
243
240
|
--color-black: #ffffff;
|
|
244
241
|
--color-white: #000000;
|
|
245
242
|
|
|
246
|
-
|
|
247
|
-
--color-brand-pink-subtle-bg: var(--color-brand-subtle-1);
|
|
248
|
-
--color-brand-pink-subtle-bg-hover: var(--color-brand-subtle-2);
|
|
249
|
-
--color-brand-pink-subtle-border: var(--color-brand-subtle-3);
|
|
250
|
-
--color-brand-pink-subtle-border-hover: var(--color-brand-subtle-4);
|
|
251
|
-
|
|
252
243
|
--color-hover-base: #32343E;
|
|
253
244
|
|
|
254
245
|
--bg-color: var(--color-warm-grey-2);
|
|
@@ -272,6 +263,11 @@ exports.darkMode = (0, styled_components_1.css) `
|
|
|
272
263
|
--layer-accent-hover: var(--color-warm-grey-10);
|
|
273
264
|
--layer-color-raised: var(--color-warm-grey-3);
|
|
274
265
|
|
|
266
|
+
--color-brand-subtle-bg: var(--color-brand-subtle-1);
|
|
267
|
+
--color-brand-subtle-bg-hover: var(--color-brand-subtle-2);
|
|
268
|
+
--color-brand-subtle-border: var(--color-brand-subtle-3);
|
|
269
|
+
--color-brand-subtle-border-hover: var(--color-brand-subtle-4);
|
|
270
|
+
|
|
275
271
|
/**
|
|
276
272
|
* @tokens Border Colors
|
|
277
273
|
* @presenter Color
|
|
@@ -335,25 +331,22 @@ exports.darkMode = (0, styled_components_1.css) `
|
|
|
335
331
|
--plus-square-outlined-icon: url("data:image/svg+xml,%3Csvg width='10' height='10' viewBox='0 0 10 10' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3.20312 5.3125H4.6875V6.79687C4.6875 6.83984 4.72266 6.875 4.76562 6.875H5.23438C5.27734 6.875 5.3125 6.83984 5.3125 6.79687V5.3125H6.79688C6.83984 5.3125 6.875 5.27734 6.875 5.23437V4.76562C6.875 4.72266 6.83984 4.6875 6.79688 4.6875H5.3125V3.20312C5.3125 3.16016 5.27734 3.125 5.23438 3.125H4.76562C4.72266 3.125 4.6875 3.16016 4.6875 3.20312V4.6875H3.20312C3.16016 4.6875 3.125 4.72266 3.125 4.76562V5.23437C3.125 5.27734 3.16016 5.3125 3.20312 5.3125Z' fill='%239B9CA8'/%3E%3Cpath d='M8.59375 1.09375H1.40625C1.2334 1.09375 1.09375 1.2334 1.09375 1.40625V8.59375C1.09375 8.7666 1.2334 8.90625 1.40625 8.90625H8.59375C8.7666 8.90625 8.90625 8.7666 8.90625 8.59375V1.40625C8.90625 1.2334 8.7666 1.09375 8.59375 1.09375ZM8.20312 8.20312H1.79688V1.79687H8.20312V8.20312Z' fill='%239B9CA8'/%3E%3C/svg%3E%0A");
|
|
336
332
|
--minus-square-outlined-icon: url("data:image/svg+xml,%3Csvg width='10' height='10' viewBox='0 0 10 10' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3.20312 5.3125H6.79688C6.83984 5.3125 6.875 5.27734 6.875 5.23437V4.76562C6.875 4.72266 6.83984 4.6875 6.79688 4.6875H3.20312C3.16016 4.6875 3.125 4.72266 3.125 4.76562V5.23437C3.125 5.27734 3.16016 5.3125 3.20312 5.3125Z' fill='%239B9CA8'/%3E%3Cpath d='M8.59375 1.09375H1.40625C1.2334 1.09375 1.09375 1.2334 1.09375 1.40625V8.59375C1.09375 8.7666 1.2334 8.90625 1.40625 8.90625H8.59375C8.7666 8.90625 8.90625 8.7666 8.90625 8.59375V1.40625C8.90625 1.2334 8.7666 1.09375 8.59375 1.09375ZM8.20312 8.20312H1.79688V1.79687H8.20312V8.20312Z' fill='%239B9CA8'/%3E%3C/svg%3E%0A");
|
|
337
333
|
|
|
338
|
-
${
|
|
339
|
-
${
|
|
340
|
-
${
|
|
341
|
-
${
|
|
342
|
-
${
|
|
343
|
-
${
|
|
344
|
-
${
|
|
345
|
-
${variables_dark_2.mermaidDarkMode}
|
|
346
|
-
${variables_dark_3.excalidrawDarkMode}
|
|
334
|
+
${variables_dark_5.segmentedButtonsDarkMode}
|
|
335
|
+
${variables_dark_3.buttonDarkMode}
|
|
336
|
+
${variables_dark_4.aiAssistantButtonDarkMode}
|
|
337
|
+
${variables_dark_6.checkboxDarkMode}
|
|
338
|
+
${variables_dark_7.tagDarkMode}
|
|
339
|
+
${variables_dark_8.statusCodeDarkMode}
|
|
340
|
+
${variables_dark_2.menuDarkMode}
|
|
347
341
|
${variables_dark_1.scorecardDarkMode}
|
|
348
342
|
${replayDarkMode}
|
|
349
|
-
${
|
|
350
|
-
${
|
|
351
|
-
${
|
|
352
|
-
${
|
|
353
|
-
${
|
|
354
|
-
${
|
|
355
|
-
${
|
|
356
|
-
${variables_dark_18.svgViewerDarkMode}
|
|
343
|
+
${variables_dark_9.switcherDarkMode}
|
|
344
|
+
${variables_dark_10.cardsDarkMode}
|
|
345
|
+
${variables_dark_11.catalogDarkMode}
|
|
346
|
+
${variables_dark_12.pageActionsDarkMode}
|
|
347
|
+
${variables_dark_13.tooltipDarkMode}
|
|
348
|
+
${variables_dark_14.bannerDarkMode}
|
|
349
|
+
${variables_dark_15.admonitionDarkMode}
|
|
357
350
|
${badgesDarkMode}
|
|
358
351
|
${palette_dark_1.activeBrandPaletteDark}
|
|
359
352
|
/**
|