@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
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 { useKashi } from "./KashiProvider.js";
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 { messages: M, n: N } = useKashi();
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)));
@@ -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 { useKashi } from "./KashiProvider.js";
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 } = useKashi();
8
+ const { digits: D, locale } = useKashiLocale();
9
9
  digits ?? (digits = D);
10
10
  const [now, setNow] = useState(() => new Date());
11
11
  useEffect(() => {
@@ -2,7 +2,8 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useEffect, useId, useRef, useState } from "react";
4
4
  import { cx } from "./cx.js";
5
- import { useKashi } from "./KashiProvider.js";
5
+ import { useKashiLocale, useMessages } from "./KashiProvider.js";
6
+ import { faRichText } from "@kashi-ui/persian";
6
7
  const DEFAULT_TOOLS = ["bold", "italic", "underline", "strike", "|", "heading", "quote", "bullet", "ordered", "|", "link", "direction", "|", "undo", "clear"];
7
8
  const ALLOWED = new Set(["P", "BR", "B", "STRONG", "I", "EM", "U", "S", "STRIKE", "DEL", "A", "UL", "OL", "LI", "H2", "H3", "BLOCKQUOTE", "DIV", "SPAN", "CODE"]);
8
9
  const BLOCKS = "p, li, h2, h3, blockquote, div";
@@ -87,7 +88,8 @@ const ICONS = {
87
88
  const DIR_ICON = I(_jsx("path", { d: "M9 4h6M13 4v12M9 4v8a3 3 0 0 1-3-3 3 3 0 0 1 3-3M4 14l2 2 2-2" }));
88
89
  /** ویرایشگر متن غنی سبک و فارسی: جهت هر بند جدا، نیم‌فاصله با Shift+Space، چسباندن پاک‌شده و نوار ابزار با کیبورد */
89
90
  export function RichTextEditor({ value, defaultValue = "", onChange, label, "aria-label": ariaLabel, placeholder, tools = DEFAULT_TOOLS, minHeight = "8rem", showCount = true, name, hint, error, disabled, className, }) {
90
- const { messages: M, n } = useKashi();
91
+ const M = useMessages({ richText: faRichText });
92
+ const { n } = useKashiLocale();
91
93
  const R = M.richText;
92
94
  const area = useRef(null);
93
95
  const bar = useRef(null);
@@ -5,10 +5,12 @@ import { formatSayad, isValidSayad } 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 { useKashi } from "./KashiProvider.js";
8
+ import { useKashiLocale, useMessages } from "./KashiProvider.js";
9
+ import { faInvalid } from "@kashi-ui/persian";
9
10
  /** شناسهٔ صیادی چک: ۱۶ رقم در گروه‌های چهارتایی؛ فقط طول بررسی می‌شود چون رقم کنترل آن عمومی نیست */
10
11
  export const SayadInput = forwardRef(function SayadInput({ value, defaultValue, onValueChange, digits, invalidMessage, error, name, onBlur, placeholder, ...rest }, ref) {
11
- const { messages: M, digits: D } = useKashi();
12
+ const M = useMessages({ invalid: faInvalid });
13
+ const { digits: D } = useKashiLocale();
12
14
  digits ?? (digits = D);
13
15
  invalidMessage ?? (invalidMessage = M.invalid.sayad);
14
16
  const { raw, shown, inputRef, handleChange } = useDigitsInput({ value, defaultValue, maxDigits: 16, format: formatSayad, digits });
package/dist/Scheduler.js CHANGED
@@ -3,7 +3,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useEffect, useRef, useState } from "react";
4
4
  import { formatJalali, formatTime, getIranHoliday, jalaliWeekday, toJalali } from "@kashi-ui/persian";
5
5
  import { cx } from "./cx.js";
6
- import { useKashi } from "./KashiProvider.js";
6
+ import { useKashiLocale, useMessages } from "./KashiProvider.js";
7
+ import { faCommon, faScheduler } from "@kashi-ui/persian";
7
8
  import { SegmentedControl } from "./SegmentedControl.js";
8
9
  const day0 = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate());
9
10
  const addDays = (d, n) => new Date(d.getFullYear(), d.getMonth(), d.getDate() + n);
@@ -45,7 +46,8 @@ function layout(list) {
45
46
  * خط «اکنون»، تعطیلات، و خانه‌های خالی که با کلیک یا کیبورد (کلیدهای جهت و Enter) رویداد تازه می‌سازند.
46
47
  */
47
48
  export function Scheduler({ events, date, defaultDate, onDateChange, view, defaultView = "week", onViewChange, startHour = 8, endHour = 20, step = 30, onSlotClick, onEventClick, holidays = true, now: nowProp, hourHeight = "3.5rem", className, }) {
48
- const { messages: M, locale, digits, weekdays, weekdaysShort, months, n } = useKashi();
49
+ const M = useMessages({ common: faCommon, scheduler: faScheduler });
50
+ const { locale, digits, weekdays, weekdaysShort, months, n } = useKashiLocale();
49
51
  const S = M.scheduler;
50
52
  const [innerDate, setInnerDate] = useState(() => day0(defaultDate ?? new Date()));
51
53
  const [innerView, setInnerView] = useState(defaultView);
@@ -1,8 +1,10 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
4
+ import { persianFilter } from "@kashi-ui/persian";
4
5
  import { cx } from "./cx.js";
5
- import { useKashi } from "./KashiProvider.js";
6
+ import { useMessages } from "./KashiProvider.js";
7
+ import { faSearchSuggest } from "@kashi-ui/persian";
6
8
  import { useIsomorphicLayoutEffect } from "./utils.js";
7
9
  const norm = (s) => s.replace(/[يى]/g, "ی").replace(/ك/g, "ک").replace(/[‌\s]+/g, " ").trim().toLowerCase();
8
10
  const SearchIcon = () => _jsxs("svg", { viewBox: "0 0 20 20", width: "20", height: "20", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", "aria-hidden": "true", children: [_jsx("circle", { cx: "9.1", cy: "9.1", r: "6.2" }), _jsx("path", { d: "m14 14 3.3 3.3" })] });
@@ -10,7 +12,7 @@ const TrendIcon = () => _jsx("svg", { viewBox: "0 0 20 20", width: "16", height:
10
12
  const HistoryIcon = () => _jsx("svg", { viewBox: "0 0 20 20", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "M3.3 10a6.7 6.7 0 1 0 1.9-4.7M3.2 2.9v2.6h2.6M10 6.6V10l2.3 1.5" }) });
11
13
  /** جعبهٔ جستجو با جستجوهای اخیر و پرطرفدار و پیشنهاد هنگام تایپ (الگوی فروشگاه‌های اینترنتی) */
12
14
  export function SearchSuggest({ value, defaultValue, onChange, onSearch, recent, onClearRecent, storageKey, popular = [], suggestions, placeholder, label, name, className, labels = {}, loading, emptyMessage, }) {
13
- const { messages: M } = useKashi();
15
+ const M = useMessages({ searchSuggest: faSearchSuggest });
14
16
  const id = useId();
15
17
  const listId = `${id}-panel`;
16
18
  const [inner, setInner] = useState(defaultValue ?? "");
@@ -53,8 +55,8 @@ export function SearchSuggest({ value, defaultValue, onChange, onSearch, recent,
53
55
  return [];
54
56
  if (typeof suggestions === "function")
55
57
  return suggestions(q).slice(0, 8);
56
- const n = norm(q);
57
- return suggestions.filter((s) => norm(s).includes(n)).slice(0, 8);
58
+ // جستجوی فارسی: فینگلیش، چیدمان اشتباه صفحه‌کلید، ي/ی؛ بهترین تطبیق‌ها اول
59
+ return persianFilter(suggestions, q).slice(0, 8);
58
60
  }, [q, suggestions]);
59
61
  const [open, setOpen] = useState(false);
60
62
  const [active, setActive] = useState(-1);
package/dist/Select.js CHANGED
@@ -4,7 +4,8 @@ import { Children, forwardRef, isValidElement, useCallback, useEffect, useId, us
4
4
  import { cx } from "./cx.js";
5
5
  import { Field, describedBy } from "./Field.js";
6
6
  import { useIsomorphicLayoutEffect } from "./utils.js";
7
- import { useKashi } from "./KashiProvider.js";
7
+ import { useMessages } from "./KashiProvider.js";
8
+ import { faCommon } from "@kashi-ui/persian";
8
9
  const textOf = (node) => typeof node === "string" || typeof node === "number" ? String(node)
9
10
  : Array.isArray(node) ? node.map(textOf).join("")
10
11
  : isValidElement(node) ? textOf(node.props.children) : "";
@@ -46,7 +47,7 @@ export const Select = forwardRef(function Select({ label, hint, error, placehold
46
47
  });
47
48
  function CustomSelect({ selectId, label, hint, error, placeholder, options, size, required, className, fieldClassName, children, extra, placeholderSelected, rest, forwardedRef, readOnly, loading, emptyMessage, }) {
48
49
  const { value, defaultValue, onChange, disabled, name, form, autoComplete, onBlur, onFocus, ...other } = rest;
49
- const { messages: M } = useKashi();
50
+ const M = useMessages({ common: faCommon });
50
51
  const items = useMemo(() => collect(options, children), [options, children]);
51
52
  const opts = items.filter((i) => i.kind === "option");
52
53
  const nativeRef = useRef(null);
package/dist/SideNav.js CHANGED
@@ -2,7 +2,8 @@
2
2
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useId, useState } from "react";
4
4
  import { cx } from "./cx.js";
5
- import { useKashi } from "./KashiProvider.js";
5
+ import { useMessages } from "./KashiProvider.js";
6
+ import { faSideNav } from "@kashi-ui/persian";
6
7
  const Chevron = () => (_jsx("svg", { className: "k-sidenav__chevron", viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.7, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "m6 8 4 4 4-4" }) }));
7
8
  const hasCurrent = (it) => Boolean(it.current || it.items?.some(hasCurrent));
8
9
  function Item({ item, collapsed }) {
@@ -19,7 +20,7 @@ function Item({ item, collapsed }) {
19
20
  }
20
21
  /** ناوبری کناری پنل مدیریت با گروه، زیرمنو، نشان و حالت جمع‌شده */
21
22
  export function SideNav({ sections, header, footer, collapsed, "aria-label": ariaLabel, className }) {
22
- const { messages: M } = useKashi();
23
+ const M = useMessages({ sideNav: faSideNav });
23
24
  ariaLabel ?? (ariaLabel = M.sideNav.label);
24
25
  const id = useId();
25
26
  return (_jsxs("nav", { className: cx("k-sidenav", collapsed && "k-sidenav--collapsed", className), "aria-label": ariaLabel, children: [header && _jsx("div", { className: "k-sidenav__header", children: header }), sections.map((sec, i) => (_jsxs("div", { children: [sec.label && _jsx("p", { className: "k-sidenav__label", id: `${id}-s${i}`, children: sec.label }), _jsx("ul", { className: "k-sidenav__group", role: "list", "aria-labelledby": sec.label ? `${id}-s${i}` : undefined, children: sec.items.map((it) => _jsx(Item, { item: it, collapsed: collapsed }, it.label)) })] }, sec.label ?? i))), footer && _jsx("div", { className: "k-sidenav__footer", children: footer })] }));
@@ -0,0 +1,38 @@
1
+ import { type ReactNode } from "react";
2
+ /** یک خط امضا: نقطه‌ها به نسبت کادر (۰ تا ۱) و فشار قلم، تا با تغییر اندازه دوباره کشیده شود */
3
+ export type SignatureStroke = Array<[x: number, y: number, pressure: number]>;
4
+ export interface SignaturePadHandle {
5
+ clear: () => void;
6
+ undo: () => void;
7
+ isEmpty: () => boolean;
8
+ /** تصویر PNG با پس‌زمینهٔ شفاف و جوهر exportColor؛ اگر امضا خالی باشد null */
9
+ toDataURL: (type?: string) => string | null;
10
+ strokes: () => SignatureStroke[];
11
+ }
12
+ export interface SignaturePadProps {
13
+ label?: ReactNode;
14
+ hint?: ReactNode;
15
+ error?: ReactNode;
16
+ /** تصویر امضا (data URL) که بعد از هر خط ساخته می‌شود */
17
+ onChange?: (dataUrl: string | null) => void;
18
+ /** خط‌های اولیه (برای بازگرداندن امضای ذخیره‌شده) */
19
+ defaultStrokes?: SignatureStroke[];
20
+ /** نام فیلد فرم؛ data URL در ورودی پنهان می‌رود */
21
+ name?: string;
22
+ required?: boolean;
23
+ disabled?: boolean;
24
+ readOnly?: boolean;
25
+ /** امکان تایپ نام به‌جای رسم (برای کیبورد و صفحه‌خوان) @default true */
26
+ allowTyped?: boolean;
27
+ /** پهنای پایهٔ قلم به پیکسل CSS @default 2.5 */
28
+ penWidth?: number;
29
+ /** رنگ جوهر در تصویر خروجی، مستقل از تم @default "#0b0c0f" */
30
+ exportColor?: string;
31
+ id?: string;
32
+ className?: string;
33
+ }
34
+ /**
35
+ * کادر امضا با ماوس، قلم و لمس: خط‌ها نرم (منحنی درجهٔ دو) و پهنایشان با فشار و سرعت قلم تغییر می‌کند.
36
+ * برگرداندن آخرین خط، پاک کردن، و حالت «تایپ امضا» برای کسی که نمی‌تواند رسم کند.
37
+ */
38
+ export declare const SignaturePad: import("react").ForwardRefExoticComponent<SignaturePadProps & import("react").RefAttributes<SignaturePadHandle>>;
@@ -0,0 +1,170 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { forwardRef, useCallback, useEffect, useId, useImperativeHandle, useRef, useState } from "react";
4
+ import { cx } from "./cx.js";
5
+ import { useMessages } from "./KashiProvider.js";
6
+ import { faCommon, faSignature } from "@kashi-ui/persian";
7
+ const dist = (a, b) => Math.hypot(a[0] - b[0], a[1] - b[1]);
8
+ /**
9
+ * کادر امضا با ماوس، قلم و لمس: خط‌ها نرم (منحنی درجهٔ دو) و پهنایشان با فشار و سرعت قلم تغییر می‌کند.
10
+ * برگرداندن آخرین خط، پاک کردن، و حالت «تایپ امضا» برای کسی که نمی‌تواند رسم کند.
11
+ */
12
+ export const SignaturePad = forwardRef(function SignaturePad({ label, hint, error, onChange, defaultStrokes = [], name, required, disabled, readOnly, allowTyped = true, penWidth = 2.5, exportColor = "#0b0c0f", id, className }, ref) {
13
+ const M = useMessages({ common: faCommon, signature: faSignature });
14
+ const S = M.signature;
15
+ const autoId = useId();
16
+ const fieldId = id ?? autoId;
17
+ const canvas = useRef(null);
18
+ const strokes = useRef(defaultStrokes);
19
+ const current = useRef(null);
20
+ const [count, setCount] = useState(defaultStrokes.length);
21
+ const [mode, setMode] = useState("draw");
22
+ const [typed, setTyped] = useState("");
23
+ const [data, setData] = useState(null);
24
+ const [live, setLive] = useState("");
25
+ const locked = disabled || readOnly;
26
+ const paint = useCallback((ctx, w, h, list, color, scale = 1) => {
27
+ ctx.clearRect(0, 0, w, h);
28
+ ctx.strokeStyle = color;
29
+ ctx.fillStyle = color;
30
+ ctx.lineCap = "round";
31
+ ctx.lineJoin = "round";
32
+ for (const s of list) {
33
+ if (s.length === 1) {
34
+ ctx.beginPath();
35
+ ctx.arc(s[0][0] * w, s[0][1] * h, (penWidth * scale * (0.6 + s[0][2])) / 2, 0, Math.PI * 2);
36
+ ctx.fill();
37
+ continue;
38
+ }
39
+ for (let i = 1; i < s.length; i++) {
40
+ const p0 = s[i - 1], p1 = s[i];
41
+ const m0 = i > 1 ? [(s[i - 2][0] + p0[0]) / 2, (s[i - 2][1] + p0[1]) / 2] : p0;
42
+ const m1 = [(p0[0] + p1[0]) / 2, (p0[1] + p1[1]) / 2];
43
+ ctx.lineWidth = penWidth * scale * (0.6 + (p0[2] + p1[2]) / 2);
44
+ ctx.beginPath();
45
+ ctx.moveTo(m0[0] * w, m0[1] * h);
46
+ ctx.quadraticCurveTo(p0[0] * w, p0[1] * h, m1[0] * w, m1[1] * h);
47
+ if (i === s.length - 1)
48
+ ctx.lineTo(p1[0] * w, p1[1] * h);
49
+ ctx.stroke();
50
+ }
51
+ }
52
+ }, [penWidth]);
53
+ const redraw = useCallback(() => {
54
+ const c = canvas.current;
55
+ if (!c)
56
+ return;
57
+ const r = c.getBoundingClientRect();
58
+ const dpr = window.devicePixelRatio || 1;
59
+ if (c.width !== Math.round(r.width * dpr) || c.height !== Math.round(r.height * dpr)) {
60
+ c.width = Math.round(r.width * dpr);
61
+ c.height = Math.round(r.height * dpr);
62
+ }
63
+ const ctx = c.getContext("2d");
64
+ if (!ctx)
65
+ return;
66
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
67
+ paint(ctx, c.width, c.height, current.current ? [...strokes.current, current.current] : strokes.current, getComputedStyle(c).color, dpr);
68
+ }, [paint]);
69
+ useEffect(() => {
70
+ redraw();
71
+ const c = canvas.current;
72
+ if (!c || typeof ResizeObserver === "undefined")
73
+ return;
74
+ const ro = new ResizeObserver(() => redraw());
75
+ ro.observe(c);
76
+ // رنگ جوهر از تم می‌آید؛ با عوض شدن تم دوباره بکش
77
+ const mq = window.matchMedia?.("(prefers-color-scheme: dark)");
78
+ mq?.addEventListener?.("change", redraw);
79
+ return () => { ro.disconnect(); mq?.removeEventListener?.("change", redraw); };
80
+ }, [redraw, mode]);
81
+ const exportImage = useCallback((type = "image/png") => {
82
+ const c = canvas.current;
83
+ if (typeof document === "undefined")
84
+ return null;
85
+ const w = c?.width || 600, h = c?.height || 200;
86
+ const out = document.createElement("canvas");
87
+ out.width = w;
88
+ out.height = h;
89
+ const ctx = out.getContext("2d");
90
+ if (!ctx)
91
+ return null;
92
+ if (mode === "type") {
93
+ if (!typed.trim())
94
+ return null;
95
+ ctx.fillStyle = exportColor;
96
+ ctx.textAlign = "center";
97
+ ctx.textBaseline = "middle";
98
+ const family = getComputedStyle(c ?? document.body).getPropertyValue("--k-font-display") || "sans-serif";
99
+ ctx.font = `700 ${Math.round(h * 0.34)}px ${family}`;
100
+ ctx.direction = "rtl";
101
+ ctx.fillText(typed.trim(), w / 2, h / 2, w * 0.9);
102
+ return out.toDataURL(type);
103
+ }
104
+ if (!strokes.current.length)
105
+ return null;
106
+ paint(ctx, w, h, strokes.current, exportColor, w / (c?.getBoundingClientRect().width || w));
107
+ return out.toDataURL(type);
108
+ }, [mode, typed, exportColor, paint]);
109
+ const commit = useCallback((announce) => {
110
+ const url = exportImage();
111
+ setData(url);
112
+ setCount(strokes.current.length);
113
+ onChange?.(url);
114
+ if (announce)
115
+ setLive(announce);
116
+ }, [exportImage, onChange]);
117
+ useEffect(() => {
118
+ if (mode === "type")
119
+ commit();
120
+ // eslint-disable-next-line react-hooks/exhaustive-deps
121
+ }, [typed, mode]);
122
+ const clear = () => { strokes.current = []; current.current = null; setTyped(""); redraw(); commit(S.cleared); };
123
+ const undo = () => { strokes.current = strokes.current.slice(0, -1); redraw(); commit(); };
124
+ useImperativeHandle(ref, () => ({
125
+ clear, undo,
126
+ isEmpty: () => (mode === "type" ? !typed.trim() : strokes.current.length === 0),
127
+ toDataURL: exportImage,
128
+ strokes: () => strokes.current,
129
+ }));
130
+ const point = (e) => {
131
+ const r = e.currentTarget.getBoundingClientRect();
132
+ const pressure = e.pointerType === "pen" && e.pressure > 0 ? e.pressure : 0.5;
133
+ return [(e.clientX - r.left) / r.width, (e.clientY - r.top) / r.height, pressure];
134
+ };
135
+ const empty = mode === "type" ? !typed.trim() : count === 0;
136
+ const hintId = `${fieldId}-hint`;
137
+ const errId = `${fieldId}-err`;
138
+ return (_jsxs("div", { className: cx("k-field k-signature", className), "data-disabled": disabled || undefined, "data-empty": empty || undefined, "data-invalid": error ? "" : undefined, children: [label && _jsxs("span", { className: "k-label", id: `${fieldId}-label`, children: [label, required && _jsx("span", { className: "k-label__required", "aria-hidden": "true", children: "*" })] }), allowTyped && !locked && (_jsx("div", { className: "k-signature__modes", role: "radiogroup", "aria-label": typeof label === "string" ? label : S.label, children: ["draw", "type"].map((m) => (_jsx("button", { type: "button", role: "radio", "aria-checked": mode === m, className: "k-signature__mode", onClick: () => setMode(m), children: S[m] }, m))) })), _jsxs("div", { className: "k-signature__pad", children: [mode === "draw" ? (_jsx("canvas", { ref: canvas, className: "k-signature__canvas", role: "img", "aria-label": `${S.area}${empty ? `${M.common.comma}${S.empty}` : ""}`, "aria-describedby": [hint || !locked ? hintId : "", error ? errId : ""].filter(Boolean).join(" ") || undefined, onPointerDown: (e) => {
139
+ if (locked || (e.pointerType === "mouse" && e.button !== 0))
140
+ return;
141
+ e.currentTarget.setPointerCapture(e.pointerId);
142
+ current.current = [point(e)];
143
+ redraw();
144
+ }, onPointerMove: (e) => {
145
+ const s = current.current;
146
+ if (!s)
147
+ return;
148
+ const coalesced = e.nativeEvent.getCoalescedEvents?.();
149
+ const events = coalesced && coalesced.length ? coalesced : [e.nativeEvent];
150
+ const r = e.currentTarget.getBoundingClientRect();
151
+ for (const ev of events) {
152
+ const p = [(ev.clientX - r.left) / r.width, (ev.clientY - r.top) / r.height, ev.pointerType === "pen" && ev.pressure > 0 ? ev.pressure : 0.5];
153
+ const last = s[s.length - 1];
154
+ const d = dist(last, p) * r.width;
155
+ if (d < 1.2)
156
+ continue;
157
+ // قلم بی‌فشار: هرچه تندتر، نازک‌تر (مثل جوهر واقعی)
158
+ if (ev.pointerType !== "pen")
159
+ p[2] = Math.max(0.15, Math.min(0.75, 0.75 - d / 60));
160
+ s.push(p);
161
+ }
162
+ redraw();
163
+ }, onPointerUp: () => {
164
+ if (!current.current)
165
+ return;
166
+ strokes.current = [...strokes.current, current.current];
167
+ current.current = null;
168
+ commit(strokes.current.length === 1 ? S.signed : undefined);
169
+ }, onPointerCancel: () => { current.current = null; redraw(); } })) : (_jsxs("label", { className: "k-signature__typed", children: [_jsx("span", { className: "k-sr-only", children: S.typedLabel }), _jsx("input", { className: "k-signature__typed-input", value: typed, onChange: (e) => setTyped(e.target.value), placeholder: S.typedLabel, disabled: disabled, readOnly: readOnly, autoComplete: "name" })] })), _jsx("span", { className: "k-signature__line", "aria-hidden": "true", children: "\u00D7" }), !locked && (_jsxs("div", { className: "k-signature__tools", children: [mode === "draw" && (_jsx("button", { type: "button", className: "k-signature__tool", onClick: undo, disabled: count === 0, "aria-label": S.undo, title: S.undo, children: _jsx("svg", { viewBox: "0 0 20 20", "aria-hidden": "true", children: _jsx("path", { d: "M7.5 5 4 8.5 7.5 12M4.5 8.5h7a4 4 0 0 1 0 8H9", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round" }) }) })), _jsx("button", { type: "button", className: "k-signature__tool", onClick: clear, disabled: empty, children: S.clear })] }))] }), (hint || !locked) && !error && _jsx("span", { className: "k-hint", id: hintId, children: hint ?? (mode === "draw" ? S.hint : null) }), error && _jsx("span", { className: "k-hint k-hint--error", id: errId, role: "alert", children: error }), name && _jsx("input", { type: "hidden", name: name, value: data ?? "", required: required }), _jsx("span", { className: "k-sr-only", "aria-live": "polite", children: live })] }));
170
+ });
package/dist/Slider.js CHANGED
@@ -3,7 +3,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useId, useState } from "react";
4
4
  import { formatNumber } from "@kashi-ui/persian";
5
5
  import { cx } from "./cx.js";
6
- import { useKashi } from "./KashiProvider.js";
6
+ import { useKashiLocale, useMessages } from "./KashiProvider.js";
7
+ import { faCommon, faSlider } from "@kashi-ui/persian";
7
8
  /** اسلایدر روی <input type="range"> بومی؛ با آرایهٔ دوتایی، بازه با دو دستگیره */
8
9
  export function Slider({ label, value, defaultValue, onChange, min = 0, max = 100, step = 1, showValue = true, format, marks, disabled, readOnly, name, className, labels = {}, }) {
9
10
  const id = useId();
@@ -12,7 +13,8 @@ export function Slider({ label, value, defaultValue, onChange, min = 0, max = 10
12
13
  const current = (value ?? inner);
13
14
  const [lo, hi] = Array.isArray(current) ? current : [min, current];
14
15
  const pct = (n) => `${((n - min) / (max - min)) * 100}%`;
15
- const { messages: M, digits: D } = useKashi();
16
+ const M = useMessages({ common: faCommon, slider: faSlider });
17
+ const { digits: D } = useKashiLocale();
16
18
  format ?? (format = (x) => formatNumber(x, { digits: D }));
17
19
  const { from = M.slider.from, to = M.slider.to, separator = M.common.range } = labels;
18
20
  const set = (next) => {
package/dist/Sortable.js CHANGED
@@ -4,14 +4,16 @@ import { useRef, useState } from "react";
4
4
  import { cx } from "./cx.js";
5
5
  import { move, useFlip } from "./dnd.js";
6
6
  import { useIsomorphicLayoutEffect } from "./utils.js";
7
- import { useKashi } from "./KashiProvider.js";
7
+ import { useKashiLocale, useMessages } from "./KashiProvider.js";
8
+ import { faSortable } 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
  /**
10
11
  * فهرست کشیدنی: با ماوس و لمس از دستگیره بکشید، یا با کیبورد: فاصله برای برداشتن، کلیدهای جهت برای حرکت،
11
12
  * فاصلهٔ دوباره برای رها کردن و Escape برای لغو. هر حرکت برای صفحه‌خوان اعلام می‌شود.
12
13
  */
13
14
  export function SortableList({ items, getId, getLabel, onReorder, renderItem, "aria-label": ariaLabel, disabled, className }) {
14
- const { messages: M, n } = useKashi();
15
+ const M = useMessages({ sortable: faSortable });
16
+ const { n } = useKashiLocale();
15
17
  const S = M.sortable;
16
18
  const root = useRef(null);
17
19
  // ترتیب پیش‌نمایش هنگام کشیدن؛ null یعنی همان items
package/dist/Splitter.js CHANGED
@@ -2,10 +2,12 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useRef, useState } from "react";
4
4
  import { cx } from "./cx.js";
5
- import { useKashi } from "./KashiProvider.js";
5
+ import { useKashiLocale, useMessages } from "./KashiProvider.js";
6
+ import { faCommon, faSplitter } from "@kashi-ui/persian";
6
7
  /** دو پنل با مرز قابل‌کشیدن؛ با کیبورد: ←→ (یا ↑↓) پنج درصد، Home/End کمینه و بیشینه */
7
8
  export function Splitter({ children, orientation = "horizontal", size, defaultSize = 40, onSizeChange, min = 15, max = 85, label, height, className }) {
8
- const { messages: M, n } = useKashi();
9
+ const M = useMessages({ common: faCommon, splitter: faSplitter });
10
+ const { n } = useKashiLocale();
9
11
  label ?? (label = M.splitter.label);
10
12
  const [inner, setInner] = useState(defaultSize);
11
13
  const current = size ?? inner;
package/dist/Stat.js CHANGED
@@ -2,11 +2,13 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { forwardRef } from "react";
4
4
  import { cx } from "./cx.js";
5
- import { useKashi } from "./KashiProvider.js";
5
+ import { useKashiLocale, useMessages } from "./KashiProvider.js";
6
+ import { faCommon, faStat } from "@kashi-ui/persian";
6
7
  const Arrow = ({ dir }) => (_jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: dir === "up" ? _jsx("path", { d: "M10 15V5m0 0-4 4m4-4 4 4" }) : _jsx("path", { d: "M10 5v10m0 0-4-4m4 4 4-4" }) }));
7
8
  /** کارت شاخص کلیدی (KPI) با روند؛ صفحه‌خوان روند را به شکل «۱۲٪ افزایش» می‌خواند */
8
9
  export const StatCard = forwardRef(function StatCard({ label, value, unit, icon, change, invertTrend, caption, children, labels = {}, loading, className, ...rest }, ref) {
9
- const { messages: M, n } = useKashi();
10
+ const M = useMessages({ common: faCommon, stat: faStat });
11
+ const { n } = useKashiLocale();
10
12
  const { up = M.stat.up, down = M.stat.down, flat = M.stat.flat } = labels;
11
13
  const dir = change === undefined ? null : change > 0 ? "up" : change < 0 ? "down" : "flat";
12
14
  // رنگ بر اساس خوب یا بد بودن، نه جهت
package/dist/Stepper.js CHANGED
@@ -1,11 +1,13 @@
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 { useKashi } from "./KashiProvider.js";
4
+ import { useKashiLocale, useMessages } from "./KashiProvider.js";
5
+ import { faCommon, faStepper } from "@kashi-ui/persian";
5
6
  const Check = () => (_jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 2.2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "m5 10.5 3.2 3L15 7" }) }));
6
7
  /** مراحل یک فرایند؛ مرحلهٔ فعلی با aria-current="step" و وضعیت هر مرحله برای صفحه‌خوان */
7
8
  export function Stepper({ steps, current, orientation = "horizontal", label, labels = {}, className }) {
8
- const { messages: M, n } = useKashi();
9
+ const M = useMessages({ common: faCommon, stepper: faStepper });
10
+ const { n } = useKashiLocale();
9
11
  label ?? (label = M.stepper.label);
10
12
  const { complete = M.stepper.complete, current: currentLabel = M.stepper.current } = labels;
11
13
  return (_jsx("ol", { className: cx("k-steps", orientation === "vertical" && "k-steps--vertical", className), "aria-label": label, children: steps.map((s, i) => {
@@ -2,7 +2,8 @@
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 { faStreaming } from "@kashi-ui/persian";
6
7
  const reduced = () => typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
7
8
  /** کلمه‌ها با فاصلهٔ بعدشان؛ نیم‌فاصله داخل کلمه می‌ماند */
8
9
  const words = (s) => s.match(/\S+\s*|\s+/g) ?? [];
@@ -11,7 +12,7 @@ const words = (s) => s.match(/\S+\s*|\s+/g) ?? [];
11
12
  * صفحه‌خوان هر کلمه را جدا نمی‌خواند: متن تا پایان aria-busy است و پایان پاسخ یک بار اعلام می‌شود.
12
13
  */
13
14
  export function StreamingText({ text, streaming = false, speed, onDone, cursor = true, as: Tag = "p", className }) {
14
- const { messages: M } = useKashi();
15
+ const M = useMessages({ streaming: faStreaming });
15
16
  const all = words(text);
16
17
  const [shown, setShown] = useState(() => (speed && !reduced() ? 0 : all.length));
17
18
  // کلمه‌هایی که پیش از این دیده شده‌اند انیمیشن نمی‌گیرند
@@ -2,10 +2,11 @@
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 { useKashi } from "./KashiProvider.js";
5
+ import { useMessages } from "./KashiProvider.js";
6
+ import { faSwatch } from "@kashi-ui/persian";
6
7
  /** انتخاب رنگ از میان نمونه‌ها (فیلتر رنگ کالا)؛ روی چک‌باکس یا رادیوی بومی، پس صفحه‌کلید و فرم خودکار کار می‌کنند */
7
8
  export function SwatchGroup({ options, value, defaultValue, onChange, single = false, label, size = "md", name, readOnly, className }) {
8
- const { messages: M } = useKashi();
9
+ const M = useMessages({ swatch: faSwatch });
9
10
  const id = useId();
10
11
  const [inner, setInner] = useState(defaultValue ?? []);
11
12
  const selected = value ?? inner;
package/dist/TagInput.js CHANGED
@@ -5,7 +5,8 @@ import { normalizePersian } from "@kashi-ui/persian";
5
5
  import { Badge } from "./Badge.js";
6
6
  import { Field, describedBy } from "./Field.js";
7
7
  import { mergeRefs } from "./utils.js";
8
- import { useKashi } from "./KashiProvider.js";
8
+ import { useKashiLocale, useMessages } from "./KashiProvider.js";
9
+ import { faCommon, faTagInput } from "@kashi-ui/persian";
9
10
  /** ورود چند مقدار، مثل مهارت‌ها یا ایمیل‌ها؛ Enter یا ویرگول (, یا ،) ثبت می‌کند و Backspace آخری را حذف می‌کند */
10
11
  export const TagInput = forwardRef(function TagInput({ label, hint, error, value, defaultValue = [], onChange, placeholder, separators = ["Enter", ",", "،"], validate, max, allowDuplicates = false, tone = "brand", disabled, readOnly, name, id, className, labels = {}, }, ref) {
11
12
  const autoId = useId();
@@ -16,7 +17,8 @@ export const TagInput = forwardRef(function TagInput({ label, hint, error, value
16
17
  const [localError, setLocalError] = useState();
17
18
  const [announce, setAnnounce] = useState("");
18
19
  const inputRef = useRef(null);
19
- const { messages: M, n: N } = useKashi();
20
+ const M = useMessages({ common: faCommon, tagInput: faTagInput });
21
+ const { n: N } = useKashiLocale();
20
22
  const { added = M.common.added, removed = M.common.removed, remove = M.common.remove, max: maxMsg = (x) => M.common.max(N(x)), duplicate = M.tagInput.duplicate, } = labels;
21
23
  const set = (next) => {
22
24
  if (value === undefined)
@@ -3,13 +3,14 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
3
3
  import { forwardRef, useState } from "react";
4
4
  import { isValidTaxId, normalizeTaxId } from "@kashi-ui/persian";
5
5
  import { Input } from "./Input.js";
6
- import { useKashi } from "./KashiProvider.js";
6
+ import { useMessages } from "./KashiProvider.js";
7
+ import { faInvalid } from "@kashi-ui/persian";
7
8
  /**
8
9
  * شمارهٔ منحصربه‌فرد مالیاتی فاکتور (سامانهٔ مودیان): ۲۲ نویسه.
9
10
  * ارقام فارسی لاتین می‌شوند، حروف بزرگ و فاصله و خط تیره حذف؛ فقط شکل بررسی می‌شود.
10
11
  */
11
12
  export const TaxIdInput = forwardRef(function TaxIdInput({ value, defaultValue = "", onValueChange, invalidMessage, error, name, onBlur, placeholder, ...rest }, ref) {
12
- const { messages: M } = useKashi();
13
+ const M = useMessages({ invalid: faInvalid });
13
14
  invalidMessage ?? (invalidMessage = M.invalid.taxId);
14
15
  const [inner, setInner] = useState(() => normalizeTaxId(defaultValue).slice(0, 22));
15
16
  const [touched, setTouched] = useState(false);
package/dist/TimeClock.js CHANGED
@@ -3,7 +3,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useEffect, useRef, useState } from "react";
4
4
  import { formatTime, parseTime, toFaDigits } from "@kashi-ui/persian";
5
5
  import { cx } from "./cx.js";
6
- import { useKashi } from "./KashiProvider.js";
6
+ import { useKashiLocale, useMessages } from "./KashiProvider.js";
7
+ import { faTimePicker } from "@kashi-ui/persian";
7
8
  const DAY = 24 * 60;
8
9
  const pad = (n) => String(n).padStart(2, "0");
9
10
  const toMin = (s) => {
@@ -22,7 +23,8 @@ const hourAngle = (h) => (h % 12) * 30;
22
23
  * با کلیک یا کشیدن روی صفحه، یا با کیبورد (↑↓←→، Home/End، Enter) کار می‌کند.
23
24
  */
24
25
  export function TimeClock({ value, defaultValue = null, onChange, onComplete, view, defaultView = "hour", onViewChange, step = 5, min, max, digits, "aria-label": ariaLabel, labels = {}, autoFocus, className, }) {
25
- const { messages: M, digits: D } = useKashi();
26
+ const M = useMessages({ timePicker: faTimePicker });
27
+ const { digits: D } = useKashiLocale();
26
28
  digits ?? (digits = D);
27
29
  ariaLabel ?? (ariaLabel = M.timePicker.clock);
28
30
  const { hour: hourLabel = M.timePicker.hour, minute: minuteLabel = M.timePicker.minute } = labels;
package/dist/TimeInput.js CHANGED
@@ -3,13 +3,15 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
3
3
  import { forwardRef, useEffect, useState } from "react";
4
4
  import { formatTime, parseTime, toFaDigits } from "@kashi-ui/persian";
5
5
  import { Input } from "./Input.js";
6
- import { useKashi } from "./KashiProvider.js";
6
+ import { useKashiLocale, useMessages } from "./KashiProvider.js";
7
+ import { faInvalid } from "@kashi-ui/persian";
7
8
  const toMin = (t) => t.hours * 60 + t.minutes;
8
9
  const fromMin = (m) => ({ hours: Math.floor(m / 60), minutes: m % 60 });
9
10
  const Clock = () => (_jsxs("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.7, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [_jsx("circle", { cx: "10", cy: "10", r: "7" }), _jsx("path", { d: "M10 6v4l2.5 2" })] }));
10
11
  /** ساعت ۲۴ساعته با ارقام فارسی: «۹۳۰» یا «۹:۳۰» تایپ کنید، ↑↓ گام به گام */
11
12
  export const TimeInput = forwardRef(function TimeInput({ value, defaultValue = null, onChange, step = 15, min, max, digits, invalidMessage, rangeMessage, error, name, placeholder, onBlur, onKeyDown, ...rest }, ref) {
12
- const { messages: M, digits: D, locale } = useKashi();
13
+ const M = useMessages({ invalid: faInvalid });
14
+ const { digits: D, locale } = useKashiLocale();
13
15
  digits ?? (digits = D);
14
16
  invalidMessage ?? (invalidMessage = M.invalid.time);
15
17
  rangeMessage ?? (rangeMessage = M.invalid.timeRange);
@@ -5,13 +5,15 @@ import { formatTime, parseTime, toFaDigits } from "@kashi-ui/persian";
5
5
  import { TimeClock } from "./TimeClock.js";
6
6
  import { TimeInput } from "./TimeInput.js";
7
7
  import { useIsomorphicLayoutEffect } from "./utils.js";
8
- import { useKashi } from "./KashiProvider.js";
8
+ import { useKashiLocale, useMessages } from "./KashiProvider.js";
9
+ import { faCommon, faTimePicker } from "@kashi-ui/persian";
9
10
  /**
10
11
  * انتخاب ساعت: تایپ مستقیم (۰۹:۳۰) یا انتخاب از صفحهٔ ساعت عقربه‌ای، کنار دیت‌پیکر شمسی.
11
12
  * با name، مقدار به شکل HH:MM با ارقام لاتین در فرم ارسال می‌شود.
12
13
  */
13
14
  export const TimePicker = forwardRef(function TimePicker({ value, defaultValue = null, onChange, step = 5, min, max, digits, openLabel, showNow = true, readOnly, disabled, ...rest }, ref) {
14
- const { messages: M, digits: D } = useKashi();
15
+ const M = useMessages({ common: faCommon, timePicker: faTimePicker });
16
+ const { digits: D } = useKashiLocale();
15
17
  digits ?? (digits = D);
16
18
  openLabel ?? (openLabel = M.timePicker.open);
17
19
  const id = useId();