@arkyn/templates 3.0.1-beta.99 โ†’ 3.0.2

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/LICENSE.txt ADDED
@@ -0,0 +1,207 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 - Arkyn | Lucas Eduardo Gonรงalves
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
203
+
204
+ ---
205
+
206
+ For more information or to contribute, visit:
207
+ https://github.com/Lucas-Eduardo-Goncalves
package/README.md CHANGED
@@ -1,22 +1,35 @@
1
1
  # @arkyn/templates
2
2
 
3
- Ready-to-use data templates and constants for international and Brazilian applications. Provides comprehensive country data, Brazilian states, currency information, and locale configurations to accelerate your development workflow.
3
+ Ready-to-use static data for international and Brazilian applications โ€” country lists, phone masks, Brazilian states, and currency/locale metadata โ€” so you don't have to source and maintain this data yourself.
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/@arkyn/templates.svg)](https://www.npmjs.com/package/@arkyn/templates)
6
6
  [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
7
7
  [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)
8
8
 
9
+ ## ๐ŸŽฏ What it solves
10
+
11
+ Building phone inputs, address forms, or currency formatters usually means sourcing and hand-maintaining reference data: every country's dialing code and phone mask, all Brazilian states, and locale/currency pairs for `Intl.NumberFormat`. `@arkyn/templates` ships that data as typed, ready-to-import constants, so `@arkyn/components` (phone/currency inputs, address selects) and `@arkyn/shared` (currency formatting) โ€” or your own app โ€” can consume it directly without any setup, network calls, or extra dependencies.
12
+
9
13
  ## โœจ Features
10
14
 
11
- - ๐ŸŒ **Global Countries Data** - Complete list of 195+ countries with flags, codes, and phone masks
12
- - ๐Ÿ‡ง๐Ÿ‡ท **Brazilian States** - All 26 states plus Federal District with codes and names
13
- - ๐Ÿ’ฑ **Currency Information** - Country-specific currency data and formatting rules
14
- - ๐Ÿ“Š **Locale Configurations** - Maximum fraction digits for different currencies
15
- - ๐ŸŽฏ **TypeScript Support** - Fully typed data structures
16
- - ๐Ÿ“ฑ **Phone Number Masks** - Country-specific phone formatting patterns
15
+ - ๐ŸŒ **Countries Data** - 245 countries with name, ISO code, dialing code, flag URL, and phone input mask
16
+ - ๐Ÿ‡ง๐Ÿ‡ท **Brazilian States** - All 26 states plus the Federal District, as `{ label, value }` pairs
17
+ - ๐Ÿ’ฑ **Country Currencies** - Currency code โ†’ locale/currency pairs ready for `Intl.NumberFormat`
18
+ - ๐Ÿ“Š **Fraction Digits Constant** - The default number of decimal places used across the Arkyn ecosystem
19
+ - ๐ŸŽฏ **Fully Typed** - Every export ships its own TypeScript type
20
+ - ๐Ÿ“ฆ **Zero Runtime Dependencies** - Pure static data, no peer dependencies required
21
+
22
+ ## ๐Ÿ“‹ Prerequisites
23
+
24
+ - Node.js `>=18.0.0`
25
+ - Bun `>=1.0.0` (only if building/developing the monorepo itself)
26
+
27
+ This package has no runtime dependencies and no peer dependencies โ€” it can be installed standalone.
17
28
 
18
29
  ## ๐Ÿ“ฆ Installation
19
30
 
31
+ > **ESM only.** This package ships as native ES modules with no CommonJS build โ€” use `import`, not `require()`.
32
+
20
33
  ```bash
21
34
  npm install @arkyn/templates
22
35
  ```
@@ -28,367 +41,113 @@ import {
28
41
  countries,
29
42
  brazilianStates,
30
43
  countryCurrencies,
44
+ maximumFractionDigits,
31
45
  } from "@arkyn/templates";
32
46
 
33
47
  // Find a specific country
34
48
  const brazil = countries.find((country) => country.iso === "BR");
35
49
  console.log(brazil);
36
50
  // {
37
- // name: "Brazil",
51
+ // name: "Brasil",
38
52
  // code: "+55",
39
- // prefix: null,
40
53
  // iso: "BR",
41
54
  // flag: "https://cdn.kcak11.com/CountryFlags/countries/br.svg",
42
- // mask: "(__) _____-____"
55
+ // mask: ["(__) _____-____", "(__) ____-____"]
43
56
  // }
44
57
 
45
- // Get Brazilian states
46
- const saoPaulo = brazilianStates.find((state) => state.code === "SP");
47
- console.log(saoPaulo); // { code: 'SP', name: 'Sรฃo Paulo' }
58
+ // Get a Brazilian state
59
+ const saoPaulo = brazilianStates.find((state) => state.value === "SP");
60
+ console.log(saoPaulo); // { label: "Sรฃo Paulo", value: "SP" }
61
+
62
+ // Get locale/currency info for Intl.NumberFormat
63
+ console.log(countryCurrencies.BRL); // { countryLanguage: "pt-BR", countryCurrency: "BRL" }
48
64
 
49
- // Access currency data
50
- console.log(countryCurrencies.USD); // Currency information for USD
65
+ // Default decimal places used across Arkyn's currency formatting
66
+ console.log(maximumFractionDigits); // 2
51
67
  ```
52
68
 
53
- ## ๐Ÿ“‹ API Reference
69
+ ## ๐Ÿ“– API Reference
54
70
 
55
- ### ๐ŸŒ Countries Data
71
+ ### ๐ŸŒ `countries`
56
72
 
57
- The `countries` array contains comprehensive data for all world countries:
73
+ An array of 245 countries, typed as `CountryType[]`:
58
74
 
59
75
  ```typescript
60
- interface Country {
61
- name: string; // Country name in English
62
- code: string; // International dialing code (e.g., "+55")
63
- prefix: string | null; // Additional prefix for specific regions
64
- iso: string; // ISO 3166-1 alpha-2 country code
65
- flag: string; // URL to country flag SVG
66
- mask: string; // Phone number formatting mask
67
- }
76
+ type CountryType = {
77
+ name: string; // Country name
78
+ code: string; // International dialing code (e.g. "+55")
79
+ iso: string; // ISO 3166-1 alpha-2 code (e.g. "BR")
80
+ flag: string; // URL to an SVG flag icon
81
+ mask: string | string[]; // Phone input mask(s); some countries have more than one valid mask
82
+ };
68
83
  ```
69
84
 
70
- #### Usage Examples
71
-
72
85
  ```typescript
73
- import { countries } from "@arkyn/templates";
74
-
75
- // Get all countries
76
- console.log(countries.length); // 195+
86
+ import { countries, type CountryType } from "@arkyn/templates";
77
87
 
78
- // Find by ISO code
79
88
  const usa = countries.find((country) => country.iso === "US");
80
-
81
- // Find by country code
82
- const brazilianCountries = countries.filter(
83
- (country) => country.code === "+55"
84
- );
85
-
86
- // Get all European countries (you'll need additional logic)
87
- const europeanCountries = countries.filter((country) =>
88
- ["FR", "DE", "IT", "ES", "PT"].includes(country.iso)
89
- );
90
-
91
- // Create a phone input selector
92
- function CountrySelector() {
93
- return (
94
- <select>
95
- {countries.map((country) => (
96
- <option key={country.iso} value={country.code}>
97
- <img src={country.flag} alt={country.name} />
98
- {country.name} ({country.code})
99
- </option>
100
- ))}
101
- </select>
102
- );
103
- }
89
+ const brazilianOptions = countries.filter((country) => country.code === "+55");
104
90
  ```
105
91
 
106
- ### ๐Ÿ‡ง๐Ÿ‡ท Brazilian States
92
+ Used internally by `@arkyn/components`' `PhoneInput` to render the country selector and apply the correct input mask.
107
93
 
108
- The `brazilianStates` array contains all Brazilian states and the Federal District:
94
+ ### ๐Ÿ‡ง๐Ÿ‡ท `brazilianStates`
95
+
96
+ An array of the 26 Brazilian states plus the Federal District:
109
97
 
110
98
  ```typescript
111
- interface BrazilianState {
112
- code: string; // Two-letter state code (e.g., "SP", "RJ")
113
- name: string; // State name in Portuguese (e.g., "Sรฃo Paulo")
114
- }
99
+ type BrazilianState = { label: string; value: string };
115
100
  ```
116
101
 
117
- #### Usage Examples
118
-
119
102
  ```typescript
120
103
  import { brazilianStates } from "@arkyn/templates";
121
104
 
122
- // Get all states
123
- console.log(brazilianStates.length); // 27 (26 states + Federal District)
124
-
125
- // Find specific state
126
- const rioDeJaneiro = brazilianStates.find((state) => state.code === "RJ");
127
- console.log(rioDeJaneiro); // { code: 'RJ', name: 'Rio de Janeiro' }
128
-
129
- // Create a state selector
130
- function StateSelector() {
131
- return (
132
- <select>
133
- {brazilianStates.map((state) => (
134
- <option key={state.code} value={state.code}>
135
- {state.name}
136
- </option>
137
- ))}
138
- </select>
139
- );
140
- }
141
-
142
- // Validate state code
143
- function isValidState(stateCode: string): boolean {
144
- return brazilianStates.some((state) => state.code === stateCode);
145
- }
105
+ console.log(brazilianStates.length); // 27
106
+ const rio = brazilianStates.find((state) => state.value === "RJ");
107
+ // { label: "Rio de Janeiro", value: "RJ" }
146
108
  ```
147
109
 
148
- ### ๐Ÿ’ฑ Country Currencies
110
+ The `{ label, value }` shape maps directly onto `@arkyn/components`' `Select` / `MultiSelect` `options` prop.
111
+
112
+ ### ๐Ÿ’ฑ `countryCurrencies`
149
113
 
150
- The `countryCurrencies` object provides currency information mapped by currency codes:
114
+ A record keyed by ISO 4217 currency code, mapping each currency to the locale/currency pair `Intl.NumberFormat` expects:
151
115
 
152
116
  ```typescript
153
- interface CountryCurrency {
154
- [currencyCode: string]: {
155
- symbol: string;
156
- name: string;
157
- countries: string[];
158
- };
159
- }
117
+ type CountryCurrencies = Record<
118
+ string,
119
+ { countryLanguage: string; countryCurrency: string }
120
+ >;
160
121
  ```
161
122
 
162
- #### Usage Examples
163
-
164
123
  ```typescript
165
124
  import { countryCurrencies } from "@arkyn/templates";
166
125
 
167
- // Get USD information
168
- console.log(countryCurrencies.USD);
169
- // {
170
- // symbol: '$',
171
- // name: 'US Dollar',
172
- // countries: ['US', 'EC', 'SV', ...]
173
- // }
174
-
175
- // Get Brazilian Real
176
- console.log(countryCurrencies.BRL);
177
- // {
178
- // symbol: 'R$',
179
- // name: 'Brazilian Real',
180
- // countries: ['BR']
181
- // }
182
-
183
- // Find all countries using EUR
184
- const euroCountries = countryCurrencies.EUR.countries;
185
-
186
- // Get currency by country
187
- function getCurrencyByCountry(countryCode: string): string | null {
188
- for (const [currency, data] of Object.entries(countryCurrencies)) {
189
- if (data.countries.includes(countryCode)) {
190
- return currency;
191
- }
192
- }
193
- return null;
194
- }
126
+ const { countryLanguage, countryCurrency } = countryCurrencies.BRL;
127
+ // { countryLanguage: "pt-BR", countryCurrency: "BRL" }
195
128
 
196
- const brazilCurrency = getCurrencyByCountry("BR"); // 'BRL'
129
+ new Intl.NumberFormat(countryLanguage, {
130
+ style: "currency",
131
+ currency: countryCurrency,
132
+ }).format(1234.56); // "R$ 1.234,56"
197
133
  ```
198
134
 
199
- ### ๐Ÿ“Š Maximum Fraction Digits
200
-
201
- The `maximumFractionDigits` object provides locale-specific decimal place configurations:
135
+ This is exactly what `@arkyn/shared`'s `formatToCurrency` uses under the hood to resolve a currency code into a locale-aware formatter.
202
136
 
203
- ```typescript
204
- interface MaximumFractionDigits {
205
- [locale: string]: number;
206
- }
207
- ```
137
+ ### ๐Ÿ“Š `maximumFractionDigits`
208
138
 
209
- #### Usage Examples
139
+ A single constant (`2`) representing the default number of decimal places used for currency values across the Arkyn ecosystem.
210
140
 
211
141
  ```typescript
212
142
  import { maximumFractionDigits } from "@arkyn/templates";
213
143
 
214
- // Get maximum decimal places for different locales
215
- console.log(maximumFractionDigits["pt-BR"]); // 2 (for Brazilian Real)
216
- console.log(maximumFractionDigits["en-US"]); // 2 (for US Dollar)
217
- console.log(maximumFractionDigits["ja-JP"]); // 0 (for Japanese Yen)
218
-
219
- // Format currency with correct decimal places
220
- function formatCurrency(amount: number, locale: string): string {
221
- const fractionDigits = maximumFractionDigits[locale] || 2;
222
-
223
- return new Intl.NumberFormat(locale, {
224
- style: "currency",
225
- currency: getCurrencyForLocale(locale),
226
- maximumFractionDigits: fractionDigits,
227
- minimumFractionDigits: fractionDigits,
228
- }).format(amount);
229
- }
144
+ console.log(maximumFractionDigits); // 2
230
145
  ```
231
146
 
232
- ## ๐Ÿ”ง Advanced Usage
147
+ ## ๐Ÿ“š Documentation
233
148
 
234
- ### International Phone Input
235
-
236
- ```typescript
237
- import { countries } from "@arkyn/templates";
238
-
239
- function InternationalPhoneInput() {
240
- const [selectedCountry, setSelectedCountry] = useState(countries[0]);
241
- const [phoneNumber, setPhoneNumber] = useState("");
242
-
243
- const formatPhoneNumber = (number: string) => {
244
- let formatted = number;
245
- const mask = selectedCountry.mask;
246
-
247
- // Apply mask logic here
248
- return formatted;
249
- };
250
-
251
- return (
252
- <div className="phone-input">
253
- <select
254
- value={selectedCountry.iso}
255
- onChange={(e) => {
256
- const country = countries.find((c) => c.iso === e.target.value);
257
- setSelectedCountry(country);
258
- }}
259
- >
260
- {countries.map((country) => (
261
- <option key={country.iso} value={country.iso}>
262
- <img src={country.flag} alt="" />
263
- {country.name} ({country.code})
264
- </option>
265
- ))}
266
- </select>
267
-
268
- <input
269
- type="tel"
270
- value={phoneNumber}
271
- onChange={(e) => setPhoneNumber(formatPhoneNumber(e.target.value))}
272
- placeholder={selectedCountry.mask.replace(/_/g, "0")}
273
- />
274
- </div>
275
- );
276
- }
277
- ```
278
-
279
- ### Multi-Currency Calculator
280
-
281
- ```typescript
282
- import { countryCurrencies, maximumFractionDigits } from "@arkyn/templates";
283
-
284
- class CurrencyCalculator {
285
- private exchangeRates: Record<string, number> = {};
286
-
287
- setExchangeRates(rates: Record<string, number>) {
288
- this.exchangeRates = rates;
289
- }
290
-
291
- convert(amount: number, fromCurrency: string, toCurrency: string): number {
292
- if (!this.exchangeRates[fromCurrency] || !this.exchangeRates[toCurrency]) {
293
- throw new Error("Exchange rate not available");
294
- }
295
-
296
- const usdAmount = amount / this.exchangeRates[fromCurrency];
297
- return usdAmount * this.exchangeRates[toCurrency];
298
- }
299
-
300
- format(amount: number, currency: string, locale: string): string {
301
- const fractionDigits = maximumFractionDigits[locale] || 2;
302
- const currencyInfo = countryCurrencies[currency];
303
-
304
- return new Intl.NumberFormat(locale, {
305
- style: "currency",
306
- currency: currency,
307
- maximumFractionDigits: fractionDigits,
308
- }).format(amount);
309
- }
310
- }
311
- ```
312
-
313
- ### Address Form with Brazilian States
314
-
315
- ```typescript
316
- import { brazilianStates } from "@arkyn/templates";
317
-
318
- function AddressForm() {
319
- const [address, setAddress] = useState({
320
- street: "",
321
- city: "",
322
- state: "",
323
- zipCode: "",
324
- });
325
-
326
- return (
327
- <form>
328
- <input
329
- type="text"
330
- placeholder="Street Address"
331
- value={address.street}
332
- onChange={(e) => setAddress({ ...address, street: e.target.value })}
333
- />
334
-
335
- <input
336
- type="text"
337
- placeholder="City"
338
- value={address.city}
339
- onChange={(e) => setAddress({ ...address, city: e.target.value })}
340
- />
341
-
342
- <select
343
- value={address.state}
344
- onChange={(e) => setAddress({ ...address, state: e.target.value })}
345
- >
346
- <option value="">Select State</option>
347
- {brazilianStates.map((state) => (
348
- <option key={state.code} value={state.code}>
349
- {state.name}
350
- </option>
351
- ))}
352
- </select>
353
-
354
- <input
355
- type="text"
356
- placeholder="ZIP Code"
357
- value={address.zipCode}
358
- onChange={(e) => setAddress({ ...address, zipCode: e.target.value })}
359
- />
360
- </form>
361
- );
362
- }
363
- ```
364
-
365
- ## ๐Ÿงช Development
366
-
367
- ```bash
368
- # Install dependencies
369
- bun install
370
-
371
- # Build the package
372
- bun run build
373
-
374
- # Type check
375
- bun run typecheck
376
- ```
377
-
378
- ## ๐Ÿค Contributing
379
-
380
- Contributions are welcome! Please read our contributing guidelines and submit pull requests to help improve the package.
149
+ For more context on how this data is consumed across the ecosystem, see the [full documentation](https://docs.arkyn.dev/docs/templates/introduction).
381
150
 
382
151
  ## ๐Ÿ“„ License
383
152
 
384
- This project is licensed under the Apache 2.0 License - see the [LICENSE](./LICENSE.txt) file for details.
385
-
386
- ## ๐Ÿ”— Links
387
-
388
- - [GitHub Repository](https://github.com/Lucas-Eduardo-Goncalves/arkyn)
389
- - [NPM Package](https://www.npmjs.com/package/@arkyn/templates)
390
- - [Full Documentation](https://github.com/Lucas-Eduardo-Goncalves/arkyn#readme)
391
-
392
- ---
393
-
394
- Made with โค๏ธ by the Arkyn team
153
+ This project is licensed under the Apache 2.0 License โ€” see the [LICENSE](./LICENSE.txt) file for details.