@symbo.ls/datepicker 2.11.90 → 2.11.94

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 (4) hide show
  1. package/days.js +26 -5
  2. package/index.js +4 -2
  3. package/months.js +50 -17
  4. package/package.json +2 -2
package/days.js CHANGED
@@ -8,14 +8,20 @@ export const DatePickerDay = {
8
8
  state: true,
9
9
 
10
10
  props: ({ state, key }) => {
11
- const isSelected = state.parent.parent.activeDay === parseInt(key) + 1
11
+ const rootState = state.parent.parent.parent
12
+ const date = new Date(state._d)
13
+ const isSelected = rootState.activeDay === date.toString()
12
14
  const gridColumnStart = 7 - state.parent.weekItems.weeks[0].dates.length
13
- const isWeekend = state.moment.isoWeekday()
15
+ const { moment } = state
16
+ moment._d = date
17
+ const isWeekend = moment.day() === 0 || moment.day() === 6
18
+ // const isWeekend = state.moment.day() === 0 || state.moment.day() === 6
14
19
  // const isWeekend = state.moment.isWeekend
15
20
 
16
21
  return {
17
22
  isSelected,
18
23
  isWeekend,
24
+ date: date.toString(),
19
25
  textAlign: 'center',
20
26
  fontSize: 'Z1',
21
27
  round: '100%',
@@ -38,10 +44,9 @@ export const DatePickerDay = {
38
44
 
39
45
  on: {
40
46
  click: (event, element, state) => {
41
- state.parent.parent.update({
42
- active: state.parse()
47
+ state.parent.parent.parent.update({
48
+ activeDay: element.props.date
43
49
  })
44
- console.log(state)
45
50
  }
46
51
  }
47
52
  }
@@ -59,6 +64,22 @@ export const DatePickerGrid = {
59
64
  childExtend: DatePickerDay,
60
65
 
61
66
  $setStateCollection: (el, s) => {
67
+ // console.warn(s.days)
62
68
  return s.days
69
+ },
70
+
71
+ on: {
72
+ render: (el, state) => {
73
+ const { key } = el
74
+ const isSelected = state.parent.parent.activeMonth === parseInt(key)
75
+ if (isSelected) {
76
+ window.requestAnimationFrame(() => {
77
+ el.parent.parent.node.scrollTo({
78
+ left: el.node.offsetLeft,
79
+ behavior: 'smooth'
80
+ })
81
+ })
82
+ }
83
+ }
63
84
  }
64
85
  }
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
 
@@ -81,6 +81,8 @@ export const DatePicker = {
81
81
  },
82
82
 
83
83
  props: {
84
+ width: 'fit-content',
85
+ margin: '0',
84
86
  maxHeight: 'G+B2'
85
87
  },
86
88
 
package/months.js CHANGED
@@ -46,12 +46,26 @@ export const DatePickerMonthsSlider = {
46
46
  },
47
47
 
48
48
  Button_left: {
49
- icon: 'arrowLeft',
50
- '@dark': {
51
- theme: 'primary @dark .color-only'
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
- '@light': {
54
- theme: 'primary @light .color-only'
58
+ on: {
59
+ click: (ev, el, s) => {
60
+ const { activeMonth, activeYear } = s
61
+ if (activeMonth > 0) s.update({ activeMonth: activeMonth - 1 })
62
+ else {
63
+ s.update({
64
+ activeYear: activeYear - 1,
65
+ activeMonth: 11
66
+ })
67
+ }
68
+ }
55
69
  }
56
70
  },
57
71
 
@@ -74,13 +88,18 @@ export const DatePickerMonthsSlider = {
74
88
  '.isSelected': { opacity: '1' }
75
89
  }),
76
90
 
77
- render: (el, state) => {
78
- const { props } = el
79
- const { isSelected } = props
80
- if (isSelected) {
81
- window.requestAnimationFrame(() => {
82
- el.parent.parent.node.scrollLeft = el.node.offsetLeft
83
- })
91
+ on: {
92
+ update: (el, state) => {
93
+ const { props } = el
94
+ const { isSelected } = props
95
+ if (isSelected) {
96
+ window.requestAnimationFrame(() => {
97
+ el.parent.parent.node.scrollTo({
98
+ left: el.node.offsetLeft,
99
+ behavior: 'smooth'
100
+ })
101
+ })
102
+ }
84
103
  }
85
104
  }
86
105
  },
@@ -104,12 +123,26 @@ export const DatePickerMonthsSlider = {
104
123
  },
105
124
 
106
125
  Button_right: {
107
- icon: 'arrowRight',
108
- '@dark': {
109
- theme: 'primary @dark .color-only'
126
+ props: {
127
+ icon: 'arrowRight',
128
+ '@dark': {
129
+ theme: 'primary @dark .color-only'
130
+ },
131
+ '@light': {
132
+ theme: 'primary @light .color-only'
133
+ }
110
134
  },
111
- '@light': {
112
- theme: 'primary @light .color-only'
135
+ on: {
136
+ click: (ev, el, s) => {
137
+ const { activeMonth, activeYear } = s
138
+ if (activeMonth < 11) s.update({ activeMonth: activeMonth + 1 })
139
+ else {
140
+ s.update({
141
+ activeYear: activeYear + 1,
142
+ activeMonth: 0
143
+ })
144
+ }
145
+ }
113
146
  }
114
147
  }
115
148
  }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@symbo.ls/datepicker",
3
- "version": "2.11.90",
3
+ "version": "2.11.94",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
- "gitHead": "4c5a23152b7b38852c4f7115c2565dfe724382ee",
6
+ "gitHead": "80354d405a3dd6085ee93472538ebef687c97764",
7
7
  "dependencies": {
8
8
  "@symbo.ls/atoms": "latest",
9
9
  "@symbo.ls/button": "latest",