@rockshin/tao-ui 0.0.45 → 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 (114) hide show
  1. package/README.md +3 -1
  2. package/component-manifest.json +32 -3
  3. package/dist/components/alert/alert.js +20 -17
  4. package/dist/components/avatar/avatar.js +2 -1
  5. package/dist/components/breadcrumb/breadcrumb.js +81 -77
  6. package/dist/components/calendar/calendar.d.ts +0 -1
  7. package/dist/components/calendar/calendar.js +41 -30
  8. package/dist/components/color-picker/color-picker.js +273 -269
  9. package/dist/components/date-picker/calendar/calendar-grid.js +10 -4
  10. package/dist/components/date-picker/calendar/use-calendar.d.ts +2 -2
  11. package/dist/components/date-picker/calendar/use-calendar.js +2 -3
  12. package/dist/components/date-picker/date-localization.d.ts +3 -0
  13. package/dist/components/date-picker/date-localization.js +76 -0
  14. package/dist/components/date-picker/date-picker.js +35 -27
  15. package/dist/components/date-picker/range-picker.js +28 -20
  16. package/dist/components/dropdown/dropdown.js +21 -20
  17. package/dist/components/float-button/float-button.js +3 -2
  18. package/dist/components/form/form.js +88 -103
  19. package/dist/components/image/image.js +202 -137
  20. package/dist/components/list/list-pagination.js +148 -147
  21. package/dist/components/modal/confirm-dialog.js +4 -2
  22. package/dist/components/modal/modal.js +385 -383
  23. package/dist/components/pagination/pagination.js +115 -110
  24. package/dist/components/popconfirm/popconfirm.js +109 -107
  25. package/dist/components/qr-code/qr-code.js +22 -21
  26. package/dist/components/scroll-area/scroll-area.js +41 -38
  27. package/dist/components/select/mobile-select.d.ts +1 -1
  28. package/dist/components/select/mobile-select.js +2 -1
  29. package/dist/components/sonner/sonner.js +10 -10
  30. package/dist/components/spinner/spinner.js +1 -1
  31. package/dist/components/splitter/splitter.js +24 -21
  32. package/dist/components/statistic/statistic.d.ts +2 -0
  33. package/dist/components/statistic/statistic.js +203 -187
  34. package/dist/components/table/table-filter.js +61 -52
  35. package/dist/components/table/table-icons.js +3 -1
  36. package/dist/components/table/table.d.ts +1 -1
  37. package/dist/components/table/table.js +5 -4
  38. package/dist/components/tag/tag.js +22 -19
  39. package/dist/components/time-picker/time-picker.d.ts +0 -1
  40. package/dist/components/time-picker/time-picker.js +139 -96
  41. package/dist/components/transfer/transfer-list.js +224 -488
  42. package/dist/components/transfer/transfer-parts.js +2 -2
  43. package/dist/components/transfer/transfer-types.d.ts +1 -0
  44. package/dist/components/transfer/transfer.js +13 -16
  45. package/dist/components/upload/upload.js +30 -26
  46. package/dist/docs/component-docs.d.ts +13 -2
  47. package/dist/docs/components/headless-input-number.doc.d.ts +5 -0
  48. package/dist/docs/components/headless-input-number.doc.js +7 -0
  49. package/dist/docs/components/input-number.doc.d.ts +5 -0
  50. package/dist/docs/components/input-number.doc.js +7 -0
  51. package/dist/docs/components/statistic.doc.d.ts +5 -0
  52. package/dist/docs/components/statistic.doc.js +7 -0
  53. package/dist/docs/components/tao-provider.doc.d.ts +8 -2
  54. package/dist/docs/components/tao-provider.doc.js +10 -2
  55. package/dist/docs/components/tooltip.doc.d.ts +2 -2
  56. package/dist/entries/provider.d.ts +1 -0
  57. package/dist/entries/provider.js +1 -0
  58. package/dist/index.d.ts +1 -0
  59. package/dist/index.js +1 -0
  60. package/dist/locales/ar-EG.d.ts +3 -0
  61. package/dist/locales/ar-EG.js +199 -0
  62. package/dist/locales/create-locale.d.ts +41 -0
  63. package/dist/locales/create-locale.js +88 -0
  64. package/dist/locales/de-DE.d.ts +3 -0
  65. package/dist/locales/de-DE.js +195 -0
  66. package/dist/locales/en-US.d.ts +2 -0
  67. package/dist/locales/en-US.js +194 -0
  68. package/dist/locales/es-ES.d.ts +3 -0
  69. package/dist/locales/es-ES.js +195 -0
  70. package/dist/locales/fr-FR.d.ts +3 -0
  71. package/dist/locales/fr-FR.js +195 -0
  72. package/dist/locales/hi-IN.d.ts +3 -0
  73. package/dist/locales/hi-IN.js +194 -0
  74. package/dist/locales/id-ID.d.ts +3 -0
  75. package/dist/locales/id-ID.js +194 -0
  76. package/dist/locales/index.d.ts +18 -0
  77. package/dist/locales/index.js +17 -0
  78. package/dist/locales/it-IT.d.ts +3 -0
  79. package/dist/locales/it-IT.js +195 -0
  80. package/dist/locales/ja-JP.d.ts +3 -0
  81. package/dist/locales/ja-JP.js +194 -0
  82. package/dist/locales/ko-KR.d.ts +3 -0
  83. package/dist/locales/ko-KR.js +194 -0
  84. package/dist/locales/pt-BR.d.ts +3 -0
  85. package/dist/locales/pt-BR.js +195 -0
  86. package/dist/locales/ru-RU.d.ts +3 -0
  87. package/dist/locales/ru-RU.js +197 -0
  88. package/dist/locales/th-TH.d.ts +3 -0
  89. package/dist/locales/th-TH.js +194 -0
  90. package/dist/locales/tr-TR.d.ts +3 -0
  91. package/dist/locales/tr-TR.js +194 -0
  92. package/dist/locales/types.d.ts +176 -0
  93. package/dist/locales/types.js +0 -0
  94. package/dist/locales/vi-VN.d.ts +3 -0
  95. package/dist/locales/vi-VN.js +194 -0
  96. package/dist/locales/zh-CN.d.ts +3 -0
  97. package/dist/locales/zh-CN.js +194 -0
  98. package/dist/locales/zh-TW.d.ts +3 -0
  99. package/dist/locales/zh-TW.js +194 -0
  100. package/dist/number-input/format.d.ts +4 -3
  101. package/dist/number-input/format.js +9 -7
  102. package/dist/number-input/locale.d.ts +19 -0
  103. package/dist/number-input/locale.js +44 -0
  104. package/dist/number-input/number-input.js +1 -0
  105. package/dist/number-input/use-number-input.d.ts +2 -0
  106. package/dist/number-input/use-number-input.js +180 -176
  107. package/dist/provider/locale.d.ts +3 -65
  108. package/dist/provider/locale.js +2 -146
  109. package/dist/provider/merge-locale.d.ts +8 -0
  110. package/dist/provider/merge-locale.js +53 -0
  111. package/dist/provider/tao-provider.d.ts +6 -2
  112. package/dist/provider/tao-provider.js +2 -4
  113. package/llms.txt +1 -1
  114. package/package.json +5 -1
