@kashi-ui/react 0.26.0 → 1.1.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.
Files changed (77) hide show
  1. package/dist/ActivityHeatmap.js +12 -8
  2. package/dist/AddressForm.js +8 -4
  3. package/dist/Alert.js +4 -1
  4. package/dist/AppointmentPicker.js +16 -11
  5. package/dist/Avatar.js +8 -11
  6. package/dist/Badge.js +3 -1
  7. package/dist/BankBadge.js +4 -1
  8. package/dist/BankCard.js +7 -4
  9. package/dist/Banner.js +5 -1
  10. package/dist/Breadcrumb.js +5 -1
  11. package/dist/Button.js +4 -1
  12. package/dist/Calendar.js +10 -6
  13. package/dist/CardNumberInput.js +5 -1
  14. package/dist/Carousel.js +5 -4
  15. package/dist/Chart.js +57 -30
  16. package/dist/CitySelect.js +7 -4
  17. package/dist/ColorPicker.d.ts +1 -1
  18. package/dist/ColorPicker.js +22 -17
  19. package/dist/Combobox.js +8 -4
  20. package/dist/CommandPalette.js +6 -3
  21. package/dist/ContextMenu.js +5 -2
  22. package/dist/CopyButton.js +3 -1
  23. package/dist/Countdown.js +6 -3
  24. package/dist/DataTable.js +4 -2
  25. package/dist/DatePicker.js +8 -2
  26. package/dist/DateRangePicker.d.ts +1 -1
  27. package/dist/DateRangePicker.js +16 -10
  28. package/dist/DateTile.js +7 -4
  29. package/dist/Dialog.js +4 -1
  30. package/dist/Field.js +3 -1
  31. package/dist/FileUpload.d.ts +3 -2
  32. package/dist/FileUpload.js +15 -11
  33. package/dist/IbanInput.js +4 -1
  34. package/dist/InlineEdit.js +5 -3
  35. package/dist/Input.js +3 -1
  36. package/dist/IranMap.js +5 -3
  37. package/dist/KashiProvider.d.ts +28 -0
  38. package/dist/KashiProvider.js +27 -0
  39. package/dist/KeyboardFixInput.js +3 -1
  40. package/dist/LandlineInput.js +5 -1
  41. package/dist/LegalIdInput.js +5 -1
  42. package/dist/Meter.js +7 -4
  43. package/dist/MobileInput.js +7 -3
  44. package/dist/Money.js +10 -6
  45. package/dist/MonthPicker.js +8 -4
  46. package/dist/MultiSelect.js +7 -5
  47. package/dist/NationalIdInput.js +5 -1
  48. package/dist/NumberInput.js +5 -2
  49. package/dist/OtpInput.js +4 -1
  50. package/dist/Pagination.js +6 -3
  51. package/dist/PasswordStrength.d.ts +1 -0
  52. package/dist/PasswordStrength.js +15 -9
  53. package/dist/PaymentReceipt.js +10 -8
  54. package/dist/PersianInput.js +3 -1
  55. package/dist/PersianTextarea.js +9 -7
  56. package/dist/PlateInput.js +6 -3
  57. package/dist/PostalCodeInput.js +5 -1
  58. package/dist/PriceInput.js +9 -3
  59. package/dist/Progress.js +6 -3
  60. package/dist/ProvinceSelect.js +5 -3
  61. package/dist/Rating.js +6 -3
  62. package/dist/RelativeTime.js +5 -2
  63. package/dist/SideNav.js +4 -1
  64. package/dist/Slider.js +5 -2
  65. package/dist/Splitter.js +5 -3
  66. package/dist/Stat.js +4 -3
  67. package/dist/Stepper.js +6 -4
  68. package/dist/TagInput.js +4 -2
  69. package/dist/TimeInput.js +6 -1
  70. package/dist/Timeline.js +1 -1
  71. package/dist/Toast.js +5 -1
  72. package/dist/Tour.js +3 -2
  73. package/dist/index.d.ts +4 -0
  74. package/dist/index.js +2 -0
  75. package/dist/utils.d.ts +5 -0
  76. package/dist/utils.js +11 -0
  77. package/package.json +4 -4
