@temboplus/frontend-react-core 0.1.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/README.md +385 -0
- package/dist/antd-validators.d.ts +139 -0
- package/dist/index.cjs.js +2 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +2 -0
- package/dist/index.esm.js.map +1 -0
- package/package.json +57 -0
package/README.md
ADDED
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
# @temboplus/frontend-react-core
|
|
2
|
+
|
|
3
|
+
A React UI library for TemboPlus applications, providing reusable components, validators, and utilities for building consistent react applications across the platform.
|
|
4
|
+
|
|
5
|
+
## 📦 Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @temboplus/frontend-react-core
|
|
9
|
+
# or
|
|
10
|
+
yarn add @temboplus/frontend-react-core
|
|
11
|
+
# or
|
|
12
|
+
pnpm add @temboplus/frontend-react-core
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## 🏗️ Dependencies
|
|
16
|
+
|
|
17
|
+
This package requires the following peer dependencies:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @temboplus/frontend-core
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## 🚀 Quick Start
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { PHONE_NUMBER_VALIDATOR, AMOUNT_VALIDATOR } from '@temboplus/frontend-react-core';
|
|
27
|
+
|
|
28
|
+
// Use in your Ant Design form
|
|
29
|
+
const formRules = {
|
|
30
|
+
phoneNumber: [{ required: true, validator: PHONE_NUMBER_VALIDATOR('TZ') }],
|
|
31
|
+
amount: [{ required: true, validator: AMOUNT_VALIDATOR({ currencyCode: 'TZS' }) }]
|
|
32
|
+
};
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## 📚 Features
|
|
36
|
+
|
|
37
|
+
### ✅ Form Validators (Available Now)
|
|
38
|
+
|
|
39
|
+
Type-safe, country-aware form validators for Ant Design forms with built-in internationalization and error messaging.
|
|
40
|
+
|
|
41
|
+
### 🔄 Coming Soon
|
|
42
|
+
|
|
43
|
+
- **Reusable React Components** - Pre-built UI components for financial applications
|
|
44
|
+
- **Hooks Library** - Custom React hooks for common patterns
|
|
45
|
+
- **Context Providers** - Application-wide state management
|
|
46
|
+
- **Theme System** - Consistent design tokens and styling
|
|
47
|
+
- **Utility Functions** - Helper functions for React applications
|
|
48
|
+
|
|
49
|
+
## 📋 API Reference
|
|
50
|
+
|
|
51
|
+
### Form Validators
|
|
52
|
+
|
|
53
|
+
All validators follow the Ant Design validator pattern and return Promise-based validation results.
|
|
54
|
+
|
|
55
|
+
#### `PHONE_NUMBER_VALIDATOR(countryCode?: ISO2CountryCode)`
|
|
56
|
+
|
|
57
|
+
Validates general phone number format using libphonenumber-js.
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import { PHONE_NUMBER_VALIDATOR } from '@temboplus/frontend-react-core';
|
|
61
|
+
|
|
62
|
+
// Basic usage
|
|
63
|
+
const rules = [{ required: true, validator: PHONE_NUMBER_VALIDATOR('TZ') }];
|
|
64
|
+
|
|
65
|
+
// Supported countries: TZ, KE, and all libphonenumber-js supported countries
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Features:**
|
|
69
|
+
- Validates phone number format for any country
|
|
70
|
+
- Returns normalized E.164 format on success
|
|
71
|
+
- Country-specific error messages
|
|
72
|
+
- Supports international and local number formats
|
|
73
|
+
|
|
74
|
+
#### `MOBILE_PHONE_VALIDATOR(countryCode?: ISO2CountryCode)`
|
|
75
|
+
|
|
76
|
+
Validates mobile phone numbers eligible for payout operations (stricter validation).
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
import { MOBILE_PHONE_VALIDATOR } from '@temboplus/frontend-react-core';
|
|
80
|
+
|
|
81
|
+
const rules = [{ required: true, validator: MOBILE_PHONE_VALIDATOR('TZ') }];
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Features:**
|
|
85
|
+
- Validates mobile-specific number formats
|
|
86
|
+
- Checks payout eligibility (supports TZ and KE)
|
|
87
|
+
- MNO (Mobile Network Operator) validation
|
|
88
|
+
- Returns normalized E.164 format
|
|
89
|
+
|
|
90
|
+
#### `ACCOUNT_NAME_VALIDATOR`
|
|
91
|
+
|
|
92
|
+
Validates bank account holder names.
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
import { ACCOUNT_NAME_VALIDATOR } from '@temboplus/frontend-react-core';
|
|
96
|
+
|
|
97
|
+
const rules = [{ required: true, validator: ACCOUNT_NAME_VALIDATOR }];
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**Validation Rules:**
|
|
101
|
+
- 3-50 characters length
|
|
102
|
+
- Only letters, spaces, hyphens, apostrophes, commas
|
|
103
|
+
- At least two words (first name + last name)
|
|
104
|
+
- Not all uppercase
|
|
105
|
+
- No numbers or special characters
|
|
106
|
+
|
|
107
|
+
#### `SWIFT_CODE_VALIDATOR(countryCode?: ISO2CountryCode)`
|
|
108
|
+
|
|
109
|
+
Validates SWIFT/BIC codes for banks.
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
import { SWIFT_CODE_VALIDATOR } from '@temboplus/frontend-react-core';
|
|
113
|
+
|
|
114
|
+
// Country-specific validation
|
|
115
|
+
const rules = [{ required: true, validator: SWIFT_CODE_VALIDATOR('TZ') }];
|
|
116
|
+
|
|
117
|
+
// Multi-country validation
|
|
118
|
+
const rules = [{ required: true, validator: SWIFT_CODE_VALIDATOR() }];
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**Features:**
|
|
122
|
+
- Validates against known bank SWIFT codes
|
|
123
|
+
- Country-specific validation (TZ, KE)
|
|
124
|
+
- Automatic uppercase conversion
|
|
125
|
+
- Real bank verification
|
|
126
|
+
|
|
127
|
+
#### `ACCOUNT_NUMBER_VALIDATOR(countryCode?: ISO2CountryCode)`
|
|
128
|
+
|
|
129
|
+
Validates bank account numbers with country-specific formats.
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
import { ACCOUNT_NUMBER_VALIDATOR } from '@temboplus/frontend-react-core';
|
|
133
|
+
|
|
134
|
+
const rules = [{ required: true, validator: ACCOUNT_NUMBER_VALIDATOR('KE') }];
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
**Country-Specific Rules:**
|
|
138
|
+
- **Kenya (KE)**: 10, 12, or 15 alphanumeric characters
|
|
139
|
+
- **Tanzania (TZ)**: 9-19 characters
|
|
140
|
+
- Automatic space removal and normalization
|
|
141
|
+
|
|
142
|
+
#### `AMOUNT_VALIDATOR(options?: AmountValidatorOptions)`
|
|
143
|
+
|
|
144
|
+
Validates monetary amounts with currency-specific constraints.
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
import { AMOUNT_VALIDATOR } from '@temboplus/frontend-react-core';
|
|
148
|
+
|
|
149
|
+
// Basic usage with defaults
|
|
150
|
+
const rules = [{ required: true, validator: AMOUNT_VALIDATOR() }];
|
|
151
|
+
|
|
152
|
+
// Custom configuration
|
|
153
|
+
const rules = [{
|
|
154
|
+
required: true,
|
|
155
|
+
validator: AMOUNT_VALIDATOR({
|
|
156
|
+
currencyCode: 'KES',
|
|
157
|
+
min: 100,
|
|
158
|
+
max: 50000,
|
|
159
|
+
invalidFormatMessage: 'Please enter a valid amount',
|
|
160
|
+
minMessage: 'Minimum amount is 100 KES',
|
|
161
|
+
maxMessage: 'Maximum amount is 50,000 KES'
|
|
162
|
+
})
|
|
163
|
+
}];
|
|
164
|
+
|
|
165
|
+
// Disable constraints
|
|
166
|
+
const rules = [{
|
|
167
|
+
required: true,
|
|
168
|
+
validator: AMOUNT_VALIDATOR({
|
|
169
|
+
currencyCode: 'USD',
|
|
170
|
+
min: null, // No minimum
|
|
171
|
+
max: null, // No maximum
|
|
172
|
+
})
|
|
173
|
+
}];
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**Default Constraints:**
|
|
177
|
+
- **TZS**: Min: 1,000, Max: 1,000,000
|
|
178
|
+
- **KES**: Min: 40, Max: 40,000,000
|
|
179
|
+
- **Other**: Min: 1, Max: 1,000,000
|
|
180
|
+
|
|
181
|
+
**Options:**
|
|
182
|
+
```typescript
|
|
183
|
+
interface AmountValidatorOptions {
|
|
184
|
+
currencyCode?: CurrencyCode; // Default: 'TZS'
|
|
185
|
+
min?: number | null; // Default: currency-specific
|
|
186
|
+
max?: number | null; // Default: currency-specific
|
|
187
|
+
invalidFormatMessage?: string; // Custom error message
|
|
188
|
+
minMessage?: string; // Custom minimum error
|
|
189
|
+
maxMessage?: string; // Custom maximum error
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
**Features:**
|
|
194
|
+
- Supports all currencies from @temboplus/frontend-core
|
|
195
|
+
- Handles comma-separated numbers (1,000.50)
|
|
196
|
+
- Rejects negative amounts
|
|
197
|
+
- Currency-specific formatting
|
|
198
|
+
- Returns normalized numeric format
|
|
199
|
+
|
|
200
|
+
## 🎯 Usage Examples
|
|
201
|
+
|
|
202
|
+
### Complete Form Example
|
|
203
|
+
|
|
204
|
+
```typescript
|
|
205
|
+
import React from 'react';
|
|
206
|
+
import { Form, Input, Button } from 'antd';
|
|
207
|
+
import {
|
|
208
|
+
PHONE_NUMBER_VALIDATOR,
|
|
209
|
+
AMOUNT_VALIDATOR,
|
|
210
|
+
ACCOUNT_NAME_VALIDATOR,
|
|
211
|
+
SWIFT_CODE_VALIDATOR,
|
|
212
|
+
ACCOUNT_NUMBER_VALIDATOR,
|
|
213
|
+
} from '@temboplus/frontend-react-core';
|
|
214
|
+
|
|
215
|
+
const PayoutForm: React.FC = () => {
|
|
216
|
+
const [form] = Form.useForm();
|
|
217
|
+
|
|
218
|
+
const onFinish = (values: any) => {
|
|
219
|
+
console.log('Validated values:', values);
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
return (
|
|
223
|
+
<Form form={form} onFinish={onFinish} layout="vertical">
|
|
224
|
+
<Form.Item
|
|
225
|
+
label="Phone Number"
|
|
226
|
+
name="phoneNumber"
|
|
227
|
+
rules={[{ required: true, validator: PHONE_NUMBER_VALIDATOR('TZ') }]}
|
|
228
|
+
>
|
|
229
|
+
<Input placeholder="+255 712 345 678" />
|
|
230
|
+
</Form.Item>
|
|
231
|
+
|
|
232
|
+
<Form.Item
|
|
233
|
+
label="Amount"
|
|
234
|
+
name="amount"
|
|
235
|
+
rules={[{
|
|
236
|
+
required: true,
|
|
237
|
+
validator: AMOUNT_VALIDATOR({
|
|
238
|
+
currencyCode: 'TZS',
|
|
239
|
+
min: 1000,
|
|
240
|
+
max: 100000
|
|
241
|
+
})
|
|
242
|
+
}]}
|
|
243
|
+
>
|
|
244
|
+
<Input placeholder="10,000" />
|
|
245
|
+
</Form.Item>
|
|
246
|
+
|
|
247
|
+
<Form.Item
|
|
248
|
+
label="Account Name"
|
|
249
|
+
name="accountName"
|
|
250
|
+
rules={[{ required: true, validator: ACCOUNT_NAME_VALIDATOR }]}
|
|
251
|
+
>
|
|
252
|
+
<Input placeholder="John Smith" />
|
|
253
|
+
</Form.Item>
|
|
254
|
+
|
|
255
|
+
<Form.Item
|
|
256
|
+
label="Bank SWIFT Code"
|
|
257
|
+
name="swiftCode"
|
|
258
|
+
rules={[{ required: true, validator: SWIFT_CODE_VALIDATOR('TZ') }]}
|
|
259
|
+
>
|
|
260
|
+
<Input placeholder="CORUTZTZ" />
|
|
261
|
+
</Form.Item>
|
|
262
|
+
|
|
263
|
+
<Form.Item
|
|
264
|
+
label="Account Number"
|
|
265
|
+
name="accountNumber"
|
|
266
|
+
rules={[{ required: true, validator: ACCOUNT_NUMBER_VALIDATOR('TZ') }]}
|
|
267
|
+
>
|
|
268
|
+
<Input placeholder="123456789" />
|
|
269
|
+
</Form.Item>
|
|
270
|
+
|
|
271
|
+
<Form.Item>
|
|
272
|
+
<Button type="primary" htmlType="submit">
|
|
273
|
+
Submit
|
|
274
|
+
</Button>
|
|
275
|
+
</Form.Item>
|
|
276
|
+
</Form>
|
|
277
|
+
);
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
export default PayoutForm;
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### Multi-Country Support
|
|
284
|
+
|
|
285
|
+
```typescript
|
|
286
|
+
import { useState } from 'react';
|
|
287
|
+
import { PHONE_NUMBER_VALIDATOR, AMOUNT_VALIDATOR } from '@temboplus/frontend-react-core';
|
|
288
|
+
|
|
289
|
+
const MultiCountryForm: React.FC = () => {
|
|
290
|
+
const [selectedCountry, setSelectedCountry] = useState<'TZ' | 'KE'>('TZ');
|
|
291
|
+
|
|
292
|
+
const getValidationRules = () => ({
|
|
293
|
+
phoneNumber: [{
|
|
294
|
+
required: true,
|
|
295
|
+
validator: PHONE_NUMBER_VALIDATOR(selectedCountry)
|
|
296
|
+
}],
|
|
297
|
+
amount: [{
|
|
298
|
+
required: true,
|
|
299
|
+
validator: AMOUNT_VALIDATOR({
|
|
300
|
+
currencyCode: selectedCountry === 'TZ' ? 'TZS' : 'KES'
|
|
301
|
+
})
|
|
302
|
+
}]
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
// Rest of component...
|
|
306
|
+
};
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
## 🌍 Supported Countries
|
|
310
|
+
|
|
311
|
+
| Country | Code | Phone | Mobile | Bank | Currency |
|
|
312
|
+
| -------- | ---- | ----- | ------ | ---- | --------------- |
|
|
313
|
+
| Tanzania | TZ | ✅ | ✅ | ✅ | TZS |
|
|
314
|
+
| Kenya | KE | ✅ | ✅ | ✅ | KES |
|
|
315
|
+
| Global | * | ✅ | ❌ | ❌ | 150+ currencies |
|
|
316
|
+
|
|
317
|
+
## 🔧 Error Handling
|
|
318
|
+
|
|
319
|
+
All validators provide clear, user-friendly error messages:
|
|
320
|
+
|
|
321
|
+
```typescript
|
|
322
|
+
// Phone validation errors
|
|
323
|
+
"Invalid Tanzania phone number format. Please enter a valid Tanzania phone number."
|
|
324
|
+
|
|
325
|
+
// Amount validation errors
|
|
326
|
+
"Amount must be at least TSh 1,000. Please enter a higher amount."
|
|
327
|
+
"Negative amounts are not allowed. Please enter a positive amount."
|
|
328
|
+
|
|
329
|
+
// Account name errors
|
|
330
|
+
"Invalid account name. Please enter a valid full name with at least two words."
|
|
331
|
+
|
|
332
|
+
// SWIFT code errors
|
|
333
|
+
"Invalid Tanzania SWIFT code. Please enter a valid Tanzania bank SWIFT/BIC code."
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
## 🏆 Best Practices
|
|
337
|
+
|
|
338
|
+
### 1. Always Specify Country Context
|
|
339
|
+
```typescript
|
|
340
|
+
// ✅ Good - specific country validation
|
|
341
|
+
validator: PHONE_NUMBER_VALIDATOR('TZ')
|
|
342
|
+
|
|
343
|
+
// ❌ Less ideal - generic validation
|
|
344
|
+
validator: PHONE_NUMBER_VALIDATOR()
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
### 2. Combine with Required Rules
|
|
348
|
+
```typescript
|
|
349
|
+
// ✅ Good - explicit required validation
|
|
350
|
+
rules: [
|
|
351
|
+
{ required: true, message: 'Phone number is required' },
|
|
352
|
+
{ validator: PHONE_NUMBER_VALIDATOR('TZ') }
|
|
353
|
+
]
|
|
354
|
+
|
|
355
|
+
// ✅ Also good - validator handles required
|
|
356
|
+
rules: [{ required: true, validator: PHONE_NUMBER_VALIDATOR('TZ') }]
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
### 3. Custom Error Messages
|
|
360
|
+
```typescript
|
|
361
|
+
// ✅ Good - custom business-specific messages
|
|
362
|
+
validator: AMOUNT_VALIDATOR({
|
|
363
|
+
currencyCode: 'TZS',
|
|
364
|
+
min: 5000,
|
|
365
|
+
minMessage: 'Minimum transfer amount is TSh 5,000 for international transfers'
|
|
366
|
+
})
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
### 4. Normalize Return Values
|
|
370
|
+
```typescript
|
|
371
|
+
const onFinish = (values: any) => {
|
|
372
|
+
// Validators return normalized values
|
|
373
|
+
console.log(values.phoneNumber); // "+255712345678" (E.164 format)
|
|
374
|
+
console.log(values.amount); // "10000.00" (normalized number)
|
|
375
|
+
console.log(values.swiftCode); // "CORUTZTZ" (uppercase)
|
|
376
|
+
};
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
## 📄 License
|
|
380
|
+
|
|
381
|
+
Private package for TemboPlus applications.
|
|
382
|
+
|
|
383
|
+
## 🔗 Related Packages
|
|
384
|
+
|
|
385
|
+
- **[@temboplus/frontend-core](https://github.com/TemboPlus-Frontend/temboplus-frontend-core)** - Core business logic and models
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import type { CurrencyCode, ISO2CountryCode } from "@temboplus/frontend-core";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a validator for general phone numbers that validates format and country.
|
|
4
|
+
* Uses PhoneNumberFactory.canCreate() for validation.
|
|
5
|
+
*
|
|
6
|
+
* @param countryCode - The ISO2 country code for validation context
|
|
7
|
+
* @returns Validator function for AntD form rules
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* // In form rules
|
|
11
|
+
* rules: [{ required: true, validator: PHONE_NUMBER_VALIDATOR('TZ') }]
|
|
12
|
+
*/
|
|
13
|
+
export declare const PHONE_NUMBER_VALIDATOR: (countryCode?: ISO2CountryCode) => (rule: any, value: string | null | undefined) => Promise<string | undefined>;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a validator for mobile phone numbers eligible for payout operations.
|
|
16
|
+
* Uses PhoneNumberFactory.checkPayoutEligibility() for validation.
|
|
17
|
+
*
|
|
18
|
+
* @param countryCode - The ISO2 country code for validation context
|
|
19
|
+
* @returns Validator function for AntD form rules
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* // In form rules
|
|
23
|
+
* rules: [{ required: true, validator: MOBILE_PHONE_VALIDATOR('TZ') }]
|
|
24
|
+
*/
|
|
25
|
+
export declare const MOBILE_PHONE_VALIDATOR: (countryCode?: ISO2CountryCode) => (rule: any, value: string | null | undefined) => Promise<string | undefined>;
|
|
26
|
+
/**
|
|
27
|
+
* Validator for account name field using existing BankValidation.
|
|
28
|
+
* Ensures the account name meets the criteria defined in your validation utils.
|
|
29
|
+
*
|
|
30
|
+
* @param rule - The rule object for validation
|
|
31
|
+
* @param value - The value to validate
|
|
32
|
+
* @returns Promise resolving to trimmed account name or rejecting with error
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* // In form rules
|
|
36
|
+
* rules: [{ required: true, validator: ACCOUNT_NAME_VALIDATOR }]
|
|
37
|
+
*/
|
|
38
|
+
export declare const ACCOUNT_NAME_VALIDATOR: (rule: any, value: string | null | undefined) => Promise<string | undefined>;
|
|
39
|
+
/**
|
|
40
|
+
* Creates a validator for SWIFT/BIC codes specific to a country.
|
|
41
|
+
* Uses BankValidation.validateSwiftCode() for validation.
|
|
42
|
+
*
|
|
43
|
+
* @param countryCode - The ISO2 country code for validation context
|
|
44
|
+
* @returns Validator function for AntD form rules
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* // In form rules
|
|
48
|
+
* rules: [{ required: true, validator: SWIFT_CODE_VALIDATOR('TZ') }]
|
|
49
|
+
*/
|
|
50
|
+
export declare const SWIFT_CODE_VALIDATOR: (countryCode?: ISO2CountryCode) => (rule: any, value: string | null | undefined) => Promise<string | undefined>;
|
|
51
|
+
/**
|
|
52
|
+
* Creates a validator for bank account numbers specific to a country.
|
|
53
|
+
* Uses BankValidation.validateAccountNumber() for validation.
|
|
54
|
+
*
|
|
55
|
+
* @param countryCode - The ISO2 country code for validation context
|
|
56
|
+
* @returns Validator function for AntD form rules
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* // In form rules
|
|
60
|
+
* rules: [{ required: true, validator: ACCOUNT_NUMBER_VALIDATOR('KE') }]
|
|
61
|
+
*/
|
|
62
|
+
export declare const ACCOUNT_NUMBER_VALIDATOR: (countryCode?: ISO2CountryCode) => (rule: any, value: string | null | undefined) => Promise<string | undefined>;
|
|
63
|
+
/**
|
|
64
|
+
* Configuration options for amount validation
|
|
65
|
+
*/
|
|
66
|
+
interface AmountValidatorOptions {
|
|
67
|
+
/** Currency code for validation (defaults to 'TZS') */
|
|
68
|
+
currencyCode?: CurrencyCode;
|
|
69
|
+
/** Minimum allowed amount (inclusive). Set to null to disable minimum constraint. */
|
|
70
|
+
min?: number | null;
|
|
71
|
+
/** Maximum allowed amount (inclusive). Set to null to disable maximum constraint. */
|
|
72
|
+
max?: number | null;
|
|
73
|
+
/** Custom error message for invalid format */
|
|
74
|
+
invalidFormatMessage?: string;
|
|
75
|
+
/** Custom error message for minimum validation */
|
|
76
|
+
minMessage?: string;
|
|
77
|
+
/** Custom error message for maximum validation */
|
|
78
|
+
maxMessage?: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Creates a validator for monetary amounts using the Amount class.
|
|
82
|
+
* Validates format, currency, and range constraints with currency-specific defaults.
|
|
83
|
+
* Only allows positive amounts (including zero).
|
|
84
|
+
*
|
|
85
|
+
* **Default Range Constraints by Currency:**
|
|
86
|
+
* - **TZS (Tanzanian Shilling)**: Min: 1,000 TZS, Max: 1,000,000 TZS
|
|
87
|
+
* - **KES (Kenyan Shilling)**: Min: 40 KES, Max: 40,000,000 KES
|
|
88
|
+
* - **Other Currencies**: Min: 1, Max: 1,000,000 (in respective currency units)
|
|
89
|
+
*
|
|
90
|
+
* These defaults are applied only when `min` and/or `max` options are not explicitly provided.
|
|
91
|
+
* You can override these defaults by providing explicit `min` and `max` values in the options.
|
|
92
|
+
* Set `min` or `max` to `null` to completely disable that constraint.
|
|
93
|
+
*
|
|
94
|
+
* @param options - Configuration options for amount validation
|
|
95
|
+
* @returns Validator function for AntD form rules
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* // Basic validation with TZS currency (uses default min: 1,000 TZS, max: 1,000,000 TZS)
|
|
99
|
+
* rules: [{ required: true, validator: AMOUNT_VALIDATOR() }]
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* // Basic validation with KES currency (uses default min: 40 KES, max: 40,000,000 KES)
|
|
103
|
+
* rules: [{ required: true, validator: AMOUNT_VALIDATOR({ currencyCode: 'KES' }) }]
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* // Override default ranges with custom min/max values
|
|
107
|
+
* rules: [{
|
|
108
|
+
* required: true,
|
|
109
|
+
* validator: AMOUNT_VALIDATOR({
|
|
110
|
+
* currencyCode: 'USD',
|
|
111
|
+
* min: 1, // Custom minimum (overrides default)
|
|
112
|
+
* max: 10000, // Custom maximum (overrides default)
|
|
113
|
+
* })
|
|
114
|
+
* }]
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* // Disable range validation by setting min and max to null
|
|
118
|
+
* rules: [{
|
|
119
|
+
* required: true,
|
|
120
|
+
* validator: AMOUNT_VALIDATOR({
|
|
121
|
+
* currencyCode: 'USD',
|
|
122
|
+
* min: null, // No minimum constraint
|
|
123
|
+
* max: null, // No maximum constraint
|
|
124
|
+
* })
|
|
125
|
+
* }]
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* // Disable only minimum constraint, keep maximum
|
|
129
|
+
* rules: [{
|
|
130
|
+
* required: true,
|
|
131
|
+
* validator: AMOUNT_VALIDATOR({
|
|
132
|
+
* currencyCode: 'TZS',
|
|
133
|
+
* min: null, // No minimum constraint
|
|
134
|
+
* // max uses default (1,000,000 TZS)
|
|
135
|
+
* })
|
|
136
|
+
* }]
|
|
137
|
+
*/
|
|
138
|
+
export declare const AMOUNT_VALIDATOR: (options?: AmountValidatorOptions) => (rule: any, value: string | number | null | undefined) => Promise<string | undefined>;
|
|
139
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var e=require("@temboplus/frontend-core");exports.ACCOUNT_NAME_VALIDATOR=(r,o)=>{const n=null==o?void 0:o.toString().trim();if(!n)return r.required?Promise.reject(new Error("Account name is required.")):Promise.resolve(void 0);return e.BankValidation.validateAccountName(n)?Promise.resolve(n):Promise.reject(new Error("Invalid account name. Please enter a valid full name with at least two words (e.g., 'John Smith', 'Anna-Marie Johnson')."))},exports.ACCOUNT_NUMBER_VALIDATOR=r=>(o,n)=>{var t;const i=null==n?void 0:n.toString().trim();if(!i)return o.required?Promise.reject(new Error("Account number is required.")):Promise.resolve(void 0);const a=i.replace(/\s+/g,"");if(r){if(e.BankValidation.validateAccountNumber(a,r))return Promise.resolve(a);const o=null===(t=e.Country.from(r))||void 0===t?void 0:t.name,n=function(e){return{TZ:"Account number should be 9-19 characters long.",KE:"Account number should be 10, 12, or 15 alphanumeric characters."}[e]||"Please enter a valid account number."}(r);return Promise.reject(new Error(`Invalid ${o} account number format. ${n}`))}return e.BankValidation.validateAccountNumberForAnyCountry(a)?Promise.resolve(a):Promise.reject(new Error("Invalid account number format"))},exports.AMOUNT_VALIDATOR=(r={})=>{const{currencyCode:o="TZS",invalidFormatMessage:n,minMessage:t,maxMessage:i}=r,{defaultMin:a,defaultMax:u}=(e=>{switch(e){case"TZS":return{defaultMin:1e3,defaultMax:1e6};case"KES":return{defaultMin:40,defaultMax:4e7};default:return{defaultMin:1,defaultMax:1e6}}})(o),s=void 0!==r.min?r.min:a,l=void 0!==r.max?r.max:u;return(r,a)=>{const u=null==a?void 0:a.toString().trim();if(!u)return r.required?Promise.reject(new Error("Amount is required.")):Promise.resolve(void 0);const m=e.Amount.from(u,o);if(!m)return Promise.reject(new Error(n||'Invalid amount format. Please enter a valid monetary amount (e.g., "1000", "1,234.56").'));const d=m.numericValue;if(m.isNegative())return Promise.reject(new Error("Negative amounts are not allowed. Please enter a positive amount."));if(null!==s&&d<s){const r=e.Amount.from(s,o);return Promise.reject(new Error(t||`Amount must be at least ${(null==r?void 0:r.label)||s}. Please enter a higher amount.`))}if(null!==l&&d>l){const r=e.Amount.from(l,o);return Promise.reject(new Error(i||`Amount must not exceed ${(null==r?void 0:r.label)||l}. Please enter a lower amount.`))}return Promise.resolve(m.formattedNumericValue)}},exports.MOBILE_PHONE_VALIDATOR=r=>(o,n)=>{var t;const i=null==n?void 0:n.toString().trim();if(!i)return o.required?Promise.reject(new Error("Mobile phone number is required.")):Promise.resolve(void 0);const a=e.PhoneNumberFactory.create(i,{defaultCountry:r});if(!a)return Promise.reject(new Error("This phone number is invalid."));if(e.PhoneNumberFactory.checkPayoutEligibility(a))return Promise.resolve((null==a?void 0:a.e164Format)||i);if(r){const o=null===(t=e.Country.from(r))||void 0===t?void 0:t.name;return Promise.reject(new Error(`Invalid ${o} phone number format. Please enter a valid ${o} phone number.`))}return Promise.reject(new Error("This phone number is invalid."))},exports.PHONE_NUMBER_VALIDATOR=r=>(o,n)=>{var t;const i=null==n?void 0:n.toString().trim();if(!i)return o.required?Promise.reject(new Error("Phone number is required.")):Promise.resolve(void 0);if(e.PhoneNumberFactory.canCreate(i,{defaultCountry:r})){const o=e.PhoneNumberFactory.create(i,{defaultCountry:r});return Promise.resolve((null==o?void 0:o.e164Format)||i)}if(r){const o=null===(t=e.Country.from(r))||void 0===t?void 0:t.name;return Promise.reject(new Error(`Invalid ${o} phone number format. Please enter a valid ${o} phone number.`))}return Promise.reject(new Error("This phone number is invalid."))},exports.SWIFT_CODE_VALIDATOR=r=>(o,n)=>{var t;const i=null==n?void 0:n.toString().trim().toUpperCase();if(!i)return o.required?Promise.reject(new Error("SWIFT code is required.")):Promise.resolve(void 0);if(r){if(e.BankValidation.validateSwiftCode(i,r))return Promise.resolve(i);const o=null===(t=e.Country.from(r))||void 0===t?void 0:t.name;return Promise.reject(new Error(`Invalid ${o} SWIFT code. Please enter a valid ${o} bank SWIFT/BIC code.`))}return e.BankValidation.validateSwiftCodeForAnyCountry(i)?Promise.resolve(i):Promise.reject(new Error("Invalid SWIFT code. Please enter a valid supported bank SWIFT/BIC code."))};
|
|
2
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/antd-validators.ts"],"sourcesContent":[null],"names":["rule","value","accountNameString","toString","trim","required","Promise","reject","Error","resolve","undefined","BankValidation","validateAccountName","countryCode","accountNumberString","normalizedAccountNumber","replace","validateAccountNumber","countryName","_a","Country","from","name","formatHint","TZ","KE","getAccountNumberFormatHint","validateAccountNumberForAnyCountry","options","currencyCode","invalidFormatMessage","minMessage","maxMessage","defaultMin","defaultMax","currency","getDefaultConstraints","min","max","amountString","amountInstance","Amount","numericValue","isNegative","minAmount","label","maxAmount","formattedNumericValue","phoneString","phoneInstance","PhoneNumberFactory","create","defaultCountry","checkPayoutEligibility","e164Format","canCreate","swiftCodeString","toUpperCase","validateSwiftCode","validateSwiftCodeForAnyCountry"],"mappings":"sFAiIsC,CACpCA,EACAC,KAEA,MAAMC,EAAoBD,aAAK,EAALA,EAAOE,WAAWC,OAG5C,IAAKF,EACH,OAAIF,EAAKK,SACAC,QAAQC,OAAO,IAAIC,MAAM,8BAE3BF,QAAQG,aAAQC,GAKzB,OAFgBC,EAAAA,eAAeC,oBAAoBV,GAG1CI,QAAQG,QAAQP,GAGlBI,QAAQC,OACb,IAAIC,MACF,+JA+EmCK,GAChC,CACLb,EACAC,WAEA,MAAMa,EAAsBb,aAAK,EAALA,EAAOE,WAAWC,OAG9C,IAAKU,EACH,OAAId,EAAKK,SACAC,QAAQC,OAAO,IAAIC,MAAM,gCAE3BF,QAAQG,aAAQC,GAIzB,MAAMK,EAAuCD,EAwNlCE,QAAQ,OAAQ,IAtN3B,GAAIH,EAAa,CAMf,GALgBF,EAAAA,eAAeM,sBAC7BF,EACAF,GAIA,OAAOP,QAAQG,QAAQM,GAGzB,MAAMG,EAAuC,QAAzBC,EAAAC,EAAAA,QAAQC,KAAKR,UAAY,IAAAM,OAAA,EAAAA,EAAEG,KACzCC,EAoNZ,SAAoCV,GAOlC,MAN4C,CAC1CW,GAAI,iDACJC,GAAI,mEAIaZ,IAAgB,sCACrC,CA5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B,QAAQC,OACb,IAAIC,MACF,WAAWU,+CAAyDA,oBAK1E,OAAOZ,QAAQC,OAAO,IAAIC,MAAM,gEAgHCK,GAC5B,CACLb,EACAC,WAEA,MAAMuD,EAAkBvD,aAAK,EAALA,EAAOE,WAAWC,OAAOqD,cAGjD,IAAKD,EACH,OAAIxD,EAAKK,SACAC,QAAQC,OAAO,IAAIC,MAAM,4BAE3BF,QAAQG,aAAQC,GAGzB,GAAIG,EAAa,CAMf,GALgBF,EAAAA,eAAe+C,kBAC7BF,EACA3C,GAIA,OAAOP,QAAQG,QAAQ+C,GAGzB,MAAMtC,EAAuC,QAAzBC,EAAAC,EAAAA,QAAQC,KAAKR,UAAY,IAAAM,OAAA,EAAAA,EAAEG,KAC/C,OAAOhB,QAAQC,OACb,IAAIC,MACF,WAAWU,sCAAgDA,2BAQjE,OAFEP,EAAAA,eAAegD,+BAA+BH,GAGvClD,QAAQG,QAAQ+C,GAGlBlD,QAAQC,OACb,IAAIC,MACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./antd-validators";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{PhoneNumberFactory as e,Country as r,BankValidation as o,Amount as n}from"@temboplus/frontend-core";const t=o=>(n,t)=>{var i;const a=null==t?void 0:t.toString().trim();if(!a)return n.required?Promise.reject(new Error("Phone number is required.")):Promise.resolve(void 0);if(e.canCreate(a,{defaultCountry:o})){const r=e.create(a,{defaultCountry:o});return Promise.resolve((null==r?void 0:r.e164Format)||a)}if(o){const e=null===(i=r.from(o))||void 0===i?void 0:i.name;return Promise.reject(new Error(`Invalid ${e} phone number format. Please enter a valid ${e} phone number.`))}return Promise.reject(new Error("This phone number is invalid."))},i=o=>(n,t)=>{var i;const a=null==t?void 0:t.toString().trim();if(!a)return n.required?Promise.reject(new Error("Mobile phone number is required.")):Promise.resolve(void 0);const u=e.create(a,{defaultCountry:o});if(!u)return Promise.reject(new Error("This phone number is invalid."));if(e.checkPayoutEligibility(u))return Promise.resolve((null==u?void 0:u.e164Format)||a);if(o){const e=null===(i=r.from(o))||void 0===i?void 0:i.name;return Promise.reject(new Error(`Invalid ${e} phone number format. Please enter a valid ${e} phone number.`))}return Promise.reject(new Error("This phone number is invalid."))},a=(e,r)=>{const n=null==r?void 0:r.toString().trim();if(!n)return e.required?Promise.reject(new Error("Account name is required.")):Promise.resolve(void 0);return o.validateAccountName(n)?Promise.resolve(n):Promise.reject(new Error("Invalid account name. Please enter a valid full name with at least two words (e.g., 'John Smith', 'Anna-Marie Johnson')."))},u=e=>(n,t)=>{var i;const a=null==t?void 0:t.toString().trim().toUpperCase();if(!a)return n.required?Promise.reject(new Error("SWIFT code is required.")):Promise.resolve(void 0);if(e){if(o.validateSwiftCode(a,e))return Promise.resolve(a);const n=null===(i=r.from(e))||void 0===i?void 0:i.name;return Promise.reject(new Error(`Invalid ${n} SWIFT code. Please enter a valid ${n} bank SWIFT/BIC code.`))}return o.validateSwiftCodeForAnyCountry(a)?Promise.resolve(a):Promise.reject(new Error("Invalid SWIFT code. Please enter a valid supported bank SWIFT/BIC code."))},s=e=>(n,t)=>{var i;const a=null==t?void 0:t.toString().trim();if(!a)return n.required?Promise.reject(new Error("Account number is required.")):Promise.resolve(void 0);const u=a.replace(/\s+/g,"");if(e){if(o.validateAccountNumber(u,e))return Promise.resolve(u);const n=null===(i=r.from(e))||void 0===i?void 0:i.name,t=function(e){return{TZ:"Account number should be 9-19 characters long.",KE:"Account number should be 10, 12, or 15 alphanumeric characters."}[e]||"Please enter a valid account number."}(e);return Promise.reject(new Error(`Invalid ${n} account number format. ${t}`))}return o.validateAccountNumberForAnyCountry(u)?Promise.resolve(u):Promise.reject(new Error("Invalid account number format"))},l=(e={})=>{const{currencyCode:r="TZS",invalidFormatMessage:o,minMessage:t,maxMessage:i}=e,{defaultMin:a,defaultMax:u}=(e=>{switch(e){case"TZS":return{defaultMin:1e3,defaultMax:1e6};case"KES":return{defaultMin:40,defaultMax:4e7};default:return{defaultMin:1,defaultMax:1e6}}})(r),s=void 0!==e.min?e.min:a,l=void 0!==e.max?e.max:u;return(e,a)=>{const u=null==a?void 0:a.toString().trim();if(!u)return e.required?Promise.reject(new Error("Amount is required.")):Promise.resolve(void 0);const m=n.from(u,r);if(!m)return Promise.reject(new Error(o||'Invalid amount format. Please enter a valid monetary amount (e.g., "1000", "1,234.56").'));const d=m.numericValue;if(m.isNegative())return Promise.reject(new Error("Negative amounts are not allowed. Please enter a positive amount."));if(null!==s&&d<s){const e=n.from(s,r);return Promise.reject(new Error(t||`Amount must be at least ${(null==e?void 0:e.label)||s}. Please enter a higher amount.`))}if(null!==l&&d>l){const e=n.from(l,r);return Promise.reject(new Error(i||`Amount must not exceed ${(null==e?void 0:e.label)||l}. Please enter a lower amount.`))}return Promise.resolve(m.formattedNumericValue)}};export{a as ACCOUNT_NAME_VALIDATOR,s as ACCOUNT_NUMBER_VALIDATOR,l as AMOUNT_VALIDATOR,i as MOBILE_PHONE_VALIDATOR,t as PHONE_NUMBER_VALIDATOR,u as SWIFT_CODE_VALIDATOR};
|
|
2
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/antd-validators.ts"],"sourcesContent":[null],"names":["PHONE_NUMBER_VALIDATOR","countryCode","rule","value","phoneString","toString","trim","required","Promise","reject","Error","resolve","undefined","PhoneNumberFactory","canCreate","defaultCountry","phoneInstance","create","e164Format","countryName","_a","Country","from","name","MOBILE_PHONE_VALIDATOR","checkPayoutEligibility","ACCOUNT_NAME_VALIDATOR","accountNameString","BankValidation","validateAccountName","SWIFT_CODE_VALIDATOR","swiftCodeString","toUpperCase","validateSwiftCode","validateSwiftCodeForAnyCountry","ACCOUNT_NUMBER_VALIDATOR","accountNumberString","normalizedAccountNumber","replace","validateAccountNumber","formatHint","TZ","KE","getAccountNumberFormatHint","validateAccountNumberForAnyCountry","AMOUNT_VALIDATOR","options","currencyCode","invalidFormatMessage","minMessage","maxMessage","defaultMin","defaultMax","currency","getDefaultConstraints","min","max","amountString","amountInstance","Amount","numericValue","isNegative","minAmount","label","maxAmount","formattedNumericValue"],"mappings":"2GAqBO,MAAMA,EAA0BC,GAC9B,CACLC,EACAC,WAEA,MAAMC,EAAcD,aAAK,EAALA,EAAOE,WAAWC,OAGtC,IAAKF,EACH,OAAIF,EAAKK,SACAC,QAAQC,OAAO,IAAIC,MAAM,8BAE3BF,QAAQG,aAAQC,GAOzB,GAJgBC,EAAmBC,UAAUV,EAAa,CACxDW,eAAgBd,IAGL,CAEX,MAAMe,EAAgBH,EAAmBI,OAAOb,EAAa,CAC3DW,eAAgBd,IAElB,OAAOO,QAAQG,SAAQK,aAAa,EAAbA,EAAeE,aAAcd,GAGtD,GAAIH,EAAa,CACf,MAAMkB,EAAuC,QAAzBC,EAAAC,EAAQC,KAAKrB,UAAY,IAAAmB,OAAA,EAAAA,EAAEG,KAC/C,OAAOf,QAAQC,OACb,IAAIC,MACF,WAAWS,+CAAyDA,oBAK1E,OAAOX,QAAQC,OAAO,IAAIC,MAAM,mCAevBc,EAA0BvB,GAC9B,CACLC,EACAC,WAEA,MAAMC,EAAcD,aAAK,EAALA,EAAOE,WAAWC,OAGtC,IAAKF,EACH,OAAIF,EAAKK,SACAC,QAAQC,OAAO,IAAIC,MAAM,qCAE3BF,QAAQG,aAAQC,GAGzB,MAAMI,EAAgBH,EAAmBI,OAAOb,EAAa,CAC3DW,eAAgBd,IAGlB,IAAKe,EACH,OAAOR,QAAQC,OAAO,IAAIC,MAAM,kCAMlC,GAFEG,EAAmBY,uBAAuBT,GAG1C,OAAOR,QAAQG,SAAQK,aAAa,EAAbA,EAAeE,aAAcd,GAGtD,GAAIH,EAAa,CACf,MAAMkB,EAAuC,QAAzBC,EAAAC,EAAQC,KAAKrB,UAAY,IAAAmB,OAAA,EAAAA,EAAEG,KAC/C,OAAOf,QAAQC,OACb,IAAIC,MACF,WAAWS,+CAAyDA,oBAK1E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B,GAAY,OAARC,GAAgBI,EAAeJ,EAAK,CACtC,MAAMQ,EAAYL,EAAOrC,KAAKkC,EAAKT,GACnC,OAAOvC,QAAQC,OACb,IAAIC,MACFwC,GACE,2BACEc,aAAS,EAATA,EAAWD,QAASP,oCAO9B,OAAOhD,QAAQG,QAAQ+C,EAAeO"}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@temboplus/frontend-react-core",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"repository": "https://github.com/TemboPlus-Frontend/temboplus-frontend-react-core",
|
|
5
|
+
"author": "Okello Gerald",
|
|
6
|
+
"license": "ISC",
|
|
7
|
+
"description": "A React UI library for TemboPlus applications, providing reusable components, validators, and utilities for building consistent react applications across the platform.",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "rollup -c rollup.config.js --configTsconfig tsconfig.build.json",
|
|
10
|
+
"prepare": "npm run build",
|
|
11
|
+
"dev": "npm run build -- --watch",
|
|
12
|
+
"test": "vitest",
|
|
13
|
+
"coverage": "vitest run --coverage"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "./dist/index.cjs.js",
|
|
17
|
+
"module": "./dist/index.esm.js",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"import": "./dist/index.esm.js",
|
|
22
|
+
"require": "./dist/index.cjs.js",
|
|
23
|
+
"types": "./dist/index.d.ts"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist"
|
|
28
|
+
],
|
|
29
|
+
"keywords": [],
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@rollup/plugin-alias": "^5.1.1",
|
|
32
|
+
"@rollup/plugin-commonjs": "^28.0.6",
|
|
33
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
34
|
+
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
35
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
36
|
+
"@rollup/plugin-typescript": "^12.1.3",
|
|
37
|
+
"@types/react": "^19.1.8",
|
|
38
|
+
"@types/react-dom": "^19.1.6",
|
|
39
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
40
|
+
"antd": "5.26.2",
|
|
41
|
+
"autoprefixer": "^10.4.21",
|
|
42
|
+
"less": "^4.3.0",
|
|
43
|
+
"postcss": "^8.5.6",
|
|
44
|
+
"rollup": "^4.44.1",
|
|
45
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
46
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
47
|
+
"rollup-plugin-typescript2": "^0.36.0",
|
|
48
|
+
"typescript": "^5.8.3",
|
|
49
|
+
"vitest": "^3.2.4"
|
|
50
|
+
},
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"@temboplus/frontend-core": "file:../npm.frontend-core",
|
|
53
|
+
"antd": "^5.26.2",
|
|
54
|
+
"react": "^19.1.0",
|
|
55
|
+
"react-dom": "^19.1.0"
|
|
56
|
+
}
|
|
57
|
+
}
|