@stack-spot/portal-components 1.5.1 → 2.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.
Files changed (62) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/components/ChatBot.d.ts +0 -2
  3. package/dist/components/ChatBot.d.ts.map +1 -1
  4. package/dist/components/ChatBot.js +1 -3
  5. package/dist/components/ChatBot.js.map +1 -1
  6. package/dist/components/Placeholder.d.ts +19 -0
  7. package/dist/components/Placeholder.d.ts.map +1 -0
  8. package/dist/components/Placeholder.js +16 -0
  9. package/dist/components/Placeholder.js.map +1 -0
  10. package/dist/components/error/index.d.ts +1 -1
  11. package/dist/components/error/index.d.ts.map +1 -1
  12. package/dist/components/error/index.js.map +1 -1
  13. package/dist/hooks/date.d.ts +0 -12
  14. package/dist/hooks/date.d.ts.map +1 -1
  15. package/dist/hooks/date.js +0 -18
  16. package/dist/hooks/date.js.map +1 -1
  17. package/dist/hooks/service-now.d.ts +2 -0
  18. package/dist/hooks/service-now.d.ts.map +1 -1
  19. package/dist/hooks/service-now.js +2 -1
  20. package/dist/hooks/service-now.js.map +1 -1
  21. package/dist/index.d.ts +2 -2
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +2 -2
  24. package/dist/index.js.map +1 -1
  25. package/package.json +2 -5
  26. package/readme.md +0 -4
  27. package/src/components/ChatBot.tsx +1 -4
  28. package/src/components/Placeholder.tsx +82 -0
  29. package/src/components/error/index.ts +2 -1
  30. package/src/hooks/date.ts +0 -20
  31. package/src/hooks/service-now.tsx +2 -1
  32. package/src/index.ts +3 -2
  33. package/dist/components/Tour/StepContainer.d.ts +0 -29
  34. package/dist/components/Tour/StepContainer.d.ts.map +0 -1
  35. package/dist/components/Tour/StepContainer.js +0 -52
  36. package/dist/components/Tour/StepContainer.js.map +0 -1
  37. package/dist/components/Tour/StepNavigation.d.ts +0 -29
  38. package/dist/components/Tour/StepNavigation.d.ts.map +0 -1
  39. package/dist/components/Tour/StepNavigation.js +0 -38
  40. package/dist/components/Tour/StepNavigation.js.map +0 -1
  41. package/dist/components/Tour/StepTitle.d.ts +0 -17
  42. package/dist/components/Tour/StepTitle.d.ts.map +0 -1
  43. package/dist/components/Tour/StepTitle.js +0 -9
  44. package/dist/components/Tour/StepTitle.js.map +0 -1
  45. package/dist/components/Tour/context.d.ts +0 -28
  46. package/dist/components/Tour/context.d.ts.map +0 -1
  47. package/dist/components/Tour/context.js +0 -59
  48. package/dist/components/Tour/context.js.map +0 -1
  49. package/dist/components/Tour/index.d.ts +0 -9
  50. package/dist/components/Tour/index.d.ts.map +0 -1
  51. package/dist/components/Tour/index.js +0 -4
  52. package/dist/components/Tour/index.js.map +0 -1
  53. package/dist/components/Tour/utils.d.ts +0 -51
  54. package/dist/components/Tour/utils.d.ts.map +0 -1
  55. package/dist/components/Tour/utils.js +0 -60
  56. package/dist/components/Tour/utils.js.map +0 -1
  57. package/src/components/Tour/StepContainer.tsx +0 -83
  58. package/src/components/Tour/StepNavigation.tsx +0 -72
  59. package/src/components/Tour/StepTitle.tsx +0 -27
  60. package/src/components/Tour/context.tsx +0 -67
  61. package/src/components/Tour/index.ts +0 -7
  62. package/src/components/Tour/utils.tsx +0 -100
@@ -1,100 +0,0 @@
1
- import { theme } from '@stack-spot/portal-theme'
2
- import { ReactNode } from 'react'
3
- import { ReactourStep } from 'reactour'
4
- import { getCookie, setCookie } from '../../utils/cookie'
5
- import { PointingArrowPosition, StepContainer } from './StepContainer'
6
- import { NavigationProps } from './StepNavigation'
7
-
8
- const TOUR_COOKIE = 'guided-tour-global'
9
-
10
- const defaultExpires = new Date()
11
- defaultExpires.setFullYear(new Date().getFullYear() + 1)
12
-
13
- const getTourCookie = () => {
14
- const currentTourObject = getCookie(TOUR_COOKIE)
15
- return currentTourObject ? currentTourObject.split(',') : []
16
- }
17
-
18
- /**
19
- * Tutorial: marks the tour step as finished. This sets a cookie, preventing the tour from showing again.
20
- * @param key the identifier for the step to mark as finished.
21
- */
22
- export const finishTourStep = (key: string) => {
23
- const finishedTours: string[] = getTourCookie()
24
- if (!finishedTours.includes(key)) finishedTours.push(key)
25
- setCookie(TOUR_COOKIE, finishedTours.toString(), { expires: defaultExpires.toUTCString() })
26
- }
27
-
28
- /**
29
- * Tutorial: verifies if the React Tour step has not finished yet.
30
- *
31
- * A step has not finished if the array stored as a cookie doesn't include the string value of `step.selector`.
32
- * @param step the step config.
33
- * @returns true if the step has not yet been marked as finished. False otherwise.
34
- */
35
- export const isNewTourStep = (step: ReactourStep) => !hasFinishedTourStep(`${step.selector}`)
36
-
37
- /**
38
- * Tutorial: verifies if the key passed as parameter refers to a React Tour step that has already finished.
39
- *
40
- * The key refers to a finished step if the array stored as a cookie includes it.
41
- * If the cookie is set to 'disabled', then the step will be considered finished.Particularly useful in scenarios like e2e tests.
42
- * @param key the step's identifier to check.
43
- * @returns true if the key refers to a finished step. False otherwise.
44
- */
45
- export const hasFinishedTourStep = (key: string) => {
46
- const tourCookie = getTourCookie()
47
- return tourCookie.includes(key) || tourCookie[0] === 'disabled'
48
- }
49
-
50
- interface StackspotTourStep extends ReactourStep {
51
- /**
52
- * The step's title.
53
- */
54
- title: string,
55
- /**
56
- * The unique identifier for the step (key).
57
- */
58
- selector: string,
59
- /**
60
- * The step's content.
61
- */
62
- content: ReactNode,
63
- /**
64
- * A set of properties for customizing the next and previous buttons.
65
- */
66
- customNavigation?: NavigationProps,
67
- }
68
-
69
- /**
70
- * Tutorial: utility for building a React Tour step. This already includes some default configuration for tours in Stackspot.
71
- * @param options the options for building the step: {@link StackspotTourStep}.
72
- * @returns the React Tour step.
73
- */
74
- export const tourStepBuilder = ({
75
- selector,
76
- position,
77
- title,
78
- content,
79
- style,
80
- customNavigation,
81
- ...rest
82
- }: StackspotTourStep): ReactourStep => ({
83
- selector,
84
- content: (<StepContainer
85
- stepKey={selector}
86
- position={position as PointingArrowPosition}
87
- title={title}
88
- customNavigation={customNavigation}>
89
- {content}
90
- </StepContainer>),
91
- position,
92
- style: {
93
- backgroundColor: theme.color.inverse[500],
94
- width: '256px',
95
- padding: 0,
96
- top: ['right', 'left'].includes(position as PointingArrowPosition) ? '-3px' : '0',
97
- ...(style || {}),
98
- },
99
- ...(rest || {}),
100
- })