@kashi-ui/react 0.26.0 → 1.0.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/ActivityHeatmap.js +12 -8
- package/dist/AddressForm.js +8 -4
- package/dist/Alert.js +4 -1
- package/dist/AppointmentPicker.js +16 -11
- package/dist/Avatar.js +8 -11
- package/dist/Badge.js +3 -1
- package/dist/BankBadge.js +4 -1
- package/dist/BankCard.js +7 -4
- package/dist/Banner.js +5 -1
- package/dist/Breadcrumb.js +5 -1
- package/dist/Button.js +4 -1
- package/dist/Calendar.js +10 -6
- package/dist/CardNumberInput.js +5 -1
- package/dist/Carousel.js +5 -4
- package/dist/Chart.js +57 -30
- package/dist/CitySelect.js +7 -4
- package/dist/ColorPicker.d.ts +1 -1
- package/dist/ColorPicker.js +22 -17
- package/dist/Combobox.js +8 -4
- package/dist/CommandPalette.js +6 -3
- package/dist/ContextMenu.js +5 -2
- package/dist/CopyButton.js +3 -1
- package/dist/Countdown.js +6 -3
- package/dist/DataTable.js +4 -2
- package/dist/DatePicker.js +8 -2
- package/dist/DateRangePicker.d.ts +1 -1
- package/dist/DateRangePicker.js +16 -10
- package/dist/DateTile.js +7 -4
- package/dist/Dialog.js +4 -1
- package/dist/Field.js +3 -1
- package/dist/FileUpload.d.ts +3 -2
- package/dist/FileUpload.js +15 -11
- package/dist/IbanInput.js +4 -1
- package/dist/InlineEdit.js +5 -3
- package/dist/Input.js +3 -1
- package/dist/IranMap.js +5 -3
- package/dist/KashiProvider.d.ts +28 -0
- package/dist/KashiProvider.js +27 -0
- package/dist/KeyboardFixInput.js +3 -1
- package/dist/LandlineInput.js +5 -1
- package/dist/LegalIdInput.js +5 -1
- package/dist/Meter.js +7 -4
- package/dist/MobileInput.js +7 -3
- package/dist/Money.js +10 -6
- package/dist/MonthPicker.js +8 -4
- package/dist/MultiSelect.js +7 -5
- package/dist/NationalIdInput.js +5 -1
- package/dist/NumberInput.js +5 -2
- package/dist/OtpInput.js +4 -1
- package/dist/Pagination.js +6 -3
- package/dist/PasswordStrength.d.ts +1 -0
- package/dist/PasswordStrength.js +15 -9
- package/dist/PaymentReceipt.js +10 -8
- package/dist/PersianInput.js +3 -1
- package/dist/PersianTextarea.js +9 -7
- package/dist/PlateInput.js +6 -3
- package/dist/PostalCodeInput.js +5 -1
- package/dist/PriceInput.js +9 -3
- package/dist/Progress.js +6 -3
- package/dist/ProvinceSelect.js +5 -3
- package/dist/Rating.js +6 -3
- package/dist/RelativeTime.js +5 -2
- package/dist/SideNav.js +4 -1
- package/dist/Slider.js +5 -2
- package/dist/Splitter.js +5 -3
- package/dist/Stat.js +4 -3
- package/dist/Stepper.js +6 -4
- package/dist/TagInput.js +4 -2
- package/dist/TimeInput.js +6 -1
- package/dist/Timeline.js +1 -1
- package/dist/Toast.js +5 -1
- package/dist/Tour.js +3 -2
- package/dist/index.d.ts +4 -0
- package/dist/index.js +2 -0
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +11 -0
- package/package.json +4 -4
package/dist/ActivityHeatmap.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { formatJalali, formatNumber, jalaliMonthLength, toGregorian, toISODate, toJalali } from "@kashi-ui/persian";
|
|
4
4
|
import { useRef, useState } from "react";
|
|
5
5
|
import { cx } from "./cx.js";
|
|
6
6
|
import { ChartTip } from "./Chart.js";
|
|
7
|
-
|
|
7
|
+
import { useKashi } from "./KashiProvider.js";
|
|
8
8
|
/** نقشهٔ فعالیت سالانه با ماههای شمسی؛ هفته از شنبه شروع میشود */
|
|
9
|
-
export function ActivityHeatmap({ data, year = toJalali(new Date()).jy, label, unit
|
|
9
|
+
export function ActivityHeatmap({ data, year = toJalali(new Date()).jy, label, unit, className }) {
|
|
10
|
+
const { messages: M, digits: D, locale, n, months: MONTHS } = useKashi();
|
|
11
|
+
const H = M.heatmap;
|
|
12
|
+
const num = (v) => formatNumber(v, { digits: D });
|
|
13
|
+
unit ?? (unit = H.unit);
|
|
10
14
|
const days = [];
|
|
11
15
|
for (let m = 1; m <= 12; m++)
|
|
12
16
|
for (let d = 1; d <= jalaliMonthLength(year, m); d++) {
|
|
@@ -19,17 +23,17 @@ export function ActivityHeatmap({ data, year = toJalali(new Date()).jy, label, u
|
|
|
19
23
|
const row = (d) => (d.getDay() + 1) % 7;
|
|
20
24
|
const offset = row(days[0].date);
|
|
21
25
|
const col = (i) => Math.floor((i + offset) / 7);
|
|
22
|
-
const monthStarts =
|
|
26
|
+
const monthStarts = MONTHS.map((name, m) => ({ name, col: col(days.findIndex((d) => toJalali(d.date).jm === m + 1)) }));
|
|
23
27
|
const total = days.reduce((s, d) => s + d.value, 0);
|
|
24
|
-
const monthly =
|
|
28
|
+
const monthly = MONTHS.map((name, m) => ({ name, sum: days.filter((d) => toJalali(d.date).jm === m + 1).reduce((s, d) => s + d.value, 0) }));
|
|
25
29
|
const box = useRef(null);
|
|
26
30
|
const [tip, setTip] = useState(null);
|
|
27
|
-
const name = label ??
|
|
28
|
-
return (_jsxs("figure", { ref: box, className: cx("k-heatmap", className), style: { margin: 0 }, onPointerLeave: () => setTip(null), children: [_jsx("div", { className: "k-heatmap__scroll", children: _jsxs("div", { role: "img", "aria-label": `${name}: ${
|
|
31
|
+
const name = label ?? H.inYear(unit, n(year));
|
|
32
|
+
return (_jsxs("figure", { ref: box, className: cx("k-heatmap", className), style: { margin: 0 }, onPointerLeave: () => setTip(null), children: [_jsx("div", { className: "k-heatmap__scroll", children: _jsxs("div", { role: "img", "aria-label": `${name}: ${num(total)} ${unit}`, children: [_jsx("div", { className: "k-heatmap__months", "aria-hidden": "true", children: monthStarts.map((m) => _jsx("span", { style: { gridColumn: m.col + 1 }, children: m.name }, m.name)) }), _jsxs("div", { className: "k-heatmap__body", "aria-hidden": "true", children: [_jsx("div", { className: "k-heatmap__days", children: H.weekdays.map((w, i) => _jsx("span", { children: w }, i)) }), _jsxs("div", { className: "k-heatmap__grid", onPointerOver: (e) => {
|
|
29
33
|
const cell = e.target.closest("[data-i]");
|
|
30
34
|
if (!cell || !box.current)
|
|
31
35
|
return setTip(null);
|
|
32
36
|
const b = box.current.getBoundingClientRect(), r = cell.getBoundingClientRect();
|
|
33
37
|
setTip({ x: r.left + r.width / 2 - b.left, y: r.top - b.top - 2, i: Number(cell.dataset.i) });
|
|
34
|
-
}, children: [Array.from({ length: offset }, (_, i) => _jsx("span", { className: "k-heatmap__cell", "data-empty": "" }, `e${i}`)), days.map((d, i) => (_jsx("span", { className: "k-heatmap__cell", "data-l": level(d.value), "data-i": i, "data-active": tip?.i === i ? "" : undefined }, d.date.getTime())))] })] })] }) }), tip && _jsx(ChartTip, { x: tip.x, y: tip.y, width: box.current?.clientWidth, title: formatJalali(days[tip.i].date, { style: "full" }), rows: [{ value: `${
|
|
38
|
+
}, children: [Array.from({ length: offset }, (_, i) => _jsx("span", { className: "k-heatmap__cell", "data-empty": "" }, `e${i}`)), days.map((d, i) => (_jsx("span", { className: "k-heatmap__cell", "data-l": level(d.value), "data-i": i, "data-active": tip?.i === i ? "" : undefined }, d.date.getTime())))] })] })] }) }), tip && _jsx(ChartTip, { x: tip.x, y: tip.y, width: box.current?.clientWidth, title: formatJalali(days[tip.i].date, { style: "full", digits: D, locale }), rows: [{ value: `${num(days[tip.i].value)} ${unit}` }] }), _jsxs("figcaption", { className: "k-heatmap__foot", children: [_jsx("span", { children: H.total(num(total), unit, n(year)) }), _jsxs("span", { className: "k-heatmap__scale", "aria-hidden": "true", children: [H.less, " ", [0, 1, 2, 3, 4].map((l) => _jsx("span", { className: "k-heatmap__cell", "data-l": l }, l)), " ", H.more] })] }), _jsxs("table", { className: "k-sr-only", children: [_jsx("caption", { children: H.byMonth(name) }), _jsx("tbody", { children: monthly.map((m) => _jsxs("tr", { children: [_jsx("th", { scope: "row", children: m.name }), _jsx("td", { children: num(m.sum) })] }, m.name)) })] })] }));
|
|
35
39
|
}
|
package/dist/AddressForm.js
CHANGED
|
@@ -8,15 +8,19 @@ import { Input, Textarea } from "./Input.js";
|
|
|
8
8
|
import { IranMap } from "./IranMap.js";
|
|
9
9
|
import { PostalCodeInput } from "./PostalCodeInput.js";
|
|
10
10
|
import { ProvinceSelect } from "./ProvinceSelect.js";
|
|
11
|
-
|
|
11
|
+
import { useKashi } from "./KashiProvider.js";
|
|
12
12
|
/**
|
|
13
13
|
* فرم نشانی ایرانی: استان، شهرِ همان استان، نشانی، پلاک، واحد و کد پستی دهرقمی.
|
|
14
14
|
* با انتخاب شهر بدون استان، استان خودکار پر میشود؛ با عوض شدن استان، شهرِ نامربوط پاک میشود.
|
|
15
15
|
*/
|
|
16
|
-
export function AddressForm({ value, defaultValue, onChange, errors = {}, name, legend
|
|
16
|
+
export function AddressForm({ value, defaultValue, onChange, errors = {}, name, legend, labels: labelsProp, map = false, required = true, disabled, className, }) {
|
|
17
17
|
const [inner, setInner] = useState({ ...EMPTY_ADDRESS, ...defaultValue });
|
|
18
18
|
const address = value ?? inner;
|
|
19
|
-
const
|
|
19
|
+
const { messages: M } = useKashi();
|
|
20
|
+
const A = M.address;
|
|
21
|
+
if (legend === undefined)
|
|
22
|
+
legend = A.legend;
|
|
23
|
+
const labels = { province: A.province, city: A.city, street: A.street, plaque: A.plaque, unit: A.unit, postalCode: A.postalCode, ...labelsProp };
|
|
20
24
|
const field = (key) => (name ? `${name}[${key}]` : undefined);
|
|
21
25
|
const update = (patch) => {
|
|
22
26
|
const next = { ...address, ...patch };
|
|
@@ -29,5 +33,5 @@ export function AddressForm({ value, defaultValue, onChange, errors = {}, name,
|
|
|
29
33
|
const keep = province && address.city && getCities(province).includes(address.city);
|
|
30
34
|
update({ province, city: keep ? address.city : null });
|
|
31
35
|
};
|
|
32
|
-
return (_jsxs("fieldset", { className: cx("k-address", map && "k-address--map", className), disabled: disabled, children: [legend && _jsx("legend", { className: "k-address__legend", children: legend }), _jsxs("div", { className: "k-address__fields", children: [_jsx(ProvinceSelect, { className: "k-address__province", label: labels.province, value: address.province, onChange: setProvince, error: errors.province, required: required, showCapital: false, placeholder:
|
|
36
|
+
return (_jsxs("fieldset", { className: cx("k-address", map && "k-address--map", className), disabled: disabled, children: [legend && _jsx("legend", { className: "k-address__legend", children: legend }), _jsxs("div", { className: "k-address__fields", children: [_jsx(ProvinceSelect, { className: "k-address__province", label: labels.province, value: address.province, onChange: setProvince, error: errors.province, required: required, showCapital: false, placeholder: A.provinceSearch }), _jsx(CitySelect, { className: "k-address__city", label: labels.city, province: address.province, value: address.city, onChange: (city, province) => update({ city, ...(province && !address.province ? { province } : {}) }), error: errors.city, required: required }), _jsx(Textarea, { fieldClassName: "k-address__street", label: labels.street, value: address.street, onChange: (e) => update({ street: e.target.value }), error: errors.street, required: required, name: field("street"), autoComplete: "street-address", placeholder: A.streetHint, rows: 2, autoResize: true }), _jsx(Input, { fieldClassName: "k-address__plaque", label: labels.plaque, value: address.plaque, onChange: (e) => update({ plaque: e.target.value }), error: errors.plaque, required: required, name: field("plaque"), inputMode: "numeric", autoComplete: "address-line2" }), _jsx(Input, { fieldClassName: "k-address__unit", label: labels.unit, value: address.unit, onChange: (e) => update({ unit: e.target.value }), error: errors.unit, optional: required, name: field("unit"), inputMode: "numeric", autoComplete: "address-line3" }), _jsx(PostalCodeInput, { fieldClassName: "k-address__postal", label: labels.postalCode, value: address.postalCode, onValueChange: (postalCode) => update({ postalCode }), error: errors.postalCode, required: required, name: field("postalCode") })] }), map && (_jsx(IranMap, { className: "k-address__map", label: M.iranMap.onMap(labels.province), value: address.province, onChange: setProvince })), name && (_jsxs(_Fragment, { children: [_jsx("input", { type: "hidden", name: field("province"), value: address.province ?? "" }), _jsx("input", { type: "hidden", name: field("city"), value: address.city ?? "" })] }))] }));
|
|
33
37
|
}
|
package/dist/Alert.js
CHANGED
|
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
4
|
import { cx } from "./cx.js";
|
|
5
5
|
import { CloseIcon, ErrorIcon, InfoIcon, SuccessIcon, WarningIcon } from "./icons.js";
|
|
6
|
+
import { useKashi } from "./KashiProvider.js";
|
|
6
7
|
const ICONS = {
|
|
7
8
|
neutral: InfoIcon,
|
|
8
9
|
brand: InfoIcon,
|
|
@@ -11,7 +12,9 @@ const ICONS = {
|
|
|
11
12
|
warning: WarningIcon,
|
|
12
13
|
error: ErrorIcon,
|
|
13
14
|
};
|
|
14
|
-
export const Alert = forwardRef(function Alert({ tone = "neutral", title, icon, actions, onClose, closeLabel
|
|
15
|
+
export const Alert = forwardRef(function Alert({ tone = "neutral", title, icon, actions, onClose, closeLabel, tinted = false, layout = "card", size = "md", classNames = {}, role, className, children, ...rest }, ref) {
|
|
16
|
+
const { messages: M } = useKashi();
|
|
17
|
+
closeLabel ?? (closeLabel = M.alert.close);
|
|
15
18
|
const Icon = ICONS[tone];
|
|
16
19
|
return (_jsxs("div", { ref: ref,
|
|
17
20
|
// خطا و هشدار فوراً خوانده میشوند؛ بقیه مؤدبانه
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useId, useMemo, useRef, useState } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { formatJalali, formatTime, getIranHoliday, parseTime, toFaDigits, toISODate, toJalali } from "@kashi-ui/persian";
|
|
5
5
|
import { cx } from "./cx.js";
|
|
6
|
-
|
|
6
|
+
import { useKashi } from "./KashiProvider.js";
|
|
7
|
+
const PERIODS = [["morning", 12], ["afternoon", 17], ["evening", 24]];
|
|
7
8
|
const day = (d, add = 0) => new Date(d.getFullYear(), d.getMonth(), d.getDate() + add);
|
|
8
9
|
const same = (a, b) => a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
9
10
|
const minutes = (t) => {
|
|
@@ -34,7 +35,7 @@ export function appointmentSlots(date, { from = "09:00", to = "17:00", step = 30
|
|
|
34
35
|
* انتخاب نوبت: روزهای شمسی در یک ردیف (با تعداد نوبت خالی) و ساعتهای همان روز در گروههای صبح، بعدازظهر و عصر.
|
|
35
36
|
* جمعهها و تعطیلات رسمی بستهاند، نوبتهای پر و ساعتهای گذشته غیرفعالاند و کلیدهای جهت بین روزها و ساعتها حرکت میکنند.
|
|
36
37
|
*/
|
|
37
|
-
export function AppointmentPicker({ value, defaultValue = null, onChange, start, days = 7, from, to, step, booked, getSlots, closed = true, label
|
|
38
|
+
export function AppointmentPicker({ value, defaultValue = null, onChange, start, days = 7, from, to, step, booked, getSlots, closed = true, label, name, digits, className, }) {
|
|
38
39
|
const id = useId();
|
|
39
40
|
const [inner, setInner] = useState(defaultValue);
|
|
40
41
|
const selected = value !== undefined ? value : inner;
|
|
@@ -44,11 +45,15 @@ export function AppointmentPicker({ value, defaultValue = null, onChange, start,
|
|
|
44
45
|
const t = setInterval(() => setNow(new Date()), 60000);
|
|
45
46
|
return () => clearInterval(t);
|
|
46
47
|
}, []);
|
|
48
|
+
const { messages: M, digits: D, locale, weekdays: WD, months: MONTHS } = useKashi();
|
|
49
|
+
const A = M.appointment;
|
|
50
|
+
digits ?? (digits = D);
|
|
51
|
+
label ?? (label = A.label);
|
|
47
52
|
const n = (v) => (digits === "fa" ? toFaDigits(String(v)) : String(v));
|
|
48
53
|
const first = day(start ?? now);
|
|
49
54
|
const list = useMemo(() => Array.from({ length: days }, (_, i) => {
|
|
50
55
|
const d = day(first, i);
|
|
51
|
-
const isClosed = typeof closed === "function" ? closed(d) : closed ? !!getIranHoliday(d) : false;
|
|
56
|
+
const isClosed = typeof closed === "function" ? closed(d) : closed ? !!getIranHoliday(d, { locale }) : false;
|
|
52
57
|
const slots = isClosed ? [] : appointmentSlots(d, { from, to, step, booked, getSlots, now });
|
|
53
58
|
return { date: d, closed: isClosed, slots, free: slots.filter((s) => s.available).length };
|
|
54
59
|
}), [first.getTime(), days, closed, from, to, step, booked, getSlots, now.getHours(), now.getMinutes()]);
|
|
@@ -59,7 +64,7 @@ export function AppointmentPicker({ value, defaultValue = null, onChange, start,
|
|
|
59
64
|
const current = list[active] ?? list[0];
|
|
60
65
|
const daysRef = useRef(null);
|
|
61
66
|
const timesRef = useRef(null);
|
|
62
|
-
const label2 = (d) => (same(d, now) ?
|
|
67
|
+
const label2 = (d) => (same(d, now) ? M.common.today : same(d, day(now, 1)) ? M.common.tomorrow : WD[(d.getDay() + 1) % 7]);
|
|
63
68
|
const pick = (time) => {
|
|
64
69
|
const v = { date: current.date, time };
|
|
65
70
|
if (value === undefined)
|
|
@@ -90,12 +95,12 @@ export function AppointmentPicker({ value, defaultValue = null, onChange, start,
|
|
|
90
95
|
})).filter((g) => g.slots.length);
|
|
91
96
|
const isSelectedDay = !!selected && same(selected.date, current.date);
|
|
92
97
|
const timeFocus = isSelectedDay ? selected.time : current.slots.find((s) => s.available)?.time;
|
|
93
|
-
return (_jsxs("div", { className: cx("k-appt", className), role: "group", "aria-labelledby": `${id}-label`, children: [_jsx("p", { className: "k-label", id: `${id}-label`, style: { margin: 0 }, children: label }), _jsx("div", { className: "k-appt__days", role: "radiogroup", "aria-label":
|
|
98
|
+
return (_jsxs("div", { className: cx("k-appt", className), role: "group", "aria-labelledby": `${id}-label`, children: [_jsx("p", { className: "k-label", id: `${id}-label`, style: { margin: 0 }, children: label }), _jsx("div", { className: "k-appt__days", role: "radiogroup", "aria-label": A.day, ref: daysRef, onKeyDown: (e) => roving(e, daysRef.current, setActive), children: list.map((x, i) => {
|
|
94
99
|
const { jm, jd } = toJalali(x.date);
|
|
95
|
-
const full = formatJalali(x.date, { style: "full", digits });
|
|
96
|
-
return (_jsxs("button", { type: "button", role: "radio", "data-i": i, className: "k-appt__day", "aria-checked": i === active, tabIndex: i === active ? 0 : -1, disabled: x.closed, "aria-label": `${full}
|
|
97
|
-
}) }), _jsx("div", { className: "k-appt__slots", ref: timesRef, onKeyDown: (e) => roving(e, timesRef.current), children: current.closed || !current.free ? (_jsx("p", { className: "k-appt__empty", children: current.closed ?
|
|
100
|
+
const full = formatJalali(x.date, { style: "full", digits, locale });
|
|
101
|
+
return (_jsxs("button", { type: "button", role: "radio", "data-i": i, className: "k-appt__day", "aria-checked": i === active, tabIndex: i === active ? 0 : -1, disabled: x.closed, "aria-label": `${full}${M.common.list}${x.closed ? A.closed : x.free ? A.freeLong(n(x.free)) : A.none}`, onClick: () => setActive(i), children: [_jsx("span", { className: "k-appt__weekday", "aria-hidden": "true", children: label2(x.date) }), _jsx("span", { className: "k-appt__date", "aria-hidden": "true", children: n(jd) }), _jsx("span", { className: "k-appt__month", "aria-hidden": "true", children: MONTHS[jm - 1] }), _jsx("span", { className: "k-appt__free", "aria-hidden": "true", children: x.closed ? A.closed : x.free ? A.free(n(x.free)) : A.full })] }, x.date.getTime()));
|
|
102
|
+
}) }), _jsx("div", { className: "k-appt__slots", ref: timesRef, onKeyDown: (e) => roving(e, timesRef.current), children: current.closed || !current.free ? (_jsx("p", { className: "k-appt__empty", children: current.closed ? A.closedDay : A.noSlots })) : groups.map((g) => (_jsxs("div", { className: "k-appt__group", children: [_jsx("p", { className: "k-appt__period", id: `${id}-${g.title}`, children: A[g.title] }), _jsx("div", { className: "k-appt__times", role: "radiogroup", "aria-labelledby": `${id}-${g.title}`, children: g.slots.map((s) => {
|
|
98
103
|
const on = isSelectedDay && selected.time === s.time;
|
|
99
|
-
return (_jsx("button", { type: "button", role: "radio", className: "k-appt__time", "aria-checked": on, tabIndex: s.time === timeFocus ? 0 : -1, disabled: !s.available, "aria-label":
|
|
100
|
-
}) })] }, g.title))) }), _jsx("p", { className: "k-appt__summary", "aria-live": "polite", children: selected && (_jsxs(_Fragment, { children: [_jsx(Clock, {}), _jsxs("span", { children: ["
|
|
104
|
+
return (_jsx("button", { type: "button", role: "radio", className: "k-appt__time", "aria-checked": on, tabIndex: s.time === timeFocus ? 0 : -1, disabled: !s.available, "aria-label": `${A.time(n(s.time))}${s.available ? "" : A.booked}`, onClick: () => pick(s.time), children: n(s.time) }, s.time));
|
|
105
|
+
}) })] }, g.title))) }), _jsx("p", { className: "k-appt__summary", "aria-live": "polite", children: selected && (_jsxs(_Fragment, { children: [_jsx(Clock, {}), _jsxs("span", { children: [A.yours, " ", _jsx("strong", { children: A.at(formatJalali(selected.date, { style: "full", digits, locale }), n(selected.time)) })] })] })) }), name && (_jsxs(_Fragment, { children: [_jsx("input", { type: "hidden", name: `${name}_date`, value: selected ? toISODate(selected.date) : "" }), _jsx("input", { type: "hidden", name: `${name}_time`, value: selected?.time ?? "" })] }))] }));
|
|
101
106
|
}
|
package/dist/Avatar.js
CHANGED
|
@@ -2,13 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { Children, forwardRef, useState } from "react";
|
|
4
4
|
import { cx } from "./cx.js";
|
|
5
|
-
import {
|
|
6
|
-
const STATUS_LABEL = {
|
|
7
|
-
online: "آنلاین",
|
|
8
|
-
offline: "آفلاین",
|
|
9
|
-
busy: "مشغول",
|
|
10
|
-
away: "غایب",
|
|
11
|
-
};
|
|
5
|
+
import { useKashi } from "./KashiProvider.js";
|
|
12
6
|
/** حروف اول دو کلمهٔ اول؛ با نیمفاصله تا حروف فارسی به هم نچسبند */
|
|
13
7
|
export function initials(name, max = 2) {
|
|
14
8
|
return name
|
|
@@ -31,12 +25,15 @@ export const Avatar = forwardRef(function Avatar({ name, src, size = "md", squar
|
|
|
31
25
|
const [failed, setFailed] = useState(false);
|
|
32
26
|
const showImage = src && !failed;
|
|
33
27
|
const tone = color === "auto" ? autoTone(name) : color ?? (brand ? "brand" : "neutral");
|
|
34
|
-
const
|
|
35
|
-
|
|
28
|
+
const { messages: M } = useKashi();
|
|
29
|
+
const statusText = status ? (statusLabels?.[status] ?? M.avatar[status]) : undefined;
|
|
30
|
+
return (_jsxs("span", { ref: ref, role: "img", "aria-label": statusText ? `${name}${M.common.list}${statusText}` : name, "data-tone": tone, className: cx("k-avatar", size !== "md" && `k-avatar--${size}`, square && "k-avatar--square", tone !== "neutral" && `k-avatar--${tone}`, className), ...rest, children: [showImage ? (_jsx("img", { className: "k-avatar__image", src: src, alt: "", onError: () => setFailed(true) })) : (_jsx("span", { "aria-hidden": "true", children: initials(name, size === "xs" || size === "sm" ? 1 : 2) })), status && _jsx("span", { className: `k-avatar__status k-avatar__status--${status}`, "aria-hidden": "true" })] }));
|
|
36
31
|
});
|
|
37
|
-
export function AvatarGroup({ max, size = "md", moreLabel
|
|
32
|
+
export function AvatarGroup({ max, size = "md", moreLabel, className, children, ...rest }) {
|
|
33
|
+
const { messages: M, n } = useKashi();
|
|
34
|
+
moreLabel ?? (moreLabel = (x) => M.avatar.more(n(x)));
|
|
38
35
|
const items = Children.toArray(children);
|
|
39
36
|
const visible = max ? items.slice(0, max) : items;
|
|
40
37
|
const extra = items.length - visible.length;
|
|
41
|
-
return (_jsxs("div", { role: "group", className: cx("k-avatar-group", className), ...rest, children: [visible, extra > 0 && (_jsx("span", { role: "img", "aria-label": moreLabel(extra), className: cx("k-avatar", size !== "md" && `k-avatar--${size}`), children: _jsxs("span", { "aria-hidden": "true", children: ["+",
|
|
38
|
+
return (_jsxs("div", { role: "group", className: cx("k-avatar-group", className), ...rest, children: [visible, extra > 0 && (_jsx("span", { role: "img", "aria-label": moreLabel(extra), className: cx("k-avatar", size !== "md" && `k-avatar--${size}`), children: _jsxs("span", { "aria-hidden": "true", children: ["+", n(extra)] }) }))] }));
|
|
42
39
|
}
|
package/dist/Badge.js
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
4
|
import { cx } from "./cx.js";
|
|
5
|
+
import { useKashi } from "./KashiProvider.js";
|
|
5
6
|
export const Badge = forwardRef(function Badge({ tone = "neutral", variant = "soft", size = "md", dot = false, icon, square = false, onRemove, removeLabel, className, children, ...rest }, ref) {
|
|
6
|
-
const
|
|
7
|
+
const { messages: M } = useKashi();
|
|
8
|
+
const label = removeLabel ?? (typeof children === "string" ? M.common.remove(children) : M.common.removeShort);
|
|
7
9
|
return (_jsxs("span", { ref: ref, "data-tone": tone, "data-variant": variant, className: cx("k-badge", tone !== "neutral" && `k-badge--${tone}`, variant !== "soft" && `k-badge--${variant}`, size !== "md" && `k-badge--${size}`, square && "k-badge--square", onRemove && "k-badge--removable", className), ...rest, children: [dot && _jsx("span", { className: "k-badge__dot", "aria-hidden": "true" }), icon && _jsx("span", { className: "k-badge__icon", "aria-hidden": "true", children: icon }), children, onRemove && (_jsx("button", { type: "button", className: "k-badge__remove", "aria-label": label, onClick: onRemove, children: _jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", "aria-hidden": "true", children: _jsx("path", { d: "m6 6 8 8M14 6l-8 8" }) }) }))] }));
|
|
8
10
|
});
|
package/dist/BankBadge.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useState } from "react";
|
|
4
|
+
import { bankName } from "@kashi-ui/persian";
|
|
5
|
+
import { useKashi } from "./KashiProvider.js";
|
|
4
6
|
/** لوگوی بانک را فقط هنگام نیاز بارگذاری میکند (code-split)، تا حجم اولیهٔ برنامه زیاد نشود */
|
|
5
7
|
export function useBankLogo(slug, enabled) {
|
|
6
8
|
const [uri, setUri] = useState(null);
|
|
@@ -21,8 +23,9 @@ export function useBankLogo(slug, enabled) {
|
|
|
21
23
|
}
|
|
22
24
|
/** نام و لوگوی بانک داخل فیلد؛ نام با id به فیلد متصل میشود و لوگو تزئینی است */
|
|
23
25
|
export function BankBadge({ bank, id, showLogo }) {
|
|
26
|
+
const { locale } = useKashi();
|
|
24
27
|
const logo = useBankLogo(bank?.slug, showLogo);
|
|
25
28
|
if (!bank)
|
|
26
29
|
return null;
|
|
27
|
-
return (_jsxs("span", { className: "k-bank", id: id, children: [logo && _jsx("img", { className: "k-bank__logo", src: logo, alt: "", width: 24, height: 24 }), bank
|
|
30
|
+
return (_jsxs("span", { className: "k-bank", id: id, children: [logo && _jsx("img", { className: "k-bank__logo", src: logo, alt: "", width: 24, height: 24 }), bankName(bank, locale)] }));
|
|
28
31
|
}
|
package/dist/BankCard.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
|
-
import { formatCardNumber, getBankByCard, onlyDigits, toFaDigits } from "@kashi-ui/persian";
|
|
4
|
+
import { formatCardNumber, getBankByCard, onlyDigits, toFaDigits, bankName } from "@kashi-ui/persian";
|
|
5
5
|
import { useBankLogo } from "./BankBadge.js";
|
|
6
6
|
import { cx } from "./cx.js";
|
|
7
|
+
import { useKashi } from "./KashiProvider.js";
|
|
7
8
|
// رنگ تقریبی هویت بصری بانکها؛ برای بقیه رنگ برند کاشی
|
|
8
9
|
const COLORS = {
|
|
9
10
|
mellat: "#b5172b", melli: "#0b3f7d", saderat: "#203b8c", tejarat: "#173c7a", sepah: "#0d56a0", pasargad: "#2a2418",
|
|
@@ -13,7 +14,9 @@ const COLORS = {
|
|
|
13
14
|
};
|
|
14
15
|
const Chip = () => (_jsxs("svg", { className: "k-bankcard__chip", viewBox: "0 0 40 30", "aria-hidden": "true", children: [_jsx("rect", { x: "0.5", y: "0.5", width: "39", height: "29", rx: "5" }), _jsx("path", { d: "M14 1v28M26 1v28M1 10h13M26 10h13M1 20h13M26 20h13" })] }));
|
|
15
16
|
/** نمایش کارت بانکی با رنگ و لوگوی بانک، شمارهٔ چهاررقمی و تاریخ انقضا؛ برای کیف پول و انتخاب کارت ذخیرهشده */
|
|
16
|
-
export const BankCard = forwardRef(function BankCard({ number, holder, expiry, masked, bank, digits
|
|
17
|
+
export const BankCard = forwardRef(function BankCard({ number, holder, expiry, masked, bank, digits, showLogo = true, className, style, ...rest }, ref) {
|
|
18
|
+
const { messages: M, digits: D, locale } = useKashi();
|
|
19
|
+
digits ?? (digits = D);
|
|
17
20
|
const raw = onlyDigits(number).slice(0, 16);
|
|
18
21
|
const detected = bank === undefined ? getBankByCard(raw) : bank;
|
|
19
22
|
const logo = useBankLogo(detected?.slug, showLogo);
|
|
@@ -22,7 +25,7 @@ export const BankCard = forwardRef(function BankCard({ number, holder, expiry, m
|
|
|
22
25
|
const pad = (n) => String(n).padStart(2, "0");
|
|
23
26
|
const exp = typeof expiry === "object" ? `${pad(expiry.year % 100)}/${pad(expiry.month)}` : expiry;
|
|
24
27
|
const d = (s) => (digits === "fa" ? toFaDigits(s) : s);
|
|
25
|
-
const spokenNumber = masked ?
|
|
28
|
+
const spokenNumber = masked ? M.bankCard.endingIn(d(raw.slice(-4))) : d(formatCardNumber(raw));
|
|
26
29
|
const color = detected ? COLORS[detected.slug] : undefined;
|
|
27
|
-
return (_jsxs("figure", { ref: ref, className: cx("k-bankcard", className), style: color ? { ...style, ["--k-bankcard-color"]: color } : style, "aria-label":
|
|
30
|
+
return (_jsxs("figure", { ref: ref, className: cx("k-bankcard", className), style: color ? { ...style, ["--k-bankcard-color"]: color } : style, "aria-label": `${detected ? M.bankCard.cardOf(bankName(detected, locale)) : M.bankCard.card}${M.common.list}${spokenNumber}`, ...rest, children: [_jsxs("div", { className: "k-bankcard__top", children: [_jsxs("span", { className: "k-bankcard__bank", children: [logo && _jsx("img", { className: "k-bankcard__logo", src: logo, alt: "", width: 28, height: 28 }), detected ? bankName(detected, locale) : M.bankCard.card] }), _jsx(Chip, {})] }), _jsx("div", { className: "k-bankcard__number", dir: "ltr", "aria-hidden": "true", children: d(grouped) }), _jsxs("div", { className: "k-bankcard__bottom", "aria-hidden": holder || exp ? undefined : true, children: [holder && _jsx("span", { className: "k-bankcard__holder", children: holder }), exp && _jsxs("span", { className: "k-bankcard__exp", children: [_jsx("small", { children: M.bankCard.expiry }), _jsx("span", { dir: "ltr", children: d(exp) })] })] })] }));
|
|
28
31
|
});
|
package/dist/Banner.js
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { cx } from "./cx.js";
|
|
4
4
|
import { CloseIcon } from "./icons.js";
|
|
5
|
+
import { useKashi } from "./KashiProvider.js";
|
|
5
6
|
/** نوار اطلاعرسانی سطح صفحه، مثل نسخهٔ جدید، پایان اشتراک یا اختلال سرویس */
|
|
6
|
-
export function Banner({ tone = "neutral", icon, actions, onClose, flush, label
|
|
7
|
+
export function Banner({ tone = "neutral", icon, actions, onClose, flush, label, closeLabel, className, children, ...rest }) {
|
|
8
|
+
const { messages: M } = useKashi();
|
|
9
|
+
label ?? (label = M.banner.label);
|
|
10
|
+
closeLabel ?? (closeLabel = M.banner.close);
|
|
7
11
|
return (_jsxs("div", { role: "region", "aria-label": label, className: cx("k-banner", tone !== "neutral" && `k-banner--${tone}`, flush && "k-banner--flush", className), ...rest, children: [icon && _jsx("span", { className: "k-banner__icon", "aria-hidden": "true", children: icon }), _jsx("p", { className: "k-banner__text", children: children }), actions && _jsx("div", { className: "k-banner__actions", children: actions }), onClose && (_jsx("button", { type: "button", className: "k-btn k-btn--tertiary k-btn--icon k-btn--sm k-banner__close", "aria-label": closeLabel, onClick: onClose, children: _jsx(CloseIcon, {}) }))] }));
|
|
8
12
|
}
|
package/dist/Breadcrumb.js
CHANGED
|
@@ -2,8 +2,12 @@
|
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useRef, useState } from "react";
|
|
4
4
|
import { cx } from "./cx.js";
|
|
5
|
+
import { useKashi } from "./KashiProvider.js";
|
|
5
6
|
/** مسیر صفحه؛ آخرین مورد با aria-current="page" مشخص میشود و مسیرهای بلند جمع میشوند */
|
|
6
|
-
export function Breadcrumb({ items, maxItems, separator = "chevron", label
|
|
7
|
+
export function Breadcrumb({ items, maxItems, separator = "chevron", label, expandLabel, className }) {
|
|
8
|
+
const { messages: M } = useKashi();
|
|
9
|
+
label ?? (label = M.breadcrumb.label);
|
|
10
|
+
expandLabel ?? (expandLabel = M.breadcrumb.expand);
|
|
7
11
|
const [expanded, setExpanded] = useState(false);
|
|
8
12
|
const listRef = useRef(null);
|
|
9
13
|
const justExpanded = useRef(false);
|
package/dist/Button.js
CHANGED
|
@@ -3,7 +3,10 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
4
|
import { cx } from "./cx.js";
|
|
5
5
|
import { isDev } from "./utils.js";
|
|
6
|
-
|
|
6
|
+
import { useKashi } from "./KashiProvider.js";
|
|
7
|
+
export const Button = forwardRef(function Button({ variant = "secondary", size = "md", shape = "default", loading = false, loadingLabel, block = false, iconOnly = false, iconStart, iconEnd, disabled, type = "button", href, as, className, children, onClick, ...rest }, ref) {
|
|
8
|
+
const { messages: M } = useKashi();
|
|
9
|
+
loadingLabel ?? (loadingLabel = M.common.loading);
|
|
7
10
|
if (isDev() && iconOnly && !rest["aria-label"] && !rest["aria-labelledby"]) {
|
|
8
11
|
console.warn("[kashi] <Button iconOnly> بدون aria-label برای صفحهخوانها بینام است.");
|
|
9
12
|
}
|
package/dist/Calendar.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useId, useRef, useState } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { formatJalali, getIranHoliday, jalaliMonthLength, jalaliWeekday, toFaDigits, toGregorian, toJalali, } from "@kashi-ui/persian";
|
|
5
5
|
import { cx } from "./cx.js";
|
|
6
|
+
import { useKashi } from "./KashiProvider.js";
|
|
6
7
|
export const sameDay = (a, b) => !!a && !!b && a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
7
8
|
const startOfDay = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
|
8
9
|
const addDays = (d, n) => new Date(d.getFullYear(), d.getMonth(), d.getDate() + n);
|
|
@@ -23,7 +24,10 @@ function clamp(d, min, max) {
|
|
|
23
24
|
return d;
|
|
24
25
|
}
|
|
25
26
|
/** تقویم شمسی با الگوی grid استاندارد WAI-ARIA و پیمایش کامل با کیبورد */
|
|
26
|
-
export function Calendar({ value, defaultValue = null, onChange, min, max, isDateDisabled, holidays, digits
|
|
27
|
+
export function Calendar({ value, defaultValue = null, onChange, min, max, isDateDisabled, holidays, digits, autoFocus = false, yearRange, labels = {}, footer, range, className, "aria-label": ariaLabel, }) {
|
|
28
|
+
const { messages: M, digits: D, locale, months: MONTHS, weekdays: WD, weekdaysShort: WDS, friday: FRI } = useKashi();
|
|
29
|
+
digits ?? (digits = D);
|
|
30
|
+
ariaLabel ?? (ariaLabel = M.calendar.label);
|
|
27
31
|
const id = useId();
|
|
28
32
|
const [inner, setInner] = useState(defaultValue);
|
|
29
33
|
const selected = value !== undefined ? value : inner;
|
|
@@ -93,10 +97,10 @@ export function Calendar({ value, defaultValue = null, onChange, min, max, isDat
|
|
|
93
97
|
e.preventDefault();
|
|
94
98
|
go(next[e.key]());
|
|
95
99
|
};
|
|
96
|
-
const { prevMonth =
|
|
100
|
+
const { prevMonth = M.calendar.prevMonth, nextMonth = M.calendar.nextMonth, month: monthLabel = M.calendar.month, year: yearLabel = M.calendar.year } = labels;
|
|
97
101
|
const prevDisabled = min !== undefined && toGregorian(jy, jm, 1) <= startOfDay(min);
|
|
98
102
|
const nextDisabled = max !== undefined && toGregorian(jy, jm, length) >= startOfDay(max);
|
|
99
|
-
return (_jsxs("div", { className: cx("k-calendar", className), role: "group", "aria-label": ariaLabel, children: [_jsxs("div", { className: "k-calendar__header", children: [_jsx("button", { type: "button", className: "k-btn k-btn--tertiary k-btn--icon k-btn--sm", "aria-label": prevMonth, disabled: prevDisabled, onClick: () => go(addJalaliMonths(focused, -1), false), children: _jsx("svg", { "data-k-mirror": "", viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.7, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "m12 5-5 5 5 5" }) }) }), _jsxs("div", { className: "k-calendar__selects", children: [_jsx("select", { className: "k-calendar__select", "aria-label": monthLabel, value: jm, onChange: (e) => go(toGregorian(jy, Number(e.target.value), Math.min(toJalali(focused).jd, jalaliMonthLength(jy, Number(e.target.value)))), false), children:
|
|
103
|
+
return (_jsxs("div", { className: cx("k-calendar", className), role: "group", "aria-label": ariaLabel, children: [_jsxs("div", { className: "k-calendar__header", children: [_jsx("button", { type: "button", className: "k-btn k-btn--tertiary k-btn--icon k-btn--sm", "aria-label": prevMonth, disabled: prevDisabled, onClick: () => go(addJalaliMonths(focused, -1), false), children: _jsx("svg", { "data-k-mirror": "", viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.7, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "m12 5-5 5 5 5" }) }) }), _jsxs("div", { className: "k-calendar__selects", children: [_jsx("select", { className: "k-calendar__select", "aria-label": monthLabel, value: jm, onChange: (e) => go(toGregorian(jy, Number(e.target.value), Math.min(toJalali(focused).jd, jalaliMonthLength(jy, Number(e.target.value)))), false), children: MONTHS.map((name, i) => _jsx("option", { value: i + 1, children: name }, name)) }), _jsx("select", { className: "k-calendar__select", "aria-label": yearLabel, value: jy, onChange: (e) => go(toGregorian(Number(e.target.value), jm, Math.min(toJalali(focused).jd, jalaliMonthLength(Number(e.target.value), jm))), false), children: years.sort((a, b) => a - b).map((y) => _jsx("option", { value: y, children: n(y) }, y)) })] }), _jsx("button", { type: "button", className: "k-btn k-btn--tertiary k-btn--icon k-btn--sm", "aria-label": nextMonth, disabled: nextDisabled, onClick: () => go(addJalaliMonths(focused, 1), false), children: _jsx("svg", { "data-k-mirror": "", viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.7, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "m8 5 5 5-5 5" }) }) })] }), _jsx("h2", { className: "k-sr-only", id: `${id}-title`, "aria-live": "polite", children: `${MONTHS[jm - 1]} ${n(jy)}` }), _jsxs("table", { className: "k-calendar__grid", role: "grid", "aria-labelledby": `${id}-title`, ref: grid, children: [_jsx("thead", { children: _jsx("tr", { children: WDS.map((s, i) => (_jsx("th", { scope: "col", abbr: WD[i], children: s }, s))) }) }), _jsx("tbody", { children: weeks.map((week, wi) => (_jsx("tr", { children: week.map((d, di) => {
|
|
100
104
|
if (!d)
|
|
101
105
|
return _jsx("td", { role: "gridcell" }, di);
|
|
102
106
|
const isDisabled = disabled(d);
|
|
@@ -107,8 +111,8 @@ export function Calendar({ value, defaultValue = null, onChange, min, max, isDat
|
|
|
107
111
|
const [lo, hi] = rs && (re || previewEnd) ? [rs, (re ?? previewEnd)].sort((a, b) => +a - +b) : [null, null];
|
|
108
112
|
const inRange = !!lo && !!hi && d >= lo && d <= hi;
|
|
109
113
|
const isSelected = range ? inRange || sameDay(d, rs) : sameDay(d, selected);
|
|
110
|
-
const holiday = holidays === true ? getIranHoliday(d) : holidays ? holidays(d) || null : null;
|
|
111
|
-
return (_jsx("td", { role: "gridcell", "aria-selected": isSelected, "data-in-range": range && inRange && re ? "" : undefined, "data-preview": range && inRange && !re ? "" : undefined, "data-range-start": range && (lo ? sameDay(d, lo) : sameDay(d, rs)) ? "" : undefined, "data-range-end": range && (hi ? sameDay(d, hi) : sameDay(d, rs)) ? "" : undefined, children: _jsx("button", { type: "button", className: "k-calendar__day", "data-day": dayKey(d), tabIndex: sameDay(d, focused) ? 0 : -1, "aria-label": formatJalali(d, { style: "full", digits }) + (holiday ?
|
|
114
|
+
const holiday = holidays === true ? getIranHoliday(d, { locale }) : holidays ? holidays(d) || null : null;
|
|
115
|
+
return (_jsx("td", { role: "gridcell", "aria-selected": isSelected, "data-in-range": range && inRange && re ? "" : undefined, "data-preview": range && inRange && !re ? "" : undefined, "data-range-start": range && (lo ? sameDay(d, lo) : sameDay(d, rs)) ? "" : undefined, "data-range-end": range && (hi ? sameDay(d, hi) : sameDay(d, rs)) ? "" : undefined, children: _jsx("button", { type: "button", className: "k-calendar__day", "data-day": dayKey(d), tabIndex: sameDay(d, focused) ? 0 : -1, "aria-label": formatJalali(d, { style: "full", digits, locale }) + (holiday ? `${M.common.list}${M.calendar.holiday}${holiday === FRI ? "" : `: ${holiday}`}` : ""), title: holiday && holiday !== FRI ? holiday : undefined, "data-holiday": holiday ? "" : undefined, "aria-current": sameDay(d, today) ? "date" : undefined, "aria-disabled": isDisabled || undefined, onClick: () => {
|
|
112
116
|
setFocused(d);
|
|
113
117
|
select(d);
|
|
114
118
|
}, onKeyDown: onKeyDown, onPointerEnter: range ? () => setHover(d) : undefined, onFocus: range ? () => setHover(d) : undefined, children: n(toJalali(d).jd) }) }, di));
|
package/dist/CardNumberInput.js
CHANGED
|
@@ -6,8 +6,12 @@ import { BankBadge } from "./BankBadge.js";
|
|
|
6
6
|
import { Input } from "./Input.js";
|
|
7
7
|
import { useDigitsInput } from "./useDigitsInput.js";
|
|
8
8
|
import { mergeRefs } from "./utils.js";
|
|
9
|
+
import { useKashi } from "./KashiProvider.js";
|
|
9
10
|
/** فیلد شماره کارت بانکی: گروهبندی چهارتایی، تشخیص بانک با لوگو و بررسی Luhn */
|
|
10
|
-
export const CardNumberInput = forwardRef(function CardNumberInput({ value, defaultValue, onValueChange, digits
|
|
11
|
+
export const CardNumberInput = forwardRef(function CardNumberInput({ value, defaultValue, onValueChange, digits, showBank = true, showBankLogo = true, invalidMessage, error, name, id, onBlur, placeholder, ...rest }, ref) {
|
|
12
|
+
const { messages: M, digits: D, locale } = useKashi();
|
|
13
|
+
digits ?? (digits = D);
|
|
14
|
+
invalidMessage ?? (invalidMessage = M.invalid.card);
|
|
11
15
|
const autoId = useId();
|
|
12
16
|
const inputId = id ?? autoId;
|
|
13
17
|
const [touched, setTouched] = useState(false);
|
package/dist/Carousel.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { Children, useEffect, useId, useRef, useState } from "react";
|
|
4
|
-
import { toFaDigits } from "@kashi-ui/persian";
|
|
5
4
|
import { cx } from "./cx.js";
|
|
5
|
+
import { useKashi } from "./KashiProvider.js";
|
|
6
6
|
const Arrow = ({ next }) => (_jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", "data-k-mirror": "", children: _jsx("path", { d: next ? "m8 5 5 5-5 5" : "m12 5-5 5 5 5" }) }));
|
|
7
7
|
/**
|
|
8
8
|
* اسلایدر روی scroll-snap بومی: با کشیدن، چرخ موس، دکمهها و کلیدهای جهت کار میکند.
|
|
@@ -10,7 +10,8 @@ const Arrow = ({ next }) => (_jsx("svg", { viewBox: "0 0 20 20", fill: "none", s
|
|
|
10
10
|
*/
|
|
11
11
|
export function Carousel({ children, label, perView = 1, dots = true, className, labels = {} }) {
|
|
12
12
|
const id = useId();
|
|
13
|
-
const {
|
|
13
|
+
const { messages: M, n: N } = useKashi();
|
|
14
|
+
const { prev = M.common.prev, next = M.common.next, slide = (a, t) => M.carousel.slideOf(N(a), N(t)) } = labels;
|
|
14
15
|
const slides = Children.toArray(children);
|
|
15
16
|
const track = useRef(null);
|
|
16
17
|
const [index, setIndex] = useState(0);
|
|
@@ -41,7 +42,7 @@ export function Carousel({ children, label, perView = 1, dots = true, className,
|
|
|
41
42
|
t.scrollTo({ left: offset });
|
|
42
43
|
setIndex(n);
|
|
43
44
|
};
|
|
44
|
-
return (_jsxs("section", { className: cx("k-carousel", className), "aria-roledescription":
|
|
45
|
+
return (_jsxs("section", { className: cx("k-carousel", className), "aria-roledescription": M.carousel.slider, "aria-label": label, style: { "--k-carousel-per-view": perView }, children: [_jsx("div", { ref: track, className: "k-carousel__track", tabIndex: 0, "aria-live": "polite", onKeyDown: (e) => {
|
|
45
46
|
const rtl = getComputedStyle(e.currentTarget).direction === "rtl";
|
|
46
47
|
const step = { ArrowLeft: rtl ? 1 : -1, ArrowRight: rtl ? -1 : 1 }[e.key];
|
|
47
48
|
if (step) {
|
|
@@ -52,5 +53,5 @@ export function Carousel({ children, label, perView = 1, dots = true, className,
|
|
|
52
53
|
go(0);
|
|
53
54
|
else if (e.key === "End")
|
|
54
55
|
go(pages - 1);
|
|
55
|
-
}, children: slides.map((s, i) => (_jsx("div", { className: "k-carousel__slide", role: "group", "aria-roledescription":
|
|
56
|
+
}, children: slides.map((s, i) => (_jsx("div", { className: "k-carousel__slide", role: "group", "aria-roledescription": M.carousel.slide, "aria-label": slide(i + 1, slides.length), id: `${id}-s${i}`, children: s }, i))) }), pages > 1 && (_jsxs("div", { className: "k-carousel__bar", children: [dots ? (_jsx("ul", { className: "k-carousel__dots", "aria-label": M.carousel.slides(label), children: Array.from({ length: pages }, (_, i) => (_jsx("li", { children: _jsx("button", { type: "button", className: "k-carousel__dot", "aria-label": slide(i + 1, pages), "aria-current": i === index, "aria-controls": `${id}-s${i}`, onClick: () => go(i) }) }, i))) })) : _jsx("span", {}), _jsxs("div", { className: "k-carousel__nav", children: [_jsx("button", { type: "button", className: "k-btn k-btn--secondary k-btn--icon k-btn--sm", "aria-label": prev, disabled: index === 0, onClick: () => go(index - 1), children: _jsx(Arrow, {}) }), _jsx("button", { type: "button", className: "k-btn k-btn--secondary k-btn--icon k-btn--sm", "aria-label": next, disabled: index >= pages - 1, onClick: () => go(index + 1), children: _jsx(Arrow, { next: true }) })] })] }))] }));
|
|
56
57
|
}
|