@symbo.ls/datepicker 2.11.29 → 2.11.49

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 (3) hide show
  1. package/index.js +319 -113
  2. package/package.json +2 -2
  3. package/style.js +0 -18
package/index.js CHANGED
@@ -1,157 +1,363 @@
1
1
  'use strict'
2
2
 
3
- import style from './style'
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 buttonProps = {
9
- theme: 'quaternary',
10
- background: 'transparent',
11
- color: '--theme-quinary-dark-color',
12
- ':hover': {
13
- theme: 'quinary .child'
14
- }
15
- }
16
-
17
- const aside = {
6
+ export const DatePickerYears = {
7
+ tag: 'aside',
18
8
  props: {
19
- gap: 'X2',
20
- margin: '-Z - -Z -X2',
21
- padding: 'Z - Z X2',
22
- minHeight: '100%',
23
- height: '100%',
24
- width: '--spacing-D'
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, var(--theme-tertiary-dark-background) 0%, transparent 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, var(--theme-tertiary-dark-background) 0%, transparent 100%)'
28
+ }
25
29
  },
26
30
 
27
- cnt: {
28
- extend: Flex,
31
+ Flex: {
29
32
  props: {
30
33
  flow: 'column',
31
- overflow: 'hidden auto',
32
- boxSize: '100% --spacing-D',
33
- top: '0',
34
- position: 'absolute',
34
+ gap: 'B',
35
+ padding: 'A Z A1 B1',
35
36
  maxHeight: '100%',
36
- justifyContent: 'flex-end'
37
+ overflow: 'hidden auto',
38
+ '::-webkit-scrollbar': { display: 'none' }
37
39
  },
38
40
 
39
41
  childExtend: {
40
42
  extend: Button,
41
- props: {
42
- ...buttonProps,
43
- fontSize: 'Z1'
44
- },
45
- text: ({ state }) => state.value
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
+ ]
46
94
  }
47
95
  }
48
-
49
96
  }
50
97
 
51
- const main = {
98
+ export const DatePickerMonthsSlider = {
52
99
  extend: Flex,
53
-
54
100
  props: {
55
- flex: 1,
56
- gap: 'X2',
57
- flow: 'column',
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, var(--theme-tertiary-dark-background) 0%, transparent 100%)',
112
+ left: '0',
113
+ top: '0',
114
+ zIndex: '30',
115
+ pointerEvents: 'none'
116
+ },
117
+ ':after': {
118
+ content: '""',
119
+ position: 'absolute',
120
+ boxSize: '100% 100px',
121
+ background: 'linear-gradient(to left, var(--theme-tertiary-dark-background) 0%, transparent 100%)',
122
+ right: '0',
123
+ top: '0',
124
+ zIndex: '30',
125
+ pointerEvents: 'none'
126
+ },
58
127
 
59
- header: {
60
- align: 'center space-between'
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' }
138
+ }
61
139
  }
62
140
  },
63
141
 
64
- header: {
65
- extend: Flex,
66
- left: {
67
- extend: SquareButton,
68
- props: {
69
- ...buttonProps,
70
- round: 'C',
71
- icon: 'arrowAngleLeft'
72
- }
73
- },
74
- month: {
75
- tag: 'span',
76
- text: 'December'
142
+ leftButton: {
143
+ extend: Button,
144
+ props: { icon: 'arrowLeft' }
145
+ },
146
+
147
+ Flex: {
148
+ props: {
149
+ flex: '1',
150
+ overflow: 'auto hidden',
151
+ '::-webkit-scrollbar': { display: 'none' }
77
152
  },
78
- right: {
79
- extend: SquareButton,
80
- props: {
81
- ...buttonProps,
82
- round: 'C',
83
- icon: 'arrowAngleRight'
153
+
154
+ childExtend: {
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
+ }
84
174
  }
175
+ },
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' }
191
+ ]
85
192
  }
86
193
  },
