@saasquatch/mint-components 1.14.5 → 1.14.6-1

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 (44) hide show
  1. package/dist/cjs/{ShadowViewAddon-787391f7.js → ShadowViewAddon-c0a5fdf8.js} +83 -0
  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_41.cjs.entry.js → sqm-big-stat_42.cjs.entry.js} +218 -3
  5. package/dist/cjs/sqm-stencilbook.cjs.entry.js +115 -3
  6. package/dist/collection/collection-manifest.json +1 -0
  7. package/dist/collection/components/sqm-lead-form/LeadForm.stories.js +102 -0
  8. package/dist/collection/components/sqm-lead-form/sqm-lead-form-view.js +85 -0
  9. package/dist/collection/components/sqm-lead-form/sqm-lead-form.js +353 -0
  10. package/dist/collection/components/sqm-lead-form/useLeadForm.js +122 -0
  11. package/dist/collection/components/sqm-lead-form/useLeadFormState.js +10 -0
  12. package/dist/collection/components/sqm-stencilbook/sqm-stencilbook.js +2 -0
  13. package/dist/esm/{ShadowViewAddon-cf230f50.js → ShadowViewAddon-aa7177fe.js} +83 -1
  14. package/dist/esm/loader.js +1 -1
  15. package/dist/esm/mint-components.js +1 -1
  16. package/dist/esm/{sqm-big-stat_41.entry.js → sqm-big-stat_42.entry.js} +220 -6
  17. package/dist/esm/sqm-stencilbook.entry.js +115 -3
  18. package/dist/esm-es5/{ShadowViewAddon-cf230f50.js → ShadowViewAddon-aa7177fe.js} +1 -1
  19. package/dist/esm-es5/loader.js +1 -1
  20. package/dist/esm-es5/mint-components.js +1 -1
  21. package/dist/esm-es5/sqm-big-stat_42.entry.js +1 -0
  22. package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
  23. package/dist/mint-components/mint-components.esm.js +1 -1
  24. package/dist/mint-components/p-02a6e0df.system.entry.js +1 -0
  25. package/dist/mint-components/{p-6cc141b9.js → p-373a92a2.js} +1 -1
  26. package/dist/mint-components/p-37996351.system.js +1 -1
  27. package/dist/mint-components/p-72e5e84f.system.js +1 -0
  28. package/dist/mint-components/{p-4d7108af.entry.js → p-8dc110b0.entry.js} +2 -2
  29. package/dist/mint-components/p-cde11800.system.entry.js +1 -0
  30. package/dist/mint-components/{p-f7f8545f.entry.js → p-ede3d2f9.entry.js} +25 -19
  31. package/dist/types/components/sqm-lead-form/LeadForm.stories.d.ts +9 -0
  32. package/dist/types/components/sqm-lead-form/sqm-lead-form-view.d.ts +28 -0
  33. package/dist/types/components/sqm-lead-form/sqm-lead-form.d.ts +66 -0
  34. package/dist/types/components/sqm-lead-form/useLeadForm.d.ts +23 -0
  35. package/dist/types/components/sqm-lead-form/useLeadFormState.d.ts +19 -0
  36. package/dist/types/components.d.ts +114 -0
  37. package/docs/docs.docx +0 -0
  38. package/docs/raisins.json +1 -1
  39. package/grapesjs/grapesjs.js +1 -1
  40. package/package.json +1 -1
  41. package/dist/esm-es5/sqm-big-stat_41.entry.js +0 -1
  42. package/dist/mint-components/p-28c615f2.system.entry.js +0 -1
  43. package/dist/mint-components/p-562428ef.system.js +0 -1
  44. package/dist/mint-components/p-caca540c.system.entry.js +0 -1
@@ -23,7 +23,7 @@ const sqmPortalLoginView = require('./sqm-portal-login-view-761a4d8e.js');
23
23
  const usePortalLogin = require('./usePortalLogin-63d896d1.js');
24
24
  const AsYouType = require('./AsYouType-6788393a.js');
