@stack-spot/portal-components 0.0.15 → 0.0.16
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.map +1 -1
- package/dist/components/MiniLogo.d.ts +2 -3
- package/dist/components/MiniLogo.d.ts.map +1 -1
- package/dist/hooks/service-now.d.ts +19 -1
- package/dist/hooks/service-now.d.ts.map +1 -1
- package/dist/hooks/service-now.js +10 -13
- package/dist/hooks/service-now.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -3
- package/src/hooks/service-now.tsx +14 -13
- package/src/index.ts +4 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BannerWarning.d.ts","sourceRoot":"","sources":["../../src/components/BannerWarning.tsx"],"names":[],"mappings":"AAIA,eAAO,MAAM,aAAa;
|
|
1
|
+
{"version":3,"file":"BannerWarning.d.ts","sourceRoot":"","sources":["../../src/components/BannerWarning.tsx"],"names":[],"mappings":"AAIA,eAAO,MAAM,aAAa,iBAAkB;IAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;CAAE,4CAgBxE,CAAA"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
export declare const MiniLogo: ({ className, style }: {
|
|
3
|
-
className?: string
|
|
4
|
-
style?:
|
|
2
|
+
className?: string;
|
|
3
|
+
style?: React.CSSProperties;
|
|
5
4
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
6
5
|
//# sourceMappingURL=MiniLogo.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MiniLogo.d.ts","sourceRoot":"","sources":["../../src/components/MiniLogo.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MiniLogo.d.ts","sourceRoot":"","sources":["../../src/components/MiniLogo.tsx"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,yBAA0B;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,aAAa,CAAA;CAAE,4CA6BjG,CAAA"}
|
|
@@ -1,6 +1,24 @@
|
|
|
1
|
+
interface Options {
|
|
2
|
+
onClose?: () => void;
|
|
3
|
+
}
|
|
1
4
|
export declare function getServiceNowLauncher(): HTMLElement | null;
|
|
2
5
|
export declare function openServiceNowChat(): void;
|
|
3
6
|
export declare function addOrRemoveServiceNowLauncher(action: string): void;
|
|
4
7
|
export declare function useServiceNowChatButtonVisibility(): boolean;
|
|
5
|
-
export declare function useServiceNowEffect(): void;
|
|
8
|
+
export declare function useServiceNowEffect(options?: Options): void;
|
|
9
|
+
export declare const dictionary: {
|
|
10
|
+
en: {
|
|
11
|
+
errorLoadScript: string;
|
|
12
|
+
hide: string;
|
|
13
|
+
hiddenTitle: string;
|
|
14
|
+
hiddenMessage: string;
|
|
15
|
+
};
|
|
16
|
+
pt: {
|
|
17
|
+
errorLoadScript: string;
|
|
18
|
+
hide: string;
|
|
19
|
+
hiddenTitle: string;
|
|
20
|
+
hiddenMessage: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export {};
|
|
6
24
|
//# sourceMappingURL=service-now.d.ts.map
|
|
@@ -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":"AAwCA,UAAU,OAAO;IACf,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAuBD,wBAAgB,qBAAqB,uBAEpC;AAED,wBAAgB,kBAAkB,SAIjC;AAaD,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,MAAM,QAU3D;AAkED,wBAAgB,iCAAiC,YAIhD;AAED,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE,OAAO,QAIpD;AAED,eAAO,MAAM,UAAU;;;;;;;;;;;;;CAaD,CAAA"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { overlay } from '@stack-spot/portal-layout';
|
|
2
1
|
import { getLanguage, translate } from '@stack-spot/portal-translate';
|
|
3
2
|
import { pull } from 'lodash';
|
|
4
3
|
import { useState } from 'react';
|
|
@@ -80,7 +79,7 @@ function addChatVisibilityListener(listener) {
|
|
|
80
79
|
chatVisibilityListeners.push(listener);
|
|
81
80
|
return () => pull(chatVisibilityListeners, listener);
|
|
82
81
|
}
|
|
83
|
-
function renderCloseButton() {
|
|
82
|
+
function renderCloseButton(onClose) {
|
|
84
83
|
const serviceNowButton = getServiceNowButton();
|
|
85
84
|
const anchor = serviceNowButton?.parentElement;
|
|
86
85
|
if (!anchor)
|
|
@@ -89,7 +88,7 @@ function renderCloseButton() {
|
|
|
89
88
|
close.setAttribute('id', 'close-service-now');
|
|
90
89
|
close.style.cssText = closeButtonStyle;
|
|
91
90
|
close.textContent = '-';
|
|
92
|
-
close.addEventListener('click', () => hideServiceNowChatButton());
|
|
91
|
+
close.addEventListener('click', () => hideServiceNowChatButton(onClose));
|
|
93
92
|
anchor.appendChild(close);
|
|
94
93
|
serviceNowButton.addEventListener('mouseenter', () => {
|
|
95
94
|
const t = translate(dictionary, getLanguage());
|
|
@@ -109,27 +108,25 @@ function showServiceNowChatButton() {
|
|
|
109
108
|
localStorage.setItem(LOCAL_STORAGE_SERVICE_NOW_VALUE, 'true');
|
|
110
109
|
chatVisibilityListeners.forEach(l => l(true));
|
|
111
110
|
}
|
|
112
|
-
function hideServiceNowChatButton(
|
|
113
|
-
const t = translate(dictionary, getLanguage());
|
|
111
|
+
function hideServiceNowChatButton(onClose) {
|
|
114
112
|
hideOrShowServiceNowContent('hidden');
|
|
115
113
|
addOrRemoveServiceNowLauncher('remove');
|
|
116
114
|
getServiceNowButton()?.classList?.remove('show');
|
|
117
115
|
localStorage.setItem(LOCAL_STORAGE_SERVICE_NOW_VALUE, 'false');
|
|
118
|
-
|
|
119
|
-
overlay.showToaster({ type: 'info', title: t.hiddenTitle, message: t.hiddenMessage, autoClose: false });
|
|
116
|
+
onClose?.();
|
|
120
117
|
chatVisibilityListeners.forEach(l => l(false));
|
|
121
118
|
}
|
|
122
119
|
function isServiceNowChatButtonVisible() {
|
|
123
120
|
return localStorage.getItem(LOCAL_STORAGE_SERVICE_NOW_VALUE) !== 'false';
|
|
124
121
|
}
|
|
125
|
-
async function initializeChat() {
|
|
122
|
+
async function initializeChat({ onClose } = {}) {
|
|
126
123
|
try {
|
|
127
124
|
await loadScript(serviceNowReference);
|
|
128
125
|
if (isServiceNowChatButtonVisible())
|
|
129
126
|
showServiceNowChatButton();
|
|
130
127
|
else
|
|
131
|
-
hideServiceNowChatButton(
|
|
132
|
-
renderCloseButton();
|
|
128
|
+
hideServiceNowChatButton();
|
|
129
|
+
renderCloseButton(onClose);
|
|
133
130
|
}
|
|
134
131
|
catch {
|
|
135
132
|
const t = translate(dictionary, getLanguage());
|
|
@@ -142,12 +139,12 @@ export function useServiceNowChatButtonVisibility() {
|
|
|
142
139
|
useEffectOnce(() => addChatVisibilityListener(setVisible));
|
|
143
140
|
return visible;
|
|
144
141
|
}
|
|
145
|
-
export function useServiceNowEffect() {
|
|
142
|
+
export function useServiceNowEffect(options) {
|
|
146
143
|
useEffectOnce(() => {
|
|
147
|
-
initializeChat();
|
|
144
|
+
initializeChat(options);
|
|
148
145
|
});
|
|
149
146
|
}
|
|
150
|
-
const dictionary = {
|
|
147
|
+
export const dictionary = {
|
|
151
148
|
en: {
|
|
152
149
|
errorLoadScript: 'An error occurred while loading the script:',
|
|
153
150
|
hide: 'Hide chat button',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-now.js","sourceRoot":"","sources":["../../src/hooks/service-now.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"service-now.js","sour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,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC,CAAA;IACjC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,iCAAiC;IAC/C,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,6BAA6B,EAAE,CAAC,CAAA;IACvE,aAAa,CAAC,GAAG,EAAE,CAAC,yBAAyB,CAAC,UAAU,CAAC,CAAC,CAAA;IAC1D,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,OAAiB;IACnD,aAAa,CAAC,GAAG,EAAE;QACjB,cAAc,CAAC,OAAO,CAAC,CAAA;IACzB,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,EAAE,EAAE;QACF,eAAe,EAAE,6CAA6C;QAC9D,IAAI,EAAE,kBAAkB;QACxB,WAAW,EAAE,+BAA+B;QAC5C,aAAa,EAAE,+FAA+F;KAC/G;IACD,EAAE,EAAE;QACF,eAAe,EAAE,uCAAuC;QACxD,IAAI,EAAE,0BAA0B;QAChC,WAAW,EAAE,+BAA+B;QAC5C,aAAa,EAAE,0GAA0G;KAC1H;CACmB,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { BannerWarning } from './components/BannerWarning.js';
|
|
|
2
2
|
export { BreadcrumbList } from './components/Breadcrumb/index.js';
|
|
3
3
|
export { ChatBot } from './components/ChatBot.js';
|
|
4
4
|
export { Login } from './components/Login.js';
|
|
5
|
-
export { openServiceNowChat, useServiceNowChatButtonVisibility, useServiceNowEffect } from './hooks/service-now.js';
|
|
5
|
+
export { openServiceNowChat, dictionary as serviceNowDictionary, useServiceNowChatButtonVisibility, useServiceNowEffect, } from './hooks/service-now.js';
|
|
6
6
|
export { titleEffect, useTitleEffect } from './hooks/title.js';
|
|
7
7
|
export { useEffectOnce } from './hooks/use-effect-once.js';
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EACL,kBAAkB,EAAE,UAAU,IAAI,oBAAoB,EAAE,iCAAiC,EAAE,mBAAmB,GAC/G,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ export { BannerWarning } from './components/BannerWarning.js';
|
|
|
2
2
|
export { BreadcrumbList } from './components/Breadcrumb/index.js';
|
|
3
3
|
export { ChatBot } from './components/ChatBot.js';
|
|
4
4
|
export { Login } from './components/Login.js';
|
|
5
|
-
export { openServiceNowChat, useServiceNowChatButtonVisibility, useServiceNowEffect } from './hooks/service-now.js';
|
|
5
|
+
export { openServiceNowChat, dictionary as serviceNowDictionary, useServiceNowChatButtonVisibility, useServiceNowEffect, } from './hooks/service-now.js';
|
|
6
6
|
export { titleEffect, useTitleEffect } from './hooks/title.js';
|
|
7
7
|
export { useEffectOnce } from './hooks/use-effect-once.js';
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EACL,kBAAkB,EAAE,UAAU,IAAI,oBAAoB,EAAE,iCAAiC,EAAE,mBAAmB,GAC/G,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stack-spot/portal-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -10,10 +10,9 @@
|
|
|
10
10
|
"@citric/ui": ">=5.4.0",
|
|
11
11
|
"@stack-spot/portal-theme": ">=1.0.0",
|
|
12
12
|
"@stack-spot/portal-translate": ">=1.0.0",
|
|
13
|
-
"@stack-spot/portal-layout": ">=0.0.46",
|
|
14
13
|
"react": ">=18.2.0",
|
|
15
14
|
"react-dom": ">=18.2.0",
|
|
16
|
-
"styled-components": ">=6.1.
|
|
15
|
+
"styled-components": ">=6.1.10"
|
|
17
16
|
},
|
|
18
17
|
"devDependencies": {
|
|
19
18
|
"@types/react": "^18.2.37",
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
import { overlay } from '@stack-spot/portal-layout'
|
|
3
2
|
import { Dictionary, getLanguage, translate } from '@stack-spot/portal-translate'
|
|
4
3
|
import { pull } from 'lodash'
|
|
5
4
|
import { useState } from 'react'
|
|
@@ -39,6 +38,10 @@ const iframeStyle = `
|
|
|
39
38
|
|
|
40
39
|
type ChatVisibilityListener = (visible: boolean) => void
|
|
41
40
|
|
|
41
|
+
interface Options {
|
|
42
|
+
onClose?: () => void,
|
|
43
|
+
}
|
|
44
|
+
|
|
42
45
|
const HOVER_AREA_PX = 100
|
|
43
46
|
const LOCAL_STORAGE_SERVICE_NOW_VALUE = 'serviceNowChatButtonVisible'
|
|
44
47
|
const chatVisibilityListeners: ChatVisibilityListener[] = []
|
|
@@ -98,7 +101,7 @@ function addChatVisibilityListener(listener: ChatVisibilityListener) {
|
|
|
98
101
|
return () => pull(chatVisibilityListeners, listener)
|
|
99
102
|
}
|
|
100
103
|
|
|
101
|
-
function renderCloseButton() {
|
|
104
|
+
function renderCloseButton(onClose?: () => void) {
|
|
102
105
|
const serviceNowButton = getServiceNowButton()
|
|
103
106
|
const anchor = serviceNowButton?.parentElement
|
|
104
107
|
if (!anchor) return
|
|
@@ -107,7 +110,7 @@ function renderCloseButton() {
|
|
|
107
110
|
close.style.cssText = closeButtonStyle
|
|
108
111
|
close.textContent = '-'
|
|
109
112
|
|
|
110
|
-
close.addEventListener('click', () => hideServiceNowChatButton())
|
|
113
|
+
close.addEventListener('click', () => hideServiceNowChatButton(onClose))
|
|
111
114
|
anchor.appendChild(close)
|
|
112
115
|
|
|
113
116
|
serviceNowButton.addEventListener('mouseenter', () => {
|
|
@@ -131,14 +134,12 @@ function showServiceNowChatButton() {
|
|
|
131
134
|
chatVisibilityListeners.forEach(l => l(true))
|
|
132
135
|
}
|
|
133
136
|
|
|
134
|
-
function hideServiceNowChatButton(
|
|
135
|
-
const t = translate(dictionary, getLanguage())
|
|
136
|
-
|
|
137
|
+
function hideServiceNowChatButton(onClose?: () => void) {
|
|
137
138
|
hideOrShowServiceNowContent('hidden')
|
|
138
139
|
addOrRemoveServiceNowLauncher('remove')
|
|
139
140
|
getServiceNowButton()?.classList?.remove('show')
|
|
140
141
|
localStorage.setItem(LOCAL_STORAGE_SERVICE_NOW_VALUE, 'false')
|
|
141
|
-
|
|
142
|
+
onClose?.()
|
|
142
143
|
chatVisibilityListeners.forEach(l => l(false))
|
|
143
144
|
}
|
|
144
145
|
|
|
@@ -146,12 +147,12 @@ function isServiceNowChatButtonVisible() {
|
|
|
146
147
|
return localStorage.getItem(LOCAL_STORAGE_SERVICE_NOW_VALUE) !== 'false'
|
|
147
148
|
}
|
|
148
149
|
|
|
149
|
-
async function initializeChat() {
|
|
150
|
+
async function initializeChat({ onClose }: Options = {}) {
|
|
150
151
|
try {
|
|
151
152
|
await loadScript(serviceNowReference)
|
|
152
153
|
if (isServiceNowChatButtonVisible()) showServiceNowChatButton()
|
|
153
|
-
else hideServiceNowChatButton(
|
|
154
|
-
renderCloseButton()
|
|
154
|
+
else hideServiceNowChatButton()
|
|
155
|
+
renderCloseButton(onClose)
|
|
155
156
|
} catch {
|
|
156
157
|
const t = translate(dictionary, getLanguage())
|
|
157
158
|
// eslint-disable-next-line no-console
|
|
@@ -165,13 +166,13 @@ export function useServiceNowChatButtonVisibility() {
|
|
|
165
166
|
return visible
|
|
166
167
|
}
|
|
167
168
|
|
|
168
|
-
export function useServiceNowEffect() {
|
|
169
|
+
export function useServiceNowEffect(options?: Options) {
|
|
169
170
|
useEffectOnce(() => {
|
|
170
|
-
initializeChat()
|
|
171
|
+
initializeChat(options)
|
|
171
172
|
})
|
|
172
173
|
}
|
|
173
174
|
|
|
174
|
-
const dictionary = {
|
|
175
|
+
export const dictionary = {
|
|
175
176
|
en: {
|
|
176
177
|
errorLoadScript: 'An error occurred while loading the script:',
|
|
177
178
|
hide: 'Hide chat button',
|
package/src/index.ts
CHANGED
|
@@ -2,6 +2,9 @@ export { BannerWarning } from './components/BannerWarning'
|
|
|
2
2
|
export { BreadcrumbList } from './components/Breadcrumb'
|
|
3
3
|
export { ChatBot } from './components/ChatBot'
|
|
4
4
|
export { Login } from './components/Login'
|
|
5
|
-
export {
|
|
5
|
+
export {
|
|
6
|
+
openServiceNowChat, dictionary as serviceNowDictionary, useServiceNowChatButtonVisibility, useServiceNowEffect,
|
|
7
|
+
} from './hooks/service-now'
|
|
6
8
|
export { titleEffect, useTitleEffect } from './hooks/title'
|
|
7
9
|
export { useEffectOnce } from './hooks/use-effect-once'
|
|
10
|
+
|