react-admin-base-bootstrap 0.7.5 → 0.7.6

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/assets/main.css CHANGED
@@ -7,6 +7,10 @@
7
7
  @import url('~tingle.js/dist/tingle.css');
8
8
  @import url('~cropperjs/dist/cropper.css');
9
9
 
10
+ .password-str-bar ~ .invalid-feedback {
11
+ margin-top: -20px;
12
+ }
13
+
10
14
  .tingle-modal--visible {
11
15
  z-index: 10000;
12
16
  }
@@ -0,0 +1,3 @@
1
+ export default function DefaultValidatorOptions({ children }: {
2
+ children: any;
3
+ }): JSX.Element;
@@ -0,0 +1,24 @@
1
+ import React, { useMemo } from "react";
2
+ import { ValidatorOptionProvider } from "react-admin-base";
3
+ import { useIntl } from "react-intl";
4
+ import zxcvbn from 'zxcvbn';
5
+ export default function DefaultValidatorOptions({ children }) {
6
+ const intl = useIntl();
7
+ const options = useMemo(() => ({
8
+ validators: {
9
+ password: {
10
+ message: intl.formatMessage({ id: 'PASSWORD_NOMATCH' }),
11
+ rule: function (val, params) {
12
+ return val == params[0];
13
+ }
14
+ },
15
+ securepassword: {
16
+ message: intl.formatMessage({ id: 'INSECURE_PASSWORD' }),
17
+ rule: function (val, params) {
18
+ return !val || (zxcvbn(val, []).score >= 2);
19
+ }
20
+ }
21
+ }
22
+ }), [intl]);
23
+ return React.createElement(ValidatorOptionProvider, { value: options }, children);
24
+ }
@@ -1,5 +1,7 @@
1
1
  import React from 'react';
