@kashi-ui/react 2.24.1 → 2.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/ActivityHeatmap.js +4 -2
- package/dist/AddressForm.js +3 -2
- package/dist/Alert.js +3 -2
- package/dist/AppointmentPicker.js +4 -2
- package/dist/Avatar.js +5 -3
- package/dist/Badge.js +3 -2
- package/dist/BankBadge.js +2 -2
- package/dist/BankCard.js +4 -2
- package/dist/Banner.js +3 -2
- package/dist/BillInput.d.ts +39 -0
- package/dist/BillInput.js +57 -0
- package/dist/BottomSheet.js +3 -2
- package/dist/Breadcrumb.js +3 -2
- package/dist/BusinessHours.js +6 -3
- package/dist/Button.js +3 -2
- package/dist/Calendar.js +4 -2
- package/dist/CardNumberInput.js +4 -2
- package/dist/Carousel.js +4 -2
- package/dist/Chart.js +6 -4
- package/dist/Chat.js +6 -4
- package/dist/ChatComposer.js +4 -2
- package/dist/CitySelect.js +3 -2
- package/dist/CodeBlock.js +4 -2
- package/dist/ColorPicker.js +6 -3
- package/dist/Combobox.d.ts +4 -0
- package/dist/Combobox.js +11 -6
- package/dist/CommandPalette.js +4 -2
- package/dist/ContextMenu.js +3 -2
- package/dist/CopyButton.js +3 -2
- package/dist/Countdown.js +4 -2
- package/dist/DataTable.d.ts +19 -1
- package/dist/DataTable.js +109 -9
- package/dist/DatePicker.js +4 -2
- package/dist/DateRangePicker.d.ts +19 -1
- package/dist/DateRangePicker.js +30 -7
- package/dist/DateTile.js +2 -2
- package/dist/Dialog.js +3 -2
- package/dist/Drawer.js +3 -2
- package/dist/EconomicCodeInput.js +4 -2
- package/dist/EmptyState.js +3 -2
- package/dist/Field.js +3 -2
- package/dist/FileUpload.d.ts +1 -1
- package/dist/FileUpload.js +9 -6
- package/dist/Gantt.d.ts +42 -0
- package/dist/Gantt.js +118 -0
- package/dist/IbanInput.js +3 -2
- package/dist/ImageCropper.d.ts +56 -0
- package/dist/ImageCropper.js +187 -0
- package/dist/InfiniteScroll.d.ts +34 -0
- package/dist/InfiniteScroll.js +46 -0
- package/dist/InlineEdit.js +3 -2
- package/dist/Input.js +3 -2
- package/dist/Invoice.d.ts +65 -0
- package/dist/Invoice.js +32 -0
- package/dist/IranMap.js +4 -2
- package/dist/Kanban.js +4 -2
- package/dist/KashiProvider.d.ts +731 -3
- package/dist/KashiProvider.js +19 -4
- package/dist/KeyboardFixInput.js +4 -2
- package/dist/LandlineInput.js +4 -2
- package/dist/LegalIdInput.js +4 -2
- package/dist/Lightbox.js +6 -3
- package/dist/Meter.js +4 -2
- package/dist/MobileInput.js +4 -2
- package/dist/Money.js +4 -2
- package/dist/MonthPicker.js +4 -2
- package/dist/MultiSelect.js +4 -2
- package/dist/NationalIdInput.js +4 -2
- package/dist/Navbar.js +3 -2
- package/dist/NotificationCenter.js +6 -3
- package/dist/NumberInput.js +4 -2
- package/dist/OtpInput.js +2 -2
- package/dist/Pagination.js +4 -2
- package/dist/PasswordStrength.js +5 -4
- package/dist/PaymentReceipt.js +4 -2
- package/dist/PersianInput.d.ts +3 -0
- package/dist/PersianInput.js +8 -2
- package/dist/PersianTextarea.js +4 -2
- package/dist/PlateInput.js +3 -2
- package/dist/PostalCodeInput.js +4 -2
- package/dist/PriceInput.js +4 -2
- package/dist/PriceRange.js +4 -2
- package/dist/Progress.js +5 -3
- package/dist/ProvinceSelect.js +3 -2
- package/dist/QRCode.js +3 -2
- package/dist/Rating.js +4 -2
- package/dist/RelativeTime.js +2 -2
- package/dist/RichTextEditor.js +4 -2
- package/dist/SayadInput.js +4 -2
- package/dist/Scheduler.js +4 -2
- package/dist/SearchSuggest.js +6 -4
- package/dist/Select.js +3 -2
- package/dist/SideNav.js +3 -2
- package/dist/SignaturePad.d.ts +38 -0
- package/dist/SignaturePad.js +170 -0
- package/dist/Slider.js +4 -2
- package/dist/Sortable.js +4 -2
- package/dist/Splitter.js +4 -2
- package/dist/Stat.js +4 -2
- package/dist/Stepper.js +4 -2
- package/dist/StreamingText.js +3 -2
- package/dist/SwatchGroup.js +3 -2
- package/dist/TagInput.js +4 -2
- package/dist/TaxIdInput.js +3 -2
- package/dist/TimeClock.js +4 -2
- package/dist/TimeInput.js +4 -2
- package/dist/TimePicker.js +4 -2
- package/dist/Toast.js +3 -2
- package/dist/Tour.js +4 -2
- package/dist/VirtualList.d.ts +35 -0
- package/dist/VirtualList.js +104 -0
- package/dist/index.d.ts +19 -1
- package/dist/index.js +10 -1
- package/dist/xlsx.d.ts +5 -0
- package/dist/xlsx.js +14 -0
- package/package.json +4 -4
package/dist/Toast.js
CHANGED
|
@@ -4,7 +4,8 @@ import { useEffect, useId, useRef, useState, useSyncExternalStore } from "react"
|
|
|
4
4
|
import { isDev } from "./utils.js";
|
|
5
5
|
import { cx } from "./cx.js";
|
|
6
6
|
import { CloseIcon, ErrorIcon, InfoIcon, SuccessIcon, WarningIcon } from "./icons.js";
|
|
7
|
-
import {
|
|
7
|
+
import { useMessages } from "./KashiProvider.js";
|
|
8
|
+
import { faToast } from "@kashi-ui/persian";
|
|
8
9
|
// مخزن سادهٔ سراسری؛ هر جای برنامه میتواند toast() را صدا بزند
|
|
9
10
|
let items = [];
|
|
10
11
|
let nextId = 1;
|
|
@@ -90,7 +91,7 @@ const subscribeToasters = (l) => {
|
|
|
90
91
|
};
|
|
91
92
|
/** محل نمایش اعلانها؛ یک بار در ریشهٔ برنامه قرار دهید */
|
|
92
93
|
export function Toaster({ placement, position, max = 5, label, closeLabel }) {
|
|
93
|
-
const {
|
|
94
|
+
const M = useMessages({ toast: faToast });
|
|
94
95
|
label ?? (label = M.toast.region);
|
|
95
96
|
closeLabel ?? (closeLabel = M.toast.close);
|
|
96
97
|
const id = useId();
|
package/dist/Tour.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
5
|
+
import { faCommon, faTour } from "@kashi-ui/persian";
|
|
5
6
|
/**
|
|
6
7
|
* راهنمای قدمبهقدم برای آشنایی با محصول: بخش هر مرحله روشن و بقیه کمرنگ میشود.
|
|
7
8
|
* Esc میبندد، ←→ بین مرحلهها و فوکوس پس از پایان به جای قبلی برمیگردد.
|
|
8
9
|
*/
|
|
9
10
|
export function Tour({ steps, open, onOpenChange, onFinish, labels = {} }) {
|
|
10
11
|
const id = useId();
|
|
11
|
-
const {
|
|
12
|
+
const M = useMessages({ common: faCommon, tour: faTour });
|
|
13
|
+
const { n: N } = useKashiLocale();
|
|
12
14
|
const { next = M.common.next, prev = M.common.prev, done = M.tour.done, skip = M.tour.skip, step: stepLabel = (a, t) => M.tour.step(N(a), N(t)) } = labels;
|
|
13
15
|
const [i, setI] = useState(0);
|
|
14
16
|
const [rect, setRect] = useState(null);
|
|
@@ -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,104 @@
|
|
|
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 { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
6
|
+
import { faVirtualList } from "@kashi-ui/persian";
|
|
7
|
+
const useIso = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
8
|
+
function VirtualListInner({ items, renderItem, getKey, estimateSize = 48, fixedSize, overscan = 6, height, onEndReached, gap = 0, label, className, style }, ref) {
|
|
9
|
+
const M = useMessages({ virtualList: faVirtualList });
|
|
10
|
+
const { n } = useKashiLocale();
|
|
11
|
+
const scroller = useRef(null);
|
|
12
|
+
const sizes = useRef(new Map());
|
|
13
|
+
const [version, setVersion] = useState(0);
|
|
14
|
+
const [view, setView] = useState({ top: 0, height: 0 });
|
|
15
|
+
const keyOf = useCallback((i) => (getKey ? getKey(items[i], i) : i), [getKey, items]);
|
|
16
|
+
// جای شروع هر مورد (جمع پیشوندی ارتفاعها)
|
|
17
|
+
const offsets = useMemo(() => {
|
|
18
|
+
const out = new Float64Array(items.length + 1);
|
|
19
|
+
for (let i = 0; i < items.length; i++) {
|
|
20
|
+
const s = fixedSize ? estimateSize : (sizes.current.get(String(keyOf(i))) ?? estimateSize);
|
|
21
|
+
out[i + 1] = out[i] + s + gap;
|
|
22
|
+
}
|
|
23
|
+
return out;
|
|
24
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
25
|
+
}, [items, version, estimateSize, fixedSize, gap, keyOf]);
|
|
26
|
+
const total = Math.max(0, offsets[items.length] - gap);
|
|
27
|
+
useIso(() => {
|
|
28
|
+
const el = scroller.current;
|
|
29
|
+
if (!el)
|
|
30
|
+
return;
|
|
31
|
+
let frame = 0;
|
|
32
|
+
const read = () => { frame = 0; setView({ top: el.scrollTop, height: el.clientHeight }); };
|
|
33
|
+
const on = () => { if (!frame)
|
|
34
|
+
frame = requestAnimationFrame(read); };
|
|
35
|
+
read();
|
|
36
|
+
el.addEventListener("scroll", on, { passive: true });
|
|
37
|
+
const ro = typeof ResizeObserver !== "undefined" ? new ResizeObserver(on) : null;
|
|
38
|
+
ro?.observe(el);
|
|
39
|
+
return () => { el.removeEventListener("scroll", on); ro?.disconnect(); cancelAnimationFrame(frame); };
|
|
40
|
+
}, []);
|
|
41
|
+
// جستوجوی دودویی اولین مورد دیدهشده
|
|
42
|
+
const find = (y) => {
|
|
43
|
+
let lo = 0, hi = items.length;
|
|
44
|
+
while (lo < hi) {
|
|
45
|
+
const mid = (lo + hi) >> 1;
|
|
46
|
+
if (offsets[mid + 1] <= y)
|
|
47
|
+
lo = mid + 1;
|
|
48
|
+
else
|
|
49
|
+
hi = mid;
|
|
50
|
+
}
|
|
51
|
+
return lo;
|
|
52
|
+
};
|
|
53
|
+
const vh = view.height || 600;
|
|
54
|
+
const first = Math.max(0, find(view.top) - overscan);
|
|
55
|
+
const last = Math.min(items.length, find(view.top + vh) + 1 + overscan);
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (onEndReached && items.length > 0 && last >= items.length - 5)
|
|
58
|
+
onEndReached();
|
|
59
|
+
}, [last, items.length]);
|
|
60
|
+
// اندازهگیری موردهای ساختهشده
|
|
61
|
+
const measured = useRef(null);
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
if (fixedSize || typeof ResizeObserver === "undefined")
|
|
64
|
+
return;
|
|
65
|
+
measured.current = new ResizeObserver((entries) => {
|
|
66
|
+
let changed = false;
|
|
67
|
+
for (const e of entries) {
|
|
68
|
+
const el = e.target;
|
|
69
|
+
const k = el.dataset.key;
|
|
70
|
+
const h = el.offsetHeight;
|
|
71
|
+
if (Math.abs((sizes.current.get(k) ?? -1) - h) > 0.5) {
|
|
72
|
+
sizes.current.set(k, h);
|
|
73
|
+
changed = true;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (changed)
|
|
77
|
+
setVersion((v) => v + 1);
|
|
78
|
+
});
|
|
79
|
+
return () => measured.current?.disconnect();
|
|
80
|
+
}, [fixedSize]);
|
|
81
|
+
const measure = useCallback((el) => { if (el)
|
|
82
|
+
measured.current?.observe(el); }, []);
|
|
83
|
+
useImperativeHandle(ref, () => ({
|
|
84
|
+
scrollToIndex: (i, align = "start") => {
|
|
85
|
+
const el = scroller.current;
|
|
86
|
+
if (!el)
|
|
87
|
+
return;
|
|
88
|
+
const top = offsets[Math.max(0, Math.min(items.length - 1, i))];
|
|
89
|
+
const h = offsets[i + 1] - top;
|
|
90
|
+
el.scrollTo({ top: align === "start" ? top : align === "end" ? top - el.clientHeight + h : top - (el.clientHeight - h) / 2 });
|
|
91
|
+
},
|
|
92
|
+
}));
|
|
93
|
+
const rows = [];
|
|
94
|
+
for (let i = first; i < last; i++) {
|
|
95
|
+
const key = keyOf(i);
|
|
96
|
+
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));
|
|
97
|
+
}
|
|
98
|
+
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 }) }));
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* فهرست مجازی برای دهها هزار مورد: فقط موردهای دیدهشده ساخته میشوند و ارتفاع هر مورد خودکار اندازه گرفته میشود.
|
|
102
|
+
* aria-setsize و aria-posinset برای صفحهخوان، scrollToIndex با ref، و onEndReached برای بارگذاری پیوسته.
|
|
103
|
+
*/
|
|
104
|
+
export const VirtualList = forwardRef(VirtualListInner);
|
package/dist/index.d.ts
CHANGED
|
@@ -179,7 +179,7 @@ export { PaymentReceipt } from "./PaymentReceipt.js";
|
|
|
179
179
|
export type { PaymentReceiptProps, ReceiptStatus } from "./PaymentReceipt.js";
|
|
180
180
|
export { PersianInput, PERSIAN_INPUT_LABELS } from "./PersianInput.js";
|
|
181
181
|
export type { PersianInputKind, PersianInputKinds, PersianInputProps } from "./PersianInput.js";
|
|
182
|
-
export { KashiProvider, useKashi } from "./KashiProvider.js";
|
|
182
|
+
export { KashiProvider, useKashi, useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
183
183
|
export type { KashiProviderProps } from "./KashiProvider.js";
|
|
184
184
|
export { faMessages, enMessages } from "@kashi-ui/persian";
|
|
185
185
|
export type { KashiMessages, KashiMessagesInput, KashiLocale } from "@kashi-ui/persian";
|
|
@@ -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
|
@@ -90,7 +90,7 @@ export { BankCard } from "./BankCard.js";
|
|
|
90
90
|
export { DateTile } from "./DateTile.js";
|
|
91
91
|
export { PaymentReceipt } from "./PaymentReceipt.js";
|
|
92
92
|
export { PersianInput, PERSIAN_INPUT_LABELS } from "./PersianInput.js";
|
|
93
|
-
export { KashiProvider, useKashi } from "./KashiProvider.js";
|
|
93
|
+
export { KashiProvider, useKashi, useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
94
94
|
export { faMessages, enMessages } from "@kashi-ui/persian";
|
|
95
95
|
export { SayadInput } from "./SayadInput.js";
|
|
96
96
|
export { EconomicCodeInput } from "./EconomicCodeInput.js";
|
|
@@ -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.26.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.26.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.26.0",
|
|
63
|
+
"@kashi-ui/persian": "^2.26.0"
|
|
64
64
|
}
|
|
65
65
|
}
|