@redocly/theme 0.64.0-next.1 → 0.64.0-next.3
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/Banner/Banner.js +3 -3
- package/lib/components/Button/variables.dark.js +2 -2
- package/lib/components/Button/variables.js +3 -3
- package/lib/components/Catalog/CatalogActionsRow.d.ts +3 -3
- package/lib/components/Catalog/CatalogCardView/CatalogCard.js +4 -6
- package/lib/components/Catalog/CatalogEntities.d.ts +2 -2
- package/lib/components/Catalog/CatalogEntities.js +1 -1
- package/lib/components/Catalog/CatalogEntity/CatalogEntity.d.ts +1 -8
- package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityVersionItem.js +3 -1
- package/lib/components/Catalog/CatalogEntity/CatalogEntityMetadata.js +1 -1
- package/lib/components/Catalog/CatalogEntity/CatalogEntityMethodAndPath.js +1 -1
- package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/CatalogEntityProperties.js +1 -0
- package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/CatalogEntityPropertyCard.js +2 -1
- package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/ContactProperty.js +2 -6
- package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/DomainsProperty.js +5 -5
- package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/FormatProperty.js +1 -1
- package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/OwnersProperty.js +15 -7
- package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/TagsProperty.js +2 -2
- package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityApiDescriptionRelations.d.ts +3 -3
- package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityApiDescriptionRelations.js +4 -1
- package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityDefaultRelations.d.ts +3 -3
- package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityDefaultRelations.js +14 -2
- package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations.js +1 -1
- package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable.d.ts +3 -3
- package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable.js +1 -1
- package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTableContent.d.ts +2 -2
- package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityTeamRelations.d.ts +3 -3
- package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityTeamRelations.js +13 -3
- package/lib/components/Catalog/CatalogEntity/CatalogEntitySchema.js +4 -3
- package/lib/components/Catalog/CatalogEntityTypeIcon.d.ts +3 -2
- package/lib/components/Catalog/CatalogEntityTypeIcon.js +9 -9
- package/lib/components/Catalog/CatalogMobileTopBar/CatalogMobileTopBar.d.ts +2 -3
- package/lib/components/Catalog/CatalogMobileTopBar/CatalogMobileTopBarControls.d.ts +2 -3
- package/lib/components/Catalog/CatalogPageDescription.js +1 -1
- package/lib/components/Catalog/CatalogSortButton.d.ts +4 -5
- package/lib/components/Catalog/CatalogTableView/CatalogDomainsCell.js +6 -2
- package/lib/components/Catalog/CatalogTableView/CatalogEntityCell.js +2 -2
- package/lib/components/Catalog/CatalogTableView/CatalogLastUpdateCell.d.ts +5 -0
- package/lib/components/Catalog/CatalogTableView/CatalogLastUpdateCell.js +45 -0
- package/lib/components/Catalog/CatalogTableView/CatalogOwnersCell.js +5 -3
- package/lib/components/Catalog/CatalogTableView/CatalogTableHeaderCell.d.ts +2 -3
- package/lib/components/Catalog/CatalogTableView/CatalogTableHeaderCell.js +3 -2
- package/lib/components/Catalog/CatalogTableView/CatalogTableView.d.ts +1 -2
- package/lib/components/Catalog/CatalogTableView/CatalogTableView.js +15 -5
- package/lib/components/Catalog/CatalogTableView/CatalogTagsCell.js +3 -2
- package/lib/components/Catalog/CatalogTableView/CatalogUserEntityCell.js +2 -2
- package/lib/components/Catalog/CatalogTags.d.ts +11 -0
- package/lib/components/Catalog/CatalogTags.js +62 -0
- package/lib/components/Catalog/variables.js +22 -14
- package/lib/components/Filter/variables.js +1 -1
- 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/SearchDialog.js +118 -116
- package/lib/components/SvgViewer/variables.dark.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/catalog.d.ts +1 -1
- package/lib/core/constants/catalog.js +1 -1
- package/lib/core/constants/toast.d.ts +1 -0
- package/lib/core/constants/toast.js +5 -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 +2 -0
- package/lib/core/contexts/index.js +2 -0
- package/lib/core/hooks/catalog/use-catalog-entity-link.d.ts +8 -0
- package/lib/core/hooks/catalog/use-catalog-entity-link.js +42 -0
- package/lib/core/hooks/catalog/use-catalog-table-header-cell-actions.d.ts +2 -1
- package/lib/core/hooks/catalog/use-catalog-table-header-cell-actions.js +5 -3
- package/lib/core/hooks/index.d.ts +3 -0
- package/lib/core/hooks/index.js +3 -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.d.ts +3 -1
- package/lib/core/styles/dark.js +37 -33
- package/lib/core/styles/global.d.ts +6 -2
- package/lib/core/styles/global.js +56 -46
- package/lib/core/styles/palette.d.ts +6 -0
- package/lib/core/styles/palette.dark.d.ts +3 -0
- package/lib/core/styles/palette.dark.js +201 -0
- package/lib/core/styles/palette.js +175 -0
- package/lib/core/types/catalog.d.ts +23 -7
- package/lib/core/types/hooks.d.ts +6 -4
- package/lib/core/types/index.d.ts +1 -0
- package/lib/core/types/search.d.ts +1 -0
- 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 +5 -1
- package/lib/index.js +5 -1
- package/lib/markdoc/components/Heading/Heading.js +2 -2
- package/lib/markdoc/components/Mermaid/Mermaid.js +0 -2
- package/lib/markdoc/components/Tabs/variables.js +3 -3
- package/lib/markdoc/components/default.d.ts +0 -1
- package/lib/markdoc/components/default.js +0 -1
- package/lib/markdoc/tags/admonition.js +1 -1
- package/package.json +2 -2
- 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/Banner/Banner.tsx +7 -7
- package/src/components/Button/variables.dark.ts +2 -2
- package/src/components/Button/variables.ts +3 -3
- package/src/components/Catalog/CatalogActionsRow.tsx +3 -3
- package/src/components/Catalog/CatalogCardView/CatalogCard.tsx +4 -6
- package/src/components/Catalog/CatalogEntities.tsx +3 -3
- package/src/components/Catalog/CatalogEntity/CatalogEntity.tsx +3 -24
- package/src/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityVersionItem.tsx +3 -1
- package/src/components/Catalog/CatalogEntity/CatalogEntityMetadata.tsx +1 -1
- package/src/components/Catalog/CatalogEntity/CatalogEntityMethodAndPath.tsx +1 -1
- package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/CatalogEntityProperties.tsx +1 -0
- package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/CatalogEntityPropertyCard.tsx +2 -1
- package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/ContactProperty.tsx +8 -10
- package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/DomainsProperty.tsx +13 -8
- package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/FormatProperty.tsx +1 -0
- package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/OwnersProperty.tsx +27 -15
- package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/TagsProperty.tsx +2 -2
- package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityApiDescriptionRelations.tsx +9 -9
- package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityDefaultRelations.tsx +17 -9
- package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations.tsx +1 -1
- package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable.tsx +4 -8
- package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTableContent.tsx +2 -2
- package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityTeamRelations.tsx +16 -10
- package/src/components/Catalog/CatalogEntity/CatalogEntitySchema.tsx +4 -3
- package/src/components/Catalog/CatalogEntityTypeIcon.tsx +18 -11
- package/src/components/Catalog/CatalogMobileTopBar/CatalogMobileTopBar.tsx +3 -3
- package/src/components/Catalog/CatalogMobileTopBar/CatalogMobileTopBarControls.tsx +2 -3
- package/src/components/Catalog/CatalogPageDescription.tsx +1 -1
- package/src/components/Catalog/CatalogSortButton.tsx +5 -6
- package/src/components/Catalog/CatalogTableView/CatalogDomainsCell.tsx +6 -2
- package/src/components/Catalog/CatalogTableView/CatalogEntityCell.tsx +2 -2
- package/src/components/Catalog/CatalogTableView/CatalogLastUpdateCell.tsx +54 -0
- package/src/components/Catalog/CatalogTableView/CatalogOwnersCell.tsx +5 -2
- package/src/components/Catalog/CatalogTableView/CatalogTableHeaderCell.tsx +4 -3
- package/src/components/Catalog/CatalogTableView/CatalogTableView.tsx +17 -7
- package/src/components/Catalog/CatalogTableView/CatalogTagsCell.tsx +3 -2
- package/src/components/Catalog/CatalogTableView/CatalogUserEntityCell.tsx +2 -2
- package/src/components/Catalog/CatalogTags.tsx +115 -0
- package/src/components/Catalog/variables.ts +22 -14
- package/src/components/Filter/variables.ts +1 -1
- 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/SearchDialog.tsx +299 -293
- package/src/components/SvgViewer/variables.dark.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/catalog.ts +1 -1
- package/src/core/constants/toast.ts +1 -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 +2 -0
- package/src/core/hooks/catalog/use-catalog-entity-link.ts +46 -0
- package/src/core/hooks/catalog/use-catalog-table-header-cell-actions.ts +10 -2
- package/src/core/hooks/index.ts +3 -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 +9 -4
- package/src/core/styles/global.ts +30 -20
- package/src/core/styles/palette.dark.ts +199 -0
- package/src/core/styles/palette.ts +173 -0
- package/src/core/types/catalog.ts +24 -8
- package/src/core/types/hooks.ts +5 -10
- package/src/core/types/index.ts +1 -0
- package/src/core/types/search.ts +1 -0
- 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 +5 -1
- package/src/markdoc/components/Heading/Heading.tsx +2 -1
- package/src/markdoc/components/Mermaid/Mermaid.tsx +0 -2
- package/src/markdoc/components/Tabs/variables.ts +3 -3
- package/src/markdoc/components/default.ts +0 -1
- package/src/markdoc/tags/admonition.ts +1 -1
- package/lib/components/Catalog/CatalogTagsWithTooltip.d.ts +0 -10
- package/lib/components/Catalog/CatalogTagsWithTooltip.js +0 -57
- 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/src/components/Catalog/CatalogTagsWithTooltip.tsx +0 -101
- 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
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toast = void 0;
|
|
4
|
+
const styled_components_1 = require("styled-components");
|
|
5
|
+
/* eslint-disable theme/no-raw-colors-in-styles */
|
|
6
|
+
exports.toast = (0, styled_components_1.css) `
|
|
7
|
+
/**
|
|
8
|
+
* @tokens Toast
|
|
9
|
+
* @presenter BoxShadow
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
--toast-box-shadow: 2px 2px 12px 0 rgba(0, 0, 0, 0.04), 2px 2px 24px 8px rgba(0, 0, 0, 0.04);
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @tokens Toast surface
|
|
16
|
+
*/
|
|
17
|
+
--toast-min-width: 240px;
|
|
18
|
+
--toast-max-width: 360px;
|
|
19
|
+
--toast-bg-color: var(--layer-color); // @presenter Color
|
|
20
|
+
--toast-border: var(--border-width) var(--border-style) var(--border-color-secondary); // @presenter Border
|
|
21
|
+
--toast-border-radius: var(--border-radius-md); // @presenter BorderRadius
|
|
22
|
+
--toast-font-family: var(--font-family-base); // @presenter FontFamily
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @tokens Toast spacing
|
|
26
|
+
*/
|
|
27
|
+
--toast-simple-gap: var(--spacing-unit);
|
|
28
|
+
--toast-simple-padding: var(--spacing-xs) var(--spacing-sm);
|
|
29
|
+
--toast-detailed-padding: var(--spacing-sm);
|
|
30
|
+
--toast-content-gap: var(--spacing-xs);
|
|
31
|
+
--toast-title-gap: var(--spacing-xs);
|
|
32
|
+
--toast-description-gap: var(--spacing-xs);
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @tokens Toast icon
|
|
36
|
+
*/
|
|
37
|
+
--toast-icon-size: 14px;
|
|
38
|
+
--toast-icon-line-height: var(--line-height-base); // @presenter LineHeight
|
|
39
|
+
--toast-icon-color-info: var(--color-info-base); // @presenter Color
|
|
40
|
+
--toast-icon-color-success: var(--color-success-base); // @presenter Color
|
|
41
|
+
--toast-icon-color-warning: var(--color-warning-base); // @presenter Color
|
|
42
|
+
--toast-icon-color-error: var(--color-error-base); // @presenter Color
|
|
43
|
+
--toast-icon-color-loading: var(--loading-spinner-color); // @presenter Color
|
|
44
|
+
--toast-loading-animation-duration: 3s;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @tokens Toast typography
|
|
48
|
+
*/
|
|
49
|
+
--toast-text-font-size: var(--font-size-base); // @presenter FontSize
|
|
50
|
+
--toast-text-line-height: var(--line-height-base); // @presenter LineHeight
|
|
51
|
+
--toast-text-color: var(--text-color-primary); // @presenter Color
|
|
52
|
+
--toast-title-font-weight: var(--font-weight-semibold); // @presenter FontWeight
|
|
53
|
+
--toast-body-font-weight: var(--font-weight-regular); // @presenter FontWeight
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @tokens Toast close button
|
|
57
|
+
*/
|
|
58
|
+
--toast-close-button-padding: 3px;
|
|
59
|
+
--toast-close-button-icon-size: 14px;
|
|
60
|
+
--toast-close-button-icon-color: var(--icon-color-secondary); // @presenter Color
|
|
61
|
+
|
|
62
|
+
// @tokens End
|
|
63
|
+
`;
|
|
64
|
+
//# sourceMappingURL=variables.js.map
|
|
@@ -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,5 +1,5 @@
|
|
|
1
1
|
import type { EntityRelationType } from '../types/catalog';
|
|
2
|
-
export declare const CATALOG_TAG_MAX_LENGTH =
|
|
2
|
+
export declare const CATALOG_TAG_MAX_LENGTH = 12;
|
|
3
3
|
export declare const PREDEFINED_ENTITY_TYPES: string[];
|
|
4
4
|
export declare const reverseRelationMap: Record<EntityRelationType, EntityRelationType>;
|
|
5
5
|
export declare const relationTypeMap: Record<EntityRelationType, string>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VERSION_NOT_SPECIFIED = exports.GraphCustomEdgeType = exports.GraphCustomNodeType = exports.GraphHandleType = exports.relationTypeMap = exports.reverseRelationMap = exports.PREDEFINED_ENTITY_TYPES = exports.CATALOG_TAG_MAX_LENGTH = void 0;
|
|
4
|
-
exports.CATALOG_TAG_MAX_LENGTH =
|
|
4
|
+
exports.CATALOG_TAG_MAX_LENGTH = 12;
|
|
5
5
|
exports.PREDEFINED_ENTITY_TYPES = [
|
|
6
6
|
'service',
|
|
7
7
|
'domain',
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const TOAST_SLIDE_DURATION_MS = 300;
|
|
@@ -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
|
|
@@ -3,3 +3,5 @@ export * from './CodeWalkthrough/CodeWalkthroughControlsContext';
|
|
|
3
3
|
export * from './CodeWalkthrough/CodeWalkthroughStepsContext';
|
|
4
4
|
export * from './CodeSnippetContext';
|
|
5
5
|
export * from './SearchContext';
|
|
6
|
+
export * from './Toast/ToastContext';
|
|
7
|
+
export * from './Toast/ToastProvider';
|
|
@@ -19,4 +19,6 @@ __exportStar(require("./CodeWalkthrough/CodeWalkthroughControlsContext"), export
|
|
|
19
19
|
__exportStar(require("./CodeWalkthrough/CodeWalkthroughStepsContext"), exports);
|
|
20
20
|
__exportStar(require("./CodeSnippetContext"), exports);
|
|
21
21
|
__exportStar(require("./SearchContext"), exports);
|
|
22
|
+
__exportStar(require("./Toast/ToastContext"), exports);
|
|
23
|
+
__exportStar(require("./Toast/ToastProvider"), exports);
|
|
22
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { EntitiesCatalogConfig } from '@redocly/config';
|
|
2
|
+
export type EntityWithTypeAndKey = {
|
|
3
|
+
type?: string;
|
|
4
|
+
key?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function useCatalogEntityLink(entitiesCatalogConfig: EntitiesCatalogConfig | undefined): {
|
|
7
|
+
getEntityLink: (entity: EntityWithTypeAndKey) => string | undefined;
|
|
8
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useCatalogEntityLink = useCatalogEntityLink;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
function isEntityExcluded(excludes, entityKey) {
|
|
6
|
+
var _a;
|
|
7
|
+
return (_a = excludes === null || excludes === void 0 ? void 0 : excludes.some((ex) => ex.key === entityKey)) !== null && _a !== void 0 ? _a : false;
|
|
8
|
+
}
|
|
9
|
+
function doesCatalogIncludeEntityType(config, entityType) {
|
|
10
|
+
var _a, _b;
|
|
11
|
+
const hasNoIncludes = !config.includes || config.includes.length === 0;
|
|
12
|
+
if (hasNoIncludes)
|
|
13
|
+
return true;
|
|
14
|
+
return (_b = (_a = config.includes) === null || _a === void 0 ? void 0 : _a.some((inc) => inc.type === entityType)) !== null && _b !== void 0 ? _b : false;
|
|
15
|
+
}
|
|
16
|
+
function useCatalogEntityLink(entitiesCatalogConfig) {
|
|
17
|
+
const catalogEntries = (0, react_1.useMemo)(() => {
|
|
18
|
+
const catalogs = entitiesCatalogConfig === null || entitiesCatalogConfig === void 0 ? void 0 : entitiesCatalogConfig.catalogs;
|
|
19
|
+
if (!catalogs)
|
|
20
|
+
return [];
|
|
21
|
+
return Object.entries(catalogs)
|
|
22
|
+
.filter((entry) => entry[1] != null)
|
|
23
|
+
.sort(([keyA], [keyB]) => (keyA === 'all' ? 1 : 0) - (keyB === 'all' ? 1 : 0));
|
|
24
|
+
}, [entitiesCatalogConfig]);
|
|
25
|
+
const getEntityLink = (entity) => {
|
|
26
|
+
var _a, _b;
|
|
27
|
+
if (!(entity === null || entity === void 0 ? void 0 : entity.key))
|
|
28
|
+
return undefined;
|
|
29
|
+
const entityType = (_a = entity.type) !== null && _a !== void 0 ? _a : '';
|
|
30
|
+
for (const [catalogKey, config] of catalogEntries) {
|
|
31
|
+
if (isEntityExcluded(config.excludes, entity.key))
|
|
32
|
+
continue;
|
|
33
|
+
if (!doesCatalogIncludeEntityType(config, entityType))
|
|
34
|
+
continue;
|
|
35
|
+
const slug = (_b = config.slug) !== null && _b !== void 0 ? _b : catalogKey;
|
|
36
|
+
return `catalogs/${slug}/entities/${entity.key}`;
|
|
37
|
+
}
|
|
38
|
+
return undefined;
|
|
39
|
+
};
|
|
40
|
+
return { getEntityLink };
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=use-catalog-entity-link.js.map
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { BaseEntity, CatalogColumn } from '../../../components/Catalog/CatalogTableView/CatalogTableView';
|
|
2
2
|
type CatalogTableHeaderCellActionsProps<T extends BaseEntity> = {
|
|
3
3
|
column: CatalogColumn<T>;
|
|
4
|
+
currentSortOption?: string | null;
|
|
4
5
|
handleSortClick: (sortKey: string, direction: 'asc' | 'desc') => void;
|
|
5
6
|
isColumnSorted: (sortKey: string, direction: 'asc' | 'desc') => boolean;
|
|
6
7
|
};
|
|
7
|
-
export declare function useCatalogTableHeaderCellActions<T extends BaseEntity>({ column, handleSortClick, isColumnSorted, }: CatalogTableHeaderCellActionsProps<T>): {
|
|
8
|
+
export declare function useCatalogTableHeaderCellActions<T extends BaseEntity>({ column, currentSortOption, handleSortClick, isColumnSorted, }: CatalogTableHeaderCellActionsProps<T>): {
|
|
8
9
|
handleCellClick: () => void;
|
|
9
10
|
sortKey: string | undefined;
|
|
10
11
|
isUpActive: boolean;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useCatalogTableHeaderCellActions = useCatalogTableHeaderCellActions;
|
|
4
|
-
function useCatalogTableHeaderCellActions({ column, handleSortClick, isColumnSorted, }) {
|
|
4
|
+
function useCatalogTableHeaderCellActions({ column, currentSortOption, handleSortClick, isColumnSorted, }) {
|
|
5
5
|
const sortKey = column.sortKey;
|
|
6
|
-
const isUpActive =
|
|
7
|
-
|
|
6
|
+
const isUpActive = Boolean(sortKey &&
|
|
7
|
+
(currentSortOption ? currentSortOption === sortKey : isColumnSorted(sortKey, 'desc')));
|
|
8
|
+
const isDownActive = Boolean(sortKey &&
|
|
9
|
+
(currentSortOption ? currentSortOption === `-${sortKey}` : isColumnSorted(sortKey, 'asc')));
|
|
8
10
|
const handleCellClick = () => {
|
|
9
11
|
if (!column.sortable || !sortKey)
|
|
10
12
|
return;
|
|
@@ -46,7 +46,10 @@ export * from './use-page-actions';
|
|
|
46
46
|
export * from './use-mcp-config';
|
|
47
47
|
export * from './use-connect-mcp-button';
|
|
48
48
|
export * from './catalog/use-catalog-entity-details';
|
|
49
|
+
export * from './catalog/use-catalog-entity-link';
|
|
49
50
|
export * from './catalog/use-catalog-entity-schema';
|
|
50
51
|
export * from './catalog/use-catalog-table-header-cell-actions';
|
|
51
52
|
export * from './use-store';
|
|
52
53
|
export * from './use-is-truncated';
|
|
54
|
+
export * from './use-toast';
|
|
55
|
+
export * from './use-toast-logic';
|
package/lib/core/hooks/index.js
CHANGED
|
@@ -62,8 +62,11 @@ __exportStar(require("./use-page-actions"), exports);
|
|
|
62
62
|
__exportStar(require("./use-mcp-config"), exports);
|
|
63
63
|
__exportStar(require("./use-connect-mcp-button"), exports);
|
|
64
64
|
__exportStar(require("./catalog/use-catalog-entity-details"), exports);
|
|
65
|
+
__exportStar(require("./catalog/use-catalog-entity-link"), exports);
|
|
65
66
|
__exportStar(require("./catalog/use-catalog-entity-schema"), exports);
|
|
66
67
|
__exportStar(require("./catalog/use-catalog-table-header-cell-actions"), exports);
|
|
67
68
|
__exportStar(require("./use-store"), exports);
|
|
68
69
|
__exportStar(require("./use-is-truncated"), exports);
|
|
70
|
+
__exportStar(require("./use-toast"), exports);
|
|
71
|
+
__exportStar(require("./use-toast-logic"), exports);
|
|
69
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
|