react-restyle-components 0.2.78 → 0.2.80

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/lib/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-restyle-components",
3
- "version": "0.2.78",
3
+ "version": "0.2.80",
4
4
  "private": false,
5
5
  "description": "Easy use restyle components",
6
6
  "author": {
@@ -0,0 +1,2 @@
1
+ export declare const invertHex: (hexcolor: any) => "black" | "white";
2
+ //# sourceMappingURL=color.util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color.util.d.ts","sourceRoot":"","sources":["../../../../src/core-utils/colors/color.util.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,SAAS,sCAgBrB,CAAC"}
@@ -0,0 +1,15 @@
1
+ /* eslint-disable unicorn/number-literal-case */
2
+ export const invertHex = (hexcolor) => {
3
+ // If a leading # is provided, remove it
4
+ if (hexcolor?.slice(0, 1) === '#') {
5
+ hexcolor = hexcolor?.slice(1);
6
+ }
7
+ // Convert to RGB value
8
+ const r = Number.parseInt(hexcolor?.slice(0, 2), 16);
9
+ const g = Number.parseInt(hexcolor?.slice(2, 4), 16);
10
+ const b = Number.parseInt(hexcolor?.slice(4, 6), 16);
11
+ // Get YIQ ratio
12
+ const yiq = (r * 299 + g * 587 + b * 114) / 1000;
13
+ // Check contrast
14
+ return yiq >= 128 ? 'black' : 'white';
15
+ };
@@ -0,0 +1,35 @@
1
+ declare class FormHelper {
2
+ static patterns: {
3
+ email: RegExp;
4
+ emptySpace: RegExp;
5
+ emptyString: RegExp;
6
+ nonEmptyString: RegExp;
7
+ userName: RegExp;
8
+ password: RegExp;
9
+ mobileNo: RegExp;
10
+ panNumber: RegExp;
11
+ panNumberPartialMatch: RegExp;
12
+ aadhaarNumber: RegExp;
13
+ otp: RegExp;
14
+ };
15
+ static isUserNameValid(userName: string): boolean;
16
+ static isEmailValid(email: string): boolean;
17
+ static isAddressLengthInvalid(value: string): boolean;
18
+ static isAddressLength(value: string): boolean;
19
+ static addressNonEmpty(value: string): boolean;
20
+ static isAddressMoreLengthInvalid(value: string): boolean;
21
+ static isNameLengthInvalid(value: string): boolean;
22
+ static isPincodeLengthInvalid(value: string): boolean;
23
+ static isDateValid(date: string, month?: string, year?: string): boolean;
24
+ static isMobileNoValid(number: string): boolean;
25
+ static isMonthValid(month: string): boolean;
26
+ static isYearValid(year: string): boolean;
27
+ static isPasswordValid(password: string): boolean;
28
+ static isValidHeight(height?: string): boolean;
29
+ static isValidWeight(weight?: string): boolean;
30
+ static isNumberAvailable(val: string): boolean;
31
+ static isValidPAN(panNo: string, partial?: boolean): boolean;
32
+ }
33
+ export declare const formHelperValidation: typeof FormHelper;
34
+ export {};
35
+ //# sourceMappingURL=form-helper.util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-helper.util.d.ts","sourceRoot":"","sources":["../../../../src/core-utils/form-helper/form-helper.util.ts"],"names":[],"mappings":"AAAA,cAAM,UAAU;IACd,MAAM,CAAC,QAAQ;;;;;;;;;;;;MAab;IAEF,MAAM,CAAC,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAIjD,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAI3C,MAAM,CAAC,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAIrD,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAI9C,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAI9C,MAAM,CAAC,0BAA0B,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAIzD,MAAM,CAAC,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAIlD,MAAM,CAAC,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAIrD,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO;IAQxE,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAI/C,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAI3C,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAGzC,MAAM,CAAC,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAIjD,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO;IAI9C,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO;IAI9C,MAAM,CAAC,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAS9C,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,UAAO,GAAG,OAAO;CAQ1D;AAED,eAAO,MAAM,oBAAoB,mBAAa,CAAC"}
@@ -0,0 +1,82 @@
1
+ class FormHelper {
2
+ static patterns = {
3
+ email: /^\w+([\\.-]?\w+)*@\w+([\\.-]?\w+)*(\.\w{2,3})+$/,
4
+ emptySpace: /^\S$|^\S[\s\S]*\S$/,
5
+ emptyString: /^\s*$/,
6
+ nonEmptyString: /^(?!\s*$).+/,
7
+ userName: /^[a-z][a-z0-9_.]+$/,
8
+ password: /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,20}$/,
9
+ mobileNo: /^\d{0,10}$/,
10
+ panNumber: /^[A-Z]{3}P[A-Z]{1}\d{4}[A-Z]{1}$/,
11
+ panNumberPartialMatch: /^([A-Z]{3}P[A-Z]{1}\d{4}[A-Z]{1})|([A-Z]{3}P[A-Z]{1}\d{0,4})|([A-Z]{3}P[A-Z]{1})|([A-Z]{3}P)|([A-Z]{0,3})$/,
12
+ aadhaarNumber: /^[2-9]{1}\d{3}\d{4}\d{4}$/,
13
+ otp: /\b\d{6}\b/,
14
+ };
15
+ static isUserNameValid(userName) {
16
+ return this.patterns.userName.test(userName);
17
+ }
18
+ static isEmailValid(email) {
19
+ return this.patterns.email.test(email);
20
+ }
21
+ static isAddressLengthInvalid(value) {
22
+ return value?.length < 3 || value?.length > 60;
23
+ }
24
+ static isAddressLength(value) {
25
+ return value?.length > 2;
26
+ }
27
+ static addressNonEmpty(value) {
28
+ return this.patterns.nonEmptyString.test(value);
29
+ }
30
+ static isAddressMoreLengthInvalid(value) {
31
+ return value?.length > 60;
32
+ }
33
+ static isNameLengthInvalid(value) {
34
+ return value?.length < 3 || value?.length > 30;
35
+ }
36
+ static isPincodeLengthInvalid(value) {
37
+ return value?.length < 5;
38
+ }
39
+ static isDateValid(date, month, year) {
40
+ if (!Number(month) || !Number(year)) {
41
+ return !!Number(date) && Number(date) <= 31;
42
+ }
43
+ const daysInMonth = new Date(Number(year), Number(month), 0).getDate();
44
+ return Number(date) <= daysInMonth;
45
+ }
46
+ static isMobileNoValid(number) {
47
+ return this.patterns.mobileNo.test(number);
48
+ }
49
+ static isMonthValid(month) {
50
+ return !!Number(month) && Number(month) <= 12;
51
+ }
52
+ static isYearValid(year) {
53
+ return !!Number(year) && year.length === 4;
54
+ }
55
+ static isPasswordValid(password) {
56
+ return this.patterns.password.test(password);
57
+ }
58
+ static isValidHeight(height) {
59
+ return !!Number(height) && Number(height) <= 214;
60
+ }
61
+ static isValidWeight(weight) {
62
+ return !!Number(weight) && Number(weight) <= 150;
63
+ }
64
+ static isNumberAvailable(val) {
65
+ const matches = val.match(/\d+/g);
66
+ if (val) {
67
+ if (matches != null)
68
+ return true;
69
+ else
70
+ return false;
71
+ }
72
+ return true;
73
+ }
74
+ static isValidPAN(panNo, partial = true) {
75
+ const pattern = partial
76
+ ? this.patterns.panNumberPartialMatch
77
+ : this.patterns.panNumber;
78
+ const panNoMatch = `${panNo}`.trim().match(pattern);
79
+ return !!panNoMatch?.length && panNoMatch[0] === panNo;
80
+ }
81
+ }
82
+ export const formHelperValidation = FormHelper;
@@ -2,4 +2,7 @@ export * from './utility.util';
2
2
  export * from './calculation/calculation.util';
