@saasquatch/mint-components 1.13.2 → 1.13.3-10

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 (91) hide show
  1. package/dist/cjs/ErrorView-b2fcf954.js +35 -0
  2. package/dist/cjs/{ShadowViewAddon-cf0ee0a0.js → ShadowViewAddon-3ddee92b.js} +6 -5
  3. package/dist/cjs/copy-text-view-c85acaaa.js +96 -0
  4. package/dist/cjs/loader.cjs.js +1 -1
  5. package/dist/cjs/mint-components.cjs.js +1 -1
  6. package/dist/cjs/sqm-banking-info-form_17.cjs.entry.js +3 -2
  7. package/dist/cjs/sqm-big-stat_39.cjs.entry.js +3 -2
  8. package/dist/cjs/{sqm-invoice-table-view-baded4af.js → sqm-invoice-table-view-16ac73d0.js} +2 -31
  9. package/dist/cjs/sqm-pagination_3.cjs.entry.js +6 -5
  10. package/dist/cjs/sqm-qr-code-view-3f30d2cd.js +94 -0
  11. package/dist/cjs/sqm-qr-code.cjs.entry.js +199 -0
  12. package/dist/cjs/sqm-stencilbook.cjs.entry.js +55 -6
  13. package/dist/cjs/{copy-text-view-a5524c20.js → useReferralCodes-82e8797b.js} +0 -93
  14. package/dist/collection/collection-manifest.json +1 -0
  15. package/dist/collection/components/sqm-qr-code/QRCode.stories.js +37 -0
  16. package/dist/collection/components/sqm-qr-code/sqm-qr-code-view.js +89 -0
  17. package/dist/collection/components/sqm-qr-code/sqm-qr-code.js +229 -0
  18. package/dist/collection/components/sqm-qr-code/useQRCode.js +129 -0
  19. package/dist/collection/components/sqm-stencilbook/sqm-stencilbook.js +2 -0
  20. package/dist/esm/ErrorView-48e2b969.js +33 -0
  21. package/dist/esm/{ShadowViewAddon-fd07e6e1.js → ShadowViewAddon-499b1f86.js} +2 -1
  22. package/dist/esm/copy-text-view-782137ba.js +94 -0
  23. package/dist/esm/loader.js +1 -1
  24. package/dist/esm/mint-components.js +1 -1
  25. package/dist/esm/sqm-banking-info-form_17.entry.js +2 -1
  26. package/dist/esm/sqm-big-stat_39.entry.js +3 -2
  27. package/dist/esm/{sqm-invoice-table-view-af69cd33.js → sqm-invoice-table-view-2c726568.js} +2 -30
  28. package/dist/esm/sqm-pagination_3.entry.js +2 -1
  29. package/dist/esm/sqm-qr-code-view-7c441329.js +92 -0
  30. package/dist/esm/sqm-qr-code.entry.js +195 -0
  31. package/dist/esm/sqm-stencilbook.entry.js +55 -6
  32. package/dist/esm/{copy-text-view-459a2e35.js → useReferralCodes-8f75921a.js} +1 -93
  33. package/dist/esm-es5/ErrorView-48e2b969.js +1 -0
  34. package/dist/esm-es5/ShadowViewAddon-499b1f86.js +1 -0
  35. package/dist/esm-es5/copy-text-view-782137ba.js +1 -0
  36. package/dist/esm-es5/loader.js +1 -1
  37. package/dist/esm-es5/mint-components.js +1 -1
  38. package/dist/esm-es5/sqm-banking-info-form_17.entry.js +1 -1
  39. package/dist/esm-es5/sqm-big-stat_39.entry.js +1 -1
  40. package/dist/esm-es5/sqm-invoice-table-view-2c726568.js +1 -0
  41. package/dist/esm-es5/sqm-pagination_3.entry.js +1 -1
  42. package/dist/esm-es5/sqm-qr-code-view-7c441329.js +1 -0
  43. package/dist/esm-es5/sqm-qr-code.entry.js +1 -0
  44. package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
  45. package/dist/esm-es5/useReferralCodes-8f75921a.js +1 -0
  46. package/dist/mint-components/mint-components.esm.js +1 -1
  47. package/dist/mint-components/{p-f29eda2f.entry.js → p-012af236.entry.js} +4 -4
  48. package/dist/mint-components/p-06267664.system.js +1 -0
  49. package/dist/mint-components/p-31015791.js +1 -0
  50. package/dist/mint-components/p-37996351.system.js +1 -1
  51. package/dist/mint-components/p-3a62a7e2.system.js +1 -0
  52. package/dist/mint-components/p-3b90e01b.system.js +1 -0
  53. package/dist/mint-components/p-3f067fd5.js +1 -0
  54. package/dist/mint-components/p-3f7b81b8.js +52 -0
  55. package/dist/mint-components/p-45e82465.entry.js +17 -0
  56. package/dist/mint-components/p-5afd7e38.system.entry.js +1 -0
  57. package/dist/mint-components/p-5cb7f9fc.system.entry.js +1 -0
  58. package/dist/mint-components/{p-b51e79b3.entry.js → p-7846937e.entry.js} +2 -2
  59. package/dist/mint-components/p-97038074.system.entry.js +1 -0
  60. package/dist/mint-components/p-9acb5038.js +1 -0
  61. package/dist/mint-components/p-a7746488.system.js +1 -0
  62. package/dist/mint-components/p-b630683c.system.entry.js +1 -0
  63. package/dist/mint-components/p-da4ff3b4.system.js +1 -0
  64. package/dist/mint-components/p-dbc0e4f8.system.js +1 -0
  65. package/dist/mint-components/p-dfcc0f0e.entry.js +9 -0
  66. package/dist/mint-components/{p-d12fc50f.js → p-e2d5cd22.js} +20 -20
  67. package/dist/mint-components/p-e6e2b28b.js +1 -0
  68. package/dist/mint-components/p-e706440c.system.entry.js +1 -0
  69. package/dist/mint-components/{p-87d385d8.entry.js → p-f15c1a53.entry.js} +1 -1
  70. package/dist/types/components/sqm-qr-code/QRCode.stories.d.ts +8 -0
  71. package/dist/types/components/sqm-qr-code/sqm-qr-code-view.d.ts +17 -0
  72. package/dist/types/components/sqm-qr-code/sqm-qr-code.d.ts +41 -0
  73. package/dist/types/components/sqm-qr-code/useQRCode.d.ts +3 -0
  74. package/dist/types/components.d.ts +72 -0
  75. package/docs/docs.docx +0 -0
  76. package/docs/raisins.json +1 -1
  77. package/grapesjs/grapesjs.js +1 -1
  78. package/package.json +1 -1
  79. package/dist/esm-es5/ShadowViewAddon-fd07e6e1.js +0 -1
  80. package/dist/esm-es5/copy-text-view-459a2e35.js +0 -1
  81. package/dist/esm-es5/sqm-invoice-table-view-af69cd33.js +0 -1
  82. package/dist/mint-components/p-57e2c2fa.system.js +0 -1
  83. package/dist/mint-components/p-717cc8ac.system.js +0 -1
  84. package/dist/mint-components/p-71bc04d2.system.entry.js +0 -1
  85. package/dist/mint-components/p-7f2d4212.js +0 -52
  86. package/dist/mint-components/p-9320582e.system.js +0 -1
  87. package/dist/mint-components/p-962f3200.js +0 -1
  88. package/dist/mint-components/p-abedbbf3.system.entry.js +0 -1
  89. package/dist/mint-components/p-b93fd99c.system.entry.js +0 -1
  90. package/dist/mint-components/p-bc83460e.system.entry.js +0 -1
  91. package/dist/mint-components/p-da932ca2.entry.js +0 -9
