@nutui/nutui 4.2.8 → 4.3.0-beta.2

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 (184) hide show
  1. package/dist/nutui.es.js +4 -2
  2. package/dist/nutui.js +6306 -5969
  3. package/dist/nutui.umd.js +1 -1
  4. package/dist/packages/addresslist/AddressList.js +4 -3
  5. package/dist/packages/audiooperate/AudioOperate.js +3 -2
  6. package/dist/packages/avatarcropper/AvatarCropper.js +3 -2
  7. package/dist/packages/button/Button.js +58 -39
  8. package/dist/packages/calendar/Calendar.js +2 -1
  9. package/dist/packages/calendarcard/CalendarCard.js +529 -0
  10. package/dist/packages/calendarcard/index.css +1 -0
  11. package/dist/packages/calendarcard/index.mjs +2 -0
  12. package/dist/packages/calendarcard/index.scss +92 -0
  13. package/dist/packages/calendarcard/style/css.mjs +2 -0
  14. package/dist/packages/calendarcard/style/index.mjs +2 -0
  15. package/dist/packages/calendaritem/CalendarItem.js +817 -7
  16. package/dist/packages/date-djiVNSnJ.js +145 -0
  17. package/dist/packages/dialog/Dialog.js +4 -3
  18. package/dist/packages/divider/Divider.js +40 -18
  19. package/dist/packages/invoice/Invoice.js +3 -2
  20. package/dist/packages/locale/lang/baseLang.d.ts +8 -0
  21. package/dist/packages/locale/lang/en-US.d.ts +8 -0
  22. package/dist/packages/locale/lang/en-US.js +8 -0
  23. package/dist/packages/locale/lang/id-ID.d.ts +8 -0
  24. package/dist/packages/locale/lang/id-ID.js +8 -0
  25. package/dist/packages/locale/lang/zh-CN.d.ts +8 -0
  26. package/dist/packages/locale/lang/zh-CN.js +8 -0
  27. package/dist/packages/locale/lang/zh-TW.d.ts +8 -0
  28. package/dist/packages/locale/lang/zh-TW.js +8 -0
  29. package/dist/packages/signature/Signature.js +3 -2
  30. package/dist/packages/with-install-p59gYYU_.js +12 -0
  31. package/dist/smartips/web-types.json +62 -1
  32. package/dist/style.css +1 -1
  33. package/dist/styles/base-jdb.css +1 -1
  34. package/dist/styles/base-jddkh.css +1 -1
  35. package/dist/styles/base-jdt.css +1 -1
  36. package/dist/styles/themes/default.scss +1 -0
  37. package/dist/styles/themes/jdb.scss +1 -0
  38. package/dist/styles/themes/jddkh.scss +1 -0
  39. package/dist/styles/themes/jdt.scss +1 -0
  40. package/dist/styles/variables-jdb.scss +1 -0
  41. package/dist/styles/variables-jddkh.scss +1 -0
  42. package/dist/styles/variables-jdt.scss +1 -0
  43. package/dist/styles/variables.scss +1 -0
  44. package/dist/types/__VUE/actionsheet/index.vue.d.ts +7 -7
  45. package/dist/types/__VUE/address/index.vue.d.ts +11 -11
  46. package/dist/types/__VUE/addresslist/index.vue.d.ts +5 -5
  47. package/dist/types/__VUE/animate/index.vue.d.ts +4 -4
  48. package/dist/types/__VUE/audio/index.vue.d.ts +6 -6
  49. package/dist/types/__VUE/audiooperate/index.vue.d.ts +4 -4
  50. package/dist/types/__VUE/avatar/index.vue.d.ts +5 -5
  51. package/dist/types/__VUE/avatarcropper/index.vue.d.ts +7 -7
  52. package/dist/types/__VUE/avatargroup/index.vue.d.ts +5 -5
  53. package/dist/types/__VUE/backtop/index.vue.d.ts +6 -6
  54. package/dist/types/__VUE/badge/index.vue.d.ts +6 -6
  55. package/dist/types/__VUE/barrage/index.vue.d.ts +5 -5
  56. package/dist/types/__VUE/button/{index.vue.d.ts → button.vue.d.ts} +36 -27
  57. package/dist/types/__VUE/button/index.d.ts +5 -0
  58. package/dist/types/__VUE/calendar/index.vue.d.ts +7 -7
  59. package/dist/types/__VUE/calendarcard/calendar-card.vue.d.ts +112 -0
  60. package/dist/types/__VUE/calendarcard/icon.d.ts +12 -0
  61. package/dist/types/__VUE/calendarcard/index.d.ts +5 -0
  62. package/dist/types/__VUE/calendarcard/types.d.ts +12 -0
  63. package/dist/types/__VUE/calendarcard/utils.d.ts +19 -0
  64. package/dist/types/__VUE/calendaritem/index.vue.d.ts +10 -10
  65. package/dist/types/__VUE/card/index.vue.d.ts +4 -4
  66. package/dist/types/__VUE/cascader/cascader-item.vue.d.ts +4 -4
  67. package/dist/types/__VUE/cascader/index.vue.d.ts +7 -7
  68. package/dist/types/__VUE/category/index.vue.d.ts +4 -4
  69. package/dist/types/__VUE/categorypane/index.vue.d.ts +4 -4
  70. package/dist/types/__VUE/cell/index.vue.d.ts +7 -7
  71. package/dist/types/__VUE/cellgroup/index.vue.d.ts +4 -4
  72. package/dist/types/__VUE/checkbox/index.vue.d.ts +6 -6
  73. package/dist/types/__VUE/checkboxgroup/index.vue.d.ts +4 -4
  74. package/dist/types/__VUE/circleprogress/index.vue.d.ts +5 -5
  75. package/dist/types/__VUE/col/index.vue.d.ts +4 -4
  76. package/dist/types/__VUE/collapse/index.vue.d.ts +4 -4
  77. package/dist/types/__VUE/collapseitem/index.vue.d.ts +7 -7
  78. package/dist/types/__VUE/comment/components/CmtBottom.vue.d.ts +1 -1
  79. package/dist/types/__VUE/comment/components/CmtHeader.vue.d.ts +1 -1
  80. package/dist/types/__VUE/comment/components/CmtImages.vue.d.ts +1 -1
  81. package/dist/types/__VUE/comment/index.vue.d.ts +9 -9
  82. package/dist/types/__VUE/configprovider/index.vue.d.ts +5 -5
  83. package/dist/types/__VUE/countdown/index.vue.d.ts +4 -4
  84. package/dist/types/__VUE/countup/index.vue.d.ts +8 -8
  85. package/dist/types/__VUE/datepicker/index.vue.d.ts +9 -9
  86. package/dist/types/__VUE/dialog/index.vue.d.ts +7 -7
  87. package/dist/types/__VUE/divider/divider.vue.d.ts +56 -0
  88. package/dist/types/__VUE/divider/index.d.ts +5 -0
  89. package/dist/types/__VUE/drag/index.vue.d.ts +4 -4
  90. package/dist/types/__VUE/ecard/index.vue.d.ts +7 -7
  91. package/dist/types/__VUE/elevator/index.vue.d.ts +4 -4
  92. package/dist/types/__VUE/ellipsis/index.vue.d.ts +7 -7
  93. package/dist/types/__VUE/empty/index.vue.d.ts +4 -4
  94. package/dist/types/__VUE/fixednav/index.vue.d.ts +6 -6
  95. package/dist/types/__VUE/form/index.vue.d.ts +4 -4
  96. package/dist/types/__VUE/formitem/index.vue.d.ts +4 -4
  97. package/dist/types/__VUE/grid/index.vue.d.ts +6 -6
  98. package/dist/types/__VUE/griditem/index.vue.d.ts +4 -4
  99. package/dist/types/__VUE/image/index.vue.d.ts +8 -8
  100. package/dist/types/__VUE/imagepreview/imagePreviewItem.vue.d.ts +5 -5
  101. package/dist/types/__VUE/imagepreview/index.vue.d.ts +9 -9
  102. package/dist/types/__VUE/indicator/index.vue.d.ts +4 -4
  103. package/dist/types/__VUE/infiniteloading/index.vue.d.ts +4 -4
  104. package/dist/types/__VUE/input/index.vue.d.ts +15 -15
  105. package/dist/types/__VUE/inputnumber/index.vue.d.ts +7 -7
  106. package/dist/types/__VUE/invoice/index.vue.d.ts +6 -6
  107. package/dist/types/__VUE/layout/index.vue.d.ts +4 -4
  108. package/dist/types/__VUE/list/index.vue.d.ts +6 -6
  109. package/dist/types/__VUE/menu/index.vue.d.ts +7 -7
  110. package/dist/types/__VUE/menuitem/index.vue.d.ts +4 -4
  111. package/dist/types/__VUE/navbar/index.vue.d.ts +6 -6
  112. package/dist/types/__VUE/noticebar/index.vue.d.ts +7 -7
  113. package/dist/types/__VUE/notify/index.vue.d.ts +7 -7
  114. package/dist/types/__VUE/numberkeyboard/index.vue.d.ts +8 -8
  115. package/dist/types/__VUE/overlay/index.vue.d.ts +4 -4
  116. package/dist/types/__VUE/pagination/index.vue.d.ts +5 -5
  117. package/dist/types/__VUE/picker/Column.vue.d.ts +7 -7
  118. package/dist/types/__VUE/picker/baseProps.d.ts +4 -4
  119. package/dist/types/__VUE/picker/index.vue.d.ts +6 -6
  120. package/dist/types/__VUE/popover/index.vue.d.ts +9 -9
  121. package/dist/types/__VUE/popup/index.vue.d.ts +6 -6
  122. package/dist/types/__VUE/price/index.vue.d.ts +4 -4
  123. package/dist/types/__VUE/progress/index.vue.d.ts +6 -6
  124. package/dist/types/__VUE/pullrefresh/index.vue.d.ts +4 -4
  125. package/dist/types/__VUE/radio/index.vue.d.ts +8 -8
  126. package/dist/types/__VUE/radiogroup/index.vue.d.ts +7 -7
  127. package/dist/types/__VUE/range/index.vue.d.ts +8 -8
  128. package/dist/types/__VUE/rate/index.vue.d.ts +9 -9
  129. package/dist/types/__VUE/row/index.vue.d.ts +5 -5
  130. package/dist/types/__VUE/searchbar/index.vue.d.ts +15 -15
  131. package/dist/types/__VUE/shortpassword/index.vue.d.ts +5 -5
  132. package/dist/types/__VUE/sidenavbar/index.vue.d.ts +4 -4
  133. package/dist/types/__VUE/sidenavbaritem/index.vue.d.ts +4 -4
  134. package/dist/types/__VUE/signature/index.vue.d.ts +6 -6
  135. package/dist/types/__VUE/skeleton/index.vue.d.ts +7 -7
  136. package/dist/types/__VUE/sku/components/SkuStepper.vue.d.ts +2 -2
  137. package/dist/types/__VUE/sku/index.vue.d.ts +6 -6
  138. package/dist/types/__VUE/space/index.vue.d.ts +4 -4
  139. package/dist/types/__VUE/step/index.vue.d.ts +4 -4
  140. package/dist/types/__VUE/steps/index.vue.d.ts +4 -4
  141. package/dist/types/__VUE/sticky/index.vue.d.ts +5 -5
  142. package/dist/types/__VUE/subsidenavbar/index.vue.d.ts +4 -4
  143. package/dist/types/__VUE/swipe/index.vue.d.ts +4 -4
  144. package/dist/types/__VUE/swipegroup/index.vue.d.ts +4 -4
  145. package/dist/types/__VUE/swiper/index.vue.d.ts +5 -5
  146. package/dist/types/__VUE/swiperitem/index.vue.d.ts +4 -4
  147. package/dist/types/__VUE/switch/index.vue.d.ts +13 -13
  148. package/dist/types/__VUE/tabbar/index.vue.d.ts +6 -6
  149. package/dist/types/__VUE/tabbaritem/index.vue.d.ts +6 -6
  150. package/dist/types/__VUE/table/index.vue.d.ts +4 -4
  151. package/dist/types/__VUE/table/renderColumn.d.ts +4 -4
  152. package/dist/types/__VUE/tabpane/index.vue.d.ts +5 -5
  153. package/dist/types/__VUE/tabs/index.vue.d.ts +10 -10
  154. package/dist/types/__VUE/tag/index.vue.d.ts +8 -8
  155. package/dist/types/__VUE/textarea/index.vue.d.ts +11 -11
  156. package/dist/types/__VUE/timedetail/index.vue.d.ts +4 -4
  157. package/dist/types/__VUE/timepannel/index.vue.d.ts +4 -4
  158. package/dist/types/__VUE/timeselect/index.vue.d.ts +5 -5
  159. package/dist/types/__VUE/toast/index.vue.d.ts +10 -10
  160. package/dist/types/__VUE/tour/index.vue.d.ts +9 -9
  161. package/dist/types/__VUE/trendarrow/index.vue.d.ts +5 -5
  162. package/dist/types/__VUE/uploader/index.vue.d.ts +10 -10
  163. package/dist/types/__VUE/video/index.vue.d.ts +5 -5
  164. package/dist/types/__VUE/watermark/index.vue.d.ts +7 -7
  165. package/dist/types/index.d.ts +8 -4
  166. package/dist/types/locale/lang/baseLang.d.ts +8 -0
  167. package/dist/types/locale/lang/en-US.d.ts +8 -0
  168. package/dist/types/locale/lang/id-ID.d.ts +8 -0
  169. package/dist/types/locale/lang/zh-CN.d.ts +8 -0
  170. package/dist/types/locale/lang/zh-TW.d.ts +8 -0
  171. package/dist/types/utils/canvas.d.ts +1 -1
  172. package/dist/types/utils/create/renderIcon.d.ts +2 -2
  173. package/dist/types/utils/index.d.ts +1 -0
  174. package/dist/types/utils/with-install.d.ts +5 -0
  175. package/package.json +1 -1
  176. package/dist/packages/index-kWulbKuH.js +0 -961
  177. package/dist/types/__VUE/address/address-list.d.ts +0 -30
  178. package/dist/types/__VUE/divider/index.vue.d.ts +0 -71
  179. package/dist/types/__VUE/icon/index.vue.d.ts +0 -13
  180. package/dist/types/__VUE/invoice/types.d.ts +0 -6
  181. package/dist/types/__VUE/picker/doc.en.d.ts +0 -90
  182. package/dist/types/__VUE/sku/data.d.ts +0 -22
  183. package/dist/types/__VUE/tour/type.d.ts +0 -2
  184. /package/dist/types/__VUE/button/{type.d.ts → types.d.ts} +0 -0