package/dist/TagInput.js CHANGED
@@ -1,10 +1,11 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { forwardRef, useId, useRef, useState } from "react";
4
- import { normalizePersian, toFaDigits } from "@kashi-ui/persian";
4
+ import { normalizePersian } from "@kashi-ui/persian";
5
5
  import { Badge } from "./Badge.js";
6
6
  import { Field, describedBy } from "./Field.js";
7
7
  import { mergeRefs } from "./utils.js";
8
+ import { useKashi } from "./KashiProvider.js";
8
9
  /** ورود چند مقدار، مثل مهارت‌ها یا ایمیل‌ها؛ Enter یا ویرگول (, یا ،) ثبت می‌کند و Backspace آخری را حذف می‌کند */
9
10
  export const TagInput = forwardRef(function TagInput({ label, hint, error, value, defaultValue = [], onChange, placeholder, separators = ["Enter", ",", "،"], validate, max, allowDuplicates = false, tone = "brand", disabled, name, id, className, labels = {}, }, ref) {
10
11
  const autoId = useId();
@@ -15,7 +16,8 @@ export const TagInput = forwardRef(function TagInput({ label, hint, error, value
15
16
  const [localError, setLocalError] = useState();
16
17
  const [announce, setAnnounce] = useState("");
17
18
  const inputRef = useRef(null);
18
- const { added = (t) => `${t} اضافه شد`, removed = (t) => `${t} حذف شد`, remove = (t) => `حذف ${t}`, max: maxMsg = (n) => `حداکثر ${toFaDigits(n)} مورد`, duplicate = "این مورد قبلاً اضافه شده است.", } = labels;
19
+ const { messages: M, n: N } = useKashi();
20
+ const { added = M.common.added, removed = M.common.removed, remove = M.common.remove, max: maxMsg = (x) => M.common.max(N(x)), duplicate = M.tagInput.duplicate, } = labels;
19
21
  const set = (next) => {
20
22
  if (value === undefined)
21
23
  setInner(next);
package/dist/TimeInput.js CHANGED
@@ -3,11 +3,16 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
3
3
  import { forwardRef, useEffect, useState } from "react";
4
4
  import { formatTime, parseTime, toFaDigits } from "@kashi-ui/persian";
5
5
  import { Input } from "./Input.js";
6
+ import { useKashi } from "./KashiProvider.js";
6
7
  const toMin = (t) => t.hours * 60 + t.minutes;
7
8
  const fromMin = (m) => ({ hours: Math.floor(m / 60), minutes: m % 60 });
8
9
  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" })] }));
9
10
  /** ساعت ۲۴ساعته با ارقام فارسی: «۹۳۰» یا «۹:۳۰» تایپ کنید، ↑↓ گام به گام */
10
- 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) {
11
+ export const TimeInput = forwardRef(function TimeInput({ value, defaultValue = null, onChange, step = 15, min, max, digits, invalidMessage, rangeMessage, error, name, placeholder, onBlur, onKeyDown, ...rest }, ref) {
12
+ const { messages: M, digits: D, locale } = useKashi();
13
+ digits ?? (digits = D);
14
+ invalidMessage ?? (invalidMessage = M.invalid.time);
15
+ rangeMessage ?? (rangeMessage = M.invalid.timeRange);
11
16
  const [inner, setInner] = useState(defaultValue);
12
17
  const current = value !== undefined ? value : inner;
13
18
  const show = (s) => (s ? (digits === "fa" ? toFaDigits(s) : s) : "");
package/dist/Timeline.js CHANGED
@@ -4,6 +4,6 @@ import { cx } from "./cx.js";
4
4
  import { RelativeTime } from "./RelativeTime.js";
5
5
  const Dot = () => _jsx("svg", { viewBox: "0 0 20 20", "aria-hidden": "true", children: _jsx("circle", { cx: "10", cy: "10", r: "3", fill: "currentColor" }) });
6
6
  /** خط زمانی رویدادها و فعالیت‌ها، به ترتیب داده‌شده */
7
- export function Timeline({ items, digits = "fa", className, ...rest }) {
7
+ export function Timeline({ items, digits, className, ...rest }) {
8
8
  return (_jsx("ol", { className: cx("k-timeline", className), ...rest, children: items.map((it, i) => (_jsxs("li", { className: "k-timeline__item", "data-tone": it.tone && it.tone !== "neutral" ? it.tone : undefined, children: [_jsx("span", { className: "k-timeline__marker", "aria-hidden": "true", children: it.icon ?? _jsx(Dot, {}) }), _jsxs("div", { className: "k-timeline__body", children: [_jsx("p", { className: "k-timeline__title", children: it.title }), it.time !== undefined && (_jsx("span", { className: "k-timeline__time", children: it.time instanceof Date ? _jsx(RelativeTime, { date: it.time, digits: digits }) : it.time })), it.content && _jsx("div", { className: "k-timeline__content", children: it.content })] })] }, it.id ?? i))) }));
9
9
  }
package/dist/Toast.js CHANGED
@@ -4,6 +4,7 @@ import { useEffect, useId, useRef, useState, useSyncExternalStore } from "react"
4
4
  import { isDev } from "./utils.js";
5
5
  import { cx } from "./cx.js";
6
6
  import { CloseIcon, ErrorIcon, InfoIcon, SuccessIcon, WarningIcon } from "./icons.js";
7
+ import { useKashi } from "./KashiProvider.js";
7
8
  // مخزن سادهٔ سراسری؛ هر جای برنامه می‌تواند toast() را صدا بزند
8
9
  let items = [];
9
10
  let nextId = 1;
@@ -88,7 +89,10 @@ const subscribeToasters = (l) => {
88
89
  return () => toasterListeners.delete(l);
89
90
  };
90
91
  /** محل نمایش اعلان‌ها؛ یک بار در ریشهٔ برنامه قرار دهید */
91
- export function Toaster({ placement, position, max = 5, label = "اعلان‌ها", closeLabel = "بستن اعلان" }) {
92
+ export function Toaster({ placement, position, max = 5, label, closeLabel }) {
93
+ const { messages: M } = useKashi();
94
+ label ?? (label = M.toast.region);
95
+ closeLabel ?? (closeLabel = M.toast.close);
92
96
  const id = useId();
93
97
  const all = useSyncExternalStore(subscribe, () => items, () => items);
94
98
  const active = useSyncExternalStore(subscribeToasters, () => toasters[toasters.length - 1], () => undefined);
package/dist/Tour.js CHANGED
@@ -1,14 +1,15 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { useEffect, useId, useLayoutEffect, useRef, useState } from "react";
4
- import { toFaDigits } from "@kashi-ui/persian";
4
+ import { useKashi } from "./KashiProvider.js";
5
5
  /**
6
6
  * راهنمای قدم‌به‌قدم برای آشنایی با محصول: بخش هر مرحله روشن و بقیه کم‌رنگ می‌شود.
7
7
  * Esc می‌بندد، ←→ بین مرحله‌ها و فوکوس پس از پایان به جای قبلی برمی‌گردد.
8
8
  */
9
9
  export function Tour({ steps, open, onOpenChange, onFinish, labels = {} }) {
10
10
  const id = useId();
11
- const { next = "بعدی", prev = "قبلی", done = "تمام", skip = "رد کردن", step: stepLabel = (n, t) => `مرحلهٔ ${toFaDigits(n)} از ${toFaDigits(t)}` } = labels;
11
+ const { messages: M, n: N } = useKashi();
12
+ const { next = M.common.next, prev = M.common.prev, done = M.tour.done, skip = M.tour.skip, step: stepLabel = (a, t) => M.tour.step(N(a), N(t)) } = labels;
12
13
  const [i, setI] = useState(0);
13
14
  const [rect, setRect] = useState(null);
14
15
  const card = useRef(null);
package/dist/index.d.ts CHANGED
@@ -159,3 +159,7 @@ export { PaymentReceipt } from "./PaymentReceipt.js";
159
159
  export type { PaymentReceiptProps, ReceiptStatus } from "./PaymentReceipt.js";
160
160
  export { PersianInput, PERSIAN_INPUT_LABELS } from "./PersianInput.js";
161
161
  export type { PersianInputKind, PersianInputKinds, PersianInputProps } from "./PersianInput.js";
162
+ export { KashiProvider, useKashi } from "./KashiProvider.js";
163
+ export type { KashiProviderProps } from "./KashiProvider.js";
164
+ export { faMessages, enMessages } from "@kashi-ui/persian";
165
+ export type { KashiMessages, KashiMessagesInput, KashiLocale } from "@kashi-ui/persian";
package/dist/index.js CHANGED
@@ -80,3 +80,5 @@ export { BankCard } from "./BankCard.js";
80
80
  export { DateTile } from "./DateTile.js";
81
81
  export { PaymentReceipt } from "./PaymentReceipt.js";
82
82
  export { PersianInput, PERSIAN_INPUT_LABELS } from "./PersianInput.js";
83
+ export { KashiProvider, useKashi } from "./KashiProvider.js";
84
+ export { faMessages, enMessages } from "@kashi-ui/persian";
package/dist/utils.d.ts CHANGED
@@ -5,3 +5,8 @@ export declare function mergeRefs<T>(...refs: Array<Ref<T> | undefined>): RefCal
5
5
  export declare function isDev(): boolean;
6
6
  /** useLayoutEffect در مرورگر، useEffect در سرور؛ تا در Next.js و رندر سمت سرور هشدار ندهد */
7
7
  export declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
8
+ /**
9
+ * هشدار یک‌باره برای قابلیت منسوخ، فقط در حالت توسعه (سیاست تغییرات: /docs/versioning/).
10
+ * deprecate("Button.kind", "prop ‏kind منسوخ است؛ از variant استفاده کنید. در ۲.۰ حذف می‌شود.")
11
+ */
12
+ export declare function deprecate(id: string, message: string): void;
package/dist/utils.js CHANGED
@@ -16,3 +16,14 @@ export function isDev() {
16
16
  }
17
17
  /** useLayoutEffect در مرورگر، useEffect در سرور؛ تا در Next.js و رندر سمت سرور هشدار ندهد */
18
18
  export const useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect;
19
+ const deprecations = new Set();
20
+ /**
21
+ * هشدار یک‌باره برای قابلیت منسوخ، فقط در حالت توسعه (سیاست تغییرات: /docs/versioning/).
22
+ * deprecate("Button.kind", "prop ‏kind منسوخ است؛ از variant استفاده کنید. در ۲.۰ حذف می‌شود.")
23
+ */
24
+ export function deprecate(id, message) {
25
+ if (!isDev() || deprecations.has(id))
26
+ return;
27
+ deprecations.add(id);
28
+ console.warn(`[kashi] منسوخ: ${message}`);
29
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kashi-ui/react",
3
- "version": "0.26.0",
3
+ "version": "1.1.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.26.0",
25
+ "@kashi-ui/css": "^1.1.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.26.0",
63
- "@kashi-ui/persian": "^0.26.0"
62
+ "@kashi-ui/bank-logos": "^1.1.0",
63
+ "@kashi-ui/persian": "^1.1.0"
64
64
  }
65
65
  }