@kashi-ui/persian 0.22.1 → 0.24.0

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.
@@ -0,0 +1,17 @@
1
+ /** شهرهای یک استان به ترتیب الفبا؛ برای استان ناشناخته آرایهٔ خالی */
2
+ export declare function getCities(province: string | null | undefined): readonly string[];
3
+ /** استانِ یک شهر؛ اگر نام در چند استان هست (مثل «رودبار»)، همهٔ آن‌ها */
4
+ export declare function getCityProvinces(city: string): string[];
5
+ /** نشانی ایرانی: استان و شهر، نشانی خیابان و کوچه، پلاک، واحد و کد پستی */
6
+ export interface IranAddress {
7
+ province: string | null;
8
+ city: string | null;
9
+ /** خیابان، کوچه و جزئیات */
10
+ street: string;
11
+ plaque: string;
12
+ unit: string;
13
+ postalCode: string;
14
+ }
15
+ export declare const EMPTY_ADDRESS: IranAddress;
16
+ /** نشانی در یک خط، مثل «اصفهان، کاشان، خیابان امیرکبیر، پلاک ۱۲، واحد ۳، کد پستی ۸۷۱۳۷-۱۴۵۶۸» */
17
+ export declare function formatAddress(address: Partial<IranAddress>): string;
@@ -0,0 +1,24 @@
1
+ import { CITIES } from "./cities.js";
2
+ import { toFaDigits } from "./digits.js";
3
+ import { formatPostalCode } from "./postal.js";
4
+ /** شهرهای یک استان به ترتیب الفبا؛ برای استان ناشناخته آرایهٔ خالی */
5
+ export function getCities(province) {
6
+ return (province && CITIES[province]) || [];
7
+ }
8
+ /** استانِ یک شهر؛ اگر نام در چند استان هست (مثل «رودبار»)، همهٔ آن‌ها */
9
+ export function getCityProvinces(city) {
10
+ return Object.keys(CITIES).filter((p) => CITIES[p].includes(city));
11
+ }
12
+ export const EMPTY_ADDRESS = { province: null, city: null, street: "", plaque: "", unit: "", postalCode: "" };
13
+ /** نشانی در یک خط، مثل «اصفهان، کاشان، خیابان امیرکبیر، پلاک ۱۲، واحد ۳، کد پستی ۸۷۱۳۷-۱۴۵۶۸» */
14
+ export function formatAddress(address) {
15
+ const { province, city, street, plaque, unit, postalCode } = address;
16
+ return [
17
+ province,
18
+ city && city !== province ? city : null,
19
+ street?.trim(),
20
+ plaque?.trim() && `پلاک ${toFaDigits(plaque.trim())}`,
21
+ unit?.trim() && `واحد ${toFaDigits(unit.trim())}`,
22
+ postalCode?.trim() && `کد پستی ${toFaDigits(formatPostalCode(postalCode))}`,
23
+ ].filter(Boolean).join("، ");
24
+ }
@@ -0,0 +1 @@
1
+ export declare const CITIES: Record<string, readonly string[]>;