@saasquatch/mint-components 2.1.8-1 → 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.
Files changed (67) hide show
  1. package/dist/cjs/{ShadowViewAddon-5ce32291.js → ShadowViewAddon-3384ddc4.js} +375 -98
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/mint-components.cjs.js +1 -1
  4. package/dist/cjs/sqm-banking-info-form_10.cjs.entry.js +50 -377
  5. package/dist/cjs/{sqm-big-stat_46.cjs.entry.js → sqm-big-stat_45.cjs.entry.js} +172 -351
  6. package/dist/cjs/sqm-stencilbook.cjs.entry.js +168 -175
  7. package/dist/collection/collection-manifest.json +0 -1
  8. package/dist/collection/components/sqm-share-code/sqm-share-code.js +0 -1
  9. package/dist/collection/components/sqm-share-link/ShareLink.stories.js +142 -11
  10. package/dist/collection/components/sqm-share-link/UseShareLink.stories.js +14 -5
  11. package/dist/collection/components/sqm-share-link/sqm-share-link-view.js +173 -0
  12. package/dist/collection/components/sqm-share-link/sqm-share-link.js +536 -26
  13. package/dist/collection/components/sqm-share-link/useShareLink.js +200 -5
  14. package/dist/collection/components/sqm-stencilbook/sqm-stencilbook.js +0 -2
  15. package/dist/collection/components/tax-and-cash/sqm-banking-info-form/formDefinitions.js +37 -75
  16. package/dist/collection/components/tax-and-cash/sqm-banking-info-form/sqm-banking-info-form.js +13 -688
  17. package/dist/collection/components/tax-and-cash/sqm-banking-info-form/useBankingInfoForm.js +1 -95
  18. package/dist/esm/{ShadowViewAddon-9d97b5d5.js → ShadowViewAddon-c2f026c0.js} +376 -99
  19. package/dist/esm/loader.js +1 -1
  20. package/dist/esm/mint-components.js +1 -1
  21. package/dist/esm/sqm-banking-info-form_10.entry.js +50 -377
  22. package/dist/esm/{sqm-big-stat_46.entry.js → sqm-big-stat_45.entry.js} +177 -355
  23. package/dist/esm/sqm-stencilbook.entry.js +168 -175
  24. package/dist/esm-es5/ShadowViewAddon-c2f026c0.js +1 -0
  25. package/dist/esm-es5/loader.js +1 -1
  26. package/dist/esm-es5/mint-components.js +1 -1
  27. package/dist/esm-es5/sqm-banking-info-form_10.entry.js +1 -1
  28. package/dist/esm-es5/sqm-big-stat_45.entry.js +1 -0
  29. package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
  30. package/dist/mint-components/mint-components.esm.js +1 -1
  31. package/dist/mint-components/p-1ebdb2b3.js +500 -0
  32. package/dist/mint-components/p-87fb29a9.system.js +1 -0
  33. package/dist/mint-components/{p-499885aa.entry.js → p-a01baeea.entry.js} +2 -2
  34. package/dist/mint-components/p-ca098be1.system.js +1 -1
  35. package/dist/mint-components/p-cacb897d.system.entry.js +1 -0
  36. package/dist/mint-components/{p-22e39d2c.entry.js → p-debc2b08.entry.js} +21 -90
  37. package/dist/mint-components/{p-a6621899.system.entry.js → p-ea4cd12c.system.entry.js} +1 -1
  38. package/dist/mint-components/p-f865d476.system.entry.js +1 -0
  39. package/dist/mint-components/p-ff378015.entry.js +106 -0
  40. package/dist/types/components/sqm-share-link/ShareLink.stories.d.ts +10 -0
  41. package/dist/types/components/sqm-share-link/UseShareLink.stories.d.ts +6 -0
  42. package/dist/types/components/sqm-share-link/sqm-share-link-view.d.ts +37 -0
  43. package/dist/types/components/sqm-share-link/sqm-share-link.d.ts +107 -2
  44. package/dist/types/components/sqm-share-link/useShareLink.d.ts +27 -4
  45. package/dist/types/components/tax-and-cash/sqm-banking-info-form/formDefinitions.d.ts +0 -2
  46. package/dist/types/components/tax-and-cash/sqm-banking-info-form/sqm-banking-info-form-view.d.ts +0 -4
  47. package/dist/types/components/tax-and-cash/sqm-banking-info-form/sqm-banking-info-form.d.ts +0 -165
  48. package/dist/types/components.d.ts +183 -380
  49. package/docs/docs.docx +0 -0
  50. package/docs/raisins.json +1 -1
  51. package/grapesjs/grapesjs.js +1 -1
  52. package/package.json +1 -1
  53. package/dist/collection/components/sqm-partner-info-modal/PartnerInfoModal.stories.js +0 -143
  54. package/dist/collection/components/sqm-partner-info-modal/sqm-partner-info-modal-view.js +0 -90
  55. package/dist/collection/components/sqm-partner-info-modal/sqm-partner-info-modal.js +0 -462
  56. package/dist/collection/components/sqm-partner-info-modal/usePartnerInfoModal.js +0 -180
  57. package/dist/esm-es5/ShadowViewAddon-9d97b5d5.js +0 -1
  58. package/dist/esm-es5/sqm-big-stat_46.entry.js +0 -1
  59. package/dist/mint-components/p-0f036907.system.js +0 -1
  60. package/dist/mint-components/p-adc4e263.js +0 -463
  61. package/dist/mint-components/p-b0253f4c.entry.js +0 -108
  62. package/dist/mint-components/p-d93e19e9.system.entry.js +0 -1
  63. package/dist/mint-components/p-e45a9966.system.entry.js +0 -1
  64. package/dist/types/components/sqm-partner-info-modal/PartnerInfoModal.stories.d.ts +0 -13
  65. package/dist/types/components/sqm-partner-info-modal/sqm-partner-info-modal-view.d.ts +0 -41
  66. package/dist/types/components/sqm-partner-info-modal/sqm-partner-info-modal.d.ts +0 -80
  67. package/dist/types/components/sqm-partner-info-modal/usePartnerInfoModal.d.ts +0 -16
