@stack-spot/portal-components 1.2.0 → 1.3.0-rc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/components/AsyncContent.d.ts +39 -0
  2. package/dist/components/AsyncContent.d.ts.map +1 -0
  3. package/dist/components/AsyncContent.js +27 -0
  4. package/dist/components/AsyncContent.js.map +1 -0
  5. package/dist/components/InfiniteScroll.d.ts +3 -0
  6. package/dist/components/InfiniteScroll.d.ts.map +1 -0
  7. package/dist/components/InfiniteScroll.js +5 -0
  8. package/dist/components/InfiniteScroll.js.map +1 -0
  9. package/dist/components/LazyMarkdown/BlockquoteMd.d.ts +4 -0
  10. package/dist/components/LazyMarkdown/BlockquoteMd.d.ts.map +1 -0
  11. package/dist/components/LazyMarkdown/BlockquoteMd.js +64 -0
  12. package/dist/components/LazyMarkdown/BlockquoteMd.js.map +1 -0
  13. package/dist/components/LazyMarkdown/CodeViewer.d.ts +19 -0
  14. package/dist/components/LazyMarkdown/CodeViewer.d.ts.map +1 -0
  15. package/dist/components/LazyMarkdown/CodeViewer.js +116 -0
  16. package/dist/components/LazyMarkdown/CodeViewer.js.map +1 -0
  17. package/dist/components/LazyMarkdown/Markdown.d.ts +6 -0
  18. package/dist/components/LazyMarkdown/Markdown.d.ts.map +1 -0
  19. package/dist/components/LazyMarkdown/Markdown.js +87 -0
  20. package/dist/components/LazyMarkdown/Markdown.js.map +1 -0
  21. package/dist/components/LazyMarkdown/MarkdownButton.d.ts +8 -0
  22. package/dist/components/LazyMarkdown/MarkdownButton.d.ts.map +1 -0
  23. package/dist/components/LazyMarkdown/MarkdownButton.js +4 -0
  24. package/dist/components/LazyMarkdown/MarkdownButton.js.map +1 -0
  25. package/dist/components/LazyMarkdown/Video.d.ts +4 -0
  26. package/dist/components/LazyMarkdown/Video.d.ts.map +1 -0
  27. package/dist/components/LazyMarkdown/Video.js +3 -0
  28. package/dist/components/LazyMarkdown/Video.js.map +1 -0
  29. package/dist/components/LazyMarkdown/index.d.ts +8 -0
  30. package/dist/components/LazyMarkdown/index.d.ts.map +1 -0
  31. package/dist/components/LazyMarkdown/index.js +8 -0
  32. package/dist/components/LazyMarkdown/index.js.map +1 -0
  33. package/dist/components/Notifications/NotificationComponent.d.ts +24 -0
  34. package/dist/components/Notifications/NotificationComponent.d.ts.map +1 -0
  35. package/dist/components/Notifications/NotificationComponent.js +114 -0
  36. package/dist/components/Notifications/NotificationComponent.js.map +1 -0
  37. package/dist/components/Notifications/NotificationItem.d.ts +11 -0
  38. package/dist/components/Notifications/NotificationItem.d.ts.map +1 -0
  39. package/dist/components/Notifications/NotificationItem.js +59 -0
  40. package/dist/components/Notifications/NotificationItem.js.map +1 -0
  41. package/dist/components/Notifications/index.d.ts +4 -0
  42. package/dist/components/Notifications/index.d.ts.map +1 -0
  43. package/dist/components/Notifications/index.js +4 -0
  44. package/dist/components/Notifications/index.js.map +1 -0
  45. package/dist/components/Notifications/types.d.ts +38 -0
  46. package/dist/components/Notifications/types.d.ts.map +1 -0
  47. package/dist/components/Notifications/types.js +20 -0
  48. package/dist/components/Notifications/types.js.map +1 -0
  49. package/dist/components/ScrollView.d.ts +27 -0
  50. package/dist/components/ScrollView.d.ts.map +1 -0
  51. package/dist/components/ScrollView.js +25 -0
  52. package/dist/components/ScrollView.js.map +1 -0
  53. package/dist/components/StatusCircle.d.ts +14 -0
  54. package/dist/components/StatusCircle.d.ts.map +1 -0
  55. package/dist/components/StatusCircle.js +26 -0
  56. package/dist/components/StatusCircle.js.map +1 -0
  57. package/dist/hooks/date.d.ts +22 -0
  58. package/dist/hooks/date.d.ts.map +1 -0
  59. package/dist/hooks/date.js +40 -0
  60. package/dist/hooks/date.js.map +1 -0
  61. package/package.json +16 -5
  62. package/src/components/AsyncContent.tsx +70 -0
  63. package/src/components/InfiniteScroll.tsx +13 -0
  64. package/src/components/LazyMarkdown/BlockquoteMd.tsx +94 -0
  65. package/src/components/LazyMarkdown/CodeViewer.tsx +154 -0
  66. package/src/components/LazyMarkdown/Markdown.tsx +107 -0
  67. package/src/components/LazyMarkdown/MarkdownButton.tsx +13 -0
  68. package/src/components/LazyMarkdown/Video.tsx +6 -0
  69. package/src/components/LazyMarkdown/index.tsx +18 -0
  70. package/src/components/Notifications/NotificationComponent.tsx +264 -0
  71. package/src/components/Notifications/NotificationItem.tsx +136 -0
  72. package/src/components/Notifications/index.tsx +3 -0
  73. package/src/components/Notifications/types.ts +46 -0
  74. package/src/components/ScrollView.tsx +51 -0
  75. package/src/components/StatusCircle.tsx +44 -0
  76. package/src/hooks/date.ts +43 -0
  77. package/src/index.ts +0 -1
