@octanejs/day-picker 0.0.1

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 (185) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +14 -0
  3. package/UPSTREAM.md +24 -0
  4. package/package.json +77 -0
  5. package/src/DayPicker.tsrx +717 -0
  6. package/src/UI.ts +121 -0
  7. package/src/classes/CalendarDay.ts +82 -0
  8. package/src/classes/CalendarMonth.ts +20 -0
  9. package/src/classes/CalendarWeek.ts +19 -0
  10. package/src/classes/DateLib.ts +695 -0
  11. package/src/classes/index.ts +4 -0
  12. package/src/components/custom-components.tsrx +237 -0
  13. package/src/formatters/formatCaption.ts +18 -0
  14. package/src/formatters/formatDay.ts +17 -0
  15. package/src/formatters/formatMonthDropdown.ts +16 -0
  16. package/src/formatters/formatWeekNumber.ts +19 -0
  17. package/src/formatters/formatWeekNumberHeader.ts +11 -0
  18. package/src/formatters/formatWeekdayName.ts +17 -0
  19. package/src/formatters/formatYearDropdown.ts +15 -0
  20. package/src/formatters/index.ts +7 -0
  21. package/src/helpers/calculateFocusTarget.ts +79 -0
  22. package/src/helpers/createGetModifiers.ts +117 -0
  23. package/src/helpers/endOfBroadcastWeek.ts +22 -0
  24. package/src/helpers/getBroadcastWeeksInMonth.ts +32 -0
  25. package/src/helpers/getClassNamesForModifiers.ts +38 -0
  26. package/src/helpers/getComponents.ts +19 -0
  27. package/src/helpers/getDataAttributes.ts +17 -0
  28. package/src/helpers/getDates.ts +87 -0
  29. package/src/helpers/getDays.ts +19 -0
  30. package/src/helpers/getDefaultClassNames.ts +36 -0
  31. package/src/helpers/getDisplayMonths.ts +30 -0
  32. package/src/helpers/getFocusableDate.ts +66 -0
  33. package/src/helpers/getFormatters.ts +16 -0
  34. package/src/helpers/getInitialMonth.ts +35 -0
  35. package/src/helpers/getLabels.ts +93 -0
  36. package/src/helpers/getMonthOptions.ts +45 -0
  37. package/src/helpers/getMonths.ts +89 -0
  38. package/src/helpers/getNavMonth.ts +35 -0
  39. package/src/helpers/getNextFocus.ts +45 -0
  40. package/src/helpers/getNextMonth.ts +46 -0
  41. package/src/helpers/getPreviousMonth.ts +45 -0
  42. package/src/helpers/getStyleForModifiers.ts +31 -0
  43. package/src/helpers/getWeekdays.ts +33 -0
  44. package/src/helpers/getWeeks.ts +14 -0
  45. package/src/helpers/getYearOptions.ts +43 -0
  46. package/src/helpers/index.ts +2 -0
  47. package/src/helpers/startOfBroadcastWeek.ts +26 -0
  48. package/src/helpers/useControlledValue.ts +38 -0
  49. package/src/index.ts +13 -0
  50. package/src/labels/index.ts +12 -0
  51. package/src/labels/labelDayButton.ts +29 -0
  52. package/src/labels/labelGrid.ts +18 -0
  53. package/src/labels/labelGridcell.ts +26 -0
  54. package/src/labels/labelMonthDropdown.ts +14 -0
  55. package/src/labels/labelNav.ts +11 -0
  56. package/src/labels/labelNext.ts +17 -0
  57. package/src/labels/labelPrevious.ts +13 -0
  58. package/src/labels/labelWeekNumber.ts +15 -0
  59. package/src/labels/labelWeekNumberHeader.ts +14 -0
  60. package/src/labels/labelWeekday.ts +16 -0
  61. package/src/labels/labelYearDropdown.ts +14 -0
  62. package/src/locale/af.ts +48 -0
  63. package/src/locale/ar-DZ.ts +48 -0
  64. package/src/locale/ar-EG.ts +48 -0
  65. package/src/locale/ar-MA.ts +48 -0
  66. package/src/locale/ar-SA.ts +48 -0
  67. package/src/locale/ar-TN.ts +48 -0
  68. package/src/locale/ar.ts +48 -0
  69. package/src/locale/az.ts +48 -0
  70. package/src/locale/be-tarask.ts +51 -0
  71. package/src/locale/be.ts +48 -0
  72. package/src/locale/bg.ts +48 -0
  73. package/src/locale/bn.ts +48 -0
  74. package/src/locale/bs.ts +48 -0
  75. package/src/locale/ca.ts +48 -0
  76. package/src/locale/ckb.ts +51 -0
  77. package/src/locale/cs.ts +48 -0
  78. package/src/locale/cy.ts +48 -0
  79. package/src/locale/da.ts +48 -0
  80. package/src/locale/de-AT.ts +48 -0
  81. package/src/locale/de.ts +48 -0
  82. package/src/locale/el.ts +48 -0
  83. package/src/locale/en-AU.ts +48 -0
  84. package/src/locale/en-CA.ts +48 -0
  85. package/src/locale/en-GB.ts +51 -0
  86. package/src/locale/en-IE.ts +48 -0
  87. package/src/locale/en-IN.ts +48 -0
  88. package/src/locale/en-NZ.ts +48 -0
  89. package/src/locale/en-US.ts +72 -0
  90. package/src/locale/en-ZA.ts +48 -0
  91. package/src/locale/eo.ts +48 -0
  92. package/src/locale/es.ts +48 -0
  93. package/src/locale/et.ts +48 -0
  94. package/src/locale/eu.ts +48 -0
  95. package/src/locale/fa-IR.ts +48 -0
  96. package/src/locale/fi.ts +48 -0
  97. package/src/locale/fr-CA.ts +48 -0
  98. package/src/locale/fr-CH.ts +48 -0
  99. package/src/locale/fr.ts +48 -0
  100. package/src/locale/fy.ts +48 -0
  101. package/src/locale/gd.ts +48 -0
  102. package/src/locale/gl.ts +48 -0
  103. package/src/locale/gu.ts +48 -0
  104. package/src/locale/he.ts +48 -0
  105. package/src/locale/hi.ts +48 -0
  106. package/src/locale/hr.ts +48 -0
  107. package/src/locale/ht.ts +48 -0
  108. package/src/locale/hu.ts +48 -0
  109. package/src/locale/hy.ts +48 -0
  110. package/src/locale/id.ts +48 -0
  111. package/src/locale/is.ts +48 -0
  112. package/src/locale/it-CH.ts +48 -0
  113. package/src/locale/it.ts +48 -0
  114. package/src/locale/ja-Hira.ts +48 -0
  115. package/src/locale/ja.ts +48 -0
  116. package/src/locale/ka.ts +48 -0
  117. package/src/locale/kk.ts +48 -0
  118. package/src/locale/km.ts +48 -0
  119. package/src/locale/kn.ts +48 -0
  120. package/src/locale/ko.ts +48 -0
  121. package/src/locale/lb.ts +48 -0
  122. package/src/locale/lt.ts +48 -0
  123. package/src/locale/lv.ts +48 -0
  124. package/src/locale/mk.ts +48 -0
  125. package/src/locale/mn.ts +48 -0
  126. package/src/locale/ms.ts +48 -0
  127. package/src/locale/mt.ts +48 -0
  128. package/src/locale/nb.ts +48 -0
  129. package/src/locale/nl-BE.ts +48 -0
  130. package/src/locale/nl.ts +48 -0
  131. package/src/locale/nn.ts +48 -0
  132. package/src/locale/oc.ts +48 -0
  133. package/src/locale/pl.ts +48 -0
  134. package/src/locale/pt-BR.ts +48 -0
  135. package/src/locale/pt.ts +48 -0
  136. package/src/locale/ro.ts +48 -0
  137. package/src/locale/ru.ts +48 -0
  138. package/src/locale/se.ts +48 -0
  139. package/src/locale/sk.ts +48 -0
  140. package/src/locale/sl.ts +48 -0
  141. package/src/locale/sq.ts +48 -0
  142. package/src/locale/sr-Latn.ts +48 -0
  143. package/src/locale/sr.ts +48 -0
  144. package/src/locale/sv.ts +48 -0
  145. package/src/locale/ta.ts +48 -0
  146. package/src/locale/te.ts +48 -0
  147. package/src/locale/th.ts +48 -0
  148. package/src/locale/tr.ts +48 -0
  149. package/src/locale/ug.ts +48 -0
  150. package/src/locale/uk.ts +48 -0
  151. package/src/locale/uz-Cyrl.ts +48 -0
  152. package/src/locale/uz.ts +48 -0
  153. package/src/locale/vi.ts +48 -0
  154. package/src/locale/zh-CN.ts +48 -0
  155. package/src/locale/zh-HK.ts +51 -0
  156. package/src/locale/zh-TW.ts +51 -0
  157. package/src/locale.ts +108 -0
  158. package/src/noonDateLib.ts +202 -0
  159. package/src/selection/useMulti.ts +74 -0
  160. package/src/selection/useRange.ts +89 -0
  161. package/src/selection/useSingle.ts +77 -0
  162. package/src/style.css +451 -0
  163. package/src/style.css.d.ts +3 -0
  164. package/src/style.module.css +451 -0
  165. package/src/style.module.css.d.ts +29 -0
  166. package/src/types/index.ts +3 -0
  167. package/src/types/props.ts +671 -0
  168. package/src/types/selection.ts +97 -0
  169. package/src/types/shared.ts +346 -0
  170. package/src/useAnimation.ts +242 -0
  171. package/src/useCalendar.ts +233 -0
  172. package/src/useDayPicker.ts +91 -0
  173. package/src/useFocus.ts +109 -0
  174. package/src/useSelection.ts +36 -0
  175. package/src/utils/addToRange.ts +91 -0
  176. package/src/utils/convertMatchersToTimeZone.ts +88 -0
  177. package/src/utils/dateMatchModifiers.ts +72 -0
  178. package/src/utils/index.ts +7 -0
  179. package/src/utils/rangeContainsDayOfWeek.ts +33 -0
  180. package/src/utils/rangeContainsModifiers.ts +106 -0
  181. package/src/utils/rangeIncludesDate.ts +40 -0
  182. package/src/utils/rangeOverlaps.ts +26 -0
  183. package/src/utils/toTimeZone.ts +13 -0
  184. package/src/utils/typeguards.ts +71 -0
  185. package/status.json +13 -0
