webcake-ui-kit 1.1.29 → 1.1.30

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 (29) hide show
  1. package/package.json +7 -2
  2. package/src/components/date-picker/CalendarPanel.vue +154 -0
  3. package/src/components/date-picker/CalendarView.vue +104 -0
  4. package/src/components/date-picker/DatePicker.vue +587 -0
  5. package/src/components/date-picker/PanelFooter.vue +45 -0
  6. package/src/components/date-picker/PanelHeader.vue +102 -0
  7. package/src/components/date-picker/TimePanel.vue +98 -0
  8. package/src/components/date-picker/calendar-panel.css +36 -0
  9. package/src/components/date-picker/calendar-view.css +134 -0
  10. package/src/components/date-picker/calendar.js +116 -0
  11. package/src/components/date-picker/date-picker.css +95 -0
  12. package/src/components/date-picker/dayjs.js +34 -0
  13. package/src/components/date-picker/panel-footer.css +42 -0
  14. package/src/components/date-picker/panel-header.css +71 -0
  15. package/src/components/date-picker/time-panel.css +63 -0
  16. package/src/components/input/input.css +5 -0
  17. package/src/components/menu/menu.css +0 -1
  18. package/src/components/message/Message.vue +72 -0
  19. package/src/components/message/MessageContainer.vue +200 -0
  20. package/src/components/message/message-container.css +108 -0
  21. package/src/components/message/message.css +69 -0
  22. package/src/components/message/message.js +133 -0
  23. package/src/components/progress/Progress.vue +42 -0
  24. package/src/components/progress/progress.css +15 -0
  25. package/src/components/radio/Radio.vue +1 -1
  26. package/src/components/radio-group/RadioGroup.vue +2 -2
  27. package/src/components/table/Table.vue +30 -21
  28. package/src/components/table/table.css +18 -2
  29. package/src/index.js +5 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webcake-ui-kit",
3
- "version": "1.1.29",
3
+ "version": "1.1.30",
4
4
  "description": "UI Kit for Vue 2 && 3 - Pure Options API",
5
5
  "main": "src/index.js",
6
6
  "module": "src/index.js",
@@ -27,6 +27,7 @@
27
27
  "./WkButtonGroup": "./src/components/button-group/ButtonGroup.vue",
28
28
  "./WkCheckbox": "./src/components/checkbox/Checkbox.vue",
29
29
  "./WkCheckboxGroup": "./src/components/checkbox-group/CheckboxGroup.vue",
30
+ "./WkDatePicker": "./src/components/date-picker/DatePicker.vue",
30
31
  "./WkDialog": "./src/components/dialog/Dialog.vue",
31
32
  "./WkDivider": "./src/components/divider/Divider.vue",
32
33
  "./WkDropdown": "./src/components/dropdown/Dropdown.vue",
@@ -37,6 +38,7 @@
37
38
  "./WkInputNumber": "./src/components/input-number/InputNumber.vue",
38
39
  "./WkMenu": "./src/components/menu/Menu.vue",
39
40
  "./WkPagination": "./src/components/pagination/Pagination.vue",
41
+ "./WkProgress": "./src/components/progress/Progress.vue",
40
42
  "./WkRadio": "./src/components/radio/Radio.vue",
41
43
  "./WkRadioGroup": "./src/components/radio-group/RadioGroup.vue",
42
44
  "./WkRichCheckboxGroup": "./src/components/rich-checkbox-group/RichCheckboxGroup.vue",
@@ -135,5 +137,8 @@
135
137
  "bugs": {
136
138
  "url": "https://github.com/pancake-vn/webcake-ui-kit/issues"
137
139
  },
138
- "homepage": "https://ui.webcake.io"
140
+ "homepage": "https://ui.webcake.io",
141
+ "dependencies": {
142
+ "dayjs": "^1.11.21"
143
+ }
139
144
  }
