@kashi-ui/react 2.24.1 → 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.
Files changed (117) hide show
  1. package/README.md +1 -1
  2. package/dist/ActivityHeatmap.js +4 -2
  3. package/dist/AddressForm.js +3 -2
  4. package/dist/Alert.js +3 -2
  5. package/dist/AppointmentPicker.js +4 -2
  6. package/dist/Avatar.js +5 -3
  7. package/dist/Badge.js +3 -2
  8. package/dist/BankBadge.js +2 -2
  9. package/dist/BankCard.js +4 -2
  10. package/dist/Banner.js +3 -2
  11. package/dist/BillInput.d.ts +39 -0
  12. package/dist/BillInput.js +57 -0
  13. package/dist/BottomSheet.js +3 -2
  14. package/dist/Breadcrumb.js +3 -2
  15. package/dist/BusinessHours.js +6 -3
  16. package/dist/Button.js +3 -2
  17. package/dist/Calendar.js +4 -2
  18. package/dist/CardNumberInput.js +4 -2
  19. package/dist/Carousel.js +4 -2
  20. package/dist/Chart.js +6 -4
  21. package/dist/Chat.js +6 -4
  22. package/dist/ChatComposer.js +4 -2
  23. package/dist/CitySelect.js +3 -2
  24. package/dist/CodeBlock.js +4 -2
  25. package/dist/ColorPicker.js +6 -3
  26. package/dist/Combobox.d.ts +4 -0
  27. package/dist/Combobox.js +11 -6
  28. package/dist/CommandPalette.js +4 -2
  29. package/dist/ContextMenu.js +3 -2
  30. package/dist/CopyButton.js +3 -2
  31. package/dist/Countdown.js +4 -2
  32. package/dist/DataTable.d.ts +19 -1
  33. package/dist/DataTable.js +109 -9
  34. package/dist/DatePicker.js +4 -2
  35. package/dist/DateRangePicker.d.ts +19 -1
  36. package/dist/DateRangePicker.js +30 -7
  37. package/dist/DateTile.js +2 -2
  38. package/dist/Dialog.js +3 -2
  39. package/dist/Drawer.js +3 -2
  40. package/dist/EconomicCodeInput.js +4 -2
  41. package/dist/EmptyState.js +3 -2
  42. package/dist/Field.js +3 -2
  43. package/dist/FileUpload.d.ts +1 -1
  44. package/dist/FileUpload.js +9 -6
  45. package/dist/Gantt.d.ts +42 -0
  46. package/dist/Gantt.js +118 -0
  47. package/dist/IbanInput.js +3 -2
  48. package/dist/ImageCropper.d.ts +56 -0
  49. package/dist/ImageCropper.js +187 -0
  50. package/dist/InfiniteScroll.d.ts +34 -0
  51. package/dist/InfiniteScroll.js +46 -0
  52. package/dist/InlineEdit.js +3 -2
  53. package/dist/Input.js +3 -2
  54. package/dist/Invoice.d.ts +65 -0
  55. package/dist/Invoice.js +32 -0
  56. package/dist/IranMap.js +4 -2
  57. package/dist/Kanban.js +4 -2
  58. package/dist/KashiProvider.d.ts +731 -3
  59. package/dist/KashiProvider.js +19 -4
  60. package/dist/KeyboardFixInput.js +4 -2
  61. package/dist/LandlineInput.js +4 -2
  62. package/dist/LegalIdInput.js +4 -2
  63. package/dist/Lightbox.js +6 -3
  64. package/dist/Meter.js +4 -2
  65. package/dist/MobileInput.js +4 -2
  66. package/dist/Money.js +4 -2
  67. package/dist/MonthPicker.js +4 -2
  68. package/dist/MultiSelect.js +4 -2
  69. package/dist/NationalIdInput.js +4 -2
  70. package/dist/Navbar.js +3 -2
  71. package/dist/NotificationCenter.js +6 -3
  72. package/dist/NumberInput.js +4 -2
  73. package/dist/OtpInput.js +2 -2
  74. package/dist/Pagination.js +4 -2
  75. package/dist/PasswordStrength.js +5 -4
  76. package/dist/PaymentReceipt.js +4 -2
  77. package/dist/PersianInput.d.ts +3 -0
  78. package/dist/PersianInput.js +8 -2
  79. package/dist/PersianTextarea.js +4 -2
  80. package/dist/PlateInput.js +3 -2
  81. package/dist/PostalCodeInput.js +4 -2
  82. package/dist/PriceInput.js +4 -2
  83. package/dist/PriceRange.js +4 -2
  84. package/dist/Progress.js +5 -3
  85. package/dist/ProvinceSelect.js +3 -2
  86. package/dist/QRCode.js +3 -2
  87. package/dist/Rating.js +4 -2
  88. package/dist/RelativeTime.js +2 -2
  89. package/dist/RichTextEditor.js +4 -2
  90. package/dist/SayadInput.js +4 -2
  91. package/dist/Scheduler.js +4 -2
  92. package/dist/SearchSuggest.js +6 -4
  93. package/dist/Select.js +3 -2
  94. package/dist/SideNav.js +3 -2
  95. package/dist/SignaturePad.d.ts +38 -0
  96. package/dist/SignaturePad.js +170 -0
  97. package/dist/Slider.js +4 -2
  98. package/dist/Sortable.js +4 -2
  99. package/dist/Splitter.js +4 -2
  100. package/dist/Stat.js +4 -2
  101. package/dist/Stepper.js +4 -2
  102. package/dist/StreamingText.js +3 -2
  103. package/dist/SwatchGroup.js +3 -2
  104. package/dist/TagInput.js +4 -2
  105. package/dist/TaxIdInput.js +3 -2
  106. package/dist/TimeClock.js +4 -2
  107. package/dist/TimeInput.js +4 -2
  108. package/dist/TimePicker.js +4 -2
  109. package/dist/Toast.js +3 -2
  110. package/dist/Tour.js +4 -2
  111. package/dist/VirtualList.d.ts +35 -0
  112. package/dist/VirtualList.js +104 -0
  113. package/dist/index.d.ts +19 -1
  114. package/dist/index.js +10 -1
  115. package/dist/xlsx.d.ts +5 -0
  116. package/dist/xlsx.js +14 -0
  117. package/package.json +4 -4
