@kanso-labs/react-native-kanso-ui 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (253) hide show
  1. package/README.md +4 -3
  2. package/dist/autocomplete/index.js +15 -1
  3. package/dist/autocomplete/index.js.map +1 -1
  4. package/dist/badge/index.js +9 -70
  5. package/dist/badge/index.js.map +1 -1
  6. package/dist/button/group.d.ts +5 -0
  7. package/dist/button/group.js +115 -0
  8. package/dist/button/group.js.map +1 -0
  9. package/dist/button/index.d.ts +4 -1
  10. package/dist/button/index.js +45 -23
  11. package/dist/button/index.js.map +1 -1
  12. package/dist/button/palettes.d.ts +2 -0
  13. package/dist/button/slots.js +2 -1
  14. package/dist/button/slots.js.map +1 -1
  15. package/dist/calendar/index.js +351 -182
  16. package/dist/calendar/index.js.map +1 -1
  17. package/dist/calendar/styles.js +33 -2
  18. package/dist/calendar/styles.js.map +1 -1
  19. package/dist/carousel/arrangement.d.ts +5 -0
  20. package/dist/carousel/arrangement.js +123 -0
  21. package/dist/carousel/arrangement.js.map +1 -0
  22. package/dist/chequer/index.js +95 -0
  23. package/dist/chequer/index.js.map +1 -0
  24. package/dist/collection/index.d.ts +157 -0
  25. package/dist/collection/index.js +1331 -0
  26. package/dist/collection/index.js.map +1 -0
  27. package/dist/color-thumb/index.js +56 -0
  28. package/dist/color-thumb/index.js.map +1 -0
  29. package/dist/components/badge/index.d.ts +48 -0
  30. package/dist/components/badge/index.js +122 -0
  31. package/dist/components/badge/index.js.map +1 -0
  32. package/dist/{badge → components/badge}/styles.js +10 -6
  33. package/dist/components/badge/styles.js.map +1 -0
  34. package/dist/components/breadcrumbs/index.d.ts +66 -0
  35. package/dist/components/breadcrumbs/index.js +285 -0
  36. package/dist/components/breadcrumbs/index.js.map +1 -0
  37. package/dist/components/button/index.d.ts +4 -2
  38. package/dist/components/button/index.js +227 -188
  39. package/dist/components/button/index.js.map +1 -1
  40. package/dist/components/button-group/index.d.ts +87 -0
  41. package/dist/components/button-group/index.js +275 -0
  42. package/dist/components/button-group/index.js.map +1 -0
  43. package/dist/components/calendar/index.d.ts +11 -3
  44. package/dist/components/calendar/index.js +60 -45
  45. package/dist/components/calendar/index.js.map +1 -1
  46. package/dist/components/carousel/index.d.ts +72 -0
  47. package/dist/components/carousel/index.js +496 -0
  48. package/dist/components/carousel/index.js.map +1 -0
  49. package/dist/components/checkbox/index.d.ts +7 -1
  50. package/dist/components/checkbox/index.js +183 -138
  51. package/dist/components/checkbox/index.js.map +1 -1
  52. package/dist/components/checkbox-group/index.d.ts +92 -0
  53. package/dist/components/checkbox-group/index.js +306 -0
  54. package/dist/components/checkbox-group/index.js.map +1 -0
  55. package/dist/components/code/index.d.ts +25 -0
  56. package/dist/components/code/index.js +87 -0
  57. package/dist/components/code/index.js.map +1 -0
  58. package/dist/components/color-area/index.d.ts +85 -0
  59. package/dist/components/color-area/index.js +630 -0
  60. package/dist/components/color-area/index.js.map +1 -0
  61. package/dist/components/color-field/index.d.ts +144 -0
  62. package/dist/components/color-field/index.js +516 -0
  63. package/dist/components/color-field/index.js.map +1 -0
  64. package/dist/components/color-picker/index.d.ts +74 -0
  65. package/dist/components/color-picker/index.js +317 -0
  66. package/dist/components/color-picker/index.js.map +1 -0
  67. package/dist/components/color-slider/index.d.ts +82 -0
  68. package/dist/components/color-slider/index.js +456 -0
  69. package/dist/components/color-slider/index.js.map +1 -0
  70. package/dist/components/color-swatch/index.d.ts +46 -0
  71. package/dist/components/color-swatch/index.js +127 -0
  72. package/dist/components/color-swatch/index.js.map +1 -0
  73. package/dist/components/color-swatch-picker/index.d.ts +81 -0
  74. package/dist/components/color-swatch-picker/index.js +287 -0
  75. package/dist/components/color-swatch-picker/index.js.map +1 -0
  76. package/dist/components/color-wheel/index.d.ts +71 -0
  77. package/dist/components/color-wheel/index.js +407 -0
  78. package/dist/components/color-wheel/index.js.map +1 -0
  79. package/dist/components/combo-box/index.d.ts +193 -0
  80. package/dist/components/combo-box/index.js +616 -0
  81. package/dist/components/combo-box/index.js.map +1 -0
  82. package/dist/components/container/index.d.ts +47 -0
  83. package/dist/components/container/index.js +85 -0
  84. package/dist/components/container/index.js.map +1 -0
  85. package/dist/components/date-field/index.d.ts +120 -0
  86. package/dist/components/date-field/index.js +111 -0
  87. package/dist/components/date-field/index.js.map +1 -0
  88. package/dist/components/date-picker/index.d.ts +130 -0
  89. package/dist/components/date-picker/index.js +310 -0
  90. package/dist/components/date-picker/index.js.map +1 -0
  91. package/dist/components/date-range-picker/index.d.ts +139 -0
  92. package/dist/components/date-range-picker/index.js +421 -0
  93. package/dist/components/date-range-picker/index.js.map +1 -0
  94. package/dist/components/disclosure/index.d.ts +94 -0
  95. package/dist/components/disclosure/index.js +365 -0
  96. package/dist/components/disclosure/index.js.map +1 -0
  97. package/dist/components/disclosure-group/index.d.ts +61 -0
  98. package/dist/components/disclosure-group/index.js +100 -0
  99. package/dist/components/disclosure-group/index.js.map +1 -0
  100. package/dist/components/drop-zone/index.d.ts +113 -0
  101. package/dist/components/drop-zone/index.js +304 -0
  102. package/dist/components/drop-zone/index.js.map +1 -0
  103. package/dist/components/fab/index.d.ts +80 -0
  104. package/dist/components/fab/index.js +246 -0
  105. package/dist/components/fab/index.js.map +1 -0
  106. package/dist/components/fab-menu/index.d.ts +120 -0
  107. package/dist/components/fab-menu/index.js +640 -0
  108. package/dist/components/fab-menu/index.js.map +1 -0
  109. package/dist/components/feed/index.d.ts +57 -0
  110. package/dist/components/feed/index.js +167 -0
  111. package/dist/components/feed/index.js.map +1 -0
  112. package/dist/components/form/index.d.ts +3 -2
  113. package/dist/components/form/index.js.map +1 -1
  114. package/dist/components/icon-button/index.d.ts +4 -2
  115. package/dist/components/icon-button/index.js +204 -171
  116. package/dist/components/icon-button/index.js.map +1 -1
  117. package/dist/components/keycap/index.d.ts +27 -0
  118. package/dist/components/keycap/index.js +136 -0
  119. package/dist/components/keycap/index.js.map +1 -0
  120. package/dist/components/list/index.d.ts +15 -158
  121. package/dist/components/list/index.js +21 -1047
  122. package/dist/components/list/index.js.map +1 -1
  123. package/dist/components/list-box/index.d.ts +73 -0
  124. package/dist/components/list-box/index.js +82 -0
  125. package/dist/components/list-box/index.js.map +1 -0
  126. package/dist/components/loading-indicator/index.d.ts +32 -0
  127. package/dist/components/loading-indicator/index.js +174 -0
  128. package/dist/components/loading-indicator/index.js.map +1 -0
  129. package/dist/components/menu/index.js +1 -1
  130. package/dist/components/navigation-tree/index.d.ts +117 -0
  131. package/dist/components/navigation-tree/index.js +135 -0
  132. package/dist/components/navigation-tree/index.js.map +1 -0
  133. package/dist/components/number-field/index.js +132 -143
  134. package/dist/components/number-field/index.js.map +1 -1
  135. package/dist/components/range-calendar/index.d.ts +69 -0
  136. package/dist/components/range-calendar/index.js +144 -0
  137. package/dist/components/range-calendar/index.js.map +1 -0
  138. package/dist/components/search-view/index.d.ts +78 -0
  139. package/dist/components/search-view/index.js +570 -0
  140. package/dist/components/search-view/index.js.map +1 -0
  141. package/dist/components/select/index.d.ts +152 -0
  142. package/dist/components/select/index.js +419 -0
  143. package/dist/components/select/index.js.map +1 -0
  144. package/dist/components/separator/index.d.ts +3 -2
  145. package/dist/components/separator/index.js +29 -26
  146. package/dist/components/separator/index.js.map +1 -1
  147. package/dist/components/slider/index.d.ts +111 -0
  148. package/dist/components/slider/index.js +673 -0
  149. package/dist/components/slider/index.js.map +1 -0
  150. package/dist/components/split-button/index.d.ts +77 -0
  151. package/dist/components/split-button/index.js +354 -0
  152. package/dist/components/split-button/index.js.map +1 -0
  153. package/dist/components/supporting-pane/index.d.ts +44 -0
  154. package/dist/components/supporting-pane/index.js +109 -0
  155. package/dist/components/supporting-pane/index.js.map +1 -0
  156. package/dist/components/tabs/index.d.ts +196 -0
  157. package/dist/components/tabs/index.js +1137 -0
  158. package/dist/components/tabs/index.js.map +1 -0
  159. package/dist/components/text/index.d.ts +1 -1
  160. package/dist/components/text/index.js +49 -21
  161. package/dist/components/text/index.js.map +1 -1
  162. package/dist/components/text-area/index.d.ts +145 -0
  163. package/dist/components/text-area/index.js +231 -0
  164. package/dist/components/text-area/index.js.map +1 -0
  165. package/dist/components/time-field/index.d.ts +43 -0
  166. package/dist/components/time-field/index.js +107 -0
  167. package/dist/components/time-field/index.js.map +1 -0
  168. package/dist/components/time-picker/index.d.ts +65 -0
  169. package/dist/components/time-picker/index.js +1168 -0
  170. package/dist/components/time-picker/index.js.map +1 -0
  171. package/dist/components/toolbar/index.d.ts +53 -0
  172. package/dist/components/toolbar/index.js +185 -0
  173. package/dist/components/toolbar/index.js.map +1 -0
  174. package/dist/components/tooltip/index.d.ts +101 -0
  175. package/dist/components/tooltip/index.js +223 -0
  176. package/dist/components/tooltip/index.js.map +1 -0
  177. package/dist/components/tree/index.d.ts +112 -0
  178. package/dist/components/tree/index.js +157 -0
  179. package/dist/components/tree/index.js.map +1 -0
  180. package/dist/control/group.js +23 -0
  181. package/dist/control/group.js.map +1 -0
  182. package/dist/disclosure/chevron.js +75 -0
  183. package/dist/disclosure/chevron.js.map +1 -0
  184. package/dist/disclosure/index.js +7 -0
  185. package/dist/disclosure/index.js.map +1 -0
  186. package/dist/drop/index.d.ts +54 -0
  187. package/dist/drop/index.js +161 -0
  188. package/dist/drop/index.js.map +1 -0
  189. package/dist/fab/index.d.ts +19 -0
  190. package/dist/fab/index.js +147 -0
  191. package/dist/fab/index.js.map +1 -0
  192. package/dist/field/chevron.js +74 -0
  193. package/dist/field/chevron.js.map +1 -0
  194. package/dist/field/index.d.ts +2 -1
  195. package/dist/field/index.js +350 -153
  196. package/dist/field/index.js.map +1 -1
  197. package/dist/field/styles.js +27 -0
  198. package/dist/field/styles.js.map +1 -1
  199. package/dist/files/index.d.ts +18 -0
  200. package/dist/files/index.js +107 -0
  201. package/dist/files/index.js.map +1 -0
  202. package/dist/form/index.d.ts +6 -4
  203. package/dist/form/index.js +64 -85
  204. package/dist/form/index.js.map +1 -1
  205. package/dist/glyphs/index.js +92 -1
  206. package/dist/glyphs/index.js.map +1 -1
  207. package/dist/i18n/index.js +20 -1
  208. package/dist/i18n/index.js.map +1 -1
  209. package/dist/i18n/messages.js +1394 -34
  210. package/dist/i18n/messages.js.map +1 -1
  211. package/dist/index.d.ts +51 -6
  212. package/dist/index.js +47 -4
  213. package/dist/indicator/paths.js +23 -1
  214. package/dist/indicator/paths.js.map +1 -1
  215. package/dist/modal/index.js +96 -68
  216. package/dist/modal/index.js.map +1 -1
  217. package/dist/navigation/index.js +8 -5
  218. package/dist/navigation/index.js.map +1 -1
  219. package/dist/number/keyboard.js +16 -0
  220. package/dist/number/keyboard.js.map +1 -0
  221. package/dist/overlay/anchored.js +68 -38
  222. package/dist/overlay/anchored.js.map +1 -1
  223. package/dist/overlay/keyboard.js +57 -0
  224. package/dist/overlay/keyboard.js.map +1 -0
  225. package/dist/overlay/panel.js +173 -19
  226. package/dist/overlay/panel.js.map +1 -1
  227. package/dist/overlay/placement.js +16 -2
  228. package/dist/overlay/placement.js.map +1 -1
  229. package/dist/picker/index.js +322 -0
  230. package/dist/picker/index.js.map +1 -0
  231. package/dist/press/index.d.ts +2 -0
  232. package/dist/press/index.js +102 -100
  233. package/dist/press/index.js.map +1 -1
  234. package/dist/row/index.js +77 -69
  235. package/dist/row/index.js.map +1 -1
  236. package/dist/row/styles.js +13 -2
  237. package/dist/row/styles.js.map +1 -1
  238. package/dist/segments/field.js +277 -0
  239. package/dist/segments/field.js.map +1 -0
  240. package/dist/segments/index.js +574 -0
  241. package/dist/segments/index.js.map +1 -0
  242. package/dist/segments/styles.js +24 -0
  243. package/dist/segments/styles.js.map +1 -0
  244. package/dist/separator/index.js +7 -0
  245. package/dist/separator/index.js.map +1 -0
  246. package/dist/slider/index.js +145 -0
  247. package/dist/slider/index.js.map +1 -0
  248. package/dist/swatch/index.js +56 -0
  249. package/dist/swatch/index.js.map +1 -0
  250. package/dist/typography/size.js +14 -0
  251. package/dist/typography/size.js.map +1 -0
  252. package/package.json +11 -2
  253. package/dist/badge/styles.js.map +0 -1
