@kashi-ui/react 2.2.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Chart.d.ts +25 -5
- package/dist/Chart.js +22 -5
- package/dist/Checkbox.d.ts +2 -0
- package/dist/Checkbox.js +8 -6
- package/dist/ChipGroup.d.ts +3 -1
- package/dist/ChipGroup.js +4 -2
- package/dist/Combobox.d.ts +2 -0
- package/dist/Combobox.js +7 -3
- package/dist/DatePicker.js +3 -2
- package/dist/DateRangePicker.d.ts +3 -1
- package/dist/DateRangePicker.js +2 -2
- package/dist/MultiSelect.d.ts +5 -1
- package/dist/MultiSelect.js +5 -3
- package/dist/NumberInput.d.ts +2 -0
- package/dist/NumberInput.js +3 -3
- package/dist/OtpInput.d.ts +2 -0
- package/dist/OtpInput.js +2 -2
- package/dist/Radio.d.ts +3 -1
- package/dist/Radio.js +6 -3
- package/dist/SearchSuggest.d.ts +5 -1
- package/dist/SearchSuggest.js +6 -4
- package/dist/SegmentedControl.d.ts +3 -1
- package/dist/SegmentedControl.js +4 -2
- package/dist/Select.d.ts +6 -0
- package/dist/Select.js +17 -15
- package/dist/Slider.d.ts +3 -1
- package/dist/Slider.js +5 -3
- package/dist/Stat.d.ts +2 -0
- package/dist/Stat.js +2 -2
- package/dist/SwatchGroup.d.ts +3 -1
- package/dist/SwatchGroup.js +8 -3
- package/dist/TagInput.d.ts +2 -0
- package/dist/TagInput.js +3 -3
- package/package.json +4 -4
package/dist/Chart.d.ts
CHANGED
|
@@ -13,6 +13,10 @@ export declare function ChartTip({ x, y, title, rows, width }: {
|
|
|
13
13
|
width?: number;
|
|
14
14
|
}): import("react").JSX.Element;
|
|
15
15
|
export interface BarChartProps {
|
|
16
|
+
/** داده در راه است؛ اسکلت جای نمودار */
|
|
17
|
+
loading?: boolean;
|
|
18
|
+
/** پیام نمودار بیداده @default «دادهای برای نمایش نیست.» */
|
|
19
|
+
emptyMessage?: ReactNode;
|
|
16
20
|
/** عنوان نمودار؛ نام دسترسپذیر هم هست */
|
|
17
21
|
title: string;
|
|
18
22
|
/** یک سری */
|
|
@@ -31,8 +35,12 @@ export interface BarChartProps {
|
|
|
31
35
|
className?: string;
|
|
32
36
|
}
|
|
33
37
|
/** نمودار ستونی؛ تکسری یا انباشته تا چهار سری. با موس یا Tab روی هر ستون مقدار دقیق نمایش داده میشود */
|
|
34
|
-
export declare function BarChart({ title, data, series, labels, format, labelMax, height, className }: BarChartProps): import("react").JSX.Element;
|
|
38
|
+
export declare function BarChart({ title, data, series, labels, format, labelMax, height, className, loading, emptyMessage }: BarChartProps): import("react").JSX.Element;
|
|
35
39
|
export interface BarListProps {
|
|
40
|
+
/** داده در راه است؛ اسکلت جای نمودار */
|
|
41
|
+
loading?: boolean;
|
|
42
|
+
/** پیام نمودار بیداده @default «دادهای برای نمایش نیست.» */
|
|
43
|
+
emptyMessage?: ReactNode;
|
|
36
44
|
title: string;
|
|
37
45
|
/** به ترتیب دادهشده؛ معمولاً از بیشترین به کمترین */
|
|
38
46
|
data: {
|
|
@@ -44,8 +52,12 @@ export interface BarListProps {
|
|
|
44
52
|
className?: string;
|
|
45
53
|
}
|
|
46
54
|
/** میلههای افقی برای رتبهبندی با نامهای بلند، مثل پربازدیدترین صفحهها */
|
|
47
|
-
export declare function BarList({ title, data, format, className }: BarListProps): import("react").JSX.Element;
|
|
55
|
+
export declare function BarList({ title, data, format, className, loading, emptyMessage }: BarListProps): import("react").JSX.Element;
|
|
48
56
|
export interface ProportionBarProps {
|
|
57
|
+
/** داده در راه است؛ اسکلت جای نمودار */
|
|
58
|
+
loading?: boolean;
|
|
59
|
+
/** پیام نمودار بیداده @default «دادهای برای نمایش نیست.» */
|
|
60
|
+
emptyMessage?: ReactNode;
|
|
49
61
|
title: string;
|
|
50
62
|
/** حداکثر چهار بخش؛ بیشتر را در «سایر» جمع کنید */
|
|
51
63
|
data: {
|
|
@@ -58,8 +70,12 @@ export interface ProportionBarProps {
|
|
|
58
70
|
className?: string;
|
|
59
71
|
}
|
|
60
72
|
/** سهم هر بخش از کل در یک میلهٔ افقی، مثل منبع ورود کاربران؛ جایگزین خواناتر نمودار دایرهای */
|
|
61
|
-
export declare function ProportionBar({ title, data, percent, format, className }: ProportionBarProps): import("react").JSX.Element;
|
|
73
|
+
export declare function ProportionBar({ title, data, percent, format, className, loading, emptyMessage }: ProportionBarProps): import("react").JSX.Element;
|
|
62
74
|
export interface PieChartProps {
|
|
75
|
+
/** داده در راه است؛ اسکلت جای نمودار */
|
|
76
|
+
loading?: boolean;
|
|
77
|
+
/** پیام نمودار بیداده @default «دادهای برای نمایش نیست.» */
|
|
78
|
+
emptyMessage?: ReactNode;
|
|
63
79
|
title: string;
|
|
64
80
|
/** بیش از پنج بخش در «سایر» جمع میشود */
|
|
65
81
|
data: {
|
|
@@ -79,7 +95,7 @@ export interface PieChartProps {
|
|
|
79
95
|
* نمودار دایرهای یا دونات تا پنج بخش، با فاصلهٔ کوچک بین بخشها، راهنمای درصد و جدول همارز.
|
|
80
96
|
* برای مقایسهٔ دقیق بخشها ProportionBar خواناتر است.
|
|
81
97
|
*/
|
|
82
|
-
export declare function PieChart({ title, data, variant, format, totalLabel, size, className }: PieChartProps): import("react").JSX.Element;
|
|
98
|
+
export declare function PieChart({ title, data, variant, format, totalLabel, size, className, loading, emptyMessage }: PieChartProps): import("react").JSX.Element;
|
|
83
99
|
export interface SparklineProps {
|
|
84
100
|
values: number[];
|
|
85
101
|
/** نام دسترسپذیر، مثل «روند فروش هفت روز اخیر: افزایشی» */
|
|
@@ -97,6 +113,10 @@ export interface LineSeries {
|
|
|
97
113
|
values: number[];
|
|
98
114
|
}
|
|
99
115
|
export interface LineChartProps {
|
|
116
|
+
/** داده در راه است؛ اسکلت جای نمودار */
|
|
117
|
+
loading?: boolean;
|
|
118
|
+
/** پیام نمودار بیداده @default «دادهای برای نمایش نیست.» */
|
|
119
|
+
emptyMessage?: ReactNode;
|
|
100
120
|
title: string;
|
|
101
121
|
/** برچسب محور افقی، مثل ماهها */
|
|
102
122
|
labels: string[];
|
|
@@ -112,4 +132,4 @@ export interface LineChartProps {
|
|
|
112
132
|
* نمودار خطی تا چهار سری: خط ۲ پیکسلی، برچسب نام در انتهای هر خط،
|
|
113
133
|
* راهنمای عمودی با موس و ←→ روی کیبورد، و جدول همارز برای صفحهخوان.
|
|
114
134
|
*/
|
|
115
|
-
export declare function LineChart({ title, labels, series, format, area, height, className }: LineChartProps): import("react").JSX.Element;
|
|
135
|
+
export declare function LineChart({ title, labels, series, format, area, height, className, loading, emptyMessage }: LineChartProps): import("react").JSX.Element;
|
package/dist/Chart.js
CHANGED
|
@@ -54,8 +54,15 @@ function DataTable({ caption, labels, series, format }) {
|
|
|
54
54
|
const { messages: M } = useKashi();
|
|
55
55
|
return (_jsxs("table", { className: "k-sr-only", children: [_jsx("caption", { children: caption }), _jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { scope: "col", children: M.chart.period }), series.map((s) => _jsx("th", { scope: "col", children: s.name }, s.name))] }) }), _jsx("tbody", { children: labels.map((l, i) => _jsxs("tr", { children: [_jsx("th", { scope: "row", children: l }), series.map((s) => _jsx("td", { children: format(s.values[i]) }, s.name))] }, l)) })] }));
|
|
56
56
|
}
|
|
57
|
+
/** قاب نمودار در حالت بارگذاری یا بیداده: عنوان میماند، جای نمودار اسکلت یا پیام */
|
|
58
|
+
function ChartPlaceholder({ title, loading, emptyMessage, className }) {
|
|
59
|
+
const { messages: M } = useKashi();
|
|
60
|
+
return (_jsxs("figure", { className: cx("k-chart", className), style: { margin: 0 }, "aria-busy": loading || undefined, children: [title && _jsx("figcaption", { className: "k-chart__head", children: _jsx("p", { className: "k-chart__title", children: title }) }), loading
|
|
61
|
+
? _jsx("div", { className: "k-chart__skeleton", role: "status", children: _jsx("span", { className: "k-sr-only", children: M.common.loading }) })
|
|
62
|
+
: _jsx("div", { className: "k-chart__empty", role: "status", children: emptyMessage ?? M.common.noData })] }));
|
|
63
|
+
}
|
|
57
64
|
/** نمودار ستونی؛ تکسری یا انباشته تا چهار سری. با موس یا Tab روی هر ستون مقدار دقیق نمایش داده میشود */
|
|
58
|
-
export function BarChart({ title, data, series, labels, format, labelMax = true, height, className }) {
|
|
65
|
+
export function BarChart({ title, data, series, labels, format, labelMax = true, height, className, loading, emptyMessage }) {
|
|
59
66
|
const T = useChartText();
|
|
60
67
|
const M = T.M;
|
|
61
68
|
format ?? (format = T.fmt);
|
|
@@ -72,12 +79,14 @@ export function BarChart({ title, data, series, labels, format, labelMax = true,
|
|
|
72
79
|
const box = useRef(null);
|
|
73
80
|
const [tip, setTip] = useState(null);
|
|
74
81
|
const show = (e, i) => setTip(tipAt(e.currentTarget, box.current, i, e.currentTarget.querySelector(".k-bars__bar, .k-bars__stack")));
|
|
82
|
+
if (loading || cats.length === 0)
|
|
83
|
+
return _jsx(ChartPlaceholder, { title: title, loading: loading, emptyMessage: emptyMessage, className: className });
|
|
75
84
|
return (_jsxs("figure", { className: cx("k-chart k-chart--bar", className), "aria-labelledby": `${id}-t`, style: { margin: 0, ...(height ? { "--k-chart-height": height } : {}) }, children: [_jsxs("figcaption", { className: "k-chart__head", children: [_jsx("p", { className: "k-chart__title", id: `${id}-t`, children: title }), stacked && stacked.length > 1 && (_jsx("ul", { className: "k-chart__legend", "aria-hidden": "true", children: stacked.map((s, i) => _jsxs("li", { style: color(i), children: [_jsx("span", { className: "k-chart__key k-chart__key--box" }), s.name] }, s.name)) }))] }), _jsxs("div", { className: "k-chart__plot", ref: box, children: [_jsx("div", { className: "k-bars__grid", "aria-hidden": "true", children: ticks.map((t) => _jsx("span", { "data-v": T.compact(t) }, t)) }), _jsx("div", { className: "k-bars", role: "list", "aria-label": title, children: cats.map((label, i) => (_jsxs("div", { className: "k-bars__col", role: "listitem", tabIndex: 0, "aria-label": describe(i), "data-active": tip?.i === i ? "" : undefined, style: { "--_d": `${i * 40}ms` }, onPointerEnter: (e) => show(e, i), onPointerLeave: () => setTip(null), onFocus: (e) => show(e, i), onBlur: () => setTip(null), children: [labelMax && i === maxIndex && _jsx("span", { className: "k-bars__value", "aria-hidden": "true", children: format(totals[i]) }), stacked ? (_jsx("span", { className: "k-bars__stack", style: { blockSize: `${(totals[i] / top) * 100}%` }, "aria-hidden": "true", children: stacked.map((s, si) => (_jsx("span", { className: "k-bars__seg", style: { ...color(si), flexGrow: s.values[i] ?? 0 } }, s.name))) })) : (_jsx("span", { className: "k-bars__bar", style: { blockSize: `${(totals[i] / top) * 100}%` }, "aria-hidden": "true" })), _jsx("span", { className: "k-bars__label", "aria-hidden": "true", children: label })] }, label))) }), tip && (_jsx(ChartTip, { x: tip.x, y: tip.y, width: box.current?.clientWidth, title: cats[tip.i], rows: stacked
|
|
76
85
|
? [...stacked.map((s, si) => ({ name: s.name, value: format(s.values[tip.i] ?? 0), color: `var(--k-chart-${si + 1})` })), { name: M.common.total, value: format(totals[tip.i]) }]
|
|
77
86
|
: [{ value: format(totals[tip.i]) }] }))] })] }));
|
|
78
87
|
}
|
|
79
88
|
/** میلههای افقی برای رتبهبندی با نامهای بلند، مثل پربازدیدترین صفحهها */
|
|
80
|
-
export function BarList({ title, data, format, className }) {
|
|
89
|
+
export function BarList({ title, data, format, className, loading, emptyMessage }) {
|
|
81
90
|
const T = useChartText();
|
|
82
91
|
const M = T.M;
|
|
83
92
|
format ?? (format = T.fmt);
|
|
@@ -87,10 +96,12 @@ export function BarList({ title, data, format, className }) {
|
|
|
87
96
|
const share = (v) => T.pct(v, total);
|
|
88
97
|
const box = useRef(null);
|
|
89
98
|
const [tip, setTip] = useState(null);
|
|
99
|
+
if (loading || !data?.length)
|
|
100
|
+
return _jsx(ChartPlaceholder, { title: title, loading: loading, emptyMessage: emptyMessage, className: className });
|
|
90
101
|
return (_jsxs("figure", { className: cx("k-chart", className), "aria-labelledby": `${id}-t`, style: { margin: 0 }, children: [_jsx("figcaption", { className: "k-chart__head", children: _jsx("p", { className: "k-chart__title", id: `${id}-t`, children: title }) }), _jsxs("ol", { className: "k-barlist", ref: box, style: { position: "relative" }, children: [data.map((d, i) => (_jsxs("li", { className: "k-barlist__row", "data-active": tip?.i === i ? "" : undefined, style: { "--_d": `${i * 60}ms` }, onPointerEnter: (e) => setTip(tipAt(e.currentTarget, box.current, i, e.currentTarget.querySelector(".k-barlist__fill"))), onPointerLeave: () => setTip(null), children: [_jsxs("span", { className: "k-barlist__track", children: [_jsx("span", { className: "k-barlist__fill", style: { inlineSize: `${(d.value / max) * 100}%` }, "aria-hidden": "true" }), d.href ? _jsx("a", { className: "k-barlist__label", href: d.href, children: d.label }) : _jsx("span", { className: "k-barlist__label", children: d.label })] }), _jsxs("span", { className: "k-barlist__value", children: [format(d.value), " ", _jsx("span", { className: "k-barlist__share", children: share(d.value) })] })] }, d.label))), tip && _jsx(ChartTip, { x: tip.x, y: tip.y, width: box.current?.clientWidth, title: data[tip.i].label, rows: [{ name: M.chart.value, value: format(data[tip.i].value) }, { name: M.chart.share, value: share(data[tip.i].value) }] })] })] }));
|
|
91
102
|
}
|
|
92
103
|
/** سهم هر بخش از کل در یک میلهٔ افقی، مثل منبع ورود کاربران؛ جایگزین خواناتر نمودار دایرهای */
|
|
93
|
-
export function ProportionBar({ title, data, percent = true, format, className }) {
|
|
104
|
+
export function ProportionBar({ title, data, percent = true, format, className, loading, emptyMessage }) {
|
|
94
105
|
const T = useChartText();
|
|
95
106
|
const M = T.M;
|
|
96
107
|
format ?? (format = T.fmt);
|
|
@@ -101,13 +112,15 @@ export function ProportionBar({ title, data, percent = true, format, className }
|
|
|
101
112
|
const color = (i) => ({ "--_c": `var(--k-chart-${i + 1})` });
|
|
102
113
|
const box = useRef(null);
|
|
103
114
|
const [tip, setTip] = useState(null);
|
|
115
|
+
if (loading || !data?.length)
|
|
116
|
+
return _jsx(ChartPlaceholder, { title: title, loading: loading, emptyMessage: emptyMessage, className: className });
|
|
104
117
|
return (_jsxs("figure", { className: cx("k-chart", className), "aria-labelledby": `${id}-t`, style: { margin: 0 }, children: [_jsx("figcaption", { className: "k-chart__head", children: _jsx("p", { className: "k-chart__title", id: `${id}-t`, children: title }) }), _jsxs("div", { className: "k-proportion__wrap", ref: box, children: [_jsx("div", { className: "k-proportion", "aria-hidden": "true", children: parts.map((d, i) => (_jsx("span", { className: "k-proportion__seg", "data-active": tip?.i === i ? "" : undefined, style: { ...color(i), flexGrow: d.value }, onPointerEnter: (e) => setTip(tipAt(e.currentTarget, box.current, i)), onPointerLeave: () => setTip(null) }, d.label))) }), tip && _jsx(ChartTip, { x: tip.x, y: tip.y, width: box.current?.clientWidth, rows: [{ name: parts[tip.i].label, value: pct(parts[tip.i].value), color: `var(--k-chart-${tip.i + 1})` }, { name: M.chart.count, value: format(parts[tip.i].value) }] })] }), _jsx("ul", { className: "k-proportion__legend", children: parts.map((d, i) => (_jsxs("li", { style: color(i), "data-active": tip?.i === i ? "" : undefined, children: [_jsx("span", { className: "k-chart__key k-chart__key--box", "aria-hidden": "true" }), _jsx("span", { children: d.label }), _jsx("strong", { children: percent ? pct(d.value) : format(d.value) }), percent && _jsx("span", { className: "k-proportion__abs", children: format(d.value) })] }, d.label))) })] }));
|
|
105
118
|
}
|
|
106
119
|
/**
|
|
107
120
|
* نمودار دایرهای یا دونات تا پنج بخش، با فاصلهٔ کوچک بین بخشها، راهنمای درصد و جدول همارز.
|
|
108
121
|
* برای مقایسهٔ دقیق بخشها ProportionBar خواناتر است.
|
|
109
122
|
*/
|
|
110
|
-
export function PieChart({ title, data, variant = "donut", format, totalLabel, size = 176, className }) {
|
|
123
|
+
export function PieChart({ title, data, variant = "donut", format, totalLabel, size = 176, className, loading, emptyMessage }) {
|
|
111
124
|
const T = useChartText();
|
|
112
125
|
const M = T.M;
|
|
113
126
|
format ?? (format = T.fmt);
|
|
@@ -137,6 +150,8 @@ export function PieChart({ title, data, variant = "donut", format, totalLabel, s
|
|
|
137
150
|
const rr = donut ? r : r * 1.3;
|
|
138
151
|
return { x: (R + rr * Math.cos(ang)) / (2 * R), y: (R + rr * Math.sin(ang)) / (2 * R) };
|
|
139
152
|
};
|
|
153
|
+
if (loading || !data?.length)
|
|
154
|
+
return _jsx(ChartPlaceholder, { title: title, loading: loading, emptyMessage: emptyMessage, className: className });
|
|
140
155
|
return (_jsxs("figure", { className: cx("k-chart k-pie", className), "aria-labelledby": `${id}-t`, style: { margin: 0 }, children: [_jsx("figcaption", { className: "k-chart__head", children: _jsx("p", { className: "k-chart__title", id: `${id}-t`, children: title }) }), _jsxs("div", { className: "k-pie__body", children: [_jsxs("div", { className: "k-pie__plot", ref: box, style: { inlineSize: size, blockSize: size }, onPointerLeave: () => setActive(null), children: [_jsxs("svg", { viewBox: "0 0 100 100", className: "k-pie__svg", "aria-hidden": "true", children: [donut && _jsx("circle", { cx: R, cy: R, r: r, fill: "none", stroke: "var(--k-bg-tertiary)", strokeWidth: w }), parts.map((d, i) => (_jsx("circle", { className: "k-pie__slice", "data-active": active === i ? "" : undefined, cx: R, cy: R, r: r, fill: "none", stroke: slot(i), strokeWidth: w, strokeDasharray: `${Math.max(0, arcs[i].len - gap)} ${C}`, strokeDashoffset: -arcs[i].start, transform: `rotate(-90 ${R} ${R})`, style: { "--_d": `${i * 80}ms` }, onPointerEnter: () => setActive(i) }, d.label)))] }), donut && (_jsxs("div", { className: "k-pie__center", "aria-hidden": "true", children: [_jsx("strong", { children: active === null ? format(total) : pct(parts[active].value) }), _jsx("span", { children: active === null ? totalLabel : parts[active].label })] })), active !== null && !donut && (_jsx(ChartTip, { x: mid(active).x * size, y: mid(active).y * size - 8, rows: [{ name: parts[active].label, value: pct(parts[active].value), color: slot(active) }, { name: M.chart.count, value: format(parts[active].value) }] }))] }), _jsx("ul", { className: "k-pie__legend", children: parts.map((d, i) => (_jsxs("li", { style: { "--_c": slot(i) }, "data-active": active === i ? "" : undefined, onPointerEnter: () => setActive(i), onPointerLeave: () => setActive(null), children: [_jsx("span", { className: "k-chart__key k-chart__key--box", "aria-hidden": "true" }), _jsx("span", { className: "k-pie__name", children: d.label }), _jsx("strong", { children: pct(d.value) }), _jsx("span", { className: "k-pie__abs", children: format(d.value) })] }, d.label))) })] })] }));
|
|
141
156
|
}
|
|
142
157
|
/** خط روند کوچک برای کارت آمار و جدول؛ بدون محور، فقط شکل روند */
|
|
@@ -154,7 +169,7 @@ export function Sparkline({ values, "aria-label": ariaLabel, tone = "brand", are
|
|
|
154
169
|
* نمودار خطی تا چهار سری: خط ۲ پیکسلی، برچسب نام در انتهای هر خط،
|
|
155
170
|
* راهنمای عمودی با موس و ←→ روی کیبورد، و جدول همارز برای صفحهخوان.
|
|
156
171
|
*/
|
|
157
|
-
export function LineChart({ title, labels, series, format, area, height, className }) {
|
|
172
|
+
export function LineChart({ title, labels, series, format, area, height, className, loading, emptyMessage }) {
|
|
158
173
|
const T = useChartText();
|
|
159
174
|
const M = T.M;
|
|
160
175
|
format ?? (format = T.fmt);
|
|
@@ -221,5 +236,7 @@ export function LineChart({ title, labels, series, format, area, height, classNa
|
|
|
221
236
|
setActive(null);
|
|
222
237
|
};
|
|
223
238
|
const step = Math.max(1, Math.ceil(labels.length / Math.max(2, Math.floor(innerW / 64))));
|
|
239
|
+
if (loading || !labels?.length || !series?.length)
|
|
240
|
+
return _jsx(ChartPlaceholder, { title: title, loading: loading, emptyMessage: emptyMessage, className: className });
|
|
224
241
|
return (_jsxs("figure", { className: cx("k-chart", className), "aria-labelledby": `${id}-t`, style: { margin: 0, ...(height ? { "--k-chart-height": height } : {}) }, children: [_jsxs("figcaption", { className: "k-chart__head", children: [_jsx("p", { className: "k-chart__title", id: `${id}-t`, children: title }), shown.length > 1 && (_jsx("ul", { className: "k-chart__legend", "aria-hidden": "true", children: shown.map((s, i) => _jsxs("li", { style: color(i), children: [_jsx("span", { className: "k-chart__key" }), s.name] }, s.name)) }))] }), _jsxs("div", { ref: plot, className: "k-chart__plot", tabIndex: 0, role: "img", "aria-label": M.chart.keyboard(title), "aria-describedby": `${id}-live`, onPointerMove: (e) => pick(e.clientX), onPointerLeave: () => setActive(null), onKeyDown: onKey, onBlur: () => setActive(null), children: [_jsxs("svg", { className: "k-chart__svg", "aria-hidden": "true", direction: "ltr", children: [_jsx("g", { className: "k-chart__grid", children: ticks.map((t) => _jsx("line", { x1: pad.start - (size.rtl ? 0 : 0), x2: size.w - pad.end, y1: y(t), y2: y(t), transform: size.rtl ? `translate(${pad.end - pad.start} 0)` : undefined }, t)) }), ticks.map((t) => _jsx("text", { className: "k-chart__tick", x: tickX, y: y(t) + 4, textAnchor: anchor, children: T.compact(t) }, t)), labels.map((l, i) => (i % step === 0 || i === labels.length - 1) && _jsx("text", { className: "k-chart__tick", x: x(i), y: size.h - 6, textAnchor: "middle", children: l }, l)), _jsx("defs", { children: _jsxs("linearGradient", { id: `${id}-fade`, x1: "0", y1: "0", x2: "0", y2: "1", children: [_jsx("stop", { offset: "0", style: { stopColor: "var(--k-chart-1)", stopOpacity: 0.28 } }), _jsx("stop", { offset: "1", style: { stopColor: "var(--k-chart-1)", stopOpacity: 0 } })] }) }), (area ?? shown.length === 1) && shown.length === 1 && (_jsx("path", { className: "k-chart__area", fill: `url(#${id}-fade)`, d: `M${x(0)},${y(0)} ${shown[0].values.map((v, i) => `L${x(i)},${y(v)}`).join(" ")} L${x(labels.length - 1)},${y(0)} Z` })), active !== null && _jsx("line", { className: "k-chart__cross", x1: x(active), x2: x(active), y1: pad.top, y2: pad.top + innerH }), shown.map((s, si) => (_jsxs("g", { style: color(si), children: [_jsx("path", { className: "k-chart__line", pathLength: 1, d: s.values.map((v, i) => `${i ? "L" : "M"}${x(i)},${y(v)}`).join(" ") }), _jsx("circle", { className: "k-chart__dot", cx: x(s.values.length - 1), cy: y(s.values[s.values.length - 1]), r: 4 }), shown.length > 1 && _jsx("text", { className: "k-chart__end", x: endX(last), y: endY[si] + 4, textAnchor: size.rtl ? "end" : "start", children: s.name }), active !== null && _jsx("circle", { className: "k-chart__dot", cx: x(active), cy: y(s.values[active]), r: 4.5 })] }, s.name)))] }), active !== null && (_jsx(ChartTip, { x: x(active), y: Math.min(...shown.map((s) => y(s.values[active]))) - 6, width: size.w, title: labels[active], rows: shown.map((s, si) => ({ name: s.name, value: format(s.values[active]), color: `var(--k-chart-${si + 1})` })) }))] }), _jsx("span", { className: "k-sr-only", "aria-live": "polite", id: `${id}-live`, children: active !== null ? `${labels[active]}: ${shown.map((s) => `${s.name} ${format(s.values[active])}`).join(M.common.list)}` : "" }), _jsx(DataTable, { caption: title, labels: labels, series: shown, format: format })] }));
|
|
225
242
|
}
|
package/dist/Checkbox.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ interface CheckOwnProps {
|
|
|
15
15
|
description?: ReactNode;
|
|
16
16
|
/** حالت خطا */
|
|
17
17
|
invalid?: boolean;
|
|
18
|
+
/** فقطخواندنی: وضعیت دیده و با فرم ارسال میشود ولی با کلیک یا صفحهکلید عوض نمیشود (برخلاف disabled، کمرنگ نمیشود) */
|
|
19
|
+
readOnly?: boolean;
|
|
18
20
|
}
|
|
19
21
|
export interface CheckboxProps extends CheckOwnProps, Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "size"> {
|
|
20
22
|
/** حالت نیمهانتخاب (مثلاً برای «انتخاب همه») */
|
package/dist/Checkbox.js
CHANGED
|
@@ -3,13 +3,15 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
3
3
|
import { forwardRef, useEffect, useId, useRef } from "react";
|
|
4
4
|
import { cx } from "./cx.js";
|
|
5
5
|
import { mergeRefs } from "./utils.js";
|
|
6
|
+
/** فقطخواندنی: کلیک و فاصله تیک را عوض نمیکنند؛ checkbox بومی readonly را نادیده میگیرد */
|
|
7
|
+
const readOnlyProps = (readOnly, onClick) => readOnly ? { "aria-readonly": true, onClick: (e) => { e.preventDefault(); onClick?.(e); } } : { onClick };
|
|
6
8
|
/** برچسب و توضیح مشترک بین Checkbox و Switch */
|
|
7
|
-
function CheckLabel({ id, label, description, className, classNames = {}, labelPosition = "end", children }) {
|
|
9
|
+
function CheckLabel({ id, label, description, className, classNames = {}, labelPosition = "end", readOnly, children }) {
|
|
8
10
|
if (!label && !description)
|
|
9
11
|
return _jsx(_Fragment, { children: children });
|
|
10
|
-
return (_jsxs("label", { className: cx("k-check", labelPosition === "start" && "k-check--start", className, classNames.root), htmlFor: id, children: [children, _jsxs("span", { className: "k-check__text", children: [label && _jsx("span", { className: cx("k-check__label", classNames.label), children: label }), description && _jsx("span", { className: cx("k-check__description", classNames.description), id: `${id}-desc`, children: description })] })] }));
|
|
12
|
+
return (_jsxs("label", { className: cx("k-check", labelPosition === "start" && "k-check--start", className, classNames.root), htmlFor: id, "data-readonly": readOnly || undefined, children: [children, _jsxs("span", { className: "k-check__text", children: [label && _jsx("span", { className: cx("k-check__label", classNames.label), children: label }), description && _jsx("span", { className: cx("k-check__description", classNames.description), id: `${id}-desc`, children: description })] })] }));
|
|
11
13
|
}
|
|
12
|
-
export const Checkbox = forwardRef(function Checkbox({ label, description, invalid, indeterminate = false, size = "md", id, className, classNames, labelPosition, ...rest }, ref) {
|
|
14
|
+
export const Checkbox = forwardRef(function Checkbox({ label, description, invalid, indeterminate = false, size = "md", id, className, classNames, labelPosition, readOnly, onClick, ...rest }, ref) {
|
|
13
15
|
const autoId = useId();
|
|
14
16
|
const inputId = id ?? autoId;
|
|
15
17
|
const inner = useRef(null);
|
|
@@ -18,10 +20,10 @@ export const Checkbox = forwardRef(function Checkbox({ label, description, inval
|
|
|
18
20
|
if (inner.current)
|
|
19
21
|
inner.current.indeterminate = indeterminate;
|
|
20
22
|
}, [indeterminate]);
|
|
21
|
-
return (_jsx(CheckLabel, { id: inputId, label: label, description: description, className: className, classNames: classNames, labelPosition: labelPosition, children: _jsx("input", { ref: mergeRefs(ref, inner), type: "checkbox", id: inputId, className: cx("k-checkbox", size === "lg" && "k-checkbox--lg", !label && !description && className, classNames?.control), "aria-invalid": invalid || undefined, "aria-describedby": description ? `${inputId}-desc` : undefined, "data-indeterminate": indeterminate || undefined, ...rest }) }));
|
|
23
|
+
return (_jsx(CheckLabel, { id: inputId, label: label, description: description, className: className, classNames: classNames, labelPosition: labelPosition, readOnly: readOnly, children: _jsx("input", { ref: mergeRefs(ref, inner), type: "checkbox", id: inputId, className: cx("k-checkbox", size === "lg" && "k-checkbox--lg", !label && !description && className, classNames?.control), "aria-invalid": invalid || undefined, "aria-describedby": description ? `${inputId}-desc` : undefined, "data-indeterminate": indeterminate || undefined, ...readOnlyProps(readOnly, onClick), ...rest }) }));
|
|
22
24
|
});
|
|
23
|
-
export const Switch = forwardRef(function Switch({ label, description, invalid, size = "md", id, className, classNames, labelPosition, ...rest }, ref) {
|
|
25
|
+
export const Switch = forwardRef(function Switch({ label, description, invalid, size = "md", id, className, classNames, labelPosition, readOnly, onClick, ...rest }, ref) {
|
|
24
26
|
const autoId = useId();
|
|
25
27
|
const inputId = id ?? autoId;
|
|
26
|
-
return (_jsx(CheckLabel, { id: inputId, label: label, description: description, className: className, classNames: classNames, labelPosition: labelPosition, children: _jsx("input", { ref: ref, type: "checkbox", role: "switch", id: inputId, className: cx("k-switch", size !== "md" && `k-switch--${size}`, !label && !description && className, classNames?.control), "aria-invalid": invalid || undefined, "aria-describedby": description ? `${inputId}-desc` : undefined, ...rest }) }));
|
|
28
|
+
return (_jsx(CheckLabel, { id: inputId, label: label, description: description, className: className, classNames: classNames, labelPosition: labelPosition, readOnly: readOnly, children: _jsx("input", { ref: ref, type: "checkbox", role: "switch", id: inputId, className: cx("k-switch", size !== "md" && `k-switch--${size}`, !label && !description && className, classNames?.control), "aria-invalid": invalid || undefined, "aria-describedby": description ? `${inputId}-desc` : undefined, ...readOnlyProps(readOnly, onClick), ...rest }) }));
|
|
27
29
|
});
|
package/dist/ChipGroup.d.ts
CHANGED
|
@@ -15,8 +15,10 @@ export interface ChipGroupProps {
|
|
|
15
15
|
onChange?: (value: string[]) => void;
|
|
16
16
|
/** فقط یک انتخاب؛ کلیک دوباره انتخاب را برمیدارد */
|
|
17
17
|
single?: boolean;
|
|
18
|
+
/** فقطخواندنی: انتخابها دیده میشوند ولی عوض نمیشوند */
|
|
19
|
+
readOnly?: boolean;
|
|
18
20
|
"aria-label"?: string;
|
|
19
21
|
className?: string;
|
|
20
22
|
}
|
|
21
23
|
/** چیپهای فیلتر روشن و خاموششونده، مثل دستهبندیها یا وضعیت سفارش */
|
|
22
|
-
export declare function ChipGroup({ options, value, defaultValue, onChange, single, "aria-label": ariaLabel, className }: ChipGroupProps): import("react").JSX.Element;
|
|
24
|
+
export declare function ChipGroup({ options, value, defaultValue, onChange, single, readOnly, "aria-label": ariaLabel, className }: ChipGroupProps): import("react").JSX.Element;
|
package/dist/ChipGroup.js
CHANGED
|
@@ -5,15 +5,17 @@ import { toFaDigits } from "@kashi-ui/persian";
|
|
|
5
5
|
import { cx } from "./cx.js";
|
|
6
6
|
const Check = () => (_jsx("svg", { className: "k-chip__check", viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "m5 10.5 3.2 3L15 7" }) }));
|
|
7
7
|
/** چیپهای فیلتر روشن و خاموششونده، مثل دستهبندیها یا وضعیت سفارش */
|
|
8
|
-
export function ChipGroup({ options, value, defaultValue = [], onChange, single, "aria-label": ariaLabel, className }) {
|
|
8
|
+
export function ChipGroup({ options, value, defaultValue = [], onChange, single, readOnly, "aria-label": ariaLabel, className }) {
|
|
9
9
|
const [inner, setInner] = useState(defaultValue);
|
|
10
10
|
const current = value ?? inner;
|
|
11
11
|
const toggle = (v) => {
|
|
12
|
+
if (readOnly)
|
|
13
|
+
return;
|
|
12
14
|
const on = current.includes(v);
|
|
13
15
|
const next = single ? (on ? [] : [v]) : on ? current.filter((x) => x !== v) : [...current, v];
|
|
14
16
|
if (value === undefined)
|
|
15
17
|
setInner(next);
|
|
16
18
|
onChange?.(next);
|
|
17
19
|
};
|
|
18
|
-
return (_jsx("div", { role: "group", "aria-label": ariaLabel, className: cx("k-chips", className), children: options.map((o) => (_jsxs("button", { type: "button", className: "k-chip", "aria-pressed": current.includes(o.value), disabled: o.disabled, onClick: () => toggle(o.value), children: [_jsx(Check, {}), o.icon, o.label, o.count !== undefined && _jsx("span", { className: "k-chip__count", children: toFaDigits(o.count) })] }, o.value))) }));
|
|
20
|
+
return (_jsx("div", { role: "group", "aria-label": ariaLabel, "aria-readonly": readOnly || undefined, "data-readonly": readOnly || undefined, className: cx("k-chips", className), children: options.map((o) => (_jsxs("button", { type: "button", className: "k-chip", "aria-pressed": current.includes(o.value), disabled: o.disabled, onClick: () => toggle(o.value), children: [_jsx(Check, {}), o.icon, o.label, o.count !== undefined && _jsx("span", { className: "k-chip__count", children: toFaDigits(o.count) })] }, o.value))) }));
|
|
19
21
|
}
|
package/dist/Combobox.d.ts
CHANGED
|
@@ -30,6 +30,8 @@ export interface ComboboxProps {
|
|
|
30
30
|
filter?: (option: ComboboxOption, query: string) => boolean;
|
|
31
31
|
/** @default "نتیجهای پیدا نشد." */
|
|
32
32
|
emptyMessage?: ReactNode;
|
|
33
|
+
/** فقطخواندنی: مقدار دیده و ارسال میشود ولی فهرست باز و متن عوض نمیشود */
|
|
34
|
+
readOnly?: boolean;
|
|
33
35
|
/** نمایش اسپینر، مثلاً هنگام جستجوی سمت سرور */
|
|
34
36
|
loading?: boolean;
|
|
35
37
|
required?: boolean;
|
package/dist/Combobox.js
CHANGED
|
@@ -30,7 +30,7 @@ const Check = () => (_jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "
|
|
|
30
30
|
* تایپ فهرست را فیلتر میکند، ↑↓ حرکت، Enter انتخاب، Esc بستن (و در حالت بسته، پاک کردن).
|
|
31
31
|
* جستجو «علي» و «علی» را یکی میداند.
|
|
32
32
|
*/
|
|
33
|
-
export const Combobox = forwardRef(function Combobox({ label, hint, error, options, value, defaultValue = null, onChange, onInputChange, placeholder, filter = defaultFilter, emptyMessage, loading, required, disabled, name, id, className, resultsLabel, }, ref) {
|
|
33
|
+
export const Combobox = forwardRef(function Combobox({ label, hint, error, options, value, defaultValue = null, onChange, onInputChange, placeholder, filter = defaultFilter, emptyMessage, loading, required, disabled, readOnly, name, id, className, resultsLabel, }, ref) {
|
|
34
34
|
const { messages: M, n: N } = useKashi();
|
|
35
35
|
emptyMessage ?? (emptyMessage = M.common.noResults);
|
|
36
36
|
resultsLabel ?? (resultsLabel = (x) => M.common.results(N(x)));
|
|
@@ -63,6 +63,8 @@ export const Combobox = forwardRef(function Combobox({ label, hint, error, optio
|
|
|
63
63
|
setActive(-1);
|
|
64
64
|
};
|
|
65
65
|
const openList = (at = "selected") => {
|
|
66
|
+
if (readOnly)
|
|
67
|
+
return;
|
|
66
68
|
if (disabled)
|
|
67
69
|
return;
|
|
68
70
|
setOpen(true);
|
|
@@ -114,7 +116,7 @@ export const Combobox = forwardRef(function Combobox({ label, hint, error, optio
|
|
|
114
116
|
}
|
|
115
117
|
};
|
|
116
118
|
let lastGroup;
|
|
117
|
-
return (_jsx(Field, { id: inputId, label: label, hint: hint, error: error, required: required, className: className, children: _jsxs("div", { ref: wrapRef, className: "k-combobox", "data-open": open ? "" : undefined, onBlur: (e) => {
|
|
119
|
+
return (_jsx(Field, { id: inputId, label: label, hint: hint, error: error, required: required, className: className, children: _jsxs("div", { ref: wrapRef, className: "k-combobox", "data-open": open ? "" : undefined, "data-readonly": readOnly || undefined, onBlur: (e) => {
|
|
118
120
|
if (wrapRef.current?.contains(e.relatedTarget))
|
|
119
121
|
return;
|
|
120
122
|
setOpen(false);
|
|
@@ -123,7 +125,9 @@ export const Combobox = forwardRef(function Combobox({ label, hint, error, optio
|
|
|
123
125
|
setTyping(false);
|
|
124
126
|
setQuery(selectedOption?.label ?? "");
|
|
125
127
|
}
|
|
126
|
-
}, children: [_jsxs("div", { className: cx("k-input"), "data-state": error ? "invalid" : undefined, children: [_jsx("input", { ref: mergeRefs(ref, inputRef), id: inputId, className: "k-input__control", type: "text", role: "combobox", "aria-autocomplete": "list", "aria-expanded": open, "aria-controls": listId, "aria-activedescendant": open && active >= 0 ? `${listId}-${active}` : undefined, "aria-invalid": error ? true : undefined, "aria-describedby": describedBy(inputId, hint, error), autoComplete: "off", placeholder: placeholder, value: query, required: required, disabled: disabled, onChange: (e) => {
|
|
128
|
+
}, children: [_jsxs("div", { className: cx("k-input"), "data-state": error ? "invalid" : undefined, children: [_jsx("input", { ref: mergeRefs(ref, inputRef), id: inputId, className: "k-input__control", type: "text", role: "combobox", "aria-autocomplete": "list", "aria-expanded": open, "aria-controls": listId, "aria-activedescendant": open && active >= 0 ? `${listId}-${active}` : undefined, "aria-invalid": error ? true : undefined, "aria-describedby": describedBy(inputId, hint, error), autoComplete: "off", placeholder: placeholder, value: query, required: required, disabled: disabled, readOnly: readOnly, onChange: (e) => {
|
|
129
|
+
if (readOnly)
|
|
130
|
+
return;
|
|
127
131
|
setQuery(e.target.value);
|
|
128
132
|
setTyping(true);
|
|
129
133
|
setOpen(true);
|
package/dist/DatePicker.js
CHANGED
|
@@ -10,7 +10,7 @@ import { useKashi } from "./KashiProvider.js";
|
|
|
10
10
|
* انتخاب تاریخ شمسی: تایپ مستقیم (۱۴۰۳/۰۵/۱۲) یا انتخاب از تقویم.
|
|
11
11
|
* با name، مقدار میلادی به شکل YYYY-MM-DD در فرم ارسال میشود.
|
|
12
12
|
*/
|
|
13
|
-
export const DatePicker = forwardRef(function DatePicker({ value, defaultValue = null, onChange, min, max, isDateDisabled, holidays, digits, yearRange, invalidMessage, openLabel, todayLabel, calendarLabels, error, name, onBlur, placeholder, ...rest }, ref) {
|
|
13
|
+
export const DatePicker = forwardRef(function DatePicker({ value, defaultValue = null, onChange, min, max, isDateDisabled, holidays, digits, yearRange, invalidMessage, openLabel, todayLabel, calendarLabels, error, name, onBlur, placeholder, readOnly, ...rest }, ref) {
|
|
14
14
|
const { messages: M, digits: D, locale } = useKashi();
|
|
15
15
|
digits ?? (digits = D);
|
|
16
16
|
invalidMessage ?? (invalidMessage = M.datePicker.invalid);
|
|
@@ -76,7 +76,8 @@ export const DatePicker = forwardRef(function DatePicker({ value, defaultValue =
|
|
|
76
76
|
setInvalid(true);
|
|
77
77
|
}
|
|
78
78
|
onBlur?.(e);
|
|
79
|
-
}, error: error ?? (invalid ? invalidMessage : undefined),
|
|
79
|
+
}, error: error ?? (invalid ? invalidMessage : undefined), readOnly: readOnly, addonEnd: readOnly ? undefined :
|
|
80
|
+
_jsx("button", { ref: button, type: "button", className: "k-btn k-btn--tertiary k-btn--icon k-btn--sm k-datepicker__toggle", "aria-label": selected ? `${openLabel}${M.common.list}${formatJalali(selected, { style: "full", digits, locale })}` : openLabel, "aria-haspopup": "dialog", "aria-expanded": open, "aria-controls": open ? popoverId : undefined, onClick: () => setOpen((o) => !o), children: _jsxs("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.7, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [_jsx("rect", { x: "3", y: "4.5", width: "14", height: "12.5", rx: "2" }), _jsx("path", { d: "M3 8.5h14M7 3v3M13 3v3" })] }) }), ...rest }), name && _jsx("input", { type: "hidden", name: name, value: selected ? toISODate(selected) : "" }), open && (_jsx("div", { id: popoverId, className: "k-datepicker__popover", role: "dialog", "aria-label": openLabel, style: { insetBlockStart: top }, onKeyDown: (e) => {
|
|
80
81
|
if (e.key === "Escape") {
|
|
81
82
|
e.stopPropagation();
|
|
82
83
|
close();
|
|
@@ -31,6 +31,8 @@ export interface DateRangePickerProps {
|
|
|
31
31
|
/** با name، دو فیلد پنهان name_start و name_end به شکل YYYY-MM-DD ساخته میشود */
|
|
32
32
|
name?: string;
|
|
33
33
|
disabled?: boolean;
|
|
34
|
+
/** فقطخواندنی: مقدار دیده و با فرم ارسال میشود ولی عوض نمیشود */
|
|
35
|
+
readOnly?: boolean;
|
|
34
36
|
id?: string;
|
|
35
37
|
className?: string;
|
|
36
38
|
calendarLabels?: CalendarLabels;
|
|
@@ -49,4 +51,4 @@ export interface DateRangePickerProps {
|
|
|
49
51
|
* انتخاب بازهٔ تاریخ شمسی: کلیک اول شروع، کلیک دوم پایان؛ پیش از تأیید، بازه با حرکت موس پیشنمایش میشود.
|
|
50
52
|
* تغییرها فقط با «تأیید» ثبت میشوند.
|
|
51
53
|
*/
|
|
52
|
-
export declare function DateRangePicker({ label, hint, error, value, defaultValue, onChange, min, max, isDateDisabled, holidays, presets, digits, name, disabled, id, className, calendarLabels, labels, }: DateRangePickerProps): import("react").JSX.Element;
|
|
54
|
+
export declare function DateRangePicker({ label, hint, error, value, defaultValue, onChange, min, max, isDateDisabled, holidays, presets, digits, name, disabled, readOnly, id, className, calendarLabels, labels, }: DateRangePickerProps): import("react").JSX.Element;
|
package/dist/DateRangePicker.js
CHANGED
|
@@ -33,7 +33,7 @@ export const defaultRangePresets = presetsFor(faMessages.dateRange, (v) => toFaD
|
|
|
33
33
|
* انتخاب بازهٔ تاریخ شمسی: کلیک اول شروع، کلیک دوم پایان؛ پیش از تأیید، بازه با حرکت موس پیشنمایش میشود.
|
|
34
34
|
* تغییرها فقط با «تأیید» ثبت میشوند.
|
|
35
35
|
*/
|
|
36
|
-
export function DateRangePicker({ label, hint, error, value, defaultValue = { start: null, end: null }, onChange, min, max, isDateDisabled, holidays, presets, digits, name, disabled, id, className, calendarLabels, labels = {}, }) {
|
|
36
|
+
export function DateRangePicker({ label, hint, error, value, defaultValue = { start: null, end: null }, onChange, min, max, isDateDisabled, holidays, presets, digits, name, disabled, readOnly, id, className, calendarLabels, labels = {}, }) {
|
|
37
37
|
const { messages: M, digits: D, locale, n: N } = useKashi();
|
|
38
38
|
digits ?? (digits = D);
|
|
39
39
|
presets ?? (presets = presetsFor(M.dateRange, N));
|
|
@@ -85,7 +85,7 @@ export function DateRangePicker({ label, hint, error, value, defaultValue = { st
|
|
|
85
85
|
const r = p.range(today);
|
|
86
86
|
return draft.start?.getTime() === r.start.getTime() && draft.end?.getTime() === r.end.getTime();
|
|
87
87
|
});
|
|
88
|
-
return (_jsx(Field, { id: triggerId, label: label, hint: hint, error: error, className: className, children: _jsxs("div", { className: "k-datepicker k-daterange", ref: wrap, children: [_jsx("div", { className: "k-select", children: _jsxs("button", { ref: trigger, id: triggerId, type: "button", className: "k-select__control k-daterange__trigger", "aria-haspopup": "dialog", "aria-expanded": open, "aria-controls": open ? popoverId : undefined, "aria-invalid": error ? true : undefined, disabled: disabled, "data-placeholder": text ? undefined : "", onClick: () => setOpen((o) => !o), children: [_jsxs("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.7, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [_jsx("rect", { x: "3", y: "4.5", width: "14", height: "12.5", rx: "2" }), _jsx("path", { d: "M3 8.5h14M7 3v3M13 3v3" })] }), _jsx("span", { children: text ?? placeholder })] }) }), name && (_jsxs(_Fragment, { children: [_jsx("input", { type: "hidden", name: `${name}_start`, value: current.start ? toISODate(current.start) : "" }), _jsx("input", { type: "hidden", name: `${name}_end`, value: current.end ? toISODate(current.end) : "" })] })), open && (_jsxs("div", { id: popoverId, role: "dialog", "aria-label": typeof label === "string" ? label : placeholder, className: "k-datepicker__popover k-daterange__popover", onKeyDown: (e) => {
|
|
88
|
+
return (_jsx(Field, { id: triggerId, label: label, hint: hint, error: error, className: className, children: _jsxs("div", { className: "k-datepicker k-daterange", ref: wrap, "data-readonly": readOnly || undefined, children: [_jsx("div", { className: "k-select", children: _jsxs("button", { ref: trigger, id: triggerId, type: "button", className: "k-select__control k-daterange__trigger", "aria-haspopup": "dialog", "aria-expanded": open, "aria-controls": open ? popoverId : undefined, "aria-invalid": error ? true : undefined, disabled: disabled, "aria-readonly": readOnly || undefined, "data-placeholder": text ? undefined : "", onClick: () => !readOnly && setOpen((o) => !o), children: [_jsxs("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.7, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [_jsx("rect", { x: "3", y: "4.5", width: "14", height: "12.5", rx: "2" }), _jsx("path", { d: "M3 8.5h14M7 3v3M13 3v3" })] }), _jsx("span", { children: text ?? placeholder })] }) }), name && (_jsxs(_Fragment, { children: [_jsx("input", { type: "hidden", name: `${name}_start`, value: current.start ? toISODate(current.start) : "" }), _jsx("input", { type: "hidden", name: `${name}_end`, value: current.end ? toISODate(current.end) : "" })] })), open && (_jsxs("div", { id: popoverId, role: "dialog", "aria-label": typeof label === "string" ? label : placeholder, className: "k-datepicker__popover k-daterange__popover", onKeyDown: (e) => {
|
|
89
89
|
if (e.key === "Escape") {
|
|
90
90
|
e.stopPropagation();
|
|
91
91
|
close();
|
package/dist/MultiSelect.d.ts
CHANGED
|
@@ -14,6 +14,10 @@ export interface MultiSelectProps {
|
|
|
14
14
|
filter?: (option: ComboboxOption, query: string) => boolean;
|
|
15
15
|
/** @default "نتیجهای پیدا نشد." */
|
|
16
16
|
emptyMessage?: ReactNode;
|
|
17
|
+
/** فقطخواندنی: انتخابها دیده و ارسال میشوند ولی فهرست باز و چیزی حذف نمیشود */
|
|
18
|
+
readOnly?: boolean;
|
|
19
|
+
/** گزینهها در حال بارگذاریاند؛ ردیفهای اسکلتی در فهرست */
|
|
20
|
+
loading?: boolean;
|
|
17
21
|
disabled?: boolean;
|
|
18
22
|
/** با name، یک فیلد پنهان برای هر مقدار */
|
|
19
23
|
name?: string;
|
|
@@ -30,4 +34,4 @@ export interface MultiSelectProps {
|
|
|
30
34
|
* انتخاب چند گزینه با جستجو؛ انتخابها بهشکل برچسب داخل فیلد.
|
|
31
35
|
* ↑↓ حرکت، Enter انتخاب یا لغو انتخاب، Backspace در فیلد خالی آخرین برچسب را حذف میکند، Esc بستن.
|
|
32
36
|
*/
|
|
33
|
-
export declare function MultiSelect({ label, hint, error, options, value, defaultValue, onChange, placeholder, max, filter, emptyMessage, disabled, name, id, className, labels, }: MultiSelectProps): import("react").JSX.Element;
|
|
37
|
+
export declare function MultiSelect({ label, hint, error, options, value, defaultValue, onChange, placeholder, max, filter, emptyMessage, disabled, readOnly, loading, name, id, className, labels, }: MultiSelectProps): import("react").JSX.Element;
|
package/dist/MultiSelect.js
CHANGED
|
@@ -10,7 +10,7 @@ const Check = () => _jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "c
|
|
|
10
10
|
* انتخاب چند گزینه با جستجو؛ انتخابها بهشکل برچسب داخل فیلد.
|
|
11
11
|
* ↑↓ حرکت، Enter انتخاب یا لغو انتخاب، Backspace در فیلد خالی آخرین برچسب را حذف میکند، Esc بستن.
|
|
12
12
|
*/
|
|
13
|
-
export function MultiSelect({ label, hint, error, options, value, defaultValue = [], onChange, placeholder, max, filter = defaultFilter, emptyMessage, disabled, name, id, className, labels = {}, }) {
|
|
13
|
+
export function MultiSelect({ label, hint, error, options, value, defaultValue = [], onChange, placeholder, max, filter = defaultFilter, emptyMessage, disabled, readOnly, loading, name, id, className, labels = {}, }) {
|
|
14
14
|
const { messages: M, n: N } = useKashi();
|
|
15
15
|
emptyMessage ?? (emptyMessage = M.common.noResults);
|
|
16
16
|
const { remove = M.common.remove, selected: selectedLabel = (x) => M.multiSelect.selected(N(x)), max: maxLabel = (x) => M.common.max(N(x)), clear = M.common.clearAll, } = labels;
|
|
@@ -74,11 +74,13 @@ export function MultiSelect({ label, hint, error, options, value, defaultValue =
|
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
76
|
const labelOf = (v) => options.find((o) => o.value === v)?.label ?? v;
|
|
77
|
-
return (_jsx(Field, { id: inputId, label: label, hint: hint, error: error, className: className, children: _jsxs("div", { ref: wrap, className: "k-combobox k-multiselect", "data-open": open ? "" : undefined, onBlur: (e) => !wrap.current?.contains(e.relatedTarget) && setOpen(false), children: [_jsxs("div", { className: "k-tag-input", "data-invalid": error ? "" : undefined, onClick: () => input.current?.focus(), children: [chosen.map((v) => (_jsx(Badge, { tone: "brand", onRemove: disabled ? undefined : () => set(chosen.filter((x) => x !== v)), removeLabel: remove(labelOf(v)), children: labelOf(v) }, v))), _jsx("input", { ref: input, id: inputId, className: "k-tag-input__control", role: "combobox", "aria-autocomplete": "list", "aria-expanded": open, "aria-controls": listId, "aria-activedescendant": open && active >= 0 ? `${listId}-${active}` : undefined, "aria-describedby": describedBy(inputId, hint, error, `${inputId}-count`), "aria-invalid": error ? true : undefined, autoComplete: "off", placeholder: chosen.length ? undefined : placeholder, disabled: disabled, value: query, onChange: (e) => {
|
|
77
|
+
return (_jsx(Field, { id: inputId, label: label, hint: hint, error: error, className: className, children: _jsxs("div", { ref: wrap, className: "k-combobox k-multiselect", "data-open": open ? "" : undefined, onBlur: (e) => !wrap.current?.contains(e.relatedTarget) && setOpen(false), children: [_jsxs("div", { className: "k-tag-input", "data-invalid": error ? "" : undefined, "data-readonly": readOnly || undefined, "aria-busy": loading || undefined, onClick: () => input.current?.focus(), children: [chosen.map((v) => (_jsx(Badge, { tone: "brand", onRemove: disabled || readOnly ? undefined : () => set(chosen.filter((x) => x !== v)), removeLabel: remove(labelOf(v)), children: labelOf(v) }, v))), _jsx("input", { ref: input, id: inputId, className: "k-tag-input__control", role: "combobox", "aria-autocomplete": "list", "aria-expanded": open, "aria-controls": listId, "aria-activedescendant": open && active >= 0 ? `${listId}-${active}` : undefined, "aria-describedby": describedBy(inputId, hint, error, `${inputId}-count`), "aria-invalid": error ? true : undefined, autoComplete: "off", placeholder: chosen.length || readOnly ? undefined : placeholder, disabled: disabled, readOnly: readOnly, value: query, onChange: (e) => {
|
|
78
|
+
if (readOnly)
|
|
79
|
+
return;
|
|
78
80
|
setQuery(e.target.value);
|
|
79
81
|
setOpen(true);
|
|
80
82
|
setActive(0);
|
|
81
|
-
}, onFocus: () => setOpen(true), onKeyDown: onKey }), chosen.length > 1 && !disabled && (_jsx("button", { type: "button", className: "k-input__action", "aria-label": clear, onClick: () => { set([]); input.current?.focus(); }, children: _jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.7, strokeLinecap: "round", "aria-hidden": "true", children: _jsx("path", { d: "m6 6 8 8M14 6l-8 8" }) }) }))] }), _jsxs("ul", { id: listId, role: "listbox", "aria-multiselectable": "true", "aria-label": typeof label === "string" ? label : undefined, className: "k-listbox", hidden: !open, style: { insetBlockStart: "calc(100% + 6px)" }, children: [filtered.length === 0 && _jsx("li", { className: "k-listbox__empty", role: "presentation", children: emptyMessage }), filtered.map((o, i) => {
|
|
83
|
+
}, onFocus: () => !readOnly && setOpen(true), onKeyDown: readOnly ? undefined : onKey }), chosen.length > 1 && !disabled && !readOnly && (_jsx("button", { type: "button", className: "k-input__action", "aria-label": clear, onClick: () => { set([]); input.current?.focus(); }, children: _jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.7, strokeLinecap: "round", "aria-hidden": "true", children: _jsx("path", { d: "m6 6 8 8M14 6l-8 8" }) }) }))] }), _jsxs("ul", { id: listId, role: "listbox", "aria-multiselectable": "true", "aria-label": typeof label === "string" ? label : undefined, className: "k-listbox", hidden: !open, style: { insetBlockStart: "calc(100% + 6px)" }, children: [loading && filtered.length === 0 && [0, 1, 2].map((k) => _jsx("li", { className: "k-listbox__loading", role: "presentation" }, `l${k}`)), !loading && filtered.length === 0 && _jsx("li", { className: "k-listbox__empty", role: "presentation", children: emptyMessage }), filtered.map((o, i) => {
|
|
82
84
|
const on = chosen.includes(o.value);
|
|
83
85
|
return (_jsxs("li", { id: `${listId}-${i}`, role: "option", "aria-selected": on, "aria-disabled": o.disabled || (!on && full) || undefined, "data-active": i === active ? "" : undefined, className: "k-option k-option--check", onPointerDown: (e) => e.preventDefault(), onClick: () => toggle(o), onPointerMove: () => active !== i && setActive(i), children: [_jsx("span", { className: "k-multiselect__box", "aria-hidden": "true", children: on && _jsx(Check, {}) }), o.icon, _jsxs("span", { className: "k-option__body", children: [_jsx("span", { children: highlight(o.label, query) }), o.description && _jsx("span", { className: "k-option__desc", children: o.description })] })] }, o.value));
|
|
84
86
|
})] }), _jsx("span", { id: `${inputId}-count`, className: "k-sr-only", children: selectedLabel(chosen.length) }), _jsx("span", { className: "k-sr-only", "aria-live": "polite", children: announce }), name && chosen.map((v) => _jsx("input", { type: "hidden", name: name, value: v }, v))] }) }));
|
package/dist/NumberInput.d.ts
CHANGED
|
@@ -17,6 +17,8 @@ export interface NumberInputProps {
|
|
|
17
17
|
/** واحد کنار عدد، مثل «نفر» */
|
|
18
18
|
unit?: ReactNode;
|
|
19
19
|
disabled?: boolean;
|
|
20
|
+
/** فقطخواندنی: مقدار دیده و با فرم ارسال میشود ولی عوض نمیشود */
|
|
21
|
+
readOnly?: boolean;
|
|
20
22
|
name?: string;
|
|
21
23
|
id?: string;
|
|
22
24
|
className?: string;
|
package/dist/NumberInput.js
CHANGED
|
@@ -8,7 +8,7 @@ import { useKashi } from "./KashiProvider.js";
|
|
|
8
8
|
const Minus = () => _jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", "aria-hidden": "true", children: _jsx("path", { d: "M5 10h10" }) });
|
|
9
9
|
const Plus = () => _jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", "aria-hidden": "true", children: _jsx("path", { d: "M10 5v10M5 10h10" }) });
|
|
10
10
|
/** ورودی عدد با دکمههای + و −؛ ↑↓ یک گام، PageUp/PageDown ده گام، Home/End کمینه و بیشینه */
|
|
11
|
-
export const NumberInput = forwardRef(function NumberInput({ label, hint, error, value, defaultValue = null, onChange, min, max, step = 1, thousands, digits, unit, disabled, name, id, className, labels = {} }, ref) {
|
|
11
|
+
export const NumberInput = forwardRef(function NumberInput({ label, hint, error, value, defaultValue = null, onChange, min, max, step = 1, thousands, digits, unit, disabled, readOnly, name, id, className, labels = {} }, ref) {
|
|
12
12
|
const { messages: M, digits: D } = useKashi();
|
|
13
13
|
digits ?? (digits = D);
|
|
14
14
|
const autoId = useId();
|
|
@@ -46,7 +46,7 @@ export const NumberInput = forwardRef(function NumberInput({ label, hint, error,
|
|
|
46
46
|
keys[e.key]();
|
|
47
47
|
setDraft(null);
|
|
48
48
|
};
|
|
49
|
-
return (_jsxs(Field, { id: inputId, label: label, hint: hint, error: error, className: className, children: [_jsx("div", { className: cx("k-number"), children: _jsxs("div", { className: "k-input", "data-state": error ? "invalid" : disabled ? "disabled" : undefined, children: [_jsx("button", { type: "button", className: "k-number__step", tabIndex: -1, "aria-label": decrement, disabled: disabled || (min !== undefined && (current ?? 0) <= min), onClick: () => bump(-1), children: _jsx(Minus, {}) }), _jsx("input", { ref: ref, id: inputId, className: "k-input__control", type: "text", inputMode: "decimal", role: "spinbutton", "aria-valuenow": current ?? undefined, "aria-valuemin": min, "aria-valuemax": max, "aria-valuetext": current === null ? undefined : show(current), "aria-invalid": error ? true : undefined, "aria-describedby": describedBy(inputId, hint, error), disabled: disabled, dir: "ltr", value: draft ?? show(current), onChange: (e) => {
|
|
49
|
+
return (_jsxs(Field, { id: inputId, label: label, hint: hint, error: error, className: className, children: [_jsx("div", { className: cx("k-number"), children: _jsxs("div", { className: "k-input", "data-state": error ? "invalid" : disabled ? "disabled" : undefined, children: [_jsx("button", { type: "button", className: "k-number__step", tabIndex: -1, "aria-label": decrement, hidden: readOnly, disabled: disabled || (min !== undefined && (current ?? 0) <= min), onClick: () => bump(-1), children: _jsx(Minus, {}) }), _jsx("input", { ref: ref, id: inputId, className: "k-input__control", type: "text", inputMode: "decimal", role: "spinbutton", "aria-valuenow": current ?? undefined, "aria-valuemin": min, "aria-valuemax": max, "aria-valuetext": current === null ? undefined : show(current), "aria-invalid": error ? true : undefined, "aria-describedby": describedBy(inputId, hint, error), disabled: disabled, readOnly: readOnly, "aria-readonly": readOnly || undefined, dir: "ltr", value: draft ?? show(current), onChange: (e) => {
|
|
50
50
|
const raw = e.target.value;
|
|
51
51
|
const neg = /^\s*[-−]/.test(raw);
|
|
52
52
|
const d = onlyDigits(raw);
|
|
@@ -56,5 +56,5 @@ export const NumberInput = forwardRef(function NumberInput({ label, hint, error,
|
|
|
56
56
|
setDraft(null);
|
|
57
57
|
if (current !== null && current !== clamp(current))
|
|
58
58
|
set(clamp(current));
|
|
59
|
-
}, onKeyDown: onKeyDown }), unit && _jsx("span", { className: "k-input__addon", children: unit }), _jsx("button", { type: "button", className: "k-number__step", tabIndex: -1, "aria-label": increment, disabled: disabled || (max !== undefined && (current ?? 0) >= max), onClick: () => bump(1), children: _jsx(Plus, {}) })] }) }), name && _jsx("input", { type: "hidden", name: name, value: current ?? "" })] }));
|
|
59
|
+
}, onKeyDown: readOnly ? undefined : onKeyDown }), unit && _jsx("span", { className: "k-input__addon", children: unit }), _jsx("button", { type: "button", className: "k-number__step", tabIndex: -1, "aria-label": increment, hidden: readOnly, disabled: disabled || (max !== undefined && (current ?? 0) >= max), onClick: () => bump(1), children: _jsx(Plus, {}) })] }) }), name && _jsx("input", { type: "hidden", name: name, value: current ?? "" })] }));
|
|
60
60
|
});
|
package/dist/OtpInput.d.ts
CHANGED
package/dist/OtpInput.js
CHANGED
|
@@ -10,7 +10,7 @@ import { useKashi } from "./KashiProvider.js";
|
|
|
10
10
|
* کد تأیید یکبارمصرف: یک input واقعی (نه شش input جدا)، پس چسباندن، پاک کردن،
|
|
11
11
|
* صفحهخوان و پر شدن خودکار کد پیامکی (autocomplete="one-time-code") بینقص کار میکنند.
|
|
12
12
|
*/
|
|
13
|
-
export const OtpInput = forwardRef(function OtpInput({ label, hint, error, length = 6, value, defaultValue = "", onChange, onComplete, digits, groupAfter, size = "md", disabled, autoFocus, name, id, className }, ref) {
|
|
13
|
+
export const OtpInput = forwardRef(function OtpInput({ label, hint, error, length = 6, value, defaultValue = "", onChange, onComplete, digits, groupAfter, size = "md", disabled, readOnly, autoFocus, name, id, className }, ref) {
|
|
14
14
|
const { digits: D } = useKashi();
|
|
15
15
|
digits ?? (digits = D);
|
|
16
16
|
const autoId = useId();
|
|
@@ -22,7 +22,7 @@ export const OtpInput = forwardRef(function OtpInput({ label, hint, error, lengt
|
|
|
22
22
|
const d = (c) => (digits === "fa" ? toFaDigits(c) : c);
|
|
23
23
|
const active = Math.min(caret, length - 1);
|
|
24
24
|
const sync = () => setCaret(Math.min(inputRef.current?.selectionStart ?? code.length, length));
|
|
25
|
-
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) => {
|
|
25
|
+
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, readOnly: readOnly, autoFocus: autoFocus, "aria-invalid": error ? true : undefined, "aria-describedby": describedBy(inputId, hint, error), onChange: (e) => {
|
|
26
26
|
const next = onlyDigits(e.target.value).slice(0, length);
|
|
27
27
|
if (value === undefined)
|
|
28
28
|
setInner(next);
|
package/dist/Radio.d.ts
CHANGED
|
@@ -13,11 +13,13 @@ export interface RadioGroupProps {
|
|
|
13
13
|
error?: ReactNode;
|
|
14
14
|
required?: boolean;
|
|
15
15
|
disabled?: boolean;
|
|
16
|
+
/** فقطخواندنی: گزینهٔ انتخابشده دیده و با فرم ارسال میشود ولی عوض نمیشود */
|
|
17
|
+
readOnly?: boolean;
|
|
16
18
|
className?: string;
|
|
17
19
|
children: ReactNode;
|
|
18
20
|
}
|
|
19
21
|
/** گروه رادیو با fieldset و legend؛ پیمایش با کلیدهای جهتدار را مرورگر انجام میدهد */
|
|
20
|
-
export declare function RadioGroup({ label, name, value, defaultValue, onChange, variant, hint, error, required, disabled, className, children, }: RadioGroupProps): import("react").JSX.Element;
|
|
22
|
+
export declare function RadioGroup({ label, name, value, defaultValue, onChange, variant, hint, error, required, disabled, readOnly, className, children, }: RadioGroupProps): import("react").JSX.Element;
|
|
21
23
|
export interface RadioProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "value"> {
|
|
22
24
|
value: string;
|
|
23
25
|
label: ReactNode;
|
package/dist/Radio.js
CHANGED
|
@@ -5,17 +5,20 @@ import { cx } from "./cx.js";
|
|
|
5
5
|
import { isDev } from "./utils.js";
|
|
6
6
|
const RadioCtx = createContext(null);
|
|
7
7
|
/** گروه رادیو با fieldset و legend؛ پیمایش با کلیدهای جهتدار را مرورگر انجام میدهد */
|
|
8
|
-
export function RadioGroup({ label, name, value, defaultValue, onChange, variant = "list", hint, error, required, disabled, className, children, }) {
|
|
8
|
+
export function RadioGroup({ label, name, value, defaultValue, onChange, variant = "list", hint, error, required, disabled, readOnly, className, children, }) {
|
|
9
9
|
const id = useId();
|
|
10
10
|
const [inner, setInner] = useState(defaultValue);
|
|
11
11
|
const current = value !== undefined ? value : inner;
|
|
12
12
|
const describedBy = [error && `${id}-error`, hint && `${id}-hint`].filter(Boolean).join(" ") || undefined;
|
|
13
|
-
return (_jsxs("fieldset", { className: cx("k-radio-group", variant !== "list" && `k-radio-group--${variant}`, className), "aria-describedby": describedBy, "aria-required": required || undefined, "aria-invalid": error ? true : undefined, disabled: disabled, children: [_jsxs("legend", { className: "k-label", children: [label, required && _jsx("span", { className: "k-label__required", "aria-hidden": "true", children: "*" })] }), _jsx(RadioCtx.Provider, { value: {
|
|
13
|
+
return (_jsxs("fieldset", { className: cx("k-radio-group", variant !== "list" && `k-radio-group--${variant}`, className), "aria-describedby": describedBy, "aria-required": required || undefined, "aria-invalid": error ? true : undefined, "aria-readonly": readOnly || undefined, "data-readonly": readOnly || undefined, disabled: disabled, children: [_jsxs("legend", { className: "k-label", children: [label, required && _jsx("span", { className: "k-label__required", "aria-hidden": "true", children: "*" })] }), _jsx(RadioCtx.Provider, { value: {
|
|
14
14
|
name: name ?? id,
|
|
15
15
|
value: current,
|
|
16
16
|
invalid: !!error,
|
|
17
17
|
disabled,
|
|
18
|
+
readOnly,
|
|
18
19
|
setValue: (v) => {
|
|
20
|
+
if (readOnly)
|
|
21
|
+
return;
|
|
19
22
|
if (value === undefined)
|
|
20
23
|
setInner(v);
|
|
21
24
|
onChange?.(v);
|
|
@@ -30,5 +33,5 @@ export const Radio = forwardRef(function Radio({ value, label, description, badg
|
|
|
30
33
|
}
|
|
31
34
|
const autoId = useId();
|
|
32
35
|
const inputId = id ?? autoId;
|
|
33
|
-
return (_jsxs("label", { className: cx("k-check", className), htmlFor: inputId, children: [_jsx("input", { ref: ref, type: "radio", className: "k-radio", id: inputId, name: ctx?.name ?? name, value: value, checked: ctx ? ctx.value === value : undefined, onChange: () => ctx?.setValue(value), disabled: disabled, "aria-describedby": description ? `${inputId}-desc` : undefined, ...rest }), _jsxs("span", { className: "k-check__text", children: [badge != null && badge !== false ? (_jsxs("span", { className: "k-check__head", children: [_jsx("span", { className: "k-check__label", children: label }), typeof badge === "string" ? _jsx("span", { className: "k-badge k-badge--brand k-badge--sm", children: badge }) : badge] })) : (_jsx("span", { className: "k-check__label", children: label })), description && _jsx("span", { className: "k-check__description", id: `${inputId}-desc`, children: description })] }), meta != null && meta !== false && _jsx("span", { className: "k-check__meta", children: meta })] }));
|
|
36
|
+
return (_jsxs("label", { className: cx("k-check", className), htmlFor: inputId, "data-readonly": ctx?.readOnly || undefined, children: [_jsx("input", { ref: ref, type: "radio", className: "k-radio", id: inputId, name: ctx?.name ?? name, value: value, checked: ctx ? ctx.value === value : undefined, onChange: () => ctx?.setValue(value), disabled: disabled, "aria-readonly": ctx?.readOnly || undefined, "aria-describedby": description ? `${inputId}-desc` : undefined, ...rest }), _jsxs("span", { className: "k-check__text", children: [badge != null && badge !== false ? (_jsxs("span", { className: "k-check__head", children: [_jsx("span", { className: "k-check__label", children: label }), typeof badge === "string" ? _jsx("span", { className: "k-badge k-badge--brand k-badge--sm", children: badge }) : badge] })) : (_jsx("span", { className: "k-check__label", children: label })), description && _jsx("span", { className: "k-check__description", id: `${inputId}-desc`, children: description })] }), meta != null && meta !== false && _jsx("span", { className: "k-check__meta", children: meta })] }));
|
|
34
37
|
});
|
package/dist/SearchSuggest.d.ts
CHANGED
|
@@ -24,6 +24,10 @@ export interface SearchSuggestProps {
|
|
|
24
24
|
popular?: ReactNode;
|
|
25
25
|
clear?: ReactNode;
|
|
26
26
|
};
|
|
27
|
+
/** پیشنهادها در راهاند (مثلاً از سرور)؛ ردیفهای اسکلتی زیر جعبه */
|
|
28
|
+
loading?: boolean;
|
|
29
|
+
/** پیام وقتی برای عبارت تایپشده پیشنهادی نیست؛ بدون آن، پنل بسته میماند */
|
|
30
|
+
emptyMessage?: ReactNode;
|
|
27
31
|
}
|
|
28
32
|
/** جعبهٔ جستجو با جستجوهای اخیر و پرطرفدار و پیشنهاد هنگام تایپ (الگوی فروشگاههای اینترنتی) */
|
|
29
|
-
export declare function SearchSuggest({ value, defaultValue, onChange, onSearch, recent, onClearRecent, storageKey, popular, suggestions, placeholder, label, name, className, labels, }: SearchSuggestProps): import("react").JSX.Element;
|
|
33
|
+
export declare function SearchSuggest({ value, defaultValue, onChange, onSearch, recent, onClearRecent, storageKey, popular, suggestions, placeholder, label, name, className, labels, loading, emptyMessage, }: SearchSuggestProps): import("react").JSX.Element;
|
package/dist/SearchSuggest.js
CHANGED
|
@@ -9,7 +9,7 @@ const SearchIcon = () => _jsxs("svg", { viewBox: "0 0 20 20", width: "20", heigh
|
|
|
9
9
|
const TrendIcon = () => _jsx("svg", { viewBox: "0 0 20 20", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "m2.75 13.5 4.6-4.6 3.2 3.2 6.2-6.2M12.75 5.9h4v4" }) });
|
|
10
10
|
const HistoryIcon = () => _jsx("svg", { viewBox: "0 0 20 20", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "M3.3 10a6.7 6.7 0 1 0 1.9-4.7M3.2 2.9v2.6h2.6M10 6.6V10l2.3 1.5" }) });
|
|
11
11
|
/** جعبهٔ جستجو با جستجوهای اخیر و پرطرفدار و پیشنهاد هنگام تایپ (الگوی فروشگاههای اینترنتی) */
|
|
12
|
-
export function SearchSuggest({ value, defaultValue, onChange, onSearch, recent, onClearRecent, storageKey, popular = [], suggestions, placeholder, label, name, className, labels = {}, }) {
|
|
12
|
+
export function SearchSuggest({ value, defaultValue, onChange, onSearch, recent, onClearRecent, storageKey, popular = [], suggestions, placeholder, label, name, className, labels = {}, loading, emptyMessage, }) {
|
|
13
13
|
const { messages: M } = useKashi();
|
|
14
14
|
const id = useId();
|
|
15
15
|
const listId = `${id}-panel`;
|
|
@@ -63,7 +63,9 @@ export function SearchSuggest({ value, defaultValue, onChange, onSearch, recent,
|
|
|
63
63
|
const boxRef = useRef(null);
|
|
64
64
|
const showList = list.length > 0;
|
|
65
65
|
const showIdle = !q.trim() && (history.length > 0 || popular.length > 0);
|
|
66
|
-
const
|
|
66
|
+
const showLoading = !!loading && !!q.trim() && !showList;
|
|
67
|
+
const showEmpty = !loading && !!q.trim() && !showList && emptyMessage !== undefined;
|
|
68
|
+
const visible = open && (showList || showIdle || showLoading || showEmpty);
|
|
67
69
|
const submit = (s) => {
|
|
68
70
|
const t = s.trim();
|
|
69
71
|
if (!t)
|
|
@@ -137,8 +139,8 @@ export function SearchSuggest({ value, defaultValue, onChange, onSearch, recent,
|
|
|
137
139
|
return s;
|
|
138
140
|
return _jsxs(_Fragment, { children: [s.slice(0, i), _jsx("mark", { children: s.slice(i, i + q.trim().length) }), s.slice(i + q.trim().length)] });
|
|
139
141
|
};
|
|
140
|
-
return (_jsxs("form", { role: "search", className: cx("k-search-suggest", className), onSubmit: onSubmit, "data-open": visible || undefined, children: [_jsxs("div", { className: "k-search-suggest__box", ref: boxRef, children: [_jsx(SearchIcon, {}), _jsx("input", { ref: inputRef, type: "search", name: name, className: "k-search-suggest__input", value: q, placeholder: placeholder, "aria-label": label ?? M.searchSuggest.label, role: "combobox", "aria-autocomplete": "list", "aria-expanded": visible, "aria-controls": listId, "aria-activedescendant": visible && showList && active >= 0 ? `${listId}-${active}` : undefined, autoComplete: "off", enterKeyHint: "search", onFocus: () => setOpen(true), onChange: (e) => { setQ(e.target.value); setOpen(true); }, onKeyDown: onKeyDown })] }), _jsx("div", { id: listId, ref: panelRef, className: "k-search-suggest__panel", hidden: !visible, ...{ popover: "manual" }, style: pos ? { position: "fixed", inset: "auto", margin: 0, top: pos.top, left: pos.left, width: pos.width } : undefined, onKeyDown: (e) => { if (e.key === "Escape") {
|
|
142
|
+
return (_jsxs("form", { role: "search", className: cx("k-search-suggest", className), onSubmit: onSubmit, "data-open": visible || undefined, children: [_jsxs("div", { className: "k-search-suggest__box", ref: boxRef, "aria-busy": loading || undefined, children: [_jsx(SearchIcon, {}), _jsx("input", { ref: inputRef, type: "search", name: name, className: "k-search-suggest__input", value: q, placeholder: placeholder, "aria-label": label ?? M.searchSuggest.label, role: "combobox", "aria-autocomplete": "list", "aria-expanded": visible, "aria-controls": listId, "aria-activedescendant": visible && showList && active >= 0 ? `${listId}-${active}` : undefined, autoComplete: "off", enterKeyHint: "search", onFocus: () => setOpen(true), onChange: (e) => { setQ(e.target.value); setOpen(true); }, onKeyDown: onKeyDown })] }), _jsx("div", { id: listId, ref: panelRef, className: "k-search-suggest__panel", hidden: !visible, ...{ popover: "manual" }, style: pos ? { position: "fixed", inset: "auto", margin: 0, top: pos.top, left: pos.left, width: pos.width } : undefined, onKeyDown: (e) => { if (e.key === "Escape") {
|
|
141
143
|
setOpen(false);
|
|
142
144
|
inputRef.current?.focus();
|
|
143
|
-
} }, children: showList ? (_jsx("ul", { role: "listbox", "aria-label": M.searchSuggest.suggestions, className: "k-search-suggest__list", children: list.map((s, i) => (_jsxs("li", { id: `${listId}-${i}`, role: "option", "aria-selected": i === active, className: "k-option", "data-active": i === active || undefined, onMouseDown: (e) => e.preventDefault(), onPointerMove: () => setActive(i), onClick: () => submit(s), children: [_jsx(SearchIcon, {}), _jsx("span", { className: "k-option__label", children: highlight(s) })] }, s))) })) : (_jsxs(_Fragment, { children: [history.length > 0 && (_jsxs("section", { className: "k-search-suggest__section", children: [_jsxs("div", { className: "k-search-suggest__head", children: [_jsx("b", { children: labels.recent ?? M.searchSuggest.recent }), _jsx("button", { type: "button", className: "k-btn k-btn--link k-btn--sm", onMouseDown: (e) => e.preventDefault(), onClick: clearHistory, children: labels.clear ?? M.searchSuggest.clear })] }), _jsx("ul", { className: "k-search-suggest__chips", children: history.map((s) => chip(s, "recent")) })] })), popular.length > 0 && (_jsxs("section", { className: "k-search-suggest__section", children: [_jsx("div", { className: "k-search-suggest__head", children: _jsx("b", { children: labels.popular ?? M.searchSuggest.popular }) }), _jsx("ul", { className: "k-search-suggest__chips", children: popular.map((s) => chip(s, "popular")) })] }))] })) })] }));
|
|
145
|
+
} }, children: showLoading ? (_jsx("ul", { className: "k-search-suggest__list", role: "presentation", children: [0, 1, 2].map((k) => _jsx("li", { className: "k-listbox__loading" }, k)) })) : showEmpty ? (_jsx("ul", { className: "k-search-suggest__list", role: "presentation", children: _jsx("li", { className: "k-listbox__empty", children: emptyMessage }) })) : showList ? (_jsx("ul", { role: "listbox", "aria-label": M.searchSuggest.suggestions, className: "k-search-suggest__list", children: list.map((s, i) => (_jsxs("li", { id: `${listId}-${i}`, role: "option", "aria-selected": i === active, className: "k-option", "data-active": i === active || undefined, onMouseDown: (e) => e.preventDefault(), onPointerMove: () => setActive(i), onClick: () => submit(s), children: [_jsx(SearchIcon, {}), _jsx("span", { className: "k-option__label", children: highlight(s) })] }, s))) })) : (_jsxs(_Fragment, { children: [history.length > 0 && (_jsxs("section", { className: "k-search-suggest__section", children: [_jsxs("div", { className: "k-search-suggest__head", children: [_jsx("b", { children: labels.recent ?? M.searchSuggest.recent }), _jsx("button", { type: "button", className: "k-btn k-btn--link k-btn--sm", onMouseDown: (e) => e.preventDefault(), onClick: clearHistory, children: labels.clear ?? M.searchSuggest.clear })] }), _jsx("ul", { className: "k-search-suggest__chips", children: history.map((s) => chip(s, "recent")) })] })), popular.length > 0 && (_jsxs("section", { className: "k-search-suggest__section", children: [_jsx("div", { className: "k-search-suggest__head", children: _jsx("b", { children: labels.popular ?? M.searchSuggest.popular }) }), _jsx("ul", { className: "k-search-suggest__chips", children: popular.map((s) => chip(s, "popular")) })] }))] })) })] }));
|
|
144
146
|
}
|
|
@@ -21,7 +21,9 @@ export interface SegmentedControlProps {
|
|
|
21
21
|
/** تمامعرض با بخشهای هماندازه */
|
|
22
22
|
block?: boolean;
|
|
23
23
|
disabled?: boolean;
|
|
24
|
+
/** فقطخواندنی: انتخابها دیده میشوند ولی عوض نمیشوند */
|
|
25
|
+
readOnly?: boolean;
|
|
24
26
|
className?: string;
|
|
25
27
|
}
|
|
26
28
|
/** انتخاب یکی از چند گزینهٔ کوتاه، مثل «فهرست / جدول / کارت»؛ روی رادیوی بومی با پیمایش ↑↓←→ */
|
|
27
|
-
export declare function SegmentedControl({ options, value, defaultValue, onChange, name, size, block, disabled, className, "aria-label": ariaLabel, "aria-labelledby": labelledBy, }: SegmentedControlProps): import("react").JSX.Element;
|
|
29
|
+
export declare function SegmentedControl({ options, value, defaultValue, onChange, name, size, block, disabled, readOnly, className, "aria-label": ariaLabel, "aria-labelledby": labelledBy, }: SegmentedControlProps): import("react").JSX.Element;
|
package/dist/SegmentedControl.js
CHANGED
|
@@ -4,7 +4,7 @@ import { useId, useRef, useState } from "react";
|
|
|
4
4
|
import { cx } from "./cx.js";
|
|
5
5
|
import { useIsomorphicLayoutEffect } from "./utils.js";
|
|
6
6
|
/** انتخاب یکی از چند گزینهٔ کوتاه، مثل «فهرست / جدول / کارت»؛ روی رادیوی بومی با پیمایش ↑↓←→ */
|
|
7
|
-
export function SegmentedControl({ options, value, defaultValue, onChange, name, size = "md", block, disabled, className, "aria-label": ariaLabel, "aria-labelledby": labelledBy, }) {
|
|
7
|
+
export function SegmentedControl({ options, value, defaultValue, onChange, name, size = "md", block, disabled, readOnly, className, "aria-label": ariaLabel, "aria-labelledby": labelledBy, }) {
|
|
8
8
|
const autoName = useId();
|
|
9
9
|
const [inner, setInner] = useState(defaultValue ?? options.find((o) => !o.disabled)?.value);
|
|
10
10
|
const current = value ?? inner;
|
|
@@ -24,7 +24,9 @@ export function SegmentedControl({ options, value, defaultValue, onChange, name,
|
|
|
24
24
|
ro.observe(el);
|
|
25
25
|
return () => ro.disconnect();
|
|
26
26
|
}, [current]);
|
|
27
|
-
return (_jsxs("div", { ref: ref, role: "radiogroup", "aria-label": ariaLabel, "aria-labelledby": labelledBy, className: cx("k-segmented", size === "sm" && "k-segmented--sm", block && "k-segmented--block", className), "data-indicator": box ? "" : undefined, style: box ? { "--_ix": `${box.x}px`, "--_iw": `${box.w}px` } : undefined, children: [box && _jsx("span", { className: "k-segmented__indicator", "aria-hidden": "true" }), options.map((o) => (_jsxs("label", { className: "k-segmented__item", children: [_jsx("input", { type: "radio", className: "k-sr-only", name: name ?? autoName, value: o.value, checked: current === o.value, disabled: disabled || o.disabled, "aria-label": o["aria-label"], onChange: () => {
|
|
27
|
+
return (_jsxs("div", { ref: ref, role: "radiogroup", "aria-label": ariaLabel, "aria-labelledby": labelledBy, "aria-readonly": readOnly || undefined, "data-readonly": readOnly || undefined, className: cx("k-segmented", size === "sm" && "k-segmented--sm", block && "k-segmented--block", className), "data-indicator": box ? "" : undefined, style: box ? { "--_ix": `${box.x}px`, "--_iw": `${box.w}px` } : undefined, children: [box && _jsx("span", { className: "k-segmented__indicator", "aria-hidden": "true" }), options.map((o) => (_jsxs("label", { className: "k-segmented__item", children: [_jsx("input", { type: "radio", className: "k-sr-only", name: name ?? autoName, value: o.value, checked: current === o.value, disabled: disabled || o.disabled, "aria-label": o["aria-label"], onChange: () => {
|
|
28
|
+
if (readOnly)
|
|
29
|
+
return;
|
|
28
30
|
if (value === undefined)
|
|
29
31
|
setInner(o.value);
|
|
30
32
|
onChange?.(o.value);
|
package/dist/Select.d.ts
CHANGED
|
@@ -17,6 +17,12 @@ export interface SelectProps extends Omit<SelectHTMLAttributes<HTMLSelectElement
|
|
|
17
17
|
fieldClassName?: string;
|
|
18
18
|
/** فهرست بومی مرورگر بهجای فهرست کاشی؛ برای فهرستهای خیلی بلند یا وقتی انتخابگر سیستم گوشی را میخواهید @default false */
|
|
19
19
|
native?: boolean;
|
|
20
|
+
/** فقطخواندنی: مقدار دیده و با فرم ارسال میشود ولی فهرست باز نمیشود (برخلاف disabled، کمرنگ نمیشود) */
|
|
21
|
+
readOnly?: boolean;
|
|
22
|
+
/** گزینهها در حال بارگذاریاند؛ اسپینر جای شورون و ردیفهای اسکلتی در فهرست */
|
|
23
|
+
loading?: boolean;
|
|
24
|
+
/** پیام فهرست خالی @default «گزینهای برای انتخاب نیست.» */
|
|
25
|
+
emptyMessage?: ReactNode;
|
|
20
26
|
}
|
|
21
27
|
/**
|
|
22
28
|
* انتخاب از فهرست. نسخهٔ ۲: فهرست با ظاهر کاشی، صفحهکلید کامل (فلشها، Home/End، Enter، Escape و تایپ حرف اول)
|
package/dist/Select.js
CHANGED
|
@@ -4,6 +4,7 @@ import { Children, forwardRef, isValidElement, useCallback, useEffect, useId, us
|
|
|
4
4
|
import { cx } from "./cx.js";
|
|
5
5
|
import { Field, describedBy } from "./Field.js";
|
|
6
6
|
import { useIsomorphicLayoutEffect } from "./utils.js";
|
|
7
|
+
import { useKashi } from "./KashiProvider.js";
|
|
7
8
|
const textOf = (node) => typeof node === "string" || typeof node === "number" ? String(node)
|
|
8
9
|
: Array.isArray(node) ? node.map(textOf).join("")
|
|
9
10
|
: isValidElement(node) ? textOf(node.props.children) : "";
|
|
@@ -34,17 +35,18 @@ const Check = () => (_jsx("svg", { className: "k-option__check", viewBox: "0 0 2
|
|
|
34
35
|
* و یک <select> بومیِ پنهان زیرش، تا فرم، name، required، onChange و ref مثل قبل کار کنند.
|
|
35
36
|
* برای انتخابگر سیستم، native بدهید.
|
|
36
37
|
*/
|
|
37
|
-
export const Select = forwardRef(function Select({ label, hint, error, placeholder, options, size = "md", id, required, className, fieldClassName, children, native = false, "aria-describedby": extra, ...rest }, ref) {
|
|
38
|
+
export const Select = forwardRef(function Select({ label, hint, error, placeholder, options, size = "md", id, required, className, fieldClassName, children, native = false, readOnly, loading, emptyMessage, "aria-describedby": extra, ...rest }, ref) {
|
|
38
39
|
const autoId = useId();
|
|
39
40
|
const selectId = id ?? autoId;
|
|
40
41
|
const placeholderSelected = placeholder !== undefined && rest.value === undefined && rest.defaultValue === undefined;
|
|
41
42
|
if (native) {
|
|
42
43
|
return (_jsx(Field, { id: selectId, label: label, hint: hint, error: error, required: required, className: fieldClassName, children: _jsx("div", { className: cx("k-select", size !== "md" && `k-select--${size}`, className), children: _jsxs("select", { ref: ref, id: selectId, className: "k-select__control", required: required, "aria-invalid": error ? true : undefined, "aria-describedby": describedBy(selectId, hint, error, extra), defaultValue: placeholderSelected ? "" : undefined, ...rest, children: [placeholder !== undefined && _jsx("option", { value: "", disabled: true, children: placeholder }), options?.map((o) => _jsx("option", { value: o.value, disabled: o.disabled, children: o.label }, o.value)), children] }) }) }));
|
|
43
44
|
}
|
|
44
|
-
return _jsx(CustomSelect, { selectId, label, hint, error, placeholder, options, size, required, className, fieldClassName, children, extra, placeholderSelected, rest, forwardedRef: ref });
|
|
45
|
+
return _jsx(CustomSelect, { selectId, label, hint, error, placeholder, options, size, required, className, fieldClassName, children, extra, placeholderSelected, rest, readOnly, loading, emptyMessage, forwardedRef: ref });
|
|
45
46
|
});
|
|
46
|
-
function CustomSelect({ selectId, label, hint, error, placeholder, options, size, required, className, fieldClassName, children, extra, placeholderSelected, rest, forwardedRef, }) {
|
|
47
|
+
function CustomSelect({ selectId, label, hint, error, placeholder, options, size, required, className, fieldClassName, children, extra, placeholderSelected, rest, forwardedRef, readOnly, loading, emptyMessage, }) {
|
|
47
48
|
const { value, defaultValue, onChange, disabled, name, form, autoComplete, onBlur, onFocus, ...other } = rest;
|
|
49
|
+
const { messages: M } = useKashi();
|
|
48
50
|
const items = useMemo(() => collect(options, children), [options, children]);
|
|
49
51
|
const opts = items.filter((i) => i.kind === "option");
|
|
50
52
|
const nativeRef = useRef(null);
|
|
@@ -71,7 +73,7 @@ function CustomSelect({ selectId, label, hint, error, placeholder, options, size
|
|
|
71
73
|
}
|
|
72
74
|
}, [controlled]);
|
|
73
75
|
const openList = (to) => {
|
|
74
|
-
if (disabled)
|
|
76
|
+
if (disabled || readOnly)
|
|
75
77
|
return;
|
|
76
78
|
const idx = to ?? Math.max(0, opts.findIndex((o) => o.value === current));
|
|
77
79
|
setActive(idx);
|
|
@@ -147,7 +149,7 @@ function CustomSelect({ selectId, label, hint, error, placeholder, options, size
|
|
|
147
149
|
choose(opts[hit].value);
|
|
148
150
|
};
|
|
149
151
|
const onKeyDown = (e) => {
|
|
150
|
-
if (disabled)
|
|
152
|
+
if (disabled || readOnly)
|
|
151
153
|
return;
|
|
152
154
|
const k = e.key;
|
|
153
155
|
if (!open) {
|
|
@@ -202,15 +204,15 @@ function CustomSelect({ selectId, label, hint, error, placeholder, options, size
|
|
|
202
204
|
typeahead(k);
|
|
203
205
|
};
|
|
204
206
|
let index = -1;
|
|
205
|
-
return (_jsx(Field, { id: selectId, label: label, hint: hint, error: error, required: required, className: fieldClassName, children: _jsxs("div", { className: cx("k-select", "k-select--custom", size !== "md" && `k-select--${size}`, className), "data-open": open || undefined, children: [_jsxs("button", { ref: triggerRef, id: selectId, type: "button", role: "combobox", className: "k-select__control", "aria-haspopup": "listbox", "aria-expanded": open, "aria-controls": listId, "aria-activedescendant": open && active >= 0 ? `${listId}-${active}` : undefined, "aria-invalid": error ? true : undefined, "aria-required": required || undefined, "aria-describedby": describedBy(selectId, hint, error, extra), disabled: disabled, onClick: () => (open ? close(false) : openList()), onKeyDown: onKeyDown, onBlur: (e) => { if (!listRef.current?.contains(e.relatedTarget))
|
|
206
|
-
setOpen(false); }, ...other, children: [_jsx("span", { className: cx("k-select__value", !selected && "k-select__value--placeholder"), children: selected ? selected.label : placeholder ?? " " }), _jsx(Chevron, {})] }),
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
207
|
+
return (_jsx(Field, { id: selectId, label: label, hint: hint, error: error, required: required, className: fieldClassName, children: _jsxs("div", { className: cx("k-select", "k-select--custom", size !== "md" && `k-select--${size}`, className), "data-open": open || undefined, "data-readonly": readOnly || undefined, "aria-busy": loading || undefined, children: [_jsxs("button", { ref: triggerRef, id: selectId, type: "button", role: "combobox", className: "k-select__control", "aria-haspopup": "listbox", "aria-expanded": open, "aria-controls": listId, "aria-activedescendant": open && active >= 0 ? `${listId}-${active}` : undefined, "aria-invalid": error ? true : undefined, "aria-required": required || undefined, "aria-readonly": readOnly || undefined, "aria-describedby": describedBy(selectId, hint, error, extra), disabled: disabled, onClick: () => (open ? close(false) : openList()), onKeyDown: onKeyDown, onBlur: (e) => { if (!listRef.current?.contains(e.relatedTarget))
|
|
208
|
+
setOpen(false); }, ...other, children: [_jsx("span", { className: cx("k-select__value", !selected && "k-select__value--placeholder"), children: selected ? selected.label : placeholder ?? " " }), _jsx(Chevron, {})] }), _jsxs("ul", { id: listId, ref: listRef, role: "listbox", "aria-labelledby": selectId, className: cx("k-listbox", "k-select__list", up && "k-select__list--up"), hidden: !open, tabIndex: -1, ...{ popover: "manual" }, style: pos ? { position: "fixed", insetBlock: "auto", top: pos.top, bottom: pos.bottom, left: pos.left, width: pos.width, right: "auto" } : undefined, children: [loading && opts.length === 0 && [0, 1, 2].map((k) => _jsx("li", { className: "k-listbox__loading", role: "presentation" }, `l${k}`)), !loading && opts.length === 0 && _jsx("li", { className: "k-listbox__empty", role: "presentation", children: emptyMessage ?? M.common.noOptions }), items.map((it, i) => {
|
|
209
|
+
if (it.kind === "group")
|
|
210
|
+
return _jsx("li", { role: "presentation", className: "k-listbox__group", children: it.label }, `g${i}`);
|
|
211
|
+
index += 1;
|
|
212
|
+
const n = index;
|
|
213
|
+
const isSel = it.value === current;
|
|
214
|
+
return (_jsxs("li", { id: `${listId}-${n}`, "data-index": n, role: "option", className: "k-option", "aria-selected": isSel, "aria-disabled": it.disabled || undefined, "data-active": n === active || undefined, onPointerMove: () => !it.disabled && setActive(n), onMouseDown: (e) => e.preventDefault(), onClick: () => { if (it.disabled)
|
|
215
|
+
return; choose(it.value); close(); }, children: [_jsx("span", { className: "k-option__label", children: it.label }), isSel && _jsx(Check, {})] }, it.value));
|
|
216
|
+
})] }), _jsxs("select", { ref: nativeRef, className: "k-select__native", tabIndex: -1, "aria-hidden": "true", name: name, form: form, autoComplete: autoComplete, required: required, disabled: disabled, value: current, onChange: (e) => { if (!controlled)
|
|
215
217
|
setInner(e.target.value); onChange?.(e); }, onFocus: (e) => { triggerRef.current?.focus(); onFocus?.(e); }, onBlur: onBlur, onInvalid: () => triggerRef.current?.focus(), children: [_jsx("option", { value: "" }), opts.map((o) => _jsx("option", { value: o.value, disabled: o.disabled, children: o.text }, o.value))] })] }) }));
|
|
216
218
|
}
|
package/dist/Slider.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export interface SliderProps<V extends Val = Val> {
|
|
|
21
21
|
/** برچسبهای زیر نوار، مثل [0, 50, 100] */
|
|
22
22
|
marks?: number[];
|
|
23
23
|
disabled?: boolean;
|
|
24
|
+
/** فقطخواندنی: مقدار دیده و با فرم ارسال میشود ولی عوض نمیشود */
|
|
25
|
+
readOnly?: boolean;
|
|
24
26
|
name?: string;
|
|
25
27
|
className?: string;
|
|
26
28
|
labels?: {
|
|
@@ -30,5 +32,5 @@ export interface SliderProps<V extends Val = Val> {
|
|
|
30
32
|
};
|
|
31
33
|
}
|
|
32
34
|
/** اسلایدر روی <input type="range"> بومی؛ با آرایهٔ دوتایی، بازه با دو دستگیره */
|
|
33
|
-
export declare function Slider<V extends Val>({ label, value, defaultValue, onChange, min, max, step, showValue, format, marks, disabled, name, className, labels, }: SliderProps<V>): import("react").JSX.Element;
|
|
35
|
+
export declare function Slider<V extends Val>({ label, value, defaultValue, onChange, min, max, step, showValue, format, marks, disabled, readOnly, name, className, labels, }: SliderProps<V>): import("react").JSX.Element;
|
|
34
36
|
export {};
|
package/dist/Slider.js
CHANGED
|
@@ -5,7 +5,7 @@ import { formatNumber } from "@kashi-ui/persian";
|
|
|
5
5
|
import { cx } from "./cx.js";
|
|
6
6
|
import { useKashi } from "./KashiProvider.js";
|
|
7
7
|
/** اسلایدر روی <input type="range"> بومی؛ با آرایهٔ دوتایی، بازه با دو دستگیره */
|
|
8
|
-
export function Slider({ label, value, defaultValue, onChange, min = 0, max = 100, step = 1, showValue = true, format, marks, disabled, name, className, labels = {}, }) {
|
|
8
|
+
export function Slider({ label, value, defaultValue, onChange, min = 0, max = 100, step = 1, showValue = true, format, marks, disabled, readOnly, name, className, labels = {}, }) {
|
|
9
9
|
const id = useId();
|
|
10
10
|
const isRange = Array.isArray(value ?? defaultValue);
|
|
11
11
|
const [inner, setInner] = useState(defaultValue ?? (isRange ? [min, max] : min));
|
|
@@ -24,7 +24,9 @@ export function Slider({ label, value, defaultValue, onChange, min = 0, max = 10
|
|
|
24
24
|
const labelId = `${id}-label`;
|
|
25
25
|
const input = (which) => {
|
|
26
26
|
const v = which === "lo" ? lo : hi;
|
|
27
|
-
return (_jsx("input", { type: "range", className: "k-slider__input", min: min, max: max, step: step, value: v, disabled: disabled, name: name ? (isRange ? `${name}_${which === "lo" ? "min" : "max"}` : name) : undefined, "aria-labelledby": isRange ? undefined : label ? labelId : undefined, "aria-label": isRange ? `${which === "lo" ? from : to}${typeof label === "string" ? ` ${label}` : ""}` : undefined, "aria-valuetext": format(v), onChange: (e) => {
|
|
27
|
+
return (_jsx("input", { type: "range", className: "k-slider__input", min: min, max: max, step: step, value: v, disabled: disabled, "aria-readonly": readOnly || undefined, name: name ? (isRange ? `${name}_${which === "lo" ? "min" : "max"}` : name) : undefined, "aria-labelledby": isRange ? undefined : label ? labelId : undefined, "aria-label": isRange ? `${which === "lo" ? from : to}${typeof label === "string" ? ` ${label}` : ""}` : undefined, "aria-valuetext": format(v), onChange: (e) => {
|
|
28
|
+
if (readOnly)
|
|
29
|
+
return;
|
|
28
30
|
const n = Number(e.target.value);
|
|
29
31
|
// دستگیرهها از روی هم رد نمیشوند
|
|
30
32
|
if (!isRange)
|
|
@@ -33,5 +35,5 @@ export function Slider({ label, value, defaultValue, onChange, min = 0, max = 10
|
|
|
33
35
|
set(which === "lo" ? [Math.min(n, hi), hi] : [lo, Math.max(n, lo)]);
|
|
34
36
|
} }));
|
|
35
37
|
};
|
|
36
|
-
return (_jsxs("div", { className: cx("k-slider", className), "data-range": isRange ? "" : undefined, children: [(label || showValue) && (_jsxs("div", { className: "k-slider__head", children: [label && _jsx("span", { className: "k-label", id: labelId, children: label }), showValue && _jsx("span", { className: "k-slider__value", "aria-hidden": "true", children: isRange ? `${format(lo)}${separator}${format(hi)}` : format(hi) })] })), _jsxs("div", { className: "k-slider__track", style: fill, children: [_jsx("span", { className: "k-slider__fill", "aria-hidden": "true" }), isRange && input("lo"), input("hi")] }), marks && (_jsx("div", { className: "k-slider__marks", "aria-hidden": "true", children: marks.map((m) => _jsx("span", { children: format(m) }, m)) }))] }));
|
|
38
|
+
return (_jsxs("div", { className: cx("k-slider", className), "data-range": isRange ? "" : undefined, "data-readonly": readOnly || undefined, children: [(label || showValue) && (_jsxs("div", { className: "k-slider__head", children: [label && _jsx("span", { className: "k-label", id: labelId, children: label }), showValue && _jsx("span", { className: "k-slider__value", "aria-hidden": "true", children: isRange ? `${format(lo)}${separator}${format(hi)}` : format(hi) })] })), _jsxs("div", { className: "k-slider__track", style: fill, children: [_jsx("span", { className: "k-slider__fill", "aria-hidden": "true" }), isRange && input("lo"), input("hi")] }), marks && (_jsx("div", { className: "k-slider__marks", "aria-hidden": "true", children: marks.map((m) => _jsx("span", { children: format(m) }, m)) }))] }));
|
|
37
39
|
}
|
package/dist/Stat.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ export interface StatCardProps extends Omit<HTMLAttributes<HTMLDivElement>, "tit
|
|
|
18
18
|
down?: string;
|
|
19
19
|
flat?: string;
|
|
20
20
|
};
|
|
21
|
+
/** عدد در راه است؛ اسکلت جای محتوا */
|
|
22
|
+
loading?: boolean;
|
|
21
23
|
}
|
|
22
24
|
/** کارت شاخص کلیدی (KPI) با روند؛ صفحهخوان روند را به شکل «۱۲٪ افزایش» میخواند */
|
|
23
25
|
export declare const StatCard: import("react").ForwardRefExoticComponent<StatCardProps & import("react").RefAttributes<HTMLDivElement>>;
|
package/dist/Stat.js
CHANGED
|
@@ -5,14 +5,14 @@ import { cx } from "./cx.js";
|
|
|
5
5
|
import { useKashi } from "./KashiProvider.js";
|
|
6
6
|
const Arrow = ({ dir }) => (_jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: dir === "up" ? _jsx("path", { d: "M10 15V5m0 0-4 4m4-4 4 4" }) : _jsx("path", { d: "M10 5v10m0 0-4-4m4 4 4-4" }) }));
|
|
7
7
|
/** کارت شاخص کلیدی (KPI) با روند؛ صفحهخوان روند را به شکل «۱۲٪ افزایش» میخواند */
|
|
8
|
-
export const StatCard = forwardRef(function StatCard({ label, value, unit, icon, change, invertTrend, caption, children, labels = {}, className, ...rest }, ref) {
|
|
8
|
+
export const StatCard = forwardRef(function StatCard({ label, value, unit, icon, change, invertTrend, caption, children, labels = {}, loading, className, ...rest }, ref) {
|
|
9
9
|
const { messages: M, n } = useKashi();
|
|
10
10
|
const { up = M.stat.up, down = M.stat.down, flat = M.stat.flat } = labels;
|
|
11
11
|
const dir = change === undefined ? null : change > 0 ? "up" : change < 0 ? "down" : "flat";
|
|
12
12
|
// رنگ بر اساس خوب یا بد بودن، نه جهت
|
|
13
13
|
const good = dir === "flat" ? "flat" : (dir === "up") !== Boolean(invertTrend) ? "up" : "down";
|
|
14
14
|
const pct = change === undefined ? "" : M.common.percent(n(Math.abs(Math.round(change * 10) / 10)).replace(".", M.common.decimal));
|
|
15
|
-
return (_jsxs("div", { ref: ref, className: cx("k-stat", className), ...rest, children: [_jsxs("div", { className: "k-stat__head", children: [icon && _jsx("span", { className: "k-stat__icon", "aria-hidden": "true", children: icon }), _jsx("p", { className: "k-stat__label", children: label })] }), _jsxs("p", { className: "k-stat__value", children: [_jsx("span", { children: value }), unit && _jsx("span", { className: "k-stat__unit", children: unit })] }), (dir || caption) && (_jsxs("div", { className: "k-stat__foot", children: [dir && (_jsxs("span", { className: `k-trend k-trend--${good}`, children: [dir !== "flat" && _jsx(Arrow, { dir: dir }), _jsx("span", { "aria-hidden": "true", children: dir === "flat" ? flat : pct }), _jsx("span", { className: "k-sr-only", children: dir === "flat" ? flat : `${pct} ${dir === "up" ? up : down}` })] })), caption && _jsx("span", { children: caption })] })), children && _jsx("div", { className: "k-stat__chart", children: children })] }));
|
|
15
|
+
return (_jsxs("div", { ref: ref, className: cx("k-stat", className), "aria-busy": loading || undefined, ...rest, children: [_jsxs("div", { className: "k-stat__head", children: [icon && _jsx("span", { className: "k-stat__icon", "aria-hidden": "true", children: icon }), _jsx("p", { className: "k-stat__label", children: label })] }), _jsxs("p", { className: "k-stat__value", children: [_jsx("span", { children: value }), unit && _jsx("span", { className: "k-stat__unit", children: unit })] }), (dir || caption) && (_jsxs("div", { className: "k-stat__foot", children: [dir && (_jsxs("span", { className: `k-trend k-trend--${good}`, children: [dir !== "flat" && _jsx(Arrow, { dir: dir }), _jsx("span", { "aria-hidden": "true", children: dir === "flat" ? flat : pct }), _jsx("span", { className: "k-sr-only", children: dir === "flat" ? flat : `${pct} ${dir === "up" ? up : down}` })] })), caption && _jsx("span", { children: caption })] })), children && _jsx("div", { className: "k-stat__chart", children: children })] }));
|
|
16
16
|
});
|
|
17
17
|
export function StatGrid({ className, ...rest }) {
|
|
18
18
|
return _jsx("div", { className: cx("k-stat-grid", className), ...rest });
|
package/dist/SwatchGroup.d.ts
CHANGED
|
@@ -20,7 +20,9 @@ export interface SwatchGroupProps {
|
|
|
20
20
|
size?: "sm" | "md" | "lg";
|
|
21
21
|
/** با name، مقدارهای انتخابشده در فرم ارسال میشوند */
|
|
22
22
|
name?: string;
|
|
23
|
+
/** فقطخواندنی: انتخابها دیده میشوند ولی عوض نمیشوند */
|
|
24
|
+
readOnly?: boolean;
|
|
23
25
|
className?: string;
|
|
24
26
|
}
|
|
25
27
|
/** انتخاب رنگ از میان نمونهها (فیلتر رنگ کالا)؛ روی چکباکس یا رادیوی بومی، پس صفحهکلید و فرم خودکار کار میکنند */
|
|
26
|
-
export declare function SwatchGroup({ options, value, defaultValue, onChange, single, label, size, name, className }: SwatchGroupProps): import("react").JSX.Element;
|
|
28
|
+
export declare function SwatchGroup({ options, value, defaultValue, onChange, single, label, size, name, readOnly, className }: SwatchGroupProps): import("react").JSX.Element;
|
package/dist/SwatchGroup.js
CHANGED
|
@@ -4,20 +4,25 @@ import { useId, useState } from "react";
|
|
|
4
4
|
import { cx } from "./cx.js";
|
|
5
5
|
import { useKashi } from "./KashiProvider.js";
|
|
6
6
|
/** انتخاب رنگ از میان نمونهها (فیلتر رنگ کالا)؛ روی چکباکس یا رادیوی بومی، پس صفحهکلید و فرم خودکار کار میکنند */
|
|
7
|
-
export function SwatchGroup({ options, value, defaultValue, onChange, single = false, label, size = "md", name, className }) {
|
|
7
|
+
export function SwatchGroup({ options, value, defaultValue, onChange, single = false, label, size = "md", name, readOnly, className }) {
|
|
8
8
|
const { messages: M } = useKashi();
|
|
9
9
|
const id = useId();
|
|
10
10
|
const [inner, setInner] = useState(defaultValue ?? []);
|
|
11
11
|
const selected = value ?? inner;
|
|
12
12
|
const toggle = (v) => {
|
|
13
|
+
if (readOnly)
|
|
14
|
+
return;
|
|
13
15
|
const next = single ? (selected[0] === v ? [] : [v]) : selected.includes(v) ? selected.filter((x) => x !== v) : [...selected, v];
|
|
14
16
|
if (value === undefined)
|
|
15
17
|
setInner(next);
|
|
16
18
|
onChange?.(next);
|
|
17
19
|
};
|
|
18
|
-
return (_jsxs("fieldset", { className: cx("k-swatches", size !== "md" && `k-swatches--${size}`, className), children: [label && _jsx("legend", { className: "k-label k-swatches__legend", children: label }), _jsx("div", { className: "k-swatches__grid", role: single ? "radiogroup" : undefined, children: options.map((o) => {
|
|
20
|
+
return (_jsxs("fieldset", { className: cx("k-swatches", size !== "md" && `k-swatches--${size}`, className), "aria-readonly": readOnly || undefined, "data-readonly": readOnly || undefined, children: [label && _jsx("legend", { className: "k-label k-swatches__legend", children: label }), _jsx("div", { className: "k-swatches__grid", role: single ? "radiogroup" : undefined, children: options.map((o) => {
|
|
19
21
|
const on = selected.includes(o.value);
|
|
20
|
-
return (_jsxs("label", { className: "k-swatch", "data-disabled": o.disabled || undefined, children: [_jsx("input", { type: single ? "radio" : "checkbox", className: "k-sr-only", name: name ?? (single ? id : undefined), value: o.value, checked: on, disabled: o.disabled, onChange: () => toggle(o.value), onClick: (e) => { if (
|
|
22
|
+
return (_jsxs("label", { className: "k-swatch", "data-disabled": o.disabled || undefined, children: [_jsx("input", { type: single ? "radio" : "checkbox", className: "k-sr-only", name: name ?? (single ? id : undefined), value: o.value, checked: on, disabled: o.disabled, onChange: () => toggle(o.value), onClick: (e) => { if (readOnly) {
|
|
23
|
+
e.preventDefault();
|
|
24
|
+
return;
|
|
25
|
+
} if (single && on) {
|
|
21
26
|
e.preventDefault();
|
|
22
27
|
toggle(o.value);
|
|
23
28
|
} } }), _jsx("span", { className: "k-swatch__color", style: { "--_c": o.color }, "aria-hidden": "true", children: _jsx("svg", { className: "k-swatch__check", viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", children: _jsx("path", { d: "m5 10.5 3.2 3L15 7" }) }) }), _jsxs("span", { className: "k-swatch__label", children: [o.label, on && _jsxs("span", { className: "k-sr-only", children: ["\u060C ", M.swatch.selected] })] })] }, o.value));
|
package/dist/TagInput.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ export interface TagInputProps {
|
|
|
18
18
|
allowDuplicates?: boolean;
|
|
19
19
|
tone?: BadgeTone;
|
|
20
20
|
disabled?: boolean;
|
|
21
|
+
/** فقطخواندنی: برچسبها دیده و ارسال میشوند ولی اضافه یا حذف نمیشوند */
|
|
22
|
+
readOnly?: boolean;
|
|
21
23
|
name?: string;
|
|
22
24
|
id?: string;
|
|
23
25
|
className?: string;
|
package/dist/TagInput.js
CHANGED
|
@@ -7,7 +7,7 @@ import { Field, describedBy } from "./Field.js";
|
|
|
7
7
|
import { mergeRefs } from "./utils.js";
|
|
8
8
|
import { useKashi } from "./KashiProvider.js";
|
|
9
9
|
/** ورود چند مقدار، مثل مهارتها یا ایمیلها؛ Enter یا ویرگول (, یا ،) ثبت میکند و Backspace آخری را حذف میکند */
|
|
10
|
-
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) {
|
|
10
|
+
export const TagInput = forwardRef(function TagInput({ label, hint, error, value, defaultValue = [], onChange, placeholder, separators = ["Enter", ",", "،"], validate, max, allowDuplicates = false, tone = "brand", disabled, readOnly, name, id, className, labels = {}, }, ref) {
|
|
11
11
|
const autoId = useId();
|
|
12
12
|
const inputId = id ?? autoId;
|
|
13
13
|
const [inner, setInner] = useState(defaultValue);
|
|
@@ -74,7 +74,7 @@ export const TagInput = forwardRef(function TagInput({ label, hint, error, value
|
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
76
|
const shownError = error ?? localError;
|
|
77
|
-
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) => {
|
|
77
|
+
return (_jsxs(Field, { id: inputId, label: label, hint: hint, error: shownError, className: className, children: [_jsxs("div", { className: "k-tag-input", "data-invalid": shownError ? "" : undefined, "data-readonly": readOnly || undefined, onClick: () => inputRef.current?.focus(), children: [tags.map((t, i) => (_jsx(Badge, { tone: tone, onRemove: disabled || readOnly ? 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 || readOnly ? undefined : placeholder, disabled: disabled, readOnly: readOnly, "aria-invalid": shownError ? true : undefined, "aria-describedby": describedBy(inputId, hint, shownError), onChange: (e) => {
|
|
78
78
|
const v = e.target.value;
|
|
79
79
|
setLocalError(undefined);
|
|
80
80
|
// صفحهکلید موبایل و IME رویداد کلید نمیفرستند؛ جداکننده را در متن هم پیدا کن
|
|
@@ -87,5 +87,5 @@ export const TagInput = forwardRef(function TagInput({ label, hint, error, value
|
|
|
87
87
|
}
|
|
88
88
|
else
|
|
89
89
|
setText(v);
|
|
90
|
-
}, 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))] }));
|
|
90
|
+
}, onKeyDown: readOnly ? undefined : onKeyDown, onPaste: readOnly ? undefined : onPaste, onBlur: () => !readOnly && 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))] }));
|
|
91
91
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kashi-ui/react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.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.4.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.4.0",
|
|
63
|
+
"@kashi-ui/persian": "^2.4.0"
|
|
64
64
|
}
|
|
65
65
|
}
|