@arkyn/templates 3.0.7 → 3.0.8
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/AGENTS.md +62 -0
- package/package.json +2 -1
package/AGENTS.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# @arkyn/templates — agent guide
|
|
2
|
+
|
|
3
|
+
Static reference data: countries, Brazilian states, currency/locale metadata. Zero runtime dependencies, safe to import anywhere (client, server, or edge). Use it instead of hardcoding country/state lists or currency locale pairs in app code. Everything below is exact — read directly from source, no need to open README.md or any other file for correct usage.
|
|
4
|
+
|
|
5
|
+
## Required setup
|
|
6
|
+
|
|
7
|
+
- ESM only: `import`, never `require()`.
|
|
8
|
+
- No peer dependencies.
|
|
9
|
+
|
|
10
|
+
## Import convention — always prefer subpath imports
|
|
11
|
+
|
|
12
|
+
Prefer importing each export from its own subpath instead of the root barrel (`@arkyn/templates`):
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
import { countries } from "@arkyn/templates/countries";
|
|
16
|
+
import { brazilianStates } from "@arkyn/templates/brazilianStates";
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**Naming rule**: the subpath is always the export name, unchanged (every export here already starts with a lowercase letter) — no casing transformation needed. This is exact for every export in this package. There are no per-export CSS files (no UI).
|
|
20
|
+
|
|
21
|
+
## Available exports
|
|
22
|
+
|
|
23
|
+
#### countries
|
|
24
|
+
- Import: `import { countries, type CountryType } from "@arkyn/templates/countries";`
|
|
25
|
+
- Type: `CountryType[]` — 245 entries, each `{ name: string; code: string; iso: string; flag: string; mask: string | string[] }`.
|
|
26
|
+
- `code` — international dialing code, e.g. `"+55"`.
|
|
27
|
+
- `iso` — ISO 3166-1 alpha-2 code, e.g. `"BR"`.
|
|
28
|
+
- `flag` — URL to an SVG flag icon.
|
|
29
|
+
- `mask` — phone input mask using `"_"` placeholders; an array when the country has more than one valid mask length (e.g. Brazil with/without the ninth digit: `["(__) _____-____", "(__) ____-____"]`).
|
|
30
|
+
- Feeds `@arkyn/components`'s `PhoneInput` internally and `@arkyn/shared`'s `findCountryMask`/`formatToPhone`.
|
|
31
|
+
|
|
32
|
+
#### brazilianStates
|
|
33
|
+
- Import: `import { brazilianStates } from "@arkyn/templates/brazilianStates";`
|
|
34
|
+
- Type: `{ label: string; value: string }[]` — 27 entries (all 26 states plus the Federal District, `value: "DF"`).
|
|
35
|
+
- Shape matches `@arkyn/components`'s `Select`/`MultiSelect` `options` prop directly — pass it straight through, no mapping needed.
|
|
36
|
+
|
|
37
|
+
#### countryCurrencies
|
|
38
|
+
- Import: `import { countryCurrencies } from "@arkyn/templates/countryCurrencies";`
|
|
39
|
+
- Type: `Record<string, { countryLanguage: string; countryCurrency: string }>` — 22 entries keyed by ISO 4217 currency code (`USD`, `EUR`, `JPY`, `GBP`, `AUD`, `CAD`, `CHF`, `CNY`, `SEK`, `NZD`, `BRL`, `INR`, `RUB`, `ZAR`, `MXN`, `SGD`, `HKD`, `NOK`, `KRW`, `TRY`, `IDR`, `THB`).
|
|
40
|
+
- Each value gives the `Intl.NumberFormat` locale/currency pair, e.g. `BRL` → `{ countryLanguage: "pt-BR", countryCurrency: "BRL" }`.
|
|
41
|
+
- Used internally by `@arkyn/shared`'s `formatToCurrency` to resolve a currency code — passing a code not in this map throws there.
|
|
42
|
+
|
|
43
|
+
#### maximumFractionDigits
|
|
44
|
+
- Import: `import { maximumFractionDigits } from "@arkyn/templates/maximumFractionDigits";`
|
|
45
|
+
- Type: `number` — constant value `2`. Default decimal places used for currency formatting across the ecosystem.
|
|
46
|
+
|
|
47
|
+
## Quick example
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import { countries } from "@arkyn/templates/countries";
|
|
51
|
+
import { brazilianStates } from "@arkyn/templates/brazilianStates";
|
|
52
|
+
import { countryCurrencies } from "@arkyn/templates/countryCurrencies";
|
|
53
|
+
|
|
54
|
+
const brazil = countries.find((c) => c.iso === "BR");
|
|
55
|
+
const saoPaulo = brazilianStates.find((s) => s.value === "SP");
|
|
56
|
+
const { countryLanguage, countryCurrency } = countryCurrencies.BRL;
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Related packages
|
|
60
|
+
|
|
61
|
+
- `@arkyn/shared` — `formatToCurrency`/`formatToPhone`/`findCountryMask` consume this data instead of you resolving it manually.
|
|
62
|
+
- `@arkyn/components` — `PhoneInput`, `Select`, and `MultiSelect` are natural homes for `countries`/`brazilianStates`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkyn/templates",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.8",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"files": [
|
|
36
36
|
"dist",
|
|
37
37
|
"README.md",
|
|
38
|
+
"AGENTS.md",
|
|
38
39
|
"LICENSE.txt"
|
|
39
40
|
],
|
|
40
41
|
"scripts": {
|