@@ -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 { getMessages, toFaDigits } from "@kashi-ui/persian";
4
+ import { faFileUpload, toFaDigits } from "@kashi-ui/persian";
5
5
  import { cx } from "./cx.js";
6
6
  import { Progress } from "./Progress.js";
7
- import { useKashi } from "./KashiProvider.js";
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
- const units = getMessages(locale).fileUpload.units;
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 { messages: M, n: N, locale } = useKashi();
88
- const bytes = (b) => formatBytes(b, locale);
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);
@@ -0,0 +1,42 @@
1
+ import { type ReactNode } from "react";
2
+ export interface GanttTask {
3
+ id: string;
4
+ name: string;
5
+ start: Date;
6
+ /** روز پایان (شامل) */
7
+ end: Date;
8
+ /** درصد انجام‌شده (۰ تا ۱۰۰) */
9
+ progress?: number;
10
+ /** رنگ نوار؛ هر رنگ CSS یا توکن، مثل "var(--k-nemoodar-2)" */
11
+ color?: string;
12
+ /** شناسهٔ کارهایی که این کار بعد از آن‌ها شروع می‌شود */
13
+ dependsOn?: string[];
14
+ /** نقطهٔ عطف: یک روز، به شکل لوزی */
15
+ milestone?: boolean;
16
+ }
17
+ export interface GanttProps {
18
+ tasks: GanttTask[];
19
+ /** عنوان برای صفحه‌خوان */
20
+ label?: string;
21
+ /** روز اول و آخر نمودار؛ پیش‌فرض کمی پیش و پس از کارها */
22
+ from?: Date;
23
+ to?: Date;
24
+ /** امروز (برای خط امروز)؛ پیش‌فرض تاریخ دستگاه */
25
+ today?: Date;
26
+ /** جابه‌جا یا کشیدن نوار؛ بدون آن نمودار فقط‌خواندنی است */
27
+ onTaskChange?: (task: GanttTask, change: {
28
+ start: Date;
29
+ end: Date;
30
+ }) => void;
31
+ onTaskClick?: (task: GanttTask) => void;
32
+ /** تعطیلات رسمی ایران را هم مثل جمعه رنگ بزن @default true */
33
+ holidays?: boolean;
34
+ /** عنوان ستون کارها */
35
+ taskHeader?: ReactNode;
36
+ className?: string;
37
+ }
38
+ /**
39
+ * نمودار گانت با تقویم شمسی: سرستون ماه و روز شمسی، جمعه و تعطیلات رسمی، خط امروز، وابستگی کارها و پیشرفت هر کار.
40
+ * نوارها با ماوس و لمس جابه‌جا و کشیده می‌شوند و با کیبورد هم (جهت‌ها جابه‌جا، Shift + جهت طول).
41
+ */
42
+ export declare function Gantt({ tasks, label, from, to, today: todayProp, onTaskChange, onTaskClick, holidays, taskHeader, className }: GanttProps): import("react").JSX.Element;
package/dist/Gantt.js ADDED
@@ -0,0 +1,118 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useId, useMemo, useRef, useState } from "react";
4
+ import { formatJalali, getIranHoliday, toJalali } from "@kashi-ui/persian";
5
+ import { cx } from "./cx.js";
6
+ import { useKashiLocale, useMessages } from "./KashiProvider.js";
7
+ import { faCommon, faGantt } from "@kashi-ui/persian";
8
+ const DAY = 86400000;
9
+ const midnight = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate());
10
+ const addDays = (d, n) => new Date(d.getFullYear(), d.getMonth(), d.getDate() + n);
11
+ const diffDays = (a, b) => Math.round((midnight(b).getTime() - midnight(a).getTime()) / DAY);
12
+ /**
13
+ * نمودار گانت با تقویم شمسی: سرستون ماه و روز شمسی، جمعه و تعطیلات رسمی، خط امروز، وابستگی کارها و پیشرفت هر کار.
14
+ * نوارها با ماوس و لمس جابه‌جا و کشیده می‌شوند و با کیبورد هم (جهت‌ها جابه‌جا، Shift + جهت طول).
15
+ */
16
+ export function Gantt({ tasks, label, from, to, today: todayProp, onTaskChange, onTaskClick, holidays = true, taskHeader, className }) {
17
+ const M = useMessages({ common: faCommon, gantt: faGantt });
18
+ const { months, n, locale, digits } = useKashiLocale();
19
+ const G = M.gantt;
20
+ const id = useId();
21
+ const today = midnight(todayProp ?? new Date());
22
+ const [live, setLive] = useState("");
23
+ const [preview, setPreview] = useState(null);
24
+ const dragRef = useRef(null);
25
+ const range = useMemo(() => {
26
+ const starts = tasks.map((t) => midnight(t.start).getTime());
27
+ const ends = tasks.map((t) => midnight(t.end).getTime());
28
+ const a = from ? midnight(from) : addDays(new Date(Math.min(...starts, today.getTime())), -3);
29
+ const b = to ? midnight(to) : addDays(new Date(Math.max(...ends, today.getTime())), 5);
30
+ return { a, b, days: diffDays(a, b) + 1 };
31
+ }, [tasks, from, to, today.getTime()]);
32
+ const days = useMemo(() => Array.from({ length: range.days }, (_, i) => {
33
+ const d = addDays(range.a, i);
34
+ const j = toJalali(d);
35
+ const off = d.getDay() === 5 || (holidays && !!getIranHoliday(d));
36
+ return { d, j, off };
37
+ }), [range.a.getTime(), range.days, holidays]);
38
+ const monthsRow = useMemo(() => {
39
+ const out = [];
40
+ for (const { j } of days) {
41
+ const key = `${j.jy}-${j.jm}`;
42
+ const last = out[out.length - 1];
43
+ if (last?.key === key)
44
+ last.span++;
45
+ else
46
+ out.push({ key, label: `${months[j.jm - 1]} ${n(j.jy)}`, span: 1 });
47
+ }
48
+ return out;
49
+ }, [days, months, n]);
50
+ const byId = new Map(tasks.map((t) => [t.id, t]));
51
+ const fmt = (d) => formatJalali(d, { locale, digits });
52
+ const shown = (t) => (preview?.id === t.id ? preview : { start: t.start, end: t.end });
53
+ const editable = !!onTaskChange;
54
+ const commit = (t, start, end) => {
55
+ if (end < start)
56
+ end = start;
57
+ onTaskChange?.(t, { start, end });
58
+ setLive(G.moved(t.name, fmt(start), fmt(end)));
59
+ };
60
+ const todayIdx = diffDays(range.a, today);
61
+ const rowIndex = new Map(tasks.map((t, i) => [t.id, i]));
62
+ return (_jsxs("div", { className: cx("k-gantt", className), style: { "--k-gantt-days": range.days }, children: [_jsxs("div", { className: "k-gantt__scroll", role: "region", "aria-labelledby": `${id}-title`, tabIndex: 0, children: [_jsx("span", { className: "k-sr-only", id: `${id}-title`, children: label ?? G.label }), _jsxs("div", { className: "k-gantt__grid", role: "table", "aria-label": label ?? G.label, "aria-rowcount": tasks.length + 1, children: [_jsxs("div", { className: "k-gantt__head", role: "row", children: [_jsx("div", { className: "k-gantt__corner", role: "columnheader", children: taskHeader ?? G.task }), _jsxs("div", { className: "k-gantt__timehead", role: "columnheader", "aria-label": `${fmt(range.a)} – ${fmt(range.b)}`, children: [_jsx("div", { className: "k-gantt__months", "aria-hidden": "true", children: monthsRow.map((m) => _jsx("span", { className: "k-gantt__month", style: { gridColumn: `span ${m.span}` }, children: m.label }, m.key)) }), _jsx("div", { className: "k-gantt__days", "aria-hidden": "true", children: days.map(({ d, j, off }, i) => (_jsx("span", { className: "k-gantt__day", "data-off": off || undefined, "data-today": i === todayIdx || undefined, "data-first": j.jd === 1 || undefined, children: n(j.jd) }, i))) })] })] }), tasks.map((t, row) => {
63
+ const s = shown(t);
64
+ const startIdx = diffDays(range.a, s.start);
65
+ const len = t.milestone ? 1 : diffDays(s.start, s.end) + 1;
66
+ const p = Math.max(0, Math.min(100, t.progress ?? 0));
67
+ const deps = (t.dependsOn ?? []).map((x) => byId.get(x)).filter(Boolean);
68
+ const desc = [G.bar(t.name, fmt(s.start), fmt(s.end), n(p)), ...deps.map((d) => G.dependsOn(d.name))].join(M.common.comma);
69
+ return (_jsxs("div", { className: "k-gantt__row", role: "row", "aria-rowindex": row + 2, children: [_jsxs("div", { className: "k-gantt__name", role: "rowheader", children: [_jsx("span", { className: "k-gantt__dot", style: t.color ? { background: t.color } : undefined, "aria-hidden": "true" }), _jsx("span", { className: "k-gantt__label", children: t.name }), _jsx("span", { className: "k-gantt__len", children: G.days(n(len)) })] }), _jsxs("div", { className: "k-gantt__track", role: "cell", children: [days.map(({ off }, i) => off && _jsx("span", { className: "k-gantt__off", style: { gridColumn: `${i + 1}` }, "aria-hidden": "true" }, i)), deps.map((d) => {
70
+ const ds = shown(d);
71
+ const fromIdx = diffDays(range.a, ds.end) + 1;
72
+ const up = (rowIndex.get(d.id) ?? 0) - row;
73
+ return (_jsx("span", { className: "k-gantt__dep", "aria-hidden": "true", "data-backward": fromIdx > startIdx || undefined, "data-below": up > 0 || undefined, style: { "--from": fromIdx, "--to": startIdx, "--rows": Math.abs(up) } }, d.id));
74
+ }), _jsxs("button", { type: "button", className: "k-gantt__bar", "data-milestone": t.milestone || undefined, "data-dragging": preview?.id === t.id || undefined, "data-done": p >= 100 || undefined, style: { "--start": startIdx, "--len": len, "--progress": `${p}%`, ...(t.color ? { "--k-gantt-color": t.color } : {}) }, "aria-label": desc, "aria-describedby": editable ? `${id}-hint` : undefined, onClick: () => { if (!dragRef.current?.moved)
75
+ onTaskClick?.(t); }, onKeyDown: (e) => {
76
+ if (!editable || !["ArrowLeft", "ArrowRight"].includes(e.key))
77
+ return;
78
+ e.preventDefault();
79
+ const rtl = getComputedStyle(e.currentTarget).direction === "rtl";
80
+ // در RTL زمان به چپ جلو می‌رود
81
+ const step = (e.key === "ArrowLeft" ? 1 : -1) * (rtl ? 1 : -1);
82
+ if (e.shiftKey && !t.milestone)
83
+ commit(t, t.start, addDays(t.end, step));
84
+ else
85
+ commit(t, addDays(t.start, step), addDays(t.end, step));
86
+ }, onPointerDown: (e) => {
87
+ if (!editable || e.button !== 0)
88
+ return;
89
+ const el = e.currentTarget;
90
+ el.setPointerCapture(e.pointerId);
91
+ const r = el.getBoundingClientRect();
92
+ const rtl = getComputedStyle(el).direction === "rtl";
93
+ const edge = rtl ? e.clientX - r.left : r.right - e.clientX;
94
+ dragRef.current = {
95
+ id: t.id, x: e.clientX, kind: !t.milestone && edge < 10 ? "end" : "move", start: t.start, end: t.end,
96
+ dayPx: r.width / len, dir: rtl ? -1 : 1, moved: false,
97
+ };
98
+ }, onPointerMove: (e) => {
99
+ const d = dragRef.current;
100
+ if (!d || d.id !== t.id)
101
+ return;
102
+ const delta = Math.round(((e.clientX - d.x) * d.dir) / d.dayPx);
103
+ if (delta !== 0)
104
+ d.moved = true;
105
+ if (!d.moved)
106
+ return;
107
+ setPreview(d.kind === "move"
108
+ ? { id: t.id, start: addDays(d.start, delta), end: addDays(d.end, delta) }
109
+ : { id: t.id, start: d.start, end: addDays(d.end, Math.max(delta, -diffDays(d.start, d.end))) });
110
+ }, onPointerUp: () => {
111
+ const d = dragRef.current;
112
+ if (d?.moved && preview)
113
+ commit(t, preview.start, preview.end);
114
+ setPreview(null);
115
+ setTimeout(() => { dragRef.current = null; });
116
+ }, onPointerCancel: () => { setPreview(null); dragRef.current = null; }, children: [!t.milestone && _jsx("span", { className: "k-gantt__fill", "aria-hidden": "true" }), !t.milestone && _jsx("span", { className: "k-gantt__text", "aria-hidden": "true", children: t.name }), editable && !t.milestone && _jsx("span", { className: "k-gantt__grip", "aria-hidden": "true" })] })] })] }, t.id));
117
+ }), todayIdx >= 0 && todayIdx < range.days && (_jsx("span", { className: "k-gantt__now", style: { "--today": todayIdx }, "aria-hidden": "true", children: _jsx("span", { children: G.today }) }))] })] }), editable && _jsx("span", { className: "k-sr-only", id: `${id}-hint`, children: G.hint }), _jsx("span", { className: "k-sr-only", "aria-live": "polite", children: live })] }));
118
+ }
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 { useKashi } from "./KashiProvider.js";
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 { messages: M } = useKashi();
14
+ const M = useMessages({ invalid: faInvalid });
14
15
  invalidMessage ?? (invalidMessage = M.invalid.iban);
