Skip to content

Commit

Permalink
✨ [#2] Add currency component
Browse files Browse the repository at this point in the history
  • Loading branch information
Viicos committed Oct 26, 2023
1 parent dab8ef2 commit 5079107
Showing 1 changed file with 200 additions and 0 deletions.
200 changes: 200 additions & 0 deletions src/formio/components/currency.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
import {InputComponentSchema, MultipleCapable, PrefillConfig} from '..';

type Validator = 'required' | 'maxLength' | 'pattern';
type TranslatableKeys = 'label' | 'description' | 'tooltip' | 'defaultValue' | 'placeholder';
type AvailableCurrencies =
| 'USD'
| 'EUR'
| 'GBP'
| 'AUD'
| 'AFN'
| 'ALL'
| 'DZD'
| 'AOA'
| 'XCD'
| 'ARS'
| 'AMD'
| 'AWG'
| 'AZN'
| 'BSD'
| 'BHD'
| 'BDT'
| 'BBD'
| 'BYN'
| 'BZD'
| 'XOF'
| 'BMD'
| 'INR'
| 'BTN'
| 'BOB'
| 'BOV'
| 'BAM'
| 'BWP'
| 'NOK'
| 'BRL'
| 'BND'
| 'BGN'
| 'BIF'
| 'CVE'
| 'KHR'
| 'XAF'
| 'CAD'
| 'KYD'
| 'CLP'
| 'CLF'
| 'CNY'
| 'COP'
| 'COU'
| 'KMF'
| 'CDF'
| 'NZD'
| 'CRC'
| 'HRK'
| 'CUP'
| 'CUC'
| 'ANG'
| 'CZK'
| 'DKK'
| 'DJF'
| 'DOP'
| 'EGP'
| 'SVC'
| 'ERN'
| 'ETB'
| 'FKP'
| 'FJD'
| 'XPF'
| 'GMD'
| 'GEL'
| 'GHS'
| 'GIP'
| 'GTQ'
| 'GNF'
| 'GYD'
| 'HTG'
| 'HNL'
| 'HKD'
| 'HUF'
| 'ISK'
| 'INR'
| 'IDR'
| 'XDR'
| 'IRR'
| 'IQD'
| 'ILS'
| 'JMD'
| 'JPY'
| 'JOD'
| 'KZT'
| 'KES'
| 'KPW'
| 'KRW'
| 'KWD'
| 'KGS'
| 'LAK'
| 'LBP'
| 'LSL'
| 'ZAR'
| 'LRD'
| 'LYD'
| 'CHF'
| 'MOP'
| 'MKD'
| 'MGA'
| 'MWK'
| 'MYR'
| 'MVR'
| 'MRU'
| 'MUR'
| 'XUA'
| 'MXN'
| 'MXV'
| 'MDL'
| 'MNT'
| 'MAD'
| 'MZN'
| 'MMK'
| 'NAD'
| 'NPR'
| 'NIO'
| 'NGN'
| 'OMR'
| 'PKR'
| 'PAB'
| 'PGK'
| 'PYG'
| 'PEN'
| 'PHP'
| 'PLN'
| 'QAR'
| 'RON'
| 'RUB'
| 'RWF'
| 'SHP'
| 'WST'
| 'STN'
| 'SAR'
| 'RSD'
| 'SCR'
| 'SLL'
| 'SGD'
| 'XSU'
| 'SBD'
| 'SOS'
| 'SSP'
| 'LKR'
| 'SDG'
| 'SRD'
| 'SZL'
| 'SEK'
| 'CHE'
| 'CHW'
| 'SYP'
| 'TWD'
| 'TJS'
| 'TZS'
| 'THB'
| 'TOP'
| 'TTD'
| 'TND'
| 'TRY'
| 'TMT'
| 'UGX'
| 'UAH'
| 'AED'
| 'USN'
| 'UYU'
| 'UYI'
| 'UYW'
| 'UZS'
| 'VUV'
| 'VES'
| 'VND'
| 'YER'
| 'ZMW'
| 'ZWL';

export type CurrencyInputSchema = InputComponentSchema<number, Validator, TranslatableKeys>;

/**
* @group Form.io components
* @category Base types
*/
export interface BaseCurrencyComponentSchema
extends Omit<CurrencyInputSchema, 'hideLabel'>,
PrefillConfig {
type: 'currency';
// additional properties
currency?: AvailableCurrencies;
decimalLimit?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
allowNegative?: boolean;
// re-add
prefix?: string;
suffix?: string;
}

/**
* @group Form.io components
* @category Concrete types
*/
export type CurrencyComponentSchema = MultipleCapable<BaseCurrencyComponentSchema>;

0 comments on commit 5079107

Please sign in to comment.