@rockshin/tao-ui 0.0.44 → 0.0.46

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 (152) hide show
  1. package/README.md +9 -1
  2. package/component-manifest.json +38 -4
  3. package/dist/components/alert/alert.js +20 -17
  4. package/dist/components/auto-complete/auto-complete.js +12 -3
  5. package/dist/components/avatar/avatar.js +2 -1
  6. package/dist/components/breadcrumb/breadcrumb.css +4 -0
  7. package/dist/components/breadcrumb/breadcrumb.js +82 -77
  8. package/dist/components/calendar/calendar.d.ts +1 -1
  9. package/dist/components/calendar/calendar.js +51 -33
  10. package/dist/components/card/card-tabs.js +204 -182
  11. package/dist/components/card/card.js +1 -1
  12. package/dist/components/carousel/carousel.js +11 -5
  13. package/dist/components/cascader/cascader.js +16 -4
  14. package/dist/components/collapse/collapse.css +8 -0
  15. package/dist/components/color-picker/color-picker.js +273 -269
  16. package/dist/components/context-menu/context-menu.d.ts +2 -1
  17. package/dist/components/context-menu/context-menu.js +57 -44
  18. package/dist/components/date-picker/calendar/calendar-grid.js +13 -6
  19. package/dist/components/date-picker/calendar/use-calendar.d.ts +2 -2
  20. package/dist/components/date-picker/calendar/use-calendar.js +2 -3
  21. package/dist/components/date-picker/date-localization.d.ts +3 -0
  22. package/dist/components/date-picker/date-localization.js +76 -0
  23. package/dist/components/date-picker/date-picker.css +4 -0
  24. package/dist/components/date-picker/date-picker.d.ts +1 -0
  25. package/dist/components/date-picker/date-picker.js +48 -30
  26. package/dist/components/date-picker/range-picker.d.ts +1 -0
  27. package/dist/components/date-picker/range-picker.js +41 -23
  28. package/dist/components/drawer/drawer.d.ts +2 -1
  29. package/dist/components/drawer/drawer.js +32 -20
  30. package/dist/components/dropdown/dropdown.d.ts +1 -0
  31. package/dist/components/dropdown/dropdown.js +160 -143
  32. package/dist/components/float-button/float-button.js +3 -2
  33. package/dist/components/form/form.js +88 -103
  34. package/dist/components/image/image.js +202 -137
  35. package/dist/components/list/list-pagination.js +148 -147
  36. package/dist/components/mentions/mentions.js +6 -2
  37. package/dist/components/modal/confirm-dialog.js +4 -2
  38. package/dist/components/modal/modal.d.ts +2 -1
  39. package/dist/components/modal/modal.js +387 -375
  40. package/dist/components/pagination/pagination.css +4 -0
  41. package/dist/components/pagination/pagination.js +115 -110
  42. package/dist/components/popconfirm/popconfirm.js +109 -107
  43. package/dist/components/popover/popover.d.ts +2 -1
  44. package/dist/components/popover/popover.js +185 -176
  45. package/dist/components/qr-code/qr-code.js +22 -21
  46. package/dist/components/rate/rate.js +114 -88
  47. package/dist/components/scroll-area/scroll-area.js +132 -120
  48. package/dist/components/segmented/segmented.js +52 -29
  49. package/dist/components/select/mobile-select.d.ts +3 -2
  50. package/dist/components/select/mobile-select.js +54 -48
  51. package/dist/components/select/select-types.d.ts +1 -0
  52. package/dist/components/select/select.js +19 -6
  53. package/dist/components/slider/slider.js +136 -133
  54. package/dist/components/sonner/sonner.js +10 -10
  55. package/dist/components/spinner/spinner.js +1 -1
  56. package/dist/components/splitter/splitter.css +4 -0
  57. package/dist/components/splitter/splitter.js +29 -24
  58. package/dist/components/statistic/statistic.d.ts +2 -0
  59. package/dist/components/statistic/statistic.js +203 -187
  60. package/dist/components/table/table-filter.js +61 -52
  61. package/dist/components/table/table-icons.js +3 -1
  62. package/dist/components/table/table.css +29 -11
  63. package/dist/components/table/table.d.ts +1 -1
  64. package/dist/components/table/table.js +384 -547
  65. package/dist/components/tabs/tabs.js +3 -2
  66. package/dist/components/tag/tag.js +22 -19
  67. package/dist/components/time-picker/time-picker.d.ts +0 -1
  68. package/dist/components/time-picker/time-picker.js +160 -103
  69. package/dist/components/tooltip/tooltip.d.ts +2 -1
  70. package/dist/components/tooltip/tooltip.js +82 -71
  71. package/dist/components/transfer/transfer-list.js +224 -488
  72. package/dist/components/transfer/transfer-parts.js +14 -4
  73. package/dist/components/transfer/transfer-types.d.ts +1 -0
  74. package/dist/components/transfer/transfer.js +23 -20
  75. package/dist/components/tree/tree-keyboard.d.ts +6 -0
  76. package/dist/components/tree/tree-keyboard.js +27 -0
  77. package/dist/components/tree/tree.js +14 -3
  78. package/dist/components/tree-select/select-engine.d.ts +2 -1
  79. package/dist/components/tree-select/select-engine.js +23 -15
  80. package/dist/components/tree-select/tree-select.js +20 -10
  81. package/dist/components/upload/upload.js +30 -26
  82. package/dist/docs/component-docs.d.ts +13 -2
  83. package/dist/docs/components/headless-input-number.doc.d.ts +5 -0
  84. package/dist/docs/components/headless-input-number.doc.js +7 -0
  85. package/dist/docs/components/input-number.doc.d.ts +5 -0
  86. package/dist/docs/components/input-number.doc.js +7 -0
  87. package/dist/docs/components/statistic.doc.d.ts +5 -0
  88. package/dist/docs/components/statistic.doc.js +7 -0
  89. package/dist/docs/components/tao-provider.doc.d.ts +8 -2
  90. package/dist/docs/components/tao-provider.doc.js +16 -3
  91. package/dist/docs/components/tooltip.doc.d.ts +2 -2
  92. package/dist/entries/provider.d.ts +2 -1
  93. package/dist/entries/provider.js +1 -0
  94. package/dist/index.d.ts +2 -1
  95. package/dist/index.js +1 -0
  96. package/dist/locales/ar-EG.d.ts +3 -0
  97. package/dist/locales/ar-EG.js +199 -0
  98. package/dist/locales/create-locale.d.ts +41 -0
  99. package/dist/locales/create-locale.js +88 -0
  100. package/dist/locales/de-DE.d.ts +3 -0
  101. package/dist/locales/de-DE.js +195 -0
  102. package/dist/locales/en-US.d.ts +2 -0
  103. package/dist/locales/en-US.js +194 -0
  104. package/dist/locales/es-ES.d.ts +3 -0
  105. package/dist/locales/es-ES.js +195 -0
  106. package/dist/locales/fr-FR.d.ts +3 -0
  107. package/dist/locales/fr-FR.js +195 -0
  108. package/dist/locales/hi-IN.d.ts +3 -0
  109. package/dist/locales/hi-IN.js +194 -0
  110. package/dist/locales/id-ID.d.ts +3 -0
  111. package/dist/locales/id-ID.js +194 -0
  112. package/dist/locales/index.d.ts +18 -0
  113. package/dist/locales/index.js +17 -0
  114. package/dist/locales/it-IT.d.ts +3 -0
  115. package/dist/locales/it-IT.js +195 -0
  116. package/dist/locales/ja-JP.d.ts +3 -0
  117. package/dist/locales/ja-JP.js +194 -0
  118. package/dist/locales/ko-KR.d.ts +3 -0
  119. package/dist/locales/ko-KR.js +194 -0
  120. package/dist/locales/pt-BR.d.ts +3 -0
  121. package/dist/locales/pt-BR.js +195 -0
  122. package/dist/locales/ru-RU.d.ts +3 -0
  123. package/dist/locales/ru-RU.js +197 -0
  124. package/dist/locales/th-TH.d.ts +3 -0
  125. package/dist/locales/th-TH.js +194 -0
  126. package/dist/locales/tr-TR.d.ts +3 -0
  127. package/dist/locales/tr-TR.js +194 -0
  128. package/dist/locales/types.d.ts +176 -0
  129. package/dist/locales/types.js +0 -0
  130. package/dist/locales/vi-VN.d.ts +3 -0
  131. package/dist/locales/vi-VN.js +194 -0
  132. package/dist/locales/zh-CN.d.ts +3 -0
  133. package/dist/locales/zh-CN.js +194 -0
  134. package/dist/locales/zh-TW.d.ts +3 -0
  135. package/dist/locales/zh-TW.js +194 -0
  136. package/dist/number-input/format.d.ts +4 -3
  137. package/dist/number-input/format.js +9 -7
  138. package/dist/number-input/locale.d.ts +19 -0
  139. package/dist/number-input/locale.js +44 -0
  140. package/dist/number-input/number-input.js +1 -0
  141. package/dist/number-input/use-number-input.d.ts +2 -0
  142. package/dist/number-input/use-number-input.js +180 -176
  143. package/dist/provider/locale.d.ts +3 -65
  144. package/dist/provider/locale.js +2 -146
  145. package/dist/provider/merge-locale.d.ts +8 -0
  146. package/dist/provider/merge-locale.js +53 -0
  147. package/dist/provider/tao-provider.d.ts +16 -5
  148. package/dist/provider/tao-provider.js +200 -92
  149. package/dist/utils/scroll-left.d.ts +3 -0
  150. package/dist/utils/scroll-left.js +7 -0
  151. package/llms.txt +3 -3
  152. package/package.json +5 -1