@@ -6,71 +6,123 @@ import { withOpacity } from "../theme/color.js";
6
6
  import { messagesFor } from "../i18n/index.js";
7
7
  import { ArrowDropDownGlyph, CheckGlyph, ChevronEndGlyph } from "../glyphs/index.js";
8
8
  import { IconButton } from "../components/icon-button/index.js";
9
+ import { useWindowSizeClass } from "../hooks/useWindowSizeClass.js";
9
10
  import { useFocusOnPlaced, useReturnFocus } from "../overlay/panel.js";
10
- import { styles, stylesOf } from "./styles.js";
11
+ import { rootWidthOf, styles, stylesOf } from "./styles.js";
11
12
  import { c } from "react/compiler-runtime";
12
- import { FlatList, I18nManager, Pressable, Text, View } from "react-native";
13
+ import { FlatList, I18nManager, Pressable, StyleSheet, Text, View } from "react-native";
13
14
  import Animated, { Easing, useAnimatedStyle, useReducedMotion, useSharedValue, withTiming } from "react-native-reanimated";
14
- import { useLayoutEffect, useRef, useState } from "react";
15
+ import { createContext, use, useLayoutEffect, useRef, useState } from "react";
15
16
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
16
- import { DateFormatter, endOfMonth, isSameDay, isSameYear, isToday, startOfMonth, startOfWeek, toCalendarDate, today } from "@internationalized/date";
17
+ import { DateFormatter, endOfMonth, isSameDay, isSameMonth, isSameYear, isToday, startOfMonth, startOfWeek, toCalendarDate, today } from "@internationalized/date";
17
18
  //#region src/calendar/index.tsx
