@kashi-ui/react 0.7.0 → 0.9.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/Alert.d.ts +11 -0
- package/dist/Alert.js +2 -2
- package/dist/Avatar.d.ts +6 -0
- package/dist/Avatar.js +11 -2
- package/dist/Badge.d.ts +9 -1
- package/dist/Badge.js +3 -2
- package/dist/Button.d.ts +15 -4
- package/dist/Button.js +12 -2
- package/dist/Calendar.d.ts +6 -1
- package/dist/Calendar.js +12 -5
- package/dist/Card.d.ts +17 -3
- package/dist/Card.js +13 -4
- package/dist/Checkbox.d.ts +9 -0
- package/dist/Checkbox.js +6 -6
- package/dist/Combobox.d.ts +48 -0
- package/dist/Combobox.js +143 -0
- package/dist/CommandPalette.d.ts +37 -0
- package/dist/CommandPalette.js +95 -0
- package/dist/DataTable.d.ts +28 -1
- package/dist/DataTable.js +17 -10
- package/dist/DateRangePicker.d.ts +50 -0
- package/dist/DateRangePicker.js +94 -0
- package/dist/Dialog.d.ts +4 -2
- package/dist/Dialog.js +2 -2
- package/dist/DropdownMenu.d.ts +3 -1
- package/dist/DropdownMenu.js +7 -5
- package/dist/Field.d.ts +15 -1
- package/dist/Field.js +4 -2
- package/dist/FileUpload.d.ts +39 -0
- package/dist/FileUpload.js +90 -0
- package/dist/Input.d.ts +34 -0
- package/dist/Input.js +57 -6
- package/dist/NumberInput.d.ts +29 -0
- package/dist/NumberInput.js +56 -0
- package/dist/Popover.d.ts +19 -0
- package/dist/Popover.js +58 -0
- package/dist/Progress.d.ts +3 -1
- package/dist/Progress.js +6 -1
- package/dist/SideNav.d.ts +28 -0
- package/dist/SideNav.js +22 -0
- package/dist/Slider.d.ts +32 -0
- package/dist/Slider.js +33 -0
- package/dist/Stat.d.ts +24 -0
- package/dist/Stat.js +17 -0
- package/dist/Tabs.d.ts +5 -1
- package/dist/Tabs.js +8 -9
- package/dist/TagInput.d.ts +33 -0
- package/dist/TagInput.js +88 -0
- package/dist/Timeline.d.ts +19 -0
- package/dist/Timeline.js +8 -0
- package/dist/Toast.d.ts +22 -8
- package/dist/Toast.js +55 -12
- package/dist/Tooltip.d.ts +2 -2
- package/dist/Tooltip.js +1 -1
- package/dist/index.d.ts +28 -6
- package/dist/index.js +13 -2
- package/package.json +4 -4
package/dist/TagInput.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useId, useRef, useState } from "react";
|
|
3
|
+
import { normalizePersian, toFaDigits } from "@kashi-ui/persian";
|
|
4
|
+
import { Badge } from "./Badge.js";
|
|
5
|
+
import { Field, describedBy } from "./Field.js";
|
|
6
|
+
import { mergeRefs } from "./utils.js";
|
|
7
|
+
/** ورود چند مقدار، مثل مهارتها یا ایمیلها؛ Enter یا ویرگول (, یا ،) ثبت میکند و Backspace آخری را حذف میکند */
|
|
8
|
+
export const TagInput = forwardRef(function TagInput({ label, hint, error, value, defaultValue = [], onChange, placeholder, separators = ["Enter", ",", "،"], validate, max, allowDuplicates = false, tone = "brand", disabled, name, id, className, labels = {}, }, ref) {
|
|
9
|
+
const autoId = useId();
|
|
10
|
+
const inputId = id ?? autoId;
|
|
11
|
+
const [inner, setInner] = useState(defaultValue);
|
|
12
|
+
const tags = value !== undefined ? value : inner;
|
|
13
|
+
const [text, setText] = useState("");
|
|
14
|
+
const [localError, setLocalError] = useState();
|
|
15
|
+
const [announce, setAnnounce] = useState("");
|
|
16
|
+
const inputRef = useRef(null);
|
|
17
|
+
const { added = (t) => `${t} اضافه شد`, removed = (t) => `${t} حذف شد`, remove = (t) => `حذف ${t}`, max: maxMsg = (n) => `حداکثر ${toFaDigits(n)} مورد`, duplicate = "این مورد قبلاً اضافه شده است.", } = labels;
|
|
18
|
+
const set = (next) => {
|
|
19
|
+
if (value === undefined)
|
|
20
|
+
setInner(next);
|
|
21
|
+
onChange?.(next);
|
|
22
|
+
};
|
|
23
|
+
/** چند برچسب را یکجا اضافه میکند؛ اگر یکی نامعتبر بود، متنش در فیلد میماند */
|
|
24
|
+
const addMany = (raw) => {
|
|
25
|
+
let next = [...tags];
|
|
26
|
+
for (const r of raw) {
|
|
27
|
+
const t = normalizePersian(r).trim();
|
|
28
|
+
if (!t)
|
|
29
|
+
continue;
|
|
30
|
+
if (max !== undefined && next.length >= max)
|
|
31
|
+
return fail(maxMsg(max), t);
|
|
32
|
+
if (!allowDuplicates && next.includes(t))
|
|
33
|
+
return fail(duplicate, t);
|
|
34
|
+
const err = validate?.(t);
|
|
35
|
+
if (err)
|
|
36
|
+
return fail(err, t);
|
|
37
|
+
next = [...next, t];
|
|
38
|
+
setAnnounce(added(t));
|
|
39
|
+
}
|
|
40
|
+
set(next);
|
|
41
|
+
setText("");
|
|
42
|
+
setLocalError(undefined);
|
|
43
|
+
function fail(msg, t) {
|
|
44
|
+
set(next);
|
|
45
|
+
setText(t);
|
|
46
|
+
setLocalError(msg);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const removeAt = (i) => {
|
|
50
|
+
const t = tags[i];
|
|
51
|
+
set(tags.filter((_, j) => j !== i));
|
|
52
|
+
setAnnounce(removed(t));
|
|
53
|
+
inputRef.current?.focus();
|
|
54
|
+
};
|
|
55
|
+
const singleSeps = separators.filter((s) => s.length === 1).map((s) => `\\${s}`).join("");
|
|
56
|
+
const onKeyDown = (e) => {
|
|
57
|
+
if (separators.includes(e.key) && text.trim()) {
|
|
58
|
+
e.preventDefault();
|
|
59
|
+
addMany([text]);
|
|
60
|
+
}
|
|
61
|
+
else if (e.key === "Backspace" && !text && tags.length) {
|
|
62
|
+
removeAt(tags.length - 1);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const onPaste = (e) => {
|
|
66
|
+
const data = e.clipboardData.getData("text");
|
|
67
|
+
const parts = data.split(new RegExp(`[${singleSeps}\\n\\t]`));
|
|
68
|
+
if (parts.length > 1) {
|
|
69
|
+
e.preventDefault();
|
|
70
|
+
addMany(parts);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const shownError = error ?? localError;
|
|
74
|
+
return (_jsxs(Field, { id: inputId, label: label, hint: hint, error: shownError, className: className, children: [_jsxs("div", { className: "k-tag-input", "data-invalid": shownError ? "" : undefined, onClick: () => inputRef.current?.focus(), children: [tags.map((t, i) => (_jsx(Badge, { tone: tone, onRemove: disabled ? undefined : () => removeAt(i), removeLabel: remove(t), children: t }, `${t}-${i}`))), _jsx("input", { ref: mergeRefs(ref, inputRef), id: inputId, className: "k-tag-input__control", value: text, placeholder: tags.length ? undefined : placeholder, disabled: disabled, "aria-invalid": shownError ? true : undefined, "aria-describedby": describedBy(inputId, hint, shownError), onChange: (e) => {
|
|
75
|
+
const v = e.target.value;
|
|
76
|
+
setLocalError(undefined);
|
|
77
|
+
// صفحهکلید موبایل و IME رویداد کلید نمیفرستند؛ جداکننده را در متن هم پیدا کن
|
|
78
|
+
const parts = v.split(new RegExp(`[${singleSeps}]`));
|
|
79
|
+
if (singleSeps && parts.length > 1) {
|
|
80
|
+
const rest = parts.pop() ?? "";
|
|
81
|
+
addMany(parts);
|
|
82
|
+
if (rest)
|
|
83
|
+
setText(rest);
|
|
84
|
+
}
|
|
85
|
+
else
|
|
86
|
+
setText(v);
|
|
87
|
+
}, onKeyDown: onKeyDown, onPaste: onPaste, onBlur: () => text.trim() && addMany([text]) })] }), _jsx("span", { className: "k-sr-only", "aria-live": "polite", children: announce }), name && tags.map((t, i) => _jsx("input", { type: "hidden", name: name, value: t }, i))] }));
|
|
88
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
export interface TimelineItem {
|
|
3
|
+
id?: string | number;
|
|
4
|
+
title: ReactNode;
|
|
5
|
+
/** Date به شکل نسبی («۵ دقیقه پیش») نمایش داده میشود */
|
|
6
|
+
time?: Date | ReactNode;
|
|
7
|
+
/** آیکون یا آواتار داخل نشانگر */
|
|
8
|
+
icon?: ReactNode;
|
|
9
|
+
tone?: "neutral" | "brand" | "success" | "error";
|
|
10
|
+
/** متن یا محتوای اضافه در کادر زیر عنوان، مثل متن کامنت */
|
|
11
|
+
content?: ReactNode;
|
|
12
|
+
}
|
|
13
|
+
export interface TimelineProps extends HTMLAttributes<HTMLOListElement> {
|
|
14
|
+
items: TimelineItem[];
|
|
15
|
+
/** @default "fa" */
|
|
16
|
+
digits?: "fa" | "latin";
|
|
17
|
+
}
|
|
18
|
+
/** خط زمانی رویدادها و فعالیتها، به ترتیب دادهشده */
|
|
19
|
+
export declare function Timeline({ items, digits, className, ...rest }: TimelineProps): import("react").JSX.Element;
|
package/dist/Timeline.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cx } from "./cx.js";
|
|
3
|
+
import { RelativeTime } from "./RelativeTime.js";
|
|
4
|
+
const Dot = () => _jsx("svg", { viewBox: "0 0 20 20", "aria-hidden": "true", children: _jsx("circle", { cx: "10", cy: "10", r: "3", fill: "currentColor" }) });
|
|
5
|
+
/** خط زمانی رویدادها و فعالیتها، به ترتیب دادهشده */
|
|
6
|
+
export function Timeline({ items, digits = "fa", className, ...rest }) {
|
|
7
|
+
return (_jsx("ol", { className: cx("k-timeline", className), ...rest, children: items.map((it, i) => (_jsxs("li", { className: "k-timeline__item", "data-tone": it.tone && it.tone !== "neutral" ? it.tone : undefined, children: [_jsx("span", { className: "k-timeline__marker", "aria-hidden": "true", children: it.icon ?? _jsx(Dot, {}) }), _jsxs("div", { className: "k-timeline__body", children: [_jsx("p", { className: "k-timeline__title", children: it.title }), it.time !== undefined && (_jsx("span", { className: "k-timeline__time", children: it.time instanceof Date ? _jsx(RelativeTime, { date: it.time, digits: digits }) : it.time })), it.content && _jsx("div", { className: "k-timeline__content", children: it.content })] })] }, it.id ?? i))) }));
|
|
8
|
+
}
|
package/dist/Toast.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
export type ToastTone = "neutral" | "success" | "error" | "warning" | "info";
|
|
3
3
|
export interface ToastOptions {
|
|
4
|
+
/** شناسهٔ دلخواه؛ toast() با همین شناسه اعلان قبلی را بهروز میکند */
|
|
5
|
+
id?: number | string;
|
|
4
6
|
title: ReactNode;
|
|
5
7
|
description?: ReactNode;
|
|
6
8
|
tone?: ToastTone;
|
|
@@ -12,21 +14,33 @@ export interface ToastOptions {
|
|
|
12
14
|
};
|
|
13
15
|
}
|
|
14
16
|
/** نمایش اعلان کوتاه؛ شناسهٔ آن را برمیگرداند */
|
|
15
|
-
export declare function toast(options: ToastOptions | string): number;
|
|
17
|
+
export declare function toast(options: ToastOptions | string): number | string;
|
|
16
18
|
export declare namespace toast {
|
|
17
|
-
var success: (title: ReactNode, o?: Omit<ToastOptions, "title" | "tone">) => number;
|
|
18
|
-
var error: (title: ReactNode, o?: Omit<ToastOptions, "title" | "tone">) => number;
|
|
19
|
-
var warning: (title: ReactNode, o?: Omit<ToastOptions, "title" | "tone">) => number;
|
|
20
|
-
var info: (title: ReactNode, o?: Omit<ToastOptions, "title" | "tone">) => number;
|
|
21
|
-
var dismiss: (id: number) => void;
|
|
19
|
+
var success: (title: ReactNode, o?: Omit<ToastOptions, "title" | "tone">) => string | number;
|
|
20
|
+
var error: (title: ReactNode, o?: Omit<ToastOptions, "title" | "tone">) => string | number;
|
|
21
|
+
var warning: (title: ReactNode, o?: Omit<ToastOptions, "title" | "tone">) => string | number;
|
|
22
|
+
var info: (title: ReactNode, o?: Omit<ToastOptions, "title" | "tone">) => string | number;
|
|
23
|
+
var dismiss: (id: number | string) => void;
|
|
24
|
+
var promise: <T>(promise: Promise<T>, msgs: {
|
|
25
|
+
loading: ReactNode;
|
|
26
|
+
success: Msg<T>;
|
|
27
|
+
error: Msg<unknown>;
|
|
28
|
+
}) => Promise<T>;
|
|
22
29
|
}
|
|
30
|
+
type Msg<T> = ReactNode | ((value: T) => ReactNode);
|
|
31
|
+
export type ToastPlacement = "top-start" | "top-center" | "top-end" | "bottom-start" | "bottom-center" | "bottom-end";
|
|
23
32
|
export interface ToasterProps {
|
|
24
|
-
/** @default "bottom" */
|
|
33
|
+
/** جای اعلانها؛ در RTL «end» سمت چپ است @default "bottom-end" */
|
|
34
|
+
placement?: ToastPlacement;
|
|
35
|
+
/** @deprecated از placement استفاده کنید */
|
|
25
36
|
position?: "top" | "bottom";
|
|
37
|
+
/** بیشترین تعداد اعلان همزمان؛ قدیمیترها پنهان میشوند @default 5 */
|
|
38
|
+
max?: number;
|
|
26
39
|
/** @default "اعلانها" */
|
|
27
40
|
label?: string;
|
|
28
41
|
/** @default "بستن اعلان" */
|
|
29
42
|
closeLabel?: string;
|
|
30
43
|
}
|
|
31
44
|
/** محل نمایش اعلانها؛ یک بار در ریشهٔ برنامه قرار دهید */
|
|
32
|
-
export declare function Toaster({ position, label, closeLabel }: ToasterProps): import("react").JSX.Element;
|
|
45
|
+
export declare function Toaster({ placement, position, max, label, closeLabel }: ToasterProps): import("react").JSX.Element;
|
|
46
|
+
export {};
|
package/dist/Toast.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useRef, useState, useSyncExternalStore } from "react";
|
|
2
|
+
import { useEffect, useId, useRef, useState, useSyncExternalStore } from "react";
|
|
3
|
+
import { isDev } from "./utils.js";
|
|
3
4
|
import { cx } from "./cx.js";
|
|
4
5
|
import { CloseIcon, ErrorIcon, InfoIcon, SuccessIcon, WarningIcon } from "./icons.js";
|
|
5
6
|
// مخزن سادهٔ سراسری؛ هر جای برنامه میتواند toast() را صدا بزند
|
|
@@ -19,25 +20,43 @@ function dismiss(id) {
|
|
|
19
20
|
emit();
|
|
20
21
|
}, 200);
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
items =
|
|
23
|
+
function upsert(o) {
|
|
24
|
+
const id = o.id ?? nextId++;
|
|
25
|
+
const existing = items.find((t) => t.id === id);
|
|
26
|
+
const item = { ...o, id, closing: false, version: (existing?.version ?? 0) + 1 };
|
|
27
|
+
items = existing ? items.map((t) => (t.id === id ? item : t)) : [...items, item];
|
|
27
28
|
emit();
|
|
28
29
|
return id;
|
|
29
30
|
}
|
|
31
|
+
/** نمایش اعلان کوتاه؛ شناسهٔ آن را برمیگرداند */
|
|
32
|
+
export function toast(options) {
|
|
33
|
+
return upsert(typeof options === "string" ? { title: options } : options);
|
|
34
|
+
}
|
|
30
35
|
toast.success = (title, o = {}) => toast({ ...o, title, tone: "success" });
|
|
31
36
|
toast.error = (title, o = {}) => toast({ ...o, title, tone: "error" });
|
|
32
37
|
toast.warning = (title, o = {}) => toast({ ...o, title, tone: "warning" });
|
|
33
38
|
toast.info = (title, o = {}) => toast({ ...o, title, tone: "info" });
|
|
34
39
|
toast.dismiss = dismiss;
|
|
40
|
+
/**
|
|
41
|
+
* اعلان برای کار زمانبر: «در حال ذخیره…» و سپس «ذخیره شد» یا پیام خطا، در همان اعلان.
|
|
42
|
+
* toast.promise(save(), { loading: "در حال ذخیره…", success: "ذخیره شد", error: (e) => e.message })
|
|
43
|
+
*/
|
|
44
|
+
toast.promise = (promise, msgs) => {
|
|
45
|
+
const id = upsert({ title: msgs.loading, tone: "info", duration: Infinity, loading: true });
|
|
46
|
+
const show = (m, v) => (typeof m === "function" ? m(v) : m);
|
|
47
|
+
promise.then((v) => upsert({ id, title: show(msgs.success, v), tone: "success" }), (e) => upsert({ id, title: show(msgs.error, e), tone: "error" }));
|
|
48
|
+
return promise;
|
|
49
|
+
};
|
|
35
50
|
const ICONS = {
|
|
36
51
|
neutral: InfoIcon, info: InfoIcon, success: SuccessIcon, warning: WarningIcon, error: ErrorIcon,
|
|
37
52
|
};
|
|
38
53
|
function ToastView({ t, closeLabel }) {
|
|
39
54
|
const duration = t.duration ?? (t.action ? Infinity : 5000);
|
|
40
55
|
const remaining = useRef(duration);
|
|
56
|
+
// اعلان بهروزشده (مثلاً پس از toast.promise) زمانش از نو شروع میشود
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
remaining.current = duration;
|
|
59
|
+
}, [t.version]);
|
|
41
60
|
const started = useRef(0);
|
|
42
61
|
const timer = useRef();
|
|
43
62
|
const [paused, setPaused] = useState(false);
|
|
@@ -51,15 +70,39 @@ function ToastView({ t, closeLabel }) {
|
|
|
51
70
|
clearTimeout(timer.current);
|
|
52
71
|
remaining.current -= Date.now() - started.current;
|
|
53
72
|
};
|
|
54
|
-
}, [paused, t.closing]);
|
|
73
|
+
}, [paused, t.closing, t.version]);
|
|
55
74
|
const Icon = ICONS[t.tone ?? "neutral"];
|
|
56
|
-
|
|
75
|
+
const icon = t.loading ? _jsx("span", { className: "k-spinner k-spinner--sm", style: { color: "inherit" } }) : _jsx(Icon, {});
|
|
76
|
+
return (_jsxs("li", { className: cx("k-toast", t.tone && t.tone !== "neutral" && `k-toast--${t.tone}`), "data-state": t.closing ? "closing" : "open", role: t.tone === "error" ? "alert" : "status", onMouseEnter: () => setPaused(true), onMouseLeave: () => setPaused(false), onFocus: () => setPaused(true), onBlur: () => setPaused(false), onKeyDown: (e) => e.key === "Escape" && dismiss(t.id), children: [_jsx("span", { className: "k-toast__icon", "aria-hidden": "true", children: icon }), _jsxs("div", { className: "k-toast__content", children: [_jsx("p", { className: "k-toast__title", children: t.title }), t.description && _jsx("p", { className: "k-toast__description", children: t.description }), t.action && (_jsx("button", { type: "button", className: "k-btn k-btn--link k-toast__action", onClick: () => {
|
|
57
77
|
t.action.onClick();
|
|
58
78
|
dismiss(t.id);
|
|
59
|
-
}, children: t.action.label }))] }), _jsx("button", { type: "button", className: "k-btn k-btn--tertiary k-btn--icon k-btn--sm k-toast__close", "aria-label": closeLabel, onClick: () => dismiss(t.id), children: _jsx(CloseIcon, {}) }), Number.isFinite(duration) && _jsx("span", { className: "k-toast__progress", "aria-hidden": "true", style: { animationDuration: `${duration}ms` } })] }));
|
|
79
|
+
}, children: t.action.label }))] }), _jsx("button", { type: "button", className: "k-btn k-btn--tertiary k-btn--icon k-btn--sm k-toast__close", "aria-label": closeLabel, onClick: () => dismiss(t.id), children: _jsx(CloseIcon, {}) }), Number.isFinite(duration) && _jsx("span", { className: "k-toast__progress", "aria-hidden": "true", style: { animationDuration: `${duration}ms` } }, t.version)] }));
|
|
60
80
|
}
|
|
81
|
+
// اگر چند Toaster همزمان در صفحه باشد، فقط آخرینِ نصبشده اعلانها را نشان میدهد تا تکراری نشوند
|
|
82
|
+
let toasters = [];
|
|
83
|
+
const toasterListeners = new Set();
|
|
84
|
+
const emitToasters = () => toasterListeners.forEach((l) => l());
|
|
85
|
+
const subscribeToasters = (l) => {
|
|
86
|
+
toasterListeners.add(l);
|
|
87
|
+
return () => toasterListeners.delete(l);
|
|
88
|
+
};
|
|
61
89
|
/** محل نمایش اعلانها؛ یک بار در ریشهٔ برنامه قرار دهید */
|
|
62
|
-
export function Toaster({ position =
|
|
63
|
-
const
|
|
64
|
-
|
|
90
|
+
export function Toaster({ placement, position, max = 5, label = "اعلانها", closeLabel = "بستن اعلان" }) {
|
|
91
|
+
const id = useId();
|
|
92
|
+
const all = useSyncExternalStore(subscribe, () => items, () => items);
|
|
93
|
+
const active = useSyncExternalStore(subscribeToasters, () => toasters[toasters.length - 1], () => undefined);
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
toasters = [...toasters, id];
|
|
96
|
+
if (isDev() && toasters.length > 1)
|
|
97
|
+
console.warn("[kashi] بیش از یک <Toaster> در صفحه است؛ فقط آخرین آنها اعلانها را نشان میدهد.");
|
|
98
|
+
emitToasters();
|
|
99
|
+
return () => {
|
|
100
|
+
toasters = toasters.filter((t) => t !== id);
|
|
101
|
+
emitToasters();
|
|
102
|
+
};
|
|
103
|
+
}, [id]);
|
|
104
|
+
// تا وقتی Toasterی ثبت نشده (مثلاً رندر سرور) همین Toaster نشان میدهد
|
|
105
|
+
const list = active === undefined || active === id ? all.slice(-max) : [];
|
|
106
|
+
const place = placement ?? (position === "top" ? "top-end" : "bottom-end");
|
|
107
|
+
return (_jsx("section", { "aria-label": label, children: _jsx("ol", { className: cx("k-toaster", `k-toaster--${place}`), "data-placement": place, "aria-live": "polite", children: list.map((t) => _jsx(ToastView, { t: t, closeLabel: closeLabel }, t.id)) }) }));
|
|
65
108
|
}
|
package/dist/Tooltip.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ export interface TooltipProps {
|
|
|
4
4
|
content: ReactNode;
|
|
5
5
|
/** عنصر فوکوسپذیر، معمولاً یک دکمه */
|
|
6
6
|
children: ReactElement;
|
|
7
|
-
/** @default "top" */
|
|
8
|
-
placement?: "top" | "bottom";
|
|
7
|
+
/** «start»/«end» کنار عنصر؛ در RTL «start» سمت راست است @default "top" */
|
|
8
|
+
placement?: "top" | "bottom" | "start" | "end";
|
|
9
9
|
/** تأخیر نمایش با hover بر حسب میلیثانیه @default 300 */
|
|
10
10
|
delay?: number;
|
|
11
11
|
}
|
package/dist/Tooltip.js
CHANGED
|
@@ -30,5 +30,5 @@ export function Tooltip({ content, children, placement = "top", delay = 300 }) {
|
|
|
30
30
|
"aria-describedby": [children.props["aria-describedby"], id].filter(Boolean).join(" "),
|
|
31
31
|
})
|
|
32
32
|
: children;
|
|
33
|
-
return (_jsxs("span", { className: "k-tooltip-anchor", onMouseEnter: () => show(delay), onMouseLeave: hide, onFocus: () => show(0), onBlur: hide, children: [child, _jsx("span", { role: "tooltip", id: id, className: cx("k-tooltip", placement
|
|
33
|
+
return (_jsxs("span", { className: "k-tooltip-anchor", onMouseEnter: () => show(delay), onMouseLeave: hide, onFocus: () => show(0), onBlur: hide, children: [child, _jsx("span", { role: "tooltip", id: id, className: cx("k-tooltip", placement !== "top" && `k-tooltip--${placement}`), hidden: !open, children: content })] }));
|
|
34
34
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
export { Button } from "./Button.js";
|
|
2
2
|
export type { ButtonProps, ButtonVariant, ButtonSize } from "./Button.js";
|
|
3
3
|
export { Input, Textarea } from "./Input.js";
|
|
4
|
-
export type { InputProps, InputSize, TextareaProps } from "./Input.js";
|
|
4
|
+
export type { InputProps, InputSize, InputClassNames, TextareaProps } from "./Input.js";
|
|
5
5
|
export { Badge } from "./Badge.js";
|
|
6
6
|
export type { BadgeProps, BadgeTone } from "./Badge.js";
|
|
7
|
-
export { Card, CardHeader, CardTitle, CardDescription, CardBody, CardFooter } from "./Card.js";
|
|
8
|
-
export type { CardProps } from "./Card.js";
|
|
7
|
+
export { Card, CardHeader, CardTitle, CardDescription, CardBody, CardFooter, CardMedia } from "./Card.js";
|
|
8
|
+
export type { CardProps, CardHeaderProps, CardMediaProps } from "./Card.js";
|
|
9
9
|
export { Alert } from "./Alert.js";
|
|
10
10
|
export type { AlertProps, AlertTone } from "./Alert.js";
|
|
11
|
-
export { Avatar, AvatarGroup, initials } from "./Avatar.js";
|
|
11
|
+
export { Avatar, AvatarGroup, initials, autoTone } from "./Avatar.js";
|
|
12
12
|
export type { AvatarProps, AvatarGroupProps, AvatarSize, AvatarStatus } from "./Avatar.js";
|
|
13
13
|
export { Checkbox, Switch } from "./Checkbox.js";
|
|
14
|
-
export type { CheckboxProps, SwitchProps } from "./Checkbox.js";
|
|
14
|
+
export type { CheckboxProps, SwitchProps, CheckClassNames } from "./Checkbox.js";
|
|
15
15
|
export { cx } from "./cx.js";
|
|
16
16
|
export { toFaDigits } from "./utils.js";
|
|
17
17
|
export { NationalIdInput } from "./NationalIdInput.js";
|
|
@@ -37,7 +37,7 @@ export type { TabsProps, TabListProps, TabProps, TabPanelProps } from "./Tabs.js
|
|
|
37
37
|
export { Dialog } from "./Dialog.js";
|
|
38
38
|
export type { DialogProps } from "./Dialog.js";
|
|
39
39
|
export { Toaster, toast } from "./Toast.js";
|
|
40
|
-
export type { ToasterProps, ToastOptions, ToastTone } from "./Toast.js";
|
|
40
|
+
export type { ToasterProps, ToastOptions, ToastTone, ToastPlacement } from "./Toast.js";
|
|
41
41
|
export { Tooltip } from "./Tooltip.js";
|
|
42
42
|
export type { TooltipProps } from "./Tooltip.js";
|
|
43
43
|
export { RelativeTime } from "./RelativeTime.js";
|
|
@@ -62,3 +62,25 @@ export { Accordion, AccordionItem } from "./Accordion.js";
|
|
|
62
62
|
export type { AccordionProps, AccordionItemProps } from "./Accordion.js";
|
|
63
63
|
export { Stepper } from "./Stepper.js";
|
|
64
64
|
export type { StepperProps, Step } from "./Stepper.js";
|
|
65
|
+
export { Combobox, defaultFilter, highlight, searchText } from "./Combobox.js";
|
|
66
|
+
export type { ComboboxOption, ComboboxProps } from "./Combobox.js";
|
|
67
|
+
export { CommandPalette } from "./CommandPalette.js";
|
|
68
|
+
export type { CommandPaletteProps, CommandItem } from "./CommandPalette.js";
|
|
69
|
+
export { TagInput } from "./TagInput.js";
|
|
70
|
+
export type { TagInputProps } from "./TagInput.js";
|
|
71
|
+
export { FileUpload, formatBytes } from "./FileUpload.js";
|
|
72
|
+
export type { FileUploadProps, FileItem, FileStatus } from "./FileUpload.js";
|
|
73
|
+
export { Slider } from "./Slider.js";
|
|
74
|
+
export type { SliderProps } from "./Slider.js";
|
|
75
|
+
export { NumberInput } from "./NumberInput.js";
|
|
76
|
+
export type { NumberInputProps } from "./NumberInput.js";
|
|
77
|
+
export { Popover } from "./Popover.js";
|
|
78
|
+
export type { PopoverProps } from "./Popover.js";
|
|
79
|
+
export { DateRangePicker, defaultRangePresets } from "./DateRangePicker.js";
|
|
80
|
+
export type { DateRange, DateRangePreset, DateRangePickerProps } from "./DateRangePicker.js";
|
|
81
|
+
export { StatCard, StatGrid } from "./Stat.js";
|
|
82
|
+
export type { StatCardProps } from "./Stat.js";
|
|
83
|
+
export { Timeline } from "./Timeline.js";
|
|
84
|
+
export type { TimelineItem, TimelineProps } from "./Timeline.js";
|
|
85
|
+
export { SideNav } from "./SideNav.js";
|
|
86
|
+
export type { SideNavItem, SideNavSection, SideNavProps } from "./SideNav.js";
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { Button } from "./Button.js";
|
|
2
2
|
export { Input, Textarea } from "./Input.js";
|
|
3
3
|
export { Badge } from "./Badge.js";
|
|
4
|
-
export { Card, CardHeader, CardTitle, CardDescription, CardBody, CardFooter } from "./Card.js";
|
|
4
|
+
export { Card, CardHeader, CardTitle, CardDescription, CardBody, CardFooter, CardMedia } from "./Card.js";
|
|
5
5
|
export { Alert } from "./Alert.js";
|
|
6
|
-
export { Avatar, AvatarGroup, initials } from "./Avatar.js";
|
|
6
|
+
export { Avatar, AvatarGroup, initials, autoTone } from "./Avatar.js";
|
|
7
7
|
export { Checkbox, Switch } from "./Checkbox.js";
|
|
8
8
|
export { cx } from "./cx.js";
|
|
9
9
|
export { toFaDigits } from "./utils.js";
|
|
@@ -31,3 +31,14 @@ export { DataTable } from "./DataTable.js";
|
|
|
31
31
|
export { OtpInput } from "./OtpInput.js";
|
|
32
32
|
export { Accordion, AccordionItem } from "./Accordion.js";
|
|
33
33
|
export { Stepper } from "./Stepper.js";
|
|
34
|
+
export { Combobox, defaultFilter, highlight, searchText } from "./Combobox.js";
|
|
35
|
+
export { CommandPalette } from "./CommandPalette.js";
|
|
36
|
+
export { TagInput } from "./TagInput.js";
|
|
37
|
+
export { FileUpload, formatBytes } from "./FileUpload.js";
|
|
38
|
+
export { Slider } from "./Slider.js";
|
|
39
|
+
export { NumberInput } from "./NumberInput.js";
|
|
40
|
+
export { Popover } from "./Popover.js";
|
|
41
|
+
export { DateRangePicker, defaultRangePresets } from "./DateRangePicker.js";
|
|
42
|
+
export { StatCard, StatGrid } from "./Stat.js";
|
|
43
|
+
export { Timeline } from "./Timeline.js";
|
|
44
|
+
export { SideNav } from "./SideNav.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kashi-ui/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.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.9.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.9.0",
|
|
63
|
+
"@kashi-ui/persian": "^0.9.0"
|
|
64
64
|
}
|
|
65
65
|
}
|