3
3
  export * from './convert/numberToWords/numToWords.util';
4
4
  export * from './convert/typography/camelCaseToTitleCase.util';
5
+ export * from './colors/color.util';
6
+ export * from './uuid/uuid.util';
7
+ export * from './form-helper/form-helper.util';
5
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core-utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,yCAAyC,CAAC;AACxD,cAAc,gDAAgD,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core-utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,yCAAyC,CAAC;AACxD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gCAAgC,CAAC"}
@@ -2,3 +2,6 @@ export * from './utility.util';
2
2
  export * from './calculation/calculation.util';
3
3
  export * from './convert/numberToWords/numToWords.util';
4
4
  export * from './convert/typography/camelCaseToTitleCase.util';
5
+ export * from './colors/color.util';
6
+ export * from './uuid/uuid.util';
7
+ export * from './form-helper/form-helper.util';
@@ -0,0 +1,2 @@
1
+ export declare function uuidv4(len: number): any;
2
+ //# sourceMappingURL=uuid.util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uuid.util.d.ts","sourceRoot":"","sources":["../../../../src/core-utils/uuid/uuid.util.ts"],"names":[],"mappings":"AAGA,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,OAMjC"}
@@ -0,0 +1,8 @@
1
+ /* eslint-disable unicorn/prefer-math-trunc */
2
+ import _ from 'lodash';
3
+ export function uuidv4(len) {
4
+ return _.repeat('x', len).replace(/[xy]/g, function (c) {
5
+ const r = (Math.random() * len) | 0, v = c === 'x' ? r : (r & 0x3) | 0x8;
6
+ return v.toString(len);
7
+ });
8
+ }
@@ -1,5 +1,7 @@
1
1
  .visible { visibility: visible;
2
2
  } .invisible { visibility: hidden;
3
+ } .collapse { visibility: collapse;
4
+ } .static { position: static;
3
5
  } .fixed { position: fixed;
4
6
  } .absolute { position: absolute;
5
7
  } .relative { position: relative;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-restyle-components",
3
- "version": "0.2.78",
3
+ "version": "0.2.80",
4
4
  "private": false,
5
5
  "description": "Easy use restyle components",
6
6
  "author": {