@symbo.ls/datepicker 2.11.52 → 2.11.55
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 +90 -45
- package/package.json +4 -3
package/index.js
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
import { Flex, Grid } from '@symbo.ls/atoms'
|
|
4
4
|
import { Button } from '@symbo.ls/button'
|
|
5
5
|
import { Dialog } from '@symbo.ls/dialog'
|
|
6
|
+
import { HeadlessDatepicker } from 'headless-datepicker'
|
|
7
|
+
const calendar = new HeadlessDatepicker.Calendar({
|
|
8
|
+
calendarMode: 'exact'
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
const extractMonthDays = (data) => {
|
|
12
|
+
const result = []
|
|
13
|
+
|
|
14
|
+
data.weeks.forEach((week) => {
|
|
15
|
+
week.dates.forEach((date) => {
|
|
16
|
+
result.push(date)
|
|
17
|
+
})
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
return result
|
|
21
|
+
}
|
|
6
22
|
|
|
7
23
|
export const DatePickerYears = {
|
|
8
24
|
tag: 'aside',
|
|
@@ -47,16 +63,16 @@ export const DatePickerYears = {
|
|
|
47
63
|
opacity: '.4',
|
|
48
64
|
background: 'transparent',
|
|
49
65
|
transition: 'opacity .25s ease',
|
|
50
|
-
|
|
51
|
-
'.
|
|
66
|
+
isSelected: state.activeYear === text,
|
|
67
|
+
'.isSelected': { opacity: '1' },
|
|
52
68
|
':hover': { opacity: '1' }
|
|
53
69
|
}),
|
|
54
70
|
on: {
|
|
55
71
|
click: (event, element, state) => state.update({ activeYear: element.text }),
|
|
56
72
|
render: (el, state) => {
|
|
57
73
|
const { props } = el
|
|
58
|
-
const {
|
|
59
|
-
if (
|
|
74
|
+
const { isSelected } = props
|
|
75
|
+
if (isSelected) {
|
|
60
76
|
window.requestAnimationFrame(() => {
|
|
61
77
|
el.parent.parent.node.scrollTop = el.node.offsetTop - 100
|
|
62
78
|
})
|
|
@@ -160,14 +176,14 @@ export const DatePickerMonthsSlider = {
|
|
|
160
176
|
boxSizing: 'content-box',
|
|
161
177
|
minWidth: '272px',
|
|
162
178
|
|
|
163
|
-
|
|
164
|
-
'.
|
|
179
|
+
isSelected: state.activeMonth === parseInt(key),
|
|
180
|
+
'.isSelected': { opacity: '1' }
|
|
165
181
|
}),
|
|
166
182
|
|
|
167
183
|
render: (el, state) => {
|
|
168
184
|
const { props } = el
|
|
169
|
-
const {
|
|
170
|
-
if (
|
|
185
|
+
const { isSelected } = props
|
|
186
|
+
if (isSelected) {
|
|
171
187
|
window.requestAnimationFrame(() => {
|
|
172
188
|
el.parent.parent.node.scrollLeft = el.node.offsetLeft
|
|
173
189
|
})
|
|
@@ -226,18 +242,16 @@ export const DatePickerWeekDays = {
|
|
|
226
242
|
]
|
|
227
243
|
}
|
|
228
244
|
|
|
229
|
-
export const
|
|
230
|
-
extend:
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
props: ({ state, key }) => ({
|
|
240
|
-
isActive: state.activeDay === parseInt(key) + 1,
|
|
245
|
+
export const DatePickerDay = {
|
|
246
|
+
extend: Button,
|
|
247
|
+
state: true,
|
|
248
|
+
|
|
249
|
+
props: ({ state, key }) => {
|
|
250
|
+
const isSelected = state.parent.activeDay === parseInt(key) + 1
|
|
251
|
+
const gridColumnStart = 7 - state.parent.weekItems.weeks[0].dates.length
|
|
252
|
+
|
|
253
|
+
return {
|
|
254
|
+
isSelected,
|
|
241
255
|
textAlign: 'center',
|
|
242
256
|
fontSize: 'Z1',
|
|
243
257
|
round: '100%',
|
|
@@ -246,24 +260,42 @@ export const DatePickerGrid = {
|
|
|
246
260
|
lineHeight: '.9',
|
|
247
261
|
background: 'transparent',
|
|
248
262
|
theme: 'secondary @dark .color',
|
|
249
|
-
|
|
250
|
-
'
|
|
263
|
+
text: parseInt(key) + 1,
|
|
264
|
+
':first-child': {
|
|
265
|
+
style: { gridColumnStart }
|
|
266
|
+
},
|
|
267
|
+
'.isSelected': { theme: 'primary' },
|
|
268
|
+
'!isSelected': {
|
|
251
269
|
':hover': { theme: 'secondary' },
|
|
252
270
|
':nth-child(7n-1), &:nth-child(7n)': { opacity: '.5' }
|
|
253
271
|
}
|
|
254
|
-
}),
|
|
255
|
-
on: {
|
|
256
|
-
click: (event, element, state) => {
|
|
257
|
-
state.update({ activeDay: element.text })
|
|
258
|
-
console.log(state.activeDay + '.' + state.activeMonth + '.' + state.activeYear)
|
|
259
|
-
}
|
|
260
272
|
}
|
|
261
273
|
},
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
.
|
|
266
|
-
|
|
274
|
+
|
|
275
|
+
on: {
|
|
276
|
+
click: (event, element, state) => {
|
|
277
|
+
state.parent.parent.update({
|
|
278
|
+
active: state.parse()
|
|
279
|
+
})
|
|
280
|
+
console.log(state)
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export const DatePickerGrid = {
|
|
286
|
+
extend: Grid,
|
|
287
|
+
|
|
288
|
+
props: {
|
|
289
|
+
columns: 'repeat(7, 1fr)',
|
|
290
|
+
minWidth: '100%',
|
|
291
|
+
gap: 'W2',
|
|
292
|
+
padding: '- Z'
|
|
293
|
+
},
|
|
294
|
+
|
|
295
|
+
childExtend: DatePickerDay,
|
|
296
|
+
|
|
297
|
+
$setStateCollection: (el, s) => {
|
|
298
|
+
return s.days
|
|
267
299
|
}
|
|
268
300
|
}
|
|
269
301
|
|
|
@@ -294,10 +326,25 @@ const monthNumbersContainer = {
|
|
|
294
326
|
}
|
|
295
327
|
},
|
|
296
328
|
|
|
329
|
+
state: (el, s) => {
|
|
330
|
+
const state = el.parent.state
|
|
331
|
+
return (new Array(12)).fill(undefined).map((v, k) => {
|
|
332
|
+
const year = state.activeYear
|
|
333
|
+
const month = k + 1
|
|
334
|
+
const weekItems = calendar.getMonth({ year, month })
|
|
335
|
+
return {
|
|
336
|
+
year,
|
|
337
|
+
month,
|
|
338
|
+
weekItems,
|
|
339
|
+
days: extractMonthDays(weekItems)
|
|
340
|
+
}
|
|
341
|
+
})
|
|
342
|
+
},
|
|
343
|
+
|
|
297
344
|
content: {
|
|
298
345
|
extend: Flex,
|
|
299
346
|
childExtend: DatePickerGrid,
|
|
300
|
-
|
|
347
|
+
$setStateCollection: (el, s) => s.parse()
|
|
301
348
|
}
|
|
302
349
|
}
|
|
303
350
|
|
|
@@ -343,17 +390,15 @@ export const DatePicker = {
|
|
|
343
390
|
|
|
344
391
|
export const DatePickerTwoColumns = {
|
|
345
392
|
extend: DatePicker,
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
maxWidth: `${544 / 16}em`
|
|
356
|
-
}
|
|
393
|
+
Flex: {
|
|
394
|
+
DatePickerMonthsSlider: {
|
|
395
|
+
maxWidth: `${544 / 16}em`
|
|
396
|
+
},
|
|
397
|
+
DatePickerWeekDays: {
|
|
398
|
+
maxWidth: `${544 / 16}em`
|
|
399
|
+
},
|
|
400
|
+
monthNumbersContainer: {
|
|
401
|
+
maxWidth: `${544 / 16}em`
|
|
357
402
|
}
|
|
358
403
|
}
|
|
359
404
|
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/datepicker",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.55",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"gitHead": "
|
|
6
|
+
"gitHead": "f4a6af272593be22cbf1337ddb25afec00ba359d",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@symbo.ls/atoms": "latest",
|
|
9
9
|
"@symbo.ls/button": "latest",
|
|
10
10
|
"@symbo.ls/dialog": "latest",
|
|
11
|
-
"@symbo.ls/icon": "latest"
|
|
11
|
+
"@symbo.ls/icon": "latest",
|
|
12
|
+
"headless-datepicker": "^1.0.1"
|
|
12
13
|
},
|
|
13
14
|
"source": "src/index.js"
|
|
14
15
|
}
|