@tachui/forms 0.7.1-alpha → 0.8.0-alpha

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 (90) hide show
  1. package/README.md +87 -272
  2. package/dist/DatePicker-D5nRFTUm.js +475 -0
  3. package/dist/DatePicker-D5nRFTUm.js.map +1 -0
  4. package/dist/Select-yZyKooXk.js +945 -0
  5. package/dist/Select-yZyKooXk.js.map +1 -0
  6. package/dist/Slider-0-oal5YR.js +644 -0
  7. package/dist/Slider-0-oal5YR.js.map +1 -0
  8. package/dist/TextField-hX15dY3U.js +509 -0
  9. package/dist/TextField-hX15dY3U.js.map +1 -0
  10. package/dist/components/advanced/Slider.d.ts +190 -0
  11. package/dist/components/advanced/Slider.d.ts.map +1 -0
  12. package/dist/components/advanced/Stepper.d.ts +161 -0
  13. package/dist/components/advanced/Stepper.d.ts.map +1 -0
  14. package/dist/components/advanced/index.d.ts +15 -0
  15. package/dist/components/advanced/index.d.ts.map +1 -0
  16. package/dist/components/advanced/index.js +6 -0
  17. package/dist/components/advanced/index.js.map +1 -0
  18. package/dist/components/date-picker/DatePicker.d.ts +126 -0
  19. package/dist/components/date-picker/DatePicker.d.ts.map +1 -0
  20. package/dist/components/date-picker/index.d.ts +14 -0
  21. package/dist/components/date-picker/index.d.ts.map +1 -0
  22. package/dist/components/date-picker/index.js +5 -0
  23. package/dist/components/date-picker/index.js.map +1 -0
  24. package/dist/components/form-container/index.d.ts +58 -0
  25. package/dist/components/form-container/index.d.ts.map +1 -0
  26. package/dist/components/selection/Checkbox.d.ts.map +1 -0
  27. package/dist/components/selection/Radio.d.ts.map +1 -0
  28. package/dist/components/selection/Select.d.ts.map +1 -0
  29. package/dist/components/selection/index.d.ts +68 -0
  30. package/dist/components/selection/index.d.ts.map +1 -0
  31. package/dist/components/selection/index.js +12 -0
  32. package/dist/components/selection/index.js.map +1 -0
  33. package/dist/components/text-input/TextField.d.ts.map +1 -0
  34. package/dist/components/text-input/index.d.ts +8 -0
  35. package/dist/components/text-input/index.d.ts.map +1 -0
  36. package/dist/components/text-input/index.js +18 -0
  37. package/dist/components/text-input/index.js.map +1 -0
  38. package/dist/{state/index.js → index-D3WfkqVv.js} +15 -8
  39. package/dist/index-D3WfkqVv.js.map +1 -0
  40. package/dist/index.d.ts +10 -15
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +198 -376
  43. package/dist/index.js.map +1 -0
  44. package/dist/state/index.d.ts.map +1 -1
  45. package/dist/types/index.d.ts.map +1 -1
  46. package/dist/utils/index.d.ts +19 -0
  47. package/dist/utils/index.d.ts.map +1 -0
  48. package/dist/validation/component-validation.d.ts +11 -2
  49. package/dist/validation/component-validation.d.ts.map +1 -1
  50. package/dist/validation/index.d.ts.map +1 -1
  51. package/dist/validation/index.js +282 -191
  52. package/dist/validation/index.js.map +1 -0
  53. package/package.json +53 -39
  54. package/src/components/advanced/Slider.ts +722 -0
  55. package/src/components/advanced/Stepper.ts +715 -0
  56. package/src/components/advanced/index.ts +20 -0
  57. package/src/components/date-picker/DatePicker.ts +925 -0
  58. package/src/components/date-picker/index.ts +20 -0
  59. package/src/components/form-container/index.ts +266 -0
  60. package/src/components/selection/Checkbox.ts +478 -0
  61. package/src/components/selection/Radio.ts +470 -0
  62. package/src/components/selection/Select.ts +620 -0
  63. package/src/components/selection/index.ts +81 -0
  64. package/src/components/text-input/TextField.ts +728 -0
  65. package/src/components/text-input/index.ts +35 -0
  66. package/src/index.ts +48 -0
  67. package/src/state/index.ts +544 -0
  68. package/src/types/index.ts +579 -0
  69. package/src/utils/formatters.ts +184 -0
  70. package/src/utils/index.ts +57 -0
  71. package/src/validation/component-validation.ts +429 -0
  72. package/src/validation/index.ts +641 -0
  73. package/dist/TextField-CGBM3x7K.js +0 -1799
  74. package/dist/components/Form.d.ts +0 -76
  75. package/dist/components/Form.d.ts.map +0 -1
  76. package/dist/components/index.d.ts +0 -9
  77. package/dist/components/index.d.ts.map +0 -1
  78. package/dist/components/index.js +0 -28
  79. package/dist/components/input/Checkbox.d.ts.map +0 -1
  80. package/dist/components/input/Radio.d.ts.map +0 -1
  81. package/dist/components/input/Select.d.ts.map +0 -1
  82. package/dist/components/input/TextField.d.ts.map +0 -1
  83. package/dist/components/input/index.d.ts +0 -11
  84. package/dist/components/input/index.d.ts.map +0 -1
  85. package/dist/utils/validators.d.ts +0 -101
  86. package/dist/utils/validators.d.ts.map +0 -1
  87. /package/dist/components/{input → selection}/Checkbox.d.ts +0 -0
  88. /package/dist/components/{input → selection}/Radio.d.ts +0 -0
  89. /package/dist/components/{input → selection}/Select.d.ts +0 -0
  90. /package/dist/components/{input → text-input}/TextField.d.ts +0 -0
