@fctc/widget-logic 1.0.0 → 1.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.d.mts CHANGED
@@ -1 +1,2 @@
1
- export { handleGeneratePasswordMessage, handleValidateInput, handleValidateInputByType } from './validate.mjs';
1
+
2
+ export { }
package/dist/index.d.ts CHANGED
@@ -1 +1,2 @@
1
- export { handleGeneratePasswordMessage, handleValidateInput, handleValidateInputByType } from './validate.js';
1
+
2
+ export { }
package/dist/index.js CHANGED
@@ -1,83 +1 @@
1
1
  "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- handleGeneratePasswordMessage: () => handleGeneratePasswordMessage,
24
- handleValidateInput: () => handleValidateInput,
25
- handleValidateInputByType: () => handleValidateInputByType
26
- });
27
- module.exports = __toCommonJS(index_exports);
28
-
29
- // src/utils/validate.ts
30
- function handleValidateInputByType(value, type) {
31
- if (type === "text") {
32
- return /^[\p{L}\s]+$/u.test(value);
33
- }
34
- if (type === "number") {
35
- return /^[0-9]+$/.test(value);
36
- }
37
- if (type === "email") {
38
- return /^[a-zA-Z0-9._]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(value);
39
- }
40
- if (type === "phone") {
41
- return /^(0|\+?84)[0-9]{9}$/.test(value);
42
- }
43
- return false;
44
- }
45
- function handleGeneratePasswordMessage({ min, max, upcase, digit, special }) {
46
- let message = `M\u1EADt kh\u1EA9u ph\u1EA3i c\xF3 t\u1EEB ${min} \u0111\u1EBFn ${max} k\xFD t\u1EF1`;
47
- if (upcase || upcase === "0") {
48
- message += `, ${upcase} ch\u1EEF in hoa`;
49
- }
50
- if (digit || digit === "0") {
51
- message += `, ${digit} s\u1ED1`;
52
- }
53
- if (special || special === "0") {
54
- message += `, ${special} k\xFD t\u1EF1 \u0111\u1EB7c bi\u1EC7t`;
55
- }
56
- return message;
57
- }
58
- function handleValidateInput(props) {
59
- const { value, widget, regex, min, max, upcase, digit, special, textValidate } = props;
60
- if (!value) return true;
61
- if (widget === "custom_passord") {
62
- if (regex && !new RegExp(regex)?.test(value)) {
63
- return handleGeneratePasswordMessage({
64
- min,
65
- max,
66
- upcase,
67
- digit,
68
- special
69
- });
70
- }
71
- return true;
72
- }
73
- if (!widget) return;
74
- const inputType = widget === "email" ? "email" : widget === "phone" ? "phone" : widget === "text-only" ? "text" : widget === "number" ? "number" : null;
75
- if (!inputType) return;
76
- return handleValidateInputByType(value, inputType) || textValidate;
77
- }
78
- // Annotate the CommonJS export names for ESM import in node:
79
- 0 && (module.exports = {
80
- handleGeneratePasswordMessage,
81
- handleValidateInput,
82
- handleValidateInputByType
83
- });
package/dist/index.mjs CHANGED
@@ -1,54 +0,0 @@
1
- // src/utils/validate.ts
2
- function handleValidateInputByType(value, type) {
3
- if (type === "text") {
4
- return /^[\p{L}\s]+$/u.test(value);
5
- }
6
- if (type === "number") {
7
- return /^[0-9]+$/.test(value);
8
- }
9
- if (type === "email") {
10
- return /^[a-zA-Z0-9._]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(value);
11
- }
12
- if (type === "phone") {
13
- return /^(0|\+?84)[0-9]{9}$/.test(value);
14
- }
15
- return false;
16
- }
17
- function handleGeneratePasswordMessage({ min, max, upcase, digit, special }) {
18
- let message = `M\u1EADt kh\u1EA9u ph\u1EA3i c\xF3 t\u1EEB ${min} \u0111\u1EBFn ${max} k\xFD t\u1EF1`;
19
- if (upcase || upcase === "0") {
20
- message += `, ${upcase} ch\u1EEF in hoa`;
21
- }
22
- if (digit || digit === "0") {
23
- message += `, ${digit} s\u1ED1`;
24
- }
25
- if (special || special === "0") {
26
- message += `, ${special} k\xFD t\u1EF1 \u0111\u1EB7c bi\u1EC7t`;
27
- }
28
- return message;
29
- }
30
- function handleValidateInput(props) {
31
- const { value, widget, regex, min, max, upcase, digit, special, textValidate } = props;
32
- if (!value) return true;
33
- if (widget === "custom_passord") {
34
- if (regex && !new RegExp(regex)?.test(value)) {
35
- return handleGeneratePasswordMessage({
36
- min,
37
- max,
38
- upcase,
39
- digit,
40
- special
41
- });
42
- }
43
- return true;
44
- }
45
- if (!widget) return;
46
- const inputType = widget === "email" ? "email" : widget === "phone" ? "phone" : widget === "text-only" ? "text" : widget === "number" ? "number" : null;
47
- if (!inputType) return;
48
- return handleValidateInputByType(value, inputType) || textValidate;
49
- }
50
- export {
51
- handleGeneratePasswordMessage,
52
- handleValidateInput,
53
- handleValidateInputByType
54
- };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fctc/widget-logic",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "main": "dist/index.cjs",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -26,6 +26,10 @@
26
26
  "test": "jest"