@@ -4,6 +4,7 @@ import { type MenuProps, type MenuSemanticPart } from '../menu/menu-render.js';
4
4
  import './context-menu.css';
5
5
  export type ContextMenuSemanticPart = MenuSemanticPart;
6
6
  export interface ContextMenuProps {
7
+ direction?: 'ltr' | 'rtl';
7
8
  menu: MenuProps;
8
9
  /** Element whose right-click (long-press on touch) opens the menu. */
9
10
  children: ReactNode;
@@ -16,4 +17,4 @@ export interface ContextMenuProps {
16
17
  classNames?: SemanticClassNames<ContextMenuSemanticPart>;
17
18
  styles?: SemanticStyles<ContextMenuSemanticPart>;
18
19
  }
19
- export declare function ContextMenu({ menu, children, open, onOpenChange, disabled, className, style, classNames, styles, }: ContextMenuProps): import("react").JSX.Element;
20
+ export declare function ContextMenu({ direction: directionProp, menu, children, open, onOpenChange, disabled, className, style, classNames, styles, }: ContextMenuProps): import("react").JSX.Element;
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { c } from "react-compiler-runtime";
3
- import { TaoPortalScope, useTaoConfig } from "../../provider/tao-provider.js";
3
+ import { TaoPortalScope, useTaoConfig, useTaoDirection } from "../../provider/tao-provider.js";
4
4
  import { cx } from "../../utils/semantic.js";
5
5
  import { useMenuController } from "../menu/menu-render.js";
6
6
  import "./context-menu.css";
@@ -20,8 +20,9 @@ const CM = {
20
20
  ItemIndicator: __rspack_external__radix_ui_react_context_menu_d8b375cc.ItemIndicator
21
21
  };
22
22
  function ContextMenu(t0) {
23
- const $ = c(22);
24
- const { menu, children, open, onOpenChange, disabled, className, style, classNames, styles } = t0;
23
+ const $ = c(27);
24
+ const { direction: directionProp, menu, children, open, onOpenChange, disabled, className, style, classNames, styles } = t0;
25
+ const [direction, directionRef] = useTaoDirection(directionProp, "self");
25
26
  const { size, disabled: ctxDisabled } = useTaoConfig();
26
27
  const resolvedDisabled = disabled ?? ctxDisabled;
27
28
  let t1;
@@ -36,72 +37,84 @@ function ContextMenu(t0) {
36
37
  } else t1 = $[2];
37
38
  const content = useMenuController(menu, CM, t1);
38
39
  let t2;
39
- if ($[3] !== children || $[4] !== resolvedDisabled) {
40
+ if ($[3] !== children || $[4] !== directionRef || $[5] !== resolvedDisabled) {
40
41
  t2 = /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_context_menu_d8b375cc.Trigger, {
42
+ ref: directionRef,
41
43
  disabled: resolvedDisabled,
42
44
  "data-tao-context-menu-trigger": "",
43
45
  children: children
44
46
  });
45
47
  $[3] = children;
46
- $[4] = resolvedDisabled;
47
- $[5] = t2;
48
- } else t2 = $[5];
48
+ $[4] = directionRef;
49
+ $[5] = resolvedDisabled;
50
+ $[6] = t2;
51
+ } else t2 = $[6];
49
52
  const t3 = classNames?.content;
50
53
  let t4;
51
- if ($[6] !== className || $[7] !== t3) {
54
+ if ($[7] !== className || $[8] !== t3) {
52
55
  t4 = cx(t3, className);
53
- $[6] = className;
54
- $[7] = t3;
55
- $[8] = t4;
56
- } else t4 = $[8];
56
+ $[7] = className;
57
+ $[8] = t3;
58
+ $[9] = t4;
59
+ } else t4 = $[9];
57
60
  const t5 = styles?.content;
58
61
  let t6;
59
- if ($[9] !== style || $[10] !== t5) {
62
+ if ($[10] !== style || $[11] !== t5) {
60
63
  t6 = {
61
64
  ...t5,
62
65
  ...style
63
66
  };
64
- $[9] = style;
65
- $[10] = t5;
66
- $[11] = t6;
67
- } else t6 = $[11];
67
+ $[10] = style;
68
+ $[11] = t5;
69
+ $[12] = t6;
70
+ } else t6 = $[12];
68
71
  let t7;
69
- if ($[12] !== content || $[13] !== size || $[14] !== t4 || $[15] !== t6) {
70
- t7 = /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_context_menu_d8b375cc.Portal, {
72
+ if ($[13] !== content || $[14] !== size || $[15] !== t4 || $[16] !== t6) {
73
+ t7 = /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_context_menu_d8b375cc.Content, {
74
+ "data-tao-menu-content": "",
75
+ "data-tao-context-menu": "",
76
+ "data-tao-size": size,
77
+ className: t4,
78
+ style: t6,
79
+ children: content
80
+ });
81
+ $[13] = content;
82
+ $[14] = size;
83
+ $[15] = t4;
84
+ $[16] = t6;
85
+ $[17] = t7;
86
+ } else t7 = $[17];
87
+ let t8;
88
+ if ($[18] !== direction || $[19] !== t7) {
89
+ t8 = /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_context_menu_d8b375cc.Portal, {
71
90
  children: /*#__PURE__*/ jsx(TaoPortalScope, {
72
91
  asChild: true,
73
- children: /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_context_menu_d8b375cc.Content, {
74
- "data-tao-menu-content": "",
75
- "data-tao-context-menu": "",
76
- "data-tao-size": size,
77
- className: t4,
78
- style: t6,
79
- children: content
80
- })
92
+ direction: direction,
93
+ children: t7
81
94
  })
82
95
  });
83
- $[12] = content;
84
- $[13] = size;
85
- $[14] = t4;
86
- $[15] = t6;
87
- $[16] = t7;
88
- } else t7 = $[16];
89
- let t8;
90
- if ($[17] !== onOpenChange || $[18] !== open || $[19] !== t2 || $[20] !== t7) {
91
- t8 = /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_context_menu_d8b375cc.Root, {
96
+ $[18] = direction;
97
+ $[19] = t7;
98
+ $[20] = t8;
99
+ } else t8 = $[20];
100
+ let t9;
101
+ if ($[21] !== direction || $[22] !== onOpenChange || $[23] !== open || $[24] !== t2 || $[25] !== t8) {
102
+ t9 = /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_context_menu_d8b375cc.Root, {
103
+ dir: direction,
92
104
  open: open,
93
105
  onOpenChange: onOpenChange,
94
106
  children: [
95
107
  t2,
96
- t7
108
+ t8
97
109
  ]
98
110
  });
99
- $[17] = onOpenChange;
100
- $[18] = open;
101
- $[19] = t2;
102
- $[20] = t7;
103
- $[21] = t8;
104
- } else t8 = $[21];
105
- return t8;
111
+ $[21] = direction;
112
+ $[22] = onOpenChange;
113
+ $[23] = open;
114
+ $[24] = t2;
115
+ $[25] = t8;
116
+ $[26] = t9;
117
+ } else t9 = $[26];
118
+ return t9;
106
119
  }