@@ -1,229 +1,313 @@
1
- var g = Object.defineProperty;
2
- var v = (e, t, r) => t in e ? g(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var m = (e, t, r) => v(e, typeof t != "symbol" ? t + "" : t, r);
4
1
  class s extends Error {
5
2
  constructor(t, r) {
6
3
  super(t), this.context = r, this.name = "FormsValidationError";
7
4
  }
8
5
  getFormattedMessage() {
9
- const { component: t, suggestion: r, example: a, documentation: o } = this.context;
10
- let i = `❌ [@tachui/forms] ${t} Component Error: ${this.message}
6
+ const { component: t, suggestion: r, example: a, documentation: n } = this.context;
7
+ let i = `❌ [@tachui/advanced-forms] ${t} Component Error: ${this.message}
11
8
  `;
12
9
  return r && (i += `
13
10
  💡 Suggestion: ${r}
14
11
  `), a && (i += `
15
12
  ❌ Wrong: ${a.wrong}`, i += `
16
13
  ✅ Correct: ${a.correct}
17
- `), o && (i += `
18
- 📚 Documentation: ${o}`), i;
14
+ `), n && (i += `
15
+ 📚 Documentation: ${n}`), i;
19
16
  }
20
17
  }
21
18
  const l = {
22
- // EmailField Component
23
- validateEmailField(e) {
19
+ // TextField Component
20
+ validateTextField(e) {
24
21
  if (e.length === 0)
25
- throw new s("EmailField component requires a props object with value", {
26
- component: "EmailField",
27
- suggestion: "Add value: EmailField({ value: emailSignal })",
28
- documentation: "https://docs.tachui.dev/forms/components/emailfield",
22
+ throw new s(
23
+ "TextField component requires a props object with name",
24
+ {
25
+ component: "TextField",
26
+ suggestion: 'Add name property: TextField({ name: "fieldName" })',
27
+ documentation: "https://docs.tachui.dev/advanced-forms/components/textfield",
28
+ example: {
29
+ wrong: "TextField()",
30
+ correct: 'TextField({ name: "email", value: emailSignal })'
31
+ }
32
+ }
33
+ );
34
+ const [t] = e;
35
+ if (!t || typeof t != "object")
36
+ throw new s("TextField requires a props object", {
37
+ component: "TextField",
38
+ suggestion: "Pass a props object with name property",
29
39
  example: {
30
- wrong: "EmailField()",
31
- correct: "EmailField({ value: emailSignal, onChange: handleChange })"
40
+ wrong: 'TextField("email")',
41
+ correct: 'TextField({ name: "email" })'
32
42
  }
33
43
  });
44
+ const r = t;
45
+ if (!r.name || typeof r.name != "string")
46
+ throw new s(
47
+ "TextField name property is required and must be a string",
48
+ {
49
+ component: "TextField",
50
+ suggestion: "Provide a unique name for the field",
51
+ example: {
52
+ wrong: 'TextField({ placeholder: "Email" })',
53
+ correct: 'TextField({ name: "email", placeholder: "Email" })'
54
+ }
55
+ }
56
+ );
57
+ },
58
+ // EmailField Component
59
+ validateEmailField(e) {
60
+ if (e.length === 0)
61
+ throw new s(
62
+ "EmailField component requires a props object with name",
63
+ {
64
+ component: "EmailField",
65
+ suggestion: 'Add name property: EmailField({ name: "email" })',
66
+ documentation: "https://docs.tachui.dev/advanced-forms/components/emailfield",
67
+ example: {
68
+ wrong: "EmailField()",
69
+ correct: 'EmailField({ name: "email", value: emailSignal })'
70
+ }
71
+ }
72
+ );
34
73
  const [t] = e;
35
74
  if (!t || typeof t != "object")
36
75
  throw new s("EmailField requires a props object", {
37
76
  component: "EmailField",
38
- suggestion: "Pass a props object with value property",
77
+ suggestion: "Pass a props object with name property",
39
78
  example: {
40
79
  wrong: 'EmailField("email@example.com")',
41
- correct: 'EmailField({ value: "email@example.com" })'
80
+ correct: 'EmailField({ name: "email", value: "email@example.com" })'
42
81
  }
43
82
  });
44
- if (t.value === void 0)
45
- throw new s("EmailField value property is required", {
46
- component: "EmailField",
47
- suggestion: "Provide a value for the email field",
48
- example: {
49
- wrong: 'EmailField({ placeholder: "Email" })',
50
- correct: 'EmailField({ value: emailSignal, placeholder: "Email" })'
83
+ const r = t;
84
+ if (!r.name || typeof r.name != "string")
85
+ throw new s(
86
+ "EmailField name property is required and must be a string",
87
+ {
88
+ component: "EmailField",
89
+ suggestion: "Provide a unique name for the email field",
90
+ example: {
91
+ wrong: 'EmailField({ placeholder: "Email" })',
92
+ correct: 'EmailField({ name: "email", placeholder: "Email" })'
93
+ }
51
94
  }
52
- });
95
+ );
53
96
  },
54
97
  // PasswordField Component
55
98
  validatePasswordField(e) {
56
99
  if (e.length === 0)
57
- throw new s("PasswordField component requires a props object with value", {
58
- component: "PasswordField",
59
- suggestion: "Add value: PasswordField({ value: passwordSignal })",
60
- documentation: "https://docs.tachui.dev/forms/components/passwordfield",
61
- example: {
62
- wrong: "PasswordField()",
63
- correct: "PasswordField({ value: passwordSignal, onChange: handleChange })"
100
+ throw new s(
101
+ "PasswordField component requires a props object with name",
102
+ {
103
+ component: "PasswordField",
104
+ suggestion: 'Add name property: PasswordField({ name: "password" })',
105
+ documentation: "https://docs.tachui.dev/advanced-forms/components/passwordfield",
106
+ example: {
107
+ wrong: "PasswordField()",
108
+ correct: 'PasswordField({ name: "password", value: passwordSignal })'
109
+ }
64
110
  }
65
- });
111
+ );
66
112
  const [t] = e;
67
113
  if (!t || typeof t != "object")
68
114
  throw new s("PasswordField requires a props object", {
69
115
  component: "PasswordField",
70
- suggestion: "Pass a props object with value property",
116
+ suggestion: "Pass a props object with name property",
71
117
  example: {
72
118
  wrong: 'PasswordField("password")',
73
- correct: "PasswordField({ value: passwordSignal })"
119
+ correct: 'PasswordField({ name: "password", value: passwordSignal })'
74
120
  }
75
121
  });
76
- if (t.value === void 0)
77
- throw new s("PasswordField value property is required", {
78
- component: "PasswordField",
79
- suggestion: "Provide a value for the password field",
80
- example: {
81
- wrong: 'PasswordField({ placeholder: "Password" })',
82
- correct: 'PasswordField({ value: passwordSignal, placeholder: "Password" })'
122
+ const r = t;
123
+ if (!r.name || typeof r.name != "string")
124
+ throw new s(
125
+ "PasswordField name property is required and must be a string",
126
+ {
127
+ component: "PasswordField",
128
+ suggestion: "Provide a unique name for the password field",
129
+ example: {
130
+ wrong: 'PasswordField({ placeholder: "Password" })',
131
+ correct: 'PasswordField({ name: "password", placeholder: "Password" })'
132
+ }
83
133
  }
84
- });
134
+ );
85
135
  },
86
- // PhoneField Component
136
+ // PhoneField Component
87
137
  validatePhoneField(e) {
88
138
  if (e.length === 0)
89
- throw new s("PhoneField component requires a props object with value", {
90
- component: "PhoneField",
91
- suggestion: "Add value: PhoneField({ value: phoneSignal })",
92
- documentation: "https://docs.tachui.dev/forms/components/phonefield",
93
- example: {
94
- wrong: "PhoneField()",
95
- correct: 'PhoneField({ value: phoneSignal, format: "US" })'
139
+ throw new s(
140
+ "PhoneField component requires a props object with name",
141
+ {
142
+ component: "PhoneField",
143
+ suggestion: 'Add name property: PhoneField({ name: "phone" })',
144
+ documentation: "https://docs.tachui.dev/advanced-forms/components/phonefield",
145
+ example: {
146
+ wrong: "PhoneField()",
147
+ correct: 'PhoneField({ name: "phone", format: "US" })'
148
+ }
96
149
  }
97
- });
150
+ );
98
151
  const [t] = e;
99
152
  if (!t || typeof t != "object")
100
153
  throw new s("PhoneField requires a props object", {
101
154
  component: "PhoneField",
102
- suggestion: "Pass a props object with value property",
155
+ suggestion: "Pass a props object with name property",
103
156
  example: {
104
157
  wrong: 'PhoneField("(555) 123-4567")',
105
- correct: "PhoneField({ value: phoneSignal })"
158
+ correct: 'PhoneField({ name: "phone", value: phoneSignal })'
106
159
  }
107
160
  });
108
- if (t.value === void 0)
109
- throw new s("PhoneField value property is required", {
110
- component: "PhoneField",
111
- suggestion: "Provide a value for the phone field",
112
- example: {
113
- wrong: 'PhoneField({ format: "US" })',
114
- correct: 'PhoneField({ value: phoneSignal, format: "US" })'
161
+ const r = t;
162
+ if (!r.name || typeof r.name != "string")
163
+ throw new s(
164
+ "PhoneField name property is required and must be a string",
165
+ {
166
+ component: "PhoneField",
167
+ suggestion: "Provide a unique name for the phone field",
168
+ example: {
169
+ wrong: 'PhoneField({ format: "US" })',
170
+ correct: 'PhoneField({ name: "phone", format: "US" })'
171
+ }
115
172
  }
116
- });
173
+ );
117
174
  },
118
175
  // NumberField Component
119
176
  validateNumberField(e) {
120
177
  if (e.length === 0)
121
- throw new s("NumberField component requires a props object with value", {
122
- component: "NumberField",
123
- suggestion: "Add value: NumberField({ value: numberSignal })",
124
- documentation: "https://docs.tachui.dev/forms/components/numberfield",
125
- example: {
126
- wrong: "NumberField()",
127
- correct: "NumberField({ value: numberSignal, min: 0, max: 100 })"
178
+ throw new s(
179
+ "NumberField component requires a props object with name",
180
+ {
181
+ component: "NumberField",
182
+ suggestion: 'Add name property: NumberField({ name: "amount" })',
183
+ documentation: "https://docs.tachui.dev/advanced-forms/components/numberfield",
184
+ example: {
185
+ wrong: "NumberField()",
186
+ correct: 'NumberField({ name: "amount", min: 0, max: 100 })'
187
+ }
128
188
  }
129
- });
189
+ );
130
190
  const [t] = e;
131
191
  if (!t || typeof t != "object")
132
192
  throw new s("NumberField requires a props object", {
133
193
  component: "NumberField",
134
- suggestion: "Pass a props object with value property",
194
+ suggestion: "Pass a props object with name property",
135
195
  example: {
136
196
  wrong: "NumberField(42)",
137
- correct: "NumberField({ value: 42 })"
197
+ correct: 'NumberField({ name: "amount", value: 42 })'
138
198
  }
139
199
  });
140
- if (t.value === void 0)
141
- throw new s("NumberField value property is required", {
142
- component: "NumberField",
143
- suggestion: "Provide a numeric value for the field",
144
- example: {
145
- wrong: "NumberField({ min: 0, max: 100 })",
146
- correct: "NumberField({ value: 42, min: 0, max: 100 })"
200
+ const r = t;
201
+ if (!r.name || typeof r.name != "string")
202
+ throw new s(
203
+ "NumberField name property is required and must be a string",
204
+ {
205
+ component: "NumberField",
206
+ suggestion: "Provide a unique name for the number field",
207
+ example: {
208
+ wrong: "NumberField({ min: 0, max: 100 })",
209
+ correct: 'NumberField({ name: "amount", min: 0, max: 100 })'
210
+ }
147
211
  }
148
- });
212
+ );
149
213
  },
150
214
  // CreditCardField Component
151
215
  validateCreditCardField(e) {
152
216
  if (e.length === 0)
153
- throw new s("CreditCardField component requires a props object with value", {
154
- component: "CreditCardField",
155
- suggestion: "Add value: CreditCardField({ value: cardSignal })",
156
- documentation: "https://docs.tachui.dev/forms/components/creditcardfield",
157
- example: {
158
- wrong: "CreditCardField()",
159
- correct: "CreditCardField({ value: cardSignal, onChange: handleChange })"
217
+ throw new s(
218
+ "CreditCardField component requires a props object with name",
219
+ {
220
+ component: "CreditCardField",
221
+ suggestion: 'Add name property: CreditCardField({ name: "cardNumber" })',
222
+ documentation: "https://docs.tachui.dev/advanced-forms/components/creditcardfield",
223
+ example: {
224
+ wrong: "CreditCardField()",
225
+ correct: 'CreditCardField({ name: "cardNumber", onChange: handleChange })'
226
+ }
160
227
  }
161
- });
228
+ );
162
229
  const [t] = e;
163
230
  if (!t || typeof t != "object")
164
- throw new s("CreditCardField requires a props object", {
165
- component: "CreditCardField",
166
- suggestion: "Pass a props object with value property",
167
- example: {
168
- wrong: 'CreditCardField("4111111111111111")',
169
- correct: "CreditCardField({ value: cardSignal })"
231
+ throw new s(
232
+ "CreditCardField requires a props object",
233
+ {
234
+ component: "CreditCardField",
235
+ suggestion: "Pass a props object with name property",
236
+ example: {
237
+ wrong: 'CreditCardField("4111111111111111")',
238
+ correct: 'CreditCardField({ name: "cardNumber", value: cardSignal })'
239
+ }
170
240
  }
171
- });
172
- if (t.value === void 0)
173
- throw new s("CreditCardField value property is required", {
174
- component: "CreditCardField",
175
- suggestion: "Provide a value for the credit card field",
176
- example: {
177
- wrong: 'CreditCardField({ placeholder: "Card Number" })',
178
- correct: 'CreditCardField({ value: cardSignal, placeholder: "Card Number" })'
241
+ );
242
+ const r = t;
243
+ if (!r.name || typeof r.name != "string")
244
+ throw new s(
245
+ "CreditCardField name property is required and must be a string",
246
+ {
247
+ component: "CreditCardField",
248
+ suggestion: "Provide a unique name for the credit card field",
249
+ example: {
250
+ wrong: 'CreditCardField({ placeholder: "Card Number" })',
251
+ correct: 'CreditCardField({ name: "cardNumber", placeholder: "Card Number" })'
252
+ }
179
253
  }
180
- });
254
+ );
181
255
  }
182
256
  // Additional Forms components would go here...
183
- // (SearchField, URLField, TextArea, ColorField, Select, MultiSelect, Checkbox, Radio, etc.)
257
+ // (SearchField, URLField, TextArea, ColorField, etc.)
184
258
  };
185
- function f() {
259
+ function p() {
186
260
  return [
187
261
  {
188
- packageName: "forms",
262
+ packageName: "advanced-forms",
263
+ componentName: "TextField",
264
+ validate: l.validateTextField
265
+ },
266
+ {
267
+ packageName: "advanced-forms",
189
268
  componentName: "EmailField",
190
269
  validate: l.validateEmailField
191
270
  },
192
271
  {
193
- packageName: "forms",
272
+ packageName: "advanced-forms",
194
273
  componentName: "PasswordField",
195
274
  validate: l.validatePasswordField
196
275
  },
197
276
  {
198
- packageName: "forms",
277
+ packageName: "advanced-forms",
199
278
  componentName: "PhoneField",
200
279
  validate: l.validatePhoneField
201
280
  },
202
281
  {
203
- packageName: "forms",
282
+ packageName: "advanced-forms",
204
283
  componentName: "NumberField",
205
284
  validate: l.validateNumberField
206
285
  },
207
286
  {
208
- packageName: "forms",
287
+ packageName: "advanced-forms",
209
288
  componentName: "CreditCardField",
210
289
  validate: l.validateCreditCardField
211
290
  }
212
- // Additional validators would be added here for remaining 9+ Forms components
291
+ // Additional validators would be added here for remaining Forms components
213
292
  ];
214
293
  }
215
- async function h() {
294
+ async function g() {
216
295
  try {
217
- const { registerComponentValidator: e } = await import("@tachui/core/validation"), t = f();
296
+ const { registerComponentValidator: e } = await import("@tachui/core/validation"), t = p();
218
297
  for (const r of t)
219
298
  e(r);
220
- process.env.NODE_ENV !== "production" && console.info(`🔍 [@tachui/forms] Registered ${t.length} component validators`);
299
+ process.env.NODE_ENV !== "production" && console.info(
300
+ `🔍 [@tachui/advanced-forms] Registered ${t.length} component validators`
301
+ );
221
302
  } catch (e) {
222
- process.env.NODE_ENV !== "production" && console.warn("⚠️ [@tachui/forms] Could not register validators with Core:", e);
303
+ process.env.NODE_ENV !== "production" && console.warn(
304
+ "⚠️ [@tachui/advanced-forms] Could not register validators with Core:",
305
+ e
306
+ );
223
307
  }
224
308
  }
225
- typeof window < "u" && process.env.NODE_ENV !== "production" && setTimeout(h, 10);
226
- const u = {
309
+ typeof window < "u" && process.env.NODE_ENV !== "production" && setTimeout(g, 10);
310
+ const m = {
227
311
  required: (e) => ({
228
312
  valid: e != null && e !== "",
229
313
  message: "This field is required",
@@ -320,8 +404,8 @@ const u = {
320
404
  if (!e) return { valid: !0 };
321
405
  const t = e.replace(/\s/g, "");
322
406
  let r = 0, a = !1;
323
- for (let o = t.length - 1; o >= 0; o--) {
324
- let i = parseInt(t.charAt(o));
407
+ for (let n = t.length - 1; n >= 0; n--) {
408
+ let i = parseInt(t.charAt(n));
325
409
  a && (i *= 2, i > 9 && (i = i % 10 + 1)), r += i, a = !a;
326
410
  }
327
411
  return {
@@ -369,101 +453,101 @@ const u = {
369
453
  } : { valid: !0 },
370
454
  strongPassword: (e) => {
371
455
  if (!e) return { valid: !0 };
372
- const t = /[A-Z]/.test(e), r = /[a-z]/.test(e), a = /\d/.test(e), o = /\W/.test(e), i = e.length >= 8, n = t && r && a && o && i;
456
+ const t = /[A-Z]/.test(e), r = /[a-z]/.test(e), a = /\d/.test(e), n = /\W/.test(e), i = e.length >= 8, o = t && r && a && n && i;
373
457
  return {
374
- valid: n,
375
- message: n ? void 0 : "Password must be at least 8 characters with uppercase, lowercase, number and special character",
458
+ valid: o,
459
+ message: o ? void 0 : "Password must be at least 8 characters with uppercase, lowercase, number and special character",
376
460
  code: "WEAK_PASSWORD"
377
461
  };
378
462
  }
379
463
  }, c = /* @__PURE__ */ new Map();
380
- function P(e) {
464
+ function v(e) {
381
465
  c.set(e.name, e);
382
466
  }
383
- function E(e) {
467
+ function F(e) {
384
468
  c.delete(e);
385
469
  }
386
- function C() {
387
- return [...Object.keys(u), ...c.keys()];
470
+ function N() {
471
+ return [...Object.keys(m), ...c.keys()];
388
472
  }
389
- function p(e, t, r) {
473
+ function u(e, t, r) {
390
474
  for (const a of t) {
391
- let o;
475
+ let n;
392
476
  if (typeof a == "string") {
393
- const i = u[a];
477
+ const i = m[a];
394
478
  if (i)
395
- o = i(e, r?.[a]);
479
+ n = i(e, r?.[a]);
396
480
  else {
397
- const n = c.get(a);
398
- if (n)
399
- o = n.validate(e, n.options);
481
+ const o = c.get(a);
482
+ if (o)
483
+ n = o.validate(e, o.options);
400
484
  else {
401
485
  console.warn(`Unknown validation rule: ${a}`);
402
486
  continue;
403
487
  }
404
488
  }
405
489
  } else if ("validate" in a)
406
- o = a.validate(e, a.options);
490
+ n = a.validate(e, a.options);
407
491
  else {
408
- const i = u[a.name];
492
+ const i = m[a.name];
409
493
  if (i)
410
- o = i(e, a.options);
494
+ n = i(e, a.options);
411
495
  else {
412
496
  console.warn(`Unknown built-in validation rule: ${a.name}`);
413
497
  continue;
414
498
  }
415
499
  }
416
- if (!o.valid)
417
- return o;
500
+ if (!n.valid)
501
+ return n;
418
502
  }
419
503
  return { valid: !0 };
420
504
  }
421
- function V(e, t) {
422
- return !t?.rules || t.rules.length === 0 ? { valid: !0 } : p(e.value, t.rules);
505
+ function b(e, t) {
506
+ return !t?.rules || t.rules.length === 0 ? { valid: !0 } : u(e.value, t.rules);
423
507
  }
424
- async function w(e, t, r) {
508
+ async function f(e, t, r) {
425
509
  for (const a of t) {
426
- let o;
510
+ let n;
427
511
  if (typeof a == "string") {
428
- const n = u[a];
429
- if (n)
430
- o = n(e, r?.[a]);
512
+ const o = m[a];
513
+ if (o)
514
+ n = o(e, r?.[a]);
431
515
  else {
432
516
  const d = c.get(a);
433
517
  if (d)
434
- o = d.validate(e, d.options);
518
+ n = d.validate(e, d.options);
435
519
  else
436
520
  continue;
437
521
  }
438
522
  } else if ("validate" in a)
439
- o = a.validate(e, a.options);
523
+ n = a.validate(e, a.options);
440
524
  else {
441
- const n = u[a.name];
442
- if (n)
443
- o = n(e, a.options);
525
+ const o = m[a.name];
526
+ if (o)
527
+ n = o(e, a.options);
444
528
  else
445
529
  continue;
446
530
  }
447
- const i = await Promise.resolve(o);
531
+ const i = await Promise.resolve(n);
448
532
  if (!i.valid)
449
533
  return i;
450
534
  }
451
535
  return { valid: !0 };
452
536
  }
453
- function I(e, t = 300) {
454
- let r, a, o;
455
- return (i) => new Promise((n) => {
456
- if (i === a && o) {
457
- Promise.resolve(o).then(n);
537
+ function P(e, t = 300) {
538
+ let r, a, n;
539
+ return (i) => new Promise((o) => {
540
+ if (i === a && n) {
541
+ Promise.resolve(n).then(o);
458
542
  return;
459
543
  }
460
544
  a = i, clearTimeout(r), r = setTimeout(async () => {
461
545
  try {
462
- o = e(i);
463
- const d = await Promise.resolve(o);
464
- n(d);
546
+ n = e(i);
547
+ const d = await Promise.resolve(n);
548
+ o(d);
465
549
  } catch {
466
- n({
550
+ o({
467
551
  valid: !1,
468
552
  message: "Validation error occurred",
469
553
  code: "VALIDATION_ERROR"
@@ -472,7 +556,7 @@ function I(e, t = 300) {
472
556
  }, t);
473
557
  });
474
558
  }
475
- const A = {
559
+ const E = {
476
560
  /**
477
561
  * Validate that two fields match (e.g., password confirmation)
478
562
  */
@@ -484,8 +568,8 @@ const A = {
484
568
  /**
485
569
  * Validate that at least one field in a group is filled
486
570
  */
487
- requireOneOf: (e, t = "At least one field is required") => (r) => e.some((o) => {
488
- const i = r[o];
571
+ requireOneOf: (e, t = "At least one field is required") => (r) => e.some((n) => {
572
+ const i = r[n];
489
573
  return i != null && i !== "";
490
574
  }) ? { valid: !0 } : {
491
575
  valid: !1,
@@ -495,9 +579,9 @@ const A = {
495
579
  /**
496
580
  * Validate that a field is required when another field has a specific value
497
581
  */
498
- requiredWhen: (e, t, r, a = `${e} is required`) => (o) => {
499
- if (o[t] === r) {
500
- const i = o[e];
582
+ requiredWhen: (e, t, r, a = `${e} is required`) => (n) => {
583
+ if (n[t] === r) {
584
+ const i = n[e];
501
585
  return i != null && i !== "" ? { valid: !0 } : {
502
586
  valid: !1,
503
587
  message: a,
@@ -510,10 +594,10 @@ const A = {
510
594
  * Validate date range (start date before end date)
511
595
  */
512
596
  dateRange: (e, t, r = "End date must be after start date") => (a) => {
513
- const o = a[e], i = a[t];
514
- if (!o || !i) return { valid: !0 };
515
- const n = new Date(o);
516
- return new Date(i) >= n ? { valid: !0 } : {
597
+ const n = a[e], i = a[t];
598
+ if (!n || !i) return { valid: !0 };
599
+ const o = new Date(n);
600
+ return new Date(i) >= o ? { valid: !0 } : {
517
601
  valid: !1,
518
602
  message: r,
519
603
  code: "INVALID_DATE_RANGE"
@@ -524,7 +608,10 @@ const A = {
524
608
  password: ["required", { name: "minLength", options: { minLength: 8 } }],
525
609
  phone: [
526
610
  "required",
527
- { name: "pattern", options: { pattern: /^\+?[\d\s-()]+$/, message: "Invalid phone number" } }
611
+ {
612
+ name: "pattern",
613
+ options: { pattern: /^\+?[\d\s-()]+$/, message: "Invalid phone number" }
614
+ }
528
615
  ],
529
616
  url: ["required", "url"],
530
617
  positiveNumber: ["required", "number", { name: "min", options: { min: 0 } }],
@@ -535,9 +622,9 @@ const A = {
535
622
  { name: "max", options: { max: 100 } }
536
623
  ]
537
624
  };
538
- class F {
625
+ class h {
626
+ messages = {};
539
627
  constructor(t = {}) {
540
- m(this, "messages", {});
541
628
  this.messages = t;
542
629
  }
543
630
  setMessage(t, r) {
@@ -547,10 +634,13 @@ class F {
547
634
  this.messages = { ...this.messages, ...t };
548
635
  }
549
636
  format(t, r) {
550
- return t.code && this.messages[t.code] ? this.messages[t.code].replace("${field}", r || "field") : t.message || "Validation failed";
637
+ return t.code && this.messages[t.code] ? this.messages[t.code].replace(
638
+ "${field}",
639
+ r || "field"
640
+ ) : t.message || "Validation failed";
551
641
  }
552
642
  }
553
- const R = new F(), L = {
643
+ const C = new h(), V = {
554
644
  /**
555
645
  * Check if a validation result represents an error
556
646
  */
@@ -573,28 +663,29 @@ const R = new F(), L = {
573
663
  /**
574
664
  * Create a validation function from a rule configuration
575
665
  */
576
- createValidator: (e, t) => (r) => p(r, e, t),
666
+ createValidator: (e, t) => (r) => u(r, e, t),
577
667
  /**
578
668
  * Create an async validation function
579
669
  */
580
- createAsyncValidator: (e, t) => (r) => w(r, e, t)
670
+ createAsyncValidator: (e, t) => (r) => f(r, e, t)
581
671
  };
582
672
  export {
583
- A as CrossFieldValidators,
673
+ E as CrossFieldValidators,
584
674
  l as FormsComponentValidation,
585
675
  s as FormsValidationError,
586
- u as VALIDATION_RULES,
587
- F as ValidationMessageFormatter,
676
+ m as VALIDATION_RULES,
677
+ h as ValidationMessageFormatter,
588
678
  x as ValidationPresets,
589
- L as ValidationUtils,
590
- I as createDebouncedValidator,
591
- f as createFormsValidators,
592
- R as defaultMessageFormatter,
593
- C as getValidationRules,
594
- h as registerFormsValidators,
595
- P as registerValidationRule,
596
- E as unregisterValidationRule,
597
- V as validateField,
598
- p as validateValue,
599
- w as validateValueAsync
679
+ V as ValidationUtils,
680
+ P as createDebouncedValidator,
681
+ p as createFormsValidators,
682
+ C as defaultMessageFormatter,
683
+ N as getValidationRules,
684
+ g as registerFormsValidators,
685
+ v as registerValidationRule,
686
+ F as unregisterValidationRule,
687
+ b as validateField,
688
+ u as validateValue,
689
+ f as validateValueAsync
600
690
  };
691
+ //# sourceMappingURL=index.js.map