@@ -0,0 +1,114 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { Box, Button, Flex, IconBox, Text } from '@citric/core';
3
+ import { Bell, TimesMini } from '@citric/icons';
4
+ import { listToClass, theme } from '@stack-spot/portal-theme';
5
+ import { useTranslate } from '@stack-spot/portal-translate';
6
+ import { useState } from 'react';
7
+ import styled from 'styled-components';
8
+ import { AsyncContent } from '../AsyncContent.js';
9
+ import { InfiniteScroll } from '../InfiniteScroll.js';
10
+ import { ScrollView } from '../ScrollView.js';
11
+ import { StatusCircle } from '../StatusCircle.js';
12
+ import { NotificationItem } from './NotificationItem.js';
13
+ import { NotificationType, UnreadType } from './types.js';
14
+ const ANIMATION_DURATION_MS = 300;
15
+ const MAX_HEIGHT_TRANSITION = `max-height ease-in ${ANIMATION_DURATION_MS / 1000}s`;
16
+ const NotificationsComponent = styled(Flex) `
17
+ max-height: 0;
18
+ z-index: 1;
19
+ visibility: hidden;
20
+ position: absolute;
21
+ top: calc(var(--header-height) - 2px);
22
+ right: -270%;
23
+ width: 400px;
24
+
25
+ &.visible {
26
+ min-height: 802px;
27
+ visibility: visible;
28
+ transition: ${MAX_HEIGHT_TRANSITION};
29
+ }
30
+
31
+ .content {
32
+ border-radius: 4px;
33
+ border: 1px solid ${theme.color.light[400]};
34
+ box-shadow: 4px 4px 48px ${theme.color.danger.contrastText};
35
+ background-color: ${theme.color.light[300]};
36
+ overflow-y: ${({ $scroll }) => $scroll ? 'auto' : 'hidden'};
37
+ overflow-x: hidden;
38
+ transition: ${MAX_HEIGHT_TRANSITION}, visibility 0s ${ANIMATION_DURATION_MS / 1000}s;
39
+ }
40
+
41
+ &::after {
42
+ content: '';
43
+ position: absolute;
44
+ border-width: 10px;
45
+ border-style: solid;
46
+ border-color: transparent;
47
+ bottom: 100%;
48
+ left: 74%;
49
+ margin-left: -5px;
50
+ transform: rotate(180deg);
51
+ border-top-color: ${theme.color.light[400]};
52
+ }
53
+ `;
54
+ const StyledBox = styled(Box) `
55
+ width: 100%;
56
+ > div:first-child{
57
+ width: 100%;
58
+ }
59
+ `;
60
+ const NotificationFilterButton = (props) => {
61
+ const { type, onChangeFilterType, ariaLabel, label, enumType } = props;
62
+ return (_jsx(Button, { appearance: "text", role: "button", "aria-label": ariaLabel, "aria-pressed": type === enumType, onClick: () => onChangeFilterType(enumType), sx: { borderColor: type === enumType ? 'primary' : 'transparent' }, children: _jsx(Text, { colorScheme: "inverse", appearance: "microtext1", children: label }) }));
63
+ };
64
+ const NotificationsFilter = ({ type, onChangeFilterType }) => {
65
+ const t = useTranslate(dictionary);
66
+ return (_jsxs(Flex, { alignItems: "center", sx: { gap: '4px' }, my: "5", children: [_jsx(Button, { "aria-pressed": !type, appearance: "text", role: "button", "aria-label": t.filterAll, onClick: () => onChangeFilterType(), sx: { borderColor: !type ? 'primary' : 'transparent' }, children: _jsx(Text, { colorScheme: "inverse", appearance: "microtext1", children: t.all }) }), _jsx(NotificationFilterButton, { type: type, onChangeFilterType: onChangeFilterType, ariaLabel: t.filterUnread, label: t.unread, enumType: UnreadType.Unread }), _jsx(NotificationFilterButton, { type: type, onChangeFilterType: onChangeFilterType, ariaLabel: t.filterHigh, label: t.high, enumType: NotificationType.High }), _jsx(NotificationFilterButton, { type: type, onChangeFilterType: onChangeFilterType, ariaLabel: t.filterMedium, label: t.medium, enumType: NotificationType.Medium }), _jsx(NotificationFilterButton, { type: type, onChangeFilterType: onChangeFilterType, ariaLabel: t.filterLow, label: t.low, enumType: NotificationType.Low })] }));
67
+ };
68
+ export const NotificationComponent = ({ hasUnreadNotification, onMarkAsRead, notifications, isLoading, error, type, onUpdateType, onClickViewNotifications, onClickViewAll, errorDetails, fetchNextPage, hasNextPage, placeholderComponent, isSummary = false, }) => {
69
+ const t = useTranslate(dictionary);
70
+ const [visible, setVisible] = useState(false);
71
+ const updateType = (updatedType) => {
72
+ onUpdateType(updatedType);
73
+ };
74
+ return (_jsxs(Flex, { sx: { position: 'relative' }, children: [_jsx(IconBox, { size: "md", sx: { cursor: 'pointer' }, onClick: () => {
75
+ onClickViewNotifications();
76
+ setVisible(true);
77
+ }, className: "notificationsTour", children: _jsx(Bell, {}) }), hasUnreadNotification && _jsx(Box, { sx: { position: 'absolute', right: '2px' }, children: _jsx(StatusCircle, { status: 'danger' }) }), _jsx(NotificationsComponent, { className: listToClass(['selection-list', visible ? 'visible' : undefined]), "$scroll": true, "aria-hidden": !visible, children: _jsxs(Flex, { className: "content", p: 5, flexDirection: "column", justifyContent: "space-between", children: [_jsxs(Flex, { children: [_jsxs(Flex, { justifyContent: "space-between", w: "100%", children: [_jsx(Text, { appearance: "h4", children: t.notifications }), _jsx(IconBox, { appearance: "circle", onClick: () => setVisible(false), sx: { border: `1px solid ${theme.color.light[500]}`, cursor: 'pointer' }, children: _jsx(TimesMini, {}) })] }), _jsx(NotificationsFilter, { type: type, onChangeFilterType: updateType }), _jsx(AsyncContent, { error: error, errorDetails: errorDetails, loading: isLoading, children: notifications?.length ? _jsx(StyledBox, { children: _jsx(InfiniteScroll, { dataLength: notifications?.length || 0, next: fetchNextPage, hasMore: hasNextPage, children: _jsx(ScrollView, { direction: "vertical", style: { maxHeight: '630px' }, children: _jsx(Flex, { sx: { gap: '4px' }, mr: "3", children: notifications?.map((item) => (_jsx(NotificationItem, { notification: item, isSummary: isSummary, onClickMarkRead: () => onMarkAsRead(item.id) }, item.id))) }) }) }) })
78
+ :
79
+ _jsx(_Fragment, { children: placeholderComponent }) })] }), _jsx(Flex, { w: "100%", pt: 3, children: _jsx(Button, { size: "sm", sx: { width: '100%' }, colorScheme: "inverse", appearance: "text", onClick: () => {
80
+ setVisible(false);
81
+ onClickViewAll();
82
+ }, children: _jsx(Text, { appearance: "microtext1", children: t.seeAll }) }) })] }) })] }));
83
+ };
84
+ const dictionary = {
85
+ en: {
86
+ notifications: 'Notifications',
87
+ all: 'All',
88
+ filterAll: 'Filter all notifications',
89
+ filterUnread: 'Filter unread notifications',
90
+ filterHigh: 'Filter high notifications',
91
+ filterMedium: 'Filter medium notifications',
92
+ filterLow: 'Filter low notifications',
93
+ unread: 'Unread',
94
+ high: 'High',
95
+ medium: 'Medium',
96
+ low: 'Low',
97
+ seeAll: 'See all notifications',
98
+ },
99
+ pt: {
100
+ notifications: 'Notificações',
101
+ all: 'Todos',
102
+ filterAll: 'Filtrar todas as notificações ',
103
+ filterUnread: 'Filtrar notificações não lidas',
104
+ filterHigh: 'Filtrar notificações criticidade alta',
105
+ filterMedium: 'Filtrar notificações criticidade média',
106
+ filterLow: 'Filtrar notificações criticidade baixa',
107
+ unread: 'Não lidas',
108
+ high: 'Alto',
109
+ medium: 'Médio',
110
+ low: 'Baixo',
111
+ seeAll: 'Ver todas as notificações',
112
+ },
113
+ };
114
+ //# sourceMappingURL=NotificationComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotificationComponent.js","sourceRoot":"","sources":["../../../src/components/Notifications/NotificationComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAC/D,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;AAC7D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AS,EAAE,0BAA0B;QACrC,YAAY,EAAE,6BAA6B;QAC3C,UAAU,EAAE,2BAA2B;QACvC,YAAY,EAAE,6BAA6B;QAC3C,SAAS,EAAE,0BAA0B;QACrC,MAAM,EAAE,QAAQ;QAChB,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,QAAQ;QAChB,GAAG,EAAE,KAAK;QACV,MAAM,EAAE,uBAAuB;KAChC;IACD,EAAE,EAAE;QACF,aAAa,EAAE,cAAc;QAC7B,GAAG,EAAE,OAAO;QACZ,SAAS,EAAE,gCAAgC;QAC3C,YAAY,EAAE,gCAAgC;QAC9C,UAAU,EAAE,uCAAuC;QACnD,YAAY,EAAE,wCAAwC;QACtD,SAAS,EAAE,wCAAwC;QACnD,MAAM,EAAE,WAAW;QACnB,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,OAAO;QACf,GAAG,EAAE,OAAO;QACZ,MAAM,EAAE,2BAA2B;KACpC;CACmB,CAAA"}
@@ -0,0 +1,11 @@
1
+ import { StackspotNotification } from './types.js';
2
+ interface Props {
3
+ notification: StackspotNotification;
4
+ isSummary: boolean;
5
+ }
6
+ interface NotificationItemProps extends Props {
7
+ onClickMarkRead: () => void;
8
+ }
9
+ export declare const NotificationItem: ({ notification, isSummary, onClickMarkRead }: NotificationItemProps) => import("react/jsx-runtime").JSX.Element;
10
+ export {};
11
+ //# sourceMappingURL=NotificationItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotificationItem.d.ts","sourceRoot":"","sources":["../../../src/components/Notifications/NotificationItem.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAe/C,UAAU,KAAK;IACb,YAAY,EAAE,qBAAqB,CAAC;IACpC,SAAS,EAAE,OAAO,CAAC;CACpB;AA8ED,UAAU,qBAAsB,SAAQ,KAAK;IAC3C,eAAe,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED,eAAO,MAAM,gBAAgB,iDAAkD,qBAAqB,4CAQnG,CAAA"}
@@ -0,0 +1,59 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { Button, Flex, IconBox, Text } from '@citric/core';
3
+ import { Envelope, EnvelopeOpen } from '@citric/icons';
4
+ import { theme } from '@stack-spot/portal-theme';
5
+ import { useTranslate } from '@stack-spot/portal-translate';
6
+ import { differenceInDays, parseISO } from 'date-fns';
7
+ import { useAnchorTag } from '../../context/anchor.js';
8
+ import { useDateFormatter } from '../../hooks/date.js';
9
+ import { LazyMarkdown } from '../LazyMarkdown/index.js';
10
+ const styles = {
11
+ item: (color, isRead) => ({
12
+ borderLeft: `2px solid ${color}`,
13
+ opacity: isRead ? 0.5 : 1,
14
+ }),
15
+ };
16
+ const statusToColor = {
17
+ LOW: 'success.500',
18
+ MEDIUM: 'warning.500',
19
+ HIGH: 'danger.500',
20
+ };
21
+ const NotificationHeader = ({ notification, isSummary, onClickMarkRead }) => (_jsxs(Flex, { justifyContent: "space-between", mb: 2, children: [_jsx(Text, { appearance: isSummary ? 'body2' : 'body1', children: notification.title }), _jsx(IconBox, { appearance: "circle", onClick: () => {
22
+ !notification.committed && onClickMarkRead();
23
+ }, sx: { border: `1px solid ${theme.color.light[500]}`, cursor: notification.committed ? 'default' : 'pointer' }, children: notification.committed ? _jsx(Envelope, {}) : _jsx(EnvelopeOpen, {}) })] }));
24
+ const getDaysAgo = (dateString) => {
25
+ const givenDate = parseISO(dateString);
26
+ const today = new Date();
27
+ return differenceInDays(today, givenDate);
28
+ };
29
+ const NotificationContent = ({ notification, isSummary }) => {
30
+ const { formatDate } = useDateFormatter();
31
+ const t = useTranslate(dictionary);
32
+ const daysAgo = getDaysAgo(notification.trigger_at);
33
+ return (_jsxs(_Fragment, { children: [!isSummary && _jsx(Flex, { mt: 4, mb: 3, children: _jsx(LazyMarkdown, { children: notification.description }) }), _jsxs(Flex, { children: [_jsx(Text, { appearance: "microtext1", colorScheme: "light.700", children: t[notification.context] }), _jsx(Text, { appearance: "microtext1", colorScheme: "light.700", mx: "2", children: "\u2022" }), !isSummary && _jsxs(_Fragment, { children: [_jsx(Text, { appearance: "microtext1", colorScheme: "light.700", children: formatDate(notification.created_at) }), _jsx(Text, { appearance: "microtext1", colorScheme: "light.700", mx: "2", children: "\u2022" })] }), _jsx(Text, { appearance: "microtext1", colorScheme: "light.700", children: daysAgo > 0 ? daysAgo + ' ' + t.daysAgo : t.today })] })] }));
34
+ };
35
+ const NotificationFooter = ({ call_to_action, onClickMarkRead }) => {
36
+ const t = useTranslate(dictionary);
37
+ const Link = useAnchorTag();
38
+ return (_jsx(Flex, { mt: "5", children: _jsx(Button, { size: "sm", colorScheme: "inverse", onClick: onClickMarkRead, children: _jsx(Link, { href: call_to_action, children: _jsx(Text, { colorScheme: 'inverse.contrastText', children: t.takeMeThere }) }) }) }));
39
+ };
40
+ export const NotificationItem = ({ notification, isSummary, onClickMarkRead }) => (_jsxs(Flex, { bg: "light.400", p: "3 3 3 5", r: "xs", flexDirection: "column", w: "100%", sx: styles.item(statusToColor[notification.criticality], notification.committed), children: [_jsx(NotificationHeader, { notification: notification, isSummary: isSummary, onClickMarkRead: onClickMarkRead }), _jsx(NotificationContent, { notification: notification, isSummary: isSummary }), notification.call_to_action && _jsx(NotificationFooter, { call_to_action: notification.call_to_action, onClickMarkRead: onClickMarkRead })] }));
41
+ const dictionary = {
42
+ en: {
43
+ takeMeThere: 'Take me there',
44
+ ACCOUNT: 'Account',
45
+ WORKSPACE: 'Workspace',
46
+ STUDIO: 'Studio',
47
+ daysAgo: 'days ago',
48
+ today: 'today',
49
+ },
50
+ pt: {
51
+ takeMeThere: 'Leve-me para lá',
52
+ ACCOUNT: 'Conta',
53
+ WORKSPACE: 'Workspace',
54
+ STUDIO: 'Estúdio',
55
+ daysAgo: 'dias atrás',
56
+ today: 'hoje',
57
+ },
58
+ };
59
+ //# sourceMappingURL=NotificationItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"N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a,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE,YAAY,CAAC,SAAS,CAAC,aAChH,KAAC,kBAAkB,IAAC,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,eAAe,GAAG,EACzG,KAAC,mBAAmB,IAAC,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,GAAI,EACxE,YAAY,CAAC,cAAc,IAAI,KAAC,kBAAkB,IAAC,cAAc,EAAE,YAAY,CAAC,cAAc,EAC7F,eAAe,EAAE,eAAe,GAAI,IACjC,CACR,CAAA;AAED,MAAM,UAAU,GAAG;IACjB,EAAE,EAAE;QACF,WAAW,EAAE,eAAe;QAC5B,OAAO,EAAE,SAAS;QAClB,SAAS,EAAE,WAAW;QACtB,MAAM,EAAE,QAAQ;QAChB,OAAO,EAAE,UAAU;QACnB,KAAK,EAAE,OAAO;KACf;IACD,EAAE,EAAE;QACF,WAAW,EAAE,iBAAiB;QAC9B,OAAO,EAAE,OAAO;QAChB,SAAS,EAAE,WAAW;QACtB,MAAM,EAAE,SAAS;QACjB,OAAO,EAAE,YAAY;QACrB,KAAK,EAAE,MAAM;KACd;CACmB,CAAA"}
@@ -0,0 +1,4 @@
1
+ export { NotificationComponent } from './NotificationComponent.js';
2
+ export { NotificationItem } from './NotificationItem.js';
3
+ export * from './types.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Notifications/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,cAAc,SAAS,CAAA"}
@@ -0,0 +1,4 @@
1
+ export { NotificationComponent } from './NotificationComponent.js';
2
+ export { NotificationItem } from './NotificationItem.js';
3
+ export * from './types.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Notifications/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,cAAc,SAAS,CAAA"}
@@ -0,0 +1,38 @@
1
+ export declare enum NotificationType {
2
+ High = "HIGH",
3
+ Medium = "MEDIUM",
4
+ Low = "LOW"
5
+ }
6
+ export declare enum NotificationContext {
7
+ Account = "ACCOUNT",
8
+ Workspace = "WORKSPACE",
9
+ Studio = "STUDIO"
10
+ }
11
+ export interface StackspotNotification {
12
+ id: string;
13
+ title: string;
14
+ description: string;
15
+ criticality: NotificationType;
16
+ call_to_action?: string;
17
+ committed: boolean;
18
+ context: NotificationContext;
19
+ trigger_at: string;
20
+ created_at: string;
21
+ }
22
+ export type NotificationTypeFilters = NotificationType | UnreadType;
23
+ export interface NotificationFilters {
24
+ filterBy?: 'criticality' | 'context';
25
+ filterValue?: string;
26
+ sort?: string;
27
+ direction?: string;
28
+ page?: any;
29
+ size?: string;
30
+ }
31
+ export interface NotificationCommitted {
32
+ id: string;
33
+ committed: boolean;
34
+ }
35
+ export declare enum UnreadType {
36
+ Unread = "unread"
37
+ }
38
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Notifications/types.ts"],"names":[],"mappings":"AACA,oBAAY,gBAAgB;IAC1B,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,GAAG,QAAQ;CACZ;AAGD,oBAAY,mBAAmB;IAC7B,OAAO,YAAY;IACnB,SAAS,cAAc;IACvB,MAAM,WAAW;CAClB;AAED,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,gBAAgB,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,mBAAmB,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,uBAAuB,GAAG,gBAAgB,GAAG,UAAU,CAAA;AAEnE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,OAAO,CAAC;CACpB;AAGD,oBAAY,UAAU;IACpB,MAAM,WAAW;CAClB"}
@@ -0,0 +1,20 @@
1
+ // eslint-disable-next-line no-restricted-syntax
2
+ export var NotificationType;
3
+ (function (NotificationType) {
4
+ NotificationType["High"] = "HIGH";
5
+ NotificationType["Medium"] = "MEDIUM";
6
+ NotificationType["Low"] = "LOW";
7
+ })(NotificationType || (NotificationType = {}));
8
+ // eslint-disable-next-line no-restricted-syntax
9
+ export var NotificationContext;
10
+ (function (NotificationContext) {
11
+ NotificationContext["Account"] = "ACCOUNT";
12
+ NotificationContext["Workspace"] = "WORKSPACE";
13
+ NotificationContext["Studio"] = "STUDIO";
14
+ })(NotificationContext || (NotificationContext = {}));
15
+ // eslint-disable-next-line no-restricted-syntax
16
+ export var UnreadType;
17
+ (function (UnreadType) {
18
+ UnreadType["Unread"] = "unread";
19
+ })(UnreadType || (UnreadType = {}));
20
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/Notifications/types.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,MAAM,CAAN,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,iCAAa,CAAA;IACb,qCAAiB,CAAA;IACjB,+BAAW,CAAA;AACb,CAAC,EAJW,gBAAgB,KAAhB,gBAAgB,QAI3B;AAED,gDAAgD;AAChD,MAAM,CAAN,IAAY,mBAIX;AAJD,WAAY,mBAAmB;IAC7B,0CAAmB,CAAA;IACnB,8CAAuB,CAAA;IACvB,wCAAiB,CAAA;AACnB,CAAC,EAJW,mBAAmB,KAAnB,mBAAmB,QAI9B;AA8BD,gDAAgD;AAChD,MAAM,CAAN,IAAY,UAEX;AAFD,WAAY,UAAU;IACpB,+BAAiB,CAAA;AACnB,CAAC,EAFW,UAAU,KAAV,UAAU,QAErB"}
@@ -0,0 +1,27 @@
1
+ /// <reference types="react" />
2
+ import { OneOfColorSchemesWithVariants, OneOfPalettesWithVariants } from '@citric/core';
3
+ type Color = OneOfColorSchemesWithVariants | OneOfPalettesWithVariants;
4
+ interface Props {
5
+ /**
6
+ * By default, the ScrollView scrolls in both directions
7
+ */
8
+ direction?: 'horizontal' | 'vertical' | 'both';
9
+ /**
10
+ * The color of the track in the scroll bar (background)
11
+ * light.400 by default
12
+ */
13
+ trackColor?: Color;
14
+ /**
15
+ * The color of the thumb in the scroll bar (foreground)
16
+ * light.700 by default
17
+ */
18
+ thumbColor?: Color;
19
+ /**
20
+ * `auto` to show the scroll-bar only when the content overflows. `scroll` to always show it.
21
+ * `auto` by default
22
+ */
23
+ scrollType?: 'auto' | 'scroll';
24
+ }
25
+ export declare const ScrollView: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, Props>> & string;
26
+ export {};
27
+ //# sourceMappingURL=ScrollView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScrollView.d.ts","sourceRoot":"","sources":["../../src/components/ScrollView.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,6BAA6B,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AAIvF,KAAK,KAAK,GAAG,6BAA6B,GAAG,yBAAyB,CAAA;AAEtE,UAAU,KAAK;IACb;;OAEG;IACH,SAAS,CAAC,EAAE,YAAY,GAAG,UAAU,GAAG,MAAM,CAAC;IAC/C;;;OAGG;IACH,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB;;;OAGG;IACH,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;CAChC;AAQD,eAAO,MAAM,UAAU,0OAgBtB,CAAA"}
@@ -0,0 +1,25 @@
1
+ import { getColor } from '@citric/core/dist/utils/theme.js';
2
+ import { styled } from 'styled-components';
3
+ function getDirectionStyle({ direction = 'both', scrollType = 'auto' }) {
4
+ const x = direction === 'both' || direction === 'horizontal' ? `overflow-x: ${scrollType};` : '';
5
+ const y = direction === 'both' || direction === 'vertical' ? `overflow-x: ${scrollType};` : '';
6
+ return `${x}${y}`;
7
+ }
8
+ export const ScrollView = styled.div `
9
+ ${getDirectionStyle}
10
+ &::-webkit-scrollbar {
11
+ width: 4px;
12
+ height: 4px;
13
+ }
14
+ &::-webkit-scrollbar-track {
15
+ background: ${({ theme, trackColor = 'light.400' }) => getColor(theme, trackColor)};
16
+ border-radius: 2px;
17
+ left: 40px;
18
+ }
19
+ &::-webkit-scrollbar-thumb,
20
+ &::-webkit-scrollbar-thumb:hover {
21
+ background: ${({ theme, thumbColor = 'light.700' }) => getColor(theme, thumbColor)};
22
+ border-radius: 2px;
23
+ }
24
+ `;
25
+ //# sourceMappingURL=ScrollView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScrollView.js","sourceRoot":"","sources":["../../src/components/ScrollView.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAA;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AA0B1C,SAAS,iBAAiB,CAAC,EAAE,SAAS,GAAG,MAAM,EAAE,UAAU,GAAG,MAAM,EAAS;IAC3E,MAAM,CAAC,GAAG,SAAS,KAAK,MAAM,IAAI,SAAS,KAAK,YAAY,CAAC,CAAC,CAAC,eAAe,UAAU,GAAG,CAAC,CAAC,CAAC,EAAE,CAAA;IAChG,MAAM,CAAC,GAAG,SAAS,KAAK,MAAM,IAAI,SAAS,KAAK,UAAU,CAAC,CAAC,CAAC,eAAe,UAAU,GAAG,CAAC,CAAC,CAAC,EAAE,CAAA;IAC9F,OAAO,GAAG,CAAC,GAAG,CAAC,EAAE,CAAA;AACnB,CAAC;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAO;IACvC,iBAAiB;;;;;;kBAMH,CAAC,EAAE,KAAK,EAAE,UAAU,GAAG,WAAW,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;;;;;;kBAMpE,CAAC,EAAE,KAAK,EAAE,UAAU,GAAG,WAAW,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;;;CAGrF,CAAA"}
@@ -0,0 +1,14 @@
1
+ /// <reference types="react" />
2
+ export type Status = 'success' | 'warning' | 'danger' | 'unknown' | 'progress';
3
+ interface Props {
4
+ status?: Status;
5
+ tooltip?: string;
6
+ }
7
+ interface WithTooltip {
8
+ tooltip?: string;
9
+ className?: string;
10
+ style?: React.CSSProperties;
11
+ }
12
+ export declare const StatusCircle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<WithTooltip, Props>> & string & Omit<({ tooltip, className, style }: WithTooltip) => import("react/jsx-runtime").JSX.Element, keyof import("react").Component<any, {}, any>>;
13
+ export {};
14
+ //# sourceMappingURL=StatusCircle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StatusCircle.d.ts","sourceRoot":"","sources":["../../src/components/StatusCircle.tsx"],"names":[],"mappings":";AAOA,MAAM,MAAM,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,CAAA;AAE9E,UAAU,KAAK;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAeD,UAAU,WAAW;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAOD,eAAO,MAAM,YAAY,4LALiC,WAAW,4FAUpE,CAAA"}
@@ -0,0 +1,26 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { getColor } from '@citric/core/dist/utils/theme.js';
3
+ import { Tooltip } from '@citric/ui';
4
+ import styled from 'styled-components';
5
+ const statusToColor = {
6
+ success: 'success.500',
7
+ warning: 'warning.500',
8
+ danger: 'danger.500',
9
+ progress: 'secondary.500',
10
+ unknown: 'light.contrastText',
11
+ };
12
+ function getColorFromStatus(theme, status) {
13
+ const colorName = status && status in statusToColor ? statusToColor[status] : statusToColor.unknown;
14
+ return getColor(theme, colorName);
15
+ }
16
+ const CircleWithTooltip = ({ tooltip, className, style }) => {
17
+ const circle = _jsx("div", { style: style, className: className });
18
+ return tooltip && tooltip.length ? _jsx(Tooltip, { text: tooltip, children: circle }) : circle;
19
+ };
20
+ export const StatusCircle = styled(CircleWithTooltip) `
21
+ background-color: ${({ status, theme }) => getColorFromStatus(theme, status)};
22
+ width: 12px;
23
+ height: 12px;
24
+ border-radius: 50%;
25
+ `;
26
+ //# sourceMappingURL=StatusCircle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StatusCircle.js","sourceRoot":"","sources":["../../src/components/StatusCircle.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAA;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,MAAM,MAAM,mBAAmB,CAAA;AAWtC,MAAM,aAAa,GAA0B;IAC3C,OAAO,EAAE,aAAa;IACtB,OAAO,EAAE,aAAa;IACtB,MAAM,EAAE,YAAY;IACpB,QAAQ,EAAE,eAAe;IACzB,OAAO,EAAE,oBAAoB;CAC9B,CAAA;AAED,SAAS,kBAAkB,CAAC,KAAY,EAAE,MAAe;IACvD,MAAM,SAAS,GAAG,MAAM,IAAI,MAAM,IAAI,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,CAAA;IACnG,OAAO,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;AACnC,CAAC;AAQD,MAAM,iBAAiB,GAAG,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAe,EAAE,EAAE;IACvE,MAAM,MAAM,GAAG,cAAK,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,GAAQ,CAAA;IAC9D,OAAO,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,KAAC,OAAO,IAAC,IAAI,EAAE,OAAO,YAAG,MAAM,GAAW,CAAC,CAAC,CAAC,MAAM,CAAA;AACxF,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAO;sBACtC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,kBAAkB,CAAC,KAAY,EAAE,MAAM,CAAC;;;;CAIpF,CAAA"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @deprecated this hook is prone to errors due to how React Hooks work. Use `useDateFormatter()` instead.
3
+ * @param date
4
+ * @returns the formatted date
5
+ */
6
+ export declare function useFormatDate(date?: string): string | undefined;
7
+ /**
8
+ * @deprecated this hook is prone to errors due to how React Hooks work. Use `useDateFormatter()` instead.
9
+ * @param date
10
+ * @returns the formatted date with its time
11
+ */
12
+ export declare function useFormatDateWithTime(date?: string): string | undefined;
13
+ /**
14
+ * A utility for formatting dates.
15
+ * @param date
16
+ * @returns a date formatter object.
17
+ */
18
+ export declare function useDateFormatter(): {
19
+ formatDate: (date?: string) => string | undefined;
20
+ formatDateWithTime: (date?: string) => string | undefined;
21
+ };
22
+ //# sourceMappingURL=date.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../src/hooks/date.ts"],"names":[],"mappings":"AAWA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,CAAC,EAAE,MAAM,sBAG1C;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,CAAC,EAAE,MAAM,sBAGlD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB;wBAGR,MAAM;gCACE,MAAM;EAErC"}
@@ -0,0 +1,40 @@
1
+ import { useLanguage } from '@stack-spot/portal-translate';
2
+ import { format } from 'date-fns';
3
+ import { ptBR } from 'date-fns/locale';
4
+ function formatDate(date, locale, includeTime) {
5
+ const time = includeTime ? ' HH:mm' : '';
6
+ return locale === 'pt'
7
+ ? format(new Date(date), `dd/MM/yyyy${time}`, { locale: ptBR })
8
+ : format(new Date(date), `MMMM dd yyyy${time}`);
9
+ }
10
+ /**
11
+ * @deprecated this hook is prone to errors due to how React Hooks work. Use `useDateFormatter()` instead.
12
+ * @param date
13
+ * @returns the formatted date
14
+ */
15
+ export function useFormatDate(date) {
16
+ const locale = useLanguage();
17
+ return date ? formatDate(date, locale, false) : undefined;
18
+ }
19
+ /**
20
+ * @deprecated this hook is prone to errors due to how React Hooks work. Use `useDateFormatter()` instead.
21
+ * @param date
22
+ * @returns the formatted date with its time
23
+ */
24
+ export function useFormatDateWithTime(date) {
25
+ const locale = useLanguage();
26
+ return date ? formatDate(date, locale, true) : undefined;
27
+ }
28
+ /**
29
+ * A utility for formatting dates.
30
+ * @param date
31
+ * @returns a date formatter object.
32
+ */
33
+ export function useDateFormatter() {
34
+ const locale = useLanguage();
35
+ return {
36
+ formatDate: (date) => date ? formatDate(date, locale, false) : undefined,
37
+ formatDateWithTime: (date) => date ? formatDate(date, locale, true) : undefined,
38
+ };
39
+ }
40
+ //# sourceMappingURL=date.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date.js","sourceRoot":"","sources":["../../src/hooks/date.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,WAAW,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAEtC,SAAS,UAAU,CAAC,IAAY,EAAE,MAAgB,EAAE,WAAoB;IACtE,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAA;IACxC,OAAO,MAAM,KAAK,IAAI;QACpB,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,aAAa,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;QAC/D,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,eAAe,IAAI,EAAE,CAAC,CAAA;AACnD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,IAAa;IACzC,MAAM,MAAM,GAAG,WAAW,EAAE,CAAA;IAC5B,OAAO,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;AAC3D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAa;IACjD,MAAM,MAAM,GAAG,WAAW,EAAE,CAAA;IAC5B,OAAO,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;AAC1D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,MAAM,GAAG,WAAW,EAAE,CAAA;IAC5B,OAAO;QACL,UAAU,EAAE,CAAC,IAAa,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS;QACjF,kBAAkB,EAAE,CAAC,IAAa,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;KACzF,CAAA;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stack-spot/portal-components",
3
- "version": "1.2.0",
3
+ "version": "1.3.0-rc",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -10,6 +10,10 @@
10
10
  "./ErrorFeedback": "./dist/components/ErrorFeedback.js",