@@ -0,0 +1,529 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ import { h, defineComponent, ref, computed, watchEffect, withDirectives, openBlock, createElementBlock, createElementVNode, createVNode, unref, toDisplayString, Fragment, renderList, normalizeClass, renderSlot, createTextVNode, vShow } from "vue";
21
+ import { U as Utils } from "../date-djiVNSnJ.js";
22
+ import { u as useLocale } from "../index-s3RgMhc7.js";
23
+ import { w as withInstall } from "../with-install-p59gYYU_.js";
24
+ import "@nutui/nutui/dist/packages/locale/lang";
25
+ import "../util-4Jkyw4BJ.js";
26
+ const Left = () => {
27
+ return h(
28
+ "svg",
29
+ {
30
+ xmlns: "http://www.w3.org/2000/svg",
31
+ width: "18",
32
+ height: "18",
33
+ viewBox: "0 0 18 18"
34
+ },
35
+ [
36
+ h("path", {
37
+ d: "M6.605 9.49a.771.771 0 0 1 0-.98l3.6-4.372a.771.771 0 0 1 1.19.981L8.2 9l3.197 3.881a.771.771 0 1 1-1.191.98l-3.6-4.37Z"
38
+ })
39
+ ]
40
+ );
41
+ };
42
+ const Right = () => {
43
+ return h(
44
+ "svg",
45
+ {
46
+ xmlns: "http://www.w3.org/2000/svg",
47
+ width: "18",
48
+ height: "18",
49
+ viewBox: "0 0 18 18"
50
+ },
51
+ [
52
+ h("path", {
53
+ d: "M11.396 9.49a.771.771 0 0 0 0-.98l-3.6-4.372a.771.771 0 0 0-1.191.981L9.8 9l-3.196 3.881a.771.771 0 0 0 1.19.98l3.6-4.37Z"
54
+ })
55
+ ]
56
+ );
57
+ };
58
+ const DoubleLeft = () => {
59
+ return h(
60
+ "svg",
61
+ {
62
+ xmlns: "http://www.w3.org/2000/svg",
63
+ width: "18",
64
+ height: "18",
65
+ viewBox: "0 0 18 18"
66
+ },
67
+ [
68
+ h("path", {
69
+ d: "M13.853 4.026a.771.771 0 0 1 .12 1.085L10.864 9l3.11 3.889a.771.771 0 1 1-1.204.963L9.272 9.482a.771.771 0 0 1 0-.964l3.497-4.371a.771.771 0 0 1 1.084-.12Zm-5.245 0a.771.771 0 0 1 .12 1.085L5.617 9l3.111 3.889a.771.771 0 0 1-1.205.963L4.026 9.482a.771.771 0 0 1 0-.964l3.497-4.371a.771.771 0 0 1 1.085-.12Z"
70
+ })
71
+ ]
72
+ );
73
+ };
74
+ const DoubleRight = () => {
75
+ return h(
76
+ "svg",
77
+ {
78
+ xmlns: "http://www.w3.org/2000/svg",
79
+ width: "18",
80
+ height: "18",
81
+ viewBox: "0 0 18 18"
82
+ },
83
+ [
84
+ h("path", {
85
+ d: "M4.147 13.974a.771.771 0 0 1-.12-1.085L7.136 9 4.028 5.11a.771.771 0 1 1 1.204-.963l3.497 4.371a.771.771 0 0 1 0 .964l-3.497 4.371a.771.771 0 0 1-1.084.12Zm5.245 0a.771.771 0 0 1-.12-1.085L12.383 9 9.272 5.11a.771.771 0 1 1 1.205-.963l3.497 4.371a.771.771 0 0 1 0 .964l-3.497 4.371a.771.771 0 0 1-1.085.12Z"
86
+ })
87
+ ]
88
+ );
89
+ };
90
+ const convertDateToDay = (date) => {
91
+ return date ? {
92
+ year: date.getFullYear(),
93
+ month: date.getMonth() + 1,
94
+ date: date.getDate()
95
+ } : null;
96
+ };
97
+ const convertDayToDate = (day) => {
98
+ return day ? new Date(day.year, day.month - 1, day.date) : null;
99
+ };
100
+ const valueToRange = (val) => {
101
+ if (Array.isArray(val)) {
102
+ return val.map((date) => {
103
+ return convertDateToDay(date);
104
+ });
105
+ }
106
+ return val ? [convertDateToDay(val)] : [];
107
+ };
108
+ const rangeTovalue = (range) => {
109
+ if (Array.isArray(range)) {
110
+ return range.map((day) => {
111
+ return convertDayToDate(day);
112
+ });
113
+ }
114
+ return range ? [convertDayToDate(range)] : [];
115
+ };
116
+ const getPrevMonthDays = (year, month, firstDayOfWeek) => {
117
+ let prevMonth = month - 1;
118
+ let prevYear = year;
119
+ if (prevMonth <= 0) {
120
+ prevMonth = 12;
121
+ prevYear -= 1;
122
+ }
123
+ let days = Utils.getMonthPreDay(year, month);
124
+ days -= firstDayOfWeek;
125
+ if (days >= 7) {
126
+ days -= 7;
127
+ }
128
+ const preDates = Utils.getMonthDays(`${prevYear}`, `${prevMonth}`);
129
+ const months = Array.from(Array(preDates), (_, k) => {
130
+ return {
131
+ type: "prev",
132
+ year: prevYear,
133
+ month: prevMonth,
134
+ date: k + 1
135
+ };
136
+ });
137
+ return months.slice(preDates - days);
138
+ };
139
+ const getCurrentMonthDays = (year, month) => {
140
+ const days = Utils.getMonthDays(`${year}`, `${month}`);
141
+ return Array.from(Array(days), (_, k) => {
142
+ return {
143
+ type: "current",
144
+ year,
145
+ month,
146
+ date: k + 1
147
+ };
148
+ });
149
+ };
150
+ const getCurrentWeekDays = (day, firstDayOfWeek) => {
151
+ const current = new Date(day.year, day.month - 1, day.date);
152
+ const count = (current.getDay() + 7 - firstDayOfWeek) % 7;
153
+ return [
154
+ convertDateToDay(new Date(current.getTime() - 24 * 60 * 60 * 1e3 * count)),
155
+ convertDateToDay(new Date(current.getTime() + 24 * 60 * 60 * 1e3 * (6 - count)))
156
+ ];
157
+ };
158
+ const getDays = (month, firstDayOfWeek) => {
159
+ const y = month.year;
160
+ const m = month.month;
161
+ const days = [...getPrevMonthDays(y, m, firstDayOfWeek), ...getCurrentMonthDays(y, m)];
162
+ const size = days.length;
163
+ const yearOfNextMonth = month.month === 12 ? month.year + 1 : month.year;
164
+ const monthOfNextMonth = month.month === 12 ? 1 : month.month + 1;
165
+ for (let i = 1; i <= 42 - size; i++) {
166
+ days.push({
167
+ type: "next",
168
+ year: yearOfNextMonth,
169
+ month: monthOfNextMonth,
170
+ date: i
171
+ });
172
+ }
173
+ return days;
174
+ };
175
+ const compareDay = (day1, day2) => {
176
+ if (day1 && day2) {
177
+ if (day1.year === day2.year) {
178
+ if (day1.month === day2.month) {
179
+ return day1.date - day2.date;
180
+ }
181
+ return day1.month - day2.month;
182
+ }
183
+ return day1.year - day2.year;
184
+ }
185
+ };
186
+ const isSameDay = (day1, day2) => {
187
+ return compareDay(day1, day2) === 0;
188
+ };
189
+ const _hoisted_1 = { class: "nut-calendarcard" };
190
+ const _hoisted_2 = { class: "nut-calendarcard-header" };
191
+ const _hoisted_3 = { class: "nut-calendarcard-header-left" };
192
+ const _hoisted_4 = { class: "nut-calendarcard-header-title" };
193
+ const _hoisted_5 = { class: "nut-calendarcard-header-right" };
194
+ const _hoisted_6 = { class: "nut-calendarcard-content" };
195
+ const _hoisted_7 = { class: "nut-calendarcard-days" };
196
+ const _hoisted_8 = { class: "nut-calendarcard-days" };
197
+ const _hoisted_9 = ["onClick"];
198
+ const _hoisted_10 = { class: "nut-calendarcard-day-top" };
199
+ const _hoisted_11 = { class: "nut-calendarcard-day-inner" };
200
+ const _hoisted_12 = { class: "nut-calendarcard-day-bottom" };
201
+ const cN = "NutCalendarCard";
202
+ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, {
203
+ name: cN
204
+ }), {
205
+ __name: "calendar-card",
206
+ props: {
207
+ type: {
208
+ type: String,
209
+ default: "single"
210
+ },
211
+ firstDayOfWeek: {
212
+ type: Number,
213
+ default: 0
214
+ },
215
+ modelValue: {
216
+ type: [Object, Array],
217
+ default: () => []
218
+ },
219
+ startDate: {
220
+ type: Date,
221
+ default: null
222
+ },
223
+ endDate: {
224
+ type: Date,
225
+ default: null
226
+ },
227
+ disableDay: {
228
+ type: Function,
229
+ default: () => false
230
+ }
231
+ },
232
+ emits: ["update:modelValue", "change", "dayClick", "pageChange"],
233
+ setup(__props, { expose: __expose, emit: __emit }) {
234
+ const props = __props;
235
+ const emit = __emit;
236
+ const translate = useLocale(cN);
237
+ const initMonth = () => {
238
+ let date = new Date(Date.now());
239
+ const val = props.modelValue;
240
+ if (Array.isArray(val)) {
241
+ if (val.length) {
242
+ date = val[0];
243
+ }
244
+ } else if (val) {
245
+ date = val;
246
+ }
247
+ return {
248
+ year: date.getFullYear(),
249
+ month: date.getMonth() + 1
250
+ };
251
+ };
252
+ const month = ref(initMonth());
253
+ const days = ref([]);
254
+ const weekHeader = computed(() => {
255
+ const weekdays = translate("weekdays").map((day, index) => {
256
+ return {
257
+ name: day,
258
+ key: index
259
+ };
260
+ });
261
+ return [...weekdays.slice(props.firstDayOfWeek, 7), ...weekdays.slice(0, props.firstDayOfWeek)];
262
+ });
263
+ const innerValue = ref(props.modelValue ? valueToRange(props.modelValue) : []);
264
+ watchEffect(() => {
265
+ const val = props.modelValue ? valueToRange(props.modelValue) : [];
266
+ innerValue.value = val;
267
+ });
268
+ const change = (v) => {
269
+ innerValue.value = v;
270
+ if (props.type === "single") {
271
+ const date = convertDayToDate(v[0]);
272
+ emit("update:modelValue", date);
273
+ emit("change", date);
274
+ } else if (props.type === "multiple" || props.type === "range" || props.type === "week") {
275
+ const val = rangeTovalue(v);
276
+ emit("update:modelValue", val);
277
+ emit("change", val);
278
+ }
279
+ };
280
+ watchEffect(() => {
281
+ const newDays = getDays(month.value, props.firstDayOfWeek);
282
+ days.value = newDays;
283
+ emit("pageChange", month.value);
284
+ });
285
+ const isDisable = (day) => {
286
+ if (props.disableDay && props.disableDay(day)) {
287
+ return true;
288
+ }
289
+ if (props.startDate && Number(compareDay(day, convertDateToDay(props.startDate))) < 0) {
290
+ return true;
291
+ }
292
+ if (props.endDate && Number(compareDay(day, convertDateToDay(props.endDate))) > 0) {
293
+ return true;
294
+ }
295
+ return false;
296
+ };
297
+ const isActive = (day) => {
298
+ if (props.type === "single" || props.type === "multiple") {
299
+ for (const val in innerValue.value) {
300
+ if (isSameDay(day, innerValue.value[val])) {
301
+ return true;
302
+ }
303
+ }
304
+ } else if (props.type === "range" && innerValue.value.length === 1 && isSameDay(innerValue.value[0], day)) {
305
+ return true;
306
+ }
307
+ return false;
308
+ };
309
+ const isStart = (day) => {
310
+ return (props.type === "range" || props.type === "week") && innerValue.value.length === 2 && isSameDay(day, innerValue.value[0]);
311
+ };
312
+ const isEnd = (day) => {
313
+ return (props.type === "range" || props.type === "week") && innerValue.value.length === 2 && isSameDay(day, innerValue.value[1]);
314
+ };
315
+ const isMid = (day) => {
316
+ if (props.type === "range" || props.type === "week") {
317
+ if (innerValue.value.length === 2) {
318
+ const c1 = compareDay(innerValue.value[0], day);
319
+ const c2 = compareDay(day, innerValue.value[1]);
320
+ if (c1 && c1 < 0 && c2 && c2 < 0) {
321
+ return true;
322
+ }
323
+ }
324
+ }
325
+ return false;
326
+ };
327
+ const isWeekend = (day) => {
328
+ const d = new Date(day.year, day.month - 1, day.date).getDay();
329
+ return d === 0 || d === 6;
330
+ };
331
+ const getClasses = (day) => {
332
+ if (isDisable(day)) {
333
+ return ["disabled"];
334
+ }
335
+ const res = [];
336
+ if (day.type === "current") {
337
+ if (isActive(day)) {
338
+ res.push("active");
339
+ }
340
+ if (isStart(day)) {
341
+ res.push("start");
342
+ }
343
+ if (isEnd(day)) {
344
+ res.push("end");
345
+ }
346
+ if (isMid(day)) {
347
+ res.push("mid");
348
+ }
349
+ if (isWeekend(day)) {
350
+ res.push("weekend");
351
+ }
352
+ }
353
+ return res;
354
+ };
355
+ const jumpTo = (y, m) => {
356
+ if (props.startDate) {
357
+ const c = compareDay(
358
+ {
359
+ year: y,
360
+ month: m,
361
+ date: 31
362
+ },
363
+ convertDateToDay(props.startDate)
364
+ );
365
+ if (c && c < 0) {
366
+ return;
367
+ }
368
+ }
369
+ if (props.endDate) {
370
+ const c = compareDay(
371
+ {
372
+ year: y,
373
+ month: m,
374
+ date: 1
375
+ },
376
+ convertDateToDay(props.endDate)
377
+ );
378
+ if (c && c > 0) {
379
+ return;
380
+ }
381
+ }
382
+ month.value = {
383
+ year: y,
384
+ month: m
385
+ };
386
+ };
387
+ const jump = (step = 1) => {
388
+ const current = month.value.year * 12 + month.value.month;
389
+ let newMonth = (current + step) % 12;
390
+ if (newMonth === 0) {
391
+ newMonth = 12;
392
+ }
393
+ const newYear = Math.floor((current + step - newMonth) / 12);
394
+ jumpTo(newYear, newMonth);
395
+ };
396
+ const handleDayClick = (day) => {
397
+ if (day.type === "prev" || day.type === "next" || isDisable(day)) {
398
+ return;
399
+ }
400
+ emit("dayClick", day);
401
+ switch (props.type) {
402
+ case "single": {
403
+ if (innerValue.value[0] && isSameDay(innerValue.value[0], day)) {
404
+ change([]);
405
+ } else {
406
+ change([day]);
407
+ }
408
+ break;
409
+ }
410
+ case "multiple": {
411
+ const t = innerValue.value.find((i) => isSameDay(i, day));
412
+ if (t) {
413
+ change(innerValue.value.filter((i) => i !== t));
414
+ } else {
415
+ change([...innerValue.value, day]);
416
+ }
417
+ break;
418
+ }
419
+ case "range": {
420
+ const len = innerValue.value.length;
421
+ if (len === 0 || len === 2) {
422
+ change([day]);
423
+ } else if (len === 1) {
424
+ const t = compareDay(innerValue.value[0], day);
425
+ if (t === 0 || t === null || t === void 0) {
426
+ change([]);
427
+ } else if (t < 0) {
428
+ change([innerValue.value[0], day]);
429
+ } else {
430
+ change([day, innerValue.value[0]]);
431
+ }
432
+ } else {
433
+ console.warn("[NutUI] Calendar range error");
434
+ }
435
+ break;
436
+ }
437
+ case "week": {
438
+ if (innerValue.value.length === 2 || innerValue.value.length === 0) {
439
+ const [left, right] = getCurrentWeekDays(day, props.firstDayOfWeek);
440
+ change([left, right]);
441
+ } else {
442
+ console.warn("[NutUI] Calendar week error");
443
+ }
444
+ break;
445
+ }
446
+ default: {
447
+ console.warn("[NutUI] Calendar type error");
448
+ }
449
+ }
450
+ };
451
+ __expose({
452
+ jump,
453
+ jumpTo
454
+ });
455
+ return (_ctx, _cache) => {
456
+ return withDirectives((openBlock(), createElementBlock("div", _hoisted_1, [
457
+ createElementVNode("div", _hoisted_2, [
458
+ createElementVNode("div", _hoisted_3, [
459
+ createElementVNode("div", {
460
+ class: "double-left",
461
+ onClick: _cache[0] || (_cache[0] = ($event) => jump(-12))
462
+ }, [
463
+ createVNode(unref(DoubleLeft))
464
+ ]),
465
+ createElementVNode("div", {
466
+ class: "left",
467
+ onClick: _cache[1] || (_cache[1] = ($event) => jump(-1))
468
+ }, [
469
+ createVNode(unref(Left))
470
+ ])
471
+ ]),
472
+ createElementVNode("div", _hoisted_4, toDisplayString(unref(translate)("monthTitle", month.value.year, month.value.month)), 1),
473
+ createElementVNode("div", _hoisted_5, [
474
+ createElementVNode("div", {
475
+ class: "right",
476
+ onClick: _cache[2] || (_cache[2] = ($event) => jump(1))
477
+ }, [
478
+ createVNode(unref(Right))
479
+ ]),
480
+ createElementVNode("div", {
481
+ class: "double-right",
482
+ onClick: _cache[3] || (_cache[3] = ($event) => jump(12))
483
+ }, [
484
+ createVNode(unref(DoubleRight))
485
+ ])
486
+ ])
487
+ ]),
488
+ createElementVNode("div", _hoisted_6, [
489
+ createElementVNode("div", _hoisted_7, [
490
+ (openBlock(true), createElementBlock(Fragment, null, renderList(weekHeader.value, (d) => {
491
+ return openBlock(), createElementBlock("div", {
492
+ key: d.name,
493
+ class: normalizeClass(["nut-calendarcard-day header", d.key === 0 || d.key === 6 ? "weekend" : ""])
494
+ }, toDisplayString(d.name), 3);
495
+ }), 128))
496
+ ]),
497
+ createElementVNode("div", _hoisted_8, [
498
+ (openBlock(true), createElementBlock(Fragment, null, renderList(days.value, (day) => {
499
+ return openBlock(), createElementBlock("div", {
500
+ key: `${day.year}-${day.month}-${day.date}`,
501
+ class: normalizeClass(["nut-calendarcard-day", [day.type, ...getClasses(day)]]),
502
+ onClick: ($event) => handleDayClick(day)
503
+ }, [
504
+ createElementVNode("div", _hoisted_10, [
505
+ renderSlot(_ctx.$slots, "top", { day })
506
+ ]),
507
+ createElementVNode("div", _hoisted_11, [
508
+ renderSlot(_ctx.$slots, "default", { day }, () => [
509
+ createTextVNode(toDisplayString(day.date), 1)
510
+ ])
511
+ ]),
512
+ createElementVNode("div", _hoisted_12, [
513
+ renderSlot(_ctx.$slots, "bottom", { day })
514
+ ])
515
+ ], 10, _hoisted_9);
516
+ }), 128))
517
+ ])
518
+ ])
519
+ ], 512)), [
520
+ [vShow, days.value.length > 0]
521
+ ]);
522
+ };
523
+ }
524
+ }));
525
+ withInstall(_sfc_main);
526
+ export {
527
+ _sfc_main as CalendarCard,
528
+ _sfc_main as default
529
+ };
@@ -0,0 +1 @@
1
+ .nut-calendarcard{background:var(--nut-white, #fff);border-radius:12px;overflow:hidden;font-size:var(--nut-calendar-base-font, var(--nut-font-size-3, 16px));color:var(--nut-black, #000)}.nut-calendarcard-header{display:flex;flex-direction:row;align-items:center;justify-content:space-between;font-weight:normal}.nut-calendarcard-header-left,.nut-calendarcard-header-right{display:flex;flex-direction:row;cursor:pointer;margin:16px;line-height:1}.nut-calendarcard-header-left .left,.nut-calendarcard-header-right .left{margin-left:8px}.nut-calendarcard-header-left .right,.nut-calendarcard-header-right .right{margin-right:8px}.nut-calendarcard-days{display:flex;flex-direction:row;flex-wrap:wrap;align-items:center}.nut-calendarcard-day{display:flex;align-items:center;justify-content:center;flex-direction:column;position:relative;width:14.28%;height:48px;cursor:pointer;margin-bottom:4px;text-align:center;user-select:none}.nut-calendarcard-day.header{cursor:auto}.nut-calendarcard-day-top,.nut-calendarcard-day-bottom{width:100%;height:12px;font-size:12px;line-height:12px}.nut-calendarcard-day.weekend{color:var(--nut-calendar-choose-color, var(--nut-primary-color, #fa2c19))}.nut-calendarcard-day.mid{background-color:var(--nut-calendar-choose-background-color, rgba(250, 44, 25, 0.09));color:var(--nut-calendar-choose-color, var(--nut-primary-color, #fa2c19))}.nut-calendarcard-day.active,.nut-calendarcard-day.start,.nut-calendarcard-day.end{background-color:var(--nut-primary-color, #fa2c19);color:var(--nut-white, #fff)}.nut-calendarcard-day .nut-calendar-day-info{color:var(--nut-calendar-primary-color, var(--nut-primary-color, #fa2c19))}.nut-calendarcard-day.prev,.nut-calendarcard-day.next,.nut-calendarcard-day.disabled{color:var(--nut-calendar-disable-color, #d1d0d0);cursor:not-allowed}
@@ -0,0 +1,2 @@
1
+ import CalendarCard from './CalendarCard.js';
2
+ export { CalendarCard, CalendarCard as default };
@@ -0,0 +1,92 @@
1
+ .nut-calendarcard {
2
+ background: $white;
3
+ border-radius: 12px;
4
+ overflow: hidden;
5
+ font-size: $calendar-base-font;
6
+ color: $black;
7
+
8
+ &-header {
9
+ display: flex;
10
+ flex-direction: row;
11
+ align-items: center;
12
+ justify-content: space-between;
13
+ font-weight: normal;
14
+
15
+ &-left,
16
+ &-right {
17
+ display: flex;
18
+ flex-direction: row;
19
+ cursor: pointer;
20
+ margin: 16px;
21
+ line-height: 1;
22
+
23
+ .left {
24
+ margin-left: 8px;
25
+ }
26
+ .right {
27
+ margin-right: 8px;
28
+ }
29
+ }
30
+ }
31
+
32
+ &-days {
33
+ display: flex;
34
+ flex-direction: row;
35
+ flex-wrap: wrap;
36
+ align-items: center;
37
+ }
38
+
39
+ &-day {
40
+ display: flex;
41
+ align-items: center;
42
+ justify-content: center;
43
+ flex-direction: column;
44
+ position: relative;
45
+ width: 14.28%;
46
+ height: 48px;
47
+ cursor: pointer;
48
+ margin-bottom: 4px;
49
+ text-align: center;
50
+ user-select: none;
51
+
52
+ &.header {
53
+ cursor: auto;
54
+ }
55
+
56
+ &-top,
57
+ &-bottom {
58
+ width: 100%;
59
+ height: 12px;
60
+ font-size: 12px;
61
+ line-height: 12px;
62
+ }
63
+
64
+ &.weekend {
65
+ color: $calendar-choose-color;
66
+ }
67
+
68
+ &.mid {
69
+ background-color: $calendar-choose-background-color;
70
+ color: $calendar-choose-color;
71
+ }
72
+
73
+ &.active,
74
+ &.start,
75
+ &.end {
76
+ background-color: $primary-color;
77
+ color: $white;
78
+ }
79
+
80
+ .nut-calendar-day-info {
81
+ color: $calendar-primary-color;
82
+ }
83
+
84
+ // 上个月、下个月
85
+ &.prev,
86
+ &.next,
87
+ &.disabled {
88
+ color: $calendar-disable-color;
89
+ cursor: not-allowed;
90
+ }
91
+ }
92
+ }
@@ -0,0 +1,2 @@
1
+ import '../../../styles/reset.css';
2
+ import '../index.css';
@@ -0,0 +1,2 @@
1
+ import '../../../styles/reset.css';
2
+ import '../index.scss';