@astryx-vue/core 0.2.2 → 0.2.3

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/THIRD_PARTY_NOTICES.md +2 -0
  2. package/dist/AppShell/index.d.ts +1 -1
  3. package/dist/AppShell/index.js +1 -1
  4. package/dist/{AppShell-Cb41gIAj.js → AppShell-Dd-D4bA2.js} +2 -2
  5. package/dist/AvatarGroup/index.d.ts +1 -1
  6. package/dist/Banner/index.d.ts +1 -1
  7. package/dist/Breadcrumbs/index.d.ts +3 -2
  8. package/dist/Breadcrumbs/index.js +3 -2
  9. package/dist/{Breadcrumbs-CTQ7fjDn.js → Breadcrumbs-CWGfgLNK.js} +13 -8
  10. package/dist/Button/index.d.ts +1 -1
  11. package/dist/ButtonGroup/index.d.ts +1 -1
  12. package/dist/Calendar/index.d.ts +2 -2
  13. package/dist/Calendar/index.js +1 -1
  14. package/dist/Calendar-CnOsSjMY.js +656 -0
  15. package/dist/Card/index.d.ts +1 -1
  16. package/dist/Carousel/index.js +1 -1
  17. package/dist/{Carousel-X0cuQkvg.js → Carousel-JA7ilqI_.js} +2 -2
  18. package/dist/Chat/index.d.ts +1 -1
  19. package/dist/Chat/index.js +1 -1
  20. package/dist/{Chat-M0tiGrNT.js → Chat-C7WrCOE4.js} +3 -3
  21. package/dist/CheckboxIndicator/index.js +1 -1
  22. package/dist/CheckboxIndicator-D37cm2Rh.js +68 -0
  23. package/dist/CheckboxInput/index.d.ts +1 -1
  24. package/dist/CheckboxInput/index.js +1 -1
  25. package/dist/{CheckboxInput-CMsEE1_4.js → CheckboxInput-25Q8ItH-.js} +10 -9
  26. package/dist/CheckboxList/index.d.ts +1 -1
  27. package/dist/CheckboxList/index.js +1 -1
  28. package/dist/{CheckboxList-BbCPiend.js → CheckboxList-CnCGnkZk.js} +77 -24
  29. package/dist/Citation/index.js +1 -1
  30. package/dist/{Citation-C1veUk5p.js → Citation-CtwrU33I.js} +2 -2
  31. package/dist/ClickableCard/index.d.ts +1 -1
  32. package/dist/Code/index.d.ts +1 -1
  33. package/dist/Code/index.js +2 -2
  34. package/dist/{Code-yb_KOFtJ.js → Code-BvefYRpx.js} +2 -1
  35. package/dist/{CodeBlock-DesTJAkm.js → CodeBlock-BZGzYeoL.js} +1 -1
  36. package/dist/Collapsible/index.d.ts +1 -1
  37. package/dist/Collapsible/index.js +1 -1
  38. package/dist/{Collapsible-BestK35V.js → Collapsible-3YerR-FO.js} +1 -1
  39. package/dist/CommandPalette/index.js +1 -1
  40. package/dist/{CommandPalette-BArt97V8.js → CommandPalette-BNbM9T9y.js} +1 -1
  41. package/dist/ComplexSelector/index.d.ts +1 -1
  42. package/dist/ComplexSelector/index.js +1 -1
  43. package/dist/{ComplexSelector-CAoig1RK.js → ComplexSelector-LtbLlrcj.js} +3 -3
  44. package/dist/ContextMenu/index.d.ts +3 -2
  45. package/dist/ContextMenu/index.js +3 -2
  46. package/dist/{ContextMenu-9Im6i43E.js → ContextMenu-DVQl0xL5.js} +204 -56
  47. package/dist/DateInput/index.d.ts +2 -2
  48. package/dist/DateInput/index.js +1 -1
  49. package/dist/DateInput-zm8sNc0t.js +743 -0
  50. package/dist/DateRangeInput/index.d.ts +1 -1
  51. package/dist/DateRangeInput/index.js +1 -1
  52. package/dist/{DateRangeInput-DwDy3eRo.js → DateRangeInput-DlVFzrf7.js} +54 -19
  53. package/dist/DateTimeInput/index.d.ts +1 -1
  54. package/dist/DateTimeInput/index.js +1 -1
  55. package/dist/{DateTimeInput-BYiaC9bn.js → DateTimeInput-C7Z-p6Yd.js} +54 -15
  56. package/dist/Dialog/index.d.ts +1 -1
  57. package/dist/DropdownMenu/index.d.ts +3 -3
  58. package/dist/DropdownMenu/index.js +4 -3
  59. package/dist/{DropdownMenu-Dh-WAHKb.js → DropdownMenu-BoZChdev.js} +308 -63
  60. package/dist/DropdownMenu-u1psFjis.js +325 -0
  61. package/dist/DropdownMenuRadioItem.vue-uVM0FD2f.d.ts +564 -0
  62. package/dist/FileInput/index.d.ts +1 -1
  63. package/dist/FileInput/index.js +1 -1
  64. package/dist/{FileInput-DLO6V12n.js → FileInput-QdlZn7qK.js} +2 -2
  65. package/dist/Icon/index.d.ts +4 -3
  66. package/dist/Icon/index.js +2 -2
  67. package/dist/{Icon-CJKjdJy-.js → Icon-bteSId7T.js} +113 -18
  68. package/dist/Indicator/index.d.ts +3 -0
  69. package/dist/Indicator/index.js +2 -0
  70. package/dist/InputGroup/index.d.ts +2 -2
  71. package/dist/InputGroup/index.js +3 -2
  72. package/dist/InputGroup-BzR6JRZb.js +129 -0
  73. package/dist/Lightbox/index.js +1 -1
  74. package/dist/{Lightbox-CdFCS_EA.js → Lightbox-BSzfqZ-u.js} +2 -2
  75. package/dist/List/index.d.ts +1 -1
  76. package/dist/Markdown/index.js +1 -1
  77. package/dist/{Markdown-BqKloI3w.js → Markdown-B6tSqenv.js} +8 -5
  78. package/dist/MetadataList/index.js +1 -1
  79. package/dist/{MetadataList-CvZkmisf.js → MetadataList-aN1tRn6W.js} +1 -1
  80. package/dist/MobileNav/index.js +1 -1
  81. package/dist/{MobileNavToggle-Bwi0qXXM.js → MobileNavToggle-fqcSafkc.js} +1 -1
  82. package/dist/MoreMenu/index.d.ts +1 -1
  83. package/dist/MoreMenu/index.js +1 -1
  84. package/dist/{MoreMenu-BwJaJrkB.js → MoreMenu-B3brqdK_.js} +1 -1
  85. package/dist/MultiSelector/index.d.ts +2 -2
  86. package/dist/MultiSelector/index.js +1 -1
  87. package/dist/{MultiSelector-C-ETfFy_.js → MultiSelector-BD5PMgez.js} +303 -121
  88. package/dist/{NavDisclosure-DHrSNRDR.js → NavDisclosure-DbYLDXK0.js} +1 -1
  89. package/dist/NavItem/index.d.ts +1 -1
  90. package/dist/NavMenu/index.js +2 -2
  91. package/dist/{NavMenuItem-B-k7olt5.js → NavMenuItem-DrwIMHKO.js} +1 -1
  92. package/dist/NumberInput/index.d.ts +1 -1
  93. package/dist/NumberInput/index.js +1 -1
  94. package/dist/{NumberInput-DjetVB8O.js → NumberInput-CBeU4lEl.js} +1 -1
  95. package/dist/Outline/index.js +1 -1
  96. package/dist/{Outline-Bz9c-u5y.js → Outline--HVMSB6i.js} +1 -1
  97. package/dist/OverflowList/index.d.ts +1 -1
  98. package/dist/OverflowList/index.js +1 -1
  99. package/dist/{OverflowList-ED-KN9Y5.js → OverflowList-FMh7r-r_.js} +3 -3
  100. package/dist/Pagination/index.d.ts +1 -1
  101. package/dist/Pagination/index.js +1 -1
  102. package/dist/{Pagination-Cb66HMEf.js → Pagination-DlIvESjx.js} +2 -2
  103. package/dist/Popover/index.d.ts +1 -1
  104. package/dist/Popover/index.js +1 -1
  105. package/dist/{Popover-Crhk9PNP.js → Popover-D7zqpFwU.js} +1 -1
  106. package/dist/PowerSearch/index.d.ts +1 -1
  107. package/dist/PowerSearch/index.js +1 -1
  108. package/dist/{PowerSearch-CjU8y4mi.js → PowerSearch-CMG7Rb69.js} +14 -14
  109. package/dist/ProgressBar/index.d.ts +1 -1
  110. package/dist/Radio/index.d.ts +1 -1
  111. package/dist/Radio/index.js +1 -1
  112. package/dist/{RadioGroup-BqjdSCfJ.js → RadioGroup-CBqUPq_L.js} +16 -8
  113. package/dist/RadioList/index.d.ts +1 -1
  114. package/dist/RadioList/index.js +1 -1
  115. package/dist/{RadioList-DI8ujXcT.js → RadioList-CPOJn9Th.js} +1 -1
  116. package/dist/Resizable/index.js +1 -1
  117. package/dist/{Resizable-D-TBCg0Y.js → Resizable-CXpvj1TZ.js} +1 -1
  118. package/dist/ScrollableArea/index.d.ts +1 -1
  119. package/dist/SegmentedControl/index.d.ts +1 -1
  120. package/dist/SelectableCard/index.d.ts +1 -1
  121. package/dist/Selector/index.d.ts +2 -2
  122. package/dist/Selector/index.js +1 -1
  123. package/dist/Selector-BpPnuWH3.js +618 -0
  124. package/dist/SideNav/index.d.ts +1 -1
  125. package/dist/SideNav/index.js +1 -1
  126. package/dist/{SideNav-DonEfiAx.js → SideNav-D4TupqgE.js} +3 -3
  127. package/dist/Stack/index.d.ts +1 -1
  128. package/dist/Stepper/index.d.ts +1 -1
  129. package/dist/Stepper/index.js +1 -1
  130. package/dist/{Stepper-D2ZIcUNx.js → Stepper-H-6-T5Ps.js} +1 -1
  131. package/dist/Switch/index.d.ts +1 -1
  132. package/dist/TabList/index.d.ts +1 -1
  133. package/dist/TabList/index.js +1 -1
  134. package/dist/{TabList-D3F-stq-.js → TabList-BlzkrObv.js} +2 -2
  135. package/dist/Table/index.js +1 -1
  136. package/dist/{Table-CrP2Uffq.js → Table-nqA_njNz.js} +6 -6
  137. package/dist/TextArea/index.d.ts +1 -1
  138. package/dist/TextInput/index.d.ts +1 -1
  139. package/dist/Theme/index.d.ts +2 -1
  140. package/dist/Theme/index.js +1 -1
  141. package/dist/{Theme-BuUiiJNr.js → Theme-CejS9MHm.js} +21 -3
  142. package/dist/Thumbnail/index.js +1 -1
  143. package/dist/{Thumbnail-BC5JGPGZ.js → Thumbnail-CXb3m_Hv.js} +2 -2
  144. package/dist/{TimeField-DpHFrNv0.js → TimeField-B3cndWb0.js} +2 -2
  145. package/dist/TimeInput/index.d.ts +1 -1
  146. package/dist/TimeInput/index.js +1 -1
  147. package/dist/{TimeInput-DJLV0_4z.js → TimeInput-BHQ_LKGm.js} +1 -1
  148. package/dist/Timestamp/index.d.ts +1 -1
  149. package/dist/Timestamp/index.js +1 -1
  150. package/dist/{Timestamp-GKNjjt5g.js → Timestamp-Cfuxbb3i.js} +2 -2
  151. package/dist/ToggleButton/index.d.ts +1 -1
  152. package/dist/Token/index.d.ts +1 -1
  153. package/dist/Token/index.js +1 -1
  154. package/dist/{Token-Chu_eCVs.js → Token-CdVLH0_H.js} +2 -2
  155. package/dist/Tokenizer/index.d.ts +1 -1
  156. package/dist/Tokenizer/index.js +1 -1
  157. package/dist/{Tokenizer-DRDpvQ_l.js → Tokenizer-DlD-S_8-.js} +3 -3
  158. package/dist/Toolbar/index.d.ts +1 -1
  159. package/dist/TopNav/index.d.ts +1 -1
  160. package/dist/TopNav/index.js +1 -1
  161. package/dist/{TopNav-CEyWddtA.js → TopNav-DzV874G7.js} +5 -5
  162. package/dist/TreeList/index.js +1 -1
  163. package/dist/{TreeList-COS8US8e.js → TreeList-DEwvlZRV.js} +2 -2
  164. package/dist/Typeahead/index.d.ts +1 -1
  165. package/dist/Typeahead/index.js +1 -1
  166. package/dist/{Typeahead-P7cCqtaQ.js → Typeahead-DQ3tmqYe.js} +3 -3
  167. package/dist/{context-O2Vb8cJl.js → colorMode-CBgdgDSn.js} +1 -7
  168. package/dist/composables/index.d.ts +2 -2
  169. package/dist/composables/index.js +10 -5
  170. package/dist/{composables-CVfjp9h4.js → composables-DDI08XFF.js} +98 -1
  171. package/dist/context-Cws_tXTr.js +7 -0
  172. package/dist/context-D5-MwxnN.js +4 -0
  173. package/dist/{context-CiKncNSH.js → context-DmOLCubj.js} +82 -8
  174. package/dist/{index-DimuSES0.d.ts → index-B1x05arQ.d.ts} +3 -1
  175. package/dist/index-B9f1rUEv.d.ts +77 -0
  176. package/dist/{index-D-ZuubCK.d.ts → index-BB5yVIN-.d.ts} +2 -2
  177. package/dist/{index-Bu0Zd1uw.d.ts → index-BMn9ghAX.d.ts} +3 -3
  178. package/dist/{index-CJlBAXwj.d.ts → index-BRfR0lhb.d.ts} +41 -4
  179. package/dist/{index-DNRBbwp_.d.ts → index-BTAgQRP0.d.ts} +758 -111
  180. package/dist/{index-DA52oIdw.d.ts → index-BcJBLWJ0.d.ts} +2 -2
  181. package/dist/{index-jdjcb3Js.d.ts → index-Bqb_Fyju.d.ts} +2 -2
  182. package/dist/{index-CNjbOgty.d.ts → index-C-QpeUlQ.d.ts} +2 -2
  183. package/dist/{index-DGXviOlp.d.ts → index-C2sfHfBw.d.ts} +31 -5
  184. package/dist/{index-By2mSzUA.d.ts → index-CA6RbRWx.d.ts} +1 -1
  185. package/dist/{index-gW0HW02U.d.ts → index-COxy6LEW.d.ts} +1 -1
  186. package/dist/{index-CVn0GBdB.d.ts → index-Ca8VIE4l.d.ts} +1 -1
  187. package/dist/{index-CRizexSC.d.ts → index-Ch6BbxCP.d.ts} +2 -67
  188. package/dist/{index-DWH_HzXi.d.ts → index-ChWlKHjc.d.ts} +1 -1
  189. package/dist/{index-kVhSuA9t.d.ts → index-Ctu32CLv.d.ts} +4 -4
  190. package/dist/{index-DOUEn7V0.d.ts → index-D1Twv_fL.d.ts} +65 -6
  191. package/dist/{index-D_nYxnNv.d.ts → index-D7-WTV6I.d.ts} +1 -1
  192. package/dist/{index-c_TaW8mM.d.ts → index-D8o50qOE.d.ts} +1 -1
  193. package/dist/{index-D4I_obqR.d.ts → index-DAiGhkNZ.d.ts} +1 -1
  194. package/dist/{index-Cs5pcwY3.d.ts → index-DMQG6kdM.d.ts} +3 -3
  195. package/dist/index-D_UEJIU5.d.ts +83 -0
  196. package/dist/{index-fa72tWIU.d.ts → index-DkVEBdWa.d.ts} +2 -2
  197. package/dist/{index-B1TG2GPS.d.ts → index-DxsKyAxq.d.ts} +116 -44
  198. package/dist/{index-BHqRH7QW.d.ts → index-FEy8qFSD.d.ts} +2 -2
  199. package/dist/{index-qiZtHnGK.d.ts → index-LIyvJTW3.d.ts} +39 -0
  200. package/dist/{index-BKr7yvVv.d.ts → index-MPcg1Pm4.d.ts} +1 -1
  201. package/dist/{index-cGagYM1g.d.ts → index-ViSV0RBx.d.ts} +1 -1
  202. package/dist/{index-C7mxUcDR.d.ts → index-f4NGT-e2.d.ts} +4 -4
  203. package/dist/{index-DsyKhauk.d.ts → index-foQMNKZO.d.ts} +1 -1
  204. package/dist/{index-u5ozu0G7.d.ts → index-vP0EtrJJ.d.ts} +13 -3
  205. package/dist/{index-CZeoAr0a.d.ts → index-xfkEuGLY.d.ts} +2 -2
  206. package/dist/index.d.ts +76 -75
  207. package/dist/index.js +115 -107
  208. package/dist/locale/index.d.ts +1 -1
  209. package/dist/locale/index.js +2 -2
  210. package/dist/{locale-Cpk_nrLA.js → locale-CCwVnyMZ.js} +25 -1
  211. package/dist/searchResultMessage-DN0HeRRB.js +94 -0
  212. package/dist/semantic-CKH9XVqa.d.ts +54 -0
  213. package/dist/{types-pnljWjEE.d.ts → types-CwyibrRB.d.ts} +12 -11
  214. package/dist/types-jmqqnkKA.d.ts +163 -0
  215. package/dist/{useAnchoredListbox-7W90Ny-9.js → useAnchoredListbox-BN9LQnon.js} +1 -1
  216. package/dist/useDatePresentation-C07PnOCw.js +21 -0
  217. package/dist/{useMonthGrid-CmJsZTcB.js → useDateRange-CIXoE_8k.js} +1 -42
  218. package/dist/useDisclosureHandle-Df3HhAfC.js +24 -0
  219. package/dist/{useDismiss-CAiHU6QD.js → useDismiss-Cj8x_51F.js} +8 -4
  220. package/dist/useFieldControlState-voICDrys.js +18 -0
  221. package/dist/useHandleRef-6cdKugm8.js +17 -0
  222. package/dist/useIndicator-i1NORM7W.js +147 -0
  223. package/dist/useMenuDrillIn-OaEwjK44.js +520 -0
  224. package/dist/useMonthGrid-fGHSSrFc.js +43 -0
  225. package/dist/usePendingChange-ib-h8FZK.js +25 -0
  226. package/dist/useSubmenuMode-CZN9qrUo.js +37 -0
  227. package/package.json +5 -1
  228. package/styles/calendar.css +38 -3
  229. package/styles/check-indicator.css +17 -0
  230. package/styles/checkbox-indicator.css +29 -10
  231. package/styles/checkbox-input.css +0 -11
  232. package/styles/date-input.css +48 -0
  233. package/styles/dropdown-menu.css +163 -0
  234. package/styles/field.css +48 -0
  235. package/styles/icon.css +51 -3
  236. package/styles/input-group.css +32 -3
  237. package/styles/multi-selector.css +26 -0
  238. package/styles/radio-indicator.css +90 -0
  239. package/styles/radio.css +9 -42
  240. package/styles/selector.css +112 -14
  241. package/styles.css +2 -0
  242. package/dist/Calendar-BFaI5AMv.js +0 -352
  243. package/dist/CheckboxIndicator-DdJmksHt.js +0 -52
  244. package/dist/DateInput-BLocxqC3.js +0 -376
  245. package/dist/DropdownMenu-Ddfr-aEC.js +0 -164
  246. package/dist/InputGroup-ChrFVxzV.js +0 -42
  247. package/dist/Selector-DE2IEFML.js +0 -468
  248. package/dist/index-Bgv4ZmBl.d.ts +0 -72
  249. package/dist/index-DN7MXPHM.d.ts +0 -398
  250. package/dist/index-IbUN4M8V.d.ts +0 -40
  251. package/dist/types-DDAAT1Xd.d.ts +0 -285
  252. package/dist/useGridRovingFocus-DQQAOYH5.js +0 -99
  253. /package/dist/{index-BUXNRekN.d.ts → index-BXkNZF3q.d.ts} +0 -0