@@ -0,0 +1,229 @@
1
+ import { isDemo } from "@saasquatch/component-boilerplate";
2
+ import { useState, withHooks } from "@saasquatch/stencil-hooks";
3
+ import { Component, h, Prop } from "@stencil/core";
4
+ import deepmerge from "deepmerge";
5
+ import { getProps } from "../../utils/utils";
6
+ import { QrCodeView } from "./sqm-qr-code-view";
7
+ import { useQRCode } from "./useQRCode";
8
+ /**
9
+ * @uiName QR Code
10
+ * @exampleGroup Sharing
11
+ * @example QR Code - <sqm-qr-code></sqm-qr-code>
12
+ */
13
+ export class QrCode {
14
+ constructor() {
15
+ /**
16
+ * @uiName Title
17
+ */
18
+ this.titleText = "Share your QR code";
19
+ /**
20
+ * @uiName View QR code text
21
+ */
22
+ this.viewCodeText = "View QR code";
23
+ /**
24
+ * @uiName Download QR code text
25
+ */
26
+ this.downloadCodeText = "Download";
27
+ /**
28
+ * @uiName Print QR code text
29
+ */
30
+ this.printCodeText = "Print";
31
+ /**
32
+ * @uiName Header for error banner
33
+ */
34
+ this.errorHeaderText = "There was an error loading your QR code";
35
+ /**
36
+ * @uiName Description for error banner
37
+ */
38
+ this.errorDescriptionText = "Please refresh this page and try again";
39
+ withHooks(this);
40
+ }
41
+ disconnectedCallback() { }
42
+ render() {
43
+ const thisProps = getProps(this);
44
+ const props = isDemo() ? useDemoQRCode(thisProps) : useQRCode(thisProps);
45
+ return h(QrCodeView, Object.assign({}, props));
46
+ }
47
+ static get is() { return "sqm-qr-code"; }
48
+ static get encapsulation() { return "shadow"; }
49
+ static get properties() { return {
50
+ "titleText": {
51
+ "type": "string",
52
+ "mutable": false,
53
+ "complexType": {
54
+ "original": "string",
55
+ "resolved": "string",
56
+ "references": {}
57
+ },
58
+ "required": false,
59
+ "optional": true,
60
+ "docs": {
61
+ "tags": [{
62
+ "text": "Title",
63
+ "name": "uiName"
64
+ }],
65
+ "text": ""
66
+ },
67
+ "attribute": "title-text",
68
+ "reflect": false,
69
+ "defaultValue": "\"Share your QR code\""
70
+ },
71
+ "viewCodeText": {
72
+ "type": "string",
73
+ "mutable": false,
74
+ "complexType": {
75
+ "original": "string",
76
+ "resolved": "string",
77
+ "references": {}
78
+ },
79
+ "required": false,
80
+ "optional": true,
81
+ "docs": {
82
+ "tags": [{
83
+ "text": "View QR code text",
84
+ "name": "uiName"
85
+ }],
86
+ "text": ""
87
+ },
88
+ "attribute": "view-code-text",
89
+ "reflect": false,
90
+ "defaultValue": "\"View QR code\""
91
+ },
92
+ "downloadCodeText": {
93
+ "type": "string",
94
+ "mutable": false,
95
+ "complexType": {
96
+ "original": "string",
97
+ "resolved": "string",
98
+ "references": {}
99
+ },
100
+ "required": false,
101
+ "optional": true,
102
+ "docs": {
103
+ "tags": [{
104
+ "text": "Download QR code text",
105
+ "name": "uiName"
106
+ }],
107
+ "text": ""
108
+ },
109
+ "attribute": "download-code-text",
110
+ "reflect": false,
111
+ "defaultValue": "\"Download\""
112
+ },
113
+ "printCodeText": {
114
+ "type": "string",
115
+ "mutable": false,
116
+ "complexType": {
117
+ "original": "string",
118
+ "resolved": "string",
119
+ "references": {}
120
+ },
121
+ "required": false,
122
+ "optional": true,
123
+ "docs": {
124
+ "tags": [{
125
+ "text": "Print QR code text",
126
+ "name": "uiName"
127
+ }],
128
+ "text": ""
129
+ },
130
+ "attribute": "print-code-text",
131
+ "reflect": false,
132
+ "defaultValue": "\"Print\""
133
+ },
134
+ "errorHeaderText": {
135
+ "type": "string",
136
+ "mutable": false,
137
+ "complexType": {
138
+ "original": "string",
139
+ "resolved": "string",
140
+ "references": {}
141
+ },
142
+ "required": false,
143
+ "optional": true,
144
+ "docs": {
145
+ "tags": [{
146
+ "text": "Header for error banner",
147
+ "name": "uiName"
148
+ }],
149
+ "text": ""
150
+ },
151
+ "attribute": "error-header-text",
152
+ "reflect": false,
153
+ "defaultValue": "\"There was an error loading your QR code\""
154
+ },
155
+ "errorDescriptionText": {
156
+ "type": "string",
157
+ "mutable": false,
158
+ "complexType": {
159
+ "original": "string",
160
+ "resolved": "string",
161
+ "references": {}
162
+ },
163
+ "required": false,
164
+ "optional": true,
165
+ "docs": {
166
+ "tags": [{
167
+ "text": "Description for error banner",
168
+ "name": "uiName"
169
+ }],
170
+ "text": ""
171
+ },
172
+ "attribute": "error-description-text",
173
+ "reflect": false,
174
+ "defaultValue": "\"Please refresh this page and try again\""
175
+ },
176
+ "demoData": {
177
+ "type": "unknown",
178
+ "mutable": false,
179
+ "complexType": {
180
+ "original": "DemoData<QRCodeViewProps>",
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
+ "references": {
183
+ "DemoData": {
184
+ "location": "import",
185
+ "path": "../../global/demo"
186
+ },
187
+ "QRCodeViewProps": {
188
+ "location": "import",
189
+ "path": "./sqm-qr-code-view"
190
+ }
191
+ }
192
+ },
193
+ "required": false,
194
+ "optional": true,
195
+ "docs": {
196
+ "tags": [{
197
+ "text": undefined,
198
+ "name": "undocumented"
199
+ }, {
200
+ "text": "object",
201
+ "name": "uiType"
202
+ }],
203
+ "text": ""
204
+ }
205
+ }
206
+ }; }
207
+ }
208
+ function useDemoQRCode(props) {
209
+ const [dialogIsOpen, setDialog] = useState(false);
210
+ return deepmerge({
211
+ dialogIsOpen,
212
+ showDialog: () => setDialog(true),
213
+ hideDialog: () => setDialog(false),
214
+ titleText: props.titleText,
215
+ viewCodeText: props.viewCodeText,
216
+ downloadCodeText: props.downloadCodeText,
217
+ printCodeText: props.printCodeText,
218
+ 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=",
219
+ fireViewQrEvent: () => {
220
+ console.log("View QR Code clicked");
221
+ },
222
+ createDownloadable: async () => {
223
+ console.log("Download QR Code clicked");
224
+ },
225
+ createPrintable: async () => {
226
+ console.log("Print QR Code clicked");
227
+ },
228
+ }, props.demoData || {}, { arrayMerge: (_, a) => a });
229
+ }
@@ -0,0 +1,129 @@
1
+ import { useEngagementMedium, useMutation, useParentValue, useProgramId, useQuery, useUserIdentity, } from "@saasquatch/component-boilerplate";
2
+ import { useState } from "@saasquatch/stencil-hooks";
3
+ import { useEffect } from "@saasquatch/universal-hooks";
4
+ import { gql } from "graphql-request";
5
+ import { REFERRAL_CODES_NAMESPACE, } from "../sqm-referral-codes/useReferralCodes";
6
+ const ShareLinkQuery = gql `
7
+ query shareLink($programId: ID, $engagementMedium: UserEngagementMedium!) {
8
+ user: viewer {
9
+ ... on User {
10
+ shareLink(
11
+ programId: $programId
12
+ engagementMedium: $engagementMedium
13
+ shareMedium: DIRECT
14
+ )
15
+ }
16
+ }
17
+ }
18
+ `;
19
+ const WIDGET_ENGAGEMENT_EVENT = gql `
20
+ mutation loadEvent($eventMeta: UserAnalyticsEvent!) {
21
+ createUserAnalyticsEvent(eventMeta: $eventMeta)
22
+ }
23
+ `;
24
+ export function useQRCode(props) {
25
+ var _a;
26
+ const programId = useProgramId();
27
+ const user = useUserIdentity();
28
+ const engagementMedium = useEngagementMedium();
29
+ const contextData = useParentValue(REFERRAL_CODES_NAMESPACE);
30
+ const [dialogIsOpen, setDialog] = useState(false);
31
+ const [qrLink, setQrUrl] = useState(null);
32
+ const [error, setError] = useState(false);
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);
35
+ const [sendLoadEvent] = useMutation(WIDGET_ENGAGEMENT_EVENT);
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]);
54
+ const fireEvent = async () => {
55
+ sendLoadEvent({
56
+ eventMeta: {
57
+ programId,
58
+ id: user === null || user === void 0 ? void 0 : user.id,
59
+ accountId: user === null || user === void 0 ? void 0 : user.accountId,
60
+ type: "USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",
61
+ meta: {
62
+ engagementMedium,
63
+ shareMedium: "DIRECT",
64
+ },
65
+ },
66
+ });
67
+ };
68
+ const createDownloadable = async () => {
69
+ try {
70
+ const res = await fetch(`${qrPrefix}&qrCodeSize=800&qrCodeImageFormat=png`);
71
+ const blob = await res.blob();
72
+ const url = URL.createObjectURL(blob);
73
+ // Successful
74
+ if (blob)
75
+ fireEvent();
76
+ // Trigger download
77
+ const link = document.createElement("a");
78
+ link.href = url;
79
+ link.download = "qrCode.png";
80
+ document.body.appendChild(link);
81
+ link.click();
82
+ document.body.removeChild(link);
83
+ }
84
+ catch (e) {
85
+ console.error("Failed to fetch QR code:", e);
86
+ setError(true);
87
+ }
88
+ };
89
+ const createPrintable = async () => {
90
+ try {
91
+ const res = await fetch(`${qrPrefix}&qrCodeSize=1000&qrCodeImageFormat=png&qrCodeErrorCorrectionLevel=H`);
92
+ const blob = await res.blob();
93
+ const url = URL.createObjectURL(blob);
94
+ // Successful
95
+ if (blob)
96
+ fireEvent();
97
+ // Trigger print
98
+ const page = window.open("about:blank", "_new");
99
+ const img = page.document.createElement("img");
100
+ img.src = url;
101
+ img.onload = () => {
102
+ page.print();
103
+ page.close();
104
+ };
105
+ page.document.body.appendChild(img);
106
+ }
107
+ catch (e) {
108
+ console.error("Failed to fetch QR code: ", e);
109
+ setError(true);
110
+ }
111
+ };
112
+ return {
113
+ ...props,
114
+ qrLink,
115
+ dialogIsOpen,
116
+ error: error,
117
+ viewError: viewError || !!(errors === null || errors === void 0 ? void 0 : errors.message),
118
+ showDialog: () => {
119
+ setError(false);
120
+ setDialog(true);
121
+ },
122
+ hideDialog: () => {
123
+ setError(false);
124
+ setDialog(false);
125
+ },
126
+ createDownloadable,
127
+ createPrintable,
128
+ };
129
+ }
@@ -93,6 +93,7 @@ import * as ReferralCodes from "../sqm-referral-codes/ReferralCodes.stories";
93
93
  import * as BaseRegistrationForm from "../sqm-base-registration/BaseRegistrationForm.stories";
