@saasquatch/mint-components 2.1.8-2 → 2.1.8-3
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/{ShadowViewAddon-a26deae6.js → ShadowViewAddon-3384ddc4.js} +376 -10
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/mint-components.cjs.js +1 -1
- package/dist/cjs/sqm-banking-info-form_10.cjs.entry.js +4 -4
- package/dist/cjs/sqm-big-stat_45.cjs.entry.js +175 -31
- package/dist/cjs/sqm-stencilbook.cjs.entry.js +168 -19
- package/dist/collection/components/sqm-referral-iframe/ReferralIframe.stories.js +0 -1
- package/dist/collection/components/sqm-referral-iframe/sqm-referral-iframe-view.js +1 -1
- package/dist/collection/components/sqm-referral-iframe/sqm-referral-iframe.js +1 -27
- package/dist/collection/components/sqm-share-code/sqm-share-code.js +0 -1
- package/dist/collection/components/sqm-share-link/ShareLink.stories.js +142 -11
- package/dist/collection/components/sqm-share-link/UseShareLink.stories.js +14 -5
- package/dist/collection/components/sqm-share-link/sqm-share-link-view.js +173 -0
- package/dist/collection/components/sqm-share-link/sqm-share-link.js +536 -26
- package/dist/collection/components/sqm-share-link/useShareLink.js +200 -5
- package/dist/collection/components/tax-and-cash/sqm-indirect-tax-form/sqm-indirect-tax-form.js +4 -4
- package/dist/collection/components/tax-and-cash/sqm-payout-details-card/sqm-payout-details-card.js +2 -2
- package/dist/collection/components/tax-and-cash/sqm-tax-and-cash/sqm-tax-and-cash.js +6 -6
- package/dist/collection/components/tax-and-cash/sqm-tax-and-cash-dashboard/sqm-tax-and-cash-dashboard.js +2 -2
- package/dist/esm/{ShadowViewAddon-47f1e579.js → ShadowViewAddon-c2f026c0.js} +377 -12
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mint-components.js +1 -1
- package/dist/esm/sqm-banking-info-form_10.entry.js +4 -4
- package/dist/esm/sqm-big-stat_45.entry.js +175 -31
- package/dist/esm/sqm-stencilbook.entry.js +168 -19
- package/dist/esm-es5/ShadowViewAddon-c2f026c0.js +1 -0
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/mint-components.js +1 -1
- package/dist/esm-es5/sqm-banking-info-form_10.entry.js +1 -1
- package/dist/esm-es5/sqm-big-stat_45.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-1ebdb2b3.js +500 -0
- package/dist/mint-components/p-87fb29a9.system.js +1 -0
- package/dist/mint-components/p-a01baeea.entry.js +9 -0
- package/dist/mint-components/p-ca098be1.system.js +1 -1
- package/dist/mint-components/{p-5492dd51.system.entry.js → p-cacb897d.system.entry.js} +1 -1
- package/dist/mint-components/{p-7ee8f2ed.entry.js → p-debc2b08.entry.js} +20 -20
- package/dist/mint-components/p-ea4cd12c.system.entry.js +1 -0
- package/dist/mint-components/p-f865d476.system.entry.js +1 -0
- package/dist/mint-components/{p-d4f332a7.entry.js → p-ff378015.entry.js} +7 -7
- package/dist/types/components/sqm-referral-iframe/sqm-referral-iframe-view.d.ts +0 -1
- package/dist/types/components/sqm-referral-iframe/sqm-referral-iframe.d.ts +0 -5
- package/dist/types/components/sqm-share-link/ShareLink.stories.d.ts +10 -0
- package/dist/types/components/sqm-share-link/UseShareLink.stories.d.ts +6 -0
- package/dist/types/components/sqm-share-link/sqm-share-link-view.d.ts +37 -0
- package/dist/types/components/sqm-share-link/sqm-share-link.d.ts +107 -2
- package/dist/types/components/sqm-share-link/useShareLink.d.ts +27 -4
- package/dist/types/components.d.ts +183 -12
- package/docs/docs.docx +0 -0
- package/docs/raisins.json +1 -1
- package/grapesjs/grapesjs.js +1 -1
- package/package.json +1 -1
- package/dist/esm-es5/ShadowViewAddon-47f1e579.js +0 -1
- package/dist/mint-components/p-0614dcbc.entry.js +0 -9
- package/dist/mint-components/p-217dedde.js +0 -463
- package/dist/mint-components/p-bf545082.system.entry.js +0 -1
- package/dist/mint-components/p-ce050888.system.js +0 -1
- package/dist/mint-components/p-de343dd0.system.entry.js +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { h, c as Host, d as getAssetPath, F as Fragment, g as getElement } from './index-38ad4957.js';
|
|
2
2
|
import { i as intl } from './global-96c14d63.js';
|
|
3
|
-
import { b as browser, u as useMemo, k as useState } from './dom-context-hooks.module-50442785.js';
|
|
3
|
+
import { b as browser, u as useMemo, k as useState, m as useRef } from './dom-context-hooks.module-50442785.js';
|
|
4
4
|
import { H, L, J, d as dist, w as wn, B, F as Fn, $ as $e, g as getEnvironmentSDK } from './index.module-b23fdad8.js';
|
|
5
5
|
import { c as cjs } from './cjs-bdfb4486.js';
|
|
6
6
|
import { l as luxonLocale } from './utils-334c1e34.js';
|
|
@@ -3022,7 +3022,7 @@ function ReferralIframeView(props) {
|
|
|
3022
3022
|
const styleString = sheet.toString();
|
|
3023
3023
|
return (h("div", { class: sheet.classes.Container },
|
|
3024
3024
|
h("style", { type: "text/css" }, styleString),
|
|
3025
|
-
h("iframe", { class: sheet.classes.IFrame, src: `${content.iframeSrc}
|
|
3025
|
+
h("iframe", { class: sheet.classes.IFrame, src: `${content.iframeSrc}?rsCode=${data.shareCode}` })));
|
|
3026
3026
|
}
|
|
3027
3027
|
|
|
3028
3028
|
const CheckMark = () => (h("svg", { width: 12, height: 10, fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
|
@@ -4227,6 +4227,178 @@ function useShareButton(props) {
|
|
|
4227
4227
|
};
|
|
4228
4228
|
}
|
|
4229
4229
|
|
|
4230
|
+
const vanillaStyle$6 = `
|
|
4231
|
+
:host {
|
|
4232
|
+
display: block;
|
|
4233
|
+
width: 100%;
|
|
4234
|
+
}
|
|
4235
|
+
`;
|
|
4236
|
+
function ShareLinkView(props) {
|
|
4237
|
+
const { copyTextViewProps, customizeUrl, customizeLinkLabel, saveLabelText, cancelLabelText, successMessage, isEditing, editValue, domainPrefix, editsRemaining, maxEdits, limitReached, validationError, isValidating, isSaving, showSuccess, characterLimit, charactersRemaining, editLimitText, editLimitReachedText, supportLinkText, customizeDisabled, customizeDisabledTooltip, onCustomizeClick, onEditValueChange, onSave, onCancel, } = props;
|
|
4238
|
+
const style = {
|
|
4239
|
+
Container: {
|
|
4240
|
+
display: "flex",
|
|
4241
|
+
flexDirection: "column",
|
|
4242
|
+
gap: "var(--sl-spacing-x-small)",
|
|
4243
|
+
width: "100%",
|
|
4244
|
+
},
|
|
4245
|
+
CustomizeLinkText: {
|
|
4246
|
+
margin: "0",
|
|
4247
|
+
fontSize: "var(--sl-font-size-small)",
|
|
4248
|
+
fontWeight: "600",
|
|
4249
|
+
cursor: "pointer",
|
|
4250
|
+
color: "var(--sl-color-neutral-900)",
|
|
4251
|
+
textAlign: "left",
|
|
4252
|
+
"&:hover": {
|
|
4253
|
+
textDecoration: "underline",
|
|
4254
|
+
},
|
|
4255
|
+
},
|
|
4256
|
+
CustomizeLinkDisabled: {
|
|
4257
|
+
margin: "0",
|
|
4258
|
+
fontSize: "var(--sl-font-size-small)",
|
|
4259
|
+
fontWeight: "600",
|
|
4260
|
+
color: "var(--sl-color-neutral-400)",
|
|
4261
|
+
cursor: "default",
|
|
4262
|
+
textAlign: "left",
|
|
4263
|
+
},
|
|
4264
|
+
EditContainer: {
|
|
4265
|
+
display: "flex",
|
|
4266
|
+
flexDirection: "column",
|
|
4267
|
+
gap: "var(--sl-spacing-x-small)",
|
|
4268
|
+
width: "100%",
|
|
4269
|
+
},
|
|
4270
|
+
EditInputWrapper: {
|
|
4271
|
+
display: "flex",
|
|
4272
|
+
alignItems: "center",
|
|
4273
|
+
width: "100%",
|
|
4274
|
+
border: "var(--sqm-border-thickness, 1px) solid var(--sqm-input-border-color, #d1d5db)",
|
|
4275
|
+
borderRadius: "var(--sqm-border-radius-normal, 4px)",
|
|
4276
|
+
background: "var(--sqm-input-background, #fff)",
|
|
4277
|
+
overflow: "hidden",
|
|
4278
|
+
"&:focus-within": {
|
|
4279
|
+
borderColor: "#999999",
|
|
4280
|
+
boxShadow: "0 0 0 var(--sl-focus-ring-width) var(--sl-input-focus-ring-color)",
|
|
4281
|
+
},
|
|
4282
|
+
},
|
|
4283
|
+
DomainPrefix: {
|
|
4284
|
+
padding: "0 0 0 var(--sl-spacing-medium)",
|
|
4285
|
+
fontSize: "var(--sl-font-size-medium)",
|
|
4286
|
+
color: "var(--sl-color-neutral-500)",
|
|
4287
|
+
whiteSpace: "nowrap",
|
|
4288
|
+
userSelect: "none",
|
|
4289
|
+
lineHeight: "var(--sl-input-height-medium)",
|
|
4290
|
+
},
|
|
4291
|
+
EditInput: {
|
|
4292
|
+
flex: "1",
|
|
4293
|
+
border: "none",
|
|
4294
|
+
outline: "none",
|
|
4295
|
+
padding: "0 var(--sl-spacing-medium) 0 0",
|
|
4296
|
+
fontSize: "var(--sl-font-size-medium)",
|
|
4297
|
+
fontFamily: "var(--sl-font-sans)",
|
|
4298
|
+
color: "var(--sl-input-color)",
|
|
4299
|
+
background: "transparent",
|
|
4300
|
+
lineHeight: "var(--sl-input-height-medium)",
|
|
4301
|
+
minWidth: "0",
|
|
4302
|
+
},
|
|
4303
|
+
EditLabel: {
|
|
4304
|
+
margin: "0",
|
|
4305
|
+
fontSize: "var(--sl-font-size-small)",
|
|
4306
|
+
color: "var(--sl-color-neutral-500)",
|
|
4307
|
+
},
|
|
4308
|
+
HelperText: {
|
|
4309
|
+
margin: "0",
|
|
4310
|
+
fontSize: "var(--sl-font-size-small)",
|
|
4311
|
+
color: "var(--sl-color-neutral-500)",
|
|
4312
|
+
},
|
|
4313
|
+
ErrorText: {
|
|
4314
|
+
margin: "0",
|
|
4315
|
+
fontSize: "var(--sl-font-size-small)",
|
|
4316
|
+
color: "var(--sqm-danger-color-text, #dc2626)",
|
|
4317
|
+
},
|
|
4318
|
+
SuccessText: {
|
|
4319
|
+
margin: "0",
|
|
4320
|
+
fontSize: "var(--sl-font-size-small)",
|
|
4321
|
+
color: "var(--sl-color-success-600, #16a34a)",
|
|
4322
|
+
},
|
|
4323
|
+
ActionRow: {
|
|
4324
|
+
display: "flex",
|
|
4325
|
+
gap: "var(--sl-spacing-medium)",
|
|
4326
|
+
alignItems: "center",
|
|
4327
|
+
},
|
|
4328
|
+
SaveButton: {
|
|
4329
|
+
cursor: "pointer",
|
|
4330
|
+
fontFamily: "var(--sl-font-sans)",
|
|
4331
|
+
fontSize: "var(--sl-font-size-small)",
|
|
4332
|
+
fontWeight: "600",
|
|
4333
|
+
padding: "var(--sl-spacing-x-small) var(--sl-spacing-medium)",
|
|
4334
|
+
borderRadius: "var(--sqm-border-radius-normal, 4px)",
|
|
4335
|
+
border: "1px solid var(--sl-color-neutral-900)",
|
|
4336
|
+
background: "var(--sl-color-neutral-900)",
|
|
4337
|
+
color: "#fff",
|
|
4338
|
+
"&:disabled": {
|
|
4339
|
+
opacity: "0.5",
|
|
4340
|
+
cursor: "default",
|
|
4341
|
+
},
|
|
4342
|
+
},
|
|
4343
|
+
CancelButton: {
|
|
4344
|
+
margin: "0",
|
|
4345
|
+
fontSize: "var(--sl-font-size-small)",
|
|
4346
|
+
fontWeight: "600",
|
|
4347
|
+
cursor: "pointer",
|
|
4348
|
+
background: "none",
|
|
4349
|
+
border: "none",
|
|
4350
|
+
padding: "0",
|
|
4351
|
+
fontFamily: "var(--sl-font-sans)",
|
|
4352
|
+
color: "var(--sl-color-neutral-500)",
|
|
4353
|
+
},
|
|
4354
|
+
};
|
|
4355
|
+
const sheet = createStyleSheet(style);
|
|
4356
|
+
const styleString = sheet.toString();
|
|
4357
|
+
const errorMessageType = (validationError === null || validationError === void 0 ? void 0 : validationError.code) === "LINK_TAKEN" ? "info" : "warning";
|
|
4358
|
+
const showCharactersRemaining = charactersRemaining <= 7;
|
|
4359
|
+
// Editing state
|
|
4360
|
+
if (isEditing) {
|
|
4361
|
+
return (h("div", { class: sheet.classes.Container },
|
|
4362
|
+
h("style", { type: "text/css" },
|
|
4363
|
+
styleString,
|
|
4364
|
+
vanillaStyle$6),
|
|
4365
|
+
h("p", { class: sheet.classes.EditLabel }, "Enter your link"),
|
|
4366
|
+
h("div", { class: sheet.classes.EditInputWrapper },
|
|
4367
|
+
h("span", { class: sheet.classes.DomainPrefix }, domainPrefix),
|
|
4368
|
+
h("input", { class: sheet.classes.EditInput, type: "text", value: editValue, onInput: (e) => onEditValueChange(e.target.value), disabled: isSaving, maxLength: characterLimit })),
|
|
4369
|
+
h("p", { class: sheet.classes.HelperText },
|
|
4370
|
+
editLimitText,
|
|
4371
|
+
showCharactersRemaining &&
|
|
4372
|
+
` Characters remaining: ${charactersRemaining}`),
|
|
4373
|
+
validationError && (h("sqm-form-message", { type: errorMessageType },
|
|
4374
|
+
h("p", { part: "alert-title" }, validationError.title),
|
|
4375
|
+
validationError.description)),
|
|
4376
|
+
isValidating && h("p", { class: sheet.classes.HelperText }, "Validating..."),
|
|
4377
|
+
h("div", { class: sheet.classes.ActionRow },
|
|
4378
|
+
h("button", { class: sheet.classes.SaveButton, onClick: onSave, disabled: isSaving || isValidating || !!validationError || !editValue }, isSaving ? "Saving..." : saveLabelText),
|
|
4379
|
+
h("button", { class: sheet.classes.CancelButton, onClick: onCancel, disabled: isSaving }, cancelLabelText))));
|
|
4380
|
+
}
|
|
4381
|
+
// Default / Customized / Limit reached states
|
|
4382
|
+
return (h("div", { class: sheet.classes.Container },
|
|
4383
|
+
h("style", { type: "text/css" },
|
|
4384
|
+
styleString,
|
|
4385
|
+
vanillaStyle$6),
|
|
4386
|
+
h(CopyTextView, Object.assign({}, copyTextViewProps)),
|
|
4387
|
+
showSuccess && h("p", { class: sheet.classes.SuccessText }, successMessage),
|
|
4388
|
+
customizeUrl && (customizeDisabled ? (h("sl-tooltip", { content: customizeDisabledTooltip },
|
|
4389
|
+
h("p", { class: sheet.classes.CustomizeLinkDisabled }, customizeLinkLabel))) : (h("p", { class: limitReached
|
|
4390
|
+
? sheet.classes.CustomizeLinkDisabled
|
|
4391
|
+
: sheet.classes.CustomizeLinkText, onClick: limitReached ? undefined : onCustomizeClick }, customizeLinkLabel))),
|
|
4392
|
+
customizeUrl && limitReached && (h("p", { class: sheet.classes.HelperText }, intl.formatMessage({
|
|
4393
|
+
id: "editLimitReached",
|
|
4394
|
+
defaultMessage: editLimitReachedText,
|
|
4395
|
+
}, {
|
|
4396
|
+
supportLink: (h("a", { target: "_blank", href: "https://example.com" }, supportLinkText)),
|
|
4397
|
+
})))));
|
|
4398
|
+
}
|
|
4399
|
+
|
|
4400
|
+
const MAX_EDITS = 5;
|
|
4401
|
+
const CHARACTER_LIMIT = 15;
|
|
4230
4402
|
const MessageLinkQuery$1 = dist.gql `
|
|
4231
4403
|
query ($programId: ID, $engagementMedium: UserEngagementMedium!) {
|
|
4232
4404
|
user: viewer {
|
|
@@ -4245,19 +4417,119 @@ const WIDGET_ENGAGEMENT_EVENT = dist.gql `
|
|
|
4245
4417
|
createUserAnalyticsEvent(eventMeta: $eventMeta)
|
|
4246
4418
|
}
|
|
4247
4419
|
`;
|
|
4420
|
+
const ADD_SHARE_LINK_CODE = dist.gql `
|
|
4421
|
+
mutation ($addShareLinkCodeInput: AddShareLinkCodeInput!) {
|
|
4422
|
+
addShareLinkCode(addShareLinkCodeInput: $addShareLinkCodeInput) {
|
|
4423
|
+
linkCode {
|
|
4424
|
+
linkCode
|
|
4425
|
+
shortUrl
|
|
4426
|
+
referralCode {
|
|
4427
|
+
code
|
|
4428
|
+
}
|
|
4429
|
+
}
|
|
4430
|
+
}
|
|
4431
|
+
}
|
|
4432
|
+
`;
|
|
4433
|
+
// TODO: Replace with actual validation query when backend is ready
|
|
4434
|
+
const VALIDATE_LINK_CODE = dist.gql `
|
|
4435
|
+
query validateLinkCode($linkCode: String!, $programId: ID) {
|
|
4436
|
+
validateShareLinkCode(linkCode: $linkCode, programId: $programId) {
|
|
4437
|
+
valid
|
|
4438
|
+
message
|
|
4439
|
+
}
|
|
4440
|
+
}
|
|
4441
|
+
`;
|
|
4442
|
+
const GET_LINK_DOMAIN = dist.gql `
|
|
4443
|
+
query getLinkDomain {
|
|
4444
|
+
tenantSettings {
|
|
4445
|
+
primaryLinkDomain {
|
|
4446
|
+
host
|
|
4447
|
+
}
|
|
4448
|
+
}
|
|
4449
|
+
}
|
|
4450
|
+
`;
|
|
4451
|
+
// TODO: Replace with actual edit count query when backend is ready
|
|
4452
|
+
const SHARE_LINK_EDIT_COUNT = dist.gql `
|
|
4453
|
+
query shareLinkEditCount($programId: ID) {
|
|
4454
|
+
viewer {
|
|
4455
|
+
... on User {
|
|
4456
|
+
shareLinkCodes(programId: $programId) {
|
|
4457
|
+
totalCount
|
|
4458
|
+
}
|
|
4459
|
+
}
|
|
4460
|
+
}
|
|
4461
|
+
}
|
|
4462
|
+
`;
|
|
4463
|
+
function parseDomainPrefix(url) {
|
|
4464
|
+
try {
|
|
4465
|
+
const parsed = new URL(url);
|
|
4466
|
+
return parsed.origin + "/";
|
|
4467
|
+
}
|
|
4468
|
+
catch {
|
|
4469
|
+
return url;
|
|
4470
|
+
}
|
|
4471
|
+
}
|
|
4472
|
+
function parsePathSuffix(url) {
|
|
4473
|
+
try {
|
|
4474
|
+
const parsed = new URL(url);
|
|
4475
|
+
// Remove leading slash
|
|
4476
|
+
return parsed.pathname.slice(1) + parsed.search + parsed.hash;
|
|
4477
|
+
}
|
|
4478
|
+
catch {
|
|
4479
|
+
return "";
|
|
4480
|
+
}
|
|
4481
|
+
}
|
|
4248
4482
|
function useShareLink(props) {
|
|
4249
|
-
var _a, _b;
|
|
4483
|
+
var _a, _b, _c, _d, _e, _f;
|
|
4250
4484
|
const { programId = H() } = props;
|
|
4251
4485
|
const user = J();
|
|
4252
4486
|
const engagementMedium = B();
|
|
4253
4487
|
const contextData = Fn(REFERRAL_CODES_NAMESPACE);
|
|
4254
|
-
const { data } = wn(MessageLinkQuery$1, { programId, engagementMedium }, !(user === null || user === void 0 ? void 0 : user.jwt) || !!props.linkOverride || (contextData === null || contextData === void 0 ? void 0 : contextData.shareLink) !== undefined);
|
|
4488
|
+
const { data, refetch } = wn(MessageLinkQuery$1, { programId, engagementMedium }, !(user === null || user === void 0 ? void 0 : user.jwt) || !!props.linkOverride || (contextData === null || contextData === void 0 ? void 0 : contextData.shareLink) !== undefined);
|
|
4255
4489
|
const [sendLoadEvent] = $e(WIDGET_ENGAGEMENT_EVENT);
|
|
4256
|
-
const [setCopied
|
|
4490
|
+
const [setCopied] = $e(SET_CODE_COPIED);
|
|
4491
|
+
const [addShareLinkCode, { loading: isSaving }] = $e(ADD_SHARE_LINK_CODE);
|
|
4492
|
+
const { data: linkDomainData } = wn(GET_LINK_DOMAIN, {}, !(user === null || user === void 0 ? void 0 : user.jwt) || !props.customizeUrl);
|
|
4493
|
+
// TODO: Wire up when backend query is ready
|
|
4494
|
+
const { data: editCountData } = wn(SHARE_LINK_EDIT_COUNT, { programId }, !(user === null || user === void 0 ? void 0 : user.jwt) || !props.customizeUrl);
|
|
4257
4495
|
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 :
|
|
4258
4496
|
// Shown during loading
|
|
4259
4497
|
"...";
|
|
4260
4498
|
const [open, setOpen] = useState(false);
|
|
4499
|
+
const [isEditing, setIsEditing] = useState(false);
|
|
4500
|
+
const [editValue, setEditValue] = useState("");
|
|
4501
|
+
const [validationError, setValidationError] = useState(null);
|
|
4502
|
+
const [isValidating, setIsValidating] = useState(false);
|
|
4503
|
+
const [showSuccess, setShowSuccess] = useState(false);
|
|
4504
|
+
const debounceTimerRef = useRef(undefined);
|
|
4505
|
+
const domainPrefix = parseDomainPrefix(copyString);
|
|
4506
|
+
const hasPrimaryLinkDomain = ((_c = linkDomainData === null || linkDomainData === void 0 ? void 0 : linkDomainData.tenantSettings) === null || _c === void 0 ? void 0 : _c.primaryLinkDomain) != null;
|
|
4507
|
+
const customizeDisabled = !hasPrimaryLinkDomain;
|
|
4508
|
+
const editCount = (_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.totalCount) !== null && _f !== void 0 ? _f : 0;
|
|
4509
|
+
const editsRemaining = Math.max(0, MAX_EDITS - editCount);
|
|
4510
|
+
const limitReached = editsRemaining <= 0;
|
|
4511
|
+
function mapErrorCodeToInfo(errorCode) {
|
|
4512
|
+
if (!errorCode)
|
|
4513
|
+
return null;
|
|
4514
|
+
const errorMap = {
|
|
4515
|
+
LINK_TAKEN: {
|
|
4516
|
+
code: "LINK_TAKEN",
|
|
4517
|
+
title: props.linkTakenErrorTitle,
|
|
4518
|
+
description: props.linkTakenErrorDescription,
|
|
4519
|
+
},
|
|
4520
|
+
INVALID_SYMBOLS: {
|
|
4521
|
+
code: "INVALID_SYMBOLS",
|
|
4522
|
+
title: props.invalidSymbolsErrorTitle,
|
|
4523
|
+
description: props.invalidSymbolsErrorDescription,
|
|
4524
|
+
},
|
|
4525
|
+
RESTRICTED_WORD: {
|
|
4526
|
+
code: "RESTRICTED_WORD",
|
|
4527
|
+
title: props.restrictedWordErrorTitle,
|
|
4528
|
+
description: props.restrictedWordErrorDescription,
|
|
4529
|
+
},
|
|
4530
|
+
};
|
|
4531
|
+
return errorMap[errorCode];
|
|
4532
|
+
}
|
|
4261
4533
|
async function onClick() {
|
|
4262
4534
|
if (contextData) {
|
|
4263
4535
|
await setCopied({ referralCode: contextData.referralCode });
|
|
@@ -4281,7 +4553,100 @@ function useShareLink(props) {
|
|
|
4281
4553
|
},
|
|
4282
4554
|
});
|
|
4283
4555
|
}
|
|
4284
|
-
|
|
4556
|
+
function onCustomizeClick() {
|
|
4557
|
+
if (limitReached || customizeDisabled)
|
|
4558
|
+
return;
|
|
4559
|
+
setIsEditing(true);
|
|
4560
|
+
setEditValue(parsePathSuffix(copyString));
|
|
4561
|
+
setValidationError(null);
|
|
4562
|
+
}
|
|
4563
|
+
function onEditValueChange(value) {
|
|
4564
|
+
const trimmed = value.slice(0, CHARACTER_LIMIT);
|
|
4565
|
+
setEditValue(trimmed);
|
|
4566
|
+
setValidationError(null);
|
|
4567
|
+
if (debounceTimerRef.current)
|
|
4568
|
+
clearTimeout(debounceTimerRef.current);
|
|
4569
|
+
if (!trimmed) {
|
|
4570
|
+
setIsValidating(false);
|
|
4571
|
+
return;
|
|
4572
|
+
}
|
|
4573
|
+
setIsValidating(true);
|
|
4574
|
+
debounceTimerRef.current = setTimeout(async () => {
|
|
4575
|
+
// TODO: Call actual validation query when backend is ready
|
|
4576
|
+
// Example: const result = await validateLinkCode({ linkCode: trimmed, programId });
|
|
4577
|
+
// if (!result?.validateShareLinkCode?.valid) {
|
|
4578
|
+
// setValidationError(mapErrorCodeToInfo(result.validateShareLinkCode.errorCode));
|
|
4579
|
+
// }
|
|
4580
|
+
setIsValidating(false);
|
|
4581
|
+
}, 2000);
|
|
4582
|
+
}
|
|
4583
|
+
async function onSave() {
|
|
4584
|
+
var _a, _b;
|
|
4585
|
+
if (!editValue || validationError || isValidating)
|
|
4586
|
+
return;
|
|
4587
|
+
try {
|
|
4588
|
+
await addShareLinkCode({
|
|
4589
|
+
addShareLinkCodeInput: {
|
|
4590
|
+
userId: user === null || user === void 0 ? void 0 : user.id,
|
|
4591
|
+
accountId: user === null || user === void 0 ? void 0 : user.accountId,
|
|
4592
|
+
programId,
|
|
4593
|
+
linkCode: editValue,
|
|
4594
|
+
},
|
|
4595
|
+
});
|
|
4596
|
+
setIsEditing(false);
|
|
4597
|
+
setShowSuccess(true);
|
|
4598
|
+
await refetch();
|
|
4599
|
+
setTimeout(() => setShowSuccess(false), 3000);
|
|
4600
|
+
}
|
|
4601
|
+
catch (e) {
|
|
4602
|
+
const errorCode = (_a = e === null || e === void 0 ? void 0 : e.extensions) === null || _a === void 0 ? void 0 : _a.code;
|
|
4603
|
+
setValidationError((_b = mapErrorCodeToInfo(errorCode)) !== null && _b !== void 0 ? _b : {
|
|
4604
|
+
code: null,
|
|
4605
|
+
title: "Error",
|
|
4606
|
+
description: (e === null || e === void 0 ? void 0 : e.message) || "Failed to save custom link. Please try again.",
|
|
4607
|
+
});
|
|
4608
|
+
}
|
|
4609
|
+
}
|
|
4610
|
+
function onCancel() {
|
|
4611
|
+
setIsEditing(false);
|
|
4612
|
+
setEditValue("");
|
|
4613
|
+
setValidationError(null);
|
|
4614
|
+
setIsValidating(false);
|
|
4615
|
+
}
|
|
4616
|
+
return {
|
|
4617
|
+
copyTextViewProps: {
|
|
4618
|
+
...props,
|
|
4619
|
+
onClick,
|
|
4620
|
+
open,
|
|
4621
|
+
copyString,
|
|
4622
|
+
},
|
|
4623
|
+
customizeUrl: props.customizeUrl,
|
|
4624
|
+
customizeLinkLabel: props.customizeLinkLabel,
|
|
4625
|
+
saveLabelText: props.saveLabelText,
|
|
4626
|
+
cancelLabelText: props.cancelLabelText,
|
|
4627
|
+
successMessage: props.successMessage,
|
|
4628
|
+
isEditing,
|
|
4629
|
+
editValue,
|
|
4630
|
+
domainPrefix,
|
|
4631
|
+
editsRemaining,
|
|
4632
|
+
maxEdits: MAX_EDITS,
|
|
4633
|
+
limitReached,
|
|
4634
|
+
validationError,
|
|
4635
|
+
isValidating,
|
|
4636
|
+
isSaving,
|
|
4637
|
+
showSuccess,
|
|
4638
|
+
characterLimit: CHARACTER_LIMIT,
|
|
4639
|
+
charactersRemaining: CHARACTER_LIMIT - editValue.length,
|
|
4640
|
+
editLimitText: props.editLimitText,
|
|
4641
|
+
editLimitReachedText: props.editLimitReachedText,
|
|
4642
|
+
supportLinkText: props.supportLinkText,
|
|
4643
|
+
customizeDisabled,
|
|
4644
|
+
customizeDisabledTooltip: props.customizeDisabledTooltip,
|
|
4645
|
+
onCustomizeClick,
|
|
4646
|
+
onEditValueChange,
|
|
4647
|
+
onSave,
|
|
4648
|
+
onCancel,
|
|
4649
|
+
};
|
|
4285
4650
|
}
|
|
4286
4651
|
|
|
4287
4652
|
const style$9 = {
|
|
@@ -4322,7 +4687,7 @@ const style$9 = {
|
|
|
4322
4687
|
},
|
|
4323
4688
|
ErrorStyle: ErrorStyles,
|
|
4324
4689
|
};
|
|
4325
|
-
const vanillaStyle$
|
|
4690
|
+
const vanillaStyle$7 = `
|
|
4326
4691
|
sqm-portal-register {
|
|
4327
4692
|
margin: 0 auto;
|
|
4328
4693
|
width: 100%;
|
|
@@ -4354,7 +4719,7 @@ function LeadFormView(props) {
|
|
|
4354
4719
|
return (h(Fragment, null,
|
|
4355
4720
|
states.success && (h("div", { class: sheet$9.classes.Wrapper, part: "sqm-base" },
|
|
4356
4721
|
h("style", { type: "text/css" },
|
|
4357
|
-
vanillaStyle$
|
|
4722
|
+
vanillaStyle$7,
|
|
4358
4723
|
styleString$9),
|
|
4359
4724
|
h(TextSpanView, { type: "h3" }, content.pageLabel),
|
|
4360
4725
|
h("sqm-form-message", { loading: states.loading, exportparts: "success-icon" },
|
|
@@ -4364,7 +4729,7 @@ function LeadFormView(props) {
|
|
|
4364
4729
|
h("sl-button", { class: sheet$9.classes.ContinueButton, onClick: callbacks.resetForm, loading: states.loading, exportparts: "base: primarybutton-base", type: "default" }, content.resubmitFormLabel))),
|
|
4365
4730
|
h("div", { class: sheet$9.classes.Wrapper, part: "sqm-base", style: { display: states.success ? "none" : "block" } },
|
|
4366
4731
|
h("style", { type: "text/css" },
|
|
4367
|
-
vanillaStyle$
|
|
4732
|
+
vanillaStyle$7,
|
|
4368
4733
|
styleString$9),
|
|
4369
4734
|
h(TextSpanView, { type: "h3" }, content.pageLabel),
|
|
4370
4735
|
h("sl-form", { class: sheet$9.classes.Column, "onSl-submit": callbacks.submit, ref: (el) => (refs.formRef.current = el), novalidate: true },
|
|
@@ -4417,7 +4782,7 @@ const style$a = {
|
|
|
4417
4782
|
"margin-bottom": "var(--sl-spacing-large)",
|
|
4418
4783
|
},
|
|
4419
4784
|
};
|
|
4420
|
-
const vanillaStyle$
|
|
4785
|
+
const vanillaStyle$8 = `
|
|
4421
4786
|
:host {
|
|
4422
4787
|
margin: 0 auto;
|
|
4423
4788
|
width: 100%;
|
|
@@ -4446,7 +4811,7 @@ function LeadDropdownFieldView(props) {
|
|
|
4446
4811
|
});
|
|
4447
4812
|
return (h("div", { class: sheet$a.classes.FieldContainer, part: "sqm-base" },
|
|
4448
4813
|
h("style", { type: "text/css" },
|
|
4449
|
-
vanillaStyle$
|
|
4814
|
+
vanillaStyle$8,
|
|
4450
4815
|
styleString$a),
|
|
4451
4816
|
h("sl-select", Object.assign({ style: { maxHeight: "100px" }, exportparts: "label: input-label, base: input-base", label: `${content.dropdownLabel}${content.dropdownOptional ? ` ${content.optionalLabel}` : ""}`, name: `/${content.dropdownName}`, multiple: content.multiple }, (!content.dropdownOptional ? { required: true } : []), { disabled: ((_b = states.leadFormState) === null || _b === void 0 ? void 0 : _b.loading) || ((_c = states.leadFormState) === null || _c === void 0 ? void 0 : _c.disabled), validationError: ({ value }) => {
|
|
4452
4817
|
if (!value && !content.dropdownOptional) {
|
|
@@ -4497,4 +4862,4 @@ const ShadowViewAddon = ({ story }, children) => {
|
|
|
4497
4862
|
h(TagName, { "stencilbook-shadow-view": randomInt })));
|
|
4498
4863
|
};
|
|
4499
4864
|
|
|
4500
|
-
export { empty as A, BigStatView as B, CardFeedView as C, DropdownFieldView as D, EditProfileView as E, rewardExchange as F, useShareButton as G, HeroView as H, InputFieldView as I,
|
|
4865
|
+
export { empty as A, BigStatView as B, CardFeedView as C, DropdownFieldView as D, EditProfileView as E, rewardExchange as F, useShareButton as G, HeroView as H, InputFieldView as I, ShareLinkView as J, useShareLink as K, LeaderboardView as L, ProgressBarView as M, NameFieldsView as N, ProgressBar as O, PortalChangePasswordView as P, LeadFormView as Q, ReferralIframeView as R, StatContainerView as S, TaskCardView as T, LeadDropdownFieldView as U, ShadowViewAddon as V, useBigStat as W, withShadowView as X, demoRewardExchange as Y, ShareButtonView as a, PoweredByImg as b, BaseRegistrationFormView as c, CheckboxFieldView as d, CouponCodeView as e, ChangeMarktingView as f, PortalFooterView as g, PortalFrameView as h, RewardExchangeView as i, rewardExchangeLongText as j, rewardExchangeSelected as k, chooseAmountFixed as l, chooseAmountFixedNoDescription as m, chooseAmountVariable as n, chooseAmountVariableNoDescription as o, chooseAmountVariableDisabled as p, chooseAmountVariableUnavailable as q, rewardExchangeCustomErrorMsg as r, confirmFixed as s, confirmVariable as t, useDemoBigStat as u, redemptionError as v, queryError as w, success as x, successVariable as y, loading as z };
|