27
27
  },
28
28
  "dependencies": {
29
+ "@fctc/interface-logic": "^1.0.0",
30
+ "@types/react": "^19.1.8",
31
+ "react": "18.0.0",
32
+ "react-dom": "18.0.0",
29
33
  "tslib": "^2.8.1"
30
34
  },
31
35
  "devDependencies": {
@@ -1,6 +0,0 @@
1
- declare function handleRequire(props: any): false | {
2
- value: boolean;
3
- message: string;
4
- };
5
-
6
- export { handleRequire };
package/dist/require.d.ts DELETED
@@ -1,6 +0,0 @@
1
- declare function handleRequire(props: any): false | {
2
- value: boolean;
3
- message: string;
4
- };
5
-
6
- export { handleRequire };
package/dist/require.js DELETED
@@ -1,41 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/require.ts
21
- var require_exports = {};
22
- __export(require_exports, {
23
- handleRequire: () => handleRequire
24
- });
25
- module.exports = __toCommonJS(require_exports);
26
-
27
- // src/utils/require.ts
28
- function handleRequire(props) {
29
- const { required, invisible, string, textRequired } = props;
30
- if (required && !invisible) {
31
- return {
32
- value: true,
33
- message: `${string} ${textRequired}`
34
- };
35
- }
36
- return false;
37
- }
38
- // Annotate the CommonJS export names for ESM import in node:
39
- 0 && (module.exports = {
40
- handleRequire
41
- });
package/dist/require.mjs DELETED
@@ -1,14 +0,0 @@
1
- // src/utils/require.ts
2
- function handleRequire(props) {
3
- const { required, invisible, string, textRequired } = props;
4
- if (required && !invisible) {
5
- return {
6
- value: true,
7
- message: `${string} ${textRequired}`
8
- };
9
- }
10
- return false;
11
- }
12
- export {
13
- handleRequire
14
- };
@@ -1,11 +0,0 @@
1
- declare function handleValidateInputByType(value: string, type: 'text' | 'number' | 'phone' | 'email'): boolean;
2
- declare function handleGeneratePasswordMessage({ min, max, upcase, digit, special }: {
3
- min?: string;
4
- max?: string;
5
- upcase?: string;
6
- digit?: string;
7
- special?: string;
8
- }): string;
9
- declare function handleValidateInput(props: any): any;
10
-
11
- export { handleGeneratePasswordMessage, handleValidateInput, handleValidateInputByType };
@@ -1,11 +0,0 @@
1
- declare function handleValidateInputByType(value: string, type: 'text' | 'number' | 'phone' | 'email'): boolean;
2
- declare function handleGeneratePasswordMessage({ min, max, upcase, digit, special }: {
3
- min?: string;
4
- max?: string;
5
- upcase?: string;
6
- digit?: string;
7
- special?: string;
8
- }): string;
9
- declare function handleValidateInput(props: any): any;
10
-
11
- export { handleGeneratePasswordMessage, handleValidateInput, handleValidateInputByType };
package/dist/validate.js DELETED
@@ -1,83 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/validate.ts
21
- var validate_exports = {};
22
- __export(validate_exports, {
23
- handleGeneratePasswordMessage: () => handleGeneratePasswordMessage,
24
- handleValidateInput: () => handleValidateInput,
25
- handleValidateInputByType: () => handleValidateInputByType
26
- });
27
- module.exports = __toCommonJS(validate_exports);
28
-
29
- // src/utils/validate.ts
30
- function handleValidateInputByType(value, type) {
31
- if (type === "text") {
32
- return /^[\p{L}\s]+$/u.test(value);
33
- }
34
- if (type === "number") {
35
- return /^[0-9]+$/.test(value);
36
- }
37
- if (type === "email") {
38
- return /^[a-zA-Z0-9._]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(value);
39
- }
40
- if (type === "phone") {
41
- return /^(0|\+?84)[0-9]{9}$/.test(value);
42
- }
43
- return false;
44
- }
45
- function handleGeneratePasswordMessage({ min, max, upcase, digit, special }) {
46
- let message = `M\u1EADt kh\u1EA9u ph\u1EA3i c\xF3 t\u1EEB ${min} \u0111\u1EBFn ${max} k\xFD t\u1EF1`;
47
- if (upcase || upcase === "0") {
48
- message += `, ${upcase} ch\u1EEF in hoa`;
49
- }
50
- if (digit || digit === "0") {
51
- message += `, ${digit} s\u1ED1`;
52
- }
53
- if (special || special === "0") {
54
- message += `, ${special} k\xFD t\u1EF1 \u0111\u1EB7c bi\u1EC7t`;
55
- }
56
- return message;
57
- }
58
- function handleValidateInput(props) {
59
- const { value, widget, regex, min, max, upcase, digit, special, textValidate } = props;
60
- if (!value) return true;
61
- if (widget === "custom_passord") {
62
- if (regex && !new RegExp(regex)?.test(value)) {
63
- return handleGeneratePasswordMessage({
64
- min,
65
- max,
66
- upcase,
67
- digit,
68
- special
69
- });
70
- }
71
- return true;
72
- }
73
- if (!widget) return;
74
- const inputType = widget === "email" ? "email" : widget === "phone" ? "phone" : widget === "text-only" ? "text" : widget === "number" ? "number" : null;
75
- if (!inputType) return;
76
- return handleValidateInputByType(value, inputType) || textValidate;
77
- }
78
- // Annotate the CommonJS export names for ESM import in node:
79
- 0 && (module.exports = {
80
- handleGeneratePasswordMessage,
81
- handleValidateInput,
82
- handleValidateInputByType
83
- });
package/dist/validate.mjs DELETED
@@ -1,54 +0,0 @@
1
- // src/utils/validate.ts
2
- function handleValidateInputByType(value, type) {
3
- if (type === "text") {
4
- return /^[\p{L}\s]+$/u.test(value);
5
- }
6
- if (type === "number") {
7
- return /^[0-9]+$/.test(value);
8
- }
9
- if (type === "email") {
10
- return /^[a-zA-Z0-9._]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(value);
11
- }
12
- if (type === "phone") {
13
- return /^(0|\+?84)[0-9]{9}$/.test(value);
14
- }
15
- return false;
16
- }
17
- function handleGeneratePasswordMessage({ min, max, upcase, digit, special }) {
18
- let message = `M\u1EADt kh\u1EA9u ph\u1EA3i c\xF3 t\u1EEB ${min} \u0111\u1EBFn ${max} k\xFD t\u1EF1`;
19
- if (upcase || upcase === "0") {
20
- message += `, ${upcase} ch\u1EEF in hoa`;
21
- }
22
- if (digit || digit === "0") {
23
- message += `, ${digit} s\u1ED1`;
24
- }
25
- if (special || special === "0") {
26
- message += `, ${special} k\xFD t\u1EF1 \u0111\u1EB7c bi\u1EC7t`;
27
- }
28
- return message;
29
- }
30
- function handleValidateInput(props) {
31
- const { value, widget, regex, min, max, upcase, digit, special, textValidate } = props;
32
- if (!value) return true;
33
- if (widget === "custom_passord") {
34
- if (regex && !new RegExp(regex)?.test(value)) {
35
- return handleGeneratePasswordMessage({
36
- min,
37
- max,
38
- upcase,
39
- digit,
40
- special
41
- });
42
- }
43
- return true;
44
- }
45
- if (!widget) return;
46
- const inputType = widget === "email" ? "email" : widget === "phone" ? "phone" : widget === "text-only" ? "text" : widget === "number" ? "number" : null;
47
- if (!inputType) return;
48
- return handleValidateInputByType(value, inputType) || textValidate;
49
- }
50
- export {
51
- handleGeneratePasswordMessage,
52
- handleValidateInput,
53
- handleValidateInputByType
54
- };