19
+ /**
20
+ * Where a calendar hands over the cell of the date it is on, the one held or
21
+ * else the one it opened on, for a surface that sends a screen reader to that
22
+ * date as it opens, as a date picker's does. The cell hands itself over as it
23
+ * becomes that date and `null` as it stops being it. Outside such a surface
24
+ * it is `null`, and no cell hands anything over.
25
+ */
26
+ const CalendarFocusContext = createContext(null);
18
27
  const LISTED_YEARS = 201;
19
28
  const ROWS_ABOVE_SHOWN = 3;
20
29
  /**
21
- * What a calendar draws inside its container. With `showMonthYearMenus` the
22
- * header is the date pickers page's docked one, the month and the year as
23
- * menu buttons, and while either is open its list takes the grid's place.
30
+ * What a calendar draws inside its container: the header, and a grid for each
31
+ * month it shows. With `showMonthYearMenus` the header is the date pickers
32
+ * page's docked one, the month and the year as menu buttons, and while either
33
+ * is open its list takes the grid's place.
34
+ *
35
+ * The menus are for one month. They name and pick the first month alone, so
36
+ * a second grid beside it would have no month or year of its own; with more
37
+ * than one the header is the plain one, whose heading names every month
38
+ * shown, both years where they are two, as web's does.
24
39
  */
