@stack-spot/portal-components 0.0.18 → 1.0.1
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/dist/components/BannerWarning.d.ts +6 -0
- package/dist/components/BannerWarning.d.ts.map +1 -1
- package/dist/components/BannerWarning.js +6 -0
- package/dist/components/BannerWarning.js.map +1 -1
- package/dist/components/Breadcrumb/index.d.ts +7 -8
- package/dist/components/Breadcrumb/index.d.ts.map +1 -1
- package/dist/components/Breadcrumb/index.js +7 -6
- package/dist/components/Breadcrumb/index.js.map +1 -1
- package/dist/components/Breadcrumb/styled.d.ts +1 -1
- package/dist/components/Breadcrumb/styled.d.ts.map +1 -1
- package/dist/components/Breadcrumb/styled.js +1 -0
- package/dist/components/Breadcrumb/styled.js.map +1 -1
- package/dist/components/ChatBot.d.ts +7 -0
- package/dist/components/ChatBot.d.ts.map +1 -1
- package/dist/components/ChatBot.js +13 -6
- package/dist/components/ChatBot.js.map +1 -1
- package/dist/components/ErrorFeedback.d.ts +23 -0
- package/dist/components/ErrorFeedback.d.ts.map +1 -0
- package/dist/components/ErrorFeedback.js +73 -0
- package/dist/components/ErrorFeedback.js.map +1 -0
- package/dist/components/SelectionList.d.ts +123 -0
- package/dist/components/SelectionList.d.ts.map +1 -0
- package/dist/components/SelectionList.js +149 -0
- package/dist/components/SelectionList.js.map +1 -0
- package/dist/components/{tour → Tour}/StepContainer.d.ts +16 -0
- package/dist/components/Tour/StepContainer.d.ts.map +1 -0
- package/dist/components/{tour → Tour}/StepContainer.js +4 -0
- package/dist/components/Tour/StepContainer.js.map +1 -0
- package/dist/components/Tour/StepNavigation.d.ts +29 -0
- package/dist/components/Tour/StepNavigation.d.ts.map +1 -0
- package/dist/components/{tour → Tour}/StepNavigation.js +4 -0
- package/dist/components/Tour/StepNavigation.js.map +1 -0
- package/dist/components/Tour/StepTitle.d.ts +17 -0
- package/dist/components/Tour/StepTitle.d.ts.map +1 -0
- package/dist/components/{tour → Tour}/StepTitle.js +4 -0
- package/dist/components/Tour/StepTitle.js.map +1 -0
- package/dist/components/{tour → Tour}/context.d.ts +11 -0
- package/dist/components/Tour/context.d.ts.map +1 -0
- package/dist/components/{tour → Tour}/context.js +11 -0
- package/dist/components/Tour/context.js.map +1 -0
- package/dist/components/{tour → Tour}/index.d.ts +1 -1
- package/dist/components/Tour/index.d.ts.map +1 -0
- package/dist/components/{tour → Tour}/index.js +1 -1
- package/dist/components/Tour/index.js.map +1 -0
- package/dist/components/Tour/utils.d.ts +51 -0
- package/dist/components/Tour/utils.d.ts.map +1 -0
- package/dist/components/Tour/utils.js +60 -0
- package/dist/components/Tour/utils.js.map +1 -0
- package/dist/context/anchor.d.ts +28 -0
- package/dist/context/anchor.d.ts.map +1 -0
- package/dist/context/anchor.js +23 -0
- package/dist/context/anchor.js.map +1 -0
- package/dist/hooks/keyboard.d.ts +33 -0
- package/dist/hooks/keyboard.d.ts.map +1 -0
- package/dist/hooks/keyboard.js +59 -0
- package/dist/hooks/keyboard.js.map +1 -0
- package/dist/hooks/service-now.d.ts +30 -1
- package/dist/hooks/service-now.d.ts.map +1 -1
- package/dist/hooks/service-now.js +54 -15
- package/dist/hooks/service-now.js.map +1 -1
- package/dist/hooks/text.d.ts +10 -0
- package/dist/hooks/text.d.ts.map +1 -0
- package/dist/hooks/text.js +24 -0
- package/dist/hooks/text.js.map +1 -0
- package/dist/hooks/title.d.ts +13 -0
- package/dist/hooks/title.d.ts.map +1 -1
- package/dist/hooks/title.js +13 -0
- package/dist/hooks/title.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/svg/AI.d.ts +9 -0
- package/dist/svg/AI.d.ts.map +1 -0
- package/dist/svg/AI.js +12 -0
- package/dist/svg/AI.js.map +1 -0
- package/dist/svg/EDP.d.ts +9 -0
- package/dist/svg/EDP.d.ts.map +1 -0
- package/dist/svg/EDP.js +8 -0
- package/dist/svg/EDP.js.map +1 -0
- package/dist/svg/Forbidden.d.ts +6 -0
- package/dist/svg/Forbidden.d.ts.map +1 -0
- package/dist/svg/Forbidden.js +4 -0
- package/dist/svg/Forbidden.js.map +1 -0
- package/dist/svg/HUB.d.ts +9 -0
- package/dist/svg/HUB.d.ts.map +1 -0
- package/dist/svg/HUB.js +8 -0
- package/dist/svg/HUB.js.map +1 -0
- package/dist/svg/Logo.d.ts +5 -0
- package/dist/svg/Logo.d.ts.map +1 -0
- package/dist/svg/Logo.js +7 -0
- package/dist/svg/Logo.js.map +1 -0
- package/dist/svg/MiniLogo.d.ts +9 -0
- package/dist/svg/MiniLogo.d.ts.map +1 -0
- package/dist/{components → svg}/MiniLogo.js +3 -0
- package/dist/svg/MiniLogo.js.map +1 -0
- package/dist/{components/MiniLogo.d.ts → svg/NotFound.d.ts} +2 -2
- package/dist/svg/NotFound.d.ts.map +1 -0
- package/dist/svg/NotFound.js +4 -0
- package/dist/svg/NotFound.js.map +1 -0
- package/dist/svg/ServerError.d.ts +6 -0
- package/dist/svg/ServerError.d.ts.map +1 -0
- package/dist/svg/ServerError.js +4 -0
- package/dist/svg/ServerError.js.map +1 -0
- package/dist/svg/Unauthenticated.d.ts +6 -0
- package/dist/svg/Unauthenticated.d.ts.map +1 -0
- package/dist/svg/Unauthenticated.js +4 -0
- package/dist/svg/Unauthenticated.js.map +1 -0
- package/dist/svg/index.d.ts +10 -0
- package/dist/svg/index.d.ts.map +1 -0
- package/dist/svg/index.js +10 -0
- package/dist/svg/index.js.map +1 -0
- package/dist/utils/accessibility.d.ts +73 -0
- package/dist/utils/accessibility.d.ts.map +1 -0
- package/dist/utils/accessibility.js +131 -0
- package/dist/utils/accessibility.js.map +1 -0
- package/dist/utils/cookie.d.ts +34 -0
- package/dist/utils/cookie.d.ts.map +1 -0
- package/dist/utils/cookie.js +64 -0
- package/dist/utils/cookie.js.map +1 -0
- package/package.json +23 -12
- package/readme.md +58 -13
- package/src/components/BannerWarning.tsx +6 -0
- package/src/components/Breadcrumb/index.tsx +15 -13
- package/src/components/Breadcrumb/styled.ts +2 -1
- package/src/components/ChatBot.tsx +15 -7
- package/src/components/ErrorFeedback.tsx +135 -0
- package/src/components/SelectionList.tsx +361 -0
- package/src/components/{tour → Tour}/StepContainer.tsx +16 -0
- package/src/components/{tour → Tour}/StepNavigation.tsx +26 -2
- package/src/components/{tour → Tour}/StepTitle.tsx +11 -1
- package/src/components/{tour → Tour}/context.tsx +11 -0
- package/src/components/{tour → Tour}/index.ts +1 -1
- package/src/components/Tour/utils.tsx +100 -0
- package/src/context/anchor.tsx +37 -0
- package/src/hooks/keyboard.tsx +80 -0
- package/src/hooks/service-now.tsx +60 -16
- package/src/hooks/text.tsx +30 -0
- package/src/hooks/title.tsx +13 -0
- package/src/index.ts +4 -3
- package/src/svg/AI.tsx +41 -0
- package/src/svg/EDP.tsx +39 -0
- package/src/svg/Forbidden.tsx +22 -0
- package/src/svg/HUB.tsx +39 -0
- package/src/svg/Logo.tsx +38 -0
- package/src/{components → svg}/MiniLogo.tsx +3 -0
- package/src/svg/NotFound.tsx +16 -0
- package/src/svg/ServerError.tsx +33 -0
- package/src/svg/Unauthenticated.tsx +16 -0
- package/src/svg/index.ts +9 -0
- package/src/utils/accessibility.ts +141 -0
- package/src/utils/cookie.ts +66 -0
- package/dist/components/Login.d.ts +0 -26
- package/dist/components/Login.d.ts.map +0 -1
- package/dist/components/Login.js +0 -100
- package/dist/components/Login.js.map +0 -1
- package/dist/components/MiniLogo.d.ts.map +0 -1
- package/dist/components/MiniLogo.js.map +0 -1
- package/dist/components/tour/StepContainer.d.ts.map +0 -1
- package/dist/components/tour/StepContainer.js.map +0 -1
- package/dist/components/tour/StepNavigation.d.ts +0 -13
- package/dist/components/tour/StepNavigation.d.ts.map +0 -1
- package/dist/components/tour/StepNavigation.js.map +0 -1
- package/dist/components/tour/StepTitle.d.ts +0 -7
- package/dist/components/tour/StepTitle.d.ts.map +0 -1
- package/dist/components/tour/StepTitle.js.map +0 -1
- package/dist/components/tour/context.d.ts.map +0 -1
- package/dist/components/tour/context.js.map +0 -1
- package/dist/components/tour/index.d.ts.map +0 -1
- package/dist/components/tour/index.js.map +0 -1
- package/dist/components/tour/utils.d.ts +0 -13
- package/dist/components/tour/utils.d.ts.map +0 -1
- package/dist/components/tour/utils.js +0 -43
- package/dist/components/tour/utils.js.map +0 -1
- package/src/components/Login.tsx +0 -157
- package/src/components/tour/utils.tsx +0 -65
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A styled and non-dismissible alert box for showing important warnings for the user.
|
|
3
|
+
*
|
|
4
|
+
* This renders a yellow box with an exclamation icon. The content passed as parameter is placed on the right of the icon.
|
|
5
|
+
* @param props an object containing the content (children) to show inside the alert box.
|
|
6
|
+
*/
|
|
1
7
|
export declare const BannerWarning: ({ children }: {
|
|
2
8
|
children: React.ReactNode;
|
|
3
9
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BannerWarning.d.ts","sourceRoot":"","sources":["../../src/components/BannerWarning.tsx"],"names":[],"mappings":"AAIA,eAAO,MAAM,aAAa;cAA8B,MAAM,SAAS;6CAgBtE,CAAA"}
|
|
1
|
+
{"version":3,"file":"BannerWarning.d.ts","sourceRoot":"","sources":["../../src/components/BannerWarning.tsx"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,eAAO,MAAM,aAAa;cAA8B,MAAM,SAAS;6CAgBtE,CAAA"}
|
|
@@ -2,5 +2,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Flex, IconBox, Text } from '@citric/core';
|
|
3
3
|
import { ExclamationTriangle } from '@citric/icons';
|
|
4
4
|
import { Alert } from '@citric/ui';
|
|
5
|
+
/**
|
|
6
|
+
* A styled and non-dismissible alert box for showing important warnings for the user.
|
|
7
|
+
*
|
|
8
|
+
* This renders a yellow box with an exclamation icon. The content passed as parameter is placed on the right of the icon.
|
|
9
|
+
* @param props an object containing the content (children) to show inside the alert box.
|
|
10
|
+
*/
|
|
5
11
|
export const BannerWarning = ({ children }) => (_jsx(Flex, { sx: { position: 'fixed', top: 0, zIndex: '999', w: 12, left: 0 }, children: _jsxs(Alert, { colorScheme: "warning", sx: { p: 2, w: 12, justifyContent: 'center', height: ['60px', '100px'] }, children: [_jsx(IconBox, { size: "md", colorIcon: "light.500", sx: { display: ['block', 'none'] }, children: _jsx(ExclamationTriangle, {}) }), _jsx(Flex, { sx: { py: [5, 3] }, children: _jsx(Text, { sx: { fontSize: ['16px', '14px'], whiteSpace: 'pre-line' }, colorScheme: "warning.contrastText", children: children }) }), _jsx(IconBox, { size: "md", colorIcon: "light.500", sx: { display: ['block', 'none'] }, children: _jsx(ExclamationTriangle, {}) })] }) }));
|
|
6
12
|
//# sourceMappingURL=BannerWarning.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BannerWarning.js","sourceRoot":"","sources":["../../src/components/BannerWarning.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAElC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAAE,QAAQ,EAAiC,EAAE,EAAE,CAAC,CAC5E,KAAC,IAAI,IAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,YACpE,MAAC,KAAK,IAAC,WAAW,EAAC,SAAS,EAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,MAAM,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AAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,aACnG,KAAC,OAAO,IAAC,IAAI,EAAC,IAAI,EAAC,SAAS,EAAC,WAAW,EAAC,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,YACzE,KAAC,mBAAmB,KAAG,GACf,EACV,KAAC,IAAI,IAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,YACtB,KAAC,IAAI,IAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,WAAW,EAAC,sBAAsB,YACjG,QAAQ,GACJ,GACF,EACP,KAAC,OAAO,IAAC,IAAI,EAAC,IAAI,EAAC,SAAS,EAAC,WAAW,EAAC,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,YACzE,KAAC,mBAAmB,KAAG,GACf,IACJ,GACH,CACR,CAAA"}
|
|
@@ -13,10 +13,6 @@ interface BreadcrumbItem {
|
|
|
13
13
|
* If this route is accessible, the link to it.
|
|
14
14
|
*/
|
|
15
15
|
href?: string;
|
|
16
|
-
/**
|
|
17
|
-
* Anchor from Citron to be used
|
|
18
|
-
*/
|
|
19
|
-
anchorTag?: AnchorComponent;
|
|
20
16
|
}
|
|
21
17
|
interface Props {
|
|
22
18
|
/**
|
|
@@ -37,16 +33,19 @@ interface Props {
|
|
|
37
33
|
*/
|
|
38
34
|
shouldUpdatePageTitle?: boolean;
|
|
39
35
|
/**
|
|
40
|
-
*
|
|
36
|
+
* Key of the current page. If an item has this key, it won't be rendered as a link and will be marked as active.
|
|
41
37
|
*/
|
|
42
|
-
|
|
38
|
+
currentPageKey?: string;
|
|
39
|
+
}
|
|
40
|
+
interface ItemProps extends Pick<Props, 'currentPageKey'> {
|
|
41
|
+
item: BreadcrumbItem;
|
|
43
42
|
}
|
|
44
|
-
declare const BreadcrumbItem: ({ label, href,
|
|
43
|
+
declare const BreadcrumbItem: ({ item: { label, href, key }, currentPageKey }: ItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
45
44
|
/**
|
|
46
45
|
* Builds a breadcrumb navigator based on the items passed in the properties.
|
|
47
46
|
*
|
|
48
47
|
* If the breadcrumb is obtained asynchronously, pass `isLoading = true` in order to show a loading feedback.
|
|
49
48
|
*/
|
|
50
|
-
export declare const BreadcrumbList: ({ items, isLoading, shouldUpdatePageTitle,
|
|
49
|
+
export declare const BreadcrumbList: ({ items, isLoading, shouldUpdatePageTitle, currentPageKey }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
51
50
|
export {};
|
|
52
51
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Breadcrumb/index.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Breadcrumb/index.tsx"],"names":[],"mappings":";AAQA,MAAM,MAAM,eAAe,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,KAAK,KAAK,CAAC,YAAY,CAAA;AAE1G,UAAU,cAAc;IACtB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,UAAU,KAAK;IACb;;OAEG;IACH,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;;;OAOG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,UAAU,SAAU,SAAQ,IAAI,CAAC,KAAK,EAAE,gBAAgB,CAAC;IACvD,IAAI,EAAE,cAAc,CAAC;CACtB;AAED,QAAA,MAAM,cAAc,mDAAoD,SAAS,4CAKhF,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,gEAAiE,KAAK,4CAUhG,CAAA"}
|
|
@@ -3,21 +3,22 @@ import { Text } from '@citric/core';
|
|
|
3
3
|
import { Skeleton } from '@citric/ui';
|
|
4
4
|
import { last } from 'lodash';
|
|
5
5
|
import { useEffect, useMemo } from 'react';
|
|
6
|
+
import { useAnchorTag } from '../../context/anchor.js';
|
|
6
7
|
import { titleEffect } from '../../hooks/title.js';
|
|
7
8
|
import { Box } from './styled.js';
|
|
8
|
-
const BreadcrumbItem = ({ label, href,
|
|
9
|
+
const BreadcrumbItem = ({ item: { label, href, key }, currentPageKey }) => {
|
|
9
10
|
const text = _jsx(Text, { appearance: "breadcrumb", children: label });
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
return
|
|
11
|
+
const Link = useAnchorTag();
|
|
12
|
+
const shouldBeLink = href && currentPageKey != key;
|
|
13
|
+
return _jsx("li", { children: shouldBeLink ? _jsx(Link, { href: href, children: text }) : text });
|
|
13
14
|
};
|
|
14
15
|
/**
|
|
15
16
|
* Builds a breadcrumb navigator based on the items passed in the properties.
|
|
16
17
|
*
|
|
17
18
|
* If the breadcrumb is obtained asynchronously, pass `isLoading = true` in order to show a loading feedback.
|
|
18
19
|
*/
|
|
19
|
-
export const BreadcrumbList = ({ items, isLoading, shouldUpdatePageTitle,
|
|
20
|
-
const listItems = useMemo(() => items.map(item => _jsx(
|
|
20
|
+
export const BreadcrumbList = ({ items, isLoading, shouldUpdatePageTitle, currentPageKey }) => {
|
|
21
|
+
const listItems = useMemo(() => items.map(item => _jsx(BreadcrumbItem, { item: item, currentPageKey: currentPageKey }, item.key || item.label)), [items]);
|
|
21
22
|
useEffect(() => {
|
|
22
23
|
const title = last(items)?.label;
|
|
23
24
|
if (shouldUpdatePageTitle && title && !isLoading)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Breadcrumb/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AA+C9B,MAAM,cAAc,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Breadcrumb/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AA+C9B,MAAM,cAAc,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,cAAc,EAAa,EAAE,EAAE;IACnF,MAAM,IAAI,GAAG,KAAC,IAAI,IAAC,UAAU,EAAC,YAAY,YAAE,KAAK,GAAQ,CAAA;IACzD,MAAM,IAAI,GAAG,YAAY,EAAE,CAAA;IAC3B,MAAM,YAAY,GAAG,IAAI,IAAI,cAAc,IAAI,GAAG,CAAA;IAClD,OAAO,uBAAK,YAAY,CAAC,CAAC,CAAC,KAAC,IAAI,IAAC,IAAI,EAAE,IAAI,YAAG,IAAI,GAAQ,CAAC,CAAC,CAAC,IAAI,GAAM,CAAA;AACzE,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,qBAAqB,EAAE,cAAc,EAAS,EAAE,EAAE;IACnG,MAAM,SAAS,GAAG,OAAO,CACvB,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,KAAC,cAAc,IAA8B,IAAI,EAAE,IAAI,EAAE,cAAc,EAAE,cAAc,IAAlE,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,KAAK,CAAgD,CAAC,EACpH,CAAC,KAAK,CAAC,CACR,CAAA;IACD,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,CAAA;QAChC,IAAI,qBAAqB,IAAI,KAAK,IAAI,CAAC,SAAS;YAAE,OAAO,WAAW,CAAC,KAAK,CAAC,CAAA;IAC7E,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAA;IACtB,OAAO,KAAC,GAAG,cAAE,SAAS,CAAC,CAAC,CAAC,KAAC,QAAQ,IAAC,MAAM,EAAC,MAAM,GAAG,CAAC,CAAC,CAAC,uBAAK,SAAS,GAAM,GAAO,CAAA;AACnF,CAAC,CAAA"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const Box:
|
|
2
|
+
export declare const Box: React.FC<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
3
3
|
//# sourceMappingURL=styled.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styled.d.ts","sourceRoot":"","sources":["../../../src/components/Breadcrumb/styled.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"styled.d.ts","sourceRoot":"","sources":["../../../src/components/Breadcrumb/styled.ts"],"names":[],"mappings":";AAKA,eAAO,MAAM,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC,CA+BjG,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getFontAppearance } from '@citric/core/dist/utils/theme.js';
|
|
2
2
|
import { theme } from '@stack-spot/portal-theme';
|
|
3
3
|
import { styled } from 'styled-components';
|
|
4
|
+
// the type below should be inferred, but a bug in TS+PNPM prevents it: https://github.com/microsoft/TypeScript/issues/42873
|
|
4
5
|
export const Box = styled.nav `
|
|
5
6
|
margin-bottom: 24px;
|
|
6
7
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styled.js","sourceRoot":"","sources":["../../../src/components/Breadcrumb/styled.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE1C,MAAM,CAAC,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"styled.js","sourceRoot":"","sources":["../../../src/components/Breadcrumb/styled.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE1C,4HAA4H;AAC5H,MAAM,CAAC,MAAM,GAAG,GAAsF,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;cAclG,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,iBAAiB,CAAC,KAAY,EAAE,YAAY,CAAQ;;eAElE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC;;;;;;;;;aAS1B,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC;;;eAGtB,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,YAAY;;;CAG5C,CAAA"}
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
+
export declare const CHAT_BUTTON_ID = "service-now-button";
|
|
2
|
+
export declare const CHAT_BUTTON_WRAPPER_ID = "service-now-content";
|
|
3
|
+
/**
|
|
4
|
+
* A button for opening or closing the service-now chat window.
|
|
5
|
+
*
|
|
6
|
+
* This is a circular orange button with a chat icon if the chat window is closed or a close icon if the chat window is open.
|
|
7
|
+
*/
|
|
1
8
|
export declare const ChatBot: () => import("react/jsx-runtime").JSX.Element;
|
|
2
9
|
//# sourceMappingURL=ChatBot.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatBot.d.ts","sourceRoot":"","sources":["../../src/components/ChatBot.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ChatBot.d.ts","sourceRoot":"","sources":["../../src/components/ChatBot.tsx"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc,uBAAuB,CAAA;AAClD,eAAO,MAAM,sBAAsB,wBAAwB,CAAA;AA4C3D;;;;GAIG;AACH,eAAO,MAAM,OAAO,+CA8BnB,CAAA"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Button, Flex, IconBox } from '@citric/core';
|
|
3
3
|
import { QuestionAnswer, Times } from '@citric/icons';
|
|
4
|
-
import {
|
|
4
|
+
import { getServiceNowLauncher, hideChatWindow, showChatWindow } from '../hooks/service-now.js';
|
|
5
|
+
export const CHAT_BUTTON_ID = 'service-now-button';
|
|
6
|
+
export const CHAT_BUTTON_WRAPPER_ID = 'service-now-content';
|
|
5
7
|
const styles = {
|
|
6
8
|
content: {
|
|
7
9
|
position: 'fixed',
|
|
@@ -43,19 +45,24 @@ const styles = {
|
|
|
43
45
|
transform: 'translate(-50%, -50%)',
|
|
44
46
|
},
|
|
45
47
|
};
|
|
48
|
+
/**
|
|
49
|
+
* A button for opening or closing the service-now chat window.
|
|
50
|
+
*
|
|
51
|
+
* This is a circular orange button with a chat icon if the chat window is closed or a close icon if the chat window is open.
|
|
52
|
+
*/
|
|
46
53
|
export const ChatBot = () => {
|
|
47
54
|
const handleOpenChatBot = () => {
|
|
48
55
|
const chatIframe = getServiceNowLauncher();
|
|
49
56
|
if (chatIframe) {
|
|
50
|
-
const
|
|
51
|
-
if (
|
|
52
|
-
|
|
57
|
+
const isVisible = chatIframe.classList.contains('show');
|
|
58
|
+
if (isVisible) {
|
|
59
|
+
hideChatWindow();
|
|
53
60
|
}
|
|
54
61
|
else {
|
|
55
|
-
|
|
62
|
+
showChatWindow();
|
|
56
63
|
}
|
|
57
64
|
}
|
|
58
65
|
};
|
|
59
|
-
return (_jsx(Flex, { id:
|
|
66
|
+
return (_jsx(Flex, { id: CHAT_BUTTON_WRAPPER_ID, sx: styles.content, children: _jsx(Button, { onClick: handleOpenChatBot, id: CHAT_BUTTON_ID, sx: styles.button, children: _jsxs(IconBox, { colorIcon: "light.400", sx: styles.icon, size: "lg", children: [_jsx(Times, { className: "times" }), _jsx(QuestionAnswer, { className: "question" })] }) }) }));
|
|
60
67
|
};
|
|
61
68
|
//# sourceMappingURL=ChatBot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatBot.js","sourceRoot":"","sources":["../../src/components/ChatBot.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAU,MAAM,cAAc,CAAA;AAC5D,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,e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EAAE;IAC1B,MAAM,iBAAiB,GAAG,GAAG,EAAE;QAC7B,MAAM,UAAU,GAAG,qBAAqB,EAAE,CAAA;QAC1C,IAAI,UAAU,EAAE;YACd,MAAM,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;YACvD,IAAI,SAAS,EAAE;gBACb,cAAc,EAAE,CAAA;aACjB;iBAAM;gBACL,cAAc,EAAE,CAAA;aACjB;SACF;IACH,CAAC,CAAA;IAED,OAAO,CACL,KAAC,IAAI,IAAC,EAAE,EAAE,sBAAsB,EAAE,EAAE,EAAE,MAAM,CAAC,OAAO,YAClD,KAAC,MAAM,IACL,OAAO,EAAE,iBAAiB,EAC1B,EAAE,EAAE,cAAc,EAClB,EAAE,EAAE,MAAM,CAAC,MAAM,YAEjB,MAAC,OAAO,IACN,SAAS,EAAC,WAAW,EACrB,EAAE,EAAE,MAAM,CAAC,IAAI,EACf,IAAI,EAAC,IAAI,aACT,KAAC,KAAK,IAAC,SAAS,EAAC,OAAO,GAAG,EAC3B,KAAC,cAAc,IAAC,SAAS,EAAC,UAAU,GAAG,IAC/B,GACH,GACJ,CACR,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface ErrorDescription {
|
|
2
|
+
/**
|
|
3
|
+
* The HTTP Error code if this is a network error.
|
|
4
|
+
*/
|
|
5
|
+
code?: number;
|
|
6
|
+
/**
|
|
7
|
+
* The error message.
|
|
8
|
+
*/
|
|
9
|
+
message?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Whether or not the application is in debug mode.
|
|
12
|
+
*/
|
|
13
|
+
debug?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A box with an icon and an error message. This is used for giving error feedbacks to the user.
|
|
17
|
+
*
|
|
18
|
+
* If the application is in debug mode, a button is rendered to show the error message.
|
|
19
|
+
*
|
|
20
|
+
* @param options the error code, the error message and whether or not the application is in debug mode.
|
|
21
|
+
*/
|
|
22
|
+
export declare const ErrorFeedback: ({ code, message, debug }: ErrorDescription) => import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
//# sourceMappingURL=ErrorFeedback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorFeedback.d.ts","sourceRoot":"","sources":["../../src/components/ErrorFeedback.tsx"],"names":[],"mappings":"AAoBA,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,6BAAkC,gBAAgB,4CAgD3E,CAAA"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Button, Container, Flex, LinkBox, Text } from '@citric/core';
|
|
3
|
+
import { useTranslate } from '@stack-spot/portal-translate';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
import { Forbidden } from '../svg/Forbidden.js';
|
|
6
|
+
import { Logo } from '../svg/Logo.js';
|
|
7
|
+
import { NotFound } from '../svg/NotFound.js';
|
|
8
|
+
import { ServerError } from '../svg/ServerError.js';
|
|
9
|
+
import { Unauthenticated } from '../svg/Unauthenticated.js';
|
|
10
|
+
const imageStyle = {
|
|
11
|
+
width: '200px',
|
|
12
|
+
height: '200px',
|
|
13
|
+
};
|
|
14
|
+
const imageMap = {
|
|
15
|
+
401: _jsx(Unauthenticated, { style: imageStyle }),
|
|
16
|
+
403: _jsx(Forbidden, { style: imageStyle }),
|
|
17
|
+
404: _jsx(NotFound, { style: imageStyle }),
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* A box with an icon and an error message. This is used for giving error feedbacks to the user.
|
|
21
|
+
*
|
|
22
|
+
* If the application is in debug mode, a button is rendered to show the error message.
|
|
23
|
+
*
|
|
24
|
+
* @param options the error code, the error message and whether or not the application is in debug mode.
|
|
25
|
+
*/
|
|
26
|
+
export const ErrorFeedback = ({ code = 0, message, debug }) => {
|
|
27
|
+
const t = useTranslate(dictionary);
|
|
28
|
+
const [showDetails, setShowDetails] = useState(false);
|
|
29
|
+
return (_jsx(Box, { bg: "light.400", children: _jsx(Container, { children: _jsxs(Flex, { alignItems: "center", sx: { padding: 12 }, children: [_jsx(Box, { width: 5, sx: { display: ['block', 'none'] }, children: _jsx(Flex, { justifyContent: "flex-end", pr: 20, children: imageMap[code] ?? _jsx(ServerError, { style: imageStyle }) }) }), _jsxs(Box, { width: [7, 12], children: [_jsx(LinkBox, { href: "/", children: _jsx(Logo, { style: { width: '130px', height: '30px' } }) }), _jsxs(Box, { w: [7, 12], children: [_jsxs(Text, { appearance: "h4", mt: 5, colorScheme: "inverse", children: [code ? `${code}. ` : '', _jsx(Text, { appearance: "h4", as: "span", colorScheme: "light.700", children: t[`${code}.title`] })] }), _jsx(Text, { appearance: "body1", mt: 5, colorScheme: "inverse", children: t[`${code}.description`] }), _jsx(Text, { appearance: "body1", colorScheme: "light.700", mt: 1, children: t[`${code}.help`] }), debug && message && (_jsx(Button, { appearance: "outlined", colorScheme: "inverse", onClick: () => setShowDetails(v => !v), children: showDetails ? t.hideDetails : t.showDetails })), showDetails && (_jsx(Box, { bg: "danger", mt: 8, p: 4, sx: { borderRadius: '5px' }, children: _jsx(Text, { appearance: "microtext1", colorScheme: "danger.contrastText", children: message }) }))] })] })] }) }) }));
|
|
30
|
+
};
|
|
31
|
+
const dictionary = {
|
|
32
|
+
en: {
|
|
33
|
+
altLogo: 'Logo Stackspot',
|
|
34
|
+
'0.title': 'Unknown client error',
|
|
35
|
+
'0.description': 'An unknown error happened while trying to load the resource.',
|
|
36
|
+
'0.help': 'Reload the page and, if it still doesn\'t work, report the error the Stackspot team.',
|
|
37
|
+
'401.title': 'Not authorized',
|
|
38
|
+
'401.description': 'There was a failure loading credentials for this page.',
|
|
39
|
+
'401.help': 'Check if the URL is correct or clear your cache and cookies from your browser and try again.',
|
|
40
|
+
'403.title': 'Private access',
|
|
41
|
+
'403.description': 'The page you have tried to visit is private.',
|
|
42
|
+
'403.help': 'Log in with another account or request access from the person who manages your organization.',
|
|
43
|
+
'404.title': 'Resource not found',
|
|
44
|
+
'404.description': 'This resource no longer exists.',
|
|
45
|
+
'404.help': 'Please try again or request a new URL from the person who manages your organization.',
|
|
46
|
+
'500.title': 'Server error',
|
|
47
|
+
'500.description': "We have identified a problem with the server, but don't worry. We are already investigating what happened.",
|
|
48
|
+
'500.help': 'Please try again after a few minutes.',
|
|
49
|
+
showDetails: 'Show Details',
|
|
50
|
+
hideDetails: 'Hide Details',
|
|
51
|
+
},
|
|
52
|
+
pt: {
|
|
53
|
+
altLogo: 'Logo Stackspot',
|
|
54
|
+
'0.title': 'Erro desconhecido (cliente)',
|
|
55
|
+
'0.description': 'Um erro desconhecido aconteceu ao carregar o recurso',
|
|
56
|
+
'0.help': 'Recarregue a página e, se ainda não funcionar, reporte o problema para o time da Stackspot.',
|
|
57
|
+
'401.title': 'Não autorizado',
|
|
58
|
+
'401.description': 'Houve uma falha no carregamento de credenciais dessa página.',
|
|
59
|
+
'401.help': 'Verifique se a URL está correta ou limpe o cache e os cookies de seu navegador e tente novamente.',
|
|
60
|
+
'403.title': 'Acesso privado',
|
|
61
|
+
'403.description': '"A página que você tentou visualizar é particular."',
|
|
62
|
+
'403.help': 'Solicite acesso com o administrador da sua organização.',
|
|
63
|
+
'404.title': 'Recurso não encontrado',
|
|
64
|
+
'404.description': 'Este recurso não existe mais.',
|
|
65
|
+
'404.help': 'Tente novamente ou fale com o administrador da sua organização.',
|
|
66
|
+
'500.title': 'Erro ao exibir o recurso',
|
|
67
|
+
'500.description': 'Mas não se preocupe, já estamos investigando o que aconteceu.',
|
|
68
|
+
'500.help': 'Tente novamente após alguns minutos.',
|
|
69
|
+
showDetails: 'Ver Detalhes',
|
|
70
|
+
hideDetails: 'Esconder Detalhes',
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=ErrorFeedback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorFeedback.js","sourceRoot":"","sources":["../../src/components/ErrorFeedback.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAC1E,OAAO,EAAc,YAAY,EAAE,MAAM,8BAA8B,CAAA;AACvE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAExD,MAAM,UAAU,GAAwB;IACtC,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,OAAO;CAChB,CAAA;AAED,MAAM,QAAQ,GAAuC;IACnD,GAAG,EAAE,KAAC,eAAe,IAAC,KAAK,EAAE,UAAU,GAAI;IAC3C,GAAG,EAAE,KAAC,SAAS,IAAC,KAAK,EAAE,UAAU,GAAI;IACrC,GAAG,EAAE,KAAC,QAAQ,IAAC,KAAK,EAAE,UAAU,GAAI;CACrC,CAAA;AAiBD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,OAAO,EAAE,KAAK,EAAoB,EAAE,EAAE;IAC9E,MAAM,CAAC,GAAG,YAAY,CAAC,UAAU,CAA2B,CAAA;IAC5D,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAA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AAO,EAAE,gBAAgB;QACzB,SAAS,EAAE,6BAA6B;QACxC,eAAe,EAAE,sDAAsD;QACvE,QAAQ,EAAE,6FAA6F;QACvG,WAAW,EAAE,gBAAgB;QAC7B,iBAAiB,EAAE,8DAA8D;QACjF,UAAU,EAAE,mGAAmG;QAC/G,WAAW,EAAE,gBAAgB;QAC7B,iBAAiB,EAAE,qDAAqD;QACxE,UAAU,EAAE,yDAAyD;QACrE,WAAW,EAAE,wBAAwB;QACrC,iBAAiB,EAAE,+BAA+B;QAClD,UAAU,EAAE,iEAAiE;QAC7E,WAAW,EAAE,0BAA0B;QACvC,iBAAiB,EAAE,+DAA+D;QAClF,UAAU,EAAE,sCAAsC;QAClD,WAAW,EAAE,cAAc;QAC3B,WAAW,EAAE,mBAAmB;KACjC;CACmB,CAAA"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { WithStyle } from '@stack-spot/portal-theme';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
3
|
+
interface CustomLabel {
|
|
4
|
+
/**
|
|
5
|
+
* A unique identifier for this label. This is also used to read this label to screen readers.
|
|
6
|
+
*/
|
|
7
|
+
id: string;
|
|
8
|
+
/**
|
|
9
|
+
* A custom label that can be made up of any React component.
|
|
10
|
+
*/
|
|
11
|
+
element: React.ReactNode;
|
|
12
|
+
}
|
|
13
|
+
export interface Action {
|
|
14
|
+
/**
|
|
15
|
+
* The label of the action.
|
|
16
|
+
*/
|
|
17
|
+
label: string | CustomLabel;
|
|
18
|
+
/**
|
|
19
|
+
* Function to run on a click.
|
|
20
|
+
*/
|
|
21
|
+
onClick?: () => void;
|
|
22
|
+
/**
|
|
23
|
+
* URL to open on a click.
|
|
24
|
+
*/
|
|
25
|
+
href?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Target of the URL to open.
|
|
28
|
+
*/
|
|
29
|
+
target?: React.AnchorHTMLAttributes<HTMLAnchorElement>['target'];
|
|
30
|
+
}
|
|
31
|
+
interface ItemWithIcon {
|
|
32
|
+
/**
|
|
33
|
+
* An Icon to appear at the left of the item.
|
|
34
|
+
*/
|
|
35
|
+
icon?: React.ReactElement;
|
|
36
|
+
/**
|
|
37
|
+
* An Icon to appear at the right of the item.
|
|
38
|
+
*/
|
|
39
|
+
iconRight?: React.ReactElement;
|
|
40
|
+
}
|
|
41
|
+
export interface ListAction extends ItemWithIcon, Action {
|
|
42
|
+
/**
|
|
43
|
+
* Whether or not this option is currently active.
|
|
44
|
+
*/
|
|
45
|
+
active?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Icon to render when this option is active.
|
|
48
|
+
*/
|
|
49
|
+
iconActive?: React.ReactElement;
|
|
50
|
+
}
|
|
51
|
+
interface ListGroup {
|
|
52
|
+
/**
|
|
53
|
+
* If this group is rendered as a section with its items right below it or a collapsible, which requires a click to open a submenu.
|
|
54
|
+
*/
|
|
55
|
+
type?: 'section' | 'collapsible';
|
|
56
|
+
/**
|
|
57
|
+
* The items of this group.
|
|
58
|
+
*/
|
|
59
|
+
children: ListItem[];
|
|
60
|
+
}
|
|
61
|
+
interface ListSection extends ListGroup {
|
|
62
|
+
type: 'section';
|
|
63
|
+
/**
|
|
64
|
+
* The section's title.
|
|
65
|
+
*/
|
|
66
|
+
label?: string;
|
|
67
|
+
}
|
|
68
|
+
interface ListCollapsible extends ListGroup, ItemWithIcon {
|
|
69
|
+
type?: 'collapsible';
|
|
70
|
+
/**
|
|
71
|
+
* The title of the collapsible menu.
|
|
72
|
+
*/
|
|
73
|
+
label: string;
|
|
74
|
+
}
|
|
75
|
+
type ListItem = ListSection | ListCollapsible | ListAction;
|
|
76
|
+
export interface SelectionListProps extends WithStyle {
|
|
77
|
+
/**
|
|
78
|
+
* The id of this selection list. This is important for accessibility. Be sure to link it to the aria-controls tag of the element who
|
|
79
|
+
* controls the visibility of this selection list.
|
|
80
|
+
*/
|
|
81
|
+
id: string;
|
|
82
|
+
/**
|
|
83
|
+
* Whether or not the selection list is visible.
|
|
84
|
+
*/
|
|
85
|
+
visible?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* The options in the selection list.
|
|
88
|
+
*/
|
|
89
|
+
items: ListItem[];
|
|
90
|
+
/**
|
|
91
|
+
* Function to run when the selection list is hidden/closed.
|
|
92
|
+
*/
|
|
93
|
+
onHide?: () => void;
|
|
94
|
+
/**
|
|
95
|
+
* The maximum height for the selection list.
|
|
96
|
+
* @default "300px"
|
|
97
|
+
*/
|
|
98
|
+
maxHeight?: string;
|
|
99
|
+
/**
|
|
100
|
+
* A React element to render right before the items.
|
|
101
|
+
*/
|
|
102
|
+
before?: ReactElement;
|
|
103
|
+
/**
|
|
104
|
+
* A React element to render right after the items.
|
|
105
|
+
*/
|
|
106
|
+
after?: ReactElement;
|
|
107
|
+
/**
|
|
108
|
+
* Whether or not this list should be scrollable.
|
|
109
|
+
*/
|
|
110
|
+
scroll?: boolean;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Renders a component that allows the selection of one item. The list is show/hidden according to the prop `visible`.
|
|
114
|
+
*
|
|
115
|
+
* The items in this list can be grouped into multiple sections. Sections may be displayed on a column (section) or might replace the
|
|
116
|
+
* current list of options with another list of options (collapsible).
|
|
117
|
+
*
|
|
118
|
+
* This component implements keyboard controls and accessibility features.
|
|
119
|
+
* @param props the component's props {@link SelectionListProps}.
|
|
120
|
+
*/
|
|
121
|
+
export declare const SelectionList: ({ id, items, className, style, visible, maxHeight, onHide, before, after, scroll, }: SelectionListProps) => import("react/jsx-runtime").JSX.Element;
|
|
122
|
+
export {};
|
|
123
|
+
//# sourceMappingURL=SelectionList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectionList.d.ts","sourceRoot":"","sources":["../../src/components/SelectionList.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAsB,MAAM,0BAA0B,CAAA;AAExE,OAAO,EAAE,YAAY,EAA6C,MAAM,OAAO,CAAA;AAK/E,UAAU,WAAW;IACnB;;OAEG;IACH,EA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AO,CAAC;IAClB;;OAEG;IACH,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB;;OAEG;IACH,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAwHD;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,wFAEvB,kBAAkB,4CAqFpB,CAAA"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Flex, IconBox, Text } from '@citric/core';
|
|
3
|
+
import { ArrowLeft, Check, ChevronRight } from '@citric/icons';
|
|
4
|
+
import { IconButton } from '@citric/ui';
|
|
5
|
+
import { listToClass, theme } from '@stack-spot/portal-theme';
|
|
6
|
+
import { useTranslate } from '@stack-spot/portal-translate';
|
|
7
|
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
8
|
+
import { styled } from 'styled-components';
|
|
9
|
+
import { useAnchorTag } from '../context/anchor.js';
|
|
10
|
+
import { useKeyboardControls } from '../hooks/keyboard.js';
|
|
11
|
+
const ANIMATION_DURATION_MS = 300;
|
|
12
|
+
const MAX_HEIGHT_TRANSITION = `max-height ease-in ${ANIMATION_DURATION_MS / 1000}s`;
|
|
13
|
+
const SelectionBox = styled.div `
|
|
14
|
+
max-height: 0;
|
|
15
|
+
overflow-y: ${({ $scroll }) => $scroll ? 'auto' : 'hidden'};
|
|
16
|
+
overflow-x: hidden;
|
|
17
|
+
transition: ${MAX_HEIGHT_TRANSITION}, visibility 0s ${ANIMATION_DURATION_MS / 1000}s;
|
|
18
|
+
z-index: 1;
|
|
19
|
+
box-shadow: 4px 4px 48px #000;
|
|
20
|
+
border-radius: 0.5rem;
|
|
21
|
+
visibility: hidden;
|
|
22
|
+
|
|
23
|
+
.selection-list-content {
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
background: ${theme.color.light['500']};
|
|
27
|
+
border-radius: 0.5rem;
|
|
28
|
+
border: 1px solid ${theme.color.light['600']};
|
|
29
|
+
background-color: ${theme.color.light['300']};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.section-title, li > a {
|
|
33
|
+
height: 40px;
|
|
34
|
+
padding: 0 8px;
|
|
35
|
+
display: flex;
|
|
36
|
+
flex-direction: row;
|
|
37
|
+
align-items: center;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
li > a {
|
|
41
|
+
gap: 4px;
|
|
42
|
+
transition: background-color 0.2s;
|
|
43
|
+
&:hover, &:focus {
|
|
44
|
+
background: ${theme.color.light['400']};
|
|
45
|
+
}
|
|
46
|
+
.label {
|
|
47
|
+
flex: 1;
|
|
48
|
+
white-space: nowrap;
|
|
49
|
+
overflow: hidden;
|
|
50
|
+
text-overflow: ellipsis;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
li.section {
|
|
55
|
+
border-bottom: 2px solid ${theme.color.light['600']};
|
|
56
|
+
&:last-child {
|
|
57
|
+
border-bottom: none;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&.visible {
|
|
62
|
+
max-height: ${({ $maxHeight }) => $maxHeight};
|
|
63
|
+
visibility: visible;
|
|
64
|
+
transition: ${MAX_HEIGHT_TRANSITION};
|
|
65
|
+
}
|
|
66
|
+
`;
|
|
67
|
+
function renderAction({ label, href, onClick, icon, iconRight, active, target, iconActive = _jsx(Check, {}), }, { onClose, Link }) {
|
|
68
|
+
function handleClick() {
|
|
69
|
+
onClick?.();
|
|
70
|
+
onClose?.();
|
|
71
|
+
}
|
|
72
|
+
const isTextLabel = typeof label === 'string';
|
|
73
|
+
return (_jsx("li", { className: "action", children: _jsxs(Link, { href: href, onClick: handleClick, target: target, tabIndex: 0, "aria-selected": active, children: [icon && _jsx(IconBox, { children: icon }), isTextLabel ? _jsx(Text, { appearance: "body2", className: "label", children: label }) : label.element, iconRight && _jsx(IconBox, { children: iconRight }), active && _jsx(IconBox, { children: iconActive })] }) }, isTextLabel ? label : label.id));
|
|
74
|
+
}
|
|
75
|
+
function renderCollapsible({ label, icon, iconRight, children }, { setCurrent, controllerId, Link }) {
|
|
76
|
+
function handleClick(ev) {
|
|
77
|
+
// accessibility: this will tell the screen reader the section was expanded before this link is removed from the DOM.
|
|
78
|
+
ev.target?.setAttribute?.('aria-expanded', 'true');
|
|
79
|
+
setCurrent({ items: children, label });
|
|
80
|
+
}
|
|
81
|
+
return (_jsx("li", { className: "collapsible", children: _jsxs(Link, { onClick: handleClick, tabIndex: 0, "aria-expanded": false, "aria-controls": controllerId, children: [icon && _jsx(IconBox, { children: icon }), _jsx(Text, { appearance: "body2", className: "label", children: label }), iconRight && _jsx(IconBox, { children: iconRight }), _jsx(IconBox, { children: _jsx(ChevronRight, {}) })] }) }, label));
|
|
82
|
+
}
|
|
83
|
+
function renderSection({ label, children }, options) {
|
|
84
|
+
return (_jsxs("li", { className: "section", children: [label && _jsx(Text, { appearance: "overheader2", colorScheme: "primary", className: "section-title", children: label }), _jsx("ul", { children: children.map(i => renderItem(i, options)) })] }, label ?? children.map(c => c.label).join('-')));
|
|
85
|
+
}
|
|
86
|
+
function renderItem(item, options) {
|
|
87
|
+
if ('children' in item) {
|
|
88
|
+
return item.type === 'section' ? renderSection(item, options) : renderCollapsible(item, options);
|
|
89
|
+
}
|
|
90
|
+
return renderAction(item, options);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Renders a component that allows the selection of one item. The list is show/hidden according to the prop `visible`.
|
|
94
|
+
*
|
|
95
|
+
* The items in this list can be grouped into multiple sections. Sections may be displayed on a column (section) or might replace the
|
|
96
|
+
* current list of options with another list of options (collapsible).
|
|
97
|
+
*
|
|
98
|
+
* This component implements keyboard controls and accessibility features.
|
|
99
|
+
* @param props the component's props {@link SelectionListProps}.
|
|
100
|
+
*/
|
|
101
|
+
export const SelectionList = ({ id, items, className, style, visible = true, maxHeight = '300px', onHide, before, after, scroll, }) => {
|
|
102
|
+
const Link = useAnchorTag();
|
|
103
|
+
const t = useTranslate(dictionary);
|
|
104
|
+
const [current, setCurrent] = useState({ items });
|
|
105
|
+
const { keyboardControlledElement: wrapper, attachKeyboardListeners, detachKeyboardListeners } = useKeyboardControls({ onPressEscape: onHide, querySelectors: 'li.action a, li.collapsible a, button' });
|
|
106
|
+
const listItems = useMemo(() => current.items.map(i => renderItem(i, {
|
|
107
|
+
setCurrent: (next) => setCurrent({ ...next, parent: current }),
|
|
108
|
+
onClose: onHide,
|
|
109
|
+
controllerId: id,
|
|
110
|
+
Link,
|
|
111
|
+
})), [current]);
|
|
112
|
+
const hide = useCallback((event) => {
|
|
113
|
+
const target = event.target;
|
|
114
|
+
// if the element is not in the DOM anymore, we'll consider the click was inside the selection list
|
|
115
|
+
const isClickInsideSelectionList = !target?.isConnected || wrapper.current?.contains(target);
|
|
116
|
+
const isAction = target?.classList?.contains('action') || !!target?.closest('.action');
|
|
117
|
+
if (!isClickInsideSelectionList || isAction)
|
|
118
|
+
onHide?.();
|
|
119
|
+
}, []);
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
if (visible) {
|
|
122
|
+
setCurrent({ items });
|
|
123
|
+
attachKeyboardListeners();
|
|
124
|
+
if (onHide)
|
|
125
|
+
setTimeout(() => document.addEventListener('click', hide), 50);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
detachKeyboardListeners();
|
|
129
|
+
document.removeEventListener('click', hide);
|
|
130
|
+
}
|
|
131
|
+
}, [visible]);
|
|
132
|
+
return (_jsx(SelectionBox, { id: id, ref: wrapper, "$maxHeight": maxHeight, style: style, className: listToClass(['selection-list', visible ? 'visible' : undefined, className]), "$scroll": scroll, "aria-hidden": !visible, children: _jsxs("div", { className: "selection-list-content", children: [before, current.parent
|
|
133
|
+
? (_jsxs(Flex, { mt: 5, mb: 1, alignItems: "center", children: [_jsx(IconButton, { onClick: (ev) => {
|
|
134
|
+
// accessibility: this will tell the screen reader the section was collapsed before this button is removed from the DOM.
|
|
135
|
+
ev.target?.setAttribute?.('aria-expanded', 'false');
|
|
136
|
+
setCurrent(current.parent ?? { items });
|
|
137
|
+
}, sx: { mr: 3 }, title: t.back, "aria-controls": id, "aria-expanded": true, children: _jsx(ArrowLeft, {}) }), _jsx(Text, { appearance: "microtext1", children: current.label })] }))
|
|
138
|
+
: undefined, _jsxs("ul", { children: [listItems, after &&
|
|
139
|
+
_jsx("li", { className: "action", children: after })] })] }) }));
|
|
140
|
+
};
|
|
141
|
+
const dictionary = {
|
|
142
|
+
en: {
|
|
143
|
+
back: 'Go back',
|
|
144
|
+
},
|
|
145
|
+
pt: {
|
|
146
|
+
back: 'Voltar',
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
//# sourceMappingURL=SelectionList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectionList.js","sourceRoot":"","sources":["../../src/components/SelectionList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,EAAa,WAAW,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;AACxE,OAAO,EAAc,YAAY,EAAE,MAAM,8BAA8B,CAAA;AACvE,OAAO,EAAgB,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC1C,OAAO,EAAmB,YAAY,EAAE,MAAM,mBA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