@saasquatch/mint-components 2.1.10-57 → 2.1.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 (156) hide show
  1. package/dist/cjs/{ShadowViewAddon-a26deae6.js → ShadowViewAddon-c97e80de.js} +422 -19
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/mint-components.cjs.js +1 -1
  4. package/dist/cjs/{sqm-big-stat_46.cjs.entry.js → sqm-big-stat_45.cjs.entry.js} +264 -92
  5. package/dist/cjs/sqm-code-verification.cjs.entry.js +1 -1
  6. package/dist/cjs/sqm-email-verification.cjs.entry.js +1 -1
  7. package/dist/cjs/sqm-empty_4.cjs.entry.js +1 -1
  8. package/dist/cjs/{sqm-portal-container-view-70a47420.js → sqm-portal-container-view-757f921b.js} +5 -6
  9. package/dist/cjs/{sqm-portal-email-verification-view-c81fe7f1.js → sqm-portal-email-verification-view-abb773a7.js} +1 -1
  10. package/dist/cjs/sqm-portal-email-verification.cjs.entry.js +2 -2
  11. package/dist/cjs/sqm-portal-forgot-password_6.cjs.entry.js +5 -5
  12. package/dist/cjs/{sqm-portal-profile-view-639337e3.js → sqm-portal-profile-view-3515e1e5.js} +1 -1
  13. package/dist/cjs/sqm-portal-profile.cjs.entry.js +2 -2
  14. package/dist/cjs/{sqm-portal-registration-form-view-020f661c.js → sqm-portal-registration-form-view-a45f7a52.js} +1 -1
  15. package/dist/cjs/{sqm-portal-reset-password-view-6b1acd90.js → sqm-portal-reset-password-view-a767b044.js} +1 -1
  16. package/dist/cjs/sqm-portal-reset-password.cjs.entry.js +2 -2
  17. package/dist/cjs/{sqm-portal-verify-email-view-424e406a.js → sqm-portal-verify-email-view-717d0633.js} +1 -1
  18. package/dist/cjs/sqm-referral-table_11.cjs.entry.js +1 -1
  19. package/dist/cjs/sqm-rewards-table-customer-note-cell.cjs.entry.js +1 -1
  20. package/dist/cjs/sqm-stencilbook.cjs.entry.js +168 -59
  21. package/dist/cjs/{sqm-text-span-view-f274fdf2.js → sqm-text-span-view-b9e10f5d.js} +1 -1
  22. package/dist/cjs/sqm-text-span.cjs.entry.js +1 -1
  23. package/dist/collection/collection-manifest.json +0 -1
  24. package/dist/collection/components/sqm-password-field/sqm-password-field.js +1 -0
  25. package/dist/collection/components/sqm-portal-container/sqm-portal-container-view.js +6 -7
  26. package/dist/collection/components/sqm-portal-google-login/sqm-portal-google-login.js +1 -1
  27. package/dist/collection/components/sqm-portal-login/sqm-portal-login.js +1 -1
  28. package/dist/collection/components/sqm-share-code/sqm-share-code.js +0 -1
  29. package/dist/collection/components/sqm-share-link/ShareLink.stories.js +136 -11
  30. package/dist/collection/components/sqm-share-link/UseShareLink.stories.js +14 -5
  31. package/dist/collection/components/sqm-share-link/sqm-share-link-view.js +192 -0
  32. package/dist/collection/components/sqm-share-link/sqm-share-link.js +935 -48
  33. package/dist/collection/components/sqm-share-link/useShareLink.js +227 -14
  34. package/dist/collection/components/sqm-stencilbook/sqm-stencilbook.js +0 -2
  35. package/dist/collection/components/sqm-text-span/sqm-text-span-view.js +1 -1
  36. package/dist/esm/{ShadowViewAddon-47f1e579.js → ShadowViewAddon-33f1a8f7.js} +424 -22
  37. package/dist/esm/loader.js +1 -1
  38. package/dist/esm/mint-components.js +1 -1
  39. package/dist/esm/{sqm-big-stat_46.entry.js → sqm-big-stat_45.entry.js} +265 -92
  40. package/dist/esm/sqm-code-verification.entry.js +1 -1
  41. package/dist/esm/sqm-email-verification.entry.js +1 -1
  42. package/dist/esm/sqm-empty_4.entry.js +1 -1
  43. package/dist/esm/{sqm-portal-container-view-a8c708cd.js → sqm-portal-container-view-200c9df8.js} +6 -7
  44. package/dist/esm/{sqm-portal-email-verification-view-426370f1.js → sqm-portal-email-verification-view-04528277.js} +1 -1
  45. package/dist/esm/sqm-portal-email-verification.entry.js +2 -2
  46. package/dist/esm/sqm-portal-forgot-password_6.entry.js +5 -5
  47. package/dist/esm/{sqm-portal-profile-view-f015fd6a.js → sqm-portal-profile-view-b5ea620f.js} +1 -1
  48. package/dist/esm/sqm-portal-profile.entry.js +2 -2
  49. package/dist/esm/{sqm-portal-registration-form-view-2f4936ef.js → sqm-portal-registration-form-view-79265df5.js} +1 -1
  50. package/dist/esm/{sqm-portal-reset-password-view-cfbc0eb0.js → sqm-portal-reset-password-view-f84c04cf.js} +1 -1
  51. package/dist/esm/sqm-portal-reset-password.entry.js +2 -2
  52. package/dist/esm/{sqm-portal-verify-email-view-1a638fae.js → sqm-portal-verify-email-view-c61536b7.js} +1 -1
  53. package/dist/esm/sqm-referral-table_11.entry.js +1 -1
  54. package/dist/esm/sqm-rewards-table-customer-note-cell.entry.js +1 -1
  55. package/dist/esm/sqm-stencilbook.entry.js +168 -59
  56. package/dist/esm/{sqm-text-span-view-738acfb3.js → sqm-text-span-view-72f43dff.js} +1 -1
  57. package/dist/esm/sqm-text-span.entry.js +1 -1
  58. package/dist/esm-es5/ShadowViewAddon-33f1a8f7.js +1 -0
  59. package/dist/esm-es5/loader.js +1 -1
  60. package/dist/esm-es5/mint-components.js +1 -1
  61. package/dist/esm-es5/sqm-big-stat_45.entry.js +1 -0
  62. package/dist/esm-es5/sqm-code-verification.entry.js +1 -1
  63. package/dist/esm-es5/sqm-email-verification.entry.js +1 -1
  64. package/dist/esm-es5/sqm-empty_4.entry.js +1 -1
  65. package/dist/esm-es5/sqm-portal-container-view-200c9df8.js +1 -0
  66. package/dist/esm-es5/{sqm-portal-email-verification-view-426370f1.js → sqm-portal-email-verification-view-04528277.js} +1 -1
  67. package/dist/esm-es5/sqm-portal-email-verification.entry.js +1 -1
  68. package/dist/esm-es5/sqm-portal-forgot-password_6.entry.js +1 -1
  69. package/dist/esm-es5/{sqm-portal-profile-view-f015fd6a.js → sqm-portal-profile-view-b5ea620f.js} +1 -1
  70. package/dist/esm-es5/sqm-portal-profile.entry.js +1 -1
  71. package/dist/esm-es5/{sqm-portal-registration-form-view-2f4936ef.js → sqm-portal-registration-form-view-79265df5.js} +1 -1
  72. package/dist/esm-es5/{sqm-portal-reset-password-view-cfbc0eb0.js → sqm-portal-reset-password-view-f84c04cf.js} +1 -1
  73. package/dist/esm-es5/sqm-portal-reset-password.entry.js +1 -1
  74. package/dist/esm-es5/{sqm-portal-verify-email-view-1a638fae.js → sqm-portal-verify-email-view-c61536b7.js} +1 -1
  75. package/dist/esm-es5/sqm-referral-table_11.entry.js +1 -1
  76. package/dist/esm-es5/sqm-rewards-table-customer-note-cell.entry.js +1 -1
  77. package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
  78. package/dist/esm-es5/{sqm-text-span-view-738acfb3.js → sqm-text-span-view-72f43dff.js} +1 -1
  79. package/dist/esm-es5/sqm-text-span.entry.js +1 -1
  80. package/dist/mint-components/mint-components.esm.js +1 -1
  81. package/dist/mint-components/{p-ab0ea688.system.entry.js → p-00b235c5.system.entry.js} +1 -1
  82. package/dist/mint-components/p-08930b83.js +499 -0
  83. package/dist/mint-components/p-0b1e90fe.system.js +1 -0
  84. package/dist/mint-components/p-1021a49f.system.entry.js +1 -0
  85. package/dist/mint-components/{p-25558a33.entry.js → p-13292317.entry.js} +1 -1
  86. package/dist/mint-components/{p-d65991d0.entry.js → p-13d1b10d.entry.js} +1 -1
  87. package/dist/mint-components/{p-d4570314.entry.js → p-1d92c169.entry.js} +1 -1
  88. package/dist/mint-components/{p-7161e1a6.js → p-2668335b.js} +1 -1
  89. package/dist/mint-components/{p-6e512063.entry.js → p-3af3e2c1.entry.js} +1 -1
  90. package/dist/mint-components/{p-5ff7b000.entry.js → p-40bad95a.entry.js} +1 -1
  91. package/dist/mint-components/{p-f35d856a.system.js → p-43c31fd5.system.js} +1 -1
  92. package/dist/mint-components/p-5bc5c61e.entry.js +1 -0
  93. package/dist/mint-components/{p-dac20392.system.js → p-686dd5eb.system.js} +1 -1
  94. package/dist/mint-components/{p-7b909aa5.system.js → p-7562cd98.system.js} +1 -1
  95. package/dist/mint-components/p-76271ec4.entry.js +9 -0
  96. package/dist/mint-components/p-78b40f71.system.js +1 -0
  97. package/dist/mint-components/{p-cb0a5990.entry.js → p-7939e4af.entry.js} +1 -1
  98. package/dist/mint-components/{p-e6ace3ab.js → p-832aea99.js} +1 -1
  99. package/dist/mint-components/{p-746500b2.entry.js → p-8784539d.entry.js} +21 -29
  100. package/dist/mint-components/{p-b9f57e84.system.entry.js → p-8899ff38.system.entry.js} +1 -1
  101. package/dist/mint-components/{p-fbe00c97.system.entry.js → p-892797eb.system.entry.js} +1 -1
  102. package/dist/mint-components/{p-d997001a.js → p-8962e023.js} +1 -1
  103. package/dist/mint-components/{p-dd368927.system.entry.js → p-9390586b.system.entry.js} +1 -1
  104. package/dist/mint-components/{p-3c46b4dd.system.js → p-a4825ec2.system.js} +1 -1
  105. package/dist/mint-components/{p-058aefe1.entry.js → p-af407cce.entry.js} +1 -1
  106. package/dist/mint-components/{p-56ca7e3c.js → p-b3ad957c.js} +1 -1
  107. package/dist/mint-components/{p-70570e4d.system.entry.js → p-b96e90a2.system.entry.js} +1 -1
  108. package/dist/mint-components/{p-c67f8558.system.entry.js → p-bba16a46.system.entry.js} +1 -1
  109. package/dist/mint-components/{p-669d52c4.js → p-bee4af5d.js} +1 -1
  110. package/dist/mint-components/p-c3c8d4ee.system.entry.js +1 -0
  111. package/dist/mint-components/{p-cabf6326.js → p-c813ec64.js} +1 -1
  112. package/dist/mint-components/p-ca098be1.system.js +1 -1
  113. package/dist/mint-components/{p-18133026.system.entry.js → p-d3b1ab20.system.entry.js} +1 -1
  114. package/dist/mint-components/{p-692e14c5.system.js → p-d55c50af.system.js} +1 -1
  115. package/dist/mint-components/p-dd12c32a.system.entry.js +1 -0
  116. package/dist/mint-components/p-e30abc44.js +1 -0
  117. package/dist/mint-components/{p-fb5c9802.entry.js → p-e506bf7f.entry.js} +1 -1
  118. package/dist/mint-components/{p-aefc6c4f.system.entry.js → p-e9485160.system.entry.js} +1 -1
  119. package/dist/mint-components/{p-f0baeed0.entry.js → p-f6528f8a.entry.js} +1 -1
  120. package/dist/mint-components/{p-5141769d.system.entry.js → p-f7ca4cc4.system.entry.js} +1 -1
  121. package/dist/mint-components/{p-e4f17c21.system.js → p-f8026ed6.system.js} +1 -1
  122. package/dist/types/components/sqm-share-link/ShareLink.stories.d.ts +9 -0
  123. package/dist/types/components/sqm-share-link/UseShareLink.stories.d.ts +6 -0
  124. package/dist/types/components/sqm-share-link/sqm-share-link-view.d.ts +41 -0
  125. package/dist/types/components/sqm-share-link/sqm-share-link.d.ts +195 -2
  126. package/dist/types/components/sqm-share-link/useShareLink.d.ts +33 -4
  127. package/dist/types/components.d.ts +349 -80
  128. package/dist/types/global/android.d.ts +7 -0
  129. package/dist/types/global/demo.d.ts +2 -0
  130. package/dist/types/stories/features.d.ts +4 -0
  131. package/dist/types/stories/templates.d.ts +4 -0
  132. package/docs/docs.docx +0 -0
  133. package/docs/raisins.json +1 -1
  134. package/docs/stats.json +122783 -0
  135. package/grapesjs/grapesjs.js +1 -1
  136. package/package.json +2 -2
  137. package/dist/collection/components/sqm-user-attribute/UserAttribute.stories.js +0 -25
  138. package/dist/collection/components/sqm-user-attribute/sqm-user-attribute-view.js +0 -19
  139. package/dist/collection/components/sqm-user-attribute/sqm-user-attribute.js +0 -172
  140. package/dist/collection/components/sqm-user-attribute/useUserAttribute.js +0 -26
  141. package/dist/esm-es5/ShadowViewAddon-47f1e579.js +0 -1
  142. package/dist/esm-es5/sqm-big-stat_46.entry.js +0 -1
  143. package/dist/esm-es5/sqm-portal-container-view-a8c708cd.js +0 -1
  144. package/dist/mint-components/p-217dedde.js +0 -463
  145. package/dist/mint-components/p-4007afba.system.entry.js +0 -1
  146. package/dist/mint-components/p-445f50cc.entry.js +0 -9
  147. package/dist/mint-components/p-55676213.entry.js +0 -1
  148. package/dist/mint-components/p-89a20547.system.entry.js +0 -1
  149. package/dist/mint-components/p-b699f76e.system.js +0 -1
  150. package/dist/mint-components/p-b6a1e2ac.js +0 -1
  151. package/dist/mint-components/p-ce050888.system.js +0 -1
  152. package/dist/mint-components/p-e3497e0e.system.entry.js +0 -1
  153. package/dist/types/components/sqm-user-attribute/UserAttribute.stories.d.ts +0 -7
  154. package/dist/types/components/sqm-user-attribute/sqm-user-attribute-view.d.ts +0 -8
  155. package/dist/types/components/sqm-user-attribute/sqm-user-attribute.d.ts +0 -45
  156. package/dist/types/components/sqm-user-attribute/useUserAttribute.d.ts +0 -3