@@ -25,95 +25,6 @@ export const paypalFeeMap = {
25
25
  const ACH_PAYMENT_METHOD = 3;
26
26
  const WIRE_PAYMENT_METHOD = 5;
27
27
  const PAYPAL_PAYMENT_METHOD = 7;
28
- /**
29
- * Maps GraphQL validation error field names to form field names.
30
- */
31
- const API_FIELD_TO_FORM_FIELD = {
32
- // bankProvinceState → form uses bankState
33
- bankProvinceState: "bankState",
34
- };
35
- /**
36
- * Maps Impact API error code paths (from validationErrors[].errorPath) to short,
37
- * readable frontend error codes used in the ICU select props.
38
- */
39
- const API_ERROR_PATH_TO_FRONTEND = {
40
- // Beneficiary account name
41
- "withdrawal.settings.error.empty_beneficiaryname": "empty",
42
- "withdrawal.settings.error.invalid_character_beneficiaryname": "invalidCharacters",
43
- "withdrawal.settings.error.numeric_beneficiaryname": "numeric",
44
- "withdrawal_settings.error.beneficiaryname.size": "tooLong",
45
- "withdrawal.settings.error.non_english_beneficiaryname": "nonEnglish",
46
- "withdrawal_settings.error.business_beneficiaryname_match": "businessNameMismatch",
47
- "withdrawal_settings.error.beneficiaryname_match": "nameMismatch",
48
- "withdrawal_settings.error.business_checkpayeename_match": "businessPayeeMismatch",
49
- "withdrawal_settings.error.checkpayeename_match": "payeeMismatch",
50
- // Bank account number
51
- "withdrawal.settings.error.accountnumber.empty": "empty",
52
- "withdrawal.settings.error.accountnumber.uk": "invalidUk",
53
- "withdrawal.settings.error.bankaccount.invalid": "invalid",
54
- // IBAN
55
- "withdrawal.settings.error.iban": "ibanEmpty",
56
- "withdrawal.settings.error.iban.alphanumeric": "ibanAlphanumeric",
57
- "withdrawal.settings.error.iban.invalid": "ibanInvalid",
58
- "withdrawal.settings.error.iban.uk.country.mismatch": "ibanCountryMismatch",
59
- // Routing code
60
- "withdrawal.settings.error.bsbNumber": "invalidBsb",
61
- "withdrawal.settings.error.sortcode": "invalidSortCode",
62
- "withdrawal.settings.error.routingNumber": "empty",
63
- "withdrawal.settings.error.routingcode": "invalid",
64
- // SWIFT / BIC
65
- "withdrawal.settings.error.bic": "empty",
66
- "withdrawal.settings.error.bic.alphanumeric": "alphanumeric",
67
- "withdrawal.settings.error.bic.invalid": "invalid",
68
- // Bank account type
69
- "global.error.invalid.accounttype": "empty",
70
- // Bank name
71
- "withdrawal.settings.error.bankName": "empty",
72
- // Tax payer ID
73
- "withdrawal.settings.error.taxPayerId": "empty",
74
- "withdrawal.settings.error.taxPayerId.ar": "emptyAr",
75
- "withdrawal.settings.error.taxPayerId.kr": "emptyKr",
76
- "withdrawal.settings.error.taxPayerId.alphanumeric": "alphanumeric",
77
- "withdrawal.settings.error.taxPayerId.alphanumeric.ar": "alphanumericAr",
78
- "withdrawal.settings.error.taxPayerId.alphanumeric.kr": "alphanumericKr",
79
- "withdrawal.settings.error.taxPayerId.invalid": "invalid",
80
- "withdrawal.settings.error.taxPayerId.invalid.ar": "invalidAr",
81
- "withdrawal.settings.error.taxPayerId.invalid.kr": "invalidKr",
82
- "withdrawal.settings.error.taxPayerId.invalid.kzt": "invalidKzt",
83
- "withdrawal.settings.error.taxPayerId.cnpj": "cnpjTooShort",
84
- "withdrawal.settings.error.taxPayerId.cpf": "cpfTooShort",
85
- // Patronymic name
86
- "withdrawal.settings.error.patronymicName": "empty",
87
- "withdrawal.settings.error.patronymicName.alphanumeric": "alphanumeric",
88
- // VO code
89
- "withdrawal.settings.error.voCode": "empty",
90
- "withdrawal.settings.error.voCode.alphanumeric": "alphanumeric",
91
- // Agency code
92
- "withdrawal.settings.error.agencyCode": "empty",
93
- "withdrawal.settings.error.agencyCode.alphanumeric": "alphanumeric",
94
- "withdrawal.settings.error.agencyCode.length": "tooShort",
95
- // Bank address fields
96
- "withdrawal.settings.error.bankAddress": "empty",
97
- "withdrawal.settings.error.bankCity": "empty",
98
- "withdrawal.settings.error.bankProvinceState": "empty",
99
- "withdrawal.settings.error.bankPostalCode": "empty",
100
- // Branch code / name
101
- "withdrawal.settings.error.branchCode": "invalid",
102
- "withdrawal.settings.error.branchName": "empty",
103
- // Classification code
104
- "withdrawal.settings.error.classificationCode.invalid": "empty",
105
- "withdrawal.settings.error.classificationCode.invalid.kzt": "invalidKzt",
106
- // PayPal
107
- "payment.error.email": "empty",
108
- "payment.error.paypal_not_supported": "unsupportedCurrency",
109
- "payment.error.email.invalid": "invalidEmail",
110
- "payment.error.paypal_verification_incomplete": "verificationIncomplete",
111
- // Payment schedule
112
- "payment.error.no_threshold": "empty",
113
- "payment.error.invalid_threshold": "invalid",
114
- "payment.error.no_dayOfMonth": "empty",
115
- "payment.error.invalid_dayOfMonth": "invalid",
116
- };
117
28
  export function getFormInputs({ bitset, formMap }) {
118
29
  // Convert bitset to binary representation
119
30
  const binary = bitset.toString(2).padStart(Object.keys(formMap).length, "0");
@@ -137,7 +48,6 @@ const SAVE_WITHDRAWAL_SETTINGS = gql `
137
48
  validationErrors {
138
49
  field
139
50
  message
140
- code
141
51
  }
142
52
  }
143
53
  }
@@ -153,7 +63,6 @@ const UPDATE_WITHDRAWAL_SETTINGS = gql `
153
63
  validationErrors {
154
64
  field
155
65
  message
156
- code
157
66
  }
158
67
  }
159
68
  }
