@symbo.ls/datepicker 2.11.78 → 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 +28 -6
- package/index.js +36 -19
- package/months.js +43 -17
- package/package.json +2 -2
- package/years.js +2 -2
package/days.js
CHANGED
|
@@ -2,17 +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
|
|
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
|
|
20
|
+
// const isWeekend = state.moment.isWeekend
|
|
13
21
|
|
|
14
22
|
return {
|
|
15
23
|
isSelected,
|
|
24
|
+
isWeekend,
|
|
25
|
+
date: date.toString(),
|
|
16
26
|
textAlign: 'center',
|
|
17
27
|
fontSize: 'Z1',
|
|
18
28
|
round: '100%',
|
|
@@ -27,18 +37,17 @@ export const DatePickerDay = {
|
|
|
27
37
|
},
|
|
28
38
|
'.isSelected': { theme: 'primary' },
|
|
29
39
|
'!isSelected': {
|
|
30
|
-
'
|
|
31
|
-
':
|
|
40
|
+
'.isWeekend': { opacity: '.5' },
|
|
41
|
+
':hover': { theme: 'secondary' }
|
|
32
42
|
}
|
|
33
43
|
}
|
|
34
44
|
},
|
|
35
45
|
|
|
36
46
|
on: {
|
|
37
47
|
click: (event, element, state) => {
|
|
38
|
-
state.parent.parent.update({
|
|
39
|
-
|
|
48
|
+
state.parent.parent.parent.update({
|
|
49
|
+
activeDay: element.props.date
|
|
40
50
|
})
|
|
41
|
-
console.log(state)
|
|
42
51
|
}
|
|
43
52
|
}
|
|
44
53
|
}
|
|
@@ -56,6 +65,19 @@ export const DatePickerGrid = {
|
|
|
56
65
|
childExtend: DatePickerDay,
|
|
57
66
|
|
|
58
67
|
$setStateCollection: (el, s) => {
|
|
68
|
+
// console.warn(s.days)
|
|
59
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
|
+
}
|
|
60
82
|
}
|
|
61
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,14 +14,14 @@ 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
|
|
|
21
21
|
return result
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
const
|
|
24
|
+
export const DatePickerGridContainer = {
|
|
25
25
|
props: {
|
|
26
26
|
maxWidth: `${272 / 16}em`,
|
|
27
27
|
position: 'relative',
|
|
@@ -70,28 +70,27 @@ const monthNumbersContainer = {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
const props = {
|
|
74
|
-
yearRange: [1993, 2023],
|
|
75
|
-
maxHeight: 'G+B',
|
|
76
|
-
boxSize: 'fit-content fit-content',
|
|
77
|
-
style: {
|
|
78
|
-
button: {
|
|
79
|
-
padding: '0'
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
73
|
export const DatePicker = {
|
|
85
74
|
extend: [Dialog, Flex],
|
|
75
|
+
|
|
86
76
|
state: {
|
|
77
|
+
yearRange: [1993, 2023],
|
|
87
78
|
activeYear: 1993,
|
|
88
79
|
activeMonth: 8,
|
|
89
80
|
activeDay: 14
|
|
90
81
|
},
|
|
91
82
|
|
|
92
|
-
props
|
|
83
|
+
props: {
|
|
84
|
+
maxHeight: 'G+B2'
|
|
85
|
+
},
|
|
93
86
|
|
|
94
|
-
DatePickerYears: {
|
|
87
|
+
DatePickerYears: {
|
|
88
|
+
style: {
|
|
89
|
+
button: {
|
|
90
|
+
padding: '0'
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
},
|
|
95
94
|
|
|
96
95
|
Flex: {
|
|
97
96
|
props: {
|
|
@@ -100,11 +99,29 @@ export const DatePicker = {
|
|
|
100
99
|
position: 'relative'
|
|
101
100
|
},
|
|
102
101
|
|
|
103
|
-
DatePickerMonthsSlider: {
|
|
102
|
+
DatePickerMonthsSlider: {
|
|
103
|
+
style: {
|
|
104
|
+
button: {
|
|
105
|
+
padding: '0'
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
},
|
|
104
109
|
|
|
105
|
-
DatePickerWeekDays: {
|
|
110
|
+
DatePickerWeekDays: {
|
|
111
|
+
style: {
|
|
112
|
+
button: {
|
|
113
|
+
padding: '0'
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
},
|
|
106
117
|
|
|
107
|
-
|
|
118
|
+
DatePickerGridContainer: {
|
|
119
|
+
style: {
|
|
120
|
+
button: {
|
|
121
|
+
padding: '0'
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
},
|
|
108
125
|
|
|
109
126
|
DialogFooter: {}
|
|
110
127
|
}
|
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",
|
package/years.js
CHANGED
|
@@ -63,8 +63,8 @@ export const DatePickerYears = {
|
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
65
|
|
|
66
|
-
$setCollection: ({ state
|
|
67
|
-
const { yearRange } =
|
|
66
|
+
$setCollection: ({ state }) => {
|
|
67
|
+
const { yearRange } = state
|
|
68
68
|
|
|
69
69
|
if (yearRange) {
|
|
70
70
|
const [start, end] = yearRange
|