@kashi-ui/react 2.24.0 → 2.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/Gantt.js ADDED
@@ -0,0 +1,116 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useId, useMemo, useRef, useState } from "react";
4
+ import { formatJalali, getIranHoliday, toJalali } from "@kashi-ui/persian";
5
+ import { cx } from "./cx.js";
6
+ import { useKashi } from "./KashiProvider.js";
7
+ const DAY = 86400000;
8
+ const midnight = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate());
9
+ const addDays = (d, n) => new Date(d.getFullYear(), d.getMonth(), d.getDate() + n);
10
+ const diffDays = (a, b) => Math.round((midnight(b).getTime() - midnight(a).getTime()) / DAY);
11
+ /**
12
+ * نمودار گانت با تقویم شمسی: سرستون ماه و روز شمسی، جمعه و تعطیلات رسمی، خط امروز، وابستگی کارها و پیشرفت هر کار.
13
+ * نوارها با ماوس و لمس جابه‌جا و کشیده می‌شوند و با کیبورد هم (جهت‌ها جابه‌جا، Shift + جهت طول).
14
+ */
15
+ export function Gantt({ tasks, label, from, to, today: todayProp, onTaskChange, onTaskClick, holidays = true, taskHeader, className }) {
16
+ const { messages: M, months, n, locale, digits } = useKashi();
17
+ const G = M.gantt;
18
+ const id = useId();
19
+ const today = midnight(todayProp ?? new Date());
20
+ const [live, setLive] = useState("");
21
+ const [preview, setPreview] = useState(null);
22
+ const dragRef = useRef(null);
23
+ const range = useMemo(() => {
24
+ const starts = tasks.map((t) => midnight(t.start).getTime());
25
+ const ends = tasks.map((t) => midnight(t.end).getTime());
26
+ const a = from ? midnight(from) : addDays(new Date(Math.min(...starts, today.getTime())), -3);
27
+ const b = to ? midnight(to) : addDays(new Date(Math.max(...ends, today.getTime())), 5);
28
+ return { a, b, days: diffDays(a, b) + 1 };
29
+ }, [tasks, from, to, today.getTime()]);
30
+ const days = useMemo(() => Array.from({ length: range.days }, (_, i) => {
31
+ const d = addDays(range.a, i);
32
+ const j = toJalali(d);
33
+ const off = d.getDay() === 5 || (holidays && !!getIranHoliday(d));
34
+ return { d, j, off };
35
+ }), [range.a.getTime(), range.days, holidays]);
36
+ const monthsRow = useMemo(() => {
37
+ const out = [];
38
+ for (const { j } of days) {
39
+ const key = `${j.jy}-${j.jm}`;
40
+ const last = out[out.length - 1];
41
+ if (last?.key === key)
42
+ last.span++;
43
+ else
44
+ out.push({ key, label: `${months[j.jm - 1]} ${n(j.jy)}`, span: 1 });
45
+ }
46
+ return out;
47
+ }, [days, months, n]);
48
+ const byId = new Map(tasks.map((t) => [t.id, t]));
49
+ const fmt = (d) => formatJalali(d, { locale, digits });
50
+ const shown = (t) => (preview?.id === t.id ? preview : { start: t.start, end: t.end });
51
+ const editable = !!onTaskChange;
52
+ const commit = (t, start, end) => {
53
+ if (end < start)
54
+ end = start;
55
+ onTaskChange?.(t, { start, end });
56
+ setLive(G.moved(t.name, fmt(start), fmt(end)));
57
+ };
58
+ const todayIdx = diffDays(range.a, today);
59
+ const rowIndex = new Map(tasks.map((t, i) => [t.id, i]));
60
+ return (_jsxs("div", { className: cx("k-gantt", className), style: { "--k-gantt-days": range.days }, children: [_jsxs("div", { className: "k-gantt__scroll", role: "region", "aria-labelledby": `${id}-title`, tabIndex: 0, children: [_jsx("span", { className: "k-sr-only", id: `${id}-title`, children: label ?? G.label }), _jsxs("div", { className: "k-gantt__grid", role: "table", "aria-label": label ?? G.label, "aria-rowcount": tasks.length + 1, children: [_jsxs("div", { className: "k-gantt__head", role: "row", children: [_jsx("div", { className: "k-gantt__corner", role: "columnheader", children: taskHeader ?? G.task }), _jsxs("div", { className: "k-gantt__timehead", role: "columnheader", "aria-label": `${fmt(range.a)} – ${fmt(range.b)}`, children: [_jsx("div", { className: "k-gantt__months", "aria-hidden": "true", children: monthsRow.map((m) => _jsx("span", { className: "k-gantt__month", style: { gridColumn: `span ${m.span}` }, children: m.label }, m.key)) }), _jsx("div", { className: "k-gantt__days", "aria-hidden": "true", children: days.map(({ d, j, off }, i) => (_jsx("span", { className: "k-gantt__day", "data-off": off || undefined, "data-today": i === todayIdx || undefined, "data-first": j.jd === 1 || undefined, children: n(j.jd) }, i))) })] })] }), tasks.map((t, row) => {
61
+ const s = shown(t);
62
+ const startIdx = diffDays(range.a, s.start);
63
+ const len = t.milestone ? 1 : diffDays(s.start, s.end) + 1;
64
+ const p = Math.max(0, Math.min(100, t.progress ?? 0));
65
+ const deps = (t.dependsOn ?? []).map((x) => byId.get(x)).filter(Boolean);
66
+ const desc = [G.bar(t.name, fmt(s.start), fmt(s.end), n(p)), ...deps.map((d) => G.dependsOn(d.name))].join(M.common.comma);
67
+ return (_jsxs("div", { className: "k-gantt__row", role: "row", "aria-rowindex": row + 2, children: [_jsxs("div", { className: "k-gantt__name", role: "rowheader", children: [_jsx("span", { className: "k-gantt__dot", style: t.color ? { background: t.color } : undefined, "aria-hidden": "true" }), _jsx("span", { className: "k-gantt__label", children: t.name }), _jsx("span", { className: "k-gantt__len", children: G.days(n(len)) })] }), _jsxs("div", { className: "k-gantt__track", role: "cell", children: [days.map(({ off }, i) => off && _jsx("span", { className: "k-gantt__off", style: { gridColumn: `${i + 1}` }, "aria-hidden": "true" }, i)), deps.map((d) => {
68
+ const ds = shown(d);
69
+ const fromIdx = diffDays(range.a, ds.end) + 1;
70
+ const up = (rowIndex.get(d.id) ?? 0) - row;
71
+ return (_jsx("span", { className: "k-gantt__dep", "aria-hidden": "true", "data-backward": fromIdx > startIdx || undefined, "data-below": up > 0 || undefined, style: { "--from": fromIdx, "--to": startIdx, "--rows": Math.abs(up) } }, d.id));
72
+ }), _jsxs("button", { type: "button", className: "k-gantt__bar", "data-milestone": t.milestone || undefined, "data-dragging": preview?.id === t.id || undefined, "data-done": p >= 100 || undefined, style: { "--start": startIdx, "--len": len, "--progress": `${p}%`, ...(t.color ? { "--k-gantt-color": t.color } : {}) }, "aria-label": desc, "aria-describedby": editable ? `${id}-hint` : undefined, onClick: () => { if (!dragRef.current?.moved)
73
+ onTaskClick?.(t); }, onKeyDown: (e) => {
74
+ if (!editable || !["ArrowLeft", "ArrowRight"].includes(e.key))
75
+ return;
76
+ e.preventDefault();
77
+ const rtl = getComputedStyle(e.currentTarget).direction === "rtl";
78
+ // در RTL زمان به چپ جلو می‌رود
79
+ const step = (e.key === "ArrowLeft" ? 1 : -1) * (rtl ? 1 : -1);
80
+ if (e.shiftKey && !t.milestone)
81
+ commit(t, t.start, addDays(t.end, step));
82
+ else
83
+ commit(t, addDays(t.start, step), addDays(t.end, step));
84
+ }, onPointerDown: (e) => {
85
+ if (!editable || e.button !== 0)
86
+ return;
87
+ const el = e.currentTarget;
88
+ el.setPointerCapture(e.pointerId);
89
+ const r = el.getBoundingClientRect();
90
+ const rtl = getComputedStyle(el).direction === "rtl";
91
+ const edge = rtl ? e.clientX - r.left : r.right - e.clientX;
92
+ dragRef.current = {
93
+ id: t.id, x: e.clientX, kind: !t.milestone && edge < 10 ? "end" : "move", start: t.start, end: t.end,
94
+ dayPx: r.width / len, dir: rtl ? -1 : 1, moved: false,
95
+ };
96
+ }, onPointerMove: (e) => {
97
+ const d = dragRef.current;
98
+ if (!d || d.id !== t.id)
99
+ return;
100
+ const delta = Math.round(((e.clientX - d.x) * d.dir) / d.dayPx);
101
+ if (delta !== 0)
102
+ d.moved = true;
103
+ if (!d.moved)
104
+ return;
105
+ setPreview(d.kind === "move"
106
+ ? { id: t.id, start: addDays(d.start, delta), end: addDays(d.end, delta) }
107
+ : { id: t.id, start: d.start, end: addDays(d.end, Math.max(delta, -diffDays(d.start, d.end))) });
108
+ }, onPointerUp: () => {
109
+ const d = dragRef.current;
110
+ if (d?.moved && preview)
111
+ commit(t, preview.start, preview.end);
112
+ setPreview(null);
113
+ setTimeout(() => { dragRef.current = null; });
114
+ }, onPointerCancel: () => { setPreview(null); dragRef.current = null; }, children: [!t.milestone && _jsx("span", { className: "k-gantt__fill", "aria-hidden": "true" }), !t.milestone && _jsx("span", { className: "k-gantt__text", "aria-hidden": "true", children: t.name }), editable && !t.milestone && _jsx("span", { className: "k-gantt__grip", "aria-hidden": "true" })] })] })] }, t.id));
115
+ }), todayIdx >= 0 && todayIdx < range.days && (_jsx("span", { className: "k-gantt__now", style: { "--today": todayIdx }, "aria-hidden": "true", children: _jsx("span", { children: G.today }) }))] })] }), editable && _jsx("span", { className: "k-sr-only", id: `${id}-hint`, children: G.hint }), _jsx("span", { className: "k-sr-only", "aria-live": "polite", children: live })] }));
116
+ }
@@ -0,0 +1,56 @@
1
+ import { type ReactNode } from "react";
2
+ /** ناحیهٔ برش به پیکسل تصویر اصلی (بعد از چرخش) */
3
+ export interface CropArea {
4
+ x: number;
5
+ y: number;
6
+ width: number;
7
+ height: number;
8
+ }
9
+ export interface CropState {
10
+ /** جابه‌جایی مرکز تصویر از مرکز کادر، به نسبت اندازهٔ کادر */
11
+ x: number;
12
+ y: number;
13
+ /** ۱ = تصویر کادر را تازه پر کرده است */
14
+ zoom: number;
15
+ /** ۰، ۹۰، ۱۸۰ یا ۲۷۰ */
16
+ rotation: number;
17
+ }
18
+ export interface ImageCropperHandle {
19
+ /** تصویر بریده‌شده به Blob (پیش‌فرض WebP، اگر مرورگر بخواهد PNG) */
20
+ crop: (options?: CropImageOptions) => Promise<Blob | null>;
21
+ reset: () => void;
22
+ }
23
+ export interface CropImageOptions {
24
+ /** پهنای خروجی به پیکسل؛ پیش‌فرض اندازهٔ واقعی ناحیه */
25
+ width?: number;
26
+ type?: string;
27
+ quality?: number;
28
+ /** برش دایره‌ای (گوشه‌ها شفاف) */
29
+ circle?: boolean;
30
+ }
31
+ export interface ImageCropperProps {
32
+ src: string;
33
+ alt?: string;
34
+ /** نسبت پهنا به ارتفاع کادر @default 1 */
35
+ aspect?: number;
36
+ /** کادر دایره‌ای برای عکس پروفایل */
37
+ shape?: "rect" | "circle";
38
+ /** بیشترین بزرگ‌نمایی @default 4 */
39
+ maxZoom?: number;
40
+ value?: CropState;
41
+ defaultValue?: Partial<CropState>;
42
+ onChange?: (state: CropState) => void;
43
+ /** بعد از هر تغییر، ناحیهٔ برش به پیکسل تصویر */
44
+ onCropComplete?: (area: CropArea, state: CropState) => void;
45
+ /** دکمهٔ چرخش @default true */
46
+ rotatable?: boolean;
47
+ label?: ReactNode;
48
+ className?: string;
49
+ }
50
+ /** تصویر را با ناحیه و چرخش داده‌شده می‌بُرد؛ برای سرور هم قابل استفاده است (در مرورگر) */
51
+ export declare function cropImage(src: string, area: CropArea, rotation?: number, { width, type, quality, circle }?: CropImageOptions): Promise<Blob | null>;
52
+ /**
53
+ * برش تصویر برای عکس پروفایل و کاور: تصویر زیر کادر ثابت جابه‌جا و بزرگ می‌شود (کشیدن، چرخ ماوس، دو انگشت یا کیبورد)
54
+ * و همیشه کادر را پر نگه می‌دارد. خروجی با ref.crop() یا تابع cropImage.
55
+ */
56
+ export declare const ImageCropper: import("react").ForwardRefExoticComponent<ImageCropperProps & import("react").RefAttributes<ImageCropperHandle>>;
@@ -0,0 +1,185 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { forwardRef, useCallback, useEffect, useImperativeHandle, useLayoutEffect, useRef, useState } from "react";
4
+ import { cx } from "./cx.js";
5
+ import { useKashi } from "./KashiProvider.js";
6
+ const START = { x: 0, y: 0, zoom: 1, rotation: 0 };
7
+ const clampN = (v, a, b) => Math.min(b, Math.max(a, v));
8
+ /** تصویر را با ناحیه و چرخش داده‌شده می‌بُرد؛ برای سرور هم قابل استفاده است (در مرورگر) */
9
+ export async function cropImage(src, area, rotation = 0, { width, type = "image/webp", quality = 0.92, circle } = {}) {
10
+ const img = new Image();
11
+ img.crossOrigin = "anonymous";
12
+ img.src = src;
13
+ await img.decode();
14
+ const rad = (rotation * Math.PI) / 180;
15
+ const side = rotation % 180 !== 0;
16
+ const rw = side ? img.naturalHeight : img.naturalWidth;
17
+ const rh = side ? img.naturalWidth : img.naturalHeight;
18
+ const outW = Math.round(width ?? area.width);
19
+ const outH = Math.round((outW * area.height) / area.width);
20
+ const c = document.createElement("canvas");
21
+ c.width = outW;
22
+ c.height = outH;
23
+ const ctx = c.getContext("2d");
24
+ if (!ctx)
25
+ return null;
26
+ const k = outW / area.width;
27
+ if (circle) {
28
+ ctx.beginPath();
29
+ ctx.ellipse(outW / 2, outH / 2, outW / 2, outH / 2, 0, 0, Math.PI * 2);
30
+ ctx.clip();
31
+ }
32
+ ctx.scale(k, k);
33
+ ctx.translate(-area.x + rw / 2, -area.y + rh / 2);
34
+ ctx.rotate(rad);
35
+ ctx.drawImage(img, -img.naturalWidth / 2, -img.naturalHeight / 2);
36
+ return new Promise((done) => c.toBlob((b) => done(b), type, quality));
37
+ }
38
+ /**
39
+ * برش تصویر برای عکس پروفایل و کاور: تصویر زیر کادر ثابت جابه‌جا و بزرگ می‌شود (کشیدن، چرخ ماوس، دو انگشت یا کیبورد)
40
+ * و همیشه کادر را پر نگه می‌دارد. خروجی با ref.crop() یا تابع cropImage.
41
+ */
42
+ export const ImageCropper = forwardRef(function ImageCropper({ src, alt = "", aspect = 1, shape = "rect", maxZoom = 4, value, defaultValue, onChange, onCropComplete, rotatable = true, label, className }, ref) {
43
+ const { messages: M, n } = useKashi();
44
+ const C = M.cropper;
45
+ const stage = useRef(null);
46
+ const imgRef = useRef(null);
47
+ const [inner, setInner] = useState({ ...START, ...defaultValue });
48
+ const state = value ?? inner;
49
+ // آخرین حالت، تا کلیدها و رویدادهای پشت‌سرهم (پیش از رندر بعدی) روی حالت کهنه حساب نشوند
50
+ const latest = useRef(state);
51
+ latest.current = state;
52
+ const [nat, setNat] = useState(null);
53
+ const [box, setBox] = useState({ w: 0, h: 0 });
54
+ const [live, setLive] = useState("");
55
+ const drag = useRef(null);
56
+ const pinch = useRef(null);
57
+ const pointers = useRef(new Map());
58
+ const useIso = typeof window === "undefined" ? useEffect : useLayoutEffect;
59
+ useIso(() => {
60
+ const el = stage.current;
61
+ if (!el)
62
+ return;
63
+ const read = () => setBox({ w: el.clientWidth, h: el.clientHeight });
64
+ read();
65
+ if (typeof ResizeObserver === "undefined")
66
+ return;
67
+ const ro = new ResizeObserver(read);
68
+ ro.observe(el);
69
+ return () => ro.disconnect();
70
+ }, []);
71
+ // تصویری که پیش از hydrate شدن (یا از حافظهٔ مرورگر) بارگذاری شده، رویداد load را دوباره نمی‌فرستد
72
+ useEffect(() => {
73
+ const img = imgRef.current;
74
+ if (img?.complete && img.naturalWidth)
75
+ setNat({ w: img.naturalWidth, h: img.naturalHeight });
76
+ }, [src]);
77
+ // کادر: بزرگ‌ترین مستطیل با نسبت aspect با ۱۶px فاصله از لبه‌ها
78
+ const pad = 16;
79
+ const fw = Math.max(1, Math.min(box.w - pad * 2, (box.h - pad * 2) * aspect));
80
+ const fh = fw / aspect;
81
+ const side = state.rotation % 180 !== 0;
82
+ const iw = nat ? (side ? nat.h : nat.w) : 1;
83
+ const ih = nat ? (side ? nat.w : nat.h) : 1;
84
+ const base = Math.max(fw / iw, fh / ih);
85
+ const scale = base * state.zoom;
86
+ const clampState = useCallback((s) => {
87
+ const zoom = clampN(s.zoom, 1, maxZoom);
88
+ const sc = base * zoom;
89
+ const mx = Math.max(0, (iw * sc - fw) / 2) / fw;
90
+ const my = Math.max(0, (ih * sc - fh) / 2) / fh;
91
+ return { ...s, zoom, x: clampN(s.x, -mx, mx), y: clampN(s.y, -my, my) };
92
+ }, [base, iw, ih, fw, fh, maxZoom]);
93
+ const area = useCallback((s) => {
94
+ const sc = base * s.zoom;
95
+ return {
96
+ x: Math.max(0, (iw * sc) / 2 - s.x * fw - fw / 2) / sc,
97
+ y: Math.max(0, (ih * sc) / 2 - s.y * fh - fh / 2) / sc,
98
+ width: fw / sc,
99
+ height: fh / sc,
100
+ };
101
+ }, [base, iw, ih, fw, fh]);
102
+ const set = useCallback((next, announce) => {
103
+ const s = clampState(next);
104
+ latest.current = s;
105
+ if (value === undefined)
106
+ setInner(s);
107
+ onChange?.(s);
108
+ if (nat)
109
+ onCropComplete?.(area(s), s);
110
+ if (announce)
111
+ setLive(announce);
112
+ }, [clampState, value, onChange, onCropComplete, area, nat]);
113
+ // وقتی اندازه یا تصویر عوض شد، حالت را دوباره در محدوده بیاور
114
+ useEffect(() => {
115
+ if (nat && box.w)
116
+ set(state);
117
+ // eslint-disable-next-line react-hooks/exhaustive-deps
118
+ }, [nat, box.w, box.h, aspect]);
119
+ useImperativeHandle(ref, () => ({
120
+ crop: (o) => cropImage(src, area(state), state.rotation, { circle: shape === "circle", ...o }),
121
+ reset: () => set(START),
122
+ }));
123
+ const zoomBy = (f) => { const z = latest.current.zoom * f; set({ ...latest.current, zoom: z }, C.zoomed(n(Math.round(clampN(z, 1, maxZoom) * 100)))); };
124
+ const tx = box.w / 2 + state.x * fw - (iw * scale) / 2;
125
+ const ty = box.h / 2 + state.y * fh - (ih * scale) / 2;
126
+ return (_jsxs("div", { className: cx("k-cropper", className), "data-shape": shape, children: [label && _jsx("span", { className: "k-label", children: label }), _jsxs("div", { ref: stage, className: "k-cropper__stage", dir: "ltr", tabIndex: 0, role: "application", "aria-roledescription": C.label, "aria-label": C.area, onPointerDown: (e) => {
127
+ e.currentTarget.setPointerCapture(e.pointerId);
128
+ pointers.current.set(e.pointerId, { x: e.clientX, y: e.clientY });
129
+ if (pointers.current.size === 2) {
130
+ const [a, b] = [...pointers.current.values()];
131
+ pinch.current = { d: Math.hypot(a.x - b.x, a.y - b.y), zoom: latest.current.zoom };
132
+ drag.current = null;
133
+ }
134
+ else
135
+ drag.current = { id: e.pointerId, x: e.clientX, y: e.clientY, start: latest.current };
136
+ }, onPointerMove: (e) => {
137
+ if (!pointers.current.has(e.pointerId))
138
+ return;
139
+ pointers.current.set(e.pointerId, { x: e.clientX, y: e.clientY });
140
+ if (pinch.current && pointers.current.size === 2) {
141
+ const [a, b] = [...pointers.current.values()];
142
+ set({ ...latest.current, zoom: (pinch.current.zoom * Math.hypot(a.x - b.x, a.y - b.y)) / pinch.current.d });
143
+ }
144
+ else if (drag.current?.id === e.pointerId) {
145
+ const d = drag.current;
146
+ set({ ...d.start, x: d.start.x + (e.clientX - d.x) / fw, y: d.start.y + (e.clientY - d.y) / fh });
147
+ }
148
+ }, onPointerUp: (e) => {
149
+ pointers.current.delete(e.pointerId);
150
+ if (pointers.current.size < 2)
151
+ pinch.current = null;
152
+ if (drag.current?.id === e.pointerId)
153
+ drag.current = null;
154
+ }, onPointerCancel: (e) => { pointers.current.delete(e.pointerId); drag.current = null; pinch.current = null; }, onWheel: (e) => {
155
+ if (!e.ctrlKey && Math.abs(e.deltaY) < 1)
156
+ return;
157
+ e.preventDefault();
158
+ set({ ...latest.current, zoom: latest.current.zoom * Math.exp(-e.deltaY / 400) });
159
+ }, onKeyDown: (e) => {
160
+ const step = e.shiftKey ? 0.1 : 0.02;
161
+ const moves = { ArrowLeft: [step, 0], ArrowRight: [-step, 0], ArrowUp: [0, step], ArrowDown: [0, -step] };
162
+ if (moves[e.key]) {
163
+ e.preventDefault();
164
+ const [dx, dy] = moves[e.key];
165
+ const next = clampState({ ...latest.current, x: latest.current.x + dx, y: latest.current.y + dy });
166
+ set(next, C.moved(n(Math.round((0.5 - next.x) * 100)), n(Math.round((0.5 - next.y) * 100))));
167
+ }
168
+ else if (e.key === "+" || e.key === "=") {
169
+ e.preventDefault();
170
+ zoomBy(1.1);
171
+ }
172
+ else if (e.key === "-" || e.key === "_") {
173
+ e.preventDefault();
174
+ zoomBy(1 / 1.1);
175
+ }
176
+ else if (e.key === "0") {
177
+ e.preventDefault();
178
+ set(START, C.reset);
179
+ }
180
+ }, children: [_jsx("img", { ref: imgRef, className: "k-cropper__img", src: src, alt: alt, draggable: false, onLoad: (e) => setNat({ w: e.currentTarget.naturalWidth, h: e.currentTarget.naturalHeight }), style: nat ? {
181
+ inlineSize: (side ? ih : iw) * scale,
182
+ blockSize: (side ? iw : ih) * scale,
183
+ transform: `translate(${tx + (side ? (iw * scale - ih * scale) / 2 : 0)}px, ${ty + (side ? (ih * scale - iw * scale) / 2 : 0)}px) rotate(${state.rotation}deg)`,
184
+ } : { opacity: 0 } }), _jsx("div", { className: "k-cropper__frame", "aria-hidden": "true", style: { inlineSize: fw, blockSize: fh }, children: _jsx("span", { className: "k-cropper__grid" }) })] }), _jsxs("div", { className: "k-cropper__controls", children: [_jsx("button", { type: "button", className: "k-cropper__btn", onClick: () => zoomBy(1 / 1.2), "aria-label": `${C.zoom} −`, disabled: state.zoom <= 1, children: _jsx("svg", { viewBox: "0 0 20 20", "aria-hidden": "true", children: _jsx("path", { d: "M5 10h10", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" }) }) }), _jsx("input", { type: "range", className: "k-slider k-cropper__zoom", min: 1, max: maxZoom, step: 0.01, value: state.zoom, "aria-label": C.zoom, "aria-valuetext": M.common.percent(n(Math.round(state.zoom * 100))), onChange: (e) => set({ ...latest.current, zoom: Number(e.target.value) }) }), _jsx("button", { type: "button", className: "k-cropper__btn", onClick: () => zoomBy(1.2), "aria-label": `${C.zoom} +`, disabled: state.zoom >= maxZoom, children: _jsx("svg", { viewBox: "0 0 20 20", "aria-hidden": "true", children: _jsx("path", { d: "M5 10h10M10 5v10", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" }) }) }), rotatable && (_jsx("button", { type: "button", className: "k-cropper__btn", onClick: () => set({ ...latest.current, rotation: (latest.current.rotation + 90) % 360, x: 0, y: 0 }), "aria-label": C.rotate, title: C.rotate, children: _jsx("svg", { viewBox: "0 0 20 20", "aria-hidden": "true", children: _jsx("path", { d: "M15.5 9A5.5 5.5 0 1 0 14 13.3M15.5 4.5V9H11", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round" }) }) }))] }), _jsx("span", { className: "k-sr-only", "aria-live": "polite", children: live })] }));
185
+ });
@@ -0,0 +1,34 @@
1
+ import { type CSSProperties, type ReactNode } from "react";
2
+ export interface InfiniteScrollProps {
3
+ children: ReactNode;
4
+ /** هنوز موردی برای بارگذاری مانده است */
5
+ hasMore: boolean;
6
+ /** در حال بارگذاری صفحهٔ بعد */
7
+ loading?: boolean;
8
+ /** خطای آخرین بارگذاری؛ دکمهٔ «تلاش دوباره» نشان داده می‌شود */
9
+ error?: ReactNode | boolean;
10
+ /** بارگذاری صفحهٔ بعد؛ وقتی پایین فهرست دیده شود صدا زده می‌شود */
11
+ onLoadMore: () => void;
12
+ /** تعداد موردهای فعلی؛ برای اعلام «n مورد دیگر بارگذاری شد» به صفحه‌خوان */
13
+ itemCount?: number;
14
+ /** «auto» با رسیدن به پایین، «button» با دکمهٔ «نمایش بیشتر» (بهتر برای پاورقی و کیبورد) @default "auto" */
15
+ mode?: "auto" | "button";
16
+ /** فاصلهٔ پیش‌بارگذاری پیش از رسیدن به پایین @default "320px" */
17
+ rootMargin?: string;
18
+ /** ارتفاع بیشینه؛ با آن خود کامپوننت اسکرول می‌خورد (وگرنه صفحه) */
19
+ maxHeight?: string;
20
+ /** متن پایان فهرست؛ null برای پنهان */
21
+ endMessage?: ReactNode;
22
+ /** جای‌نگه‌دار هنگام بارگذاری؛ پیش‌فرض سه اسکلت */
23
+ loader?: ReactNode;
24
+ /** نقش فهرست: "feed" برای خبرخوان (فرزندان باید <article> باشند)؛ پیش‌فرض feed وقتی همهٔ فرزندان article‌اند، وگرنه بدون نقش */
25
+ role?: "feed" | "list" | "none";
26
+ label?: string;
27
+ className?: string;
28
+ style?: CSSProperties;
29
+ }
30
+ /**
31
+ * بارگذاری پیوسته: با رسیدن به پایین (IntersectionObserver) صفحهٔ بعد را می‌خواهد، یا با دکمهٔ «نمایش بیشتر».
32
+ * aria-busy و اعلام تعداد موردهای تازه برای صفحه‌خوان، خطا با «تلاش دوباره»، و پیام پایان.
33
+ */
34
+ export declare function InfiniteScroll({ children, hasMore, loading, error, onLoadMore, itemCount, mode, rootMargin, maxHeight, endMessage, loader, role: roleProp, label, className, style, }: InfiniteScrollProps): import("react").JSX.Element;
@@ -0,0 +1,44 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Children, isValidElement, useEffect, useRef, useState } from "react";
4
+ import { cx } from "./cx.js";
5
+ import { useKashi } from "./KashiProvider.js";
6
+ /**
7
+ * بارگذاری پیوسته: با رسیدن به پایین (IntersectionObserver) صفحهٔ بعد را می‌خواهد، یا با دکمهٔ «نمایش بیشتر».
8
+ * aria-busy و اعلام تعداد موردهای تازه برای صفحه‌خوان، خطا با «تلاش دوباره»، و پیام پایان.
9
+ */
10
+ export function InfiniteScroll({ children, hasMore, loading, error, onLoadMore, itemCount, mode = "auto", rootMargin = "320px", maxHeight, endMessage, loader, role: roleProp, label, className, style, }) {
11
+ const kids = Children.toArray(children);
12
+ const role = roleProp ?? (kids.length > 0 && kids.every((c) => isValidElement(c) && c.type === "article") ? "feed" : "none");
13
+ const { messages: M, n } = useKashi();
14
+ const L = M.infinite;
15
+ const root = useRef(null);
16
+ const sentinel = useRef(null);
17
+ const prevCount = useRef(itemCount);
18
+ const [live, setLive] = useState("");
19
+ const call = useRef(onLoadMore);
20
+ call.current = onLoadMore;
21
+ const blocked = !hasMore || loading || !!error;
22
+ useEffect(() => {
23
+ if (mode !== "auto" || blocked || typeof IntersectionObserver === "undefined")
24
+ return;
25
+ const el = sentinel.current;
26
+ if (!el)
27
+ return;
28
+ const io = new IntersectionObserver((entries) => {
29
+ if (entries.some((e) => e.isIntersecting))
30
+ call.current();
31
+ }, { root: maxHeight ? root.current : null, rootMargin });
32
+ io.observe(el);
33
+ return () => io.disconnect();
34
+ }, [mode, blocked, rootMargin, maxHeight]);
35
+ useEffect(() => {
36
+ if (itemCount === undefined)
37
+ return;
38
+ const before = prevCount.current ?? 0;
39
+ if (itemCount > before && before > 0)
40
+ setLive(L.loaded(n(itemCount - before)));
41
+ prevCount.current = itemCount;
42
+ }, [itemCount]);
43
+ return (_jsxs("div", { ref: root, className: cx("k-infinite", maxHeight && "k-infinite--scroll", className), style: maxHeight ? { maxBlockSize: maxHeight, ...style } : style, tabIndex: maxHeight ? 0 : undefined, role: maxHeight ? "region" : undefined, "aria-label": maxHeight ? label : undefined, children: [_jsx("div", { className: "k-infinite__items", role: role === "none" ? undefined : role, "aria-label": role === "none" ? undefined : label, "aria-busy": loading || undefined, children: children }), loading && (loader ?? (_jsx("div", { className: "k-infinite__loader", "aria-hidden": "true", children: [0, 1, 2].map((i) => _jsx("span", { className: "k-skeleton k-infinite__sk" }, i)) }))), loading && _jsx("span", { className: "k-sr-only", role: "status", children: L.loading }), error && !loading && (_jsxs("div", { className: "k-infinite__error", role: "alert", children: [_jsx("span", { children: error === true ? L.error : error }), _jsx("button", { type: "button", className: "k-btn k-btn--secondary k-btn--sm", onClick: () => call.current(), children: L.retry })] })), hasMore && !loading && !error && mode === "button" && (_jsx("div", { className: "k-infinite__more", children: _jsx("button", { type: "button", className: "k-btn k-btn--secondary", onClick: () => call.current(), children: L.loadMore }) })), !hasMore && !loading && endMessage !== null && _jsx("p", { className: "k-infinite__end", children: endMessage ?? L.end }), _jsx("div", { ref: sentinel, className: "k-infinite__sentinel", "aria-hidden": "true" }), _jsx("span", { className: "k-sr-only", "aria-live": "polite", children: live })] }));
44
+ }
@@ -0,0 +1,65 @@
1
+ import { type ReactNode } from "react";
2
+ export interface InvoiceParty {
3
+ name: string;
4
+ /** کد اقتصادی (۱۰، ۱۱ یا ۱۲ رقم) */
5
+ economicCode?: string;
6
+ /** شناسهٔ ملی شرکت یا کد ملی شخص */
7
+ nationalId?: string;
8
+ postalCode?: string;
9
+ phone?: string;
10
+ address?: string;
11
+ }
12
+ export interface InvoiceItem {
13
+ description: ReactNode;
14
+ /** شناسهٔ کالا یا خدمت در سامانهٔ مؤدیان (اختیاری) */
15
+ code?: string;
16
+ quantity: number;
17
+ /** واحد شمارش، مثل «عدد» یا «ساعت» */
18
+ unit?: string;
19
+ /** مبلغ واحد به واحد پول فاکتور */
20
+ unitPrice: number;
21
+ /** تخفیف این ردیف (مبلغ) */
22
+ discount?: number;
23
+ }
24
+ export interface InvoiceTotals {
25
+ subtotal: number;
26
+ discount: number;
27
+ /** جمع پس از تخفیف (پایهٔ مالیات) */
28
+ taxable: number;
29
+ vat: number;
30
+ payable: number;
31
+ }
32
+ /** جمع‌های فاکتور: جمع ردیف‌ها، تخفیف، پایهٔ مالیات، مالیات بر ارزش افزوده (گرد به نزدیک‌ترین واحد) و مبلغ قابل پرداخت */
33
+ export declare function invoiceTotals(items: InvoiceItem[], vatRate?: number): InvoiceTotals;
34
+ export interface InvoiceProps {
35
+ /** «official» صورتحساب فروش (الگوی سامانهٔ مؤدیان) یا «proforma» پیش‌فاکتور @default "official" */
36
+ variant?: "official" | "proforma";
37
+ number: string;
38
+ date: Date;
39
+ /** فقط برای پیش‌فاکتور: تاریخ پایان اعتبار */
40
+ validUntil?: Date;
41
+ /** شمارهٔ مالیاتی ۲۲ نویسه‌ای که سامانهٔ مؤدیان می‌دهد */
42
+ taxId?: string;
43
+ seller: InvoiceParty;
44
+ buyer: InvoiceParty;
45
+ items: InvoiceItem[];
46
+ /** نرخ مالیات و عوارض ارزش افزوده به درصد؛ نرخ سال جاری را خودتان بدهید @default 10 */
47
+ vatRate?: number;
48
+ /** واحد پول همهٔ مبلغ‌ها @default "rial" */
49
+ currency?: "rial" | "toman";
50
+ notes?: ReactNode;
51
+ /** لوگو یا مهر فروشنده بالای فاکتور */
52
+ logo?: ReactNode;
53
+ /** جای مهر و امضا @default true */
54
+ signatures?: boolean;
55
+ /** دکمهٔ «چاپ یا ذخیرهٔ PDF» (در چاپ دیده نمی‌شود) @default true */
56
+ printButton?: boolean;
57
+ /** محتوای اضافه پایین فاکتور، مثل QR پرداخت */
58
+ footer?: ReactNode;
59
+ className?: string;
60
+ }
61
+ /**
62
+ * صورتحساب رسمی و پیش‌فاکتور: مشخصات فروشنده و خریدار با کد اقتصادی، ردیف‌ها با تخفیف، مالیات بر ارزش افزوده،
63
+ * مبلغ به حروف و جای مهر و امضا. برای چاپ و PDF آماده است (‎@media print‎): «چاپ» مرورگر و «ذخیره به PDF».
64
+ */
65
+ export declare function Invoice({ variant, number, date, validUntil, taxId, seller, buyer, items, vatRate, currency, notes, logo, signatures, printButton, footer, className, }: InvoiceProps): import("react").JSX.Element;
@@ -0,0 +1,30 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useId } from "react";
4
+ import { formatJalali, formatNumber, numberToWords } from "@kashi-ui/persian";
5
+ import { cx } from "./cx.js";
6
+ import { useKashi } from "./KashiProvider.js";
7
+ /** جمع‌های فاکتور: جمع ردیف‌ها، تخفیف، پایهٔ مالیات، مالیات بر ارزش افزوده (گرد به نزدیک‌ترین واحد) و مبلغ قابل پرداخت */
8
+ export function invoiceTotals(items, vatRate = 10) {
9
+ const subtotal = items.reduce((s, i) => s + i.quantity * i.unitPrice, 0);
10
+ const discount = items.reduce((s, i) => s + (i.discount ?? 0), 0);
11
+ const taxable = subtotal - discount;
12
+ const vat = Math.round((taxable * vatRate) / 100);
13
+ return { subtotal, discount, taxable, vat, payable: taxable + vat };
14
+ }
15
+ /**
16
+ * صورتحساب رسمی و پیش‌فاکتور: مشخصات فروشنده و خریدار با کد اقتصادی، ردیف‌ها با تخفیف، مالیات بر ارزش افزوده،
17
+ * مبلغ به حروف و جای مهر و امضا. برای چاپ و PDF آماده است (‎@media print‎): «چاپ» مرورگر و «ذخیره به PDF».
18
+ */
19
+ export function Invoice({ variant = "official", number, date, validUntil, taxId, seller, buyer, items, vatRate = 10, currency = "rial", notes, logo, signatures = true, printButton = true, footer, className, }) {
20
+ const { messages: M, locale, digits, n } = useKashi();
21
+ const I = M.invoice;
22
+ const t = invoiceTotals(items, vatRate);
23
+ const money = (v) => formatNumber(v, { digits });
24
+ const dateText = (d) => formatJalali(d, { locale, digits });
25
+ const unitName = currency === "rial" ? I.rial : I.toman;
26
+ const hasDiscount = items.some((i) => i.discount);
27
+ const titleId = useId();
28
+ const party = (title, p) => (_jsxs("section", { className: "k-invoice__party", "aria-label": title, children: [_jsx("h3", { className: "k-invoice__party-title", children: title }), _jsxs("dl", { className: "k-invoice__dl", children: [_jsxs("div", { children: [_jsx("dt", { children: I.name }), _jsx("dd", { children: p.name })] }), p.economicCode && _jsxs("div", { children: [_jsx("dt", { children: I.economicCode }), _jsx("dd", { className: "k-invoice__num", children: n(p.economicCode) })] }), p.nationalId && _jsxs("div", { children: [_jsx("dt", { children: I.nationalId }), _jsx("dd", { className: "k-invoice__num", children: n(p.nationalId) })] }), p.postalCode && _jsxs("div", { children: [_jsx("dt", { children: I.postal }), _jsx("dd", { className: "k-invoice__num", children: n(p.postalCode) })] }), p.phone && _jsxs("div", { children: [_jsx("dt", { children: I.phone }), _jsx("dd", { className: "k-invoice__num", children: n(p.phone) })] }), p.address && _jsxs("div", { className: "k-invoice__wide", children: [_jsx("dt", { children: I.address }), _jsx("dd", { children: p.address })] })] })] }));
29
+ return (_jsxs("article", { className: cx("k-invoice", className), "data-variant": variant, "aria-labelledby": titleId, children: [_jsxs("header", { className: "k-invoice__head", children: [logo && _jsx("div", { className: "k-invoice__logo", children: logo }), _jsx("h2", { className: "k-invoice__title", id: titleId, children: variant === "proforma" ? I.proforma : I.official }), _jsxs("dl", { className: "k-invoice__meta", children: [_jsxs("div", { children: [_jsx("dt", { children: I.number }), _jsx("dd", { children: n(number) })] }), _jsxs("div", { children: [_jsx("dt", { children: I.date }), _jsx("dd", { children: dateText(date) })] }), variant === "proforma" && validUntil && _jsxs("div", { children: [_jsx("dt", { children: I.validUntil }), _jsx("dd", { children: dateText(validUntil) })] }), taxId && _jsxs("div", { children: [_jsx("dt", { children: I.taxId }), _jsx("dd", { dir: "ltr", className: "k-invoice__mono", children: taxId })] })] })] }), _jsxs("div", { className: "k-invoice__parties", children: [party(I.seller, seller), party(I.buyer, buyer)] }), _jsx("div", { className: "k-invoice__table-wrap", role: "region", tabIndex: 0, "aria-label": I.description, children: _jsxs("table", { className: "k-invoice__table", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { scope: "col", className: "k-invoice__num-col", children: I.row }), _jsx("th", { scope: "col", children: I.description }), _jsx("th", { scope: "col", className: "k-invoice__n", children: I.quantity }), _jsx("th", { scope: "col", className: "k-invoice__n", children: I.unitPrice }), hasDiscount && _jsx("th", { scope: "col", className: "k-invoice__n", children: I.discount }), _jsx("th", { scope: "col", className: "k-invoice__n", children: I.lineTotal })] }) }), _jsx("tbody", { children: items.map((it, i) => (_jsxs("tr", { children: [_jsx("td", { className: "k-invoice__num-col", children: n(i + 1) }), _jsxs("td", { children: [it.description, it.code && _jsx("span", { className: "k-invoice__code", dir: "ltr", children: n(it.code) })] }), _jsxs("td", { className: "k-invoice__n", children: [money(it.quantity), it.unit && _jsxs("span", { className: "k-invoice__unit", children: [" ", it.unit] })] }), _jsx("td", { className: "k-invoice__n", children: money(it.unitPrice) }), hasDiscount && _jsx("td", { className: "k-invoice__n", children: it.discount ? money(it.discount) : "—" }), _jsx("td", { className: "k-invoice__n", children: money(it.quantity * it.unitPrice - (it.discount ?? 0)) })] }, i))) })] }) }), _jsxs("div", { className: "k-invoice__summary", children: [_jsxs("dl", { className: "k-invoice__totals", children: [_jsxs("div", { children: [_jsx("dt", { children: I.subtotal }), _jsx("dd", { children: money(t.subtotal) })] }), t.discount > 0 && _jsxs("div", { children: [_jsx("dt", { children: I.totalDiscount }), _jsx("dd", { children: money(t.discount) })] }), _jsxs("div", { children: [_jsx("dt", { children: I.vat(n(vatRate)) }), _jsx("dd", { children: money(t.vat) })] }), _jsxs("div", { className: "k-invoice__payable", children: [_jsx("dt", { children: I.payable }), _jsxs("dd", { children: [money(t.payable), " ", _jsx("span", { className: "k-invoice__cur", children: unitName })] })] })] }), _jsx("p", { className: "k-invoice__words", children: I.inWords(numberToWords(t.payable, { locale }), unitName) })] }), notes && _jsxs("section", { className: "k-invoice__notes", children: [_jsx("h3", { className: "k-invoice__party-title", children: I.notes }), _jsx("div", { children: notes })] }), signatures && (_jsxs("div", { className: "k-invoice__signs", children: [_jsx("div", { className: "k-invoice__sign", children: I.sellerSign }), _jsx("div", { className: "k-invoice__sign", children: I.buyerSign })] })), footer && _jsx("footer", { className: "k-invoice__footer", children: footer }), printButton && (_jsxs("button", { type: "button", className: "k-btn k-btn--secondary k-btn--sm k-invoice__print", onClick: () => window.print(), children: [_jsx("svg", { viewBox: "0 0 20 20", "aria-hidden": "true", width: "16", height: "16", children: _jsx("path", { d: "M5.5 7.5V3h9v4.5M5.5 14H4a1.5 1.5 0 0 1-1.5-1.5v-3.5A1.5 1.5 0 0 1 4 7.5h12a1.5 1.5 0 0 1 1.5 1.5v3.5A1.5 1.5 0 0 1 16 14h-1.5M5.5 11.5h9V17h-9z", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinejoin: "round" }) }), I.print] }))] }));
30
+ }
package/dist/Meter.js CHANGED
@@ -13,5 +13,5 @@ export function Meter({ label, value, max = 100, warning = max * 0.8, critical =
13
13
  const status = v >= critical ? "critical" : v >= warning ? "warning" : "ok";
14
14
  const pct = Math.round((v / max) * 100);
15
15
  const text = { ok, warning: warnText, critical: critText }[status];
16
- return (_jsxs("div", { className: cx("k-meter", className), "data-status": status, children: [_jsxs("div", { className: "k-meter__head", children: [_jsx("span", { className: "k-meter__label", children: label }), _jsxs("span", { className: "k-meter__value", children: [format(v), " ", _jsxs("span", { children: [of, " ", format(max)] })] })] }), _jsxs("div", { className: "k-meter__track", role: "meter", "aria-valuenow": v, "aria-valuemin": 0, "aria-valuemax": max, "aria-valuetext": `${of ? `${format(v)} ${of} ${format(max)}` : M.common.of(format(v), format(max))}${M.common.list}${M.common.percent(n(pct))}${M.common.list}${text}`, "aria-label": typeof label === "string" ? label : undefined, children: [_jsx("span", { className: "k-meter__fill", style: { inlineSize: `${pct}%` } }), _jsx("span", { className: "k-meter__mark", style: { insetInlineStart: `${(warning / max) * 100}%` }, "aria-hidden": "true" })] }), _jsxs("p", { className: "k-meter__status", "aria-hidden": "true", children: [_jsx(Icon, { d: status === "ok" ? "m5 10.5 3.2 3L15 7" : "M10 3 2.5 16.5h15ZM10 8v4M10 14.5h.01" }), text, " \u00B7 ", M.common.percent(n(pct))] })] }));
16
+ return (_jsxs("div", { className: cx("k-meter", className), "data-status": status, children: [_jsxs("div", { className: "k-meter__head", children: [_jsx("span", { className: "k-meter__label", children: label }), _jsxs("span", { className: "k-meter__value", children: [format(v), " ", _jsx("span", { children: of !== undefined ? `${of} ${format(max)}` : M.common.of("", format(max)).trim() })] })] }), _jsxs("div", { className: "k-meter__track", role: "meter", "aria-valuenow": v, "aria-valuemin": 0, "aria-valuemax": max, "aria-valuetext": `${of ? `${format(v)} ${of} ${format(max)}` : M.common.of(format(v), format(max))}${M.common.list}${M.common.percent(n(pct))}${M.common.list}${text}`, "aria-label": typeof label === "string" ? label : undefined, children: [_jsx("span", { className: "k-meter__fill", style: { inlineSize: `${pct}%` } }), _jsx("span", { className: "k-meter__mark", style: { insetInlineStart: `${(warning / max) * 100}%` }, "aria-hidden": "true" })] }), _jsxs("p", { className: "k-meter__status", "aria-hidden": "true", children: [_jsx(Icon, { d: status === "ok" ? "m5 10.5 3.2 3L15 7" : "M10 3 2.5 16.5h15ZM10 8v4M10 14.5h.01" }), text, " \u00B7 ", M.common.percent(n(pct))] })] }));
17
17
  }
@@ -25,7 +25,7 @@ export function NotificationList({ items, onRead, onReadAll, onSelect, onSetting
25
25
  groups[d >= today ? 0 : d >= today - 86400000 ? 1 : 2][1].push(it);
26
26
  }
27
27
  return (_jsxs("div", { className: cx("k-notif", className), children: [_jsxs("div", { className: "k-notif__head", children: [_jsx("h2", { className: "k-notif__title", children: title ?? N.label }), onReadAll && unread > 0 && (_jsxs("button", { type: "button", className: "k-notif__link", onClick: onReadAll, children: [_jsx(CheckAll, {}), N.markAll] })), onSettings && _jsx("button", { type: "button", className: "k-notif__icon", "aria-label": N.settings, onClick: onSettings, children: _jsx(Gear, {}) })] }), _jsx("div", { className: "k-notif__tabs", role: "group", children: ["all", "unread"].map((t) => (_jsxs("button", { type: "button", className: "k-notif__tab", "aria-pressed": tab === t, onClick: () => setTab(t), children: [N[t], t === "unread" && unread > 0 && _jsx("span", { className: "k-notif__count", children: n(unread) })] }, t))) }), list.length === 0 ? (_jsxs("div", { className: "k-notif__empty", children: [_jsx("span", { className: "k-notif__empty-icon", children: _jsx(Bell, {}) }), _jsx("p", { children: tab === "unread" ? N.emptyUnread : N.empty })] })) : (_jsx("div", { className: "k-notif__scroll", tabIndex: -1, children: groups.filter(([, g]) => g.length).map(([name, g]) => (_jsxs("section", { className: "k-notif__group", "aria-label": name, children: [_jsx("h3", { className: "k-notif__group-title", children: name }), _jsx("ul", { className: "k-notif__list", children: g.map((it) => {
28
- const inner = (_jsxs(_Fragment, { children: [it.icon && _jsx("span", { className: "k-notif__media", "data-tone": it.tone, children: it.icon }), _jsxs("span", { className: "k-notif__text", children: [_jsx("span", { className: "k-notif__item-title", children: it.title }), it.body && _jsx("span", { className: "k-notif__body", children: it.body }), _jsx("time", { className: "k-notif__time", dateTime: it.time.toISOString(), children: formatRelative(it.time, { now: ref, locale, digits }) })] })] }));
28
+ const inner = (_jsxs(_Fragment, { children: [it.icon && _jsx("span", { className: "k-notif__media", "data-tone": it.tone, children: it.icon }), _jsxs("span", { className: "k-notif__text", children: [_jsx("span", { className: "k-notif__item-title", children: it.title }), !it.read && _jsxs("span", { className: "k-sr-only", children: [" ", N.unreadDot] }), it.body && _jsx("span", { className: "k-notif__body", children: it.body }), _jsx("time", { className: "k-notif__time", dateTime: it.time.toISOString(), children: formatRelative(it.time, { now: ref, locale, digits }) })] })] }));
29
29
  const select = () => {
30
30
  if (!it.read)
31
31
  onRead?.(it.id);
@@ -8,6 +8,7 @@ import { type NationalIdInputProps } from "./NationalIdInput.js";
8
8
  import { type PostalCodeInputProps } from "./PostalCodeInput.js";
9
9
  import { type PlateInputProps } from "./PlateInput.js";
10
10
  import { type SayadInputProps } from "./SayadInput.js";
11
+ import { type BillIdInputProps, type PaymentIdInputProps } from "./BillInput.js";
11
12
  import { type EconomicCodeInputProps } from "./EconomicCodeInput.js";
12
13
  import { type TaxIdInputProps } from "./TaxIdInput.js";
13
14
  import { type PriceInputProps } from "./PriceInput.js";
@@ -26,6 +27,8 @@ export interface PersianInputKinds {
26
27
  time: TimeInputProps;
27
28
  plate: PlateInputProps;
28
29
  sayad: SayadInputProps;
30
+ "bill-id": BillIdInputProps;
31
+ "payment-id": PaymentIdInputProps;
29
32
  "economic-code": EconomicCodeInputProps;
30
33
  "tax-id": TaxIdInputProps;
31
34
  }
@@ -11,6 +11,7 @@ import { NationalIdInput } from "./NationalIdInput.js";
11
11
  import { PostalCodeInput } from "./PostalCodeInput.js";
12
12
  import { PlateInput } from "./PlateInput.js";
13
13
  import { SayadInput } from "./SayadInput.js";
14
+ import { BillIdInput, PaymentIdInput } from "./BillInput.js";
14
15
  import { EconomicCodeInput } from "./EconomicCodeInput.js";
15
16
  import { TaxIdInput } from "./TaxIdInput.js";
16
17
  import { PriceInput } from "./PriceInput.js";
@@ -32,6 +33,8 @@ export const PERSIAN_INPUT_LABELS = {
32
33
  sayad: "شناسهٔ صیادی چک",
33
34
  "economic-code": "کد اقتصادی",
34
35
  "tax-id": "شمارهٔ مالیاتی فاکتور",
36
+ "bill-id": "شناسهٔ قبض",
37
+ "payment-id": "شناسهٔ پرداخت",
35
38
  };
36
39
  const COMPONENTS = {
37
40
  text: KeyboardFixInput,
@@ -48,6 +51,8 @@ const COMPONENTS = {
48
51
  sayad: SayadInput,
49
52
  "economic-code": EconomicCodeInput,
50
53
  "tax-id": TaxIdInput,
54
+ "bill-id": BillIdInput,
55
+ "payment-id": PaymentIdInput,
51
56
  };
52
57
  /**
53
58
  * یک فیلد برای همهٔ داده‌های فارسی (کد ملی، شبا، کارت، مبلغ، کد پستی، ساعت، پلاک و…): نوع را با kind انتخاب کنید و بقیهٔ ویژگی‌ها همان کامپوننت تخصصی است.