@@ -1,16 +1,15 @@
1
- import { useEngagementMedium, useMutation, useParentValue, useProgramId, useQuery, useUserIdentity, } from "@saasquatch/component-boilerplate";
2
- import { useState } from "@saasquatch/universal-hooks";
1
+ import { useEngagementMedium, useLazyQuery, useMutation, useParentValue, useProgramId, useQuery, useRefreshDispatcher, useUserIdentity, } from "@saasquatch/component-boilerplate";
2
+ import { useRef, useState } from "@saasquatch/universal-hooks";
3
3
  import { gql } from "graphql-request";
4
4
  import { REFERRAL_CODES_NAMESPACE, SET_CODE_COPIED, } from "../sqm-referral-codes/useReferralCodes";
5
+ const MAX_EDITS = 5;
6
+ const CHARACTER_LIMIT = 15;
7
+ const MIN_CHARACTERS = 3;
5
8
  const MessageLinkQuery = gql `
6
- query ($programId: ID, $engagementMedium: UserEngagementMedium!) {
9
+ query ($programId: ID) {
7
10
  user: viewer {
8
11
  ... on User {
9
- shareLink(
10
- programId: $programId
11
- engagementMedium: $engagementMedium
12
- shareMedium: DIRECT
13
- )
12
+ shareLink(programId: $programId)
14
13
  }
15
14
  }
16
15
  }
@@ -20,19 +19,115 @@ const WIDGET_ENGAGEMENT_EVENT = gql `
20
19
  createUserAnalyticsEvent(eventMeta: $eventMeta)
