@stack-spot/portal-components 0.0.18 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/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 +50 -0
- package/dist/components/Tour/utils.d.ts.map +1 -0
- package/dist/components/Tour/utils.js +54 -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 +33 -0
- package/dist/utils/cookie.d.ts.map +1 -0
- package/dist/utils/cookie.js +62 -0
- package/dist/utils/cookie.js.map +1 -0
- package/package.json +24 -14
- package/readme.md +58 -13
- package/src/components/BannerWarning.tsx +6 -0
- package/src/components/Breadcrumb/index.tsx +15 -13
- 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 +93 -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 +63 -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
|
@@ -4,6 +4,10 @@ import { styled } from 'styled-components';
|
|
|
4
4
|
import { StepNavigation } from './StepNavigation.js';
|
|
5
5
|
import { StepTitle } from './StepTitle.js';
|
|
6
6
|
import { useTour } from './context.js';
|
|
7
|
+
/**
|
|
8
|
+
* Tutorial: the overlay component for showing a step on React Tour.
|
|
9
|
+
* @param props the react props for the component {@link StepContainerProps}.
|
|
10
|
+
*/
|
|
7
11
|
export const StepContainer = ({ title, stepKey, customNavigation, position, children }) => {
|
|
8
12
|
const { finishStep } = useTour();
|
|
9
13
|
return _jsxs(BoxWithPointingArrow, { "$position": position, children: [_jsx(StepTitle, { title: title, onClose: () => finishStep(stepKey) }), children, _jsx(StepNavigation, { stepKey: stepKey, ...(customNavigation || {}) })] });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StepContainer.js","sourceRoot":"","sources":["../../../src/components/Tour/StepContainer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC1C,OAAO,EAAmB,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAsBnC;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,QAAQ,EAAsB,EAAE,EAAE;IAC5G,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,EAAE,CAAA;IAChC,OAAO,MAAC,oBAAoB,iBAAY,QAAQ,aAC9C,KAAC,SAAS,IAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,GAAI,EAC9D,QAAQ,EACT,KAAC,cAAc,IAAC,OAAO,EAAE,OAAO,KAAM,CAAC,gBAAgB,IAAI,EAAE,CAAC,GAAI,IAC7C,CAAA;AACzB,CAAC,CAAA;AAID,MAAM,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAInC;;;sBAGkB,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;;;;;;;;0BAQpB,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;MAC5C,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,SAAS,KAAK,OAAO,CAAC,CAAC;IAClD;aACS,IAAI,IAAI,MAAM;;KAEtB,CAAC,CAAC,CAAC,EAAE;MACJ,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,SAAS,KAAK,KAAK,CAAC,CAAC;IAClD;;aAES,MAAM,IAAI,MAAM;;KAExB,CAAC,CAAC,CAAC,EAAE;MACJ,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,SAAS,KAAK,MAAM,CAAC,CAAC;IACjD;aACS,IAAI,IAAI,MAAM;;;KAGtB,CAAC,CAAC,CAAC,EAAE;MACJ,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,SAAS,KAAK,QAAQ,CAAC,CAAC;IACrD;;aAES,MAAM,IAAI,MAAM;;KAExB,CAAC,CAAC,CAAC,EAAE;;CAET,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import '@stack-spot/portal-theme/dist/theme.css';
|
|
2
|
+
interface CustomNavigationButton {
|
|
3
|
+
/**
|
|
4
|
+
* The text content to render.
|
|
5
|
+
*/
|
|
6
|
+
text: string;
|
|
7
|
+
onClick?: () => void;
|
|
8
|
+
}
|
|
9
|
+
export interface NavigationProps {
|
|
10
|
+
/**
|
|
11
|
+
* The unique identifier of the step.
|
|
12
|
+
*/
|
|
13
|
+
stepKey: string;
|
|
14
|
+
/**
|
|
15
|
+
* The text and click handler for the button "next".
|
|
16
|
+
*/
|
|
17
|
+
nextButton?: CustomNavigationButton;
|
|
18
|
+
/**
|
|
19
|
+
* The text and click handler for the button "previous".
|
|
20
|
+
*/
|
|
21
|
+
prevButton?: CustomNavigationButton;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Tutorial: the component in a React Tour overlay that shows the next and previous buttons (for step navigation).
|
|
25
|
+
* @param props the react props for the component {@link NavigationProps}.
|
|
26
|
+
*/
|
|
27
|
+
export declare const StepNavigation: ({ stepKey, nextButton, prevButton }: NavigationProps) => import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=StepNavigation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StepNavigation.d.ts","sourceRoot":"","sources":["../../../src/components/Tour/StepNavigation.tsx"],"names":[],"mappings":"AACA,OAAO,yCAAyC,CAAA;AAKhD,UAAU,sBAAsB;IAC9B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,UAAU,CAAC,EAAE,sBAAsB,CAAC;IACpC;;OAEG;IACH,UAAU,CAAC,EAAE,sBAAsB,CAAC;CACrC;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,wCAAyC,eAAe,4CAsBlF,CAAA"}
|
|
@@ -4,6 +4,10 @@ import '@stack-spot/portal-theme/dist/theme.css';
|
|
|
4
4
|
import { useTranslate } from '@stack-spot/portal-translate';
|
|
5
5
|
import { useTour } from './context.js';
|
|
6
6
|
import { finishTourStep } from './utils.js';
|
|
7
|
+
/**
|
|
8
|
+
* Tutorial: the component in a React Tour overlay that shows the next and previous buttons (for step navigation).
|
|
9
|
+
* @param props the react props for the component {@link NavigationProps}.
|
|
10
|
+
*/
|
|
7
11
|
export const StepNavigation = ({ stepKey, nextButton, prevButton }) => {
|
|
8
12
|
const { currentStep, steps, nextStep, prevStep } = useTour();
|
|
9
13
|
const t = useTranslate({ en: { of: 'of', back: 'back' }, pt: { of: 'de', back: 'voltar' } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StepNavigation.js","sourceRoot":"","sources":["../../../src/components/Tour/StepNavigation.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,yCAAyC,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAyBxC;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAmB,EAAE,EAAE;IACrF,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,OAAO,EAAE,CAAA;IAC5D,MAAM,CAAC,GAAG,YAAY,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAA;IAC5F,OAAO,MAAC,IAAI,IAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAC,MAAM,EAAC,EAAE,EAAC,aAAa,EAAC,cAAc,EAAC,eAAe,aACzF,MAAC,IAAI,IAAC,UAAU,EAAC,YAAY,EAAC,WAAW,EAAC,sBAAsB,aAAE,WAAW,GAAG,CAAC,OAAG,CAAC,CAAC,EAAE,OAAG,KAAK,CAAC,MAAM,IAAQ,EAC/G,MAAC,IAAI,IAAC,EAAE,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,aACrB,WAAW,IAAI,CAAC;wBACf,KAAC,MAAM,IAAC,EAAE,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE;gCACnD,QAAQ,EAAE,EAAE,CAAA;gCACZ,UAAU,EAAE,OAAO,EAAE,EAAE,CAAA;4BACzB,CAAC,EAAE,IAAI,EAAC,IAAI,EAAC,WAAW,EAAC,OAAO,YAC7B,UAAU,EAAE,IAAI,IAAI,CAAC,CAAC,IAAI,GACpB,EACX,KAAC,MAAM,IAAC,EAAE,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE;4BACnD,UAAU,EAAE,OAAO,EAAE,EAAE,CAAA;4BACvB,QAAQ,EAAE,EAAE,CAAA;4BACZ,cAAc,CAAC,OAAO,CAAC,CAAA;wBACzB,CAAC,EAAE,IAAI,EAAC,IAAI,EAAC,WAAW,EAAC,OAAO,YAC7B,UAAU,EAAE,IAAI,IAAI,IAAI,GAClB,IACJ,IACF,CAAA;AACT,CAAC,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
interface StepTitleProps {
|
|
2
|
+
/**
|
|
3
|
+
* The step's title.
|
|
4
|
+
*/
|
|
5
|
+
title: string;
|
|
6
|
+
/**
|
|
7
|
+
* A function to run once the step is closed.
|
|
8
|
+
*/
|
|
9
|
+
onClose?: () => void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Tutorial: the component in a React Tour overlay that renders the title.
|
|
13
|
+
* @param props the react props for the component {@link StepTitleProps}.
|
|
14
|
+
*/
|
|
15
|
+
export declare const StepTitle: ({ title, onClose }: StepTitleProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=StepTitle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StepTitle.d.ts","sourceRoot":"","sources":["../../../src/components/Tour/StepTitle.tsx"],"names":[],"mappings":"AAGA,UAAU,cAAc;IACtB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS,uBAAwB,cAAc,4CAQnD,CAAA"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Button, Flex, IconBox, Text } from '@citric/core';
|
|
3
3
|
import { TimesMini } from '@citric/icons';
|
|
4
|
+
/**
|
|
5
|
+
* Tutorial: the component in a React Tour overlay that renders the title.
|
|
6
|
+
* @param props the react props for the component {@link StepTitleProps}.
|
|
7
|
+
*/
|
|
4
8
|
export const StepTitle = ({ title, onClose }) => _jsxs(Flex, { w: 12, pl: 5, py: 3, flexWrap: "nowrap", justifyContent: "space-between", alignItems: "center", children: [_jsxs(Text, { appearance: "body2", colorScheme: "inverse.contrastText", weight: "medium", children: [" ", title, " "] }), _jsx(Button, { appearance: "text", size: "sm", onClick: () => onClose?.(), sx: { ':hover': { borderColor: 'transparent !important' } }, children: _jsx(IconBox, { size: "xs", colorIcon: "inverse.contrastText", children: _jsx(TimesMini, {}) }) })] });
|
|
5
9
|
//# sourceMappingURL=StepTitle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StepTitle.js","sourceRoot":"","sources":["../../../src/components/Tour/StepTitle.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAazC;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,EAAE,KAAK,EAAE,OAAO,EAAkB,EAAE,EAAE,CAC9D,MAAC,IAAI,IAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,QAAQ,EAAC,QAAQ,EAAC,cAAc,EAAC,eAAe,EAAC,UAAU,EAAC,QAAQ,aAC7F,MAAC,IAAI,IAAC,UAAU,EAAC,OAAO,EAAC,WAAW,EAAC,sBAAsB,EAAC,MAAM,EAAC,QAAQ,kBAAG,KAAK,SAAS,EAC5F,KAAC,MAAM,IAAC,UAAU,EAAC,MAAM,EAAC,IAAI,EAAC,IAAI,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,WAAW,EAAE,wBAAwB,EAAE,EAAE,YACzH,KAAC,OAAO,IAAC,IAAI,EAAC,IAAI,EAAC,SAAS,EAAC,sBAAsB,YACjD,KAAC,SAAS,KAAG,GACL,GACH,IACJ,CAAA"}
|
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { ReactourProps } from 'reactour';
|
|
3
3
|
type TourConfig = Omit<ReactourProps, 'children'>;
|
|
4
|
+
/**
|
|
5
|
+
* Tutorial: the default configuration for a React Tour.
|
|
6
|
+
*/
|
|
4
7
|
export declare const defaultTourConfig: TourConfig;
|
|
8
|
+
/**
|
|
9
|
+
* Tutorial: provides the configuration for React Tour.
|
|
10
|
+
* @param props the configuration for the tour and the content to render.
|
|
11
|
+
*/
|
|
5
12
|
export declare const TourProvider: ({ config, children }: {
|
|
6
13
|
config: TourConfig;
|
|
7
14
|
children: ReactNode;
|
|
8
15
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
/**
|
|
17
|
+
* Tutorial: retrieves data related to the current step of React Tour.
|
|
18
|
+
* @returns an object with all the information related to the steps of React Tour.
|
|
19
|
+
*/
|
|
9
20
|
export declare const useTour: () => {
|
|
10
21
|
currentStep: number;
|
|
11
22
|
nextStep: (() => void) | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/components/Tour/context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAuC,MAAM,OAAO,CAAA;AACtE,OAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAG9C,KAAK,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC,CAAA;AAEjD;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,UAU9B,CAAA;AAOF;;;GAGG;AACH,eAAO,MAAM,YAAY;YAAoC,UAAU;cAAY,SAAS;6CAkB3F,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,OAAO;;;;;0BAOM,MAAM;CAK/B,CAAA"}
|
|
@@ -2,6 +2,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { createContext, useContext, useState } from 'react';
|
|
3
3
|
import Tour from 'reactour';
|
|
4
4
|
import { finishTourStep } from './utils.js';
|
|
5
|
+
/**
|
|
6
|
+
* Tutorial: the default configuration for a React Tour.
|
|
7
|
+
*/
|
|
5
8
|
export const defaultTourConfig = Object.freeze({
|
|
6
9
|
steps: [],
|
|
7
10
|
isOpen: true,
|
|
@@ -17,6 +20,10 @@ const TourContext = createContext({
|
|
|
17
20
|
tourConfig: defaultTourConfig,
|
|
18
21
|
currentStep: 0,
|
|
19
22
|
});
|
|
23
|
+
/**
|
|
24
|
+
* Tutorial: provides the configuration for React Tour.
|
|
25
|
+
* @param props the configuration for the tour and the content to render.
|
|
26
|
+
*/
|
|
20
27
|
export const TourProvider = ({ config, children }) => {
|
|
21
28
|
const [currentStep, setCurrentStep] = useState(0);
|
|
22
29
|
const tourConfig = {
|
|
@@ -32,6 +39,10 @@ export const TourProvider = ({ config, children }) => {
|
|
|
32
39
|
tourConfig,
|
|
33
40
|
}, children: [_jsx(Tour, { ...tourConfig }), children] });
|
|
34
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* Tutorial: retrieves data related to the current step of React Tour.
|
|
44
|
+
* @returns an object with all the information related to the steps of React Tour.
|
|
45
|
+
*/
|
|
35
46
|
export const useTour = () => {
|
|
36
47
|
const { currentStep, tourConfig: { nextStep, prevStep, steps } } = useContext(TourContext);
|
|
37
48
|
return {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/components/Tour/context.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAa,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACtE,OAAO,IAAuB,MAAM,UAAU,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAIxC;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAe,MAAM,CAAC,MAAM,CAAC;IACzD,KAAK,EAAE,EAAE;IACT,MAAM,EAAE,IAAI;IACZ,cAAc,EAAE,GAAG,EAAE,CAAC,EAAE;IACxB,WAAW,EAAE,KAAK;IAClB,cAAc,EAAE,KAAK;IACrB,oBAAoB,EAAE,KAAK;IAC3B,UAAU,EAAE,KAAK;IACjB,eAAe,EAAE,KAAK;IACtB,gBAAgB,EAAE,IAAI;CACvB,CAAC,CAAA;AAEF,MAAM,WAAW,GAAG,aAAa,CAAkD;IACjF,UAAU,EAAE,iBAAiB;IAC7B,WAAW,EAAE,CAAC;CACf,CAAC,CAAA;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAAE,MAAM,EAAE,QAAQ,EAA+C,EAAE,EAAE;IAChG,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAS,CAAC,CAAC,CAAA;IACzD,MAAM,UAAU,GAAe;QAC7B,GAAG,MAAM;QACT,QAAQ,EAAE,WAAW;QACrB,MAAM,EAAE,GAAG,WAAW,EAAE;QACxB,QAAQ,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,WAAW,GAAG,CAAC,CAAC;QAC/C,QAAQ,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,WAAW,GAAG,CAAC,CAAC;QAC/C,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC;KACrE,CAAA;IAED,OAAO,MAAC,WAAW,CAAC,QAAQ,IAAC,KAAK,EAAE;YAClC,WAAW;YACX,UAAU;SACX,aACC,KAAC,IAAI,OAAK,UAAU,GAAI,EACvB,QAAQ,IACY,CAAA;AACzB,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,EAAE;IAC1B,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,GAAG,UAAU,CAAC,WAAW,CAAC,CAAA;IAC1F,OAAO;QACL,WAAW;QACX,QAAQ;QACR,QAAQ;QACR,KAAK;QACL,UAAU,EAAE,CAAC,OAAe,EAAE,EAAE;YAC9B,cAAc,CAAC,OAAO,CAAC,CAAA;YACvB,QAAQ,EAAE,EAAE,CAAA;QACd,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactourProps, ReactourStep } from 'reactour';
|
|
2
2
|
export { StepContainer } from './StepContainer.js';
|
|
3
3
|
export { TourProvider, defaultTourConfig, useTour } from './context.js';
|
|
4
|
-
export { isNewTourStep, tourStepBuilder } from './utils.js';
|
|
4
|
+
export { hasFinishedTourStep, isNewTourStep, tourStepBuilder } from './utils.js';
|
|
5
5
|
export { ReactourStep as TourStep };
|
|
6
6
|
export type TourProps = Partial<Omit<ReactourProps, 'children'>> & {
|
|
7
7
|
steps: ReactourStep[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Tour/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAEtD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACpE,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAC7E,OAAO,EAAE,YAAY,IAAI,QAAQ,EAAE,CAAA;AACnC,MAAM,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC,GAAG;IAAE,KAAK,EAAE,YAAY,EAAE,CAAA;CAAE,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { StepContainer } from './StepContainer.js';
|
|
2
2
|
export { TourProvider, defaultTourConfig, useTour } from './context.js';
|
|
3
|
-
export { isNewTourStep, tourStepBuilder } from './utils.js';
|
|
3
|
+
export { hasFinishedTourStep, isNewTourStep, tourStepBuilder } from './utils.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Tour/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACpE,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ReactourStep } from 'reactour';
|
|
3
|
+
import { NavigationProps } from './StepNavigation.js';
|
|
4
|
+
/**
|
|
5
|
+
* Tutorial: marks the tour step as finished. This sets a cookie, preventing the tour from showing again.
|
|
6
|
+
* @param key the identifier for the step to mark as finished.
|
|
7
|
+
*/
|
|
8
|
+
export declare const finishTourStep: (key: string) => void;
|
|
9
|
+
/**
|
|
10
|
+
* Tutorial: verifies if the React Tour step has not finished yet.
|
|
11
|
+
*
|
|
12
|
+
* A step has not finished if the array stored as a cookie doesn't include the string value of `step.selector`.
|
|
13
|
+
* @param step the step config.
|
|
14
|
+
* @returns true if the step has not yet been marked as finished. False otherwise.
|
|
15
|
+
*/
|
|
16
|
+
export declare const isNewTourStep: (step: ReactourStep) => boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Tutorial: verifies if the key passed as parameter refers to a React Tour step that has already finished.
|
|
19
|
+
*
|
|
20
|
+
* The key refers to a finished step if the array stored as a cookie includes it.
|
|
21
|
+
* @param key the step's identifier to check.
|
|
22
|
+
* @returns true if the key refers to a finished step. False otherwise.
|
|
23
|
+
*/
|
|
24
|
+
export declare const hasFinishedTourStep: (key: string) => boolean;
|
|
25
|
+
interface StackspotTourStep extends ReactourStep {
|
|
26
|
+
/**
|
|
27
|
+
* The step's title.
|
|
28
|
+
*/
|
|
29
|
+
title: string;
|
|
30
|
+
/**
|
|
31
|
+
* The unique identifier for the step (key).
|
|
32
|
+
*/
|
|
33
|
+
selector: string;
|
|
34
|
+
/**
|
|
35
|
+
* The step's content.
|
|
36
|
+
*/
|
|
37
|
+
content: ReactNode;
|
|
38
|
+
/**
|
|
39
|
+
* A set of properties for customizing the next and previous buttons.
|
|
40
|
+
*/
|
|
41
|
+
customNavigation?: NavigationProps;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Tutorial: utility for building a React Tour step. This already includes some default configuration for tours in Stackspot.
|
|
45
|
+
* @param options the options for building the step: {@link StackspotTourStep}.
|
|
46
|
+
* @returns the React Tour step.
|
|
47
|
+
*/
|
|
48
|
+
export declare const tourStepBuilder: ({ selector, position, title, content, style, customNavigation, ...rest }: StackspotTourStep) => ReactourStep;
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/Tour/utils.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAGvC,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AASlD;;;GAGG;AACH,eAAO,MAAM,cAAc,QAAS,MAAM,SAIzC,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,SAAU,YAAY,YAA6C,CAAA;AAE7F;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,QAAS,MAAM,YAAkC,CAAA;AAEjF,UAAU,iBAAkB,SAAQ,YAAY;IAC9C;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,OAAO,EAAE,SAAS,CAAC;IACnB;;OAEG;IACH,gBAAgB,CAAC,EAAE,eAAe,CAAC;CACpC;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,6EAQzB,iBAAiB,KAAG,YAkBrB,CAAA"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { theme } from '@stack-spot/portal-theme';
|
|
3
|
+
import { getCookie, setCookie } from '../../utils/cookie.js';
|
|
4
|
+
import { StepContainer } from './StepContainer.js';
|
|
5
|
+
const TOUR_COOKIE = 'guided-tour-global';
|
|
6
|
+
const getTourCookie = () => {
|
|
7
|
+
const currentTourObject = getCookie(TOUR_COOKIE);
|
|
8
|
+
return currentTourObject ? currentTourObject.split(',') : [];
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Tutorial: marks the tour step as finished. This sets a cookie, preventing the tour from showing again.
|
|
12
|
+
* @param key the identifier for the step to mark as finished.
|
|
13
|
+
*/
|
|
14
|
+
export const finishTourStep = (key) => {
|
|
15
|
+
const finishedTours = getTourCookie();
|
|
16
|
+
if (!finishedTours.includes(key))
|
|
17
|
+
finishedTours.push(key);
|
|
18
|
+
setCookie(TOUR_COOKIE, finishedTours.toString());
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Tutorial: verifies if the React Tour step has not finished yet.
|
|
22
|
+
*
|
|
23
|
+
* A step has not finished if the array stored as a cookie doesn't include the string value of `step.selector`.
|
|
24
|
+
* @param step the step config.
|
|
25
|
+
* @returns true if the step has not yet been marked as finished. False otherwise.
|
|
26
|
+
*/
|
|
27
|
+
export const isNewTourStep = (step) => !hasFinishedTourStep(`${step.selector}`);
|
|
28
|
+
/**
|
|
29
|
+
* Tutorial: verifies if the key passed as parameter refers to a React Tour step that has already finished.
|
|
30
|
+
*
|
|
31
|
+
* The key refers to a finished step if the array stored as a cookie includes it.
|
|
32
|
+
* @param key the step's identifier to check.
|
|
33
|
+
* @returns true if the key refers to a finished step. False otherwise.
|
|
34
|
+
*/
|
|
35
|
+
export const hasFinishedTourStep = (key) => getTourCookie().includes(key);
|
|
36
|
+
/**
|
|
37
|
+
* Tutorial: utility for building a React Tour step. This already includes some default configuration for tours in Stackspot.
|
|
38
|
+
* @param options the options for building the step: {@link StackspotTourStep}.
|
|
39
|
+
* @returns the React Tour step.
|
|
40
|
+
*/
|
|
41
|
+
export const tourStepBuilder = ({ selector, position, title, content, style, customNavigation, ...rest }) => ({
|
|
42
|
+
selector,
|
|
43
|
+
content: (_jsx(StepContainer, { stepKey: selector, position: position, title: title, customNavigation: customNavigation, children: content })),
|
|
44
|
+
position,
|
|
45
|
+
style: {
|
|
46
|
+
backgroundColor: theme.color.inverse[500],
|
|
47
|
+
width: '256px',
|
|
48
|
+
padding: 0,
|
|
49
|
+
top: ['right', 'left'].includes(position) ? '-3px' : '0',
|
|
50
|
+
...(style || {}),
|
|
51
|
+
},
|
|
52
|
+
...(rest || {}),
|
|
53
|
+
});
|
|
54
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/components/Tour/utils.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;AAGhD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,EAAyB,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAGtE,MAAM,WAAW,GAAG,oBAAoB,CAAA;AAExC,MAAM,aAAa,GAAG,GAAG,EAAE;IACzB,MAAM,iBAAiB,GAAG,SAAS,CAAC,WAAW,CAAC,CAAA;IAChD,OAAO,iBAAiB,CAAC,CAAC,CAAC,iBAAiB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;AAC9D,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAW,EAAE,EAAE;IAC5C,MAAM,aAAa,GAAa,aAAa,EAAE,CAAA;IAC/C,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACzD,SAAS,CAAC,WAAW,EAAE,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAA;AAClD,CAAC,CAAA;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAkB,EAAE,EAAE,CAAC,CAAC,mBAAmB,CAAC,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAA;AAE7F;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,aAAa,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;AAqBjF;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAC9B,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,OAAO,EACP,KAAK,EACL,gBAAgB,EAChB,GAAG,IAAI,EACW,EAAgB,EAAE,CAAC,CAAC;IACtC,QAAQ;IACR,OAAO,EAAE,CAAC,KAAC,aAAa,IACtB,OAAO,EAAE,QAAQ,EACjB,QAAQ,EAAE,QAAiC,EAC3C,KAAK,EAAE,KAAK,EACZ,gBAAgB,EAAE,gBAAgB,YACjC,OAAO,GACM,CAAC;IACjB,QAAQ;IACR,KAAK,EAAE;QACL,eAAe,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;QACzC,KAAK,EAAE,OAAO;QACd,OAAO,EAAE,CAAC;QACV,GAAG,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,QAAiC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG;QACjF,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;KACjB;IACD,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;CAChB,CAAC,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export type AnchorComponent = (props: React.AnchorHTMLAttributes<HTMLAnchorElement>) => React.ReactElement;
|
|
3
|
+
interface AnchorContext {
|
|
4
|
+
/**
|
|
5
|
+
* The component to render by a layout component a link is needed.
|
|
6
|
+
* @default <a>
|
|
7
|
+
*/
|
|
8
|
+
anchorTag?: AnchorComponent;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Some components need to create HTML anchors (links) to other pages in the website. These links, sometimes, must to be managed by a
|
|
12
|
+
* navigator for React. Since we don't want to couple this library with any specific navigator, you can provide your own component for
|
|
13
|
+
* creating links, it must follow the same interface of the HTML's `a` tag.
|
|
14
|
+
*
|
|
15
|
+
* If this is not used, the tag `<a>` is used by default.
|
|
16
|
+
* @param props the anchor component (anchorTag) and the content to render (children).
|
|
17
|
+
*/
|
|
18
|
+
export declare const AnchorProvider: ({ children, ...props }: Required<AnchorContext> & {
|
|
19
|
+
children: React.ReactNode;
|
|
20
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
/**
|
|
22
|
+
* A React hook for retrieving the Link (anchor) component.
|
|
23
|
+
* @returns the link component declared at {@link AnchorProvider} or a component that renders the tag <a> from HTML if no link component was
|
|
24
|
+
* provided.
|
|
25
|
+
*/
|
|
26
|
+
export declare function useAnchorTag(): AnchorComponent;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=anchor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anchor.d.ts","sourceRoot":"","sources":["../../src/context/anchor.tsx"],"names":[],"mappings":";AAEA,MAAM,MAAM,eAAe,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,KAAK,KAAK,CAAC,YAAY,CAAA;AAE1G,UAAU,aAAa;IACrB;;;OAGG;IACH,SAAS,CAAC,EAAE,eAAe,CAAC;CAC7B;AAMD;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc;cAAkE,MAAM,SAAS;6CAE3G,CAAA;AAED;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,eAAe,CAG9C"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext } from 'react';
|
|
3
|
+
const context = createContext({});
|
|
4
|
+
const Anchor = props => _jsx("a", { ...props });
|
|
5
|
+
/**
|
|
6
|
+
* Some components need to create HTML anchors (links) to other pages in the website. These links, sometimes, must to be managed by a
|
|
7
|
+
* navigator for React. Since we don't want to couple this library with any specific navigator, you can provide your own component for
|
|
8
|
+
* creating links, it must follow the same interface of the HTML's `a` tag.
|
|
9
|
+
*
|
|
10
|
+
* If this is not used, the tag `<a>` is used by default.
|
|
11
|
+
* @param props the anchor component (anchorTag) and the content to render (children).
|
|
12
|
+
*/
|
|
13
|
+
export const AnchorProvider = ({ children, ...props }) => (_jsx(context.Provider, { value: props, children: children }));
|
|
14
|
+
/**
|
|
15
|
+
* A React hook for retrieving the Link (anchor) component.
|
|
16
|
+
* @returns the link component declared at {@link AnchorProvider} or a component that renders the tag <a> from HTML if no link component was
|
|
17
|
+
* provided.
|
|
18
|
+
*/
|
|
19
|
+
export function useAnchorTag() {
|
|
20
|
+
const { anchorTag } = useContext(context);
|
|
21
|
+
return anchorTag ?? Anchor;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=anchor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anchor.js","sourceRoot":"","sources":["../../src/context/anchor.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAYjD,MAAM,OAAO,GAAG,aAAa,CAAgB,EAAE,CAAC,CAAA;AAEhD,MAAM,MAAM,GAAoB,KAAK,CAAC,EAAE,CAAC,eAAO,KAAK,GAAI,CAAA;AAEzD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAA2D,EAAE,EAAE,CAAC,CACjH,KAAC,OAAO,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAoB,CAC9D,CAAA;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY;IAC1B,MAAM,EAAE,SAAS,EAAE,GAAG,UAAU,CAAC,OAAO,CAAC,CAAA;IACzC,OAAO,SAAS,IAAI,MAAM,CAAA;AAC5B,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface Props {
|
|
3
|
+
/**
|
|
4
|
+
* A query selector that returns every html element that must be navigable through the keyboard.
|
|
5
|
+
*/
|
|
6
|
+
querySelectors: string;
|
|
7
|
+
/**
|
|
8
|
+
* Function to call when ESC is pressed. or when TAB is pressed at the last item in the list of items returned by the query selector.
|
|
9
|
+
*/
|
|
10
|
+
onPressEscape?: () => void;
|
|
11
|
+
/**
|
|
12
|
+
* Function to call when TAB is pressed at the last item in the list of items returned by the query selector. Will be the same as
|
|
13
|
+
* onPressEscape if not specified.
|
|
14
|
+
*/
|
|
15
|
+
onPressLastTab?: () => void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Creates listeners for controlling a Menu UI through the keyboard.
|
|
19
|
+
* - Arrow down: next element in the iterator returned by the query selectors. First element, it the current element is the last.
|
|
20
|
+
* - Arrow up: previous element in the iterator returned by the query selectors. Last element, it the current element is the first.
|
|
21
|
+
* - Tab: same as Arrow down, but has a different behavior if the element is the last (see onPressLastTab).
|
|
22
|
+
* - Esc: determined by onPressEscape.
|
|
23
|
+
* @param props {@link Props}.
|
|
24
|
+
* @returns an object with the element controlled by the keyboard (useRef); a function to attach the keyboard events and a function to
|
|
25
|
+
* detach the keyboard events.
|
|
26
|
+
*/
|
|
27
|
+
export declare function useKeyboardControls({ querySelectors, onPressEscape, onPressLastTab }: Props): {
|
|
28
|
+
keyboardControlledElement: import("react").RefObject<HTMLDivElement>;
|
|
29
|
+
attachKeyboardListeners: () => void;
|
|
30
|
+
detachKeyboardListeners: () => void;
|
|
31
|
+
};
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=keyboard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyboard.d.ts","sourceRoot":"","sources":["../../src/hooks/keyboard.tsx"],"names":[],"mappings":";AAEA,UAAU,KAAK;IACb;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,cAAc,EAAE,aAAa,EAAE,cAA8B,EAAE,EAAE,KAAK;;;;EAmD3G"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { useCallback, useRef } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Creates listeners for controlling a Menu UI through the keyboard.
|
|
4
|
+
* - Arrow down: next element in the iterator returned by the query selectors. First element, it the current element is the last.
|
|
5
|
+
* - Arrow up: previous element in the iterator returned by the query selectors. Last element, it the current element is the first.
|
|
6
|
+
* - Tab: same as Arrow down, but has a different behavior if the element is the last (see onPressLastTab).
|
|
7
|
+
* - Esc: determined by onPressEscape.
|
|
8
|
+
* @param props {@link Props}.
|
|
9
|
+
* @returns an object with the element controlled by the keyboard (useRef); a function to attach the keyboard events and a function to
|
|
10
|
+
* detach the keyboard events.
|
|
11
|
+
*/
|
|
12
|
+
export function useKeyboardControls({ querySelectors, onPressEscape, onPressLastTab = onPressEscape }) {
|
|
13
|
+
const keyboardControlledElement = useRef(null);
|
|
14
|
+
const listeners = useRef({});
|
|
15
|
+
listeners.current = { onPressEscape, onPressLastTab };
|
|
16
|
+
const keyboardControls = useCallback((event) => {
|
|
17
|
+
const target = event?.target;
|
|
18
|
+
function getSelectableAnchors() {
|
|
19
|
+
return keyboardControlledElement.current?.querySelectorAll(querySelectors) ?? [];
|
|
20
|
+
}
|
|
21
|
+
function handleArrows(key = event.key) {
|
|
22
|
+
const anchors = getSelectableAnchors();
|
|
23
|
+
let i = 0;
|
|
24
|
+
while (i < anchors.length && document.activeElement !== anchors[i])
|
|
25
|
+
i++;
|
|
26
|
+
const next = key === 'ArrowDown' ? (anchors[i + 1] ?? anchors[0]) : (anchors[i - 1] ?? anchors[anchors.length - 1]);
|
|
27
|
+
next?.focus?.();
|
|
28
|
+
}
|
|
29
|
+
const handlers = {
|
|
30
|
+
Escape: () => {
|
|
31
|
+
listeners.current.onPressEscape?.();
|
|
32
|
+
event.stopPropagation();
|
|
33
|
+
event.preventDefault();
|
|
34
|
+
},
|
|
35
|
+
Enter: () => {
|
|
36
|
+
target?.click();
|
|
37
|
+
},
|
|
38
|
+
Tab: () => {
|
|
39
|
+
const anchors = getSelectableAnchors();
|
|
40
|
+
if (document.activeElement === anchors[anchors.length - 1])
|
|
41
|
+
listeners.current.onPressLastTab?.();
|
|
42
|
+
else
|
|
43
|
+
handleArrows('ArrowDown');
|
|
44
|
+
event.preventDefault();
|
|
45
|
+
},
|
|
46
|
+
ArrowUp: handleArrows,
|
|
47
|
+
ArrowDown: handleArrows,
|
|
48
|
+
};
|
|
49
|
+
handlers[event.key]?.();
|
|
50
|
+
}, []);
|
|
51
|
+
const attachKeyboardListeners = useCallback(() => {
|
|
52
|
+
document.addEventListener('keydown', keyboardControls);
|
|
53
|
+
}, []);
|
|
54
|
+
const detachKeyboardListeners = useCallback(() => {
|
|
55
|
+
document.removeEventListener('keydown', keyboardControls);
|
|
56
|
+
}, []);
|
|
57
|
+
return { keyboardControlledElement, attachKeyboardListeners, detachKeyboardListeners };
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=keyboard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyboard.js","sourceRoot":"","sources":["../../src/hooks/keyboard.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAkB3C;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB,CAAC,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,GAAG,aAAa,EAAS;IAC1G,MAAM,yBAAyB,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAA;IAC9D,MAAM,SAAS,GAAG,MAAM,CAAkD,EAAE,CAAC,CAAA;IAC7E,SAAS,CAAC,OAAO,GAAG,EAAE,aAAa,EAAE,cAAc,EAAE,CAAA;IAErD,MAAM,gBAAgB,GAAG,WAAW,CAAC,CAAC,KAAoB,EAAE,EAAE;QAC5D,MAAM,MAAM,GAAG,KAAK,EAAE,MAA4B,CAAA;QAElD,SAAS,oBAAoB;YAC3B,OAAO,yBAAyB,CAAC,OAAO,EAAE,gBAAgB,CAAC,cAAc,CAAC,IAAI,EAAE,CAAA;QAClF,CAAC;QAED,SAAS,YAAY,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG;YACnC,MAAM,OAAO,GAAG,oBAAoB,EAAE,CAAA;YACtC,IAAI,CAAC,GAAG,CAAC,CAAA;YACT,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,IAAI,QAAQ,CAAC,aAAa,KAAK,OAAO,CAAC,CAAC,CAAC;gBAAE,CAAC,EAAE,CAAA;YACvE,MAAM,IAAI,GAAQ,GAAG,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAA;YACxH,IAAI,EAAE,KAAK,EAAE,EAAE,CAAA;QACjB,CAAC;QAED,MAAM,QAAQ,GAA6C;YACzD,MAAM,EAAE,GAAG,EAAE;gBACX,SAAS,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAA;gBACnC,KAAK,CAAC,eAAe,EAAE,CAAA;gBACvB,KAAK,CAAC,cAAc,EAAE,CAAA;YACxB,CAAC;YACD,KAAK,EAAE,GAAG,EAAE;gBACV,MAAM,EAAE,KAAK,EAAE,CAAA;YACjB,CAAC;YACD,GAAG,EAAE,GAAG,EAAE;gBACR,MAAM,OAAO,GAAG,oBAAoB,EAAE,CAAA;gBACtC,IAAI,QAAQ,CAAC,aAAa,KAAK,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;oBAAE,SAAS,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAA;;oBAC1F,YAAY,CAAC,WAAW,CAAC,CAAA;gBAC/B,KAAK,CAAC,cAAc,EAAE,CAAA;YACxB,CAAC;YACD,OAAO,EAAE,YAAY;YACrB,SAAS,EAAE,YAAY;SACxB,CAAA;QAED,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,CAAA;IACzB,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,MAAM,uBAAuB,GAAG,WAAW,CAAC,GAAG,EAAE;QAC/C,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAA;IACxD,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,MAAM,uBAAuB,GAAG,WAAW,CAAC,GAAG,EAAE;QAC/C,QAAQ,CAAC,mBAAmB,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAA;IAC3D,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,CAAA;AACxF,CAAC"}
|
|
@@ -1,10 +1,39 @@
|
|
|
1
1
|
interface Options {
|
|
2
|
+
/**
|
|
3
|
+
* Function to run when the chat button is hidden, i.e. when the user clicks the close button that appears when the chat button is
|
|
4
|
+
* hovered.
|
|
5
|
+
*/
|
|
2
6
|
onClose?: () => void;
|
|
3
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* @returns the iframe loaded by service now, i.e. the chat window; or null if the chat window doesn't exist.
|
|
10
|
+
*/
|
|
4
11
|
export declare function getServiceNowLauncher(): HTMLElement | null;
|
|
12
|
+
/**
|
|
13
|
+
* Opens the chat window and makes the chat button visible.
|
|
14
|
+
*/
|
|
5
15
|
export declare function openServiceNowChat(): void;
|
|
6
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Shows the chat window, i.e. shows the service now iframe and switch the icon in the chat button to "close".
|
|
18
|
+
*/
|
|
19
|
+
export declare function showChatWindow(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Hides the chat window, i.e. hides the service now iframe and switch the icon in the chat button to "chat".
|
|
22
|
+
*/
|
|
23
|
+
export declare function hideChatWindow(): void;
|
|
24
|
+
/**
|
|
25
|
+
* A react hook that indicates whether the chat button is visible or not. This is updated whenever the value changes.
|
|
26
|
+
* @returns true if the chat button is visible and false otherwise.
|
|
27
|
+
*/
|
|
7
28
|
export declare function useServiceNowChatButtonVisibility(): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Starts Service Now:
|
|
31
|
+
*
|
|
32
|
+
* - Creates the chat window feature by loading the required script.
|
|
33
|
+
* - Adds a "minimize" button on top of the chat button (left bottom corner). This button appears whenever the user hovers the chat button.
|
|
34
|
+
* If clicked, the chat button is hidden.
|
|
35
|
+
* @param options
|
|
36
|
+
*/
|
|
8
37
|
export declare function useServiceNowEffect(options?: Options): void;
|
|
9
38
|
export declare const dictionary: {
|
|
10
39
|
en: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-now.d.ts","sourceRoot":"","sources":["../../src/hooks/service-now.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"service-now.d.ts","sourceRoot":"","sources":["../../src/hooks/service-now.tsx"],"names":[],"mappings":"AA2CA,UAAU,OAAO;IACf;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAuBD;;GAEG;AACH,wBAAgB,qBAAqB,uBAEpC;AAED;;GAEG;AACH,wBAAgB,kBAAkB,SAIjC;AAuBD;;GAEG;AACH,wBAAgB,cAAc,SAE7B;AAED;;GAEG;AACH,wBAAgB,cAAc,SAE7B;AAyED;;;GAGG;AACH,wBAAgB,iCAAiC,YAIhD;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE,OAAO,QAIpD;AAED,eAAO,MAAM,UAAU;;;;;;;;;;;;;CAaD,CAAA"}
|