87
- days: {
194
+
195
+ rightButton: { extend: Button, props: { icon: 'arrowRight' } }
196
+ }
197
+
198
+ export const DatePickerWeekDays = {
199
+ extend: Grid,
200
+ props: {
201
+ overflow: 'hidden',
202
+ padding: '- Z Z',
203
+ width: '100%',
204
+ columns: 'repeat(7, 1fr)',
205
+ gap: 'W2'
206
+ },
207
+ childExtend: {
208
+ tag: 'span',
88
209
  extend: Flex,
89
210
  props: {
90
- flow: 'column',
91
- gap: 'X2'
92
- },
93
- childExtend: {
94
- extend: Grid,
95
- props: {
96
- columns: 'repeat(7, 1fr)',
97
- gap: 'X2'
211
+ fontSize: 'Y1',
212
+ textTransform: 'capitalize',
213
+ align: 'center center',
214
+ ':nth-child(7n-1), &:nth-child(7n)': { opacity: '.5' },
215
+ }
216
+ },
217
+ ...[
218
+ { text: 'Mo' },
219
+ { text: 'Tu' },
220
+ { text: 'We' },
221
+ { text: 'Th' },
222
+ { text: 'Fr' },
223
+ { text: 'Sa' },
224
+ { text: 'Su' }
225
+ ]
226
+ }
227
+
228
+ export const DatePickerGrid = {
229
+ extend: Grid,
230
+ props: {
231
+ columns: 'repeat(7, 1fr)',
232
+ minWidth: '100%',
233
+ gap: 'W2',
234
+ padding: `- Z`
235
+ },
236
+ childExtend: {
237
+ extend: Button,
238
+ props: ({ state, key }) => ({
239
+ isActive: state.activeDay === parseInt(key) + 1,
240
+ textAlign: 'center',
241
+ fontSize: 'Z1',
242
+ round: '100%',
243
+ height: 'B1',
244
+ aspectRatio: '1/1',
245
+ lineHeight: '.9',
246
+ background: 'transparent',
247
+ theme: 'secondary @dark .color',
248
+ '.isActive': { theme: 'primary' },
249
+ '!isActive': {
250
+ ':hover': { theme: 'secondary' },
251
+ ':nth-child(7n-1), &:nth-child(7n)': { opacity: '.5' },
252
+ },
253
+ }),
254
+ on: {
255
+ click: (event, element, state) => {
256
+ state.update({ activeDay: element.text })
257
+ console.log(state.activeDay + '.' + state.activeMonth + '.' + state.activeYear)
98
258
  }
259
+ }
260
+ },
261
+ $setPropsCollection: (el, s) => {
262
+ const daysInMonth = new Date(s.activeYear, s.activeMonth, 0).getDate()
263
+ const days = (new Array(daysInMonth)).fill(undefined)
264
+ .map((v, k) => ({ text: k + 1 }))
265
+ return days
266
+ }
267
+ }
268
+
269
+ const monthNumbersContainer = {
270
+ props: {
271
+ maxWidth: `${272 / 16}em`,
272
+ position: 'relative',
273
+ ':before': {
274
+ content: '""',
275
+ position: 'absolute',
276
+ boxSize: '100% 12px',
277
+ background: 'linear-gradient(to right, var(--theme-tertiary-dark-background) 0%, transparent 100%)',
278
+ left: '0',
279
+ top: '0',
280
+ zIndex: '30'
99
281
  },
100
- weekDays: {
101
- childExtend: {
102
- extend: Button,
103
- props: {
104
- ...buttonProps,
105
- fontSize: 'Z1',
106
- padding: 'X2'
107
- }
108
- },
109
- ...[
110
- { text: 'Mo' },
111
- { text: 'Tu' },
112
- { text: 'We' },
113
- { text: 'Th' },
114
- { text: 'Fr' },
115
- { text: 'Sa' },
116
- { text: 'Su' }
117
- ]
282
+ ':after': {
283
+ content: '""',
284
+ position: 'absolute',
285
+ boxSize: '100% 12px',
286
+ background: 'linear-gradient(to left, var(--theme-tertiary-dark-background) 0%, transparent 100%)',
287
+ right: '0',
288
+ top: '0',
289
+ zIndex: '30'
118
290
  },
291
+ content: {
292
+ overflow: 'auto hidden'
293
+ }
294
+ },
119
295
 
120
- cnt: {
121
- childExtend: {
122
- extend: SquareButton,
123
-
124
- props: ({ key, state }) => ({
125
- ...buttonProps,
126
- theme: 'quaternary',
127
- active: key === '18',
128
- '.active': {
129
- theme: 'quinary'
130
- }
131
- })
132
- },
296
+ content: {
297
+ extend: Flex,
298
+ childExtend: DatePickerGrid,
299
+ ...[{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}]
300
+ }
301
+ }
133
302
 
134
- ...new Array(31).fill(undefined).map((_, i) => ({ text: i + 1 }))
303
+ const props = {
304
+ yearRange: [1993, 2023],
305
+ theme: 'tertiary',
306
+ round: 'Z2',
307
+ margin: 'E',
308
+ overflow: 'hidden',
309
+ maxHeight: '318px',
310
+ boxSize: 'fit-content fit-content',
311
+ padding: '- Z - -',
312
+ style: {
313
+ button: {
314
+ padding: '0'
135
315
  }
136
316
  }
137
317
  }
138
318
 
139
319
  export const DatePicker = {
140
- style,
141
320
  extend: Flex,
142
-
143
- props: {
144
- position: 'relative',
145
- theme: 'quaternary',
146
- transition: 'A all',
147
- round: 'Z',
148
- padding: 'Z Z2 Z X2',
149
- gap: 'X2',
150
- depth: 16,
151
- minHeight: '0',
152
- align: 'stretch center'
321
+ state: {
322
+ activeYear: 1993,
323
+ activeMonth: 8,
324
+ activeDay: 14
153
325
  },
154
326
 
155
- aside,
156
- main
327
+ props,
328
+
329
+ DatePickerYears: {},
330
+
331
+ Flex: {
332
+ props: {
333
+ flow: 'column',
334
+ padding: '20px - - -',
335
+ position: 'relative',
336
+ },
337
+
338
+ DatePickerMonthsSlider: {},
339
+
340
+ DatePickerWeekDays: {},
341
+
342
+ monthNumbersContainer,
343
+
344
+ DialogFooter: {}
345
+ }
346
+ }
347
+
348
+ export const DatePickerTwoColumns = {
349
+ extend: DatePicker,
350
+ props: {
351
+ calendar: {
352
+ months: {
353
+ maxWidth: `${544 / 16}em`
354
+ },
355
+ weekDaysContainer: {
356
+ maxWidth: `${544 / 16}em`
357
+ },
358
+ monthNumbersContainer: {
359
+ maxWidth: `${544 / 16}em`
360
+ }
361
+ }
362
+ }
157
363
  }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@symbo.ls/datepicker",
3
- "version": "2.11.29",
3
+ "version": "2.11.49",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
- "gitHead": "cb520b92aca9016f8c18fcbd79dd6199cbb9353a",
6
+ "gitHead": "396ff036bf106d7813a1688d842d7a36d407cf31",
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
- }