@tachui/forms 0.7.0-alpha1

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.
Files changed (62) hide show
  1. package/LICENSE +363 -0
  2. package/dist/Form-ueYEcSg1.cjs +2 -0
  3. package/dist/Form-ueYEcSg1.cjs.map +1 -0
  4. package/dist/Form-ylAr3o_e.js +376 -0
  5. package/dist/Form-ylAr3o_e.js.map +1 -0
  6. package/dist/components/Form.d.ts +76 -0
  7. package/dist/components/Form.d.ts.map +1 -0
  8. package/dist/components/index.cjs +2 -0
  9. package/dist/components/index.cjs.map +1 -0
  10. package/dist/components/index.d.ts +9 -0
  11. package/dist/components/index.d.ts.map +1 -0
  12. package/dist/components/index.js +31 -0
  13. package/dist/components/index.js.map +1 -0
  14. package/dist/components/input/Checkbox.d.ts +42 -0
  15. package/dist/components/input/Checkbox.d.ts.map +1 -0
  16. package/dist/components/input/Radio.d.ts +36 -0
  17. package/dist/components/input/Radio.d.ts.map +1 -0
  18. package/dist/components/input/Select.d.ts +21 -0
  19. package/dist/components/input/Select.d.ts.map +1 -0
  20. package/dist/components/input/TextField.d.ts +58 -0
  21. package/dist/components/input/TextField.d.ts.map +1 -0
  22. package/dist/components/input/index.d.ts +11 -0
  23. package/dist/components/input/index.d.ts.map +1 -0
  24. package/dist/forms-complex-BiQsZZlT.js +361 -0
  25. package/dist/forms-complex-BiQsZZlT.js.map +1 -0
  26. package/dist/forms-complex-DLEnXXJ5.cjs +2 -0
  27. package/dist/forms-complex-DLEnXXJ5.cjs.map +1 -0
  28. package/dist/forms-core-B1bx1drO.js +839 -0
  29. package/dist/forms-core-B1bx1drO.js.map +1 -0
  30. package/dist/forms-core-W_JGVLAI.cjs +9 -0
  31. package/dist/forms-core-W_JGVLAI.cjs.map +1 -0
  32. package/dist/forms-inputs-6QdeMWFk.js +1075 -0
  33. package/dist/forms-inputs-6QdeMWFk.js.map +1 -0
  34. package/dist/forms-inputs-DQ5QI_SU.cjs +2 -0
  35. package/dist/forms-inputs-DQ5QI_SU.cjs.map +1 -0
  36. package/dist/index.cjs +2 -0
  37. package/dist/index.cjs.map +1 -0
  38. package/dist/index.d.ts +21 -0
  39. package/dist/index.d.ts.map +1 -0
  40. package/dist/index.js +383 -0
  41. package/dist/index.js.map +1 -0
  42. package/dist/state/index.cjs +2 -0
  43. package/dist/state/index.cjs.map +1 -0
  44. package/dist/state/index.d.ts +46 -0
  45. package/dist/state/index.d.ts.map +1 -0
  46. package/dist/state/index.js +9 -0
  47. package/dist/state/index.js.map +1 -0
  48. package/dist/types/index.d.ts +452 -0
  49. package/dist/types/index.d.ts.map +1 -0
  50. package/dist/utils/formatters.d.ts +98 -0
  51. package/dist/utils/formatters.d.ts.map +1 -0
  52. package/dist/utils/validators.d.ts +101 -0
  53. package/dist/utils/validators.d.ts.map +1 -0
  54. package/dist/validation/component-validation.d.ts +52 -0
  55. package/dist/validation/component-validation.d.ts.map +1 -0
  56. package/dist/validation/index.cjs +2 -0
  57. package/dist/validation/index.cjs.map +1 -0
  58. package/dist/validation/index.d.ts +141 -0
  59. package/dist/validation/index.d.ts.map +1 -0
  60. package/dist/validation/index.js +21 -0
  61. package/dist/validation/index.js.map +1 -0
  62. package/package.json +65 -0
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Forms Package Component Validation
3
+ *
4
+ * Validation for @tachui/forms components that registers with the Core
5
+ * validation system, following proper plugin architecture.
6
+ */
7
+ import type { ComponentValidator } from '@tachui/core/validation';
8
+ /**
9
+ * TachUI Forms validation error class
10
+ */
11
+ export declare class FormsValidationError extends Error {
12
+ context: {
13
+ component: string;
14
+ property?: string;
15
+ suggestion?: string;
16
+ documentation?: string;
17
+ example?: {
18
+ wrong: string;
19
+ correct: string;
20
+ };
21
+ };
22
+ constructor(message: string, context: {
23
+ component: string;
24
+ property?: string;
25
+ suggestion?: string;
26
+ documentation?: string;
27
+ example?: {
28
+ wrong: string;
29
+ correct: string;
30
+ };
31
+ });
32
+ getFormattedMessage(): string;
33
+ }
34
+ /**
35
+ * Forms Components Validation
36
+ */
37
+ export declare const FormsComponentValidation: {
38
+ validateEmailField(args: unknown[]): void;
39
+ validatePasswordField(args: unknown[]): void;
40
+ validatePhoneField(args: unknown[]): void;
41
+ validateNumberField(args: unknown[]): void;
42
+ validateCreditCardField(args: unknown[]): void;
43
+ };
44
+ /**
45
+ * Create Forms component validators for registration
46
+ */
47
+ export declare function createFormsValidators(): ComponentValidator[];
48
+ /**
49
+ * Register Forms validators with Core validation system
50
+ */
51
+ export declare function registerFormsValidators(): Promise<void>;
52
+ //# sourceMappingURL=component-validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-validation.d.ts","sourceRoot":"","sources":["../../src/validation/component-validation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAEjE;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAGpC,OAAO,EAAE;QACd,SAAS,EAAE,MAAM,CAAA;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,aAAa,CAAC,EAAE,MAAM,CAAA;QACtB,OAAO,CAAC,EAAE;YACR,KAAK,EAAE,MAAM,CAAA;YACb,OAAO,EAAE,MAAM,CAAA;SAChB,CAAA;KACF;gBAVD,OAAO,EAAE,MAAM,EACR,OAAO,EAAE;QACd,SAAS,EAAE,MAAM,CAAA;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,aAAa,CAAC,EAAE,MAAM,CAAA;QACtB,OAAO,CAAC,EAAE;YACR,KAAK,EAAE,MAAM,CAAA;YACb,OAAO,EAAE,MAAM,CAAA;SAChB,CAAA;KACF;IAMH,mBAAmB,IAAI,MAAM;CAoB9B;AAED;;GAEG;AACH,eAAO,MAAM,wBAAwB;6BAGV,OAAO,EAAE,GAAG,IAAI;gCAuCb,OAAO,EAAE,GAAG,IAAI;6BAuCnB,OAAO,EAAE,GAAG,IAAI;8BAuCf,OAAO,EAAE,GAAG,IAAI;kCAuCZ,OAAO,EAAE,GAAG,IAAI;CAwC/C,CAAA;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,kBAAkB,EAAE,CA6B5D;AAED;;GAEG;AACH,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC,CAmB7D"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../forms-core-W_JGVLAI.cjs");exports.CrossFieldValidators=a.CrossFieldValidators;exports.FormsComponentValidation=a.FormsComponentValidation;exports.FormsValidationError=a.FormsValidationError;exports.VALIDATION_RULES=a.VALIDATION_RULES;exports.ValidationMessageFormatter=a.ValidationMessageFormatter;exports.ValidationPresets=a.ValidationPresets;exports.ValidationUtils=a.ValidationUtils;exports.createDebouncedValidator=a.createDebouncedValidator;exports.createFormsValidators=a.createFormsValidators;exports.defaultMessageFormatter=a.defaultMessageFormatter;exports.getValidationRules=a.getValidationRules;exports.registerFormsValidators=a.registerFormsValidators;exports.registerValidationRule=a.registerValidationRule;exports.unregisterValidationRule=a.unregisterValidationRule;exports.validateField=a.validateField;exports.validateValue=a.validateValue;exports.validateValueAsync=a.validateValueAsync;
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,141 @@
1
+ /**
2
+ * TachUI Forms Validation System
3
+ *
4
+ * Comprehensive validation engine with built-in rules, custom validators,
5
+ * async validation support, and i18n-ready error messages.
6
+ */
7
+ import type { CustomValidationRule, FieldState, FieldValidation, ValidationResult, ValidationRule } from '../types';
8
+ /**
9
+ * Built-in validation rules
10
+ */
11
+ declare const VALIDATION_RULES: Record<string, (value: any, options?: any) => ValidationResult>;
12
+ /**
13
+ * Register a custom validation rule
14
+ */
15
+ export declare function registerValidationRule(rule: CustomValidationRule): void;
16
+ /**
17
+ * Unregister a custom validation rule
18
+ */
19
+ export declare function unregisterValidationRule(name: string): void;
20
+ /**
21
+ * Get all registered validation rules
22
+ */
23
+ export declare function getValidationRules(): string[];
24
+ /**
25
+ * Validate a single value against validation rules
26
+ */
27
+ export declare function validateValue(value: any, rules: ValidationRule[], options?: Record<string, any>): ValidationResult;
28
+ /**
29
+ * Validate a field state
30
+ */
31
+ export declare function validateField(field: FieldState, validation?: FieldValidation): ValidationResult;
32
+ /**
33
+ * Async validation function
34
+ */
35
+ export declare function validateValueAsync(value: any, rules: ValidationRule[], options?: Record<string, any>): Promise<ValidationResult>;
36
+ /**
37
+ * Debounced validation
38
+ */
39
+ export declare function createDebouncedValidator(validator: (value: any) => ValidationResult | Promise<ValidationResult>, delayMs?: number): (value: any) => Promise<ValidationResult>;
40
+ /**
41
+ * Cross-field validation utilities
42
+ */
43
+ export declare const CrossFieldValidators: {
44
+ /**
45
+ * Validate that two fields match (e.g., password confirmation)
46
+ */
47
+ fieldMatch: (field1: string, field2: string, message?: string) => (values: Record<string, any>) => ValidationResult;
48
+ /**
49
+ * Validate that at least one field in a group is filled
50
+ */
51
+ requireOneOf: (fields: string[], message?: string) => (values: Record<string, any>) => ValidationResult;
52
+ /**
53
+ * Validate that a field is required when another field has a specific value
54
+ */
55
+ requiredWhen: (targetField: string, conditionalField: string, conditionalValue: any, message?: string) => (values: Record<string, any>) => ValidationResult;
56
+ /**
57
+ * Validate date range (start date before end date)
58
+ */
59
+ dateRange: (startField: string, endField: string, message?: string) => (values: Record<string, any>) => ValidationResult;
60
+ };
61
+ /**
62
+ * Built-in validation rule presets
63
+ */
64
+ export declare const ValidationPresets: {
65
+ email: string[];
66
+ password: (string | {
67
+ name: string;
68
+ options: {
69
+ minLength: number;
70
+ };
71
+ })[];
72
+ phone: (string | {
73
+ name: string;
74
+ options: {
75
+ pattern: RegExp;
76
+ message: string;
77
+ };
78
+ })[];
79
+ url: string[];
80
+ positiveNumber: (string | {
81
+ name: string;
82
+ options: {
83
+ min: number;
84
+ };
85
+ })[];
86
+ percentage: (string | {
87
+ name: string;
88
+ options: {
89
+ min: number;
90
+ max?: undefined;
91
+ };
92
+ } | {
93
+ name: string;
94
+ options: {
95
+ max: number;
96
+ min?: undefined;
97
+ };
98
+ })[];
99
+ };
100
+ /**
101
+ * Validation message formatter
102
+ */
103
+ export declare class ValidationMessageFormatter {
104
+ private messages;
105
+ constructor(messages?: Record<string, string>);
106
+ setMessage(code: string, message: string): void;
107
+ setMessages(messages: Record<string, string>): void;
108
+ format(result: ValidationResult, fieldName?: string): string;
109
+ }
110
+ /**
111
+ * Default validation message formatter instance
112
+ */
113
+ export declare const defaultMessageFormatter: ValidationMessageFormatter;
114
+ /**
115
+ * Validation utilities
116
+ */
117
+ export declare const ValidationUtils: {
118
+ /**
119
+ * Check if a validation result represents an error
120
+ */
121
+ isError: (result: ValidationResult) => boolean;
122
+ /**
123
+ * Check if a validation result is valid
124
+ */
125
+ isValid: (result: ValidationResult) => boolean;
126
+ /**
127
+ * Combine multiple validation results
128
+ */
129
+ combineResults: (results: ValidationResult[]) => ValidationResult;
130
+ /**
131
+ * Create a validation function from a rule configuration
132
+ */
133
+ createValidator: (rules: ValidationRule[], options?: Record<string, any>) => (value: any) => ValidationResult;
134
+ /**
135
+ * Create an async validation function
136
+ */
137
+ createAsyncValidator: (rules: ValidationRule[], options?: Record<string, any>) => (value: any) => Promise<ValidationResult>;
138
+ };
139
+ export { VALIDATION_RULES };
140
+ export * from './component-validation';
141
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validation/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,oBAAoB,EACpB,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,cAAc,EACf,MAAM,UAAU,CAAA;AAEjB;;GAEG;AACH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AAA;AAG3B,cAAc,wBAAwB,CAAA"}
@@ -0,0 +1,21 @@
1
+ import { C as e, m as i, F as t, l as r, j as l, V as o, k as d, i as V, n, d as m, g as u, r as F, e as g, u as c, h as v, f as R, v as f } from "../forms-core-B1bx1drO.js";
2
+ export {
3
+ e as CrossFieldValidators,
4
+ i as FormsComponentValidation,
5
+ t as FormsValidationError,
6
+ r as VALIDATION_RULES,
7
+ l as ValidationMessageFormatter,
8
+ o as ValidationPresets,
9
+ d as ValidationUtils,
10
+ V as createDebouncedValidator,
11
+ n as createFormsValidators,
12
+ m as defaultMessageFormatter,
13
+ u as getValidationRules,
14
+ F as registerFormsValidators,
15
+ g as registerValidationRule,
16
+ c as unregisterValidationRule,
17
+ v as validateField,
18
+ R as validateValue,
19
+ f as validateValueAsync
20
+ };
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@tachui/forms",
3
+ "version": "0.7.0-alpha1",
4
+ "description": "Form components and validation system for tachUI framework",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "files": [
9
+ "dist/"
10
+ ],
11
+ "keywords": [
12
+ "tachui",
13
+ "forms",
14
+ "validation",
15
+ "ui",
16
+ "components",
17
+ "plugin"
18
+ ],
19
+ "author": "tachUI Team",
20
+ "license": "MPL-2.0",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/tachUI/tachui.git",
24
+ "directory": "packages/forms"
25
+ },
26
+ "peerDependencies": {
27
+ "@tachui/core": "^0.1.0"
28
+ },
29
+ "devDependencies": {
30
+ "@types/node": "^20.0.0",
31
+ "typescript": "^5.2.0",
32
+ "vite": "^5.0.0",
33
+ "vitest": "^1.6.0",
34
+ "@tachui/core": "0.7.0-alpha1"
35
+ },
36
+ "exports": {
37
+ ".": {
38
+ "types": "./dist/index.d.ts",
39
+ "import": "./dist/index.js",
40
+ "require": "./dist/index.cjs"
41
+ },
42
+ "./components": {
43
+ "types": "./dist/components/index.d.ts",
44
+ "import": "./dist/components/index.js"
45
+ },
46
+ "./validation": {
47
+ "types": "./dist/validation/index.d.ts",
48
+ "import": "./dist/validation/index.js"
49
+ },
50
+ "./state": {
51
+ "types": "./dist/state/index.d.ts",
52
+ "import": "./dist/state/index.js"
53
+ }
54
+ },
55
+ "sideEffects": false,
56
+ "scripts": {
57
+ "build": "vite build && tsc --emitDeclarationOnly",
58
+ "dev": "vite build --watch",
59
+ "test": "vitest",
60
+ "test:ci": "vitest run",
61
+ "type-check": "tsc --noEmit",
62
+ "lint": "oxlint src",
63
+ "clean": "rm -rf dist"
64
+ }
65
+ }