@saasquatch/mint-components 1.6.2-3 → 1.6.2-4
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/{esm/useValidationState-34e24357.js → cjs/AsYouType-6788393a.js} +2 -10
- package/dist/cjs/{ShadowViewAddon-1c9ca20c.js → ShadowViewAddon-d2c9b323.js} +9 -2
- package/dist/cjs/sqm-big-stat_35.cjs.entry.js +11 -8
- package/dist/cjs/sqm-password-field.cjs.entry.js +12 -6
- package/dist/cjs/sqm-portal-registration-form.cjs.entry.js +63 -17
- package/dist/cjs/sqm-portal-verify-email.cjs.entry.js +0 -1
- package/dist/cjs/sqm-stencilbook.cjs.entry.js +4 -1
- package/dist/cjs/useRegistrationFormState-aa366992.js +23 -0
- package/dist/collection/components/sqm-name-fields/sqm-name-fields-view.js +9 -2
- package/dist/collection/components/sqm-name-fields/sqm-name-fields.js +1 -1
- package/dist/collection/components/sqm-name-fields/useNameFields.js +3 -0
- package/dist/collection/components/sqm-password-field/PasswordField.stories.js +3 -0
- package/dist/collection/components/sqm-password-field/sqm-password-field-view.js +7 -4
- package/dist/collection/components/sqm-password-field/sqm-password-field.js +1 -0
- package/dist/collection/components/sqm-password-field/usePasswordField.js +5 -2
- package/dist/collection/components/sqm-portal-registration-form/sqm-portal-registration-form-view.js +16 -9
- package/dist/collection/components/sqm-portal-registration-form/sqm-portal-registration-form.js +1 -1
- package/dist/collection/components/sqm-portal-registration-form/usePortalRegistrationForm.js +46 -6
- package/dist/collection/components/sqm-portal-registration-form/useRegistrationFormState.js +8 -0
- package/dist/collection/components/sqm-portal-verify-email/usePortalVerifyEmail.js +0 -1
- package/dist/{cjs/useValidationState-942d11da.js → esm/AsYouType-46f67d0d.js} +1 -15
- package/dist/esm/{ShadowViewAddon-77643eb3.js → ShadowViewAddon-34b985aa.js} +9 -2
- package/dist/esm/sqm-big-stat_35.entry.js +5 -2
- package/dist/esm/sqm-password-field.entry.js +12 -6
- package/dist/esm/sqm-portal-registration-form.entry.js +62 -16
- package/dist/esm/sqm-portal-verify-email.entry.js +0 -1
- package/dist/esm/sqm-stencilbook.entry.js +4 -1
- package/dist/esm/useRegistrationFormState-1378c47e.js +18 -0
- package/dist/esm-es5/AsYouType-46f67d0d.js +1 -0
- package/dist/esm-es5/{ShadowViewAddon-77643eb3.js → ShadowViewAddon-34b985aa.js} +1 -1
- package/dist/esm-es5/sqm-big-stat_35.entry.js +1 -1
- package/dist/esm-es5/sqm-password-field.entry.js +1 -1
- package/dist/esm-es5/sqm-portal-registration-form.entry.js +1 -1
- package/dist/esm-es5/sqm-portal-verify-email.entry.js +1 -1
- package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
- package/dist/esm-es5/useRegistrationFormState-1378c47e.js +1 -0
- package/dist/mint-components/mint-components.esm.js +1 -1
- package/dist/mint-components/p-03d611e6.system.entry.js +1 -0
- package/dist/mint-components/p-121cdc60.js +1 -0
- package/dist/mint-components/p-28002477.system.js +1 -0
- package/dist/mint-components/p-4f4c7f69.system.entry.js +1 -0
- package/dist/mint-components/{p-60ae6839.js → p-55411493.js} +1 -1
- package/dist/mint-components/p-586eec52.js +1 -0
- package/dist/mint-components/p-7ca29279.system.entry.js +1 -0
- package/dist/mint-components/p-9d362d44.system.js +1 -0
- package/dist/mint-components/p-c0221050.entry.js +13 -0
- package/dist/mint-components/{p-1d11d313.entry.js → p-c32cc965.entry.js} +12 -12
- package/dist/mint-components/p-c78782b3.system.js +1 -0
- package/dist/mint-components/p-d0f1cc06.entry.js +9 -0
- package/dist/mint-components/p-d3c61681.system.js +1 -1
- package/dist/mint-components/p-dd2506bd.system.entry.js +1 -0
- package/dist/mint-components/p-df9c90db.system.entry.js +1 -0
- package/dist/mint-components/p-e5591fd2.entry.js +1 -0
- package/dist/mint-components/p-fcb6bc22.entry.js +1 -0
- package/dist/types/components/sqm-name-fields/sqm-name-fields-view.d.ts +2 -0
- package/dist/types/components/sqm-name-fields/useNameFields.d.ts +2 -0
- package/dist/types/components/sqm-password-field/sqm-password-field-view.d.ts +2 -0
- package/dist/types/components/sqm-password-field/sqm-password-field.d.ts +2 -0
- package/dist/types/components/sqm-portal-registration-form/sqm-portal-registration-form-view.d.ts +2 -0
- package/dist/types/components/sqm-portal-registration-form/usePortalRegistrationForm.d.ts +2 -0
- package/dist/types/components/sqm-portal-registration-form/useRegistrationFormState.d.ts +23 -0
- package/docs/docs.docx +0 -0
- package/package.json +1 -1
- package/dist/esm-es5/useValidationState-34e24357.js +0 -1
- package/dist/mint-components/p-00893b1e.system.entry.js +0 -1
- package/dist/mint-components/p-2e827a20.system.entry.js +0 -1
- package/dist/mint-components/p-9311fb68.entry.js +0 -1
- package/dist/mint-components/p-955ecee3.system.entry.js +0 -1
- package/dist/mint-components/p-a7895b97.system.entry.js +0 -1
- package/dist/mint-components/p-c6fc021c.js +0 -1
- package/dist/mint-components/p-c7bc2261.entry.js +0 -9
- package/dist/mint-components/p-d78b809c.system.js +0 -1
- package/dist/mint-components/p-e013289c.entry.js +0 -1
- package/dist/mint-components/p-e2fe2d6f.entry.js +0 -1
- package/dist/mint-components/p-e5d4a15d.system.js +0 -1
- package/dist/mint-components/p-f2efaa41.system.entry.js +0 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { P } from './index.module-8e654eb1.js';
|
|
1
|
+
'use strict';
|
|
3
2
|
|
|
4
3
|
// This file is a workaround for a bug in web browsers' "native"
|
|
5
4
|
// ES6 importing system which is uncapable of importing "*.json" files.
|
|
@@ -3872,11 +3871,4 @@ function AsYouType$1(country) {
|
|
|
3872
3871
|
AsYouType$1.prototype = Object.create(AsYouType.prototype, {});
|
|
3873
3872
|
AsYouType$1.prototype.constructor = AsYouType$1;
|
|
3874
3873
|
|
|
3875
|
-
|
|
3876
|
-
function useValidationState(formState) {
|
|
3877
|
-
const host = P();
|
|
3878
|
-
const [validationState, setValidationState] = y(host, FORM_VALIDATION_CONTEXT, formState);
|
|
3879
|
-
return { validationState, setValidationState };
|
|
3880
|
-
}
|
|
3881
|
-
|
|
3882
|
-
export { AsYouType$1 as A, FORM_VALIDATION_CONTEXT as F, useValidationState as u };
|
|
3874
|
+
exports.AsYouType = AsYouType$1;
|
|
@@ -2450,18 +2450,25 @@ sl-input::part(label){
|
|
|
2450
2450
|
const sheet$9 = JSS.createStyleSheet(style$9);
|
|
2451
2451
|
const styleString$9 = sheet$9.toString();
|
|
2452
2452
|
function NameFieldsView(props) {
|
|
2453
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
2453
2454
|
const { states } = props;
|
|
2454
2455
|
const validationErrors = states === null || states === void 0 ? void 0 : states.validationErrors;
|
|
2455
2456
|
return (index.h("div", { class: sheet$9.classes.FieldsContainer },
|
|
2456
2457
|
index.h("style", { type: "text/css" },
|
|
2457
2458
|
vanillaStyle$3,
|
|
2458
2459
|
styleString$9),
|
|
2459
|
-
index.h("sl-input", Object.assign({ exportparts: "label: input-label", name: "/firstName", type: "text", label: states.content.firstNameLabel, required: true }, ((
|
|
2460
|
+
index.h("sl-input", Object.assign({ exportparts: "label: input-label", name: "/firstName", type: "text", label: states.content.firstNameLabel, required: true, disabled: ((_a = states.registrationFormState) === null || _a === void 0 ? void 0 : _a.loading) || ((_b = states.registrationFormState) === null || _b === void 0 ? void 0 : _b.disabled) }, (((_d = (_c = states.registrationFormState) === null || _c === void 0 ? void 0 : _c.initialData) === null || _d === void 0 ? void 0 : _d.firstName) ? {
|
|
2461
|
+
value: (_f = (_e = states.registrationFormState) === null || _e === void 0 ? void 0 : _e.initialData) === null || _f === void 0 ? void 0 : _f.firstName,
|
|
2462
|
+
}
|
|
2463
|
+
: {}), ((validationErrors === null || validationErrors === void 0 ? void 0 : validationErrors.firstName) ? {
|
|
2460
2464
|
class: sheet$9.classes.ErrorStyle,
|
|
2461
2465
|
helpText: (validationErrors === null || validationErrors === void 0 ? void 0 : validationErrors.firstName) || "Cannot be empty",
|
|
2462
2466
|
}
|
|
2463
2467
|
: []))),
|
|
2464
|
-
index.h("sl-input", Object.assign({ exportparts: "label: input-label", name: "/lastName", type: "text", label: states.content.lastNameLabel, required: true }, ((
|
|
2468
|
+
index.h("sl-input", Object.assign({ exportparts: "label: input-label", name: "/lastName", type: "text", label: states.content.lastNameLabel, required: true, disabled: ((_g = states.registrationFormState) === null || _g === void 0 ? void 0 : _g.loading) || ((_h = states.registrationFormState) === null || _h === void 0 ? void 0 : _h.disabled) }, (((_k = (_j = states.registrationFormState) === null || _j === void 0 ? void 0 : _j.initialData) === null || _k === void 0 ? void 0 : _k.lastName) ? {
|
|
2469
|
+
value: (_m = (_l = states.registrationFormState) === null || _l === void 0 ? void 0 : _l.initialData) === null || _m === void 0 ? void 0 : _m.lastName,
|
|
2470
|
+
}
|
|
2471
|
+
: {}), ((validationErrors === null || validationErrors === void 0 ? void 0 : validationErrors.lastName) ? {
|
|
2465
2472
|
class: sheet$9.classes.ErrorStyle,
|
|
2466
2473
|
helpText: (validationErrors === null || validationErrors === void 0 ? void 0 : validationErrors.lastName) || "Cannot be empty",
|
|
2467
2474
|
}
|
|
@@ -18,8 +18,9 @@ require('./luxon-59ca7d19.js');
|
|
|
18
18
|
const utils = require('./utils-6847bc06.js');
|
|
19
19
|
require('./sqm-text-span-view-2c7d94b5.js');
|
|
20
20
|
require('./sqm-portal-container-view-840db620.js');
|
|
21
|
-
const
|
|
22
|
-
const
|
|
21
|
+
const AsYouType = require('./AsYouType-6788393a.js');
|
|
22
|
+
const useRegistrationFormState = require('./useRegistrationFormState-aa366992.js');
|
|
23
|
+
const ShadowViewAddon = require('./ShadowViewAddon-d2c9b323.js');
|
|
23
24
|
require('./sqm-portal-section-view-854a3e9c.js');
|
|
24
25
|
|
|
25
26
|
const BigStat = class {
|
|
@@ -180,7 +181,7 @@ function RequiredPropsError({ missingProps, heading = "There was a problem loadi
|
|
|
180
181
|
}
|
|
181
182
|
|
|
182
183
|
function useCheckboxField() {
|
|
183
|
-
const validationState = stencilHooks_module.d(
|
|
184
|
+
const validationState = stencilHooks_module.d(useRegistrationFormState.FORM_VALIDATION_CONTEXT);
|
|
184
185
|
const [checked, setChecked] = stencilHooks_module.useState(false);
|
|
185
186
|
return {
|
|
186
187
|
states: {
|
|
@@ -322,7 +323,7 @@ const DividedLayout = class {
|
|
|
322
323
|
};
|
|
323
324
|
|
|
324
325
|
function useDropdownField() {
|
|
325
|
-
const validationState = stencilHooks_module.d(
|
|
326
|
+
const validationState = stencilHooks_module.d(useRegistrationFormState.FORM_VALIDATION_CONTEXT);
|
|
326
327
|
return {
|
|
327
328
|
states: {
|
|
328
329
|
validationErrors: validationState === null || validationState === void 0 ? void 0 : validationState.validationErrors,
|
|
@@ -813,7 +814,7 @@ const SqmHookStoryContainer = class {
|
|
|
813
814
|
};
|
|
814
815
|
|
|
815
816
|
function useInputField() {
|
|
816
|
-
const validationState = stencilHooks_module.d(
|
|
817
|
+
const validationState = stencilHooks_module.d(useRegistrationFormState.FORM_VALIDATION_CONTEXT);
|
|
817
818
|
return {
|
|
818
819
|
states: {
|
|
819
820
|
validationErrors: validationState === null || validationState === void 0 ? void 0 : validationState.validationErrors,
|
|
@@ -1105,10 +1106,12 @@ function useLeaderboardDemo(props) {
|
|
|
1105
1106
|
}
|
|
1106
1107
|
|
|
1107
1108
|
function useNameFields(props) {
|
|
1108
|
-
const
|
|
1109
|
+
const registrationFormState = stencilHooks_module.d(useRegistrationFormState.REGISTRATION_FORM_STATE_CONTEXT);
|
|
1110
|
+
const validationState = stencilHooks_module.d(useRegistrationFormState.FORM_VALIDATION_CONTEXT);
|
|
1109
1111
|
return {
|
|
1110
1112
|
states: {
|
|
1111
1113
|
validationErrors: validationState === null || validationState === void 0 ? void 0 : validationState.validationErrors,
|
|
1114
|
+
registrationFormState,
|
|
1112
1115
|
content: {
|
|
1113
1116
|
lastNameLabel: props.lastNameLabel,
|
|
1114
1117
|
firstNameLabel: props.firstNameLabel,
|
|
@@ -1542,7 +1545,7 @@ function useLoginDemo(props) {
|
|
|
1542
1545
|
function usePortalRegister(props) {
|
|
1543
1546
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
1544
1547
|
const formRef = stencilHooks_module.useRef(null);
|
|
1545
|
-
const { validationState, setValidationState } =
|
|
1548
|
+
const { validationState, setValidationState } = useRegistrationFormState.useValidationState({});
|
|
1546
1549
|
const [request, { loading, errors, data }] = index_module.He();
|
|
1547
1550
|
const submit = async (event) => {
|
|
1548
1551
|
let formControls = event.target.getFormControls();
|
|
@@ -1602,7 +1605,7 @@ function usePortalRegister(props) {
|
|
|
1602
1605
|
const name = (_b = (_a = e.target) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.toLowerCase();
|
|
1603
1606
|
if (name !== "tel")
|
|
1604
1607
|
return;
|
|
1605
|
-
const asYouType = new
|
|
1608
|
+
const asYouType = new AsYouType.AsYouType("US");
|
|
1606
1609
|
e.target.value = asYouType.input(e.target.value);
|
|
1607
1610
|
}, []);
|
|
1608
1611
|
stencilHooks_module.useEffect(() => {
|
|
@@ -10,6 +10,7 @@ require('./extends-08099afd.js');
|
|
|
10
10
|
const cjs = require('./cjs-1066ec21.js');
|
|
11
11
|
const mixins = require('./mixins-fe9d4112.js');
|
|
12
12
|
const JSS = require('./JSS-97fd087e.js');
|
|
13
|
+
const useRegistrationFormState = require('./useRegistrationFormState-aa366992.js');
|
|
13
14
|
|
|
14
15
|
var constants = {
|
|
15
16
|
error: {
|
|
@@ -487,27 +488,30 @@ const vanillaStyle = `
|
|
|
487
488
|
const sheet$1 = JSS.createStyleSheet(style$1);
|
|
488
489
|
const styleString$1 = sheet$1.toString();
|
|
489
490
|
function PortalResetPasswordView(props) {
|
|
490
|
-
var _a, _b;
|
|
491
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
491
492
|
const { states, callbacks } = props;
|
|
492
493
|
return (index.h("div", { class: sheet$1.classes.InputContainer },
|
|
493
494
|
index.h("style", { type: "text/css" },
|
|
494
495
|
vanillaStyle,
|
|
495
496
|
styleString$1),
|
|
496
|
-
index.h("sl-input", Object.assign({ exportparts: "label: input-label", type: "password", name: "/password", label: states.content.fieldLabel || "Password", required: true, validationError: ({ value }) => {
|
|
497
|
+
index.h("sl-input", Object.assign({ exportparts: "label: input-label", type: "password", name: "/password", label: states.content.fieldLabel || "Password", required: true, disabled: ((_a = states.registrationFormState) === null || _a === void 0 ? void 0 : _a.loading) || ((_b = states.registrationFormState) === null || _b === void 0 ? void 0 : _b.disabled), validationError: ({ value }) => {
|
|
497
498
|
if (!value) {
|
|
498
499
|
return "Cannot be empty";
|
|
499
500
|
}
|
|
500
|
-
} }, (((
|
|
501
|
+
} }, (((_d = (_c = states.registrationFormState) === null || _c === void 0 ? void 0 : _c.initialData) === null || _d === void 0 ? void 0 : _d.password) ? {
|
|
502
|
+
value: (_f = (_e = states.registrationFormState) === null || _e === void 0 ? void 0 : _e.initialData) === null || _f === void 0 ? void 0 : _f.password,
|
|
503
|
+
}
|
|
504
|
+
: {}), (((_g = states.validationErrors) === null || _g === void 0 ? void 0 : _g.password) ? {
|
|
501
505
|
class: sheet$1.classes.ErrorStyle,
|
|
502
|
-
helpText: ((
|
|
506
|
+
helpText: ((_h = states.validationErrors) === null || _h === void 0 ? void 0 : _h.password) || "Cannot be empty",
|
|
503
507
|
}
|
|
504
508
|
: []), { onInput: (input) => states.enableValidation && callbacks.onInput(input) })),
|
|
505
509
|
states.dynamicValidation));
|
|
506
510
|
}
|
|
507
511
|
|
|
508
|
-
const CONTEXT_NAME = "sq:validation-state";
|
|
509
512
|
function usePasswordField(props) {
|
|
510
|
-
const validationState = stencilHooks_module.d(
|
|
513
|
+
const validationState = stencilHooks_module.d(useRegistrationFormState.FORM_VALIDATION_CONTEXT);
|
|
514
|
+
const registrationFormState = stencilHooks_module.d(useRegistrationFormState.REGISTRATION_FORM_STATE_CONTEXT);
|
|
511
515
|
const [dynamicValidation, setDynamicValidation] = stencilHooks_module.useState("");
|
|
512
516
|
function onInput(input) {
|
|
513
517
|
const validation = validateNewPassword(input.target.value);
|
|
@@ -517,6 +521,7 @@ function usePasswordField(props) {
|
|
|
517
521
|
states: {
|
|
518
522
|
enableValidation: props.enableValidation,
|
|
519
523
|
dynamicValidation,
|
|
524
|
+
registrationFormState,
|
|
520
525
|
validationErrors: validationState === null || validationState === void 0 ? void 0 : validationState.validationErrors,
|
|
521
526
|
content: {
|
|
522
527
|
fieldLabel: props.fieldLabel,
|
|
@@ -571,6 +576,7 @@ function usePasswordFieldDemo(props) {
|
|
|
571
576
|
enableValidation: true,
|
|
572
577
|
dynamicValidation,
|
|
573
578
|
validationErrors: ((_f = (_e = props === null || props === void 0 ? void 0 : props.demoData) === null || _e === void 0 ? void 0 : _e.states) === null || _f === void 0 ? void 0 : _f.validationErrors) || {},
|
|
579
|
+
registrationFormState: {},
|
|
574
580
|
content: {
|
|
575
581
|
fieldLabel: "Password",
|
|
576
582
|
},
|
|
@@ -12,7 +12,8 @@ const cjs = require('./cjs-1066ec21.js');
|
|
|
12
12
|
const mixins = require('./mixins-fe9d4112.js');
|
|
13
13
|
const JSS = require('./JSS-97fd087e.js');
|
|
14
14
|
const sqmTextSpanView = require('./sqm-text-span-view-2c7d94b5.js');
|
|
15
|
-
const
|
|
15
|
+
const AsYouType = require('./AsYouType-6788393a.js');
|
|
16
|
+
const useRegistrationFormState = require('./useRegistrationFormState-aa366992.js');
|
|
16
17
|
|
|
17
18
|
const style = {
|
|
18
19
|
Wrapper: { ...mixins.AuthWrapper, "max-width": "600px" },
|
|
@@ -43,7 +44,7 @@ sqm-portal-register {
|
|
|
43
44
|
const sheet = JSS.createStyleSheet(style);
|
|
44
45
|
const styleString = sheet.toString();
|
|
45
46
|
function PortalRegistrationFormView(props) {
|
|
46
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
47
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
47
48
|
const { states, refs, callbacks, content } = props;
|
|
48
49
|
if (states.error) {
|
|
49
50
|
window.scrollTo({ top: 0, left: 0, behavior: "smooth" });
|
|
@@ -54,10 +55,11 @@ function PortalRegistrationFormView(props) {
|
|
|
54
55
|
styleString),
|
|
55
56
|
index.h(sqmTextSpanView.TextSpanView, { type: "h3" }, content.pageLabel),
|
|
56
57
|
index.h("sl-form", { class: sheet.classes.Column, "onSl-submit": callbacks.submit, ref: (el) => (refs.formRef.current = el), novalidate: true },
|
|
57
|
-
states.
|
|
58
|
-
index.h("div", { part: "erroralert-text" },
|
|
58
|
+
((_a = states.registrationFormState) === null || _a === void 0 ? void 0 : _a.disabled) ? (index.h("sqm-form-message", { type: "error", exportparts: "erroralert-icon" },
|
|
59
|
+
index.h("div", { part: "erroralert-text" }, states.registrationFormState.disabledMessage))) : (states.error && (index.h("sqm-form-message", { type: "error", exportparts: "erroralert-icon" },
|
|
60
|
+
index.h("div", { part: "erroralert-text" }, props.states.error)))),
|
|
59
61
|
content.formData,
|
|
60
|
-
!states.hideInputs && (index.h("sl-input", Object.assign({ exportparts: "label: input-label", type: "email", name: "/email", label: content.emailLabel || "Email", disabled: states.loading, required: true, validationError: ({ value }) => {
|
|
62
|
+
!states.hideInputs && (index.h("sl-input", Object.assign({ exportparts: "label: input-label", type: "email", name: "/email", label: content.emailLabel || "Email", disabled: states.loading || ((_b = states.registrationFormState) === null || _b === void 0 ? void 0 : _b.disabled), required: true, validationError: ({ value }) => {
|
|
61
63
|
if (!value) {
|
|
62
64
|
return "Cannot be empty";
|
|
63
65
|
}
|
|
@@ -65,40 +67,78 @@ function PortalRegistrationFormView(props) {
|
|
|
65
67
|
if (!value.includes("@")) {
|
|
66
68
|
return "Must be a valid email address";
|
|
67
69
|
}
|
|
68
|
-
} }, (((
|
|
70
|
+
} }, (((_d = (_c = states.registrationFormState) === null || _c === void 0 ? void 0 : _c.initialData) === null || _d === void 0 ? void 0 : _d.email) ? {
|
|
71
|
+
value: (_f = (_e = states.registrationFormState) === null || _e === void 0 ? void 0 : _e.initialData) === null || _f === void 0 ? void 0 : _f.email,
|
|
72
|
+
}
|
|
73
|
+
: {}), (((_h = (_g = states.validationState) === null || _g === void 0 ? void 0 : _g.validationErrors) === null || _h === void 0 ? void 0 : _h.email) ? {
|
|
69
74
|
class: sheet.classes.ErrorStyle,
|
|
70
|
-
helpText: ((
|
|
75
|
+
helpText: ((_k = (_j = states.validationState) === null || _j === void 0 ? void 0 : _j.validationErrors) === null || _k === void 0 ? void 0 : _k.email) ||
|
|
71
76
|
"Cannot be empty",
|
|
72
77
|
}
|
|
73
78
|
: [])))),
|
|
74
79
|
!states.hideInputs && (index.h("sqm-password-field", { fieldLabel: content.passwordLabel, "enable-validation": states.enablePasswordValidation })),
|
|
75
80
|
content.passwordField,
|
|
76
|
-
!states.hideInputs && states.confirmPassword && (index.h("sl-input", Object.assign({ exportparts: "label: input-label", type: "password", name: "/confirmPassword", label: content.confirmPasswordLabel, disabled: states.loading, required: true }, (((
|
|
81
|
+
!states.hideInputs && states.confirmPassword && (index.h("sl-input", Object.assign({ exportparts: "label: input-label", type: "password", name: "/confirmPassword", label: content.confirmPasswordLabel, disabled: states.loading, required: true }, (((_m = (_l = states.registrationFormState) === null || _l === void 0 ? void 0 : _l.initialData) === null || _m === void 0 ? void 0 : _m.confirmPassword) ? {
|
|
82
|
+
value: (_p = (_o = states.registrationFormState) === null || _o === void 0 ? void 0 : _o.initialData) === null || _p === void 0 ? void 0 : _p.confirmPassword,
|
|
83
|
+
}
|
|
84
|
+
: {}), (((_r = (_q = states.validationState) === null || _q === void 0 ? void 0 : _q.validationErrors) === null || _r === void 0 ? void 0 : _r.confirmPassword) ? {
|
|
77
85
|
class: sheet.classes.ErrorStyle,
|
|
78
|
-
helpText: ((
|
|
86
|
+
helpText: ((_t = (_s = states.validationState) === null || _s === void 0 ? void 0 : _s.validationErrors) === null || _t === void 0 ? void 0 : _t.confirmPassword) ||
|
|
79
87
|
"Cannot be empty",
|
|
80
88
|
}
|
|
81
89
|
: [])))),
|
|
82
90
|
content.terms,
|
|
83
91
|
index.h("div", { class: sheet.classes.ButtonsContainer },
|
|
84
|
-
index.h("sl-button", { submit: true, loading: states.loading, exportparts: "base: primarybutton-base", type: "primary" }, content.submitLabel || "Register"),
|
|
92
|
+
index.h("sl-button", { submit: true, loading: states.loading, disabled: (_u = states.registrationFormState) === null || _u === void 0 ? void 0 : _u.disabled, exportparts: "base: primarybutton-base", type: "primary" }, content.submitLabel || "Register"),
|
|
85
93
|
content.secondaryButton))));
|
|
86
94
|
}
|
|
87
95
|
|
|
96
|
+
const RegistrationFormQuery = index_module.dist.gql `
|
|
97
|
+
query RegistrationFormQuery($key: String!) {
|
|
98
|
+
form(key: $key) {
|
|
99
|
+
key
|
|
100
|
+
type
|
|
101
|
+
initialData {
|
|
102
|
+
initialData
|
|
103
|
+
isEnabled
|
|
104
|
+
isEnabledErrorMessage
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
`;
|
|
88
109
|
function usePortalRegistrationForm(props) {
|
|
89
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
110
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
90
111
|
const formRef = stencilHooks_module.useRef(null);
|
|
91
|
-
const {
|
|
112
|
+
const { registrationFormState, setRegistrationFormState } = useRegistrationFormState.useRegistrationFormState({});
|
|
113
|
+
const { validationState, setValidationState } = useRegistrationFormState.useValidationState({});
|
|
92
114
|
const [request, { loading, errors, data, formError }] = index_module.We();
|
|
115
|
+
const queryResponse = index_module.wn(RegistrationFormQuery, { key: props.formKey });
|
|
116
|
+
const formLoading = loading || queryResponse.loading;
|
|
117
|
+
stencilHooks_module.useEffect(() => {
|
|
118
|
+
var _a, _b, _c;
|
|
119
|
+
const initialData = (_a = queryResponse === null || queryResponse === void 0 ? void 0 : queryResponse.data) === null || _a === void 0 ? void 0 : _a.form.initialData.initialData;
|
|
120
|
+
const disabled = !((_b = queryResponse === null || queryResponse === void 0 ? void 0 : queryResponse.data) === null || _b === void 0 ? void 0 : _b.form.initialData.isEnabled);
|
|
121
|
+
const disabledMessage = ((_c = queryResponse === null || queryResponse === void 0 ? void 0 : queryResponse.data) === null || _c === void 0 ? void 0 : _c.form.initialData.isEnabledErrorMessage) ||
|
|
122
|
+
"The registration form is currently disabled.";
|
|
123
|
+
const formState = {
|
|
124
|
+
loading: formLoading,
|
|
125
|
+
disabled,
|
|
126
|
+
disabledMessage,
|
|
127
|
+
initialData,
|
|
128
|
+
};
|
|
129
|
+
setRegistrationFormState(formState);
|
|
130
|
+
}, [(_a = queryResponse === null || queryResponse === void 0 ? void 0 : queryResponse.data) === null || _a === void 0 ? void 0 : _a.form.initialData, formLoading]);
|
|
93
131
|
const submit = async (event) => {
|
|
94
132
|
let formControls = event.target.getFormControls();
|
|
95
133
|
let formData = {};
|
|
96
134
|
let validationErrors = {};
|
|
97
135
|
formControls === null || formControls === void 0 ? void 0 : formControls.forEach((control) => {
|
|
136
|
+
console.log({ control }, control.name);
|
|
98
137
|
if (!control.name)
|
|
99
138
|
return;
|
|
100
139
|
const key = control.name;
|
|
101
140
|
const value = control.value;
|
|
141
|
+
// control.value = initialData[key] || control.value;
|
|
102
142
|
jsonpointer.jsonpointer.set(formData, key, value);
|
|
103
143
|
// required validation
|
|
104
144
|
if (control.required && !value) {
|
|
@@ -149,7 +189,7 @@ function usePortalRegistrationForm(props) {
|
|
|
149
189
|
const name = (_b = (_a = e.target) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.toLowerCase();
|
|
150
190
|
if (name !== "tel")
|
|
151
191
|
return;
|
|
152
|
-
const asYouType = new
|
|
192
|
+
const asYouType = new AsYouType.AsYouType("US");
|
|
153
193
|
e.target.value = asYouType.input(e.target.value);
|
|
154
194
|
}, []);
|
|
155
195
|
stencilHooks_module.useEffect(() => {
|
|
@@ -172,21 +212,27 @@ function usePortalRegistrationForm(props) {
|
|
|
172
212
|
};
|
|
173
213
|
}, [formRef.current]);
|
|
174
214
|
let errorMessage = "";
|
|
175
|
-
if ((
|
|
215
|
+
if (((_b = queryResponse === null || queryResponse === void 0 ? void 0 : queryResponse.data) === null || _b === void 0 ? void 0 : _b.form.initialData.isEnabled) === false) {
|
|
216
|
+
errorMessage =
|
|
217
|
+
((_c = queryResponse === null || queryResponse === void 0 ? void 0 : queryResponse.data) === null || _c === void 0 ? void 0 : _c.form.initialData.isEnabledErrorMessage) ||
|
|
218
|
+
"The registration form is disabled";
|
|
219
|
+
}
|
|
220
|
+
else if ((_d = errors === null || errors === void 0 ? void 0 : errors.response) === null || _d === void 0 ? void 0 : _d["error"]) {
|
|
176
221
|
errorMessage = "Network request failed";
|
|
177
222
|
}
|
|
178
|
-
else if ((errors === null || errors === void 0 ? void 0 : errors.message) && !((
|
|
223
|
+
else if ((errors === null || errors === void 0 ? void 0 : errors.message) && !((_e = errors === null || errors === void 0 ? void 0 : errors.response) === null || _e === void 0 ? void 0 : _e.errors.length)) {
|
|
179
224
|
errorMessage = "Network request failed";
|
|
180
225
|
}
|
|
181
226
|
else {
|
|
182
227
|
errorMessage =
|
|
183
|
-
formError || ((_f = (
|
|
228
|
+
formError || ((_j = (_h = (_g = (_f = queryResponse === null || queryResponse === void 0 ? void 0 : queryResponse.errors) === null || _f === void 0 ? void 0 : _f.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) || ((_o = (_m = (_l = (_k = errors === null || errors === void 0 ? void 0 : errors.response) === null || _k === void 0 ? void 0 : _k.errors) === null || _l === void 0 ? void 0 : _l[0]) === null || _m === void 0 ? void 0 : _m.extensions) === null || _o === void 0 ? void 0 : _o.message) || ((_r = (_q = (_p = errors === null || errors === void 0 ? void 0 : errors.response) === null || _p === void 0 ? void 0 : _p.errors) === null || _q === void 0 ? void 0 : _q[0]) === null || _r === void 0 ? void 0 : _r.message) || (validationState === null || validationState === void 0 ? void 0 : validationState.error);
|
|
184
229
|
}
|
|
185
230
|
return {
|
|
186
231
|
states: {
|
|
187
|
-
loading,
|
|
232
|
+
loading: loading || queryResponse.loading,
|
|
188
233
|
error: errorMessage,
|
|
189
234
|
validationState,
|
|
235
|
+
registrationFormState,
|
|
190
236
|
confirmPassword: props.confirmPassword,
|
|
191
237
|
hideInputs: props.hideInputs,
|
|
192
238
|
loginPath: props.loginPath,
|
|
@@ -24,7 +24,6 @@ function usePortalVerifyEmail({ nextPage, failedPage }) {
|
|
|
24
24
|
const urlParams = new URLSearchParams(window.location.search);
|
|
25
25
|
const oobCode = urlParams.get("oobCode");
|
|
26
26
|
const nextPageOverride = urlParams.get("nextPage");
|
|
27
|
-
urlParams.delete("oobCode");
|
|
28
27
|
const failed = () => {
|
|
29
28
|
return index_module.In.push({
|
|
30
29
|
pathname: failedPage,
|
|
@@ -28,7 +28,7 @@ const sqmPortalContainerView = require('./sqm-portal-container-view-840db620.js'
|
|
|
28
28
|
const sqmPortalProfileView = require('./sqm-portal-profile-view-d0818828.js');
|
|
29
29
|
const sqmPortalResetPasswordView = require('./sqm-portal-reset-password-view-f8dc0b79.js');
|
|
30
30
|
const sqmPortalVerifyEmailView = require('./sqm-portal-verify-email-view-cc59877c.js');
|
|
31
|
-
const ShadowViewAddon = require('./ShadowViewAddon-
|
|
31
|
+
const ShadowViewAddon = require('./ShadowViewAddon-d2c9b323.js');
|
|
32
32
|
const sqmPortalSectionView = require('./sqm-portal-section-view-854a3e9c.js');
|
|
33
33
|
|
|
34
34
|
/**
|
|
@@ -5986,6 +5986,7 @@ const Start = () => {
|
|
|
5986
5986
|
initValue: "",
|
|
5987
5987
|
states: {
|
|
5988
5988
|
enableValidation: true,
|
|
5989
|
+
registrationFormState: {},
|
|
5989
5990
|
validationErrors: {},
|
|
5990
5991
|
content: {
|
|
5991
5992
|
fieldLabel: "Password",
|
|
@@ -5999,6 +6000,7 @@ const EmptyError = () => {
|
|
|
5999
6000
|
states: {
|
|
6000
6001
|
enableValidation: true,
|
|
6001
6002
|
validationErrors: { password: "Cannot be empty" },
|
|
6003
|
+
registrationFormState: {},
|
|
6002
6004
|
content: {
|
|
6003
6005
|
fieldLabel: "Password",
|
|
6004
6006
|
},
|
|
@@ -6010,6 +6012,7 @@ const ValidationError = () => {
|
|
|
6010
6012
|
initValue: "asdf",
|
|
6011
6013
|
states: {
|
|
6012
6014
|
enableValidation: true,
|
|
6015
|
+
registrationFormState: {},
|
|
6013
6016
|
validationErrors: { password: "Incomplete" },
|
|
6014
6017
|
content: {
|
|
6015
6018
|
fieldLabel: "Password",
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const stencilHooks_module = require('./stencil-hooks.module-87a1f4f7.js');
|
|
4
|
+
const index_module = require('./index.module-7eab8006.js');
|
|
5
|
+
|
|
6
|
+
const FORM_VALIDATION_CONTEXT = "sq:validation-state";
|
|
7
|
+
function useValidationState(formState) {
|
|
8
|
+
const host = index_module.P();
|
|
9
|
+
const [validationState, setValidationState] = stencilHooks_module.y(host, FORM_VALIDATION_CONTEXT, formState);
|
|
10
|
+
return { validationState, setValidationState };
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const REGISTRATION_FORM_STATE_CONTEXT = "sq:registration-form-state";
|
|
14
|
+
function useRegistrationFormState(formState) {
|
|
15
|
+
const host = index_module.P();
|
|
16
|
+
const [registrationFormState, setRegistrationFormState] = stencilHooks_module.y(host, REGISTRATION_FORM_STATE_CONTEXT, formState);
|
|
17
|
+
return { registrationFormState, setRegistrationFormState };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
exports.FORM_VALIDATION_CONTEXT = FORM_VALIDATION_CONTEXT;
|
|
21
|
+
exports.REGISTRATION_FORM_STATE_CONTEXT = REGISTRATION_FORM_STATE_CONTEXT;
|
|
22
|
+
exports.useRegistrationFormState = useRegistrationFormState;
|
|
23
|
+
exports.useValidationState = useValidationState;
|
|
@@ -24,18 +24,25 @@ sl-input::part(label){
|
|
|
24
24
|
const sheet = createStyleSheet(style);
|
|
25
25
|
const styleString = sheet.toString();
|
|
26
26
|
export function NameFieldsView(props) {
|
|
27
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
27
28
|
const { states } = props;
|
|
28
29
|
const validationErrors = states === null || states === void 0 ? void 0 : states.validationErrors;
|
|
29
30
|
return (h("div", { class: sheet.classes.FieldsContainer },
|
|
30
31
|
h("style", { type: "text/css" },
|
|
31
32
|
vanillaStyle,
|
|
32
33
|
styleString),
|
|
33
|
-
h("sl-input", Object.assign({ exportparts: "label: input-label", name: "/firstName", type: "text", label: states.content.firstNameLabel, required: true }, ((
|
|
34
|
+
h("sl-input", Object.assign({ exportparts: "label: input-label", name: "/firstName", type: "text", label: states.content.firstNameLabel, required: true, disabled: ((_a = states.registrationFormState) === null || _a === void 0 ? void 0 : _a.loading) || ((_b = states.registrationFormState) === null || _b === void 0 ? void 0 : _b.disabled) }, (((_d = (_c = states.registrationFormState) === null || _c === void 0 ? void 0 : _c.initialData) === null || _d === void 0 ? void 0 : _d.firstName) ? {
|
|
35
|
+
value: (_f = (_e = states.registrationFormState) === null || _e === void 0 ? void 0 : _e.initialData) === null || _f === void 0 ? void 0 : _f.firstName,
|
|
36
|
+
}
|
|
37
|
+
: {}), ((validationErrors === null || validationErrors === void 0 ? void 0 : validationErrors.firstName) ? {
|
|
34
38
|
class: sheet.classes.ErrorStyle,
|
|
35
39
|
helpText: (validationErrors === null || validationErrors === void 0 ? void 0 : validationErrors.firstName) || "Cannot be empty",
|
|
36
40
|
}
|
|
37
41
|
: []))),
|
|
38
|
-
h("sl-input", Object.assign({ exportparts: "label: input-label", name: "/lastName", type: "text", label: states.content.lastNameLabel, required: true }, ((
|
|
42
|
+
h("sl-input", Object.assign({ exportparts: "label: input-label", name: "/lastName", type: "text", label: states.content.lastNameLabel, required: true, disabled: ((_g = states.registrationFormState) === null || _g === void 0 ? void 0 : _g.loading) || ((_h = states.registrationFormState) === null || _h === void 0 ? void 0 : _h.disabled) }, (((_k = (_j = states.registrationFormState) === null || _j === void 0 ? void 0 : _j.initialData) === null || _k === void 0 ? void 0 : _k.lastName) ? {
|
|
43
|
+
value: (_m = (_l = states.registrationFormState) === null || _l === void 0 ? void 0 : _l.initialData) === null || _m === void 0 ? void 0 : _m.lastName,
|
|
44
|
+
}
|
|
45
|
+
: {}), ((validationErrors === null || validationErrors === void 0 ? void 0 : validationErrors.lastName) ? {
|
|
39
46
|
class: sheet.classes.ErrorStyle,
|
|
40
47
|
helpText: (validationErrors === null || validationErrors === void 0 ? void 0 : validationErrors.lastName) || "Cannot be empty",
|
|
41
48
|
}
|
|
@@ -74,7 +74,7 @@ export class NameFields {
|
|
|
74
74
|
"mutable": false,
|
|
75
75
|
"complexType": {
|
|
76
76
|
"original": "DemoData<NameFieldsViewProps>",
|
|
77
|
-
"resolved": "{ states?: { validationErrors?: ValidationErrors; content: { firstNameLabel: string; lastNameLabel: string; }; }; }",
|
|
77
|
+
"resolved": "{ states?: { validationErrors?: ValidationErrors; registrationFormState?: RegistrationFormState; content: { firstNameLabel: string; lastNameLabel: string; }; }; }",
|
|
78
78
|
"references": {
|
|
79
79
|
"DemoData": {
|
|
80
80
|
"location": "import",
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { useDomContext } from "@saasquatch/stencil-hooks";
|
|
2
2
|
import { FORM_VALIDATION_CONTEXT, } from "../sqm-portal-register/useValidationState";
|
|
3
|
+
import { REGISTRATION_FORM_STATE_CONTEXT, } from "../sqm-portal-registration-form/useRegistrationFormState";
|
|
3
4
|
export function useNameFields(props) {
|
|
5
|
+
const registrationFormState = useDomContext(REGISTRATION_FORM_STATE_CONTEXT);
|
|
4
6
|
const validationState = useDomContext(FORM_VALIDATION_CONTEXT);
|
|
5
7
|
return {
|
|
6
8
|
states: {
|
|
7
9
|
validationErrors: validationState === null || validationState === void 0 ? void 0 : validationState.validationErrors,
|
|
10
|
+
registrationFormState,
|
|
8
11
|
content: {
|
|
9
12
|
lastNameLabel: props.lastNameLabel,
|
|
10
13
|
firstNameLabel: props.firstNameLabel,
|
|
@@ -7,6 +7,7 @@ export const Start = () => {
|
|
|
7
7
|
initValue: "",
|
|
8
8
|
states: {
|
|
9
9
|
enableValidation: true,
|
|
10
|
+
registrationFormState: {},
|
|
10
11
|
validationErrors: {},
|
|
11
12
|
content: {
|
|
12
13
|
fieldLabel: "Password",
|
|
@@ -20,6 +21,7 @@ export const EmptyError = () => {
|
|
|
20
21
|
states: {
|
|
21
22
|
enableValidation: true,
|
|
22
23
|
validationErrors: { password: "Cannot be empty" },
|
|
24
|
+
registrationFormState: {},
|
|
23
25
|
content: {
|
|
24
26
|
fieldLabel: "Password",
|
|
25
27
|
},
|
|
@@ -31,6 +33,7 @@ export const ValidationError = () => {
|
|
|
31
33
|
initValue: "asdf",
|
|
32
34
|
states: {
|
|
33
35
|
enableValidation: true,
|
|
36
|
+
registrationFormState: {},
|
|
34
37
|
validationErrors: { password: "Incomplete" },
|
|
35
38
|
content: {
|
|
36
39
|
fieldLabel: "Password",
|
|
@@ -22,19 +22,22 @@ const vanillaStyle = `
|
|
|
22
22
|
const sheet = createStyleSheet(style);
|
|
23
23
|
const styleString = sheet.toString();
|
|
24
24
|
export function PortalResetPasswordView(props) {
|
|
25
|
-
var _a, _b;
|
|
25
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
26
26
|
const { states, callbacks } = props;
|
|
27
27
|
return (h("div", { class: sheet.classes.InputContainer },
|
|
28
28
|
h("style", { type: "text/css" },
|
|
29
29
|
vanillaStyle,
|
|
30
30
|
styleString),
|
|
31
|
-
h("sl-input", Object.assign({ exportparts: "label: input-label", type: "password", name: "/password", label: states.content.fieldLabel || "Password", required: true, validationError: ({ value }) => {
|
|
31
|
+
h("sl-input", Object.assign({ exportparts: "label: input-label", type: "password", name: "/password", label: states.content.fieldLabel || "Password", required: true, disabled: ((_a = states.registrationFormState) === null || _a === void 0 ? void 0 : _a.loading) || ((_b = states.registrationFormState) === null || _b === void 0 ? void 0 : _b.disabled), validationError: ({ value }) => {
|
|
32
32
|
if (!value) {
|
|
33
33
|
return "Cannot be empty";
|
|
34
34
|
}
|
|
35
|
-
} }, (((
|
|
35
|
+
} }, (((_d = (_c = states.registrationFormState) === null || _c === void 0 ? void 0 : _c.initialData) === null || _d === void 0 ? void 0 : _d.password) ? {
|
|
36
|
+
value: (_f = (_e = states.registrationFormState) === null || _e === void 0 ? void 0 : _e.initialData) === null || _f === void 0 ? void 0 : _f.password,
|
|
37
|
+
}
|
|
38
|
+
: {}), (((_g = states.validationErrors) === null || _g === void 0 ? void 0 : _g.password) ? {
|
|
36
39
|
class: sheet.classes.ErrorStyle,
|
|
37
|
-
helpText: ((
|
|
40
|
+
helpText: ((_h = states.validationErrors) === null || _h === void 0 ? void 0 : _h.password) || "Cannot be empty",
|
|
38
41
|
}
|
|
39
42
|
: []), { onInput: (input) => states.enableValidation && callbacks.onInput(input) })),
|
|
40
43
|
states.dynamicValidation));
|
|
@@ -124,6 +124,7 @@ function usePasswordFieldDemo(props) {
|
|
|
124
124
|
enableValidation: true,
|
|
125
125
|
dynamicValidation,
|
|
126
126
|
validationErrors: ((_f = (_e = props === null || props === void 0 ? void 0 : props.demoData) === null || _e === void 0 ? void 0 : _e.states) === null || _f === void 0 ? void 0 : _f.validationErrors) || {},
|
|
127
|
+
registrationFormState: {},
|
|
127
128
|
content: {
|
|
128
129
|
fieldLabel: "Password",
|
|
129
130
|
},
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { useState } from "@saasquatch/universal-hooks";
|
|
2
|
+
import { FORM_VALIDATION_CONTEXT, } from "../sqm-portal-register/useValidationState";
|
|
2
3
|
import { validateNewPassword } from "./passwordValidation";
|
|
3
4
|
import { useDomContext } from "@saasquatch/stencil-hooks";
|
|
4
|
-
|
|
5
|
+
import { REGISTRATION_FORM_STATE_CONTEXT, } from "../sqm-portal-registration-form/useRegistrationFormState";
|
|
5
6
|
export function usePasswordField(props) {
|
|
6
|
-
const validationState = useDomContext(
|
|
7
|
+
const validationState = useDomContext(FORM_VALIDATION_CONTEXT);
|
|
8
|
+
const registrationFormState = useDomContext(REGISTRATION_FORM_STATE_CONTEXT);
|
|
7
9
|
const [dynamicValidation, setDynamicValidation] = useState("");
|
|
8
10
|
function onInput(input) {
|
|
9
11
|
const validation = validateNewPassword(input.target.value);
|
|
@@ -13,6 +15,7 @@ export function usePasswordField(props) {
|
|
|
13
15
|
states: {
|
|
14
16
|
enableValidation: props.enableValidation,
|
|
15
17
|
dynamicValidation,
|
|
18
|
+
registrationFormState,
|
|
16
19
|
validationErrors: validationState === null || validationState === void 0 ? void 0 : validationState.validationErrors,
|
|
17
20
|
content: {
|
|
18
21
|
fieldLabel: props.fieldLabel,
|
package/dist/collection/components/sqm-portal-registration-form/sqm-portal-registration-form-view.js
CHANGED
|
@@ -31,7 +31,7 @@ sqm-portal-register {
|
|
|
31
31
|
const sheet = createStyleSheet(style);
|
|
32
32
|
const styleString = sheet.toString();
|
|
33
33
|
export function PortalRegistrationFormView(props) {
|
|
34
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
34
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
35
35
|
const { states, refs, callbacks, content } = props;
|
|
36
36
|
if (states.error) {
|
|
37
37
|
window.scrollTo({ top: 0, left: 0, behavior: "smooth" });
|
|
@@ -42,10 +42,11 @@ export function PortalRegistrationFormView(props) {
|
|
|
42
42
|
styleString),
|
|
43
43
|
h(TextSpanView, { type: "h3" }, content.pageLabel),
|
|
44
44
|
h("sl-form", { class: sheet.classes.Column, "onSl-submit": callbacks.submit, ref: (el) => (refs.formRef.current = el), novalidate: true },
|
|
45
|
-
states.
|
|
46
|
-
h("div", { part: "erroralert-text" },
|
|
45
|
+
((_a = states.registrationFormState) === null || _a === void 0 ? void 0 : _a.disabled) ? (h("sqm-form-message", { type: "error", exportparts: "erroralert-icon" },
|
|
46
|
+
h("div", { part: "erroralert-text" }, states.registrationFormState.disabledMessage))) : (states.error && (h("sqm-form-message", { type: "error", exportparts: "erroralert-icon" },
|
|
47
|
+
h("div", { part: "erroralert-text" }, props.states.error)))),
|
|
47
48
|
content.formData,
|
|
48
|
-
!states.hideInputs && (h("sl-input", Object.assign({ exportparts: "label: input-label", type: "email", name: "/email", label: content.emailLabel || "Email", disabled: states.loading, required: true, validationError: ({ value }) => {
|
|
49
|
+
!states.hideInputs && (h("sl-input", Object.assign({ exportparts: "label: input-label", type: "email", name: "/email", label: content.emailLabel || "Email", disabled: states.loading || ((_b = states.registrationFormState) === null || _b === void 0 ? void 0 : _b.disabled), required: true, validationError: ({ value }) => {
|
|
49
50
|
if (!value) {
|
|
50
51
|
return "Cannot be empty";
|
|
51
52
|
}
|
|
@@ -53,22 +54,28 @@ export function PortalRegistrationFormView(props) {
|
|
|
53
54
|
if (!value.includes("@")) {
|
|
54
55
|
return "Must be a valid email address";
|
|
55
56
|
}
|
|
56
|
-
} }, (((
|
|
57
|
+
} }, (((_d = (_c = states.registrationFormState) === null || _c === void 0 ? void 0 : _c.initialData) === null || _d === void 0 ? void 0 : _d.email) ? {
|
|
58
|
+
value: (_f = (_e = states.registrationFormState) === null || _e === void 0 ? void 0 : _e.initialData) === null || _f === void 0 ? void 0 : _f.email,
|
|
59
|
+
}
|
|
60
|
+
: {}), (((_h = (_g = states.validationState) === null || _g === void 0 ? void 0 : _g.validationErrors) === null || _h === void 0 ? void 0 : _h.email) ? {
|
|
57
61
|
class: sheet.classes.ErrorStyle,
|
|
58
|
-
helpText: ((
|
|
62
|
+
helpText: ((_k = (_j = states.validationState) === null || _j === void 0 ? void 0 : _j.validationErrors) === null || _k === void 0 ? void 0 : _k.email) ||
|
|
59
63
|
"Cannot be empty",
|
|
60
64
|
}
|
|
61
65
|
: [])))),
|
|
62
66
|
!states.hideInputs && (h("sqm-password-field", { fieldLabel: content.passwordLabel, "enable-validation": states.enablePasswordValidation })),
|
|
63
67
|
content.passwordField,
|
|
64
|
-
!states.hideInputs && states.confirmPassword && (h("sl-input", Object.assign({ exportparts: "label: input-label", type: "password", name: "/confirmPassword", label: content.confirmPasswordLabel, disabled: states.loading, required: true }, (((
|
|
68
|
+
!states.hideInputs && states.confirmPassword && (h("sl-input", Object.assign({ exportparts: "label: input-label", type: "password", name: "/confirmPassword", label: content.confirmPasswordLabel, disabled: states.loading, required: true }, (((_m = (_l = states.registrationFormState) === null || _l === void 0 ? void 0 : _l.initialData) === null || _m === void 0 ? void 0 : _m.confirmPassword) ? {
|
|
69
|
+
value: (_p = (_o = states.registrationFormState) === null || _o === void 0 ? void 0 : _o.initialData) === null || _p === void 0 ? void 0 : _p.confirmPassword,
|
|
70
|
+
}
|
|
71
|
+
: {}), (((_r = (_q = states.validationState) === null || _q === void 0 ? void 0 : _q.validationErrors) === null || _r === void 0 ? void 0 : _r.confirmPassword) ? {
|
|
65
72
|
class: sheet.classes.ErrorStyle,
|
|
66
|
-
helpText: ((
|
|
73
|
+
helpText: ((_t = (_s = states.validationState) === null || _s === void 0 ? void 0 : _s.validationErrors) === null || _t === void 0 ? void 0 : _t.confirmPassword) ||
|
|
67
74
|
"Cannot be empty",
|
|
68
75
|
}
|
|
69
76
|
: [])))),
|
|
70
77
|
content.terms,
|
|
71
78
|
h("div", { class: sheet.classes.ButtonsContainer },
|
|
72
|
-
h("sl-button", { submit: true, loading: states.loading, exportparts: "base: primarybutton-base", type: "primary" }, content.submitLabel || "Register"),
|
|
79
|
+
h("sl-button", { submit: true, loading: states.loading, disabled: (_u = states.registrationFormState) === null || _u === void 0 ? void 0 : _u.disabled, exportparts: "base: primarybutton-base", type: "primary" }, content.submitLabel || "Register"),
|
|
73
80
|
content.secondaryButton))));
|
|
74
81
|
}
|
package/dist/collection/components/sqm-portal-registration-form/sqm-portal-registration-form.js
CHANGED
|
@@ -383,7 +383,7 @@ export class PortalRegistrationForm {
|
|
|
383
383
|
"mutable": false,
|
|
384
384
|
"complexType": {
|
|
385
385
|
"original": "DemoData<PortalRegistrationFormViewProps>",
|
|
386
|
-
"resolved": "{ states?: { error: string; loading: boolean; confirmPassword: boolean; hideInputs: boolean; validationState?: FormState; enablePasswordValidation?: boolean; loginPath: string; }; refs?: { formRef: any; }; content?: { formData?: VNode; terms?: VNode; passwordField?: VNode; secondaryButton?: VNode; emailLabel?: string; passwordLabel?: string; submitLabel?: string; pageLabel?: string; confirmPasswordLabel: string; }; }",
|
|
386
|
+
"resolved": "{ states?: { error: string; loading: boolean; confirmPassword: boolean; hideInputs: boolean; validationState?: FormState; registrationFormState?: RegistrationFormState; enablePasswordValidation?: boolean; loginPath: string; }; refs?: { formRef: any; }; content?: { formData?: VNode; terms?: VNode; passwordField?: VNode; secondaryButton?: VNode; emailLabel?: string; passwordLabel?: string; submitLabel?: string; pageLabel?: string; confirmPasswordLabel: string; }; }",
|
|
387
387
|
"references": {
|
|
388
388
|
"DemoData": {
|
|
389
389
|
"location": "import",
|