21
20
  }
22
21
  `;
22
+ const ADD_SHARE_LINK_CODE = gql `
23
+ mutation ($addShareLinkCodeInput: AddShareLinkCodeInput!) {
24
+ addShareLinkCode(addShareLinkCodeInput: $addShareLinkCodeInput) {
25
+ linkCode {
26
+ linkCode
27
+ shortUrl
28
+ referralCode {
29
+ code
30
+ }
31
+ }
32
+ }
33
+ }
34
+ `;
35
+ const VALIDATE_LINK_CODE = gql `
36
+ query validateLinkCode($linkCode: String!) {
37
+ validateLinkCode(linkCode: $linkCode) {
38
+ valid
39
+ invalidReason
40
+ }
41
+ }
42
+ `;
43
+ const GET_LINK_DOMAIN = gql `
44
+ query getLinkDomain {
45
+ tenantSettings {
46
+ primaryLinkDomain {
47
+ host
48
+ }
49
+ }
50
+ }
51
+ `;
52
+ const SHARE_LINK_EDIT_COUNT = gql `
53
+ query shareLinkEditCount {
54
+ viewer {
55
+ ... on User {
56
+ shareLinkCodes {
57
+ totalCount
58
+ data {
59
+ isVanity
60
+ }
61
+ }
62
+ }
63
+ }
64
+ }
65
+ `;
66
+ function parseShareUrl(url) {
67
+ try {
68
+ const parsed = new URL(url);
69
+ return {
70
+ url: parsed.origin + parsed.pathname,
71
+ domain: parsed.origin + "/",
72
+ path: parsed.pathname.slice(1),
73
+ };
74
+ }
75
+ catch {
76
+ return { url, domain: url, path: "" };
77
+ }
78
+ }
23
79
  export function useShareLink(props) {
24
- var _a, _b;
80
+ var _a, _b, _c, _d, _e, _f, _g;
25
81
  const { programId = useProgramId() } = props;
26
82
  const user = useUserIdentity();
27
83
  const engagementMedium = useEngagementMedium();
28
84
  const contextData = useParentValue(REFERRAL_CODES_NAMESPACE);
29
- const { data } = useQuery(MessageLinkQuery, { programId, engagementMedium }, !(user === null || user === void 0 ? void 0 : user.jwt) || !!props.linkOverride || (contextData === null || contextData === void 0 ? void 0 : contextData.shareLink) !== undefined);
85
+ const { data, refetch } = useQuery(MessageLinkQuery, { programId }, !(user === null || user === void 0 ? void 0 : user.jwt) || !!props.linkOverride || (contextData === null || contextData === void 0 ? void 0 : contextData.shareLink) !== undefined);
30
86
  const [sendLoadEvent] = useMutation(WIDGET_ENGAGEMENT_EVENT);
31
- const [setCopied, copiedRes] = useMutation(SET_CODE_COPIED);
32
- const copyString = (_b = ((contextData === null || contextData === void 0 ? void 0 : contextData.shareLink) || ((_a = data === null || data === void 0 ? void 0 : data.user) === null || _a === void 0 ? void 0 : _a.shareLink))) !== null && _b !== void 0 ? _b :
87
+ const [setCopied] = useMutation(SET_CODE_COPIED);
88
+ const [addShareLinkCode, { loading: isSaving }] = useMutation(ADD_SHARE_LINK_CODE);
89
+ const [validateLinkCode] = useLazyQuery(VALIDATE_LINK_CODE);
90
+ const { refresh } = useRefreshDispatcher();
91
+ const { data: linkDomainData } = useQuery(GET_LINK_DOMAIN, {}, !(user === null || user === void 0 ? void 0 : user.jwt) || !props.allowCustomization);
92
+ const { data: editCountData, refetch: refetchEditCount } = useQuery(SHARE_LINK_EDIT_COUNT, {}, !(user === null || user === void 0 ? void 0 : user.jwt) || !props.allowCustomization);
93
+ const { url: copyString, domain: domainPrefix, path: pathSuffix, } = parseShareUrl((_b = ((contextData === null || contextData === void 0 ? void 0 : contextData.shareLink) || ((_a = data === null || data === void 0 ? void 0 : data.user) === null || _a === void 0 ? void 0 : _a.shareLink))) !== null && _b !== void 0 ? _b :
33
94
  // Shown during loading
34
- "...";
95
+ "...");
35
96
  const [open, setOpen] = useState(false);
97
+ const [isEditing, setIsEditing] = useState(false);
98
+ const [editValue, setEditValue] = useState("");
99
+ const [validationError, setValidationError] = useState(null);
100
+ const [isValidating, setIsValidating] = useState(false);
101
+ const debounceTimerRef = useRef(undefined);
102
+ const latestValidationValueRef = useRef("");
103
+ const hasPrimaryLinkDomain = ((_c = linkDomainData === null || linkDomainData === void 0 ? void 0 : linkDomainData.tenantSettings) === null || _c === void 0 ? void 0 : _c.primaryLinkDomain) != null;
104
+ const customizeDisabled = !hasPrimaryLinkDomain;
105
+ const vanityCount = (_g = (_f = (_e = (_d = editCountData === null || editCountData === void 0 ? void 0 : editCountData.viewer) === null || _d === void 0 ? void 0 : _d.shareLinkCodes) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.filter((code) => code.isVanity).length) !== null && _g !== void 0 ? _g : 0;
106
+ const editCount = vanityCount;
107
+ const editsRemaining = Math.max(0, MAX_EDITS - editCount);
108
+ const limitReached = editsRemaining <= 0;
109
+ function mapErrorCodeToInfo(errorCode) {
110
+ if (!errorCode)
111
+ return null;
112
+ const errorMap = {
113
+ EXISTING_CODE_CONFLICT: {
114
+ code: "EXISTING_CODE_CONFLICT",
115
+ title: props.linkTakenErrorTitle,
116
+ description: props.linkTakenErrorDescription,
117
+ },
118
+ INVALID_CHARACTER: {
119
+ code: "INVALID_CHARACTER",
120
+ title: props.invalidCharactersErrorTitle,
121
+ description: props.invalidCharactersErrorDescription,
122
+ },
123
+ BLOCKED_WORD: {
124
+ code: "BLOCKED_WORD",
125
+ title: props.restrictedWordsErrorTitle,
126
+ description: props.restrictedWordsErrorDescription,
127
+ },
128
+ };
129
+ return errorMap[errorCode];
130
+ }
36
131
  async function onClick() {
37
132
  if (contextData) {
38
133
  await setCopied({ referralCode: contextData.referralCode });
@@ -56,5 +151,123 @@ export function useShareLink(props) {
56
151
  },
57
152
  });
58
153
  }
59
- return { ...props, onClick, open, copyString: copyString };
154
+ function onCustomizeClick() {
155
+ if (limitReached || customizeDisabled)
156
+ return;
157
+ setIsEditing(true);
158
+ setEditValue(editCount === 0 ? "" : pathSuffix);
159
+ setValidationError(null);
160
+ }
161
+ function onEditValueChange(value) {
162
+ const trimmed = value.slice(0, CHARACTER_LIMIT);
163
+ setEditValue(trimmed);
164
+ setValidationError(null);
165
+ latestValidationValueRef.current = trimmed;
166
+ if (debounceTimerRef.current)
167
+ clearTimeout(debounceTimerRef.current);
168
+ if (!trimmed || trimmed.length < MIN_CHARACTERS) {
169
+ setIsValidating(false);
170
+ return;
171
+ }
172
+ setIsValidating(true);
173
+ debounceTimerRef.current = setTimeout(async () => {
174
+ var _a, _b;
175
+ const requestedValue = trimmed;
176
+ try {
177
+ const result = await validateLinkCode({ linkCode: requestedValue });
178
+ // Discard stale responses if the user has continued typing
179
+ if (latestValidationValueRef.current !== requestedValue)
180
+ return;
181
+ if (!((_a = result === null || result === void 0 ? void 0 : result.validateLinkCode) === null || _a === void 0 ? void 0 : _a.valid)) {
182
+ const reason = (_b = result === null || result === void 0 ? void 0 : result.validateLinkCode) === null || _b === void 0 ? void 0 : _b.invalidReason;
183
+ setValidationError(mapErrorCodeToInfo(reason));
184
+ }
185
+ }
186
+ catch {
187
+ // Validation query failed — don't block the user
188
+ if (latestValidationValueRef.current !== requestedValue)
189
+ return;
190
+ }
191
+ if (latestValidationValueRef.current === requestedValue) {
192
+ setIsValidating(false);
193
+ }
194
+ }, 500);
195
+ }
196
+ async function onSave() {
197
+ var _a, _b;
198
+ if (!editValue ||
199
+ editValue.length < MIN_CHARACTERS ||
200
+ validationError ||
201
+ isValidating)
202
+ return;
203
+ try {
204
+ await addShareLinkCode({
205
+ addShareLinkCodeInput: {
206
+ userId: user === null || user === void 0 ? void 0 : user.id,
207
+ accountId: user === null || user === void 0 ? void 0 : user.accountId,
208
+ programId,
209
+ linkCode: editValue,
210
+ makeShareLinkCodePrimaryForReferralCode: true,
211
+ },
212
+ });
213
+ setIsEditing(false);
214
+ await Promise.all([refetch(), refetchEditCount()]);
215
+ refresh();
216
+ }
217
+ catch (e) {
218
+ const errorCode = (_a = e === null || e === void 0 ? void 0 : e.extensions) === null || _a === void 0 ? void 0 : _a.code;
219
+ setValidationError((_b = mapErrorCodeToInfo(errorCode)) !== null && _b !== void 0 ? _b : {
220
+ code: null,
221
+ title: props.saveErrorTitle,
222
+ description: (e === null || e === void 0 ? void 0 : e.message) || props.saveErrorDescription,
223
+ });
224
+ }
225
+ }
226
+ function onCancel() {
227
+ setIsEditing(false);
228
+ setEditValue("");
229
+ setValidationError(null);
230
+ setIsValidating(false);
231
+ latestValidationValueRef.current = "";
232
+ if (debounceTimerRef.current)
233
+ clearTimeout(debounceTimerRef.current);
234
+ }
235
+ return {
236
+ copyTextViewProps: {
237
+ ...props,
238
+ onClick,
239
+ open,
240
+ copyString,
241
+ },
242
+ minCharactersText: props.minCharactersText,
243
+ allowCustomization: props.allowCustomization,
244
+ customizeLinkLabel: props.customizeLinkButtonLabel,
245
+ saveLabelText: props.saveLabelText,
246
+ savingLabelText: props.savingLabelText,
247
+ cancelLabelText: props.cancelLabelText,
248
+ editLabelText: props.editLabelText,
249
+ charactersRemainingText: props.charactersRemainingText,
250
+ validatingLabelText: props.validatingLabelText,
251
+ isEditing,
252
+ editValue,
253
+ domainPrefix,
254
+ editsRemaining,
255
+ maxEdits: MAX_EDITS,
256
+ limitReached,
257
+ validationError,
258
+ isValidating,
259
+ isSaving,
260
+ characterLimit: CHARACTER_LIMIT,
261
+ minCharacters: MIN_CHARACTERS,
262
+ charactersRemaining: CHARACTER_LIMIT - editValue.length,
263
+ editLimitText: props.editLimitText,
264
+ editLimitReachedText: props.editLimitReachedText,
265
+ supportLinkText: props.supportLinkText,
266
+ customizeDisabled,
267
+ customizeDisabledTooltip: props.customizeDisabledTooltip,
268
+ onCustomizeClick,
269
+ onEditValueChange,
270
+ onSave,
271
+ onCancel,
272
+ };
60
273
  }
@@ -107,7 +107,6 @@ import * as LeadFormDropdownField from "../sqm-lead-form/LeadFormDropdownField.s
107
107
  import * as LeadCheckboxField from "../sqm-lead-form/LeadCheckboxField.stories";
108
108
  import * as Skeleton from "../sqm-skeleton/Skeleton.stories";
109
109
  import * as UserInfoFormView from "../tax-and-cash/sqm-user-info-form/UserInfoFormView.stories";
110
- import * as UserAttribute from "../sqm-user-attribute/UserAttribute.stories";
111
110
  import { ShadowViewAddon } from "../../ShadowViewAddon";
112
111
  import { CucumberAddon } from "./CucumberAddon";
113
112
  import { HookStoryAddon } from "./HookStoryAddon";
@@ -219,7 +218,6 @@ const stories = [
219
218
  TaxAndCashRewardsTable,
220
219
  TaxAndCashReferralTableRewardsCell,
221
220
  TaxAndCashReferralTable,
222
- UserAttribute,
223
221
  ];
224
222
  /**
225
223
  * For internal documentation
@@ -50,7 +50,7 @@ export function TextSpanView(props, children) {
50
50
  display: inline;
51
51
  }
52
52
  `;
53
- return (h("span", { class: sheet.classes[type], part: "sqm-base" },
53
+ return (h("span", { class: sheet.classes[type], part: "sqm-text-span" },
54
54
  h("style", { type: "text/css" },
55
55
  vanillaStyle,
56
56
  styleString),