@symbo.ls/datepicker 2.11.70 → 2.11.76

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 ADDED
@@ -0,0 +1,61 @@
1
+ 'use strict'
2
+
3
+ import { Grid } from '@symbo.ls/atoms'
4
+ import { Button } from '@symbo.ls/button'
5
+
6
+ export const DatePickerDay = {
7
+ extend: Button,
8
+ state: true,
9
+
10
+ props: ({ state, key }) => {
11
+ const isSelected = state.parent.activeDay === parseInt(key) + 1
12
+ const gridColumnStart = 7 - state.parent.weekItems.weeks[0].dates.length
13
+
14
+ return {
15
+ isSelected,
16
+ textAlign: 'center',
17
+ fontSize: 'Z1',
18
+ round: '100%',
19
+ height: 'B1',
20
+ aspectRatio: '1/1',
21
+ lineHeight: '.9',
22
+ background: 'transparent',
23
+ theme: 'secondary @dark .color',
24
+ text: parseInt(key) + 1,
25
+ ':first-child': {
26
+ style: { gridColumnStart }
27
+ },
28
+ '.isSelected': { theme: 'primary' },
29
+ '!isSelected': {
30
+ ':hover': { theme: 'secondary' },
31
+ ':nth-child(7n-1), &:nth-child(7n)': { opacity: '.5' }
32
+ }
33
+ }
34
+ },
35
+
36
+ on: {
37
+ click: (event, element, state) => {
38
+ state.parent.parent.update({
39
+ active: state.parse()
40
+ })
41
+ console.log(state)
42
+ }
43
+ }
44
+ }
45
+
46
+ export const DatePickerGrid = {
47
+ extend: Grid,
48
+
49
+ props: {
50
+ columns: 'repeat(7, 1fr)',
51
+ minWidth: '100%',
52
+ gap: 'W2',
53
+ padding: '- Z'
54
+ },
55
+
56
+ childExtend: DatePickerDay,
57
+
58
+ $setStateCollection: (el, s) => {
59
+ return s.days
60
+ }
61
+ }
package/index.js CHANGED
@@ -1,9 +1,10 @@
1
1
  'use strict'
2
2
 
3
- import { Flex, Grid } from '@symbo.ls/atoms'
4
- import { Button } from '@symbo.ls/button'
3
+ import { Flex } from '@symbo.ls/atoms'
5
4
  import { Dialog } from '@symbo.ls/dialog'
6
5
  import { HeadlessDatepicker } from 'headless-datepicker'
6
+ import { DatePickerGrid } from './days'
7
+
7
8
  const calendar = new HeadlessDatepicker.Calendar({
8
9
  calendarMode: 'exact'
9
10
  })
@@ -20,282 +21,6 @@ const extractMonthDays = (data) => {
20
21
  return result
21
22
  }
22
23
 
