@tplc/wot 1.0.12 → 1.0.13

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 (62) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/components/wd-calendar/index.scss +145 -58
  3. package/components/wd-calendar/types.ts +41 -23
  4. package/components/wd-calendar/wd-calendar.vue +130 -123
  5. package/components/wd-calendar-view/month/index.scss +65 -33
  6. package/components/wd-calendar-view/month/month.vue +113 -80
  7. package/components/wd-calendar-view/month/types.ts +1 -2
  8. package/components/wd-calendar-view/monthPanel/index.scss +15 -15
  9. package/components/wd-calendar-view/monthPanel/month-panel.vue +78 -64
  10. package/components/wd-calendar-view/monthPanel/types.ts +10 -58
  11. package/components/wd-calendar-view/types.ts +36 -12
  12. package/components/wd-calendar-view/utils.ts +36 -14
  13. package/components/wd-calendar-view/wd-calendar-view.vue +7 -7
  14. package/components/wd-calendar-view/year/index.scss +13 -18
  15. package/components/wd-calendar-view/year/types.ts +1 -2
  16. package/components/wd-calendar-view/year/year.vue +43 -25
  17. package/components/wd-calendar-view/yearPanel/index.scss +4 -4
  18. package/components/wd-calendar-view/yearPanel/types.ts +2 -2
  19. package/components/wd-calendar-view/yearPanel/year-panel.vue +41 -36
  20. package/components/wd-drop-menu/index.scss +45 -17
  21. package/components/wd-drop-menu/types.ts +3 -3
  22. package/components/wd-drop-menu/wd-drop-menu.vue +25 -61
  23. package/components/wd-drop-menu-item/index.scss +15 -15
  24. package/components/wd-drop-menu-item/types.ts +15 -18
  25. package/components/wd-drop-menu-item/wd-drop-menu-item.vue +54 -33
  26. package/package.json +1 -1
  27. package/types/components/common/dayjs.d.ts +26 -0
  28. package/types/components/wd-calendar/types.d.ts +18 -24
  29. package/types/components/wd-calendar/wd-calendar.vue.d.ts +24 -40
  30. package/types/components/wd-calendar-view/month/month.vue.d.ts +3 -11
  31. package/types/components/wd-calendar-view/month/types.d.ts +0 -4
  32. package/types/components/wd-calendar-view/monthPanel/month-panel.vue.d.ts +12 -18
  33. package/types/components/wd-calendar-view/monthPanel/types.d.ts +6 -48
  34. package/types/components/wd-calendar-view/types.d.ts +4 -11
  35. package/types/components/wd-calendar-view/utils.d.ts +12 -3
  36. package/types/components/wd-calendar-view/year/types.d.ts +0 -4
  37. package/types/components/wd-calendar-view/year/year.vue.d.ts +3 -11
  38. package/types/components/wd-cell/wd-cell.vue.d.ts +5 -5
  39. package/types/components/wd-col-picker/wd-col-picker.vue.d.ts +9 -9
  40. package/types/components/wd-datetime-picker/wd-datetime-picker.vue.d.ts +10 -10
  41. package/types/components/wd-datetime-picker-view/wd-datetime-picker-view.vue.d.ts +1 -1
  42. package/types/components/wd-drop-menu/types.d.ts +3 -3
  43. package/types/components/wd-drop-menu/wd-drop-menu.vue.d.ts +5 -5
  44. package/types/components/wd-drop-menu-item/types.d.ts +15 -27
  45. package/types/components/wd-drop-menu-item/wd-drop-menu-item.vue.d.ts +35 -46
  46. package/types/components/wd-floating-panel/wd-floating-panel.vue.d.ts +1 -1
  47. package/types/components/wd-form/wd-form.vue.d.ts +1 -1
  48. package/types/components/wd-form-item/wd-form-item.vue.d.ts +1 -1
  49. package/types/components/wd-grid-item/wd-grid-item.vue.d.ts +1 -1
  50. package/types/components/wd-input/wd-input.vue.d.ts +4 -4
  51. package/types/components/wd-keyboard/wd-keyboard.vue.d.ts +1 -1
  52. package/types/components/wd-notify/wd-notify.vue.d.ts +1 -1
  53. package/types/components/wd-number-keyboard/wd-number-keyboard.vue.d.ts +1 -1
  54. package/types/components/wd-picker/wd-picker.vue.d.ts +12 -12
  55. package/types/components/wd-picker-view/wd-picker-view.vue.d.ts +2 -2
  56. package/types/components/wd-select-picker/wd-select-picker.vue.d.ts +12 -12
  57. package/types/components/wd-signature/wd-signature.vue.d.ts +2 -2
  58. package/types/components/wd-steps/wd-steps.vue.d.ts +1 -1
  59. package/types/components/wd-swiper/wd-swiper.vue.d.ts +1 -1
  60. package/types/components/wd-tabs/wd-tabs.vue.d.ts +1 -1
  61. package/types/components/wd-textarea/wd-textarea.vue.d.ts +3 -3
  62. /package/components/wd-input/{placeholder.scss → placeholder.css} +0 -0
