From 50791070e6517046b687bd4dfe77ab951d3e9276 Mon Sep 17 00:00:00 2001 From: Viicos <65306057+Viicos@users.noreply.github.com> Date: Thu, 26 Oct 2023 13:58:13 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20[#2]=20Add=20`currency`=20component?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/formio/components/currency.ts | 200 ++++++++++++++++++++++++++++++ 1 file changed, 200 insertions(+) create mode 100644 src/formio/components/currency.ts diff --git a/src/formio/components/currency.ts b/src/formio/components/currency.ts new file mode 100644 index 0000000..f3323a6 --- /dev/null +++ b/src/formio/components/currency.ts @@ -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; + +/** + * @group Form.io components + * @category Base types + */ +export interface BaseCurrencyComponentSchema + extends Omit, + 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;