@kashi-ui/react 0.9.1 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/Banner.d.ts +19 -0
- package/dist/Banner.js +7 -0
- package/dist/ButtonGroup.d.ts +7 -0
- package/dist/ButtonGroup.js +6 -0
- package/dist/ChipGroup.d.ts +22 -0
- package/dist/ChipGroup.js +18 -0
- package/dist/CopyButton.d.ts +18 -0
- package/dist/CopyButton.js +26 -0
- package/dist/Countdown.d.ts +22 -0
- package/dist/Countdown.js +37 -0
- package/dist/LandlineInput.d.ts +19 -0
- package/dist/LandlineInput.js +23 -0
- package/dist/MonthPicker.d.ts +23 -0
- package/dist/MonthPicker.js +62 -0
- package/dist/PasswordStrength.d.ts +23 -0
- package/dist/PasswordStrength.js +21 -0
- package/dist/PlateInput.d.ts +28 -0
- package/dist/PlateInput.js +51 -0
- package/dist/PostalCodeInput.d.ts +16 -0
- package/dist/PostalCodeInput.js +19 -0
- package/dist/Rating.d.ts +22 -0
- package/dist/Rating.js +24 -0
- package/dist/SegmentedControl.d.ts +27 -0
- package/dist/SegmentedControl.js +14 -0
- package/dist/TimeInput.d.ts +23 -0
- package/dist/TimeInput.js +52 -0
- package/dist/TreeView.d.ts +26 -0
- package/dist/TreeView.js +96 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +14 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -20,8 +20,8 @@ export function SignUp() {
|
|
|
20
20
|
}
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
کامپوننتها: Button · Input · Textarea · Select · Checkbox · RadioGroup · Switch · Badge · Card · Alert · Avatar · AvatarGroup · Tabs · Dialog · Toast · Tooltip · DropdownMenu · DataTable · Pagination · Breadcrumb · Accordion · Stepper · Progress · Spinner · Skeleton · EmptyState · Divider · Kbd · RelativeTime · Combobox · CommandPalette · TagInput · FileUpload · Slider · NumberInput · Popover · StatCard · Timeline · SideNav
|
|
23
|
+
کامپوننتها: Button · Input · Textarea · Select · Checkbox · RadioGroup · Switch · Badge · Card · Alert · Avatar · AvatarGroup · Tabs · Dialog · Toast · Tooltip · DropdownMenu · DataTable · Pagination · Breadcrumb · Accordion · Stepper · Progress · Spinner · Skeleton · EmptyState · Divider · Kbd · RelativeTime · Combobox · CommandPalette · TagInput · FileUpload · Slider · NumberInput · Popover · StatCard · Timeline · SideNav · SegmentedControl · CopyButton · Banner · Rating · TreeView · ButtonGroup · ChipGroup · PasswordStrength
|
|
24
24
|
|
|
25
|
-
فارسی: DatePicker و Calendar شمسی · DateRangePicker · NationalIdInput · CardNumberInput · IbanInput · MobileInput · PriceInput · OtpInput
|
|
25
|
+
فارسی: DatePicker و Calendar شمسی · DateRangePicker · TimeInput · PostalCodeInput · PlateInput · LandlineInput · MonthPicker · Countdown · NationalIdInput · CardNumberInput · IbanInput · MobileInput · PriceInput · OtpInput
|
|
26
26
|
|
|
27
27
|
نیازمند React ۱۸ یا بالاتر. مستندات کامل: [kashi.sepantapouya.com](https://kashi.sepantapouya.com) · کد: [GitHub](https://github.com/Sepantapouya/Kashi) · لایسنس MIT
|
package/dist/Banner.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
export interface BannerProps extends Omit<HTMLAttributes<HTMLDivElement>, "title"> {
|
|
3
|
+
/** @default "neutral" */
|
|
4
|
+
tone?: "neutral" | "brand" | "warning" | "error";
|
|
5
|
+
icon?: ReactNode;
|
|
6
|
+
/** دکمه یا لینکها */
|
|
7
|
+
actions?: ReactNode;
|
|
8
|
+
/** با onClose دکمهٔ بستن نمایش داده میشود */
|
|
9
|
+
onClose?: () => void;
|
|
10
|
+
/** بدون حاشیه و گوشه، برای بالای صفحه */
|
|
11
|
+
flush?: boolean;
|
|
12
|
+
/** @default "اطلاعیه" */
|
|
13
|
+
label?: string;
|
|
14
|
+
/** @default "بستن اطلاعیه" */
|
|
15
|
+
closeLabel?: string;
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
}
|
|
18
|
+
/** نوار اطلاعرسانی سطح صفحه، مثل نسخهٔ جدید، پایان اشتراک یا اختلال سرویس */
|
|
19
|
+
export declare function Banner({ tone, icon, actions, onClose, flush, label, closeLabel, className, children, ...rest }: BannerProps): import("react").JSX.Element;
|
package/dist/Banner.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cx } from "./cx.js";
|
|
3
|
+
import { CloseIcon } from "./icons.js";
|
|
4
|
+
/** نوار اطلاعرسانی سطح صفحه، مثل نسخهٔ جدید، پایان اشتراک یا اختلال سرویس */
|
|
5
|
+
export function Banner({ tone = "neutral", icon, actions, onClose, flush, label = "اطلاعیه", closeLabel = "بستن اطلاعیه", className, children, ...rest }) {
|
|
6
|
+
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, {}) }))] }));
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { HTMLAttributes } from "react";
|
|
2
|
+
export interface ButtonGroupProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
/** نام گروه برای صفحهخوان */
|
|
4
|
+
"aria-label"?: string;
|
|
5
|
+
}
|
|
6
|
+
/** دکمههای چسبیده به هم، مثل «قبلی / امروز / بعدی» یا ابزار قالببندی */
|
|
7
|
+
export declare function ButtonGroup({ className, ...rest }: ButtonGroupProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cx } from "./cx.js";
|
|
3
|
+
/** دکمههای چسبیده به هم، مثل «قبلی / امروز / بعدی» یا ابزار قالببندی */
|
|
4
|
+
export function ButtonGroup({ className, ...rest }) {
|
|
5
|
+
return _jsx("div", { role: "group", className: cx("k-btn-group", className), ...rest });
|
|
6
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export interface ChipOption {
|
|
3
|
+
value: string;
|
|
4
|
+
label: ReactNode;
|
|
5
|
+
icon?: ReactNode;
|
|
6
|
+
/** تعداد نتیجهها کنار برچسب */
|
|
7
|
+
count?: number;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface ChipGroupProps {
|
|
11
|
+
options: ChipOption[];
|
|
12
|
+
/** مقدارهای انتخابشده */
|
|
13
|
+
value?: string[];
|
|
14
|
+
defaultValue?: string[];
|
|
15
|
+
onChange?: (value: string[]) => void;
|
|
16
|
+
/** فقط یک انتخاب؛ کلیک دوباره انتخاب را برمیدارد */
|
|
17
|
+
single?: boolean;
|
|
18
|
+
"aria-label"?: string;
|
|
19
|
+
className?: string;
|
|
20
|
+
}
|
|
21
|
+
/** تراشههای فیلتر روشن و خاموششونده، مثل دستهبندیها یا وضعیت سفارش */
|
|
22
|
+
export declare function ChipGroup({ options, value, defaultValue, onChange, single, "aria-label": ariaLabel, className }: ChipGroupProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { toFaDigits } from "@kashi-ui/persian";
|
|
4
|
+
import { cx } from "./cx.js";
|
|
5
|
+
const Check = () => (_jsx("svg", { className: "k-chip__check", viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "m5 10.5 3.2 3L15 7" }) }));
|
|
6
|
+
/** تراشههای فیلتر روشن و خاموششونده، مثل دستهبندیها یا وضعیت سفارش */
|
|
7
|
+
export function ChipGroup({ options, value, defaultValue = [], onChange, single, "aria-label": ariaLabel, className }) {
|
|
8
|
+
const [inner, setInner] = useState(defaultValue);
|
|
9
|
+
const current = value ?? inner;
|
|
10
|
+
const toggle = (v) => {
|
|
11
|
+
const on = current.includes(v);
|
|
12
|
+
const next = single ? (on ? [] : [v]) : on ? current.filter((x) => x !== v) : [...current, v];
|
|
13
|
+
if (value === undefined)
|
|
14
|
+
setInner(next);
|
|
15
|
+
onChange?.(next);
|
|
16
|
+
};
|
|
17
|
+
return (_jsx("div", { role: "group", "aria-label": ariaLabel, className: cx("k-chips", className), children: options.map((o) => (_jsxs("button", { type: "button", className: "k-chip", "aria-pressed": current.includes(o.value), disabled: o.disabled, onClick: () => toggle(o.value), children: [_jsx(Check, {}), o.icon, o.label, o.count !== undefined && _jsx("span", { className: "k-chip__count", children: toFaDigits(o.count) })] }, o.value))) }));
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ButtonProps } from "./Button.js";
|
|
2
|
+
export interface CopyButtonProps extends Omit<ButtonProps, "onClick" | "children" | "onCopy"> {
|
|
3
|
+
/** متنی که کپی میشود */
|
|
4
|
+
value: string;
|
|
5
|
+
/** پس از کپی موفق */
|
|
6
|
+
onCopy?: (value: string) => void;
|
|
7
|
+
/** فقط آیکون (نام دسترسپذیر از labels.copy) */
|
|
8
|
+
iconOnly?: boolean;
|
|
9
|
+
/** مدت نمایش «کپی شد» @default 2000 */
|
|
10
|
+
timeout?: number;
|
|
11
|
+
labels?: {
|
|
12
|
+
copy?: string;
|
|
13
|
+
copied?: string;
|
|
14
|
+
failed?: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/** دکمهٔ کپی در کلیپبورد با بازخورد «کپی شد» برای چشم و صفحهخوان */
|
|
18
|
+
export declare function CopyButton({ value, onCopy, iconOnly, timeout, labels, variant, size, ...rest }: CopyButtonProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { Button } from "./Button.js";
|
|
4
|
+
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" })] }));
|
|
5
|
+
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" }) }));
|
|
6
|
+
/** دکمهٔ کپی در کلیپبورد با بازخورد «کپی شد» برای چشم و صفحهخوان */
|
|
7
|
+
export function CopyButton({ value, onCopy, iconOnly, timeout = 2000, labels = {}, variant = "secondary", size = "sm", ...rest }) {
|
|
8
|
+
const { copy = "کپی", copied = "کپی شد", failed = "کپی نشد" } = labels;
|
|
9
|
+
const [state, setState] = useState("idle");
|
|
10
|
+
const timer = useRef();
|
|
11
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
12
|
+
const run = async () => {
|
|
13
|
+
try {
|
|
14
|
+
await navigator.clipboard.writeText(value);
|
|
15
|
+
setState("copied");
|
|
16
|
+
onCopy?.(value);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
setState("failed");
|
|
20
|
+
}
|
|
21
|
+
clearTimeout(timer.current);
|
|
22
|
+
timer.current = setTimeout(() => setState("idle"), timeout);
|
|
23
|
+
};
|
|
24
|
+
const text = state === "copied" ? copied : state === "failed" ? failed : copy;
|
|
25
|
+
return (_jsxs(_Fragment, { children: [_jsx(Button, { variant: variant, size: size, iconOnly: iconOnly, "aria-label": iconOnly ? text : undefined, iconStart: iconOnly ? undefined : state === "copied" ? _jsx(CheckIcon, {}) : _jsx(CopyIcon, {}), "data-copied": state === "copied" ? "" : undefined, onClick: run, ...rest, children: iconOnly ? (state === "copied" ? _jsx(CheckIcon, {}) : _jsx(CopyIcon, {})) : text }), _jsx("span", { className: "k-sr-only", "aria-live": "polite", children: state === "idle" ? "" : text })] }));
|
|
26
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface CountdownProps {
|
|
2
|
+
/** زمان پایان */
|
|
3
|
+
to?: Date;
|
|
4
|
+
/** یا مدت به ثانیه از لحظهٔ نمایش (مثلاً ۱۲۰ برای ارسال دوبارهٔ کد) */
|
|
5
|
+
seconds?: number;
|
|
6
|
+
onComplete?: () => void;
|
|
7
|
+
/** «clock» مثل ۰۲:۳۴، «blocks» کادرهای روز/ساعت/دقیقه/ثانیه @default "clock" */
|
|
8
|
+
variant?: "clock" | "blocks";
|
|
9
|
+
/** @default "fa" */
|
|
10
|
+
digits?: "fa" | "latin";
|
|
11
|
+
/** نام برای صفحهخوان، مثل «زمان باقیمانده تا ارسال دوباره» */
|
|
12
|
+
"aria-label"?: string;
|
|
13
|
+
className?: string;
|
|
14
|
+
labels?: {
|
|
15
|
+
days?: string;
|
|
16
|
+
hours?: string;
|
|
17
|
+
minutes?: string;
|
|
18
|
+
seconds?: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/** شمارش معکوس با ارقام فارسی؛ هر ثانیه بهروز میشود و در پایان onComplete را صدا میزند */
|
|
22
|
+
export declare function Countdown({ to, seconds, onComplete, variant, digits, "aria-label": ariaLabel, className, labels }: CountdownProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { toFaDigits } from "@kashi-ui/persian";
|
|
4
|
+
import { cx } from "./cx.js";
|
|
5
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
6
|
+
/** شمارش معکوس با ارقام فارسی؛ هر ثانیه بهروز میشود و در پایان onComplete را صدا میزند */
|
|
7
|
+
export function Countdown({ to, seconds, onComplete, variant = "clock", digits = "fa", "aria-label": ariaLabel, className, labels = {} }) {
|
|
8
|
+
const { days = "روز", hours = "ساعت", minutes = "دقیقه", seconds: secLabel = "ثانیه" } = labels;
|
|
9
|
+
const end = useRef(to?.getTime() ?? Date.now() + (seconds ?? 0) * 1000);
|
|
10
|
+
const [left, setLeft] = useState(() => Math.max(0, Math.ceil((end.current - Date.now()) / 1000)));
|
|
11
|
+
const done = useRef(false);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
end.current = to?.getTime() ?? Date.now() + (seconds ?? 0) * 1000;
|
|
14
|
+
done.current = false;
|
|
15
|
+
const tick = () => {
|
|
16
|
+
const s = Math.max(0, Math.ceil((end.current - Date.now()) / 1000));
|
|
17
|
+
setLeft(s);
|
|
18
|
+
if (s === 0 && !done.current) {
|
|
19
|
+
done.current = true;
|
|
20
|
+
onComplete?.();
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
tick();
|
|
24
|
+
const t = setInterval(tick, 1000);
|
|
25
|
+
return () => clearInterval(t);
|
|
26
|
+
}, [to?.getTime(), seconds]);
|
|
27
|
+
const d = Math.floor(left / 86400), h = Math.floor((left % 86400) / 3600), m = Math.floor((left % 3600) / 60), s = left % 60;
|
|
28
|
+
const f = (x) => (digits === "fa" ? toFaDigits(String(x)) : String(x));
|
|
29
|
+
// متن کامل برای صفحهخوان؛ role="timer" بهطور پیشفرض هر ثانیه خوانده نمیشود
|
|
30
|
+
const spoken = [d && `${f(d)} ${days}`, h && `${f(h)} ${hours}`, m && `${f(m)} ${minutes}`, `${f(s)} ${secLabel}`].filter(Boolean).join(" و ");
|
|
31
|
+
if (variant === "blocks") {
|
|
32
|
+
const units = [...(d ? [[d, days]] : []), [h, hours], [m, minutes], [s, secLabel]];
|
|
33
|
+
return (_jsx("div", { role: "timer", "aria-label": ariaLabel ? `${ariaLabel}: ${spoken}` : spoken, className: cx("k-countdown k-countdown--blocks", className), "data-done": left === 0 ? "" : undefined, children: units.map(([v, name]) => (_jsxs("span", { className: "k-countdown__unit", "aria-hidden": "true", children: [_jsx("span", { className: "k-countdown__num", children: f(pad(v)) }), _jsx("span", { className: "k-countdown__name", children: name })] }, name))) }));
|
|
34
|
+
}
|
|
35
|
+
const clock = (d ? `${d}:` : "") + (h || d ? `${pad(h)}:` : "") + `${pad(m)}:${pad(s)}`;
|
|
36
|
+
return (_jsx("span", { role: "timer", "aria-label": ariaLabel ? `${ariaLabel}: ${spoken}` : spoken, className: cx("k-countdown", className), "data-done": left === 0 ? "" : undefined, dir: "ltr", children: _jsx("span", { "aria-hidden": "true", children: f(clock) }) }));
|
|
37
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type InputProps } from "./Input.js";
|
|
3
|
+
type Base = Omit<InputProps, "value" | "defaultValue" | "onChange" | "type" | "inputMode" | "addonEnd">;
|
|
4
|
+
export interface LandlineInputProps extends Base {
|
|
5
|
+
/** مثل "02188776655" یا "+982188776655" */
|
|
6
|
+
value?: string;
|
|
7
|
+
defaultValue?: string;
|
|
8
|
+
/** شماره به شکل ۰۲۱xxxxxxxx، معتبر بودن و نام استان */
|
|
9
|
+
onValueChange?: (value: string, valid: boolean, province: string | null) => void;
|
|
10
|
+
/** @default "fa" */
|
|
11
|
+
digits?: "fa" | "latin";
|
|
12
|
+
/** نمایش نام استان از روی پیششماره @default true */
|
|
13
|
+
showProvince?: boolean;
|
|
14
|
+
/** @default "شمارهٔ تلفن ثابت معتبر نیست." */
|
|
15
|
+
invalidMessage?: ReactNode;
|
|
16
|
+
}
|
|
17
|
+
/** تلفن ثابت با پیششماره: +98 را به ۰ تبدیل میکند، گروهبندی و نام استان را نشان میدهد */
|
|
18
|
+
export declare const LandlineInput: import("react").ForwardRefExoticComponent<LandlineInputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useId, useState } from "react";
|
|
3
|
+
import { formatLandline, getLandlineProvince, isValidLandline, normalizeLandline } from "@kashi-ui/persian";
|
|
4
|
+
import { Input } from "./Input.js";
|
|
5
|
+
import { useDigitsInput } from "./useDigitsInput.js";
|
|
6
|
+
import { mergeRefs } from "./utils.js";
|
|
7
|
+
/** تلفن ثابت با پیششماره: +98 را به ۰ تبدیل میکند، گروهبندی و نام استان را نشان میدهد */
|
|
8
|
+
export const LandlineInput = forwardRef(function LandlineInput({ value, defaultValue, onValueChange, digits = "fa", showProvince = true, invalidMessage = "شمارهٔ تلفن ثابت معتبر نیست.", error, name, id, onBlur, placeholder, ...rest }, ref) {
|
|
9
|
+
const autoId = useId();
|
|
10
|
+
const inputId = id ?? autoId;
|
|
11
|
+
const [touched, setTouched] = useState(false);
|
|
12
|
+
const { raw, shown, inputRef, handleChange } = useDigitsInput({ value, defaultValue, maxDigits: 11, normalize: normalizeLandline, format: formatLandline, digits });
|
|
13
|
+
const province = showProvince ? getLandlineProvince(raw) : null;
|
|
14
|
+
const showInvalid = raw.length > 0 && (touched || raw.length === 11) && !isValidLandline(raw);
|
|
15
|
+
const provId = `${inputId}-province`;
|
|
16
|
+
return (_jsxs(_Fragment, { children: [_jsx(Input, { ref: mergeRefs(ref, inputRef), id: inputId, type: "tel", inputMode: "tel", autoComplete: "tel-national", dir: "ltr", placeholder: placeholder ?? (digits === "fa" ? "۰۲۱ ۸۸۷۷ ۶۶۵۵" : "021 8877 6655"), value: shown, onChange: (e) => {
|
|
17
|
+
const next = handleChange(e);
|
|
18
|
+
onValueChange?.(next, isValidLandline(next), getLandlineProvince(next));
|
|
19
|
+
}, onBlur: (e) => {
|
|
20
|
+
setTouched(true);
|
|
21
|
+
onBlur?.(e);
|
|
22
|
+
}, addonEnd: province ? _jsx("span", { className: "k-input__meta", id: provId, children: province }) : undefined, "aria-describedby": province ? provId : undefined, error: error ?? (showInvalid ? invalidMessage : undefined), ...rest }), name && _jsx("input", { type: "hidden", name: name, value: raw })] }));
|
|
23
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface JalaliMonth {
|
|
2
|
+
year: number;
|
|
3
|
+
/** ۱ تا ۱۲ */
|
|
4
|
+
month: number;
|
|
5
|
+
}
|
|
6
|
+
export interface MonthPickerProps {
|
|
7
|
+
value?: JalaliMonth | null;
|
|
8
|
+
defaultValue?: JalaliMonth | null;
|
|
9
|
+
onChange?: (value: JalaliMonth) => void;
|
|
10
|
+
min?: JalaliMonth;
|
|
11
|
+
max?: JalaliMonth;
|
|
12
|
+
/** @default "fa" */
|
|
13
|
+
digits?: "fa" | "latin";
|
|
14
|
+
/** @default "انتخاب ماه" */
|
|
15
|
+
"aria-label"?: string;
|
|
16
|
+
className?: string;
|
|
17
|
+
labels?: {
|
|
18
|
+
prevYear?: string;
|
|
19
|
+
nextYear?: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/** انتخاب ماه و سال شمسی، برای گزارش ماهانه یا تاریخ انقضای کارت؛ ↑↓←→ بین ماهها و PageUp/PageDown بین سالها */
|
|
23
|
+
export declare function MonthPicker({ value, defaultValue, onChange, min, max, digits, "aria-label": ariaLabel, className, labels }: MonthPickerProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { JALALI_MONTHS, toFaDigits, toJalali } from "@kashi-ui/persian";
|
|
4
|
+
import { cx } from "./cx.js";
|
|
5
|
+
const key = (m) => m.year * 12 + m.month;
|
|
6
|
+
const Arrow = ({ next }) => (_jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.7, 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
|
+
/** انتخاب ماه و سال شمسی، برای گزارش ماهانه یا تاریخ انقضای کارت؛ ↑↓←→ بین ماهها و PageUp/PageDown بین سالها */
|
|
8
|
+
export function MonthPicker({ value, defaultValue = null, onChange, min, max, digits = "fa", "aria-label": ariaLabel = "انتخاب ماه", className, labels = {} }) {
|
|
9
|
+
const { prevYear = "سال قبل", nextYear = "سال بعد" } = labels;
|
|
10
|
+
const today = toJalali(new Date());
|
|
11
|
+
const [inner, setInner] = useState(defaultValue);
|
|
12
|
+
const selected = value !== undefined ? value : inner;
|
|
13
|
+
const [year, setYear] = useState(selected?.year ?? today.jy);
|
|
14
|
+
const [focus, setFocus] = useState(selected?.year === year ? selected.month : today.jy === year ? today.jm : 1);
|
|
15
|
+
const grid = useRef(null);
|
|
16
|
+
// پس از رندر سال یا ماه تازه، فوکوس به همان ماه برود (با کیبورد)
|
|
17
|
+
const pendingFocus = useRef(false);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (!pendingFocus.current)
|
|
20
|
+
return;
|
|
21
|
+
pendingFocus.current = false;
|
|
22
|
+
grid.current?.querySelector(`[data-month="${focus}"]`)?.focus();
|
|
23
|
+
}, [year, focus]);
|
|
24
|
+
const f = (n) => (digits === "fa" ? toFaDigits(String(n)) : String(n));
|
|
25
|
+
const out = (m) => (min && key(m) < key(min)) || (max && key(m) > key(max));
|
|
26
|
+
const pick = (m) => {
|
|
27
|
+
if (out(m))
|
|
28
|
+
return;
|
|
29
|
+
if (value === undefined)
|
|
30
|
+
setInner(m);
|
|
31
|
+
onChange?.(m);
|
|
32
|
+
};
|
|
33
|
+
const moveTo = (y, m) => {
|
|
34
|
+
pendingFocus.current = true;
|
|
35
|
+
setYear(y);
|
|
36
|
+
setFocus(m);
|
|
37
|
+
};
|
|
38
|
+
const onKeyDown = (e) => {
|
|
39
|
+
const rtl = getComputedStyle(e.currentTarget).direction === "rtl";
|
|
40
|
+
const delta = { ArrowRight: rtl ? -1 : 1, ArrowLeft: rtl ? 1 : -1, ArrowDown: 3, ArrowUp: -3 };
|
|
41
|
+
let idx = year * 12 + focus - 1;
|
|
42
|
+
if (e.key in delta)
|
|
43
|
+
idx += delta[e.key];
|
|
44
|
+
else if (e.key === "PageUp")
|
|
45
|
+
idx -= 12;
|
|
46
|
+
else if (e.key === "PageDown")
|
|
47
|
+
idx += 12;
|
|
48
|
+
else if (e.key === "Home")
|
|
49
|
+
idx = year * 12;
|
|
50
|
+
else if (e.key === "End")
|
|
51
|
+
idx = year * 12 + 11;
|
|
52
|
+
else
|
|
53
|
+
return;
|
|
54
|
+
e.preventDefault();
|
|
55
|
+
moveTo(Math.floor(idx / 12), (idx % 12) + 1);
|
|
56
|
+
};
|
|
57
|
+
return (_jsxs("div", { className: cx("k-monthpicker", className), role: "group", "aria-label": ariaLabel, children: [_jsxs("div", { className: "k-monthpicker__header", children: [_jsx("button", { type: "button", className: "k-btn k-btn--tertiary k-btn--icon k-btn--sm", "aria-label": prevYear, onClick: () => setYear(year - 1), disabled: !!min && year <= min.year, children: _jsx(Arrow, {}) }), _jsx("span", { className: "k-monthpicker__year", "aria-live": "polite", children: f(year) }), _jsx("button", { type: "button", className: "k-btn k-btn--tertiary k-btn--icon k-btn--sm", "aria-label": nextYear, onClick: () => setYear(year + 1), disabled: !!max && year >= max.year, children: _jsx(Arrow, { next: true }) })] }), _jsx("div", { className: "k-monthpicker__grid", ref: grid, onKeyDown: onKeyDown, children: JALALI_MONTHS.map((name, i) => {
|
|
58
|
+
const m = { year, month: i + 1 };
|
|
59
|
+
const isSel = selected?.year === year && selected.month === i + 1;
|
|
60
|
+
return (_jsx("button", { type: "button", "data-month": i + 1, className: "k-monthpicker__month", tabIndex: focus === i + 1 ? 0 : -1, "aria-pressed": isSel, "aria-label": `${name} ${f(year)}`, "aria-current": today.jy === year && today.jm === i + 1 ? "date" : undefined, disabled: !!out(m), onFocus: () => setFocus(i + 1), onClick: () => pick(m), children: name }, name));
|
|
61
|
+
}) })] }));
|
|
62
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface PasswordRule {
|
|
2
|
+
label: string;
|
|
3
|
+
test: (password: string) => boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare const defaultPasswordRules: PasswordRule[];
|
|
6
|
+
export interface PasswordStrengthProps {
|
|
7
|
+
password: string;
|
|
8
|
+
rules?: PasswordRule[];
|
|
9
|
+
/** نمایش فهرست شرطها @default true */
|
|
10
|
+
showRules?: boolean;
|
|
11
|
+
/** هشدار وقتی رمز حروف فارسی دارد (صفحهکلید فارسی مانده) @default true */
|
|
12
|
+
warnPersian?: boolean;
|
|
13
|
+
/** شناسهٔ این بخش، برای aria-describedby فیلد رمز */
|
|
14
|
+
id?: string;
|
|
15
|
+
className?: string;
|
|
16
|
+
labels?: {
|
|
17
|
+
title?: string;
|
|
18
|
+
levels?: [string, string, string, string];
|
|
19
|
+
persian?: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/** قدرت رمز عبور با نوار چهارقسمتی و فهرست شرطها؛ زیر فیلد رمز بگذارید و با id به آن وصل کنید */
|
|
23
|
+
export declare function PasswordStrength({ password, rules, showRules, warnPersian, id, className, labels }: PasswordStrengthProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { toFaDigits } from "@kashi-ui/persian";
|
|
3
|
+
import { cx } from "./cx.js";
|
|
4
|
+
export const defaultPasswordRules = [
|
|
5
|
+
{ label: `حداقل ${toFaDigits(8)} نویسه`, test: (p) => p.length >= 8 },
|
|
6
|
+
{ label: "حروف بزرگ و کوچک انگلیسی", test: (p) => /[a-z]/.test(p) && /[A-Z]/.test(p) },
|
|
7
|
+
{ label: "دستکم یک عدد", test: (p) => /\d/.test(p) },
|
|
8
|
+
{ label: "دستکم یک نماد، مثل ! یا @", test: (p) => /[^A-Za-z0-9\s-ۿ]/.test(p) },
|
|
9
|
+
];
|
|
10
|
+
const Check = () => _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" }) });
|
|
11
|
+
const Dot = () => _jsx("svg", { viewBox: "0 0 20 20", "aria-hidden": "true", children: _jsx("circle", { cx: "10", cy: "10", r: "2.5", fill: "currentColor" }) });
|
|
12
|
+
/** قدرت رمز عبور با نوار چهارقسمتی و فهرست شرطها؛ زیر فیلد رمز بگذارید و با id به آن وصل کنید */
|
|
13
|
+
export function PasswordStrength({ password, rules = defaultPasswordRules, showRules = true, warnPersian = true, id, className, labels = {} }) {
|
|
14
|
+
const { title = "قدرت رمز", levels = ["ضعیف", "متوسط", "خوب", "قوی"], persian = "رمز حروف فارسی دارد؛ شاید صفحهکلید روی فارسی مانده است." } = labels;
|
|
15
|
+
const met = rules.map((r) => r.test(password));
|
|
16
|
+
const n = met.filter(Boolean).length;
|
|
17
|
+
// امتیاز ۰ تا ۴ به نسبت شرطهای برآوردهشده
|
|
18
|
+
const score = password ? Math.max(1, Math.round((n / rules.length) * 4)) : 0;
|
|
19
|
+
const persianTyped = warnPersian && /[-ۿ]/.test(password);
|
|
20
|
+
return (_jsxs("div", { id: id, className: cx("k-strength", className), "data-score": score, children: [_jsx("div", { className: "k-strength__bars", "aria-hidden": "true", children: [0, 1, 2, 3].map((i) => _jsx("span", { className: "k-strength__bar" }, i)) }), _jsx("p", { className: "k-strength__label", "aria-live": "polite", style: { margin: 0 }, children: score > 0 && _jsxs(_Fragment, { children: [title, ": ", _jsx("strong", { children: levels[score - 1] })] }) }), persianTyped && _jsx("p", { className: "k-hint k-hint--error", role: "alert", children: persian }), showRules && (_jsx("ul", { className: "k-strength__rules", children: rules.map((r, i) => (_jsxs("li", { className: "k-strength__rule", "data-met": met[i] ? "" : undefined, children: [met[i] ? _jsx(Check, {}) : _jsx(Dot, {}), _jsxs("span", { children: [r.label, _jsx("span", { className: "k-sr-only", children: met[i] ? "، رعایت شده" : "، رعایت نشده" })] })] }, r.label))) }))] }));
|
|
21
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type Plate } from "@kashi-ui/persian";
|
|
3
|
+
export interface PlateInputProps {
|
|
4
|
+
label?: ReactNode;
|
|
5
|
+
hint?: ReactNode;
|
|
6
|
+
error?: ReactNode;
|
|
7
|
+
value?: Plate;
|
|
8
|
+
defaultValue?: Partial<Plate>;
|
|
9
|
+
onChange?: (plate: Plate, valid: boolean) => void;
|
|
10
|
+
/** با name، چهار فیلد پنهان name_first، name_letter، name_middle و name_region */
|
|
11
|
+
name?: string;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
id?: string;
|
|
14
|
+
className?: string;
|
|
15
|
+
/** @default "پلاک خودرو معتبر نیست." */
|
|
16
|
+
invalidMessage?: ReactNode;
|
|
17
|
+
labels?: {
|
|
18
|
+
first?: string;
|
|
19
|
+
letter?: string;
|
|
20
|
+
middle?: string;
|
|
21
|
+
region?: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* پلاک خودروی ایران با ظاهر واقعی: دو رقم، حرف، سه رقم و کد استان.
|
|
26
|
+
* با پر شدن هر بخش فوکوس خودکار به بخش بعد میرود و Backspace در بخش خالی به قبلی برمیگردد.
|
|
27
|
+
*/
|
|
28
|
+
export declare function PlateInput({ label, hint, error, value, defaultValue, onChange, name, disabled, id, className, invalidMessage, labels, }: PlateInputProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId, useRef, useState } from "react";
|
|
3
|
+
import { PLATE_LETTERS, formatPlate, isValidPlate, onlyDigits, plateType, toFaDigits } from "@kashi-ui/persian";
|
|
4
|
+
import { Field, describedBy } from "./Field.js";
|
|
5
|
+
const EMPTY = { first: "", letter: "", middle: "", region: "" };
|
|
6
|
+
/**
|
|
7
|
+
* پلاک خودروی ایران با ظاهر واقعی: دو رقم، حرف، سه رقم و کد استان.
|
|
8
|
+
* با پر شدن هر بخش فوکوس خودکار به بخش بعد میرود و Backspace در بخش خالی به قبلی برمیگردد.
|
|
9
|
+
*/
|
|
10
|
+
export function PlateInput({ label, hint, error, value, defaultValue, onChange, name, disabled, id, className, invalidMessage = "پلاک خودرو معتبر نیست.", labels = {}, }) {
|
|
11
|
+
const autoId = useId();
|
|
12
|
+
const groupId = id ?? autoId;
|
|
13
|
+
// برچسب به اولین بخش وصل است تا کلیک روی آن فوکوس بدهد
|
|
14
|
+
const firstId = `${groupId}-first`;
|
|
15
|
+
const { first = "دو رقم اول پلاک", letter = "حرف پلاک", middle = "سه رقم پلاک", region = "کد استان" } = labels;
|
|
16
|
+
const [inner, setInner] = useState({ ...EMPTY, ...defaultValue });
|
|
17
|
+
const plate = value ?? inner;
|
|
18
|
+
const [touched, setTouched] = useState(false);
|
|
19
|
+
const refs = [useRef(null), useRef(null), useRef(null), useRef(null)];
|
|
20
|
+
const complete = plate.first.length === 2 && plate.letter && plate.middle.length === 3 && plate.region.length === 2;
|
|
21
|
+
const valid = isValidPlate(plate);
|
|
22
|
+
const showInvalid = (touched || complete) && Object.values(plate).some(Boolean) && !valid;
|
|
23
|
+
const set = (patch) => {
|
|
24
|
+
const next = { ...plate, ...patch };
|
|
25
|
+
if (value === undefined)
|
|
26
|
+
setInner(next);
|
|
27
|
+
onChange?.(next, isValidPlate(next));
|
|
28
|
+
};
|
|
29
|
+
const seg = (key, len, idx, aria, cls = "") => (_jsx("input", { ref: refs[idx], id: idx === 0 ? firstId : undefined, className: `k-plate__seg ${cls}`, inputMode: "numeric", autoComplete: "off", "aria-label": aria, disabled: disabled, placeholder: toFaDigits("0".repeat(len)), value: toFaDigits(plate[key]), onChange: (e) => {
|
|
30
|
+
const all = onlyDigits(e.target.value);
|
|
31
|
+
const d = all.slice(0, len);
|
|
32
|
+
// تایپ سریع یا چسباندن: رقمهای اضافه به بخش عددی بعدی میروند
|
|
33
|
+
if (key === "middle" && all.length > len)
|
|
34
|
+
set({ middle: d, region: (plate.region + all.slice(len)).slice(0, 2) });
|
|
35
|
+
else
|
|
36
|
+
set({ [key]: d });
|
|
37
|
+
if (d.length === len)
|
|
38
|
+
refs[idx + 1]?.current?.focus();
|
|
39
|
+
}, onKeyDown: (e) => {
|
|
40
|
+
if (e.key === "Backspace" && !plate[key])
|
|
41
|
+
refs[idx - 1]?.current?.focus();
|
|
42
|
+
} }));
|
|
43
|
+
return (_jsxs(Field, { id: firstId, label: label, hint: hint, error: error ?? (showInvalid ? invalidMessage : undefined), className: className, children: [_jsxs("div", { className: "k-plate", role: "group", id: groupId, "aria-describedby": describedBy(firstId, hint, error ?? (showInvalid ? invalidMessage : undefined)), "aria-label": typeof label === "string" ? label : "پلاک خودرو", "data-invalid": showInvalid || error ? "" : undefined, "data-type": plateType(plate.letter), onBlur: (e) => {
|
|
44
|
+
if (!e.currentTarget.contains(e.relatedTarget))
|
|
45
|
+
setTouched(true);
|
|
46
|
+
}, children: [_jsxs("span", { className: "k-plate__flag", "aria-hidden": "true", children: [_jsx("span", { className: "k-plate__flag-colors" }), "I.R.", _jsx("br", {}), "IRAN"] }), seg("first", 2, 0, first), _jsxs("select", { ref: refs[1], className: "k-plate__letter", "aria-label": letter, disabled: disabled, value: plate.letter, onChange: (e) => {
|
|
47
|
+
set({ letter: e.target.value });
|
|
48
|
+
if (e.target.value)
|
|
49
|
+
refs[2].current?.focus();
|
|
50
|
+
}, children: [_jsx("option", { value: "", children: "\u2013" }), PLATE_LETTERS.map((l) => _jsx("option", { value: l, children: l === "ه" ? "هـ" : l }, l))] }), seg("middle", 3, 2, middle, "k-plate__seg--3"), _jsxs("span", { className: "k-plate__region", children: [_jsx("span", { className: "k-plate__region-label", "aria-hidden": "true", children: "\u0627\u06CC\u0631\u0627\u0646" }), seg("region", 2, 3, region)] })] }), _jsx("span", { className: "k-sr-only", "aria-live": "polite", children: valid ? formatPlate(plate) : "" }), name && ["first", "letter", "middle", "region"].map((k) => _jsx("input", { type: "hidden", name: `${name}_${k}`, value: plate[k] }, k))] }));
|
|
51
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type InputProps } from "./Input.js";
|
|
3
|
+
type Base = Omit<InputProps, "value" | "defaultValue" | "onChange" | "type" | "inputMode">;
|
|
4
|
+
export interface PostalCodeInputProps extends Base {
|
|
5
|
+
/** ارقام لاتین، مثل "1193653471" */
|
|
6
|
+
value?: string;
|
|
7
|
+
defaultValue?: string;
|
|
8
|
+
onValueChange?: (value: string, valid: boolean) => void;
|
|
9
|
+
/** @default "fa" */
|
|
10
|
+
digits?: "fa" | "latin";
|
|
11
|
+
/** @default "کد پستی معتبر نیست." */
|
|
12
|
+
invalidMessage?: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
/** کد پستی ۱۰ رقمی با قالب ۱۲۳۴۵-۶۷۸۹۰ و بررسی قواعد کد پستی ایران */
|
|
15
|
+
export declare const PostalCodeInput: import("react").ForwardRefExoticComponent<PostalCodeInputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useState } from "react";
|
|
3
|
+
import { formatPostalCode, isValidPostalCode } from "@kashi-ui/persian";
|
|
4
|
+
import { Input } from "./Input.js";
|
|
5
|
+
import { useDigitsInput } from "./useDigitsInput.js";
|
|
6
|
+
import { mergeRefs } from "./utils.js";
|
|
7
|
+
/** کد پستی ۱۰ رقمی با قالب ۱۲۳۴۵-۶۷۸۹۰ و بررسی قواعد کد پستی ایران */
|
|
8
|
+
export const PostalCodeInput = forwardRef(function PostalCodeInput({ value, defaultValue, onValueChange, digits = "fa", invalidMessage = "کد پستی معتبر نیست.", error, name, onBlur, placeholder, ...rest }, ref) {
|
|
9
|
+
const { raw, shown, inputRef, handleChange } = useDigitsInput({ value, defaultValue, maxDigits: 10, format: formatPostalCode, digits });
|
|
10
|
+
const [touched, setTouched] = useState(false);
|
|
11
|
+
const showInvalid = raw.length > 0 && (touched || raw.length === 10) && !isValidPostalCode(raw);
|
|
12
|
+
return (_jsxs(_Fragment, { children: [_jsx(Input, { ref: mergeRefs(ref, inputRef), type: "text", inputMode: "numeric", autoComplete: "postal-code", dir: "ltr", placeholder: placeholder ?? (digits === "fa" ? "۱۲۳۴۵-۶۷۸۹۰" : "12345-67890"), value: shown, onChange: (e) => {
|
|
13
|
+
const next = handleChange(e);
|
|
14
|
+
onValueChange?.(next, isValidPostalCode(next));
|
|
15
|
+
}, onBlur: (e) => {
|
|
16
|
+
setTouched(true);
|
|
17
|
+
onBlur?.(e);
|
|
18
|
+
}, error: error ?? (showInvalid ? invalidMessage : undefined), ...rest }), name && _jsx("input", { type: "hidden", name: name, value: raw })] }));
|
|
19
|
+
});
|
package/dist/Rating.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface RatingProps {
|
|
2
|
+
value?: number;
|
|
3
|
+
defaultValue?: number;
|
|
4
|
+
onChange?: (value: number) => void;
|
|
5
|
+
/** @default 5 */
|
|
6
|
+
max?: number;
|
|
7
|
+
/** فقط نمایش؛ مقدار اعشاری مثل ۴٫۵ نیمستاره نشان میدهد */
|
|
8
|
+
readOnly?: boolean;
|
|
9
|
+
/** نمایش عدد کنار ستارهها */
|
|
10
|
+
showValue?: boolean;
|
|
11
|
+
/** @default "md" */
|
|
12
|
+
size?: "sm" | "md" | "lg";
|
|
13
|
+
/** @default "امتیاز" */
|
|
14
|
+
label?: string;
|
|
15
|
+
name?: string;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
className?: string;
|
|
18
|
+
/** نام هر ستاره برای صفحهخوان @default (n, max) => «n از max» */
|
|
19
|
+
starLabel?: (n: number, max: number) => string;
|
|
20
|
+
}
|
|
21
|
+
/** امتیاز ستارهای؛ قابلانتخاب با رادیوهای بومی (←→) یا فقطخواندنی */
|
|
22
|
+
export declare function Rating({ value, defaultValue, onChange, max, readOnly, showValue, size, label, name, disabled, className, starLabel, }: RatingProps): import("react").JSX.Element;
|
package/dist/Rating.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId, useState } from "react";
|
|
3
|
+
import { toFaDigits } from "@kashi-ui/persian";
|
|
4
|
+
import { cx } from "./cx.js";
|
|
5
|
+
const Star = () => (_jsxs("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", children: [_jsx("path", { fill: "currentColor", d: "M12 2.8l2.8 5.9 6.4.8-4.7 4.4 1.2 6.3L12 17.1l-5.7 3.1 1.2-6.3L2.8 9.5l6.4-.8z" }), _jsx("path", { className: "k-rating__half", fill: "none", d: "M12 2.8v14.3l-5.7 3.1 1.2-6.3L2.8 9.5l6.4-.8z" })] }));
|
|
6
|
+
const fa = (n) => toFaDigits(String(n)).replace(".", "٫");
|
|
7
|
+
/** امتیاز ستارهای؛ قابلانتخاب با رادیوهای بومی (←→) یا فقطخواندنی */
|
|
8
|
+
export function Rating({ value, defaultValue = 0, onChange, max = 5, readOnly, showValue, size = "md", label = "امتیاز", name, disabled, className, starLabel = (n, m) => `${fa(n)} از ${fa(m)}`, }) {
|
|
9
|
+
const id = useId();
|
|
10
|
+
const [inner, setInner] = useState(defaultValue);
|
|
11
|
+
const [hover, setHover] = useState(null);
|
|
12
|
+
const current = value ?? inner;
|
|
13
|
+
const shown = hover ?? current;
|
|
14
|
+
const stars = Array.from({ length: max }, (_, i) => i + 1);
|
|
15
|
+
const cls = cx("k-rating", size !== "md" && `k-rating--${size}`, className);
|
|
16
|
+
if (readOnly) {
|
|
17
|
+
return (_jsxs("span", { className: cls, "data-readonly": "", role: "img", "aria-label": `${label}: ${starLabel(current, max)}`, children: [stars.map((n) => (_jsx("span", { className: "k-rating__star", "data-filled": n <= Math.floor(current) ? "" : undefined, "data-half": n === Math.ceil(current) && current % 1 >= 0.25 ? "" : undefined, children: _jsx(Star, {}) }, n))), showValue && _jsx("span", { className: "k-rating__value", "aria-hidden": "true", children: fa(current) })] }));
|
|
18
|
+
}
|
|
19
|
+
return (_jsxs("fieldset", { className: cls, onPointerLeave: () => setHover(null), children: [_jsx("legend", { className: "k-sr-only", children: label }), stars.map((n) => (_jsxs("label", { className: "k-rating__star", "data-filled": n <= shown ? "" : undefined, onPointerEnter: () => !disabled && setHover(n), children: [_jsx("input", { type: "radio", className: "k-sr-only", name: name ?? id, value: n, checked: current === n, disabled: disabled, "aria-label": starLabel(n, max), onChange: () => {
|
|
20
|
+
if (value === undefined)
|
|
21
|
+
setInner(n);
|
|
22
|
+
onChange?.(n);
|
|
23
|
+
} }), _jsx(Star, {})] }, n))), showValue && _jsx("span", { className: "k-rating__value", "aria-hidden": "true", children: fa(current) })] }));
|
|
24
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export interface SegmentedOption {
|
|
3
|
+
value: string;
|
|
4
|
+
label: ReactNode;
|
|
5
|
+
icon?: ReactNode;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
/** نام دسترسپذیر وقتی label فقط آیکون است */
|
|
8
|
+
"aria-label"?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface SegmentedControlProps {
|
|
11
|
+
options: SegmentedOption[];
|
|
12
|
+
value?: string;
|
|
13
|
+
defaultValue?: string;
|
|
14
|
+
onChange?: (value: string) => void;
|
|
15
|
+
/** نام گروه برای صفحهخوان (الزامی اگر برچسب دیداری ندارد) */
|
|
16
|
+
"aria-label"?: string;
|
|
17
|
+
"aria-labelledby"?: string;
|
|
18
|
+
name?: string;
|
|
19
|
+
/** @default "md" */
|
|
20
|
+
size?: "sm" | "md";
|
|
21
|
+
/** تمامعرض با بخشهای هماندازه */
|
|
22
|
+
block?: boolean;
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
className?: string;
|
|
25
|
+
}
|
|
26
|
+
/** انتخاب یکی از چند گزینهٔ کوتاه، مثل «فهرست / جدول / کارت»؛ روی رادیوی بومی با پیمایش ↑↓←→ */
|
|
27
|
+
export declare function SegmentedControl({ options, value, defaultValue, onChange, name, size, block, disabled, className, "aria-label": ariaLabel, "aria-labelledby": labelledBy, }: SegmentedControlProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId, useState } from "react";
|
|
3
|
+
import { cx } from "./cx.js";
|
|
4
|
+
/** انتخاب یکی از چند گزینهٔ کوتاه، مثل «فهرست / جدول / کارت»؛ روی رادیوی بومی با پیمایش ↑↓←→ */
|
|
5
|
+
export function SegmentedControl({ options, value, defaultValue, onChange, name, size = "md", block, disabled, className, "aria-label": ariaLabel, "aria-labelledby": labelledBy, }) {
|
|
6
|
+
const autoName = useId();
|
|
7
|
+
const [inner, setInner] = useState(defaultValue ?? options.find((o) => !o.disabled)?.value);
|
|
8
|
+
const current = value ?? inner;
|
|
9
|
+
return (_jsx("div", { role: "radiogroup", "aria-label": ariaLabel, "aria-labelledby": labelledBy, className: cx("k-segmented", size === "sm" && "k-segmented--sm", block && "k-segmented--block", className), children: options.map((o) => (_jsxs("label", { className: "k-segmented__item", children: [_jsx("input", { type: "radio", className: "k-sr-only", name: name ?? autoName, value: o.value, checked: current === o.value, disabled: disabled || o.disabled, "aria-label": o["aria-label"], onChange: () => {
|
|
10
|
+
if (value === undefined)
|
|
11
|
+
setInner(o.value);
|
|
12
|
+
onChange?.(o.value);
|
|
13
|
+
} }), o.icon, o.label] }, o.value))) }));
|
|
14
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type InputProps } from "./Input.js";
|
|
3
|
+
type Base = Omit<InputProps, "value" | "defaultValue" | "onChange" | "type" | "min" | "max" | "step">;
|
|
4
|
+
export interface TimeInputProps extends Base {
|
|
5
|
+
/** "HH:MM" با ارقام لاتین */
|
|
6
|
+
value?: string | null;
|
|
7
|
+
defaultValue?: string | null;
|
|
8
|
+
onChange?: (value: string | null) => void;
|
|
9
|
+
/** گام ↑↓ به دقیقه @default 15 */
|
|
10
|
+
step?: number;
|
|
11
|
+
/** "08:00" */
|
|
12
|
+
min?: string;
|
|
13
|
+
max?: string;
|
|
14
|
+
/** @default "fa" */
|
|
15
|
+
digits?: "fa" | "latin";
|
|
16
|
+
/** @default "ساعت معتبر نیست؛ آن را به شکل ۰۹:۳۰ وارد کنید." */
|
|
17
|
+
invalidMessage?: ReactNode;
|
|
18
|
+
/** @default (min, max) => «ساعت باید بین min و max باشد.» */
|
|
19
|
+
rangeMessage?: (min: string, max: string) => ReactNode;
|
|
20
|
+
}
|
|
21
|
+
/** ساعت ۲۴ساعته با ارقام فارسی: «۹۳۰» یا «۹:۳۰» تایپ کنید، ↑↓ گام به گام */
|
|
22
|
+
export declare const TimeInput: import("react").ForwardRefExoticComponent<TimeInputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useEffect, useState } from "react";
|
|
3
|
+
import { formatTime, parseTime, toFaDigits } from "@kashi-ui/persian";
|
|
4
|
+
import { Input } from "./Input.js";
|
|
5
|
+
const toMin = (t) => t.hours * 60 + t.minutes;
|
|
6
|
+
const fromMin = (m) => ({ hours: Math.floor(m / 60), minutes: m % 60 });
|
|
7
|
+
const Clock = () => (_jsxs("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.7, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [_jsx("circle", { cx: "10", cy: "10", r: "7" }), _jsx("path", { d: "M10 6v4l2.5 2" })] }));
|
|
8
|
+
/** ساعت ۲۴ساعته با ارقام فارسی: «۹۳۰» یا «۹:۳۰» تایپ کنید، ↑↓ گام به گام */
|
|
9
|
+
export const TimeInput = forwardRef(function TimeInput({ value, defaultValue = null, onChange, step = 15, min, max, digits = "fa", invalidMessage = "ساعت معتبر نیست؛ آن را به شکل ۰۹:۳۰ وارد کنید.", rangeMessage = (a, b) => `ساعت باید بین ${a} و ${b} باشد.`, error, name, placeholder, onBlur, onKeyDown, ...rest }, ref) {
|
|
10
|
+
const [inner, setInner] = useState(defaultValue);
|
|
11
|
+
const current = value !== undefined ? value : inner;
|
|
12
|
+
const show = (s) => (s ? (digits === "fa" ? toFaDigits(s) : s) : "");
|
|
13
|
+
const [text, setText] = useState(show(current));
|
|
14
|
+
const [invalid, setInvalid] = useState(false);
|
|
15
|
+
useEffect(() => setText(show(current)), [current, digits]);
|
|
16
|
+
const lo = min ? toMin(parseTime(min)) : 0;
|
|
17
|
+
const hi = max ? toMin(parseTime(max)) : 24 * 60 - 1;
|
|
18
|
+
const commit = (t) => {
|
|
19
|
+
const v = t ? formatTime(fromMin(Math.min(hi, Math.max(lo, toMin(t))))) : null;
|
|
20
|
+
if (value === undefined)
|
|
21
|
+
setInner(v);
|
|
22
|
+
setText(show(v));
|
|
23
|
+
setInvalid(false);
|
|
24
|
+
if (v !== current)
|
|
25
|
+
onChange?.(v);
|
|
26
|
+
};
|
|
27
|
+
return (_jsxs(_Fragment, { children: [_jsx(Input, { ref: ref, type: "text", inputMode: "numeric", dir: "ltr", autoComplete: "off", placeholder: placeholder ?? (digits === "fa" ? "۰۹:۳۰" : "09:30"), value: text, addonEnd: _jsx(Clock, {}), error: error ?? (invalid === "range" ? rangeMessage(show(formatTime(fromMin(lo))), show(formatTime(fromMin(hi)))) : invalid ? invalidMessage : undefined), onChange: (e) => setText(e.target.value), onBlur: (e) => {
|
|
28
|
+
const t = e.target.value.trim();
|
|
29
|
+
if (!t)
|
|
30
|
+
commit(null);
|
|
31
|
+
else {
|
|
32
|
+
const p = parseTime(t);
|
|
33
|
+
if (!p)
|
|
34
|
+
setInvalid("format");
|
|
35
|
+
else if (toMin(p) < lo || toMin(p) > hi)
|
|
36
|
+
setInvalid("range");
|
|
37
|
+
else
|
|
38
|
+
commit(p);
|
|
39
|
+
}
|
|
40
|
+
onBlur?.(e);
|
|
41
|
+
}, onKeyDown: (e) => {
|
|
42
|
+
if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
|
43
|
+
e.preventDefault();
|
|
44
|
+
const base = parseTime(text) ?? parseTime(current ?? "") ?? fromMin(lo);
|
|
45
|
+
const m = toMin(base);
|
|
46
|
+
// به نزدیکترین گام بعدی یا قبلی میپرد
|
|
47
|
+
const next = e.key === "ArrowUp" ? Math.floor(m / step) * step + step : Math.ceil(m / step) * step - step;
|
|
48
|
+
commit(fromMin(Math.min(hi, Math.max(lo, next))));
|
|
49
|
+
}
|
|
50
|
+
onKeyDown?.(e);
|
|
51
|
+
}, ...rest }), name && _jsx("input", { type: "hidden", name: name, value: current ?? "" })] }));
|
|
52
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export interface TreeNode {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
icon?: ReactNode;
|
|
6
|
+
/** متن کوچک انتهای ردیف، مثل تعداد یا حجم */
|
|
7
|
+
meta?: ReactNode;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
children?: TreeNode[];
|
|
10
|
+
}
|
|
11
|
+
export interface TreeViewProps {
|
|
12
|
+
items: TreeNode[];
|
|
13
|
+
selected?: string | null;
|
|
14
|
+
defaultSelected?: string | null;
|
|
15
|
+
onSelect?: (id: string, node: TreeNode) => void;
|
|
16
|
+
expanded?: string[];
|
|
17
|
+
defaultExpanded?: string[];
|
|
18
|
+
onExpandedChange?: (ids: string[]) => void;
|
|
19
|
+
"aria-label"?: string;
|
|
20
|
+
className?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* درخت پوشهها یا دستهبندیها با الگوی Tree در WAI-ARIA:
|
|
24
|
+
* ↑↓ حرکت، → و ← (در RTL برعکس) باز و بسته کردن، Home/End، Enter یا Space انتخاب.
|
|
25
|
+
*/
|
|
26
|
+
export declare function TreeView({ items, selected, defaultSelected, onSelect, expanded, defaultExpanded, onExpandedChange, "aria-label": ariaLabel, className }: TreeViewProps): import("react").JSX.Element;
|
package/dist/TreeView.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useState } from "react";
|
|
3
|
+
import { cx } from "./cx.js";
|
|
4
|
+
const Chevron = () => _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: "m8 5 5 5-5 5" }) });
|
|
5
|
+
/**
|
|
6
|
+
* درخت پوشهها یا دستهبندیها با الگوی Tree در WAI-ARIA:
|
|
7
|
+
* ↑↓ حرکت، → و ← (در RTL برعکس) باز و بسته کردن، Home/End، Enter یا Space انتخاب.
|
|
8
|
+
*/
|
|
9
|
+
export function TreeView({ items, selected, defaultSelected = null, onSelect, expanded, defaultExpanded = [], onExpandedChange, "aria-label": ariaLabel, className }) {
|
|
10
|
+
const [innerSel, setInnerSel] = useState(defaultSelected);
|
|
11
|
+
const [innerExp, setInnerExp] = useState(defaultExpanded);
|
|
12
|
+
const sel = selected !== undefined ? selected : innerSel;
|
|
13
|
+
const exp = expanded ?? innerExp;
|
|
14
|
+
const [focusId, setFocusId] = useState(null);
|
|
15
|
+
const root = useRef(null);
|
|
16
|
+
// ردیفهای قابلمشاهده به ترتیب، برای پیمایش با کیبورد
|
|
17
|
+
const visible = [];
|
|
18
|
+
const walk = (nodes, level, parent) => {
|
|
19
|
+
for (const n of nodes) {
|
|
20
|
+
visible.push({ node: n, level, parent });
|
|
21
|
+
if (n.children?.length && exp.includes(n.id))
|
|
22
|
+
walk(n.children, level + 1, n.id);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
walk(items, 1, null);
|
|
26
|
+
const current = focusId && visible.some((v) => v.node.id === focusId) ? focusId : sel && visible.some((v) => v.node.id === sel) ? sel : visible[0]?.node.id;
|
|
27
|
+
const setExp = (ids) => {
|
|
28
|
+
if (expanded === undefined)
|
|
29
|
+
setInnerExp(ids);
|
|
30
|
+
onExpandedChange?.(ids);
|
|
31
|
+
};
|
|
32
|
+
const toggle = (id, open = !exp.includes(id)) => setExp(open ? [...new Set([...exp, id])] : exp.filter((x) => x !== id));
|
|
33
|
+
const choose = (n) => {
|
|
34
|
+
if (n.disabled)
|
|
35
|
+
return;
|
|
36
|
+
if (selected === undefined)
|
|
37
|
+
setInnerSel(n.id);
|
|
38
|
+
onSelect?.(n.id, n);
|
|
39
|
+
};
|
|
40
|
+
const focus = (id) => {
|
|
41
|
+
setFocusId(id);
|
|
42
|
+
root.current?.querySelector(`[data-id="${CSS.escape(id)}"]`)?.focus();
|
|
43
|
+
};
|
|
44
|
+
const onKeyDown = (e) => {
|
|
45
|
+
const i = visible.findIndex((v) => v.node.id === current);
|
|
46
|
+
const v = visible[i];
|
|
47
|
+
if (!v)
|
|
48
|
+
return;
|
|
49
|
+
const rtl = getComputedStyle(e.currentTarget).direction === "rtl";
|
|
50
|
+
const inKey = rtl ? "ArrowLeft" : "ArrowRight";
|
|
51
|
+
const outKey = rtl ? "ArrowRight" : "ArrowLeft";
|
|
52
|
+
const hasKids = !!v.node.children?.length;
|
|
53
|
+
const open = exp.includes(v.node.id);
|
|
54
|
+
let handled = true;
|
|
55
|
+
if (e.key === "ArrowDown")
|
|
56
|
+
visible[i + 1] && focus(visible[i + 1].node.id);
|
|
57
|
+
else if (e.key === "ArrowUp")
|
|
58
|
+
visible[i - 1] && focus(visible[i - 1].node.id);
|
|
59
|
+
else if (e.key === "Home")
|
|
60
|
+
focus(visible[0].node.id);
|
|
61
|
+
else if (e.key === "End")
|
|
62
|
+
focus(visible[visible.length - 1].node.id);
|
|
63
|
+
else if (e.key === inKey) {
|
|
64
|
+
if (hasKids && !open)
|
|
65
|
+
toggle(v.node.id, true);
|
|
66
|
+
else if (hasKids)
|
|
67
|
+
focus(v.node.children[0].id);
|
|
68
|
+
}
|
|
69
|
+
else if (e.key === outKey) {
|
|
70
|
+
if (hasKids && open)
|
|
71
|
+
toggle(v.node.id, false);
|
|
72
|
+
else if (v.parent)
|
|
73
|
+
focus(v.parent);
|
|
74
|
+
}
|
|
75
|
+
else if (e.key === "Enter" || e.key === " ")
|
|
76
|
+
choose(v.node);
|
|
77
|
+
else
|
|
78
|
+
handled = false;
|
|
79
|
+
if (handled)
|
|
80
|
+
e.preventDefault();
|
|
81
|
+
};
|
|
82
|
+
const render = (nodes, level) => nodes.map((n) => {
|
|
83
|
+
const hasKids = !!n.children?.length;
|
|
84
|
+
const open = exp.includes(n.id);
|
|
85
|
+
return (_jsxs("li", { role: "treeitem", "data-id": n.id, className: "k-tree__item", "aria-level": level, "aria-expanded": hasKids ? open : undefined, "aria-selected": sel === n.id, "aria-disabled": n.disabled || undefined, tabIndex: current === n.id ? 0 : -1, onFocus: (e) => {
|
|
86
|
+
if (e.target === e.currentTarget)
|
|
87
|
+
setFocusId(n.id);
|
|
88
|
+
}, children: [_jsxs("div", { className: "k-tree__row", onClick: () => {
|
|
89
|
+
if (hasKids)
|
|
90
|
+
toggle(n.id);
|
|
91
|
+
choose(n);
|
|
92
|
+
focus(n.id);
|
|
93
|
+
}, children: [hasKids ? _jsx("span", { className: "k-tree__toggle", "aria-hidden": "true", children: _jsx(Chevron, {}) }) : _jsx("span", { className: "k-tree__spacer" }), n.icon && _jsx("span", { className: "k-tree__icon", "aria-hidden": "true", children: n.icon }), _jsx("span", { className: "k-tree__label", children: n.label }), n.meta && _jsx("span", { className: "k-tree__meta", children: n.meta })] }), hasKids && open && _jsx("ul", { role: "group", children: render(n.children, level + 1) })] }, n.id));
|
|
94
|
+
});
|
|
95
|
+
return (_jsx("ul", { ref: root, role: "tree", "aria-label": ariaLabel, className: cx("k-tree", className), onKeyDown: onKeyDown, children: render(items, 1) }));
|
|
96
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -84,3 +84,31 @@ export { Timeline } from "./Timeline.js";
|
|
|
84
84
|
export type { TimelineItem, TimelineProps } from "./Timeline.js";
|
|
85
85
|
export { SideNav } from "./SideNav.js";
|
|
86
86
|
export type { SideNavItem, SideNavSection, SideNavProps } from "./SideNav.js";
|
|
87
|
+
export { SegmentedControl } from "./SegmentedControl.js";
|
|
88
|
+
export type { SegmentedOption, SegmentedControlProps } from "./SegmentedControl.js";
|
|
89
|
+
export { CopyButton } from "./CopyButton.js";
|
|
90
|
+
export type { CopyButtonProps } from "./CopyButton.js";
|
|
91
|
+
export { Banner } from "./Banner.js";
|
|
92
|
+
export type { BannerProps } from "./Banner.js";
|
|
93
|
+
export { Rating } from "./Rating.js";
|
|
94
|
+
export type { RatingProps } from "./Rating.js";
|
|
95
|
+
export { TimeInput } from "./TimeInput.js";
|
|
96
|
+
export type { TimeInputProps } from "./TimeInput.js";
|
|
97
|
+
export { PostalCodeInput } from "./PostalCodeInput.js";
|
|
98
|
+
export type { PostalCodeInputProps } from "./PostalCodeInput.js";
|
|
99
|
+
export { PlateInput } from "./PlateInput.js";
|
|
100
|
+
export type { PlateInputProps } from "./PlateInput.js";
|
|
101
|
+
export { TreeView } from "./TreeView.js";
|
|
102
|
+
export type { TreeNode, TreeViewProps } from "./TreeView.js";
|
|
103
|
+
export { ButtonGroup } from "./ButtonGroup.js";
|
|
104
|
+
export type { ButtonGroupProps } from "./ButtonGroup.js";
|
|
105
|
+
export { ChipGroup } from "./ChipGroup.js";
|
|
106
|
+
export type { ChipOption, ChipGroupProps } from "./ChipGroup.js";
|
|
107
|
+
export { PasswordStrength, defaultPasswordRules } from "./PasswordStrength.js";
|
|
108
|
+
export type { PasswordRule, PasswordStrengthProps } from "./PasswordStrength.js";
|
|
109
|
+
export { Countdown } from "./Countdown.js";
|
|
110
|
+
export type { CountdownProps } from "./Countdown.js";
|
|
111
|
+
export { MonthPicker } from "./MonthPicker.js";
|
|
112
|
+
export type { JalaliMonth, MonthPickerProps } from "./MonthPicker.js";
|
|
113
|
+
export { LandlineInput } from "./LandlineInput.js";
|
|
114
|
+
export type { LandlineInputProps } from "./LandlineInput.js";
|
package/dist/index.js
CHANGED
|
@@ -42,3 +42,17 @@ export { DateRangePicker, defaultRangePresets } from "./DateRangePicker.js";
|
|
|
42
42
|
export { StatCard, StatGrid } from "./Stat.js";
|
|
43
43
|
export { Timeline } from "./Timeline.js";
|
|
44
44
|
export { SideNav } from "./SideNav.js";
|
|
45
|
+
export { SegmentedControl } from "./SegmentedControl.js";
|
|
46
|
+
export { CopyButton } from "./CopyButton.js";
|
|
47
|
+
export { Banner } from "./Banner.js";
|
|
48
|
+
export { Rating } from "./Rating.js";
|
|
49
|
+
export { TimeInput } from "./TimeInput.js";
|
|
50
|
+
export { PostalCodeInput } from "./PostalCodeInput.js";
|
|
51
|
+
export { PlateInput } from "./PlateInput.js";
|
|
52
|
+
export { TreeView } from "./TreeView.js";
|
|
53
|
+
export { ButtonGroup } from "./ButtonGroup.js";
|
|
54
|
+
export { ChipGroup } from "./ChipGroup.js";
|
|
55
|
+
export { PasswordStrength, defaultPasswordRules } from "./PasswordStrength.js";
|
|
56
|
+
export { Countdown } from "./Countdown.js";
|
|
57
|
+
export { MonthPicker } from "./MonthPicker.js";
|
|
58
|
+
export { LandlineInput } from "./LandlineInput.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kashi-ui/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "کامپوننتهای React دیزاینسیستم کاشی",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"test": "node --test test/*.test.mjs"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@kashi-ui/css": "^0.
|
|
25
|
+
"@kashi-ui/css": "^0.11.0",
|
|
26
26
|
"react": ">=18"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@kashi-ui/bank-logos": "^0.
|
|
63
|
-
"@kashi-ui/persian": "^0.
|
|
62
|
+
"@kashi-ui/bank-logos": "^0.11.0",
|
|
63
|
+
"@kashi-ui/persian": "^0.11.0"
|
|
64
64
|
}
|
|
65
65
|
}
|