23
- export const DatePickerYears = {
24
- tag: 'aside',
25
- props: {
26
- overflow: 'hidden',
27
- position: 'relative',
28
-
29
- ':before': {
30
- content: '""',
31
- boxSize: 'A1 100%',
32
- position: 'absolute',
33
- top: '0',
34
- left: '0',
35
- background: 'linear-gradient(to bottom, var(--theme-tertiary-dark-background) 0%, transparent 100%)',
36
- zIndex: '10'
37
- },
38
- ':after': {
39
- content: '""',
40
- boxSize: 'B 100%',
41
- position: 'absolute',
42
- bottom: '0',
43
- left: '0',
44
- background: 'linear-gradient(to top, var(--theme-tertiary-dark-background) 0%, transparent 100%)'
45
- }
46
- },
47
-
48
- Flex: {
49
- props: {
50
- flow: 'column',
51
- gap: 'B',
52
- padding: 'A Z A1 B1',
53
- maxHeight: '100%',
54
- overflow: 'hidden auto',
55
- '::-webkit-scrollbar': { display: 'none' }
56
- },
57
-
58
- childExtend: {
59
- extend: Button,
60
- props: ({ state, text }) => ({
61
- fontSize: 'Y1',
62
- color: 'white',
63
- opacity: '.4',
64
- background: 'transparent',
65
- transition: 'opacity .25s ease',
66
- isSelected: state.activeYear === text,
67
- '.isSelected': { opacity: '1' },
68
- ':hover': { opacity: '1' }
69
- }),
70
- on: {
71
- click: (event, element, state) => state.update({ activeYear: element.text }),
72
- render: (el, state) => {
73
- const { props } = el
74
- const { isSelected } = props
75
- if (isSelected) {
76
- window.requestAnimationFrame(() => {
77
- el.parent.parent.node.scrollTop = el.node.offsetTop - 100
78
- })
79
- }
80
- }
81
- }
82
- },
83
-
84
- $setCollection: ({ state, parent }) => {
85
- const { yearRange } = parent.parent.props
86
-
87
- if (yearRange) {
88
- const [start, end] = yearRange
89
- const yearsArray = (new Array(end + 1 - start)).fill(undefined).map((v, k) => {
90
- return { text: start + k }
91
- }).reverse()
92
- return yearsArray
93
- }
94
-
95
- return [
96
- { text: '2023' },
97
- { text: '2022' },
98
- { text: '2021' },
99
- { text: '2020' },
100
- { text: '2019' },
101
- { text: '2018' },
102
- { text: '2017' },
103
- { text: '2016' },
104
- { text: '2015' },
105
- { text: '2014' },
106
- { text: '2013' },
107
- { text: '2012' },
108
- { text: '2012' },
109
- { text: '2012' }
110
- ]
111
- }
112
- }
113
- }
114
-
115
- export const DatePickerMonthsSlider = {
116
- extend: Flex,
117
- props: {
118
- position: 'relative',
119
- overflow: 'hidden',
120
- alignItems: 'center',
121
- padding: '- - B -',
122
- maxWidth: `${272 / 16}em`,
123
- boxSizing: 'border-box',
124
- ':before': {
125
- content: '""',
126
- position: 'absolute',
127
- boxSize: '100% 100px',
128
- background: 'linear-gradient(to right, var(--theme-tertiary-dark-background) 0%, transparent 100%)',
129
- left: '0',
130
- top: '0',
131
- zIndex: '30',
132
- pointerEvents: 'none'
133
- },
134
- ':after': {
135
- content: '""',
136
- position: 'absolute',
137
- boxSize: '100% 100px',
138
- background: 'linear-gradient(to left, var(--theme-tertiary-dark-background) 0%, transparent 100%)',
139
- right: '0',
140
- top: '0',
141
- zIndex: '30',
142
- pointerEvents: 'none'
143
- },
144
-
145
- style: {
146
- '> button': {
147
- width: '16px',
148
- height: '16px',
149
- position: 'absolute',
150
- zIndex: '35',
151
- background: 'transparent',
152
- color: '#0079FD',
153
- ':first-child': { left: '18px' },
154
- ':last-child': { right: '18px' }
155
- }
156
- }
157
- },
158
-
159
- Button_left: { icon: 'arrowLeft' },
160
-
161
- Flex: {
162
- props: {
163
- flex: '1',
164
- overflow: 'auto hidden',
165
- '::-webkit-scrollbar': { display: 'none' }
166
- },
167
-
168
- childExtend: {
169
- tag: 'h6',
170
- props: ({ state, key }) => ({
171
- fontSize: 'Z1',
172
- textAlign: 'center',
173
- boxSizing: 'content-box',
174
- minWidth: '272px',
175
-
176
- isSelected: state.activeMonth === parseInt(key),
177
- '.isSelected': { opacity: '1' }
178
- }),
179
-
180
- render: (el, state) => {
181
- const { props } = el
182
- const { isSelected } = props
183
- if (isSelected) {
184
- window.requestAnimationFrame(() => {
185
- el.parent.parent.node.scrollLeft = el.node.offsetLeft
186
- })
187
- }
188
- }
189
- },
190
-
191
- $setCollection: ({ state, parent }) => {
192
- return [
193
- { text: 'January' },
194
- { text: 'February' },
195
- { text: 'March' },
196
- { text: 'April' },
197
- { text: 'May' },
198
- { text: 'June' },
199
- { text: 'July' },
200
- { text: 'August' },
201
- { text: 'September' },
202
- { text: 'October' },
203
- { text: 'November' },
204
- { text: 'December' }
205
- ]
206
- }
207
- },
208
-
209
- Button_right: { icon: 'arrowRight' }
210
- }
211
-
212
- export const DatePickerWeekDays = {
213
- extend: Grid,
214
- props: {
215
- overflow: 'hidden',
216
- padding: '- Z Z',
217
- width: '100%',
218
- columns: 'repeat(7, 1fr)',
219
- gap: 'W2'
220
- },
221
- childExtend: {
222
- tag: 'span',
223
- extend: Flex,
224
- props: {
225
- fontSize: 'Y1',
226
- textTransform: 'capitalize',
227
- align: 'center center',
228
- ':nth-child(7n-1), &:nth-child(7n)': { opacity: '.5' }
229
- }
230
- },
231
- ...[
232
- { text: 'Mo' },
233
- { text: 'Tu' },
234
- { text: 'We' },
235
- { text: 'Th' },
236
- { text: 'Fr' },
237
- { text: 'Sa' },
238
- { text: 'Su' }
239
- ]
240
- }
241
-
242
- export const DatePickerDay = {
243
- extend: Button,
244
- state: true,
245
-
246
- props: ({ state, key }) => {
247
- const isSelected = state.parent.activeDay === parseInt(key) + 1
248
- const gridColumnStart = 7 - state.parent.weekItems.weeks[0].dates.length
249
-
250
- return {
251
- isSelected,
252
- textAlign: 'center',
253
- fontSize: 'Z1',
254
- round: '100%',
255
- height: 'B1',
256
- aspectRatio: '1/1',
257
- lineHeight: '.9',
258
- background: 'transparent',
259
- theme: 'secondary @dark .color',
260
- text: parseInt(key) + 1,
261
- ':first-child': {
262
- style: { gridColumnStart }
263
- },
264
- '.isSelected': { theme: 'primary' },
265
- '!isSelected': {
266
- ':hover': { theme: 'secondary' },
267
- ':nth-child(7n-1), &:nth-child(7n)': { opacity: '.5' }
268
- }
269
- }
270
- },
271
-
272
- on: {
273
- click: (event, element, state) => {
274
- state.parent.parent.update({
275
- active: state.parse()
276
- })
277
- console.log(state)
278
- }
279
- }
280
- }
281
-
282
- export const DatePickerGrid = {
283
- extend: Grid,
284
-
285
- props: {
286
- columns: 'repeat(7, 1fr)',
287
- minWidth: '100%',
288
- gap: 'W2',
289
- padding: '- Z'
290
- },
291
-
292
- childExtend: DatePickerDay,
293
-
294
- $setStateCollection: (el, s) => {
295
- return s.days
296
- }
297
- }
298
-
299
24
  const monthNumbersContainer = {
300
25
  props: {
301
26
  maxWidth: `${272 / 16}em`,
@@ -347,7 +72,7 @@ const monthNumbersContainer = {
347
72
 
348
73
  const props = {
349
74
  yearRange: [1993, 2023],
350
- maxHeight: '318px',
75
+ maxHeight: 'G+B',
351
76
  boxSize: 'fit-content fit-content',
352
77
  style: {
353
78
  button: {
@@ -406,3 +131,8 @@ export const DatePickerTwoColumns = {
406
131
  }
407
132
  }
408
133
  }
134
+
135
+ export * from './years'
136
+ export * from './months'
137
+ export * from './weekdays'
138
+ export * from './days'
package/months.js ADDED
@@ -0,0 +1,100 @@
1
+ 'use strict'
2
+
3
+ import { Flex } from '@symbo.ls/atoms'
4
+
5
+ export const DatePickerMonthsSlider = {
6
+ extend: Flex,
7
+ props: {
8
+ position: 'relative',
9
+ overflow: 'hidden',
10
+ alignItems: 'center',
11
+ padding: '- - B -',
12
+ maxWidth: `${272 / 16}em`,
13
+ boxSizing: 'border-box',
14
+ ':before': {
15
+ content: '""',
16
+ position: 'absolute',
17
+ boxSize: '100% 100px',
18
+ background: 'linear-gradient(to right, var(--theme-tertiary-dark-background) 0%, transparent 100%)',
19
+ left: '0',
20
+ top: '0',
21
+ zIndex: '30',
22
+ pointerEvents: 'none'
23
+ },
24
+ ':after': {
25
+ content: '""',
26
+ position: 'absolute',
27
+ boxSize: '100% 100px',
28
+ background: 'linear-gradient(to left, var(--theme-tertiary-dark-background) 0%, transparent 100%)',
29
+ right: '0',
30
+ top: '0',
31
+ zIndex: '30',
32
+ pointerEvents: 'none'
33
+ },
34
+
35
+ style: {
36
+ '> button': {
37
+ width: '16px',
38
+ height: '16px',
39
+ position: 'absolute',
40
+ zIndex: '35',
41
+ background: 'transparent',
42
+ color: '#0079FD',
43
+ ':first-child': { left: '18px' },
44
+ ':last-child': { right: '18px' }
45
+ }
46
+ }
47
+ },
48
+
49
+ Button_left: { icon: 'arrowLeft' },
50
+
51
+ Flex: {
52
+ props: {
53
+ flex: '1',
54
+ overflow: 'auto hidden',
55
+ '::-webkit-scrollbar': { display: 'none' }
56
+ },
57
+
58
+ childExtend: {
59
+ tag: 'h6',
60
+ props: ({ state, key }) => ({
61
+ fontSize: 'Z1',
62
+ textAlign: 'center',
63
+ boxSizing: 'content-box',
64
+ minWidth: '272px',
65
+
66
+ isSelected: state.activeMonth === parseInt(key),
67
+ '.isSelected': { opacity: '1' }
68
+ }),
69
+
70
+ render: (el, state) => {
71
+ const { props } = el
72
+ const { isSelected } = props
73
+ if (isSelected) {
74
+ window.requestAnimationFrame(() => {
75
+ el.parent.parent.node.scrollLeft = el.node.offsetLeft
76
+ })
77
+ }
78
+ }
79
+ },
80
+
81
+ $setCollection: ({ state, parent }) => {
82
+ return [
83
+ { text: 'January' },
84
+ { text: 'February' },
85
+ { text: 'March' },
86
+ { text: 'April' },
87
+ { text: 'May' },
88
+ { text: 'June' },
89
+ { text: 'July' },
90
+ { text: 'August' },
91
+ { text: 'September' },
92
+ { text: 'October' },
93
+ { text: 'November' },
94
+ { text: 'December' }
95
+ ]
96
+ }
97
+ },
98
+
99
+ Button_right: { icon: 'arrowRight' }
100
+ }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@symbo.ls/datepicker",
3
- "version": "2.11.70",
3
+ "version": "2.11.76",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
- "gitHead": "329c180a4cf02896ec76566a5b2f5368f62a6b06",
6
+ "gitHead": "08b91598dfbcc46a59273441a121ff3798cc0ce8",
7
7
  "dependencies": {
8
8
  "@symbo.ls/atoms": "latest",
9
9
  "@symbo.ls/button": "latest",
package/weekdays.js ADDED
@@ -0,0 +1,33 @@
1
+ 'use strict'
2
+
3
+ import { Flex, Grid } from '@symbo.ls/atoms'
4
+
5
+ export const DatePickerWeekDays = {
6
+ extend: Grid,
7
+ props: {
8
+ overflow: 'hidden',
9
+ padding: '- Z Z',
10
+ width: '100%',
11
+ columns: 'repeat(7, 1fr)',
12
+ gap: 'W2'
13
+ },
14
+ childExtend: {
15
+ tag: 'span',
16
+ extend: Flex,
17
+ props: {
18
+ fontSize: 'Y1',
19
+ textTransform: 'capitalize',
20
+ align: 'center center',
21
+ ':nth-child(7n-1), &:nth-child(7n)': { opacity: '.5' }
22
+ }
23
+ },
24
+ ...[
25
+ { text: 'Mo' },
26
+ { text: 'Tu' },
27
+ { text: 'We' },
28
+ { text: 'Th' },
29
+ { text: 'Fr' },
30
+ { text: 'Sa' },
31
+ { text: 'Su' }
32
+ ]
33
+ }
package/years.js ADDED
@@ -0,0 +1,95 @@
1
+ 'use strict'
2
+
3
+ import { Button } from '@symbo.ls/button'
4
+
5
+ export const DatePickerYears = {
6
+ tag: 'aside',
7
+ props: {
8
+ overflow: 'hidden',
9
+ position: 'relative',
10
+
11
+ ':before': {
12
+ content: '""',
13
+ boxSize: 'A1 100%',
14
+ position: 'absolute',
15
+ top: '0',
16
+ left: '0',
17
+ background: 'linear-gradient(to bottom, var(--theme-tertiary-dark-background) 0%, transparent 100%)',
18
+ zIndex: '10'
19
+ },
20
+ ':after': {
21
+ content: '""',
22
+ boxSize: 'B 100%',
23
+ position: 'absolute',
24
+ bottom: '0',
25
+ left: '0',
26
+ background: 'linear-gradient(to top, var(--theme-tertiary-dark-background) 0%, transparent 100%)'
27
+ }
28
+ },
29
+
30
+ Flex: {
31
+ props: {
32
+ flow: 'column',
33
+ gap: 'B',
34
+ padding: 'A Z A1 B1',
35
+ maxHeight: '100%',
36
+ overflow: 'hidden auto',
37
+ '::-webkit-scrollbar': { display: 'none' }
38
+ },
39
+
40
+ childExtend: {
41
+ extend: Button,
42
+ props: ({ state, text }) => ({
43
+ fontSize: 'Y1',
44
+ color: 'white',
45
+ opacity: '.4',
46
+ background: 'transparent',
47
+ transition: 'opacity .25s ease',
48
+ isSelected: state.activeYear === text,
49
+ '.isSelected': { opacity: '1' },
50
+ ':hover': { opacity: '1' }
51
+ }),
52
+ on: {
53
+ click: (event, element, state) => state.update({ activeYear: element.text }),
54
+ render: (el, state) => {
55
+ const { props } = el
56
+ const { isSelected } = props
57
+ if (isSelected) {
58
+ window.requestAnimationFrame(() => {
59
+ el.parent.parent.node.scrollTop = el.node.offsetTop - 100
60
+ })
61
+ }
62
+ }
63
+ }
64
+ },
65
+
66
+ $setCollection: ({ state, parent }) => {
67
+ const { yearRange } = parent.parent.props
68
+
69
+ if (yearRange) {
70
+ const [start, end] = yearRange
71
+ const yearsArray = (new Array(end + 1 - start)).fill(undefined).map((v, k) => {
72
+ return { text: start + k }
73
+ }).reverse()
74
+ return yearsArray
75
+ }
76
+
77
+ return [
78
+ { text: '2023' },
79
+ { text: '2022' },
80
+ { text: '2021' },
81
+ { text: '2020' },
82
+ { text: '2019' },
83
+ { text: '2018' },
84
+ { text: '2017' },
85
+ { text: '2016' },
86
+ { text: '2015' },
87
+ { text: '2014' },
88
+ { text: '2013' },
89
+ { text: '2012' },
90
+ { text: '2012' },
91
+ { text: '2012' }
92
+ ]
93
+ }
94
+ }
95
+ }