@symbo.ls/datepicker 2.11.16 → 2.11.43
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/index.js +358 -111
- package/package.json +2 -2
- package/style.js +0 -18
package/index.js
CHANGED
|
@@ -1,156 +1,403 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import { SquareButton, Button } from '@symbo.ls/button'
|
|
3
|
+
import { Button } from '@symbo.ls/button'
|
|
6
4
|
import { Flex, Grid } from '@symbo.ls/atoms'
|
|
7
5
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
color: '--theme-quinary-dark-color',
|
|
11
|
-
':hover': {
|
|
12
|
-
theme: 'quinary .child'
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const aside = {
|
|
6
|
+
export const DatePickerYears = {
|
|
7
|
+
tag: 'aside',
|
|
17
8
|
props: {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
9
|
+
overflow: 'hidden',
|
|
10
|
+
position: 'relative',
|
|
11
|
+
|
|
12
|
+
':before': {
|
|
13
|
+
content: '""',
|
|
14
|
+
boxSize: 'A1 100%',
|
|
15
|
+
position: 'absolute',
|
|
16
|
+
top: '0',
|
|
17
|
+
left: '0',
|
|
18
|
+
background: 'linear-gradient(to bottom, rgba(20, 20, 22, 1) 0%, rgba(20, 20, 22, 0) 100%)',
|
|
19
|
+
zIndex: '10'
|
|
20
|
+
},
|
|
21
|
+
':after': {
|
|
22
|
+
content: '""',
|
|
23
|
+
boxSize: 'B 100%',
|
|
24
|
+
position: 'absolute',
|
|
25
|
+
bottom: '0',
|
|
26
|
+
left: '0',
|
|
27
|
+
background: 'linear-gradient(to top, rgba(20, 20, 22, 1) 0%, rgba(20, 20, 22, 0) 100%)'
|
|
28
|
+
}
|
|
24
29
|
},
|
|
25
30
|
|
|
26
|
-
|
|
27
|
-
extend: Flex,
|
|
31
|
+
Flex: {
|
|
28
32
|
props: {
|
|
29
33
|
flow: 'column',
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
top: '0',
|
|
33
|
-
position: 'absolute',
|
|
34
|
+
gap: 'B',
|
|
35
|
+
padding: 'A Z A1 B1',
|
|
34
36
|
maxHeight: '100%',
|
|
35
|
-
|
|
37
|
+
overflow: 'hidden auto',
|
|
38
|
+
'::-webkit-scrollbar': { display: 'none' }
|
|
36
39
|
},
|
|
37
40
|
|
|
38
41
|
childExtend: {
|
|
39
42
|
extend: Button,
|
|
40
|
-
props: {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
props: ({ state, text }) => ({
|
|
44
|
+
fontSize: 'Y1',
|
|
45
|
+
color: 'white',
|
|
46
|
+
opacity: '.4',
|
|
47
|
+
background: 'transparent',
|
|
48
|
+
transition: 'opacity .25s ease',
|
|
49
|
+
isActive: state.activeYear === text,
|
|
50
|
+
'.isActive': { opacity: '1' },
|
|
51
|
+
':hover': { opacity: '1' }
|
|
52
|
+
}),
|
|
53
|
+
on: {
|
|
54
|
+
click: (event, element, state) => state.update({ activeYear: element.text }),
|
|
55
|
+
render: (el, state) => {
|
|
56
|
+
const { props } = el
|
|
57
|
+
const { isActive } = props
|
|
58
|
+
if (isActive) {
|
|
59
|
+
window.requestAnimationFrame(() => {
|
|
60
|
+
el.parent.parent.node.scrollTop = el.node.offsetTop - 100
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
$setCollection: ({ state, parent }) => {
|
|
68
|
+
const { yearRange } = parent.parent.props
|
|
69
|
+
|
|
70
|
+
if (yearRange) {
|
|
71
|
+
const [start, end] = yearRange
|
|
72
|
+
const yearsArray = (new Array(end + 1 - start)).fill(undefined).map((v, k) => {
|
|
73
|
+
return { text: start + k }
|
|
74
|
+
}).reverse()
|
|
75
|
+
return yearsArray
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return [
|
|
79
|
+
{ text: '2023' },
|
|
80
|
+
{ text: '2022' },
|
|
81
|
+
{ text: '2021' },
|
|
82
|
+
{ text: '2020' },
|
|
83
|
+
{ text: '2019' },
|
|
84
|
+
{ text: '2018' },
|
|
85
|
+
{ text: '2017' },
|
|
86
|
+
{ text: '2016' },
|
|
87
|
+
{ text: '2015' },
|
|
88
|
+
{ text: '2014' },
|
|
89
|
+
{ text: '2013' },
|
|
90
|
+
{ text: '2012' },
|
|
91
|
+
{ text: '2012' },
|
|
92
|
+
{ text: '2012' }
|
|
93
|
+
]
|
|
45
94
|
}
|
|
46
95
|
}
|
|
47
|
-
|
|
48
96
|
}
|
|
49
97
|
|
|
50
|
-
const
|
|
98
|
+
const months = {
|
|
51
99
|
extend: Flex,
|
|
52
|
-
|
|
53
100
|
props: {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
round: 'C',
|
|
70
|
-
icon: 'arrowAngleLeft'
|
|
71
|
-
}
|
|
101
|
+
position: 'relative',
|
|
102
|
+
overflow: 'hidden',
|
|
103
|
+
alignItems: 'center',
|
|
104
|
+
padding: '- - B -',
|
|
105
|
+
maxWidth: `${272 / 16}em`,
|
|
106
|
+
boxSizing: 'border-box',
|
|
107
|
+
':before': {
|
|
108
|
+
content: '""',
|
|
109
|
+
position: 'absolute',
|
|
110
|
+
boxSize: '100% 100px',
|
|
111
|
+
background: 'linear-gradient(to right, rgba(20, 20, 22, 1) 0%, rgba(20, 20, 22, 0) 100%)',
|
|
112
|
+
left: '0',
|
|
113
|
+
top: '0',
|
|
114
|
+
zIndex: '30',
|
|
115
|
+
pointerEvents: 'none'
|
|
72
116
|
},
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
117
|
+
':after': {
|
|
118
|
+
content: '""',
|
|
119
|
+
position: 'absolute',
|
|
120
|
+
boxSize: '100% 100px',
|
|
121
|
+
background: 'linear-gradient(to left, rgba(20, 20, 22, 1) 0%, rgba(20, 20, 22, 0) 100%)',
|
|
122
|
+
right: '0',
|
|
123
|
+
top: '0',
|
|
124
|
+
zIndex: '30',
|
|
125
|
+
pointerEvents: 'none'
|
|
76
126
|
},
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
127
|
+
|
|
128
|
+
style: {
|
|
129
|
+
'> button': {
|
|
130
|
+
width: '16px',
|
|
131
|
+
height: '16px',
|
|
132
|
+
position: 'absolute',
|
|
133
|
+
zIndex: '35',
|
|
134
|
+
background: 'transparent',
|
|
135
|
+
color: '#0079FD',
|
|
136
|
+
':first-child': { left: '18px' },
|
|
137
|
+
':last-child': { right: '18px' }
|
|
83
138
|
}
|
|
84
139
|
}
|
|
85
140
|
},
|
|
86
|
-
|
|
87
|
-
|
|
141
|
+
|
|
142
|
+
leftButton: {
|
|
143
|
+
extend: Button,
|
|
144
|
+
props: { icon: 'arrowLeft' }
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
Flex: {
|
|
88
148
|
props: {
|
|
89
|
-
|
|
90
|
-
|
|
149
|
+
flex: '1',
|
|
150
|
+
overflow: 'auto hidden',
|
|
151
|
+
'::-webkit-scrollbar': { display: 'none' }
|
|
91
152
|
},
|
|
153
|
+
|
|
92
154
|
childExtend: {
|
|
93
|
-
|
|
94
|
-
props: {
|
|
95
|
-
|
|
96
|
-
|
|
155
|
+
tag: 'h6',
|
|
156
|
+
props: ({ state, key }) => ({
|
|
157
|
+
fontSize: 'Z1',
|
|
158
|
+
textAlign: 'center',
|
|
159
|
+
boxSizing: 'content-box',
|
|
160
|
+
minWidth: '272px',
|
|
161
|
+
|
|
162
|
+
isActive: state.activeMonth === parseInt(key),
|
|
163
|
+
'.isActive': { opacity: '1' }
|
|
164
|
+
}),
|
|
165
|
+
|
|
166
|
+
render: (el, state) => {
|
|
167
|
+
const { props } = el
|
|
168
|
+
const { isActive } = props
|
|
169
|
+
if (isActive) {
|
|
170
|
+
window.requestAnimationFrame(() => {
|
|
171
|
+
el.parent.parent.node.scrollLeft = el.node.offsetLeft
|
|
172
|
+
})
|
|
173
|
+
}
|
|
97
174
|
}
|
|
98
175
|
},
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
{ text: '
|
|
110
|
-
{ text: '
|
|
111
|
-
{ text: '
|
|
112
|
-
{ text: '
|
|
113
|
-
{ text: '
|
|
114
|
-
{ text: 'Sa' },
|
|
115
|
-
{ text: 'Su' }
|
|
176
|
+
|
|
177
|
+
$setCollection: ({ state, parent }) => {
|
|
178
|
+
return [
|
|
179
|
+
{ text: 'January' },
|
|
180
|
+
{ text: 'February' },
|
|
181
|
+
{ text: 'March' },
|
|
182
|
+
{ text: 'April' },
|
|
183
|
+
{ text: 'May' },
|
|
184
|
+
{ text: 'June' },
|
|
185
|
+
{ text: 'July' },
|
|
186
|
+
{ text: 'August' },
|
|
187
|
+
{ text: 'September' },
|
|
188
|
+
{ text: 'October' },
|
|
189
|
+
{ text: 'November' },
|
|
190
|
+
{ text: 'December' }
|
|
116
191
|
]
|
|
117
|
-
}
|
|
192
|
+
}
|
|
193
|
+
},
|
|
118
194
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
extend: SquareButton,
|
|
195
|
+
rightButton: { extend: Button, props: { icon: 'arrowRight' } }
|
|
196
|
+
}
|
|
122
197
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
198
|
+
const weekDays = {
|
|
199
|
+
extend: Grid,
|
|
200
|
+
childExtend: {
|
|
201
|
+
tag: 'span',
|
|
202
|
+
extend: Flex
|
|
203
|
+
},
|
|
204
|
+
...[
|
|
205
|
+
{ text: 'Mo' },
|
|
206
|
+
{ text: 'Tu' },
|
|
207
|
+
{ text: 'We' },
|
|
208
|
+
{ text: 'Th' },
|
|
209
|
+
{ text: 'Fr' },
|
|
210
|
+
{ text: 'Sa' },
|
|
211
|
+
{ text: 'Su' }
|
|
212
|
+
]
|
|
213
|
+
}
|
|
132
214
|
|
|
133
|
-
|
|
215
|
+
const monthNumbers = {
|
|
216
|
+
extend: Grid,
|
|
217
|
+
props: {
|
|
218
|
+
columns: 'repeat(7, 32px)',
|
|
219
|
+
gap: '4px',
|
|
220
|
+
boxSizing: 'content-box',
|
|
221
|
+
padding: `- ${12 / 16}em`
|
|
222
|
+
},
|
|
223
|
+
childExtend: {
|
|
224
|
+
extend: Button,
|
|
225
|
+
props: ({ state, key }) => ({
|
|
226
|
+
color: 'white',
|
|
227
|
+
textAlign: 'center',
|
|
228
|
+
background: 'transparent',
|
|
229
|
+
fontSize: 'Z1',
|
|
230
|
+
round: '100%',
|
|
231
|
+
height: '32px',
|
|
232
|
+
':hover': { theme: 'secondary' },
|
|
233
|
+
':nth-child(7n-1)': { color: 'rgba(255, 255, 255, .5)' },
|
|
234
|
+
':nth-child(7n)': { color: 'rgba(255, 255, 255, .5)' },
|
|
235
|
+
isActive: state.activeDay === parseInt(key) + 1,
|
|
236
|
+
'.isActive': { theme: 'secondary' }
|
|
237
|
+
}),
|
|
238
|
+
on: {
|
|
239
|
+
click: (event, element, state) => {
|
|
240
|
+
state.update({ activeDay: element.text })
|
|
241
|
+
console.log(state.activeDay + '.' + state.activeMonth + '.' + state.activeYear)
|
|
242
|
+
}
|
|
134
243
|
}
|
|
244
|
+
},
|
|
245
|
+
$setCollection: (el, s) => {
|
|
246
|
+
const daysInMonth = new Date(s.activeYear, s.activeMonth, 0).getDate()
|
|
247
|
+
const days = (new Array(daysInMonth)).fill(undefined)
|
|
248
|
+
.map((v, k) => ({ text: k + 1 }))
|
|
249
|
+
return days
|
|
135
250
|
}
|
|
136
251
|
}
|
|
137
252
|
|
|
138
|
-
|
|
139
|
-
style,
|
|
253
|
+
const confirmButtons = {
|
|
140
254
|
extend: Flex,
|
|
255
|
+
childExtend: Button,
|
|
256
|
+
...[
|
|
257
|
+
{
|
|
258
|
+
text: 'cancel',
|
|
259
|
+
on: {
|
|
260
|
+
click: (event, element, state) => {
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
text: 'ok'
|
|
266
|
+
}
|
|
267
|
+
]
|
|
268
|
+
}
|
|
141
269
|
|
|
270
|
+
const monthNumbersContainer = {
|
|
142
271
|
props: {
|
|
272
|
+
maxWidth: `${272 / 16}em`,
|
|
143
273
|
position: 'relative',
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
274
|
+
':before': {
|
|
275
|
+
content: '""',
|
|
276
|
+
position: 'absolute',
|
|
277
|
+
boxSize: '100% 12px',
|
|
278
|
+
background: 'linear-gradient(to right, rgba(20, 20, 22, 1) 0%, rgba(20, 20, 22, 0) 100%)',
|
|
279
|
+
left: '0',
|
|
280
|
+
top: '0',
|
|
281
|
+
zIndex: '30'
|
|
282
|
+
},
|
|
283
|
+
':after': {
|
|
284
|
+
content: '""',
|
|
285
|
+
position: 'absolute',
|
|
286
|
+
boxSize: '100% 12px',
|
|
287
|
+
background: 'linear-gradient(to left, rgba(20, 20, 22, 1) 0%, rgba(20, 20, 22, 0) 100%)',
|
|
288
|
+
right: '0',
|
|
289
|
+
top: '0',
|
|
290
|
+
zIndex: '30'
|
|
291
|
+
},
|
|
292
|
+
content: {
|
|
293
|
+
style: { overflowX: 'auto' }
|
|
294
|
+
}
|
|
152
295
|
},
|
|
296
|
+
content: {
|
|
297
|
+
extend: Flex,
|
|
298
|
+
childExtend: monthNumbers,
|
|
299
|
+
...[{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}]
|
|
300
|
+
}
|
|
301
|
+
}
|
|
153
302
|
|
|
154
|
-
|
|
155
|
-
|
|
303
|
+
const props = {
|
|
304
|
+
yearRange: [1993, 2023],
|
|
305
|
+
round: 'Z2',
|
|
306
|
+
margin: 'E',
|
|
307
|
+
overflow: 'hidden',
|
|
308
|
+
maxHeight: '318px',
|
|
309
|
+
boxSize: 'fit-content fit-content',
|
|
310
|
+
background: '#141416',
|
|
311
|
+
padding: '- Z - -',
|
|
312
|
+
style: {
|
|
313
|
+
button: {
|
|
314
|
+
padding: '0'
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
|
|
318
|
+
calendar: {
|
|
319
|
+
flow: 'column',
|
|
320
|
+
padding: '20px - - -',
|
|
321
|
+
position: 'relative',
|
|
322
|
+
|
|
323
|
+
weekDaysContainer: {
|
|
324
|
+
overflow: 'hidden',
|
|
325
|
+
padding: '- - Z1 -',
|
|
326
|
+
boxSizing: 'content-box',
|
|
327
|
+
maxWidth: `${272 / 16}em`,
|
|
328
|
+
childProps: {
|
|
329
|
+
maxWidth: 'fit-content',
|
|
330
|
+
columns: 'repeat(7, 32px)',
|
|
331
|
+
gap: '4px',
|
|
332
|
+
boxSizing: 'content-box',
|
|
333
|
+
padding: `- ${12 / 16}em`,
|
|
334
|
+
childProps: {
|
|
335
|
+
fontSize: 'Y1',
|
|
336
|
+
textTransform: 'capitalize',
|
|
337
|
+
':nth-child(7n-1)': { color: 'rgba(255, 255, 255, .5)' },
|
|
338
|
+
':nth-child(7n)': { color: 'rgba(255, 255, 255, .5)' },
|
|
339
|
+
align: 'center center'
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
},
|
|
343
|
+
|
|
344
|
+
confirmButtons: {
|
|
345
|
+
align: 'center flex-end',
|
|
346
|
+
gap: 'A1',
|
|
347
|
+
padding: 'A A1 - -',
|
|
348
|
+
childProps: {
|
|
349
|
+
color: '#0079FD',
|
|
350
|
+
fontSize: 'Y',
|
|
351
|
+
textTransform: 'uppercase',
|
|
352
|
+
background: 'transparent'
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
export const DatePicker = {
|
|
360
|
+
extend: Flex,
|
|
361
|
+
state: {
|
|
362
|
+
activeYear: 1993,
|
|
363
|
+
activeMonth: 8,
|
|
364
|
+
activeDay: 14
|
|
365
|
+
},
|
|
366
|
+
|
|
367
|
+
props,
|
|
368
|
+
|
|
369
|
+
DatePickerYears: {},
|
|
370
|
+
|
|
371
|
+
calendar: {
|
|
372
|
+
extend: Flex,
|
|
373
|
+
|
|
374
|
+
months,
|
|
375
|
+
|
|
376
|
+
weekDaysContainer: {
|
|
377
|
+
extend: Flex,
|
|
378
|
+
childExtend: weekDays,
|
|
379
|
+
...[{}, {}]
|
|
380
|
+
},
|
|
381
|
+
|
|
382
|
+
monthNumbersContainer,
|
|
383
|
+
|
|
384
|
+
confirmButtons
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
export const DatePickerTwoColumns = {
|
|
389
|
+
extend: DatePicker,
|
|
390
|
+
props: {
|
|
391
|
+
calendar: {
|
|
392
|
+
months: {
|
|
393
|
+
maxWidth: `${544 / 16}em`
|
|
394
|
+
},
|
|
395
|
+
weekDaysContainer: {
|
|
396
|
+
maxWidth: `${544 / 16}em`
|
|
397
|
+
},
|
|
398
|
+
monthNumbersContainer: {
|
|
399
|
+
maxWidth: `${544 / 16}em`
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
156
403
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/datepicker",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.43",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"gitHead": "
|
|
6
|
+
"gitHead": "9fc7b25250ed06e3c759f7539edff7855b31ec21",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@symbo.ls/block": "latest",
|
|
9
9
|
"@symbo.ls/icon": "latest",
|
package/style.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
main: {
|
|
5
|
-
'section > header span:nth-child(6)': {
|
|
6
|
-
opacity: 0.5
|
|
7
|
-
},
|
|
8
|
-
'section > header span:nth-child(7)': {
|
|
9
|
-
opacity: 0.5
|
|
10
|
-
},
|
|
11
|
-
'section > div button:nth-child(7n)': {
|
|
12
|
-
opacity: 0.5
|
|
13
|
-
},
|
|
14
|
-
'section > div button:nth-child(7n - 1)': {
|
|
15
|
-
opacity: 0.5
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|