@symbo.ls/datepicker 2.11.90 → 2.11.92
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.
- package/days.js +24 -5
- package/index.js +2 -2
- package/months.js +43 -17
- package/package.json +2 -2
package/days.js
CHANGED
|
@@ -2,20 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
import { Grid } from '@symbo.ls/atoms'
|
|
4
4
|
import { Button } from '@symbo.ls/button'
|
|
5
|
+
import { calendar } from '.'
|
|
5
6
|
|
|
6
7
|
export const DatePickerDay = {
|
|
7
8
|
extend: Button,
|
|
8
9
|
state: true,
|
|
9
10
|
|
|
10
11
|
props: ({ state, key }) => {
|
|
11
|
-
const
|
|
12
|
+
const rootState = state.parent.parent.parent
|
|
13
|
+
const date = new Date(state._d)
|
|
14
|
+
const isSelected = rootState.activeDay === date.toString()
|
|
12
15
|
const gridColumnStart = 7 - state.parent.weekItems.weeks[0].dates.length
|
|
13
|
-
const
|
|
16
|
+
const { moment } = state
|
|
17
|
+
moment._d = date
|
|
18
|
+
const isWeekend = moment.day() === 0 || moment.day() === 6
|
|
19
|
+
// const isWeekend = state.moment.day() === 0 || state.moment.day() === 6
|
|
14
20
|
// const isWeekend = state.moment.isWeekend
|
|
15
21
|
|
|
16
22
|
return {
|
|
17
23
|
isSelected,
|
|
18
24
|
isWeekend,
|
|
25
|
+
date: date.toString(),
|
|
19
26
|
textAlign: 'center',
|
|
20
27
|
fontSize: 'Z1',
|
|
21
28
|
round: '100%',
|
|
@@ -38,10 +45,9 @@ export const DatePickerDay = {
|
|
|
38
45
|
|
|
39
46
|
on: {
|
|
40
47
|
click: (event, element, state) => {
|
|
41
|
-
state.parent.parent.update({
|
|
42
|
-
|
|
48
|
+
state.parent.parent.parent.update({
|
|
49
|
+
activeDay: element.props.date
|
|
43
50
|
})
|
|
44
|
-
console.log(state)
|
|
45
51
|
}
|
|
46
52
|
}
|
|
47
53
|
}
|
|
@@ -59,6 +65,19 @@ export const DatePickerGrid = {
|
|
|
59
65
|
childExtend: DatePickerDay,
|
|
60
66
|
|
|
61
67
|
$setStateCollection: (el, s) => {
|
|
68
|
+
// console.warn(s.days)
|
|
62
69
|
return s.days
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
on: {
|
|
73
|
+
render: (el, state) => {
|
|
74
|
+
const { key } = el
|
|
75
|
+
const isSelected = state.parent.parent.activeMonth === parseInt(key)
|
|
76
|
+
if (isSelected) {
|
|
77
|
+
window.requestAnimationFrame(() => {
|
|
78
|
+
el.node.scrollIntoView()
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
}
|
|
63
82
|
}
|
|
64
83
|
}
|
package/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { Dialog } from '@symbo.ls/dialog'
|
|
|
5
5
|
import { HeadlessDatepicker } from 'headless-datepicker'
|
|
6
6
|
import { DatePickerGrid } from './days'
|
|
7
7
|
|
|
8
|
-
const calendar = new HeadlessDatepicker.Calendar({
|
|
8
|
+
export const calendar = new HeadlessDatepicker.Calendar({
|
|
9
9
|
calendarMode: 'exact'
|
|
10
10
|
})
|
|
11
11
|
|
|
@@ -14,7 +14,7 @@ const extractMonthDays = (data) => {
|
|
|
14
14
|
|
|
15
15
|
data.weeks.forEach((week) => {
|
|
16
16
|
week.dates.forEach((date) => {
|
|
17
|
-
result.push(date)
|
|
17
|
+
result.push({ ...date, _d: date.moment._d.toString() })
|
|
18
18
|
})
|
|
19
19
|
})
|
|
20
20
|
|
package/months.js
CHANGED
|
@@ -46,12 +46,24 @@ export const DatePickerMonthsSlider = {
|
|
|
46
46
|
},
|
|
47
47
|
|
|
48
48
|
Button_left: {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
props: {
|
|
50
|
+
icon: 'arrowLeft',
|
|
51
|
+
'@dark': {
|
|
52
|
+
theme: 'primary @dark .color-only'
|
|
53
|
+
},
|
|
54
|
+
'@light': {
|
|
55
|
+
theme: 'primary @light .color-only'
|
|
56
|
+
}
|
|
52
57
|
},
|
|
53
|
-
|
|
54
|
-
|
|
58
|
+
on: {
|
|
59
|
+
click: (ev, el, s) => {
|
|
60
|
+
const { activeMonth, activeYear } = s
|
|
61
|
+
if (activeMonth > 0) s.update({ activeMonth: activeMonth - 1 })
|
|
62
|
+
else s.update({
|
|
63
|
+
activeYear: activeYear - 1,
|
|
64
|
+
activeMonth: 11
|
|
65
|
+
})
|
|
66
|
+
}
|
|
55
67
|
}
|
|
56
68
|
},
|
|
57
69
|
|
|
@@ -74,13 +86,15 @@ export const DatePickerMonthsSlider = {
|
|
|
74
86
|
'.isSelected': { opacity: '1' }
|
|
75
87
|
}),
|
|
76
88
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
89
|
+
on: {
|
|
90
|
+
update: (el, state) => {
|
|
91
|
+
const { props } = el
|
|
92
|
+
const { isSelected } = props
|
|
93
|
+
if (isSelected) {
|
|
94
|
+
window.requestAnimationFrame(() => {
|
|
95
|
+
el.parent.parent.node.scrollLeft = el.node.offsetLeft
|
|
96
|
+
})
|
|
97
|
+
}
|
|
84
98
|
}
|
|
85
99
|
}
|
|
86
100
|
},
|
|
@@ -104,12 +118,24 @@ export const DatePickerMonthsSlider = {
|
|
|
104
118
|
},
|
|
105
119
|
|
|
106
120
|
Button_right: {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
121
|
+
props: {
|
|
122
|
+
icon: 'arrowRight',
|
|
123
|
+
'@dark': {
|
|
124
|
+
theme: 'primary @dark .color-only'
|
|
125
|
+
},
|
|
126
|
+
'@light': {
|
|
127
|
+
theme: 'primary @light .color-only'
|
|
128
|
+
}
|
|
110
129
|
},
|
|
111
|
-
|
|
112
|
-
|
|
130
|
+
on: {
|
|
131
|
+
click: (ev, el, s) => {
|
|
132
|
+
const { activeMonth, activeYear } = s
|
|
133
|
+
if (activeMonth < 11) s.update({ activeMonth: activeMonth + 1 })
|
|
134
|
+
else s.update({
|
|
135
|
+
activeYear: activeYear + 1,
|
|
136
|
+
activeMonth: 0
|
|
137
|
+
})
|
|
138
|
+
}
|
|
113
139
|
}
|
|
114
140
|
}
|
|
115
141
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/datepicker",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.92",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"gitHead": "
|
|
6
|
+
"gitHead": "8404ab11b0a8bfa4b56f8d63545c456cb4b0f23c",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@symbo.ls/atoms": "latest",
|
|
9
9
|
"@symbo.ls/button": "latest",
|