107
120
  export { ContextMenu };
@@ -5,7 +5,13 @@ import { useTaoConfig } from "../../../provider/tao-provider.js";
5
5
  import { getCalendarWeeks } from "./use-calendar.js";
6
6
  function CalendarGrid({ viewDate, value, rangeStart, rangeEnd, hoverDate, onSelect, onViewDateChange, onHover, disabledDate, minDate, maxDate, className, style, cellClassName, cellStyle }) {
7
7
  const { locale } = useTaoConfig();
8
- const weeks = getCalendarWeeks(viewDate);
8
+ const weekStartsOn = locale.weekStartsOn ?? 1;
9
+ const weekdayOffset = (weekStartsOn + 6) % 7;
10
+ const weekdays = [
11
+ ...locale.weekdays.slice(weekdayOffset),
12
+ ...locale.weekdays.slice(0, weekdayOffset)
13
+ ];
14
+ const weeks = getCalendarWeeks(viewDate, weekStartsOn);
9
15
  const today = dayjs();
10
16
  const currentMonth = viewDate.month();
11
17
  const isRangeMode = void 0 !== rangeStart;
@@ -65,12 +71,13 @@ function CalendarGrid({ viewDate, value, rangeStart, rangeEnd, hoverDate, onSele
65
71
  };
66
72
  const handleKeyDown = (event, date_4)=>{
67
73
  let next_0;
68
- if ('ArrowLeft' === event.key) next_0 = date_4.subtract(1, 'day');
69
- else if ('ArrowRight' === event.key) next_0 = date_4.add(1, 'day');
74
+ const rtl = 'rtl' === getComputedStyle(event.currentTarget).direction;
75
+ if ('ArrowLeft' === event.key) next_0 = date_4.add(rtl ? 1 : -1, 'day');
76
+ else if ('ArrowRight' === event.key) next_0 = date_4.add(rtl ? -1 : 1, 'day');
70
77
  else if ('ArrowUp' === event.key) next_0 = date_4.subtract(7, 'day');
71
78
  else if ('ArrowDown' === event.key) next_0 = date_4.add(7, 'day');
72
- else if ('Home' === event.key) next_0 = date_4.subtract((date_4.day() + 6) % 7, 'day');
73
- else if ('End' === event.key) next_0 = date_4.add(6 - (date_4.day() + 6) % 7, 'day');
79
+ else if ('Home' === event.key) next_0 = date_4.subtract((date_4.day() - weekStartsOn + 7) % 7, 'day');
80
+ else if ('End' === event.key) next_0 = date_4.add(6 - (date_4.day() - weekStartsOn + 7) % 7, 'day');
74
81
  else if ('PageUp' === event.key) next_0 = date_4.subtract(1, 'month');
75
82
  else if ('PageDown' === event.key) next_0 = date_4.add(1, 'month');
76
83
  if (!next_0) return;
@@ -114,7 +121,7 @@ function CalendarGrid({ viewDate, value, rangeStart, rangeEnd, hoverDate, onSele
114
121
  children: [
115
122
  /*#__PURE__*/ jsx("thead", {
116
123
  children: /*#__PURE__*/ jsx("tr", {
117
- children: locale.weekdays.map((d)=>/*#__PURE__*/ jsx("th", {
124
+ children: weekdays.map((d)=>/*#__PURE__*/ jsx("th", {
118
125
  "data-tao-calendar-weekday": "",
119
126
  children: d
120
127
  }, d))
@@ -1,9 +1,9 @@
1
1
  import type { Dayjs } from 'dayjs';
2
2
  /**
3
3
  * Generate 6×7 matrix of days for a calendar month view.
4
- * Weeks start on Monday. Includes fill days from prev/next month.
4
+ * Includes fill days from prev/next month; legacy callers start on Monday.
5
5
  */
6
- export declare function getCalendarWeeks(viewDate: Dayjs): Dayjs[][];
6
+ export declare function getCalendarWeeks(viewDate: Dayjs, weekStartsOn?: number): Dayjs[][];
7
7
  /**
8
8
  * Generate 12 months for a given year.
9
9
  */
@@ -1,8 +1,7 @@
1
1
  import dayjs from "dayjs";
2
- function getCalendarWeeks(viewDate) {
2
+ function getCalendarWeeks(viewDate, weekStartsOn = 1) {
3
3
  const startOfMonth = viewDate.startOf('month');
4
- const dayOfWeek = startOfMonth.day();
5
- const offset = 0 === dayOfWeek ? 6 : dayOfWeek - 1;
4
+ const offset = (startOfMonth.day() - weekStartsOn + 7) % 7;
6
5
  const start = startOfMonth.subtract(offset, 'day');
7
6
  return Array.from({
8
7
  length: 6
@@ -0,0 +1,3 @@
1
+ import { type Dayjs } from 'dayjs';
2
+ export declare function formatPickerDate(value: Dayjs | null | undefined, format: string, locale: string | undefined): string;
3
+ export declare function parsePickerDate(text: string, format: string, locale: string | undefined, numberLocale?: string): Dayjs;
@@ -0,0 +1,76 @@
1
+ import dayjs from "dayjs";
2
+ import customParseFormat from "dayjs/plugin/customParseFormat";
3
+ import localizedFormat from "dayjs/plugin/localizedFormat";
4
+ import localeData from "dayjs/plugin/localeData";
5
+ import { normalizeDigits, resolveNumberFormat } from "../../number-input/locale.js";
6
+ dayjs.extend(customParseFormat);
7
+ dayjs.extend(localizedFormat);
8
+ dayjs.extend(localeData);
9
+ const withoutDirectionMarks = (text)=>text.replace(/[\u061c\u200e\u200f]/g, '');
10
+ function formatPickerDate(value, format, locale) {
11
+ if (!value) return '';
12
+ return (locale ? value.locale(locale) : value).format(format);
13
+ }
14
+ function parsePickerDate(text, format, locale, numberLocale) {
15
+ const normalized = withoutDirectionMarks(normalizeDigits(text, resolveNumberFormat(numberLocale)));
16
+ const parsed = dayjs(normalized, format, locale, true);
17
+ if (parsed.isValid()) return parsed;
18
+ const reference = locale ? dayjs('2000-01-01').locale(locale) : dayjs('2000-01-01');
19
+ const expanded = withoutDirectionMarks(format.replace(/(\[[^\]]*])|(LTS?|l{1,4}|L{1,4})/g, (token, literal)=>literal ?? reference.localeData().longDateFormat(token)));
20
+ const literalFormat = expanded.replace(/(\[[^\]]*\])|(\P{ASCII}+)/gu, (token, literal)=>literal ?? `[${token}]`);
21
+ const weekdayFormat = literalFormat.replace(/(\[[^\]]*])|(dddd|ddd|dd)/g, (token, literal)=>{
22
+ if (literal) return literal;
23
+ const name = Array.from({
24
+ length: 7
25
+ }, (_, day)=>reference.day(day).format(token)).sort((left, right)=>right.length - left.length).find((candidate)=>normalized.includes(candidate));
26
+ return `[${name}]`;
27
+ });
28
+ let hasMeridiem = false;
29
+ const namedFormat = weekdayFormat.replace(/(\[[^\]]*])|(A|a)/g, (token, literal)=>{
30
+ if (literal) return literal;
31
+ hasMeridiem = true;
32
+ const name = Array.from({
33
+ length: 24
34
+ }, (_, hour)=>reference.hour(hour).format(token)).sort((left, right)=>right.length - left.length).find((candidate)=>normalized.includes(candidate));
35
+ return `[${name}]`;
36
+ });
37
+ const exactResult = (value)=>{
38
+ if (!value.isValid()) return value;
39
+ const candidates = hasMeridiem ? [
40
+ value.hour(value.hour() % 12),
41
+ value.hour(value.hour() % 12 + 12)
42
+ ] : [
43
+ value
44
+ ];
45
+ return candidates.find((candidate)=>withoutDirectionMarks(candidate.format(format)) === normalized) ?? dayjs(0 / 0);
46
+ };
47
+ const monthTokens = [
48
+ ...namedFormat.matchAll(/(\[[^\]]*])|(MMMM|MMM)/g)
49
+ ].map((match)=>match[2]).filter((token)=>void 0 !== token);
50
+ if (0 === monthTokens.length) {
51
+ const parsedWeekday = dayjs(normalized, namedFormat, locale, true);
52
+ return exactResult(parsedWeekday);
53
+ }
54
+ const monthNames = (month, token)=>{
55
+ const date = reference.month(month);
56
+ return [
57
+ date.format(token),
58
+ date.format(`D ${token}`).slice(2)
59
+ ];
60
+ };
61
+ const selected = Array.from({
62
+ length: 12
63
+ }, (_, month)=>monthNames(month, monthTokens[0]).map((name)=>({
64
+ month,
65
+ name
66
+ }))).flat().sort((left, right)=>right.name.length - left.name.length).find(({ name })=>normalized.includes(name));
67
+ if (!selected) return dayjs(0 / 0);
68
+ const numericFormat = namedFormat.replace(/(\[[^\]]*])|(MMMM|MMM)/g, (token, literal)=>{
69
+ if (literal) return literal;
70
+ const name = monthNames(selected.month, token).sort((left, right)=>right.length - left.length).find((candidate)=>normalized.includes(candidate));
71
+ return `[${name}]`;
72
+ });
73
+ const parsedMonth = dayjs(`${normalized} ${String(selected.month + 1).padStart(2, '0')}`, `${numericFormat} MM`, locale, true);
74
+ return exactResult(parsedMonth);
75
+ }
76
+ export { formatPickerDate, parsePickerDate };
@@ -722,3 +722,7 @@ input[data-tao-range-input]::placeholder {
722
722
  }
723
723
  }
724
724
 
725
+ [data-tao-calendar-nav-btn]:dir(rtl) > svg {
726
+ transform: scaleX(-1);
727
+ }
728
+
@@ -7,6 +7,7 @@ import { type PickerRef, type PresetItem, type TimeConfig } from './types.js';
7
7
  export type { PickerRef } from './types.js';
8
8
  export type DatePickerSemanticPart = 'root' | 'input' | 'popup' | 'calendar' | 'cell' | 'footer';
9
9
  export interface DatePickerProps extends Pick<AriaAttributes, 'aria-label' | 'aria-labelledby' | 'aria-describedby' | 'aria-errormessage' | 'aria-invalid' | 'aria-required'> {
10
+ direction?: 'ltr' | 'rtl';
10
11
  id?: string;
11
12
  value?: Dayjs | null;
12
13
  defaultValue?: Dayjs | null;
@@ -1,13 +1,13 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { c } from "react-compiler-runtime";
3
3
  import dayjs from "dayjs";
4
- import customParseFormat from "dayjs/plugin/customParseFormat";
5
4
  import { forwardRef, useCallback, useEffect, useId, useImperativeHandle, useMemo, useRef, useState } from "react";
6
- import { TaoPortalScope, useTaoConfig } from "../../provider/tao-provider.js";
5
+ import { TaoPortalScope, useTaoConfig, useTaoDirection } from "../../provider/tao-provider.js";
7
6
  import { useIsMobile } from "../../utils/breakpoint.js";
8
7
  import { useMobileTitle } from "../../utils/field-label.js";
9
- import { Button } from "../button/button.js";
8
+ import { mergeRefs } from "../../utils/refs.js";
10
9
  import { cx } from "../../utils/semantic.js";
10
+ import { Button } from "../button/button.js";
11
11
  import { Drawer } from "../drawer/drawer.js";
12
12
  import { CalendarGrid } from "./calendar/calendar-grid.js";
13
13
  import { CalendarHeader } from "./calendar/calendar-header.js";
@@ -16,9 +16,9 @@ import { TimePanel } from "./calendar/time-panel.js";
16
16
  import { YearGrid } from "./calendar/year-grid.js";
17
17
  import "./date-picker.css";
18
18
  import { Presets } from "./presets.js";
19
+ import { formatPickerDate, parsePickerDate } from "./date-localization.js";
19
20
  import { getDefaultFormat } from "./types.js";
20
21
  import * as __rspack_external__radix_ui_react_popover_c8444160 from "@radix-ui/react-popover";
21
- dayjs.extend(customParseFormat);
22
22
  const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
23
23
  const { value, defaultValue, onChange, picker = 'date', showTime, format: formatProp, disabledDate, minDate, maxDate, presets, placeholder, size, variant, disabled, allowClear = true, prefix, suffixIcon, status, mobile, open: controlledOpen, onOpenChange, className, style, classNames, styles } = props;
24
24
  const popupId = useId();
@@ -31,6 +31,10 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
31
31
  const autoMobile = useIsMobile();
32
32
  const isMobile = mobile ?? autoMobile;
33
33
  const mobileTriggerRef = useRef(null);
34
+ const [direction, directionRef] = useTaoDirection(props.direction);
35
+ const mergedMobileRef = useMemo(()=>mergeRefs(mobileTriggerRef, directionRef), [
36
+ directionRef
37
+ ]);
34
38
  const inputRef = useRef(null);
35
39
  useImperativeHandle(ref, ()=>({
36
40
  focus: ()=>(isMobile ? mobileTriggerRef.current : inputRef.current)?.focus(),
@@ -45,11 +49,17 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
45
49
  isMobile
46
50
  ]);
47
51
  const fmt = formatProp ?? getDefaultFormat(picker, showTime);
52
+ const dayjsLocale = ctx.locale.dayjsLocale;
53
+ const numberLocale = ctx.locale.numberLocale;
54
+ const formatValue = useCallback((date)=>formatPickerDate(date, fmt, dayjsLocale), [
55
+ fmt,
56
+ dayjsLocale
57
+ ]);
48
58
  const defaultPlaceholder = placeholder ?? fmt;
49
59
  const drawerTitle = useMobileTitle(props.mobileTitle, showTime ? ctx.locale.dateTime : ctx.locale.selectDate);
50
- const isDateBlocked = useCallback((date)=>{
60
+ const isDateBlocked = useCallback((date_0)=>{
51
61
  const granularity = 'date' === picker ? 'day' : picker;
52
- return !date.isValid() || Boolean(disabledDate?.(date)) || null != minDate && date.isBefore(minDate, granularity) || null != maxDate && date.isAfter(maxDate, granularity);
62
+ return !date_0.isValid() || Boolean(disabledDate?.(date_0)) || null != minDate && date_0.isBefore(minDate, granularity) || null != maxDate && date_0.isAfter(maxDate, granularity);
53
63
  }, [
54
64
  picker,
55
65
  disabledDate,
@@ -67,7 +77,7 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
67
77
  onChange
68
78
  ]);
69
79
  const [internalOpen, setInternalOpen] = useState(false);
70
- const displayValue = resolvedValue ? resolvedValue.format(fmt) : '';
80
+ const displayValue = formatValue(resolvedValue);
71
81
  const [inputValue, setInputValue] = useState(displayValue);
72
82
  const isOpen = controlledOpen ?? internalOpen;
73
83
  const setOpen = useCallback((v)=>{
@@ -102,57 +112,57 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
102
112
  }), [
103
113
  resolvedValue
104
114
  ]);
105
- const handleDateSelect = useCallback((date_0)=>{
106
- let result = date_0;
107
- if (showTime && resolvedValue) result = date_0.hour(resolvedValue.hour()).minute(resolvedValue.minute()).second(resolvedValue.second());
108
- if (showTime) emitChange(result, result.format(fmt));
115
+ const handleDateSelect = useCallback((date_1)=>{
116
+ let result = date_1;
117
+ if (showTime && resolvedValue) result = date_1.hour(resolvedValue.hour()).minute(resolvedValue.minute()).second(resolvedValue.second());
118
+ if (showTime) emitChange(result, formatValue(result));
109
119
  else {
110
- emitChange(result, result.format(fmt));
120
+ emitChange(result, formatValue(result));
111
121
  setOpen(false);
112
122
  }
113
123
  }, [
114
124
  emitChange,
115
- fmt,
125
+ formatValue,
116
126
  showTime,
117
127
  resolvedValue,
118
128
  setOpen
119
129
  ]);
120
- const handleMonthSelect = useCallback((date_1)=>{
130
+ const handleMonthSelect = useCallback((date_2)=>{
121
131
  if ('month' === picker) {
122
- emitChange(date_1, date_1.format(fmt));
132
+ emitChange(date_2, formatValue(date_2));
123
133
  setOpen(false);
124
134
  } else {
125
- setViewDate(date_1);
135
+ setViewDate(date_2);
126
136
  setPanelMode('date');
127
137
  }
128
138
  }, [
129
139
  picker,
130
140
  emitChange,
131
- fmt,
141
+ formatValue,
132
142
  setOpen
133
143
  ]);
134
- const handleYearSelect = useCallback((date_2)=>{
144
+ const handleYearSelect = useCallback((date_3)=>{
135
145
  if ('year' === picker) {
136
- emitChange(date_2, date_2.format(fmt));
146
+ emitChange(date_3, formatValue(date_3));
137
147
  setOpen(false);
138
148
  } else {
139
- setViewDate(date_2);
149
+ setViewDate(date_3);
140
150
  setPanelMode('month' === picker ? 'month' : 'date');
141
151
  }
142
152
  }, [
143
153
  picker,
144
154
  emitChange,
145
- fmt,
155
+ formatValue,
146
156
  setOpen
147
157
  ]);
148
158
  const handleTimeChange = useCallback((h, m, s)=>{
149
159
  const base = resolvedValue ?? dayjs();
150
160
  const result_0 = base.hour(h).minute(m).second(s);
151
- emitChange(result_0, result_0.format(fmt));
161
+ emitChange(result_0, formatValue(result_0));
152
162
  }, [
153
163
  resolvedValue,
154
164
  emitChange,
155
- fmt
165
+ formatValue
156
166
  ]);
157
167
  const handleClear = useCallback((e)=>{
158
168
  e.stopPropagation();
@@ -163,11 +173,11 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
163
173
  const handlePresetSelect = useCallback((val)=>{
164
174
  const d = val;
165
175
  if (isDateBlocked(d)) return;
166
- emitChange(d, d.format(fmt));
176
+ emitChange(d, formatValue(d));
167
177
  setOpen(false);
168
178
  }, [
169
179
  emitChange,
170
- fmt,
180
+ formatValue,
171
181
  setOpen,
172
182
  isDateBlocked
173
183
  ]);
@@ -178,13 +188,13 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
178
188
  ]);
179
189
  const handleNow = useCallback(()=>{
180
190
  const now = dayjs();
181
- emitChange(now, now.format(fmt));
191
+ emitChange(now, formatValue(now));
182
192
  setViewDate(now);
183
193
  setPanelMode('date');
184
194
  setTimeScrollKey((k_0)=>k_0 + 1);
185
195
  }, [
186
196
  emitChange,
187
- fmt
197
+ formatValue
188
198
  ]);
189
199
  const showClearBtn = allowClear && resolvedValue && !resolvedDisabled;
190
200
  const commitInputValue = useCallback(()=>{
@@ -195,9 +205,9 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
195
205
  setOpen(false);
196
206
  return;
197
207
  }
198
- const parsed = dayjs(text, fmt, true);
208
+ const parsed = parsePickerDate(text, fmt, dayjsLocale, numberLocale);
199
209
  if (isDateBlocked(parsed)) return void setInputValue(displayValue);
200
- const formatted = parsed.format(fmt);
210
+ const formatted = formatValue(parsed);
201
211
  setInputValue(isValueControlled ? displayValue : formatted);
202
212
  setViewDate(parsed);
203
213
  if (formatted !== displayValue) emitChange(parsed, formatted);
@@ -205,6 +215,9 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
205
215
  }, [
206
216
  displayValue,
207
217
  fmt,
218
+ dayjsLocale,
219
+ numberLocale,
220
+ formatValue,
208
221
  inputValue,
209
222
  isValueControlled,
210
223
  isDateBlocked,
@@ -373,7 +386,8 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
373
386
  }
374
387
  };
375
388
  const mobileTrigger = /*#__PURE__*/ jsxs("button", {
376
- ref: mobileTriggerRef,
389
+ ref: mergedMobileRef,
390
+ dir: direction,
377
391
  id: props.id,
378
392
  ...controlAria,
379
393
  type: "button",
@@ -407,6 +421,8 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
407
421
  ]
408
422
  });
409
423
  const desktopTrigger = /*#__PURE__*/ jsxs("div", {
424
+ ref: directionRef,
425
+ dir: direction,
410
426
  "data-tao-control": "",
411
427
  "data-tao-picker-trigger": "",
412
428
  onClick: ()=>!resolvedDisabled && setOpen(!isOpen),
@@ -464,6 +480,7 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
464
480
  children: [
465
481
  mobileTrigger,
466
482
  /*#__PURE__*/ jsx(Drawer, {
483
+ direction: direction,
467
484
  open: isOpen,
468
485
  onClose: ()=>setOpen(false),
469
486
  placement: "bottom",
@@ -484,6 +501,7 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
484
501
  /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_popover_c8444160.Portal, {
485
502
  children: /*#__PURE__*/ jsx(TaoPortalScope, {
486
503
  asChild: true,
504
+ direction: direction,
487
505
  children: /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_popover_c8444160.Content, {
488
506
  id: popupId,
489
507
  ref: popupRef,
@@ -7,6 +7,7 @@ import { type PickerRef, type RangePresetItem } from './types.js';
7
7
  type RangeValue = [Dayjs | null, Dayjs | null] | null;
8
8
  export type RangePickerSemanticPart = 'root' | 'input' | 'separator' | 'popup' | 'calendar' | 'cell';
9
9
  export interface RangePickerProps extends Pick<AriaAttributes, 'aria-label' | 'aria-labelledby' | 'aria-describedby' | 'aria-errormessage' | 'aria-invalid' | 'aria-required'> {
10
+ direction?: 'ltr' | 'rtl';
10
11
  id?: string;
11
12
  value?: RangeValue;
12
13
  defaultValue?: [Dayjs | null, Dayjs | null];