@krollins/blueprint 0.1.12 → 0.1.13
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/dist/components/accordion.js +393 -0
- package/dist/components/accordion.js.map +1 -0
- package/dist/components/alert.js +213 -0
- package/dist/components/alert.js.map +1 -0
- package/dist/components/avatar.js +237 -0
- package/dist/components/avatar.js.map +1 -0
- package/dist/components/badge.js +144 -0
- package/dist/components/badge.js.map +1 -0
- package/dist/components/breadcrumb.js +481 -0
- package/dist/components/breadcrumb.js.map +1 -0
- package/dist/components/button.js +192 -0
- package/dist/components/button.js.map +1 -0
- package/dist/components/card.js +223 -0
- package/dist/components/card.js.map +1 -0
- package/dist/components/checkbox.js +337 -0
- package/dist/components/checkbox.js.map +1 -0
- package/dist/components/color-picker.js +1660 -0
- package/dist/components/color-picker.js.map +1 -0
- package/dist/components/combobox.js +595 -0
- package/dist/components/combobox.js.map +1 -0
- package/dist/components/date-picker.js +726 -0
- package/dist/components/date-picker.js.map +1 -0
- package/dist/components/divider.js +214 -0
- package/dist/components/divider.js.map +1 -0
- package/dist/components/drawer.js +568 -0
- package/dist/components/drawer.js.map +1 -0
- package/dist/components/dropdown.js +377 -0
- package/dist/components/dropdown.js.map +1 -0
- package/dist/components/file-upload.js +669 -0
- package/dist/components/file-upload.js.map +1 -0
- package/dist/components/heading.js +161 -0
- package/dist/components/heading.js.map +1 -0
- package/dist/components/icon.js +599 -0
- package/dist/components/icon.js.map +1 -0
- package/dist/components/input.js +363 -0
- package/dist/components/input.js.map +1 -0
- package/dist/components/link.js +178 -0
- package/dist/components/link.js.map +1 -0
- package/dist/components/menu.js +331 -0
- package/dist/components/menu.js.map +1 -0
- package/dist/components/modal.js +317 -0
- package/dist/components/modal.js.map +1 -0
- package/dist/components/multi-select.js +642 -0
- package/dist/components/multi-select.js.map +1 -0
- package/dist/components/notification.js +429 -0
- package/dist/components/notification.js.map +1 -0
- package/dist/components/number-input.js +556 -0
- package/dist/components/number-input.js.map +1 -0
- package/dist/components/pagination.js +320 -0
- package/dist/components/pagination.js.map +1 -0
- package/dist/components/popover.js +597 -0
- package/dist/components/popover.js.map +1 -0
- package/dist/components/progress.js +219 -0
- package/dist/components/progress.js.map +1 -0
- package/dist/components/radio.js +321 -0
- package/dist/components/radio.js.map +1 -0
- package/dist/components/select.js +498 -0
- package/dist/components/select.js.map +1 -0
- package/dist/components/skeleton.js +240 -0
- package/dist/components/skeleton.js.map +1 -0
- package/dist/components/slider.js +9 -0
- package/dist/components/slider.js.map +1 -0
- package/dist/components/spinner.js +133 -0
- package/dist/components/spinner.js.map +1 -0
- package/dist/components/stepper.js +812 -0
- package/dist/components/stepper.js.map +1 -0
- package/dist/components/switch.js +380 -0
- package/dist/components/switch.js.map +1 -0
- package/dist/components/table.js +642 -0
- package/dist/components/table.js.map +1 -0
- package/dist/components/tabs.js +547 -0
- package/dist/components/tabs.js.map +1 -0
- package/dist/components/tag.js +291 -0
- package/dist/components/tag.js.map +1 -0
- package/dist/components/text.js +278 -0
- package/dist/components/text.js.map +1 -0
- package/dist/components/textarea.js +380 -0
- package/dist/components/textarea.js.map +1 -0
- package/dist/components/time-picker.js +457 -0
- package/dist/components/time-picker.js.map +1 -0
- package/dist/components/tooltip.js +239 -0
- package/dist/components/tooltip.js.map +1 -0
- package/dist/components/tree.js +582 -0
- package/dist/components/tree.js.map +1 -0
- package/dist/index.js +93 -17799
- package/dist/index.js.map +1 -1
- package/dist/shared/boolean-converter-XDGfS9LC.js +12 -0
- package/dist/shared/boolean-converter-XDGfS9LC.js.map +1 -0
- package/dist/shared/debounce-BckY30Sf.js +23 -0
- package/dist/shared/debounce-BckY30Sf.js.map +1 -0
- package/dist/shared/memoize-DlOFy-92.js +16 -0
- package/dist/shared/memoize-DlOFy-92.js.map +1 -0
- package/dist/shared/slider-BNt5TITl.js +484 -0
- package/dist/shared/slider-BNt5TITl.js.map +1 -0
- package/package.json +44 -2
|
@@ -0,0 +1,726 @@
|
|
|
1
|
+
import { css as f, LitElement as k, html as l } from "lit";
|
|
2
|
+
import { property as c, state as b, customElement as m } from "lit/decorators.js";
|
|
3
|
+
import { classMap as g } from "lit/directives/class-map.js";
|
|
4
|
+
const _ = f`
|
|
5
|
+
/* Base */
|
|
6
|
+
.date-picker {
|
|
7
|
+
position: relative;
|
|
8
|
+
width: 100%;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.date-picker__input-wrapper {
|
|
12
|
+
position: relative;
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.date-picker__input {
|
|
18
|
+
flex: 1;
|
|
19
|
+
padding: var(--bp-spacing-sm) var(--bp-spacing-md);
|
|
20
|
+
padding-right: var(--bp-spacing-2xl);
|
|
21
|
+
font-family: var(--bp-font-family);
|
|
22
|
+
font-size: var(--bp-font-size-base);
|
|
23
|
+
color: var(--bp-color-text);
|
|
24
|
+
background-color: var(--bp-color-surface);
|
|
25
|
+
border: var(--bp-border-width) solid var(--bp-color-border);
|
|
26
|
+
border-radius: var(--bp-border-radius-md);
|
|
27
|
+
cursor: pointer;
|
|
28
|
+
transition:
|
|
29
|
+
border-color var(--bp-transition-fast),
|
|
30
|
+
box-shadow var(--bp-transition-fast);
|
|
31
|
+
outline: none;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.date-picker__input:hover:not(:disabled) {
|
|
35
|
+
border-color: var(--bp-color-primary);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.date-picker__input:focus {
|
|
39
|
+
border-color: var(--bp-color-focus);
|
|
40
|
+
box-shadow: 0 0 0 var(--bp-focus-width) var(--bp-color-focus);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.date-picker__input:disabled {
|
|
44
|
+
opacity: 0.5;
|
|
45
|
+
cursor: not-allowed;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.date-picker__input::placeholder {
|
|
49
|
+
color: var(--bp-color-text-muted);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.date-picker__clear {
|
|
53
|
+
position: absolute;
|
|
54
|
+
right: var(--bp-spacing-2xl);
|
|
55
|
+
display: flex;
|
|
56
|
+
align-items: center;
|
|
57
|
+
justify-content: center;
|
|
58
|
+
width: var(--bp-spacing-lg);
|
|
59
|
+
height: var(--bp-spacing-lg);
|
|
60
|
+
padding: 0;
|
|
61
|
+
font-size: var(--bp-font-size-sm);
|
|
62
|
+
color: var(--bp-color-text-muted);
|
|
63
|
+
background: none;
|
|
64
|
+
border: none;
|
|
65
|
+
border-radius: var(--bp-border-radius-sm);
|
|
66
|
+
cursor: pointer;
|
|
67
|
+
transition:
|
|
68
|
+
color var(--bp-transition-fast),
|
|
69
|
+
background-color var(--bp-transition-fast);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.date-picker__clear:hover {
|
|
73
|
+
color: var(--bp-color-primary);
|
|
74
|
+
background-color: color-mix(
|
|
75
|
+
in srgb,
|
|
76
|
+
var(--bp-color-primary) 8%,
|
|
77
|
+
transparent
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.date-picker__indicator {
|
|
82
|
+
position: absolute;
|
|
83
|
+
right: var(--bp-spacing-md);
|
|
84
|
+
display: flex;
|
|
85
|
+
align-items: center;
|
|
86
|
+
justify-content: center;
|
|
87
|
+
width: var(--bp-spacing-lg);
|
|
88
|
+
height: var(--bp-spacing-lg);
|
|
89
|
+
color: var(--bp-color-text-muted);
|
|
90
|
+
pointer-events: none;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* Calendar */
|
|
94
|
+
.date-picker__calendar {
|
|
95
|
+
position: absolute;
|
|
96
|
+
top: calc(100% + var(--bp-spacing-xs));
|
|
97
|
+
left: 0;
|
|
98
|
+
z-index: var(--bp-z-dropdown);
|
|
99
|
+
min-width: var(--bp-spacing-2xl);
|
|
100
|
+
padding: var(--bp-spacing-md);
|
|
101
|
+
background-color: var(--bp-color-surface);
|
|
102
|
+
border-top: calc(var(--bp-border-width) * 2) solid var(--bp-color-primary);
|
|
103
|
+
border-right: var(--bp-border-width) solid var(--bp-color-border);
|
|
104
|
+
border-bottom: var(--bp-border-width) solid var(--bp-color-border);
|
|
105
|
+
border-left: var(--bp-border-width) solid var(--bp-color-border);
|
|
106
|
+
border-radius: var(--bp-border-radius-md);
|
|
107
|
+
box-shadow: var(--bp-shadow-md);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/* Header */
|
|
111
|
+
.date-picker__header {
|
|
112
|
+
display: flex;
|
|
113
|
+
align-items: center;
|
|
114
|
+
justify-content: space-between;
|
|
115
|
+
margin-bottom: var(--bp-spacing-sm);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.date-picker__nav-button {
|
|
119
|
+
display: flex;
|
|
120
|
+
align-items: center;
|
|
121
|
+
justify-content: center;
|
|
122
|
+
width: var(--bp-spacing-xl);
|
|
123
|
+
height: var(--bp-spacing-xl);
|
|
124
|
+
padding: 0;
|
|
125
|
+
font-size: var(--bp-font-size-xl);
|
|
126
|
+
color: var(--bp-color-text);
|
|
127
|
+
background: none;
|
|
128
|
+
border: none;
|
|
129
|
+
border-radius: var(--bp-border-radius-sm);
|
|
130
|
+
cursor: pointer;
|
|
131
|
+
transition: background-color var(--bp-transition-fast);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.date-picker__nav-button:hover {
|
|
135
|
+
background-color: color-mix(
|
|
136
|
+
in srgb,
|
|
137
|
+
var(--bp-color-primary) 8%,
|
|
138
|
+
transparent
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.date-picker__month-year {
|
|
143
|
+
flex: 1;
|
|
144
|
+
font-size: var(--bp-font-size-base);
|
|
145
|
+
font-weight: var(--bp-font-weight-semibold);
|
|
146
|
+
color: var(--bp-color-text);
|
|
147
|
+
text-align: center;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/* Weekdays */
|
|
151
|
+
.date-picker__weekdays {
|
|
152
|
+
display: grid;
|
|
153
|
+
grid-template-columns: repeat(7, 1fr);
|
|
154
|
+
gap: var(--bp-spacing-xs);
|
|
155
|
+
margin-bottom: var(--bp-spacing-xs);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.date-picker__weekday {
|
|
159
|
+
padding: var(--bp-spacing-xs);
|
|
160
|
+
font-size: var(--bp-font-size-xs);
|
|
161
|
+
font-weight: var(--bp-font-weight-semibold);
|
|
162
|
+
color: var(--bp-color-text-muted);
|
|
163
|
+
text-align: center;
|
|
164
|
+
text-transform: uppercase;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/* Days */
|
|
168
|
+
.date-picker__days {
|
|
169
|
+
display: grid;
|
|
170
|
+
grid-template-columns: repeat(7, 1fr);
|
|
171
|
+
gap: var(--bp-spacing-xs);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.date-picker__day {
|
|
175
|
+
aspect-ratio: 1;
|
|
176
|
+
padding: var(--bp-spacing-xs);
|
|
177
|
+
font-size: var(--bp-font-size-sm);
|
|
178
|
+
color: var(--bp-color-text);
|
|
179
|
+
background: none;
|
|
180
|
+
border: none;
|
|
181
|
+
border-radius: var(--bp-border-radius-sm);
|
|
182
|
+
cursor: pointer;
|
|
183
|
+
transition:
|
|
184
|
+
background-color var(--bp-transition-fast),
|
|
185
|
+
color var(--bp-transition-fast);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.date-picker__day:hover:not(:disabled) {
|
|
189
|
+
background-color: color-mix(
|
|
190
|
+
in srgb,
|
|
191
|
+
var(--bp-color-primary) 8%,
|
|
192
|
+
transparent
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.date-picker__day--other-month {
|
|
197
|
+
color: var(--bp-color-text-muted);
|
|
198
|
+
opacity: 0.5;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.date-picker__day--today {
|
|
202
|
+
font-weight: var(--bp-font-weight-bold);
|
|
203
|
+
color: var(--bp-color-primary);
|
|
204
|
+
background-color: color-mix(
|
|
205
|
+
in srgb,
|
|
206
|
+
var(--bp-color-primary) 4%,
|
|
207
|
+
transparent
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.date-picker__day--selected {
|
|
212
|
+
color: var(--bp-color-text-inverse);
|
|
213
|
+
background-color: var(--bp-color-primary);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.date-picker__day--selected:hover:not(:disabled) {
|
|
217
|
+
background-color: var(--bp-color-primary-hover);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.date-picker__day--focused {
|
|
221
|
+
outline: var(--bp-focus-width) solid var(--bp-color-primary);
|
|
222
|
+
outline-offset: calc(-1 * var(--bp-focus-width));
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.date-picker__day--disabled {
|
|
226
|
+
color: var(--bp-color-text-muted);
|
|
227
|
+
opacity: 0.5;
|
|
228
|
+
cursor: not-allowed;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/* Sizes */
|
|
232
|
+
.date-picker--sm .date-picker__input {
|
|
233
|
+
padding: var(--bp-spacing-xs) var(--bp-spacing-sm);
|
|
234
|
+
padding-right: var(--bp-spacing-xl);
|
|
235
|
+
font-size: var(--bp-font-size-sm);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.date-picker--sm .date-picker__indicator {
|
|
239
|
+
right: var(--bp-spacing-xs);
|
|
240
|
+
width: var(--bp-spacing-md);
|
|
241
|
+
height: var(--bp-spacing-md);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.date-picker--sm .date-picker__clear {
|
|
245
|
+
right: var(--bp-spacing-xl);
|
|
246
|
+
width: var(--bp-spacing-md);
|
|
247
|
+
height: var(--bp-spacing-md);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.date-picker--sm .date-picker__calendar {
|
|
251
|
+
padding: var(--bp-spacing-sm);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
.date-picker--sm .date-picker__nav-button {
|
|
255
|
+
width: var(--bp-spacing-lg);
|
|
256
|
+
height: var(--bp-spacing-lg);
|
|
257
|
+
font-size: var(--bp-font-size-lg);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.date-picker--sm .date-picker__month-year {
|
|
261
|
+
font-size: var(--bp-font-size-sm);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.date-picker--sm .date-picker__header {
|
|
265
|
+
margin-bottom: var(--bp-spacing-xs);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.date-picker--sm .date-picker__weekdays {
|
|
269
|
+
gap: var(--bp-spacing-2xs);
|
|
270
|
+
margin-bottom: var(--bp-spacing-2xs);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
.date-picker--sm .date-picker__weekday {
|
|
274
|
+
padding: var(--bp-spacing-2xs);
|
|
275
|
+
font-size: var(--bp-font-size-xs);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
.date-picker--sm .date-picker__days {
|
|
279
|
+
gap: var(--bp-spacing-2xs);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.date-picker--sm .date-picker__day {
|
|
283
|
+
padding: var(--bp-spacing-2xs);
|
|
284
|
+
font-size: var(--bp-font-size-xs);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
.date-picker--lg .date-picker__input {
|
|
288
|
+
padding: var(--bp-spacing-md) var(--bp-spacing-lg);
|
|
289
|
+
padding-right: var(--bp-spacing-24);
|
|
290
|
+
font-size: var(--bp-font-size-lg);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
.date-picker--lg .date-picker__indicator {
|
|
294
|
+
right: var(--bp-spacing-md);
|
|
295
|
+
width: var(--bp-spacing-xl);
|
|
296
|
+
height: var(--bp-spacing-xl);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
.date-picker--lg .date-picker__clear {
|
|
300
|
+
right: var(--bp-spacing-24);
|
|
301
|
+
width: var(--bp-spacing-xl);
|
|
302
|
+
height: var(--bp-spacing-xl);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
.date-picker--lg .date-picker__calendar {
|
|
306
|
+
padding: var(--bp-spacing-lg);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
.date-picker--lg .date-picker__nav-button {
|
|
310
|
+
width: var(--bp-spacing-2xl);
|
|
311
|
+
height: var(--bp-spacing-2xl);
|
|
312
|
+
font-size: var(--bp-font-size-2xl);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
.date-picker--lg .date-picker__month-year {
|
|
316
|
+
font-size: var(--bp-font-size-lg);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
.date-picker--lg .date-picker__header {
|
|
320
|
+
margin-bottom: var(--bp-spacing-md);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
.date-picker--lg .date-picker__weekdays {
|
|
324
|
+
gap: var(--bp-spacing-sm);
|
|
325
|
+
margin-bottom: var(--bp-spacing-sm);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
.date-picker--lg .date-picker__weekday {
|
|
329
|
+
padding: var(--bp-spacing-sm);
|
|
330
|
+
font-size: var(--bp-font-size-sm);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
.date-picker--lg .date-picker__days {
|
|
334
|
+
gap: var(--bp-spacing-sm);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
.date-picker--lg .date-picker__day {
|
|
338
|
+
padding: var(--bp-spacing-sm);
|
|
339
|
+
font-size: var(--bp-font-size-base);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/* States */
|
|
343
|
+
.date-picker--disabled {
|
|
344
|
+
opacity: 0.6;
|
|
345
|
+
pointer-events: none;
|
|
346
|
+
}
|
|
347
|
+
`;
|
|
348
|
+
var D = Object.defineProperty, w = Object.getOwnPropertyDescriptor, o = (e, t, a, d) => {
|
|
349
|
+
for (var s = d > 1 ? void 0 : d ? w(t, a) : t, n = e.length - 1, r; n >= 0; n--)
|
|
350
|
+
(r = e[n]) && (s = (d ? r(t, a, s) : r(s)) || s);
|
|
351
|
+
return d && s && D(t, a, s), s;
|
|
352
|
+
};
|
|
353
|
+
let i = class extends k {
|
|
354
|
+
constructor() {
|
|
355
|
+
super(), this.isOpen = !1, this.displayMonth = (/* @__PURE__ */ new Date()).getMonth(), this.displayYear = (/* @__PURE__ */ new Date()).getFullYear(), this.focusedDate = null, this.value = "", this.name = "", this.label = "", this.placeholder = "Select date...", this.disabled = !1, this.required = !1, this.size = "md", this.min = "", this.max = "", this.firstDayOfWeek = "0";
|
|
356
|
+
}
|
|
357
|
+
handleInputClick() {
|
|
358
|
+
this.disabled || (this.isOpen = !this.isOpen);
|
|
359
|
+
}
|
|
360
|
+
handlePreviousMonth() {
|
|
361
|
+
this.displayMonth === 0 ? (this.displayMonth = 11, this.displayYear--) : this.displayMonth--;
|
|
362
|
+
}
|
|
363
|
+
handleNextMonth() {
|
|
364
|
+
this.displayMonth === 11 ? (this.displayMonth = 0, this.displayYear++) : this.displayMonth++;
|
|
365
|
+
}
|
|
366
|
+
handleDateSelect(e) {
|
|
367
|
+
const t = this.value;
|
|
368
|
+
this.value = this.formatDate(e), this.isOpen = !1, this.focusedDate = null, this.dispatchEvent(
|
|
369
|
+
new CustomEvent("bp-change", {
|
|
370
|
+
detail: {
|
|
371
|
+
value: this.value,
|
|
372
|
+
previousValue: t,
|
|
373
|
+
date: e
|
|
374
|
+
},
|
|
375
|
+
bubbles: !0,
|
|
376
|
+
composed: !0
|
|
377
|
+
})
|
|
378
|
+
);
|
|
379
|
+
}
|
|
380
|
+
handleClear(e) {
|
|
381
|
+
e.stopPropagation();
|
|
382
|
+
const t = this.value;
|
|
383
|
+
this.value = "", this.focusedDate = null, this.dispatchEvent(
|
|
384
|
+
new CustomEvent("bp-change", {
|
|
385
|
+
detail: {
|
|
386
|
+
value: "",
|
|
387
|
+
previousValue: t,
|
|
388
|
+
date: null
|
|
389
|
+
},
|
|
390
|
+
bubbles: !0,
|
|
391
|
+
composed: !0
|
|
392
|
+
})
|
|
393
|
+
);
|
|
394
|
+
}
|
|
395
|
+
handleKeyDown(e) {
|
|
396
|
+
const t = e;
|
|
397
|
+
if (!this.isOpen) {
|
|
398
|
+
(t.key === "ArrowDown" || t.key === "Enter" || t.key === " ") && (t.preventDefault(), this.isOpen = !0, this.focusedDate = this.getSelectedDate() || this.getTodayDate());
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
const a = this.focusedDate || this.getSelectedDate() || this.getTodayDate();
|
|
402
|
+
switch (t.key) {
|
|
403
|
+
case "Escape":
|
|
404
|
+
t.preventDefault(), this.isOpen = !1, this.focusedDate = null;
|
|
405
|
+
break;
|
|
406
|
+
case "ArrowLeft":
|
|
407
|
+
t.preventDefault(), this.focusedDate = this.addDays(a, -1), this.updateDisplayMonth(this.focusedDate);
|
|
408
|
+
break;
|
|
409
|
+
case "ArrowRight":
|
|
410
|
+
t.preventDefault(), this.focusedDate = this.addDays(a, 1), this.updateDisplayMonth(this.focusedDate);
|
|
411
|
+
break;
|
|
412
|
+
case "ArrowUp":
|
|
413
|
+
t.preventDefault(), this.focusedDate = this.addDays(a, -7), this.updateDisplayMonth(this.focusedDate);
|
|
414
|
+
break;
|
|
415
|
+
case "ArrowDown":
|
|
416
|
+
t.preventDefault(), this.focusedDate = this.addDays(a, 7), this.updateDisplayMonth(this.focusedDate);
|
|
417
|
+
break;
|
|
418
|
+
case "Home":
|
|
419
|
+
t.preventDefault(), this.focusedDate = new Date(
|
|
420
|
+
a.getFullYear(),
|
|
421
|
+
a.getMonth(),
|
|
422
|
+
1
|
|
423
|
+
);
|
|
424
|
+
break;
|
|
425
|
+
case "End":
|
|
426
|
+
t.preventDefault(), this.focusedDate = new Date(
|
|
427
|
+
a.getFullYear(),
|
|
428
|
+
a.getMonth() + 1,
|
|
429
|
+
0
|
|
430
|
+
);
|
|
431
|
+
break;
|
|
432
|
+
case "PageUp":
|
|
433
|
+
t.preventDefault(), this.focusedDate = this.addMonths(
|
|
434
|
+
a,
|
|
435
|
+
t.shiftKey ? -12 : -1
|
|
436
|
+
), this.updateDisplayMonth(this.focusedDate);
|
|
437
|
+
break;
|
|
438
|
+
case "PageDown":
|
|
439
|
+
t.preventDefault(), this.focusedDate = this.addMonths(
|
|
440
|
+
a,
|
|
441
|
+
t.shiftKey ? 12 : 1
|
|
442
|
+
), this.updateDisplayMonth(this.focusedDate);
|
|
443
|
+
break;
|
|
444
|
+
case "Enter":
|
|
445
|
+
case " ":
|
|
446
|
+
t.preventDefault(), this.focusedDate && !this.isDateDisabled(this.focusedDate) && this.handleDateSelect(this.focusedDate);
|
|
447
|
+
break;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
updateDisplayMonth(e) {
|
|
451
|
+
this.displayMonth = e.getMonth(), this.displayYear = e.getFullYear();
|
|
452
|
+
}
|
|
453
|
+
addDays(e, t) {
|
|
454
|
+
const a = new Date(e);
|
|
455
|
+
return a.setDate(a.getDate() + t), a;
|
|
456
|
+
}
|
|
457
|
+
addMonths(e, t) {
|
|
458
|
+
const a = new Date(e);
|
|
459
|
+
return a.setMonth(a.getMonth() + t), a;
|
|
460
|
+
}
|
|
461
|
+
formatDate(e) {
|
|
462
|
+
const t = e.getFullYear(), a = String(e.getMonth() + 1).padStart(2, "0"), d = String(e.getDate()).padStart(2, "0");
|
|
463
|
+
return `${t}-${a}-${d}`;
|
|
464
|
+
}
|
|
465
|
+
parseDate(e) {
|
|
466
|
+
if (!e) return null;
|
|
467
|
+
const t = e.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
468
|
+
if (t) {
|
|
469
|
+
const [, d, s, n] = t, r = new Date(
|
|
470
|
+
parseInt(d, 10),
|
|
471
|
+
parseInt(s, 10) - 1,
|
|
472
|
+
parseInt(n, 10)
|
|
473
|
+
);
|
|
474
|
+
return r.setHours(0, 0, 0, 0), r;
|
|
475
|
+
}
|
|
476
|
+
const a = new Date(e);
|
|
477
|
+
return isNaN(a.getTime()) ? (console.warn(
|
|
478
|
+
`bp-date-picker: Invalid date format "${e}". Expected YYYY-MM-DD.`
|
|
479
|
+
), null) : a;
|
|
480
|
+
}
|
|
481
|
+
getSelectedDate() {
|
|
482
|
+
return this.parseDate(this.value);
|
|
483
|
+
}
|
|
484
|
+
getTodayDate() {
|
|
485
|
+
const e = /* @__PURE__ */ new Date();
|
|
486
|
+
return e.setHours(0, 0, 0, 0), e;
|
|
487
|
+
}
|
|
488
|
+
isSameDay(e, t) {
|
|
489
|
+
return e.getFullYear() === t.getFullYear() && e.getMonth() === t.getMonth() && e.getDate() === t.getDate();
|
|
490
|
+
}
|
|
491
|
+
isDateDisabled(e) {
|
|
492
|
+
if (this.min) {
|
|
493
|
+
const t = this.parseDate(this.min);
|
|
494
|
+
if (t && e < t) return !0;
|
|
495
|
+
}
|
|
496
|
+
if (this.max) {
|
|
497
|
+
const t = this.parseDate(this.max);
|
|
498
|
+
if (t && e > t) return !0;
|
|
499
|
+
}
|
|
500
|
+
return !1;
|
|
501
|
+
}
|
|
502
|
+
getCalendarDays() {
|
|
503
|
+
const t = new Date(this.displayYear, this.displayMonth, 1), a = new Date(this.displayYear, this.displayMonth + 1, 0), d = this.firstDayOfWeek === "1" ? 1 : 0;
|
|
504
|
+
let s = t.getDay() - d;
|
|
505
|
+
s < 0 && (s += 7);
|
|
506
|
+
const n = [];
|
|
507
|
+
for (let p = s - 1; p >= 0; p--) {
|
|
508
|
+
const h = new Date(this.displayYear, this.displayMonth, -p);
|
|
509
|
+
n.push(h);
|
|
510
|
+
}
|
|
511
|
+
for (let p = 1; p <= a.getDate(); p++)
|
|
512
|
+
n.push(new Date(this.displayYear, this.displayMonth, p));
|
|
513
|
+
const r = 42 - n.length;
|
|
514
|
+
for (let p = 1; p <= r; p++)
|
|
515
|
+
n.push(new Date(this.displayYear, this.displayMonth + 1, p));
|
|
516
|
+
return n;
|
|
517
|
+
}
|
|
518
|
+
checkValidity() {
|
|
519
|
+
if (this.required && !this.value)
|
|
520
|
+
return !1;
|
|
521
|
+
if (this.value) {
|
|
522
|
+
const e = this.parseDate(this.value);
|
|
523
|
+
if (e && this.isDateDisabled(e))
|
|
524
|
+
return !1;
|
|
525
|
+
}
|
|
526
|
+
return !0;
|
|
527
|
+
}
|
|
528
|
+
getWeekdayNames() {
|
|
529
|
+
const e = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
530
|
+
return this.firstDayOfWeek === "1" ? [...e.slice(1), e[0]] : e;
|
|
531
|
+
}
|
|
532
|
+
getMonthName(e) {
|
|
533
|
+
return new Date(2e3, e, 1).toLocaleString("default", {
|
|
534
|
+
month: "long"
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
getFormattedValue() {
|
|
538
|
+
const e = this.getSelectedDate();
|
|
539
|
+
return e ? e.toLocaleDateString() : "";
|
|
540
|
+
}
|
|
541
|
+
render() {
|
|
542
|
+
const e = this.getSelectedDate(), t = this.getTodayDate(), a = this.getCalendarDays(), d = this.getWeekdayNames(), s = !!this.value, n = {
|
|
543
|
+
"date-picker": !0,
|
|
544
|
+
"date-picker--open": this.isOpen,
|
|
545
|
+
"date-picker--disabled": this.disabled,
|
|
546
|
+
[`date-picker--${this.size}`]: !0
|
|
547
|
+
};
|
|
548
|
+
return l`
|
|
549
|
+
<div class=${g(n)} part="control">
|
|
550
|
+
<div class="date-picker__input-wrapper">
|
|
551
|
+
<input
|
|
552
|
+
type="text"
|
|
553
|
+
class="date-picker__input"
|
|
554
|
+
part="input"
|
|
555
|
+
.value=${this.getFormattedValue()}
|
|
556
|
+
placeholder=${this.placeholder}
|
|
557
|
+
?disabled=${this.disabled}
|
|
558
|
+
?required=${this.required}
|
|
559
|
+
readonly
|
|
560
|
+
@click=${this.handleInputClick}
|
|
561
|
+
@keydown=${this.handleKeyDown}
|
|
562
|
+
role="combobox"
|
|
563
|
+
aria-haspopup="grid"
|
|
564
|
+
aria-expanded=${this.isOpen}
|
|
565
|
+
aria-disabled=${this.disabled}
|
|
566
|
+
aria-label=${this.label || this.placeholder || "Date picker"}
|
|
567
|
+
/>
|
|
568
|
+
${s && !this.disabled ? l`
|
|
569
|
+
<button
|
|
570
|
+
type="button"
|
|
571
|
+
class="date-picker__clear"
|
|
572
|
+
part="clear-button"
|
|
573
|
+
@click=${this.handleClear}
|
|
574
|
+
aria-label="Clear date"
|
|
575
|
+
tabindex="-1"
|
|
576
|
+
>
|
|
577
|
+
✕
|
|
578
|
+
</button>
|
|
579
|
+
` : ""}
|
|
580
|
+
<div class="date-picker__indicator" part="indicator">
|
|
581
|
+
<svg
|
|
582
|
+
width="16"
|
|
583
|
+
height="16"
|
|
584
|
+
viewBox="0 0 16 16"
|
|
585
|
+
fill="none"
|
|
586
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
587
|
+
>
|
|
588
|
+
<path
|
|
589
|
+
d="M5 2V4M11 2V4M3 6H13M4 4H12C12.5523 4 13 4.44772 13 5V13C13 13.5523 12.5523 14 12 14H4C3.44772 14 3 13.5523 3 13V5C3 4.44772 3.44772 4 4 4Z"
|
|
590
|
+
stroke="currentColor"
|
|
591
|
+
stroke-width="1.5"
|
|
592
|
+
stroke-linecap="round"
|
|
593
|
+
stroke-linejoin="round"
|
|
594
|
+
/>
|
|
595
|
+
</svg>
|
|
596
|
+
</div>
|
|
597
|
+
</div>
|
|
598
|
+
|
|
599
|
+
${this.isOpen ? l`
|
|
600
|
+
<div class="date-picker__calendar" part="calendar" role="grid">
|
|
601
|
+
<div class="date-picker__header" part="header">
|
|
602
|
+
<button
|
|
603
|
+
type="button"
|
|
604
|
+
class="date-picker__nav-button"
|
|
605
|
+
part="nav-button"
|
|
606
|
+
@click=${this.handlePreviousMonth}
|
|
607
|
+
aria-label="Previous month"
|
|
608
|
+
tabindex="-1"
|
|
609
|
+
>
|
|
610
|
+
‹
|
|
611
|
+
</button>
|
|
612
|
+
<div class="date-picker__month-year" part="month-year">
|
|
613
|
+
${this.getMonthName(this.displayMonth)} ${this.displayYear}
|
|
614
|
+
</div>
|
|
615
|
+
<button
|
|
616
|
+
type="button"
|
|
617
|
+
class="date-picker__nav-button"
|
|
618
|
+
part="nav-button"
|
|
619
|
+
@click=${this.handleNextMonth}
|
|
620
|
+
aria-label="Next month"
|
|
621
|
+
tabindex="-1"
|
|
622
|
+
>
|
|
623
|
+
›
|
|
624
|
+
</button>
|
|
625
|
+
</div>
|
|
626
|
+
|
|
627
|
+
<div class="date-picker__weekdays">
|
|
628
|
+
${d.map(
|
|
629
|
+
(r) => l`
|
|
630
|
+
<div
|
|
631
|
+
class="date-picker__weekday"
|
|
632
|
+
part="weekday"
|
|
633
|
+
role="columnheader"
|
|
634
|
+
>
|
|
635
|
+
${r}
|
|
636
|
+
</div>
|
|
637
|
+
`
|
|
638
|
+
)}
|
|
639
|
+
</div>
|
|
640
|
+
|
|
641
|
+
<div class="date-picker__days">
|
|
642
|
+
${a.map((r) => {
|
|
643
|
+
const p = r.getMonth() === this.displayMonth, h = e && this.isSameDay(r, e), v = this.isSameDay(r, t), y = this.focusedDate && this.isSameDay(r, this.focusedDate), u = this.isDateDisabled(r);
|
|
644
|
+
return l`
|
|
645
|
+
<button
|
|
646
|
+
type="button"
|
|
647
|
+
class=${g({
|
|
648
|
+
"date-picker__day": !0,
|
|
649
|
+
"date-picker__day--other-month": !p,
|
|
650
|
+
"date-picker__day--selected": !!h,
|
|
651
|
+
"date-picker__day--today": v,
|
|
652
|
+
"date-picker__day--focused": !!y,
|
|
653
|
+
"date-picker__day--disabled": u
|
|
654
|
+
})}
|
|
655
|
+
part="day"
|
|
656
|
+
@click=${() => !u && this.handleDateSelect(r)}
|
|
657
|
+
?disabled=${u}
|
|
658
|
+
tabindex="-1"
|
|
659
|
+
role="gridcell"
|
|
660
|
+
aria-selected=${!!h}
|
|
661
|
+
aria-label=${r.toLocaleDateString()}
|
|
662
|
+
>
|
|
663
|
+
${r.getDate()}
|
|
664
|
+
</button>
|
|
665
|
+
`;
|
|
666
|
+
})}
|
|
667
|
+
</div>
|
|
668
|
+
</div>
|
|
669
|
+
` : ""}
|
|
670
|
+
${this.name ? l`
|
|
671
|
+
<input type="hidden" name=${this.name} .value=${this.value} />
|
|
672
|
+
` : ""}
|
|
673
|
+
</div>
|
|
674
|
+
`;
|
|
675
|
+
}
|
|
676
|
+
};
|
|
677
|
+
i.styles = [_];
|
|
678
|
+
o([
|
|
679
|
+
c({ type: String, reflect: !0 })
|
|
680
|
+
], i.prototype, "value", 2);
|
|
681
|
+
o([
|
|
682
|
+
c({ type: String })
|
|
683
|
+
], i.prototype, "name", 2);
|
|
684
|
+
o([
|
|
685
|
+
c({ type: String })
|
|
686
|
+
], i.prototype, "label", 2);
|
|
687
|
+
o([
|
|
688
|
+
c({ type: String })
|
|
689
|
+
], i.prototype, "placeholder", 2);
|
|
690
|
+
o([
|
|
691
|
+
c({ type: Boolean, reflect: !0 })
|
|
692
|
+
], i.prototype, "disabled", 2);
|
|
693
|
+
o([
|
|
694
|
+
c({ type: Boolean, reflect: !0 })
|
|
695
|
+
], i.prototype, "required", 2);
|
|
696
|
+
o([
|
|
697
|
+
c({ type: String, reflect: !0 })
|
|
698
|
+
], i.prototype, "size", 2);
|
|
699
|
+
o([
|
|
700
|
+
c({ type: String })
|
|
701
|
+
], i.prototype, "min", 2);
|
|
702
|
+
o([
|
|
703
|
+
c({ type: String })
|
|
704
|
+
], i.prototype, "max", 2);
|
|
705
|
+
o([
|
|
706
|
+
c({ type: String, attribute: "first-day-of-week" })
|
|
707
|
+
], i.prototype, "firstDayOfWeek", 2);
|
|
708
|
+
o([
|
|
709
|
+
b()
|
|
710
|
+
], i.prototype, "isOpen", 2);
|
|
711
|
+
o([
|
|
712
|
+
b()
|
|
713
|
+
], i.prototype, "displayMonth", 2);
|
|
714
|
+
o([
|
|
715
|
+
b()
|
|
716
|
+
], i.prototype, "displayYear", 2);
|
|
717
|
+
o([
|
|
718
|
+
b()
|
|
719
|
+
], i.prototype, "focusedDate", 2);
|
|
720
|
+
i = o([
|
|
721
|
+
m("bp-date-picker")
|
|
722
|
+
], i);
|
|
723
|
+
export {
|
|
724
|
+
i as BpDatePicker
|
|
725
|
+
};
|
|
726
|
+
//# sourceMappingURL=date-picker.js.map
|