@arkyn/templates 3.0.1-beta.20 → 3.0.1-beta.201

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,24 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ Copyright 2025 Lucas Gonçalves
8
+
9
+ Licensed under the Apache License, Version 2.0 (the "License");
10
+ you may not use this file except in compliance with the License.
11
+ You may obtain a copy of the License at
12
+
13
+ http://www.apache.org/licenses/LICENSE-2.0
14
+
15
+ Unless required by applicable law or agreed to in writing, software
16
+ distributed under the License is distributed on an "AS IS" BASIS,
17
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ See the License for the specific language governing permissions and
19
+ limitations under the License.
20
+
21
+ ---
22
+
23
+ For more information or to contribute, visit:
24
+ https://github.com/Lucas-Eduardo-Goncalves
package/README.md ADDED
@@ -0,0 +1,153 @@
1
+ # @arkyn/templates
2
+
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
+
5
+ [![npm version](https://img.shields.io/npm/v/@arkyn/templates.svg)](https://www.npmjs.com/package/@arkyn/templates)
6
+ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
7
+ [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)
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
+
13
+ ## ✨ Features
14
+
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 `>=24.16.0`
25
+ - Bun `>=1.3.14` (only if building/developing the monorepo itself)
26
+
27
+ This package has no runtime dependencies and no peer dependencies — it can be installed standalone.
28
+
29
+ ## 📦 Installation
30
+
31
+ > **ESM only.** This package ships as native ES modules with no CommonJS build — use `import`, not `require()`.
32
+
33
+ ```bash
34
+ npm install @arkyn/templates
35
+ ```
36
+
37
+ ## 🚀 Quick Start
38
+
39
+ ```typescript
40
+ import {
41
+ countries,
42
+ brazilianStates,
43
+ countryCurrencies,
44
+ maximumFractionDigits,
45
+ } from "@arkyn/templates";
46
+
47
+ // Find a specific country
48
+ const brazil = countries.find((country) => country.iso === "BR");
49
+ console.log(brazil);
50
+ // {
51
+ // name: "Brasil",
52
+ // code: "+55",
53
+ // iso: "BR",
54
+ // flag: "https://cdn.kcak11.com/CountryFlags/countries/br.svg",
55
+ // mask: ["(__) _____-____", "(__) ____-____"]
56
+ // }
57
+
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" }
64
+
65
+ // Default decimal places used across Arkyn's currency formatting
66
+ console.log(maximumFractionDigits); // 2
67
+ ```
68
+
69
+ ## 📖 API Reference
70
+
71
+ ### 🌍 `countries`
72
+
73
+ An array of 245 countries, typed as `CountryType[]`:
74
+
75
+ ```typescript
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
+ };
83
+ ```
84
+
85
+ ```typescript
86
+ import { countries, type CountryType } from "@arkyn/templates";
87
+
88
+ const usa = countries.find((country) => country.iso === "US");
89
+ const brazilianOptions = countries.filter((country) => country.code === "+55");
90
+ ```
91
+
92
+ Used internally by `@arkyn/components`' `PhoneInput` to render the country selector and apply the correct input mask.
93
+
94
+ ### 🇧🇷 `brazilianStates`
95
+
96
+ An array of the 26 Brazilian states plus the Federal District:
97
+
98
+ ```typescript
99
+ type BrazilianState = { label: string; value: string };
100
+ ```
101
+
102
+ ```typescript
103
+ import { brazilianStates } from "@arkyn/templates";
104
+
105
+ console.log(brazilianStates.length); // 27
106
+ const rio = brazilianStates.find((state) => state.value === "RJ");
107
+ // { label: "Rio de Janeiro", value: "RJ" }
108
+ ```
109
+
110
+ The `{ label, value }` shape maps directly onto `@arkyn/components`' `Select` / `MultiSelect` `options` prop.
111
+
112
+ ### 💱 `countryCurrencies`
113
+
114
+ A record keyed by ISO 4217 currency code, mapping each currency to the locale/currency pair `Intl.NumberFormat` expects:
115
+
116
+ ```typescript
117
+ type CountryCurrencies = Record<
118
+ string,
119
+ { countryLanguage: string; countryCurrency: string }
120
+ >;
121
+ ```
122
+
123
+ ```typescript
124
+ import { countryCurrencies } from "@arkyn/templates";
125
+
126
+ const { countryLanguage, countryCurrency } = countryCurrencies.BRL;
127
+ // { countryLanguage: "pt-BR", countryCurrency: "BRL" }
128
+
129
+ new Intl.NumberFormat(countryLanguage, {
130
+ style: "currency",
131
+ currency: countryCurrency,
132
+ }).format(1234.56); // "R$ 1.234,56"
133
+ ```
134
+
135
+ This is exactly what `@arkyn/shared`'s `formatToCurrency` uses under the hood to resolve a currency code into a locale-aware formatter.
136
+
137
+ ### 📊 `maximumFractionDigits`
138
+
139
+ A single constant (`2`) representing the default number of decimal places used for currency values across the Arkyn ecosystem.
140
+
141
+ ```typescript
142
+ import { maximumFractionDigits } from "@arkyn/templates";
143
+
144
+ console.log(maximumFractionDigits); // 2
145
+ ```
146
+
147
+ ## 📚 Documentation
148
+
149
+ For more context on how this data is consumed across the ecosystem, see the [full documentation](https://docs.arkyn.dev/docs/templates/introduction).
150
+
151
+ ## 📄 License
152
+
153
+ This project is licensed under the Apache 2.0 License — see the [LICENSE](./LICENSE.txt) file for details.