@@ -1,352 +0,0 @@
1
- import { t as useGridRovingFocus } from "./useGridRovingFocus-DQQAOYH5.js";
2
- import { a as useAstryxMessages, i as useAstryxLocale } from "./context-CiKncNSH.js";
3
- import { n as weekdayNames, t as formatCalendarMonth } from "./locale-Cpk_nrLA.js";
4
- import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, defineComponent, normalizeClass, openBlock, ref, renderList, renderSlot, toDisplayString, unref, useId, withKeys } from "vue";
5
- import { CalendarDate, getLocalTimeZone, today } from "@internationalized/date";
6
- import "../styles/calendar.css";
7
- //#region src/composables/useCalendar.ts
8
- function calendarDateToJSDate(date) {
9
- return new Date(date.year, date.month - 1, date.day);
10
- }
11
- function jsDateToCalendarDate(date) {
12
- return new CalendarDate(date.getFullYear(), date.getMonth() + 1, date.getDate());
13
- }
14
- /**
15
- * 日历逻辑:日期计算、月份导航、日期选择。
16
- */
17
- function useCalendar(options) {
18
- const { value, min, max, isDateDisabled, onChange, initialDate } = options;
19
- const timeZone = getLocalTimeZone();
20
- const focusedDate = ref(initialDate ? jsDateToCalendarDate(initialDate) : value.value ? jsDateToCalendarDate(value.value) : today(timeZone));
21
- function datesFor(month) {
22
- const firstDay = new CalendarDate(month.year, month.month, 1);
23
- const firstDayOfWeek = firstDay.toDate(timeZone).getDay();
24
- const startDate = firstDay.subtract({ days: firstDayOfWeek });
25
- const weeks = [];
26
- let currentDate = startDate;
27
- for (let week = 0; week < 6; week++) {
28
- const weekDates = [];
29
- for (let day = 0; day < 7; day++) {
30
- weekDates.push(currentDate);
31
- currentDate = currentDate.add({ days: 1 });
32
- }
33
- weeks.push(weekDates);
34
- }
35
- return weeks;
36
- }
37
- const dates = computed(() => datesFor(focusedDate.value));
38
- function select(date) {
39
- if (isDisabled(date)) return;
40
- onChange(calendarDateToJSDate(date));
41
- }
42
- function previousMonth() {
43
- focusedDate.value = focusedDate.value.subtract({ months: 1 });
44
- }
45
- function nextMonth() {
46
- focusedDate.value = focusedDate.value.add({ months: 1 });
47
- }
48
- function isSelected(date) {
49
- if (!value.value) return false;
50
- const selected = jsDateToCalendarDate(value.value);
51
- return date.compare(selected) === 0;
52
- }
53
- function isDisabled(date) {
54
- const jsDate = calendarDateToJSDate(date);
55
- if (min && jsDate < min) return true;
56
- if (max && jsDate > max) return true;
57
- if (isDateDisabled?.(jsDate)) return true;
58
- return false;
59
- }
60
- function isInMonth(date) {
61
- return date.month === focusedDate.value.month;
62
- }
63
- return {
64
- focusedDate,
65
- dates,
66
- datesFor,
67
- select,
68
- previousMonth,
69
- nextMonth,
70
- isSelected,
71
- isDisabled,
72
- isInMonth
73
- };
74
- }
75
- //#endregion
76
- //#region src/Calendar/Calendar.vue
77
- const _hoisted_1 = ["data-months", "aria-label"];
78
- const _hoisted_2 = { class: "astryx-calendar-header" };
79
- const _hoisted_3 = ["disabled", "aria-label"];
80
- const _hoisted_4 = { class: "astryx-calendar-month-year" };
81
- const _hoisted_5 = ["disabled", "aria-label"];
82
- const _hoisted_6 = { class: "astryx-calendar-month-year" };
83
- const _hoisted_7 = ["disabled", "aria-label"];
84
- const _hoisted_8 = {
85
- class: "astryx-calendar-weekdays",
86
- role: "row"
87
- };
88
- const _hoisted_9 = ["aria-label"];
89
- const _hoisted_10 = ["aria-activedescendant", "onKeydown"];
90
- const _hoisted_11 = [
91
- "id",
92
- "aria-selected",
93
- "aria-disabled",
94
- "aria-current",
95
- "onClick",
96
- "onKeydown"
97
- ];
98
- const _hoisted_12 = { class: "astryx-calendar-day" };
99
- const _sfc_main = /*@__PURE__*/ defineComponent({
100
- name: "AstryxCalendar",
101
- __name: "Calendar",
102
- props: {
103
- modelValue: { default: null },
104
- mode: { default: "single" },
105
- range: { default: null },
106
- numberOfMonths: { default: 1 },
107
- focusDate: {},
108
- min: {},
109
- max: {},
110
- isDateDisabled: {},
111
- label: {},
112
- disabled: {
113
- type: Boolean,
114
- default: false
115
- }
116
- },
117
- emits: [
118
- "update:modelValue",
119
- "update:range",
120
- "change"
121
- ],
122
- setup(__props, { emit: __emit }) {
123
- const props = __props;
124
- const emit = __emit;
125
- const calendarId = `astryx-calendar-${useId()}`;
126
- const locale = useAstryxLocale();
127
- const messages = useAstryxMessages();
128
- const resolvedLabel = computed(() => props.label ?? messages.value.calendar.label);
129
- const weekDays = computed(() => weekdayNames(locale.value, "narrow"));
130
- const weekDayLabels = computed(() => weekdayNames(locale.value, "long"));
131
- const modelValueRef = computed({
132
- get: () => props.modelValue,
133
- set: (value) => {
134
- emit("update:modelValue", value);
135
- emit("change", value);
136
- }
137
- });
138
- const calendar = useCalendar({
139
- value: modelValueRef,
140
- initialDate: props.focusDate,
141
- min: props.min,
142
- max: props.max,
143
- isDateDisabled: props.isDateDisabled,
144
- onChange: (value) => {
145
- modelValueRef.value = value;
146
- }
147
- });
148
- const months = computed(() => {
149
- const first = calendar.focusedDate.value;
150
- return props.numberOfMonths === 2 ? [first, first.add({ months: 1 })] : [first];
151
- });
152
- const timeZone = getLocalTimeZone();
153
- const todayDate = today(timeZone);
154
- const activeIndex = ref(0);
155
- const isEnabled = computed(() => !props.disabled);
156
- const grid = useGridRovingFocus({
157
- rows: computed(() => 6),
158
- columns: computed(() => 7),
159
- activeIndex,
160
- isEnabled,
161
- isDisabled: (row, col) => {
162
- const dateIndex = row * 7 + col;
163
- const date = calendar.dates.value.flat()[dateIndex];
164
- return date ? calendar.isDisabled(date) : true;
165
- },
166
- onChange: (index) => {
167
- activeIndex.value = index;
168
- }
169
- });
170
- function getCellId(rowIndex, colIndex) {
171
- return `${calendarId}-cell-${rowIndex}-${colIndex}`;
172
- }
173
- function isToday(date) {
174
- return date.compare(todayDate) === 0;
175
- }
176
- function sameDay(date, day) {
177
- return !!date && date.getFullYear() === day.year && date.getMonth() + 1 === day.month && date.getDate() === day.day;
178
- }
179
- function isRangeStart(date) {
180
- return props.mode === "range" && sameDay(props.range?.start ?? null, date);
181
- }
182
- function isRangeEnd(date) {
183
- return props.mode === "range" && sameDay(props.range?.end ?? null, date);
184
- }
185
- function isInRange(date) {
186
- if (props.mode !== "range") return false;
187
- const start = props.range?.start;
188
- const end = props.range?.end;
189
- if (!start || !end) return false;
190
- const day = new Date(date.year, date.month - 1, date.day);
191
- return day > (start < end ? start : end) && day < (start < end ? end : start);
192
- }
193
- function selectRange(date) {
194
- const day = new Date(date.year, date.month - 1, date.day);
195
- const start = props.range?.start ?? null;
196
- const end = props.range?.end ?? null;
197
- emit("update:range", !start || end ? {
198
- start: day,
199
- end: null
200
- } : day < start ? {
201
- start: day,
202
- end: start
203
- } : {
204
- start,
205
- end: day
206
- });
207
- emit("change", day);
208
- }
209
- function onDateClick(date, rowIndex, colIndex) {
210
- if (props.disabled || calendar.isDisabled(date)) return;
211
- activeIndex.value = rowIndex * 7 + colIndex;
212
- if (props.mode === "range") {
213
- selectRange(date);
214
- return;
215
- }
216
- calendar.select(date);
217
- }
218
- function onKeyDown(event) {
219
- if (props.disabled) return;
220
- grid.onKeyDown(event);
221
- if (event.key === "Enter" || event.key === " ") {
222
- event.preventDefault();
223
- const date = calendar.dates.value.flat()[activeIndex.value];
224
- if (date && !calendar.isDisabled(date)) calendar.select(date);
225
- }
226
- }
227
- return (_ctx, _cache) => {
228
- return openBlock(), createElementBlock("div", {
229
- id: calendarId,
230
- class: normalizeClass(["astryx-calendar", { "is-disabled": props.disabled }]),
231
- "data-months": props.numberOfMonths,
232
- role: "application",
233
- "aria-label": resolvedLabel.value
234
- }, [(openBlock(true), createElementBlock(Fragment, null, renderList(months.value, (month, monthIndex) => {
235
- return openBlock(), createElementBlock("div", {
236
- key: `${month.year}-${month.month}`,
237
- class: "astryx-calendar-month"
238
- }, [
239
- createElementVNode("div", _hoisted_2, [monthIndex === 0 ? renderSlot(_ctx.$slots, "header", {}, () => [
240
- createElementVNode("button", {
241
- type: "button",
242
- class: "astryx-calendar-nav-button",
243
- disabled: props.disabled,
244
- "aria-label": unref(messages).calendar.previousMonth,
245
- onClick: _cache[0] || (_cache[0] = (...args) => unref(calendar).previousMonth && unref(calendar).previousMonth(...args))
246
- }, [..._cache[3] || (_cache[3] = [createElementVNode("svg", {
247
- width: "16",
248
- height: "16",
249
- viewBox: "0 0 16 16",
250
- fill: "none"
251
- }, [createElementVNode("path", {
252
- d: "M10 12L6 8L10 4",
253
- stroke: "currentColor",
254
- "stroke-width": "1.5",
255
- "stroke-linecap": "round",
256
- "stroke-linejoin": "round"
257
- })], -1)])], 8, _hoisted_3),
258
- createElementVNode("span", _hoisted_4, toDisplayString(unref(formatCalendarMonth)(month.year, month.month, unref(locale))), 1),
259
- props.numberOfMonths === 1 ? (openBlock(), createElementBlock("button", {
260
- key: 0,
261
- type: "button",
262
- class: "astryx-calendar-nav-button",
263
- disabled: props.disabled,
264
- "aria-label": unref(messages).calendar.nextMonth,
265
- onClick: _cache[1] || (_cache[1] = (...args) => unref(calendar).nextMonth && unref(calendar).nextMonth(...args))
266
- }, [..._cache[4] || (_cache[4] = [createElementVNode("svg", {
267
- width: "16",
268
- height: "16",
269
- viewBox: "0 0 16 16",
270
- fill: "none"
271
- }, [createElementVNode("path", {
272
- d: "M6 4L10 8L6 12",
273
- stroke: "currentColor",
274
- "stroke-width": "1.5",
275
- "stroke-linecap": "round",
276
- "stroke-linejoin": "round"
277
- })], -1)])], 8, _hoisted_5)) : createCommentVNode("v-if", true)
278
- ], void 0, 0) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createElementVNode("span", _hoisted_6, toDisplayString(unref(formatCalendarMonth)(month.year, month.month, unref(locale))), 1), createElementVNode("button", {
279
- type: "button",
280
- class: "astryx-calendar-nav-button",
281
- disabled: props.disabled,
282
- "aria-label": unref(messages).calendar.nextMonth,
283
- onClick: _cache[2] || (_cache[2] = (...args) => unref(calendar).nextMonth && unref(calendar).nextMonth(...args))
284
- }, [..._cache[5] || (_cache[5] = [createElementVNode("svg", {
285
- width: "16",
286
- height: "16",
287
- viewBox: "0 0 16 16",
288
- fill: "none"
289
- }, [createElementVNode("path", {
290
- d: "M6 4L10 8L6 12",
291
- stroke: "currentColor",
292
- "stroke-width": "1.5",
293
- "stroke-linecap": "round",
294
- "stroke-linejoin": "round"
295
- })], -1)])], 8, _hoisted_7)], 64))]),
296
- createElementVNode("div", _hoisted_8, [(openBlock(true), createElementBlock(Fragment, null, renderList(weekDays.value, (day, index) => {
297
- return openBlock(), createElementBlock("div", {
298
- key: index,
299
- class: "astryx-calendar-weekday",
300
- role: "columnheader",
301
- "aria-label": weekDayLabels.value[index]
302
- }, toDisplayString(day), 9, _hoisted_9);
303
- }), 128))]),
304
- createElementVNode("div", {
305
- class: "astryx-calendar-grid",
306
- role: "grid",
307
- "aria-labelledby": calendarId,
308
- "aria-activedescendant": monthIndex === 0 ? getCellId(unref(grid).row.value, unref(grid).column.value) : void 0,
309
- tabindex: "0",
310
- onKeydown: ($event) => monthIndex === 0 ? onKeyDown($event) : void 0
311
- }, [(openBlock(true), createElementBlock(Fragment, null, renderList(unref(calendar).datesFor(month), (week, rowIndex) => {
312
- return openBlock(), createElementBlock("div", {
313
- key: rowIndex,
314
- class: "astryx-calendar-row",
315
- role: "row"
316
- }, [(openBlock(true), createElementBlock(Fragment, null, renderList(week, (date, colIndex) => {
317
- return openBlock(), createElementBlock("div", {
318
- id: monthIndex === 0 ? getCellId(rowIndex, colIndex) : void 0,
319
- key: colIndex,
320
- class: normalizeClass(["astryx-calendar-cell", {
321
- "is-selected": props.mode === "range" ? isRangeStart(date) || isRangeEnd(date) : unref(calendar).isSelected(date),
322
- "is-range-start": isRangeStart(date),
323
- "is-range-end": isRangeEnd(date),
324
- "is-in-range": isInRange(date),
325
- "is-disabled": unref(calendar).isDisabled(date),
326
- "is-today": isToday(date),
327
- "is-other-month": date.month !== month.month || date.year !== month.year,
328
- "is-active": monthIndex === 0 && activeIndex.value === rowIndex * 7 + colIndex
329
- }]),
330
- role: "gridcell",
331
- "aria-selected": props.mode === "range" ? isRangeStart(date) || isRangeEnd(date) : unref(calendar).isSelected(date),
332
- "aria-disabled": unref(calendar).isDisabled(date),
333
- "aria-current": isToday(date) ? "date" : void 0,
334
- tabindex: "-1",
335
- onClick: ($event) => onDateClick(date, rowIndex, colIndex),
336
- onKeydown: withKeys(($event) => onDateClick(date, rowIndex, colIndex), ["enter"])
337
- }, [renderSlot(_ctx.$slots, "day", {
338
- date,
339
- isSelected: props.mode === "range" ? isRangeStart(date) || isRangeEnd(date) : unref(calendar).isSelected(date),
340
- isDisabled: unref(calendar).isDisabled(date),
341
- isToday: isToday(date),
342
- isInMonth: date.month === month.month && date.year === month.year
343
- }, () => [createElementVNode("span", _hoisted_12, toDisplayString(date.day), 1)])], 42, _hoisted_11);
344
- }), 128))]);
345
- }), 128))], 40, _hoisted_10)
346
- ]);
347
- }), 128))], 10, _hoisted_1);
348
- };
349
- }
350
- });
351
- //#endregion
352
- export { _sfc_main as t };
@@ -1,52 +0,0 @@
1
- import { createElementBlock, createElementVNode, defineComponent, mergeProps, openBlock, renderSlot, useAttrs, useTemplateRef } from "vue";
2
- import "../styles/checkbox-indicator.css";
3
- //#region src/CheckboxIndicator/CheckboxIndicator.vue
4
- const _hoisted_1 = [
5
- "data-state",
6
- "data-size",
7
- "data-disabled"
8
- ];
9
- const _sfc_main = /*@__PURE__*/ defineComponent({
10
- name: "AstryxCheckboxIndicator",
11
- inheritAttrs: false,
12
- __name: "CheckboxIndicator",
13
- props: {
14
- state: {},
15
- size: { default: "md" },
16
- isDisabled: { type: Boolean }
17
- },
18
- setup(__props, { expose: __expose }) {
19
- const attrs = useAttrs();
20
- __expose({ element: useTemplateRef("indicator") });
21
- function decorativeAttrs() {
22
- return Object.fromEntries(Object.entries(attrs).filter(([key]) => !key.startsWith("aria-") && ![
23
- "role",
24
- "tabindex",
25
- "contenteditable"
26
- ].includes(key)));
27
- }
28
- return (_ctx, _cache) => {
29
- return openBlock(), createElementBlock("span", mergeProps(decorativeAttrs(), {
30
- ref: "indicator",
31
- class: "astryx-checkbox-indicator",
32
- "aria-hidden": "true",
33
- "data-state": __props.state,
34
- "data-size": __props.size,
35
- "data-disabled": __props.isDisabled || void 0
36
- }), [renderSlot(_ctx.$slots, "default", {}, () => [_cache[0] || (_cache[0] = createElementVNode("svg", {
37
- class: "astryx-checkbox-indicator-check",
38
- viewBox: "0 0 10 10",
39
- focusable: "false"
40
- }, [createElementVNode("path", {
41
- d: "M8.5 2.5L4 7.5L1.5 5",
42
- stroke: "currentColor",
43
- "stroke-width": "1.5",
44
- fill: "none",
45
- "stroke-linecap": "round",
46
- "stroke-linejoin": "round"
47
- })], -1)), _cache[1] || (_cache[1] = createElementVNode("span", { class: "astryx-checkbox-indicator-dash" }, null, -1))])], 16, _hoisted_1);
48
- };
49
- }
50
- });
51
- //#endregion
52
- export { _sfc_main as t };