@kashi-ui/react 2.25.0 → 2.26.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/DataTable.js
CHANGED
|
@@ -3,7 +3,8 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
3
3
|
import { useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
import { toEnDigits } from "@kashi-ui/persian";
|
|
5
5
|
import { cx } from "./cx.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useMessages } from "./KashiProvider.js";
|
|
7
|
+
import { faCommon, faTable } from "@kashi-ui/persian";
|
|
7
8
|
/** جدول داده با مرتبسازی (aria-sort)، انتخاب ردیفها و حالت خالی */
|
|
8
9
|
export function DataTable({ columns, rows, getRowId, caption, description, hideCaption, selectable, selected, onSelectedChange, sort, defaultSort = null, onSortChange, empty, compact, striped, stickyHeader, maxHeight, loading, onRowClick, footer, virtual, onCellEdit, exportable, labels = {}, classNames = {}, className, }) {
|
|
9
10
|
const id = useId();
|
|
@@ -42,7 +43,7 @@ export function DataTable({ columns, rows, getRowId, caption, description, hideC
|
|
|
42
43
|
if (allRef.current)
|
|
43
44
|
allRef.current.indeterminate = some;
|
|
44
45
|
}, [some]);
|
|
45
|
-
const {
|
|
46
|
+
const M = useMessages({ common: faCommon, table: faTable });
|
|
46
47
|
const { selectAll = M.table.selectAll, selectRow = () => M.table.selectRow, loading: loadingLabel = M.common.loading } = labels;
|
|
47
48
|
const loadingRows = loading === true ? 5 : typeof loading === "number" ? loading : 0;
|
|
48
49
|
const cellCls = (c) => cx(c.numeric && "k-table__num", c.align && !c.numeric && `k-table__align-${c.align}`, c.hideBelow && `k-table__hide-${c.hideBelow}`, c.className, classNames.cell) || undefined;
|
package/dist/DatePicker.js
CHANGED
|
@@ -5,13 +5,15 @@ import { formatJalali, parseJalali, toISODate } from "@kashi-ui/persian";
|
|
|
5
5
|
import { Calendar, sameDay } from "./Calendar.js";
|
|
6
6
|
import { Input } from "./Input.js";
|
|
7
7
|
import { mergeRefs, useIsomorphicLayoutEffect } from "./utils.js";
|
|
8
|
-
import {
|
|
8
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
9
|
+
import { faCommon, faDatePicker } from "@kashi-ui/persian";
|
|
9
10
|
/**
|
|
10
11
|
* انتخاب تاریخ شمسی: تایپ مستقیم (۱۴۰۳/۰۵/۱۲) یا انتخاب از تقویم.
|
|
11
12
|
* با name، مقدار میلادی به شکل YYYY-MM-DD در فرم ارسال میشود.
|
|
12
13
|
*/
|
|
13
14
|
export const DatePicker = forwardRef(function DatePicker({ value, defaultValue = null, onChange, min, max, isDateDisabled, holidays, digits, yearRange, invalidMessage, openLabel, todayLabel, calendarLabels, error, name, onBlur, placeholder, readOnly, ...rest }, ref) {
|
|
14
|
-
const {
|
|
15
|
+
const M = useMessages({ common: faCommon, datePicker: faDatePicker });
|
|
16
|
+
const { digits: D, locale } = useKashiLocale();
|
|
15
17
|
digits ?? (digits = D);
|
|
16
18
|
invalidMessage ?? (invalidMessage = M.datePicker.invalid);
|
|
17
19
|
openLabel ?? (openLabel = M.datePicker.open);
|
package/dist/DateRangePicker.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useId, useRef, useState } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { faDateRange, fiscalYearOf, fiscalYearRange, formatJalali, jalaliSeason, seasonRange, toFaDigits, toGregorian, toISODate, toJalali } from "@kashi-ui/persian";
|
|
5
5
|
import { Calendar } from "./Calendar.js";
|
|
6
6
|
import { Field } from "./Field.js";
|
|
7
7
|
import { cx } from "./cx.js";
|
|
8
|
-
import {
|
|
8
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
9
|
+
import { faCommon } from "@kashi-ui/persian";
|
|
9
10
|
const day = (d, add = 0) => new Date(d.getFullYear(), d.getMonth(), d.getDate() + add);
|
|
10
11
|
/** میانبرهای پیشفرض با ماههای شمسی، با متنهای یک زبان */
|
|
11
12
|
const presetsFor = (m, n) => [
|
|
@@ -32,7 +33,7 @@ const span = (r) => ({ start: r.from, end: r.to });
|
|
|
32
33
|
* میانبرهای گزارشگیری: امروز، ۷ و ۳۰ روز، این ماه و ماه قبل، فصل جاری و قبلی، سال مالی جاری و قبلی.
|
|
33
34
|
* startMonth ماه شروع سال مالی است (۱ = فروردین؛ برای سال مالی تیرماهی ۴).
|
|
34
35
|
*/
|
|
35
|
-
export function fiscalRangePresets({ messages =
|
|
36
|
+
export function fiscalRangePresets({ messages = faDateRange, n = (v) => toFaDigits(v), startMonth = 1, today = new Date() } = {}) {
|
|
36
37
|
const fy = fiscalYearOf(today, startMonth);
|
|
37
38
|
return [
|
|
38
39
|
{ label: messages.today, range: (t) => ({ start: day(t), end: day(t) }) },
|
|
@@ -47,13 +48,14 @@ export function fiscalRangePresets({ messages = faMessages.dateRange, n = (v) =>
|
|
|
47
48
|
];
|
|
48
49
|
}
|
|
49
50
|
/** میانبرهای پیشفرض به فارسی؛ بدون presets، کامپوننت همینها را به زبان KashiProvider نشان میدهد */
|
|
50
|
-
export const defaultRangePresets = presetsFor(
|
|
51
|
+
export const defaultRangePresets = presetsFor(faDateRange, (v) => toFaDigits(v));
|
|
51
52
|
/**
|
|
52
53
|
* انتخاب بازهٔ تاریخ شمسی: کلیک اول شروع، کلیک دوم پایان؛ پیش از تأیید، بازه با حرکت موس پیشنمایش میشود.
|
|
53
54
|
* تغییرها فقط با «تأیید» ثبت میشوند.
|
|
54
55
|
*/
|
|
55
56
|
export function DateRangePicker({ label, hint, error, value, defaultValue = { start: null, end: null }, onChange, min, max, isDateDisabled, holidays, presets, fiscalPresets, today: todayProp, digits, name, disabled, readOnly, id, className, calendarLabels, labels = {}, }) {
|
|
56
|
-
const
|
|
57
|
+
const M = useMessages({ common: faCommon, dateRange: faDateRange });
|
|
58
|
+
const { digits: D, locale, n: N } = useKashiLocale();
|
|
57
59
|
digits ?? (digits = D);
|
|
58
60
|
presets ?? (presets = fiscalPresets
|
|
59
61
|
? fiscalRangePresets({ messages: M.dateRange, n: N, startMonth: typeof fiscalPresets === "number" ? fiscalPresets : 1, today: todayProp ?? new Date() })
|
package/dist/DateTile.js
CHANGED
|
@@ -3,13 +3,13 @@ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
4
|
import { getIranHoliday, jalaliWeekday, toISODate, toJalali } from "@kashi-ui/persian";
|
|
5
5
|
import { cx } from "./cx.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useKashiLocale } from "./KashiProvider.js";
|
|
7
7
|
const gregFmt = new Intl.DateTimeFormat("fa-IR-u-ca-gregory-nu-arabext", { day: "numeric", month: "long", year: "numeric" });
|
|
8
8
|
const gregFmtEn = new Intl.DateTimeFormat("en-US", { day: "numeric", month: "long", year: "numeric" });
|
|
9
9
|
/** کاشی تاریخ شمسی به شکل برگ تقویم: روز، ماه، روز هفته، مناسبت تعطیل و معادل میلادی */
|
|
10
10
|
export const DateTile = forwardRef(function DateTile({ date, holidays = true, gregorian = true, size = "md", className, ...rest }, ref) {
|
|
11
11
|
const { jy, jm, jd } = toJalali(date);
|
|
12
|
-
const { n, locale, months: MONTHS, weekdays: WD, friday: FRI } =
|
|
12
|
+
const { n, locale, months: MONTHS, weekdays: WD, friday: FRI } = useKashiLocale();
|
|
13
13
|
const holiday = holidays ? getIranHoliday(date, holidays === true ? { locale } : { locale, ...holidays }) : null;
|
|
14
14
|
const occasion = holiday && holiday !== FRI ? holiday : null;
|
|
15
15
|
return (_jsxs("time", { ref: ref, dateTime: toISODate(date), className: cx("k-datetile", `k-datetile--${size}`, className), "data-holiday": holiday ? "" : undefined, ...rest, children: [_jsxs("span", { className: "k-datetile__head", children: [MONTHS[jm - 1], " ", n(jy)] }), _jsx("span", { className: "k-datetile__day", children: n(jd) }), _jsx("span", { className: "k-datetile__weekday", children: WD[jalaliWeekday(date)] }), occasion && _jsx("span", { className: "k-datetile__occasion", children: occasion }), gregorian && _jsx("span", { className: "k-datetile__greg", children: (locale === "en" ? gregFmtEn : gregFmt).format(date) })] }));
|
package/dist/Dialog.js
CHANGED
|
@@ -3,7 +3,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useId, useRef } from "react";
|
|
4
4
|
import { cx } from "./cx.js";
|
|
5
5
|
import { CloseIcon } from "./icons.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useMessages } from "./KashiProvider.js";
|
|
7
|
+
import { faCommon } from "@kashi-ui/persian";
|
|
7
8
|
import { useModalDialog } from "./modal.js";
|
|
8
9
|
/**
|
|
9
10
|
* پنجرهٔ گفتگو روی <dialog> بومی با showModal:
|
|
@@ -11,7 +12,7 @@ import { useModalDialog } from "./modal.js";
|
|
|
11
12
|
* و پس از بستن، فوکوس به عنصری که پنجره را باز کرده برمیگردد.
|
|
12
13
|
*/
|
|
13
14
|
export function Dialog({ open, onOpenChange, title, description, icon, tone = "default", size = "md", footer, dismissible = true, closeLabel, placement = "center", className, children, }) {
|
|
14
|
-
const {
|
|
15
|
+
const M = useMessages({ common: faCommon });
|
|
15
16
|
closeLabel ?? (closeLabel = M.common.close);
|
|
16
17
|
const ref = useRef(null);
|
|
17
18
|
const id = useId();
|
package/dist/Drawer.js
CHANGED
|
@@ -3,14 +3,15 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useId, useRef } from "react";
|
|
4
4
|
import { cx } from "./cx.js";
|
|
5
5
|
import { CloseIcon } from "./icons.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useMessages } from "./KashiProvider.js";
|
|
7
|
+
import { faCommon } from "@kashi-ui/persian";
|
|
7
8
|
import { useModalDialog } from "./modal.js";
|
|
8
9
|
/**
|
|
9
10
|
* کشوی کناری روی <dialog> بومی: فیلترها، جزئیات یک ردیف، تنظیمات یا منوی گوشی.
|
|
10
11
|
* فوکوس داخل کشو میماند، Esc میبندد و با انیمیشن خروج بسته میشود.
|
|
11
12
|
*/
|
|
12
13
|
export function Drawer({ open, onOpenChange, title, description, side = "end", size = "md", footer, dismissible = true, closeLabel, className, children, }) {
|
|
13
|
-
const {
|
|
14
|
+
const M = useMessages({ common: faCommon });
|
|
14
15
|
closeLabel ?? (closeLabel = M.common.close);
|
|
15
16
|
const ref = useRef(null);
|
|
16
17
|
const id = useId();
|
|
@@ -5,13 +5,15 @@ import { economicCodeType, isValidEconomicCode } 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, faTaxCode } from "@kashi-ui/persian";
|
|
9
10
|
/**
|
|
10
11
|
* کد اقتصادی فاکتور: ۱۰ رقم (کد ملی شخص حقیقی)، ۱۱ رقم (شناسهٔ ملی شخص حقوقی) یا ۱۲ رقم قدیمی.
|
|
11
12
|
* کد ملی و شناسهٔ ملی با رقم کنترل خودشان بررسی میشوند و نوع کنار فیلد میآید.
|
|
12
13
|
*/
|
|
13
14
|
export const EconomicCodeInput = forwardRef(function EconomicCodeInput({ value, defaultValue, onValueChange, showType = true, digits, invalidMessage, error, name, onBlur, placeholder, ...rest }, ref) {
|
|
14
|
-
const {
|
|
15
|
+
const M = useMessages({ invalid: faInvalid, taxCode: faTaxCode });
|
|
16
|
+
const { digits: D } = useKashiLocale();
|
|
15
17
|
digits ?? (digits = D);
|
|
16
18
|
invalidMessage ?? (invalidMessage = M.invalid.economicCode);
|
|
17
19
|
const { raw, shown, inputRef, handleChange } = useDigitsInput({ value, defaultValue, maxDigits: 12, format: (d) => d, digits });
|
package/dist/EmptyState.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
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 { useMessages } from "./KashiProvider.js";
|
|
5
|
+
import { faEmpty } from "@kashi-ui/persian";
|
|
5
6
|
const P = { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true };
|
|
6
7
|
// آیکونها از @kashi-ui/icons، کپیشده تا پکیج React به آن وابسته نشود
|
|
7
8
|
const ICONS = {
|
|
@@ -14,7 +15,7 @@ const ICONS = {
|
|
|
14
15
|
};
|
|
15
16
|
/** حالت خالی: وقتی دادهای برای نمایش نیست؛ بگویید چرا و قدم بعدی را پیشنهاد کنید */
|
|
16
17
|
export function EmptyState({ title, description, icon, actions, preset, size = "md", bordered, className, ...rest }) {
|
|
17
|
-
const {
|
|
18
|
+
const M = useMessages({ empty: faEmpty });
|
|
18
19
|
const text = preset ? M.empty[preset] : undefined;
|
|
19
20
|
title ?? (title = text?.[0]);
|
|
20
21
|
description ?? (description = text?.[1]);
|
package/dist/Field.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
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 { useMessages } from "./KashiProvider.js";
|
|
5
|
+
import { faCommon } from "@kashi-ui/persian";
|
|
5
6
|
/** شناسهٔ متنهای راهنما و خطا برای aria-describedby */
|
|
6
7
|
export const hintId = (id) => `${id}-hint`;
|
|
7
8
|
export const errorId = (id) => `${id}-error`;
|
|
@@ -10,7 +11,7 @@ export function describedBy(id, hint, error, extra) {
|
|
|
10
11
|
}
|
|
11
12
|
/** قالب مشترک برچسب + کنترل + راهنما/خطا */
|
|
12
13
|
export function Field({ id, label, hint, error, required, optional, labelEnd, hintEnd, className, classNames = {}, children }) {
|
|
13
|
-
const {
|
|
14
|
+
const M = useMessages({ common: faCommon });
|
|
14
15
|
const optionalText = optional === true ? M.common.optional : optional;
|
|
15
16
|
return (_jsxs("div", { className: cx("k-field", className, classNames.root), "data-invalid": error ? "" : undefined, children: [(label || labelEnd) && (_jsxs("div", { className: "k-field__label-row", children: [label && (_jsxs("label", { className: cx("k-label", classNames.label), htmlFor: id, children: [label, required && _jsx("span", { className: "k-label__required", "aria-hidden": "true", children: "*" }), optionalText && _jsx("span", { className: "k-label__optional", children: optionalText })] })), labelEnd && _jsx("span", { className: "k-field__label-end", children: labelEnd })] })), children, (error || hint || hintEnd) && (_jsxs("div", { className: "k-field__hint-row", children: [_jsxs("div", { className: "k-field__hints", children: [error && _jsx("p", { className: cx("k-hint k-hint--error", classNames.error), id: errorId(id), children: error }), hint && _jsx("p", { className: cx("k-hint", classNames.hint), id: hintId(id), children: hint })] }), hintEnd] }))] }));
|
|
16
17
|
}
|
package/dist/FileUpload.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export interface FileItem {
|
|
|
14
14
|
note?: string;
|
|
15
15
|
}
|
|
16
16
|
/** حجم فایل: ۱٫۲ مگابایت؛ با locale="en" ← «1.2 MB» */
|
|
17
|
-
export declare function formatBytes(bytes: number, locale?: KashiLocale): string;
|
|
17
|
+
export declare function formatBytes(bytes: number, locale?: KashiLocale, units?: readonly string[]): string;
|
|
18
18
|
export interface ImageResizeOptions {
|
|
19
19
|
/** بلندترین ضلع تصویر بعد از کوچک شدن، به پیکسل */
|
|
20
20
|
maxDimension: number;
|
package/dist/FileUpload.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useId, useRef, useState } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { faFileUpload, toFaDigits } from "@kashi-ui/persian";
|
|
5
5
|
import { cx } from "./cx.js";
|
|
6
6
|
import { Progress } from "./Progress.js";
|
|
7
|
-
import {
|
|
7
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
8
|
+
import { faCommon } from "@kashi-ui/persian";
|
|
8
9
|
/** حجم فایل: ۱٫۲ مگابایت؛ با locale="en" ← «1.2 MB» */
|
|
9
|
-
export function formatBytes(bytes, locale = "fa") {
|
|
10
|
+
export function formatBytes(bytes, locale = "fa", units) {
|
|
10
11
|
const en = locale === "en";
|
|
11
|
-
|
|
12
|
+
// واحدها از متنهای کامپوننت (units)؛ بدون آن فارسی، یا نمادهای بینالمللی برای انگلیسی
|
|
13
|
+
units ?? (units = en ? ["B", "KB", "MB", "GB"] : faFileUpload.units);
|
|
12
14
|
let v = bytes;
|
|
13
15
|
let i = 0;
|
|
14
16
|
while (v >= 1024 && i < units.length - 1) {
|
|
@@ -84,8 +86,9 @@ export function FileUpload({ accept, multiple = true, maxSize, maxFiles, uploade
|
|
|
84
86
|
itemsRef.current = items;
|
|
85
87
|
const [dragging, setDragging] = useState(false);
|
|
86
88
|
const [announce, setAnnounce] = useState("");
|
|
87
|
-
const {
|
|
88
|
-
const
|
|
89
|
+
const M = useMessages({ common: faCommon, fileUpload: faFileUpload });
|
|
90
|
+
const { n: N, locale } = useKashiLocale();
|
|
91
|
+
const bytes = (b) => formatBytes(b, locale, M.fileUpload.units);
|
|
89
92
|
const { browse = M.fileUpload.browse, drop = M.fileUpload.drop, remove = M.common.remove, tooBig = M.fileUpload.tooBig, wrongType = M.fileUpload.wrongType, tooMany = (x) => M.fileUpload.tooMany(N(x)), done = M.fileUpload.done, uploading = M.fileUpload.uploading, } = labels;
|
|
90
93
|
const update = (fn) => setItems((prev) => {
|
|
91
94
|
const next = fn(prev);
|
package/dist/Gantt.js
CHANGED
|
@@ -3,7 +3,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useId, useMemo, useRef, useState } from "react";
|
|
4
4
|
import { formatJalali, getIranHoliday, toJalali } from "@kashi-ui/persian";
|
|
5
5
|
import { cx } from "./cx.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
7
|
+
import { faCommon, faGantt } from "@kashi-ui/persian";
|
|
7
8
|
const DAY = 86400000;
|
|
8
9
|
const midnight = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
|
9
10
|
const addDays = (d, n) => new Date(d.getFullYear(), d.getMonth(), d.getDate() + n);
|
|
@@ -13,7 +14,8 @@ const diffDays = (a, b) => Math.round((midnight(b).getTime() - midnight(a).getTi
|
|
|
13
14
|
* نوارها با ماوس و لمس جابهجا و کشیده میشوند و با کیبورد هم (جهتها جابهجا، Shift + جهت طول).
|
|
14
15
|
*/
|
|
15
16
|
export function Gantt({ tasks, label, from, to, today: todayProp, onTaskChange, onTaskClick, holidays = true, taskHeader, className }) {
|
|
16
|
-
const {
|
|
17
|
+
const M = useMessages({ common: faCommon, gantt: faGantt });
|
|
18
|
+
const { months, n, locale, digits } = useKashiLocale();
|
|
17
19
|
const G = M.gantt;
|
|
18
20
|
const id = useId();
|
|
19
21
|
const today = midnight(todayProp ?? new Date());
|
package/dist/IbanInput.js
CHANGED
|
@@ -6,11 +6,12 @@ import { BankBadge } from "./BankBadge.js";
|
|
|
6
6
|
import { Input } from "./Input.js";
|
|
7
7
|
import { useDigitsInput } from "./useDigitsInput.js";
|
|
8
8
|
import { mergeRefs } from "./utils.js";
|
|
9
|
-
import {
|
|
9
|
+
import { useMessages } from "./KashiProvider.js";
|
|
10
|
+
import { faInvalid } from "@kashi-ui/persian";
|
|
10
11
|
const ibanOf = (d) => (d ? `IR${d}` : "");
|
|
11
12
|
/** فیلد شماره شبا: IR خودکار، گروهبندی، تشخیص بانک با لوگو و بررسی رقمهای کنترل */
|
|
12
13
|
export const IbanInput = forwardRef(function IbanInput({ value, defaultValue, onValueChange, digits = "latin", showBank = true, showBankLogo = true, invalidMessage, error, name, id, onBlur, placeholder, ...rest }, ref) {
|
|
13
|
-
const {
|
|
14
|
+
const M = useMessages({ invalid: faInvalid });
|
|
14
15
|
invalidMessage ?? (invalidMessage = M.invalid.iban);
|
|
15
16
|
const autoId = useId();
|
|
16
17
|
const inputId = id ?? autoId;
|
package/dist/ImageCropper.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { forwardRef, useCallback, useEffect, useImperativeHandle, useLayoutEffect, useRef, useState } from "react";
|
|
4
4
|
import { cx } from "./cx.js";
|
|
5
|
-
import {
|
|
5
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
6
|
+
import { faCommon, faCropper } from "@kashi-ui/persian";
|
|
6
7
|
const START = { x: 0, y: 0, zoom: 1, rotation: 0 };
|
|
7
8
|
const clampN = (v, a, b) => Math.min(b, Math.max(a, v));
|
|
8
9
|
/** تصویر را با ناحیه و چرخش دادهشده میبُرد؛ برای سرور هم قابل استفاده است (در مرورگر) */
|
|
@@ -40,7 +41,8 @@ export async function cropImage(src, area, rotation = 0, { width, type = "image/
|
|
|
40
41
|
* و همیشه کادر را پر نگه میدارد. خروجی با ref.crop() یا تابع cropImage.
|
|
41
42
|
*/
|
|
42
43
|
export const ImageCropper = forwardRef(function ImageCropper({ src, alt = "", aspect = 1, shape = "rect", maxZoom = 4, value, defaultValue, onChange, onCropComplete, rotatable = true, label, className }, ref) {
|
|
43
|
-
const {
|
|
44
|
+
const M = useMessages({ common: faCommon, cropper: faCropper });
|
|
45
|
+
const { n } = useKashiLocale();
|
|
44
46
|
const C = M.cropper;
|
|
45
47
|
const stage = useRef(null);
|
|
46
48
|
const imgRef = useRef(null);
|
package/dist/InfiniteScroll.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { Children, isValidElement, useEffect, useRef, useState } from "react";
|
|
4
4
|
import { cx } from "./cx.js";
|
|
5
|
-
import {
|
|
5
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
6
|
+
import { faInfinite } from "@kashi-ui/persian";
|
|
6
7
|
/**
|
|
7
8
|
* بارگذاری پیوسته: با رسیدن به پایین (IntersectionObserver) صفحهٔ بعد را میخواهد، یا با دکمهٔ «نمایش بیشتر».
|
|
8
9
|
* aria-busy و اعلام تعداد موردهای تازه برای صفحهخوان، خطا با «تلاش دوباره»، و پیام پایان.
|
|
@@ -10,7 +11,8 @@ import { useKashi } from "./KashiProvider.js";
|
|
|
10
11
|
export function InfiniteScroll({ children, hasMore, loading, error, onLoadMore, itemCount, mode = "auto", rootMargin = "320px", maxHeight, endMessage, loader, role: roleProp, label, className, style, }) {
|
|
11
12
|
const kids = Children.toArray(children);
|
|
12
13
|
const role = roleProp ?? (kids.length > 0 && kids.every((c) => isValidElement(c) && c.type === "article") ? "feed" : "none");
|
|
13
|
-
const {
|
|
14
|
+
const M = useMessages({ infinite: faInfinite });
|
|
15
|
+
const { n } = useKashiLocale();
|
|
14
16
|
const L = M.infinite;
|
|
15
17
|
const root = useRef(null);
|
|
16
18
|
const sentinel = useRef(null);
|
package/dist/InlineEdit.js
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useRef, useState } from "react";
|
|
4
4
|
import { cx } from "./cx.js";
|
|
5
|
-
import {
|
|
5
|
+
import { useMessages } from "./KashiProvider.js";
|
|
6
|
+
import { faCommon, faInlineEdit } from "@kashi-ui/persian";
|
|
6
7
|
const Pencil = () => _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: "m13.5 3.5 3 3L7 16H4v-3Z" }) });
|
|
7
8
|
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" }) });
|
|
8
9
|
const X = () => _jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", "aria-hidden": "true", children: _jsx("path", { d: "m6 6 8 8M14 6l-8 8" }) });
|
|
9
10
|
/** ویرایش درجا: کلیک یا Enter برای ویرایش، Enter ثبت، Esc انصراف */
|
|
10
11
|
export function InlineEdit({ value, defaultValue = "", onSave, label, placeholder, validate, renderView, className, labels = {} }) {
|
|
11
|
-
const {
|
|
12
|
+
const M = useMessages({ common: faCommon, inlineEdit: faInlineEdit });
|
|
12
13
|
const { edit = M.common.edit, save = M.common.save, cancel = M.common.cancel, empty = M.inlineEdit.empty } = labels;
|
|
13
14
|
const [inner, setInner] = useState(defaultValue);
|
|
14
15
|
const current = value ?? inner;
|
package/dist/Input.js
CHANGED
|
@@ -5,7 +5,8 @@ import { toFaDigits } from "@kashi-ui/persian";
|
|
|
5
5
|
import { cx } from "./cx.js";
|
|
6
6
|
import { Field, describedBy } from "./Field.js";
|
|
7
7
|
import { mergeRefs, useIsomorphicLayoutEffect } from "./utils.js";
|
|
8
|
-
import {
|
|
8
|
+
import { useMessages } from "./KashiProvider.js";
|
|
9
|
+
import { faInput } from "@kashi-ui/persian";
|
|
9
10
|
const Eye = ({ off }) => (_jsxs("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.7, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [_jsx("path", { d: "M1.8 10S4.8 4.5 10 4.5 18.2 10 18.2 10 15.2 15.5 10 15.5 1.8 10 1.8 10Z" }), _jsx("circle", { cx: "10", cy: "10", r: "2.5" }), off && _jsx("path", { d: "m3 3 14 14" })] }));
|
|
10
11
|
const X = () => (_jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.7, strokeLinecap: "round", "aria-hidden": "true", children: _jsx("path", { d: "m6 6 8 8M14 6l-8 8" }) }));
|
|
11
12
|
/** طول متن فعلی، برای کنترلشده و کنترلنشده */
|
|
@@ -30,7 +31,7 @@ export const Input = forwardRef(function Input({ label, hint, error, optional, l
|
|
|
30
31
|
const [revealed, setRevealed] = useState(false);
|
|
31
32
|
const [length, trackLength] = useLength(value, defaultValue);
|
|
32
33
|
const isPassword = type === "password";
|
|
33
|
-
const {
|
|
34
|
+
const M = useMessages({ input: faInput });
|
|
34
35
|
const { clear = M.input.clear, show = M.input.show, hide = M.input.hide, loading: loadingLabel = M.input.checking } = labels;
|
|
35
36
|
const counterId = `${inputId}-count`;
|
|
36
37
|
const canClear = clearable && length > 0 && !disabled && !readOnly;
|
package/dist/Invoice.js
CHANGED
|
@@ -3,7 +3,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useId } from "react";
|
|
4
4
|
import { formatJalali, formatNumber, numberToWords } from "@kashi-ui/persian";
|
|
5
5
|
import { cx } from "./cx.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
7
|
+
import { faInvoice } from "@kashi-ui/persian";
|
|
7
8
|
/** جمعهای فاکتور: جمع ردیفها، تخفیف، پایهٔ مالیات، مالیات بر ارزش افزوده (گرد به نزدیکترین واحد) و مبلغ قابل پرداخت */
|
|
8
9
|
export function invoiceTotals(items, vatRate = 10) {
|
|
9
10
|
const subtotal = items.reduce((s, i) => s + i.quantity * i.unitPrice, 0);
|
|
@@ -17,7 +18,8 @@ export function invoiceTotals(items, vatRate = 10) {
|
|
|
17
18
|
* مبلغ به حروف و جای مهر و امضا. برای چاپ و PDF آماده است (@media print): «چاپ» مرورگر و «ذخیره به PDF».
|
|
18
19
|
*/
|
|
19
20
|
export function Invoice({ variant = "official", number, date, validUntil, taxId, seller, buyer, items, vatRate = 10, currency = "rial", notes, logo, signatures = true, printButton = true, footer, className, }) {
|
|
20
|
-
const {
|
|
21
|
+
const M = useMessages({ invoice: faInvoice });
|
|
22
|
+
const { locale, digits, n } = useKashiLocale();
|
|
21
23
|
const I = M.invoice;
|
|
22
24
|
const t = invoiceTotals(items, vatRate);
|
|
23
25
|
const money = (v) => formatNumber(v, { digits });
|
package/dist/IranMap.js
CHANGED
|
@@ -5,13 +5,15 @@ import { PROVINCES, formatNumber } from "@kashi-ui/persian";
|
|
|
5
5
|
import { cx } from "./cx.js";
|
|
6
6
|
import { ChartTip } from "./Chart.js";
|
|
7
7
|
import { IRAN_PROVINCES, IRAN_VIEWBOX } from "./iranMapData.js";
|
|
8
|
-
import {
|
|
8
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
9
|
+
import { faIranMap, faProvince } from "@kashi-ui/persian";
|
|
9
10
|
const NAMES = PROVINCES.map((p) => p.name);
|
|
10
11
|
const CAPITAL = Object.fromEntries(PROVINCES.map((p) => [p.name, p.capital]));
|
|
11
12
|
const [, , VW, VH] = IRAN_VIEWBOX.split(" ").map(Number);
|
|
12
13
|
/** نقشهٔ ۳۱ استان ایران؛ نقشهٔ رنگی برای داده و/یا انتخاب یک یا چند استان، با صفحهکلید و جدول همارز */
|
|
13
14
|
export function IranMap(props) {
|
|
14
|
-
const {
|
|
15
|
+
const M = useMessages({ iranMap: faIranMap, province: faProvince });
|
|
16
|
+
const { digits: D } = useKashiLocale();
|
|
15
17
|
const { data, value, defaultValue, multiple = false, label = M.iranMap.label, unit, format = (n) => formatNumber(n, { digits: D }), steps = 5, scale = "quantile", legend, tooltip, className, } = props;
|
|
16
18
|
const onChange = props.onChange;
|
|
17
19
|
const selectable = value !== undefined || defaultValue !== undefined || onChange !== undefined;
|
package/dist/Kanban.js
CHANGED
|
@@ -4,7 +4,8 @@ import { useRef, useState } from "react";
|
|
|
4
4
|
import { cx } from "./cx.js";
|
|
5
5
|
import { isRtl, useFlip } from "./dnd.js";
|
|
6
6
|
import { useIsomorphicLayoutEffect } from "./utils.js";
|
|
7
|
-
import {
|
|
7
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
8
|
+
import { faCommon, faKanban } from "@kashi-ui/persian";
|
|
8
9
|
const Grip = () => (_jsx("svg", { viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true", children: [6, 10, 14].flatMap((y) => [_jsx("circle", { cx: "7.5", cy: y, r: "1.3" }, `a${y}`), _jsx("circle", { cx: "12.5", cy: y, r: "1.3" }, `b${y}`)]) }));
|
|
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
|
const tr = (el) => {
|
|
@@ -16,7 +17,8 @@ const tr = (el) => {
|
|
|
16
17
|
* چپ و راست بین ستونها (در راستبهچپ، چپ یعنی ستون بعد)، فاصله برای رها کردن و Escape برای لغو.
|
|
17
18
|
*/
|
|
18
19
|
export function Kanban({ columns, getId, getLabel, onChange, renderCard, onAdd, addLabel, "aria-label": ariaLabel, className }) {
|
|
19
|
-
const {
|
|
20
|
+
const M = useMessages({ common: faCommon, kanban: faKanban });
|
|
21
|
+
const { n } = useKashiLocale();
|
|
20
22
|
const K = M.kanban;
|
|
21
23
|
const root = useRef(null);
|
|
22
24
|
const [preview, setPreview] = useState(null);
|