11
11
  "./SelectionList": "./dist/components/SelectionList.js",
12
12
  "./Tour": "./dist/components/Tour/index.js",
13
+ "./LazyMarkdown": "./dist/components/LazyMarkdown/index.js",
14
+ "./Notifications": "./dist/components/Notifications/index.js",
15
+ "./StatusCircle": "./dist/components/StatusCircle.js",
16
+ "./InfiniteScroll": "./dist/components/InfiniteScroll.js",
13
17
  "./svg": "./dist/svg/index.js",
14
18
  "./anchor": "./dist/context/anchor.js"
15
19
  },
@@ -31,6 +35,7 @@
31
35
  "@types/lodash": "^4.14.202",
32
36
  "@types/react": "^18.2.37",
33
37
  "@types/react-dom": "^18.2.15",
38
+ "@types/react-syntax-highlighter": "^15.5.13",
34
39
  "@types/reactour": "^1.18.5",
35
40
  "@typescript-eslint/eslint-plugin": "^6.10.0",
36
41
  "@typescript-eslint/parser": "^6.10.0",
@@ -43,15 +48,21 @@
43
48
  "eslint-plugin-react": "^7.33.2",
44
49
  "eslint-plugin-react-hooks": "^4.6.0",
45
50
  "eslint-plugin-react-refresh": "^0.4.4",
