@nutui/nutui 4.2.6 → 4.3.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/nutui.es.js +4 -2
  3. package/dist/nutui.js +5569 -5179
  4. package/dist/nutui.umd.js +1 -1
  5. package/dist/packages/calendar/Calendar.js +19 -4
  6. package/dist/packages/calendarcard/CalendarCard.js +525 -0
  7. package/dist/packages/calendarcard/index.css +1 -0
  8. package/dist/packages/calendarcard/index.mjs +2 -0
  9. package/dist/packages/calendarcard/index.scss +92 -0
  10. package/dist/packages/calendarcard/style/css.mjs +2 -0
  11. package/dist/packages/calendarcard/style/index.mjs +2 -0
  12. package/dist/packages/calendaritem/CalendarItem.js +817 -7
  13. package/dist/packages/cascader/index.css +1 -1
  14. package/dist/packages/cascader/index.scss +1 -2
  15. package/dist/packages/date-djiVNSnJ.js +145 -0
  16. package/dist/packages/datepicker/DatePicker.js +31 -24
  17. package/dist/packages/datepicker/index.css +1 -1
  18. package/dist/packages/dialog/index.css +1 -1
  19. package/dist/packages/dialog/index.scss +0 -3
  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/picker/index.css +1 -1
  30. package/dist/packages/picker/index.scss +3 -0
  31. package/dist/packages/swiper/Swiper.js +5 -1
  32. package/dist/packages/tabs/Tabs.js +21 -4
  33. package/dist/packages/tabs/index.css +1 -1
  34. package/dist/packages/tabs/index.scss +6 -0
  35. package/dist/smartips/web-types.json +74 -4
  36. package/dist/style.css +1 -1
  37. package/dist/styles/base-jdb.css +1 -1
  38. package/dist/styles/base-jddkh.css +1 -1
  39. package/dist/styles/base-jdt.css +1 -1
  40. package/dist/styles/themes/default.scss +1 -0
  41. package/dist/styles/themes/jdb.scss +1 -0
  42. package/dist/styles/themes/jddkh.scss +1 -0
  43. package/dist/styles/themes/jdt.scss +1 -0
  44. package/dist/styles/variables-jdb.scss +1 -0
  45. package/dist/styles/variables-jddkh.scss +1 -0
  46. package/dist/styles/variables-jdt.scss +1 -0
  47. package/dist/styles/variables.scss +1 -0
  48. package/dist/types/__VUE/actionsheet/index.vue.d.ts +3 -3
  49. package/dist/types/__VUE/address/index.vue.d.ts +2 -2
  50. package/dist/types/__VUE/addresslist/components/GeneralShell.vue.d.ts +1 -1
  51. package/dist/types/__VUE/addresslist/components/ItemContents.vue.d.ts +1 -1
  52. package/dist/types/__VUE/addresslist/index.vue.d.ts +1 -1
  53. package/dist/types/__VUE/animate/index.vue.d.ts +1 -1
  54. package/dist/types/__VUE/audio/index.vue.d.ts +7 -5
  55. package/dist/types/__VUE/audio/types.d.ts +1 -0
  56. package/dist/types/__VUE/audiooperate/index.vue.d.ts +7 -5
  57. package/dist/types/__VUE/audiooperate/types.d.ts +1 -0
  58. package/dist/types/__VUE/avatar/index.vue.d.ts +2 -2
  59. package/dist/types/__VUE/avatarcropper/index.vue.d.ts +1 -1
  60. package/dist/types/__VUE/avatargroup/index.vue.d.ts +2 -2
  61. package/dist/types/__VUE/backtop/index.vue.d.ts +1 -1
  62. package/dist/types/__VUE/badge/index.vue.d.ts +1 -1
  63. package/dist/types/__VUE/barrage/index.vue.d.ts +1 -1
  64. package/dist/types/__VUE/button/index.vue.d.ts +2 -2
  65. package/dist/types/__VUE/calendar/index.vue.d.ts +4 -2
  66. package/dist/types/__VUE/calendarcard/icon.d.ts +12 -0
  67. package/dist/types/__VUE/calendarcard/icon.taro.d.ts +12 -0
  68. package/dist/types/__VUE/calendarcard/index.vue.d.ts +95 -0
  69. package/dist/types/__VUE/calendarcard/types.d.ts +12 -0
  70. package/dist/types/__VUE/calendarcard/utils.d.ts +19 -0
  71. package/dist/types/__VUE/calendaritem/index.vue.d.ts +1 -1
  72. package/dist/types/__VUE/card/index.vue.d.ts +1 -1
  73. package/dist/types/__VUE/cascader/cascader-item.vue.d.ts +1 -1
  74. package/dist/types/__VUE/cascader/index.vue.d.ts +2 -2
  75. package/dist/types/__VUE/category/index.vue.d.ts +1 -1
  76. package/dist/types/__VUE/categorypane/index.vue.d.ts +1 -1
  77. package/dist/types/__VUE/cell/index.vue.d.ts +3 -3
  78. package/dist/types/__VUE/cellgroup/index.vue.d.ts +1 -1
  79. package/dist/types/__VUE/checkbox/index.vue.d.ts +1 -1
  80. package/dist/types/__VUE/checkboxgroup/index.vue.d.ts +1 -1
  81. package/dist/types/__VUE/circleprogress/index.vue.d.ts +1 -1
  82. package/dist/types/__VUE/col/index.vue.d.ts +1 -1
  83. package/dist/types/__VUE/collapse/index.vue.d.ts +1 -1
  84. package/dist/types/__VUE/collapseitem/index.vue.d.ts +1 -1
  85. package/dist/types/__VUE/comment/components/CmtBottom.vue.d.ts +1 -1
  86. package/dist/types/__VUE/comment/components/CmtHeader.vue.d.ts +1 -1
  87. package/dist/types/__VUE/comment/components/CmtImages.vue.d.ts +1 -1
  88. package/dist/types/__VUE/comment/index.vue.d.ts +1 -1
  89. package/dist/types/__VUE/configprovider/index.vue.d.ts +1 -1
  90. package/dist/types/__VUE/countdown/index.vue.d.ts +1 -1
  91. package/dist/types/__VUE/countup/index.vue.d.ts +3 -3
  92. package/dist/types/__VUE/datepicker/index.vue.d.ts +3 -3
  93. package/dist/types/__VUE/dialog/index.vue.d.ts +2 -2
  94. package/dist/types/__VUE/divider/index.vue.d.ts +1 -1
  95. package/dist/types/__VUE/drag/index.vue.d.ts +1 -1
  96. package/dist/types/__VUE/ecard/index.vue.d.ts +1 -1
  97. package/dist/types/__VUE/elevator/index.vue.d.ts +1 -1
  98. package/dist/types/__VUE/ellipsis/index.vue.d.ts +2 -2
  99. package/dist/types/__VUE/empty/index.vue.d.ts +1 -1
  100. package/dist/types/__VUE/fixednav/index.vue.d.ts +1 -1
  101. package/dist/types/__VUE/form/index.vue.d.ts +1 -1
  102. package/dist/types/__VUE/formitem/index.vue.d.ts +1 -1
  103. package/dist/types/__VUE/grid/index.vue.d.ts +1 -1
  104. package/dist/types/__VUE/griditem/index.vue.d.ts +1 -1
  105. package/dist/types/__VUE/icon/index.vue.d.ts +1 -1
  106. package/dist/types/__VUE/image/index.vue.d.ts +2 -2
  107. package/dist/types/__VUE/imagepreview/imagePreviewItem.vue.d.ts +1 -1
  108. package/dist/types/__VUE/imagepreview/index.vue.d.ts +1 -1
  109. package/dist/types/__VUE/indicator/index.vue.d.ts +2 -2
  110. package/dist/types/__VUE/infiniteloading/index.vue.d.ts +1 -1
  111. package/dist/types/__VUE/input/index.vue.d.ts +3 -3
  112. package/dist/types/__VUE/inputnumber/index.vue.d.ts +2 -2
  113. package/dist/types/__VUE/invoice/index.vue.d.ts +1 -1
  114. package/dist/types/__VUE/layout/index.vue.d.ts +1 -1
  115. package/dist/types/__VUE/list/index.vue.d.ts +1 -1
  116. package/dist/types/__VUE/menu/index.vue.d.ts +1 -1
  117. package/dist/types/__VUE/menuitem/index.vue.d.ts +1 -1
  118. package/dist/types/__VUE/navbar/index.vue.d.ts +2 -2
  119. package/dist/types/__VUE/noticebar/index.vue.d.ts +1 -1
  120. package/dist/types/__VUE/notify/index.vue.d.ts +1 -1
  121. package/dist/types/__VUE/numberkeyboard/index.vue.d.ts +3 -3
  122. package/dist/types/__VUE/overlay/index.vue.d.ts +1 -1
  123. package/dist/types/__VUE/pagination/index.vue.d.ts +1 -1
  124. package/dist/types/__VUE/picker/Column.vue.d.ts +3 -3
  125. package/dist/types/__VUE/picker/index.vue.d.ts +2 -2
  126. package/dist/types/__VUE/popover/index.vue.d.ts +2 -2
  127. package/dist/types/__VUE/popup/index.vue.d.ts +2 -2
  128. package/dist/types/__VUE/price/index.vue.d.ts +1 -1
  129. package/dist/types/__VUE/progress/index.vue.d.ts +1 -1
  130. package/dist/types/__VUE/pullrefresh/index.vue.d.ts +1 -1
  131. package/dist/types/__VUE/radio/index.vue.d.ts +2 -2
  132. package/dist/types/__VUE/radiogroup/index.vue.d.ts +1 -1
  133. package/dist/types/__VUE/range/index.vue.d.ts +1 -1
  134. package/dist/types/__VUE/rate/index.vue.d.ts +1 -1
  135. package/dist/types/__VUE/row/index.vue.d.ts +2 -2
  136. package/dist/types/__VUE/searchbar/index.vue.d.ts +2 -2
  137. package/dist/types/__VUE/shortpassword/index.vue.d.ts +3 -3
  138. package/dist/types/__VUE/sidenavbar/index.vue.d.ts +1 -1
  139. package/dist/types/__VUE/sidenavbaritem/index.vue.d.ts +1 -1
  140. package/dist/types/__VUE/signature/index.vue.d.ts +1 -1
  141. package/dist/types/__VUE/skeleton/index.vue.d.ts +1 -1
  142. package/dist/types/__VUE/sku/components/SkuHeader.vue.d.ts +1 -1
  143. package/dist/types/__VUE/sku/components/SkuOperate.vue.d.ts +1 -1
  144. package/dist/types/__VUE/sku/components/SkuSelect.vue.d.ts +1 -1
  145. package/dist/types/__VUE/sku/components/SkuStepper.vue.d.ts +1 -1
  146. package/dist/types/__VUE/sku/index.vue.d.ts +2 -2
  147. package/dist/types/__VUE/space/index.vue.d.ts +1 -1
  148. package/dist/types/__VUE/step/index.vue.d.ts +1 -1
  149. package/dist/types/__VUE/steps/index.vue.d.ts +2 -2
  150. package/dist/types/__VUE/sticky/index.vue.d.ts +1 -1
  151. package/dist/types/__VUE/subsidenavbar/index.vue.d.ts +1 -1
  152. package/dist/types/__VUE/swipe/index.vue.d.ts +1 -1
  153. package/dist/types/__VUE/swipegroup/index.vue.d.ts +1 -1
  154. package/dist/types/__VUE/swiper/index.vue.d.ts +10 -1
  155. package/dist/types/__VUE/swiperitem/index.vue.d.ts +1 -1
  156. package/dist/types/__VUE/switch/index.vue.d.ts +1 -1
  157. package/dist/types/__VUE/tabbar/index.vue.d.ts +1 -1
  158. package/dist/types/__VUE/tabbaritem/index.vue.d.ts +1 -1
  159. package/dist/types/__VUE/table/index.vue.d.ts +1 -1
  160. package/dist/types/__VUE/table/renderColumn.d.ts +1 -1
  161. package/dist/types/__VUE/tabpane/index.vue.d.ts +1 -1
  162. package/dist/types/__VUE/tabs/index.vue.d.ts +13 -4
  163. package/dist/types/__VUE/tabs/types.d.ts +1 -0
  164. package/dist/types/__VUE/tag/index.vue.d.ts +1 -1
  165. package/dist/types/__VUE/textarea/index.vue.d.ts +2 -2
  166. package/dist/types/__VUE/timedetail/index.vue.d.ts +1 -1
  167. package/dist/types/__VUE/timepannel/index.vue.d.ts +1 -1
  168. package/dist/types/__VUE/timeselect/index.vue.d.ts +2 -2
  169. package/dist/types/__VUE/toast/index.vue.d.ts +2 -2
  170. package/dist/types/__VUE/tour/index.vue.d.ts +2 -2
  171. package/dist/types/__VUE/trendarrow/index.vue.d.ts +1 -1
  172. package/dist/types/__VUE/uploader/index.vue.d.ts +2 -2
  173. package/dist/types/__VUE/video/index.vue.d.ts +1 -1
  174. package/dist/types/__VUE/watermark/index.vue.d.ts +1 -1
  175. package/dist/types/index.d.ts +3 -2
  176. package/dist/types/locale/lang/baseLang.d.ts +8 -0
  177. package/dist/types/locale/lang/en-US.d.ts +8 -0
  178. package/dist/types/locale/lang/id-ID.d.ts +8 -0
  179. package/dist/types/locale/lang/zh-CN.d.ts +8 -0
  180. package/dist/types/locale/lang/zh-TW.d.ts +8 -0
  181. package/dist/types/utils/touchEmulator.d.ts +0 -0
  182. package/package.json +1 -1
  183. package/dist/packages/index-NLe0VBkN.js +0 -959
