@stack-spot/portal-layout 2.22.1 → 2.23.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/CHANGELOG.md +7 -0
- package/dist/components/Rate/hook.d.ts +0 -1
- package/dist/components/Rate/hook.d.ts.map +1 -1
- package/dist/components/Rate/hook.js +0 -17
- package/dist/components/Rate/hook.js.map +1 -1
- package/dist/components/TypeForm/hook.d.ts +2 -0
- package/dist/components/TypeForm/hook.d.ts.map +1 -0
- package/dist/components/TypeForm/hook.js +11 -0
- package/dist/components/TypeForm/hook.js.map +1 -0
- package/dist/components/TypeForm/index.d.ts +9 -0
- package/dist/components/TypeForm/index.d.ts.map +1 -0
- package/dist/components/TypeForm/index.js +16 -0
- package/dist/components/TypeForm/index.js.map +1 -0
- package/dist/components/TypeForm/show-typeform-modal.d.ts +5 -0
- package/dist/components/TypeForm/show-typeform-modal.d.ts.map +1 -0
- package/dist/components/TypeForm/show-typeform-modal.js +12 -0
- package/dist/components/TypeForm/show-typeform-modal.js.map +1 -0
- package/dist/components/TypeForm/utils.d.ts +2 -0
- package/dist/components/TypeForm/utils.d.ts.map +1 -0
- package/dist/components/TypeForm/utils.js +9 -0
- package/dist/components/TypeForm/utils.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Rate/hook.tsx +4 -25
- package/src/components/TypeForm/hook.tsx +13 -0
- package/src/components/TypeForm/index.tsx +51 -0
- package/src/components/TypeForm/show-typeform-modal.tsx +11 -0
- package/src/components/TypeForm/utils.ts +8 -0
- package/src/index.ts +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.23.0](https://github.com/stack-spot/portal-commons/compare/portal-layout@v2.22.1...portal-layout@v2.23.0) (2025-01-17)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* 1224 typeform ([#643](https://github.com/stack-spot/portal-commons/issues/643)) ([7203759](https://github.com/stack-spot/portal-commons/commit/7203759c66137fadcc2076d4a536902d118cf33f))
|
|
9
|
+
|
|
3
10
|
## [2.22.1](https://github.com/stack-spot/portal-commons/compare/portal-layout@v2.22.0...portal-layout@v2.22.1) (2025-01-16)
|
|
4
11
|
|
|
5
12
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hook.d.ts","sourceRoot":"","sources":["../../../src/components/Rate/hook.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hook.d.ts","sourceRoot":"","sources":["../../../src/components/Rate/hook.tsx"],"names":[],"mappings":"AAEA,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,WAaxD;AASD,eAAO,MAAM,kBAAkB,QAAO,OAoCrC,CAAA"}
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
import { useEffectOnce } from '@stack-spot/portal-components';
|
|
2
|
-
const loadScript = () => new Promise((resolve, reject) => {
|
|
3
|
-
const script = document.createElement('script');
|
|
4
|
-
script.setAttribute('src', '//embed.typeform.com/next/embed.js');
|
|
5
|
-
script.setAttribute('async', 'true');
|
|
6
|
-
script.onload = () => resolve();
|
|
7
|
-
script.onerror = (error) => reject(error);
|
|
8
|
-
document.body.appendChild(script);
|
|
9
|
-
});
|
|
10
1
|
// Function to check if the difference between two dates is greater than 30 days
|
|
11
2
|
export function isLessThan30Days(date1, date2) {
|
|
12
3
|
// Get the timestamps of the dates
|
|
@@ -54,12 +45,4 @@ export const shouldShowNpsModal = () => {
|
|
|
54
45
|
}
|
|
55
46
|
return false;
|
|
56
47
|
};
|
|
57
|
-
export function useRatingEffect() {
|
|
58
|
-
const handleInit = async () => {
|
|
59
|
-
await loadScript();
|
|
60
|
-
};
|
|
61
|
-
useEffectOnce(() => {
|
|
62
|
-
handleInit();
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
48
|
//# sourceMappingURL=hook.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hook.js","sourceRoot":"","sources":["../../../src/components/Rate/hook.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hook.js","sourceRoot":"","sources":["../../../src/components/Rate/hook.tsx"],"names":[],"mappings":"AACA,gFAAgF;AAChF,MAAM,UAAU,gBAAgB,CAAC,KAAW,EAAE,KAAW;IACvD,kCAAkC;IAClC,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,EAAE,CAAA;IAClC,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,EAAE,CAAA;IAElC,2CAA2C;IAC3C,MAAM,wBAAwB,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,GAAG,UAAU,CAAC,CAAA;IAElE,+BAA+B;IAC/B,MAAM,gBAAgB,GAAG,wBAAwB,GAAG,CAAC,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAA;IAEzE,gDAAgD;IAChD,OAAO,gBAAgB,GAAG,EAAE,CAAA;AAC9B,CAAC;AAED,6CAA6C;AAC7C,MAAM,aAAa,GAAG,CAAC,IAAU,EAAW,EAAE;IAC5C,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,EAAE,CAAA;IAC/B,OAAO,SAAS,KAAK,CAAC,IAAI,SAAS,KAAK,CAAC,CAAA,CAAC,2BAA2B;AACvE,CAAC,CAAA;AAED,yDAAyD;AACzD,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAY,EAAE;IAC9C,MAAM,KAAK,GAAG,IAAI,IAAI,EAAE,CAAA;IACxB,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,EAAE,CAAA;IAElC,gDAAgD;IAChD,MAAM,SAAS,GAAG,YAAY,CAAC,OAAO,CAAC,aAAa,CAAC,CAAA;IAErD,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,CAAA;QACnD,MAAM,WAAW,GAAG,SAAS,CAAC,QAAQ,EAAE,KAAK,KAAK,CAAC,QAAQ,EAAE,IAAI,SAAS,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,WAAW,EAAE,CAAA;QAEhH,qEAAqE;QACrE,IAAI,WAAW;YAAE,OAAO,KAAK,CAAA;IAC/B,CAAC;IAED,4DAA4D;IAC5D,IAAI,iBAAiB,GAAG,CAAC,CAAA;IACzB,IAAI,GAAG,GAAG,EAAE,CAAA;IAEZ,2DAA2D;IAC3D,OAAO,iBAAiB,GAAG,CAAC,EAAE,CAAC;QAC7B,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,GAAG,CAAC,CAAA;QAEtE,IAAI,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC;YAC7B,iBAAiB,EAAE,CAAA;QACrB,CAAC;QAED,2FAA2F;QAC3F,IAAI,UAAU,KAAK,GAAG,EAAE,CAAC;YACvB,OAAO,IAAI,CAAA;QACb,CAAC;QAED,GAAG,EAAE,CAAA;IACP,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hook.d.ts","sourceRoot":"","sources":["../../../src/components/TypeForm/hook.tsx"],"names":[],"mappings":"AAGA,wBAAgB,iBAAiB,SAShC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useEffectOnce } from '@stack-spot/portal-components';
|
|
2
|
+
import { loadTypeFormScript } from './utils.js';
|
|
3
|
+
export function useTypeFormEffect() {
|
|
4
|
+
const handleInit = async () => {
|
|
5
|
+
await loadTypeFormScript();
|
|
6
|
+
};
|
|
7
|
+
useEffectOnce(() => {
|
|
8
|
+
handleInit();
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=hook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hook.js","sourceRoot":"","sources":["../../../src/components/TypeForm/hook.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAE5C,MAAM,UAAU,iBAAiB;IAE/B,MAAM,UAAU,GAAG,KAAK,IAAI,EAAE;QAC5B,MAAM,kBAAkB,EAAE,CAAA;IAC5B,CAAC,CAAA;IAED,aAAa,CAAC,GAAG,EAAE;QACjB,UAAU,EAAE,CAAA;IACd,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface TypeFormProps {
|
|
2
|
+
dataTfLive: string;
|
|
3
|
+
orgId: string;
|
|
4
|
+
userId: string;
|
|
5
|
+
appId?: string;
|
|
6
|
+
infraId?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const TypeForm: ({ dataTfLive, orgId, userId, appId, infraId, }: TypeFormProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/TypeForm/index.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,QAAQ,mDAMlB,aAAa,4CAgCf,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Flex } from '@citric/core';
|
|
3
|
+
import { LoadingCircular } from '@citric/ui';
|
|
4
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
5
|
+
export const TypeForm = ({ dataTfLive, orgId, userId, appId, infraId, }) => {
|
|
6
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
window.tf?.load();
|
|
9
|
+
setTimeout(() => {
|
|
10
|
+
setIsLoading(false);
|
|
11
|
+
}, 2000);
|
|
12
|
+
}, []);
|
|
13
|
+
const typeform = useMemo(() => _jsx(Box, { children: appId ? _jsx("div", { "data-tf-live": dataTfLive, "data-tf-hidden": `org_id=${orgId},user_id=${userId},app_id=${appId}` }) : _jsx("div", { "data-tf-live": dataTfLive, "data-tf-hidden": `org_id=${orgId},user_id=${userId}infra_id=${infraId}` }) }), []);
|
|
14
|
+
return (_jsxs(Box, { sx: { minWidth: '650px', minHeight: '500px' }, children: [isLoading && _jsx(Flex, { alignItems: "center", justifyContent: "center", w: "12", sx: { height: '100%' }, children: _jsx(LoadingCircular, {}) }), _jsx(Box, { sx: { opacity: isLoading ? '0' : 1 }, children: typeform })] }));
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/TypeForm/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAUpD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,EACvB,UAAU,EACV,KAAK,EACL,MAAM,EACN,KAAK,EACL,OAAO,GACO,EAAE,EAAE;IAGlB,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAA;IAEhD,SAAS,CAAC,GAAG,EAAE;QACZ,MAAc,CAAC,EAAE,EAAE,IAAI,EAAE,CAAA;QAC1B,UAAU,CAAC,GAAG,EAAE;YACd,YAAY,CAAC,KAAK,CAAC,CAAA;QACrB,CAAC,EAAE,IAAI,CAAC,CAAA;IACV,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,KAAC,GAAG,cAChC,KAAK,CAAC,CAAC,CAAC,8BACO,UAAU,oBACR,UAAU,KAAK,YAAY,MAAM,WAAW,KAAK,EAAE,GACnE,CAAC,CAAC,CAAC,8BACW,UAAU,oBACR,UAAU,KAAK,YAAY,MAAM,YAAY,OAAO,EAAE,GACtE,GACE,EAAE,EAAE,CAAC,CAAA;IAEX,OAAO,CACL,MAAC,GAAG,IAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,aAC/C,SAAS,IAAI,KAAC,IAAI,IAAC,UAAU,EAAC,QAAQ,EAAC,cAAc,EAAC,QAAQ,EAAC,CAAC,EAAC,IAAI,EAAC,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,YAC3F,KAAC,eAAe,KAAG,GACd,EACP,KAAC,GAAG,IAAC,EAAE,EAAE,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,YACtC,QAAQ,GACL,IACF,CACP,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"show-typeform-modal.d.ts","sourceRoot":"","sources":["../../../src/components/TypeForm/show-typeform-modal.tsx"],"names":[],"mappings":"AACA,OAAO,EAAY,aAAa,EAAE,MAAM,GAAG,CAAA;AAE3C,eAAO,MAAM,iBAAiB,wBAAyB,aAAa,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,SAOvF,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { overlay } from '../../LayoutOverlayManager.js';
|
|
3
|
+
import { TypeForm } from './index.js';
|
|
4
|
+
export const showTypeFormModal = ({ title, ...props }) => {
|
|
5
|
+
const { dataTfLive, orgId, userId, appId, infraId } = props;
|
|
6
|
+
overlay.showModal({
|
|
7
|
+
title: title,
|
|
8
|
+
children: _jsx(TypeForm, { dataTfLive: dataTfLive, orgId: orgId, userId: userId, appId: appId, infraId: infraId }),
|
|
9
|
+
size: 'large',
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=show-typeform-modal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"show-typeform-modal.js","sourceRoot":"","sources":["../../../src/components/TypeForm/show-typeform-modal.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACpD,OAAO,EAAE,QAAQ,EAAiB,MAAM,GAAG,CAAA;AAE3C,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAAE,KAAK,EAAE,GAAG,KAAK,EAAqC,EAAE,EAAE;IAC1F,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,KAAK,CAAA;IAC3D,OAAO,CAAC,SAAS,CAAC;QAChB,KAAK,EAAE,KAAK;QACZ,QAAQ,EAAE,KAAC,QAAQ,IAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,GAAI;QAC5G,IAAI,EAAE,OAAO;KACd,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/TypeForm/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,qBAO7B,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const loadTypeFormScript = () => new Promise((resolve, reject) => {
|
|
2
|
+
const script = document.createElement('script');
|
|
3
|
+
script.setAttribute('src', '//embed.typeform.com/next/embed.js');
|
|
4
|
+
script.setAttribute('async', 'true');
|
|
5
|
+
script.onload = () => resolve();
|
|
6
|
+
script.onerror = (error) => reject(error);
|
|
7
|
+
document.body.appendChild(script);
|
|
8
|
+
});
|
|
9
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/components/TypeForm/utils.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,EAAE,CAAC,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;IAC5E,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;IAC/C,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,oCAAoC,CAAC,CAAA;IAChE,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IACpC,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,EAAE,CAAA;IAC/B,MAAM,CAAC,OAAO,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IACzC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;AACnC,CAAC,CAAC,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -9,9 +9,11 @@ export { CLOSE_OVERLAY_ID, OverlayContent } from './components/OverlayContent.js
|
|
|
9
9
|
export { PortalSwitcher } from './components/PortalSwitcher.js';
|
|
10
10
|
export { usePrivacyPolicyEffect } from './components/PrivacyPolicyMessage/hooks.js';
|
|
11
11
|
export { RateComponent } from './components/Rate/index.js';
|
|
12
|
-
export { shouldShowNpsModal
|
|
12
|
+
export { shouldShowNpsModal } from './components/Rate/hook.js';
|
|
13
13
|
export { ShowFeedbackModal, showRateUsModal } from './components/Rate/show-rate-us-modals.js';
|
|
14
14
|
export * from './components/tour/index.js';
|
|
15
|
+
export { useTypeFormEffect } from './components/TypeForm/hook.js';
|
|
16
|
+
export { showTypeFormModal } from './components/TypeForm/show-typeform-modal.js';
|
|
15
17
|
export * from './elements.js';
|
|
16
18
|
export * from './errors.js';
|
|
17
19
|
export { Layout, RawLayout } from './Layout.js';
|
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,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAA;AAC5E,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAA;AACzF,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAA;AAC7D,cAAc,yBAAyB,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAA;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAA;AAC5E,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAA;AACzF,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAA;AAC7D,cAAc,yBAAyB,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAA;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAC3D,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAA;AAC1F,cAAc,mBAAmB,CAAA;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAA;AAC7E,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAChD,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -9,9 +9,11 @@ export { CLOSE_OVERLAY_ID, OverlayContent } from './components/OverlayContent.js
|
|
|
9
9
|
export { PortalSwitcher } from './components/PortalSwitcher.js';
|
|
10
10
|
export { usePrivacyPolicyEffect } from './components/PrivacyPolicyMessage/hooks.js';
|
|
11
11
|
export { RateComponent } from './components/Rate/index.js';
|
|
12
|
-
export { shouldShowNpsModal
|
|
12
|
+
export { shouldShowNpsModal } from './components/Rate/hook.js';
|
|
13
13
|
export { ShowFeedbackModal, showRateUsModal } from './components/Rate/show-rate-us-modals.js';
|
|
14
14
|
export * from './components/tour/index.js';
|
|
15
|
+
export { useTypeFormEffect } from './components/TypeForm/hook.js';
|
|
16
|
+
export { showTypeFormModal } from './components/TypeForm/show-typeform-modal.js';
|
|
15
17
|
export * from './elements.js';
|
|
16
18
|
export * from './errors.js';
|
|
17
19
|
export { Layout, RawLayout } from './Layout.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAA;AAC5E,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,OAAO,EAAE,MAAM,EAAe,MAAM,qBAAqB,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAA;AACzF,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAA;AAC7D,cAAc,yBAAyB,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAA;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAA;AAC5E,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,OAAO,EAAE,MAAM,EAAe,MAAM,qBAAqB,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAA;AACzF,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAA;AAC7D,cAAc,yBAAyB,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAA;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAC3D,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAA;AAC1F,cAAc,mBAAmB,CAAA;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAA;AAC7E,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAChD,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,26 +1,16 @@
|
|
|
1
|
-
import { useEffectOnce } from '@stack-spot/portal-components'
|
|
2
|
-
|
|
3
|
-
const loadScript = () => new Promise<void>((resolve, reject) => {
|
|
4
|
-
const script = document.createElement('script')
|
|
5
|
-
script.setAttribute('src', '//embed.typeform.com/next/embed.js')
|
|
6
|
-
script.setAttribute('async', 'true')
|
|
7
|
-
script.onload = () => resolve()
|
|
8
|
-
script.onerror = (error) => reject(error)
|
|
9
|
-
document.body.appendChild(script)
|
|
10
|
-
})
|
|
11
1
|
|
|
12
2
|
// Function to check if the difference between two dates is greater than 30 days
|
|
13
3
|
export function isLessThan30Days(date1: Date, date2: Date) {
|
|
14
4
|
// Get the timestamps of the dates
|
|
15
5
|
const timestamp1 = date1.getTime()
|
|
16
6
|
const timestamp2 = date2.getTime()
|
|
17
|
-
|
|
7
|
+
|
|
18
8
|
// Calculate the difference in milliseconds
|
|
19
9
|
const differenceInMilliseconds = Math.abs(timestamp2 - timestamp1)
|
|
20
|
-
|
|
10
|
+
|
|
21
11
|
// Convert milliseconds to days
|
|
22
12
|
const differenceInDays = differenceInMilliseconds / (1000 * 60 * 60 * 24)
|
|
23
|
-
|
|
13
|
+
|
|
24
14
|
// Check if the difference is fewer than 30 days
|
|
25
15
|
return differenceInDays < 30
|
|
26
16
|
}
|
|
@@ -42,7 +32,7 @@ export const shouldShowNpsModal = (): boolean => {
|
|
|
42
32
|
if (ratedInfo) {
|
|
43
33
|
const savedDate = new Date(parseInt(ratedInfo, 10))
|
|
44
34
|
const isSameMonth = savedDate.getMonth() === today.getMonth() && savedDate.getFullYear() === today.getFullYear()
|
|
45
|
-
|
|
35
|
+
|
|
46
36
|
// If it has already been evaluated this month, do not show the modal
|
|
47
37
|
if (isSameMonth) return false
|
|
48
38
|
}
|
|
@@ -69,14 +59,3 @@ export const shouldShowNpsModal = (): boolean => {
|
|
|
69
59
|
|
|
70
60
|
return false
|
|
71
61
|
}
|
|
72
|
-
|
|
73
|
-
export function useRatingEffect() {
|
|
74
|
-
|
|
75
|
-
const handleInit = async () => {
|
|
76
|
-
await loadScript()
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
useEffectOnce(() => {
|
|
80
|
-
handleInit()
|
|
81
|
-
})
|
|
82
|
-
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useEffectOnce } from '@stack-spot/portal-components'
|
|
2
|
+
import { loadTypeFormScript } from './utils'
|
|
3
|
+
|
|
4
|
+
export function useTypeFormEffect() {
|
|
5
|
+
|
|
6
|
+
const handleInit = async () => {
|
|
7
|
+
await loadTypeFormScript()
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
useEffectOnce(() => {
|
|
11
|
+
handleInit()
|
|
12
|
+
})
|
|
13
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Box, Flex } from '@citric/core'
|
|
2
|
+
import { LoadingCircular } from '@citric/ui'
|
|
3
|
+
import { useEffect, useMemo, useState } from 'react'
|
|
4
|
+
|
|
5
|
+
export interface TypeFormProps {
|
|
6
|
+
dataTfLive: string,
|
|
7
|
+
orgId: string,
|
|
8
|
+
userId: string,
|
|
9
|
+
appId?: string,
|
|
10
|
+
infraId?: string,
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const TypeForm = ({
|
|
14
|
+
dataTfLive,
|
|
15
|
+
orgId,
|
|
16
|
+
userId,
|
|
17
|
+
appId,
|
|
18
|
+
infraId,
|
|
19
|
+
}: TypeFormProps) => {
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
const [isLoading, setIsLoading] = useState(true)
|
|
23
|
+
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
(window as any).tf?.load()
|
|
26
|
+
setTimeout(() => {
|
|
27
|
+
setIsLoading(false)
|
|
28
|
+
}, 2000)
|
|
29
|
+
}, [])
|
|
30
|
+
|
|
31
|
+
const typeform = useMemo(() => <Box>
|
|
32
|
+
{appId ? <div
|
|
33
|
+
data-tf-live={dataTfLive}
|
|
34
|
+
data-tf-hidden={`org_id=${orgId},user_id=${userId},app_id=${appId}`}
|
|
35
|
+
/> : <div
|
|
36
|
+
data-tf-live={dataTfLive}
|
|
37
|
+
data-tf-hidden={`org_id=${orgId},user_id=${userId}infra_id=${infraId}`}
|
|
38
|
+
/>}
|
|
39
|
+
</Box>, [])
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<Box sx={{ minWidth: '650px', minHeight: '500px' }}>
|
|
43
|
+
{isLoading && <Flex alignItems="center" justifyContent="center" w="12" sx={{ height: '100%' }}>
|
|
44
|
+
<LoadingCircular />
|
|
45
|
+
</Flex>}
|
|
46
|
+
<Box sx={{ opacity: isLoading ? '0' : 1 }}>
|
|
47
|
+
{typeform}
|
|
48
|
+
</Box>
|
|
49
|
+
</Box>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { overlay } from '../../LayoutOverlayManager'
|
|
2
|
+
import { TypeForm, TypeFormProps } from '.'
|
|
3
|
+
|
|
4
|
+
export const showTypeFormModal = ({ title, ...props }: TypeFormProps & { title: string }) => {
|
|
5
|
+
const { dataTfLive, orgId, userId, appId, infraId } = props
|
|
6
|
+
overlay.showModal({
|
|
7
|
+
title: title,
|
|
8
|
+
children: <TypeForm dataTfLive={dataTfLive} orgId={orgId} userId={userId} appId={appId} infraId={infraId} />,
|
|
9
|
+
size: 'large',
|
|
10
|
+
})
|
|
11
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const loadTypeFormScript = () => new Promise<void>((resolve, reject) => {
|
|
2
|
+
const script = document.createElement('script')
|
|
3
|
+
script.setAttribute('src', '//embed.typeform.com/next/embed.js')
|
|
4
|
+
script.setAttribute('async', 'true')
|
|
5
|
+
script.onload = () => resolve()
|
|
6
|
+
script.onerror = (error) => reject(error)
|
|
7
|
+
document.body.appendChild(script)
|
|
8
|
+
})
|
package/src/index.ts
CHANGED
|
@@ -9,9 +9,11 @@ export { CLOSE_OVERLAY_ID, OverlayContent } from './components/OverlayContent'
|
|
|
9
9
|
export { PortalSwitcher } from './components/PortalSwitcher'
|
|
10
10
|
export { usePrivacyPolicyEffect } from './components/PrivacyPolicyMessage/hooks'
|
|
11
11
|
export { RateComponent } from './components/Rate'
|
|
12
|
-
export { shouldShowNpsModal
|
|
12
|
+
export { shouldShowNpsModal } from './components/Rate/hook'
|
|
13
13
|
export { ShowFeedbackModal, showRateUsModal } from './components/Rate/show-rate-us-modals'
|
|
14
14
|
export * from './components/tour'
|
|
15
|
+
export { useTypeFormEffect } from './components/TypeForm/hook'
|
|
16
|
+
export { showTypeFormModal } from './components/TypeForm/show-typeform-modal'
|
|
15
17
|
export * from './elements'
|
|
16
18
|
export * from './errors'
|
|
17
19
|
export { Layout, RawLayout } from './Layout'
|