@kashi-ui/react 2.25.0 → 2.27.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.
- package/dist/ActivityHeatmap.js +4 -2
- package/dist/AddressForm.js +3 -2
- package/dist/Alert.js +3 -2
- package/dist/AppointmentPicker.js +4 -2
- package/dist/Avatar.js +5 -3
- package/dist/Badge.js +3 -2
- package/dist/BankBadge.js +2 -2
- package/dist/BankCard.js +4 -2
- package/dist/Banner.js +3 -2
- package/dist/BillInput.js +6 -3
- package/dist/BottomSheet.js +3 -2
- package/dist/Breadcrumb.js +3 -2
- package/dist/BusinessHours.js +6 -3
- package/dist/Button.js +3 -2
- package/dist/Calendar.js +4 -2
- package/dist/CardNumberInput.js +4 -2
- package/dist/Carousel.js +4 -2
- package/dist/Chart.js +6 -4
- package/dist/Chat.js +6 -4
- package/dist/ChatComposer.js +4 -2
- package/dist/CitySelect.js +3 -2
- package/dist/CodeBlock.js +4 -2
- package/dist/ColorPicker.js +6 -3
- package/dist/Combobox.js +4 -2
- package/dist/CommandPalette.js +4 -2
- package/dist/ContextMenu.js +3 -2
- package/dist/CopyButton.js +3 -2
- package/dist/Countdown.js +4 -2
- package/dist/DataTable.js +3 -2
- package/dist/DatePicker.js +4 -2
- package/dist/DateRangePicker.js +7 -5
- package/dist/DateTile.js +2 -2
- package/dist/Dialog.js +3 -2
- package/dist/Drawer.js +3 -2
- package/dist/EconomicCodeInput.js +4 -2
- package/dist/EmptyState.js +3 -2
- package/dist/Field.js +3 -2
- package/dist/FileUpload.d.ts +1 -1
- package/dist/FileUpload.js +9 -6
- package/dist/Gantt.js +4 -2
- package/dist/IbanInput.js +3 -2
- package/dist/ImageCropper.js +4 -2
- package/dist/InfiniteScroll.js +4 -2
- package/dist/InlineEdit.js +3 -2
- package/dist/Input.js +3 -2
- package/dist/Invoice.js +4 -2
- package/dist/IranMap.js +4 -2
- package/dist/Kanban.js +4 -2
- package/dist/KashiProvider.d.ts +731 -3
- package/dist/KashiProvider.js +19 -4
- package/dist/KeyboardFixInput.js +4 -2
- package/dist/LandlineInput.js +4 -2
- package/dist/LegalIdInput.js +4 -2
- package/dist/Lightbox.js +6 -3
- package/dist/Meter.js +4 -2
- package/dist/MobileInput.js +4 -2
- package/dist/Money.js +4 -2
- package/dist/MonthPicker.js +4 -2
- package/dist/MultiSelect.js +4 -2
- package/dist/NationalIdInput.js +4 -2
- package/dist/Navbar.js +3 -2
- package/dist/NotificationCenter.js +6 -3
- package/dist/NumberInput.js +4 -2
- package/dist/OtpInput.js +2 -2
- package/dist/Pagination.js +4 -2
- package/dist/PasswordStrength.js +5 -4
- package/dist/PaymentReceipt.js +4 -2
- package/dist/PersianInput.js +3 -2
- package/dist/PersianTextarea.js +4 -2
- package/dist/PlateInput.js +3 -2
- package/dist/PostalCodeInput.js +4 -2
- package/dist/PriceInput.js +4 -2
- package/dist/PriceRange.js +4 -2
- package/dist/Progress.js +5 -3
- package/dist/ProvinceSelect.js +3 -2
- package/dist/QRCode.js +3 -2
- package/dist/Rating.js +4 -2
- package/dist/RelativeTime.js +2 -2
- package/dist/RichTextEditor.js +4 -2
- package/dist/SayadInput.js +4 -2
- package/dist/Scheduler.js +4 -2
- package/dist/SearchSuggest.js +3 -2
- package/dist/Select.js +3 -2
- package/dist/SideNav.js +3 -2
- package/dist/SignaturePad.js +3 -2
- package/dist/Slider.js +4 -2
- package/dist/Sortable.js +4 -2
- package/dist/Splitter.js +4 -2
- package/dist/Stat.js +4 -2
- package/dist/Stepper.js +4 -2
- package/dist/StreamingText.js +3 -2
- package/dist/SwatchGroup.js +3 -2
- package/dist/TagInput.js +4 -2
- package/dist/TaxIdInput.js +3 -2
- package/dist/TimeClock.js +4 -2
- package/dist/TimeInput.js +4 -2
- package/dist/TimePicker.js +4 -2
- package/dist/Toast.js +3 -2
- package/dist/Tour.js +4 -2
- package/dist/VirtualList.js +4 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +4 -4
package/dist/KashiProvider.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { createContext, useContext, useMemo } from "react";
|
|
4
4
|
import { JALALI_MONTHS, JALALI_MONTHS_EN, WEEKDAYS, WEEKDAYS_EN, WEEKDAYS_SHORT, WEEKDAYS_SHORT_EN, faMessages, getMessages, toFaDigits, } from "@kashi-ui/persian";
|
|
5
|
-
|
|
5
|
+
// فرهنگ کامل متنها در مقدار پیشفرض نیست تا کامپوننتی که فقط useMessages میخواهد همهٔ متنها را در بسته نبرد
|
|
6
|
+
const KashiContext = createContext({ locale: "fa", digits: "fa" });
|
|
6
7
|
/**
|
|
7
8
|
* زبان کامپوننتهای کاشی: بدون آن همهچیز فارسی است. با locale="en" برچسب دکمهها، متن صفحهخوان،
|
|
8
9
|
* پیامهای خطا، نام ماهها و ارقام انگلیسی میشوند. جهت صفحه (dir) را خودتان روی html بگذارید.
|
|
@@ -11,12 +12,13 @@ export function KashiProvider({ locale = "fa", messages, digits, children }) {
|
|
|
11
12
|
const value = useMemo(() => ({ locale, messages: getMessages(locale, messages), digits: digits ?? (locale === "en" ? "latin" : "fa") }), [locale, messages, digits]);
|
|
12
13
|
return _jsx(KashiContext.Provider, { value: value, children: children });
|
|
13
14
|
}
|
|
14
|
-
/** زبان،
|
|
15
|
-
export function
|
|
15
|
+
/** زبان، ارقام و نامهای تقویم شمسی فعلی، بدون فرهنگ متنها (کامپوننتها متن را با useMessages میگیرند) */
|
|
16
|
+
export function useKashiLocale() {
|
|
16
17
|
const ctx = useContext(KashiContext);
|
|
17
18
|
const en = ctx.locale === "en";
|
|
18
19
|
return {
|
|
19
|
-
|
|
20
|
+
locale: ctx.locale,
|
|
21
|
+
digits: ctx.digits,
|
|
20
22
|
n: (v, digits = ctx.digits) => (digits === "fa" ? toFaDigits(String(v)) : String(v)),
|
|
21
23
|
months: en ? JALALI_MONTHS_EN : JALALI_MONTHS,
|
|
22
24
|
weekdays: en ? WEEKDAYS_EN : WEEKDAYS,
|
|
@@ -25,3 +27,16 @@ export function useKashi() {
|
|
|
25
27
|
friday: en ? "Friday" : "جمعه",
|
|
26
28
|
};
|
|
27
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* متنهای داخلی یک کامپوننت: بخشهای فارسیای که خود کامپوننت import کرده (مثلاً `useMessages({ table: faTable, common: faCommon })`).
|
|
32
|
+
* با KashiProvider (انگلیسی یا متنهای عوضشده) همان بخشها از فرهنگ Provider میآیند. نتیجه همان شکل KashiMessages را دارد.
|
|
33
|
+
*/
|
|
34
|
+
export function useMessages(fa) {
|
|
35
|
+
const ctx = useContext(KashiContext);
|
|
36
|
+
return (ctx.messages ?? fa);
|
|
37
|
+
}
|
|
38
|
+
/** زبان، فرهنگ کامل متنها و ارقام فعلی (useForm از آن استفاده میکند چون قاعدههای کاربر به همهٔ متنها دسترسی دارند)؛ n() عدد را با ارقام همان زبان مینویسد و months/weekdays نامهای تقویم شمسیاند */
|
|
39
|
+
export function useKashi() {
|
|
40
|
+
const ctx = useContext(KashiContext);
|
|
41
|
+
return { ...useKashiLocale(), messages: ctx.messages ?? faMessages };
|
|
42
|
+
}
|
package/dist/KeyboardFixInput.js
CHANGED
|
@@ -4,13 +4,15 @@ import { forwardRef, useRef, useState } from "react";
|
|
|
4
4
|
import { fixKeyboardLayout, looksLikeWrongLayout } from "@kashi-ui/persian";
|
|
5
5
|
import { Input } from "./Input.js";
|
|
6
6
|
import { mergeRefs } from "./utils.js";
|
|
7
|
-
import {
|
|
7
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
8
|
+
import { faKeyboardFix } from "@kashi-ui/persian";
|
|
8
9
|
/**
|
|
9
10
|
* فیلدی که اگر کاربر فارسی را با صفحهکلید انگلیسی تایپ کرده باشد («sghl»)، شکل درست («سلام») را پیشنهاد میدهد.
|
|
10
11
|
* مناسب جستجو و فرمهایی که کاربر زبان صفحهکلید را عوض نکرده است.
|
|
11
12
|
*/
|
|
12
13
|
export const KeyboardFixInput = forwardRef(function KeyboardFixInput({ value, defaultValue = "", onValueChange, suggest = "auto", renderSuggestion, hint, ...rest }, ref) {
|
|
13
|
-
const {
|
|
14
|
+
const M = useMessages({ keyboardFix: faKeyboardFix });
|
|
15
|
+
const { locale } = useKashiLocale();
|
|
14
16
|
const [inner, setInner] = useState(defaultValue);
|
|
15
17
|
const current = value ?? inner;
|
|
16
18
|
const el = useRef(null);
|
package/dist/LandlineInput.js
CHANGED
|
@@ -5,10 +5,12 @@ import { formatLandline, getLandlineProvince, isValidLandline, normalizeLandline
|
|
|
5
5
|
import { Input } from "./Input.js";
|
|
6
6
|
import { useDigitsInput } from "./useDigitsInput.js";
|
|
7
7
|
import { mergeRefs } from "./utils.js";
|
|
8
|
-
import {
|
|
8
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
9
|
+
import { faInvalid } from "@kashi-ui/persian";
|
|
9
10
|
/** تلفن ثابت با پیششماره: +98 را به ۰ تبدیل میکند، گروهبندی و نام استان را نشان میدهد */
|
|
10
11
|
export const LandlineInput = forwardRef(function LandlineInput({ value, defaultValue, onValueChange, digits, showProvince = true, invalidMessage, error, name, id, onBlur, placeholder, ...rest }, ref) {
|
|
11
|
-
const
|
|
12
|
+
const M = useMessages({ invalid: faInvalid });
|
|
13
|
+
const { digits: D, locale } = useKashiLocale();
|
|
12
14
|
digits ?? (digits = D);
|
|
13
15
|
invalidMessage ?? (invalidMessage = M.invalid.landline);
|
|
14
16
|
const autoId = useId();
|
package/dist/LegalIdInput.js
CHANGED
|
@@ -3,10 +3,12 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
3
3
|
import { forwardRef, useState } from "react";
|
|
4
4
|
import { isValidLegalId, onlyDigits, toFaDigits } from "@kashi-ui/persian";
|
|
5
5
|
import { Input } from "./Input.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
7
|
+
import { faInvalid } from "@kashi-ui/persian";
|
|
7
8
|
/** شناسهٔ ملی اشخاص حقوقی (شرکتها): ۱۱ رقم با بررسی رقم کنترل */
|
|
8
9
|
export const LegalIdInput = forwardRef(function LegalIdInput({ value, defaultValue = "", onValueChange, digits, invalidMessage, error, name, onBlur, placeholder, ...rest }, ref) {
|
|
9
|
-
const
|
|
10
|
+
const M = useMessages({ invalid: faInvalid });
|
|
11
|
+
const { digits: D, locale } = useKashiLocale();
|
|
10
12
|
digits ?? (digits = D);
|
|
11
13
|
invalidMessage ?? (invalidMessage = M.invalid.legalId);
|
|
12
14
|
const [inner, setInner] = useState(() => onlyDigits(defaultValue).slice(0, 11));
|
package/dist/Lightbox.js
CHANGED
|
@@ -3,7 +3,8 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
3
3
|
import { useEffect, useId, useRef, useState } from "react";
|
|
4
4
|
import { cx } from "./cx.js";
|
|
5
5
|
import { isRtl } from "./dnd.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
7
|
+
import { faLightbox } from "@kashi-ui/persian";
|
|
7
8
|
import { useModalDialog } from "./modal.js";
|
|
8
9
|
const svg = (d, w = 1.8) => (_jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: w, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: d }) }));
|
|
9
10
|
/**
|
|
@@ -11,7 +12,8 @@ const svg = (d, w = 1.8) => (_jsx("svg", { viewBox: "0 0 20 20", fill: "none", s
|
|
|
11
12
|
* بزرگنمایی با کلیک یا دوبار ضربه، و برگشت فوکوس به تصویر کوچک پس از بستن.
|
|
12
13
|
*/
|
|
13
14
|
export function Lightbox({ images, index, onIndexChange, thumbnails = true, loop = false, className }) {
|
|
14
|
-
const {
|
|
15
|
+
const M = useMessages({ lightbox: faLightbox });
|
|
16
|
+
const { n } = useKashiLocale();
|
|
15
17
|
const L = M.lightbox;
|
|
16
18
|
const ref = useRef(null);
|
|
17
19
|
const open = index !== null;
|
|
@@ -119,7 +121,8 @@ export function Lightbox({ images, index, onIndexChange, thumbnails = true, loop
|
|
|
119
121
|
}
|
|
120
122
|
/** شبکهٔ تصویرهای کوچک که هر کدام با کلیک در نمایش تمامصفحه باز میشود */
|
|
121
123
|
export function Gallery({ images, columns, aspect = "1 / 1", max, loop, "aria-label": ariaLabel, className }) {
|
|
122
|
-
const {
|
|
124
|
+
const M = useMessages({ lightbox: faLightbox });
|
|
125
|
+
const { n } = useKashiLocale();
|
|
123
126
|
const [open, setOpen] = useState(null);
|
|
124
127
|
const shown = max && images.length > max ? images.slice(0, max) : images;
|
|
125
128
|
const rest = images.length - shown.length;
|
package/dist/Meter.js
CHANGED
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { formatNumber } from "@kashi-ui/persian";
|
|
4
4
|
import { cx } from "./cx.js";
|
|
5
|
-
import {
|
|
5
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
6
|
+
import { faCommon, faMeter } from "@kashi-ui/persian";
|
|
6
7
|
const Icon = ({ d }) => _jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: d }) });
|
|
7
8
|
/** سنجهٔ یک مقدار در برابر سقف، مثل فضای ذخیره یا سهمیهٔ پیامک؛ وضعیت با متن و آیکون، نه فقط رنگ */
|
|
8
9
|
export function Meter({ label, value, max = 100, warning = max * 0.8, critical = max * 0.95, format, className, labels = {} }) {
|
|
9
|
-
const {
|
|
10
|
+
const M = useMessages({ common: faCommon, meter: faMeter });
|
|
11
|
+
const { n, digits: D } = useKashiLocale();
|
|
10
12
|
format ?? (format = (x) => formatNumber(x, { digits: D }));
|
|
11
13
|
const { ok = M.meter.ok, warning: warnText = M.meter.warning, critical: critText = M.meter.critical, of } = labels;
|
|
12
14
|
const v = Math.min(max, Math.max(0, value));
|
package/dist/MobileInput.js
CHANGED
|
@@ -5,10 +5,12 @@ import { formatMobile, getMobileOperator, isValidMobile, normalizeMobile, operat
|
|
|
5
5
|
import { Input } from "./Input.js";
|
|
6
6
|
import { useDigitsInput } from "./useDigitsInput.js";
|
|
7
7
|
import { mergeRefs } from "./utils.js";
|
|
8
|
-
import {
|
|
8
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
9
|
+
import { faInvalid } from "@kashi-ui/persian";
|
|
9
10
|
/** فیلد شماره موبایل: +98 و 0098 را به 09 تبدیل میکند، گروهبندی و تشخیص اپراتور */
|
|
10
11
|
export const MobileInput = forwardRef(function MobileInput({ value, defaultValue, onValueChange, digits, showOperator = true, invalidMessage, error, name, id, onBlur, placeholder, ...rest }, ref) {
|
|
11
|
-
const
|
|
12
|
+
const M = useMessages({ invalid: faInvalid });
|
|
13
|
+
const { digits: D, locale } = useKashiLocale();
|
|
12
14
|
digits ?? (digits = D);
|
|
13
15
|
invalidMessage ?? (invalidMessage = M.invalid.mobile);
|
|
14
16
|
const autoId = useId();
|
package/dist/Money.js
CHANGED
|
@@ -3,10 +3,12 @@ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
4
|
import { formatMoney, numberToWords, rialToToman, tomanToRial } from "@kashi-ui/persian";
|
|
5
5
|
import { cx } from "./cx.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
7
|
+
import { faMoney } from "@kashi-ui/persian";
|
|
7
8
|
/** نمایش مبلغ با تومان یا ریال، حالت خلاصه (۱٫۲ میلیون) و مبلغ به حروف برای صفحهخوان */
|
|
8
9
|
export const Money = forwardRef(function Money({ value, unit = "toman", from = "toman", compact, digits, signed, words = true, size = "md", className, ...rest }, ref) {
|
|
9
|
-
const
|
|
10
|
+
const M = useMessages({ money: faMoney });
|
|
11
|
+
const { digits: D, locale } = useKashiLocale();
|
|
10
12
|
digits ?? (digits = D);
|
|
11
13
|
const n = from === unit ? value : from === "rial" ? rialToToman(value) : tomanToRial(value);
|
|
12
14
|
const amount = formatMoney(n, { unit, compact, digits, locale, showUnit: false });
|
package/dist/MonthPicker.js
CHANGED
|
@@ -3,12 +3,14 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useEffect, useRef, useState } from "react";
|
|
4
4
|
import { toFaDigits, toJalali } from "@kashi-ui/persian";
|
|
5
5
|
import { cx } from "./cx.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
7
|
+
import { faMonthPicker } from "@kashi-ui/persian";
|
|
7
8
|
const key = (m) => m.year * 12 + m.month;
|
|
8
9
|
const Arrow = ({ next }) => (_jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.7, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", "data-k-mirror": "", children: _jsx("path", { d: next ? "m8 5 5 5-5 5" : "m12 5-5 5 5 5" }) }));
|
|
9
10
|
/** انتخاب ماه و سال شمسی، برای گزارش ماهانه یا تاریخ انقضای کارت؛ ↑↓←→ بین ماهها و PageUp/PageDown بین سالها */
|
|
10
11
|
export function MonthPicker({ value, defaultValue = null, onChange, min, max, digits, "aria-label": ariaLabel, className, labels = {} }) {
|
|
11
|
-
const
|
|
12
|
+
const M = useMessages({ monthPicker: faMonthPicker });
|
|
13
|
+
const { digits: D, months: MONTHS } = useKashiLocale();
|
|
12
14
|
digits ?? (digits = D);
|
|
13
15
|
ariaLabel ?? (ariaLabel = M.monthPicker.label);
|
|
14
16
|
const { prevYear = M.monthPicker.prevYear, nextYear = M.monthPicker.nextYear } = labels;
|
package/dist/MultiSelect.js
CHANGED
|
@@ -4,14 +4,16 @@ import { useId, useMemo, useRef, useState } from "react";
|
|
|
4
4
|
import { Badge } from "./Badge.js";
|
|
5
5
|
import { defaultFilter, highlight } from "./Combobox.js";
|
|
6
6
|
import { Field, describedBy } from "./Field.js";
|
|
7
|
-
import {
|
|
7
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
8
|
+
import { faCommon, faMultiSelect } from "@kashi-ui/persian";
|
|
8
9
|
const Check = () => _jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "m5 10.5 3.2 3L15 7" }) });
|
|
9
10
|
/**
|
|
10
11
|
* انتخاب چند گزینه با جستجو؛ انتخابها بهشکل برچسب داخل فیلد.
|
|
11
12
|
* ↑↓ حرکت، Enter انتخاب یا لغو انتخاب، Backspace در فیلد خالی آخرین برچسب را حذف میکند، Esc بستن.
|
|
12
13
|
*/
|
|
13
14
|
export function MultiSelect({ label, hint, error, options, value, defaultValue = [], onChange, placeholder, max, filter = defaultFilter, emptyMessage, disabled, readOnly, loading, name, id, className, labels = {}, }) {
|
|
14
|
-
const {
|
|
15
|
+
const M = useMessages({ common: faCommon, multiSelect: faMultiSelect });
|
|
16
|
+
const { n: N } = useKashiLocale();
|
|
15
17
|
emptyMessage ?? (emptyMessage = M.common.noResults);
|
|
16
18
|
const { remove = M.common.remove, selected: selectedLabel = (x) => M.multiSelect.selected(N(x)), max: maxLabel = (x) => M.common.max(N(x)), clear = M.common.clearAll, } = labels;
|
|
17
19
|
const autoId = useId();
|
package/dist/NationalIdInput.js
CHANGED
|
@@ -3,10 +3,12 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
3
3
|
import { forwardRef, useState } from "react";
|
|
4
4
|
import { isValidNationalId, onlyDigits, toFaDigits } from "@kashi-ui/persian";
|
|
5
5
|
import { Input } from "./Input.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
7
|
+
import { faInvalid } from "@kashi-ui/persian";
|
|
7
8
|
/** فیلد کد ملی: ارقام فارسی و لاتین را میپذیرد، ۱۰ رقم را محدود و رقم کنترل را بررسی میکند. */
|
|
8
9
|
export const NationalIdInput = forwardRef(function NationalIdInput({ value, defaultValue = "", onValueChange, digits, invalidMessage, error, name, onBlur, placeholder, ...rest }, ref) {
|
|
9
|
-
const
|
|
10
|
+
const M = useMessages({ invalid: faInvalid });
|
|
11
|
+
const { digits: D, locale } = useKashiLocale();
|
|
10
12
|
digits ?? (digits = D);
|
|
11
13
|
invalidMessage ?? (invalidMessage = M.invalid.nationalId);
|
|
12
14
|
const [inner, setInner] = useState(() => onlyDigits(defaultValue).slice(0, 10));
|
package/dist/Navbar.js
CHANGED
|
@@ -3,14 +3,15 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
4
4
|
import { cx } from "./cx.js";
|
|
5
5
|
import { Drawer } from "./Drawer.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useMessages } from "./KashiProvider.js";
|
|
7
|
+
import { faNavbar } from "@kashi-ui/persian";
|
|
7
8
|
const useIsoLayout = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
8
9
|
/**
|
|
9
10
|
* نوار ناوبری بالای سایت: لوگو، پیوندها با نشانگر لغزان، دکمهها
|
|
10
11
|
* و در گوشی منوی کشو با همان پیوندها. با اسکرول سایه میگیرد.
|
|
11
12
|
*/
|
|
12
13
|
export function Navbar({ brand, brandHref = "/", links = [], actions, sticky = true, variant = "line", centered, floating, transparent, collapseBelow = "md", menuFooter, linkAs, "aria-label": ariaLabel, className, }) {
|
|
13
|
-
const {
|
|
14
|
+
const M = useMessages({ navbar: faNavbar });
|
|
14
15
|
const label = ariaLabel ?? M.navbar.label;
|
|
15
16
|
const A = linkAs ?? "a";
|
|
16
17
|
const [open, setOpen] = useState(false);
|
|
@@ -3,7 +3,8 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
3
3
|
import { useEffect, useRef, useState } from "react";
|
|
4
4
|
import { formatRelative } from "@kashi-ui/persian";
|
|
5
5
|
import { cx } from "./cx.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
7
|
+
import { faNotifications } from "@kashi-ui/persian";
|
|
7
8
|
import { Popover } from "./Popover.js";
|
|
8
9
|
const svg = (d) => _jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.7, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: d }) });
|
|
9
10
|
const Bell = () => svg("M5 8a5 5 0 0 1 10 0c0 4 1.5 5.5 1.5 5.5h-13S5 12 5 8ZM8.5 16.5a1.6 1.6 0 0 0 3 0");
|
|
@@ -12,7 +13,8 @@ const CheckAll = () => svg("m2.5 10.5 3 3 6-7M9 13.2l.3.3 6-7");
|
|
|
12
13
|
const day = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime();
|
|
13
14
|
/** فهرست اعلانها با زبانههای «همه» و «خواندهنشده»، گروه امروز و دیروز و زمان نسبی فارسی؛ تنها یا داخل NotificationCenter */
|
|
14
15
|
export function NotificationList({ items, onRead, onReadAll, onSelect, onSettings, viewAllHref, title, now, className }) {
|
|
15
|
-
const {
|
|
16
|
+
const M = useMessages({ notifications: faNotifications });
|
|
17
|
+
const { locale, digits, n } = useKashiLocale();
|
|
16
18
|
const N = M.notifications;
|
|
17
19
|
const [tab, setTab] = useState("all");
|
|
18
20
|
const unread = items.filter((x) => !x.read).length;
|
|
@@ -36,7 +38,8 @@ export function NotificationList({ items, onRead, onReadAll, onSelect, onSetting
|
|
|
36
38
|
}
|
|
37
39
|
/** دکمهٔ زنگ با شمار اعلانهای خواندهنشده که فهرست اعلانها را در پاپاور باز میکند */
|
|
38
40
|
export function NotificationCenter({ open, onOpenChange, placement = "bottom-end", className, ...list }) {
|
|
39
|
-
const {
|
|
41
|
+
const M = useMessages({ notifications: faNotifications });
|
|
42
|
+
const { n } = useKashiLocale();
|
|
40
43
|
const N = M.notifications;
|
|
41
44
|
const unread = list.items.filter((x) => !x.read).length;
|
|
42
45
|
// با رسیدن اعلان تازه، شمارنده یک بار تکان میخورد
|
package/dist/NumberInput.js
CHANGED
|
@@ -4,12 +4,14 @@ import { forwardRef, useId, useState } from "react";
|
|
|
4
4
|
import { formatNumber, onlyDigits, toFaDigits } from "@kashi-ui/persian";
|
|
5
5
|
import { cx } from "./cx.js";
|
|
6
6
|
import { Field, describedBy } from "./Field.js";
|
|
7
|
-
import {
|
|
7
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
8
|
+
import { faNumberInput } from "@kashi-ui/persian";
|
|
8
9
|
const Minus = () => _jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", "aria-hidden": "true", children: _jsx("path", { d: "M5 10h10" }) });
|
|
9
10
|
const Plus = () => _jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", "aria-hidden": "true", children: _jsx("path", { d: "M10 5v10M5 10h10" }) });
|
|
10
11
|
/** ورودی عدد با دکمههای + و −؛ ↑↓ یک گام، PageUp/PageDown ده گام، Home/End کمینه و بیشینه */
|
|
11
12
|
export const NumberInput = forwardRef(function NumberInput({ label, hint, error, value, defaultValue = null, onChange, min, max, step = 1, thousands, digits, unit, disabled, readOnly, name, id, className, labels = {} }, ref) {
|
|
12
|
-
const
|
|
13
|
+
const M = useMessages({ numberInput: faNumberInput });
|
|
14
|
+
const { digits: D } = useKashiLocale();
|
|
13
15
|
digits ?? (digits = D);
|
|
14
16
|
const autoId = useId();
|
|
15
17
|
const inputId = id ?? autoId;
|
package/dist/OtpInput.js
CHANGED
|
@@ -5,13 +5,13 @@ import { onlyDigits, toFaDigits } from "@kashi-ui/persian";
|
|
|
5
5
|
import { cx } from "./cx.js";
|
|
6
6
|
import { Field, describedBy } from "./Field.js";
|
|
7
7
|
import { mergeRefs } from "./utils.js";
|
|
8
|
-
import {
|
|
8
|
+
import { useKashiLocale } from "./KashiProvider.js";
|
|
9
9
|
/**
|
|
10
10
|
* کد تأیید یکبارمصرف: یک input واقعی (نه شش input جدا)، پس چسباندن، پاک کردن،
|
|
11
11
|
* صفحهخوان و پر شدن خودکار کد پیامکی (autocomplete="one-time-code") بینقص کار میکنند.
|
|
12
12
|
*/
|
|
13
13
|
export const OtpInput = forwardRef(function OtpInput({ label, hint, error, length = 6, value, defaultValue = "", onChange, onComplete, digits, groupAfter, size = "md", disabled, readOnly, autoFocus, name, id, className }, ref) {
|
|
14
|
-
const { digits: D } =
|
|
14
|
+
const { digits: D } = useKashiLocale();
|
|
15
15
|
digits ?? (digits = D);
|
|
16
16
|
const autoId = useId();
|
|
17
17
|
const inputId = id ?? autoId;
|
package/dist/Pagination.js
CHANGED
|
@@ -3,7 +3,8 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
3
3
|
import { useState } from "react";
|
|
4
4
|
import { toFaDigits } from "@kashi-ui/persian";
|
|
5
5
|
import { cx } from "./cx.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
7
|
+
import { faCommon, faPagination } from "@kashi-ui/persian";
|
|
7
8
|
/** صفحههایی که نمایش داده میشوند؛ null یعنی «…» */
|
|
8
9
|
export function pageRange(page, total, siblings = 1) {
|
|
9
10
|
const out = [];
|
|
@@ -23,7 +24,8 @@ export function pageRange(page, total, siblings = 1) {
|
|
|
23
24
|
const Chevron = ({ dir }) => (_jsx("svg", { "data-k-mirror": "", viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.7, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: dir === "prev" ? "m12 5-5 5 5 5" : "m8 5 5 5-5 5" }) }));
|
|
24
25
|
/** صفحهبندی با ارقام فارسی؛ صفحهٔ فعلی با aria-current="page" */
|
|
25
26
|
export function Pagination({ page, total, onChange, getHref, siblings = 1, summary, digits, pageSize, pageSizes = [10, 20, 50, 100], onPageSizeChange, jumper, labels = {}, className, }) {
|
|
26
|
-
const {
|
|
27
|
+
const M = useMessages({ common: faCommon, pagination: faPagination });
|
|
28
|
+
const { digits: D } = useKashiLocale();
|
|
27
29
|
digits ?? (digits = D);
|
|
28
30
|
const n = (v) => (digits === "fa" ? toFaDigits(v) : String(v));
|
|
29
31
|
const { nav = M.pagination.nav, prev = M.common.prev, next = M.common.next, page: pageLabel = (x) => M.pagination.page(x), perPage = M.pagination.perPage, jump = M.pagination.jump } = labels;
|
package/dist/PasswordStrength.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { faPassword, toFaDigits } from "@kashi-ui/persian";
|
|
4
4
|
import { cx } from "./cx.js";
|
|
5
|
-
import {
|
|
5
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
6
6
|
/** شرطهای پیشفرض با متنهای زبان فعلی */
|
|
7
7
|
const rulesFor = (m, n) => [
|
|
8
8
|
{ label: m.length(n(8)), test: (p) => p.length >= 8 },
|
|
@@ -11,12 +11,13 @@ const rulesFor = (m, n) => [
|
|
|
11
11
|
{ label: m.symbol, test: (p) => /[^A-Za-z0-9\s-ۿ]/.test(p) },
|
|
12
12
|
];
|
|
13
13
|
/** شرطهای پیشفرض به فارسی؛ بدون rules، کامپوننت همینها را به زبان KashiProvider نشان میدهد */
|
|
14
|
-
export const defaultPasswordRules = rulesFor(
|
|
14
|
+
export const defaultPasswordRules = rulesFor(faPassword, (v) => toFaDigits(v));
|
|
15
15
|
const Check = () => _jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "m5 10.5 3.2 3L15 7" }) });
|
|
16
16
|
const Dot = () => _jsx("svg", { viewBox: "0 0 20 20", "aria-hidden": "true", children: _jsx("circle", { cx: "10", cy: "10", r: "2.5", fill: "currentColor" }) });
|
|
17
17
|
/** قدرت رمز عبور با نوار چهارقسمتی و فهرست شرطها؛ زیر فیلد رمز بگذارید و با id به آن وصل کنید */
|
|
18
18
|
export function PasswordStrength({ password, rules, showRules = true, warnPersian = true, id, className, labels = {} }) {
|
|
19
|
-
const
|
|
19
|
+
const M = useMessages({ password: faPassword });
|
|
20
|
+
const { n: N } = useKashiLocale();
|
|
20
21
|
rules ?? (rules = rulesFor(M.password, N));
|
|
21
22
|
const { title = M.password.title, levels = M.password.levels, persian = M.password.persian } = labels;
|
|
22
23
|
const met = rules.map((r) => r.test(password));
|
package/dist/PaymentReceipt.js
CHANGED
|
@@ -7,11 +7,13 @@ import { CopyButton } from "./CopyButton.js";
|
|
|
7
7
|
import { cx } from "./cx.js";
|
|
8
8
|
import { ErrorIcon, SuccessIcon, WarningIcon } from "./icons.js";
|
|
9
9
|
import { Money } from "./Money.js";
|
|
10
|
-
import {
|
|
10
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
11
|
+
import { faBankCard, faCommon, faMoney, faReceipt } from "@kashi-ui/persian";
|
|
11
12
|
const ICONS = { success: SuccessIcon, failed: ErrorIcon, pending: WarningIcon };
|
|
12
13
|
/** رسید پرداخت: وضعیت، مبلغ به عدد و حروف، کد پیگیری با دکمهٔ کپی، کارت پوشانده با لوگوی بانک و تاریخ شمسی */
|
|
13
14
|
export const PaymentReceipt = forwardRef(function PaymentReceipt({ status, amount, unit = "toman", title, description, merchant, trackingCode, referenceId, cardNumber, date, rows = [], children, className, ...rest }, ref) {
|
|
14
|
-
const {
|
|
15
|
+
const M = useMessages({ bankCard: faBankCard, common: faCommon, money: faMoney, receipt: faReceipt });
|
|
16
|
+
const { digits: D, locale, n } = useKashiLocale();
|
|
15
17
|
const R = M.receipt;
|
|
16
18
|
const id = useId();
|
|
17
19
|
const card = cardNumber ? onlyDigits(cardNumber) : "";
|
package/dist/PersianInput.js
CHANGED
|
@@ -16,7 +16,8 @@ import { EconomicCodeInput } from "./EconomicCodeInput.js";
|
|
|
16
16
|
import { TaxIdInput } from "./TaxIdInput.js";
|
|
17
17
|
import { PriceInput } from "./PriceInput.js";
|
|
18
18
|
import { TimeInput } from "./TimeInput.js";
|
|
19
|
-
import {
|
|
19
|
+
import { useMessages } from "./KashiProvider.js";
|
|
20
|
+
import { faPersianInput } from "@kashi-ui/persian";
|
|
20
21
|
/** برچسب پیشفرض هر نوع، اگر label یا aria-label داده نشود */
|
|
21
22
|
export const PERSIAN_INPUT_LABELS = {
|
|
22
23
|
text: "متن",
|
|
@@ -61,7 +62,7 @@ const COMPONENTS = {
|
|
|
61
62
|
export const PersianInput = forwardRef(function PersianInput({ kind, ...rest }, ref) {
|
|
62
63
|
const Component = COMPONENTS[kind];
|
|
63
64
|
const props = rest;
|
|
64
|
-
const {
|
|
65
|
+
const M = useMessages({ persianInput: faPersianInput });
|
|
65
66
|
const label = props.label ?? (props["aria-label"] ? undefined : M.persianInput[kind]);
|
|
66
67
|
// PlateInput چند فیلد دارد و ref نمیگیرد
|
|
67
68
|
return _jsx(Component, { ref: kind === "plate" ? undefined : ref, ...props, label: label, "data-kind": kind });
|
package/dist/PersianTextarea.js
CHANGED
|
@@ -4,11 +4,13 @@ import { forwardRef, useMemo, useState } from "react";
|
|
|
4
4
|
import { fixPersianText } from "@kashi-ui/persian";
|
|
5
5
|
import { Button } from "./Button.js";
|
|
6
6
|
import { Textarea } from "./Input.js";
|
|
7
|
-
import {
|
|
7
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
8
|
+
import { faCommon, faTextFix } from "@kashi-ui/persian";
|
|
8
9
|
const KINDS = ["arabic", "zwnj", "punctuation", "digits", "spacing"];
|
|
9
10
|
/** ناحیهٔ متن با ویرایش نگارشی فارسی: «ي/ك» عربی، نیمفاصله، ویرگول و علامت سؤال فارسی و ارقام */
|
|
10
11
|
export const PersianTextarea = forwardRef(function PersianTextarea({ value, defaultValue = "", onValueChange, fixDigits = true, fixOnBlur = false, labels = {}, hint, onBlur, ...rest }, ref) {
|
|
11
|
-
const {
|
|
12
|
+
const M = useMessages({ common: faCommon, textFix: faTextFix });
|
|
13
|
+
const { n } = useKashiLocale();
|
|
12
14
|
const { fix = M.textFix.fix, clean = M.textFix.clean } = labels;
|
|
13
15
|
const [inner, setInner] = useState(defaultValue);
|
|
14
16
|
const current = value ?? inner;
|
package/dist/PlateInput.js
CHANGED
|
@@ -3,14 +3,15 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useId, useRef, useState } from "react";
|
|
4
4
|
import { PLATE_LETTERS, formatPlate, isValidPlate, onlyDigits, plateType, toFaDigits } from "@kashi-ui/persian";
|
|
5
5
|
import { Field, describedBy } from "./Field.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useMessages } from "./KashiProvider.js";
|
|
7
|
+
import { faInvalid, faPlate } from "@kashi-ui/persian";
|
|
7
8
|
const EMPTY = { first: "", letter: "", middle: "", region: "" };
|
|
8
9
|
/**
|
|
9
10
|
* پلاک خودروی ایران با ظاهر واقعی: دو رقم، حرف، سه رقم و کد استان.
|
|
10
11
|
* با پر شدن هر بخش فوکوس خودکار به بخش بعد میرود و Backspace در بخش خالی به قبلی برمیگردد.
|
|
11
12
|
*/
|
|
12
13
|
export function PlateInput({ label, hint, error, value, defaultValue, onChange, name, disabled, id, className, invalidMessage, labels = {}, }) {
|
|
13
|
-
const {
|
|
14
|
+
const M = useMessages({ invalid: faInvalid, plate: faPlate });
|
|
14
15
|
invalidMessage ?? (invalidMessage = M.invalid.plate);
|
|
15
16
|
const autoId = useId();
|
|
16
17
|
const groupId = id ?? autoId;
|
package/dist/PostalCodeInput.js
CHANGED
|
@@ -5,10 +5,12 @@ import { formatPostalCode, isValidPostalCode } from "@kashi-ui/persian";
|
|
|
5
5
|
import { Input } from "./Input.js";
|
|
6
6
|
import { useDigitsInput } from "./useDigitsInput.js";
|
|
7
7
|
import { mergeRefs } from "./utils.js";
|
|
8
|
-
import {
|
|
8
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
9
|
+
import { faInvalid } from "@kashi-ui/persian";
|
|
9
10
|
/** کد پستی ۱۰ رقمی با قالب ۱۲۳۴۵-۶۷۸۹۰ و بررسی قواعد کد پستی ایران */
|
|
10
11
|
export const PostalCodeInput = forwardRef(function PostalCodeInput({ value, defaultValue, onValueChange, digits, invalidMessage, error, name, onBlur, placeholder, ...rest }, ref) {
|
|
11
|
-
const
|
|
12
|
+
const M = useMessages({ invalid: faInvalid });
|
|
13
|
+
const { digits: D, locale } = useKashiLocale();
|
|
12
14
|
digits ?? (digits = D);
|
|
13
15
|
invalidMessage ?? (invalidMessage = M.invalid.postal);
|
|
14
16
|
const { raw, shown, inputRef, handleChange } = useDigitsInput({ value, defaultValue, maxDigits: 10, format: formatPostalCode, digits });
|
package/dist/PriceInput.js
CHANGED
|
@@ -5,11 +5,13 @@ import { formatNumber, numberToWords, toFaDigits } from "@kashi-ui/persian";
|
|
|
5
5
|
import { Input } from "./Input.js";
|
|
6
6
|
import { useDigitsInput } from "./useDigitsInput.js";
|
|
7
7
|
import { mergeRefs } from "./utils.js";
|
|
8
|
-
import {
|
|
8
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
9
|
+
import { faInvalid, faMoney } from "@kashi-ui/persian";
|
|
9
10
|
const toRaw = (n) => (n === null || n === undefined ? undefined : String(Math.trunc(Math.abs(n))));
|
|
10
11
|
/** فیلد مبلغ: جداکنندهٔ هزارگان، واحد پول و نمایش مبلغ به حروف برای اطمینان کاربر */
|
|
11
12
|
export const PriceInput = forwardRef(function PriceInput({ value, defaultValue, onValueChange, unit, showWords = true, digits, min, max, rangeMessage, error, hint, name, onBlur, placeholder, ...rest }, ref) {
|
|
12
|
-
const {
|
|
13
|
+
const M = useMessages({ invalid: faInvalid, money: faMoney });
|
|
14
|
+
const { digits: D, locale } = useKashiLocale();
|
|
13
15
|
digits ?? (digits = D);
|
|
14
16
|
unit ?? (unit = M.money.toman);
|
|
15
17
|
const money = (v) => (digits === "fa" ? toFaDigits(formatNumber(v)) : formatNumber(v, { digits: "latin" }));
|
package/dist/PriceRange.js
CHANGED
|
@@ -3,11 +3,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useEffect, useId, useState } from "react";
|
|
4
4
|
import { formatNumber, toEnDigits } from "@kashi-ui/persian";
|
|
5
5
|
import { cx } from "./cx.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
7
|
+
import { faPriceRange } from "@kashi-ui/persian";
|
|
7
8
|
import { Slider } from "./Slider.js";
|
|
8
9
|
/** فیلتر بازهٔ قیمت: دو فیلد «از» و «تا» با جداکنندهٔ هزارگان و یک اسلایدر دودستگیره که با هم هماهنگاند */
|
|
9
10
|
export function PriceRange({ min, max, value, defaultValue, onChange, step = 1000, label, unit, name, disabled, className, labels = {}, }) {
|
|
10
|
-
const
|
|
11
|
+
const M = useMessages({ priceRange: faPriceRange });
|
|
12
|
+
const { digits: D, locale } = useKashiLocale();
|
|
11
13
|
const id = useId();
|
|
12
14
|
const [inner, setInner] = useState(defaultValue ?? [min, max]);
|
|
13
15
|
const [lo, hi] = value ?? inner;
|
package/dist/Progress.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { cx } from "./cx.js";
|
|
4
|
-
import {
|
|
4
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
5
|
+
import { faCommon } from "@kashi-ui/persian";
|
|
5
6
|
export function Progress({ value, max = 100, label, showValue, size = "md", tone = "brand", variant = "linear", className, "aria-label": ariaLabel, ...rest }) {
|
|
6
|
-
const {
|
|
7
|
+
const M = useMessages({ common: faCommon });
|
|
8
|
+
const { n } = useKashiLocale();
|
|
7
9
|
const pct = value === undefined ? undefined : Math.max(0, Math.min(100, (value / max) * 100));
|
|
8
10
|
const text = pct === undefined ? undefined : M.common.percent(n(Math.round(pct)));
|
|
9
11
|
if (variant === "circular") {
|
|
@@ -18,7 +20,7 @@ export function Progress({ value, max = 100, label, showValue, size = "md", tone
|
|
|
18
20
|
}
|
|
19
21
|
/** اسپینر با متن صفحهخوان */
|
|
20
22
|
export function Spinner({ label, size = "md", className, ...rest }) {
|
|
21
|
-
const {
|
|
23
|
+
const M = useMessages({ common: faCommon });
|
|
22
24
|
label ?? (label = M.common.loading);
|
|
23
25
|
return (_jsxs("span", { role: "status", className: className, ...rest, children: [_jsx("span", { className: cx("k-spinner", size !== "md" && `k-spinner--${size}`), "aria-hidden": "true" }), _jsx("span", { className: "k-sr-only", children: label })] }));
|
|
24
26
|
}
|
package/dist/ProvinceSelect.js
CHANGED
|
@@ -3,10 +3,11 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
4
|
import { PROVINCES } from "@kashi-ui/persian";
|
|
5
5
|
import { Combobox } from "./Combobox.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useMessages } from "./KashiProvider.js";
|
|
7
|
+
import { faProvince } from "@kashi-ui/persian";
|
|
7
8
|
const options = (capital, label) => PROVINCES.map((p) => ({ value: p.name, label: p.name, description: capital ? label(p.capital) : undefined, keywords: [p.capital] }));
|
|
8
9
|
/** انتخاب یکی از ۳۱ استان با جستجو؛ با نام مرکز استان هم پیدا میشود (مثلاً «مشهد») */
|
|
9
10
|
export const ProvinceSelect = forwardRef(function ProvinceSelect({ showCapital = true, label, placeholder, ...rest }, ref) {
|
|
10
|
-
const {
|
|
11
|
+
const M = useMessages({ province: faProvince });
|
|
11
12
|
return _jsx(Combobox, { ref: ref, label: label ?? M.province.label, placeholder: placeholder ?? M.province.search, options: options(showCapital, M.province.capital), ...rest });
|
|
12
13
|
});
|
package/dist/QRCode.js
CHANGED
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useMemo } from "react";
|
|
4
4
|
import { cx } from "./cx.js";
|
|
5
|
-
import {
|
|
5
|
+
import { useMessages } from "./KashiProvider.js";
|
|
6
|
+
import { faQr } from "@kashi-ui/persian";
|
|
6
7
|
import { encodeQr } from "./qr.js";
|
|
7
8
|
/**
|
|
8
9
|
* کد QR بدون کتابخانهٔ جانبی، به شکل SVG: رنگ از currentColor و پسزمینه از --k-qr-bg میآید.
|
|
9
10
|
* کد همیشه تیره روی روشن است تا همهٔ دوربینها بخوانندش، حتی در تم تیره.
|
|
10
11
|
*/
|
|
11
12
|
export function QRCode({ value, size = 160, level = "M", margin = 4, logo, rounded = true, "aria-label": ariaLabel, className }) {
|
|
12
|
-
const {
|
|
13
|
+
const M = useMessages({ qr: faQr });
|
|
13
14
|
const lvl = logo ? "H" : level;
|
|
14
15
|
const matrix = useMemo(() => encodeQr(value, lvl), [value, lvl]);
|
|
15
16
|
if (!matrix)
|
package/dist/Rating.js
CHANGED
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useId, useState } from "react";
|
|
4
4
|
import { cx } from "./cx.js";
|
|
5
|
-
import {
|
|
5
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
6
|
+
import { faCommon, faRating } from "@kashi-ui/persian";
|
|
6
7
|
const Star = () => (_jsxs("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", children: [_jsx("path", { fill: "currentColor", d: "M12 2.8l2.8 5.9 6.4.8-4.7 4.4 1.2 6.3L12 17.1l-5.7 3.1 1.2-6.3L2.8 9.5l6.4-.8z" }), _jsx("path", { className: "k-rating__half", fill: "none", d: "M12 2.8v14.3l-5.7 3.1 1.2-6.3L2.8 9.5l6.4-.8z" })] }));
|
|
7
8
|
/** امتیاز ستارهای؛ قابلانتخاب با رادیوهای بومی (←→) یا فقطخواندنی */
|
|
8
9
|
export function Rating({ value, defaultValue = 0, onChange, max = 5, readOnly, showValue, size = "md", label, name, disabled, className, starLabel, }) {
|
|
9
|
-
const {
|
|
10
|
+
const M = useMessages({ common: faCommon, rating: faRating });
|
|
11
|
+
const { n: N } = useKashiLocale();
|
|
10
12
|
const fa = (x) => N(x).replace(".", M.common.decimal);
|
|
11
13
|
label ?? (label = M.rating.label);
|
|
12
14
|
starLabel ?? (starLabel = (a, b) => M.common.of(fa(a), fa(b)));
|
package/dist/RelativeTime.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useState } from "react";
|
|
4
4
|
import { formatJalali, formatRelative } from "@kashi-ui/persian";
|
|
5
|
-
import {
|
|
5
|
+
import { useKashiLocale } from "./KashiProvider.js";
|
|
6
6
|
/** «۵ دقیقه پیش» در یک <time> معنایی؛ تاریخ کامل شمسی در title و برای صفحهخوان در دسترس است */
|
|
7
7
|
export function RelativeTime({ date, digits, refresh = 60000, ...rest }) {
|
|
8
|
-
const { digits: D, locale } =
|
|
8
|
+
const { digits: D, locale } = useKashiLocale();
|
|
9
9
|
digits ?? (digits = D);
|
|
10
10
|
const [now, setNow] = useState(() => new Date());
|
|
11
11
|
useEffect(() => {
|