@propellerads/password-validator 6.0.0 → 7.0.0
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.css +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +23 -29
- package/dist/index.js.map +1 -1
- package/package.json +14 -8
package/dist/index.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.password-validator{margin-bottom:16px}.password-validator__rule{min-height:20px;color:var(--color-quiet,#b3b3b3);align-items:flex-start;display:flex}.password-validator__rule--passed{color:var(--color-dark-inversion,#000)}.password-validator__icon{margin-right:8px}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
|
|
4
4
|
type DefaultRulesParams = {
|
|
@@ -21,7 +21,7 @@ type PasswordValidatorProps = {
|
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
declare const getDefaultRules: ({ passwordChangeRuleLengthText, passwordChangeRuleLatinLowercaseText, passwordChangeRuleLatinUppercaseText, passwordChangeRuleDigitsText, passwordChangeRuleIsEqualText, }: DefaultRulesParams) => Rule[];
|
|
24
|
-
declare const PasswordValidator: ({ rules, password, confirmPassword, onTestsPassed }: PasswordValidatorProps) =>
|
|
24
|
+
declare const PasswordValidator: ({ rules, password, confirmPassword, onTestsPassed }: PasswordValidatorProps) => react.JSX.Element;
|
|
25
25
|
|
|
26
26
|
export { PasswordValidator as default, getDefaultRules };
|
|
27
27
|
export type { DefaultRulesParams, PasswordValidatorProps, Rule };
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,8 @@
|
|
|
1
1
|
import { Check as e, Color as t, Size as n } from "@propellerads/icon";
|
|
2
2
|
import { useEffect as r } from "react";
|
|
3
|
-
import i from "
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
//#region src/style.tsx
|
|
7
|
-
var c = i.div`
|
|
8
|
-
margin-bottom: ${a * 4}px;
|
|
9
|
-
`, l = i.div`
|
|
10
|
-
display: flex;
|
|
11
|
-
align-items: flex-start;
|
|
12
|
-
min-height: 20px;
|
|
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 }) => [
|
|
3
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
4
|
+
import './index.css';// src/index.tsx
|
|
5
|
+
var o = ({ passwordChangeRuleLengthText: e, passwordChangeRuleLatinLowercaseText: t, passwordChangeRuleLatinUppercaseText: n, passwordChangeRuleDigitsText: r, passwordChangeRuleIsEqualText: i }) => [
|
|
17
6
|
{
|
|
18
7
|
test: (e) => e.length >= 8,
|
|
19
8
|
label: e,
|
|
@@ -39,23 +28,28 @@ var c = i.div`
|
|
|
39
28
|
label: i,
|
|
40
29
|
key: "passwordChangeRuleIsEqualText"
|
|
41
30
|
}
|
|
42
|
-
],
|
|
43
|
-
let
|
|
31
|
+
], s = ({ rules: o, password: s = "", confirmPassword: c = "", onTestsPassed: l }) => {
|
|
32
|
+
let u = o.map((e) => !!e.test(s, c));
|
|
44
33
|
return r(() => {
|
|
45
|
-
|
|
34
|
+
l && l(u.every((e) => e));
|
|
46
35
|
}, [
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
]), /* @__PURE__ */
|
|
51
|
-
|
|
52
|
-
children:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
36
|
+
s,
|
|
37
|
+
c,
|
|
38
|
+
o
|
|
39
|
+
]), /* @__PURE__ */ i("div", {
|
|
40
|
+
className: "password-validator",
|
|
41
|
+
children: o.map((r, o) => /* @__PURE__ */ a("div", {
|
|
42
|
+
className: `password-validator__rule${u[o] ? " password-validator__rule--passed" : ""}`,
|
|
43
|
+
children: [/* @__PURE__ */ i("span", {
|
|
44
|
+
className: "password-validator__icon",
|
|
45
|
+
children: /* @__PURE__ */ i(e, {
|
|
46
|
+
color: r.test(s, c) ? t.Success : t.Gray,
|
|
47
|
+
size: n.Small
|
|
48
|
+
})
|
|
49
|
+
}), r.label]
|
|
50
|
+
}, r.key))
|
|
51
|
+
});
|
|
57
52
|
};
|
|
58
|
-
|
|
59
|
-
export { f as default, d as getDefaultRules };
|
|
53
|
+
export { s as default, o as getDefaultRules };
|
|
60
54
|
|
|
61
55
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.js","names":["getDefaultRules","value","passwordChangeRuleLengthText","passwordChangeRuleLatinLowercaseText","passwordChangeRuleLatinUppercaseText","passwordChangeRuleDigitsText","oneValue","twoValue","passwordChangeRuleIsEqualText","PasswordValidator","testResults","rules","rule","password","confirmPassword","useEffect","onTestsPassed","index","Check","Color","Size"],"sources":["../src/index.tsx"],"sourcesContent":["import {Check, Color, Size} from '@propellerads/icon';\nimport {useEffect} from 'react';\nimport './password-validator.css';\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 <div className=\"password-validator\">\n {rules.map((rule, index) => (\n <div\n className={`password-validator__rule${testResults[index] ? ' password-validator__rule--passed' : ''}`}\n key={rule.key}\n >\n <span className=\"password-validator__icon\">\n <Check color={rule.test(password, confirmPassword) ? Color.Success : Color.Gray} size={Size.Small} />\n </span>\n\n {rule.label}\n </div>\n ))}\n </div>\n );\n};\n\nexport default PasswordValidator;\n\nexport type {DefaultRulesParams, PasswordValidatorProps, Rule};\n"],"mappings":";;;;AAKA,IAAaA,KAAmB,EAC9B,iCACA,yCACA,yCACA,iCACA,uCACgC;CAChC;EACE,OAAO,MAAkBC,EAAM,UAAU;EACzC,OAAOC;EACP,KAAK;CACP;CACA;EACE,OAAO,MAAkB,QAAQ,KAAKD,CAAK;EAC3C,OAAOE;EACP,KAAK;CACP;CACA;EACE,OAAO,MAAkB,QAAQ,KAAKF,CAAK;EAC3C,OAAOG;EACP,KAAK;CACP;CACA;EACE,OAAO,MAAkB,KAAK,KAAKH,CAAK;EACxC,OAAOI;EACP,KAAK;CACP;CACA;EACE,OAAO,GAAkB,MAAqB,GAAQC,KAAYC,KAAYD,MAAaC;EAC3F,OAAOC;EACP,KAAK;CACP;AACF,GAEMC,KAAqB,EAAC,UAAO,cAAW,IAAI,qBAAkB,IAAI,uBAA2C;CACjH,IAAMC,IAAcC,EAAM,KAAK,MAAS,EAAQC,EAAK,KAAKC,GAAUC,CAAe,CAAE;CAUrF,OARAC,QAAgB;EACd,AAAKC,KAILA,EAAcN,EAAY,OAAO,MAAUT,CAAK,CAAC;CACnD,GAAG;EAACY;EAAUC;EAAiBH;CAAK,CAAC,GAGnC,kBAAC,OAAD;EAAK,WAAU;EACZ,UAAAA,EAAM,KAAK,GAAM,MAChB,kBAAC,OAAD;GACE,WAAW,2BAA2BD,EAAYO,KAAS,sCAAsC;GADnG,UAAA,CAIE,kBAAC,QAAD;IAAM,WAAU;IACd,UAAA,kBAACC,GAAD;KAAO,OAAON,EAAK,KAAKC,GAAUC,CAAe,IAAIK,EAAM,UAAUA,EAAM;KAAM,MAAMC,EAAK;IAAQ,CAAA;GAChG,CAAA,GAELR,EAAK,KACH;EAPE,GAAAA,EAAK,GAOP,CACN;CACE,CAAA;AAET"}
|
package/package.json
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@propellerads/password-validator",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
|
+
"style": "dist/index.css",
|
|
6
7
|
"exports": {
|
|
7
8
|
".": {
|
|
8
9
|
"types": "./dist/index.d.ts",
|
|
9
10
|
"import": "./dist/index.js"
|
|
10
|
-
}
|
|
11
|
+
},
|
|
12
|
+
"./index.css": "./dist/index.css"
|
|
11
13
|
},
|
|
14
|
+
"sideEffects": [
|
|
15
|
+
"**/*.css"
|
|
16
|
+
],
|
|
12
17
|
"files": [
|
|
13
18
|
"dist"
|
|
14
19
|
],
|
|
@@ -19,24 +24,25 @@
|
|
|
19
24
|
"url": "https://github.com/propellerads/ui-components/issues"
|
|
20
25
|
},
|
|
21
26
|
"scripts": {
|
|
22
|
-
"build": "tsc && vite build &&
|
|
27
|
+
"build": "tsc && vite build && rollup -c rollup.dts.config.mjs"
|
|
23
28
|
},
|
|
24
29
|
"homepage": "https://github.com/propellerads/ui-components#readme",
|
|
25
30
|
"private": false,
|
|
26
31
|
"dependencies": {
|
|
27
|
-
"@propellerads/icon": "^
|
|
28
|
-
"@propellerads/stylevariables": "^2.0.2"
|
|
32
|
+
"@propellerads/icon": "^11.0.0"
|
|
29
33
|
},
|
|
30
34
|
"peerDependencies": {
|
|
31
|
-
"
|
|
32
|
-
"
|
|
35
|
+
"@propellerads/tokens": ">=0.5.0",
|
|
36
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
33
37
|
},
|
|
34
38
|
"devDependencies": {
|
|
39
|
+
"@propellerads/tokens": "workspace:^",
|
|
35
40
|
"@types/react": "^19.2.14",
|
|
36
41
|
"@vitejs/plugin-react": "^6.0.1",
|
|
37
42
|
"rollup": "^4.60.3",
|
|
38
43
|
"rollup-plugin-dts": "^6.4.1",
|
|
39
44
|
"typescript": "^6.0.3",
|
|
40
|
-
"vite": "^8.0.11"
|
|
45
|
+
"vite": "^8.0.11",
|
|
46
|
+
"vite-plugin-lib-inject-css": "^2.2.2"
|
|
41
47
|
}
|
|
42
48
|
}
|