@@ -0,0 +1,154 @@
1
+ <template>
2
+ <div class="ui-cal-panel" :class="{ 'ui-cal-panel--with-time': showTime }">
3
+ <div class="ui-cal-panel__main">
4
+ <slot name="header">
5
+ <PanelHeader
6
+ :panels="panels"
7
+ :month-options="monthOptions"
8
+ :year-options="yearOptions"
9
+ :show-select-month="showSelectMonth"
10
+ :show-select-year="showSelectYear"
11
+ :can-prev="canPrev"
12
+ :can-next="canNext"
13
+ :show-year-jump="showYearJump"
14
+ @prev="$emit('prev')"
15
+ @next="$emit('next')"
16
+ @prev-year="$emit('prev-year')"
17
+ @next-year="$emit('next-year')"
18
+ @set-month="p => $emit('set-month', p)"
19
+ @set-year="p => $emit('set-year', p)"
20
+ @label-click="p => $emit('label-click', p)"
21
+ />
22
+ </slot>
23
+
24
+ <div class="ui-cal-panel__body">
25
+ <div class="ui-cal-panel__months" @keydown="$emit('grid-keydown', $event)">
26
+ <CalendarView
27
+ v-for="(view, i) in views"
28
+ :key="i"
29
+ class="ui-cal-panel__month"
30
+ :matrix="view.matrix"
31
+ :weekdays="weekdays"
32
+ :mode="mode"
33
+ :selected="selected"
34
+ :range-start="rangeStart"
35
+ :range-end="rangeEnd"
36
+ :focus-iso="focusIso"
37
+ :clip-outside="views.length > 1"
38
+ @select="iso => $emit('select', iso)"
39
+ @hover="iso => $emit('hover', iso)"
40
+ >
41
+ <!-- Always forward; the fallback renders the day number when the
42
+ consumer hasn't supplied a custom #cell slot (dual-compat: no
43
+ $scopedSlots sniffing needed). -->
44
+ <template #cell="slotProps">
45
+ <slot name="cell" v-bind="slotProps">{{ slotProps.cell.day }}</slot>
46
+ </template>
47
+ </CalendarView>
48
+ </div>
49
+
50
+ <div v-if="showTime" class="ui-cal-panel__time">
51
+ <slot name="time">
52
+ <TimePanel
53
+ :value="timeValue"
54
+ :show-seconds="showSeconds"
55
+ :hour-step="hourStep"
56
+ :minute-step="minuteStep"
57
+ :second-step="secondStep"
58
+ :disabled-time="disabledTime"
59
+ @change="t => $emit('time-change', t)"
60
+ />
61
+ </slot>
62
+ </div>
63
+ </div>
64
+ </div>
65
+
66
+ <slot name="footer">
67
+ <PanelFooter
68
+ v-if="showFooter"
69
+ :show-today="showToday"
70
+ :show-clear="showClear"
71
+ :show-confirm="showConfirm"
72
+ :today-disabled="todayDisabled"
73
+ :confirm-disabled="confirmDisabled"
74
+ :today-text="todayText"
75
+ :clear-text="clearText"
76
+ :confirm-text="confirmText"
77
+ @today="$emit('today')"
78
+ @clear="$emit('clear')"
79
+ @confirm="$emit('confirm')"
80
+ />
81
+ </slot>
82
+ </div>
83
+ </template>
84
+
85
+ <script>
86
+ import CalendarView from './CalendarView.vue'
87
+ import PanelHeader from './PanelHeader.vue'
88
+ import PanelFooter from './PanelFooter.vue'
89
+ import TimePanel from './TimePanel.vue'
90
+
91
+ export default {
92
+ name: 'CalendarPanel',
93
+ components: { CalendarView, PanelHeader, PanelFooter, TimePanel },
94
+ props: {
95
+ // [{ matrix, monthLabel, month, year }] — one per visible month.
96
+ views: { type: Array, default: () => [] },
97
+ // Localized month names + selectable years for the header dropdowns.
98
+ monthOptions: { type: Array, default: () => [] },
99
+ yearOptions: { type: Array, default: () => [] },
100
+ showSelectMonth: { type: Boolean, default: false },
101
+ showSelectYear: { type: Boolean, default: false },
102
+ weekdays: { type: Array, default: () => [] },
103
+ mode: { type: String, default: 'single' },
104
+ selected: { type: Array, default: () => [] },
105
+ rangeStart: { type: String, default: null },
106
+ rangeEnd: { type: String, default: null },
107
+ focusIso: { type: String, default: null },
108
+ canPrev: { type: Boolean, default: true },
109
+ canNext: { type: Boolean, default: true },
110
+ showYearJump: { type: Boolean, default: false },
111
+ // Time
112
+ showTime: { type: Boolean, default: false },
113
+ timeValue: { type: Object, default: () => ({ hour: 0, minute: 0, second: 0 }) },
114
+ showSeconds: { type: Boolean, default: false },
115
+ hourStep: { type: Number, default: 1 },
116
+ minuteStep: { type: Number, default: 1 },
117
+ secondStep: { type: Number, default: 1 },
118
+ disabledTime: { type: Function, default: null },
119
+ // Footer
120
+ showFooter: { type: Boolean, default: true },
121
+ showToday: { type: Boolean, default: true },
122
+ showClear: { type: Boolean, default: true },
123
+ showConfirm: { type: Boolean, default: false },
124
+ todayDisabled: { type: Boolean, default: false },
125
+ confirmDisabled: { type: Boolean, default: false },
126
+ todayText: { type: String, default: 'Today' },
127
+ clearText: { type: String, default: 'Clear' },
128
+ confirmText: { type: String, default: 'OK' }
129
+ },
130
+ emits: [
131
+ 'prev',
132
+ 'next',
133
+ 'prev-year',
134
+ 'next-year',
135
+ 'set-month',
136
+ 'set-year',
137
+ 'label-click',
138
+ 'select',
139
+ 'hover',
140
+ 'grid-keydown',
141
+ 'time-change',
142
+ 'today',
143
+ 'clear',
144
+ 'confirm'
145
+ ],
146
+ computed: {
147
+ panels() {
148
+ return this.views.map(v => ({ month: v.month, year: v.year }))
149
+ }
150
+ }
151
+ }
152
+ </script>
153
+
154
+ <style src="./calendar-panel.css" scoped></style>
@@ -0,0 +1,104 @@
1
+ <template>
2
+ <div class="ui-cal-view">
3
+ <div class="ui-cal-view__weekdays" aria-hidden="true">
4
+ <span v-for="(w, i) in weekdays" :key="i" class="ui-cal-view__weekday">{{ w }}</span>
5
+ </div>
6
+ <div class="ui-cal-view__grid" role="grid" @mouseleave="$emit('hover', null)">
7
+ <button
8
+ v-for="cell in matrix"
9
+ :key="cell.iso"
10
+ type="button"
11
+ role="gridcell"
12
+ class="ui-cal-cell"
13
+ :class="cellClass(cell)"
14
+ :disabled="cell.disabled"
15
+ :tabindex="cell.iso === focusIso ? 0 : -1"
16
+ :aria-selected="isSelected(cell) ? 'true' : 'false'"
17
+ :aria-current="cell.today ? 'date' : null"
18
+ @click="onSelect(cell)"
19
+ @mouseenter="onHover(cell)"
20
+ @focus="onHover(cell)"
21
+ >
22
+ <span class="ui-cal-cell__inner">
23
+ <slot name="cell" :cell="cell">{{ cell.day }}</slot>
24
+ </span>
25
+ </button>
26
+ </div>
27
+ </div>
28
+ </template>
29
+
30
+ <script>
31
+ import { rangePosition, isWithinRange } from './calendar.js'
32
+
33
+ export default {
34
+ name: 'CalendarView',
35
+ props: {
36
+ // 42-cell array from buildDayMatrix().
37
+ matrix: { type: Array, default: () => [] },
38
+ // 7 weekday header labels, already rotated to weekStart.
39
+ weekdays: { type: Array, default: () => [] },
40
+ mode: { type: String, default: 'single' },
41
+ // Selected ISO keys (single => [iso], multiple => [...isos], range => []).
42
+ selected: { type: Array, default: () => [] },
43
+ // Resolved range endpoints (include live hover preview) for the band.
44
+ rangeStart: { type: String, default: null },
45
+ rangeEnd: { type: String, default: null },
46
+ // Roving keyboard focus target.
47
+ focusIso: { type: String, default: null },
48
+ // When true (multi-month view), suppress selection/range styling on days
49
+ // that belong to an adjacent month so each panel only paints its own days.
50
+ clipOutside: { type: Boolean, default: false }
51
+ },
52
+ emits: ['select', 'hover'],
53
+ methods: {
54
+ isSelected(cell) {
55
+ if (this.clipOutside && cell.outside) return false
56
+ if (this.mode === 'range') {
57
+ return cell.iso === this.rangeStart || cell.iso === this.rangeEnd
58
+ }
59
+ return this.selected.indexOf(cell.iso) !== -1
60
+ },
61
+ cellClass(cell) {
62
+ const cls = {
63
+ 'is-outside': cell.outside,
64
+ 'is-today': cell.today,
65
+ 'is-weekend': cell.weekend,
66
+ 'is-disabled': cell.disabled,
67
+ // The filled endpoint chip is clipped on outside days (via isSelected)
68
+ // so a shared date isn't drawn "active" in two panels at once...
69
+ 'is-selected': this.isSelected(cell),
70
+ 'is-focus': cell.iso === this.focusIso
71
+ }
72
+ if (this.mode === 'range') {
73
+ // ...but the connecting band (::before) DOES extend onto outside days so
74
+ // the range reads continuously to each panel's edge.
75
+ const pos = rangePosition(cell.iso, this.rangeStart, this.rangeEnd)
76
+ const clippedOutside = this.clipOutside && cell.outside
77
+ if (pos === 'middle') {
78
+ cls['is-in-range'] = true
79
+ } else if (pos === 'left' || pos === 'right') {
80
+ // A true endpoint (with chip) gets the rounded half end-cap; an outside
81
+ // endpoint has no chip, so give it a FULL band segment instead of a
82
+ // bare half-cell — otherwise the panel edge shows a broken 50% band.
83
+ if (clippedOutside) cls['is-in-range'] = true
84
+ else cls['is-range-' + pos] = true
85
+ } else if (pos === 'single' && !clippedOutside) {
86
+ cls['is-range-single'] = true
87
+ }
88
+ if (isWithinRange(cell.iso, this.rangeStart, this.rangeEnd)) cls['is-in-range'] = true
89
+ }
90
+ return cls
91
+ },
92
+ onSelect(cell) {
93
+ if (cell.disabled) return
94
+ this.$emit('select', cell.iso)
95
+ },
96
+ onHover(cell) {
97
+ if (cell.disabled) return
98
+ this.$emit('hover', cell.iso)
99
+ }
100
+ }
101
+ }
102
+ </script>
103
+
104
+ <style src="./calendar-view.css" scoped></style>