@@ -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;
@@ -70,8 +76,8 @@ function CalendarGrid({ viewDate, value, rangeStart, rangeEnd, hoverDate, onSele
70
76
  else if ('ArrowRight' === event.key) next_0 = date_4.add(rtl ? -1 : 1, 'day');
71
77
  else if ('ArrowUp' === event.key) next_0 = date_4.subtract(7, 'day');
72
78
  else if ('ArrowDown' === event.key) next_0 = date_4.add(7, 'day');
73
- else if ('Home' === event.key) next_0 = date_4.subtract((date_4.day() + 6) % 7, 'day');
74
- 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');
75
81
  else if ('PageUp' === event.key) next_0 = date_4.subtract(1, 'month');
76
82
  else if ('PageDown' === event.key) next_0 = date_4.add(1, 'month');
77
83
  if (!next_0) return;
@@ -115,7 +121,7 @@ function CalendarGrid({ viewDate, value, rangeStart, rangeEnd, hoverDate, onSele
115
121
  children: [
116
122
  /*#__PURE__*/ jsx("thead", {
117
123
  children: /*#__PURE__*/ jsx("tr", {
118
- children: locale.weekdays.map((d)=>/*#__PURE__*/ jsx("th", {
124
+ children: weekdays.map((d)=>/*#__PURE__*/ jsx("th", {
119
125
  "data-tao-calendar-weekday": "",
120
126
  children: d
121
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 };
@@ -1,7 +1,6 @@
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
5
  import { TaoPortalScope, useTaoConfig, useTaoDirection } from "../../provider/tao-provider.js";
7
6
  import { useIsMobile } from "../../utils/breakpoint.js";
@@ -17,9 +16,9 @@ import { TimePanel } from "./calendar/time-panel.js";
17
16
  import { YearGrid } from "./calendar/year-grid.js";
18
17
  import "./date-picker.css";
19
18
  import { Presets } from "./presets.js";
19
+ import { formatPickerDate, parsePickerDate } from "./date-localization.js";
20
20
  import { getDefaultFormat } from "./types.js";
21
21
  import * as __rspack_external__radix_ui_react_popover_c8444160 from "@radix-ui/react-popover";
22
- dayjs.extend(customParseFormat);
23
22
  const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
24
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;
25
24
  const popupId = useId();
@@ -50,11 +49,17 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
50
49
  isMobile
51
50
  ]);
52
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
+ ]);
53
58
  const defaultPlaceholder = placeholder ?? fmt;
54
59
  const drawerTitle = useMobileTitle(props.mobileTitle, showTime ? ctx.locale.dateTime : ctx.locale.selectDate);
55
- const isDateBlocked = useCallback((date)=>{
60
+ const isDateBlocked = useCallback((date_0)=>{
56
61
  const granularity = 'date' === picker ? 'day' : picker;
57
- 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);
58
63
  }, [
59
64
  picker,
60
65
  disabledDate,
@@ -72,7 +77,7 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
72
77
  onChange
73
78
  ]);
74
79
  const [internalOpen, setInternalOpen] = useState(false);
75
- const displayValue = resolvedValue ? resolvedValue.format(fmt) : '';
80
+ const displayValue = formatValue(resolvedValue);
76
81
  const [inputValue, setInputValue] = useState(displayValue);
77
82
  const isOpen = controlledOpen ?? internalOpen;
78
83
  const setOpen = useCallback((v)=>{
@@ -107,57 +112,57 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
107
112
  }), [
108
113
  resolvedValue
109
114
  ]);
110
- const handleDateSelect = useCallback((date_0)=>{
111
- let result = date_0;
112
- if (showTime && resolvedValue) result = date_0.hour(resolvedValue.hour()).minute(resolvedValue.minute()).second(resolvedValue.second());
113
- 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));
114
119
  else {
115
- emitChange(result, result.format(fmt));
120
+ emitChange(result, formatValue(result));
116
121
  setOpen(false);
117
122
  }
118
123
  }, [
119
124
  emitChange,
120
- fmt,
125
+ formatValue,
121
126
  showTime,
122
127
  resolvedValue,
123
128
  setOpen
124
129
  ]);
125
- const handleMonthSelect = useCallback((date_1)=>{
130
+ const handleMonthSelect = useCallback((date_2)=>{
126
131
  if ('month' === picker) {
127
- emitChange(date_1, date_1.format(fmt));
132
+ emitChange(date_2, formatValue(date_2));
128
133
  setOpen(false);
129
134
  } else {
130
- setViewDate(date_1);
135
+ setViewDate(date_2);
131
136
  setPanelMode('date');
132
137
  }
133
138
  }, [
134
139
  picker,
135
140
  emitChange,
136
- fmt,
141
+ formatValue,
137
142
  setOpen
138
143
  ]);
139
- const handleYearSelect = useCallback((date_2)=>{
144
+ const handleYearSelect = useCallback((date_3)=>{
140
145
  if ('year' === picker) {
141
- emitChange(date_2, date_2.format(fmt));
146
+ emitChange(date_3, formatValue(date_3));
142
147
  setOpen(false);
143
148
  } else {
144
- setViewDate(date_2);
149
+ setViewDate(date_3);
145
150
  setPanelMode('month' === picker ? 'month' : 'date');
146
151
  }
147
152
  }, [
148
153
  picker,
149
154
  emitChange,
150
- fmt,
155
+ formatValue,
151
156
  setOpen
152
157
  ]);
153
158
  const handleTimeChange = useCallback((h, m, s)=>{
154
159
  const base = resolvedValue ?? dayjs();
155
160
  const result_0 = base.hour(h).minute(m).second(s);
156
- emitChange(result_0, result_0.format(fmt));
161
+ emitChange(result_0, formatValue(result_0));
157
162
  }, [
158
163
  resolvedValue,
159
164
  emitChange,
160
- fmt
165
+ formatValue
161
166
  ]);
162
167
  const handleClear = useCallback((e)=>{
163
168
  e.stopPropagation();
@@ -168,11 +173,11 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
168
173
  const handlePresetSelect = useCallback((val)=>{
169
174
  const d = val;
170
175
  if (isDateBlocked(d)) return;
171
- emitChange(d, d.format(fmt));
176
+ emitChange(d, formatValue(d));
172
177
  setOpen(false);
173
178
  }, [
174
179
  emitChange,
175
- fmt,
180
+ formatValue,
176
181
  setOpen,
177
182
  isDateBlocked
178
183
  ]);
@@ -183,13 +188,13 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
183
188
  ]);
184
189
  const handleNow = useCallback(()=>{
185
190
  const now = dayjs();
186
- emitChange(now, now.format(fmt));
191
+ emitChange(now, formatValue(now));
187
192
  setViewDate(now);
188
193
  setPanelMode('date');
189
194
  setTimeScrollKey((k_0)=>k_0 + 1);
190
195
  }, [
191
196
  emitChange,
192
- fmt
197
+ formatValue
193
198
  ]);
194
199
  const showClearBtn = allowClear && resolvedValue && !resolvedDisabled;
195
200
  const commitInputValue = useCallback(()=>{
@@ -200,9 +205,9 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
200
205
  setOpen(false);
201
206
  return;
202
207
  }
203
- const parsed = dayjs(text, fmt, true);
208
+ const parsed = parsePickerDate(text, fmt, dayjsLocale, numberLocale);
204
209
  if (isDateBlocked(parsed)) return void setInputValue(displayValue);
205
- const formatted = parsed.format(fmt);
210
+ const formatted = formatValue(parsed);
206
211
  setInputValue(isValueControlled ? displayValue : formatted);
207
212
  setViewDate(parsed);
208
213
  if (formatted !== displayValue) emitChange(parsed, formatted);
@@ -210,6 +215,9 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
210
215
  }, [
211
216
  displayValue,
212
217
  fmt,
218
+ dayjsLocale,
219
+ numberLocale,
220
+ formatValue,
213
221
  inputValue,
214
222
  isValueControlled,
215
223
  isDateBlocked,
@@ -1,7 +1,6 @@
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
5
  import { TaoPortalScope, useTaoConfig, useTaoDirection } from "../../provider/tao-provider.js";
7
6
  import { useIsMobile } from "../../utils/breakpoint.js";
@@ -12,9 +11,9 @@ import { Drawer } from "../drawer/drawer.js";
12
11
  import { CalendarGrid } from "./calendar/calendar-grid.js";
13
12
  import "./date-picker.css";
14
13
  import { Presets } from "./presets.js";
14
+ import { formatPickerDate, parsePickerDate } from "./date-localization.js";
15
15
  import { getDefaultFormat } from "./types.js";
16
16
  import * as __rspack_external__radix_ui_react_popover_c8444160 from "@radix-ui/react-popover";
17
- dayjs.extend(customParseFormat);
18
17
  const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
19
18
  const { value, defaultValue, onChange, picker = 'date', showTime, format: formatProp, disabledDate, minDate, maxDate, presets, placeholder: placeholderProp, separator = '~', size, variant, disabled, allowClear = true, status, mobile, open: controlledOpen, onOpenChange, className, style, classNames, styles } = props;
20
19
  const popupId = useId();
@@ -55,7 +54,13 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
55
54
  isMobile
56
55
  ]);
57
56
  const fmt = formatProp ?? getDefaultFormat(picker, showTime);
58
- const isDateBlocked = useCallback((date)=>!date.isValid() || Boolean(disabledDate?.(date)) || null != minDate && date.isBefore(minDate, 'day') || null != maxDate && date.isAfter(maxDate, 'day'), [
57
+ const dayjsLocale = ctx.locale.dayjsLocale;
58
+ const numberLocale = ctx.locale.numberLocale;
59
+ const formatValue = useCallback((date)=>formatPickerDate(date, fmt, dayjsLocale), [
60
+ fmt,
61
+ dayjsLocale
62
+ ]);
63
+ const isDateBlocked = useCallback((date_0)=>!date_0.isValid() || Boolean(disabledDate?.(date_0)) || null != minDate && date_0.isBefore(minDate, 'day') || null != maxDate && date_0.isAfter(maxDate, 'day'), [
59
64
  disabledDate,
60
65
  minDate,
61
66
  maxDate
@@ -74,8 +79,8 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
74
79
  ] : null;
75
80
  if (!isValueControlled) setInternalValue(nextValue);
76
81
  onChange?.(nextValue, [
77
- start?.format(fmt) ?? '',
78
- end?.format(fmt) ?? ''
82
+ formatValue(start),
83
+ formatValue(end)
79
84
  ]);
80
85
  return true;
81
86
  }, [
@@ -85,7 +90,7 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
85
90
  endDisabled,
86
91
  resolvedDisabled,
87
92
  resolvedValue,
88
- fmt
93
+ formatValue
89
94
  ]);
90
95
  const [internalOpen, setInternalOpen] = useState(false);
91
96
  const isOpen = controlledOpen ?? internalOpen;
@@ -138,13 +143,13 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
138
143
  hover
139
144
  } : current_0);
140
145
  }, []);
141
- const handleDateSelect = useCallback((date_0)=>{
146
+ const handleDateSelect = useCallback((date_1)=>{
142
147
  if (startDisabled || endDisabled) {
143
148
  if (!emitChange(startDisabled ? [
144
149
  rangeStart,
145
- date_0
150
+ date_1
146
151
  ] : [
147
- date_0,
152
+ date_1,
148
153
  rangeEnd
149
154
  ])) return;
150
155
  setInteraction({
@@ -157,14 +162,14 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
157
162
  if ('idle' === interaction.phase && 'start' === interaction.activeInput) setInteraction({
158
163
  phase: 'pickingEnd',
159
164
  activeInput: 'end',
160
- start: date_0,
165
+ start: date_1,
161
166
  hover: null
162
167
  });
163
168
  else {
164
169
  let start_0 = 'pickingEnd' === interaction.phase ? interaction.start : rangeStart;
165
- let end_0 = date_0;
166
- if (start_0 && date_0.isBefore(start_0)) [start_0, end_0] = [
167
- date_0,
170
+ let end_0 = date_1;
171
+ if (start_0 && date_1.isBefore(start_0)) [start_0, end_0] = [
172
+ date_1,
168
173
  start_0
169
174
  ];
170
175
  emitChange([
@@ -216,8 +221,8 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
216
221
  startDisabled,
217
222
  endDisabled
218
223
  ]);
219
- const displayStart = rangeStart ? rangeStart.format(fmt) : '';
220
- const displayEnd = rangeEnd ? rangeEnd.format(fmt) : '';
224
+ const displayStart = formatValue(rangeStart);
225
+ const displayEnd = formatValue(rangeEnd);
221
226
  const [inputStart, setInputStart] = useState(displayStart);
222
227
  const [inputEnd, setInputEnd] = useState(displayEnd);
223
228
  useEffect(()=>setInputStart(displayStart), [
@@ -230,7 +235,7 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
230
235
  if ('start' === position_0 ? startDisabled : endDisabled) return;
231
236
  const text = ('start' === position_0 ? inputStart : inputEnd).trim();
232
237
  const currentValue = 'start' === position_0 ? displayStart : displayEnd;
233
- const parsed = text ? dayjs(text, fmt, true) : null;
238
+ const parsed = text ? parsePickerDate(text, fmt, dayjsLocale, numberLocale) : null;
234
239
  const isBlocked = null != parsed && (isDateBlocked(parsed) || 'start' === position_0 && null != rangeEnd && parsed.isAfter(rangeEnd) || 'end' === position_0 && null != rangeStart && parsed.isBefore(rangeStart));
235
240
  if (isBlocked) {
236
241
  if ('start' === position_0) setInputStart(currentValue);
@@ -240,8 +245,8 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
240
245
  const nextStart = 'start' === position_0 ? parsed : rangeStart;
241
246
  const nextEnd = 'end' === position_0 ? parsed : rangeEnd;
242
247
  const nextStrings = [
243
- nextStart?.format(fmt) ?? '',
244
- nextEnd?.format(fmt) ?? ''
248
+ formatValue(nextStart),
249
+ formatValue(nextEnd)
245
250
  ];
246
251
  if (nextStrings[0] !== displayStart || nextStrings[1] !== displayEnd) emitChange(nextStart || nextEnd ? [
247
252
  nextStart,
@@ -263,6 +268,9 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
263
268
  displayStart,
264
269
  emitChange,
265
270
  fmt,
271
+ dayjsLocale,
272
+ numberLocale,
273
+ formatValue,
266
274
  inputEnd,
267
275
  inputStart,
268
276
  isValueControlled,
@@ -271,7 +279,7 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
271
279
  setOpen
272
280
  ]);
273
281
  const showClearBtn = allowClear && (!startDisabled && rangeStart || !endDisabled && rangeEnd);
274
- const isDateDisabled = (date_1)=>Boolean(resolvedDisabled || disabledDate?.(date_1) || startDisabled && rangeStart && date_1.isBefore(rangeStart, 'day') || endDisabled && rangeEnd && date_1.isAfter(rangeEnd, 'day'));
282
+ const isDateDisabled = (date_2)=>Boolean(resolvedDisabled || disabledDate?.(date_2) || startDisabled && rangeStart && date_2.isBefore(rangeStart, 'day') || endDisabled && rangeEnd && date_2.isAfter(rangeEnd, 'day'));
275
283
  const panelContent = /*#__PURE__*/ jsxs("div", {
276
284
  "data-tao-range-panel": "",
277
285
  className: isMobile ? classNames?.popup : void 0,
@@ -368,7 +376,7 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
368
376
  rangeEnd: rangeEnd,
369
377
  hoverDate: hoverDate,
370
378
  onSelect: handleDateSelect,
371
- onViewDateChange: (date_2)=>setViewDateStart(date_2.subtract(1, 'month')),
379
+ onViewDateChange: (date_3)=>setViewDateStart(date_3.subtract(1, 'month')),
372
380
  onHover: setHoverDate,
373
381
  disabledDate: isDateDisabled,
374
382
  minDate: minDate,
@@ -306,7 +306,7 @@ function Dropdown(props) {
306
306
  return t21;
307
307
  }
308
308
  function DropdownButton(t0) {
309
- const $ = c(26);
309
+ const $ = c(27);
310
310
  let children;
311
311
  let dropdownRest;
312
312
  let icon;
@@ -334,7 +334,7 @@ function DropdownButton(t0) {
334
334
  t1 = $[7];
335
335
  }
336
336
  const variant = void 0 === t1 ? "secondary" : t1;
337
- const { size: ctxSize } = useTaoConfig();
337
+ const { size: ctxSize, locale } = useTaoConfig();
338
338
  const resolvedSize = size ?? ctxSize;
339
339
  let t2;
340
340
  if ($[8] !== children || $[9] !== onClick || $[10] !== resolvedSize || $[11] !== variant) {
@@ -358,33 +358,34 @@ function DropdownButton(t0) {
358
358
  $[14] = t3;
359
359
  } else t3 = $[14];
360
360
  let t4;
361
- if ($[15] !== resolvedSize || $[16] !== t3 || $[17] !== variant) {
361
+ if ($[15] !== locale.messages.more || $[16] !== resolvedSize || $[17] !== t3 || $[18] !== variant) {
362
362
  t4 = /*#__PURE__*/ jsx(Button, {
363
363
  variant: variant,
364
364
  size: resolvedSize,
365
- "aria-label": "More",
365
+ "aria-label": locale.messages.more,
366
366
  "data-tao-dropdown-button-trigger": "",
367
367
  children: t3
368
368
  });
369
- $[15] = resolvedSize;
370
- $[16] = t3;
371
- $[17] = variant;
372
- $[18] = t4;
373
- } else t4 = $[18];
369
+ $[15] = locale.messages.more;
370
+ $[16] = resolvedSize;
371
+ $[17] = t3;
372
+ $[18] = variant;
373
+ $[19] = t4;
374
+ } else t4 = $[19];
374
375
  let t5;
375
- if ($[19] !== dropdownRest || $[20] !== menu || $[21] !== t4) {
376
+ if ($[20] !== dropdownRest || $[21] !== menu || $[22] !== t4) {
376
377
  t5 = /*#__PURE__*/ jsx(Dropdown, {
377
378
  menu: menu,
378
379
  ...dropdownRest,
379
380
  children: t4
380
381
  });
381
- $[19] = dropdownRest;
382
- $[20] = menu;
383
- $[21] = t4;
384
- $[22] = t5;
385
- } else t5 = $[22];
382
+ $[20] = dropdownRest;
383
+ $[21] = menu;
384
+ $[22] = t4;
385
+ $[23] = t5;
386
+ } else t5 = $[23];
386
387
  let t6;
387
- if ($[23] !== t2 || $[24] !== t5) {
388
+ if ($[24] !== t2 || $[25] !== t5) {
388
389
  t6 = /*#__PURE__*/ jsxs("span", {
389
390
  "data-tao-dropdown-button-group": "",
390
391
  children: [
@@ -392,10 +393,10 @@ function DropdownButton(t0) {
392
393
  t5
393
394
  ]
394
395
  });
395
- $[23] = t2;
396
- $[24] = t5;
397
- $[25] = t6;
398
- } else t6 = $[25];
396
+ $[24] = t2;
397
+ $[25] = t5;
398
+ $[26] = t6;
399
+ } else t6 = $[26];
399
400
  return t6;
400
401
  }
401
402
  Dropdown.Button = DropdownButton;
@@ -189,7 +189,7 @@ const FloatButtonGroup = /*#__PURE__*/ forwardRef((props, ref)=>{
189
189
  return /*#__PURE__*/ jsxs("div", {
190
190
  ref: root,
191
191
  role: "toolbar",
192
- "aria-label": "Floating actions",
192
+ "aria-label": config.locale.messages.floatingActions,
193
193
  "data-tao-float-button-group": "",
194
194
  "data-tao-shape": shape,
195
195
  "data-tao-placement": placement,
@@ -265,6 +265,7 @@ function scrollElement(target) {
265
265
  return target === window || target instanceof Document ? (target instanceof Document ? target : document).scrollingElement : target;
266
266
  }
267
267
  const BackTop = /*#__PURE__*/ forwardRef((props, ref)=>{
268
+ const { locale } = useTaoConfig();
268
269
  const { visibilityHeight = 400, target = defaultTarget, duration = 450, showProgress = false, onClick, icon = /*#__PURE__*/ jsx(ActionIcon, {
269
270
  kind: "top"
270
271
  }), style, ...rest } = props;
@@ -328,7 +329,7 @@ const BackTop = /*#__PURE__*/ forwardRef((props, ref)=>{
328
329
  ...rest,
329
330
  ref: node,
330
331
  icon: icon,
331
- "aria-label": rest['aria-label'] ?? 'Back to top',
332
+ "aria-label": rest['aria-label'] ?? locale.messages.backToTop,
332
333
  onClick: click,
333
334
  style: {
334
335
  ...showProgress ? {