@@ -0,0 +1,48 @@
1
+ import { tr as dateFnsTr } from 'date-fns/locale';
2
+
3
+ import type { DateLibOptions, DayPickerLocale } from '../classes/DateLib.js';
4
+ import { DateLib } from '../classes/DateLib.js';
5
+ import type { Modifiers } from '../types/index.js';
6
+
7
+ /** Turkish locale extended with DayPicker-specific translations. */
8
+ export const tr: DayPickerLocale = {
9
+ ...dateFnsTr,
10
+ labels: {
11
+ labelDayButton: (
12
+ date: Date,
13
+ modifiers: Modifiers,
14
+ options?: DateLibOptions,
15
+ dateLib?: DateLib,
16
+ ) => {
17
+ const lib = dateLib ?? new DateLib(options);
18
+ let label = lib.format(date, 'PPPP');
19
+ if (modifiers.today) label = `Bugün, ${label}`;
20
+ if (modifiers.selected) label = `${label}, seçili`;
21
+ return label;
22
+ },
23
+ labelMonthDropdown: 'Ayı seçin',
24
+ labelNext: 'Sonraki aya git',
25
+ labelPrevious: 'Önceki aya git',
26
+ labelWeekNumber: (weekNumber: number) => `Hafta ${weekNumber}`,
27
+ labelYearDropdown: 'Yılı seçin',
28
+ labelGrid: (date: Date, options?: DateLibOptions, dateLib?: DateLib) =>
29
+ (dateLib ?? new DateLib(options)).formatMonthYear(date),
30
+ labelGridcell: (
31
+ date: Date,
32
+ modifiers?: Modifiers,
33
+ options?: DateLibOptions,
34
+ dateLib?: DateLib,
35
+ ) => {
36
+ const lib = dateLib ?? new DateLib(options);
37
+ let label = lib.format(date, 'PPPP');
38
+ if (modifiers?.today) {
39
+ label = `Bugün, ${label}`;
40
+ }
41
+ return label;
42
+ },
43
+ labelNav: 'Gezinme çubuğu',
44
+ labelWeekNumberHeader: 'Hafta numarası',
45
+ labelWeekday: (date: Date, options?: DateLibOptions, dateLib?: DateLib) =>
46
+ (dateLib ?? new DateLib(options)).format(date, 'cccc'),
47
+ },
48
+ };
@@ -0,0 +1,48 @@
1
+ import { ug as dateFnsUg } from 'date-fns/locale';
2
+
3
+ import type { DateLibOptions, DayPickerLocale } from '../classes/DateLib.js';
4
+ import { DateLib } from '../classes/DateLib.js';
5
+ import type { Modifiers } from '../types/index.js';
6
+
7
+ /** Uyghur locale extended with DayPicker-specific translations. */
8
+ export const ug: DayPickerLocale = {
9
+ ...dateFnsUg,
10
+ labels: {
11
+ labelDayButton: (
12
+ date: Date,
13
+ modifiers: Modifiers,
14
+ options?: DateLibOptions,
15
+ dateLib?: DateLib,
16
+ ) => {
17
+ const lib = dateLib ?? new DateLib(options);
18
+ let label = lib.format(date, 'PPPP');
19
+ if (modifiers.today) label = `بۈگۈن، ${label}`;
20
+ if (modifiers.selected) label = `${label}، تاللانغان`;
21
+ return label;
22
+ },
23
+ labelMonthDropdown: 'ئاي تاللاڭ',
24
+ labelNext: 'كېيىنكى ئايغا يۆتكەڭ',
25
+ labelPrevious: 'ئالدىنقى ئايغا يۆتكەڭ',
26
+ labelWeekNumber: (weekNumber: number) => `ھەپتە ${weekNumber}`,
27
+ labelYearDropdown: 'يىل تاللاڭ',
28
+ labelGrid: (date: Date, options?: DateLibOptions, dateLib?: DateLib) =>
29
+ (dateLib ?? new DateLib(options)).formatMonthYear(date),
30
+ labelGridcell: (
31
+ date: Date,
32
+ modifiers?: Modifiers,
33
+ options?: DateLibOptions,
34
+ dateLib?: DateLib,
35
+ ) => {
36
+ const lib = dateLib ?? new DateLib(options);
37
+ let label = lib.format(date, 'PPPP');
38
+ if (modifiers?.today) {
39
+ label = `بۈگۈن، ${label}`;
40
+ }
41
+ return label;
42
+ },
43
+ labelNav: 'يولباشچى بالداق',
44
+ labelWeekNumberHeader: 'ھەپتە نومۇرى',
45
+ labelWeekday: (date: Date, options?: DateLibOptions, dateLib?: DateLib) =>
46
+ (dateLib ?? new DateLib(options)).format(date, 'cccc'),
47
+ },
48
+ };
@@ -0,0 +1,48 @@
1
+ import { uk as dateFnsUk } from 'date-fns/locale';
2
+
3
+ import type { DateLibOptions, DayPickerLocale } from '../classes/DateLib.js';
4
+ import { DateLib } from '../classes/DateLib.js';
5
+ import type { Modifiers } from '../types/index.js';
6
+
7
+ /** Ukrainian locale extended with DayPicker-specific translations. */
8
+ export const uk: DayPickerLocale = {
9
+ ...dateFnsUk,
10
+ labels: {
11
+ labelDayButton: (
12
+ date: Date,
13
+ modifiers: Modifiers,
14
+ options?: DateLibOptions,
15
+ dateLib?: DateLib,
16
+ ) => {
17
+ const lib = dateLib ?? new DateLib(options);
18
+ let label = lib.format(date, 'PPPP');
19
+ if (modifiers.today) label = `Сьогодні, ${label}`;
20
+ if (modifiers.selected) label = `${label}, вибрано`;
21
+ return label;
22
+ },
23
+ labelMonthDropdown: 'Виберіть місяць',
24
+ labelNext: 'Перейти до наступного місяця',
25
+ labelPrevious: 'Перейти до попереднього місяця',
26
+ labelWeekNumber: (weekNumber: number) => `Тиждень ${weekNumber}`,
27
+ labelYearDropdown: 'Виберіть рік',
28
+ labelGrid: (date: Date, options?: DateLibOptions, dateLib?: DateLib) =>
29
+ (dateLib ?? new DateLib(options)).formatMonthYear(date),
30
+ labelGridcell: (
31
+ date: Date,
32
+ modifiers?: Modifiers,
33
+ options?: DateLibOptions,
34
+ dateLib?: DateLib,
35
+ ) => {
36
+ const lib = dateLib ?? new DateLib(options);
37
+ let label = lib.format(date, 'PPPP');
38
+ if (modifiers?.today) {
39
+ label = `Сьогодні, ${label}`;
40
+ }
41
+ return label;
42
+ },
43
+ labelNav: 'Панель навігації',
44
+ labelWeekNumberHeader: 'Номер тижня',
45
+ labelWeekday: (date: Date, options?: DateLibOptions, dateLib?: DateLib) =>
46
+ (dateLib ?? new DateLib(options)).format(date, 'cccc'),
47
+ },
48
+ };
@@ -0,0 +1,48 @@
1
+ import { uzCyrl as dateFnsUzCyrl } from 'date-fns/locale';
2
+
3
+ import type { DateLibOptions, DayPickerLocale } from '../classes/DateLib.js';
4
+ import { DateLib } from '../classes/DateLib.js';
5
+ import type { Modifiers } from '../types/index.js';
6
+
7
+ /** Uzbek (Cyrillic) locale extended with DayPicker-specific translations. */
8
+ export const uzCyrl: DayPickerLocale = {
9
+ ...dateFnsUzCyrl,
10
+ labels: {
11
+ labelDayButton: (
12
+ date: Date,
13
+ modifiers: Modifiers,
14
+ options?: DateLibOptions,
15
+ dateLib?: DateLib,
16
+ ) => {
17
+ const lib = dateLib ?? new DateLib(options);
18
+ let label = lib.format(date, 'PPPP');
19
+ if (modifiers.today) label = `Бугун, ${label}`;
20
+ if (modifiers.selected) label = `${label}, танланган`;
21
+ return label;
22
+ },
23
+ labelMonthDropdown: 'Ойни танланг',
24
+ labelNext: 'Кейинги ойга ўтинг',
25
+ labelPrevious: 'Олдинги ойга ўтинг',
26
+ labelWeekNumber: (weekNumber: number) => `Ҳафта ${weekNumber}`,
27
+ labelYearDropdown: 'Йилни танланг',
28
+ labelGrid: (date: Date, options?: DateLibOptions, dateLib?: DateLib) =>
29
+ (dateLib ?? new DateLib(options)).formatMonthYear(date),
30
+ labelGridcell: (
31
+ date: Date,
32
+ modifiers?: Modifiers,
33
+ options?: DateLibOptions,
34
+ dateLib?: DateLib,
35
+ ) => {
36
+ const lib = dateLib ?? new DateLib(options);
37
+ let label = lib.format(date, 'PPPP');
38
+ if (modifiers?.today) {
39
+ label = `Бугун, ${label}`;
40
+ }
41
+ return label;
42
+ },
43
+ labelNav: 'Навигация панели',
44
+ labelWeekNumberHeader: 'Ҳафта рақами',
45
+ labelWeekday: (date: Date, options?: DateLibOptions, dateLib?: DateLib) =>
46
+ (dateLib ?? new DateLib(options)).format(date, 'cccc'),
47
+ },
48
+ };
@@ -0,0 +1,48 @@
1
+ import { uz as dateFnsUz } from 'date-fns/locale';
2
+
3
+ import type { DateLibOptions, DayPickerLocale } from '../classes/DateLib.js';
4
+ import { DateLib } from '../classes/DateLib.js';
5
+ import type { Modifiers } from '../types/index.js';
6
+
7
+ /** Uzbek (Latin) locale extended with DayPicker-specific translations. */
8
+ export const uz: DayPickerLocale = {
9
+ ...dateFnsUz,
10
+ labels: {
11
+ labelDayButton: (
12
+ date: Date,
13
+ modifiers: Modifiers,
14
+ options?: DateLibOptions,
15
+ dateLib?: DateLib,
16
+ ) => {
17
+ const lib = dateLib ?? new DateLib(options);
18
+ let label = lib.format(date, 'PPPP');
19
+ if (modifiers.today) label = `Bugun, ${label}`;
20
+ if (modifiers.selected) label = `${label}, tanlangan`;
21
+ return label;
22
+ },
23
+ labelMonthDropdown: 'Oyni tanlang',
24
+ labelNext: "Keyingi oyga o'ting",
25
+ labelPrevious: "Oldingi oyga o'ting",
26
+ labelWeekNumber: (weekNumber: number) => `Hafta ${weekNumber}`,
27
+ labelYearDropdown: 'Yilni tanlang',
28
+ labelGrid: (date: Date, options?: DateLibOptions, dateLib?: DateLib) =>
29
+ (dateLib ?? new DateLib(options)).formatMonthYear(date),
30
+ labelGridcell: (
31
+ date: Date,
32
+ modifiers?: Modifiers,
33
+ options?: DateLibOptions,
34
+ dateLib?: DateLib,
35
+ ) => {
36
+ const lib = dateLib ?? new DateLib(options);
37
+ let label = lib.format(date, 'PPPP');
38
+ if (modifiers?.today) {
39
+ label = `Bugun, ${label}`;
40
+ }
41
+ return label;
42
+ },
43
+ labelNav: 'Navigatsiya paneli',
44
+ labelWeekNumberHeader: 'Hafta raqami',
45
+ labelWeekday: (date: Date, options?: DateLibOptions, dateLib?: DateLib) =>
46
+ (dateLib ?? new DateLib(options)).format(date, 'cccc'),
47
+ },
48
+ };
@@ -0,0 +1,48 @@
1
+ import { vi as dateFnsVi } from 'date-fns/locale';
2
+
3
+ import type { DateLibOptions, DayPickerLocale } from '../classes/DateLib.js';
4
+ import { DateLib } from '../classes/DateLib.js';
5
+ import type { Modifiers } from '../types/index.js';
6
+
7
+ /** Vietnamese locale extended with DayPicker-specific translations. */
8
+ export const vi: DayPickerLocale = {
9
+ ...dateFnsVi,
10
+ labels: {
11
+ labelDayButton: (
12
+ date: Date,
13
+ modifiers: Modifiers,
14
+ options?: DateLibOptions,
15
+ dateLib?: DateLib,
16
+ ) => {
17
+ const lib = dateLib ?? new DateLib(options);
18
+ let label = lib.format(date, 'PPPP');
19
+ if (modifiers.today) label = `Hôm nay, ${label}`;
20
+ if (modifiers.selected) label = `${label}, đã chọn`;
21
+ return label;
22
+ },
23
+ labelMonthDropdown: 'Chọn tháng',
24
+ labelNext: 'Đến tháng tiếp theo',
25
+ labelPrevious: 'Đến tháng trước',
26
+ labelWeekNumber: (weekNumber: number) => `Tuần ${weekNumber}`,
27
+ labelYearDropdown: 'Chọn năm',
28
+ labelGrid: (date: Date, options?: DateLibOptions, dateLib?: DateLib) =>
29
+ (dateLib ?? new DateLib(options)).formatMonthYear(date),
30
+ labelGridcell: (
31
+ date: Date,
32
+ modifiers?: Modifiers,
33
+ options?: DateLibOptions,
34
+ dateLib?: DateLib,
35
+ ) => {
36
+ const lib = dateLib ?? new DateLib(options);
37
+ let label = lib.format(date, 'PPPP');
38
+ if (modifiers?.today) {
39
+ label = `Hôm nay, ${label}`;
40
+ }
41
+ return label;
42
+ },
43
+ labelNav: 'Thanh điều hướng',
44
+ labelWeekNumberHeader: 'Số tuần',
45
+ labelWeekday: (date: Date, options?: DateLibOptions, dateLib?: DateLib) =>
46
+ (dateLib ?? new DateLib(options)).format(date, 'cccc'),
47
+ },
48
+ };
@@ -0,0 +1,48 @@
1
+ import { zhCN as dateFnsZhCN } from 'date-fns/locale';
2
+
3
+ import type { DateLibOptions, DayPickerLocale } from '../classes/DateLib.js';
4
+ import { DateLib } from '../classes/DateLib.js';
5
+ import type { Modifiers } from '../types/index.js';
6
+
7
+ /** Chinese (Simplified) locale extended with DayPicker-specific translations. */
8
+ export const zhCN: DayPickerLocale = {
9
+ ...dateFnsZhCN,
10
+ labels: {
11
+ labelDayButton: (
12
+ date: Date,
13
+ modifiers: Modifiers,
14
+ options?: DateLibOptions,
15
+ dateLib?: DateLib,
16
+ ) => {
17
+ const lib = dateLib ?? new DateLib(options);
18
+ let label = lib.format(date, 'PPPP');
19
+ if (modifiers.today) label = `今天,${label}`;
20
+ if (modifiers.selected) label = `${label},已选择`;
21
+ return label;
22
+ },
23
+ labelMonthDropdown: '选择月份',
24
+ labelNext: '前往下个月',
25
+ labelPrevious: '前往上个月',
26
+ labelWeekNumber: (weekNumber: number) => `第 ${weekNumber} 周`,
27
+ labelYearDropdown: '选择年份',
28
+ labelGrid: (date: Date, options?: DateLibOptions, dateLib?: DateLib) =>
29
+ (dateLib ?? new DateLib(options)).formatMonthYear(date),
30
+ labelGridcell: (
31
+ date: Date,
32
+ modifiers?: Modifiers,
33
+ options?: DateLibOptions,
34
+ dateLib?: DateLib,
35
+ ) => {
36
+ const lib = dateLib ?? new DateLib(options);
37
+ let label = lib.format(date, 'PPPP');
38
+ if (modifiers?.today) {
39
+ label = `今天,${label}`;
40
+ }
41
+ return label;
42
+ },
43
+ labelNav: '导航栏',
44
+ labelWeekNumberHeader: '周数',
45
+ labelWeekday: (date: Date, options?: DateLibOptions, dateLib?: DateLib) =>
46
+ (dateLib ?? new DateLib(options)).format(date, 'cccc'),
47
+ },
48
+ };
@@ -0,0 +1,51 @@
1
+ import { zhHK as dateFnsZhHK } from 'date-fns/locale';
2
+
3
+ import type { DateLibOptions, DayPickerLocale } from '../classes/DateLib.js';
4
+ import { DateLib } from '../classes/DateLib.js';
5
+ import type { Modifiers } from '../types/index.js';
6
+
7
+ /**
8
+ * Chinese (Traditional, Hong Kong) locale extended with DayPicker-specific
9
+ * translations.
10
+ */
11
+ export const zhHK: DayPickerLocale = {
12
+ ...dateFnsZhHK,
13
+ labels: {
14
+ labelDayButton: (
15
+ date: Date,
16
+ modifiers: Modifiers,
17
+ options?: DateLibOptions,
18
+ dateLib?: DateLib,
19
+ ) => {
20
+ const lib = dateLib ?? new DateLib(options);
21
+ let label = lib.format(date, 'PPPP');
22
+ if (modifiers.today) label = `今日,${label}`;
23
+ if (modifiers.selected) label = `${label},已選擇`;
24
+ return label;
25
+ },
26
+ labelMonthDropdown: '選擇月份',
27
+ labelNext: '前往下個月',
28
+ labelPrevious: '前往上個月',
29
+ labelWeekNumber: (weekNumber: number) => `第 ${weekNumber} 週`,
30
+ labelYearDropdown: '選擇年份',
31
+ labelGrid: (date: Date, options?: DateLibOptions, dateLib?: DateLib) =>
32
+ (dateLib ?? new DateLib(options)).formatMonthYear(date),
33
+ labelGridcell: (
34
+ date: Date,
35
+ modifiers?: Modifiers,
36
+ options?: DateLibOptions,
37
+ dateLib?: DateLib,
38
+ ) => {
39
+ const lib = dateLib ?? new DateLib(options);
40
+ let label = lib.format(date, 'PPPP');
41
+ if (modifiers?.today) {
42
+ label = `今日,${label}`;
43
+ }
44
+ return label;
45
+ },
46
+ labelNav: '導覽列',
47
+ labelWeekNumberHeader: '週數',
48
+ labelWeekday: (date: Date, options?: DateLibOptions, dateLib?: DateLib) =>
49
+ (dateLib ?? new DateLib(options)).format(date, 'cccc'),
50
+ },
51
+ };
@@ -0,0 +1,51 @@
1
+ import { zhTW as dateFnsZhTW } from 'date-fns/locale';
2
+
3
+ import type { DateLibOptions, DayPickerLocale } from '../classes/DateLib.js';
4
+ import { DateLib } from '../classes/DateLib.js';
5
+ import type { Modifiers } from '../types/index.js';
6
+
7
+ /**
8
+ * Chinese (Traditional, Taiwan) locale extended with DayPicker-specific
9
+ * translations.
10
+ */
11
+ export const zhTW: DayPickerLocale = {
12
+ ...dateFnsZhTW,
13
+ labels: {
14
+ labelDayButton: (
15
+ date: Date,
16
+ modifiers: Modifiers,
17
+ options?: DateLibOptions,
18
+ dateLib?: DateLib,
19
+ ) => {
20
+ const lib = dateLib ?? new DateLib(options);
21
+ let label = lib.format(date, 'PPPP');
22
+ if (modifiers.today) label = `今天,${label}`;
23
+ if (modifiers.selected) label = `${label},已選取`;
24
+ return label;
25
+ },
26
+ labelMonthDropdown: '選擇月份',
27
+ labelNext: '前往下個月',
28
+ labelPrevious: '前往上個月',
29
+ labelWeekNumber: (weekNumber: number) => `第 ${weekNumber} 週`,
30
+ labelYearDropdown: '選擇年份',
31
+ labelGrid: (date: Date, options?: DateLibOptions, dateLib?: DateLib) =>
32
+ (dateLib ?? new DateLib(options)).formatMonthYear(date),
33
+ labelGridcell: (
34
+ date: Date,
35
+ modifiers?: Modifiers,
36
+ options?: DateLibOptions,
37
+ dateLib?: DateLib,
38
+ ) => {
39
+ const lib = dateLib ?? new DateLib(options);
40
+ let label = lib.format(date, 'PPPP');
41
+ if (modifiers?.today) {
42
+ label = `今天,${label}`;
43
+ }
44
+ return label;
45
+ },
46
+ labelNav: '導覽列',
47
+ labelWeekNumberHeader: '週數',
48
+ labelWeekday: (date: Date, options?: DateLibOptions, dateLib?: DateLib) =>
49
+ (dateLib ?? new DateLib(options)).format(date, 'cccc'),
50
+ },
51
+ };
package/src/locale.ts ADDED
@@ -0,0 +1,108 @@
1
+ export * from 'date-fns/locale';
2
+
3
+ /**
4
+ * DayPicker locale types including translated DayPicker labels.
5
+ *
6
+ * @since V9.12.0
7
+ */
8
+ export type { DayPickerLocale, DayPickerLocaleLabels } from './classes/DateLib.js';
9
+ /**
10
+ * DayPicker locales extended with translated labels.
11
+ *
12
+ * @since V9.12.0
13
+ */
14
+ export { af } from './locale/af.js';
15
+ export { ar } from './locale/ar.js';
16
+ export { arDZ } from './locale/ar-DZ.js';
17
+ export { arEG } from './locale/ar-EG.js';
18
+ export { arMA } from './locale/ar-MA.js';
19
+ export { arSA } from './locale/ar-SA.js';
20
+ export { arTN } from './locale/ar-TN.js';
21
+ export { az } from './locale/az.js';
22
+ export { be } from './locale/be.js';
23
+ export { beTarask } from './locale/be-tarask.js';
24
+ export { bg } from './locale/bg.js';
25
+ export { bn } from './locale/bn.js';
26
+ export { bs } from './locale/bs.js';
27
+ export { ca } from './locale/ca.js';
28
+ export { ckb } from './locale/ckb.js';
29
+ export { cs } from './locale/cs.js';
30
+ export { cy } from './locale/cy.js';
31
+ export { da } from './locale/da.js';
32
+ export { de } from './locale/de.js';
33
+ export { deAT } from './locale/de-AT.js';
34
+ export { el } from './locale/el.js';
35
+ export { enAU } from './locale/en-AU.js';
36
+ export { enCA } from './locale/en-CA.js';
37
+ export { enGB } from './locale/en-GB.js';
38
+ export { enIE } from './locale/en-IE.js';
39
+ export { enIN } from './locale/en-IN.js';
40
+ export { enNZ } from './locale/en-NZ.js';
41
+ export { enUS } from './locale/en-US.js';
42
+ export { enZA } from './locale/en-ZA.js';
43
+ export { eo } from './locale/eo.js';
44
+ export { es } from './locale/es.js';
45
+ export { et } from './locale/et.js';
46
+ export { eu } from './locale/eu.js';
47
+ export { faIR } from './locale/fa-IR.js';
48
+ export { fi } from './locale/fi.js';
49
+ export { fr } from './locale/fr.js';
50
+ export { frCA } from './locale/fr-CA.js';
51
+ export { frCH } from './locale/fr-CH.js';
52
+ export { fy } from './locale/fy.js';
53
+ export { gd } from './locale/gd.js';
54
+ export { gl } from './locale/gl.js';
55
+ export { gu } from './locale/gu.js';
56
+ export { he } from './locale/he.js';
57
+ export { hi } from './locale/hi.js';
58
+ export { hr } from './locale/hr.js';
59
+ export { ht } from './locale/ht.js';
60
+ export { hu } from './locale/hu.js';
61
+ export { hy } from './locale/hy.js';
62
+ export { id } from './locale/id.js';
63
+ export { is } from './locale/is.js';
64
+ export { it } from './locale/it.js';
65
+ export { itCH } from './locale/it-CH.js';
66
+ export { ja } from './locale/ja.js';
67
+ export { jaHira } from './locale/ja-Hira.js';
68
+ export { ka } from './locale/ka.js';
69
+ export { kk } from './locale/kk.js';
70
+ export { km } from './locale/km.js';
71
+ export { kn } from './locale/kn.js';
72
+ export { ko } from './locale/ko.js';
73
+ export { lb } from './locale/lb.js';
74
+ export { lt } from './locale/lt.js';
75
+ export { lv } from './locale/lv.js';
76
+ export { mk } from './locale/mk.js';
77
+ export { mn } from './locale/mn.js';
78
+ export { ms } from './locale/ms.js';
79
+ export { mt } from './locale/mt.js';
80
+ export { nb } from './locale/nb.js';
81
+ export { nl } from './locale/nl.js';
82
+ export { nlBE } from './locale/nl-BE.js';
83
+ export { nn } from './locale/nn.js';
84
+ export { oc } from './locale/oc.js';
85
+ export { pl } from './locale/pl.js';
86
+ export { pt } from './locale/pt.js';
87
+ export { ptBR } from './locale/pt-BR.js';
88
+ export { ro } from './locale/ro.js';
89
+ export { ru } from './locale/ru.js';
90
+ export { se } from './locale/se.js';
91
+ export { sk } from './locale/sk.js';
92
+ export { sl } from './locale/sl.js';
93
+ export { sq } from './locale/sq.js';
94
+ export { sr } from './locale/sr.js';
95
+ export { srLatn } from './locale/sr-Latn.js';
96
+ export { sv } from './locale/sv.js';
97
+ export { ta } from './locale/ta.js';
98
+ export { te } from './locale/te.js';
99
+ export { th } from './locale/th.js';
100
+ export { tr } from './locale/tr.js';
101
+ export { ug } from './locale/ug.js';
102
+ export { uk } from './locale/uk.js';
103
+ export { uz } from './locale/uz.js';
104
+ export { uzCyrl } from './locale/uz-Cyrl.js';
105
+ export { vi } from './locale/vi.js';
106
+ export { zhCN } from './locale/zh-CN.js';
107
+ export { zhHK } from './locale/zh-HK.js';
108
+ export { zhTW } from './locale/zh-TW.js';