2
- export default class ErrorBoundary extends React.Component {
2
+ export default class ErrorBoundary extends React.Component<{
3
+ children: React.ReactNode;
4
+ }> {
3
5
  state: {
4
6
  hasError: boolean;
5
7
  error: null;
@@ -8,5 +10,5 @@ export default class ErrorBoundary extends React.Component {
8
10
  hasError: boolean;
9
11
  error: any;
10
12
  };
11
- render(): React.ReactNode;
13
+ render(): string | number | boolean | JSX.Element | React.ReactFragment | null | undefined;
12
14
  }
@@ -0,0 +1,11 @@
1
+ interface PasswordInputParams {
2
+ value?: string;
3
+ onChange: (str: string) => any;
4
+ className?: string;
5
+ disabled?: boolean;
6
+ icon?: string;
7
+ required?: boolean;
8
+ placeholder?: string;
9
+ }
10
+ export default function PasswordInput({ value, onChange, className, disabled, icon, required, placeholder }: PasswordInputParams): JSX.Element;
11
+ export {};
@@ -0,0 +1,39 @@
1
+ import React, { useEffect, useMemo, useState } from "react";
2
+ import { FormattedMessage, useIntl } from "react-intl";
3
+ import PasswordStrengthBar from "react-password-strength-bar";
4
+ import { FormGroup, Label, Input } from 'reactstrap';
5
+ import { Validator } from "./Validator";
6
+ function BootstrapPasswordInput({ className, value, onChange, disabled, placeholder }) {
7
+ const intl = useIntl();
8
+ const short = intl.formatMessage({ id: "PASSWORD_SHORT" });
9
+ const bad = intl.formatMessage({ id: "PASSWORD_BAD" });
10
+ const okay = intl.formatMessage({ id: "PASSWORD_OKAY" });
11
+ const good = intl.formatMessage({ id: "PASSWORD_GOOD" });
12
+ const perfect = intl.formatMessage({ id: "PASSWORD_PERFECT" });
13
+ const scoreWords = useMemo(() => [short, bad, okay, good, perfect], [short, bad, okay, good, perfect]);
14
+ return React.createElement(React.Fragment, null,
15
+ React.createElement(Input, { className: className, type: "password", value: value || '', onChange: a => onChange(a.currentTarget.value), disabled: disabled, placeholder: placeholder }),
16
+ React.createElement(PasswordStrengthBar, { className: "password-str-bar", password: value || '', scoreWords: scoreWords, shortScoreWord: short }));
17
+ }
18
+ export default function PasswordInput({ value, onChange, className, disabled, icon, required, placeholder }) {
19
+ const [password2, setPassword2] = useState('');
20
+ const iconElem = icon && React.createElement("i", { className: icon });
21
+ useEffect(function () {
22
+ if (!value) {
23
+ setPassword2('');
24
+ }
25
+ }, [value, setPassword2]);
26
+ return React.createElement(React.Fragment, null,
27
+ React.createElement(FormGroup, { className: className },
28
+ iconElem,
29
+ React.createElement(Label, null,
30
+ React.createElement(FormattedMessage, { id: "PASSWORD" })),
31
+ React.createElement(Validator, { name: "password", type: [required && "required", "securepassword"].filter(a => !!a) },
32
+ React.createElement(BootstrapPasswordInput, { value: value, onChange: onChange, disabled: disabled, placeholder: placeholder }))),
33
+ !!(required || value) && React.createElement(FormGroup, { className: className },
34
+ iconElem,
35
+ React.createElement(Label, null,
36
+ React.createElement(FormattedMessage, { id: "PASSWORD_AGAIN" })),
37
+ React.createElement(Validator, { name: "password2", type: [(required || value) && "required", { password: value || '' }].filter(a => !!a) },
38
+ React.createElement(Input, { type: "password", value: password2 || '', onChange: a => setPassword2(a.currentTarget.value), disabled: disabled }))));
39
+ }
@@ -4,6 +4,13 @@
4
4
  "USERNAME": "Benutzername",
5
5
  "PASSWORD": "Passwort",
6
6
  "FORGOT_PASSWORD": "Ich habe mein Passwort vergessen",
7
+ "INSECURE_PASSWORD": "Passwort ist nicht sicher",
8
+ "PASSWORD_NOMATCH": "Passwort ist falsch",
9
+ "PASSWORD_SHORT": "zu kurz",
10
+ "PASSWORD_BAD": "schlecht",
11
+ "PASSWORD_OKAY": "okay",
12
+ "PASSWORD_GOOD": "gut",
13
+ "PASSWORD_PERFECT": "perfekt",
7
14
  "LOGIN": "Einloggen",
8
15
  "LOGIN_HEAD": "Anmeldebereich",
9
16
  "SUBMIT": "Absenden",
@@ -3,6 +3,14 @@
3
3
  "ENTITY.CANCEL": "Cancel",
4
4
  "USERNAME": "Username",
5
5
  "PASSWORD": "Password",
6
+ "PASSWORD_AGAIN": "Password (again)",
7
+ "PASSWORD_SHORT": "too short",
8
+ "PASSWORD_BAD": "bad",
9
+ "PASSWORD_OKAY": "okay",
10
+ "PASSWORD_GOOD": "good",
11
+ "PASSWORD_PERFECT": "perfect",
12
+ "INSECURE_PASSWORD": "Password is not secure",
13
+ "PASSWORD_NOMATCH": "Passwords does not match",
6
14
  "FORGOT_PASSWORD": "I forgot my password",
7
15
  "LOGIN": "Login",
8
16
  "LOGIN_HEAD": "Login Area",
@@ -12,7 +20,7 @@
12
20
  "EMAIL": "Email",
13
21
  "AUTH_CODE": "Authorization Code",
14
22
  "ENTER_AUTH_CODE": "Please enter the verification code that we sent to {email}.",
15
- "CHANGE_EMAIL": "Not your e-mail? <1>Sent to a new email address</1>.",
23
+ "CHANGE_EMAIL": "Not your e-mail? <a>Sent to a new email address</a>.",
16
24
  "PASSWORD_REPEAT": "Password (again)",
17
25
  "VALIDATION.ERROR": "Entity has following errors:",
18
26
  "ENTITY.SAVED": "Changes are saved.",
@@ -4,6 +4,13 @@
4
4
  "USERNAME": "Kullanıcı Adı",
5
5
  "PASSWORD": "Şifre",
6
6
  "FORGOT_PASSWORD": "Şifremi unuttum",
7
+ "INSECURE_PASSWORD": "Şifre güvenli değil",
8
+ "PASSWORD_NOMATCH": "Şifreler uyuşmuyor",
9
+ "PASSWORD_SHORT": "çok kısa",
10
+ "PASSWORD_BAD": "kötü",
11
+ "PASSWORD_OKAY": "idare eder",
12
+ "PASSWORD_GOOD": "iyi",
13
+ "PASSWORD_PERFECT": "harika",
7
14
  "SUBMIT": "Gönder",
8
15
  "LOGIN": "Giriş",
9
16
  "LOGIN_HEAD": "Oturum Açma Alanı",
@@ -18,4 +18,6 @@ import { useMenuState, useIsMobile } from './Components/MenuState';
18
18
  import TopProgressBar from './Components/TopProgressBar';
19
19
  import ThemeProvider, { useTheme, useAllThemes } from './Components/ThemeProvider';
20
20
  import StepList, { StepItem } from './Components/StepList';
21
- export { ThemeProvider, useTheme, useAllThemes, useIsMobile, useMenuState, StepList, StepItem, TopProgressBar, CRUD, ModalEntityEditor, CRUDActions, Relative, ApiSelect, Preview, ExcelExportButton, ExternalLoginButton, SingleFilePicker, MultiFilePicker, ImagePicker, BootstrapTable, EntityEditor, GoToTop, Validator, ValueValidator, ValidationErrors, LoadingButton, BootstrapDataTable, IdColumn, Column, ActionsColumn, Actions, useDataTableContext, LanguageProvider, useLanguage, LanguageSwitcher, ErrorBoundary, CheckBox };
21
+ import PasswordInput from './Components/PasswordInput';
22
+ import DefaultValidatorOptions from './Components/DefaultValidatorOptions';
23
+ export { ThemeProvider, useTheme, useAllThemes, useIsMobile, useMenuState, DefaultValidatorOptions, PasswordInput, StepList, StepItem, TopProgressBar, CRUD, ModalEntityEditor, CRUDActions, Relative, ApiSelect, Preview, ExcelExportButton, ExternalLoginButton, SingleFilePicker, MultiFilePicker, ImagePicker, BootstrapTable, EntityEditor, GoToTop, Validator, ValueValidator, ValidationErrors, LoadingButton, BootstrapDataTable, IdColumn, Column, ActionsColumn, Actions, useDataTableContext, LanguageProvider, useLanguage, LanguageSwitcher, ErrorBoundary, CheckBox };
package/lib/esm/index.js CHANGED
@@ -18,4 +18,6 @@ import { useMenuState, useIsMobile } from './Components/MenuState';
18
18
  import TopProgressBar from './Components/TopProgressBar';
19
19
  import ThemeProvider, { useTheme, useAllThemes } from './Components/ThemeProvider';
20
20
  import StepList, { StepItem } from './Components/StepList';
21
- export { ThemeProvider, useTheme, useAllThemes, useIsMobile, useMenuState, StepList, StepItem, TopProgressBar, CRUD, ModalEntityEditor, CRUDActions, Relative, ApiSelect, Preview, ExcelExportButton, ExternalLoginButton, SingleFilePicker, MultiFilePicker, ImagePicker, BootstrapTable, EntityEditor, GoToTop, Validator, ValueValidator, ValidationErrors, LoadingButton, BootstrapDataTable, IdColumn, Column, ActionsColumn, Actions, useDataTableContext, LanguageProvider, useLanguage, LanguageSwitcher, ErrorBoundary, CheckBox };
21
+ import PasswordInput from './Components/PasswordInput';
22
+ import DefaultValidatorOptions from './Components/DefaultValidatorOptions';
23
+ export { ThemeProvider, useTheme, useAllThemes, useIsMobile, useMenuState, DefaultValidatorOptions, PasswordInput, StepList, StepItem, TopProgressBar, CRUD, ModalEntityEditor, CRUDActions, Relative, ApiSelect, Preview, ExcelExportButton, ExternalLoginButton, SingleFilePicker, MultiFilePicker, ImagePicker, BootstrapTable, EntityEditor, GoToTop, Validator, ValueValidator, ValidationErrors, LoadingButton, BootstrapDataTable, IdColumn, Column, ActionsColumn, Actions, useDataTableContext, LanguageProvider, useLanguage, LanguageSwitcher, ErrorBoundary, CheckBox };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-admin-base-bootstrap",
3
- "version": "0.7.5",
3
+ "version": "0.7.6",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -25,29 +25,32 @@
25
25
  "delay": "100"
26
26
  },
27
27
  "peerDependencies": {
28
- "react": "^18.0.0",
28
+ "react": "^18.2.0",
29
+ "react-dom": "^18.2.0",
29
30
  "react-intl": "^5.21.0",
30
31
  "react-router-dom": "^6.3.0"
31
32
  },
32
33
  "dependencies": {
33
- "@emotion/react": "^11.8.2",
34
+ "@emotion/react": "^11.9.3",
34
35
  "@fortawesome/fontawesome-free": "^6.1.1",
35
36
  "bootstrap": "^5.1.3",
36
37
  "file-dialog": "^0.0.8",
37
38
  "modal-cropper": "^1.2.3",
38
39
  "nprogress": "^0.2.0",
39
40
  "prettysize": "^2.0.0",
40
- "react-admin-base": "^0.7.2",
41
+ "react-admin-base": "^0.7.3",
42
+ "react-password-strength-bar": "^0.4.1",
41
43
  "react-responsive": "^8.2.0",
42
- "react-select": "^5.2.2",
43
- "reactstrap": "^9.0.1",
44
+ "react-select": "^5.3.2",
45
+ "reactstrap": "^9.1.1",
44
46
  "rewire": "^6.0.0",
45
- "sweetalert2": "^11.4.8"
47
+ "sweetalert2": "^11.4.17"
46
48
  },
47
49
  "devDependencies": {
50
+ "@types/react": "^18.0.12",
48
51
  "cross-env": "^7.0.3",
49
- "nodemon": "^2.0.15",
50
- "react-intl": "^5.24.8",
51
- "typescript": "^4.6.3"
52
+ "nodemon": "^2.0.16",
53
+ "react-intl": "^6.0.4",
54
+ "typescript": "^4.7.3"
52
55
  }
53
56
  }
