@kashi-ui/react 2.24.1 → 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/README.md +1 -1
- package/dist/BillInput.d.ts +39 -0
- package/dist/BillInput.js +54 -0
- package/dist/Combobox.d.ts +4 -0
- package/dist/Combobox.js +7 -4
- package/dist/DataTable.d.ts +19 -1
- package/dist/DataTable.js +106 -7
- package/dist/DateRangePicker.d.ts +19 -1
- package/dist/DateRangePicker.js +25 -4
- package/dist/Gantt.d.ts +42 -0
- package/dist/Gantt.js +116 -0
- package/dist/ImageCropper.d.ts +56 -0
- package/dist/ImageCropper.js +185 -0
- package/dist/InfiniteScroll.d.ts +34 -0
- package/dist/InfiniteScroll.js +44 -0
- package/dist/Invoice.d.ts +65 -0
- package/dist/Invoice.js +30 -0
- package/dist/PersianInput.d.ts +3 -0
- package/dist/PersianInput.js +5 -0
- package/dist/SearchSuggest.js +3 -2
- package/dist/SignaturePad.d.ts +38 -0
- package/dist/SignaturePad.js +169 -0
- package/dist/VirtualList.d.ts +35 -0
- package/dist/VirtualList.js +102 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +9 -0
- package/dist/xlsx.d.ts +5 -0
- package/dist/xlsx.js +14 -0
- package/package.json +4 -4
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef, useCallback, useEffect, useId, useImperativeHandle, useRef, useState } from "react";
|
|
4
|
+
import { cx } from "./cx.js";
|
|
5
|
+
import { useKashi } from "./KashiProvider.js";
|
|
6
|
+
const dist = (a, b) => Math.hypot(a[0] - b[0], a[1] - b[1]);
|
|
7
|
+
/**
|
|
8
|
+
* کادر امضا با ماوس، قلم و لمس: خطها نرم (منحنی درجهٔ دو) و پهنایشان با فشار و سرعت قلم تغییر میکند.
|
|
9
|
+
* برگرداندن آخرین خط، پاک کردن، و حالت «تایپ امضا» برای کسی که نمیتواند رسم کند.
|
|
10
|
+
*/
|
|
11
|
+
export const SignaturePad = forwardRef(function SignaturePad({ label, hint, error, onChange, defaultStrokes = [], name, required, disabled, readOnly, allowTyped = true, penWidth = 2.5, exportColor = "#0b0c0f", id, className }, ref) {
|
|
12
|
+
const { messages: M } = useKashi();
|
|
13
|
+
const S = M.signature;
|
|
14
|
+
const autoId = useId();
|
|
15
|
+
const fieldId = id ?? autoId;
|
|
16
|
+
const canvas = useRef(null);
|
|
17
|
+
const strokes = useRef(defaultStrokes);
|
|
18
|
+
const current = useRef(null);
|
|
19
|
+
const [count, setCount] = useState(defaultStrokes.length);
|
|
20
|
+
const [mode, setMode] = useState("draw");
|
|
21
|
+
const [typed, setTyped] = useState("");
|
|
22
|
+
const [data, setData] = useState(null);
|
|
23
|
+
const [live, setLive] = useState("");
|
|
24
|
+
const locked = disabled || readOnly;
|
|
25
|
+
const paint = useCallback((ctx, w, h, list, color, scale = 1) => {
|
|
26
|
+
ctx.clearRect(0, 0, w, h);
|
|
27
|
+
ctx.strokeStyle = color;
|
|
28
|
+
ctx.fillStyle = color;
|
|
29
|
+
ctx.lineCap = "round";
|
|
30
|
+
ctx.lineJoin = "round";
|
|
31
|
+
for (const s of list) {
|
|
32
|
+
if (s.length === 1) {
|
|
33
|
+
ctx.beginPath();
|
|
34
|
+
ctx.arc(s[0][0] * w, s[0][1] * h, (penWidth * scale * (0.6 + s[0][2])) / 2, 0, Math.PI * 2);
|
|
35
|
+
ctx.fill();
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
for (let i = 1; i < s.length; i++) {
|
|
39
|
+
const p0 = s[i - 1], p1 = s[i];
|
|
40
|
+
const m0 = i > 1 ? [(s[i - 2][0] + p0[0]) / 2, (s[i - 2][1] + p0[1]) / 2] : p0;
|
|
41
|
+
const m1 = [(p0[0] + p1[0]) / 2, (p0[1] + p1[1]) / 2];
|
|
42
|
+
ctx.lineWidth = penWidth * scale * (0.6 + (p0[2] + p1[2]) / 2);
|
|
43
|
+
ctx.beginPath();
|
|
44
|
+
ctx.moveTo(m0[0] * w, m0[1] * h);
|
|
45
|
+
ctx.quadraticCurveTo(p0[0] * w, p0[1] * h, m1[0] * w, m1[1] * h);
|
|
46
|
+
if (i === s.length - 1)
|
|
47
|
+
ctx.lineTo(p1[0] * w, p1[1] * h);
|
|
48
|
+
ctx.stroke();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}, [penWidth]);
|
|
52
|
+
const redraw = useCallback(() => {
|
|
53
|
+
const c = canvas.current;
|
|
54
|
+
if (!c)
|
|
55
|
+
return;
|
|
56
|
+
const r = c.getBoundingClientRect();
|
|
57
|
+
const dpr = window.devicePixelRatio || 1;
|
|
58
|
+
if (c.width !== Math.round(r.width * dpr) || c.height !== Math.round(r.height * dpr)) {
|
|
59
|
+
c.width = Math.round(r.width * dpr);
|
|
60
|
+
c.height = Math.round(r.height * dpr);
|
|
61
|
+
}
|
|
62
|
+
const ctx = c.getContext("2d");
|
|
63
|
+
if (!ctx)
|
|
64
|
+
return;
|
|
65
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
66
|
+
paint(ctx, c.width, c.height, current.current ? [...strokes.current, current.current] : strokes.current, getComputedStyle(c).color, dpr);
|
|
67
|
+
}, [paint]);
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
redraw();
|
|
70
|
+
const c = canvas.current;
|
|
71
|
+
if (!c || typeof ResizeObserver === "undefined")
|
|
72
|
+
return;
|
|
73
|
+
const ro = new ResizeObserver(() => redraw());
|
|
74
|
+
ro.observe(c);
|
|
75
|
+
// رنگ جوهر از تم میآید؛ با عوض شدن تم دوباره بکش
|
|
76
|
+
const mq = window.matchMedia?.("(prefers-color-scheme: dark)");
|
|
77
|
+
mq?.addEventListener?.("change", redraw);
|
|
78
|
+
return () => { ro.disconnect(); mq?.removeEventListener?.("change", redraw); };
|
|
79
|
+
}, [redraw, mode]);
|
|
80
|
+
const exportImage = useCallback((type = "image/png") => {
|
|
81
|
+
const c = canvas.current;
|
|
82
|
+
if (typeof document === "undefined")
|
|
83
|
+
return null;
|
|
84
|
+
const w = c?.width || 600, h = c?.height || 200;
|
|
85
|
+
const out = document.createElement("canvas");
|
|
86
|
+
out.width = w;
|
|
87
|
+
out.height = h;
|
|
88
|
+
const ctx = out.getContext("2d");
|
|
89
|
+
if (!ctx)
|
|
90
|
+
return null;
|
|
91
|
+
if (mode === "type") {
|
|
92
|
+
if (!typed.trim())
|
|
93
|
+
return null;
|
|
94
|
+
ctx.fillStyle = exportColor;
|
|
95
|
+
ctx.textAlign = "center";
|
|
96
|
+
ctx.textBaseline = "middle";
|
|
97
|
+
const family = getComputedStyle(c ?? document.body).getPropertyValue("--k-font-display") || "sans-serif";
|
|
98
|
+
ctx.font = `700 ${Math.round(h * 0.34)}px ${family}`;
|
|
99
|
+
ctx.direction = "rtl";
|
|
100
|
+
ctx.fillText(typed.trim(), w / 2, h / 2, w * 0.9);
|
|
101
|
+
return out.toDataURL(type);
|
|
102
|
+
}
|
|
103
|
+
if (!strokes.current.length)
|
|
104
|
+
return null;
|
|
105
|
+
paint(ctx, w, h, strokes.current, exportColor, w / (c?.getBoundingClientRect().width || w));
|
|
106
|
+
return out.toDataURL(type);
|
|
107
|
+
}, [mode, typed, exportColor, paint]);
|
|
108
|
+
const commit = useCallback((announce) => {
|
|
109
|
+
const url = exportImage();
|
|
110
|
+
setData(url);
|
|
111
|
+
setCount(strokes.current.length);
|
|
112
|
+
onChange?.(url);
|
|
113
|
+
if (announce)
|
|
114
|
+
setLive(announce);
|
|
115
|
+
}, [exportImage, onChange]);
|
|
116
|
+
useEffect(() => {
|
|
117
|
+
if (mode === "type")
|
|
118
|
+
commit();
|
|
119
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
120
|
+
}, [typed, mode]);
|
|
121
|
+
const clear = () => { strokes.current = []; current.current = null; setTyped(""); redraw(); commit(S.cleared); };
|
|
122
|
+
const undo = () => { strokes.current = strokes.current.slice(0, -1); redraw(); commit(); };
|
|
123
|
+
useImperativeHandle(ref, () => ({
|
|
124
|
+
clear, undo,
|
|
125
|
+
isEmpty: () => (mode === "type" ? !typed.trim() : strokes.current.length === 0),
|
|
126
|
+
toDataURL: exportImage,
|
|
127
|
+
strokes: () => strokes.current,
|
|
128
|
+
}));
|
|
129
|
+
const point = (e) => {
|
|
130
|
+
const r = e.currentTarget.getBoundingClientRect();
|
|
131
|
+
const pressure = e.pointerType === "pen" && e.pressure > 0 ? e.pressure : 0.5;
|
|
132
|
+
return [(e.clientX - r.left) / r.width, (e.clientY - r.top) / r.height, pressure];
|
|
133
|
+
};
|
|
134
|
+
const empty = mode === "type" ? !typed.trim() : count === 0;
|
|
135
|
+
const hintId = `${fieldId}-hint`;
|
|
136
|
+
const errId = `${fieldId}-err`;
|
|
137
|
+
return (_jsxs("div", { className: cx("k-field k-signature", className), "data-disabled": disabled || undefined, "data-empty": empty || undefined, "data-invalid": error ? "" : undefined, children: [label && _jsxs("span", { className: "k-label", id: `${fieldId}-label`, children: [label, required && _jsx("span", { className: "k-label__required", "aria-hidden": "true", children: "*" })] }), allowTyped && !locked && (_jsx("div", { className: "k-signature__modes", role: "radiogroup", "aria-label": typeof label === "string" ? label : S.label, children: ["draw", "type"].map((m) => (_jsx("button", { type: "button", role: "radio", "aria-checked": mode === m, className: "k-signature__mode", onClick: () => setMode(m), children: S[m] }, m))) })), _jsxs("div", { className: "k-signature__pad", children: [mode === "draw" ? (_jsx("canvas", { ref: canvas, className: "k-signature__canvas", role: "img", "aria-label": `${S.area}${empty ? `${M.common.comma}${S.empty}` : ""}`, "aria-describedby": [hint || !locked ? hintId : "", error ? errId : ""].filter(Boolean).join(" ") || undefined, onPointerDown: (e) => {
|
|
138
|
+
if (locked || (e.pointerType === "mouse" && e.button !== 0))
|
|
139
|
+
return;
|
|
140
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
141
|
+
current.current = [point(e)];
|
|
142
|
+
redraw();
|
|
143
|
+
}, onPointerMove: (e) => {
|
|
144
|
+
const s = current.current;
|
|
145
|
+
if (!s)
|
|
146
|
+
return;
|
|
147
|
+
const coalesced = e.nativeEvent.getCoalescedEvents?.();
|
|
148
|
+
const events = coalesced && coalesced.length ? coalesced : [e.nativeEvent];
|
|
149
|
+
const r = e.currentTarget.getBoundingClientRect();
|
|
150
|
+
for (const ev of events) {
|
|
151
|
+
const p = [(ev.clientX - r.left) / r.width, (ev.clientY - r.top) / r.height, ev.pointerType === "pen" && ev.pressure > 0 ? ev.pressure : 0.5];
|
|
152
|
+
const last = s[s.length - 1];
|
|
153
|
+
const d = dist(last, p) * r.width;
|
|
154
|
+
if (d < 1.2)
|
|
155
|
+
continue;
|
|
156
|
+
// قلم بیفشار: هرچه تندتر، نازکتر (مثل جوهر واقعی)
|
|
157
|
+
if (ev.pointerType !== "pen")
|
|
158
|
+
p[2] = Math.max(0.15, Math.min(0.75, 0.75 - d / 60));
|
|
159
|
+
s.push(p);
|
|
160
|
+
}
|
|
161
|
+
redraw();
|
|
162
|
+
}, onPointerUp: () => {
|
|
163
|
+
if (!current.current)
|
|
164
|
+
return;
|
|
165
|
+
strokes.current = [...strokes.current, current.current];
|
|
166
|
+
current.current = null;
|
|
167
|
+
commit(strokes.current.length === 1 ? S.signed : undefined);
|
|
168
|
+
}, onPointerCancel: () => { current.current = null; redraw(); } })) : (_jsxs("label", { className: "k-signature__typed", children: [_jsx("span", { className: "k-sr-only", children: S.typedLabel }), _jsx("input", { className: "k-signature__typed-input", value: typed, onChange: (e) => setTyped(e.target.value), placeholder: S.typedLabel, disabled: disabled, readOnly: readOnly, autoComplete: "name" })] })), _jsx("span", { className: "k-signature__line", "aria-hidden": "true", children: "\u00D7" }), !locked && (_jsxs("div", { className: "k-signature__tools", children: [mode === "draw" && (_jsx("button", { type: "button", className: "k-signature__tool", onClick: undo, disabled: count === 0, "aria-label": S.undo, title: S.undo, children: _jsx("svg", { viewBox: "0 0 20 20", "aria-hidden": "true", children: _jsx("path", { d: "M7.5 5 4 8.5 7.5 12M4.5 8.5h7a4 4 0 0 1 0 8H9", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round" }) }) })), _jsx("button", { type: "button", className: "k-signature__tool", onClick: clear, disabled: empty, children: S.clear })] }))] }), (hint || !locked) && !error && _jsx("span", { className: "k-hint", id: hintId, children: hint ?? (mode === "draw" ? S.hint : null) }), error && _jsx("span", { className: "k-hint k-hint--error", id: errId, role: "alert", children: error }), name && _jsx("input", { type: "hidden", name: name, value: data ?? "", required: required }), _jsx("span", { className: "k-sr-only", "aria-live": "polite", children: live })] }));
|
|
169
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type CSSProperties, type ReactNode } from "react";
|
|
2
|
+
export interface VirtualListHandle {
|
|
3
|
+
/** اسکرول تا یک مورد */
|
|
4
|
+
scrollToIndex: (index: number, align?: "start" | "center" | "end") => void;
|
|
5
|
+
}
|
|
6
|
+
export interface VirtualListProps<T> {
|
|
7
|
+
items: readonly T[];
|
|
8
|
+
renderItem: (item: T, index: number) => ReactNode;
|
|
9
|
+
/** کلید پایدار هر مورد @default index */
|
|
10
|
+
getKey?: (item: T, index: number) => string | number;
|
|
11
|
+
/** ارتفاع تخمینی هر مورد به پیکسل؛ ارتفاع واقعی بعد از نمایش اندازه گرفته میشود @default 48 */
|
|
12
|
+
estimateSize?: number;
|
|
13
|
+
/** همهٔ موردها همقدند (سریعتر؛ بدون اندازهگیری) */
|
|
14
|
+
fixedSize?: boolean;
|
|
15
|
+
/** موردهای اضافهٔ بالا و پایین پنجره @default 6 */
|
|
16
|
+
overscan?: number;
|
|
17
|
+
/** ارتفاع فهرست؛ پیشفرض متغیر --k-vlist-height */
|
|
18
|
+
height?: string;
|
|
19
|
+
/** وقتی به ۵ مورد مانده به آخر رسید (برای بارگذاری پیوسته) */
|
|
20
|
+
onEndReached?: () => void;
|
|
21
|
+
/** فاصلهٔ بین موردها به پیکسل @default 0 */
|
|
22
|
+
gap?: number;
|
|
23
|
+
label?: string;
|
|
24
|
+
className?: string;
|
|
25
|
+
style?: CSSProperties;
|
|
26
|
+
}
|
|
27
|
+
declare function VirtualListInner<T>({ items, renderItem, getKey, estimateSize, fixedSize, overscan, height, onEndReached, gap, label, className, style }: VirtualListProps<T>, ref: React.ForwardedRef<VirtualListHandle>): import("react").JSX.Element;
|
|
28
|
+
/**
|
|
29
|
+
* فهرست مجازی برای دهها هزار مورد: فقط موردهای دیدهشده ساخته میشوند و ارتفاع هر مورد خودکار اندازه گرفته میشود.
|
|
30
|
+
* aria-setsize و aria-posinset برای صفحهخوان، scrollToIndex با ref، و onEndReached برای بارگذاری پیوسته.
|
|
31
|
+
*/
|
|
32
|
+
export declare const VirtualList: <T>(props: VirtualListProps<T> & {
|
|
33
|
+
ref?: React.Ref<VirtualListHandle>;
|
|
34
|
+
}) => ReturnType<typeof VirtualListInner>;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef, useCallback, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { cx } from "./cx.js";
|
|
5
|
+
import { useKashi } from "./KashiProvider.js";
|
|
6
|
+
const useIso = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
7
|
+
function VirtualListInner({ items, renderItem, getKey, estimateSize = 48, fixedSize, overscan = 6, height, onEndReached, gap = 0, label, className, style }, ref) {
|
|
8
|
+
const { messages: M, n } = useKashi();
|
|
9
|
+
const scroller = useRef(null);
|
|
10
|
+
const sizes = useRef(new Map());
|
|
11
|
+
const [version, setVersion] = useState(0);
|
|
12
|
+
const [view, setView] = useState({ top: 0, height: 0 });
|
|
13
|
+
const keyOf = useCallback((i) => (getKey ? getKey(items[i], i) : i), [getKey, items]);
|
|
14
|
+
// جای شروع هر مورد (جمع پیشوندی ارتفاعها)
|
|
15
|
+
const offsets = useMemo(() => {
|
|
16
|
+
const out = new Float64Array(items.length + 1);
|
|
17
|
+
for (let i = 0; i < items.length; i++) {
|
|
18
|
+
const s = fixedSize ? estimateSize : (sizes.current.get(String(keyOf(i))) ?? estimateSize);
|
|
19
|
+
out[i + 1] = out[i] + s + gap;
|
|
20
|
+
}
|
|
21
|
+
return out;
|
|
22
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
23
|
+
}, [items, version, estimateSize, fixedSize, gap, keyOf]);
|
|
24
|
+
const total = Math.max(0, offsets[items.length] - gap);
|
|
25
|
+
useIso(() => {
|
|
26
|
+
const el = scroller.current;
|
|
27
|
+
if (!el)
|
|
28
|
+
return;
|
|
29
|
+
let frame = 0;
|
|
30
|
+
const read = () => { frame = 0; setView({ top: el.scrollTop, height: el.clientHeight }); };
|
|
31
|
+
const on = () => { if (!frame)
|
|
32
|
+
frame = requestAnimationFrame(read); };
|
|
33
|
+
read();
|
|
34
|
+
el.addEventListener("scroll", on, { passive: true });
|
|
35
|
+
const ro = typeof ResizeObserver !== "undefined" ? new ResizeObserver(on) : null;
|
|
36
|
+
ro?.observe(el);
|
|
37
|
+
return () => { el.removeEventListener("scroll", on); ro?.disconnect(); cancelAnimationFrame(frame); };
|
|
38
|
+
}, []);
|
|
39
|
+
// جستوجوی دودویی اولین مورد دیدهشده
|
|
40
|
+
const find = (y) => {
|
|
41
|
+
let lo = 0, hi = items.length;
|
|
42
|
+
while (lo < hi) {
|
|
43
|
+
const mid = (lo + hi) >> 1;
|
|
44
|
+
if (offsets[mid + 1] <= y)
|
|
45
|
+
lo = mid + 1;
|
|
46
|
+
else
|
|
47
|
+
hi = mid;
|
|
48
|
+
}
|
|
49
|
+
return lo;
|
|
50
|
+
};
|
|
51
|
+
const vh = view.height || 600;
|
|
52
|
+
const first = Math.max(0, find(view.top) - overscan);
|
|
53
|
+
const last = Math.min(items.length, find(view.top + vh) + 1 + overscan);
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (onEndReached && items.length > 0 && last >= items.length - 5)
|
|
56
|
+
onEndReached();
|
|
57
|
+
}, [last, items.length]);
|
|
58
|
+
// اندازهگیری موردهای ساختهشده
|
|
59
|
+
const measured = useRef(null);
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
if (fixedSize || typeof ResizeObserver === "undefined")
|
|
62
|
+
return;
|
|
63
|
+
measured.current = new ResizeObserver((entries) => {
|
|
64
|
+
let changed = false;
|
|
65
|
+
for (const e of entries) {
|
|
66
|
+
const el = e.target;
|
|
67
|
+
const k = el.dataset.key;
|
|
68
|
+
const h = el.offsetHeight;
|
|
69
|
+
if (Math.abs((sizes.current.get(k) ?? -1) - h) > 0.5) {
|
|
70
|
+
sizes.current.set(k, h);
|
|
71
|
+
changed = true;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (changed)
|
|
75
|
+
setVersion((v) => v + 1);
|
|
76
|
+
});
|
|
77
|
+
return () => measured.current?.disconnect();
|
|
78
|
+
}, [fixedSize]);
|
|
79
|
+
const measure = useCallback((el) => { if (el)
|
|
80
|
+
measured.current?.observe(el); }, []);
|
|
81
|
+
useImperativeHandle(ref, () => ({
|
|
82
|
+
scrollToIndex: (i, align = "start") => {
|
|
83
|
+
const el = scroller.current;
|
|
84
|
+
if (!el)
|
|
85
|
+
return;
|
|
86
|
+
const top = offsets[Math.max(0, Math.min(items.length - 1, i))];
|
|
87
|
+
const h = offsets[i + 1] - top;
|
|
88
|
+
el.scrollTo({ top: align === "start" ? top : align === "end" ? top - el.clientHeight + h : top - (el.clientHeight - h) / 2 });
|
|
89
|
+
},
|
|
90
|
+
}));
|
|
91
|
+
const rows = [];
|
|
92
|
+
for (let i = first; i < last; i++) {
|
|
93
|
+
const key = keyOf(i);
|
|
94
|
+
rows.push(_jsx("div", { ref: fixedSize ? undefined : measure, "data-key": String(key), className: "k-vlist__item", role: "listitem", "aria-posinset": i + 1, "aria-setsize": items.length, style: { transform: `translateY(${offsets[i]}px)`, ...(fixedSize ? { blockSize: estimateSize } : {}) }, children: renderItem(items[i], i) }, key));
|
|
95
|
+
}
|
|
96
|
+
return (_jsx("div", { ref: scroller, className: cx("k-vlist", className), style: { ...(height ? { blockSize: height } : {}), ...style }, tabIndex: 0, role: "list", "aria-label": label ?? M.virtualList.label(n(items.length)), children: _jsx("div", { className: "k-vlist__space", style: { blockSize: total }, children: rows }) }));
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* فهرست مجازی برای دهها هزار مورد: فقط موردهای دیدهشده ساخته میشوند و ارتفاع هر مورد خودکار اندازه گرفته میشود.
|
|
100
|
+
* aria-setsize و aria-posinset برای صفحهخوان، scrollToIndex با ref، و onEndReached برای بارگذاری پیوسته.
|
|
101
|
+
*/
|
|
102
|
+
export const VirtualList = forwardRef(VirtualListInner);
|
package/dist/index.d.ts
CHANGED
|
@@ -216,3 +216,21 @@ export type { QrLevel } from "./qr.js";
|
|
|
216
216
|
export { Scheduler } from "./Scheduler.js";
|
|
217
217
|
export type { SchedulerProps, SchedulerEvent } from "./Scheduler.js";
|
|
218
218
|
export type { EconomicCodeType, WeekHours, DayHours, TimeRange } from "@kashi-ui/persian";
|
|
219
|
+
export { BillIdInput, PaymentIdInput } from "./BillInput.js";
|
|
220
|
+
export type { BillIdInputProps, PaymentIdInputProps } from "./BillInput.js";
|
|
221
|
+
export { fiscalRangePresets } from "./DateRangePicker.js";
|
|
222
|
+
export { SignaturePad } from "./SignaturePad.js";
|
|
223
|
+
export type { SignaturePadProps, SignaturePadHandle, SignatureStroke } from "./SignaturePad.js";
|
|
224
|
+
export { ImageCropper, cropImage } from "./ImageCropper.js";
|
|
225
|
+
export type { ImageCropperProps, ImageCropperHandle, CropArea, CropState, CropImageOptions } from "./ImageCropper.js";
|
|
226
|
+
export { Gantt } from "./Gantt.js";
|
|
227
|
+
export type { GanttProps, GanttTask } from "./Gantt.js";
|
|
228
|
+
export { Invoice, invoiceTotals } from "./Invoice.js";
|
|
229
|
+
export type { InvoiceProps, InvoiceParty, InvoiceItem, InvoiceTotals } from "./Invoice.js";
|
|
230
|
+
export { InfiniteScroll } from "./InfiniteScroll.js";
|
|
231
|
+
export type { InfiniteScrollProps } from "./InfiniteScroll.js";
|
|
232
|
+
export { VirtualList } from "./VirtualList.js";
|
|
233
|
+
export type { VirtualListProps, VirtualListHandle } from "./VirtualList.js";
|
|
234
|
+
export { toXlsx, downloadXlsx } from "./xlsx.js";
|
|
235
|
+
export type { XlsxCell, XlsxOptions } from "./xlsx.js";
|
|
236
|
+
export type { BillService, BillInfo, JalaliRangePreset, JalaliRangePresetId } from "@kashi-ui/persian";
|
package/dist/index.js
CHANGED
|
@@ -108,3 +108,12 @@ export { NotificationCenter, NotificationList } from "./NotificationCenter.js";
|
|
|
108
108
|
export { QRCode } from "./QRCode.js";
|
|
109
109
|
export { encodeQr } from "./qr.js";
|
|
110
110
|
export { Scheduler } from "./Scheduler.js";
|
|
111
|
+
export { BillIdInput, PaymentIdInput } from "./BillInput.js";
|
|
112
|
+
export { fiscalRangePresets } from "./DateRangePicker.js";
|
|
113
|
+
export { SignaturePad } from "./SignaturePad.js";
|
|
114
|
+
export { ImageCropper, cropImage } from "./ImageCropper.js";
|
|
115
|
+
export { Gantt } from "./Gantt.js";
|
|
116
|
+
export { Invoice, invoiceTotals } from "./Invoice.js";
|
|
117
|
+
export { InfiniteScroll } from "./InfiniteScroll.js";
|
|
118
|
+
export { VirtualList } from "./VirtualList.js";
|
|
119
|
+
export { toXlsx, downloadXlsx } from "./xlsx.js";
|
package/dist/xlsx.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { toXlsx, type XlsxCell, type XlsxOptions } from "@kashi-ui/persian";
|
|
2
|
+
export { toXlsx };
|
|
3
|
+
export type { XlsxCell, XlsxOptions };
|
|
4
|
+
/** ساخت و دانلود فایل اکسل در مرورگر */
|
|
5
|
+
export declare function downloadXlsx(fileName: string, header: string[], rows: XlsxCell[][], options?: XlsxOptions): void;
|
package/dist/xlsx.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { toXlsx } from "@kashi-ui/persian";
|
|
2
|
+
export { toXlsx };
|
|
3
|
+
/** ساخت و دانلود فایل اکسل در مرورگر */
|
|
4
|
+
export function downloadXlsx(fileName, header, rows, options) {
|
|
5
|
+
const bytes = toXlsx(header, rows, options);
|
|
6
|
+
const blob = new Blob([bytes], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" });
|
|
7
|
+
const a = document.createElement("a");
|
|
8
|
+
a.href = URL.createObjectURL(blob);
|
|
9
|
+
a.download = fileName.endsWith(".xlsx") ? fileName : `${fileName}.xlsx`;
|
|
10
|
+
document.body.append(a);
|
|
11
|
+
a.click();
|
|
12
|
+
a.remove();
|
|
13
|
+
setTimeout(() => URL.revokeObjectURL(a.href), 1000);
|
|
14
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kashi-ui/react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.25.0",
|
|
4
4
|
"description": "کامپوننتهای React دیزاینسیستم کاشی",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"test": "node --test test/*.test.mjs"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@kashi-ui/css": "^2.
|
|
25
|
+
"@kashi-ui/css": "^2.25.0",
|
|
26
26
|
"react": ">=18"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@kashi-ui/bank-logos": "^2.
|
|
63
|
-
"@kashi-ui/persian": "^2.
|
|
62
|
+
"@kashi-ui/bank-logos": "^2.25.0",
|
|
63
|
+
"@kashi-ui/persian": "^2.25.0"
|
|
64
64
|
}
|
|
65
65
|
}
|