25
40
  function CalendarFrame(t0) {
26
- const $ = c(14);
27
- const { firstDayOfWeek, locale, showMonthYearMenus, state } = t0;
28
- let t1;
29
- if ($[0] !== firstDayOfWeek || $[1] !== locale || $[2] !== state) {
30
- t1 = /* @__PURE__ */ jsx(MonthGrid, {
31
- firstDayOfWeek,
32
- locale,
33
- state
41
+ const $ = c(28);
42
+ const { firstDayOfWeek, locale, months, showMonthYearMenus, state } = t0;
43
+ const t1 = useTheme();
44
+ let t2;
45
+ if ($[0] !== t1) {
46
+ t2 = stylesOf(t1);
47
+ $[0] = t1;
48
+ $[1] = t2;
49
+ } else t2 = $[1];
50
+ const own = t2;
51
+ const sideBySide = useSideBySide(months);
52
+ const t3 = sideBySide ? own.monthsSideBySide : own.months;
53
+ let t4;
54
+ if ($[2] !== firstDayOfWeek || $[3] !== locale || $[4] !== months || $[5] !== own.monthSideBySide || $[6] !== sideBySide || $[7] !== state) {
55
+ let t5;
56
+ if ($[9] !== firstDayOfWeek || $[10] !== locale || $[11] !== own.monthSideBySide || $[12] !== sideBySide || $[13] !== state) {
57
+ t5 = (offset) => /* @__PURE__ */ jsx(View, {
58
+ style: sideBySide ? own.monthSideBySide : void 0,
59
+ children: /* @__PURE__ */ jsx(MonthGrid, {
60
+ firstDayOfWeek,
61
+ locale,
62
+ offset,
63
+ state
64
+ })
65
+ }, offset.months);
66
+ $[9] = firstDayOfWeek;
67
+ $[10] = locale;
68
+ $[11] = own.monthSideBySide;
69
+ $[12] = sideBySide;
70
+ $[13] = state;
71
+ $[14] = t5;
72
+ } else t5 = $[14];
73
+ t4 = offsetsOf(months).map(t5);
74
+ $[2] = firstDayOfWeek;
75
+ $[3] = locale;
76
+ $[4] = months;
77
+ $[5] = own.monthSideBySide;
78
+ $[6] = sideBySide;
79
+ $[7] = state;
80
+ $[8] = t4;
81
+ } else t4 = $[8];
82
+ let t5;
83
+ if ($[15] !== t3 || $[16] !== t4) {
84
+ t5 = /* @__PURE__ */ jsx(View, {
85
+ style: t3,
86
+ children: t4
34
87
  });
35
- $[0] = firstDayOfWeek;
36
- $[1] = locale;
37
- $[2] = state;
38
- $[3] = t1;
39
- } else t1 = $[3];
40
- const grid = t1;
41
- if (showMonthYearMenus) {
42
- let t2;
43
- if ($[4] !== grid || $[5] !== locale || $[6] !== state) {
44
- t2 = /* @__PURE__ */ jsx(CalendarMenus, {
88
+ $[15] = t3;
89
+ $[16] = t4;
90
+ $[17] = t5;
91
+ } else t5 = $[17];
92
+ const grids = t5;
93
+ if (showMonthYearMenus && months <= 1) {
94
+ let t6;
95
+ if ($[18] !== grids || $[19] !== locale || $[20] !== state) {
96
+ t6 = /* @__PURE__ */ jsx(CalendarMenus, {
45
97
  locale,
46
98
  state,
47
- children: grid
99
+ children: grids
48
100
  });
49
- $[4] = grid;
50
- $[5] = locale;
51
- $[6] = state;
52
- $[7] = t2;
53
- } else t2 = $[7];
54
- return t2;
101
+ $[18] = grids;
102
+ $[19] = locale;
103
+ $[20] = state;
104
+ $[21] = t6;
105
+ } else t6 = $[21];
106
+ return t6;
55
107
  }
56
- let t2;
57
- if ($[8] !== locale || $[9] !== state) {
58
- t2 = /* @__PURE__ */ jsx(CalendarHeader, {
108
+ let t6;
109
+ if ($[22] !== locale || $[23] !== state) {
110
+ t6 = /* @__PURE__ */ jsx(CalendarHeader, {
59
111
  locale,
60
112
  state
61
113
  });
62
- $[8] = locale;
63
- $[9] = state;
64
- $[10] = t2;
65
- } else t2 = $[10];
66
- let t3;
67
- if ($[11] !== grid || $[12] !== t2) {
68
- t3 = /* @__PURE__ */ jsxs(Fragment$1, { children: [t2, grid] });
69
- $[11] = grid;
70
- $[12] = t2;
71
- $[13] = t3;
72
- } else t3 = $[13];
73
- return t3;
114
+ $[22] = locale;
115
+ $[23] = state;
116
+ $[24] = t6;
117
+ } else t6 = $[24];
118
+ let t7;
119
+ if ($[25] !== grids || $[26] !== t6) {
120
+ t7 = /* @__PURE__ */ jsxs(Fragment$1, { children: [t6, grids] });
121
+ $[25] = grids;
122
+ $[26] = t6;
123
+ $[27] = t7;
124
+ } else t7 = $[27];
125
+ return t7;
74
126
  }
75
127
  /** The two chevrons with the month and year between them. */
76
128
  function CalendarHeader(t0) {
@@ -97,7 +149,7 @@ function CalendarHeader(t0) {
97
149
  const t5 = composeStyles(role, own.heading);
98
150
  let t6;
99
151
  if ($[3] !== locale || $[4] !== state) {
100
- t6 = visibleMonthOf(state, locale);
152
+ t6 = visibleRangeOf(state, locale);
101
153
  $[3] = locale;
102
154
  $[4] = state;
103
155
  $[5] = t6;
@@ -418,119 +470,159 @@ function chooseThen(state, setOpen, shown) {
418
470
  setOpen(null);
419
471
  };
420
472
  }
473
+ function cornersOf(shape) {
474
+ const { borderBottomEndRadius, borderBottomStartRadius, borderRadius, borderTopEndRadius, borderTopStartRadius } = StyleSheet.flatten(shape) ?? {};
475
+ return {
476
+ borderBottomEndRadius,
477
+ borderBottomStartRadius,
478
+ borderRadius,
479
+ borderTopEndRadius,
480
+ borderTopStartRadius
481
+ };
482
+ }
421
483
  /**
422
484
  * One date: the page's 40dp circle in its 48dp square, which `hitSlop` makes
423
485
  * the press target. Its name is the date in full, with today, the selection
424
486
  * and the first or last date the bounds allow said as web says them, and it
425
- * reports itself disabled where it cannot be picked.
487
+ * reports itself disabled where it cannot be picked, as a date of the months
488
+ * either side of its grid's is.
489
+ *
490
+ * In a range calendar a selected day is the band instead, as wide as its
491
+ * column, with the two ends filled and round on their outer side, and the
492
+ * state layers follow the ground under them: on primary over an end, on
493
+ * primary container over the band, on surface elsewhere. While a range is
494
+ * started, a pointer over a date draws the range as far as it, as web's
495
+ * does; a touch has no such preview, and the second press ends the range.
426
496
  */
427
497
  function DateCell(t0) {
428
- const $ = c(29);
429
- const { date, locale, state } = t0;
498
+ const $ = c(37);
499
+ const { date, locale, month, state } = t0;
430
500
  const theme = useTheme();
431
501
  const { colors, sizing } = theme;
432
502
  const own = stylesOf(theme);
433
503
  const role = useTypeRole("bodyLarge");
434
504
  let t1;
435
- if ($[0] !== date || $[1] !== state) {
436
- t1 = state.isCellDisabled(date);
505
+ if ($[0] !== date || $[1] !== month || $[2] !== state) {
506
+ t1 = state.isCellDisabled(date) || !isSameMonth(date, month);
437
507
  $[0] = date;
438
- $[1] = state;
439
- $[2] = t1;
440
- } else t1 = $[2];
508
+ $[1] = month;
509
+ $[2] = state;
510
+ $[3] = t1;
511
+ } else t1 = $[3];
441
512
  const isDisabled = t1;
442
513
  let t2;
443
- if ($[3] !== date || $[4] !== state) {
514
+ if ($[4] !== date || $[5] !== state) {
444
515
  t2 = state.isCellUnavailable(date);
445
- $[3] = date;
446
- $[4] = state;
447
- $[5] = t2;
448
- } else t2 = $[5];
516
+ $[4] = date;
517
+ $[5] = state;
518
+ $[6] = t2;
519
+ } else t2 = $[6];
449
520
  const isUnavailable = t2;
450
521
  const selectable = !isDisabled && !isUnavailable;
451
522
  const isSelected = selectable && state.isSelected(date);
452
523
  const isCurrent = isToday(date, state.timeZone);
524
+ const range = rangeOf(state, date, isSelected);
525
+ const isFilled = range === null ? isSelected : range.isEnd;
526
+ const report = use(CalendarFocusContext);
527
+ const isFocused = isSameMonth(date, month) && isSameDay(date, state.focusedDate);
528
+ const shape = composeStyles(own.date, range === null ? void 0 : own.dateInRange, range?.isFirst === true ? own.dateRangeStart : void 0, range?.isLast === true ? own.dateRangeEnd : void 0);
453
529
  const feedback = usePressFeedback({
454
- color: isSelected ? colors.onPrimary : colors.onSurface,
455
- corners: own.date,
456
- disabled: !selectable
530
+ color: isFilled ? colors.onPrimary : range === null ? colors.onSurface : colors.onPrimaryContainer,
531
+ corners: cornersOf(shape),
532
+ disabled: !selectable,
533
+ onHoverIn: highlightThen(state, date)
457
534
  });
458
535
  const T0 = Pressable;
459
- const t3 = dateLabelOf(date, state, locale, isCurrent, isSelected);
460
- let t4;
461
- if ($[6] !== sizing.controlSm) {
462
- t4 = hitSlop(sizing.controlSm, sizing.controlSm);
463
- $[6] = sizing.controlSm;
464
- $[7] = t4;
465
- } else t4 = $[7];
466
- let t5;
467
- if ($[8] !== date || $[9] !== state) {
468
- t5 = selectThen(state, date);
469
- $[8] = date;
536
+ let t3;
537
+ if ($[7] !== locale || $[8] !== selectable || $[9] !== state) {
538
+ t3 = promptOf(state, locale, selectable);
539
+ $[7] = locale;
540
+ $[8] = selectable;
470
541
  $[9] = state;
471
- $[10] = t5;
472
- } else t5 = $[10];
473
- const t6 = "button";
474
- const t7 = feedback.handlers;
475
- const t8 = !selectable;
476
- const t9 = composeStyles(own.date, isCurrent ? own.dateToday : void 0, isSelected ? own.dateSelected : void 0, feedback.ring);
477
- const t10 = feedback.layer;
542
+ $[10] = t3;
543
+ } else t3 = $[10];
544
+ const t4 = dateLabelOf(date, state, locale, isCurrent, isSelected);
545
+ const t5 = range === null ? sizing.controlSm : void 0;
546
+ let t6;
547
+ if ($[11] !== sizing.controlSm || $[12] !== t5) {
548
+ t6 = hitSlop(sizing.controlSm, t5);
549
+ $[11] = sizing.controlSm;
550
+ $[12] = t5;
551
+ $[13] = t6;
552
+ } else t6 = $[13];
553
+ let t7;
554
+ if ($[14] !== date || $[15] !== state) {
555
+ t7 = selectThen(state, date);
556
+ $[14] = date;
557
+ $[15] = state;
558
+ $[16] = t7;
559
+ } else t7 = $[16];
560
+ const t8 = isFocused && report !== null ? report : void 0;
561
+ const t9 = "button";
562
+ const t10 = feedback.handlers;
563
+ const t11 = !selectable;
564
+ const t12 = composeStyles(shape, isCurrent ? own.dateToday : void 0, isFilled ? own.dateSelected : void 0, feedback.ring);
565
+ const t13 = feedback.layer;
478
566
  const T1 = Text;
479
- const t11 = composeStyles(role, own.dateText, isCurrent ? own.dateTextToday : void 0, isSelected ? own.dateTextSelected : void 0, isUnavailable ? own.dateTextUnavailable : void 0, isDisabled ? own.dateTextDisabled : void 0);
480
- let t12;
481
- if ($[11] !== date || $[12] !== locale || $[13] !== state) {
482
- t12 = dayOf(date, state, locale);
483
- $[11] = date;
484
- $[12] = locale;
485
- $[13] = state;
486
- $[14] = t12;
487
- } else t12 = $[14];
488
- let t13;
489
- if ($[15] !== T1 || $[16] !== t11 || $[17] !== t12) {
490
- t13 = /* @__PURE__ */ jsx(T1, {
491
- style: t11,
492
- children: t12
567
+ const t14 = composeStyles(role, own.dateText, isCurrent ? own.dateTextToday : void 0, range === null ? void 0 : own.dateTextInRange, isFilled ? own.dateTextSelected : void 0, isUnavailable ? own.dateTextUnavailable : void 0, isDisabled ? own.dateTextDisabled : void 0);
568
+ let t15;
569
+ if ($[17] !== date || $[18] !== locale || $[19] !== state) {
570
+ t15 = dayOf(date, state, locale);
571
+ $[17] = date;
572
+ $[18] = locale;
573
+ $[19] = state;
574
+ $[20] = t15;
575
+ } else t15 = $[20];
576
+ let t16;
577
+ if ($[21] !== T1 || $[22] !== t14 || $[23] !== t15) {
578
+ t16 = /* @__PURE__ */ jsx(T1, {
579
+ style: t14,
580
+ children: t15
493
581
  });
494
- $[15] = T1;
495
- $[16] = t11;
496
- $[17] = t12;
497
- $[18] = t13;
498
- } else t13 = $[18];
499
- let t14;
500
- if ($[19] !== T0 || $[20] !== feedback.handlers || $[21] !== feedback.layer || $[22] !== t13 || $[23] !== t3 || $[24] !== t4 || $[25] !== t5 || $[26] !== t8 || $[27] !== t9) {
501
- t14 = /* @__PURE__ */ jsxs(T0, {
502
- "aria-label": t3,
503
- hitSlop: t4,
504
- onPress: t5,
505
- role: t6,
506
- ...t7,
507
- disabled: t8,
508
- style: t9,
509
- children: [t10, t13]
582
+ $[21] = T1;
583
+ $[22] = t14;
584
+ $[23] = t15;
585
+ $[24] = t16;
586
+ } else t16 = $[24];
587
+ let t17;
588
+ if ($[25] !== T0 || $[26] !== feedback.handlers || $[27] !== feedback.layer || $[28] !== t11 || $[29] !== t12 || $[30] !== t16 || $[31] !== t3 || $[32] !== t4 || $[33] !== t6 || $[34] !== t7 || $[35] !== t8) {
589
+ t17 = /* @__PURE__ */ jsxs(T0, {
590
+ accessibilityHint: t3,
591
+ "aria-label": t4,
592
+ hitSlop: t6,
593
+ onPress: t7,
594
+ ref: t8,
595
+ role: t9,
596
+ ...t10,
597
+ disabled: t11,
598
+ style: t12,
599
+ children: [t13, t16]
510
600
  });
511
- $[19] = T0;
512
- $[20] = feedback.handlers;
513
- $[21] = feedback.layer;
514
- $[22] = t13;
515
- $[23] = t3;
516
- $[24] = t4;
517
- $[25] = t5;
518
- $[26] = t8;
519
- $[27] = t9;
520
- $[28] = t14;
521
- } else t14 = $[28];
522
- return t14;
601
+ $[25] = T0;
602
+ $[26] = feedback.handlers;
603
+ $[27] = feedback.layer;
604
+ $[28] = t11;
605
+ $[29] = t12;
606
+ $[30] = t16;
607
+ $[31] = t3;
608
+ $[32] = t4;
609
+ $[33] = t6;
610
+ $[34] = t7;
611
+ $[35] = t8;
612
+ $[36] = t17;
613
+ } else t17 = $[36];
614
+ return t17;
523
615
  }
524
616
  function dateLabelOf(date, state, locale, isCurrent, isSelected) {
525
617
  const words = messagesFor(locale).calendar;
526
- const full = new DateFormatter(locale, {
618
+ const full = `${rangeNameOf(state, date, locale)}${new DateFormatter(locale, {
527
619
  day: "numeric",
528
620
  era: eraOf(date),
529
621
  month: "long",
530
622
  timeZone: state.timeZone,
531
623
  weekday: "long",
532
624
  year: "numeric"
533
- }).format(date.toDate(state.timeZone));
625
+ }).format(date.toDate(state.timeZone))}`;
534
626
  const said = isCurrent ? (isSelected ? words.todayDateSelected : words.todayDate).replace("{date}", full) : isSelected ? words.dateSelected.replace("{date}", full) : full;
535
627
  if (state.minValue != null && isSameDay(date, state.minValue)) return `${said}, ${words.minimumDate}`;
536
628
  if (state.maxValue != null && isSameDay(date, state.maxValue)) return `${said}, ${words.maximumDate}`;
@@ -546,6 +638,12 @@ function dayOf(date, state, locale) {
546
638
  function eraOf(date) {
547
639
  return date.calendar.identifier === "gregory" && date.era === "BC" ? "short" : void 0;
548
640
  }
641
+ function highlightThen(state, date) {
642
+ if (!("highlightDate" in state)) return;
643
+ return () => {
644
+ state.highlightDate(date);
645
+ };
646
+ }
549
647
  function layoutOf(height) {
550
648
  return (_data, index) => ({
551
649
  index,
@@ -715,83 +813,92 @@ function MenuList(t0) {
715
813
  return t5;
716
814
  }
717
815
  /**
718
- * The weekday row and the month's weeks, held at six weeks of room so the
816
+ * The weekday row and one month's weeks, held at six weeks of room so the
719
817
  * calendar keeps its height from month to month. The weeks slide in from the
720
818
  * side the new month comes from.
721
819
  */
722
820
  function MonthGrid(t0) {
723
- const $ = c(16);
724
- const { firstDayOfWeek, locale, state } = t0;
821
+ const $ = c(20);
822
+ const { firstDayOfWeek, locale, offset, state } = t0;
725
823
  const theme = useTheme();
726
824
  const own = stylesOf(theme);
727
825
  const role = useTypeRole("bodyLarge");
728
- const start = state.visibleRange.start;
826
+ let t1;
827
+ if ($[0] !== offset || $[1] !== state.visibleRange.start) {
828
+ t1 = state.visibleRange.start.add(offset);
829
+ $[0] = offset;
830
+ $[1] = state.visibleRange.start;
831
+ $[2] = t1;
832
+ } else t1 = $[2];
833
+ const start = t1;
729
834
  const slide = useMonthSlide(start, theme);
730
835
  const rowStyle = composeStyles(styles.row, own.rowHeight);
731
836
  const T0 = View;
732
- const t1 = own.grid;
837
+ const t2 = own.grid;
733
838
  const T1 = View;
734
- const t2 = true;
735
- const t3 = weekdaysOf(state, locale, firstDayOfWeek).map((weekday) => /* @__PURE__ */ jsx(View, {
839
+ const t3 = true;
840
+ const t4 = weekdaysOf(state, locale, firstDayOfWeek).map((weekday) => /* @__PURE__ */ jsx(View, {
736
841
  style: styles.column,
737
842
  children: /* @__PURE__ */ jsx(Text, {
738
843
  style: composeStyles(role, own.weekday),
739
844
  children: weekday.label
740
845
  })
741
846
  }, weekday.key));
742
- let t4;
743
- if ($[0] !== T1 || $[1] !== rowStyle || $[2] !== t3) {
744
- t4 = /* @__PURE__ */ jsx(T1, {
745
- "aria-hidden": t2,
847
+ let t5;
848
+ if ($[3] !== T1 || $[4] !== rowStyle || $[5] !== t4) {
849
+ t5 = /* @__PURE__ */ jsx(T1, {
850
+ "aria-hidden": t3,
746
851
  style: rowStyle,
747
- children: t3
852
+ children: t4
748
853
  });
749
- $[0] = T1;
750
- $[1] = rowStyle;
751
- $[2] = t3;
752
- $[3] = t4;
753
- } else t4 = $[3];
754
- let t5;
755
- if ($[4] !== locale || $[5] !== rowStyle || $[6] !== state) {
756
- t5 = weeksOf(state).map((week) => /* @__PURE__ */ jsx(View, {
854
+ $[3] = T1;
855
+ $[4] = rowStyle;
856
+ $[5] = t4;
857
+ $[6] = t5;
858
+ } else t5 = $[6];
859
+ let t6;
860
+ if ($[7] !== locale || $[8] !== rowStyle || $[9] !== start || $[10] !== state) {
861
+ t6 = weeksOf(state, start).map((week) => /* @__PURE__ */ jsx(View, {
757
862
  style: rowStyle,
758
863
  children: week.days.map((day) => /* @__PURE__ */ jsx(View, {
759
864
  style: styles.column,
760
865
  children: day.date === null ? null : /* @__PURE__ */ jsx(DateCell, {
761
866
  date: day.date,
762
867
  locale,
868
+ month: start,
763
869
  state
764
870
  })
765
871
  }, day.key))
766
872
  }, week.key));
767
- $[4] = locale;
768
- $[5] = rowStyle;
769
- $[6] = state;
770
- $[7] = t5;
771
- } else t5 = $[7];
772
- let t6;
773
- if ($[8] !== slide || $[9] !== t5) {
774
- t6 = /* @__PURE__ */ jsx(Animated.View, {
873
+ $[7] = locale;
874
+ $[8] = rowStyle;
875
+ $[9] = start;
876
+ $[10] = state;
877
+ $[11] = t6;
878
+ } else t6 = $[11];
879
+ let t7;
880
+ if ($[12] !== slide || $[13] !== t6) {
881
+ t7 = /* @__PURE__ */ jsx(Animated.View, {
775
882
  style: slide,
776
- children: t5
883
+ children: t6
777
884
  });
778
- $[8] = slide;
779
- $[9] = t5;
780
- $[10] = t6;
781
- } else t6 = $[10];
782
- let t7;
783
- if ($[11] !== T0 || $[12] !== own || $[13] !== t4 || $[14] !== t6) {
784
- t7 = /* @__PURE__ */ jsxs(T0, {
785
- style: t1,
786
- children: [t4, t6]
885
+ $[12] = slide;
886
+ $[13] = t6;
887
+ $[14] = t7;
888
+ } else t7 = $[14];
889
+ let t8;
890
+ if ($[15] !== T0 || $[16] !== own || $[17] !== t5 || $[18] !== t7) {
891
+ t8 = /* @__PURE__ */ jsxs(T0, {
892
+ style: t2,
893
+ children: [t5, t7]
787
894
  });
788
- $[11] = T0;
789
- $[12] = own;
790
- $[13] = t4;
791
- $[14] = t6;
792
- $[15] = t7;
793
- } else t7 = $[15];
794
- return t7;
895
+ $[15] = T0;
896
+ $[16] = own;
897
+ $[17] = t5;
898
+ $[18] = t7;
899
+ $[19] = t8;
900
+ } else t8 = $[19];
901
+ return t8;
795
902
  }
796
903
  /** The open month list: the months of the year shown, named in full. */
797
904
  function MonthList(t0) {
@@ -869,6 +976,9 @@ function monthsOf(state, locale, format) {
869
976
  };
870
977
  });
871
978
  }
979
+ function offsetsOf(months) {
980
+ return Array.from({ length: Math.max(1, months) }, (_unused, index) => ({ months: index }));
981
+ }
872
982
  function outsideBounds(state, months) {
873
983
  const { maxValue, minValue } = state;
874
984
  return new Set(months.filter(({ date }) => maxValue != null && startOfMonth(date).compare(maxValue) > 0 || minValue != null && endOfMonth(date).compare(minValue) < 0).map(({ id }) => id));
@@ -882,6 +992,36 @@ function pageThen(state, direction) {
882
992
  function previousGlyphStyle() {
883
993
  return I18nManager.isRTL ? styles.previousGlyphRightToLeft : styles.previousGlyph;
884
994
  }
995
+ function promptOf(state, locale, selectable) {
996
+ if (!("anchorDate" in state) || state.isReadOnly || !selectable) return;
997
+ const words = messagesFor(locale).calendar;
998
+ return state.anchorDate === null ? words.startRangeSelectionPrompt : words.finishRangeSelectionPrompt;
999
+ }
1000
+ function rangeNameOf(state, date, locale) {
1001
+ if (!("highlightedRange" in state) || state.value === null || state.anchorDate !== null || state.highlightedRange === null || !isSameDay(date, state.value.start) && !isSameDay(date, state.value.end)) return "";
1002
+ const { end, start } = state.highlightedRange;
1003
+ const { timeZone } = state;
1004
+ const words = messagesFor(locale).calendar;
1005
+ const formatter = new DateFormatter(locale, {
1006
+ day: "numeric",
1007
+ era: eraOf(start) ?? eraOf(end),
1008
+ month: "long",
1009
+ timeZone,
1010
+ weekday: "long",
1011
+ year: "numeric"
1012
+ });
1013
+ return `${isSameDay(start, end) ? words.selectedDateDescription.replace("{date}", formatter.format(start.toDate(timeZone))) : words.selectedRangeDescription.replace("{dateRange}", spokenRangeOf(formatter, locale, start, end, timeZone))}, `;
1014
+ }
1015
+ function rangeOf(state, date, isSelected) {
1016
+ if (!isSelected || !("highlightedRange" in state) || state.highlightedRange === null) return null;
1017
+ const isFirst = isSameDay(date, state.highlightedRange.start);
1018
+ const isLast = isSameDay(date, state.highlightedRange.end);
1019
+ return {
1020
+ isEnd: isFirst || isLast,
1021
+ isFirst,
1022
+ isLast
1023
+ };
1024
+ }
885
1025
  /**
886
1026
  * One row of an open list: the check where the row is the entry shown, the
887
1027
  * room it takes where it is not, then the month or the year, in body large.
@@ -971,6 +1111,18 @@ function selectThen(state, date) {
971
1111
  state.setFocusedDate(date);
972
1112
  };
973
1113
  }
1114
+ function spokenRangeOf(formatter, locale, start, end, timeZone) {
1115
+ const parts = formatter.formatRangeToParts(start.toDate(timeZone), end.toDate(timeZone));
1116
+ let separator = -1;
1117
+ for (const [index, part] of parts.entries()) {
1118
+ if (part.source === "endRange") break;
1119
+ if (part.source === "shared" && part.type === "literal") separator = index;
1120
+ }
1121
+ return messagesFor(locale).calendar.dateRange.replace("{startDate}", textOf(parts.slice(0, Math.max(0, separator)))).replace("{endDate}", textOf(parts.slice(separator + 1)));
1122
+ }
1123
+ function textOf(parts) {
1124
+ return parts.map((part) => part.value).join("");
1125
+ }
974
1126
  function toggleThen(setOpen, list) {
975
1127
  return () => {
976
1128
  setOpen((open) => open === list ? null : list);
@@ -1034,15 +1186,33 @@ function useMonthSlide(start, t0) {
1034
1186
  };
1035
1187
  });
1036
1188
  }
1037
- function visibleMonthOf(state, locale) {
1038
- const { start } = state.visibleRange;
1039
- return new DateFormatter(locale, {
1189
+ /**
1190
+ * The container's style for the months a calendar shows: the page's 360dp,
1191
+ * or as wide as its months side by side with the room between them.
1192
+ */
1193
+ function useRootStyle(months) {
1194
+ const theme = useTheme();
1195
+ const own = stylesOf(theme);
1196
+ return useSideBySide(months) ? composeStyles(own.root, { width: rootWidthOf(theme, months) }) : own.root;
1197
+ }
1198
+ function useSideBySide(months) {
1199
+ const sizeClass = useWindowSizeClass();
1200
+ return months > 1 && sizeClass !== "compact" && sizeClass !== "medium";
1201
+ }
1202
+ function visibleRangeOf(state, locale, spoken = false) {
1203
+ const { end, start } = state.visibleRange;
1204
+ const { timeZone } = state;
1205
+ const formatter = new DateFormatter(locale, {
1040
1206
  calendar: start.calendar.identifier,
1041
- era: eraOf(start),
1207
+ era: eraOf(start) ?? eraOf(end),
1042
1208
  month: "long",
1043
- timeZone: state.timeZone,
1209
+ timeZone,
1044
1210
  year: "numeric"
1045
- }).format(start.toDate(state.timeZone));
1211
+ });
1212
+ const first = start.calendar.getFormattableMonth?.(start) ?? start;
1213
+ if (isSameMonth(start, end)) return formatter.format(first.toDate(timeZone));
1214
+ const last = end.calendar.getFormattableMonth?.(end) ?? end;
1215
+ return spoken ? spokenRangeOf(formatter, locale, first, last, timeZone) : formatter.formatRange(first.toDate(timeZone), last.toDate(timeZone));
1046
1216
  }
1047
1217
  function weekdaysOf(state, locale, firstDayOfWeek) {
1048
1218
  const first = startOfWeek(today(state.timeZone), locale, firstDayOfWeek);
@@ -1058,12 +1228,11 @@ function weekdaysOf(state, locale, firstDayOfWeek) {
1058
1228
  };
1059
1229
  });
1060
1230
  }
1061
- function weeksOf(state) {
1062
- const { start } = state.visibleRange;
1063
- return Array.from({ length: state.getWeeksInMonth() }, (_unused, week) => {
1231
+ function weeksOf(state, start) {
1232
+ return Array.from({ length: state.getWeeksInMonth(start) }, (_unused, week) => {
1064
1233
  const key = start.add({ weeks: week }).toString();
1065
1234
  return {
1066
- days: state.getDatesInWeek(week).map((date, day) => ({
1235
+ days: state.getDatesInWeek(week, start).map((date, day) => ({
1067
1236
  date,
1068
1237
  key: date?.toString() ?? `${key}+${String(day)}`
1069
1238
  })),
@@ -1177,6 +1346,6 @@ function yearsOf(state, locale) {
1177
1346
  }
1178
1347
  const NONE = /* @__PURE__ */ new Set();
1179
1348
  //#endregion
1180
- export { CalendarFrame, visibleMonthOf };
1349
+ export { CalendarFocusContext, CalendarFrame, useRootStyle, visibleRangeOf };
1181
1350
 
1182
1351
  //# sourceMappingURL=index.js.map