94
94
  import * as PortalRegistrationForm from "../sqm-portal-registration-form/PortalRegistrationForm.stories";
95
95
  import * as PortalGoogleRegistrationFormStories from "../sqm-portal-google-registration-form/PortalGoogleRegistrationForm.stories";
96
+ import * as QRCode from "../sqm-qr-code/QRCode.stories";
96
97
  import * as Themes from "./Themes";
97
98
  import { CucumberAddon } from "./CucumberAddon";
98
99
  import { HookStoryAddon } from "./HookStoryAddon";
@@ -191,6 +192,7 @@ const stories = [
191
192
  WidgetCodeVerification,
192
193
  PayoutButtonScroll,
193
194
  PayoutStatusAlert,
195
+ QRCode,
194
196
  ];
195
197
  /**
196
198
  * For internal documentation
@@ -0,0 +1,33 @@
1
+ import { h } from './index-91e7729f.js';
2
+ import { c as createStyleSheet } from './JSS-67b5cff8.js';
3
+
4
+ const styles = {
5
+ Alert: {
6
+ "&::part(base)": {
7
+ backgroundColor: "var(--sl-color-danger-100)",
8
+ border: "1px solid var(--sl-color-danger-200)",
9
+ padding: "0 16px",
10
+ },
11
+ "& sl-icon": {
12
+ margin: 0,
13
+ },
14
+ "& sl-icon::part(base)": {
15
+ color: "var(--sl-color-danger-500)",
16
+ margin: 0,
17
+ },
18
+ },
19
+ };
20
+ const ErrorView = (props) => {
21
+ const sheet = createStyleSheet(styles);
22
+ const styleString = sheet.toString();
23
+ const { classes } = sheet;
24
+ return (h("div", null,
25
+ h("style", null, styleString),
26
+ h("sl-alert", { exportparts: "base: alert-base, icon:alert-icon", type: "danger", open: true, class: classes.Alert },
27
+ h("sl-icon", { slot: "icon", name: "exclamation-octagon", class: "Error" }),
28
+ h("strong", null, props.loadingErrorAlertHeader),
29
+ h("br", null),
30
+ props.loadingErrorAlertDescription)));
31
+ };
32
+
33
+ export { ErrorView as E };
@@ -5,8 +5,9 @@ import { d as dist, H, J, F as Fn, w as wn, $ as $e, B, g as getEnvironmentSDK,
5
5
  import { c as cjs } from './cjs-bdfb4486.js';
6
6
  import { l as luxonLocale } from './utils-334c1e34.js';
7
7
  import { c as createStyleSheet, j as jss, a as create } from './JSS-67b5cff8.js';
8
- import { a as REFERRAL_CODES_NAMESPACE, S as SET_CODE_COPIED, C as CopyTextView } from './copy-text-view-459a2e35.js';
8
+ import { a as REFERRAL_CODES_NAMESPACE, S as SET_CODE_COPIED } from './useReferralCodes-8f75921a.js';
9
9
  import { H as HostBlock, A as AuthWrapper, a as AuthColumn, b as AuthButtonsContainer, E as ErrorStyles } from './mixins-83f90fa1.js';
10
+ import { C as CopyTextView } from './copy-text-view-782137ba.js';
10
11
  import { u as useChildElements } from './useChildElements-7945ae56.js';
11
12
  import { l as luxon } from './luxon-8d51c92b.js';
12
13
  import { T as TextSpanView } from './sqm-text-span-view-ca32495e.js';
@@ -0,0 +1,94 @@
1
+ import { h } from './index-91e7729f.js';
2
+ import { c as createStyleSheet } from './JSS-67b5cff8.js';
3
+ import { H as HostBlock } from './mixins-83f90fa1.js';
4
+
5
+ const style = {
6
+ HostBlock: HostBlock,
7
+ inputStyle: {
8
+ "&::part(input)": { textOverflow: "ellipsis", width: "100%" },
9
+ "&::part(base)": { cursor: "pointer", overflow: "visible" },
10
+ width: "100%",
11
+ },
12
+ inputErrorStyle: {
13
+ "&::part(base)": {
14
+ border: "2px solid red",
15
+ },
16
+ },
17
+ ContainerDiv: {
18
+ display: "flex",
19
+ alignItems: "flex-start",
20
+ flexDirection: "column",
21
+ justifyContent: "center",
22
+ gap: "var(--sl-spacing-x-small)",
23
+ width: "100%",
24
+ },
25
+ containerStyle: {
26
+ display: "flex",
27
+ alignItems: "center",
28
+ gap: "var(--sl-spacing-x-small)",
29
+ width: "100%",
30
+ },
31
+ errorTextStyle: {
32
+ margin: "0",
33
+ color: "var(--sl-color-danger-500)",
34
+ },
35
+ notificationTextStyle: {
36
+ margin: "0",
37
+ color: "var(--sl-color-neutral-500)",
38
+ },
39
+ };
40
+ const vanillaStyle = `
41
+ :host{
42
+ display: block;
43
+ width: 100%;
44
+ }
45
+ `;
46
+ const textAlignStyle = {
47
+ right: `
48
+ sl-input::part(input){
49
+ text-align: right;
50
+ }`,
51
+ center: `
52
+ sl-input::part(input){
53
+ text-align: center;
54
+ }`,
55
+ left: ``,
56
+ };
57
+ const disabledStyles = `
58
+ sl-input::part(input){
59
+ cursor: default;
60
+ }
61
+ `;
62
+ const sheet = createStyleSheet(style);
63
+ const styleString = sheet.toString();
64
+ function CopyTextView(props) {
65
+ const { buttonStyle = "icon" } = props;
66
+ const error = !props.loading && props.error;
67
+ const inputText = error ? props.inputPlaceholderText : props.copyString;
68
+ const disabled = error || props.loading || props.disabled;
69
+ const tooltipPlacement = props.buttonStyle === "button-below"
70
+ ? "bottom"
71
+ : props.buttonStyle === "button-outside"
72
+ ? "top"
73
+ : "top-end";
74
+ const copyButton = (h("sl-tooltip", { trigger: "manual", content: props.tooltiptext, placement: tooltipPlacement, disabled: props.disabled, open: props.open, skidding: props.buttonStyle === "icon" ? -5 : 0, slot: "suffix" }, buttonStyle === "icon" ? (h("sl-icon-button", { exportparts: "base: icon-button-base", onClick: () => { var _a; return (_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props); }, name: "files", disabled: disabled })) : (h("sl-button", { exportparts: "base: copy-button-base", onClick: () => { var _a; return (_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props); }, size: "medium", style: { width: `${buttonStyle === "button-below" && "100%"}` }, disabled: disabled, type: "primary" }, props.copyButtonLabel || "Copy"))));
75
+ return (h("div", { class: sheet.classes.ContainerDiv },
76
+ h("style", { type: "text/css" },
77
+ styleString,
78
+ vanillaStyle,
79
+ textAlignStyle[props.textAlign],
80
+ disabled && disabledStyles),
81
+ h("div", { class: sheet.classes.containerStyle, style: {
82
+ flexDirection: `${buttonStyle === "button-below" ? "column" : "row"}`,
83
+ } },
84
+ h("sl-input", { class: `${sheet.classes.inputStyle} ${error ? sheet.classes.inputErrorStyle : ""}`, exportparts: "base: input-base, input: input-label", value: props.loading ? "Loading..." : inputText, readonly: true, disabled: disabled },
85
+ buttonStyle === "icon" && copyButton,
86
+ error && (h("p", { slot: "help-text", class: sheet.classes.errorTextStyle }, props.errorText))),
87
+ (buttonStyle === "button-outside" || buttonStyle === "button-below") &&
88
+ copyButton),
89
+ props.isCopied &&
90
+ props.showNotificationText &&
91
+ props.notificationText && (h("p", { part: "sqm-notification-text", class: sheet.classes.notificationTextStyle }, props.notificationText))));
92
+ }
93
+
94
+ export { CopyTextView as C };