@saasquatch/mint-components 1.13.3-7 → 1.13.3-9
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/cjs/{sqm-qr-code-view-1dab20a0.js → sqm-qr-code-view-82b14685.js} +4 -5
- package/dist/cjs/sqm-qr-code.cjs.entry.js +27 -6
- package/dist/cjs/sqm-stencilbook.cjs.entry.js +8 -3
- package/dist/collection/components/sqm-qr-code/QRCode.stories.js +5 -1
- package/dist/collection/components/sqm-qr-code/sqm-qr-code-view.js +4 -5
- package/dist/collection/components/sqm-qr-code/sqm-qr-code.js +1 -1
- package/dist/collection/components/sqm-qr-code/useQRCode.js +27 -5
- package/dist/esm/{sqm-qr-code-view-cfba2441.js → sqm-qr-code-view-2dff1823.js} +4 -5
- package/dist/esm/sqm-qr-code.entry.js +28 -7
- package/dist/esm/sqm-stencilbook.entry.js +8 -3
- package/dist/esm-es5/sqm-qr-code-view-2dff1823.js +1 -0
- package/dist/esm-es5/sqm-qr-code.entry.js +1 -1
- package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
- package/dist/mint-components/mint-components.esm.js +1 -1
- package/dist/mint-components/{p-31cf4105.system.entry.js → p-31c73e3a.system.entry.js} +1 -1
- package/dist/mint-components/p-37996351.system.js +1 -1
- package/dist/mint-components/{p-7d724467.entry.js → p-3edc9c8a.entry.js} +2 -2
- package/dist/mint-components/p-4f6bb357.system.js +1 -0
- package/dist/mint-components/p-7c434c65.js +1 -0
- package/dist/mint-components/p-d78298a5.entry.js +17 -0
- package/dist/mint-components/p-f4ba6e2b.system.entry.js +1 -0
- package/dist/types/components/sqm-qr-code/QRCode.stories.d.ts +1 -0
- package/dist/types/components/sqm-qr-code/sqm-qr-code-view.d.ts +2 -1
- package/docs/docs.docx +0 -0
- package/package.json +1 -1
- package/dist/esm-es5/sqm-qr-code-view-cfba2441.js +0 -1
- package/dist/mint-components/p-54fe93d8.entry.js +0 -17
- package/dist/mint-components/p-571e6814.system.js +0 -1
- package/dist/mint-components/p-b1205f52.js +0 -1
- package/dist/mint-components/p-b7c2b39f.system.entry.js +0 -1
|
@@ -9,7 +9,6 @@ const style = {
|
|
|
9
9
|
maxWidth: "390px !important",
|
|
10
10
|
},
|
|
11
11
|
Container: {
|
|
12
|
-
padding: "var(--sl-spacing-small)",
|
|
13
12
|
display: "flex",
|
|
14
13
|
flexDirection: "row",
|
|
15
14
|
gap: "var(--sl-spacing-small)",
|
|
@@ -67,7 +66,7 @@ const vanillaStyle = `
|
|
|
67
66
|
display: block;
|
|
68
67
|
}
|
|
69
68
|
}`;
|
|
70
|
-
function QrCodeView({ dialogIsOpen, error, showDialog, hideDialog, qrLink, titleText, viewCodeText, downloadCodeText, printCodeText, errorHeaderText, errorDescriptionText, createDownloadable, createPrintable, }) {
|
|
69
|
+
function QrCodeView({ dialogIsOpen, error, viewError, showDialog, hideDialog, qrLink, titleText, viewCodeText, downloadCodeText, printCodeText, errorHeaderText, errorDescriptionText, createDownloadable, createPrintable, }) {
|
|
71
70
|
return (index.h("div", { class: sheet.classes.Container, part: "sqm-base" },
|
|
72
71
|
index.h("style", null, vanillaStyle),
|
|
73
72
|
index.h("style", null, styleString),
|
|
@@ -79,9 +78,9 @@ function QrCodeView({ dialogIsOpen, error, showDialog, hideDialog, qrLink, title
|
|
|
79
78
|
index.h("sl-button", { type: "text", onClick: createDownloadable }, downloadCodeText),
|
|
80
79
|
index.h("sl-button", { type: "text", onClick: createPrintable }, printCodeText))),
|
|
81
80
|
index.h("sl-dialog", { class: sheet.classes.DialogContainer, width: "250px", open: dialogIsOpen, label: titleText, "onSl-hide": hideDialog },
|
|
82
|
-
error && (index.h(ErrorView.ErrorView, { loadingErrorAlertDescription: errorHeaderText, loadingErrorAlertHeader: errorDescriptionText })),
|
|
83
|
-
index.h("div", { class: sheet.classes.CodeContainer },
|
|
84
|
-
index.h("img", { class: sheet.classes.Code, src:
|
|
81
|
+
(viewError || error) && (index.h(ErrorView.ErrorView, { loadingErrorAlertDescription: errorHeaderText, loadingErrorAlertHeader: errorDescriptionText })),
|
|
82
|
+
qrLink && (index.h("div", { class: sheet.classes.CodeContainer },
|
|
83
|
+
index.h("img", { class: sheet.classes.Code, src: qrLink }))),
|
|
85
84
|
index.h("div", { slot: "footer", class: sheet.classes.FooterContainer },
|
|
86
85
|
index.h("sl-button", { disabled: error, variant: "default", onClick: createDownloadable }, downloadCodeText),
|
|
87
86
|
index.h("sl-button", { disabled: error, variant: "default", onClick: createPrintable }, printCodeText)))));
|
|
@@ -10,7 +10,7 @@ const utils = require('./utils-6847bc06.js');
|
|
|
10
10
|
require('./JSS-8503a151.js');
|
|
11
11
|
const useReferralCodes = require('./useReferralCodes-82e8797b.js');
|
|
12
12
|
require('./ErrorView-b2fcf954.js');
|
|
13
|
-
const sqmQrCodeView = require('./sqm-qr-code-view-
|
|
13
|
+
const sqmQrCodeView = require('./sqm-qr-code-view-82b14685.js');
|
|
14
14
|
|
|
15
15
|
const ShareLinkQuery = index_module.dist.gql `
|
|
16
16
|
query shareLink($programId: ID, $engagementMedium: UserEngagementMedium!) {
|
|
@@ -31,15 +31,35 @@ const WIDGET_ENGAGEMENT_EVENT = index_module.dist.gql `
|
|
|
31
31
|
}
|
|
32
32
|
`;
|
|
33
33
|
function useQRCode(props) {
|
|
34
|
+
var _a;
|
|
34
35
|
const programId = index_module.H();
|
|
35
36
|
const user = index_module.J();
|
|
36
37
|
const engagementMedium = index_module.B();
|
|
37
38
|
const contextData = index_module.Fn(useReferralCodes.REFERRAL_CODES_NAMESPACE);
|
|
38
39
|
const [dialogIsOpen, setDialog] = stencilHooks_module.useState(false);
|
|
40
|
+
const [qrLink, setQrUrl] = stencilHooks_module.useState(null);
|
|
39
41
|
const [error, setError] = stencilHooks_module.useState(false);
|
|
40
|
-
const
|
|
42
|
+
const [viewError, setViewError] = stencilHooks_module.useState(false);
|
|
43
|
+
const { data, errors } = index_module.wn(ShareLinkQuery, { programId, engagementMedium }, !(user === null || user === void 0 ? void 0 : user.jwt) || (contextData === null || contextData === void 0 ? void 0 : contextData.shareLink) !== undefined);
|
|
41
44
|
const [sendLoadEvent] = index_module.$e(WIDGET_ENGAGEMENT_EVENT);
|
|
42
|
-
const
|
|
45
|
+
const shareLink = (_a = data === null || data === void 0 ? void 0 : data.user) === null || _a === void 0 ? void 0 : _a.shareLink;
|
|
46
|
+
const qrPrefix = `${shareLink}?qrCode`;
|
|
47
|
+
stencilHooks_module.useEffect(() => {
|
|
48
|
+
if (!shareLink)
|
|
49
|
+
return;
|
|
50
|
+
const getQrCode = async () => {
|
|
51
|
+
try {
|
|
52
|
+
const res = await fetch(`${shareLink}?qrCode&qrCodeImageFormat=svg`);
|
|
53
|
+
const blob = await res.blob();
|
|
54
|
+
const url = URL.createObjectURL(blob);
|
|
55
|
+
setQrUrl(url);
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
setViewError(true);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
getQrCode();
|
|
62
|
+
}, [shareLink]);
|
|
43
63
|
const fireEvent = async () => {
|
|
44
64
|
sendLoadEvent({
|
|
45
65
|
eventMeta: {
|
|
@@ -56,7 +76,7 @@ function useQRCode(props) {
|
|
|
56
76
|
};
|
|
57
77
|
const createDownloadable = async () => {
|
|
58
78
|
try {
|
|
59
|
-
const res = await fetch(`${
|
|
79
|
+
const res = await fetch(`${qrPrefix}&qrCodeSize=800&qrCodeImageFormat=png`);
|
|
60
80
|
const blob = await res.blob();
|
|
61
81
|
const url = URL.createObjectURL(blob);
|
|
62
82
|
// Successful
|
|
@@ -77,7 +97,7 @@ function useQRCode(props) {
|
|
|
77
97
|
};
|
|
78
98
|
const createPrintable = async () => {
|
|
79
99
|
try {
|
|
80
|
-
const res = await fetch(`${
|
|
100
|
+
const res = await fetch(`${qrPrefix}&qrCodeSize=1000&qrCodeImageFormat=png&qrCodeErrorCorrectionLevel=H`);
|
|
81
101
|
const blob = await res.blob();
|
|
82
102
|
const url = URL.createObjectURL(blob);
|
|
83
103
|
// Successful
|
|
@@ -102,7 +122,8 @@ function useQRCode(props) {
|
|
|
102
122
|
...props,
|
|
103
123
|
qrLink,
|
|
104
124
|
dialogIsOpen,
|
|
105
|
-
error,
|
|
125
|
+
error: error,
|
|
126
|
+
viewError: viewError || !!(errors === null || errors === void 0 ? void 0 : errors.message),
|
|
106
127
|
showDialog: () => {
|
|
107
128
|
setError(false);
|
|
108
129
|
setDialog(true);
|
|
@@ -34,7 +34,7 @@ require('./utilities-78f5e169.js');
|
|
|
34
34
|
const sqmPortalResetPasswordView = require('./sqm-portal-reset-password-view-fe602822.js');
|
|
35
35
|
const sqmPortalVerifyEmailView = require('./sqm-portal-verify-email-view-7b678f34.js');
|
|
36
36
|
require('./ErrorView-b2fcf954.js');
|
|
37
|
-
const sqmQrCodeView = require('./sqm-qr-code-view-
|
|
37
|
+
const sqmQrCodeView = require('./sqm-qr-code-view-82b14685.js');
|
|
38
38
|
const ShadowViewAddon = require('./ShadowViewAddon-3ddee92b.js');
|
|
39
39
|
const sqmPortalContainerView = require('./sqm-portal-container-view-4f15143a.js');
|
|
40
40
|
const sqmInvoiceTableView = require('./sqm-invoice-table-view-16ac73d0.js');
|
|
@@ -15680,6 +15680,7 @@ const QRCode_stories = {
|
|
|
15680
15680
|
const defaultProps$r = {
|
|
15681
15681
|
dialogIsOpen: false,
|
|
15682
15682
|
error: false,
|
|
15683
|
+
viewError: false,
|
|
15683
15684
|
showDialog: () => void 0,
|
|
15684
15685
|
hideDialog: () => void 0,
|
|
15685
15686
|
qrLink: "https://media.istockphoto.com/id/1251071788/vector/qr-code-bar-code-black-icon-digital-technology.jpg?s=612x612&w=0&k=20&c=maw4OqMSEegAdSo8Drm9HO7i1ddddvP2YaL1UuWbRig=",
|
|
@@ -15703,7 +15704,10 @@ const Expanded = () => {
|
|
|
15703
15704
|
return index.h(sqmQrCodeView.QrCodeView, Object.assign({}, defaultProps$r, { dialogIsOpen: true }));
|
|
15704
15705
|
};
|
|
15705
15706
|
const Error$b = () => {
|
|
15706
|
-
return (index.h(sqmQrCodeView.QrCodeView, Object.assign({}, defaultProps$r, { dialogIsOpen: true,
|
|
15707
|
+
return (index.h(sqmQrCodeView.QrCodeView, Object.assign({}, defaultProps$r, { dialogIsOpen: true, viewError: true })));
|
|
15708
|
+
};
|
|
15709
|
+
const DownloadError = () => {
|
|
15710
|
+
return (index.h(sqmQrCodeView.QrCodeView, Object.assign({}, defaultProps$r, { dialogIsOpen: false, error: true })));
|
|
15707
15711
|
};
|
|
15708
15712
|
|
|
15709
15713
|
const QRCode = /*#__PURE__*/Object.freeze({
|
|
@@ -15711,7 +15715,8 @@ const QRCode = /*#__PURE__*/Object.freeze({
|
|
|
15711
15715
|
'default': QRCode_stories,
|
|
15712
15716
|
Default: Default$o,
|
|
15713
15717
|
Expanded: Expanded,
|
|
15714
|
-
Error: Error$b
|
|
15718
|
+
Error: Error$b,
|
|
15719
|
+
DownloadError: DownloadError
|
|
15715
15720
|
});
|
|
15716
15721
|
|
|
15717
15722
|
/**
|
|
@@ -6,6 +6,7 @@ export default {
|
|
|
6
6
|
const defaultProps = {
|
|
7
7
|
dialogIsOpen: false,
|
|
8
8
|
error: false,
|
|
9
|
+
viewError: false,
|
|
9
10
|
showDialog: () => void 0,
|
|
10
11
|
hideDialog: () => void 0,
|
|
11
12
|
qrLink: "https://media.istockphoto.com/id/1251071788/vector/qr-code-bar-code-black-icon-digital-technology.jpg?s=612x612&w=0&k=20&c=maw4OqMSEegAdSo8Drm9HO7i1ddddvP2YaL1UuWbRig=",
|
|
@@ -29,5 +30,8 @@ export const Expanded = () => {
|
|
|
29
30
|
return h(QrCodeView, Object.assign({}, defaultProps, { dialogIsOpen: true }));
|
|
30
31
|
};
|
|
31
32
|
export const Error = () => {
|
|
32
|
-
return (h(QrCodeView, Object.assign({}, defaultProps, { dialogIsOpen: true,
|
|
33
|
+
return (h(QrCodeView, Object.assign({}, defaultProps, { dialogIsOpen: true, viewError: true })));
|
|
34
|
+
};
|
|
35
|
+
export const DownloadError = () => {
|
|
36
|
+
return (h(QrCodeView, Object.assign({}, defaultProps, { dialogIsOpen: false, error: true })));
|
|
33
37
|
};
|
|
@@ -6,7 +6,6 @@ const style = {
|
|
|
6
6
|
maxWidth: "390px !important",
|
|
7
7
|
},
|
|
8
8
|
Container: {
|
|
9
|
-
padding: "var(--sl-spacing-small)",
|
|
10
9
|
display: "flex",
|
|
11
10
|
flexDirection: "row",
|
|
12
11
|
gap: "var(--sl-spacing-small)",
|
|
@@ -64,7 +63,7 @@ const vanillaStyle = `
|
|
|
64
63
|
display: block;
|
|
65
64
|
}
|
|
66
65
|
}`;
|
|
67
|
-
export function QrCodeView({ dialogIsOpen, error, showDialog, hideDialog, qrLink, titleText, viewCodeText, downloadCodeText, printCodeText, errorHeaderText, errorDescriptionText, createDownloadable, createPrintable, }) {
|
|
66
|
+
export function QrCodeView({ dialogIsOpen, error, viewError, showDialog, hideDialog, qrLink, titleText, viewCodeText, downloadCodeText, printCodeText, errorHeaderText, errorDescriptionText, createDownloadable, createPrintable, }) {
|
|
68
67
|
return (h("div", { class: sheet.classes.Container, part: "sqm-base" },
|
|
69
68
|
h("style", null, vanillaStyle),
|
|
70
69
|
h("style", null, styleString),
|
|
@@ -76,9 +75,9 @@ export function QrCodeView({ dialogIsOpen, error, showDialog, hideDialog, qrLink
|
|
|
76
75
|
h("sl-button", { type: "text", onClick: createDownloadable }, downloadCodeText),
|
|
77
76
|
h("sl-button", { type: "text", onClick: createPrintable }, printCodeText))),
|
|
78
77
|
h("sl-dialog", { class: sheet.classes.DialogContainer, width: "250px", open: dialogIsOpen, label: titleText, "onSl-hide": hideDialog },
|
|
79
|
-
error && (h(ErrorView, { loadingErrorAlertDescription: errorHeaderText, loadingErrorAlertHeader: errorDescriptionText })),
|
|
80
|
-
h("div", { class: sheet.classes.CodeContainer },
|
|
81
|
-
h("img", { class: sheet.classes.Code, src:
|
|
78
|
+
(viewError || error) && (h(ErrorView, { loadingErrorAlertDescription: errorHeaderText, loadingErrorAlertHeader: errorDescriptionText })),
|
|
79
|
+
qrLink && (h("div", { class: sheet.classes.CodeContainer },
|
|
80
|
+
h("img", { class: sheet.classes.Code, src: qrLink }))),
|
|
82
81
|
h("div", { slot: "footer", class: sheet.classes.FooterContainer },
|
|
83
82
|
h("sl-button", { disabled: error, variant: "default", onClick: createDownloadable }, downloadCodeText),
|
|
84
83
|
h("sl-button", { disabled: error, variant: "default", onClick: createPrintable }, printCodeText)))));
|
|
@@ -178,7 +178,7 @@ export class QrCode {
|
|
|
178
178
|
"mutable": false,
|
|
179
179
|
"complexType": {
|
|
180
180
|
"original": "DemoData<QRCodeViewProps>",
|
|
181
|
-
"resolved": "{ titleText?: string; error?: boolean; dialogIsOpen?: boolean; showDialog?: () => void; hideDialog?: () => void; qrLink?: string; createDownloadable?: () => void; viewCodeText?: string; downloadCodeText?: string; printCodeText?: string; errorHeaderText?: string; errorDescriptionText?: string; createPrintable?: () => void; }",
|
|
181
|
+
"resolved": "{ titleText?: string; error?: boolean; dialogIsOpen?: boolean; viewError?: boolean; showDialog?: () => void; hideDialog?: () => void; qrLink?: string; createDownloadable?: () => void; viewCodeText?: string; downloadCodeText?: string; printCodeText?: string; errorHeaderText?: string; errorDescriptionText?: string; createPrintable?: () => void; }",
|
|
182
182
|
"references": {
|
|
183
183
|
"DemoData": {
|
|
184
184
|
"location": "import",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useEngagementMedium, useMutation, useParentValue, useProgramId, useQuery, useUserIdentity, } from "@saasquatch/component-boilerplate";
|
|
2
2
|
import { useState } from "@saasquatch/stencil-hooks";
|
|
3
|
+
import { useEffect } from "@saasquatch/universal-hooks";
|
|
3
4
|
import { gql } from "graphql-request";
|
|
4
5
|
import { REFERRAL_CODES_NAMESPACE, } from "../sqm-referral-codes/useReferralCodes";
|
|
5
6
|
const ShareLinkQuery = gql `
|
|
@@ -21,15 +22,35 @@ const WIDGET_ENGAGEMENT_EVENT = gql `
|
|
|
21
22
|
}
|
|
22
23
|
`;
|
|
23
24
|
export function useQRCode(props) {
|
|
25
|
+
var _a;
|
|
24
26
|
const programId = useProgramId();
|
|
25
27
|
const user = useUserIdentity();
|
|
26
28
|
const engagementMedium = useEngagementMedium();
|
|
27
29
|
const contextData = useParentValue(REFERRAL_CODES_NAMESPACE);
|
|
28
30
|
const [dialogIsOpen, setDialog] = useState(false);
|
|
31
|
+
const [qrLink, setQrUrl] = useState(null);
|
|
29
32
|
const [error, setError] = useState(false);
|
|
30
|
-
const
|
|
33
|
+
const [viewError, setViewError] = useState(false);
|
|
34
|
+
const { data, errors } = useQuery(ShareLinkQuery, { programId, engagementMedium }, !(user === null || user === void 0 ? void 0 : user.jwt) || (contextData === null || contextData === void 0 ? void 0 : contextData.shareLink) !== undefined);
|
|
31
35
|
const [sendLoadEvent] = useMutation(WIDGET_ENGAGEMENT_EVENT);
|
|
32
|
-
const
|
|
36
|
+
const shareLink = (_a = data === null || data === void 0 ? void 0 : data.user) === null || _a === void 0 ? void 0 : _a.shareLink;
|
|
37
|
+
const qrPrefix = `${shareLink}?qrCode`;
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (!shareLink)
|
|
40
|
+
return;
|
|
41
|
+
const getQrCode = async () => {
|
|
42
|
+
try {
|
|
43
|
+
const res = await fetch(`${shareLink}?qrCode&qrCodeImageFormat=svg`);
|
|
44
|
+
const blob = await res.blob();
|
|
45
|
+
const url = URL.createObjectURL(blob);
|
|
46
|
+
setQrUrl(url);
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
setViewError(true);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
getQrCode();
|
|
53
|
+
}, [shareLink]);
|
|
33
54
|
const fireEvent = async () => {
|
|
34
55
|
sendLoadEvent({
|
|
35
56
|
eventMeta: {
|
|
@@ -46,7 +67,7 @@ export function useQRCode(props) {
|
|
|
46
67
|
};
|
|
47
68
|
const createDownloadable = async () => {
|
|
48
69
|
try {
|
|
49
|
-
const res = await fetch(`${
|
|
70
|
+
const res = await fetch(`${qrPrefix}&qrCodeSize=800&qrCodeImageFormat=png`);
|
|
50
71
|
const blob = await res.blob();
|
|
51
72
|
const url = URL.createObjectURL(blob);
|
|
52
73
|
// Successful
|
|
@@ -67,7 +88,7 @@ export function useQRCode(props) {
|
|
|
67
88
|
};
|
|
68
89
|
const createPrintable = async () => {
|
|
69
90
|
try {
|
|
70
|
-
const res = await fetch(`${
|
|
91
|
+
const res = await fetch(`${qrPrefix}&qrCodeSize=1000&qrCodeImageFormat=png&qrCodeErrorCorrectionLevel=H`);
|
|
71
92
|
const blob = await res.blob();
|
|
72
93
|
const url = URL.createObjectURL(blob);
|
|
73
94
|
// Successful
|
|
@@ -92,7 +113,8 @@ export function useQRCode(props) {
|
|
|
92
113
|
...props,
|
|
93
114
|
qrLink,
|
|
94
115
|
dialogIsOpen,
|
|
95
|
-
error,
|
|
116
|
+
error: error,
|
|
117
|
+
viewError: viewError || !!(errors === null || errors === void 0 ? void 0 : errors.message),
|
|
96
118
|
showDialog: () => {
|
|
97
119
|
setError(false);
|
|
98
120
|
setDialog(true);
|
|
@@ -7,7 +7,6 @@ const style = {
|
|
|
7
7
|
maxWidth: "390px !important",
|
|
8
8
|
},
|
|
9
9
|
Container: {
|
|
10
|
-
padding: "var(--sl-spacing-small)",
|
|
11
10
|
display: "flex",
|
|
12
11
|
flexDirection: "row",
|
|
13
12
|
gap: "var(--sl-spacing-small)",
|
|
@@ -65,7 +64,7 @@ const vanillaStyle = `
|
|
|
65
64
|
display: block;
|
|
66
65
|
}
|
|
67
66
|
}`;
|
|
68
|
-
function QrCodeView({ dialogIsOpen, error, showDialog, hideDialog, qrLink, titleText, viewCodeText, downloadCodeText, printCodeText, errorHeaderText, errorDescriptionText, createDownloadable, createPrintable, }) {
|
|
67
|
+
function QrCodeView({ dialogIsOpen, error, viewError, showDialog, hideDialog, qrLink, titleText, viewCodeText, downloadCodeText, printCodeText, errorHeaderText, errorDescriptionText, createDownloadable, createPrintable, }) {
|
|
69
68
|
return (h("div", { class: sheet.classes.Container, part: "sqm-base" },
|
|
70
69
|
h("style", null, vanillaStyle),
|
|
71
70
|
h("style", null, styleString),
|
|
@@ -77,9 +76,9 @@ function QrCodeView({ dialogIsOpen, error, showDialog, hideDialog, qrLink, title
|
|
|
77
76
|
h("sl-button", { type: "text", onClick: createDownloadable }, downloadCodeText),
|
|
78
77
|
h("sl-button", { type: "text", onClick: createPrintable }, printCodeText))),
|
|
79
78
|
h("sl-dialog", { class: sheet.classes.DialogContainer, width: "250px", open: dialogIsOpen, label: titleText, "onSl-hide": hideDialog },
|
|
80
|
-
error && (h(ErrorView, { loadingErrorAlertDescription: errorHeaderText, loadingErrorAlertHeader: errorDescriptionText })),
|
|
81
|
-
h("div", { class: sheet.classes.CodeContainer },
|
|
82
|
-
h("img", { class: sheet.classes.Code, src:
|
|
79
|
+
(viewError || error) && (h(ErrorView, { loadingErrorAlertDescription: errorHeaderText, loadingErrorAlertHeader: errorDescriptionText })),
|
|
80
|
+
qrLink && (h("div", { class: sheet.classes.CodeContainer },
|
|
81
|
+
h("img", { class: sheet.classes.Code, src: qrLink }))),
|
|
83
82
|
h("div", { slot: "footer", class: sheet.classes.FooterContainer },
|
|
84
83
|
h("sl-button", { disabled: error, variant: "default", onClick: createDownloadable }, downloadCodeText),
|
|
85
84
|
h("sl-button", { disabled: error, variant: "default", onClick: createPrintable }, printCodeText)))));
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { r as registerInstance, h as h$1 } from './index-91e7729f.js';
|
|
2
|
-
import { k as useState, n as h } from './stencil-hooks.module-4bc38af4.js';
|
|
2
|
+
import { k as useState, f as useEffect, n as h } from './stencil-hooks.module-4bc38af4.js';
|
|
3
3
|
import { d as dist, H, J, F as Fn, w as wn, $ as $e, B, i as isDemo } from './index.module-89a79f66.js';
|
|
4
4
|
import { c as cjs } from './cjs-bdfb4486.js';
|
|
5
5
|
import { g as getProps } from './utils-334c1e34.js';
|
|
6
6
|
import './JSS-67b5cff8.js';
|
|
7
7
|
import { a as REFERRAL_CODES_NAMESPACE } from './useReferralCodes-8f75921a.js';
|
|
8
8
|
import './ErrorView-48e2b969.js';
|
|
9
|
-
import { Q as QrCodeView } from './sqm-qr-code-view-
|
|
9
|
+
import { Q as QrCodeView } from './sqm-qr-code-view-2dff1823.js';
|
|
10
10
|
|
|
11
11
|
const ShareLinkQuery = dist.gql `
|
|
12
12
|
query shareLink($programId: ID, $engagementMedium: UserEngagementMedium!) {
|
|
@@ -27,15 +27,35 @@ const WIDGET_ENGAGEMENT_EVENT = dist.gql `
|
|
|
27
27
|
}
|
|
28
28
|
`;
|
|
29
29
|
function useQRCode(props) {
|
|
30
|
+
var _a;
|
|
30
31
|
const programId = H();
|
|
31
32
|
const user = J();
|
|
32
33
|
const engagementMedium = B();
|
|
33
34
|
const contextData = Fn(REFERRAL_CODES_NAMESPACE);
|
|
34
35
|
const [dialogIsOpen, setDialog] = useState(false);
|
|
36
|
+
const [qrLink, setQrUrl] = useState(null);
|
|
35
37
|
const [error, setError] = useState(false);
|
|
36
|
-
const
|
|
38
|
+
const [viewError, setViewError] = useState(false);
|
|
39
|
+
const { data, errors } = wn(ShareLinkQuery, { programId, engagementMedium }, !(user === null || user === void 0 ? void 0 : user.jwt) || (contextData === null || contextData === void 0 ? void 0 : contextData.shareLink) !== undefined);
|
|
37
40
|
const [sendLoadEvent] = $e(WIDGET_ENGAGEMENT_EVENT);
|
|
38
|
-
const
|
|
41
|
+
const shareLink = (_a = data === null || data === void 0 ? void 0 : data.user) === null || _a === void 0 ? void 0 : _a.shareLink;
|
|
42
|
+
const qrPrefix = `${shareLink}?qrCode`;
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (!shareLink)
|
|
45
|
+
return;
|
|
46
|
+
const getQrCode = async () => {
|
|
47
|
+
try {
|
|
48
|
+
const res = await fetch(`${shareLink}?qrCode&qrCodeImageFormat=svg`);
|
|
49
|
+
const blob = await res.blob();
|
|
50
|
+
const url = URL.createObjectURL(blob);
|
|
51
|
+
setQrUrl(url);
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
setViewError(true);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
getQrCode();
|
|
58
|
+
}, [shareLink]);
|
|
39
59
|
const fireEvent = async () => {
|
|
40
60
|
sendLoadEvent({
|
|
41
61
|
eventMeta: {
|
|
@@ -52,7 +72,7 @@ function useQRCode(props) {
|
|
|
52
72
|
};
|
|
53
73
|
const createDownloadable = async () => {
|
|
54
74
|
try {
|
|
55
|
-
const res = await fetch(`${
|
|
75
|
+
const res = await fetch(`${qrPrefix}&qrCodeSize=800&qrCodeImageFormat=png`);
|
|
56
76
|
const blob = await res.blob();
|
|
57
77
|
const url = URL.createObjectURL(blob);
|
|
58
78
|
// Successful
|
|
@@ -73,7 +93,7 @@ function useQRCode(props) {
|
|
|
73
93
|
};
|
|
74
94
|
const createPrintable = async () => {
|
|
75
95
|
try {
|
|
76
|
-
const res = await fetch(`${
|
|
96
|
+
const res = await fetch(`${qrPrefix}&qrCodeSize=1000&qrCodeImageFormat=png&qrCodeErrorCorrectionLevel=H`);
|
|
77
97
|
const blob = await res.blob();
|
|
78
98
|
const url = URL.createObjectURL(blob);
|
|
79
99
|
// Successful
|
|
@@ -98,7 +118,8 @@ function useQRCode(props) {
|
|
|
98
118
|
...props,
|
|
99
119
|
qrLink,
|
|
100
120
|
dialogIsOpen,
|
|
101
|
-
error,
|
|
121
|
+
error: error,
|
|
122
|
+
viewError: viewError || !!(errors === null || errors === void 0 ? void 0 : errors.message),
|
|
102
123
|
showDialog: () => {
|
|
103
124
|
setError(false);
|
|
104
125
|
setDialog(true);
|
|
@@ -30,7 +30,7 @@ import './utilities-5b0ca040.js';
|
|
|
30
30
|
import { P as PortalResetPasswordView } from './sqm-portal-reset-password-view-54a8651f.js';
|
|
31
31
|
import { P as PortalVerifyEmailView } from './sqm-portal-verify-email-view-b12cb894.js';
|
|
32
32
|
import './ErrorView-48e2b969.js';
|
|
33
|
-
import { Q as QrCodeView } from './sqm-qr-code-view-
|
|
33
|
+
import { Q as QrCodeView } from './sqm-qr-code-view-2dff1823.js';
|
|
34
34
|
import { S as ShareButtonView, L as LeaderboardView, B as BigStatView, P as PortalFrameView, E as EditProfileView, u as useShareLink, a as useShareButton, b as useDemoBigStat, c as StatContainerView, d as PortalChangePasswordView, e as PortalRegisterView, T as TaskCardView, f as ProgressBarView, g as PoweredByImg$1, h as PortalFooterView, H as HeroView, R as ReferralIframeView, N as NameFieldsView, C as CheckboxFieldView, D as DropdownFieldView, I as InputFieldView, i as RewardExchangeView, r as rewardExchangeCustomErrorMsg, j as rewardExchangeLongText, k as rewardExchangeSelected, l as chooseAmountFixed, m as chooseAmountFixedNoDescription, n as chooseAmountVariable, o as chooseAmountVariableNoDescription, p as chooseAmountVariableDisabled, q as chooseAmountVariableUnavailable, s as confirmFixed, t as confirmVariable, v as redemptionError, w as queryError, x as success, y as successVariable, z as loading, A as empty$1, F as rewardExchange, G as CardFeedView, J as CouponCodeView, K as ProgressBar$2, M as autoColorScaleCss, O as ShadowViewAddon } from './ShadowViewAddon-499b1f86.js';
|
|
35
35
|
import { P as PortalContainerView, a as PortalSectionView } from './sqm-portal-container-view-1683ae32.js';
|
|
36
36
|
import { O as OtherRegionSlotView, I as InvoiceTableView, T as TaxForm } from './sqm-invoice-table-view-2c726568.js';
|
|
@@ -15676,6 +15676,7 @@ const QRCode_stories = {
|
|
|
15676
15676
|
const defaultProps$r = {
|
|
15677
15677
|
dialogIsOpen: false,
|
|
15678
15678
|
error: false,
|
|
15679
|
+
viewError: false,
|
|
15679
15680
|
showDialog: () => void 0,
|
|
15680
15681
|
hideDialog: () => void 0,
|
|
15681
15682
|
qrLink: "https://media.istockphoto.com/id/1251071788/vector/qr-code-bar-code-black-icon-digital-technology.jpg?s=612x612&w=0&k=20&c=maw4OqMSEegAdSo8Drm9HO7i1ddddvP2YaL1UuWbRig=",
|
|
@@ -15699,7 +15700,10 @@ const Expanded = () => {
|
|
|
15699
15700
|
return h(QrCodeView, Object.assign({}, defaultProps$r, { dialogIsOpen: true }));
|
|
15700
15701
|
};
|
|
15701
15702
|
const Error$b = () => {
|
|
15702
|
-
return (h(QrCodeView, Object.assign({}, defaultProps$r, { dialogIsOpen: true,
|
|
15703
|
+
return (h(QrCodeView, Object.assign({}, defaultProps$r, { dialogIsOpen: true, viewError: true })));
|
|
15704
|
+
};
|
|
15705
|
+
const DownloadError = () => {
|
|
15706
|
+
return (h(QrCodeView, Object.assign({}, defaultProps$r, { dialogIsOpen: false, error: true })));
|
|
15703
15707
|
};
|
|
15704
15708
|
|
|
15705
15709
|
const QRCode = /*#__PURE__*/Object.freeze({
|
|
@@ -15707,7 +15711,8 @@ const QRCode = /*#__PURE__*/Object.freeze({
|
|
|
15707
15711
|
'default': QRCode_stories,
|
|
15708
15712
|
Default: Default$o,
|
|
15709
15713
|
Expanded: Expanded,
|
|
15710
|
-
Error: Error$b
|
|
15714
|
+
Error: Error$b,
|
|
15715
|
+
DownloadError: DownloadError
|
|
15711
15716
|
});
|
|
15712
15717
|
|
|
15713
15718
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h}from"./index-91e7729f.js";import{c as createStyleSheet}from"./JSS-67b5cff8.js";import{E as ErrorView}from"./ErrorView-48e2b969.js";var style={DialogContainer:{maxWidth:"390px !important"},Container:{display:"flex",flexDirection:"row",gap:"var(--sl-spacing-small)",justifyContent:"space-between"},FacadeContainer:{display:"flex",gap:"var(--sl-spacing-medium)",flexDirection:"column"},ButtonContainer:{display:"flex",gap:"var(--sl-spacing-medium)"},FooterContainer:{textAlign:"left",display:"flex",flexDirection:"column",gap:"var(--sl-spacing-medium)"},CodeContainer:{display:"flex",width:"100%",alignItems:"center",justifyContent:"center"},Code:{width:"100%",height:"100%",maxWidth:"335px"}};var sheet=createStyleSheet(style);var styleString=sheet.toString();var vanillaStyle="\n sl-dialog::part(panel) {\n max-width: 390px;\n width: 100%;\n }\n sl-dialog::part(footer) {\n display: flex;\n flex-direction: column;\n gap: var(--sl-spacing-small);\n width: 100%;\n }\n sl-dialog::part(body) {\n padding: 0 var(--sl-spacing-large);\n }\n :host{\n display: flex;\n width: 100%;\n }\n @media (max-width: 499px) {\n :host{\n display: block;\n }\n }";function QrCodeView(e){var t=e.dialogIsOpen,a=e.error,i=e.viewError,l=e.showDialog,r=e.hideDialog,n=e.qrLink,s=e.titleText,o=e.viewCodeText,d=e.downloadCodeText,c=e.printCodeText,p=e.errorHeaderText,g=e.errorDescriptionText,x=e.createDownloadable,m=e.createPrintable;return h("div",{class:sheet.classes.Container,part:"sqm-base"},h("style",null,vanillaStyle),h("style",null,styleString),h("div",{class:sheet.classes.FacadeContainer},a&&h(ErrorView,{loadingErrorAlertDescription:p,loadingErrorAlertHeader:g}),h("span",{part:"sqm-title"},s),h("div",{class:sheet.classes.ButtonContainer},h("sl-button",{type:"primary",onClick:l},o),h("sl-button",{type:"text",onClick:x},d),h("sl-button",{type:"text",onClick:m},c))),h("sl-dialog",{class:sheet.classes.DialogContainer,width:"250px",open:t,label:s,"onSl-hide":r},(i||a)&&h(ErrorView,{loadingErrorAlertDescription:p,loadingErrorAlertHeader:g}),n&&h("div",{class:sheet.classes.CodeContainer},h("img",{class:sheet.classes.Code,src:n})),h("div",{slot:"footer",class:sheet.classes.FooterContainer},h("sl-button",{disabled:a,variant:"default",onClick:x},d),h("sl-button",{disabled:a,variant:"default",onClick:m},c))))}export{QrCodeView as Q};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var __makeTemplateObject=this&&this.__makeTemplateObject||function(e,t){if(Object.defineProperty){Object.defineProperty(e,"raw",{value:t})}else{e.raw=t}return e};var __assign=this&&this.__assign||function(){__assign=Object.assign||function(e){for(var t,
|
|
1
|
+
var __makeTemplateObject=this&&this.__makeTemplateObject||function(e,t){if(Object.defineProperty){Object.defineProperty(e,"raw",{value:t})}else{e.raw=t}return e};var __assign=this&&this.__assign||function(){__assign=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var a in t)if(Object.prototype.hasOwnProperty.call(t,a))e[a]=t[a]}return e};return __assign.apply(this,arguments)};var __awaiter=this&&this.__awaiter||function(e,t,r,n){function a(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,o){function i(e){try{c(n.next(e))}catch(e){o(e)}}function s(e){try{c(n["throw"](e))}catch(e){o(e)}}function c(e){e.done?r(e.value):a(e.value).then(i,s)}c((n=n.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,a,o,i;return i={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function s(e){return function(t){return c([e,t])}}function c(i){if(n)throw new TypeError("Generator is already executing.");while(r)try{if(n=1,a&&(o=i[0]&2?a["return"]:i[0]?a["throw"]||((o=a["return"])&&o.call(a),0):a.next)&&!(o=o.call(a,i[1])).done)return o;if(a=0,o)i=[i[0]&2,o.value];switch(i[0]){case 0:case 1:o=i;break;case 4:r.label++;return{value:i[1],done:false};case 5:r.label++;a=i[1];i=[0];continue;case 7:i=r.ops.pop();r.trys.pop();continue;default:if(!(o=r.trys,o=o.length>0&&o[o.length-1])&&(i[0]===6||i[0]===2)){r=0;continue}if(i[0]===3&&(!o||i[1]>o[0]&&i[1]<o[3])){r.label=i[1];break}if(i[0]===6&&r.label<o[1]){r.label=o[1];o=i;break}if(o&&r.label<o[2]){r.label=o[2];r.ops.push(i);break}if(o[2])r.ops.pop();r.trys.pop();continue}i=t.call(e,r)}catch(e){i=[6,e];a=0}finally{n=o=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:true}}};import{r as registerInstance,h as h$1}from"./index-91e7729f.js";import{k as useState,f as useEffect,n as h}from"./stencil-hooks.module-4bc38af4.js";import{d as dist,H,J,F as Fn,w as wn,$ as $e,B,i as isDemo}from"./index.module-89a79f66.js";import{c as cjs}from"./cjs-bdfb4486.js";import{g as getProps}from"./utils-334c1e34.js";import"./JSS-67b5cff8.js";import{a as REFERRAL_CODES_NAMESPACE}from"./useReferralCodes-8f75921a.js";import"./ErrorView-48e2b969.js";import{Q as QrCodeView}from"./sqm-qr-code-view-2dff1823.js";var ShareLinkQuery=dist.gql(templateObject_1||(templateObject_1=__makeTemplateObject(["\n query shareLink($programId: ID, $engagementMedium: UserEngagementMedium!) {\n user: viewer {\n ... on User {\n shareLink(\n programId: $programId\n engagementMedium: $engagementMedium\n shareMedium: DIRECT\n )\n }\n }\n }\n"],["\n query shareLink($programId: ID, $engagementMedium: UserEngagementMedium!) {\n user: viewer {\n ... on User {\n shareLink(\n programId: $programId\n engagementMedium: $engagementMedium\n shareMedium: DIRECT\n )\n }\n }\n }\n"])));var WIDGET_ENGAGEMENT_EVENT=dist.gql(templateObject_2||(templateObject_2=__makeTemplateObject(["\n mutation loadEvent($eventMeta: UserAnalyticsEvent!) {\n createUserAnalyticsEvent(eventMeta: $eventMeta)\n }\n"],["\n mutation loadEvent($eventMeta: UserAnalyticsEvent!) {\n createUserAnalyticsEvent(eventMeta: $eventMeta)\n }\n"])));function useQRCode(e){var t=this;var r;var n=H();var a=J();var o=B();var i=Fn(REFERRAL_CODES_NAMESPACE);var s=useState(false),c=s[0],u=s[1];var d=useState(null),l=d[0],f=d[1];var m=useState(false),v=m[0],h=m[1];var g=useState(false),p=g[0],_=g[1];var b=wn(ShareLinkQuery,{programId:n,engagementMedium:o},!(a===null||a===void 0?void 0:a.jwt)||(i===null||i===void 0?void 0:i.shareLink)!==undefined),w=b.data,E=b.errors;var C=$e(WIDGET_ENGAGEMENT_EVENT)[0];var y=(r=w===null||w===void 0?void 0:w.user)===null||r===void 0?void 0:r.shareLink;var R=y+"?qrCode";useEffect((function(){if(!y)return;var e=function(){return __awaiter(t,void 0,void 0,(function(){var e,t,r,n;return __generator(this,(function(a){switch(a.label){case 0:a.trys.push([0,3,,4]);return[4,fetch(y+"?qrCode&qrCodeImageFormat=svg")];case 1:e=a.sent();return[4,e.blob()];case 2:t=a.sent();r=URL.createObjectURL(t);f(r);return[3,4];case 3:n=a.sent();_(true);return[3,4];case 4:return[2]}}))}))};e()}),[y]);var j=function(){return __awaiter(t,void 0,void 0,(function(){return __generator(this,(function(e){C({eventMeta:{programId:n,id:a===null||a===void 0?void 0:a.id,accountId:a===null||a===void 0?void 0:a.accountId,type:"USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",meta:{engagementMedium:o,shareMedium:"DIRECT"}}});return[2]}))}))};var T=function(){return __awaiter(t,void 0,void 0,(function(){var e,t,r,n,a;return __generator(this,(function(o){switch(o.label){case 0:o.trys.push([0,3,,4]);return[4,fetch(R+"&qrCodeSize=800&qrCodeImageFormat=png")];case 1:e=o.sent();return[4,e.blob()];case 2:t=o.sent();r=URL.createObjectURL(t);if(t)j();n=document.createElement("a");n.href=r;n.download="qrCode.png";document.body.appendChild(n);n.click();document.body.removeChild(n);return[3,4];case 3:a=o.sent();console.error("Failed to fetch QR code:",a);h(true);return[3,4];case 4:return[2]}}))}))};var k=function(){return __awaiter(t,void 0,void 0,(function(){var e,t,r,n,a,o;return __generator(this,(function(i){switch(i.label){case 0:i.trys.push([0,3,,4]);return[4,fetch(R+"&qrCodeSize=1000&qrCodeImageFormat=png&qrCodeErrorCorrectionLevel=H")];case 1:e=i.sent();return[4,e.blob()];case 2:t=i.sent();r=URL.createObjectURL(t);if(t)j();n=window.open("about:blank","_new");a=n.document.createElement("img");a.src=r;a.onload=function(){n.print();n.close()};n.document.body.appendChild(a);return[3,4];case 3:o=i.sent();console.error("Failed to fetch QR code: ",o);h(true);return[3,4];case 4:return[2]}}))}))};return __assign(__assign({},e),{qrLink:l,dialogIsOpen:c,error:v,viewError:p||!!(E===null||E===void 0?void 0:E.message),showDialog:function(){h(false);u(true)},hideDialog:function(){h(false);u(false)},createDownloadable:T,createPrintable:k})}var QrCode=function(){function e(e){registerInstance(this,e);this.titleText="Share your QR code";this.viewCodeText="View QR code";this.downloadCodeText="Download";this.printCodeText="Print";this.errorHeaderText="There was an error loading your QR code";this.errorDescriptionText="Please refresh this page and try again";h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){var e=getProps(this);var t=isDemo()?useDemoQRCode(e):useQRCode(e);return h$1(QrCodeView,Object.assign({},t))};return e}();function useDemoQRCode(e){var t=this;var r=useState(false),n=r[0],a=r[1];return cjs({dialogIsOpen:n,showDialog:function(){return a(true)},hideDialog:function(){return a(false)},titleText:e.titleText,viewCodeText:e.viewCodeText,downloadCodeText:e.downloadCodeText,printCodeText:e.printCodeText,qrLink:"https://media.istockphoto.com/id/1251071788/vector/qr-code-bar-code-black-icon-digital-technology.jpg?s=612x612&w=0&k=20&c=maw4OqMSEegAdSo8Drm9HO7i1ddddvP2YaL1UuWbRig=",fireViewQrEvent:function(){console.log("View QR Code clicked")},createDownloadable:function(){return __awaiter(t,void 0,void 0,(function(){return __generator(this,(function(e){console.log("Download QR Code clicked");return[2]}))}))},createPrintable:function(){return __awaiter(t,void 0,void 0,(function(){return __generator(this,(function(e){console.log("Print QR Code clicked");return[2]}))}))}},e.demoData||{},{arrayMerge:function(e,t){return t}})}export{QrCode as sqm_qr_code};var templateObject_1,templateObject_2;
|