@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/README.md CHANGED
@@ -20,7 +20,7 @@ export function SignUp() {
20
20
  }
21
21
  ```
22
22
 
23
- کامپوننت‌ها: Button · Input · Textarea · Select · Checkbox · RadioGroup · Switch · Badge · Card · Alert · Avatar · AvatarGroup · Tabs · Dialog · Toast · Tooltip · DropdownMenu · DataTable · Pagination · Breadcrumb · Accordion · Stepper · Progress · Spinner · Skeleton · EmptyState · Divider · Kbd · RelativeTime · Combobox · MultiSelect · CommandPalette · TagInput · FileUpload · Slider · NumberInput · Popover · StatCard · Timeline · SideNav · SegmentedControl · CopyButton · Banner · Rating · TreeView · ButtonGroup · ChipGroup · PasswordStrength · BarChart · LineChart · ContextMenu · InlineEdit · PieChart · BarList · ProportionBar · Sparkline · Carousel · ColorPicker · Tour · Meter · Splitter · ChatThread · ChatMessage · TypingIndicator · ChatComposer · StreamingText · CodeBlock · SortableList · Kanban · Gallery · Lightbox · RichTextEditor · NotificationCenter · QRCode · Scheduler
23
+ کامپوننت‌ها: Button · Input · Textarea · Select · Checkbox · RadioGroup · Switch · Badge · Card · Alert · Avatar · AvatarGroup · Tabs · Dialog · Toast · Tooltip · DropdownMenu · DataTable · Pagination · Breadcrumb · Accordion · Stepper · Progress · Spinner · Skeleton · EmptyState · Divider · Kbd · RelativeTime · Combobox · MultiSelect · CommandPalette · TagInput · FileUpload · Slider · NumberInput · Popover · StatCard · Timeline · SideNav · SegmentedControl · CopyButton · Banner · Rating · TreeView · ButtonGroup · ChipGroup · PasswordStrength · BarChart · LineChart · ContextMenu · InlineEdit · PieChart · BarList · ProportionBar · Sparkline · Carousel · ColorPicker · Tour · Meter · Splitter · ChatThread · ChatMessage · TypingIndicator · ChatComposer · StreamingText · CodeBlock · SortableList · Kanban · Gallery · Lightbox · RichTextEditor · NotificationCenter · QRCode · Scheduler · Gantt · SignaturePad · ImageCropper · Invoice · VirtualList · InfiniteScroll · BillIdInput · PaymentIdInput
24
24
 
25
25
  فارسی: DatePicker و Calendar شمسی · DateRangePicker · TimeInput · TimePicker · TimeClock · PostalCodeInput · PlateInput · LandlineInput · MonthPicker · Countdown · ActivityHeatmap · ProvinceSelect · NationalIdInput · CardNumberInput · IbanInput · MobileInput · PriceInput · OtpInput
26
26
 
@@ -4,10 +4,12 @@ import { formatJalali, formatNumber, jalaliMonthLength, toGregorian, toISODate,
4
4
  import { useRef, useState } from "react";
5
5
  import { cx } from "./cx.js";
6
6
  import { ChartTip } from "./Chart.js";
7
- import { useKashi } from "./KashiProvider.js";
7
+ import { useKashiLocale, useMessages } from "./KashiProvider.js";
8
+ import { faHeatmap } from "@kashi-ui/persian";
8
9
  /** نقشهٔ فعالیت سالانه با ماه‌های شمسی؛ هفته از شنبه شروع می‌شود */
9
10
  export function ActivityHeatmap({ data, year = toJalali(new Date()).jy, label, unit, className }) {
10
- const { messages: M, digits: D, locale, n, months: MONTHS } = useKashi();
11
+ const M = useMessages({ heatmap: faHeatmap });
12
+ const { digits: D, locale, n, months: MONTHS } = useKashiLocale();
11
13
  const H = M.heatmap;
12
14
  const num = (v) => formatNumber(v, { digits: D });
13
15
  unit ?? (unit = H.unit);
@@ -8,7 +8,8 @@ import { Input, Textarea } from "./Input.js";
8
8
  import { IranMap } from "./IranMap.js";
9
9
  import { PostalCodeInput } from "./PostalCodeInput.js";
10
10
  import { ProvinceSelect } from "./ProvinceSelect.js";
11
- import { useKashi } from "./KashiProvider.js";
11
+ import { useMessages } from "./KashiProvider.js";
12
+ import { faAddress, faIranMap } from "@kashi-ui/persian";
12
13
  /**
13
14
  * فرم نشانی ایرانی: استان، شهرِ همان استان، نشانی، پلاک، واحد و کد پستی ده‌رقمی.
14
15
  * با انتخاب شهر بدون استان، استان خودکار پر می‌شود؛ با عوض شدن استان، شهرِ نامربوط پاک می‌شود.
@@ -16,7 +17,7 @@ import { useKashi } from "./KashiProvider.js";
16
17
  export function AddressForm({ value, defaultValue, onChange, errors = {}, name, legend, labels: labelsProp, map = false, required = true, disabled, className, }) {
17
18
  const [inner, setInner] = useState({ ...EMPTY_ADDRESS, ...defaultValue });
18
19
  const address = value ?? inner;
19
- const { messages: M } = useKashi();
20
+ const M = useMessages({ address: faAddress, iranMap: faIranMap });
20
21
  const A = M.address;
21
22
  if (legend === undefined)
22
23
  legend = A.legend;
package/dist/Alert.js CHANGED
@@ -3,7 +3,8 @@ 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
5
  import { CloseIcon, ErrorIcon, InfoIcon, SuccessIcon, WarningIcon } from "./icons.js";
6
- import { useKashi } from "./KashiProvider.js";
6
+ import { useMessages } from "./KashiProvider.js";
7
+ import { faAlert } from "@kashi-ui/persian";
7
8
  const ICONS = {
8
9
  neutral: InfoIcon,
9
10
  brand: InfoIcon,
@@ -13,7 +14,7 @@ const ICONS = {
13
14
  error: ErrorIcon,
14
15
  };
15
16
  export const Alert = forwardRef(function Alert({ tone = "neutral", title, icon, actions, onClose, closeLabel, tinted = false, layout = "card", size = "md", classNames = {}, role, className, children, ...rest }, ref) {
16
- const { messages: M } = useKashi();
17
+ const M = useMessages({ alert: faAlert });
17
18
  closeLabel ?? (closeLabel = M.alert.close);
18
19
  const Icon = ICONS[tone];
19
20
  return (_jsxs("div", { ref: ref,
@@ -3,7 +3,8 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
3
3
  import { useEffect, useId, useMemo, useRef, useState } from "react";
4
4
  import { formatJalali, formatTime, getIranHoliday, parseTime, toFaDigits, toISODate, 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 { faAppointment, faCommon } from "@kashi-ui/persian";
7
8
  const PERIODS = [["morning", 12], ["afternoon", 17], ["evening", 24]];
8
9
  const day = (d, add = 0) => new Date(d.getFullYear(), d.getMonth(), d.getDate() + add);
9
10
  const same = (a, b) => a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
@@ -45,7 +46,8 @@ export function AppointmentPicker({ value, defaultValue = null, onChange, start,
45
46
  const t = setInterval(() => setNow(new Date()), 60000);
46
47
  return () => clearInterval(t);
47
48
  }, []);
48
- const { messages: M, digits: D, locale, weekdays: WD, months: MONTHS } = useKashi();
49
+ const M = useMessages({ appointment: faAppointment, common: faCommon });
50
+ const { digits: D, locale, weekdays: WD, months: MONTHS } = useKashiLocale();
49
51
  const A = M.appointment;
50
52
  digits ?? (digits = D);
51
53
  label ?? (label = A.label);
package/dist/Avatar.js CHANGED
@@ -2,7 +2,8 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { Children, forwardRef, 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 { faAvatar, faCommon } from "@kashi-ui/persian";
6
7
  /** حروف اول دو کلمهٔ اول؛ با نیم‌فاصله تا حروف فارسی به هم نچسبند */
7
8
  export function initials(name, max = 2) {
8
9
  return name
@@ -25,12 +26,13 @@ export const Avatar = forwardRef(function Avatar({ name, src, size = "md", squar
25
26
  const [failed, setFailed] = useState(false);
26
27
  const showImage = src && !failed;
27
28
  const tone = color === "auto" ? autoTone(name) : color ?? (brand ? "brand" : "neutral");
28
- const { messages: M } = useKashi();
29
+ const M = useMessages({ avatar: faAvatar, common: faCommon });
29
30
  const statusText = status ? (statusLabels?.[status] ?? M.avatar[status]) : undefined;
30
31
  return (_jsxs("span", { ref: ref, role: "img", "aria-label": statusText ? `${name}${M.common.list}${statusText}` : name, "data-tone": tone, className: cx("k-avatar", size !== "md" && `k-avatar--${size}`, square && "k-avatar--square", tone !== "neutral" && `k-avatar--${tone}`, className), ...rest, children: [showImage ? (_jsx("img", { className: "k-avatar__image", src: src, alt: "", onError: () => setFailed(true) })) : (_jsx("span", { "aria-hidden": "true", children: initials(name, size === "xs" || size === "sm" ? 1 : 2) })), status && _jsx("span", { className: `k-avatar__status k-avatar__status--${status}`, "aria-hidden": "true" })] }));
31
32
  });
32
33
  export function AvatarGroup({ max, size = "md", moreLabel, className, children, ...rest }) {
33
- const { messages: M, n } = useKashi();
34
+ const M = useMessages({ avatar: faAvatar, common: faCommon });
35
+ const { n } = useKashiLocale();
34
36
  moreLabel ?? (moreLabel = (x) => M.avatar.more(n(x)));
35
37
  const items = Children.toArray(children);
36
38
  const visible = max ? items.slice(0, max) : items;
package/dist/Badge.js CHANGED
@@ -2,9 +2,10 @@
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 { useMessages } from "./KashiProvider.js";
6
+ import { faCommon } from "@kashi-ui/persian";
6
7
  export const Badge = forwardRef(function Badge({ tone = "neutral", variant = "soft", size = "md", dot = false, icon, square = false, onRemove, removeLabel, className, children, ...rest }, ref) {
7
- const { messages: M } = useKashi();
8
+ const M = useMessages({ common: faCommon });
8
9
  const label = removeLabel ?? (typeof children === "string" ? M.common.remove(children) : M.common.removeShort);
9
10
  return (_jsxs("span", { ref: ref, "data-tone": tone, "data-variant": variant, className: cx("k-badge", tone !== "neutral" && `k-badge--${tone}`, variant !== "soft" && `k-badge--${variant}`, size !== "md" && `k-badge--${size}`, square && "k-badge--square", onRemove && "k-badge--removable", className), ...rest, children: [dot && _jsx("span", { className: "k-badge__dot", "aria-hidden": "true" }), icon && _jsx("span", { className: "k-badge__icon", "aria-hidden": "true", children: icon }), children, onRemove && (_jsx("button", { type: "button", className: "k-badge__remove", "aria-label": label, onClick: onRemove, children: _jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", "aria-hidden": "true", children: _jsx("path", { d: "m6 6 8 8M14 6l-8 8" }) }) }))] }));
10
11
  });
package/dist/BankBadge.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useEffect, useState } from "react";
4
4
  import { bankName } from "@kashi-ui/persian";
5
- import { useKashi } from "./KashiProvider.js";
5
+ import { useKashiLocale } from "./KashiProvider.js";
6
6
  /** لوگوی بانک را فقط هنگام نیاز بارگذاری می‌کند (code-split)، تا حجم اولیهٔ برنامه زیاد نشود */
7
7
  export function useBankLogo(slug, enabled) {
8
8
  const [uri, setUri] = useState(null);
@@ -23,7 +23,7 @@ export function useBankLogo(slug, enabled) {
23
23
  }
24
24
  /** نام و لوگوی بانک داخل فیلد؛ نام با id به فیلد متصل می‌شود و لوگو تزئینی است */
25
25
  export function BankBadge({ bank, id, showLogo }) {
26
- const { locale } = useKashi();
26
+ const { locale } = useKashiLocale();
27
27
  const logo = useBankLogo(bank?.slug, showLogo);
28
28
  if (!bank)
29
29
  return null;
package/dist/BankCard.js CHANGED
@@ -4,7 +4,8 @@ import { forwardRef } from "react";
4
4
  import { formatCardNumber, getBankByCard, onlyDigits, toFaDigits, bankName } from "@kashi-ui/persian";
5
5
  import { useBankLogo } from "./BankBadge.js";
6
6
  import { cx } from "./cx.js";
7
- import { useKashi } from "./KashiProvider.js";
7
+ import { useKashiLocale, useMessages } from "./KashiProvider.js";
8
+ import { faBankCard, faCommon } from "@kashi-ui/persian";
8
9
  // رنگ تقریبی هویت بصری بانک‌ها؛ برای بقیه رنگ برند کاشی
9
10
  const COLORS = {
10
11
  mellat: "#b5172b", melli: "#0b3f7d", saderat: "#203b8c", tejarat: "#173c7a", sepah: "#0d56a0", pasargad: "#2a2418",
@@ -15,7 +16,8 @@ const COLORS = {
15
16
  const Chip = () => (_jsxs("svg", { className: "k-bankcard__chip", viewBox: "0 0 40 30", "aria-hidden": "true", children: [_jsx("rect", { x: "0.5", y: "0.5", width: "39", height: "29", rx: "5" }), _jsx("path", { d: "M14 1v28M26 1v28M1 10h13M26 10h13M1 20h13M26 20h13" })] }));
16
17
  /** نمایش کارت بانکی با رنگ و لوگوی بانک، شمارهٔ چهاررقمی و تاریخ انقضا؛ برای کیف پول و انتخاب کارت ذخیره‌شده */
17
18
  export const BankCard = forwardRef(function BankCard({ number, holder, expiry, masked, bank, digits, showLogo = true, className, style, ...rest }, ref) {
18
- const { messages: M, digits: D, locale } = useKashi();
19
+ const M = useMessages({ bankCard: faBankCard, common: faCommon });
20
+ const { digits: D, locale } = useKashiLocale();
19
21
  digits ?? (digits = D);
20
22
  const raw = onlyDigits(number).slice(0, 16);
21
23
  const detected = bank === undefined ? getBankByCard(raw) : bank;
package/dist/Banner.js CHANGED
@@ -2,10 +2,11 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { cx } from "./cx.js";
4
4
  import { CloseIcon } from "./icons.js";
5
- import { useKashi } from "./KashiProvider.js";
5
+ import { useMessages } from "./KashiProvider.js";
6
+ import { faBanner } from "@kashi-ui/persian";
6
7
  /** نوار اطلاع‌رسانی سطح صفحه، مثل نسخهٔ جدید، پایان اشتراک یا اختلال سرویس */
7
8
  export function Banner({ tone = "neutral", icon, actions, onClose, flush, label, closeLabel, className, children, ...rest }) {
8
- const { messages: M } = useKashi();
9
+ const M = useMessages({ banner: faBanner });
9
10
  label ?? (label = M.banner.label);
10
11
  closeLabel ?? (closeLabel = M.banner.close);
11
12
  return (_jsxs("div", { role: "region", "aria-label": label, className: cx("k-banner", tone !== "neutral" && `k-banner--${tone}`, flush && "k-banner--flush", className), ...rest, children: [icon && _jsx("span", { className: "k-banner__icon", "aria-hidden": "true", children: icon }), _jsx("p", { className: "k-banner__text", children: children }), actions && _jsx("div", { className: "k-banner__actions", children: actions }), onClose && (_jsx("button", { type: "button", className: "k-btn k-btn--tertiary k-btn--icon k-btn--sm k-banner__close", "aria-label": closeLabel, onClick: onClose, children: _jsx(CloseIcon, {}) }))] }));
@@ -0,0 +1,39 @@
1
+ import { type ReactNode } from "react";
2
+ import { type BillInfo, type BillService } from "@kashi-ui/persian";
3
+ import { type InputProps } from "./Input.js";
4
+ type Base = Omit<InputProps, "value" | "defaultValue" | "onChange" | "type" | "inputMode">;
5
+ export interface BillIdInputProps extends Base {
6
+ /** ارقام لاتین، مثل "7748317800142" */
7
+ value?: string;
8
+ defaultValue?: string;
9
+ onValueChange?: (value: string, valid: boolean, service: BillService | null) => void;
10
+ /** نوع قبض (آب، برق، گاز…) کنار فیلد @default true */
11
+ showService?: boolean;
12
+ /** @default "fa" */
13
+ digits?: "fa" | "latin";
14
+ invalidMessage?: ReactNode;
15
+ }
16
+ /**
17
+ * شناسهٔ قبض (۶ تا ۱۳ رقم): رقم کنترل استاندارد بانک مرکزی بررسی می‌شود و نوع قبض
18
+ * (آب، برق، گاز، تلفن، شهرداری، مالیات، جریمه) از رقم یکی‌مانده‌به‌آخر کنار فیلد می‌آید.
19
+ */
20
+ export declare const BillIdInput: import("react").ForwardRefExoticComponent<BillIdInputProps & import("react").RefAttributes<HTMLInputElement>>;
21
+ export interface PaymentIdInputProps extends Base {
22
+ /** شناسهٔ قبضی که این شناسهٔ پرداخت مال آن است؛ رقم کنترل دوم به آن بسته است */
23
+ billId: string;
24
+ value?: string;
25
+ defaultValue?: string;
26
+ onValueChange?: (value: string, valid: boolean, info: BillInfo | null) => void;
27
+ /** مبلغ قبض کنار فیلد @default true */
28
+ showAmount?: boolean;
29
+ /** واحد نمایش مبلغ @default "toman" */
30
+ unit?: "rial" | "toman";
31
+ /** @default "fa" */
32
+ digits?: "fa" | "latin";
33
+ invalidMessage?: ReactNode;
34
+ }
35
+ /**
36
+ * شناسهٔ پرداخت قبض: هر دو رقم کنترل بررسی می‌شوند (دومی همراه شناسهٔ قبض) و مبلغ قبض کنار فیلد می‌آید.
37
+ */
38
+ export declare const PaymentIdInput: import("react").ForwardRefExoticComponent<PaymentIdInputProps & import("react").RefAttributes<HTMLInputElement>>;
39
+ export {};
@@ -0,0 +1,57 @@
1
+ "use client";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { forwardRef, useId, useState } from "react";
4
+ import { billService, formatMoney, isValidBillId, parseBill } from "@kashi-ui/persian";
5
+ import { Input } from "./Input.js";
6
+ import { useDigitsInput } from "./useDigitsInput.js";
7
+ import { mergeRefs } from "./utils.js";
8
+ import { useKashiLocale, useMessages } from "./KashiProvider.js";
9
+ import { faBill, faInvalid } from "@kashi-ui/persian";
10
+ /**
11
+ * شناسهٔ قبض (۶ تا ۱۳ رقم): رقم کنترل استاندارد بانک مرکزی بررسی می‌شود و نوع قبض
12
+ * (آب، برق، گاز، تلفن، شهرداری، مالیات، جریمه) از رقم یکی‌مانده‌به‌آخر کنار فیلد می‌آید.
13
+ */
14
+ export const BillIdInput = forwardRef(function BillIdInput({ value, defaultValue, onValueChange, showService = true, digits, invalidMessage, error, name, onBlur, placeholder, ...rest }, ref) {
15
+ const M = useMessages({ bill: faBill, invalid: faInvalid });
16
+ const { digits: D } = useKashiLocale();
17
+ digits ?? (digits = D);
18
+ invalidMessage ?? (invalidMessage = M.invalid.billId);
19
+ const { raw, shown, inputRef, handleChange } = useDigitsInput({ value, defaultValue, maxDigits: 13, format: (d) => d, digits });
20
+ const [touched, setTouched] = useState(false);
21
+ const valid = isValidBillId(raw);
22
+ const service = valid ? billService(raw) : null;
23
+ const metaId = useId();
24
+ const showInvalid = raw.length > 0 && (touched || raw.length === 13) && !valid;
25
+ return (_jsxs(_Fragment, { children: [_jsx(Input, { ref: mergeRefs(ref, inputRef), type: "text", inputMode: "numeric", autoComplete: "off", dir: "ltr", placeholder: placeholder ?? (digits === "fa" ? "۰۰۰۰۰۰۰۰۰۰۰۰۰" : "0000000000000"), value: shown, onChange: (e) => {
26
+ const next = handleChange(e);
27
+ const ok = isValidBillId(next);
28
+ onValueChange?.(next, ok, ok ? billService(next) : null);
29
+ }, onBlur: (e) => {
30
+ setTouched(true);
31
+ onBlur?.(e);
32
+ }, addonEnd: showService && service ? _jsx("span", { className: "k-input__meta k-bill__service", "data-service": service, id: metaId, children: M.bill.service[service] }) : undefined, "aria-describedby": showService && service ? metaId : undefined, error: error ?? (showInvalid ? invalidMessage : undefined), ...rest }), name && _jsx("input", { type: "hidden", name: name, value: raw })] }));
33
+ });
34
+ /**
35
+ * شناسهٔ پرداخت قبض: هر دو رقم کنترل بررسی می‌شوند (دومی همراه شناسهٔ قبض) و مبلغ قبض کنار فیلد می‌آید.
36
+ */
37
+ export const PaymentIdInput = forwardRef(function PaymentIdInput({ billId, value, defaultValue, onValueChange, showAmount = true, unit = "toman", digits, invalidMessage, error, hint, name, onBlur, placeholder, ...rest }, ref) {
38
+ const M = useMessages({ bill: faBill, invalid: faInvalid });
39
+ const { digits: D, locale } = useKashiLocale();
40
+ digits ?? (digits = D);
41
+ invalidMessage ?? (invalidMessage = M.invalid.paymentId);
42
+ const { raw, shown, inputRef, handleChange } = useDigitsInput({ value, defaultValue, maxDigits: 13, format: (d) => d, digits });
43
+ const [touched, setTouched] = useState(false);
44
+ const billOk = isValidBillId(billId);
45
+ const info = parseBill(billId, raw);
46
+ const metaId = useId();
47
+ const showInvalid = billOk && raw.length > 0 && (touched || raw.length === 13) && !info;
48
+ const amount = info ? formatMoney(info.amount, { from: "rial", unit, locale, digits }) : "";
49
+ return (_jsxs(_Fragment, { children: [_jsx(Input, { ref: mergeRefs(ref, inputRef), type: "text", inputMode: "numeric", autoComplete: "off", dir: "ltr", placeholder: placeholder ?? (digits === "fa" ? "۰۰۰۰۰۰۰۰" : "00000000"), value: shown, onChange: (e) => {
50
+ const next = handleChange(e);
51
+ const parsed = parseBill(billId, next);
52
+ onValueChange?.(next, !!parsed, parsed);
53
+ }, onBlur: (e) => {
54
+ setTouched(true);
55
+ onBlur?.(e);
56
+ }, addonEnd: showAmount && info ? _jsx("span", { className: "k-input__meta k-bill__amount", id: metaId, children: amount }) : undefined, "aria-describedby": showAmount && info ? metaId : undefined, hint: hint ?? (!billOk ? M.bill.needBill : undefined), error: error ?? (showInvalid ? invalidMessage : undefined), ...rest }), name && _jsx("input", { type: "hidden", name: name, value: raw })] }));
57
+ });
@@ -3,7 +3,8 @@ 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
5
  import { CloseIcon } from "./icons.js";
6
- import { useKashi } from "./KashiProvider.js";
6
+ import { useMessages } from "./KashiProvider.js";
7
+ import { faCommon, faSheet } from "@kashi-ui/persian";
7
8
  import { useModalDialog } from "./modal.js";
8
9
  /** فاصله‌ای که بعد از آن، کشیدن به پایین برگه را می‌بندد (نسبت به ارتفاع برگه) */
9
10
  const CLOSE_RATIO = 0.3;
@@ -15,7 +16,7 @@ const FLING = 0.6;
15
16
  * دستگیره با کیبورد هم کار می‌کند: Enter ایست بعدی، جهت‌های بالا و پایین تغییر ارتفاع.
16
17
  */
17
18
  export function BottomSheet({ open, onOpenChange, title, description, hideTitle, snapPoints, defaultSnap = 0, snap, onSnapChange, footer, dismissible = true, showClose = false, closeLabel, className, children, }) {
18
- const { messages: M } = useKashi();
19
+ const M = useMessages({ common: faCommon, sheet: faSheet });
19
20
  closeLabel ?? (closeLabel = M.common.close);
20
21
  const ref = useRef(null);
21
22
  const id = useId();
@@ -2,10 +2,11 @@
2
2
  import { jsx as _jsx, Fragment as _Fragment, 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 { faBreadcrumb } from "@kashi-ui/persian";
6
7
  /** مسیر صفحه؛ آخرین مورد با aria-current="page" مشخص می‌شود و مسیرهای بلند جمع می‌شوند */
7
8
  export function Breadcrumb({ items, maxItems, separator = "chevron", label, expandLabel, className }) {
8
- const { messages: M } = useKashi();
9
+ const M = useMessages({ breadcrumb: faBreadcrumb });
9
10
  label ?? (label = M.breadcrumb.label);
10
11
  expandLabel ?? (expandLabel = M.breadcrumb.expand);
11
12
  const [expanded, setExpanded] = useState(false);
@@ -3,11 +3,13 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
3
3
  import { useId, useState } from "react";
4
4
  import { defaultWeekHours, invalidRanges, isOpenAt, summarizeHours } 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 { faBusinessHours, faCommon } from "@kashi-ui/persian";
7
8
  import { TimeInput } from "./TimeInput.js";
8
9
  /** انتخاب روزهای هفتهٔ شمسی از شنبه تا جمعه؛ هر روز یک دکمهٔ روشن و خاموش */
9
10
  export function WeekdayPicker({ value, defaultValue = [], onChange, format = "short", "aria-label": ariaLabel, disabled, className }) {
10
- const { messages: M, weekdays, weekdaysShort } = useKashi();
11
+ const M = useMessages({ businessHours: faBusinessHours, common: faCommon });
12
+ const { weekdays, weekdaysShort } = useKashiLocale();
11
13
  const [inner, setInner] = useState(defaultValue);
12
14
  const days = value ?? inner;
13
15
  const toggle = (d) => {
@@ -20,7 +22,8 @@ export function WeekdayPicker({ value, defaultValue = [], onChange, format = "sh
20
22
  }
21
23
  /** ساعت کاری هفتگی: هر روز باز یا تعطیل، با یک یا چند بازهٔ ساعت؛ برای فروشگاه، مطب و نوبت‌دهی */
22
24
  export function BusinessHours({ value, defaultValue, onChange, label, step = 30, maxRanges = 3, summary = true, now, name, digits, disabled, className, }) {
23
- const { messages: M, weekdays, locale, digits: D } = useKashi();
25
+ const M = useMessages({ businessHours: faBusinessHours, common: faCommon });
26
+ const { weekdays, locale, digits: D } = useKashiLocale();
24
27
  digits ?? (digits = D);
25
28
  const B = M.businessHours;
26
29
  const [inner, setInner] = useState(() => defaultValue ?? defaultWeekHours());
package/dist/Button.js CHANGED
@@ -3,9 +3,10 @@ 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
5
  import { isDev } from "./utils.js";
6
- import { useKashi } from "./KashiProvider.js";
6
+ import { useMessages } from "./KashiProvider.js";
7
+ import { faCommon } from "@kashi-ui/persian";
7
8
  export const Button = forwardRef(function Button({ variant = "secondary", size = "md", shape = "default", loading = false, loadingLabel, block = false, iconOnly = false, iconStart, iconEnd, disabled, type = "button", href, as, className, children, onClick, ...rest }, ref) {
8
- const { messages: M } = useKashi();
9
+ const M = useMessages({ common: faCommon });
9
10
  loadingLabel ?? (loadingLabel = M.common.loading);
10
11
  if (isDev() && iconOnly && !rest["aria-label"] && !rest["aria-labelledby"]) {
11
12
  console.warn("[kashi] <Button iconOnly> بدون aria-label برای صفحه‌خوان‌ها بی‌نام است.");
package/dist/Calendar.js CHANGED
@@ -3,7 +3,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useEffect, useId, useRef, useState } from "react";
4
4
  import { formatJalali, getIranHoliday, jalaliMonthLength, jalaliWeekday, toFaDigits, toGregorian, 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 { faCalendar, faCommon } from "@kashi-ui/persian";
7
8
  export const sameDay = (a, b) => !!a && !!b && a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
8
9
  const startOfDay = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate());
9
10
  const addDays = (d, n) => new Date(d.getFullYear(), d.getMonth(), d.getDate() + n);
@@ -25,7 +26,8 @@ function clamp(d, min, max) {
25
26
  }
26
27
  /** تقویم شمسی با الگوی grid استاندارد WAI-ARIA و پیمایش کامل با کیبورد */
27
28
  export function Calendar({ value, defaultValue = null, onChange, min, max, isDateDisabled, holidays, digits, autoFocus = false, yearRange, labels = {}, footer, range, className, "aria-label": ariaLabel, }) {
28
- const { messages: M, digits: D, locale, months: MONTHS, weekdays: WD, weekdaysShort: WDS, friday: FRI } = useKashi();
29
+ const M = useMessages({ calendar: faCalendar, common: faCommon });
30
+ const { digits: D, locale, months: MONTHS, weekdays: WD, weekdaysShort: WDS, friday: FRI } = useKashiLocale();
29
31
  digits ?? (digits = D);
30
32
  ariaLabel ?? (ariaLabel = M.calendar.label);
31
33
  const id = useId();
@@ -6,10 +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 { useKashiLocale, useMessages } from "./KashiProvider.js";
10
+ import { faInvalid } from "@kashi-ui/persian";
10
11
  /** فیلد شماره کارت بانکی: گروه‌بندی چهارتایی، تشخیص بانک با لوگو و بررسی Luhn */
11
12
  export const CardNumberInput = forwardRef(function CardNumberInput({ value, defaultValue, onValueChange, digits, showBank = true, showBankLogo = true, invalidMessage, error, name, id, onBlur, placeholder, ...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.card);
15
17
  const autoId = useId();
package/dist/Carousel.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 { Children, 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 { faCarousel, faCommon } from "@kashi-ui/persian";
6
7
  const Arrow = ({ next }) => (_jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", "data-k-mirror": "", children: _jsx("path", { d: next ? "m8 5 5 5-5 5" : "m12 5-5 5 5 5" }) }));
7
8
  const PlayIcon = ({ playing }) => (_jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: playing ? _jsx("path", { d: "M7.5 5v10M12.5 5v10" }) : _jsx("path", { d: "M7 4.8v10.4a.6.6 0 0 0 .9.5l8-5.2a.6.6 0 0 0 0-1L7.9 4.3a.6.6 0 0 0-.9.5Z" }) }));
8
9
  const ExpandIcon = () => (_jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "M12 3.5h4.5V8M8 16.5H3.5V12M16.5 3.5 11.5 8.5M3.5 16.5l5-5" }) }));
@@ -43,7 +44,8 @@ function useSwipe(onStep) {
43
44
  */
44
45
  export function Carousel({ children, label, perView: perViewProp = 1, dots = true, effect = "slide", autoplay, thumbnails, lightbox, onIndexChange, className, labels = {}, }) {
45
46
  const id = useId();
46
- const { messages: M, n: N } = useKashi();
47
+ const M = useMessages({ carousel: faCarousel, common: faCommon });
48
+ const { n: N } = useKashiLocale();
47
49
  const { prev = M.common.prev, next = M.common.next, slide = (a, t) => M.carousel.slideOf(N(a), N(t)), play = M.carousel.play, pause = M.carousel.pause, expand = M.carousel.expand, } = labels;
48
50
  const fade = effect === "fade";
49
51
  const perView = fade ? 1 : perViewProp;
package/dist/Chart.js CHANGED
@@ -3,10 +3,12 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useId, useLayoutEffect, useRef, 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 { faChart, faCommon } from "@kashi-ui/persian";
7
8
  /** متن‌ها و قالب عددهای نمودار به زبان و ارقام KashiProvider */
8
9
  function useChartText() {
9
- const { messages: M, digits } = useKashi();
10
+ const M = useMessages({ chart: faChart, common: faCommon });
11
+ const { digits } = useKashiLocale();
10
12
  const num = (n) => formatNumber(n, { digits });
11
13
  const dec = (x) => num(Math.round(x * 10) / 10).replace(".", M.common.decimal);
12
14
  return {
@@ -53,12 +55,12 @@ const tipAt = (el, box, i, anchor) => {
53
55
  };
54
56
  /** جدول هم‌ارز برای صفحه‌خوان و چاپ */
55
57
  function DataTable({ caption, labels, series, format }) {
56
- const { messages: M } = useKashi();
58
+ const M = useMessages({ chart: faChart, common: faCommon });
57
59
  return (_jsxs("table", { className: "k-sr-only", children: [_jsx("caption", { children: caption }), _jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { scope: "col", children: M.chart.period }), series.map((s) => _jsx("th", { scope: "col", children: s.name }, s.name))] }) }), _jsx("tbody", { children: labels.map((l, i) => _jsxs("tr", { children: [_jsx("th", { scope: "row", children: l }), series.map((s) => _jsx("td", { children: format(s.values[i]) }, s.name))] }, l)) })] }));
58
60
  }
59
61
  /** قاب نمودار در حالت بارگذاری یا بی‌داده: عنوان می‌ماند، جای نمودار اسکلت یا پیام */
60
62
  function ChartPlaceholder({ title, loading, emptyMessage, className }) {
61
- const { messages: M } = useKashi();
63
+ const M = useMessages({ chart: faChart, common: faCommon });
62
64
  return (_jsxs("figure", { className: cx("k-chart", className), style: { margin: 0 }, "aria-busy": loading || undefined, children: [title && _jsx("figcaption", { className: "k-chart__head", children: _jsx("p", { className: "k-chart__title", children: title }) }), loading
63
65
  ? _jsx("div", { className: "k-chart__skeleton", role: "status", children: _jsx("span", { className: "k-sr-only", children: M.common.loading }) })
64
66
  : _jsx("div", { className: "k-chart__empty", role: "status", children: emptyMessage ?? M.common.noData })] }));
package/dist/Chat.js CHANGED
@@ -3,7 +3,8 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
3
3
  import { useEffect, useRef, useState } from "react";
4
4
  import { formatRelative } from "@kashi-ui/persian";
5
5
  import { cx } from "./cx.js";
6
- import { useKashi } from "./KashiProvider.js";
6
+ import { useKashiLocale, useMessages } from "./KashiProvider.js";
7
+ import { faChat } from "@kashi-ui/persian";
7
8
  /* ---------- آیکون‌ها ---------- */
8
9
  const svg = (d, w = 1.7) => (_jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: w, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: d }));
9
10
  const Tick = () => svg(_jsx("path", { d: "m4.5 10.5 3 3 6-7" }), 1.9);
@@ -21,7 +22,7 @@ const Arrow = () => svg(_jsx("path", { d: "M10 4v12m0 0-4.5-4.5M10 16l4.5-4.5" }
21
22
  * (مگر کاربر بالا رفته باشد) و دکمهٔ «رفتن به آخرین پیام» نشان می‌دهد.
22
23
  */
23
24
  export function ChatThread({ label, autoScroll = true, className, children, ...rest }) {
24
- const { messages: M } = useKashi();
25
+ const M = useMessages({ chat: faChat });
25
26
  const ref = useRef(null);
26
27
  const stick = useRef(true);
27
28
  const [away, setAway] = useState(false);
@@ -60,7 +61,8 @@ export function ChatDivider({ children, className }) {
60
61
  }
61
62
  /** حباب پیام در گفتگو یا رابط هوش مصنوعی؛ جهت متن هر پیام خودکار است تا پیام انگلیسی هم درست چیده شود */
62
63
  export function ChatMessage({ from = "assistant", name, avatar, time, status, edited, copyText, onRetry, onFeedback, feedback, actions, className, children, ...rest }) {
63
- const { messages: M, locale, digits } = useKashi();
64
+ const M = useMessages({ chat: faChat });
65
+ const { locale, digits } = useKashiLocale();
64
66
  const C = M.chat;
65
67
  const [copied, setCopied] = useState(false);
66
68
  const timer = useRef(undefined);
@@ -85,7 +87,7 @@ export function ChatMessage({ from = "assistant", name, avatar, time, status, ed
85
87
  }
86
88
  /** نشانگر «در حال نوشتن…» با سه نقطهٔ موجی؛ صفحه‌خوان یک بار می‌خواندش */
87
89
  export function TypingIndicator({ name, showLabel, className }) {
88
- const { messages: M } = useKashi();
90
+ const M = useMessages({ chat: faChat });
89
91
  const text = name ? M.chat.typing(name) : M.chat.typingShort;
90
92
  return (_jsxs("div", { className: cx("k-typing", className), role: "status", children: [_jsxs("span", { className: "k-typing__dots", "aria-hidden": "true", children: [_jsx("i", {}), _jsx("i", {}), _jsx("i", {})] }), showLabel ? _jsxs("span", { className: "k-typing__label", children: [text, "\u2026"] }) : _jsx("span", { className: "k-sr-only", children: text })] }));
91
93
  }
@@ -3,7 +3,8 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
3
3
  import { useEffect, useId, useRef, useState } from "react";
4
4
  import { cx } from "./cx.js";
5
5
  import { formatBytes } from "./FileUpload.js";
6
- import { useKashi } from "./KashiProvider.js";
6
+ import { useKashiLocale, useMessages } from "./KashiProvider.js";
7
+ import { faComposer } from "@kashi-ui/persian";
7
8
  import { useIsomorphicLayoutEffect } from "./utils.js";
8
9
  const svg = (d) => (_jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: d }));
9
10
  const Clip = () => svg(_jsx("path", { d: "m15.5 9.5-5.6 5.6a3.5 3.5 0 0 1-5-5l6-6a2.3 2.3 0 0 1 3.3 3.3l-6 6a1.2 1.2 0 0 1-1.7-1.7l5.5-5.5" }));
@@ -16,7 +17,8 @@ const Doc = () => svg(_jsxs(_Fragment, { children: [_jsx("path", { d: "M11.5 3H6
16
17
  * (هنگام تایپ با IME ارسال نمی‌کند)، پیوست با دکمه یا چسباندن تصویر، و دکمهٔ توقف هنگام پاسخ.
17
18
  */
18
19
  export function ChatComposer({ onSend, streaming, onStop, value, onValueChange, attach, maxFiles = 5, maxSize, maxLength, maxRows = 8, placeholder, label, showHint, tools, disabled, autoFocus, className, }) {
19
- const { messages: M, locale, n } = useKashi();
20
+ const M = useMessages({ composer: faComposer });
21
+ const { locale, n } = useKashiLocale();
20
22
  const C = M.composer;
21
23
  const [inner, setInner] = useState("");
22
24
  const text = value ?? inner;
@@ -3,14 +3,15 @@ import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { forwardRef, useMemo, useState } from "react";
4
4
  import { CITIES, getCities } from "@kashi-ui/persian";
5
5
  import { Combobox, searchText } from "./Combobox.js";
6
- import { useKashi } from "./KashiProvider.js";
6
+ import { useMessages } from "./KashiProvider.js";
7
+ import { faCity } from "@kashi-ui/persian";
7
8
  const SEP = "|";
8
9
  // «علی آباد»، «علی‌آباد» و «علیآباد» یکی‌اند
9
10
  const loose = (s) => searchText(s).replace(/[\s‌]/g, "");
10
11
  const filter = (o, q) => o.value.startsWith(`custom${SEP}`) || [o.label, o.description ?? ""].some((t) => loose(t).includes(loose(q)));
11
12
  /** انتخاب شهر با جستجو؛ با استان فقط شهرهای همان استان، بدون آن همهٔ ۱۲۰۰+ شهر ایران با نام استان */
12
13
  export const CitySelect = forwardRef(function CitySelect({ province, value, defaultValue = null, onChange, allowCustom = true, label, placeholder, onInputChange, ...rest }, ref) {
13
- const { messages: M } = useKashi();
14
+ const M = useMessages({ city: faCity });
14
15
  label ?? (label = M.city.label);
15
16
  const [query, setQuery] = useState("");
16
17
  const [inner, setInner] = useState(defaultValue);
package/dist/CodeBlock.js CHANGED
@@ -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 { useKashiLocale, useMessages } from "./KashiProvider.js";
6
+ import { faCodeBlock } from "@kashi-ui/persian";
6
7
  const KEYWORDS = new Set(("import export from default const let var function return if else for while do switch case break continue new class extends " +
7
8
  "async await try catch finally throw typeof instanceof in of interface type enum implements public private protected static readonly " +
8
9
  "def lambda pass elif with as yield None True False self print fn pub use mod impl struct match mut package func go defer select " +
@@ -34,7 +35,8 @@ const Check = () => _jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "c
34
35
  const Wrap = () => (_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: "M3 5h14M3 10h11a3 3 0 0 1 0 6h-3m0 0 2-2m-2 2 2 2M3 15h4" }) }));
35
36
  /** نمایش کد در پاسخ دستیار یا مستندات: همیشه چپ‌به‌راست، با برچسب زبان، دکمهٔ کپی و شکستن خط */
36
37
  export function CodeBlock({ code, language, filename, lineNumbers, highlightLines = [], wrap: wrapDefault = false, highlight = true, maxHeight, className }) {
37
- const { messages: M, n } = useKashi();
38
+ const M = useMessages({ codeBlock: faCodeBlock });
39
+ const { n } = useKashiLocale();
38
40
  const B = M.codeBlock;
39
41
  const [copied, setCopied] = useState(false);
40
42
  const [wrap, setWrap] = useState(wrapDefault);
@@ -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 { Field } from "./Field.js";
5
- import { useKashi } from "./KashiProvider.js";
5
+ import { useKashiLocale, useMessages } from "./KashiProvider.js";
6
+ import { faColorPicker, faCommon } from "@kashi-ui/persian";
6
7
  // نام رنگ‌ها از فرهنگ متن‌ها می‌آید تا با زبان KashiProvider عوض شود
7
8
  const DEFAULT_SWATCHES = [
8
9
  { key: "firoozeh", value: "#0b8077" },
@@ -52,7 +53,8 @@ function hsvToHex({ h, s, v }) {
52
53
  const Dropper = () => _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: "m11 5 4 4M13.5 2.5a2.1 2.1 0 0 1 3 3L15 7 13 5ZM12 6l-7.5 7.5L3 17l3.5-1.5L14 8" }) });
53
54
  /** پنل انتخاب رنگ: سطح اشباع و روشنایی، نوار رنگ‌مایه، قطره‌چکان و کدها */
54
55
  function ColorPanel({ hex, onChange, onClose }) {
55
- const { messages: M, n: N } = useKashi();
56
+ const M = useMessages({ colorPicker: faColorPicker, common: faCommon });
57
+ const { n: N } = useKashiLocale();
56
58
  const C = M.colorPicker;
57
59
  const [hsv, setHsv] = useState(() => hexToHsv(hex));
58
60
  const area = useRef(null);
@@ -118,7 +120,8 @@ function ColorPanel({ hex, onChange, onClose }) {
118
120
  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" }) });
119
121
  /** انتخاب رنگ برند یا برچسب: نمونه‌رنگ‌ها، پنل انتخاب دلخواه و کد hex، با کنتراست متن روی آن */
120
122
  export function ColorPicker({ label, hint, value, defaultValue = "#0b8077", onChange, swatches: swatchesProp, showContrast = true, name, id, className }) {
121
- const { messages: M, n: N } = useKashi();
123
+ const M = useMessages({ colorPicker: faColorPicker, common: faCommon });
124
+ const { n: N } = useKashiLocale();
122
125
  const swatches = swatchesProp ?? DEFAULT_SWATCHES.map((s) => ({ name: M.colorPicker.names[s.key], value: s.value }));
123
126
  const autoId = useId();
124
127
  const fieldId = id ?? autoId;
@@ -12,6 +12,10 @@ export interface ComboboxOption {
12
12
  }
13
13
  /** متن یکدست برای جستجو: ي/ی، ك/ک، ارقام، حروف کوچک */
14
14
  export declare const searchText: (s: string) => string;
15
+ /**
16
+ * فیلتر پیش‌فرض با جستجوی فارسی کاشی (persianMatch): ي/ی و ك/ک یکی‌اند، نیم‌فاصله نادیده گرفته می‌شود،
17
+ * «mamad» «ممد» را پیدا می‌کند و متنی که با چیدمان انگلیسی صفحه‌کلید تایپ شده («hdvhk») هم «ایران» را.
18
+ */
15
19
  export declare function defaultFilter(option: ComboboxOption, query: string): boolean;
16
20
  /** بخش منطبق با جستجو را با <mark> برجسته می‌کند */
17
21
  export declare function highlight(text: string, query: string): ReactNode;