@kashi-ui/react 2.25.0 → 2.27.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 +4 -2
- package/dist/AddressForm.js +3 -2
- package/dist/Alert.js +3 -2
- package/dist/AppointmentPicker.js +4 -2
- package/dist/Avatar.js +5 -3
- package/dist/Badge.js +3 -2
- package/dist/BankBadge.js +2 -2
- package/dist/BankCard.js +4 -2
- package/dist/Banner.js +3 -2
- package/dist/BillInput.js +6 -3
- package/dist/BottomSheet.js +3 -2
- package/dist/Breadcrumb.js +3 -2
- package/dist/BusinessHours.js +6 -3
- package/dist/Button.js +3 -2
- package/dist/Calendar.js +4 -2
- package/dist/CardNumberInput.js +4 -2
- package/dist/Carousel.js +4 -2
- package/dist/Chart.js +6 -4
- package/dist/Chat.js +6 -4
- package/dist/ChatComposer.js +4 -2
- package/dist/CitySelect.js +3 -2
- package/dist/CodeBlock.js +4 -2
- package/dist/ColorPicker.js +6 -3
- package/dist/Combobox.js +4 -2
- package/dist/CommandPalette.js +4 -2
- package/dist/ContextMenu.js +3 -2
- package/dist/CopyButton.js +3 -2
- package/dist/Countdown.js +4 -2
- package/dist/DataTable.js +3 -2
- package/dist/DatePicker.js +4 -2
- package/dist/DateRangePicker.js +7 -5
- package/dist/DateTile.js +2 -2
- package/dist/Dialog.js +3 -2
- package/dist/Drawer.js +3 -2
- package/dist/EconomicCodeInput.js +4 -2
- package/dist/EmptyState.js +3 -2
- package/dist/Field.js +3 -2
- package/dist/FileUpload.d.ts +1 -1
- package/dist/FileUpload.js +9 -6
- package/dist/Gantt.js +4 -2
- package/dist/IbanInput.js +3 -2
- package/dist/ImageCropper.js +4 -2
- package/dist/InfiniteScroll.js +4 -2
- package/dist/InlineEdit.js +3 -2
- package/dist/Input.js +3 -2
- package/dist/Invoice.js +4 -2
- package/dist/IranMap.js +4 -2
- package/dist/Kanban.js +4 -2
- package/dist/KashiProvider.d.ts +731 -3
- package/dist/KashiProvider.js +19 -4
- package/dist/KeyboardFixInput.js +4 -2
- package/dist/LandlineInput.js +4 -2
- package/dist/LegalIdInput.js +4 -2
- package/dist/Lightbox.js +6 -3
- package/dist/Meter.js +4 -2
- package/dist/MobileInput.js +4 -2
- package/dist/Money.js +4 -2
- package/dist/MonthPicker.js +4 -2
- package/dist/MultiSelect.js +4 -2
- package/dist/NationalIdInput.js +4 -2
- package/dist/Navbar.js +3 -2
- package/dist/NotificationCenter.js +6 -3
- package/dist/NumberInput.js +4 -2
- package/dist/OtpInput.js +2 -2
- package/dist/Pagination.js +4 -2
- package/dist/PasswordStrength.js +5 -4
- package/dist/PaymentReceipt.js +4 -2
- package/dist/PersianInput.js +3 -2
- package/dist/PersianTextarea.js +4 -2
- package/dist/PlateInput.js +3 -2
- package/dist/PostalCodeInput.js +4 -2
- package/dist/PriceInput.js +4 -2
- package/dist/PriceRange.js +4 -2
- package/dist/Progress.js +5 -3
- package/dist/ProvinceSelect.js +3 -2
- package/dist/QRCode.js +3 -2
- package/dist/Rating.js +4 -2
- package/dist/RelativeTime.js +2 -2
- package/dist/RichTextEditor.js +4 -2
- package/dist/SayadInput.js +4 -2
- package/dist/Scheduler.js +4 -2
- package/dist/SearchSuggest.js +3 -2
- package/dist/Select.js +3 -2
- package/dist/SideNav.js +3 -2
- package/dist/SignaturePad.js +3 -2
- package/dist/Slider.js +4 -2
- package/dist/Sortable.js +4 -2
- package/dist/Splitter.js +4 -2
- package/dist/Stat.js +4 -2
- package/dist/Stepper.js +4 -2
- package/dist/StreamingText.js +3 -2
- package/dist/SwatchGroup.js +3 -2
- package/dist/TagInput.js +4 -2
- package/dist/TaxIdInput.js +3 -2
- package/dist/TimeClock.js +4 -2
- package/dist/TimeInput.js +4 -2
- package/dist/TimePicker.js +4 -2
- package/dist/Toast.js +3 -2
- package/dist/Tour.js +4 -2
- package/dist/VirtualList.js +4 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +4 -4
package/dist/ActivityHeatmap.js
CHANGED
|
@@ -4,10 +4,12 @@ import { formatJalali, formatNumber, jalaliMonthLength, toGregorian, toISODate,
|
|
|
4
4
|
import { useRef, useState } from "react";
|
|
5
5
|
import { cx } from "./cx.js";
|
|
6
6
|
import { ChartTip } from "./Chart.js";
|
|
7
|
-
import {
|
|
7
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
8
|
+
import { faHeatmap } from "@kashi-ui/persian";
|
|
8
9
|
/** نقشهٔ فعالیت سالانه با ماههای شمسی؛ هفته از شنبه شروع میشود */
|
|
9
10
|
export function ActivityHeatmap({ data, year = toJalali(new Date()).jy, label, unit, className }) {
|
|
10
|
-
const
|
|
11
|
+
const M = useMessages({ heatmap: faHeatmap });
|
|
12
|
+
const { digits: D, locale, n, months: MONTHS } = useKashiLocale();
|
|
11
13
|
const H = M.heatmap;
|
|
12
14
|
const num = (v) => formatNumber(v, { digits: D });
|
|
13
15
|
unit ?? (unit = H.unit);
|
package/dist/AddressForm.js
CHANGED
|
@@ -8,7 +8,8 @@ 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
|
-
import {
|
|
11
|
+
import { useMessages } from "./KashiProvider.js";
|
|
12
|
+
import { faAddress, faIranMap } from "@kashi-ui/persian";
|
|
12
13
|
/**
|
|
13
14
|
* فرم نشانی ایرانی: استان، شهرِ همان استان، نشانی، پلاک، واحد و کد پستی دهرقمی.
|
|
14
15
|
* با انتخاب شهر بدون استان، استان خودکار پر میشود؛ با عوض شدن استان، شهرِ نامربوط پاک میشود.
|
|
@@ -16,7 +17,7 @@ import { useKashi } from "./KashiProvider.js";
|
|
|
16
17
|
export function AddressForm({ value, defaultValue, onChange, errors = {}, name, legend, labels: labelsProp, map = false, required = true, disabled, className, }) {
|
|
17
18
|
const [inner, setInner] = useState({ ...EMPTY_ADDRESS, ...defaultValue });
|
|
18
19
|
const address = value ?? inner;
|
|
19
|
-
const {
|
|
20
|
+
const M = useMessages({ address: faAddress, iranMap: faIranMap });
|
|
20
21
|
const A = M.address;
|
|
21
22
|
if (legend === undefined)
|
|
22
23
|
legend = A.legend;
|
package/dist/Alert.js
CHANGED
|
@@ -3,7 +3,8 @@ 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 {
|
|
6
|
+
import { useMessages } from "./KashiProvider.js";
|
|
7
|
+
import { faAlert } from "@kashi-ui/persian";
|
|
7
8
|
const ICONS = {
|
|
8
9
|
neutral: InfoIcon,
|
|
9
10
|
brand: InfoIcon,
|
|
@@ -13,7 +14,7 @@ const ICONS = {
|
|
|
13
14
|
error: ErrorIcon,
|
|
14
15
|
};
|
|
15
16
|
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 {
|
|
17
|
+
const M = useMessages({ alert: faAlert });
|
|
17
18
|
closeLabel ?? (closeLabel = M.alert.close);
|
|
18
19
|
const Icon = ICONS[tone];
|
|
19
20
|
return (_jsxs("div", { ref: ref,
|
|
@@ -3,7 +3,8 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
3
3
|
import { useEffect, useId, useMemo, useRef, useState } from "react";
|
|
4
4
|
import { formatJalali, formatTime, getIranHoliday, parseTime, toFaDigits, toISODate, toJalali } from "@kashi-ui/persian";
|
|
5
5
|
import { cx } from "./cx.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
7
|
+
import { faAppointment, faCommon } from "@kashi-ui/persian";
|
|
7
8
|
const PERIODS = [["morning", 12], ["afternoon", 17], ["evening", 24]];
|
|
8
9
|
const day = (d, add = 0) => new Date(d.getFullYear(), d.getMonth(), d.getDate() + add);
|
|
9
10
|
const same = (a, b) => a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
@@ -45,7 +46,8 @@ export function AppointmentPicker({ value, defaultValue = null, onChange, start,
|
|
|
45
46
|
const t = setInterval(() => setNow(new Date()), 60000);
|
|
46
47
|
return () => clearInterval(t);
|
|
47
48
|
}, []);
|
|
48
|
-
const
|
|
49
|
+
const M = useMessages({ appointment: faAppointment, common: faCommon });
|
|
50
|
+
const { digits: D, locale, weekdays: WD, months: MONTHS } = useKashiLocale();
|
|
49
51
|
const A = M.appointment;
|
|
50
52
|
digits ?? (digits = D);
|
|
51
53
|
label ?? (label = A.label);
|
package/dist/Avatar.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
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 {
|
|
5
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
6
|
+
import { faAvatar, faCommon } from "@kashi-ui/persian";
|
|
6
7
|
/** حروف اول دو کلمهٔ اول؛ با نیمفاصله تا حروف فارسی به هم نچسبند */
|
|
7
8
|
export function initials(name, max = 2) {
|
|
8
9
|
return name
|
|
@@ -25,12 +26,13 @@ export const Avatar = forwardRef(function Avatar({ name, src, size = "md", squar
|
|
|
25
26
|
const [failed, setFailed] = useState(false);
|
|
26
27
|
const showImage = src && !failed;
|
|
27
28
|
const tone = color === "auto" ? autoTone(name) : color ?? (brand ? "brand" : "neutral");
|
|
28
|
-
const {
|
|
29
|
+
const M = useMessages({ avatar: faAvatar, common: faCommon });
|
|
29
30
|
const statusText = status ? (statusLabels?.[status] ?? M.avatar[status]) : undefined;
|
|
30
31
|
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" })] }));
|
|
31
32
|
});
|
|
32
33
|
export function AvatarGroup({ max, size = "md", moreLabel, className, children, ...rest }) {
|
|
33
|
-
const {
|
|
34
|
+
const M = useMessages({ avatar: faAvatar, common: faCommon });
|
|
35
|
+
const { n } = useKashiLocale();
|
|
34
36
|
moreLabel ?? (moreLabel = (x) => M.avatar.more(n(x)));
|
|
35
37
|
const items = Children.toArray(children);
|
|
36
38
|
const visible = max ? items.slice(0, max) : items;
|
package/dist/Badge.js
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
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 {
|
|
5
|
+
import { useMessages } from "./KashiProvider.js";
|
|
6
|
+
import { faCommon } from "@kashi-ui/persian";
|
|
6
7
|
export const Badge = forwardRef(function Badge({ tone = "neutral", variant = "soft", size = "md", dot = false, icon, square = false, onRemove, removeLabel, className, children, ...rest }, ref) {
|
|
7
|
-
const {
|
|
8
|
+
const M = useMessages({ common: faCommon });
|
|
8
9
|
const label = removeLabel ?? (typeof children === "string" ? M.common.remove(children) : M.common.removeShort);
|
|
9
10
|
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" }) }) }))] }));
|
|
10
11
|
});
|
package/dist/BankBadge.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useState } from "react";
|
|
4
4
|
import { bankName } from "@kashi-ui/persian";
|
|
5
|
-
import {
|
|
5
|
+
import { useKashiLocale } from "./KashiProvider.js";
|
|
6
6
|
/** لوگوی بانک را فقط هنگام نیاز بارگذاری میکند (code-split)، تا حجم اولیهٔ برنامه زیاد نشود */
|
|
7
7
|
export function useBankLogo(slug, enabled) {
|
|
8
8
|
const [uri, setUri] = useState(null);
|
|
@@ -23,7 +23,7 @@ export function useBankLogo(slug, enabled) {
|
|
|
23
23
|
}
|
|
24
24
|
/** نام و لوگوی بانک داخل فیلد؛ نام با id به فیلد متصل میشود و لوگو تزئینی است */
|
|
25
25
|
export function BankBadge({ bank, id, showLogo }) {
|
|
26
|
-
const { locale } =
|
|
26
|
+
const { locale } = useKashiLocale();
|
|
27
27
|
const logo = useBankLogo(bank?.slug, showLogo);
|
|
28
28
|
if (!bank)
|
|
29
29
|
return null;
|
package/dist/BankCard.js
CHANGED
|
@@ -4,7 +4,8 @@ import { forwardRef } from "react";
|
|
|
4
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 {
|
|
7
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
8
|
+
import { faBankCard, faCommon } from "@kashi-ui/persian";
|
|
8
9
|
// رنگ تقریبی هویت بصری بانکها؛ برای بقیه رنگ برند کاشی
|
|
9
10
|
const COLORS = {
|
|
10
11
|
mellat: "#b5172b", melli: "#0b3f7d", saderat: "#203b8c", tejarat: "#173c7a", sepah: "#0d56a0", pasargad: "#2a2418",
|
|
@@ -15,7 +16,8 @@ const COLORS = {
|
|
|
15
16
|
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" })] }));
|
|
16
17
|
/** نمایش کارت بانکی با رنگ و لوگوی بانک، شمارهٔ چهاررقمی و تاریخ انقضا؛ برای کیف پول و انتخاب کارت ذخیرهشده */
|
|
17
18
|
export const BankCard = forwardRef(function BankCard({ number, holder, expiry, masked, bank, digits, showLogo = true, className, style, ...rest }, ref) {
|
|
18
|
-
const {
|
|
19
|
+
const M = useMessages({ bankCard: faBankCard, common: faCommon });
|
|
20
|
+
const { digits: D, locale } = useKashiLocale();
|
|
19
21
|
digits ?? (digits = D);
|
|
20
22
|
const raw = onlyDigits(number).slice(0, 16);
|
|
21
23
|
const detected = bank === undefined ? getBankByCard(raw) : bank;
|
package/dist/Banner.js
CHANGED
|
@@ -2,10 +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 {
|
|
5
|
+
import { useMessages } from "./KashiProvider.js";
|
|
6
|
+
import { faBanner } from "@kashi-ui/persian";
|
|
6
7
|
/** نوار اطلاعرسانی سطح صفحه، مثل نسخهٔ جدید، پایان اشتراک یا اختلال سرویس */
|
|
7
8
|
export function Banner({ tone = "neutral", icon, actions, onClose, flush, label, closeLabel, className, children, ...rest }) {
|
|
8
|
-
const {
|
|
9
|
+
const M = useMessages({ banner: faBanner });
|
|
9
10
|
label ?? (label = M.banner.label);
|
|
10
11
|
closeLabel ?? (closeLabel = M.banner.close);
|
|
11
12
|
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, {}) }))] }));
|
package/dist/BillInput.js
CHANGED
|
@@ -5,13 +5,15 @@ import { billService, formatMoney, isValidBillId, parseBill } from "@kashi-ui/pe
|
|
|
5
5
|
import { Input } from "./Input.js";
|
|
6
6
|
import { useDigitsInput } from "./useDigitsInput.js";
|
|
7
7
|
import { mergeRefs } from "./utils.js";
|
|
8
|
-
import {
|
|
8
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
9
|
+
import { faBill, faInvalid } from "@kashi-ui/persian";
|
|
9
10
|
/**
|
|
10
11
|
* شناسهٔ قبض (۶ تا ۱۳ رقم): رقم کنترل استاندارد بانک مرکزی بررسی میشود و نوع قبض
|
|
11
12
|
* (آب، برق، گاز، تلفن، شهرداری، مالیات، جریمه) از رقم یکیماندهبهآخر کنار فیلد میآید.
|
|
12
13
|
*/
|
|
13
14
|
export const BillIdInput = forwardRef(function BillIdInput({ value, defaultValue, onValueChange, showService = true, digits, invalidMessage, error, name, onBlur, placeholder, ...rest }, ref) {
|
|
14
|
-
const {
|
|
15
|
+
const M = useMessages({ bill: faBill, invalid: faInvalid });
|
|
16
|
+
const { digits: D } = useKashiLocale();
|
|
15
17
|
digits ?? (digits = D);
|
|
16
18
|
invalidMessage ?? (invalidMessage = M.invalid.billId);
|
|
17
19
|
const { raw, shown, inputRef, handleChange } = useDigitsInput({ value, defaultValue, maxDigits: 13, format: (d) => d, digits });
|
|
@@ -33,7 +35,8 @@ export const BillIdInput = forwardRef(function BillIdInput({ value, defaultValue
|
|
|
33
35
|
* شناسهٔ پرداخت قبض: هر دو رقم کنترل بررسی میشوند (دومی همراه شناسهٔ قبض) و مبلغ قبض کنار فیلد میآید.
|
|
34
36
|
*/
|
|
35
37
|
export const PaymentIdInput = forwardRef(function PaymentIdInput({ billId, value, defaultValue, onValueChange, showAmount = true, unit = "toman", digits, invalidMessage, error, hint, name, onBlur, placeholder, ...rest }, ref) {
|
|
36
|
-
const {
|
|
38
|
+
const M = useMessages({ bill: faBill, invalid: faInvalid });
|
|
39
|
+
const { digits: D, locale } = useKashiLocale();
|
|
37
40
|
digits ?? (digits = D);
|
|
38
41
|
invalidMessage ?? (invalidMessage = M.invalid.paymentId);
|
|
39
42
|
const { raw, shown, inputRef, handleChange } = useDigitsInput({ value, defaultValue, maxDigits: 13, format: (d) => d, digits });
|
package/dist/BottomSheet.js
CHANGED
|
@@ -3,7 +3,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useEffect, useId, useRef, useState } from "react";
|
|
4
4
|
import { cx } from "./cx.js";
|
|
5
5
|
import { CloseIcon } from "./icons.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useMessages } from "./KashiProvider.js";
|
|
7
|
+
import { faCommon, faSheet } from "@kashi-ui/persian";
|
|
7
8
|
import { useModalDialog } from "./modal.js";
|
|
8
9
|
/** فاصلهای که بعد از آن، کشیدن به پایین برگه را میبندد (نسبت به ارتفاع برگه) */
|
|
9
10
|
const CLOSE_RATIO = 0.3;
|
|
@@ -15,7 +16,7 @@ const FLING = 0.6;
|
|
|
15
16
|
* دستگیره با کیبورد هم کار میکند: Enter ایست بعدی، جهتهای بالا و پایین تغییر ارتفاع.
|
|
16
17
|
*/
|
|
17
18
|
export function BottomSheet({ open, onOpenChange, title, description, hideTitle, snapPoints, defaultSnap = 0, snap, onSnapChange, footer, dismissible = true, showClose = false, closeLabel, className, children, }) {
|
|
18
|
-
const {
|
|
19
|
+
const M = useMessages({ common: faCommon, sheet: faSheet });
|
|
19
20
|
closeLabel ?? (closeLabel = M.common.close);
|
|
20
21
|
const ref = useRef(null);
|
|
21
22
|
const id = useId();
|
package/dist/Breadcrumb.js
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
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 {
|
|
5
|
+
import { useMessages } from "./KashiProvider.js";
|
|
6
|
+
import { faBreadcrumb } from "@kashi-ui/persian";
|
|
6
7
|
/** مسیر صفحه؛ آخرین مورد با aria-current="page" مشخص میشود و مسیرهای بلند جمع میشوند */
|
|
7
8
|
export function Breadcrumb({ items, maxItems, separator = "chevron", label, expandLabel, className }) {
|
|
8
|
-
const {
|
|
9
|
+
const M = useMessages({ breadcrumb: faBreadcrumb });
|
|
9
10
|
label ?? (label = M.breadcrumb.label);
|
|
10
11
|
expandLabel ?? (expandLabel = M.breadcrumb.expand);
|
|
11
12
|
const [expanded, setExpanded] = useState(false);
|
package/dist/BusinessHours.js
CHANGED
|
@@ -3,11 +3,13 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
3
3
|
import { useId, useState } from "react";
|
|
4
4
|
import { defaultWeekHours, invalidRanges, isOpenAt, summarizeHours } from "@kashi-ui/persian";
|
|
5
5
|
import { cx } from "./cx.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
7
|
+
import { faBusinessHours, faCommon } from "@kashi-ui/persian";
|
|
7
8
|
import { TimeInput } from "./TimeInput.js";
|
|
8
9
|
/** انتخاب روزهای هفتهٔ شمسی از شنبه تا جمعه؛ هر روز یک دکمهٔ روشن و خاموش */
|
|
9
10
|
export function WeekdayPicker({ value, defaultValue = [], onChange, format = "short", "aria-label": ariaLabel, disabled, className }) {
|
|
10
|
-
const {
|
|
11
|
+
const M = useMessages({ businessHours: faBusinessHours, common: faCommon });
|
|
12
|
+
const { weekdays, weekdaysShort } = useKashiLocale();
|
|
11
13
|
const [inner, setInner] = useState(defaultValue);
|
|
12
14
|
const days = value ?? inner;
|
|
13
15
|
const toggle = (d) => {
|
|
@@ -20,7 +22,8 @@ export function WeekdayPicker({ value, defaultValue = [], onChange, format = "sh
|
|
|
20
22
|
}
|
|
21
23
|
/** ساعت کاری هفتگی: هر روز باز یا تعطیل، با یک یا چند بازهٔ ساعت؛ برای فروشگاه، مطب و نوبتدهی */
|
|
22
24
|
export function BusinessHours({ value, defaultValue, onChange, label, step = 30, maxRanges = 3, summary = true, now, name, digits, disabled, className, }) {
|
|
23
|
-
const {
|
|
25
|
+
const M = useMessages({ businessHours: faBusinessHours, common: faCommon });
|
|
26
|
+
const { weekdays, locale, digits: D } = useKashiLocale();
|
|
24
27
|
digits ?? (digits = D);
|
|
25
28
|
const B = M.businessHours;
|
|
26
29
|
const [inner, setInner] = useState(() => defaultValue ?? defaultWeekHours());
|
package/dist/Button.js
CHANGED
|
@@ -3,9 +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
|
-
import {
|
|
6
|
+
import { useMessages } from "./KashiProvider.js";
|
|
7
|
+
import { faCommon } from "@kashi-ui/persian";
|
|
7
8
|
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 {
|
|
9
|
+
const M = useMessages({ common: faCommon });
|
|
9
10
|
loadingLabel ?? (loadingLabel = M.common.loading);
|
|
10
11
|
if (isDev() && iconOnly && !rest["aria-label"] && !rest["aria-labelledby"]) {
|
|
11
12
|
console.warn("[kashi] <Button iconOnly> بدون aria-label برای صفحهخوانها بینام است.");
|
package/dist/Calendar.js
CHANGED
|
@@ -3,7 +3,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useEffect, useId, useRef, useState } from "react";
|
|
4
4
|
import { formatJalali, getIranHoliday, jalaliMonthLength, jalaliWeekday, toFaDigits, toGregorian, toJalali, } from "@kashi-ui/persian";
|
|
5
5
|
import { cx } from "./cx.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
7
|
+
import { faCalendar, faCommon } from "@kashi-ui/persian";
|
|
7
8
|
export const sameDay = (a, b) => !!a && !!b && a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
8
9
|
const startOfDay = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
|
9
10
|
const addDays = (d, n) => new Date(d.getFullYear(), d.getMonth(), d.getDate() + n);
|
|
@@ -25,7 +26,8 @@ function clamp(d, min, max) {
|
|
|
25
26
|
}
|
|
26
27
|
/** تقویم شمسی با الگوی grid استاندارد WAI-ARIA و پیمایش کامل با کیبورد */
|
|
27
28
|
export function Calendar({ value, defaultValue = null, onChange, min, max, isDateDisabled, holidays, digits, autoFocus = false, yearRange, labels = {}, footer, range, className, "aria-label": ariaLabel, }) {
|
|
28
|
-
const
|
|
29
|
+
const M = useMessages({ calendar: faCalendar, common: faCommon });
|
|
30
|
+
const { digits: D, locale, months: MONTHS, weekdays: WD, weekdaysShort: WDS, friday: FRI } = useKashiLocale();
|
|
29
31
|
digits ?? (digits = D);
|
|
30
32
|
ariaLabel ?? (ariaLabel = M.calendar.label);
|
|
31
33
|
const id = useId();
|
package/dist/CardNumberInput.js
CHANGED
|
@@ -6,10 +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 {
|
|
9
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
10
|
+
import { faInvalid } from "@kashi-ui/persian";
|
|
10
11
|
/** فیلد شماره کارت بانکی: گروهبندی چهارتایی، تشخیص بانک با لوگو و بررسی Luhn */
|
|
11
12
|
export const CardNumberInput = forwardRef(function CardNumberInput({ value, defaultValue, onValueChange, digits, showBank = true, showBankLogo = true, invalidMessage, error, name, id, onBlur, placeholder, ...rest }, ref) {
|
|
12
|
-
const
|
|
13
|
+
const M = useMessages({ invalid: faInvalid });
|
|
14
|
+
const { digits: D, locale } = useKashiLocale();
|
|
13
15
|
digits ?? (digits = D);
|
|
14
16
|
invalidMessage ?? (invalidMessage = M.invalid.card);
|
|
15
17
|
const autoId = useId();
|
package/dist/Carousel.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { Children, useEffect, useId, useRef, useState } from "react";
|
|
4
4
|
import { cx } from "./cx.js";
|
|
5
|
-
import {
|
|
5
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
6
|
+
import { faCarousel, faCommon } from "@kashi-ui/persian";
|
|
6
7
|
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
8
|
const PlayIcon = ({ playing }) => (_jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: playing ? _jsx("path", { d: "M7.5 5v10M12.5 5v10" }) : _jsx("path", { d: "M7 4.8v10.4a.6.6 0 0 0 .9.5l8-5.2a.6.6 0 0 0 0-1L7.9 4.3a.6.6 0 0 0-.9.5Z" }) }));
|
|
8
9
|
const ExpandIcon = () => (_jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "M12 3.5h4.5V8M8 16.5H3.5V12M16.5 3.5 11.5 8.5M3.5 16.5l5-5" }) }));
|
|
@@ -43,7 +44,8 @@ function useSwipe(onStep) {
|
|
|
43
44
|
*/
|
|
44
45
|
export function Carousel({ children, label, perView: perViewProp = 1, dots = true, effect = "slide", autoplay, thumbnails, lightbox, onIndexChange, className, labels = {}, }) {
|
|
45
46
|
const id = useId();
|
|
46
|
-
const {
|
|
47
|
+
const M = useMessages({ carousel: faCarousel, common: faCommon });
|
|
48
|
+
const { n: N } = useKashiLocale();
|
|
47
49
|
const { prev = M.common.prev, next = M.common.next, slide = (a, t) => M.carousel.slideOf(N(a), N(t)), play = M.carousel.play, pause = M.carousel.pause, expand = M.carousel.expand, } = labels;
|
|
48
50
|
const fade = effect === "fade";
|
|
49
51
|
const perView = fade ? 1 : perViewProp;
|
package/dist/Chart.js
CHANGED
|
@@ -3,10 +3,12 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useId, useLayoutEffect, useRef, useState } from "react";
|
|
4
4
|
import { formatNumber } from "@kashi-ui/persian";
|
|
5
5
|
import { cx } from "./cx.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
7
|
+
import { faChart, faCommon } from "@kashi-ui/persian";
|
|
7
8
|
/** متنها و قالب عددهای نمودار به زبان و ارقام KashiProvider */
|
|
8
9
|
function useChartText() {
|
|
9
|
-
const {
|
|
10
|
+
const M = useMessages({ chart: faChart, common: faCommon });
|
|
11
|
+
const { digits } = useKashiLocale();
|
|
10
12
|
const num = (n) => formatNumber(n, { digits });
|
|
11
13
|
const dec = (x) => num(Math.round(x * 10) / 10).replace(".", M.common.decimal);
|
|
12
14
|
return {
|
|
@@ -53,12 +55,12 @@ const tipAt = (el, box, i, anchor) => {
|
|
|
53
55
|
};
|
|
54
56
|
/** جدول همارز برای صفحهخوان و چاپ */
|
|
55
57
|
function DataTable({ caption, labels, series, format }) {
|
|
56
|
-
const {
|
|
58
|
+
const M = useMessages({ chart: faChart, common: faCommon });
|
|
57
59
|
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)) })] }));
|
|
58
60
|
}
|
|
59
61
|
/** قاب نمودار در حالت بارگذاری یا بیداده: عنوان میماند، جای نمودار اسکلت یا پیام */
|
|
60
62
|
function ChartPlaceholder({ title, loading, emptyMessage, className }) {
|
|
61
|
-
const {
|
|
63
|
+
const M = useMessages({ chart: faChart, common: faCommon });
|
|
62
64
|
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
|
|
63
65
|
? _jsx("div", { className: "k-chart__skeleton", role: "status", children: _jsx("span", { className: "k-sr-only", children: M.common.loading }) })
|
|
64
66
|
: _jsx("div", { className: "k-chart__empty", role: "status", children: emptyMessage ?? M.common.noData })] }));
|
package/dist/Chat.js
CHANGED
|
@@ -3,7 +3,8 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
3
3
|
import { useEffect, useRef, useState } from "react";
|
|
4
4
|
import { formatRelative } from "@kashi-ui/persian";
|
|
5
5
|
import { cx } from "./cx.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
7
|
+
import { faChat } from "@kashi-ui/persian";
|
|
7
8
|
/* ---------- آیکونها ---------- */
|
|
8
9
|
const svg = (d, w = 1.7) => (_jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: w, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: d }));
|
|
9
10
|
const Tick = () => svg(_jsx("path", { d: "m4.5 10.5 3 3 6-7" }), 1.9);
|
|
@@ -21,7 +22,7 @@ const Arrow = () => svg(_jsx("path", { d: "M10 4v12m0 0-4.5-4.5M10 16l4.5-4.5" }
|
|
|
21
22
|
* (مگر کاربر بالا رفته باشد) و دکمهٔ «رفتن به آخرین پیام» نشان میدهد.
|
|
22
23
|
*/
|
|
23
24
|
export function ChatThread({ label, autoScroll = true, className, children, ...rest }) {
|
|
24
|
-
const {
|
|
25
|
+
const M = useMessages({ chat: faChat });
|
|
25
26
|
const ref = useRef(null);
|
|
26
27
|
const stick = useRef(true);
|
|
27
28
|
const [away, setAway] = useState(false);
|
|
@@ -60,7 +61,8 @@ export function ChatDivider({ children, className }) {
|
|
|
60
61
|
}
|
|
61
62
|
/** حباب پیام در گفتگو یا رابط هوش مصنوعی؛ جهت متن هر پیام خودکار است تا پیام انگلیسی هم درست چیده شود */
|
|
62
63
|
export function ChatMessage({ from = "assistant", name, avatar, time, status, edited, copyText, onRetry, onFeedback, feedback, actions, className, children, ...rest }) {
|
|
63
|
-
const {
|
|
64
|
+
const M = useMessages({ chat: faChat });
|
|
65
|
+
const { locale, digits } = useKashiLocale();
|
|
64
66
|
const C = M.chat;
|
|
65
67
|
const [copied, setCopied] = useState(false);
|
|
66
68
|
const timer = useRef(undefined);
|
|
@@ -85,7 +87,7 @@ export function ChatMessage({ from = "assistant", name, avatar, time, status, ed
|
|
|
85
87
|
}
|
|
86
88
|
/** نشانگر «در حال نوشتن…» با سه نقطهٔ موجی؛ صفحهخوان یک بار میخواندش */
|
|
87
89
|
export function TypingIndicator({ name, showLabel, className }) {
|
|
88
|
-
const {
|
|
90
|
+
const M = useMessages({ chat: faChat });
|
|
89
91
|
const text = name ? M.chat.typing(name) : M.chat.typingShort;
|
|
90
92
|
return (_jsxs("div", { className: cx("k-typing", className), role: "status", children: [_jsxs("span", { className: "k-typing__dots", "aria-hidden": "true", children: [_jsx("i", {}), _jsx("i", {}), _jsx("i", {})] }), showLabel ? _jsxs("span", { className: "k-typing__label", children: [text, "\u2026"] }) : _jsx("span", { className: "k-sr-only", children: text })] }));
|
|
91
93
|
}
|
package/dist/ChatComposer.js
CHANGED
|
@@ -3,7 +3,8 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
3
3
|
import { useEffect, useId, useRef, useState } from "react";
|
|
4
4
|
import { cx } from "./cx.js";
|
|
5
5
|
import { formatBytes } from "./FileUpload.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
7
|
+
import { faComposer } from "@kashi-ui/persian";
|
|
7
8
|
import { useIsomorphicLayoutEffect } from "./utils.js";
|
|
8
9
|
const svg = (d) => (_jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: d }));
|
|
9
10
|
const Clip = () => svg(_jsx("path", { d: "m15.5 9.5-5.6 5.6a3.5 3.5 0 0 1-5-5l6-6a2.3 2.3 0 0 1 3.3 3.3l-6 6a1.2 1.2 0 0 1-1.7-1.7l5.5-5.5" }));
|
|
@@ -16,7 +17,8 @@ const Doc = () => svg(_jsxs(_Fragment, { children: [_jsx("path", { d: "M11.5 3H6
|
|
|
16
17
|
* (هنگام تایپ با IME ارسال نمیکند)، پیوست با دکمه یا چسباندن تصویر، و دکمهٔ توقف هنگام پاسخ.
|
|
17
18
|
*/
|
|
18
19
|
export function ChatComposer({ onSend, streaming, onStop, value, onValueChange, attach, maxFiles = 5, maxSize, maxLength, maxRows = 8, placeholder, label, showHint, tools, disabled, autoFocus, className, }) {
|
|
19
|
-
const {
|
|
20
|
+
const M = useMessages({ composer: faComposer });
|
|
21
|
+
const { locale, n } = useKashiLocale();
|
|
20
22
|
const C = M.composer;
|
|
21
23
|
const [inner, setInner] = useState("");
|
|
22
24
|
const text = value ?? inner;
|
package/dist/CitySelect.js
CHANGED
|
@@ -3,14 +3,15 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { forwardRef, useMemo, useState } from "react";
|
|
4
4
|
import { CITIES, getCities } from "@kashi-ui/persian";
|
|
5
5
|
import { Combobox, searchText } from "./Combobox.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useMessages } from "./KashiProvider.js";
|
|
7
|
+
import { faCity } from "@kashi-ui/persian";
|
|
7
8
|
const SEP = "|";
|
|
8
9
|
// «علی آباد»، «علیآباد» و «علیآباد» یکیاند
|
|
9
10
|
const loose = (s) => searchText(s).replace(/[\s]/g, "");
|
|
10
11
|
const filter = (o, q) => o.value.startsWith(`custom${SEP}`) || [o.label, o.description ?? ""].some((t) => loose(t).includes(loose(q)));
|
|
11
12
|
/** انتخاب شهر با جستجو؛ با استان فقط شهرهای همان استان، بدون آن همهٔ ۱۲۰۰+ شهر ایران با نام استان */
|
|
12
13
|
export const CitySelect = forwardRef(function CitySelect({ province, value, defaultValue = null, onChange, allowCustom = true, label, placeholder, onInputChange, ...rest }, ref) {
|
|
13
|
-
const {
|
|
14
|
+
const M = useMessages({ city: faCity });
|
|
14
15
|
label ?? (label = M.city.label);
|
|
15
16
|
const [query, setQuery] = useState("");
|
|
16
17
|
const [inner, setInner] = useState(defaultValue);
|
package/dist/CodeBlock.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useRef, useState } from "react";
|
|
4
4
|
import { cx } from "./cx.js";
|
|
5
|
-
import {
|
|
5
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
6
|
+
import { faCodeBlock } from "@kashi-ui/persian";
|
|
6
7
|
const KEYWORDS = new Set(("import export from default const let var function return if else for while do switch case break continue new class extends " +
|
|
7
8
|
"async await try catch finally throw typeof instanceof in of interface type enum implements public private protected static readonly " +
|
|
8
9
|
"def lambda pass elif with as yield None True False self print fn pub use mod impl struct match mut package func go defer select " +
|
|
@@ -34,7 +35,8 @@ const Check = () => _jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "c
|
|
|
34
35
|
const Wrap = () => (_jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.7, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "M3 5h14M3 10h11a3 3 0 0 1 0 6h-3m0 0 2-2m-2 2 2 2M3 15h4" }) }));
|
|
35
36
|
/** نمایش کد در پاسخ دستیار یا مستندات: همیشه چپبهراست، با برچسب زبان، دکمهٔ کپی و شکستن خط */
|
|
36
37
|
export function CodeBlock({ code, language, filename, lineNumbers, highlightLines = [], wrap: wrapDefault = false, highlight = true, maxHeight, className }) {
|
|
37
|
-
const {
|
|
38
|
+
const M = useMessages({ codeBlock: faCodeBlock });
|
|
39
|
+
const { n } = useKashiLocale();
|
|
38
40
|
const B = M.codeBlock;
|
|
39
41
|
const [copied, setCopied] = useState(false);
|
|
40
42
|
const [wrap, setWrap] = useState(wrapDefault);
|
package/dist/ColorPicker.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useId, useRef, useState } from "react";
|
|
4
4
|
import { Field } from "./Field.js";
|
|
5
|
-
import {
|
|
5
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
6
|
+
import { faColorPicker, faCommon } from "@kashi-ui/persian";
|
|
6
7
|
// نام رنگها از فرهنگ متنها میآید تا با زبان KashiProvider عوض شود
|
|
7
8
|
const DEFAULT_SWATCHES = [
|
|
8
9
|
{ key: "firoozeh", value: "#0b8077" },
|
|
@@ -52,7 +53,8 @@ function hsvToHex({ h, s, v }) {
|
|
|
52
53
|
const Dropper = () => _jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.7, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "m11 5 4 4M13.5 2.5a2.1 2.1 0 0 1 3 3L15 7 13 5ZM12 6l-7.5 7.5L3 17l3.5-1.5L14 8" }) });
|
|
53
54
|
/** پنل انتخاب رنگ: سطح اشباع و روشنایی، نوار رنگمایه، قطرهچکان و کدها */
|
|
54
55
|
function ColorPanel({ hex, onChange, onClose }) {
|
|
55
|
-
const {
|
|
56
|
+
const M = useMessages({ colorPicker: faColorPicker, common: faCommon });
|
|
57
|
+
const { n: N } = useKashiLocale();
|
|
56
58
|
const C = M.colorPicker;
|
|
57
59
|
const [hsv, setHsv] = useState(() => hexToHsv(hex));
|
|
58
60
|
const area = useRef(null);
|
|
@@ -118,7 +120,8 @@ function ColorPanel({ hex, onChange, onClose }) {
|
|
|
118
120
|
const Check = () => _jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 2.2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "m5 10.5 3.2 3L15 7" }) });
|
|
119
121
|
/** انتخاب رنگ برند یا برچسب: نمونهرنگها، پنل انتخاب دلخواه و کد hex، با کنتراست متن روی آن */
|
|
120
122
|
export function ColorPicker({ label, hint, value, defaultValue = "#0b8077", onChange, swatches: swatchesProp, showContrast = true, name, id, className }) {
|
|
121
|
-
const {
|
|
123
|
+
const M = useMessages({ colorPicker: faColorPicker, common: faCommon });
|
|
124
|
+
const { n: N } = useKashiLocale();
|
|
122
125
|
const swatches = swatchesProp ?? DEFAULT_SWATCHES.map((s) => ({ name: M.colorPicker.names[s.key], value: s.value }));
|
|
123
126
|
const autoId = useId();
|
|
124
127
|
const fieldId = id ?? autoId;
|
package/dist/Combobox.js
CHANGED
|
@@ -5,7 +5,8 @@ import { normalizePersian, persianMatch } from "@kashi-ui/persian";
|
|
|
5
5
|
import { cx } from "./cx.js";
|
|
6
6
|
import { Field, describedBy } from "./Field.js";
|
|
7
7
|
import { mergeRefs } from "./utils.js";
|
|
8
|
-
import {
|
|
8
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
9
|
+
import { faCombobox, faCommon } from "@kashi-ui/persian";
|
|
9
10
|
/** متن یکدست برای جستجو: ي/ی، ك/ک، ارقام، حروف کوچک */
|
|
10
11
|
export const searchText = (s) => normalizePersian(s, { digits: "latin" }).toLowerCase();
|
|
11
12
|
/**
|
|
@@ -34,7 +35,8 @@ const Check = () => (_jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "
|
|
|
34
35
|
* جستجو «علي» و «علی» را یکی میداند.
|
|
35
36
|
*/
|
|
36
37
|
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) {
|
|
37
|
-
const {
|
|
38
|
+
const M = useMessages({ combobox: faCombobox, common: faCommon });
|
|
39
|
+
const { n: N } = useKashiLocale();
|
|
38
40
|
emptyMessage ?? (emptyMessage = M.common.noResults);
|
|
39
41
|
resultsLabel ?? (resultsLabel = (x) => M.common.results(N(x)));
|
|
40
42
|
const autoId = useId();
|
package/dist/CommandPalette.js
CHANGED
|
@@ -3,13 +3,15 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useEffect, useId, useMemo, useRef, useState } from "react";
|
|
4
4
|
import { defaultFilter, highlight } from "./Combobox.js";
|
|
5
5
|
import { cx } from "./cx.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
7
|
+
import { faCommand, faCommon } from "@kashi-ui/persian";
|
|
7
8
|
/**
|
|
8
9
|
* پالت فرمان: جستجوی سریع در عملها و صفحهها با Ctrl+K.
|
|
9
10
|
* پنجره روی <dialog> بومی است (تلهٔ فوکوس و Esc) و فهرست با الگوی combobox/listbox پیمایش میشود.
|
|
10
11
|
*/
|
|
11
12
|
export function CommandPalette({ open, onOpenChange, items, shortcut = true, placeholder, emptyMessage, labels = {}, className, }) {
|
|
12
|
-
const {
|
|
13
|
+
const M = useMessages({ command: faCommand, common: faCommon });
|
|
14
|
+
const { n: N } = useKashiLocale();
|
|
13
15
|
placeholder ?? (placeholder = M.command.placeholder);
|
|
14
16
|
emptyMessage ?? (emptyMessage = M.command.empty);
|
|
15
17
|
const id = useId();
|
package/dist/ContextMenu.js
CHANGED
|
@@ -3,13 +3,14 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useEffect, useId, useRef, useState } from "react";
|
|
4
4
|
import { MenuCtx, items, menuKeyDown } from "./DropdownMenu.js";
|
|
5
5
|
import { cx } from "./cx.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useMessages } from "./KashiProvider.js";
|
|
7
|
+
import { faContextMenu } from "@kashi-ui/persian";
|
|
7
8
|
/**
|
|
8
9
|
* منوی راستکلیک؛ با کیبورد هم: کلید ContextMenu یا Shift+F10 روی ناحیهٔ فوکوسشده.
|
|
9
10
|
* همان گزینهها و پیمایش منوی کشویی را دارد.
|
|
10
11
|
*/
|
|
11
12
|
export function ContextMenu({ children, menu, label, className }) {
|
|
12
|
-
const {
|
|
13
|
+
const M = useMessages({ contextMenu: faContextMenu });
|
|
13
14
|
label ?? (label = M.contextMenu.label);
|
|
14
15
|
const id = useId();
|
|
15
16
|
const [pos, setPos] = useState(null);
|
package/dist/CopyButton.js
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useRef, useState } from "react";
|
|
4
4
|
import { Button } from "./Button.js";
|
|
5
|
-
import {
|
|
5
|
+
import { useMessages } from "./KashiProvider.js";
|
|
6
|
+
import { faCopy } from "@kashi-ui/persian";
|
|
6
7
|
const CopyIcon = () => (_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: "7", y: "7", width: "10", height: "10", rx: "2" }), _jsx("path", { d: "M13 7V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2" })] }));
|
|
7
8
|
const CheckIcon = () => (_jsx("svg", { 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" }) }));
|
|
8
9
|
/** دکمهٔ کپی در کلیپبورد با بازخورد «کپی شد» برای چشم و صفحهخوان */
|
|
9
10
|
export function CopyButton({ value, onCopy, iconOnly, timeout = 2000, labels = {}, variant = "secondary", size = "sm", ...rest }) {
|
|
10
|
-
const {
|
|
11
|
+
const M = useMessages({ copy: faCopy });
|
|
11
12
|
const { copy = M.copy.copy, copied = M.copy.copied, failed = M.copy.failed } = labels;
|
|
12
13
|
const [state, setState] = useState("idle");
|
|
13
14
|
const timer = useRef(undefined);
|
package/dist/Countdown.js
CHANGED
|
@@ -3,11 +3,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useEffect, useRef, useState } from "react";
|
|
4
4
|
import { toFaDigits } from "@kashi-ui/persian";
|
|
5
5
|
import { cx } from "./cx.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useKashiLocale, useMessages } from "./KashiProvider.js";
|
|
7
|
+
import { faCommon, faCountdown } from "@kashi-ui/persian";
|
|
7
8
|
const pad = (n) => String(n).padStart(2, "0");
|
|
8
9
|
/** شمارش معکوس با ارقام فارسی؛ هر ثانیه بهروز میشود و در پایان onComplete را صدا میزند */
|
|
9
10
|
export function Countdown({ to, seconds, onComplete, variant = "clock", digits, "aria-label": ariaLabel, className, labels = {} }) {
|
|
10
|
-
const {
|
|
11
|
+
const M = useMessages({ common: faCommon, countdown: faCountdown });
|
|
12
|
+
const { digits: D } = useKashiLocale();
|
|
11
13
|
digits ?? (digits = D);
|
|
12
14
|
const { days = M.countdown.days, hours = M.countdown.hours, minutes = M.countdown.minutes, seconds: secLabel = M.countdown.seconds } = labels;
|
|
13
15
|
const end = useRef(to?.getTime() ?? Date.now() + (seconds ?? 0) * 1000);
|