@@ -1,7 +1,8 @@
1
1
  import { computed, ref, resolveComponent, openBlock, createBlock, mergeProps, withCtx, createVNode, createSlots, renderSlot } from "vue";
2
2
  import { c as createComponent } from "../component-TCzwHGVq.js";
3
- import { N as NutCalendarItem, U as Utils } from "../index-NLe0VBkN.js";
3
+ import NutCalendarItem from "../calendaritem/CalendarItem.js";
4
4
  import { N as NutPopup } from "../index-rbZsBckW.js";
5
+ import { U as Utils } from "../date-djiVNSnJ.js";
5
6
  import { _ as _export_sfc } from "../_plugin-vue_export-helper-yVxbj29m.js";
6
7
  import "../raf-MQjoO-Ag.js";
7
8
  import "../index-s3RgMhc7.js";
@@ -88,6 +89,14 @@ const _sfc_main = create({
88
89
  },
89
90
  emits: ["choose", "close", "update:visible", "select"],
90
91
  setup(props, { emit, slots, expose }) {
92
+ const visible = computed({
93
+ get() {
94
+ return props.visible;
95
+ },
96
+ set(val) {
97
+ emit("update:visible", val);
98
+ }
99
+ });
91
100
  const showTopBtn = computed(() => {
92
101
  return slots.btn;
93
102
  });
@@ -133,8 +142,14 @@ const _sfc_main = create({
133
142
  const select = (param) => {
134
143
  emit("select", param);
135
144
  };
145
+ const opened = () => {
146
+ var _a;
147
+ (_a = calendarRef.value) == null ? void 0 : _a.initPosition();
148
+ };
136
149
  return {
150
+ visible,
137
151
  closePopup,
152
+ opened,
138
153
  update,
139
154
  close,
140
155
  select,
@@ -154,14 +169,14 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
154
169
  return _ctx.poppable ? (openBlock(), createBlock(_component_nut_popup, mergeProps({
155
170
  key: 0,
156
171
  visible: _ctx.visible,
172
+ "onUpdate:visible": _cache[0] || (_cache[0] = ($event) => _ctx.visible = $event),
157
173
  position: "bottom",
158
174
  round: "",
159
175
  closeable: ""
160
176
  }, _ctx.$attrs, {
161
177
  style: { height: "85vh" },
162
178
  "lock-scroll": _ctx.lockScroll,
163
- onClickOverlay: _ctx.closePopup,
164
- onClickCloseIcon: _ctx.closePopup
179
+ onOpened: _ctx.opened
165
180
  }), {
166
181
  default: withCtx(() => [
167
182
  createVNode(_component_nut_calendar_item, {
@@ -233,7 +248,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
233
248
  ]), 1032, ["type", "is-auto-back-fill", "poppable", "title", "default-value", "start-date", "end-date", "confirm-text", "start-text", "end-text", "show-today", "show-title", "show-sub-title", "to-date-animation", "first-day-of-week", "disabled-date", "onUpdate", "onClose", "onChoose", "onSelect"])
234
249
  ]),
235
250
  _: 3
236
- }, 16, ["visible", "lock-scroll", "onClickOverlay", "onClickCloseIcon"])) : (openBlock(), createBlock(_component_nut_calendar_item, {
251
+ }, 16, ["visible", "lock-scroll", "onOpened"])) : (openBlock(), createBlock(_component_nut_calendar_item, {
237
252
  key: 1,
238
253
  ref: "calendarRef",
239
254
  type: _ctx.type,
@@ -0,0 +1,525 @@
1
+ import { h, ref, computed, watchEffect, resolveComponent, withDirectives, openBlock, createElementBlock, createElementVNode, createVNode, toDisplayString, Fragment, renderList, normalizeClass, renderSlot, createTextVNode, vShow } from "vue";
2
+ import { U as Utils } from "../date-djiVNSnJ.js";
3
+ import { u as useLocale } from "../index-s3RgMhc7.js";
4
+ import { c as createComponent } from "../component-TCzwHGVq.js";
5
+ import { _ as _export_sfc } from "../_plugin-vue_export-helper-yVxbj29m.js";
6
+ import "@nutui/nutui/dist/packages/locale/lang";
7
+ import "../util-4Jkyw4BJ.js";
8
+ const Left = () => {
9
+ return h(
10
+ "svg",
11
+ {
12
+ xmlns: "http://www.w3.org/2000/svg",
13
+ width: "18",
14
+ height: "18",
15
+ viewBox: "0 0 18 18"
16
+ },
17
+ [
18
+ h("path", {
19
+ 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"
20
+ })
21
+ ]
22
+ );
23
+ };
24
+ const Right = () => {
25
+ return h(
26
+ "svg",
27
+ {
28
+ xmlns: "http://www.w3.org/2000/svg",
29
+ width: "18",
30
+ height: "18",
31
+ viewBox: "0 0 18 18"
32
+ },
33
+ [
34
+ h("path", {
35
+ 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"
36
+ })
37
+ ]
38
+ );
39
+ };
40
+ const DoubleLeft = () => {
41
+ return h(
42
+ "svg",
43
+ {
44
+ xmlns: "http://www.w3.org/2000/svg",
45
+ width: "18",
46
+ height: "18",
47
+ viewBox: "0 0 18 18"
48
+ },
49
+ [
50
+ h("path", {
51
+ 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"
52
+ })
53
+ ]
54
+ );
55
+ };
56
+ const DoubleRight = () => {
57
+ return h(
58
+ "svg",
59
+ {
60
+ xmlns: "http://www.w3.org/2000/svg",
61
+ width: "18",
62
+ height: "18",
63
+ viewBox: "0 0 18 18"
64
+ },
65
+ [
66
+ h("path", {
67
+ 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"
68
+ })
69
+ ]
70
+ );
71
+ };
72
+ const convertDateToDay = (date) => {
73
+ return date ? {
74
+ year: date.getFullYear(),
75
+ month: date.getMonth() + 1,
76
+ date: date.getDate()
77
+ } : null;
78
+ };
79
+ const convertDayToDate = (day) => {
80
+ return day ? new Date(day.year, day.month - 1, day.date) : null;
81
+ };
82
+ const valueToRange = (val) => {
83
+ if (Array.isArray(val)) {
84
+ return val.map((date) => {
85
+ return convertDateToDay(date);
86
+ });
87
+ }
88
+ return val ? [convertDateToDay(val)] : [];
89
+ };
90
+ const rangeTovalue = (range) => {
91
+ if (Array.isArray(range)) {
92
+ return range.map((day) => {
93
+ return convertDayToDate(day);
94
+ });
95
+ }
96
+ return range ? [convertDayToDate(range)] : [];
97
+ };
98
+ const getPrevMonthDays = (year, month, firstDayOfWeek) => {
99
+ let prevMonth = month - 1;
100
+ let prevYear = year;
101
+ if (prevMonth <= 0) {
102
+ prevMonth = 12;
103
+ prevYear -= 1;
104
+ }
105
+ let days = Utils.getMonthPreDay(year, month);
106
+ days -= firstDayOfWeek;
107
+ if (days >= 7) {
108
+ days -= 7;
109
+ }
110
+ const preDates = Utils.getMonthDays(`${prevYear}`, `${prevMonth}`);
111
+ const months = Array.from(Array(preDates), (_, k) => {
112
+ return {
113
+ type: "prev",
114
+ year: prevYear,
115
+ month: prevMonth,
116
+ date: k + 1
117
+ };
118
+ });
119
+ return months.slice(preDates - days);
120
+ };
121
+ const getCurrentMonthDays = (year, month) => {
122
+ const days = Utils.getMonthDays(`${year}`, `${month}`);
123
+ return Array.from(Array(days), (_, k) => {
124
+ return {
125
+ type: "current",
126
+ year,
127
+ month,
128
+ date: k + 1
129
+ };
130
+ });
131
+ };
132
+ const getCurrentWeekDays = (day, firstDayOfWeek) => {
133
+ const current = new Date(day.year, day.month - 1, day.date);
134
+ const count = (current.getDay() + 7 - firstDayOfWeek) % 7;
135
+ return [
136
+ convertDateToDay(new Date(current.getTime() - 24 * 60 * 60 * 1e3 * count)),
137
+ convertDateToDay(new Date(current.getTime() + 24 * 60 * 60 * 1e3 * (6 - count)))
138
+ ];
139
+ };
140
+ const getDays = (month, firstDayOfWeek) => {
141
+ const y = month.year;
142
+ const m = month.month;
143
+ const days = [...getPrevMonthDays(y, m, firstDayOfWeek), ...getCurrentMonthDays(y, m)];
144
+ const size = days.length;
145
+ const yearOfNextMonth = month.month === 12 ? month.year + 1 : month.year;
146
+ const monthOfNextMonth = month.month === 12 ? 1 : month.month + 1;
147
+ for (let i = 1; i <= 42 - size; i++) {
148
+ days.push({
149
+ type: "next",
150
+ year: yearOfNextMonth,
151
+ month: monthOfNextMonth,
152
+ date: i
153
+ });
154
+ }
155
+ return days;
156
+ };
157
+ const compareDay = (day1, day2) => {
158
+ if (day1 && day2) {
159
+ if (day1.year === day2.year) {
160
+ if (day1.month === day2.month) {
161
+ return day1.date - day2.date;
162
+ }
163
+ return day1.month - day2.month;
164
+ }
165
+ return day1.year - day2.year;
166
+ }
167
+ };
168
+ const isSameDay = (day1, day2) => {
169
+ return compareDay(day1, day2) === 0;
170
+ };
171
+ const cN = "NutCalendarCard";
172
+ const { create } = createComponent("calendar-card");
173
+ const _sfc_main = create({
174
+ components: {
175
+ DoubleLeft,
176
+ Left,
177
+ Right,
178
+ DoubleRight
179
+ },
180
+ props: {
181
+ type: {
182
+ type: String,
183
+ default: "single"
184
+ },
185
+ firstDayOfWeek: {
186
+ type: Number,
187
+ default: 0
188
+ },
189
+ modelValue: {
190
+ type: [Object, Array],
191
+ default: () => []
192
+ },
193
+ startDate: {
194
+ type: Date,
195
+ default: null
196
+ },
197
+ endDate: {
198
+ type: Date,
199
+ default: null
200
+ },
201
+ disableDay: {
202
+ type: Function,
203
+ default: () => false
204
+ }
205
+ },
206
+ emits: ["update:modelValue", "change", "dayClick", "pageChange"],
207
+ setup(props, { emit, expose }) {
208
+ const translate = useLocale(cN);
209
+ const initMonth = () => {
210
+ let date = new Date(Date.now());
211
+ const val = props.modelValue;
212
+ if (Array.isArray(val)) {
213
+ if (val.length) {
214
+ date = val[0];
215
+ }
216
+ } else if (val) {
217
+ date = val;
218
+ }
219
+ return {
220
+ year: date.getFullYear(),
221
+ month: date.getMonth() + 1
222
+ };
223
+ };
224
+ const month = ref(initMonth());
225
+ const days = ref([]);
226
+ const weekHeader = computed(() => {
227
+ const weekdays = translate("weekdays").map((day, index2) => {
228
+ return {
229
+ name: day,
230
+ key: index2
231
+ };
232
+ });
233
+ return [...weekdays.slice(props.firstDayOfWeek, 7), ...weekdays.slice(0, props.firstDayOfWeek)];
234
+ });
235
+ const innerValue = ref(props.modelValue ? valueToRange(props.modelValue) : []);
236
+ watchEffect(() => {
237
+ const val = props.modelValue ? valueToRange(props.modelValue) : [];
238
+ innerValue.value = val;
239
+ });
240
+ const change = (v) => {
241
+ innerValue.value = v;
242
+ if (props.type === "single") {
243
+ const date = convertDayToDate(v[0]);
244
+ emit("update:modelValue", date);
245
+ emit("change", date);
246
+ } else if (props.type === "multiple" || props.type === "range" || props.type === "week") {
247
+ const val = rangeTovalue(v);
248
+ emit("update:modelValue", val);
249
+ emit("change", val);
250
+ }
251
+ };
252
+ watchEffect(() => {
253
+ const newDays = getDays(month.value, props.firstDayOfWeek);
254
+ days.value = newDays;
255
+ emit("pageChange", month.value);
256
+ });
257
+ const isDisable = (day) => {
258
+ if (props.disableDay && props.disableDay(day)) {
259
+ return true;
260
+ }
261
+ if (props.startDate && Number(compareDay(day, convertDateToDay(props.startDate))) < 0) {
262
+ return true;
263
+ }
264
+ if (props.endDate && Number(compareDay(day, convertDateToDay(props.endDate))) > 0) {
265
+ return true;
266
+ }
267
+ return false;
268
+ };
269
+ const isActive = (day) => {
270
+ if (props.type === "single" || props.type === "multiple") {
271
+ for (const val in innerValue.value) {
272
+ if (isSameDay(day, innerValue.value[val])) {
273
+ return true;
274
+ }
275
+ }
276
+ } else if (props.type === "range" && innerValue.value.length === 1 && isSameDay(innerValue.value[0], day)) {
277
+ return true;
278
+ }
279
+ return false;
280
+ };
281
+ const isStart = (day) => {
282
+ return (props.type === "range" || props.type === "week") && innerValue.value.length === 2 && isSameDay(day, innerValue.value[0]);
283
+ };
284
+ const isEnd = (day) => {
285
+ return (props.type === "range" || props.type === "week") && innerValue.value.length === 2 && isSameDay(day, innerValue.value[1]);
286
+ };
287
+ const isMid = (day) => {
288
+ if (props.type === "range" || props.type === "week") {
289
+ if (innerValue.value.length === 2) {
290
+ const c1 = compareDay(innerValue.value[0], day);
291
+ const c2 = compareDay(day, innerValue.value[1]);
292
+ if (c1 && c1 < 0 && c2 && c2 < 0) {
293
+ return true;
294
+ }
295
+ }
296
+ }
297
+ return false;
298
+ };
299
+ const isWeekend = (day) => {
300
+ const d = new Date(day.year, day.month - 1, day.date).getDay();
301
+ return d === 0 || d === 6;
302
+ };
303
+ const getClasses = (day) => {
304
+ if (isDisable(day)) {
305
+ return ["disabled"];
306
+ }
307
+ const res = [];
308
+ if (day.type === "current") {
309
+ if (isActive(day)) {
310
+ res.push("active");
311
+ }
312
+ if (isStart(day)) {
313
+ res.push("start");
314
+ }
315
+ if (isEnd(day)) {
316
+ res.push("end");
317
+ }
318
+ if (isMid(day)) {
319
+ res.push("mid");
320
+ }
321
+ if (isWeekend(day)) {
322
+ res.push("weekend");
323
+ }
324
+ }
325
+ return res;
326
+ };
327
+ const jumpTo = (y, m) => {
328
+ if (props.startDate) {
329
+ const c = compareDay(
330
+ {
331
+ year: y,
332
+ month: m,
333
+ date: 31
334
+ },
335
+ convertDateToDay(props.startDate)
336
+ );
337
+ if (c && c < 0) {
338
+ return;
339
+ }
340
+ }
341
+ if (props.endDate) {
342
+ const c = compareDay(
343
+ {
344
+ year: y,
345
+ month: m,
346
+ date: 1
347
+ },
348
+ convertDateToDay(props.endDate)
349
+ );
350
+ if (c && c > 0) {
351
+ return;
352
+ }
353
+ }
354
+ month.value = {
355
+ year: y,
356
+ month: m
357
+ };
358
+ };
359
+ const jump = (step = 1) => {
360
+ const current = month.value.year * 12 + month.value.month;
361
+ let newMonth = (current + step) % 12;
362
+ if (newMonth === 0) {
363
+ newMonth = 12;
364
+ }
365
+ const newYear = Math.floor((current + step - newMonth) / 12);
366
+ jumpTo(newYear, newMonth);
367
+ };
368
+ const handleDayClick = (day) => {
369
+ if (day.type === "prev" || day.type === "next" || isDisable(day)) {
370
+ return;
371
+ }
372
+ emit("dayClick", day);
373
+ switch (props.type) {
374
+ case "single": {
375
+ if (innerValue.value[0] && isSameDay(innerValue.value[0], day)) {
376
+ change([]);
377
+ } else {
378
+ change([day]);
379
+ }
380
+ break;
381
+ }
382
+ case "multiple": {
383
+ const t = innerValue.value.find((i) => isSameDay(i, day));
384
+ if (t) {
385
+ change(innerValue.value.filter((i) => i !== t));
386
+ } else {
387
+ change([...innerValue.value, day]);
388
+ }
389
+ break;
390
+ }
391
+ case "range": {
392
+ const len = innerValue.value.length;
393
+ if (len === 0 || len === 2) {
394
+ change([day]);
395
+ } else if (len === 1) {
396
+ const t = compareDay(innerValue.value[0], day);
397
+ if (t === 0 || t === null || t === void 0) {
398
+ change([]);
399
+ } else if (t < 0) {
400
+ change([innerValue.value[0], day]);
401
+ } else {
402
+ change([day, innerValue.value[0]]);
403
+ }
404
+ } else {
405
+ console.warn("[NutUI] Calendar range error");
406
+ }
407
+ break;
408
+ }
409
+ case "week": {
410
+ if (innerValue.value.length === 2 || innerValue.value.length === 0) {
411
+ const [left, right] = getCurrentWeekDays(day, props.firstDayOfWeek);
412
+ change([left, right]);
413
+ } else {
414
+ console.warn("[NutUI] Calendar week error");
415
+ }
416
+ break;
417
+ }
418
+ default: {
419
+ console.warn("[NutUI] Calendar type error");
420
+ }
421
+ }
422
+ };
423
+ expose({
424
+ jump,
425
+ jumpTo
426
+ });
427
+ return {
428
+ days,
429
+ month,
430
+ weekHeader,
431
+ getClasses,
432
+ handleDayClick,
433
+ jump,
434
+ translate
435
+ };
436
+ }
437
+ });
438
+ const _hoisted_1 = { class: "nut-calendarcard" };
439
+ const _hoisted_2 = { class: "nut-calendarcard-header" };
440
+ const _hoisted_3 = { class: "nut-calendarcard-header-left" };
441
+ const _hoisted_4 = { class: "nut-calendarcard-header-title" };
442
+ const _hoisted_5 = { class: "nut-calendarcard-header-right" };
443
+ const _hoisted_6 = { class: "nut-calendarcard-content" };
444
+ const _hoisted_7 = { class: "nut-calendarcard-days" };
445
+ const _hoisted_8 = { class: "nut-calendarcard-days" };
446
+ const _hoisted_9 = ["onClick"];
447
+ const _hoisted_10 = { class: "nut-calendarcard-day-top" };
448
+ const _hoisted_11 = { class: "nut-calendarcard-day-inner" };
449
+ const _hoisted_12 = { class: "nut-calendarcard-day-bottom" };
450
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
451
+ const _component_DoubleLeft = resolveComponent("DoubleLeft");
452
+ const _component_Left = resolveComponent("Left");
453
+ const _component_Right = resolveComponent("Right");
454
+ const _component_DoubleRight = resolveComponent("DoubleRight");
455
+ return withDirectives((openBlock(), createElementBlock("div", _hoisted_1, [
456
+ createElementVNode("div", _hoisted_2, [
457
+ createElementVNode("div", _hoisted_3, [
458
+ createElementVNode("div", {
459
+ class: "double-left",
460
+ onClick: _cache[0] || (_cache[0] = ($event) => _ctx.jump(-12))
461
+ }, [
462
+ createVNode(_component_DoubleLeft)
463
+ ]),
464
+ createElementVNode("div", {
465
+ class: "left",
466
+ onClick: _cache[1] || (_cache[1] = ($event) => _ctx.jump(-1))
467
+ }, [
468
+ createVNode(_component_Left)
469
+ ])
470
+ ]),
471
+ createElementVNode("div", _hoisted_4, toDisplayString(_ctx.translate("monthTitle", _ctx.month.year, _ctx.month.month)), 1),
472
+ createElementVNode("div", _hoisted_5, [
473
+ createElementVNode("div", {
474
+ class: "right",
475
+ onClick: _cache[2] || (_cache[2] = ($event) => _ctx.jump(1))
476
+ }, [
477
+ createVNode(_component_Right)
478
+ ]),
479
+ createElementVNode("div", {
480
+ class: "double-right",
481
+ onClick: _cache[3] || (_cache[3] = ($event) => _ctx.jump(12))
482
+ }, [
483
+ createVNode(_component_DoubleRight)
484
+ ])
485
+ ])
486
+ ]),
487
+ createElementVNode("div", _hoisted_6, [
488
+ createElementVNode("div", _hoisted_7, [
489
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.weekHeader, (d) => {
490
+ return openBlock(), createElementBlock("div", {
491
+ key: d.name,
492
+ class: normalizeClass(["nut-calendarcard-day header", d.key === 0 || d.key === 6 ? "weekend" : ""])
493
+ }, toDisplayString(d.name), 3);
494
+ }), 128))
495
+ ]),
496
+ createElementVNode("div", _hoisted_8, [
497
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.days, (day) => {
498
+ return openBlock(), createElementBlock("div", {
499
+ key: `${day.year}-${day.month}-${day.date}`,
500
+ class: normalizeClass(["nut-calendarcard-day", [day.type, ..._ctx.getClasses(day)]]),
501
+ onClick: ($event) => _ctx.handleDayClick(day)
502
+ }, [
503
+ createElementVNode("div", _hoisted_10, [
504
+ renderSlot(_ctx.$slots, "top", { day })
505
+ ]),
506
+ createElementVNode("div", _hoisted_11, [
507
+ renderSlot(_ctx.$slots, "default", { day }, () => [
508
+ createTextVNode(toDisplayString(day.date), 1)
509
+ ])
510
+ ]),
511
+ createElementVNode("div", _hoisted_12, [
512
+ renderSlot(_ctx.$slots, "bottom", { day })
513
+ ])
514
+ ], 10, _hoisted_9);
515
+ }), 128))
516
+ ])
517
+ ])
518
+ ], 512)), [
519
+ [vShow, _ctx.days.length > 0]
520
+ ]);
521
+ }
522
+ const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
523
+ export {
524
+ index as default
525
+ };
@@ -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';