@@ -0,0 +1,29 @@
1
+ import React, { useMemo } from "react";
2
+ import { ValidatorOptionProvider } from "react-admin-base";
3
+ import { useIntl } from "react-intl";
4
+ import zxcvbn from 'zxcvbn';
5
+
6
+ export default function DefaultValidatorOptions({ children }) {
7
+ const intl = useIntl();
8
+
9
+ const options = useMemo(() => ({
10
+ validators: {
11
+ password: {
12
+ message: intl.formatMessage({ id: 'PASSWORD_NOMATCH' }),
13
+ rule: function (val, params) {
14
+ return val == params[0];
15
+ }
16
+ },
17
+ securepassword: {
18
+ message: intl.formatMessage({ id: 'INSECURE_PASSWORD' }),
19
+ rule: function (val, params) {
20
+ return !val || (zxcvbn(val, []).score >= 2);
21
+ }
22
+ }
23
+ }
24
+ }), [intl]);
25
+
26
+ return <ValidatorOptionProvider value={options}>
27
+ { children }
28
+ </ValidatorOptionProvider>;
29
+ }
@@ -9,7 +9,7 @@ function ErrorHandler({ error }) {
9
9
  </Alert>;
10
10
  }
11
11
 
12
- export default class ErrorBoundary extends React.Component {
12
+ export default class ErrorBoundary extends React.Component<{ children: React.ReactNode }> {
13
13
  state = { hasError: false, error: null };
14
14
 
15
15
  static getDerivedStateFromError(error) {
@@ -0,0 +1,93 @@
1
+ import React, { useEffect, useMemo, useState } from "react";
2
+ import { FormattedMessage, useIntl } from "react-intl";
3
+ import PasswordStrengthBar from "react-password-strength-bar";
4
+ import { FormGroup, Label, Input } from 'reactstrap';
5
+ import { Validator } from "./Validator";
6
+
7
+ interface BootstrapPasswordInput {
8
+ value?: string;
9
+ onChange: (str: string) => any;
10
+ className?: string;
11
+ disabled?: boolean;
12
+ icon?: string;
13
+ required?: boolean;
14
+ placeholder?: string;
15
+ }
16
+
17
+ function BootstrapPasswordInput({ className, value, onChange, disabled, placeholder }: BootstrapPasswordInput) {
18
+ const intl = useIntl();
19
+
20
+ const short = intl.formatMessage({ id: "PASSWORD_SHORT" });
21
+ const bad = intl.formatMessage({ id: "PASSWORD_BAD" });
22
+ const okay = intl.formatMessage({ id: "PASSWORD_OKAY" });
23
+ const good = intl.formatMessage({ id: "PASSWORD_GOOD" });
24
+ const perfect = intl.formatMessage({ id: "PASSWORD_PERFECT" });
25
+
26
+ const scoreWords = useMemo(() => [short, bad, okay, good, perfect], [short, bad, okay, good, perfect]);
27
+
28
+ return <>
29
+ <Input
30
+ className={className}
31
+ type="password"
32
+ value={value || ''}
33
+ onChange={a => onChange(a.currentTarget.value)}
34
+ disabled={disabled}
35
+ placeholder={placeholder}
36
+ />
37
+ <PasswordStrengthBar
38
+ className="password-str-bar"
39
+ password={value || ''}
40
+ scoreWords={scoreWords}
41
+ shortScoreWord={short}
42
+ />
43
+ </>
44
+ }
45
+
46
+ interface PasswordInputParams {
47
+ value?: string;
48
+ onChange: (str: string) => any;
49
+ className?: string;
50
+ disabled?: boolean;
51
+ icon?: string;
52
+ required?: boolean;
53
+ placeholder?: string;
54
+ }
55
+
56
+ export default function PasswordInput({ value, onChange, className, disabled, icon, required, placeholder }: PasswordInputParams) {
57
+ const [ password2, setPassword2 ] = useState('');
58
+
59
+ const iconElem = icon && <i className={icon} />;
60
+
61
+ useEffect(function() {
62
+ if (!value) {
63
+ setPassword2('');
64
+ }
65
+ }, [value, setPassword2]);
66
+
67
+ return <>
68
+ <FormGroup className={className}>
69
+ {iconElem}
70
+ <Label><FormattedMessage id="PASSWORD" /></Label>
71
+ <Validator name="password" type={[required && "required", "securepassword"].filter(a => !!a)}>
72
+ <BootstrapPasswordInput
73
+ value={value}
74
+ onChange={onChange}
75
+ disabled={disabled}
76
+ placeholder={placeholder}
77
+ />
78
+ </Validator>
79
+ </FormGroup>
80
+ { !!(required || value) && <FormGroup className={className}>
81
+ {iconElem}
82
+ <Label><FormattedMessage id="PASSWORD_AGAIN" /></Label>
83
+ <Validator name="password2" type={[(required || value) && "required", { password: value || '' }].filter(a => !!a)}>
84
+ <Input
85
+ type="password"
86
+ value={password2 || ''}
87
+ onChange={a => setPassword2(a.currentTarget.value)}
88
+ disabled={disabled}
89
+ />
90
+ </Validator>
91
+ </FormGroup> }
92
+ </>;
93
+ }
package/src/i18n/de.json CHANGED
@@ -4,6 +4,13 @@
4
4
  "USERNAME": "Benutzername",
5
5
  "PASSWORD": "Passwort",
6
6
  "FORGOT_PASSWORD": "Ich habe mein Passwort vergessen",
7
+ "INSECURE_PASSWORD": "Passwort ist nicht sicher",
8
+ "PASSWORD_NOMATCH": "Passwort ist falsch",
9
+ "PASSWORD_SHORT": "zu kurz",
10
+ "PASSWORD_BAD": "schlecht",
11
+ "PASSWORD_OKAY": "okay",
12
+ "PASSWORD_GOOD": "gut",
13
+ "PASSWORD_PERFECT": "perfekt",
7
14
  "LOGIN": "Einloggen",
8
15
  "LOGIN_HEAD": "Anmeldebereich",
9
16
  "SUBMIT": "Absenden",
package/src/i18n/en.json CHANGED
@@ -3,6 +3,14 @@
3
3
  "ENTITY.CANCEL": "Cancel",
4
4
  "USERNAME": "Username",
5
5
  "PASSWORD": "Password",
6
+ "PASSWORD_AGAIN": "Password (again)",
7
+ "PASSWORD_SHORT": "too short",
8
+ "PASSWORD_BAD": "bad",
9
+ "PASSWORD_OKAY": "okay",
10
+ "PASSWORD_GOOD": "good",
11
+ "PASSWORD_PERFECT": "perfect",
12
+ "INSECURE_PASSWORD": "Password is not secure",
13
+ "PASSWORD_NOMATCH": "Passwords does not match",
6
14
  "FORGOT_PASSWORD": "I forgot my password",
7
15
  "LOGIN": "Login",
8
16
  "LOGIN_HEAD": "Login Area",
@@ -12,7 +20,7 @@
12
20
  "EMAIL": "Email",
13
21
  "AUTH_CODE": "Authorization Code",
14
22
  "ENTER_AUTH_CODE": "Please enter the verification code that we sent to {email}.",
15
- "CHANGE_EMAIL": "Not your e-mail? <1>Sent to a new email address</1>.",
23
+ "CHANGE_EMAIL": "Not your e-mail? <a>Sent to a new email address</a>.",
16
24
  "PASSWORD_REPEAT": "Password (again)",
17
25
  "VALIDATION.ERROR": "Entity has following errors:",
18
26
  "ENTITY.SAVED": "Changes are saved.",
package/src/i18n/tr.json CHANGED
@@ -4,6 +4,13 @@
4
4
  "USERNAME": "Kullanıcı Adı",
5
5
  "PASSWORD": "Şifre",
6
6
  "FORGOT_PASSWORD": "Şifremi unuttum",
7
+ "INSECURE_PASSWORD": "Şifre güvenli değil",
8
+ "PASSWORD_NOMATCH": "Şifreler uyuşmuyor",
9
+ "PASSWORD_SHORT": "çok kısa",
10
+ "PASSWORD_BAD": "kötü",
11
+ "PASSWORD_OKAY": "idare eder",
12
+ "PASSWORD_GOOD": "iyi",
13
+ "PASSWORD_PERFECT": "harika",
7
14
  "SUBMIT": "Gönder",
8
15
  "LOGIN": "Giriş",
9
16
  "LOGIN_HEAD": "Oturum Açma Alanı",
package/src/index.ts CHANGED
@@ -19,10 +19,14 @@ import { useMenuState, useIsMobile } from './Components/MenuState';
19
19
  import TopProgressBar from './Components/TopProgressBar';
20
20
  import ThemeProvider, { useTheme, useAllThemes } from './Components/ThemeProvider';
21
21
  import StepList, { StepItem } from './Components/StepList';
22
+ import PasswordInput from './Components/PasswordInput';
23
+ import DefaultValidatorOptions from './Components/DefaultValidatorOptions';
22
24
 
23
25
  export {
24
26
  ThemeProvider, useTheme, useAllThemes,
25
27
  useIsMobile, useMenuState,
28
+ DefaultValidatorOptions,
29
+ PasswordInput,
26
30
  StepList, StepItem,
27
31
  TopProgressBar,
28
32
  CRUD, ModalEntityEditor, CRUDActions,