@kashi-ui/react 0.5.0 → 0.7.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 +2 -2
- package/dist/Accordion.d.ts +15 -0
- package/dist/Accordion.js +13 -0
- package/dist/Breadcrumb.d.ts +23 -0
- package/dist/Breadcrumb.js +32 -0
- package/dist/DataTable.d.ts +43 -0
- package/dist/DataTable.js +52 -0
- package/dist/DropdownMenu.d.ts +33 -0
- package/dist/DropdownMenu.js +97 -0
- package/dist/Misc.d.ts +22 -0
- package/dist/Misc.js +16 -0
- package/dist/OtpInput.d.ts +28 -0
- package/dist/OtpInput.js +30 -0
- package/dist/Pagination.d.ts +25 -0
- package/dist/Pagination.js +28 -0
- package/dist/Progress.d.ts +22 -0
- package/dist/Progress.js +15 -0
- package/dist/Skeleton.d.ts +11 -0
- package/dist/Skeleton.js +11 -0
- package/dist/Stepper.d.ts +20 -0
- package/dist/Stepper.js +12 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +10 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -20,8 +20,8 @@ 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 · RelativeTime
|
|
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
|
|
24
24
|
|
|
25
|
-
فارسی: DatePicker و Calendar شمسی · NationalIdInput · CardNumberInput · IbanInput · MobileInput · PriceInput
|
|
25
|
+
فارسی: DatePicker و Calendar شمسی · NationalIdInput · CardNumberInput · IbanInput · MobileInput · PriceInput · OtpInput
|
|
26
26
|
|
|
27
27
|
نیازمند React ۱۸ یا بالاتر. مستندات کامل: [kashi.sepantapouya.com](https://kashi.sepantapouya.com) · کد: [GitHub](https://github.com/Sepantapouya/Kashi) · لایسنس MIT
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type DetailsHTMLAttributes, type HTMLAttributes, type ReactNode } from "react";
|
|
2
|
+
export interface AccordionProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
/** «single»: باز شدن هر بخش بقیه را میبندد (با name مشترک روی details) @default "multiple" */
|
|
4
|
+
type?: "single" | "multiple";
|
|
5
|
+
/** بدون حاشیه و پسزمینه */
|
|
6
|
+
flush?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/** آکاردئون روی <details> بومی: بدون JavaScript، با کیبورد و صفحهخوان کامل */
|
|
9
|
+
export declare function Accordion({ type, flush, className, children, ...rest }: AccordionProps): import("react").JSX.Element;
|
|
10
|
+
export interface AccordionItemProps extends Omit<DetailsHTMLAttributes<HTMLDetailsElement>, "title"> {
|
|
11
|
+
title: ReactNode;
|
|
12
|
+
defaultOpen?: boolean;
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
}
|
|
15
|
+
export declare function AccordionItem({ title, defaultOpen, className, children, ...rest }: AccordionItemProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useId } from "react";
|
|
3
|
+
import { cx } from "./cx.js";
|
|
4
|
+
const AccCtx = createContext({});
|
|
5
|
+
/** آکاردئون روی <details> بومی: بدون JavaScript، با کیبورد و صفحهخوان کامل */
|
|
6
|
+
export function Accordion({ type = "multiple", flush, className, children, ...rest }) {
|
|
7
|
+
const id = useId();
|
|
8
|
+
return (_jsx(AccCtx.Provider, { value: { name: type === "single" ? `k-acc-${id}` : undefined }, children: _jsx("div", { className: cx("k-accordion", flush && "k-accordion--flush", className), ...rest, children: children }) }));
|
|
9
|
+
}
|
|
10
|
+
export function AccordionItem({ title, defaultOpen, className, children, ...rest }) {
|
|
11
|
+
const { name } = useContext(AccCtx);
|
|
12
|
+
return (_jsxs("details", { className: cx("k-accordion__item", className), name: name, open: defaultOpen, ...rest, children: [_jsx("summary", { className: "k-accordion__trigger", children: title }), _jsx("div", { className: "k-accordion__content", children: children })] }));
|
|
13
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export interface BreadcrumbItem {
|
|
3
|
+
label: ReactNode;
|
|
4
|
+
href?: string;
|
|
5
|
+
icon?: ReactNode;
|
|
6
|
+
/** فقط آیکون نمایش داده شود؛ برچسب برای صفحهخوان میماند (مثل «خانه») */
|
|
7
|
+
hideLabel?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface BreadcrumbProps {
|
|
10
|
+
/** آخرین مورد صفحهٔ فعلی است */
|
|
11
|
+
items: BreadcrumbItem[];
|
|
12
|
+
/** اگر موارد بیشتر بود، وسط مسیر به «…» جمع میشود */
|
|
13
|
+
maxItems?: number;
|
|
14
|
+
/** @default "chevron" */
|
|
15
|
+
separator?: "chevron" | "slash";
|
|
16
|
+
/** @default "مسیر" */
|
|
17
|
+
label?: string;
|
|
18
|
+
/** @default "نمایش مسیر کامل" */
|
|
19
|
+
expandLabel?: string;
|
|
20
|
+
className?: string;
|
|
21
|
+
}
|
|
22
|
+
/** مسیر صفحه؛ آخرین مورد با aria-current="page" مشخص میشود و مسیرهای بلند جمع میشوند */
|
|
23
|
+
export declare function Breadcrumb({ items, maxItems, separator, label, expandLabel, className }: BreadcrumbProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { cx } from "./cx.js";
|
|
4
|
+
/** مسیر صفحه؛ آخرین مورد با aria-current="page" مشخص میشود و مسیرهای بلند جمع میشوند */
|
|
5
|
+
export function Breadcrumb({ items, maxItems, separator = "chevron", label = "مسیر", expandLabel = "نمایش مسیر کامل", className }) {
|
|
6
|
+
const [expanded, setExpanded] = useState(false);
|
|
7
|
+
const listRef = useRef(null);
|
|
8
|
+
const justExpanded = useRef(false);
|
|
9
|
+
// دکمهٔ «…» پس از باز شدن حذف میشود؛ فوکوس به اولین مورد تازهنمایان میرود تا گم نشود
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (!justExpanded.current)
|
|
12
|
+
return;
|
|
13
|
+
justExpanded.current = false;
|
|
14
|
+
listRef.current?.querySelectorAll(".k-breadcrumb__link")[1]?.focus();
|
|
15
|
+
}, [expanded]);
|
|
16
|
+
const collapse = !expanded && maxItems !== undefined && maxItems >= 2 && items.length > maxItems;
|
|
17
|
+
// اولی + «…» + آخرینها
|
|
18
|
+
const visible = collapse
|
|
19
|
+
? [items[0], "ellipsis", ...items.slice(items.length - (maxItems - 1))]
|
|
20
|
+
: items;
|
|
21
|
+
return (_jsx("nav", { className: cx("k-breadcrumb", separator === "slash" && "k-breadcrumb--slash", className), "aria-label": label, children: _jsx("ol", { ref: listRef, children: visible.map((item, i) => {
|
|
22
|
+
if (item === "ellipsis") {
|
|
23
|
+
return (_jsx("li", { children: _jsx("button", { type: "button", className: "k-breadcrumb__link", "aria-label": expandLabel, onClick: () => { justExpanded.current = true; setExpanded(true); }, children: "\u2026" }) }, "ellipsis"));
|
|
24
|
+
}
|
|
25
|
+
const last = item === items[items.length - 1];
|
|
26
|
+
const iconOnly = !!item.icon && item.hideLabel;
|
|
27
|
+
const cls = cx("k-breadcrumb__link", iconOnly && "k-breadcrumb__link--icon");
|
|
28
|
+
const title = typeof item.label === "string" && !iconOnly ? item.label : undefined;
|
|
29
|
+
const content = (_jsxs(_Fragment, { children: [item.icon, _jsx("span", { className: iconOnly ? "k-sr-only" : "k-breadcrumb__text", children: item.label })] }));
|
|
30
|
+
return (_jsx("li", { children: last || !item.href ? (_jsx("span", { className: cls, "aria-current": last ? "page" : undefined, title: title, children: content })) : (_jsx("a", { className: cls, href: item.href, title: title, children: content })) }, i));
|
|
31
|
+
}) }) }));
|
|
32
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export interface Column<T> {
|
|
3
|
+
key: string;
|
|
4
|
+
header: ReactNode;
|
|
5
|
+
/** محتوای خانه؛ پیشفرض row[key] */
|
|
6
|
+
render?: (row: T) => ReactNode;
|
|
7
|
+
/** مقدار برای مرتبسازی؛ پیشفرض row[key] */
|
|
8
|
+
sortValue?: (row: T) => string | number;
|
|
9
|
+
sortable?: boolean;
|
|
10
|
+
/** عدد و مبلغ: چپچین در RTL با ارقام همعرض */
|
|
11
|
+
numeric?: boolean;
|
|
12
|
+
width?: string;
|
|
13
|
+
}
|
|
14
|
+
export type SortState = {
|
|
15
|
+
key: string;
|
|
16
|
+
direction: "ascending" | "descending";
|
|
17
|
+
} | null;
|
|
18
|
+
export interface DataTableProps<T> {
|
|
19
|
+
columns: Column<T>[];
|
|
20
|
+
rows: T[];
|
|
21
|
+
getRowId: (row: T) => string;
|
|
22
|
+
/** عنوان جدول (caption)؛ برای صفحهخوان ضروری است */
|
|
23
|
+
caption: ReactNode;
|
|
24
|
+
description?: ReactNode;
|
|
25
|
+
/** پنهان کردن عنوان از دید (صفحهخوان همچنان میخواند) */
|
|
26
|
+
hideCaption?: boolean;
|
|
27
|
+
selectable?: boolean;
|
|
28
|
+
selected?: string[];
|
|
29
|
+
onSelectedChange?: (ids: string[]) => void;
|
|
30
|
+
sort?: SortState;
|
|
31
|
+
defaultSort?: SortState;
|
|
32
|
+
onSortChange?: (sort: SortState) => void;
|
|
33
|
+
/** وقتی ردیفی نیست */
|
|
34
|
+
empty?: ReactNode;
|
|
35
|
+
compact?: boolean;
|
|
36
|
+
labels?: {
|
|
37
|
+
selectAll?: string;
|
|
38
|
+
selectRow?: (row: T) => string;
|
|
39
|
+
};
|
|
40
|
+
className?: string;
|
|
41
|
+
}
|
|
42
|
+
/** جدول داده با مرتبسازی (aria-sort)، انتخاب ردیفها و حالت خالی */
|
|
43
|
+
export declare function DataTable<T extends Record<string, unknown>>({ columns, rows, getRowId, caption, description, hideCaption, selectable, selected, onSelectedChange, sort, defaultSort, onSortChange, empty, compact, labels, className, }: DataTableProps<T>): import("react").JSX.Element;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useId, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { cx } from "./cx.js";
|
|
4
|
+
/** جدول داده با مرتبسازی (aria-sort)، انتخاب ردیفها و حالت خالی */
|
|
5
|
+
export function DataTable({ columns, rows, getRowId, caption, description, hideCaption, selectable, selected, onSelectedChange, sort, defaultSort = null, onSortChange, empty, compact, labels = {}, className, }) {
|
|
6
|
+
const id = useId();
|
|
7
|
+
const [innerSort, setInnerSort] = useState(defaultSort);
|
|
8
|
+
const [innerSel, setInnerSel] = useState([]);
|
|
9
|
+
const activeSort = sort !== undefined ? sort : innerSort;
|
|
10
|
+
const sel = selected ?? innerSel;
|
|
11
|
+
const allRef = useRef(null);
|
|
12
|
+
const sorted = useMemo(() => {
|
|
13
|
+
if (!activeSort)
|
|
14
|
+
return rows;
|
|
15
|
+
const col = columns.find((c) => c.key === activeSort.key);
|
|
16
|
+
const val = (r) => (col?.sortValue ? col.sortValue(r) : r[activeSort.key]);
|
|
17
|
+
const dir = activeSort.direction === "ascending" ? 1 : -1;
|
|
18
|
+
return [...rows].sort((a, b) => {
|
|
19
|
+
const x = val(a);
|
|
20
|
+
const y = val(b);
|
|
21
|
+
return (typeof x === "number" && typeof y === "number" ? x - y : String(x).localeCompare(String(y), "fa")) * dir;
|
|
22
|
+
});
|
|
23
|
+
}, [rows, activeSort, columns]);
|
|
24
|
+
const setSort = (key) => {
|
|
25
|
+
const next = activeSort?.key === key && activeSort.direction === "ascending" ? { key, direction: "descending" } : { key, direction: "ascending" };
|
|
26
|
+
if (sort === undefined)
|
|
27
|
+
setInnerSort(next);
|
|
28
|
+
onSortChange?.(next);
|
|
29
|
+
};
|
|
30
|
+
const setSel = (ids) => {
|
|
31
|
+
if (selected === undefined)
|
|
32
|
+
setInnerSel(ids);
|
|
33
|
+
onSelectedChange?.(ids);
|
|
34
|
+
};
|
|
35
|
+
const ids = rows.map(getRowId);
|
|
36
|
+
const all = ids.length > 0 && ids.every((x) => sel.includes(x));
|
|
37
|
+
const some = !all && ids.some((x) => sel.includes(x));
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (allRef.current)
|
|
40
|
+
allRef.current.indeterminate = some;
|
|
41
|
+
}, [some]);
|
|
42
|
+
const { selectAll = "انتخاب همهٔ ردیفها", selectRow = () => "انتخاب ردیف" } = labels;
|
|
43
|
+
const colCount = columns.length + (selectable ? 1 : 0);
|
|
44
|
+
return (_jsx("div", { className: cx("k-table-wrap", className), role: "region", "aria-labelledby": `${id}-caption`, tabIndex: 0, children: _jsxs("table", { className: cx("k-table", compact && "k-table--compact"), children: [_jsxs("caption", { id: `${id}-caption`, className: hideCaption ? "k-sr-only" : undefined, children: [_jsx("span", { className: "k-table__caption-title", children: caption }), description && _jsx("span", { className: "k-table__caption-desc", children: description })] }), _jsx("thead", { children: _jsxs("tr", { children: [selectable && (_jsx("th", { scope: "col", className: "k-table__check", children: _jsx("input", { ref: allRef, type: "checkbox", className: "k-checkbox", "aria-label": selectAll, checked: all, onChange: () => setSel(all ? [] : ids) }) })), columns.map((c) => {
|
|
45
|
+
const s = activeSort?.key === c.key ? activeSort.direction : undefined;
|
|
46
|
+
return (_jsx("th", { scope: "col", "aria-sort": c.sortable ? (s ?? "none") : undefined, className: c.numeric ? "k-table__num" : undefined, style: c.width ? { inlineSize: c.width } : undefined, children: c.sortable ? _jsx("button", { type: "button", className: "k-table__sort", onClick: () => setSort(c.key), children: c.header }) : c.header }, c.key));
|
|
47
|
+
})] }) }), _jsx("tbody", { children: sorted.length === 0 ? (_jsx("tr", { className: "k-table__empty", children: _jsx("td", { colSpan: colCount, children: empty ?? _jsx("p", { style: { padding: "2rem", margin: 0, textAlign: "center" }, children: "\u062F\u0627\u062F\u0647\u200C\u0627\u06CC \u0648\u062C\u0648\u062F \u0646\u062F\u0627\u0631\u062F." }) }) })) : (sorted.map((r) => {
|
|
48
|
+
const rid = getRowId(r);
|
|
49
|
+
const on = sel.includes(rid);
|
|
50
|
+
return (_jsxs("tr", { "aria-selected": selectable ? on : undefined, children: [selectable && (_jsx("td", { className: "k-table__check", children: _jsx("input", { type: "checkbox", className: "k-checkbox", "aria-label": selectRow(r), checked: on, onChange: () => setSel(on ? sel.filter((x) => x !== rid) : [...sel, rid]) }) })), columns.map((c) => (_jsx("td", { className: c.numeric ? "k-table__num" : undefined, children: c.render ? c.render(r) : r[c.key] }, c.key)))] }, rid));
|
|
51
|
+
})) })] }) }));
|
|
52
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type ReactElement, type ReactNode } from "react";
|
|
2
|
+
export interface DropdownMenuProps {
|
|
3
|
+
/** دکمهای که منو را باز میکند */
|
|
4
|
+
trigger: ReactElement;
|
|
5
|
+
/** نام منو برای صفحهخوان؛ پیشفرض متن دکمه */
|
|
6
|
+
label?: string;
|
|
7
|
+
/** همترازی با لبهٔ ابتدا یا انتهای دکمه @default "start" */
|
|
8
|
+
align?: "start" | "end";
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* منوی کشویی با الگوی Menu Button در WAI-ARIA:
|
|
13
|
+
* Enter، Space یا ↓ باز میکند و اولین گزینه را فوکوس میکند، ↑ آخرین را؛
|
|
14
|
+
* ↑↓ و Home/End حرکت، حرف اول برای پرش، Esc بستن و برگشت به دکمه، Tab بستن.
|
|
15
|
+
*/
|
|
16
|
+
export declare function DropdownMenu({ trigger, label, align, children }: DropdownMenuProps): import("react").JSX.Element;
|
|
17
|
+
export interface MenuItemProps {
|
|
18
|
+
onSelect?: () => void;
|
|
19
|
+
icon?: ReactNode;
|
|
20
|
+
/** میانبر نمایشی، مثل "Ctrl+D" */
|
|
21
|
+
shortcut?: string;
|
|
22
|
+
/** «danger» برای عملیات مخرب */
|
|
23
|
+
tone?: "default" | "danger";
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
/** لینک بهجای عمل */
|
|
26
|
+
href?: string;
|
|
27
|
+
children: ReactNode;
|
|
28
|
+
}
|
|
29
|
+
export declare function MenuItem({ onSelect, icon, shortcut, tone, disabled, href, children }: MenuItemProps): import("react").JSX.Element;
|
|
30
|
+
export declare const MenuSeparator: () => import("react").JSX.Element;
|
|
31
|
+
export declare const MenuLabel: ({ children }: {
|
|
32
|
+
children: ReactNode;
|
|
33
|
+
}) => import("react").JSX.Element;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Children, cloneElement, createContext, isValidElement, useContext, useEffect, useId, useRef, useState, } from "react";
|
|
3
|
+
import { cx } from "./cx.js";
|
|
4
|
+
const MenuCtx = createContext(null);
|
|
5
|
+
const items = (menu) => [...(menu?.querySelectorAll('[role="menuitem"]:not([aria-disabled="true"])') ?? [])];
|
|
6
|
+
/**
|
|
7
|
+
* منوی کشویی با الگوی Menu Button در WAI-ARIA:
|
|
8
|
+
* Enter، Space یا ↓ باز میکند و اولین گزینه را فوکوس میکند، ↑ آخرین را؛
|
|
9
|
+
* ↑↓ و Home/End حرکت، حرف اول برای پرش، Esc بستن و برگشت به دکمه، Tab بستن.
|
|
10
|
+
*/
|
|
11
|
+
export function DropdownMenu({ trigger, label, align = "start", children }) {
|
|
12
|
+
const id = useId();
|
|
13
|
+
const [open, setOpen] = useState(false);
|
|
14
|
+
const focusOnOpen = useRef("first");
|
|
15
|
+
const triggerRef = useRef(null);
|
|
16
|
+
const menuRef = useRef(null);
|
|
17
|
+
const anchorRef = useRef(null);
|
|
18
|
+
const close = (focusTrigger = true) => {
|
|
19
|
+
setOpen(false);
|
|
20
|
+
if (focusTrigger)
|
|
21
|
+
triggerRef.current?.focus();
|
|
22
|
+
};
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (!open)
|
|
25
|
+
return;
|
|
26
|
+
const list = items(menuRef.current);
|
|
27
|
+
(focusOnOpen.current === "last" ? list[list.length - 1] : list[0])?.focus();
|
|
28
|
+
const onDown = (e) => {
|
|
29
|
+
if (!anchorRef.current?.contains(e.target))
|
|
30
|
+
setOpen(false);
|
|
31
|
+
};
|
|
32
|
+
document.addEventListener("pointerdown", onDown);
|
|
33
|
+
return () => document.removeEventListener("pointerdown", onDown);
|
|
34
|
+
}, [open]);
|
|
35
|
+
const openWith = (where) => {
|
|
36
|
+
focusOnOpen.current = where;
|
|
37
|
+
setOpen(true);
|
|
38
|
+
};
|
|
39
|
+
const onMenuKey = (e) => {
|
|
40
|
+
const list = items(menuRef.current);
|
|
41
|
+
const i = list.indexOf(document.activeElement);
|
|
42
|
+
const go = (j) => list[(j + list.length) % list.length]?.focus();
|
|
43
|
+
if (e.key === "ArrowDown")
|
|
44
|
+
go(i + 1);
|
|
45
|
+
else if (e.key === "ArrowUp")
|
|
46
|
+
go(i - 1);
|
|
47
|
+
else if (e.key === "Home")
|
|
48
|
+
go(0);
|
|
49
|
+
else if (e.key === "End")
|
|
50
|
+
go(list.length - 1);
|
|
51
|
+
else if (e.key === "Escape")
|
|
52
|
+
close();
|
|
53
|
+
else if (e.key === "Tab")
|
|
54
|
+
return setOpen(false);
|
|
55
|
+
else if (e.key.length === 1 && /\S/.test(e.key)) {
|
|
56
|
+
// پرش با حرف اول
|
|
57
|
+
const k = e.key.toLowerCase();
|
|
58
|
+
const start = i + 1;
|
|
59
|
+
const hit = [...list.slice(start), ...list.slice(0, start)].find((el) => el.textContent?.trim().toLowerCase().startsWith(k));
|
|
60
|
+
hit?.focus();
|
|
61
|
+
}
|
|
62
|
+
else
|
|
63
|
+
return;
|
|
64
|
+
e.preventDefault();
|
|
65
|
+
};
|
|
66
|
+
const t = isValidElement(trigger)
|
|
67
|
+
? cloneElement(trigger, {
|
|
68
|
+
ref: triggerRef,
|
|
69
|
+
id: `${id}-trigger`,
|
|
70
|
+
"aria-haspopup": "menu",
|
|
71
|
+
"aria-expanded": open,
|
|
72
|
+
"aria-controls": open ? `${id}-menu` : undefined,
|
|
73
|
+
onClick: () => (open ? close(false) : openWith("first")),
|
|
74
|
+
onKeyDown: (e) => {
|
|
75
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
76
|
+
e.preventDefault();
|
|
77
|
+
openWith(e.key === "ArrowUp" ? "last" : "first");
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
})
|
|
81
|
+
: trigger;
|
|
82
|
+
return (_jsxs("span", { className: "k-menu-anchor", ref: anchorRef, children: [t, _jsx(MenuCtx.Provider, { value: { close }, children: _jsx("ul", { ref: menuRef, id: `${id}-menu`, role: "menu", "aria-label": label, "aria-labelledby": label ? undefined : `${id}-trigger`, className: cx("k-menu", align === "end" && "k-menu--end"), hidden: !open, onKeyDown: onMenuKey, children: Children.map(children, (c) => c) }) })] }));
|
|
83
|
+
}
|
|
84
|
+
export function MenuItem({ onSelect, icon, shortcut, tone = "default", disabled, href, children }) {
|
|
85
|
+
const ctx = useContext(MenuCtx);
|
|
86
|
+
const cls = cx("k-menu__item", tone === "danger" && "k-menu__item--danger");
|
|
87
|
+
const content = (_jsxs(_Fragment, { children: [icon, _jsx("span", { children: children }), shortcut && _jsx("span", { className: "k-menu__shortcut", "aria-hidden": "true", children: shortcut })] }));
|
|
88
|
+
const select = () => {
|
|
89
|
+
if (disabled)
|
|
90
|
+
return;
|
|
91
|
+
onSelect?.();
|
|
92
|
+
ctx?.close();
|
|
93
|
+
};
|
|
94
|
+
return (_jsx("li", { role: "none", children: href && !disabled ? (_jsx("a", { role: "menuitem", tabIndex: -1, className: cls, href: href, onClick: () => ctx?.close(false), children: content })) : (_jsx("button", { type: "button", role: "menuitem", tabIndex: -1, className: cls, "aria-disabled": disabled || undefined, onClick: select, children: content })) }));
|
|
95
|
+
}
|
|
96
|
+
export const MenuSeparator = () => _jsx("li", { role: "separator", className: "k-menu__separator" });
|
|
97
|
+
export const MenuLabel = ({ children }) => _jsx("li", { role: "presentation", className: "k-menu__label", children: children });
|
package/dist/Misc.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
export interface DividerProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
/** متن وسط خط، مثل «یا» */
|
|
4
|
+
label?: ReactNode;
|
|
5
|
+
vertical?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function Divider({ label, vertical, className, ...rest }: DividerProps): import("react").JSX.Element;
|
|
8
|
+
export interface KbdProps extends HTMLAttributes<HTMLElement> {
|
|
9
|
+
/** چند کلید، مثل ["Ctrl", "K"] */
|
|
10
|
+
keys?: string[];
|
|
11
|
+
}
|
|
12
|
+
/** کلید صفحهکلید */
|
|
13
|
+
export declare function Kbd({ keys, children, className, ...rest }: KbdProps): import("react").JSX.Element;
|
|
14
|
+
export interface EmptyStateProps extends Omit<HTMLAttributes<HTMLDivElement>, "title"> {
|
|
15
|
+
title: ReactNode;
|
|
16
|
+
description?: ReactNode;
|
|
17
|
+
icon?: ReactNode;
|
|
18
|
+
/** دکمهها */
|
|
19
|
+
actions?: ReactNode;
|
|
20
|
+
}
|
|
21
|
+
/** حالت خالی: وقتی دادهای برای نمایش نیست */
|
|
22
|
+
export declare function EmptyState({ title, description, icon, actions, className, ...rest }: EmptyStateProps): import("react").JSX.Element;
|
package/dist/Misc.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cx } from "./cx.js";
|
|
3
|
+
export function Divider({ label, vertical, className, ...rest }) {
|
|
4
|
+
return (_jsx("div", { role: "separator", "aria-orientation": vertical ? "vertical" : undefined, className: cx("k-divider", vertical && "k-divider--vertical", className), ...rest, children: label && _jsx("span", { children: label }) }));
|
|
5
|
+
}
|
|
6
|
+
/** کلید صفحهکلید */
|
|
7
|
+
export function Kbd({ keys, children, className, ...rest }) {
|
|
8
|
+
if (keys) {
|
|
9
|
+
return (_jsx("span", { className: cx("k-kbd-combo", className), ...rest, children: keys.map((k, i) => _jsx("kbd", { className: "k-kbd", children: k }, i)) }));
|
|
10
|
+
}
|
|
11
|
+
return _jsx("kbd", { className: cx("k-kbd", className), ...rest, children: children });
|
|
12
|
+
}
|
|
13
|
+
/** حالت خالی: وقتی دادهای برای نمایش نیست */
|
|
14
|
+
export function EmptyState({ title, description, icon, actions, className, ...rest }) {
|
|
15
|
+
return (_jsxs("div", { className: cx("k-empty", className), ...rest, children: [icon && _jsx("span", { className: "k-empty__icon", "aria-hidden": "true", children: icon }), _jsx("p", { className: "k-empty__title", children: title }), description && _jsx("p", { className: "k-empty__description", children: description }), actions && _jsx("div", { className: "k-empty__actions", children: actions })] }));
|
|
16
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export interface OtpInputProps {
|
|
3
|
+
label?: ReactNode;
|
|
4
|
+
hint?: ReactNode;
|
|
5
|
+
error?: ReactNode;
|
|
6
|
+
/** تعداد رقم @default 6 */
|
|
7
|
+
length?: number;
|
|
8
|
+
value?: string;
|
|
9
|
+
defaultValue?: string;
|
|
10
|
+
onChange?: (code: string) => void;
|
|
11
|
+
/** وقتی همهٔ رقمها وارد شد */
|
|
12
|
+
onComplete?: (code: string) => void;
|
|
13
|
+
/** @default "fa" */
|
|
14
|
+
digits?: "fa" | "latin";
|
|
15
|
+
/** خط فاصله بعد از این تعداد رقم، مثلاً 3 برای ۱۲۳-۴۵۶ */
|
|
16
|
+
groupAfter?: number;
|
|
17
|
+
size?: "sm" | "md";
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
autoFocus?: boolean;
|
|
20
|
+
name?: string;
|
|
21
|
+
id?: string;
|
|
22
|
+
className?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* کد تأیید یکبارمصرف: یک input واقعی (نه شش input جدا)، پس چسباندن، پاک کردن،
|
|
26
|
+
* صفحهخوان و پر شدن خودکار کد پیامکی (autocomplete="one-time-code") بینقص کار میکنند.
|
|
27
|
+
*/
|
|
28
|
+
export declare const OtpInput: import("react").ForwardRefExoticComponent<OtpInputProps & import("react").RefAttributes<HTMLInputElement>>;
|
package/dist/OtpInput.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useId, useRef, useState } from "react";
|
|
3
|
+
import { onlyDigits, toFaDigits } from "@kashi-ui/persian";
|
|
4
|
+
import { cx } from "./cx.js";
|
|
5
|
+
import { Field, describedBy } from "./Field.js";
|
|
6
|
+
import { mergeRefs } from "./utils.js";
|
|
7
|
+
/**
|
|
8
|
+
* کد تأیید یکبارمصرف: یک input واقعی (نه شش input جدا)، پس چسباندن، پاک کردن،
|
|
9
|
+
* صفحهخوان و پر شدن خودکار کد پیامکی (autocomplete="one-time-code") بینقص کار میکنند.
|
|
10
|
+
*/
|
|
11
|
+
export const OtpInput = forwardRef(function OtpInput({ label, hint, error, length = 6, value, defaultValue = "", onChange, onComplete, digits = "fa", groupAfter, size = "md", disabled, autoFocus, name, id, className }, ref) {
|
|
12
|
+
const autoId = useId();
|
|
13
|
+
const inputId = id ?? autoId;
|
|
14
|
+
const [inner, setInner] = useState(() => onlyDigits(defaultValue).slice(0, length));
|
|
15
|
+
const code = value !== undefined ? onlyDigits(value).slice(0, length) : inner;
|
|
16
|
+
const [caret, setCaret] = useState(code.length);
|
|
17
|
+
const inputRef = useRef(null);
|
|
18
|
+
const d = (c) => (digits === "fa" ? toFaDigits(c) : c);
|
|
19
|
+
const active = Math.min(caret, length - 1);
|
|
20
|
+
const sync = () => setCaret(Math.min(inputRef.current?.selectionStart ?? code.length, length));
|
|
21
|
+
return (_jsxs(Field, { id: inputId, label: label, hint: hint, error: error, className: className, children: [_jsxs("div", { className: cx("k-otp", size === "sm" && "k-otp--sm", !!error && "k-otp--invalid"), onClick: () => inputRef.current?.focus(), children: [_jsx("input", { ref: mergeRefs(ref, inputRef), id: inputId, className: "k-otp__input", type: "text", inputMode: "numeric", autoComplete: "one-time-code", pattern: "\\d*", maxLength: length * 2 /* ارقام فارسی و فاصلههای چسباندهشده */, value: code, disabled: disabled, autoFocus: autoFocus, "aria-invalid": error ? true : undefined, "aria-describedby": describedBy(inputId, hint, error), onChange: (e) => {
|
|
22
|
+
const next = onlyDigits(e.target.value).slice(0, length);
|
|
23
|
+
if (value === undefined)
|
|
24
|
+
setInner(next);
|
|
25
|
+
onChange?.(next);
|
|
26
|
+
setCaret(next.length);
|
|
27
|
+
if (next.length === length && next !== code)
|
|
28
|
+
onComplete?.(next);
|
|
29
|
+
}, onSelect: sync, onKeyUp: sync, onFocus: sync }), Array.from({ length }, (_, i) => (_jsxs("span", { style: { display: "contents" }, children: [groupAfter && i === groupAfter && _jsx("span", { className: "k-otp__sep", "aria-hidden": "true" }), _jsx("span", { className: "k-otp__slot", "aria-hidden": "true", "data-filled": code[i] ? "" : undefined, "data-active": i === active ? "" : undefined, children: code[i] ? d(code[i]) : "" })] }, i)))] }), name && _jsx("input", { type: "hidden", name: name, value: code })] }));
|
|
30
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
/** صفحههایی که نمایش داده میشوند؛ null یعنی «…» */
|
|
3
|
+
export declare function pageRange(page: number, total: number, siblings?: number): (number | null)[];
|
|
4
|
+
export interface PaginationProps {
|
|
5
|
+
page: number;
|
|
6
|
+
total: number;
|
|
7
|
+
onChange?: (page: number) => void;
|
|
8
|
+
/** برای صفحهبندی با لینک (بهتر برای SEO)؛ در این حالت onChange لازم نیست */
|
|
9
|
+
getHref?: (page: number) => string;
|
|
10
|
+
/** تعداد صفحههای کنار صفحهٔ فعلی @default 1 */
|
|
11
|
+
siblings?: number;
|
|
12
|
+
/** متن خلاصه، مثل «نمایش ۱ تا ۱۰ از ۹۷» */
|
|
13
|
+
summary?: ReactNode;
|
|
14
|
+
/** @default "fa" */
|
|
15
|
+
digits?: "fa" | "latin";
|
|
16
|
+
labels?: {
|
|
17
|
+
nav?: string;
|
|
18
|
+
prev?: string;
|
|
19
|
+
next?: string;
|
|
20
|
+
page?: (n: string) => string;
|
|
21
|
+
};
|
|
22
|
+
className?: string;
|
|
23
|
+
}
|
|
24
|
+
/** صفحهبندی با ارقام فارسی؛ صفحهٔ فعلی با aria-current="page" */
|
|
25
|
+
export declare function Pagination({ page, total, onChange, getHref, siblings, summary, digits, labels, className }: PaginationProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { toFaDigits } from "@kashi-ui/persian";
|
|
3
|
+
import { cx } from "./cx.js";
|
|
4
|
+
/** صفحههایی که نمایش داده میشوند؛ null یعنی «…» */
|
|
5
|
+
export function pageRange(page, total, siblings = 1) {
|
|
6
|
+
const out = [];
|
|
7
|
+
const from = Math.max(2, page - siblings);
|
|
8
|
+
const to = Math.min(total - 1, page + siblings);
|
|
9
|
+
out.push(1);
|
|
10
|
+
if (from > 2)
|
|
11
|
+
out.push(from === 3 ? 2 : null);
|
|
12
|
+
for (let p = from; p <= to; p++)
|
|
13
|
+
out.push(p);
|
|
14
|
+
if (to < total - 1)
|
|
15
|
+
out.push(to === total - 2 ? total - 1 : null);
|
|
16
|
+
if (total > 1)
|
|
17
|
+
out.push(total);
|
|
18
|
+
return out;
|
|
19
|
+
}
|
|
20
|
+
const Chevron = ({ dir }) => (_jsx("svg", { "data-k-mirror": "", viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.7, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: dir === "prev" ? "m12 5-5 5 5 5" : "m8 5 5 5-5 5" }) }));
|
|
21
|
+
/** صفحهبندی با ارقام فارسی؛ صفحهٔ فعلی با aria-current="page" */
|
|
22
|
+
export function Pagination({ page, total, onChange, getHref, siblings = 1, summary, digits = "fa", labels = {}, className }) {
|
|
23
|
+
const n = (v) => (digits === "fa" ? toFaDigits(v) : String(v));
|
|
24
|
+
const { nav = "صفحهبندی", prev = "قبلی", next = "بعدی", page: pageLabel = (x) => `صفحهٔ ${x}` } = labels;
|
|
25
|
+
// تابع معمولی، نه کامپوننت: تا دکمهها با هر رندر دوباره ساخته نشوند و فوکوس کیبورد حفظ شود
|
|
26
|
+
const item = ({ to, children, current, disabled, aria, className: c }) => getHref && !disabled ? (_jsx("a", { className: c, href: getHref(to), "aria-current": current ? "page" : undefined, "aria-label": aria, children: children })) : (_jsx("button", { type: "button", className: c, disabled: disabled, "aria-current": current ? "page" : undefined, "aria-label": aria, onClick: () => onChange?.(to), children: children }));
|
|
27
|
+
return (_jsxs("nav", { className: cx("k-pagination", className), "aria-label": nav, children: [item({ to: page - 1, disabled: page <= 1, className: "k-btn k-btn--secondary k-btn--sm", children: _jsxs(_Fragment, { children: [_jsx(Chevron, { dir: "prev" }), prev] }) }), summary && _jsx("span", { className: "k-pagination__summary", children: summary }), _jsx("ul", { className: "k-pagination__pages", role: "list", children: pageRange(page, total, siblings).map((p, i) => (_jsx("li", { children: p === null ? (_jsx("span", { className: "k-pagination__ellipsis", "aria-hidden": "true", children: "\u2026" })) : (item({ to: p, current: p === page, aria: pageLabel(n(p)), className: "k-pagination__page", children: n(p) })) }, i))) }), item({ to: page + 1, disabled: page >= total, className: "k-btn k-btn--secondary k-btn--sm", children: _jsxs(_Fragment, { children: [next, _jsx(Chevron, { dir: "next" })] }) })] }));
|
|
28
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
export interface ProgressProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
/** مقدار؛ بدون آن نوار «نامعین» است */
|
|
4
|
+
value?: number;
|
|
5
|
+
/** @default 100 */
|
|
6
|
+
max?: number;
|
|
7
|
+
/** برچسب بالای نوار؛ اگر نمیدهید aria-label بدهید */
|
|
8
|
+
label?: ReactNode;
|
|
9
|
+
/** نمایش درصد کنار برچسب */
|
|
10
|
+
showValue?: boolean;
|
|
11
|
+
/** @default "md" */
|
|
12
|
+
size?: "sm" | "md" | "lg";
|
|
13
|
+
tone?: "brand" | "success" | "warning" | "error";
|
|
14
|
+
}
|
|
15
|
+
export declare function Progress({ value, max, label, showValue, size, tone, className, "aria-label": ariaLabel, ...rest }: ProgressProps): import("react").JSX.Element;
|
|
16
|
+
export interface SpinnerProps extends HTMLAttributes<HTMLSpanElement> {
|
|
17
|
+
/** @default "در حال بارگذاری" */
|
|
18
|
+
label?: string;
|
|
19
|
+
size?: "sm" | "md" | "lg";
|
|
20
|
+
}
|
|
21
|
+
/** اسپینر با متن صفحهخوان */
|
|
22
|
+
export declare function Spinner({ label, size, className, ...rest }: SpinnerProps): import("react").JSX.Element;
|
package/dist/Progress.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { toFaDigits } from "@kashi-ui/persian";
|
|
3
|
+
import { cx } from "./cx.js";
|
|
4
|
+
export function Progress({ value, max = 100, label, showValue, size = "md", tone = "brand", className, "aria-label": ariaLabel, ...rest }) {
|
|
5
|
+
const pct = value === undefined ? undefined : Math.max(0, Math.min(100, (value / max) * 100));
|
|
6
|
+
const text = pct === undefined ? undefined : `${toFaDigits(Math.round(pct))}٪`;
|
|
7
|
+
const bar = (_jsx("div", { role: "progressbar", "aria-valuemin": 0, "aria-valuemax": max, "aria-valuenow": value, "aria-valuetext": text, "aria-label": ariaLabel ?? (typeof label === "string" ? label : undefined), className: cx("k-progress", size !== "md" && `k-progress--${size}`, tone !== "brand" && `k-progress--${tone}`, !label && className), ...rest, children: _jsx("div", { className: "k-progress__bar", style: pct === undefined ? undefined : { "--k-value": `${pct}%` } }) }));
|
|
8
|
+
if (!label)
|
|
9
|
+
return bar;
|
|
10
|
+
return (_jsxs("div", { className: cx("k-progress-field", className), children: [_jsxs("div", { className: "k-progress-field__head", "aria-hidden": "true", children: [_jsx("span", { className: "k-progress-field__label", children: label }), showValue && text && _jsx("span", { className: "k-progress-field__value", children: text })] }), bar] }));
|
|
11
|
+
}
|
|
12
|
+
/** اسپینر با متن صفحهخوان */
|
|
13
|
+
export function Spinner({ label = "در حال بارگذاری", size = "md", className, ...rest }) {
|
|
14
|
+
return (_jsxs("span", { role: "status", className: className, ...rest, children: [_jsx("span", { className: cx("k-spinner", size !== "md" && `k-spinner--${size}`), "aria-hidden": "true" }), _jsx("span", { className: "k-sr-only", children: label })] }));
|
|
15
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface SkeletonProps {
|
|
2
|
+
width?: string | number;
|
|
3
|
+
height?: string | number;
|
|
4
|
+
/** شکل دایره، مثل جای آواتار */
|
|
5
|
+
circle?: boolean;
|
|
6
|
+
/** چند خط متن */
|
|
7
|
+
lines?: number;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
/** جای خالی هنگام بارگذاری؛ تزئینی است — روی ظرف والد aria-busy="true" بگذارید */
|
|
11
|
+
export declare function Skeleton({ width, height, circle, lines, className }: SkeletonProps): import("react").JSX.Element;
|
package/dist/Skeleton.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cx } from "./cx.js";
|
|
3
|
+
const size = (v) => (typeof v === "number" ? `${v}px` : v);
|
|
4
|
+
/** جای خالی هنگام بارگذاری؛ تزئینی است — روی ظرف والد aria-busy="true" بگذارید */
|
|
5
|
+
export function Skeleton({ width, height, circle, lines, className }) {
|
|
6
|
+
const style = { "--k-skeleton-width": size(width), "--k-skeleton-height": size(height ?? (circle ? width : undefined)) };
|
|
7
|
+
if (lines) {
|
|
8
|
+
return (_jsx("span", { className: cx("k-skeleton-group", className), "aria-hidden": "true", style: style, children: Array.from({ length: lines }, (_, i) => _jsx("span", { className: "k-skeleton k-skeleton--text" }, i)) }));
|
|
9
|
+
}
|
|
10
|
+
return _jsx("span", { className: cx("k-skeleton", circle && "k-skeleton--circle", className), "aria-hidden": "true", style: style });
|
|
11
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export interface Step {
|
|
3
|
+
title: ReactNode;
|
|
4
|
+
description?: ReactNode;
|
|
5
|
+
}
|
|
6
|
+
export interface StepperProps {
|
|
7
|
+
steps: Step[];
|
|
8
|
+
/** شمارهٔ مرحلهٔ فعلی از صفر */
|
|
9
|
+
current: number;
|
|
10
|
+
orientation?: "horizontal" | "vertical";
|
|
11
|
+
/** @default "مراحل" */
|
|
12
|
+
label?: string;
|
|
13
|
+
labels?: {
|
|
14
|
+
complete?: string;
|
|
15
|
+
current?: string;
|
|
16
|
+
};
|
|
17
|
+
className?: string;
|
|
18
|
+
}
|
|
19
|
+
/** مراحل یک فرایند؛ مرحلهٔ فعلی با aria-current="step" و وضعیت هر مرحله برای صفحهخوان */
|
|
20
|
+
export declare function Stepper({ steps, current, orientation, label, labels, className }: StepperProps): import("react").JSX.Element;
|
package/dist/Stepper.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { toFaDigits } from "@kashi-ui/persian";
|
|
3
|
+
import { cx } from "./cx.js";
|
|
4
|
+
const Check = () => (_jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 2.2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "m5 10.5 3.2 3L15 7" }) }));
|
|
5
|
+
/** مراحل یک فرایند؛ مرحلهٔ فعلی با aria-current="step" و وضعیت هر مرحله برای صفحهخوان */
|
|
6
|
+
export function Stepper({ steps, current, orientation = "horizontal", label = "مراحل", labels = {}, className }) {
|
|
7
|
+
const { complete = "انجام شده", current: currentLabel = "مرحلهٔ فعلی" } = labels;
|
|
8
|
+
return (_jsx("ol", { className: cx("k-steps", orientation === "vertical" && "k-steps--vertical", className), "aria-label": label, children: steps.map((s, i) => {
|
|
9
|
+
const status = i < current ? "complete" : i === current ? "current" : "upcoming";
|
|
10
|
+
return (_jsxs("li", { className: "k-steps__step", "data-status": status, "aria-current": status === "current" ? "step" : undefined, children: [_jsx("span", { className: "k-steps__marker", "aria-hidden": "true", children: status === "complete" ? _jsx(Check, {}) : toFaDigits(i + 1) }), _jsxs("span", { className: "k-steps__title", children: [s.title, status !== "upcoming" && _jsx("span", { className: "k-sr-only", children: `، ${status === "complete" ? complete : currentLabel}` })] }), s.description && _jsx("span", { className: "k-steps__description", children: s.description })] }, i));
|
|
11
|
+
}) }));
|
|
12
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -42,3 +42,23 @@ export { Tooltip } from "./Tooltip.js";
|
|
|
42
42
|
export type { TooltipProps } from "./Tooltip.js";
|
|
43
43
|
export { RelativeTime } from "./RelativeTime.js";
|
|
44
44
|
export type { RelativeTimeProps } from "./RelativeTime.js";
|
|
45
|
+
export { Breadcrumb } from "./Breadcrumb.js";
|
|
46
|
+
export type { BreadcrumbProps, BreadcrumbItem } from "./Breadcrumb.js";
|
|
47
|
+
export { Pagination, pageRange } from "./Pagination.js";
|
|
48
|
+
export type { PaginationProps } from "./Pagination.js";
|
|
49
|
+
export { Progress, Spinner } from "./Progress.js";
|
|
50
|
+
export type { ProgressProps, SpinnerProps } from "./Progress.js";
|
|
51
|
+
export { Skeleton } from "./Skeleton.js";
|
|
52
|
+
export type { SkeletonProps } from "./Skeleton.js";
|
|
53
|
+
export { Divider, Kbd, EmptyState } from "./Misc.js";
|
|
54
|
+
export type { DividerProps, KbdProps, EmptyStateProps } from "./Misc.js";
|
|
55
|
+
export { DropdownMenu, MenuItem, MenuSeparator, MenuLabel } from "./DropdownMenu.js";
|
|
56
|
+
export type { DropdownMenuProps, MenuItemProps } from "./DropdownMenu.js";
|
|
57
|
+
export { DataTable } from "./DataTable.js";
|
|
58
|
+
export type { DataTableProps, Column, SortState } from "./DataTable.js";
|
|
59
|
+
export { OtpInput } from "./OtpInput.js";
|
|
60
|
+
export type { OtpInputProps } from "./OtpInput.js";
|
|
61
|
+
export { Accordion, AccordionItem } from "./Accordion.js";
|
|
62
|
+
export type { AccordionProps, AccordionItemProps } from "./Accordion.js";
|
|
63
|
+
export { Stepper } from "./Stepper.js";
|
|
64
|
+
export type { StepperProps, Step } from "./Stepper.js";
|
package/dist/index.js
CHANGED
|
@@ -21,3 +21,13 @@ export { Dialog } from "./Dialog.js";
|
|
|
21
21
|
export { Toaster, toast } from "./Toast.js";
|
|
22
22
|
export { Tooltip } from "./Tooltip.js";
|
|
23
23
|
export { RelativeTime } from "./RelativeTime.js";
|
|
24
|
+
export { Breadcrumb } from "./Breadcrumb.js";
|
|
25
|
+
export { Pagination, pageRange } from "./Pagination.js";
|
|
26
|
+
export { Progress, Spinner } from "./Progress.js";
|
|
27
|
+
export { Skeleton } from "./Skeleton.js";
|
|
28
|
+
export { Divider, Kbd, EmptyState } from "./Misc.js";
|
|
29
|
+
export { DropdownMenu, MenuItem, MenuSeparator, MenuLabel } from "./DropdownMenu.js";
|
|
30
|
+
export { DataTable } from "./DataTable.js";
|
|
31
|
+
export { OtpInput } from "./OtpInput.js";
|
|
32
|
+
export { Accordion, AccordionItem } from "./Accordion.js";
|
|
33
|
+
export { Stepper } from "./Stepper.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kashi-ui/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.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": "^0.
|
|
25
|
+
"@kashi-ui/css": "^0.7.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": "^0.
|
|
63
|
-
"@kashi-ui/persian": "^0.
|
|
62
|
+
"@kashi-ui/bank-logos": "^0.7.0",
|
|
63
|
+
"@kashi-ui/persian": "^0.7.0"
|
|
64
64
|
}
|
|
65
65
|
}
|