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

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,151 @@
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
+ ```bash
32
+ npm install @arkyn/templates
33
+ ```
34
+
35
+ ## 🚀 Quick Start
36
+
37
+ ```typescript
38
+ import {
39
+ countries,
40
+ brazilianStates,
41
+ countryCurrencies,
42
+ maximumFractionDigits,
43
+ } from "@arkyn/templates";
44
+
45
+ // Find a specific country
46
+ const brazil = countries.find((country) => country.iso === "BR");
47
+ console.log(brazil);
48
+ // {
49
+ // name: "Brasil",
50
+ // code: "+55",
51
+ // iso: "BR",
52
+ // flag: "https://cdn.kcak11.com/CountryFlags/countries/br.svg",
53
+ // mask: ["(__) _____-____", "(__) ____-____"]
54
+ // }
55
+
56
+ // Get a Brazilian state
57
+ const saoPaulo = brazilianStates.find((state) => state.value === "SP");
58
+ console.log(saoPaulo); // { label: "São Paulo", value: "SP" }
59
+
60
+ // Get locale/currency info for Intl.NumberFormat
61
+ console.log(countryCurrencies.BRL); // { countryLanguage: "pt-BR", countryCurrency: "BRL" }
62
+
63
+ // Default decimal places used across Arkyn's currency formatting
64
+ console.log(maximumFractionDigits); // 2
65
+ ```
66
+
67
+ ## 📖 API Reference
68
+
69
+ ### 🌍 `countries`
70
+
71
+ An array of 245 countries, typed as `CountryType[]`:
72
+
73
+ ```typescript
74
+ type CountryType = {
75
+ name: string; // Country name
76
+ code: string; // International dialing code (e.g. "+55")
77
+ iso: string; // ISO 3166-1 alpha-2 code (e.g. "BR")
78
+ flag: string; // URL to an SVG flag icon
79
+ mask: string | string[]; // Phone input mask(s); some countries have more than one valid mask
80
+ };
81
+ ```
82
+
83
+ ```typescript
84
+ import { countries, type CountryType } from "@arkyn/templates";
85
+
86
+ const usa = countries.find((country) => country.iso === "US");
87
+ const brazilianOptions = countries.filter((country) => country.code === "+55");
88
+ ```
89
+
90
+ Used internally by `@arkyn/components`' `PhoneInput` to render the country selector and apply the correct input mask.
91
+
92
+ ### 🇧🇷 `brazilianStates`
93
+
94
+ An array of the 26 Brazilian states plus the Federal District:
95
+
96
+ ```typescript
97
+ type BrazilianState = { label: string; value: string };
98
+ ```
99
+
100
+ ```typescript
101
+ import { brazilianStates } from "@arkyn/templates";
102
+
103
+ console.log(brazilianStates.length); // 27
104
+ const rio = brazilianStates.find((state) => state.value === "RJ");
105
+ // { label: "Rio de Janeiro", value: "RJ" }
106
+ ```
107
+
108
+ The `{ label, value }` shape maps directly onto `@arkyn/components`' `Select` / `MultiSelect` `options` prop.
109
+
110
+ ### 💱 `countryCurrencies`
111
+
112
+ A record keyed by ISO 4217 currency code, mapping each currency to the locale/currency pair `Intl.NumberFormat` expects:
113
+
114
+ ```typescript
115
+ type CountryCurrencies = Record<
116
+ string,
117
+ { countryLanguage: string; countryCurrency: string }
118
+ >;
119
+ ```
120
+
121
+ ```typescript
122
+ import { countryCurrencies } from "@arkyn/templates";
123
+
124
+ const { countryLanguage, countryCurrency } = countryCurrencies.BRL;
125
+ // { countryLanguage: "pt-BR", countryCurrency: "BRL" }
126
+
127
+ new Intl.NumberFormat(countryLanguage, {
128
+ style: "currency",
129
+ currency: countryCurrency,
130
+ }).format(1234.56); // "R$ 1.234,56"
131
+ ```
132
+
133
+ This is exactly what `@arkyn/shared`'s `formatToCurrency` uses under the hood to resolve a currency code into a locale-aware formatter.
134
+
135
+ ### 📊 `maximumFractionDigits`
136
+
137
+ A single constant (`2`) representing the default number of decimal places used for currency values across the Arkyn ecosystem.
138
+
139
+ ```typescript
140
+ import { maximumFractionDigits } from "@arkyn/templates";
141
+
142
+ console.log(maximumFractionDigits); // 2
143
+ ```
144
+
145
+ ## 📚 Documentation
146
+
147
+ For more context on how this data is consumed across the ecosystem, see the [full documentation](https://docs.arkyn.dev/docs/templates/introduction).
148
+
149
+ ## 📄 License
150
+
151
+ This project is licensed under the Apache 2.0 License — see the [LICENSE](./LICENSE.txt) file for details.