@propellerads/password-validator 5.0.0 → 5.0.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.
- package/dist/index.js +57 -56
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1,60 +1,61 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { Check as e, Color as t, Size as n } from "@propellerads/icon";
|
|
2
|
+
import { useEffect as r } from "react";
|
|
3
|
+
import i from "styled-components";
|
|
4
|
+
import { spacing as a } from "@propellerads/stylevariables";
|
|
5
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
6
|
+
//#region src/style.tsx
|
|
7
|
+
var c = i.div`
|
|
8
|
+
margin-bottom: ${a * 4}px;
|
|
9
|
+
`, l = i.div`
|
|
9
10
|
display: flex;
|
|
10
11
|
align-items: flex-start;
|
|
11
12
|
min-height: 20px;
|
|
12
|
-
color: ${(
|
|
13
|
-
`,
|
|
14
|
-
margin-right: ${
|
|
15
|
-
`,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
13
|
+
color: ${(e) => e.$isPassed ? "black" : "#b3b3b3"};
|
|
14
|
+
`, u = i.span`
|
|
15
|
+
margin-right: ${a * 2}px;
|
|
16
|
+
`, d = ({ passwordChangeRuleLengthText: e, passwordChangeRuleLatinLowercaseText: t, passwordChangeRuleLatinUppercaseText: n, passwordChangeRuleDigitsText: r, passwordChangeRuleIsEqualText: i }) => [
|
|
17
|
+
{
|
|
18
|
+
test: (e) => e.length >= 8,
|
|
19
|
+
label: e,
|
|
20
|
+
key: "passwordChangeRuleLengthText"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
test: (e) => /[a-z]/.test(e),
|
|
24
|
+
label: t,
|
|
25
|
+
key: "passwordChangeRuleLatinLowercaseText"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
test: (e) => /[A-Z]/.test(e),
|
|
29
|
+
label: n,
|
|
30
|
+
key: "passwordChangeRuleLatinUppercaseText"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
test: (e) => /\d/.test(e),
|
|
34
|
+
label: r,
|
|
35
|
+
key: "passwordChangeRuleDigitsText"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
test: (e, t) => !!(e && t && e === t),
|
|
39
|
+
label: i,
|
|
40
|
+
key: "passwordChangeRuleIsEqualText"
|
|
41
|
+
}
|
|
42
|
+
], f = ({ rules: i, password: a = "", confirmPassword: d = "", onTestsPassed: f }) => {
|
|
43
|
+
let p = i.map((e) => !!e.test(a, d));
|
|
44
|
+
return r(() => {
|
|
45
|
+
f && f(p.every((e) => e));
|
|
46
|
+
}, [
|
|
47
|
+
a,
|
|
48
|
+
d,
|
|
49
|
+
i
|
|
50
|
+
]), /* @__PURE__ */ o(c, { children: i.map((r, i) => /* @__PURE__ */ s(l, {
|
|
51
|
+
$isPassed: !!p[i],
|
|
52
|
+
children: [/* @__PURE__ */ o(u, { children: /* @__PURE__ */ o(e, {
|
|
53
|
+
color: r.test(a, d) ? t.Success : t.Gray,
|
|
54
|
+
size: n.Small
|
|
55
|
+
}) }), r.label]
|
|
56
|
+
}, r.key)) });
|
|
55
57
|
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
//# sourceMappingURL=index.js.map
|
|
58
|
+
//#endregion
|
|
59
|
+
export { f as default, d as getDefaultRules };
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/style.tsx","../src/index.tsx"],"sourcesContent":["import styled from 'styled-components';\nimport {spacing} from '@propellerads/stylevariables';\n\nconst StyledPasswordValidator = styled.div`\n margin-bottom: ${spacing * 4}px;\n`;\n\ntype PasswordRuleProps = {\n $isPassed: boolean;\n};\n\nconst PasswordRule = styled.div<PasswordRuleProps>`\n display: flex;\n align-items: flex-start;\n min-height: 20px;\n color: ${(props) => (props.$isPassed ? 'black' : '#b3b3b3')};\n`;\n\nconst PasswordIcon = styled.span`\n margin-right: ${spacing * 2}px;\n`;\n\nexport {StyledPasswordValidator, PasswordRule, PasswordIcon};\n","import {Check, Color, Size} from '@propellerads/icon';\nimport {useEffect} from 'react';\nimport {PasswordIcon, PasswordRule, StyledPasswordValidator} from './style';\nimport {DefaultRulesParams, PasswordValidatorProps, Rule} from './types';\n\nexport const getDefaultRules = ({\n passwordChangeRuleLengthText,\n passwordChangeRuleLatinLowercaseText,\n passwordChangeRuleLatinUppercaseText,\n passwordChangeRuleDigitsText,\n passwordChangeRuleIsEqualText,\n}: DefaultRulesParams): Rule[] => [\n {\n test: (value: string) => value.length >= 8,\n label: passwordChangeRuleLengthText,\n key: 'passwordChangeRuleLengthText',\n },\n {\n test: (value: string) => /[a-z]/.test(value),\n label: passwordChangeRuleLatinLowercaseText,\n key: 'passwordChangeRuleLatinLowercaseText',\n },\n {\n test: (value: string) => /[A-Z]/.test(value),\n label: passwordChangeRuleLatinUppercaseText,\n key: 'passwordChangeRuleLatinUppercaseText',\n },\n {\n test: (value: string) => /\\d/.test(value),\n label: passwordChangeRuleDigitsText,\n key: 'passwordChangeRuleDigitsText',\n },\n {\n test: (oneValue: string, twoValue: string) => Boolean(oneValue && twoValue && oneValue === twoValue),\n label: passwordChangeRuleIsEqualText,\n key: 'passwordChangeRuleIsEqualText',\n },\n];\n\nconst PasswordValidator = ({rules, password = '', confirmPassword = '', onTestsPassed}: PasswordValidatorProps) => {\n const testResults = rules.map((rule) => Boolean(rule.test(password, confirmPassword)));\n\n useEffect(() => {\n if (!onTestsPassed) {\n return;\n }\n\n onTestsPassed(testResults.every((value) => value));\n }, [password, confirmPassword, rules]);\n\n return (\n <StyledPasswordValidator>\n {rules.map((rule, index) => (\n <PasswordRule $isPassed={Boolean(testResults[index])} key={rule.key}>\n <PasswordIcon>\n <Check color={rule.test(password, confirmPassword) ? Color.Success : Color.Gray} size={Size.Small} />\n </PasswordIcon>\n\n {rule.label}\n </PasswordRule>\n ))}\n </StyledPasswordValidator>\n );\n};\n\nexport default PasswordValidator;\n\nexport type {DefaultRulesParams, PasswordValidatorProps, Rule};\n"],"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/style.tsx","../src/index.tsx"],"sourcesContent":["import styled from 'styled-components';\nimport {spacing} from '@propellerads/stylevariables';\n\nconst StyledPasswordValidator = styled.div`\n margin-bottom: ${spacing * 4}px;\n`;\n\ntype PasswordRuleProps = {\n $isPassed: boolean;\n};\n\nconst PasswordRule = styled.div<PasswordRuleProps>`\n display: flex;\n align-items: flex-start;\n min-height: 20px;\n color: ${(props) => (props.$isPassed ? 'black' : '#b3b3b3')};\n`;\n\nconst PasswordIcon = styled.span`\n margin-right: ${spacing * 2}px;\n`;\n\nexport {StyledPasswordValidator, PasswordRule, PasswordIcon};\n","import {Check, Color, Size} from '@propellerads/icon';\nimport {useEffect} from 'react';\nimport {PasswordIcon, PasswordRule, StyledPasswordValidator} from './style';\nimport {DefaultRulesParams, PasswordValidatorProps, Rule} from './types';\n\nexport const getDefaultRules = ({\n passwordChangeRuleLengthText,\n passwordChangeRuleLatinLowercaseText,\n passwordChangeRuleLatinUppercaseText,\n passwordChangeRuleDigitsText,\n passwordChangeRuleIsEqualText,\n}: DefaultRulesParams): Rule[] => [\n {\n test: (value: string) => value.length >= 8,\n label: passwordChangeRuleLengthText,\n key: 'passwordChangeRuleLengthText',\n },\n {\n test: (value: string) => /[a-z]/.test(value),\n label: passwordChangeRuleLatinLowercaseText,\n key: 'passwordChangeRuleLatinLowercaseText',\n },\n {\n test: (value: string) => /[A-Z]/.test(value),\n label: passwordChangeRuleLatinUppercaseText,\n key: 'passwordChangeRuleLatinUppercaseText',\n },\n {\n test: (value: string) => /\\d/.test(value),\n label: passwordChangeRuleDigitsText,\n key: 'passwordChangeRuleDigitsText',\n },\n {\n test: (oneValue: string, twoValue: string) => Boolean(oneValue && twoValue && oneValue === twoValue),\n label: passwordChangeRuleIsEqualText,\n key: 'passwordChangeRuleIsEqualText',\n },\n];\n\nconst PasswordValidator = ({rules, password = '', confirmPassword = '', onTestsPassed}: PasswordValidatorProps) => {\n const testResults = rules.map((rule) => Boolean(rule.test(password, confirmPassword)));\n\n useEffect(() => {\n if (!onTestsPassed) {\n return;\n }\n\n onTestsPassed(testResults.every((value) => value));\n }, [password, confirmPassword, rules]);\n\n return (\n <StyledPasswordValidator>\n {rules.map((rule, index) => (\n <PasswordRule $isPassed={Boolean(testResults[index])} key={rule.key}>\n <PasswordIcon>\n <Check color={rule.test(password, confirmPassword) ? Color.Success : Color.Gray} size={Size.Small} />\n </PasswordIcon>\n\n {rule.label}\n </PasswordRule>\n ))}\n </StyledPasswordValidator>\n );\n};\n\nexport default PasswordValidator;\n\nexport type {DefaultRulesParams, PasswordValidatorProps, Rule};\n"],"mappings":";;;;;;AAGA,IAAM,IAA0B,EAAO,GAAG;mBACvB,IAAU,EAAE;GAOzB,IAAe,EAAO,GAAsB;;;;YAItC,MAAW,EAAM,YAAY,UAAU,UAAW;GAGxD,IAAe,EAAO,IAAI;kBACd,IAAU,EAAE;GCdjB,KAAmB,EAC9B,iCACA,yCACA,yCACA,iCACA,uCACgC;CAChC;EACE,OAAO,MAAkB,EAAM,UAAU;EACzC,OAAO;EACP,KAAK;EACN;CACD;EACE,OAAO,MAAkB,QAAQ,KAAK,EAAM;EAC5C,OAAO;EACP,KAAK;EACN;CACD;EACE,OAAO,MAAkB,QAAQ,KAAK,EAAM;EAC5C,OAAO;EACP,KAAK;EACN;CACD;EACE,OAAO,MAAkB,KAAK,KAAK,EAAM;EACzC,OAAO;EACP,KAAK;EACN;CACD;EACE,OAAO,GAAkB,MAAqB,GAAQ,KAAY,KAAY,MAAa;EAC3F,OAAO;EACP,KAAK;EACN;CACF,EAEK,KAAqB,EAAC,UAAO,cAAW,IAAI,qBAAkB,IAAI,uBAA2C;CACjH,IAAM,IAAc,EAAM,KAAK,MAAS,EAAQ,EAAK,KAAK,GAAU,EAAgB,CAAE;CAUtF,OARA,QAAgB;EACT,KAIL,EAAc,EAAY,OAAO,MAAU,EAAM,CAAC;IACjD;EAAC;EAAU;EAAiB;EAAM,CAAC,EAGpC,kBAAC,GAAD,EAAA,UACG,EAAM,KAAK,GAAM,MAChB,kBAAC,GAAD;EAAc,WAAW,EAAQ,EAAY;YAA7C,CACE,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD;GAAO,OAAO,EAAK,KAAK,GAAU,EAAgB,GAAG,EAAM,UAAU,EAAM;GAAM,MAAM,EAAK;GAAS,CAAA,EACxF,CAAA,EAEd,EAAK,MACO;IAN4C,EAAK,IAMjD,CACf,EACsB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@propellerads/password-validator",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
"url": "https://github.com/propellerads/ui-components/issues"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
|
-
"build": "tsc && vite build && rollup -c rollup.dts.config.mjs"
|
|
22
|
+
"build": "tsc && vite build && bunx rollup -c rollup.dts.config.mjs"
|
|
23
23
|
},
|
|
24
24
|
"homepage": "https://github.com/propellerads/ui-components#readme",
|
|
25
25
|
"private": false,
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@propellerads/icon": "^
|
|
27
|
+
"@propellerads/icon": "^8.0.0",
|
|
28
28
|
"@propellerads/stylevariables": "^2.0.2"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/react": "^19.2.14",
|
|
36
|
-
"@vitejs/plugin-react": "^
|
|
37
|
-
"rollup": "^4.
|
|
38
|
-
"rollup-plugin-dts": "^6.
|
|
39
|
-
"typescript": "^
|
|
40
|
-
"vite": "^
|
|
36
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
37
|
+
"rollup": "^4.60.3",
|
|
38
|
+
"rollup-plugin-dts": "^6.4.1",
|
|
39
|
+
"typescript": "^6.0.3",
|
|
40
|
+
"vite": "^8.0.10"
|
|
41
41
|
}
|
|
42
42
|
}
|