@symbo.ls/datepicker 2.11.55 → 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,285 +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
- leftButton: {
160
- extend: Button,
161
- props: { icon: 'arrowLeft' }
162
- },
163
-
164
- Flex: {
165
- props: {
166
- flex: '1',
167
- overflow: 'auto hidden',
168
- '::-webkit-scrollbar': { display: 'none' }
169
- },
170
-
171
- childExtend: {
172
- tag: 'h6',
173
- props: ({ state, key }) => ({
174
- fontSize: 'Z1',
175
- textAlign: 'center',
176
- boxSizing: 'content-box',
177
- minWidth: '272px',
178
-
179
- isSelected: state.activeMonth === parseInt(key),
180
- '.isSelected': { opacity: '1' }
181
- }),
182
-
183
- render: (el, state) => {
184
- const { props } = el
185
- const { isSelected } = props
186
- if (isSelected) {
187
- window.requestAnimationFrame(() => {
188
- el.parent.parent.node.scrollLeft = el.node.offsetLeft
189
- })
190
- }
191
- }
192
- },
193
-
194
- $setCollection: ({ state, parent }) => {
195
- return [
196
- { text: 'January' },
197
- { text: 'February' },
198
- { text: 'March' },
199
- { text: 'April' },
200
- { text: 'May' },
201
- { text: 'June' },
202
- { text: 'July' },
203
- { text: 'August' },
204
- { text: 'September' },
205
- { text: 'October' },
206
- { text: 'November' },
207
- { text: 'December' }
208
- ]
209
- }
210
- },
211
-
212
- rightButton: { extend: Button, props: { icon: 'arrowRight' } }
213
- }
214
-
215
- export const DatePickerWeekDays = {
216
- extend: Grid,
217
- props: {
218
- overflow: 'hidden',
219
- padding: '- Z Z',
220
- width: '100%',
221
- columns: 'repeat(7, 1fr)',
222
- gap: 'W2'
223
- },
224
- childExtend: {
225
- tag: 'span',
226
- extend: Flex,
227
- props: {
228
- fontSize: 'Y1',
229
- textTransform: 'capitalize',
230
- align: 'center center',
231
- ':nth-child(7n-1), &:nth-child(7n)': { opacity: '.5' }
232
- }
233
- },
234
- ...[
235
- { text: 'Mo' },
236
- { text: 'Tu' },
237
- { text: 'We' },
238
- { text: 'Th' },
239
- { text: 'Fr' },
240
- { text: 'Sa' },
241
- { text: 'Su' }
242
- ]
243
- }
244
-
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,
255
- textAlign: 'center',
256
- fontSize: 'Z1',
257
- round: '100%',
258
- height: 'B1',
259
- aspectRatio: '1/1',
260
- lineHeight: '.9',
261
- background: 'transparent',
262
- theme: 'secondary @dark .color',
263
- text: parseInt(key) + 1,
264
- ':first-child': {
265
- style: { gridColumnStart }
266
- },
267
- '.isSelected': { theme: 'primary' },
268
- '!isSelected': {
269
- ':hover': { theme: 'secondary' },
270
- ':nth-child(7n-1), &:nth-child(7n)': { opacity: '.5' }
271
- }
272
- }
273
- },
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
299
- }
300
- }
301
-
302
24
  const monthNumbersContainer = {
303
25
  props: {
304
26
  maxWidth: `${272 / 16}em`,
@@ -350,7 +72,7 @@ const monthNumbersContainer = {
350
72
 
351
73
  const props = {
352
74
  yearRange: [1993, 2023],
353
- maxHeight: '318px',
75
+ maxHeight: 'G+B',
354
76
  boxSize: 'fit-content fit-content',
355
77
  style: {
356
78
  button: {
@@ -390,15 +112,27 @@ export const DatePicker = {
390
112
 
391
113
  export const DatePickerTwoColumns = {
392
114
  extend: DatePicker,
115
+ DatePickerYears: {},
393
116
  Flex: {
394
117
  DatePickerMonthsSlider: {
395
- maxWidth: `${544 / 16}em`
118
+ props: {
119
+ maxWidth: `${544 / 16}em`
120
+ }
396
121
  },
397
122
  DatePickerWeekDays: {
398
- maxWidth: `${544 / 16}em`
123
+ props: {
124
+ maxWidth: `${544 / 16}em`
125
+ }
399
126
  },
400
127
  monthNumbersContainer: {
401
- maxWidth: `${544 / 16}em`
128
+ props: {
129
+ maxWidth: `${544 / 16}em`
130
+ }
402
131
  }
403
132
  }
404
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.55",
3
+ "version": "2.11.76",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
- "gitHead": "f4a6af272593be22cbf1337ddb25afec00ba359d",
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
+ }