51
+ "react": "18.2.0",
52
+ "react-dom": "18.2.0",
46
53
  "rimraf": "^5.0.7",
47
54
  "styled-components": "6.1.10",
48
55
  "tsc-esm-fix": "^2.20.26",
49
- "typescript": "^5.2.2",
50
- "react": "18.2.0",
51
- "react-dom": "18.2.0"
56
+ "typescript": "^5.2.2"
52
57
  },
53
58
  "dependencies": {
59
+ "date-fns": "^3.6.0",
54
60
  "lodash": "^4.17.21",
55
- "reactour": "^1.19.3"
61
+ "react-infinite-scroll-component": "^6.1.0",
62
+ "react-markdown": "^9.0.1",
63
+ "react-syntax-highlighter": "^15.5.0",
64
+ "reactour": "^1.19.3",
65
+ "rehype-raw": "^7.0.0",
66
+ "remark-gfm": "^4.0.0"
56
67
  }
57
68
  }
@@ -0,0 +1,70 @@
1
+ import { Flex } from '@citric/core'
2
+ import { LoadingCircular } from '@citric/ui'
3
+ import { MutableRefObject, useEffect, useLayoutEffect } from 'react'
4
+
5
+ export interface ErrorProps {
6
+ /**
7
+ * The error component to be rendered in case of error. It should receive error props
8
+ */
9
+ errorComponent: React.FC<{ error: any }>,
10
+ /**
11
+ * The function to report the error.
12
+ */
13
+ reportError: (error: any) => void,
14
+ }
15
+
16
+ interface Props {
17
+ /**
18
+ * Whether or not to show the loading feedback.
19
+ */
20
+ loading: boolean,
21
+ /**
22
+ * A javascript error. Used to show error feedbacks.
23
+ */
24
+ error?: any,
25
+ /**
26
+ * If provided, this element will receive focus as soon as the content is loaded and has no errors.
27
+ * Can be either a React Ref Object or a query selector.
28
+ */
29
+ autofocus?: string | MutableRefObject<HTMLElement>,
30
+ /**
31
+ * The content to show if it's not loading or has errors.
32
+ */
33
+ children: React.ReactNode,
34
+ /**
35
+ * The error details component.
36
+ */
37
+ errorDetails: ErrorProps,
38
+ }
39
+
40
+ export const AsyncContent = ({ loading, error, autofocus, children, errorDetails }: Props) => {
41
+ const ErrorComponent = errorDetails.errorComponent
42
+
43
+ useEffect(() => {
44
+ if (error) {
45
+ errorDetails.reportError(error)
46
+ // eslint-disable-next-line no-console
47
+ console.error(error)
48
+ }
49
+ }, [error])
50
+
51
+ useLayoutEffect(() => {
52
+ if (!loading && !error) {
53
+ typeof autofocus === 'string' ? (document.querySelector(autofocus) as HTMLElement)?.focus?.() : autofocus?.current?.focus()
54
+ }
55
+ }, [loading, error])
56
+
57
+ if (loading) {
58
+ return (
59
+ <Flex alignItems="center" justifyContent="center" flex={1} style={{ padding: '80px' }} data-test-hint="loading">
60
+ <LoadingCircular />
61
+ </Flex>
62
+ )
63
+ }
64
+
65
+ if (error) {
66
+ return <ErrorComponent error={error} />
67
+ }
68
+
69
+ return children
70
+ }
@@ -0,0 +1,13 @@
1
+ import { LoadingCircular } from '@citric/ui'
2
+ import ReactInfiniteScroll, { Props as ReactInfiniteScrollProps } from 'react-infinite-scroll-component'
3
+
4
+ export const InfiniteScroll = ({ style, children, scrollableTarget, ...props }: Omit<ReactInfiniteScrollProps, 'loader'>) => (
5
+ <ReactInfiniteScroll
6
+ loader={<LoadingCircular />}
7
+ scrollableTarget={scrollableTarget || 'page'}
8
+ style={{ overflow: 'hidden', ...style }}
9
+ {...props}
10
+ >
11
+ {children}
12
+ </ReactInfiniteScroll>
13
+ )