@@ -326,13 +235,10 @@ export function useBankingInfoForm(props) {
326
235
  else if (!success) {
327
236
  console.error("Validation failed: ", validationErrors);
328
237
  const mappedValidationErrors = validationErrors === null || validationErrors === void 0 ? void 0 : validationErrors.reduce((agg, error) => {
329
- const formField = API_FIELD_TO_FORM_FIELD[error.field] || error.field;
330
- const errorCode = API_ERROR_PATH_TO_FRONTEND[error.errorPath] || error.errorPath;
331
238
  return {
332
239
  ...agg,
333
- [formField]: {
240
+ [error.field]: {
334
241
  type: "invalid",
335
- errorCode,
336
242
  },
337
243
  };
338
244
  }, {});
@@ -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';
@@ -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, copiedRes] = $e(SET_CODE_COPIED);
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
- return { ...props, onClick, open, copyString: copyString };
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$6 = `
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$6,
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$6,
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$7 = `
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$7,
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) {
@@ -4463,94 +4828,6 @@ function LeadDropdownFieldView(props) {
4463
4828
  })))));
4464
4829
  }
4465
4830
 
4466
- const style$b = {
4467
- Dialog: {
4468
- "&::part(panel)": {
4469
- maxWidth: "480px",
4470
- },
4471
- "&::part(title)": {
4472
- fontSize: "var(--sl-font-size-x-large)",
4473
- fontWeight: "600",
4474
- padding: "var(--sl-spacing-x-large) var(--sl-spacing-x-large) 0 var(--sl-spacing-x-large)",
4475
- },
4476
- "&::part(body)": {
4477
- padding: "var(--sl-spacing-small) var(--sl-spacing-x-large)",
4478
- fontSize: "var(--sl-font-size-small)",
4479
- overflow: "visible",
4480
- },
4481
- "&::part(footer)": {
4482
- display: "flex",
4483
- flexDirection: "column",
4484
- gap: "var(--sl-spacing-small)",
4485
- padding: "var(--sl-spacing-small) var(--sl-spacing-x-large) var(--sl-spacing-x-large)",
4486
- },
4487
- "&::part(overlay)": {
4488
- background: "rgba(0, 0, 0, 0.5)",
4489
- },
4490
- "&::part(close-button)": {
4491
- display: "none",
4492
- },
4493
- },
4494
- FormFields: {
4495
- display: "flex",
4496
- gap: "var(--sl-spacing-medium)",
4497
- marginTop: "var(--sl-spacing-medium)",
4498
- "& > *": {
4499
- flex: 1,
4500
- },
4501
- },
4502
- ErrorMessage: {
4503
- color: "var(--sqm-danger-color-text, #d32f2f)",
4504
- fontSize: "var(--sl-font-size-small)",
4505
- marginTop: "var(--sl-spacing-x-small)",
4506
- },
4507
- SearchInput: {
4508
- "&::part(base)": {
4509
- border: "none",
4510
- borderBottom: "1px solid var(--sl-color-neutral-300)",
4511
- borderRadius: "0",
4512
- },
4513
- },
4514
- };
4515
- function PartnerInfoModalView(props) {
4516
- var _a, _b;
4517
- const { states, callbacks, text } = props;
4518
- const sheet = createStyleSheet(style$b);
4519
- const styleString = sheet.toString();
4520
- const description = states.isExistingPartner
4521
- ? text.descriptionExistingPartner
4522
- : text.descriptionNewPartner;
4523
- const buttonLabel = states.isExistingPartner
4524
- ? text.confirmButtonLabel
4525
- : text.submitButtonLabel;
4526
- return (h("sl-dialog", { class: sheet.classes.Dialog, open: states.open, noHeader: false, label: intl.formatMessage({
4527
- id: "modalBrandHeader",
4528
- defaultMessage: text.modalBrandHeader,
4529
- }, { brandName: states.brandName }), "onSl-request-close": (e) => {
4530
- e.preventDefault();
4531
- }, "onSl-hide": (e) => {
4532
- var _a;
4533
- // Prevent closing when clicking outside the dialog but not dropdowns
4534
- if (((_a = e.target) === null || _a === void 0 ? void 0 : _a.tagName) === "SL-DIALOG") {
4535
- e.preventDefault();
4536
- }
4537
- } },
4538
- h("style", { type: "text/css" }, styleString),
4539
- h("p", null, description),
4540
- h("div", { class: sheet.classes.FormFields },
4541
- h("sl-select", { exportparts: "label: input-label, base: input-base", label: text.countryLabel, value: states.countryCode, disabled: states.submitting, required: true, "onSl-select": callbacks.onCountryChange },
4542
- h("sl-input", { class: sheet.classes.SearchInput, placeholder: text.searchCountryPlaceholder, onKeyDown: (e) => e.stopPropagation(), "onSl-input": (e) => { var _a; return callbacks.onCountrySearch(((_a = e.target) === null || _a === void 0 ? void 0 : _a.value) || ""); } }), (_a = states.filteredCountries) === null || _a === void 0 ? void 0 :
4543
- _a.map((c) => (h("sl-menu-item", { value: c.countryCode }, c.displayName)))),
4544
- h("sl-select", { exportparts: "label: input-label, base: input-base", label: text.currencyLabel, value: states.currency, disabled: states.submitting, required: true, "onSl-select": callbacks.onCurrencyChange },
4545
- h("sl-input", { class: sheet.classes.SearchInput, placeholder: text.searchCurrencyPlaceholder, onKeyDown: (e) => e.stopPropagation(), "onSl-input": (e) => { var _a; return callbacks.onCurrencySearch(((_a = e.target) === null || _a === void 0 ? void 0 : _a.value) || ""); } }), (_b = states.filteredCurrencies) === null || _b === void 0 ? void 0 :
4546
- _b.map((c) => (h("sl-menu-item", { value: c.currencyCode },
4547
- c.currencyCode,
4548
- " - ",
4549
- c.displayName))))),
4550
- states.error && h("p", { class: sheet.classes.ErrorMessage }, states.error),
4551
- h("sl-button", { slot: "footer", type: "primary", loading: states.submitting, disabled: states.submitting || !states.countryCode || !states.currency, onClick: callbacks.onSubmit, style: { width: "100%" }, exportparts: "base: primarybutton-base" }, buttonLabel)));
4552
- }
4553
-
4554
4831
  const map = new Map();
4555
4832
  function withShadowView(component) {
4556
4833
  // TODO: Could only do this if rendered in a Stencilbook environment to prevent unintended side-effects
@@ -4585,4 +4862,4 @@ const ShadowViewAddon = ({ story }, children) => {
4585
4862
  h(TagName, { "stencilbook-shadow-view": randomInt })));
4586
4863
  };
4587
4864
 
4588
- 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, useShareLink as J, ProgressBarView as K, LeaderboardView as L, ProgressBar as M, NameFieldsView as N, LeadFormView as O, PortalChangePasswordView as P, LeadDropdownFieldView as Q, ReferralIframeView as R, StatContainerView as S, TaskCardView as T, PartnerInfoModalView 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 };
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 };