@kashi-ui/react 2.15.1 → 2.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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
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
24
24
 
25
25
  فارسی: DatePicker و Calendar شمسی · DateRangePicker · TimeInput · PostalCodeInput · PlateInput · LandlineInput · MonthPicker · Countdown · ActivityHeatmap · ProvinceSelect · NationalIdInput · CardNumberInput · IbanInput · MobileInput · PriceInput · OtpInput
26
26
 
@@ -0,0 +1,39 @@
1
+ import { type WeekHours } from "@kashi-ui/persian";
2
+ export interface WeekdayPickerProps {
3
+ /** روزهای انتخاب‌شده؛ ۰ شنبه … ۶ جمعه */
4
+ value?: number[];
5
+ defaultValue?: number[];
6
+ onChange?: (days: number[]) => void;
7
+ /** نام کوتاه («ش») یا کامل («شنبه») @default "short" */
8
+ format?: "short" | "long";
9
+ /** @default "روزهای کاری" */
10
+ "aria-label"?: string;
11
+ disabled?: boolean;
12
+ className?: string;
13
+ }
14
+ /** انتخاب روزهای هفتهٔ شمسی از شنبه تا جمعه؛ هر روز یک دکمهٔ روشن و خاموش */
15
+ export declare function WeekdayPicker({ value, defaultValue, onChange, format, "aria-label": ariaLabel, disabled, className }: WeekdayPickerProps): import("react").JSX.Element;
16
+ export interface BusinessHoursProps {
17
+ value?: WeekHours;
18
+ /** @default شنبه تا چهارشنبه ۹ تا ۱۷، پنجشنبه ۹ تا ۱۳، جمعه تعطیل */
19
+ defaultValue?: WeekHours;
20
+ onChange?: (week: WeekHours, valid: boolean) => void;
21
+ /** @default "ساعت کاری" */
22
+ label?: string;
23
+ /** گام ساعت‌ها با کلیدهای ↑↓ به دقیقه @default 30 */
24
+ step?: number;
25
+ /** حداکثر بازه در هر روز (مثلاً صبح و عصر) @default 3 */
26
+ maxRanges?: number;
27
+ /** خلاصهٔ خوانا و وضعیت «الان باز است» زیر فرم @default true */
28
+ summary?: boolean;
29
+ /** لحظهٔ مقایسه برای «الان باز است» @default اکنون */
30
+ now?: Date;
31
+ /** با name مقدار به شکل JSON در فرم ارسال می‌شود */
32
+ name?: string;
33
+ /** @default "fa" */
34
+ digits?: "fa" | "latin";
35
+ disabled?: boolean;
36
+ className?: string;
37
+ }
38
+ /** ساعت کاری هفتگی: هر روز باز یا تعطیل، با یک یا چند بازهٔ ساعت؛ برای فروشگاه، مطب و نوبت‌دهی */
39
+ export declare function BusinessHours({ value, defaultValue, onChange, label, step, maxRanges, summary, now, name, digits, disabled, className, }: BusinessHoursProps): import("react").JSX.Element;
@@ -0,0 +1,51 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { useId, useState } from "react";
4
+ import { defaultWeekHours, invalidRanges, isOpenAt, summarizeHours } from "@kashi-ui/persian";
5
+ import { cx } from "./cx.js";
6
+ import { useKashi } from "./KashiProvider.js";
7
+ import { TimeInput } from "./TimeInput.js";
8
+ /** انتخاب روزهای هفتهٔ شمسی از شنبه تا جمعه؛ هر روز یک دکمهٔ روشن و خاموش */
9
+ export function WeekdayPicker({ value, defaultValue = [], onChange, format = "short", "aria-label": ariaLabel, disabled, className }) {
10
+ const { messages: M, weekdays, weekdaysShort } = useKashi();
11
+ const [inner, setInner] = useState(defaultValue);
12
+ const days = value ?? inner;
13
+ const toggle = (d) => {
14
+ const next = days.includes(d) ? days.filter((x) => x !== d) : [...days, d].sort();
15
+ if (value === undefined)
16
+ setInner(next);
17
+ onChange?.(next);
18
+ };
19
+ return (_jsx("div", { className: cx("k-weekdays", format === "long" && "k-weekdays--long", className), role: "group", "aria-label": ariaLabel ?? M.businessHours.weekdays, children: weekdays.map((name, i) => (_jsx("button", { type: "button", className: "k-weekdays__day", "aria-pressed": days.includes(i), "aria-label": format === "short" ? name : undefined, disabled: disabled, "data-friday": i === 6 ? "" : undefined, onClick: () => toggle(i), children: format === "short" ? weekdaysShort[i] : name }, i))) }));
20
+ }
21
+ /** ساعت کاری هفتگی: هر روز باز یا تعطیل، با یک یا چند بازهٔ ساعت؛ برای فروشگاه، مطب و نوبت‌دهی */
22
+ 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();
24
+ digits ?? (digits = D);
25
+ const B = M.businessHours;
26
+ const [inner, setInner] = useState(() => defaultValue ?? defaultWeekHours());
27
+ const week = value ?? inner;
28
+ const legendId = useId();
29
+ const valid = week.every((d) => invalidRanges(d).length === 0);
30
+ const commit = (next) => {
31
+ if (value === undefined)
32
+ setInner(next);
33
+ onChange?.(next, next.every((d) => invalidRanges(d).length === 0));
34
+ };
35
+ const setDay = (i, day) => commit(week.map((d, j) => (j === i ? day : d)));
36
+ const firstOpen = week.findIndex((d) => d.open && d.ranges.length);
37
+ const open = isOpenAt(week, now ?? new Date());
38
+ return (_jsxs("fieldset", { className: cx("k-hours", className), disabled: disabled, "aria-labelledby": legendId, children: [_jsx("legend", { id: legendId, className: "k-hours__legend", children: label ?? B.label }), _jsx("div", { className: "k-hours__days", children: week.map((day, i) => {
39
+ const bad = invalidRanges(day);
40
+ const errId = `${legendId}-e${i}`;
41
+ return (_jsxs("div", { className: "k-hours__day", "data-open": day.open ? "" : undefined, "data-invalid": bad.length ? "" : undefined, children: [_jsxs("label", { className: "k-hours__toggle", children: [_jsx("input", { type: "checkbox", role: "switch", className: "k-switch k-switch--sm", checked: day.open, onChange: (e) => setDay(i, { open: e.target.checked, ranges: e.target.checked && !day.ranges.length ? [{ from: "09:00", to: "17:00" }] : day.ranges }) }), _jsx("span", { className: "k-hours__name", children: weekdays[i] })] }), _jsx("div", { className: "k-hours__body", children: _jsx("div", { className: "k-hours__inner", children: day.open ? (_jsxs(_Fragment, { children: [day.ranges.map((r, j) => {
42
+ const n = String(j + 1);
43
+ const group = B.rangeOf(weekdays[i], digits === "fa" ? n.replace(/\d/g, (x) => "۰۱۲۳۴۵۶۷۸۹"[+x]) : n);
44
+ return (_jsxs("div", { className: "k-hours__range", role: "group", "aria-label": group, "data-invalid": bad.includes(j) ? "" : undefined, children: [_jsx(TimeInput, { size: "sm", "aria-label": `${group}${M.common.list}${B.from}`, value: r.from, step: step, digits: digits, "aria-describedby": bad.length ? errId : undefined, onChange: (t) => t && setDay(i, { ...day, ranges: day.ranges.map((x, k) => (k === j ? { ...x, from: t } : x)) }) }), _jsx("span", { className: "k-hours__sep", "aria-hidden": "true", children: B.to }), _jsx(TimeInput, { size: "sm", "aria-label": `${group}${M.common.list}${B.to}`, value: r.to, step: step, digits: digits, "aria-describedby": bad.length ? errId : undefined, onChange: (t) => t && setDay(i, { ...day, ranges: day.ranges.map((x, k) => (k === j ? { ...x, to: t } : x)) }) }), day.ranges.length > 1 && (_jsx("button", { type: "button", className: "k-hours__icon", "aria-label": `${B.removeRange}${M.common.list}${group}`, onClick: () => setDay(i, { ...day, ranges: day.ranges.filter((_, k) => k !== j) }), children: _jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.7, strokeLinecap: "round", "aria-hidden": "true", children: _jsx("path", { d: "M6 6l8 8M14 6l-8 8" }) }) }))] }, j));
45
+ }), day.ranges.length < maxRanges && (_jsxs("button", { type: "button", className: "k-hours__add", onClick: () => {
46
+ const last = day.ranges[day.ranges.length - 1]?.to ?? "09:00";
47
+ const h = Math.min(23, Number(last.slice(0, 2)) + 1);
48
+ setDay(i, { ...day, ranges: [...day.ranges, { from: `${String(h).padStart(2, "0")}:00`, to: `${String(Math.min(23, h + 3)).padStart(2, "0")}:00` }] });
49
+ }, children: [_jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.7, strokeLinecap: "round", "aria-hidden": "true", children: _jsx("path", { d: "M10 5v10M5 10h10" }) }), B.addRange] })), bad.length > 0 && _jsx("p", { className: "k-hint k-hint--error k-hours__error", id: errId, children: B.invalid })] })) : (_jsx("span", { className: "k-hours__closed", children: B.closed })) }) })] }, i));
50
+ }) }), summary && (_jsxs("div", { className: "k-hours__foot", children: [_jsxs("span", { className: "k-hours__status", "data-open": open ? "" : undefined, children: [_jsx("span", { className: "k-hours__dot", "aria-hidden": "true" }), open ? B.openNow : B.closedNow] }), _jsx("p", { className: "k-hours__summary", children: summarizeHours(week, { locale }) }), firstOpen >= 0 && (_jsx("button", { type: "button", className: "k-btn k-btn--tertiary k-btn--sm k-hours__copy", onClick: () => commit(week.map((d) => (d.open ? { open: true, ranges: week[firstOpen].ranges.map((r) => ({ ...r })) } : d))), children: B.copyAll }))] })), name && _jsx("input", { type: "hidden", name: name, value: valid ? JSON.stringify(week) : "" })] }));
51
+ }
package/dist/Chat.d.ts ADDED
@@ -0,0 +1,56 @@
1
+ import { type HTMLAttributes, type ReactNode } from "react";
2
+ export interface ChatThreadProps extends HTMLAttributes<HTMLDivElement> {
3
+ /** نام گفتگو برای صفحه‌خوان @default "گفتگو" */
4
+ label?: string;
5
+ /** با پیام تازه به پایین برود، اگر کاربر نزدیک پایین است @default true */
6
+ autoScroll?: boolean;
7
+ children: ReactNode;
8
+ }
9
+ /**
10
+ * ظرف پیام‌ها: ناحیهٔ log که پیام تازه را برای صفحه‌خوان می‌خواند، با پیام تازه پایین می‌ماند
11
+ * (مگر کاربر بالا رفته باشد) و دکمهٔ «رفتن به آخرین پیام» نشان می‌دهد.
12
+ */
13
+ export declare function ChatThread({ label, autoScroll, className, children, ...rest }: ChatThreadProps): import("react").JSX.Element;
14
+ /** جداکنندهٔ روز یا بخش داخل گفتگو، مثل «امروز» */
15
+ export declare function ChatDivider({ children, className }: {
16
+ children: ReactNode;
17
+ className?: string;
18
+ }): import("react").JSX.Element;
19
+ export type ChatRole = "user" | "assistant" | "system";
20
+ export type ChatStatus = "sending" | "sent" | "delivered" | "read" | "failed";
21
+ export interface ChatMessageProps extends Omit<HTMLAttributes<HTMLDivElement>, "role"> {
22
+ /** فرستنده: کاربر سمت پایان خط (در راست‌به‌چپ، چپ)، دستیار سمت شروع @default "assistant" */
23
+ from?: ChatRole;
24
+ /** نام فرستنده؛ برای صفحه‌خوان و گفتگوی گروهی */
25
+ name?: string;
26
+ /** آواتار یا هر عنصر کوچک کنار پیام */
27
+ avatar?: ReactNode;
28
+ /** زمان ارسال؛ Date به شکل نسبی نشان داده می‌شود */
29
+ time?: Date | string;
30
+ /** وضعیت پیام کاربر */
31
+ status?: ChatStatus;
32
+ /** پیام ویرایش شده است */
33
+ edited?: boolean;
34
+ /** متن ساده برای دکمهٔ کپی؛ با آن دکمهٔ کپی نشان داده می‌شود */
35
+ copyText?: string;
36
+ /** دکمهٔ «تلاش دوباره» برای پیام ناموفق یا پاسخ دستیار */
37
+ onRetry?: () => void;
38
+ /** دکمه‌های پسندیدن و نپسندیدن پاسخ دستیار */
39
+ onFeedback?: (value: "up" | "down") => void;
40
+ /** بازخورد انتخاب‌شده */
41
+ feedback?: "up" | "down" | null;
42
+ /** دکمه‌های دلخواه دیگر زیر پیام */
43
+ actions?: ReactNode;
44
+ children: ReactNode;
45
+ }
46
+ /** حباب پیام در گفتگو یا رابط هوش مصنوعی؛ جهت متن هر پیام خودکار است تا پیام انگلیسی هم درست چیده شود */
47
+ export declare function ChatMessage({ from, name, avatar, time, status, edited, copyText, onRetry, onFeedback, feedback, actions, className, children, ...rest }: ChatMessageProps): import("react").JSX.Element;
48
+ export interface TypingIndicatorProps {
49
+ /** نام کسی که می‌نویسد؛ برای صفحه‌خوان */
50
+ name?: string;
51
+ /** نمایش متن کنار نقطه‌ها */
52
+ showLabel?: boolean;
53
+ className?: string;
54
+ }
55
+ /** نشانگر «در حال نوشتن…» با سه نقطهٔ موجی؛ صفحه‌خوان یک بار می‌خواندش */
56
+ export declare function TypingIndicator({ name, showLabel, className }: TypingIndicatorProps): import("react").JSX.Element;
package/dist/Chat.js ADDED
@@ -0,0 +1,91 @@
1
+ "use client";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useRef, useState } from "react";
4
+ import { formatRelative } from "@kashi-ui/persian";
5
+ import { cx } from "./cx.js";
6
+ import { useKashi } from "./KashiProvider.js";
7
+ /* ---------- آیکون‌ها ---------- */
8
+ 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
+ const Tick = () => svg(_jsx("path", { d: "m4.5 10.5 3 3 6-7" }), 1.9);
10
+ const Ticks = () => svg(_jsxs(_Fragment, { children: [_jsx("path", { d: "m2.5 10.5 3 3 6-7" }), _jsx("path", { d: "m9 13.2.3.3 6-7" })] }), 1.9);
11
+ const Clock = () => svg(_jsxs(_Fragment, { children: [_jsx("circle", { cx: "10", cy: "10", r: "6.5" }), _jsx("path", { d: "M10 6.5V10l2 1.5" })] }));
12
+ const Alert = () => svg(_jsxs(_Fragment, { children: [_jsx("circle", { cx: "10", cy: "10", r: "7" }), _jsx("path", { d: "M10 6.5v4M10 13.5h.01" })] }));
13
+ const Copy = () => svg(_jsxs(_Fragment, { children: [_jsx("rect", { x: "7", y: "7", width: "10", height: "10", rx: "2" }), _jsx("path", { d: "M13 7V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2" })] }));
14
+ const Check = () => svg(_jsx("path", { d: "m5 10.5 3.2 3L15 7" }), 2);
15
+ const Retry = () => svg(_jsxs(_Fragment, { children: [_jsx("path", { d: "M4 10a6 6 0 1 0 1.8-4.3" }), _jsx("path", { d: "M4 3.5V7h3.5" })] }));
16
+ const Up = () => svg(_jsx("path", { d: "M6.5 9 9.5 3.5a1.6 1.6 0 0 1 2.9 1.2L11.5 8h3.8a1.5 1.5 0 0 1 1.5 1.8l-1.2 5.5a1.5 1.5 0 0 1-1.5 1.2H6.5M6.5 9v7.5M6.5 9H4v7.5h2.5" }));
17
+ const Down = () => svg(_jsx("path", { d: "M13.5 11 10.5 16.5a1.6 1.6 0 0 1-2.9-1.2L8.5 12H4.7a1.5 1.5 0 0 1-1.5-1.8l1.2-5.5A1.5 1.5 0 0 1 5.9 3.5h7.6M13.5 11V3.5m0 7.5H16V3.5h-2.5" }));
18
+ const Arrow = () => svg(_jsx("path", { d: "M10 4v12m0 0-4.5-4.5M10 16l4.5-4.5" }), 1.9);
19
+ /**
20
+ * ظرف پیام‌ها: ناحیهٔ log که پیام تازه را برای صفحه‌خوان می‌خواند، با پیام تازه پایین می‌ماند
21
+ * (مگر کاربر بالا رفته باشد) و دکمهٔ «رفتن به آخرین پیام» نشان می‌دهد.
22
+ */
23
+ export function ChatThread({ label, autoScroll = true, className, children, ...rest }) {
24
+ const { messages: M } = useKashi();
25
+ const ref = useRef(null);
26
+ const stick = useRef(true);
27
+ const [away, setAway] = useState(false);
28
+ useEffect(() => {
29
+ const el = ref.current;
30
+ if (!el)
31
+ return;
32
+ const toEnd = () => {
33
+ if (autoScroll && stick.current)
34
+ el.scrollTop = el.scrollHeight;
35
+ };
36
+ toEnd();
37
+ const ro = typeof ResizeObserver === "function" ? new ResizeObserver(toEnd) : null;
38
+ const mo = new MutationObserver(toEnd);
39
+ for (const c of Array.from(el.children))
40
+ ro?.observe(c);
41
+ mo.observe(el, { childList: true, subtree: true, characterData: true });
42
+ return () => {
43
+ ro?.disconnect();
44
+ mo.disconnect();
45
+ };
46
+ }, [autoScroll]);
47
+ return (_jsxs("div", { className: cx("k-chat", className), children: [_jsx("div", { ref: ref, className: "k-chat__scroll", role: "log", "aria-live": "polite", "aria-label": label ?? M.chat.thread, tabIndex: 0, onScroll: (e) => {
48
+ const el = e.currentTarget;
49
+ const near = el.scrollHeight - el.scrollTop - el.clientHeight < 48;
50
+ stick.current = near;
51
+ setAway(!near);
52
+ }, ...rest, children: children }), _jsx("button", { type: "button", className: "k-chat__jump", "data-show": away ? "" : undefined, tabIndex: away ? 0 : -1, "aria-hidden": !away, "aria-label": M.chat.scrollDown, onClick: () => {
53
+ stick.current = true;
54
+ ref.current?.scrollTo({ top: ref.current.scrollHeight, behavior: "smooth" });
55
+ }, children: _jsx(Arrow, {}) })] }));
56
+ }
57
+ /** جداکنندهٔ روز یا بخش داخل گفتگو، مثل «امروز» */
58
+ export function ChatDivider({ children, className }) {
59
+ return _jsx("div", { className: cx("k-chat__divider", className), role: "separator", children: children });
60
+ }
61
+ /** حباب پیام در گفتگو یا رابط هوش مصنوعی؛ جهت متن هر پیام خودکار است تا پیام انگلیسی هم درست چیده شود */
62
+ 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 C = M.chat;
65
+ const [copied, setCopied] = useState(false);
66
+ const timer = useRef(undefined);
67
+ useEffect(() => () => clearTimeout(timer.current), []);
68
+ const who = name ?? (from === "user" ? C.you : from === "assistant" ? C.assistant : undefined);
69
+ const timeText = time instanceof Date ? formatRelative(time, { locale, digits }) : time;
70
+ const statusIcon = status === "sending" ? _jsx(Clock, {}) : status === "failed" ? _jsx(Alert, {}) : status === "sent" ? _jsx(Tick, {}) : status ? _jsx(Ticks, {}) : null;
71
+ const hasActions = copyText !== undefined || onRetry || onFeedback || actions;
72
+ if (from === "system")
73
+ return _jsx("div", { className: cx("k-chat__system", className), ...rest, children: children });
74
+ return (_jsxs("div", { className: cx("k-msg", className), "data-from": from, "data-status": status, ...rest, children: [avatar && _jsx("div", { className: "k-msg__avatar", children: avatar }), _jsxs("div", { className: "k-msg__main", children: [name && _jsx("div", { className: "k-msg__name", children: name }), who && !name && _jsxs("span", { className: "k-sr-only", children: [who, ": "] }), _jsx("div", { className: "k-msg__bubble", dir: "auto", children: children }), (timeText || status || edited) && (_jsxs("div", { className: "k-msg__meta", children: [edited && _jsx("span", { children: C.edited }), timeText && _jsx("time", { dateTime: time instanceof Date ? time.toISOString() : undefined, children: timeText }), status && _jsx("span", { className: "k-msg__status", "data-status": status, role: "img", "aria-label": C[status], children: statusIcon })] })), hasActions && (_jsxs("div", { className: "k-msg__actions", role: "group", "aria-label": C.actions, children: [copyText !== undefined && (_jsx("button", { type: "button", className: "k-msg__action", "aria-label": copied ? C.copied : C.copy, "data-done": copied ? "" : undefined, onClick: async () => {
75
+ try {
76
+ await navigator.clipboard.writeText(copyText);
77
+ setCopied(true);
78
+ clearTimeout(timer.current);
79
+ timer.current = setTimeout(() => setCopied(false), 2000);
80
+ }
81
+ catch {
82
+ /* کلیپ‌بورد در دسترس نیست */
83
+ }
84
+ }, children: copied ? _jsx(Check, {}) : _jsx(Copy, {}) })), onRetry && _jsx("button", { type: "button", className: "k-msg__action", "aria-label": C.retry, onClick: onRetry, children: _jsx(Retry, {}) }), onFeedback && (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "k-msg__action", "aria-label": C.like, "aria-pressed": feedback === "up", onClick: () => onFeedback("up"), children: _jsx(Up, {}) }), _jsx("button", { type: "button", className: "k-msg__action", "aria-label": C.dislike, "aria-pressed": feedback === "down", onClick: () => onFeedback("down"), children: _jsx(Down, {}) })] })), actions, _jsx("span", { className: "k-sr-only", "aria-live": "polite", children: copied ? C.copied : "" })] }))] })] }));
85
+ }
86
+ /** نشانگر «در حال نوشتن…» با سه نقطهٔ موجی؛ صفحه‌خوان یک بار می‌خواندش */
87
+ export function TypingIndicator({ name, showLabel, className }) {
88
+ const { messages: M } = useKashi();
89
+ const text = name ? M.chat.typing(name) : M.chat.typingShort;
90
+ 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
+ }
@@ -0,0 +1,41 @@
1
+ import { type ReactNode } from "react";
2
+ export interface ChatComposerSend {
3
+ text: string;
4
+ files: File[];
5
+ }
6
+ export interface ChatComposerProps {
7
+ /** ارسال با Enter یا دکمه؛ متن بدون فاصلهٔ اول و آخر */
8
+ onSend: (message: ChatComposerSend) => void;
9
+ /** پاسخ در حال نوشتن است: دکمهٔ ارسال «توقف» می‌شود */
10
+ streaming?: boolean;
11
+ /** با دکمهٔ توقف */
12
+ onStop?: () => void;
13
+ /** متن کنترل‌شده */
14
+ value?: string;
15
+ onValueChange?: (value: string) => void;
16
+ /** دکمهٔ پیوست؛ مقدار accept فایل‌ها، مثلاً "image/*,.pdf" یا true برای همه */
17
+ attach?: boolean | string;
18
+ /** حداکثر تعداد پیوست @default 5 */
19
+ maxFiles?: number;
20
+ /** حداکثر حجم هر فایل به بایت */
21
+ maxSize?: number;
22
+ /** حداکثر طول متن؛ شمارنده نزدیک سقف نشان داده می‌شود */
23
+ maxLength?: number;
24
+ /** بیشترین ارتفاع پیش از اسکرول، به ردیف @default 8 */
25
+ maxRows?: number;
26
+ placeholder?: string;
27
+ /** @default "پیام" */
28
+ label?: string;
29
+ /** راهنمای کلیدها زیر کادر @default false */
30
+ showHint?: boolean;
31
+ /** دکمه‌های دلخواه کنار پیوست، مثل انتخاب مدل */
32
+ tools?: ReactNode;
33
+ disabled?: boolean;
34
+ autoFocus?: boolean;
35
+ className?: string;
36
+ }
37
+ /**
38
+ * کادر نوشتن پیام برای گفتگو و دستیار هوش مصنوعی: بلند شدن خودکار، Enter برای ارسال و Shift+Enter برای خط تازه
39
+ * (هنگام تایپ با IME ارسال نمی‌کند)، پیوست با دکمه یا چسباندن تصویر، و دکمهٔ توقف هنگام پاسخ.
40
+ */
41
+ export declare function ChatComposer({ onSend, streaming, onStop, value, onValueChange, attach, maxFiles, maxSize, maxLength, maxRows, placeholder, label, showHint, tools, disabled, autoFocus, className, }: ChatComposerProps): import("react").JSX.Element;
@@ -0,0 +1,93 @@
1
+ "use client";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useId, useRef, useState } from "react";
4
+ import { cx } from "./cx.js";
5
+ import { formatBytes } from "./FileUpload.js";
6
+ import { useKashi } from "./KashiProvider.js";
7
+ import { useIsomorphicLayoutEffect } from "./utils.js";
8
+ 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
+ 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" }));
10
+ const Send = () => svg(_jsx("path", { d: "M10 16V4m0 0L5 9m5-5 5 5" }));
11
+ const Stop = () => _jsx("svg", { viewBox: "0 0 20 20", "aria-hidden": "true", children: _jsx("rect", { x: "6", y: "6", width: "8", height: "8", rx: "1.5", fill: "currentColor" }) });
12
+ const X = () => svg(_jsx("path", { d: "M6 6l8 8M14 6l-8 8" }));
13
+ const Doc = () => svg(_jsxs(_Fragment, { children: [_jsx("path", { d: "M11.5 3H6a1.5 1.5 0 0 0-1.5 1.5v11A1.5 1.5 0 0 0 6 17h8a1.5 1.5 0 0 0 1.5-1.5V7z" }), _jsx("path", { d: "M11.5 3v4h4" })] }));
14
+ /**
15
+ * کادر نوشتن پیام برای گفتگو و دستیار هوش مصنوعی: بلند شدن خودکار، Enter برای ارسال و Shift+Enter برای خط تازه
16
+ * (هنگام تایپ با IME ارسال نمی‌کند)، پیوست با دکمه یا چسباندن تصویر، و دکمهٔ توقف هنگام پاسخ.
17
+ */
18
+ 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 C = M.composer;
21
+ const [inner, setInner] = useState("");
22
+ const text = value ?? inner;
23
+ const [files, setFiles] = useState([]);
24
+ const [error, setError] = useState("");
25
+ const area = useRef(null);
26
+ const picker = useRef(null);
27
+ const id = useId();
28
+ const [urls, setUrls] = useState([]);
29
+ const setText = (t) => {
30
+ if (value === undefined)
31
+ setInner(t);
32
+ onValueChange?.(t);
33
+ };
34
+ // بلند شدن خودکار تا maxRows
35
+ useIsomorphicLayoutEffect(() => {
36
+ const el = area.current;
37
+ if (!el)
38
+ return;
39
+ el.style.blockSize = "auto";
40
+ const line = parseFloat(getComputedStyle(el).lineHeight) || 24;
41
+ el.style.blockSize = `${Math.min(el.scrollHeight, line * maxRows + 2)}px`;
42
+ }, [text, maxRows]);
43
+ // پیش‌نمایش تصویرها
44
+ useEffect(() => {
45
+ const list = files.map((f) => (f.type.startsWith("image/") && typeof URL.createObjectURL === "function" ? URL.createObjectURL(f) : ""));
46
+ setUrls(list);
47
+ return () => list.forEach((u) => u && URL.revokeObjectURL(u));
48
+ }, [files]);
49
+ const add = (list) => {
50
+ setError("");
51
+ const ok = [];
52
+ for (const f of list) {
53
+ if (maxSize && f.size > maxSize)
54
+ setError(C.tooLarge(f.name, formatBytes(maxSize, locale)));
55
+ else
56
+ ok.push(f);
57
+ }
58
+ const next = [...files, ...ok];
59
+ if (next.length > maxFiles)
60
+ setError(C.tooMany(n(maxFiles)));
61
+ setFiles(next.slice(0, maxFiles));
62
+ };
63
+ const canSend = !disabled && !streaming && (text.trim().length > 0 || files.length > 0) && (!maxLength || text.length <= maxLength);
64
+ const send = () => {
65
+ if (!canSend)
66
+ return;
67
+ onSend({ text: text.trim(), files });
68
+ setText("");
69
+ setFiles([]);
70
+ setError("");
71
+ area.current?.focus();
72
+ };
73
+ const near = maxLength && text.length > maxLength * 0.8;
74
+ const hintId = `${id}-hint`;
75
+ const errId = `${id}-err`;
76
+ return (_jsxs("div", { className: cx("k-composer", className), "data-disabled": disabled ? "" : undefined, "data-invalid": error ? "" : undefined, children: [files.length > 0 && (_jsx("ul", { className: "k-composer__files", "aria-label": C.attachments, children: files.map((f, i) => (_jsxs("li", { className: "k-composer__file", children: [urls[i] ? _jsx("img", { src: urls[i], alt: "", className: "k-composer__thumb" }) : _jsx("span", { className: "k-composer__thumb", children: _jsx(Doc, {}) }), _jsxs("span", { className: "k-composer__file-text", children: [_jsx("span", { className: "k-composer__file-name", dir: "auto", children: f.name }), _jsx("span", { className: "k-composer__file-size", children: formatBytes(f.size, locale) })] }), _jsx("button", { type: "button", className: "k-composer__remove", "aria-label": C.removeAttachment(f.name), onClick: () => setFiles(files.filter((_, j) => j !== i)), children: _jsx(X, {}) })] }, `${f.name}-${i}`))) })), _jsx("textarea", { ref: area, className: "k-composer__input", rows: 1, dir: "auto", value: text, disabled: disabled, autoFocus: autoFocus, placeholder: placeholder ?? C.placeholder, "aria-label": label ?? C.label, "aria-describedby": [showHint ? hintId : "", error ? errId : ""].filter(Boolean).join(" ") || undefined, "aria-invalid": maxLength && text.length > maxLength ? true : undefined, onChange: (e) => setText(e.target.value), onKeyDown: (e) => {
77
+ if (e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing && e.keyCode !== 229) {
78
+ e.preventDefault();
79
+ send();
80
+ }
81
+ }, onPaste: (e) => {
82
+ if (!attach)
83
+ return;
84
+ const pasted = Array.from(e.clipboardData.files);
85
+ if (pasted.length) {
86
+ e.preventDefault();
87
+ add(pasted);
88
+ }
89
+ } }), _jsxs("div", { className: "k-composer__bar", children: [attach && (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "k-composer__tool", "aria-label": C.attach, disabled: disabled || files.length >= maxFiles, onClick: () => picker.current?.click(), children: _jsx(Clip, {}) }), _jsx("input", { ref: picker, type: "file", hidden: true, multiple: maxFiles > 1, accept: typeof attach === "string" ? attach : undefined, onChange: (e) => {
90
+ add(Array.from(e.target.files ?? []));
91
+ e.target.value = "";
92
+ } })] })), tools, near ? _jsxs("span", { className: "k-composer__count", "data-over": text.length > maxLength ? "" : undefined, children: [n(text.length), "/", n(maxLength)] }) : null, streaming ? (_jsx("button", { type: "button", className: "k-composer__send", "data-stop": "", "aria-label": C.stop, onClick: onStop, children: _jsx(Stop, {}) })) : (_jsx("button", { type: "button", className: "k-composer__send", "aria-label": C.send, disabled: !canSend, onClick: send, children: _jsx(Send, {}) }))] }), error && _jsx("p", { className: "k-hint k-hint--error k-composer__error", id: errId, role: "alert", children: error }), showHint && _jsx("p", { className: "k-composer__hint", id: hintId, children: C.hint })] }));
93
+ }
@@ -0,0 +1,23 @@
1
+ import { type ReactNode } from "react";
2
+ export interface CodeBlockProps {
3
+ code: string;
4
+ /** نام زبان؛ برچسب بالای کد و رنگ‌آمیزی ساده */
5
+ language?: string;
6
+ /** نام فایل به‌جای نام زبان */
7
+ filename?: string;
8
+ /** شمارهٔ خط‌ها @default false */
9
+ lineNumbers?: boolean;
10
+ /** خط‌هایی که برجسته می‌شوند (از ۱) */
11
+ highlightLines?: number[];
12
+ /** شکستن خط‌های بلند به‌جای اسکرول افقی؛ کاربر هم می‌تواند عوضش کند @default false */
13
+ wrap?: boolean;
14
+ /** رنگ‌آمیزی کلمه‌های کلیدی، رشته‌ها، عددها و توضیح‌ها @default true */
15
+ highlight?: boolean;
16
+ /** بیشترین ارتفاع پیش از اسکرول، مثل "20rem" */
17
+ maxHeight?: string;
18
+ className?: string;
19
+ }
20
+ /** رنگ‌آمیزی سبک و بی‌وابستگی؛ برای کد کامل‌تر خروجی Shiki یا Prism را به children بدهید */
21
+ export declare function highlightCode(code: string, language?: string): ReactNode[];
22
+ /** نمایش کد در پاسخ دستیار یا مستندات: همیشه چپ‌به‌راست، با برچسب زبان، دکمهٔ کپی و شکستن خط */
23
+ export declare function CodeBlock({ code, language, filename, lineNumbers, highlightLines, wrap: wrapDefault, highlight, maxHeight, className }: CodeBlockProps): import("react").JSX.Element;
@@ -0,0 +1,84 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useRef, useState } from "react";
4
+ import { cx } from "./cx.js";
5
+ import { useKashi } from "./KashiProvider.js";
6
+ 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
+ "async await try catch finally throw typeof instanceof in of interface type enum implements public private protected static readonly " +
8
+ "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 " +
9
+ "true false null undefined void this super echo SELECT FROM WHERE INSERT INTO VALUES UPDATE SET DELETE JOIN ON AND OR NOT ORDER BY GROUP LIMIT").split(" "));
10
+ const TOKEN = /(\/\/[^\n]*|#(?![{\[])[^\n]*|\/\*[\s\S]*?\*\/|<!--[\s\S]*?-->)|("(?:\\.|[^"\\\n])*"|'(?:\\.|[^'\\\n])*'|`(?:\\.|[^`\\])*`)|(\b\d[\d_.]*(?:e[+-]?\d+)?\b)|([A-Za-z_$][\w$]*)/g;
11
+ /** رنگ‌آمیزی سبک و بی‌وابستگی؛ برای کد کامل‌تر خروجی Shiki یا Prism را به children بدهید */
12
+ export function highlightCode(code, language = "") {
13
+ const out = [];
14
+ const hashComments = /^(py|python|sh|bash|shell|zsh|yaml|yml|toml|rb|ruby|r)$/i.test(language);
15
+ let last = 0;
16
+ let k = 0;
17
+ for (const m of code.matchAll(TOKEN)) {
18
+ const [t, comment, str, num, word] = m;
19
+ const i = m.index ?? 0;
20
+ if (comment && comment.startsWith("#") && !hashComments)
21
+ continue;
22
+ if (i > last)
23
+ out.push(code.slice(last, i));
24
+ const cls = comment ? "comment" : str ? "string" : num ? "number" : word && KEYWORDS.has(word) ? "keyword" : word && code[i + t.length] === "(" ? "fn" : "";
25
+ out.push(cls ? _jsx("span", { className: `k-code__t-${cls}`, children: t }, k++) : t);
26
+ last = i + t.length;
27
+ }
28
+ if (last < code.length)
29
+ out.push(code.slice(last));
30
+ return out;
31
+ }
32
+ const Copy = () => (_jsxs("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.7, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [_jsx("rect", { x: "7", y: "7", width: "10", height: "10", rx: "2" }), _jsx("path", { d: "M13 7V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2" })] }));
33
+ 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" }) });
34
+ 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
+ export function CodeBlock({ code, language, filename, lineNumbers, highlightLines = [], wrap: wrapDefault = false, highlight = true, maxHeight, className }) {
37
+ const { messages: M, n } = useKashi();
38
+ const B = M.codeBlock;
39
+ const [copied, setCopied] = useState(false);
40
+ const [wrap, setWrap] = useState(wrapDefault);
41
+ const timer = useRef(undefined);
42
+ useEffect(() => () => clearTimeout(timer.current), []);
43
+ const text = code.replace(/\n$/, "");
44
+ const lines = text.split("\n");
45
+ const title = filename ?? language;
46
+ const mark = new Set(highlightLines);
47
+ const body = highlight ? highlightCode(text, language) : [text];
48
+ // خط‌ها جدا رندر می‌شوند تا شماره و برجسته‌سازی ممکن باشد؛ رنگ‌آمیزی روی کل متن است و بعد به خط‌ها تقسیم می‌شود
49
+ const perLine = [[]];
50
+ for (const part of body) {
51
+ if (typeof part !== "string") {
52
+ const s = String(part.props.children);
53
+ if (!s.includes("\n")) {
54
+ perLine[perLine.length - 1].push(part);
55
+ continue;
56
+ }
57
+ const cls = part.props.className;
58
+ s.split("\n").forEach((seg, j) => {
59
+ if (j)
60
+ perLine.push([]);
61
+ if (seg)
62
+ perLine[perLine.length - 1].push(_jsx("span", { className: cls, children: seg }, `${perLine.length}-${j}`));
63
+ });
64
+ continue;
65
+ }
66
+ part.split("\n").forEach((seg, j) => {
67
+ if (j)
68
+ perLine.push([]);
69
+ if (seg)
70
+ perLine[perLine.length - 1].push(seg);
71
+ });
72
+ }
73
+ return (_jsxs("figure", { className: cx("k-code", className), "data-wrap": wrap ? "" : undefined, children: [_jsxs("figcaption", { className: "k-code__head", children: [_jsx("span", { className: "k-code__lang", dir: "ltr", children: title ?? B.lines(n(lines.length)) }), _jsxs("span", { className: "k-code__tools", children: [_jsx("button", { type: "button", className: "k-code__btn", "aria-label": B.wrap, "aria-pressed": wrap, onClick: () => setWrap((w) => !w), children: _jsx(Wrap, {}) }), _jsxs("button", { type: "button", className: "k-code__btn", "data-done": copied ? "" : undefined, onClick: async () => {
74
+ try {
75
+ await navigator.clipboard.writeText(text);
76
+ setCopied(true);
77
+ clearTimeout(timer.current);
78
+ timer.current = setTimeout(() => setCopied(false), 2000);
79
+ }
80
+ catch {
81
+ /* کلیپ‌بورد در دسترس نیست */
82
+ }
83
+ }, children: [copied ? _jsx(Check, {}) : _jsx(Copy, {}), _jsx("span", { children: copied ? B.copied : B.copy })] }), _jsx("span", { className: "k-sr-only", "aria-live": "polite", children: copied ? B.copied : "" })] })] }), _jsx("pre", { className: "k-code__pre", dir: "ltr", tabIndex: 0, "aria-label": language ? B.code(language) : undefined, style: maxHeight ? { maxBlockSize: maxHeight } : undefined, children: _jsx("code", { children: perLine.map((parts, i) => (_jsxs("span", { className: "k-code__line", "data-marked": mark.has(i + 1) ? "" : undefined, children: [lineNumbers && _jsx("span", { className: "k-code__num", "aria-hidden": "true", children: i + 1 }), _jsx("span", { className: "k-code__text", children: parts.length ? parts : " " })] }, i))) }) })] }));
84
+ }
@@ -0,0 +1,21 @@
1
+ import { type ReactNode } from "react";
2
+ import { type EconomicCodeType } from "@kashi-ui/persian";
3
+ import { type InputProps } from "./Input.js";
4
+ type Base = Omit<InputProps, "value" | "defaultValue" | "onChange" | "type" | "inputMode">;
5
+ export interface EconomicCodeInputProps extends Base {
6
+ /** ارقام لاتین */
7
+ value?: string;
8
+ defaultValue?: string;
9
+ onValueChange?: (value: string, valid: boolean, type: EconomicCodeType | null) => void;
10
+ /** نمایش نوع (حقیقی، حقوقی یا کد قدیمی) کنار فیلد @default true */
11
+ showType?: boolean;
12
+ /** @default "fa" */
13
+ digits?: "fa" | "latin";
14
+ invalidMessage?: ReactNode;
15
+ }
16
+ /**
17
+ * کد اقتصادی فاکتور: ۱۰ رقم (کد ملی شخص حقیقی)، ۱۱ رقم (شناسهٔ ملی شخص حقوقی) یا ۱۲ رقم قدیمی.
18
+ * کد ملی و شناسهٔ ملی با رقم کنترل خودشان بررسی می‌شوند و نوع کنار فیلد می‌آید.
19
+ */
20
+ export declare const EconomicCodeInput: import("react").ForwardRefExoticComponent<EconomicCodeInputProps & import("react").RefAttributes<HTMLInputElement>>;
21
+ export {};
@@ -0,0 +1,30 @@
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 { economicCodeType, isValidEconomicCode } from "@kashi-ui/persian";
5
+ import { Input } from "./Input.js";
6
+ import { useDigitsInput } from "./useDigitsInput.js";
7
+ import { mergeRefs } from "./utils.js";
8
+ import { useKashi } from "./KashiProvider.js";
9
+ /**
10
+ * کد اقتصادی فاکتور: ۱۰ رقم (کد ملی شخص حقیقی)، ۱۱ رقم (شناسهٔ ملی شخص حقوقی) یا ۱۲ رقم قدیمی.
11
+ * کد ملی و شناسهٔ ملی با رقم کنترل خودشان بررسی می‌شوند و نوع کنار فیلد می‌آید.
12
+ */
13
+ export const EconomicCodeInput = forwardRef(function EconomicCodeInput({ value, defaultValue, onValueChange, showType = true, digits, invalidMessage, error, name, onBlur, placeholder, ...rest }, ref) {
14
+ const { messages: M, digits: D } = useKashi();
15
+ digits ?? (digits = D);
16
+ invalidMessage ?? (invalidMessage = M.invalid.economicCode);
17
+ const { raw, shown, inputRef, handleChange } = useDigitsInput({ value, defaultValue, maxDigits: 12, format: (d) => d, digits });
18
+ const [touched, setTouched] = useState(false);
19
+ const type = economicCodeType(raw);
20
+ const valid = isValidEconomicCode(raw);
21
+ const typeId = useId();
22
+ const showInvalid = raw.length > 0 && (touched || raw.length === 12) && !valid;
23
+ return (_jsxs(_Fragment, { children: [_jsx(Input, { ref: mergeRefs(ref, inputRef), type: "text", inputMode: "numeric", autoComplete: "off", dir: "ltr", placeholder: placeholder ?? (digits === "fa" ? "۰۰۰۰۰۰۰۰۰۰۰" : "00000000000"), value: shown, onChange: (e) => {
24
+ const next = handleChange(e);
25
+ onValueChange?.(next, isValidEconomicCode(next), economicCodeType(next));
26
+ }, onBlur: (e) => {
27
+ setTouched(true);
28
+ onBlur?.(e);
29
+ }, addonEnd: showType && type && valid ? _jsx("span", { className: "k-input__meta", id: typeId, children: M.taxCode[type] }) : undefined, "aria-describedby": showType && type && valid ? typeId : undefined, error: error ?? (showInvalid ? invalidMessage : undefined), ...rest }), name && _jsx("input", { type: "hidden", name: name, value: raw })] }));
30
+ });
@@ -0,0 +1,36 @@
1
+ import { type ReactNode } from "react";
2
+ export interface KanbanColumn<T> {
3
+ id: string;
4
+ title: ReactNode;
5
+ /** نام ستون برای صفحه‌خوان، اگر title متن ساده نیست */
6
+ label?: string;
7
+ items: T[];
8
+ /** سقف کارت (WIP)؛ بیشتر از آن ستون هشدار می‌گیرد */
9
+ limit?: number;
10
+ /** رنگ نشانگر ستون، مثل "var(--k-chart-3)" */
11
+ color?: string;
12
+ }
13
+ export interface KanbanCardState {
14
+ handle: ReactNode;
15
+ dragging: boolean;
16
+ }
17
+ export interface KanbanProps<T> {
18
+ columns: KanbanColumn<T>[];
19
+ getId: (item: T) => string;
20
+ getLabel: (item: T) => string;
21
+ /** با رها کردن کارت؛ ستون‌ها با ترتیب تازه */
22
+ onChange: (columns: KanbanColumn<T>[]) => void;
23
+ /** محتوای کارت */
24
+ renderCard?: (item: T, state: KanbanCardState) => ReactNode;
25
+ /** دکمهٔ «افزودن» پایین هر ستون */
26
+ onAdd?: (columnId: string) => void;
27
+ /** متن دکمهٔ افزودن */
28
+ addLabel?: string;
29
+ "aria-label"?: string;
30
+ className?: string;
31
+ }
32
+ /**
33
+ * تابلوی کانبان: کارت‌ها را بین ستون‌ها بکشید، یا با کیبورد: فاصله برای برداشتن، بالا و پایین در ستون،
34
+ * چپ و راست بین ستون‌ها (در راست‌به‌چپ، چپ یعنی ستون بعد)، فاصله برای رها کردن و Escape برای لغو.
35
+ */
36
+ export declare function Kanban<T>({ columns, getId, getLabel, onChange, renderCard, onAdd, addLabel, "aria-label": ariaLabel, className }: KanbanProps<T>): import("react").JSX.Element;