15
16
  const autoId = useId();
16
17
  const inputId = id ?? autoId;
@@ -0,0 +1,56 @@
1
+ import { type ReactNode } from "react";
2
+ /** ناحیهٔ برش به پیکسل تصویر اصلی (بعد از چرخش) */
3
+ export interface CropArea {
4
+ x: number;
5
+ y: number;
6
+ width: number;
7
+ height: number;
8
+ }
9
+ export interface CropState {
10
+ /** جابه‌جایی مرکز تصویر از مرکز کادر، به نسبت اندازهٔ کادر */
11
+ x: number;
12
+ y: number;
13
+ /** ۱ = تصویر کادر را تازه پر کرده است */
14
+ zoom: number;
15
+ /** ۰، ۹۰، ۱۸۰ یا ۲۷۰ */
16
+ rotation: number;
17
+ }
18
+ export interface ImageCropperHandle {
19
+ /** تصویر بریده‌شده به Blob (پیش‌فرض WebP، اگر مرورگر بخواهد PNG) */
20
+ crop: (options?: CropImageOptions) => Promise<Blob | null>;
21
+ reset: () => void;
22
+ }
23
+ export interface CropImageOptions {
24
+ /** پهنای خروجی به پیکسل؛ پیش‌فرض اندازهٔ واقعی ناحیه */
25
+ width?: number;
26
+ type?: string;
27
+ quality?: number;
28
+ /** برش دایره‌ای (گوشه‌ها شفاف) */
29
+ circle?: boolean;
30
+ }
31
+ export interface ImageCropperProps {
32
+ src: string;
33
+ alt?: string;
34
+ /** نسبت پهنا به ارتفاع کادر @default 1 */
35
+ aspect?: number;
36
+ /** کادر دایره‌ای برای عکس پروفایل */
37
+ shape?: "rect" | "circle";
38
+ /** بیشترین بزرگ‌نمایی @default 4 */
39
+ maxZoom?: number;
40
+ value?: CropState;
41
+ defaultValue?: Partial<CropState>;
42
+ onChange?: (state: CropState) => void;
43
+ /** بعد از هر تغییر، ناحیهٔ برش به پیکسل تصویر */
44
+ onCropComplete?: (area: CropArea, state: CropState) => void;
45
+ /** دکمهٔ چرخش @default true */
46
+ rotatable?: boolean;
47
+ label?: ReactNode;
48
+ className?: string;
49
+ }
50
+ /** تصویر را با ناحیه و چرخش داده‌شده می‌بُرد؛ برای سرور هم قابل استفاده است (در مرورگر) */
51
+ export declare function cropImage(src: string, area: CropArea, rotation?: number, { width, type, quality, circle }?: CropImageOptions): Promise<Blob | null>;
52
+ /**
53
+ * برش تصویر برای عکس پروفایل و کاور: تصویر زیر کادر ثابت جابه‌جا و بزرگ می‌شود (کشیدن، چرخ ماوس، دو انگشت یا کیبورد)
54
+ * و همیشه کادر را پر نگه می‌دارد. خروجی با ref.crop() یا تابع cropImage.
55
+ */
56
+ export declare const ImageCropper: import("react").ForwardRefExoticComponent<ImageCropperProps & import("react").RefAttributes<ImageCropperHandle>>;
@@ -0,0 +1,187 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { forwardRef, useCallback, useEffect, useImperativeHandle, useLayoutEffect, useRef, useState } from "react";
4
+ import { cx } from "./cx.js";
5
+ import { useKashiLocale, useMessages } from "./KashiProvider.js";
6
+ import { faCommon, faCropper } from "@kashi-ui/persian";
7
+ const START = { x: 0, y: 0, zoom: 1, rotation: 0 };
8
+ const clampN = (v, a, b) => Math.min(b, Math.max(a, v));
9
+ /** تصویر را با ناحیه و چرخش داده‌شده می‌بُرد؛ برای سرور هم قابل استفاده است (در مرورگر) */
10
+ export async function cropImage(src, area, rotation = 0, { width, type = "image/webp", quality = 0.92, circle } = {}) {
11
+ const img = new Image();
12
+ img.crossOrigin = "anonymous";
13
+ img.src = src;
14
+ await img.decode();
15
+ const rad = (rotation * Math.PI) / 180;
16
+ const side = rotation % 180 !== 0;
17
+ const rw = side ? img.naturalHeight : img.naturalWidth;
18
+ const rh = side ? img.naturalWidth : img.naturalHeight;
19
+ const outW = Math.round(width ?? area.width);
20
+ const outH = Math.round((outW * area.height) / area.width);
21
+ const c = document.createElement("canvas");
22
+ c.width = outW;
23
+ c.height = outH;
24
+ const ctx = c.getContext("2d");
25
+ if (!ctx)
26
+ return null;
27
+ const k = outW / area.width;
28
+ if (circle) {
29
+ ctx.beginPath();
30
+ ctx.ellipse(outW / 2, outH / 2, outW / 2, outH / 2, 0, 0, Math.PI * 2);
31
+ ctx.clip();
32
+ }
33
+ ctx.scale(k, k);
34
+ ctx.translate(-area.x + rw / 2, -area.y + rh / 2);
35
+ ctx.rotate(rad);
36
+ ctx.drawImage(img, -img.naturalWidth / 2, -img.naturalHeight / 2);
37
+ return new Promise((done) => c.toBlob((b) => done(b), type, quality));
38
+ }
39
+ /**
40
+ * برش تصویر برای عکس پروفایل و کاور: تصویر زیر کادر ثابت جابه‌جا و بزرگ می‌شود (کشیدن، چرخ ماوس، دو انگشت یا کیبورد)
41
+ * و همیشه کادر را پر نگه می‌دارد. خروجی با ref.crop() یا تابع cropImage.
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) {
44
+ const M = useMessages({ common: faCommon, cropper: faCropper });
45
+ const { n } = useKashiLocale();
46
+ const C = M.cropper;
47
+ const stage = useRef(null);
48
+ const imgRef = useRef(null);
49
+ const [inner, setInner] = useState({ ...START, ...defaultValue });
50
+ const state = value ?? inner;
51
+ // آخرین حالت، تا کلیدها و رویدادهای پشت‌سرهم (پیش از رندر بعدی) روی حالت کهنه حساب نشوند
52
+ const latest = useRef(state);
53
+ latest.current = state;
54
+ const [nat, setNat] = useState(null);
55
+ const [box, setBox] = useState({ w: 0, h: 0 });
56
+ const [live, setLive] = useState("");
57
+ const drag = useRef(null);
58
+ const pinch = useRef(null);
59
+ const pointers = useRef(new Map());
60
+ const useIso = typeof window === "undefined" ? useEffect : useLayoutEffect;
61
+ useIso(() => {
62
+ const el = stage.current;
63
+ if (!el)
64
+ return;
65
+ const read = () => setBox({ w: el.clientWidth, h: el.clientHeight });
66
+ read();
67
+ if (typeof ResizeObserver === "undefined")
68
+ return;
69
+ const ro = new ResizeObserver(read);
70
+ ro.observe(el);
71
+ return () => ro.disconnect();
72
+ }, []);
73
+ // تصویری که پیش از hydrate شدن (یا از حافظهٔ مرورگر) بارگذاری شده، رویداد load را دوباره نمی‌فرستد
74
+ useEffect(() => {
75
+ const img = imgRef.current;
76
+ if (img?.complete && img.naturalWidth)
77
+ setNat({ w: img.naturalWidth, h: img.naturalHeight });
78
+ }, [src]);
79
+ // کادر: بزرگ‌ترین مستطیل با نسبت aspect با ۱۶px فاصله از لبه‌ها
80
+ const pad = 16;
81
+ const fw = Math.max(1, Math.min(box.w - pad * 2, (box.h - pad * 2) * aspect));
82
+ const fh = fw / aspect;
83
+ const side = state.rotation % 180 !== 0;
84
+ const iw = nat ? (side ? nat.h : nat.w) : 1;
85
+ const ih = nat ? (side ? nat.w : nat.h) : 1;
86
+ const base = Math.max(fw / iw, fh / ih);
87
+ const scale = base * state.zoom;
88
+ const clampState = useCallback((s) => {
89
+ const zoom = clampN(s.zoom, 1, maxZoom);
90
+ const sc = base * zoom;
91
+ const mx = Math.max(0, (iw * sc - fw) / 2) / fw;
92
+ const my = Math.max(0, (ih * sc - fh) / 2) / fh;
93
+ return { ...s, zoom, x: clampN(s.x, -mx, mx), y: clampN(s.y, -my, my) };
94
+ }, [base, iw, ih, fw, fh, maxZoom]);
95
+ const area = useCallback((s) => {
96
+ const sc = base * s.zoom;
97
+ return {
98
+ x: Math.max(0, (iw * sc) / 2 - s.x * fw - fw / 2) / sc,
99
+ y: Math.max(0, (ih * sc) / 2 - s.y * fh - fh / 2) / sc,
100
+ width: fw / sc,
101
+ height: fh / sc,
102
+ };
103
+ }, [base, iw, ih, fw, fh]);
104
+ const set = useCallback((next, announce) => {
105
+ const s = clampState(next);
106
+ latest.current = s;
107
+ if (value === undefined)
108
+ setInner(s);
109
+ onChange?.(s);
110
+ if (nat)
111
+ onCropComplete?.(area(s), s);
112
+ if (announce)
113
+ setLive(announce);
114
+ }, [clampState, value, onChange, onCropComplete, area, nat]);
115
+ // وقتی اندازه یا تصویر عوض شد، حالت را دوباره در محدوده بیاور
116
+ useEffect(() => {
117
+ if (nat && box.w)
118
+ set(state);
119
+ // eslint-disable-next-line react-hooks/exhaustive-deps
120
+ }, [nat, box.w, box.h, aspect]);
121
+ useImperativeHandle(ref, () => ({
122
+ crop: (o) => cropImage(src, area(state), state.rotation, { circle: shape === "circle", ...o }),
123
+ reset: () => set(START),
124
+ }));
125
+ const zoomBy = (f) => { const z = latest.current.zoom * f; set({ ...latest.current, zoom: z }, C.zoomed(n(Math.round(clampN(z, 1, maxZoom) * 100)))); };
126
+ const tx = box.w / 2 + state.x * fw - (iw * scale) / 2;
127
+ const ty = box.h / 2 + state.y * fh - (ih * scale) / 2;
128
+ return (_jsxs("div", { className: cx("k-cropper", className), "data-shape": shape, children: [label && _jsx("span", { className: "k-label", children: label }), _jsxs("div", { ref: stage, className: "k-cropper__stage", dir: "ltr", tabIndex: 0, role: "application", "aria-roledescription": C.label, "aria-label": C.area, onPointerDown: (e) => {
129
+ e.currentTarget.setPointerCapture(e.pointerId);
130
+ pointers.current.set(e.pointerId, { x: e.clientX, y: e.clientY });
131
+ if (pointers.current.size === 2) {
132
+ const [a, b] = [...pointers.current.values()];
133
+ pinch.current = { d: Math.hypot(a.x - b.x, a.y - b.y), zoom: latest.current.zoom };
134
+ drag.current = null;
135
+ }
136
+ else
137
+ drag.current = { id: e.pointerId, x: e.clientX, y: e.clientY, start: latest.current };
138
+ }, onPointerMove: (e) => {
139
+ if (!pointers.current.has(e.pointerId))
140
+ return;
141
+ pointers.current.set(e.pointerId, { x: e.clientX, y: e.clientY });
142
+ if (pinch.current && pointers.current.size === 2) {
143
+ const [a, b] = [...pointers.current.values()];
144
+ set({ ...latest.current, zoom: (pinch.current.zoom * Math.hypot(a.x - b.x, a.y - b.y)) / pinch.current.d });
145
+ }
146
+ else if (drag.current?.id === e.pointerId) {
147
+ const d = drag.current;
148
+ set({ ...d.start, x: d.start.x + (e.clientX - d.x) / fw, y: d.start.y + (e.clientY - d.y) / fh });
149
+ }
150
+ }, onPointerUp: (e) => {
151
+ pointers.current.delete(e.pointerId);
152
+ if (pointers.current.size < 2)
153
+ pinch.current = null;
154
+ if (drag.current?.id === e.pointerId)
155
+ drag.current = null;
156
+ }, onPointerCancel: (e) => { pointers.current.delete(e.pointerId); drag.current = null; pinch.current = null; }, onWheel: (e) => {
157
+ if (!e.ctrlKey && Math.abs(e.deltaY) < 1)
158
+ return;
159
+ e.preventDefault();
160
+ set({ ...latest.current, zoom: latest.current.zoom * Math.exp(-e.deltaY / 400) });
161
+ }, onKeyDown: (e) => {
162
+ const step = e.shiftKey ? 0.1 : 0.02;
163
+ const moves = { ArrowLeft: [step, 0], ArrowRight: [-step, 0], ArrowUp: [0, step], ArrowDown: [0, -step] };
164
+ if (moves[e.key]) {
165
+ e.preventDefault();
166
+ const [dx, dy] = moves[e.key];
167
+ const next = clampState({ ...latest.current, x: latest.current.x + dx, y: latest.current.y + dy });
168
+ set(next, C.moved(n(Math.round((0.5 - next.x) * 100)), n(Math.round((0.5 - next.y) * 100))));
169
+ }
170
+ else if (e.key === "+" || e.key === "=") {
171
+ e.preventDefault();
172
+ zoomBy(1.1);
173
+ }
174
+ else if (e.key === "-" || e.key === "_") {
175
+ e.preventDefault();
176
+ zoomBy(1 / 1.1);
177
+ }
178
+ else if (e.key === "0") {
179
+ e.preventDefault();
180
+ set(START, C.reset);
181
+ }
182
+ }, children: [_jsx("img", { ref: imgRef, className: "k-cropper__img", src: src, alt: alt, draggable: false, onLoad: (e) => setNat({ w: e.currentTarget.naturalWidth, h: e.currentTarget.naturalHeight }), style: nat ? {
183
+ inlineSize: (side ? ih : iw) * scale,
184
+ blockSize: (side ? iw : ih) * scale,
185
+ transform: `translate(${tx + (side ? (iw * scale - ih * scale) / 2 : 0)}px, ${ty + (side ? (ih * scale - iw * scale) / 2 : 0)}px) rotate(${state.rotation}deg)`,
186
+ } : { opacity: 0 } }), _jsx("div", { className: "k-cropper__frame", "aria-hidden": "true", style: { inlineSize: fw, blockSize: fh }, children: _jsx("span", { className: "k-cropper__grid" }) })] }), _jsxs("div", { className: "k-cropper__controls", children: [_jsx("button", { type: "button", className: "k-cropper__btn", onClick: () => zoomBy(1 / 1.2), "aria-label": `${C.zoom} −`, disabled: state.zoom <= 1, children: _jsx("svg", { viewBox: "0 0 20 20", "aria-hidden": "true", children: _jsx("path", { d: "M5 10h10", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" }) }) }), _jsx("input", { type: "range", className: "k-slider k-cropper__zoom", min: 1, max: maxZoom, step: 0.01, value: state.zoom, "aria-label": C.zoom, "aria-valuetext": M.common.percent(n(Math.round(state.zoom * 100))), onChange: (e) => set({ ...latest.current, zoom: Number(e.target.value) }) }), _jsx("button", { type: "button", className: "k-cropper__btn", onClick: () => zoomBy(1.2), "aria-label": `${C.zoom} +`, disabled: state.zoom >= maxZoom, children: _jsx("svg", { viewBox: "0 0 20 20", "aria-hidden": "true", children: _jsx("path", { d: "M5 10h10M10 5v10", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" }) }) }), rotatable && (_jsx("button", { type: "button", className: "k-cropper__btn", onClick: () => set({ ...latest.current, rotation: (latest.current.rotation + 90) % 360, x: 0, y: 0 }), "aria-label": C.rotate, title: C.rotate, children: _jsx("svg", { viewBox: "0 0 20 20", "aria-hidden": "true", children: _jsx("path", { d: "M15.5 9A5.5 5.5 0 1 0 14 13.3M15.5 4.5V9H11", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round" }) }) }))] }), _jsx("span", { className: "k-sr-only", "aria-live": "polite", children: live })] }));
187
+ });
@@ -0,0 +1,34 @@
1
+ import { type CSSProperties, type ReactNode } from "react";
2
+ export interface InfiniteScrollProps {
3
+ children: ReactNode;
4
+ /** هنوز موردی برای بارگذاری مانده است */
5
+ hasMore: boolean;
6
+ /** در حال بارگذاری صفحهٔ بعد */
7
+ loading?: boolean;
8
+ /** خطای آخرین بارگذاری؛ دکمهٔ «تلاش دوباره» نشان داده می‌شود */
9
+ error?: ReactNode | boolean;
10
+ /** بارگذاری صفحهٔ بعد؛ وقتی پایین فهرست دیده شود صدا زده می‌شود */
11
+ onLoadMore: () => void;
12
+ /** تعداد موردهای فعلی؛ برای اعلام «n مورد دیگر بارگذاری شد» به صفحه‌خوان */
13
+ itemCount?: number;
14
+ /** «auto» با رسیدن به پایین، «button» با دکمهٔ «نمایش بیشتر» (بهتر برای پاورقی و کیبورد) @default "auto" */
15
+ mode?: "auto" | "button";
16
+ /** فاصلهٔ پیش‌بارگذاری پیش از رسیدن به پایین @default "320px" */
17
+ rootMargin?: string;
18
+ /** ارتفاع بیشینه؛ با آن خود کامپوننت اسکرول می‌خورد (وگرنه صفحه) */
19
+ maxHeight?: string;
20
+ /** متن پایان فهرست؛ null برای پنهان */
21
+ endMessage?: ReactNode;
22
+ /** جای‌نگه‌دار هنگام بارگذاری؛ پیش‌فرض سه اسکلت */
23
+ loader?: ReactNode;
24
+ /** نقش فهرست: "feed" برای خبرخوان (فرزندان باید <article> باشند)؛ پیش‌فرض feed وقتی همهٔ فرزندان article‌اند، وگرنه بدون نقش */
25
+ role?: "feed" | "list" | "none";
26
+ label?: string;
27
+ className?: string;
28
+ style?: CSSProperties;
29
+ }
30
+ /**
31
+ * بارگذاری پیوسته: با رسیدن به پایین (IntersectionObserver) صفحهٔ بعد را می‌خواهد، یا با دکمهٔ «نمایش بیشتر».
32
+ * aria-busy و اعلام تعداد موردهای تازه برای صفحه‌خوان، خطا با «تلاش دوباره»، و پیام پایان.
33
+ */
34
+ export declare function InfiniteScroll({ children, hasMore, loading, error, onLoadMore, itemCount, mode, rootMargin, maxHeight, endMessage, loader, role: roleProp, label, className, style, }: InfiniteScrollProps): import("react").JSX.Element;
@@ -0,0 +1,46 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Children, isValidElement, useEffect, useRef, useState } from "react";
4
+ import { cx } from "./cx.js";
5
+ import { useKashiLocale, useMessages } from "./KashiProvider.js";
6
+ import { faInfinite } from "@kashi-ui/persian";
7
+ /**
8
+ * بارگذاری پیوسته: با رسیدن به پایین (IntersectionObserver) صفحهٔ بعد را می‌خواهد، یا با دکمهٔ «نمایش بیشتر».
9
+ * aria-busy و اعلام تعداد موردهای تازه برای صفحه‌خوان، خطا با «تلاش دوباره»، و پیام پایان.
10
+ */
11
+ export function InfiniteScroll({ children, hasMore, loading, error, onLoadMore, itemCount, mode = "auto", rootMargin = "320px", maxHeight, endMessage, loader, role: roleProp, label, className, style, }) {
12
+ const kids = Children.toArray(children);
13
+ const role = roleProp ?? (kids.length > 0 && kids.every((c) => isValidElement(c) && c.type === "article") ? "feed" : "none");
14
+ const M = useMessages({ infinite: faInfinite });
15
+ const { n } = useKashiLocale();
16
+ const L = M.infinite;
17
+ const root = useRef(null);
18
+ const sentinel = useRef(null);
19
+ const prevCount = useRef(itemCount);
20
+ const [live, setLive] = useState("");
21
+ const call = useRef(onLoadMore);
22
+ call.current = onLoadMore;
23
+ const blocked = !hasMore || loading || !!error;
24
+ useEffect(() => {
25
+ if (mode !== "auto" || blocked || typeof IntersectionObserver === "undefined")
26
+ return;
27
+ const el = sentinel.current;
28
+ if (!el)
29
+ return;
30
+ const io = new IntersectionObserver((entries) => {
31
+ if (entries.some((e) => e.isIntersecting))
32
+ call.current();
33
+ }, { root: maxHeight ? root.current : null, rootMargin });
34
+ io.observe(el);
35
+ return () => io.disconnect();
36
+ }, [mode, blocked, rootMargin, maxHeight]);
37
+ useEffect(() => {
38
+ if (itemCount === undefined)
39
+ return;
40
+ const before = prevCount.current ?? 0;
41
+ if (itemCount > before && before > 0)
42
+ setLive(L.loaded(n(itemCount - before)));
43
+ prevCount.current = itemCount;
44
+ }, [itemCount]);
45
+ return (_jsxs("div", { ref: root, className: cx("k-infinite", maxHeight && "k-infinite--scroll", className), style: maxHeight ? { maxBlockSize: maxHeight, ...style } : style, tabIndex: maxHeight ? 0 : undefined, role: maxHeight ? "region" : undefined, "aria-label": maxHeight ? label : undefined, children: [_jsx("div", { className: "k-infinite__items", role: role === "none" ? undefined : role, "aria-label": role === "none" ? undefined : label, "aria-busy": loading || undefined, children: children }), loading && (loader ?? (_jsx("div", { className: "k-infinite__loader", "aria-hidden": "true", children: [0, 1, 2].map((i) => _jsx("span", { className: "k-skeleton k-infinite__sk" }, i)) }))), loading && _jsx("span", { className: "k-sr-only", role: "status", children: L.loading }), error && !loading && (_jsxs("div", { className: "k-infinite__error", role: "alert", children: [_jsx("span", { children: error === true ? L.error : error }), _jsx("button", { type: "button", className: "k-btn k-btn--secondary k-btn--sm", onClick: () => call.current(), children: L.retry })] })), hasMore && !loading && !error && mode === "button" && (_jsx("div", { className: "k-infinite__more", children: _jsx("button", { type: "button", className: "k-btn k-btn--secondary", onClick: () => call.current(), children: L.loadMore }) })), !hasMore && !loading && endMessage !== null && _jsx("p", { className: "k-infinite__end", children: endMessage ?? L.end }), _jsx("div", { ref: sentinel, className: "k-infinite__sentinel", "aria-hidden": "true" }), _jsx("span", { className: "k-sr-only", "aria-live": "polite", children: live })] }));
46
+ }
@@ -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 { useKashi } from "./KashiProvider.js";
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 { messages: M } = useKashi();
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 { useKashi } from "./KashiProvider.js";
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 { messages: M } = useKashi();
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;