25
25
  const utilities = require('./utilities-78f5e169.js');
26
- const ShadowViewAddon = require('./ShadowViewAddon-787391f7.js');
26
+ const ShadowViewAddon = require('./ShadowViewAddon-c0a5fdf8.js');
27
27
  require('./sqm-portal-container-view-4f15143a.js');
28
28
  const usePayoutStatus = require('./usePayoutStatus-feeac99b.js');
29
29
 
@@ -1344,6 +1344,220 @@ function useInputFieldDemo(props) {
1344
1344
  }, props.demoData || {}, { arrayMerge: (_, a) => a });
1345
1345
  }
1346
1346
 
1347
+ const LEAD_FORM_STATE_CONTEXT = "sq:lead-form-state";
1348
+ const LEAD_FORM_STATE_CONTEXT_INTERNAL = "sq:lead-form-state-internal";
1349
+ function useLeadFormState(formState) {
1350
+ const host = index_module._();
1351
+ const [leadFormState, setLeadFormState] = stencilHooks_module.y(host, LEAD_FORM_STATE_CONTEXT, formState);
1352
+ stencilHooks_module.y(host, LEAD_FORM_STATE_CONTEXT_INTERNAL, [leadFormState, setLeadFormState]);
1353
+ return { leadFormState, setLeadFormState };
1354
+ }
1355
+
1356
+ const SUBMIT_LEAD = index_module.dist.gql `
1357
+ mutation submitForm($formSubmissionInput: FormSubmissionInput) {
1358
+ submitForm(formSubmissionInput: $formSubmissionInput) {
1359
+ success
1360
+ }
1361
+ }
1362
+ `;
1363
+ function useLeadForm(props) {
1364
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1365
+ const formRef = stencilHooks_module.useRef(null);
1366
+ const { leadFormState, setLeadFormState } = useLeadFormState({});
1367
+ const [submitLead, { loading, errors, data }] = index_module.$e(SUBMIT_LEAD);
1368
+ stencilHooks_module.useEffect(() => {
1369
+ if (!formRef.current)
1370
+ return;
1371
+ const form = formRef.current;
1372
+ form.addEventListener("sl-input", inputFunction);
1373
+ return () => {
1374
+ form.removeEventListener("sl-input", inputFunction);
1375
+ };
1376
+ }, [formRef.current]);
1377
+ const submit = async (event) => {
1378
+ let formControls = event.target.getFormControls();
1379
+ let formData = {};
1380
+ let validationErrors = {};
1381
+ formControls === null || formControls === void 0 ? void 0 : formControls.forEach((control) => {
1382
+ if (!control.name)
1383
+ return;
1384
+ const key = control.name;
1385
+ const value = control.value;
1386
+ jsonpointer.jsonpointer.set(formData, key, value);
1387
+ // required validation
1388
+ if (control.required && !value) {
1389
+ jsonpointer.jsonpointer.set(validationErrors, key, props.requiredFieldErrorMessage);
1390
+ }
1391
+ // custom validation
1392
+ if (typeof control.validationError === "function") {
1393
+ const validate = control.validationError;
1394
+ const validationError = validate({ control, key, value });
1395
+ if (validationError)
1396
+ jsonpointer.jsonpointer.set(validationErrors, key, validationError);
1397
+ }
1398
+ });
1399
+ if (Object.keys(validationErrors).length) {
1400
+ setLeadFormState({ loading: false, error: "", validationErrors });
1401
+ // early return for validation errors
1402
+ return;
1403
+ }
1404
+ setLeadFormState({
1405
+ loading: true,
1406
+ error: "",
1407
+ validationErrors: {},
1408
+ });
1409
+ formData = { ...formData };
1410
+ const variables = {
1411
+ key: props.formKey,
1412
+ formData,
1413
+ };
1414
+ try {
1415
+ const result = await submitLead({ formSubmissionInput: variables });
1416
+ if (result instanceof Error) {
1417
+ throw result;
1418
+ }
1419
+ setLeadFormState({
1420
+ loading: false,
1421
+ error: "",
1422
+ validationErrors: {},
1423
+ });
1424
+ if (result.success) {
1425
+ index_module.jn.push(props.nextPage);
1426
+ }
1427
+ }
1428
+ catch (error) {
1429
+ setLeadFormState({
1430
+ loading: false,
1431
+ error: props.networkErrorMessage,
1432
+ validationErrors: {},
1433
+ });
1434
+ }
1435
+ };
1436
+ const inputFunction = index_module.useCallback((e) => {
1437
+ var _a, _b;
1438
+ const name = (_b = (_a = e.target) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.toLowerCase();
1439
+ if (name !== "tel")
1440
+ return;
1441
+ const asYouType = new AsYouType.AsYouType("US");
1442
+ e.target.value = asYouType.input(e.target.value);
1443
+ }, []);
1444
+ let errorMessage = "";
1445
+ if ((_a = errors === null || errors === void 0 ? void 0 : errors.response) === null || _a === void 0 ? void 0 : _a["error"]) {
1446
+ errorMessage = props.networkErrorMessage;
1447
+ }
1448
+ else if ((errors === null || errors === void 0 ? void 0 : errors.message) && !((_b = errors === null || errors === void 0 ? void 0 : errors.response) === null || _b === void 0 ? void 0 : _b.errors.length)) {
1449
+ errorMessage = props.networkErrorMessage;
1450
+ }
1451
+ else {
1452
+ errorMessage =
1453
+ ((_f = (_e = (_d = (_c = errors === null || errors === void 0 ? void 0 : errors.response) === null || _c === void 0 ? void 0 : _c.errors) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.extensions) === null || _f === void 0 ? void 0 : _f.message) || ((_j = (_h = (_g = errors === null || errors === void 0 ? void 0 : errors.response) === null || _g === void 0 ? void 0 : _g.errors) === null || _h === void 0 ? void 0 : _h[0]) === null || _j === void 0 ? void 0 : _j.message) || (leadFormState === null || leadFormState === void 0 ? void 0 : leadFormState.error);
1454
+ }
1455
+ return {
1456
+ states: {
1457
+ loading,
1458
+ error: errorMessage,
1459
+ leadFormState,
1460
+ referralCode: "ABC123",
1461
+ },
1462
+ callbacks: {
1463
+ submit,
1464
+ inputFunction,
1465
+ },
1466
+ refs: {
1467
+ formRef,
1468
+ },
1469
+ };
1470
+ }
1471
+
1472
+ const LeadForm = class {
1473
+ constructor(hostRef) {
1474
+ index.registerInstance(this, hostRef);
1475
+ this.ignored = true;
1476
+ /**
1477
+ * Redirect participants to this page from their verification email
1478
+ *
1479
+ * @uiName Submission redirect
1480
+ * @uiWidget pageSelect
1481
+ */
1482
+ this.nextPage = "/";
1483
+ /**
1484
+ * @uiName Email field label
1485
+ */
1486
+ this.emailLabel = "Email";
1487
+ /**
1488
+ * @uiName First Name field label
1489
+ */
1490
+ this.firstNameLabel = "First Name";
1491
+ /**
1492
+ * @uiName Last Name field label
1493
+ */
1494
+ this.lastNameLabel = "Last Name";
1495
+ /**
1496
+ * @uiName Submit button text
1497
+ */
1498
+ this.submitLabel = "Submit";
1499
+ /**
1500
+ * @uiName Header text
1501
+ */
1502
+ this.pageLabel = "Submit your information";
1503
+ this.formKey = "lead-form";
1504
+ /**
1505
+ * The message to be displayed when a required field is not filled.
1506
+ *
1507
+ * @uiName Required field message
1508
+ * @uiWidget textArea
1509
+ */
1510
+ this.requiredFieldErrorMessage = "Cannot be empty";
1511
+ /**
1512
+ * The message to be displayed when a the form submission fails unexpectedly.
1513
+ *
1514
+ * @uiName Network error message
1515
+ * @uiWidget textArea
1516
+ */
1517
+ this.networkErrorMessage = "Network request failed.";
1518
+ /**
1519
+ * The message to be displayed when the email used is invalid or blocked.
1520
+ *
1521
+ * @uiName Invalid email message
1522
+ * @uiWidget textArea
1523
+ */
1524
+ this.invalidEmailErrorMessage = "Must be a valid email address";
1525
+ stencilHooks_module.h$1(this);
1526
+ }
1527
+ disconnectedCallback() { }
1528
+ render() {
1529
+ const { states, callbacks, refs } = index_module.isDemo()
1530
+ ? useRegisterDemo(this)
1531
+ : useLeadForm(this);
1532
+ const content = {
1533
+ formData: index.h("slot", { name: "formData" }),
1534
+ emailLabel: this.emailLabel,
1535
+ submitLabel: this.submitLabel,
1536
+ pageLabel: this.pageLabel,
1537
+ invalidEmailErrorMessage: this.invalidEmailErrorMessage,
1538
+ requiredFieldErrorMessage: this.requiredFieldErrorMessage,
1539
+ };
1540
+ return (index.h(ShadowViewAddon.LeadFormView, { states: states, callbacks: callbacks, content: content, refs: refs }));
1541
+ }
1542
+ };
1543
+ function useRegisterDemo(props) {
1544
+ return cjs.cjs({
1545
+ states: {
1546
+ error: "",
1547
+ loading: false,
1548
+ },
1549
+ callbacks: {
1550
+ submit: async (_event) => {
1551
+ console.log("submit");
1552
+ },
1553
+ inputFunction: () => { },
1554
+ },
1555
+ refs: {
1556
+ formRef: {},
1557
+ },
1558
+ }, props.demoData || {}, { arrayMerge: (_, a) => a });
1559
+ }
1560
+
1347
1561
  const GET_LEADERBOARD = index_module.dist.gql `
1348
1562
  query (
1349
1563
  $type: String!
@@ -3044,7 +3258,7 @@ const PortalRegister = class {
3044
3258
  disconnectedCallback() { }
3045
3259
  render() {
3046
3260
  const { states, callbacks, refs } = index_module.isDemo()
3047
- ? useRegisterDemo(this)
3261
+ ? useRegisterDemo$1(this)
3048
3262
  : usePortalRegister(this);
3049
3263
  const content = {
3050
3264
  formData: index.h("slot", { name: "formData" }),
@@ -3067,7 +3281,7 @@ const PortalRegister = class {
3067
3281
  return (index.h(ShadowViewAddon.PortalRegisterView, { states: states, callbacks: callbacks, content: content, refs: refs }));
3068
3282
  }
3069
3283
  };
3070
- function useRegisterDemo(props) {
3284
+ function useRegisterDemo$1(props) {
3071
3285
  return cjs.cjs({
3072
3286
  states: {
3073
3287
  error: "",
@@ -5201,6 +5415,7 @@ exports.sqm_hero_image = HeroImage;
5201
5415
  exports.sqm_hook_story_container = SqmHookStoryContainer;
5202
5416
  exports.sqm_image = Image;
5203
5417
  exports.sqm_input_field = InputField;
5418
+ exports.sqm_lead_form = LeadForm;
5204
5419
  exports.sqm_leaderboard = Leaderboard;
5205
5420
  exports.sqm_link_button = LinkButton;
5206
5421
  exports.sqm_marketing_emails_checkbox = MarketingEmailsCheckbox;
@@ -35,7 +35,7 @@ const sqmPortalResetPasswordView = require('./sqm-portal-reset-password-view-fe6
35
35
  const sqmPortalVerifyEmailView = require('./sqm-portal-verify-email-view-7b678f34.js');
36
36
  require('./ErrorView-b2fcf954.js');
37
37
  const sqmQrCodeView = require('./sqm-qr-code-view-15dfc0b6.js');
38
- const ShadowViewAddon = require('./ShadowViewAddon-787391f7.js');
38
+ const ShadowViewAddon = require('./ShadowViewAddon-c0a5fdf8.js');
39
39
  const sqmPortalContainerView = require('./sqm-portal-container-view-4f15143a.js');
40
40
  const sqmInvoiceTableView = require('./sqm-invoice-table-view-0f7fa309.js');
41
41
 
@@ -15831,6 +15831,117 @@ const QRCode = /*#__PURE__*/Object.freeze({
15831
15831
  DownloadError: DownloadError
15832
15832
  });
15833
15833
 
15834
+ const LeadForm_stories = {
15835
+ title: "Components/Lead Form",
15836
+ };
15837
+ const defaultProps$t = {
15838
+ states: {
15839
+ leadFormState: {},
15840
+ error: "",
15841
+ loading: false,
15842
+ referralCode: "ABC123",
15843
+ },
15844
+ callbacks: {
15845
+ submit: () => console.log("Submit!"),
15846
+ inputFunction: () => { },
15847
+ },
15848
+ refs: {
15849
+ formRef: {},
15850
+ },
15851
+ content: {
15852
+ pageLabel: "Submit your information",
15853
+ requiredFieldErrorMessage: "Cannot be empty",
15854
+ invalidEmailErrorMessage: "Must be a valid email address",
15855
+ },
15856
+ };
15857
+ const errorProps$c = {
15858
+ states: {
15859
+ error: "Something went wrong. Please try again.",
15860
+ leadFormState: {},
15861
+ loading: false,
15862
+ referralCode: "ABC123",
15863
+ },
15864
+ callbacks: {
15865
+ submit: () => console.log("Submit!"),
15866
+ inputFunction: () => { },
15867
+ },
15868
+ refs: {
15869
+ formRef: {},
15870
+ },
15871
+ content: {
15872
+ pageLabel: "Submit your information",
15873
+ requiredFieldErrorMessage: "Cannot be empty",
15874
+ invalidEmailErrorMessage: "Must be a valid email address",
15875
+ },
15876
+ };
15877
+ const loadingProps$9 = {
15878
+ states: {
15879
+ leadFormState: {},
15880
+ error: "",
15881
+ loading: true,
15882
+ referralCode: "ABC123",
15883
+ },
15884
+ callbacks: {
15885
+ submit: () => console.log("Submit!"),
15886
+ inputFunction: () => { },
15887
+ },
15888
+ refs: {
15889
+ formRef: {},
15890
+ },
15891
+ content: {
15892
+ pageLabel: "Submit your information",
15893
+ requiredFieldErrorMessage: "Cannot be empty",
15894
+ invalidEmailErrorMessage: "Must be a valid email address",
15895
+ },
15896
+ };
15897
+ const slottedProps$2 = {
15898
+ states: {
15899
+ leadFormState: {},
15900
+ error: "",
15901
+ loading: false,
15902
+ referralCode: "ABC123",
15903
+ },
15904
+ callbacks: {
15905
+ submit: () => console.log("Submit!"),
15906
+ inputFunction: () => { },
15907
+ },
15908
+ refs: {
15909
+ formRef: {},
15910
+ },
15911
+ content: {
15912
+ pageLabel: "Submit your information",
15913
+ requiredFieldErrorMessage: "Cannot be empty",
15914
+ invalidEmailErrorMessage: "Must be a valid email address",
15915
+ formData: (index.h("div", null,
15916
+ index.h("sl-input", { style: { marginBottom: "var(--sl-spacing-x-large)" }, exportparts: "label: input-label, base: input-base", label: "Slotted Input", required: true }),
15917
+ index.h("sl-input", { exportparts: "label: input-label, base: input-base", label: "Slotted Input 2", required: true }))),
15918
+ },
15919
+ };
15920
+ const Default$r = () => index.h(ShadowViewAddon.LeadFormView, Object.assign({}, defaultProps$t));
15921
+ const LeadSubmitWithError = () => index.h(ShadowViewAddon.LeadFormView, Object.assign({}, errorProps$c));
15922
+ const LeadSubmitLoading = () => index.h(ShadowViewAddon.LeadFormView, Object.assign({}, loadingProps$9));
15923
+ const FieldsHidden$2 = () => {
15924
+ return (index.h("sqm-lead-form", { demoData: {
15925
+ states: {
15926
+ leadFormState: {},
15927
+ error: "",
15928
+ loading: true,
15929
+ referralCode: "ABC123",
15930
+ },
15931
+ } }));
15932
+ };
15933
+ const SlottedInputs$2 = () => index.h(ShadowViewAddon.LeadFormView, Object.assign({}, slottedProps$2));
15934
+
15935
+ const LeadForm = /*#__PURE__*/Object.freeze({
15936
+ __proto__: null,
15937
+ 'default': LeadForm_stories,
15938
+ Default: Default$r,
15939
+ LeadSubmitWithError: LeadSubmitWithError,
15940
+ LeadSubmitLoading: LeadSubmitLoading,
15941
+ FieldsHidden: FieldsHidden$2,
15942
+ SlottedInputs: SlottedInputs$2
15943
+ });
15944
+
15834
15945
  /**
15835
15946
  *
15836
15947
  * Themes
@@ -15843,7 +15954,7 @@ const QRCode = /*#__PURE__*/Object.freeze({
15843
15954
  *
15844
15955
  */
15845
15956
  //
15846
- const Default$r = `
15957
+ const Default$s = `
15847
15958
  // No CSS
15848
15959
  `;
15849
15960
  const Orangey = `
@@ -15877,7 +15988,7 @@ const Klip = `
15877
15988
 
15878
15989
  const Themes = /*#__PURE__*/Object.freeze({
15879
15990
  __proto__: null,
15880
- Default: Default$r,
15991
+ Default: Default$s,
15881
15992
  Orangey: Orangey,
15882
15993
  Netflix: Netflix,
15883
15994
  SaaSquatchCorporate: SaaSquatchCorporate,
@@ -18568,6 +18679,7 @@ const stories = [
18568
18679
  PayoutButtonScroll,
18569
18680
  PayoutStatusAlert,
18570
18681
  QRCode,
18682
+ LeadForm,
18571
18683
  ];
18572
18684
  const StencilStorybook = class {
18573
18685
  constructor(hostRef) {
@@ -42,6 +42,7 @@
42
42
  "./components/sqm-invoice-table/columns/sqm-invoice-table-data-column.js",
43
43
  "./components/sqm-invoice-table/columns/sqm-invoice-table-date-column.js",
44
44
  "./components/sqm-invoice-table/columns/sqm-invoice-table-download-column.js",
45
+ "./components/sqm-lead-form/sqm-lead-form.js",
45
46
  "./components/sqm-leaderboard/sqm-leaderboard.js",
46
47
  "./components/sqm-leaderboard-rank/sqm-leaderboard-rank.js",
47
48
  "./components/sqm-link-button/sqm-link-button.js",
@@ -0,0 +1,102 @@
1
+ import { h } from "@stencil/core";
2
+ import { LeadFormView } from "./sqm-lead-form-view";
3
+ export default {
4
+ title: "Components/Lead Form",
5
+ };
6
+ const defaultProps = {
7
+ states: {
8
+ leadFormState: {},
9
+ error: "",
10
+ loading: false,
11
+ referralCode: "ABC123",
12
+ },
13
+ callbacks: {
14
+ submit: () => console.log("Submit!"),
15
+ inputFunction: () => { },
16
+ },
17
+ refs: {
18
+ formRef: {},
19
+ },
20
+ content: {
21
+ pageLabel: "Submit your information",
22
+ requiredFieldErrorMessage: "Cannot be empty",
23
+ invalidEmailErrorMessage: "Must be a valid email address",
24
+ },
25
+ };
26
+ const errorProps = {
27
+ states: {
28
+ error: "Something went wrong. Please try again.",
29
+ leadFormState: {},
30
+ loading: false,
31
+ referralCode: "ABC123",
32
+ },
33
+ callbacks: {
34
+ submit: () => console.log("Submit!"),
35
+ inputFunction: () => { },
36
+ },
37
+ refs: {
38
+ formRef: {},
39
+ },
40
+ content: {
41
+ pageLabel: "Submit your information",
42
+ requiredFieldErrorMessage: "Cannot be empty",
43
+ invalidEmailErrorMessage: "Must be a valid email address",
44
+ },
45
+ };
46
+ const loadingProps = {
47
+ states: {
48
+ leadFormState: {},
49
+ error: "",
50
+ loading: true,
51
+ referralCode: "ABC123",
52
+ },
53
+ callbacks: {
54
+ submit: () => console.log("Submit!"),
55
+ inputFunction: () => { },
56
+ },
57
+ refs: {
58
+ formRef: {},
59
+ },
60
+ content: {
61
+ pageLabel: "Submit your information",
62
+ requiredFieldErrorMessage: "Cannot be empty",
63
+ invalidEmailErrorMessage: "Must be a valid email address",
64
+ },
65
+ };
66
+ const slottedProps = {
67
+ states: {
68
+ leadFormState: {},
69
+ error: "",
70
+ loading: false,
71
+ referralCode: "ABC123",
72
+ },
73
+ callbacks: {
74
+ submit: () => console.log("Submit!"),
75
+ inputFunction: () => { },
76
+ },
77
+ refs: {
78
+ formRef: {},
79
+ },
80
+ content: {
81
+ pageLabel: "Submit your information",
82
+ requiredFieldErrorMessage: "Cannot be empty",
83
+ invalidEmailErrorMessage: "Must be a valid email address",
84
+ formData: (h("div", null,
85
+ h("sl-input", { style: { marginBottom: "var(--sl-spacing-x-large)" }, exportparts: "label: input-label, base: input-base", label: "Slotted Input", required: true }),
86
+ h("sl-input", { exportparts: "label: input-label, base: input-base", label: "Slotted Input 2", required: true }))),
87
+ },
88
+ };
89
+ export const Default = () => h(LeadFormView, Object.assign({}, defaultProps));
90
+ export const LeadSubmitWithError = () => h(LeadFormView, Object.assign({}, errorProps));
91
+ export const LeadSubmitLoading = () => h(LeadFormView, Object.assign({}, loadingProps));
92
+ export const FieldsHidden = () => {
93
+ return (h("sqm-lead-form", { demoData: {
94
+ states: {
95
+ leadFormState: {},
96
+ error: "",
97
+ loading: true,
98
+ referralCode: "ABC123",
99
+ },
100
+ } }));
101
+ };
102
+ export const SlottedInputs = () => h(LeadFormView, Object.assign({}, slottedProps));
@@ -0,0 +1,85 @@
1
+ import { h } from "@stencil/core";
2
+ import { AuthButtonsContainer, AuthColumn, AuthWrapper, ErrorStyles, HostBlock, } from "../../global/mixins";
3
+ import { createStyleSheet } from "../../styling/JSS";
4
+ import { TextSpanView } from "../sqm-text-span/sqm-text-span-view";
5
+ const style = {
6
+ Wrapper: { ...AuthWrapper, "max-width": "600px" },
7
+ Column: AuthColumn,
8
+ HostBlock: HostBlock,
9
+ ":host": {
10
+ margin: "0 auto",
11
+ width: "100%",
12
+ },
13
+ ButtonsContainer: AuthButtonsContainer,
14
+ ErrorStyle: ErrorStyles,
15
+ };
16
+ const vanillaStyle = `
17
+ sqm-portal-register {
18
+ margin: 0 auto;
19
+ width: 100%;
20
+ display: block;
21
+ }
22
+
23
+ :host{
24
+ display: block;
25
+ }
26
+
27
+ :host([hidden]) {
28
+ display: none;
29
+ }
30
+ `;
31
+ const sheet = createStyleSheet(style);
32
+ const styleString = sheet.toString();
33
+ export function LeadFormView(props) {
34
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
35
+ const { states, refs, callbacks, content } = props;
36
+ if (states.error) {
37
+ window.scrollTo({ top: 0, left: 0, behavior: "smooth" });
38
+ }
39
+ return (h("div", { class: sheet.classes.Wrapper, part: "sqm-base" },
40
+ h("style", { type: "text/css" },
41
+ vanillaStyle,
42
+ styleString),
43
+ h(TextSpanView, { type: "h3" }, content.pageLabel),
44
+ h("sl-form", { class: sheet.classes.Column, "onSl-submit": callbacks.submit, ref: (el) => (refs.formRef.current = el), novalidate: true },
45
+ states.error && (h("sqm-form-message", { type: "error", exportparts: "erroralert-icon" },
46
+ h("div", { part: "erroralert-text" }, props.states.error))),
47
+ h("sl-input", Object.assign({ exportparts: "label: input-label, base: input-base", type: "text", name: "/lastName", label: content.firstNameLabel || "First Name", disabled: states.loading, required: true, validationError: ({ value }) => {
48
+ if (!value) {
49
+ return content.requiredFieldErrorMessage;
50
+ }
51
+ } }, (((_b = (_a = states.leadFormState) === null || _a === void 0 ? void 0 : _a.validationErrors) === null || _b === void 0 ? void 0 : _b.firstName) ? {
52
+ class: sheet.classes.ErrorStyle,
53
+ helpText: ((_d = (_c = states.leadFormState) === null || _c === void 0 ? void 0 : _c.validationErrors) === null || _d === void 0 ? void 0 : _d.firstName) ||
54
+ content.requiredFieldErrorMessage,
55
+ }
56
+ : []))),
57
+ h("sl-input", Object.assign({ exportparts: "label: input-label, base: input-base", type: "text", name: "/lastName", label: content.lastNameLabel || "Last Name", disabled: states.loading, required: true, validationError: ({ value }) => {
58
+ if (!value) {
59
+ return content.requiredFieldErrorMessage;
60
+ }
61
+ } }, (((_f = (_e = states.leadFormState) === null || _e === void 0 ? void 0 : _e.validationErrors) === null || _f === void 0 ? void 0 : _f.lastName) ? {
62
+ class: sheet.classes.ErrorStyle,
63
+ helpText: ((_h = (_g = states.leadFormState) === null || _g === void 0 ? void 0 : _g.validationErrors) === null || _h === void 0 ? void 0 : _h.lastName) ||
64
+ content.requiredFieldErrorMessage,
65
+ }
66
+ : []))),
67
+ h("sl-input", Object.assign({ exportparts: "label: input-label, base: input-base", type: "email", name: "/email", label: content.emailLabel || "Email", disabled: states.loading, required: true, validationError: ({ value }) => {
68
+ if (!value) {
69
+ return content.requiredFieldErrorMessage;
70
+ }
71
+ // this matches shoelace validation, but could be better
72
+ if (!value.includes("@")) {
73
+ return content.invalidEmailErrorMessage;
74
+ }
75
+ } }, (((_k = (_j = states.leadFormState) === null || _j === void 0 ? void 0 : _j.validationErrors) === null || _k === void 0 ? void 0 : _k.email) ? {
76
+ class: sheet.classes.ErrorStyle,
77
+ helpText: ((_m = (_l = states.leadFormState) === null || _l === void 0 ? void 0 : _l.validationErrors) === null || _m === void 0 ? void 0 : _m.email) ||
78
+ content.requiredFieldErrorMessage,
79
+ }
80
+ : []))),
81
+ h("input", { type: "hidden", hidden: true, name: "/rsReferralCode", value: states.referralCode }),
82
+ content.formData,
83
+ h("div", { class: sheet.classes.ButtonsContainer },
84
+ h("sl-button", { submit: true, loading: states.loading, exportparts: "base: primarybutton-base", type: "primary" }, content.submitLabel || "Register")))));
85
+ }