@@ -3,23 +3,51 @@
3
3
  <wd-toast selector="wd-month" />
4
4
  <view class="month">
5
5
  <view class="wd-month">
6
- <view class="wd-month__title" v-if="showTitle">{{ monthTitle(date) }}</view>
6
+ <view class="wd-month__title">{{ monthTitle(date) }}</view>
7
7
  <view class="wd-month__days">
8
8
  <view
9
9
  v-for="(item, index) in days"
10
10
  :key="index"
11
- :class="`wd-month__day ${item.disabled ? 'is-disabled' : ''} ${item.isLastRow ? 'is-last-row' : ''} ${
12
- item.type ? dayTypeClass(item.type) : ''
13
- }`"
14
- :style="index === 0 ? firstDayStyle : ''"
11
+ :class="`wd-month__day ${item.disabled ? 'is-disabled' : ''} ${item.type ? itemClass(item.type, value!, type) : ''}`"
12
+ :style="firstDayStyle(index, item.date, firstDayOfWeek)"
15
13
  @click="handleDateClick(index)"
16
14
  >
17
15
  <view class="wd-month__day-container">
18
- <view class="wd-month__day-top">{{ item.topInfo }}</view>
19
- <view class="wd-month__day-text">
16
+ <view
17
+ class="wd-month__day-top"
18
+ :class="{
19
+ 'text-price': item.restFlag,
20
+ }"
21
+ >
22
+ {{ item.topInfo }}
23
+ </view>
24
+ <view
25
+ class="wd-month__day-text"
26
+ :class="{
27
+ 'wd-month__day-text-custom': item.text !== item.day,
28
+ 'text-price': item.restFlag,
29
+ }"
30
+ >
20
31
  {{ item.text }}
21
32
  </view>
22
- <view class="wd-month__day-bottom">{{ item.bottomInfo }}</view>
33
+ <view
34
+ class="wd-month__day-bottom text-[var(--font1-color)]"
35
+ :style="{ bottom: item.floorText ? '12px' : '6px' }"
36
+ >
37
+ <text
38
+ v-if="item.bottomInfo && item.bottomInfo.includes('¥')"
39
+ style="font-size: 8px"
40
+ >
41
+ ¥
42
+ </text>
43
+ <text>{{ item.bottomInfo?.replace('¥', '') }}</text>
44
+ </view>
45
+ <view class="wd-month__day-floor text-[var(--font2-color)]">
46
+ <text v-if="item.floorText && item.floorText.includes('¥')" style="font-size: 8px">
47
+ ¥
48
+ </text>
49
+ {{ item.floorText?.replace('¥', '') }}
50
+ </view>
23
51
  </view>
24
52
  </view>
25
53
  </view>
@@ -33,30 +61,28 @@ export default {
33
61
  options: {
34
62
  addGlobalClass: true,
35
63
  virtualHost: true,
36
- styleIsolation: 'shared'
37
- }
64
+ styleIsolation: 'shared',
65
+ },
38
66
  }
39
67
  </script>
40
68
 
41
69
  <script lang="ts" setup>
42
- import wdToast from '../../wd-toast/wd-toast.vue'
43
- import { computed, ref, watch, type CSSProperties } from 'vue'
70
+ import { computed, ref, watch } from 'vue'
44
71
  import {
45
72
  compareDate,
46
73
  formatMonthTitle,
47
74
  getDateByDefaultTime,
48
75
  getDayByOffset,
49
76
  getDayOffset,
77
+ getFirstDayStyle,
50
78
  getItemClass,
51
79
  getMonthEndDay,
52
- getNextDay,
53
- getPrevDay,
54
- getWeekRange
80
+ getWeekRange,
55
81
  } from '../utils'
56
82
  import { useToast } from '../../wd-toast'
57
- import { deepClone, isArray, isFunction, objToStyle } from '../../common/util'
83
+ import { deepClone, isArray, isFunction } from '../../common/util'
58
84
  import { useTranslate } from '../../composables/useTranslate'
59
- import type { CalendarDayItem, CalendarDayType } from '../types'
85
+ import type { CalendarDayItem, CalendarDayType, CalendarType } from '../types'
60
86
  import { monthProps } from './types'
61
87
 
62
88
  const props = defineProps(monthProps)
@@ -68,15 +94,9 @@ const days = ref<Array<CalendarDayItem>>([])
68
94
 
69
95
  const toast = useToast('wd-month')
70
96
 
71
- const offset = computed(() => {
72
- const firstDayOfWeek = props.firstDayOfWeek >= 7 ? props.firstDayOfWeek % 7 : props.firstDayOfWeek
73
- const offset = (7 + new Date(props.date).getDay() - firstDayOfWeek) % 7
74
- return offset
75
- })
76
-
77
- const dayTypeClass = computed(() => {
78
- return (monthType: CalendarDayType) => {
79
- return getItemClass(monthType, props.value, props.type)
97
+ const itemClass = computed(() => {
98
+ return (monthType: CalendarDayType, value: number | (number | null)[], type: CalendarType) => {
99
+ return getItemClass(monthType, value, type)
80
100
  }
81
101
  })
82
102
 
@@ -85,30 +105,28 @@ const monthTitle = computed(() => {
85
105
  return formatMonthTitle(date)
86
106
  }
87
107
  })
88
-
89
108
  const firstDayStyle = computed(() => {
90
- const dayStyle: CSSProperties = {}
91
- dayStyle.marginLeft = `${(100 / 7) * offset.value}%`
92
- return objToStyle(dayStyle)
109
+ return (index: number, date: number, firstDayOfWeek: number) => {
110
+ return getFirstDayStyle(index, date, firstDayOfWeek)
111
+ }
93
112
  })
94
113
 
95
- const isLastRow = (date: number) => {
96
- const currentDate = new Date(date)
97
- const currentDay = currentDate.getDate()
98
- const daysInMonth = getMonthEndDay(currentDate.getFullYear(), currentDate.getMonth() + 1)
99
- const totalDaysShown = offset.value + daysInMonth
100
- const totalRows = Math.ceil(totalDaysShown / 7)
101
- return Math.ceil((offset.value + currentDay) / 7) === totalRows
102
- }
103
114
  watch(
104
- [() => props.type, () => props.date, () => props.value, () => props.minDate, () => props.maxDate, () => props.formatter],
115
+ [
116
+ () => props.type,
117
+ () => props.date,
118
+ () => props.value,
119
+ () => props.minDate,
120
+ () => props.maxDate,
121
+ () => props.formatter,
122
+ ],
105
123
  () => {
106
124
  setDays()
107
125
  },
108
126
  {
109
127
  deep: true,
110
- immediate: true
111
- }
128
+ immediate: true,
129
+ },
112
130
  )
113
131
 
114
132
  function setDays() {
@@ -159,29 +177,17 @@ function getDateType(date: number): CalendarDayType {
159
177
  }
160
178
 
161
179
  function getDatesType(date: number): CalendarDayType {
162
- const { value } = props
163
- let type: CalendarDayType = ''
164
-
165
- if (!isArray(value)) return type
166
- const isSelected = (day: number) => {
167
- return value.some((item) => compareDate(day, item) === 0)
168
- }
180
+ if (!isArray(props.value)) return ''
169
181
 
170
- if (isSelected(date)) {
171
- const prevDay = getPrevDay(date)
172
- const nextDay = getNextDay(date)
173
- const prevSelected = isSelected(prevDay)
174
- const nextSelected = isSelected(nextDay)
175
- if (prevSelected && nextSelected) {
176
- type = 'multiple-middle'
177
- } else if (prevSelected) {
178
- type = 'end'
179
- } else if (nextSelected) {
180
- type = 'start'
181
- } else {
182
- type = 'multiple-selected'
182
+ let type: CalendarDayType = ''
183
+ props.value.some((item) => {
184
+ if (compareDate(date, item) === 0) {
185
+ type = 'selected'
186
+ return true
183
187
  }
184
- }
188
+
189
+ return false
190
+ })
185
191
 
186
192
  return type
187
193
  }
@@ -195,7 +201,12 @@ function getDatetimeType(date: number, value: number | number[] | null) {
195
201
  return 'start'
196
202
  } else if (endDate && compareDate(date, endDate) === 0) {
197
203
  return 'end'
198
- } else if (startDate && endDate && compareDate(date, startDate) === 1 && compareDate(date, endDate) === -1) {
204
+ } else if (
205
+ startDate &&
206
+ endDate &&
207
+ compareDate(date, startDate) === 1 &&
208
+ compareDate(date, endDate) === -1
209
+ ) {
199
210
  return 'middle'
200
211
  } else {
201
212
  return ''
@@ -208,7 +219,12 @@ function getWeektimeType(date: number, value: number | number[] | null) {
208
219
  return 'start'
209
220
  } else if (endDate && compareDate(date, endDate) === 0) {
210
221
  return 'end'
211
- } else if (startDate && endDate && compareDate(date, startDate) === 1 && compareDate(date, endDate) === -1) {
222
+ } else if (
223
+ startDate &&
224
+ endDate &&
225
+ compareDate(date, startDate) === 1 &&
226
+ compareDate(date, endDate) === -1
227
+ ) {
212
228
  return 'middle'
213
229
  } else {
214
230
  return ''
@@ -260,7 +276,10 @@ function handleDateClick(index: number) {
260
276
  }
261
277
  }
262
278
  function getDate(date: number, isEnd: boolean = false) {
263
- date = props.defaultTime && props.defaultTime.length > 0 ? getDateByDefaultTime(date, isEnd ? props.defaultTime[1] : props.defaultTime[0]) : date
279
+ date =
280
+ props.defaultTime && props.defaultTime.length > 0
281
+ ? getDateByDefaultTime(date, isEnd ? props.defaultTime[1] : props.defaultTime[0])
282
+ : date
264
283
 
265
284
  if (date < props.minDate) return props.minDate
266
285
 
@@ -275,18 +294,22 @@ function handleDateChange(date: CalendarDayItem) {
275
294
  if (date.type !== 'selected') {
276
295
  emit('change', {
277
296
  value: getDate(date.date),
278
- type: 'start'
297
+ type: 'start',
279
298
  })
280
299
  }
281
300
  }
282
301
  function handleDatesChange(date: CalendarDayItem) {
283
302
  if (date.disabled) return
284
- const currentValue = deepClone(isArray(props.value) ? props.value : [])
285
- const dateIndex = currentValue.findIndex((item) => item && compareDate(item, date.date) === 0)
286
- const value = dateIndex === -1 ? [...currentValue, getDate(date.date)] : currentValue.filter((_, index) => index !== dateIndex)
287
- emit('change', { value })
303
+ const value = deepClone(isArray(props.value) ? props.value : [])
304
+ if (date.type !== 'selected') {
305
+ value.push(getDate(date.date))
306
+ } else {
307
+ value.splice(value.indexOf(date.date), 1)
308
+ }
309
+ emit('change', {
310
+ value,
311
+ })
288
312
  }
289
-
290
313
  function handleDateRangeChange(date: CalendarDayItem) {
291
314
  if (date.disabled) return
292
315
 
@@ -296,7 +319,12 @@ function handleDateRangeChange(date: CalendarDayItem) {
296
319
  const compare = compareDate(date.date, startDate)
297
320
 
298
321
  // 禁止选择同个日期
299
- if (!props.allowSameDay && compare === 0 && (props.type === 'daterange' || props.type === 'datetimerange') && !endDate) {
322
+ if (
323
+ !props.allowSameDay &&
324
+ compare === 0 &&
325
+ (props.type === 'daterange' || props.type === 'datetimerange') &&
326
+ !endDate
327
+ ) {
300
328
  return
301
329
  }
302
330
 
@@ -306,7 +334,7 @@ function handleDateRangeChange(date: CalendarDayItem) {
306
334
  const maxEndDate = getDayByOffset(startDate, props.maxRange - 1)
307
335
  value = [startDate, getDate(maxEndDate, true)]
308
336
  toast.show({
309
- msg: props.rangePrompt || translate('rangePrompt', props.maxRange)
337
+ msg: props.rangePrompt || translate('rangePrompt', props.maxRange),
310
338
  })
311
339
  } else {
312
340
  value = [startDate, getDate(date.date, true)]
@@ -328,7 +356,7 @@ function handleDateRangeChange(date: CalendarDayItem) {
328
356
 
329
357
  emit('change', {
330
358
  value,
331
- type: type || (value[1] ? 'end' : 'start')
359
+ type: type || (value[1] ? 'end' : 'start'),
332
360
  })
333
361
  }
334
362
  function handleWeekChange(date: CalendarDayItem) {
@@ -338,7 +366,7 @@ function handleWeekChange(date: CalendarDayItem) {
338
366
  if (getFormatterDate(weekStart, new Date(weekStart).getDate()).disabled) return
339
367
 
340
368
  emit('change', {
341
- value: getDate(weekStart) + 24 * 60 * 60 * 1000
369
+ value: getDate(weekStart) + 24 * 60 * 60 * 1000,
342
370
  })
343
371
  }
344
372
  function handleWeekRangeChange(date: CalendarDayItem) {
@@ -355,30 +383,35 @@ function handleWeekRangeChange(date: CalendarDayItem) {
355
383
  if (startDate && !endDate && compare > -1) {
356
384
  if (!props.allowSameDay && compare === 0) return
357
385
 
358
- value = [getDate(startWeekStartDate) + 24 * 60 * 60 * 1000, getDate(weekStartDate) + 24 * 60 * 60 * 1000]
386
+ value = [
387
+ getDate(startWeekStartDate) + 24 * 60 * 60 * 1000,
388
+ getDate(weekStartDate) + 24 * 60 * 60 * 1000,
389
+ ]
359
390
  } else {
360
391
  value = [getDate(weekStartDate) + 24 * 60 * 60 * 1000, null]
361
392
  }
362
393
 
363
394
  emit('change', {
364
- value
395
+ value,
365
396
  })
366
397
  }
367
398
  function getFormatterDate(date: number, day: string | number, type?: CalendarDayType) {
368
399
  let dayObj: CalendarDayItem = {
369
- date: date,
400
+ date,
370
401
  text: day,
371
402
  topInfo: '',
372
403
  bottomInfo: '',
373
404
  type,
405
+ day,
374
406
  disabled: compareDate(date, props.minDate) === -1 || compareDate(date, props.maxDate) === 1,
375
- isLastRow: isLastRow(date)
376
407
  }
377
408
  if (props.formatter) {
378
409
  if (isFunction(props.formatter)) {
379
410
  dayObj = props.formatter(dayObj)
380
411
  } else {
381
- console.error('[wot-design] error(wd-calendar-view): the formatter prop of wd-calendar-view should be a function')
412
+ console.error(
413
+ '[wot-design] error(wd-calendar-view): the formatter prop of wd-calendar-view should be a function',
414
+ )
382
415
  }
383
416
  }
384
417
  return dayObj
@@ -14,7 +14,6 @@ export const monthProps = {
14
14
  rangePrompt: String,
15
15
  allowSameDay: makeBooleanProp(false),
16
16
  defaultTime: {
17
- type: [Array] as PropType<Array<number[]>>
17
+ type: [Array] as PropType<Array<number[]>>,
18
18
  },
19
- showTitle: makeBooleanProp(true)
20
19
  }
@@ -8,13 +8,13 @@
8
8
  }
9
9
 
10
10
  @include e(weeks) {
11
- box-shadow: 0px 4px 8px 0 rgba(255, 255, 255, 0.02);
12
11
  color: $-dark-color;
12
+ box-shadow: 0px 4px 8px 0 rgba(255, 255, 255, 0.02);
13
13
  }
14
14
 
15
15
  @include e(time-label) {
16
16
  color: $-dark-color;
17
- &::after{
17
+ &::after {
18
18
  background: $-dark-background4;
19
19
  }
20
20
  }
@@ -26,20 +26,20 @@
26
26
 
27
27
  @include e(title) {
28
28
  padding: 5px 0;
29
- text-align: center;
29
+ padding: $-calendar-panel-padding;
30
30
  font-size: $-calendar-panel-title-fs;
31
31
  color: $-calendar-panel-title-color;
32
- padding: $-calendar-panel-padding;
32
+ text-align: center;
33
33
  }
34
34
 
35
35
  @include e(weeks) {
36
36
  display: flex;
37
37
  height: $-calendar-week-height;
38
+ padding: $-calendar-panel-padding;
39
+ font-size: $-calendar-week-fs;
38
40
  line-height: $-calendar-week-height;
39
- box-shadow: 0px 4px 8px 0 rgba(0, 0, 0, 0.02);
40
41
  color: $-calendar-week-color;
41
- font-size: $-calendar-week-fs;
42
- padding: $-calendar-panel-padding;
42
+ box-shadow: 0px 4px 8px 0 rgba(0, 0, 0, 0.02);
43
43
  }
44
44
 
45
45
  @include e(week) {
@@ -48,8 +48,8 @@
48
48
  }
49
49
 
50
50
  @include e(container) {
51
- padding: $-calendar-panel-padding;
52
51
  box-sizing: border-box;
52
+ padding: $-calendar-panel-padding;
53
53
  }
54
54
 
55
55
  @include e(time) {
@@ -61,20 +61,20 @@
61
61
  position: relative;
62
62
  flex: 1;
63
63
  font-size: $-picker-column-fs;
64
- text-align: center;
65
64
  line-height: 125px;
66
65
  color: $-picker-column-color;
66
+ text-align: center;
67
67
 
68
68
  &::after {
69
69
  position: absolute;
70
- content: '';
71
- height: 35px;
72
70
  top: 50%;
73
- left: 0;
74
71
  right: 0;
75
- transform: translateY(-50%);
76
- background: $-picker-column-select-bg;
72
+ left: 0;
77
73
  z-index: 0;
74
+ height: 35px;
75
+ content: '';
76
+ background: $-picker-column-select-bg;
77
+ transform: translateY(-50%);
78
78
  }
79
79
  }
80
80
 
@@ -86,4 +86,4 @@
86
86
  @include e(time-picker) {
87
87
  flex: 3;
88
88
  }
89
- }
89
+ }