@open-tender/utils 0.5.37 → 0.5.38

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.
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { LoginData, RequestError, RequestStatus } from '@open-tender/types';
3
- export declare const useLoginForm: (loading: RequestStatus, error: RequestError, login: (email: string, password?: string, recaptcha_token?: string) => void, includeRecaptcha: boolean | undefined, callback?: () => void, showPassword?: boolean) => {
3
+ export declare const useLoginForm: (loading: RequestStatus, error: RequestError, login: (email: string, password?: string, recaptcha_token?: string) => void, includeRecaptcha: boolean | undefined, callback?: () => void, showPassword?: boolean, requiredEmail?: string) => {
4
4
  submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
5
5
  inputRef: import("react").MutableRefObject<HTMLInputElement | null>;
6
6
  recaptchaRef: import("react").MutableRefObject<any>;
@@ -4,11 +4,14 @@ exports.useLoginForm = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const react_1 = require("react");
6
6
  const utils_1 = require("../utils");
7
- const useLoginForm = (loading, error, login, includeRecaptcha, callback, showPassword = true) => {
7
+ const useLoginForm = (loading, error, login, includeRecaptcha, callback, showPassword = true, requiredEmail) => {
8
8
  const submitRef = (0, react_1.useRef)(null);
9
9
  const inputRef = (0, react_1.useRef)(null);
10
10
  const recaptchaRef = (0, react_1.useRef)(null);
11
- const [data, setData] = (0, react_1.useState)({ email: '', password: '' });
11
+ const [data, setData] = (0, react_1.useState)({
12
+ email: requiredEmail || '',
13
+ password: ''
14
+ });
12
15
  const [errors, setErrors] = (0, react_1.useState)({});
13
16
  const [submitting, setSubmitting] = (0, react_1.useState)(false);
14
17
  const toRemove = [];
@@ -19,7 +22,8 @@ const useLoginForm = (loading, error, login, includeRecaptcha, callback, showPas
19
22
  label: 'Email',
20
23
  name: 'email',
21
24
  type: 'email',
22
- required: true
25
+ required: true,
26
+ disabled: !!requiredEmail
23
27
  },
24
28
  {
25
29
  label: 'Password',
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { LoginData, RequestError, RequestStatus } from '@open-tender/types';
3
- export declare const useLoginForm: (loading: RequestStatus, error: RequestError, login: (email: string, password?: string, recaptcha_token?: string) => void, includeRecaptcha: boolean | undefined, callback?: () => void, showPassword?: boolean) => {
3
+ export declare const useLoginForm: (loading: RequestStatus, error: RequestError, login: (email: string, password?: string, recaptcha_token?: string) => void, includeRecaptcha: boolean | undefined, callback?: () => void, showPassword?: boolean, requiredEmail?: string) => {
4
4
  submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
5
5
  inputRef: import("react").MutableRefObject<HTMLInputElement | null>;
6
6
  recaptchaRef: import("react").MutableRefObject<any>;
@@ -1,11 +1,14 @@
1
1
  import { __awaiter } from "tslib";
2
2
  import { useState, useEffect, useRef } from 'react';
3
3
  import { makeFormErrors } from '../utils';
4
- export const useLoginForm = (loading, error, login, includeRecaptcha, callback, showPassword = true) => {
4
+ export const useLoginForm = (loading, error, login, includeRecaptcha, callback, showPassword = true, requiredEmail) => {
5
5
  const submitRef = useRef(null);
6
6
  const inputRef = useRef(null);
7
7
  const recaptchaRef = useRef(null);
8
- const [data, setData] = useState({ email: '', password: '' });
8
+ const [data, setData] = useState({
9
+ email: requiredEmail || '',
10
+ password: ''
11
+ });
9
12
  const [errors, setErrors] = useState({});
10
13
  const [submitting, setSubmitting] = useState(false);
11
14
  const toRemove = [];
@@ -16,7 +19,8 @@ export const useLoginForm = (loading, error, login, includeRecaptcha, callback,
16
19
  label: 'Email',
17
20
  name: 'email',
18
21
  type: 'email',
19
- required: true
22
+ required: true,
23
+ disabled: !!requiredEmail
20
24
  },
21
25
  {
22
26
  label: 'Password',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/utils",
3
- "version": "0.5.37",
3
+ "version": "0.5.38",
4
4
  "description": "A library of utils for use with Open Tender applications that utilize our cloud-based Order API.",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",