@reliability-design/web 1.4.5 → 1.4.7
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/CHANGELOG.md +211 -49
- package/dist/components/rel-accordion/README.md +132 -132
- package/dist/components/rel-alert/README.md +145 -141
- package/dist/components/rel-autocomplete/README.md +156 -61
- package/dist/components/rel-avatar/README.md +116 -130
- package/dist/components/rel-badge/README.md +98 -93
- package/dist/components/rel-breadcrumb/README.md +96 -102
- package/dist/components/rel-button/README.md +160 -130
- package/dist/components/rel-calendar/README.md +109 -109
- package/dist/components/rel-card/README.md +75 -94
- package/dist/components/rel-cardmedia/README.md +100 -127
- package/dist/components/rel-carousel/README.md +184 -166
- package/dist/components/rel-checkbox/README.md +93 -75
- package/dist/components/rel-chip/README.md +132 -121
- package/dist/components/rel-container/README.md +107 -99
- package/dist/components/rel-date-picker/README.md +200 -289
- package/dist/components/rel-divider/README.md +78 -100
- package/dist/components/rel-drawer/README.md +187 -200
- package/dist/components/rel-kbd/README.md +141 -151
- package/dist/components/rel-menu/README.md +178 -151
- package/dist/components/rel-menubar/README.md +218 -329
- package/dist/components/rel-otp/README.md +170 -440
- package/dist/components/rel-pagination/README.md +100 -424
- package/dist/components/rel-popover/README.md +203 -568
- package/dist/components/rel-progress/README.md +88 -110
- package/dist/components/rel-radio/README.md +131 -135
- package/dist/components/rel-range-picker/README.md +162 -0
- package/dist/components/rel-resizable/README.md +199 -140
- package/dist/components/rel-segmented-button/README.md +155 -141
- package/dist/components/rel-select/README.md +154 -93
- package/dist/components/rel-sheet/README.md +168 -224
- package/dist/components/rel-skeleton/README.md +103 -0
- package/dist/components/rel-slider/README.md +130 -135
- package/dist/components/rel-snackbar/README.md +162 -134
- package/dist/components/rel-stepper/README.md +158 -160
- package/dist/components/rel-switch/README.md +108 -102
- package/dist/components/rel-tab/README.md +171 -163
- package/dist/components/rel-textfield/README.md +159 -69
- package/dist/components/rel-time-picker/README.md +122 -157
- package/dist/components/rel-toast/README.md +157 -148
- package/dist/components/rel-tooltip/README.md +108 -103
- package/dist/components/rel-upload/README.md +220 -0
- package/dist/index.d.mts +1387 -350
- package/dist/index.d.ts +1387 -350
- package/dist/index.js +5863 -3600
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5864 -3592
- package/dist/index.mjs.map +1 -1
- package/dist/styles/vars.css +877 -866
- package/dist/{vars-XNMTSRVN.css → vars-JHTUGNRG.css} +877 -866
- package/package.json +4 -3
- package/dist/components/rel-accordion/rel-accordion.ts +0 -336
- package/dist/components/rel-alert/rel-alert.ts +0 -305
- package/dist/components/rel-autocomplete/rel-autocomplete.ts +0 -689
- package/dist/components/rel-avatar/rel-avatar.ts +0 -142
- package/dist/components/rel-badge/rel-badge.ts +0 -170
- package/dist/components/rel-breadcrumb/rel-breadcrumb.ts +0 -106
- package/dist/components/rel-button/rel-button.ts +0 -560
- package/dist/components/rel-calendar/index.ts +0 -1
- package/dist/components/rel-calendar/rel-calendar.ts +0 -519
- package/dist/components/rel-card/rel-card.ts +0 -88
- package/dist/components/rel-cardmedia/rel-cardmedia.ts +0 -88
- package/dist/components/rel-carousel/index.ts +0 -1
- package/dist/components/rel-carousel/rel-carousel.ts +0 -700
- package/dist/components/rel-chart/README.md +0 -286
- package/dist/components/rel-chart/index.ts +0 -1
- package/dist/components/rel-chart/rel-chart.ts +0 -754
- package/dist/components/rel-checkbox/rel-checkbox.ts +0 -382
- package/dist/components/rel-chip/rel-chip.ts +0 -472
- package/dist/components/rel-container/rel-container.ts +0 -95
- package/dist/components/rel-date-picker/date-format.test.ts +0 -43
- package/dist/components/rel-date-picker/date-format.ts +0 -47
- package/dist/components/rel-date-picker/index.ts +0 -1
- package/dist/components/rel-date-picker/rel-date-picker.ts +0 -1237
- package/dist/components/rel-divider/rel-divider.ts +0 -54
- package/dist/components/rel-drawer/index.ts +0 -1
- package/dist/components/rel-drawer/rel-drawer-footer.ts +0 -27
- package/dist/components/rel-drawer/rel-drawer.ts +0 -604
- package/dist/components/rel-kbd/rel-kbd.ts +0 -188
- package/dist/components/rel-layout/rel-layout.ts +0 -49
- package/dist/components/rel-menu/rel-menu.ts +0 -535
- package/dist/components/rel-menubar/index.ts +0 -2
- package/dist/components/rel-menubar/rel-menubar-menu.css +0 -3
- package/dist/components/rel-menubar/rel-menubar-menu.ts +0 -17
- package/dist/components/rel-menubar/rel-menubar.ts +0 -777
- package/dist/components/rel-nav-menu/README.md +0 -289
- package/dist/components/rel-nav-menu/index.ts +0 -3
- package/dist/components/rel-nav-menu/rel-nav-menu-item.ts +0 -243
- package/dist/components/rel-nav-menu/rel-nav-menu-panel.ts +0 -72
- package/dist/components/rel-nav-menu/rel-nav-menu.ts +0 -270
- package/dist/components/rel-navbar/README.md +0 -126
- package/dist/components/rel-navbar/rel-navbar.ts +0 -105
- package/dist/components/rel-otp/index.ts +0 -1
- package/dist/components/rel-otp/rel-otp.ts +0 -517
- package/dist/components/rel-pagination/index.ts +0 -1
- package/dist/components/rel-pagination/rel-pagination.ts +0 -509
- package/dist/components/rel-popover/index.ts +0 -2
- package/dist/components/rel-popover/rel-popover-content.ts +0 -81
- package/dist/components/rel-popover/rel-popover.ts +0 -444
- package/dist/components/rel-progress/rel-progress.ts +0 -225
- package/dist/components/rel-radio/rel-radio.ts +0 -305
- package/dist/components/rel-range-picker/rel-range-picker.ts +0 -1331
- package/dist/components/rel-resizable/index.ts +0 -3
- package/dist/components/rel-resizable/rel-resizable-group.ts +0 -405
- package/dist/components/rel-resizable/rel-resizable-handle.ts +0 -150
- package/dist/components/rel-resizable/rel-resizable-panel.ts +0 -58
- package/dist/components/rel-segmented-button/rel-segmented-button.ts +0 -213
- package/dist/components/rel-select/rel-select.ts +0 -1385
- package/dist/components/rel-sheet/rel-sheet.ts +0 -465
- package/dist/components/rel-sidebar/README.md +0 -209
- package/dist/components/rel-sidebar/rel-sidebar.ts +0 -1185
- package/dist/components/rel-skeleton/rel-skeleton.ts +0 -134
- package/dist/components/rel-slider/rel-slider.ts +0 -670
- package/dist/components/rel-snackbar/rel-snackbar.ts +0 -325
- package/dist/components/rel-stepper/rel-stepper.ts +0 -565
- package/dist/components/rel-switch/rel-switch.ts +0 -197
- package/dist/components/rel-tab/rel-tab.ts +0 -264
- package/dist/components/rel-table/README.md +0 -178
- package/dist/components/rel-table/rel-table-body.ts +0 -22
- package/dist/components/rel-table/rel-table-caption.ts +0 -30
- package/dist/components/rel-table/rel-table-cell.ts +0 -43
- package/dist/components/rel-table/rel-table-footer.ts +0 -24
- package/dist/components/rel-table/rel-table-head.ts +0 -47
- package/dist/components/rel-table/rel-table-header.ts +0 -22
- package/dist/components/rel-table/rel-table-row.ts +0 -37
- package/dist/components/rel-table/rel-table.ts +0 -62
- package/dist/components/rel-textfield/rel-textfield.ts +0 -866
- package/dist/components/rel-time-picker/rel-time-picker.ts +0 -1126
- package/dist/components/rel-toast/rel-toast.ts +0 -204
- package/dist/components/rel-tooltip/rel-tooltip.ts +0 -190
- package/dist/components/rel-topbar/rel-topbar-actions.ts +0 -27
- package/dist/components/rel-topbar/rel-topbar-brand.ts +0 -54
- package/dist/components/rel-topbar/rel-topbar-dropdown-item.ts +0 -69
- package/dist/components/rel-topbar/rel-topbar-dropdown.ts +0 -31
- package/dist/components/rel-topbar/rel-topbar-item.ts +0 -324
- package/dist/components/rel-topbar/rel-topbar-mobile-panel.ts +0 -27
- package/dist/components/rel-topbar/rel-topbar-profile.ts +0 -243
- package/dist/components/rel-topbar/rel-topbar-utilities.ts +0 -27
- package/dist/components/rel-topbar/rel-topbar.ts +0 -446
- package/dist/components/rel-upload/UPLOAD-DESIGN-CHANGES.md +0 -134
- package/dist/components/rel-upload/rel-upload-actions.ts +0 -163
- package/dist/components/rel-upload/rel-upload.ts +0 -943
|
@@ -1,1331 +0,0 @@
|
|
|
1
|
-
import { LitElement, html, css, nothing } from "lit";
|
|
2
|
-
import { customElement, property, state, query } from "lit/decorators.js";
|
|
3
|
-
import "@reliability-design/icons/rel-icon";
|
|
4
|
-
import "../rel-button/rel-button";
|
|
5
|
-
|
|
6
|
-
interface RangeDay {
|
|
7
|
-
date: Date;
|
|
8
|
-
day: number;
|
|
9
|
-
isCurrentMonth: boolean;
|
|
10
|
-
isToday: boolean;
|
|
11
|
-
isDraftFrom: boolean;
|
|
12
|
-
isDraftTo: boolean;
|
|
13
|
-
isInRange: boolean;
|
|
14
|
-
isDisabled: boolean;
|
|
15
|
-
isWeekend: boolean;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
interface QuickSelect {
|
|
19
|
-
label: string;
|
|
20
|
-
key: string;
|
|
21
|
-
from: string;
|
|
22
|
-
to: string;
|
|
23
|
-
fullWidth?: boolean;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
@customElement("rel-range-picker")
|
|
27
|
-
export class RelRangePicker extends LitElement {
|
|
28
|
-
@property({ type: String }) from: string = "";
|
|
29
|
-
@property({ type: String }) to: string = "";
|
|
30
|
-
@property({ type: String }) locale: string = "en-US";
|
|
31
|
-
@property({ type: String, attribute: "week-start" }) weekStart: "mon" | "sun" = "sun";
|
|
32
|
-
@property({ type: String, attribute: "min-date" }) minDate: string = "";
|
|
33
|
-
@property({ type: String, attribute: "max-date" }) maxDate: string = "";
|
|
34
|
-
@property({ type: Boolean, reflect: true }) disabled = false;
|
|
35
|
-
@property({ type: Boolean, reflect: true }) open = false;
|
|
36
|
-
@property({ type: String }) mode: "popover" | "popup" = "popover";
|
|
37
|
-
@property({ type: String }) width: string = "";
|
|
38
|
-
@property({ type: String, attribute: "min-width" }) minWidth: string = "";
|
|
39
|
-
@property({ type: String, attribute: "max-width" }) maxWidth: string = "";
|
|
40
|
-
@property({ type: String }) height: string = "";
|
|
41
|
-
@property({ type: String, attribute: "min-height" }) minHeight: string = "";
|
|
42
|
-
@property({ type: String, attribute: "max-height" }) maxHeight: string = "";
|
|
43
|
-
@property({ type: String }) placeholder: string = "Select date range";
|
|
44
|
-
@property({ type: String, attribute: "trigger-variant" }) triggerVariant: "default" | "icon" = "default";
|
|
45
|
-
|
|
46
|
-
@state() private draftFrom: string = "";
|
|
47
|
-
@state() private draftTo: string = "";
|
|
48
|
-
@state() private draftActivePreset: string | null = null;
|
|
49
|
-
@state() private viewYear: number = new Date().getFullYear();
|
|
50
|
-
@state() private viewMonth: number = new Date().getMonth();
|
|
51
|
-
@state() private isSelectingRange: boolean = false;
|
|
52
|
-
@state() private hoverDate: string | null = null;
|
|
53
|
-
/** ISO date of the cell that owns the grid's single Tab stop (roving tabindex). */
|
|
54
|
-
@state() private focusedDate: string | null = null;
|
|
55
|
-
|
|
56
|
-
@query(".trigger-button") private triggerButton?: HTMLButtonElement;
|
|
57
|
-
@query(".popover") private popoverEl?: HTMLDivElement;
|
|
58
|
-
@query(".backdrop") private backdropEl?: HTMLDivElement;
|
|
59
|
-
|
|
60
|
-
static styles = css`
|
|
61
|
-
:host {
|
|
62
|
-
color: var(--rel-text-default);
|
|
63
|
-
display: inline-block;
|
|
64
|
-
font-family: var(--rel-body-md-regular-font-family);
|
|
65
|
-
position: relative;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
:host([disabled]) {
|
|
69
|
-
opacity: 0.6;
|
|
70
|
-
cursor: not-allowed;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
:host([disabled]) .trigger-button,
|
|
74
|
-
:host([disabled]) rel-button {
|
|
75
|
-
pointer-events: none;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/* ── Trigger ── */
|
|
79
|
-
.trigger-button {
|
|
80
|
-
display: flex;
|
|
81
|
-
align-items: center;
|
|
82
|
-
justify-content: space-between;
|
|
83
|
-
gap: var(--rel-spacing-xs, 8px);
|
|
84
|
-
padding: var(--rel-spacing-sm, 12px) var(--rel-spacing-md, 16px);
|
|
85
|
-
background: var(--rel-bg-surface);
|
|
86
|
-
border: 1px solid var(--rel-border-default);
|
|
87
|
-
border-radius: var(--rel-border-radius-sm, 8px);
|
|
88
|
-
color: var(--rel-text-default);
|
|
89
|
-
cursor: pointer;
|
|
90
|
-
width: 100%;
|
|
91
|
-
text-align: left;
|
|
92
|
-
transition: border-color 0.15s ease;
|
|
93
|
-
font-family: var(--rel-body-md-regular-font-family);
|
|
94
|
-
font-weight: var(--rel-body-md-regular-font-weight);
|
|
95
|
-
font-size: var(--rel-body-md-regular-font-size);
|
|
96
|
-
line-height: var(--rel-body-md-regular-line-height);
|
|
97
|
-
letter-spacing: var(--rel-body-md-regular-letter-spacing);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
.trigger-button:hover:not(:disabled) {
|
|
101
|
-
border-color: var(--rel-border-accent);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
.trigger-button:focus-visible {
|
|
105
|
-
outline: 2px solid var(--rel-border-focus);
|
|
106
|
-
outline-offset: 2px;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
.trigger-content {
|
|
110
|
-
flex: 1;
|
|
111
|
-
color: var(--rel-text-default);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
.trigger-content.placeholder {
|
|
115
|
-
color: var(--rel-text-placeholder);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/* ── Popover shell ── */
|
|
119
|
-
.popover {
|
|
120
|
-
/* Reset native [popover] UA styles first (the shell is promoted to
|
|
121
|
-
the top layer so transformed / overflow:hidden ancestors — e.g. a
|
|
122
|
-
centered rel-modal panel — can't hijack or clip it). While in the
|
|
123
|
-
top layer, JS overrides the anchored position below with inline
|
|
124
|
-
fixed coordinates; the CSS anchoring is the no-Popover-API
|
|
125
|
-
fallback. */
|
|
126
|
-
margin: 0;
|
|
127
|
-
padding: 0;
|
|
128
|
-
width: auto;
|
|
129
|
-
height: auto;
|
|
130
|
-
color: inherit;
|
|
131
|
-
position: absolute;
|
|
132
|
-
top: calc(100% + 4px);
|
|
133
|
-
left: 0;
|
|
134
|
-
z-index: 2147483647;
|
|
135
|
-
border: 1px solid var(--rel-border-default);
|
|
136
|
-
border-radius: var(--rel-border-radius-sm, 8px);
|
|
137
|
-
background: var(--rel-bg-neutral);
|
|
138
|
-
box-shadow: var(--rel-shadows-shadow-200);
|
|
139
|
-
overflow: visible;
|
|
140
|
-
display: none;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
.popover.open { display: block; }
|
|
144
|
-
|
|
145
|
-
.popover.popup {
|
|
146
|
-
position: fixed;
|
|
147
|
-
top: 50%;
|
|
148
|
-
left: 50%;
|
|
149
|
-
transform: translate(-50%, -50%);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
.backdrop {
|
|
153
|
-
position: fixed;
|
|
154
|
-
inset: 0;
|
|
155
|
-
/* Reset native [popover] UA styles — the backdrop is promoted to the
|
|
156
|
-
top layer right before the panel so the panel stacks above it. */
|
|
157
|
-
margin: 0;
|
|
158
|
-
padding: 0;
|
|
159
|
-
width: auto;
|
|
160
|
-
height: auto;
|
|
161
|
-
border: none;
|
|
162
|
-
z-index: 2147483646;
|
|
163
|
-
background: rgba(0,0,0,0.4);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/* ── Two-panel wrapper ── */
|
|
167
|
-
.picker-wrapper {
|
|
168
|
-
font-family: var(--rel-body-lg-regular-font-family);
|
|
169
|
-
font-weight: var(--rel-body-lg-regular-font-weight);
|
|
170
|
-
display: flex;
|
|
171
|
-
flex-direction: row;
|
|
172
|
-
align-items: stretch;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/* ── Left panel: presets ── */
|
|
176
|
-
.presets {
|
|
177
|
-
width: 280px;
|
|
178
|
-
flex-shrink: 0;
|
|
179
|
-
flex-grow: 0;
|
|
180
|
-
border-right: 1px solid var(--rel-border-default);
|
|
181
|
-
padding: var(--rel-spacing-sm);
|
|
182
|
-
background: var(--rel-bg-surface-elevated);
|
|
183
|
-
display: flex;
|
|
184
|
-
flex-direction: column;
|
|
185
|
-
gap: 0;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
.presets-grid {
|
|
189
|
-
display: grid;
|
|
190
|
-
grid-template-columns: 1fr 1fr;
|
|
191
|
-
gap: 6px;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
.preset-item {
|
|
195
|
-
display: flex;
|
|
196
|
-
align-items: center;
|
|
197
|
-
justify-content: space-between;
|
|
198
|
-
padding: 10px var(--rel-spacing-sm);
|
|
199
|
-
cursor: pointer;
|
|
200
|
-
font-family: var(--rel-body-sm-medium-font-family);
|
|
201
|
-
font-weight: var(--rel-body-sm-medium-font-weight);
|
|
202
|
-
font-size: var(--rel-body-sm-medium-font-size);
|
|
203
|
-
line-height: var(--rel-body-sm-medium-line-height);
|
|
204
|
-
letter-spacing: var(--rel-body-sm-medium-letter-spacing);
|
|
205
|
-
color: var(--rel-action-neutral-label-icons-link);
|
|
206
|
-
background: var(--rel-bg-neutral-elevated-1);
|
|
207
|
-
border: none;
|
|
208
|
-
border-radius: var(--rel-border-radius-sm, 8px);
|
|
209
|
-
width: 100%;
|
|
210
|
-
white-space: nowrap;
|
|
211
|
-
overflow: hidden;
|
|
212
|
-
text-overflow: ellipsis;
|
|
213
|
-
transition: background 0.15s ease;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
.preset-item:hover:not(.active) {
|
|
217
|
-
background: var(--rel-action-overlay-hover);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
.preset-item.active {
|
|
221
|
-
background: var(--rel-bg-neutral-inverse-2);
|
|
222
|
-
color: var(--rel-text-inverse);
|
|
223
|
-
font-weight: var(--rel-body-sm-semibold-font-weight);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
.preset-item.full-width {
|
|
227
|
-
grid-column: 1 / -1;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
/* ── FROM/TO inputs ── */
|
|
231
|
-
.date-inputs {
|
|
232
|
-
display: flex;
|
|
233
|
-
align-items: center;
|
|
234
|
-
gap: 8px;
|
|
235
|
-
padding: 14px 8px 4px;
|
|
236
|
-
border-top: 1px solid var(--rel-border-default);
|
|
237
|
-
margin-top: auto;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
.date-input-group {
|
|
241
|
-
flex: 1;
|
|
242
|
-
min-width: 0;
|
|
243
|
-
position: relative;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
.date-input-label {
|
|
247
|
-
position: absolute;
|
|
248
|
-
top: -8px;
|
|
249
|
-
left: 10px;
|
|
250
|
-
/* Figma: the FROM/TO tag is the nested TextField's floating label (body-sm-regular) */
|
|
251
|
-
font-family: var(--rel-body-sm-regular-font-family);
|
|
252
|
-
font-weight: var(--rel-body-sm-regular-font-weight);
|
|
253
|
-
font-size: var(--rel-body-sm-regular-font-size);
|
|
254
|
-
line-height: var(--rel-body-sm-regular-line-height);
|
|
255
|
-
letter-spacing: var(--rel-body-sm-regular-letter-spacing);
|
|
256
|
-
color: var(--rel-text-body);
|
|
257
|
-
background: var(--rel-bg-surface);
|
|
258
|
-
padding: 0 3px;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
.date-input-value {
|
|
262
|
-
display: block;
|
|
263
|
-
border: 1px solid var(--rel-border-default);
|
|
264
|
-
border-radius: var(--rel-border-radius-sm, 8px);
|
|
265
|
-
padding: 6px 8px;
|
|
266
|
-
color: var(--rel-text-default);
|
|
267
|
-
background: var(--rel-bg-surface);
|
|
268
|
-
width: 100%;
|
|
269
|
-
box-sizing: border-box;
|
|
270
|
-
font-family: var(--rel-body-md-semibold-font-family);
|
|
271
|
-
font-weight: var(--rel-body-md-semibold-font-weight);
|
|
272
|
-
font-size: var(--rel-body-md-semibold-font-size);
|
|
273
|
-
line-height: var(--rel-body-md-semibold-line-height);
|
|
274
|
-
letter-spacing: var(--rel-body-md-semibold-letter-spacing);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
.date-input-value.empty {
|
|
278
|
-
color: var(--rel-text-placeholder);
|
|
279
|
-
font-weight: var(--rel-body-md-regular-font-weight);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
/* ── Right panel: calendar ── */
|
|
283
|
-
.calendar-panel {
|
|
284
|
-
width: 300px;
|
|
285
|
-
flex-shrink: 0;
|
|
286
|
-
flex-grow: 0;
|
|
287
|
-
padding: 12px;
|
|
288
|
-
display: flex;
|
|
289
|
-
flex-direction: column;
|
|
290
|
-
gap: 6px;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
.calendar-header {
|
|
294
|
-
display: flex;
|
|
295
|
-
align-items: center;
|
|
296
|
-
justify-content: space-between;
|
|
297
|
-
padding: 0 2px;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
.month-label {
|
|
301
|
-
font-family: var(--rel-body-lg-semibold-font-family);
|
|
302
|
-
font-weight: var(--rel-body-lg-semibold-font-weight);
|
|
303
|
-
font-size: var(--rel-body-lg-regular-font-size);
|
|
304
|
-
line-height: var(--rel-body-lg-regular-line-height);
|
|
305
|
-
letter-spacing: var(--rel-body-lg-regular-letter-spacing);
|
|
306
|
-
color: var(--rel-text-label);
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
.nav-btn {
|
|
310
|
-
background: none;
|
|
311
|
-
border: none;
|
|
312
|
-
cursor: pointer;
|
|
313
|
-
color: var(--rel-action-neutral-label-icons-ghost);
|
|
314
|
-
padding: var(--rel-spacing-2xs);
|
|
315
|
-
border-radius: var(--rel-border-radius-sm, 8px);
|
|
316
|
-
display: flex;
|
|
317
|
-
align-items: center;
|
|
318
|
-
transition: background 0.15s ease;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
.nav-btn:hover { background: var(--rel-action-overlay-hover); }
|
|
322
|
-
|
|
323
|
-
/* ── Weekday header ── */
|
|
324
|
-
.week-header {
|
|
325
|
-
display: grid;
|
|
326
|
-
grid-template-columns: repeat(7, 1fr);
|
|
327
|
-
text-align: center;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
.week-day {
|
|
331
|
-
color: var(--rel-text-body);
|
|
332
|
-
padding: 2px 0;
|
|
333
|
-
/* Figma: sm-regular family + xs-medium weight on sm-medium metrics */
|
|
334
|
-
font-family: var(--rel-body-sm-regular-font-family);
|
|
335
|
-
font-weight: var(--rel-body-xs-medium-font-weight);
|
|
336
|
-
font-size: var(--rel-body-sm-medium-font-size);
|
|
337
|
-
line-height: var(--rel-body-sm-medium-line-height);
|
|
338
|
-
letter-spacing: var(--rel-body-sm-medium-letter-spacing);
|
|
339
|
-
text-align: center;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
/* ── Calendar grid ── */
|
|
343
|
-
.calendar-grid {
|
|
344
|
-
display: grid;
|
|
345
|
-
grid-template-columns: repeat(7, 1fr);
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
.day-cell {
|
|
349
|
-
height: 36px;
|
|
350
|
-
position: relative;
|
|
351
|
-
display: flex;
|
|
352
|
-
align-items: center;
|
|
353
|
-
justify-content: center;
|
|
354
|
-
cursor: pointer;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
.day-cell:focus-visible {
|
|
358
|
-
outline: 2px solid var(--rel-border-focus);
|
|
359
|
-
outline-offset: -2px;
|
|
360
|
-
z-index: 2;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
.day-cell.other-month {
|
|
364
|
-
opacity: 0.35;
|
|
365
|
-
pointer-events: none;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
.day-cell.disabled {
|
|
369
|
-
opacity: 0.4;
|
|
370
|
-
pointer-events: none;
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
.day-cell.in-range {
|
|
374
|
-
background: var(--rel-bg-neutral-elevated-2);
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
.day-cell.range-start:not(.range-end) {
|
|
378
|
-
background: linear-gradient(to right, transparent 50%, var(--rel-bg-neutral-elevated-2) 50%);
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
.day-cell.range-end:not(.range-start) {
|
|
382
|
-
background: linear-gradient(to left, transparent 50%, var(--rel-bg-neutral-elevated-2) 50%);
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
.day-cell.range-start.range-end {
|
|
386
|
-
background: transparent;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
/* ── Day inner circle ── */
|
|
390
|
-
.day-inner {
|
|
391
|
-
width: 32px;
|
|
392
|
-
height: 32px;
|
|
393
|
-
display: flex;
|
|
394
|
-
align-items: center;
|
|
395
|
-
justify-content: center;
|
|
396
|
-
border-radius: 50%;
|
|
397
|
-
font-family: var(--rel-body-sm-medium-font-family);
|
|
398
|
-
font-weight: var(--rel-body-sm-medium-font-weight);
|
|
399
|
-
font-size: var(--rel-body-sm-medium-font-size);
|
|
400
|
-
line-height: var(--rel-body-sm-medium-line-height);
|
|
401
|
-
letter-spacing: var(--rel-body-sm-medium-letter-spacing);
|
|
402
|
-
color: var(--rel-text-default);
|
|
403
|
-
position: relative;
|
|
404
|
-
z-index: 1;
|
|
405
|
-
transition: background 0.15s ease;
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
.day-cell:not(.disabled):not(.other-month):not(.range-start):not(.range-end):hover .day-inner {
|
|
409
|
-
background: var(--rel-action-overlay-hover);
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
/* Pressed (Figma State=Active): elevated-2 fill on the day circle */
|
|
413
|
-
.day-cell:not(.disabled):not(.other-month):not(.range-start):not(.range-end):active .day-inner {
|
|
414
|
-
background: var(--rel-bg-neutral-elevated-2);
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
/* Weekend (Figma Day of a week=Weekend): 70% text opacity unless a range endpoint */
|
|
418
|
-
.day-cell.weekend:not(.range-start):not(.range-end) .day-inner {
|
|
419
|
-
opacity: 0.7;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
/* Today: green outline */
|
|
423
|
-
.day-cell.today:not(.range-start):not(.range-end) .day-inner {
|
|
424
|
-
font-weight: var(--rel-body-md-medium-font-weight);
|
|
425
|
-
border: 2px solid var(--rel-border-brand);
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
/* Range endpoints: dark fill */
|
|
429
|
-
.day-cell.range-start .day-inner,
|
|
430
|
-
.day-cell.range-end .day-inner {
|
|
431
|
-
background: var(--rel-action-brand-fill);
|
|
432
|
-
color: var(--rel-action-brand-label-icons-primary);
|
|
433
|
-
font-weight: var(--rel-body-sm-semibold-font-weight);
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
/* Today AND endpoint: green ring + dark fill */
|
|
437
|
-
.day-cell.today.range-start .day-inner,
|
|
438
|
-
.day-cell.today.range-end .day-inner {
|
|
439
|
-
background: var(--rel-action-brand-fill);
|
|
440
|
-
color: var(--rel-action-brand-label-icons-primary);
|
|
441
|
-
border: 2px solid var(--rel-border-brand);
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
/* ── Footer ── */
|
|
445
|
-
.calendar-footer {
|
|
446
|
-
display: flex;
|
|
447
|
-
align-items: center;
|
|
448
|
-
justify-content: space-between;
|
|
449
|
-
padding-top: 12px;
|
|
450
|
-
border-top: 1px solid var(--rel-border-default);
|
|
451
|
-
margin-top: auto;
|
|
452
|
-
gap: 8px;
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
.footer-right {
|
|
456
|
-
display: flex;
|
|
457
|
-
gap: 8px;
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
@media (prefers-reduced-motion: reduce) {
|
|
461
|
-
.preset-item, .nav-btn, .day-inner {
|
|
462
|
-
transition: none;
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
`;
|
|
466
|
-
|
|
467
|
-
// ── Lifecycle ──
|
|
468
|
-
|
|
469
|
-
connectedCallback() {
|
|
470
|
-
super.connectedCallback();
|
|
471
|
-
document.addEventListener("click", this.handleClickOutside);
|
|
472
|
-
document.addEventListener("keydown", this.handleGlobalKeydown);
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
disconnectedCallback() {
|
|
476
|
-
super.disconnectedCallback();
|
|
477
|
-
document.removeEventListener("click", this.handleClickOutside);
|
|
478
|
-
document.removeEventListener("keydown", this.handleGlobalKeydown);
|
|
479
|
-
window.removeEventListener("resize", this.onReposition);
|
|
480
|
-
window.removeEventListener("scroll", this.onReposition, true);
|
|
481
|
-
this.hideTopLayer();
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
updated(changed: Map<string, unknown>) {
|
|
485
|
-
this.style.width = this.width;
|
|
486
|
-
this.style.minWidth = this.minWidth;
|
|
487
|
-
this.style.maxWidth = this.maxWidth;
|
|
488
|
-
this.style.height = this.height;
|
|
489
|
-
this.style.minHeight = this.minHeight;
|
|
490
|
-
this.style.maxHeight = this.maxHeight;
|
|
491
|
-
|
|
492
|
-
// `open` is a public reflected property (consumers may set it directly,
|
|
493
|
-
// not only via the trigger), so top-layer promotion syncs here rather
|
|
494
|
-
// than inside openPopover/cancelPopover.
|
|
495
|
-
if (changed.has("open")) {
|
|
496
|
-
if (this.open) {
|
|
497
|
-
this.showTopLayer();
|
|
498
|
-
window.addEventListener("resize", this.onReposition);
|
|
499
|
-
window.addEventListener("scroll", this.onReposition, true);
|
|
500
|
-
} else {
|
|
501
|
-
window.removeEventListener("resize", this.onReposition);
|
|
502
|
-
window.removeEventListener("scroll", this.onReposition, true);
|
|
503
|
-
this.hideTopLayer();
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
/* A transformed ancestor (e.g. rel-modal's centered panel with
|
|
509
|
-
* translate(-50%,-50%)) becomes the containing block for position:fixed
|
|
510
|
-
* descendants, and its overflow:hidden clips position:absolute ones —
|
|
511
|
-
* either way the picker shell breaks inside a modal. Promoting shell
|
|
512
|
-
* (and popup-mode backdrop) to the browser top layer sidesteps both —
|
|
513
|
-
* same fix as rel-popover / rel-autocomplete / rel-select. `manual`
|
|
514
|
-
* keeps outside-click and Escape handling under this component's own
|
|
515
|
-
* control. While in the top layer the CSS anchoring (absolute, below
|
|
516
|
-
* the trigger) is meaningless, so popover mode gets inline fixed
|
|
517
|
-
* coordinates from updatePopoverPosition(). */
|
|
518
|
-
|
|
519
|
-
private showTopLayer() {
|
|
520
|
-
// Backdrop first — later-shown popovers stack above earlier ones.
|
|
521
|
-
for (const el of [this.mode === "popup" ? this.backdropEl : undefined, this.popoverEl]) {
|
|
522
|
-
if (!el || typeof el.showPopover !== "function") continue;
|
|
523
|
-
try {
|
|
524
|
-
if (!el.matches(":popover-open")) el.showPopover();
|
|
525
|
-
} catch {
|
|
526
|
-
/* older engines / detached element — CSS fallback applies */
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
if (this.mode === "popover") {
|
|
530
|
-
requestAnimationFrame(() => this.updatePopoverPosition());
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
private hideTopLayer() {
|
|
535
|
-
for (const el of [this.popoverEl, this.backdropEl]) {
|
|
536
|
-
if (!el || typeof el.hidePopover !== "function") continue;
|
|
537
|
-
try {
|
|
538
|
-
if (el.matches(":popover-open")) el.hidePopover();
|
|
539
|
-
} catch {
|
|
540
|
-
/* already hidden or unsupported — nothing to do */
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
if (this.popoverEl) {
|
|
544
|
-
this.popoverEl.style.position = "";
|
|
545
|
-
this.popoverEl.style.top = "";
|
|
546
|
-
this.popoverEl.style.left = "";
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
private onReposition = () => {
|
|
551
|
-
if (this.open && this.mode === "popover") this.updatePopoverPosition();
|
|
552
|
-
};
|
|
553
|
-
|
|
554
|
-
private updatePopoverPosition = () => {
|
|
555
|
-
const panel = this.popoverEl;
|
|
556
|
-
if (!panel || !this.open || this.mode !== "popover") return;
|
|
557
|
-
|
|
558
|
-
// Host rect anchors both trigger variants (default button and icon).
|
|
559
|
-
const t = this.getBoundingClientRect();
|
|
560
|
-
const c = panel.getBoundingClientRect();
|
|
561
|
-
|
|
562
|
-
let top = t.bottom + 4;
|
|
563
|
-
if (top + c.height > window.innerHeight - 8) {
|
|
564
|
-
top = Math.max(8, t.top - c.height - 4);
|
|
565
|
-
}
|
|
566
|
-
let left = t.left;
|
|
567
|
-
if (left + c.width > window.innerWidth - 8) {
|
|
568
|
-
left = Math.max(8, window.innerWidth - c.width - 8);
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
// Without top-layer support a transformed ancestor may be the containing
|
|
572
|
-
// block for position:fixed, shifting the shell away from the viewport
|
|
573
|
-
// coordinates computed above. Apply, re-measure, and cancel the offset.
|
|
574
|
-
panel.style.position = "fixed";
|
|
575
|
-
panel.style.top = `${top}px`;
|
|
576
|
-
panel.style.left = `${left}px`;
|
|
577
|
-
const applied = panel.getBoundingClientRect();
|
|
578
|
-
top -= applied.top - top;
|
|
579
|
-
left -= applied.left - left;
|
|
580
|
-
panel.style.top = `${top}px`;
|
|
581
|
-
panel.style.left = `${left}px`;
|
|
582
|
-
};
|
|
583
|
-
|
|
584
|
-
// ── Open / close ──
|
|
585
|
-
|
|
586
|
-
private handleClickOutside = (e: MouseEvent) => {
|
|
587
|
-
if (!this.open) return;
|
|
588
|
-
const path = e.composedPath();
|
|
589
|
-
if (!path.includes(this)) {
|
|
590
|
-
this.cancelPopover();
|
|
591
|
-
}
|
|
592
|
-
};
|
|
593
|
-
|
|
594
|
-
private handleGlobalKeydown = (e: KeyboardEvent) => {
|
|
595
|
-
if (!this.open) return;
|
|
596
|
-
|
|
597
|
-
if (e.key === "Escape") {
|
|
598
|
-
this.cancelPopover();
|
|
599
|
-
this.triggerButton?.focus();
|
|
600
|
-
return;
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
if ((e.target as HTMLElement)?.tagName === "INPUT") return;
|
|
604
|
-
|
|
605
|
-
const key = e.key.toUpperCase();
|
|
606
|
-
const keyMap: Record<string, string> = {
|
|
607
|
-
T: "Today",
|
|
608
|
-
M: "Tomorrow",
|
|
609
|
-
B: "Before Today",
|
|
610
|
-
W: "This Week",
|
|
611
|
-
N: "Next Week",
|
|
612
|
-
"7": "Next 7 Days",
|
|
613
|
-
"3": "Next 30 Days",
|
|
614
|
-
};
|
|
615
|
-
|
|
616
|
-
const label = keyMap[key];
|
|
617
|
-
if (!label) return;
|
|
618
|
-
|
|
619
|
-
const qs = this.getQuickSelects().find((q) => q.label === label);
|
|
620
|
-
if (qs) this.selectQuickSelect(qs);
|
|
621
|
-
};
|
|
622
|
-
|
|
623
|
-
private toggleOpen() {
|
|
624
|
-
if (this.disabled) return;
|
|
625
|
-
if (this.open) {
|
|
626
|
-
this.cancelPopover();
|
|
627
|
-
} else {
|
|
628
|
-
this.openPopover();
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
private openPopover() {
|
|
633
|
-
this.draftFrom = this.from;
|
|
634
|
-
this.draftTo = this.to;
|
|
635
|
-
this.draftActivePreset = null;
|
|
636
|
-
this.isSelectingRange = false;
|
|
637
|
-
this.hoverDate = null;
|
|
638
|
-
this.focusedDate = null;
|
|
639
|
-
|
|
640
|
-
if (this.draftFrom) {
|
|
641
|
-
const date = this.parseISODate(this.draftFrom);
|
|
642
|
-
if (date) {
|
|
643
|
-
this.viewYear = date.getFullYear();
|
|
644
|
-
this.viewMonth = date.getMonth();
|
|
645
|
-
}
|
|
646
|
-
} else {
|
|
647
|
-
const now = new Date();
|
|
648
|
-
this.viewYear = now.getFullYear();
|
|
649
|
-
this.viewMonth = now.getMonth();
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
this.open = true;
|
|
653
|
-
this.dispatchEvent(
|
|
654
|
-
new CustomEvent("rel-open-change", {
|
|
655
|
-
detail: { open: true },
|
|
656
|
-
bubbles: true,
|
|
657
|
-
composed: true,
|
|
658
|
-
})
|
|
659
|
-
);
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
private cancelPopover() {
|
|
663
|
-
if (!this.open) return;
|
|
664
|
-
this.open = false;
|
|
665
|
-
this.draftFrom = "";
|
|
666
|
-
this.draftTo = "";
|
|
667
|
-
this.draftActivePreset = null;
|
|
668
|
-
this.isSelectingRange = false;
|
|
669
|
-
this.hoverDate = null;
|
|
670
|
-
this.dispatchEvent(
|
|
671
|
-
new CustomEvent("rel-open-change", {
|
|
672
|
-
detail: { open: false },
|
|
673
|
-
bubbles: true,
|
|
674
|
-
composed: true,
|
|
675
|
-
})
|
|
676
|
-
);
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
private applySelection() {
|
|
680
|
-
if (this.draftFrom || this.draftTo) {
|
|
681
|
-
this.from = this.draftFrom;
|
|
682
|
-
this.to = this.draftTo;
|
|
683
|
-
this.dispatchEvent(
|
|
684
|
-
new CustomEvent("rel-change", {
|
|
685
|
-
detail: { from: this.from, to: this.to, label: this.displayLabel },
|
|
686
|
-
bubbles: true,
|
|
687
|
-
composed: true,
|
|
688
|
-
})
|
|
689
|
-
);
|
|
690
|
-
this.open = false;
|
|
691
|
-
this.isSelectingRange = false;
|
|
692
|
-
this.hoverDate = null;
|
|
693
|
-
this.dispatchEvent(
|
|
694
|
-
new CustomEvent("rel-open-change", {
|
|
695
|
-
detail: { open: false },
|
|
696
|
-
bubbles: true,
|
|
697
|
-
composed: true,
|
|
698
|
-
})
|
|
699
|
-
);
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
private resetDraft() {
|
|
704
|
-
if (this.draftFrom || this.draftTo) {
|
|
705
|
-
this.draftFrom = "";
|
|
706
|
-
this.draftTo = "";
|
|
707
|
-
this.draftActivePreset = null;
|
|
708
|
-
this.isSelectingRange = false;
|
|
709
|
-
this.hoverDate = null;
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
private getTriggerLabel(): string {
|
|
714
|
-
const from = this.from ? this.formatDisplayDate(this.from) : null;
|
|
715
|
-
const to = this.to ? this.formatDisplayDate(this.to) : null;
|
|
716
|
-
if (from && to) return `${from} → ${to}`;
|
|
717
|
-
if (from) return from;
|
|
718
|
-
return "";
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
/** Formatted "MM/DD/YYYY → MM/DD/YYYY" (or single date / "") for the current committed `from`/`to`. */
|
|
722
|
-
get displayLabel(): string {
|
|
723
|
-
return this.getTriggerLabel();
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
// ── Date utilities ──
|
|
727
|
-
|
|
728
|
-
private parseISODate(iso: string): Date | null {
|
|
729
|
-
const m = iso.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
730
|
-
if (!m) return null;
|
|
731
|
-
return new Date(parseInt(m[1]), parseInt(m[2]) - 1, parseInt(m[3]));
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
private formatISODate(date: Date): string {
|
|
735
|
-
const y = date.getFullYear();
|
|
736
|
-
const mo = String(date.getMonth() + 1).padStart(2, "0");
|
|
737
|
-
const d = String(date.getDate()).padStart(2, "0");
|
|
738
|
-
return `${y}-${mo}-${d}`;
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
private formatDisplayDate(iso: string): string {
|
|
742
|
-
const date = this.parseISODate(iso);
|
|
743
|
-
if (!date) return "";
|
|
744
|
-
return new Intl.DateTimeFormat("en-US", {
|
|
745
|
-
month: "2-digit",
|
|
746
|
-
day: "2-digit",
|
|
747
|
-
year: "numeric",
|
|
748
|
-
}).format(date);
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
private isSameDay(a: Date, b: Date): boolean {
|
|
752
|
-
return (
|
|
753
|
-
a.getFullYear() === b.getFullYear() &&
|
|
754
|
-
a.getMonth() === b.getMonth() &&
|
|
755
|
-
a.getDate() === b.getDate()
|
|
756
|
-
);
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
private isDateDisabled(date: Date): boolean {
|
|
760
|
-
if (this.minDate) {
|
|
761
|
-
const min = this.parseISODate(this.minDate);
|
|
762
|
-
if (min && date < min) return true;
|
|
763
|
-
}
|
|
764
|
-
if (this.maxDate) {
|
|
765
|
-
const max = this.parseISODate(this.maxDate);
|
|
766
|
-
if (max && date > max) return true;
|
|
767
|
-
}
|
|
768
|
-
return false;
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
// ── Quick selects ──
|
|
772
|
-
|
|
773
|
-
private getQuickSelects(): QuickSelect[] {
|
|
774
|
-
const today = new Date();
|
|
775
|
-
today.setHours(0, 0, 0, 0);
|
|
776
|
-
|
|
777
|
-
const yesterday = new Date(today);
|
|
778
|
-
yesterday.setDate(today.getDate() - 1);
|
|
779
|
-
|
|
780
|
-
const tomorrow = new Date(today);
|
|
781
|
-
tomorrow.setDate(today.getDate() + 1);
|
|
782
|
-
|
|
783
|
-
const dow = today.getDay(); // 0 = Sun
|
|
784
|
-
const thisSunday = new Date(today);
|
|
785
|
-
thisSunday.setDate(today.getDate() - dow);
|
|
786
|
-
const thisSaturday = new Date(thisSunday);
|
|
787
|
-
thisSaturday.setDate(thisSunday.getDate() + 6);
|
|
788
|
-
|
|
789
|
-
const nextSunday = new Date(thisSunday);
|
|
790
|
-
nextSunday.setDate(thisSunday.getDate() + 7);
|
|
791
|
-
const nextSaturday = new Date(nextSunday);
|
|
792
|
-
nextSaturday.setDate(nextSunday.getDate() + 6);
|
|
793
|
-
|
|
794
|
-
const next7To = new Date(today);
|
|
795
|
-
next7To.setDate(today.getDate() + 6);
|
|
796
|
-
|
|
797
|
-
const next30To = new Date(today);
|
|
798
|
-
next30To.setDate(today.getDate() + 29);
|
|
799
|
-
|
|
800
|
-
return [
|
|
801
|
-
{ label: "Today", key: "T", from: this.formatISODate(today), to: this.formatISODate(today) },
|
|
802
|
-
{ label: "Tomorrow", key: "M", from: this.formatISODate(tomorrow), to: this.formatISODate(tomorrow) },
|
|
803
|
-
{ label: "Before Today", key: "B", from: "1970-01-01", to: this.formatISODate(yesterday) },
|
|
804
|
-
{ label: "This Week", key: "W", from: this.formatISODate(thisSunday), to: this.formatISODate(thisSaturday) },
|
|
805
|
-
{ label: "Next Week", key: "N", from: this.formatISODate(nextSunday), to: this.formatISODate(nextSaturday) },
|
|
806
|
-
{ label: "Next 7 Days", key: "7", from: this.formatISODate(today), to: this.formatISODate(next7To) },
|
|
807
|
-
{ label: "Next 30 Days", key: "3", from: this.formatISODate(today), to: this.formatISODate(next30To), fullWidth: true },
|
|
808
|
-
];
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
private selectQuickSelect(qs: QuickSelect) {
|
|
812
|
-
if (this.disabled) return;
|
|
813
|
-
this.draftFrom = qs.from;
|
|
814
|
-
this.draftTo = qs.to;
|
|
815
|
-
this.draftActivePreset = qs.label;
|
|
816
|
-
this.isSelectingRange = false;
|
|
817
|
-
this.hoverDate = null;
|
|
818
|
-
|
|
819
|
-
const date = this.parseISODate(qs.from);
|
|
820
|
-
if (date) {
|
|
821
|
-
this.viewYear = date.getFullYear();
|
|
822
|
-
this.viewMonth = date.getMonth();
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
// ── Calendar navigation ──
|
|
827
|
-
|
|
828
|
-
private previousMonth() {
|
|
829
|
-
if (this.viewMonth === 0) {
|
|
830
|
-
this.viewMonth = 11;
|
|
831
|
-
this.viewYear--;
|
|
832
|
-
} else {
|
|
833
|
-
this.viewMonth--;
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
private nextMonth() {
|
|
838
|
-
if (this.viewMonth === 11) {
|
|
839
|
-
this.viewMonth = 0;
|
|
840
|
-
this.viewYear++;
|
|
841
|
-
} else {
|
|
842
|
-
this.viewMonth++;
|
|
843
|
-
}
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
private getMonthName(): string {
|
|
847
|
-
return new Intl.DateTimeFormat("en-US", { month: "long" }).format(
|
|
848
|
-
new Date(this.viewYear, this.viewMonth, 1)
|
|
849
|
-
);
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
private getWeekdayLabels(): string[] {
|
|
853
|
-
const formatter = new Intl.DateTimeFormat("en-US", { weekday: "short" });
|
|
854
|
-
const base = new Date(2024, 0, 7); // Sunday Jan 7 2024
|
|
855
|
-
return Array.from({ length: 7 }, (_, i) => {
|
|
856
|
-
const offset = this.weekStart === "mon" ? i + 1 : i;
|
|
857
|
-
const d = new Date(base);
|
|
858
|
-
d.setDate(base.getDate() + offset);
|
|
859
|
-
return formatter.format(d).substring(0, 2);
|
|
860
|
-
});
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
// ── Calendar day computation ──
|
|
864
|
-
|
|
865
|
-
private getCalendarDays(): RangeDay[] {
|
|
866
|
-
const today = new Date();
|
|
867
|
-
today.setHours(0, 0, 0, 0);
|
|
868
|
-
|
|
869
|
-
const firstDay = new Date(this.viewYear, this.viewMonth, 1);
|
|
870
|
-
const lastDay = new Date(this.viewYear, this.viewMonth + 1, 0);
|
|
871
|
-
|
|
872
|
-
const draftFromDate = this.draftFrom ? this.parseISODate(this.draftFrom) : null;
|
|
873
|
-
const draftToDate = this.draftTo ? this.parseISODate(this.draftTo) : null;
|
|
874
|
-
|
|
875
|
-
let effectiveFrom: Date | null = draftFromDate;
|
|
876
|
-
let effectiveTo: Date | null = draftToDate;
|
|
877
|
-
|
|
878
|
-
if (this.isSelectingRange && this.hoverDate && draftFromDate) {
|
|
879
|
-
const hDate = this.parseISODate(this.hoverDate);
|
|
880
|
-
if (hDate) {
|
|
881
|
-
if (hDate.getTime() >= draftFromDate.getTime()) {
|
|
882
|
-
effectiveFrom = draftFromDate;
|
|
883
|
-
effectiveTo = hDate;
|
|
884
|
-
} else {
|
|
885
|
-
effectiveFrom = hDate;
|
|
886
|
-
effectiveTo = draftFromDate;
|
|
887
|
-
}
|
|
888
|
-
}
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
const days: RangeDay[] = [];
|
|
892
|
-
|
|
893
|
-
let startDay = firstDay.getDay();
|
|
894
|
-
if (this.weekStart === "mon") {
|
|
895
|
-
startDay = startDay === 0 ? 6 : startDay - 1;
|
|
896
|
-
}
|
|
897
|
-
for (let i = startDay - 1; i >= 0; i--) {
|
|
898
|
-
const date = new Date(this.viewYear, this.viewMonth, -i);
|
|
899
|
-
days.push({
|
|
900
|
-
date,
|
|
901
|
-
day: date.getDate(),
|
|
902
|
-
isCurrentMonth: false,
|
|
903
|
-
isToday: false,
|
|
904
|
-
isDraftFrom: false,
|
|
905
|
-
isDraftTo: false,
|
|
906
|
-
isInRange: false,
|
|
907
|
-
isDisabled: true,
|
|
908
|
-
isWeekend: date.getDay() === 0 || date.getDay() === 6,
|
|
909
|
-
});
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
for (let d = 1; d <= lastDay.getDate(); d++) {
|
|
913
|
-
const date = new Date(this.viewYear, this.viewMonth, d);
|
|
914
|
-
const t = date.getTime();
|
|
915
|
-
|
|
916
|
-
const isDraftFrom = !!effectiveFrom && this.isSameDay(date, effectiveFrom);
|
|
917
|
-
const isDraftTo = !!effectiveTo && this.isSameDay(date, effectiveTo);
|
|
918
|
-
const isInRange =
|
|
919
|
-
!!effectiveFrom &&
|
|
920
|
-
!!effectiveTo &&
|
|
921
|
-
t > effectiveFrom.getTime() &&
|
|
922
|
-
t < effectiveTo.getTime();
|
|
923
|
-
|
|
924
|
-
days.push({
|
|
925
|
-
date,
|
|
926
|
-
day: d,
|
|
927
|
-
isCurrentMonth: true,
|
|
928
|
-
isToday: this.isSameDay(date, today),
|
|
929
|
-
isDraftFrom,
|
|
930
|
-
isDraftTo,
|
|
931
|
-
isInRange,
|
|
932
|
-
isDisabled: this.isDateDisabled(date),
|
|
933
|
-
isWeekend: date.getDay() === 0 || date.getDay() === 6,
|
|
934
|
-
});
|
|
935
|
-
}
|
|
936
|
-
|
|
937
|
-
const remaining = 42 - days.length;
|
|
938
|
-
for (let i = 1; i <= remaining; i++) {
|
|
939
|
-
const date = new Date(this.viewYear, this.viewMonth + 1, i);
|
|
940
|
-
days.push({
|
|
941
|
-
date,
|
|
942
|
-
day: date.getDate(),
|
|
943
|
-
isCurrentMonth: false,
|
|
944
|
-
isToday: false,
|
|
945
|
-
isDraftFrom: false,
|
|
946
|
-
isDraftTo: false,
|
|
947
|
-
isInRange: false,
|
|
948
|
-
isDisabled: true,
|
|
949
|
-
isWeekend: date.getDay() === 0 || date.getDay() === 6,
|
|
950
|
-
});
|
|
951
|
-
}
|
|
952
|
-
|
|
953
|
-
return days;
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
// ── Day click / hover ──
|
|
957
|
-
|
|
958
|
-
private handleDayClick(day: RangeDay) {
|
|
959
|
-
if (day.isDisabled || this.disabled) return;
|
|
960
|
-
const iso = this.formatISODate(day.date);
|
|
961
|
-
|
|
962
|
-
if (!this.isSelectingRange) {
|
|
963
|
-
this.draftFrom = iso;
|
|
964
|
-
this.draftTo = "";
|
|
965
|
-
this.draftActivePreset = null;
|
|
966
|
-
this.isSelectingRange = true;
|
|
967
|
-
this.hoverDate = null;
|
|
968
|
-
} else {
|
|
969
|
-
const fromDate = this.parseISODate(this.draftFrom);
|
|
970
|
-
if (!fromDate) {
|
|
971
|
-
this.draftFrom = iso;
|
|
972
|
-
this.draftTo = "";
|
|
973
|
-
return;
|
|
974
|
-
}
|
|
975
|
-
|
|
976
|
-
if (day.date.getTime() >= fromDate.getTime()) {
|
|
977
|
-
this.draftTo = iso;
|
|
978
|
-
} else {
|
|
979
|
-
this.draftTo = this.draftFrom;
|
|
980
|
-
this.draftFrom = iso;
|
|
981
|
-
}
|
|
982
|
-
|
|
983
|
-
this.isSelectingRange = false;
|
|
984
|
-
this.hoverDate = null;
|
|
985
|
-
this.draftActivePreset = null;
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
|
|
989
|
-
private handleDayHover(day: RangeDay) {
|
|
990
|
-
if (!this.isSelectingRange || day.isDisabled) return;
|
|
991
|
-
this.hoverDate = this.formatISODate(day.date);
|
|
992
|
-
}
|
|
993
|
-
|
|
994
|
-
// ── Grid keyboard navigation (APG grid pattern) ──
|
|
995
|
-
|
|
996
|
-
/**
|
|
997
|
-
* The cell that carries tabindex="0". Prefers the last roved date, then the
|
|
998
|
-
* draft start, then today, then the first selectable day — always exactly
|
|
999
|
-
* one Tab stop, even after arrowing away with nothing selected.
|
|
1000
|
-
*/
|
|
1001
|
-
private getRovingIso(days: RangeDay[]): string {
|
|
1002
|
-
const inView = days.filter((d) => d.isCurrentMonth);
|
|
1003
|
-
if (inView.length === 0) return "";
|
|
1004
|
-
|
|
1005
|
-
const candidates = [
|
|
1006
|
-
this.focusedDate,
|
|
1007
|
-
this.draftFrom,
|
|
1008
|
-
this.formatISODate(new Date()),
|
|
1009
|
-
];
|
|
1010
|
-
for (const iso of candidates) {
|
|
1011
|
-
if (iso && inView.some((d) => this.formatISODate(d.date) === iso)) {
|
|
1012
|
-
return iso;
|
|
1013
|
-
}
|
|
1014
|
-
}
|
|
1015
|
-
const firstEnabled = inView.find((d) => !d.isDisabled) ?? inView[0];
|
|
1016
|
-
return this.formatISODate(firstEnabled.date);
|
|
1017
|
-
}
|
|
1018
|
-
|
|
1019
|
-
private handleGridKeydown = (e: KeyboardEvent) => {
|
|
1020
|
-
const cell = (e.target as HTMLElement).closest?.(".day-cell") as
|
|
1021
|
-
| HTMLElement
|
|
1022
|
-
| null;
|
|
1023
|
-
const iso = cell?.dataset.iso;
|
|
1024
|
-
if (!iso) return;
|
|
1025
|
-
const date = this.parseISODate(iso);
|
|
1026
|
-
if (!date) return;
|
|
1027
|
-
|
|
1028
|
-
if (e.key === "Enter" || e.key === " ") {
|
|
1029
|
-
e.preventDefault();
|
|
1030
|
-
const isDisabled = this.isDateDisabled(date);
|
|
1031
|
-
if (!isDisabled) {
|
|
1032
|
-
this.handleDayClick({
|
|
1033
|
-
date,
|
|
1034
|
-
day: date.getDate(),
|
|
1035
|
-
isCurrentMonth: true,
|
|
1036
|
-
isToday: false,
|
|
1037
|
-
isDraftFrom: false,
|
|
1038
|
-
isDraftTo: false,
|
|
1039
|
-
isInRange: false,
|
|
1040
|
-
isDisabled,
|
|
1041
|
-
isWeekend: false,
|
|
1042
|
-
});
|
|
1043
|
-
}
|
|
1044
|
-
return;
|
|
1045
|
-
}
|
|
1046
|
-
|
|
1047
|
-
const next = new Date(date);
|
|
1048
|
-
const dow = next.getDay();
|
|
1049
|
-
switch (e.key) {
|
|
1050
|
-
case "ArrowLeft":
|
|
1051
|
-
next.setDate(next.getDate() - 1);
|
|
1052
|
-
break;
|
|
1053
|
-
case "ArrowRight":
|
|
1054
|
-
next.setDate(next.getDate() + 1);
|
|
1055
|
-
break;
|
|
1056
|
-
case "ArrowUp":
|
|
1057
|
-
next.setDate(next.getDate() - 7);
|
|
1058
|
-
break;
|
|
1059
|
-
case "ArrowDown":
|
|
1060
|
-
next.setDate(next.getDate() + 7);
|
|
1061
|
-
break;
|
|
1062
|
-
case "Home":
|
|
1063
|
-
next.setDate(
|
|
1064
|
-
next.getDate() -
|
|
1065
|
-
(this.weekStart === "mon" ? (dow === 0 ? 6 : dow - 1) : dow)
|
|
1066
|
-
);
|
|
1067
|
-
break;
|
|
1068
|
-
case "End":
|
|
1069
|
-
next.setDate(
|
|
1070
|
-
next.getDate() +
|
|
1071
|
-
(this.weekStart === "mon" ? (dow === 0 ? 0 : 7 - dow) : 6 - dow)
|
|
1072
|
-
);
|
|
1073
|
-
break;
|
|
1074
|
-
case "PageUp":
|
|
1075
|
-
if (e.shiftKey) next.setFullYear(next.getFullYear() - 1);
|
|
1076
|
-
else next.setMonth(next.getMonth() - 1);
|
|
1077
|
-
break;
|
|
1078
|
-
case "PageDown":
|
|
1079
|
-
if (e.shiftKey) next.setFullYear(next.getFullYear() + 1);
|
|
1080
|
-
else next.setMonth(next.getMonth() + 1);
|
|
1081
|
-
break;
|
|
1082
|
-
default:
|
|
1083
|
-
return;
|
|
1084
|
-
}
|
|
1085
|
-
|
|
1086
|
-
e.preventDefault();
|
|
1087
|
-
this.moveGridFocusTo(next);
|
|
1088
|
-
};
|
|
1089
|
-
|
|
1090
|
-
private async moveGridFocusTo(date: Date) {
|
|
1091
|
-
this.focusedDate = this.formatISODate(date);
|
|
1092
|
-
|
|
1093
|
-
if (
|
|
1094
|
-
date.getMonth() !== this.viewMonth ||
|
|
1095
|
-
date.getFullYear() !== this.viewYear
|
|
1096
|
-
) {
|
|
1097
|
-
this.viewMonth = date.getMonth();
|
|
1098
|
-
this.viewYear = date.getFullYear();
|
|
1099
|
-
}
|
|
1100
|
-
|
|
1101
|
-
// Keyboard twin of handleDayHover: keep the range preview following focus.
|
|
1102
|
-
if (this.isSelectingRange && !this.isDateDisabled(date)) {
|
|
1103
|
-
this.hoverDate = this.focusedDate;
|
|
1104
|
-
}
|
|
1105
|
-
|
|
1106
|
-
await this.updateComplete;
|
|
1107
|
-
this.renderRoot
|
|
1108
|
-
.querySelector<HTMLElement>(`.day-cell[data-iso="${this.focusedDate}"]`)
|
|
1109
|
-
?.focus();
|
|
1110
|
-
}
|
|
1111
|
-
|
|
1112
|
-
// ── Render ──
|
|
1113
|
-
|
|
1114
|
-
render() {
|
|
1115
|
-
const quickSelects = this.getQuickSelects();
|
|
1116
|
-
const days = this.getCalendarDays();
|
|
1117
|
-
const rovingIso = this.getRovingIso(days);
|
|
1118
|
-
const weekdayLabels = this.getWeekdayLabels();
|
|
1119
|
-
|
|
1120
|
-
const draftFromDisplay = this.draftFrom ? this.formatDisplayDate(this.draftFrom) : "";
|
|
1121
|
-
const draftToDisplay = this.draftTo ? this.formatDisplayDate(this.draftTo) : "";
|
|
1122
|
-
const triggerLabel = this.getTriggerLabel();
|
|
1123
|
-
const isDraftEmpty = !this.draftFrom && !this.draftTo;
|
|
1124
|
-
const isPopup = this.mode === "popup";
|
|
1125
|
-
|
|
1126
|
-
return html`
|
|
1127
|
-
${this.triggerVariant === "icon"
|
|
1128
|
-
? html`
|
|
1129
|
-
<rel-button
|
|
1130
|
-
variant="icon"
|
|
1131
|
-
tone="secondary"
|
|
1132
|
-
?disabled=${this.disabled}
|
|
1133
|
-
aria-haspopup="dialog"
|
|
1134
|
-
aria-expanded=${this.open}
|
|
1135
|
-
aria-label=${triggerLabel || this.placeholder}
|
|
1136
|
-
@click=${() => this.toggleOpen()}
|
|
1137
|
-
>
|
|
1138
|
-
<rel-icon name="calendar-range"></rel-icon>
|
|
1139
|
-
</rel-button>
|
|
1140
|
-
`
|
|
1141
|
-
: html`
|
|
1142
|
-
<button
|
|
1143
|
-
part="trigger" class="trigger-button"
|
|
1144
|
-
type="button"
|
|
1145
|
-
?disabled=${this.disabled}
|
|
1146
|
-
aria-haspopup="dialog"
|
|
1147
|
-
aria-expanded=${this.open}
|
|
1148
|
-
aria-label=${triggerLabel || this.placeholder}
|
|
1149
|
-
@click=${this.toggleOpen}
|
|
1150
|
-
>
|
|
1151
|
-
<span class="trigger-content ${triggerLabel ? "" : "placeholder"}">
|
|
1152
|
-
${triggerLabel || this.placeholder}
|
|
1153
|
-
</span>
|
|
1154
|
-
<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true">
|
|
1155
|
-
<path d="M4 2h1V1h2v1h2V1h2v1h1a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2zm8 3H4v7h8V5z"/>
|
|
1156
|
-
</svg>
|
|
1157
|
-
</button>
|
|
1158
|
-
`}
|
|
1159
|
-
|
|
1160
|
-
${isPopup && this.open
|
|
1161
|
-
? html`<div part="overlay" class="backdrop" popover="manual" @click=${this.cancelPopover}></div>`
|
|
1162
|
-
: nothing}
|
|
1163
|
-
|
|
1164
|
-
<div
|
|
1165
|
-
part="panel" class="popover ${this.open ? "open" : ""} ${isPopup ? "popup" : ""}"
|
|
1166
|
-
popover="manual"
|
|
1167
|
-
role="dialog"
|
|
1168
|
-
aria-label="Select date range"
|
|
1169
|
-
>
|
|
1170
|
-
<div class="picker-wrapper">
|
|
1171
|
-
|
|
1172
|
-
<!-- ── Left: Quick select ── -->
|
|
1173
|
-
<div part="list" class="presets">
|
|
1174
|
-
<div class="presets-grid" role="list" aria-label="Quick date selections">
|
|
1175
|
-
${quickSelects.map(
|
|
1176
|
-
(qs) => html`
|
|
1177
|
-
<button
|
|
1178
|
-
part="option" class="preset-item ${qs.fullWidth ? "full-width" : ""} ${this.draftActivePreset === qs.label ? "active" : ""}"
|
|
1179
|
-
type="button"
|
|
1180
|
-
role="listitem"
|
|
1181
|
-
?disabled=${this.disabled}
|
|
1182
|
-
aria-pressed=${this.draftActivePreset === qs.label}
|
|
1183
|
-
@click=${() => this.selectQuickSelect(qs)}
|
|
1184
|
-
>
|
|
1185
|
-
<span>${qs.label}</span>
|
|
1186
|
-
${this.draftActivePreset === qs.label
|
|
1187
|
-
? html`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" aria-hidden="true">
|
|
1188
|
-
<circle cx="12" cy="12" r="12" fill="var(--rel-bg-brand)"/>
|
|
1189
|
-
<path d="M7 12.5l3.5 3.5 6.5-7" stroke="var(--rel-text-static-dark)" stroke-width="2"
|
|
1190
|
-
stroke-linecap="round" stroke-linejoin="round"/>
|
|
1191
|
-
</svg>`
|
|
1192
|
-
: nothing}
|
|
1193
|
-
</button>
|
|
1194
|
-
`
|
|
1195
|
-
)}
|
|
1196
|
-
</div>
|
|
1197
|
-
|
|
1198
|
-
<div class="date-inputs">
|
|
1199
|
-
<div class="date-input-group" aria-label="From date">
|
|
1200
|
-
<span class="date-input-label">FROM</span>
|
|
1201
|
-
<div class="date-input-value ${draftFromDisplay ? "" : "empty"}">
|
|
1202
|
-
${draftFromDisplay || "MM/DD/YYYY"}
|
|
1203
|
-
</div>
|
|
1204
|
-
</div>
|
|
1205
|
-
<div class="date-input-group" aria-label="To date">
|
|
1206
|
-
<span class="date-input-label">TO</span>
|
|
1207
|
-
<div class="date-input-value ${draftToDisplay ? "" : "empty"}">
|
|
1208
|
-
${draftToDisplay || "MM/DD/YYYY"}
|
|
1209
|
-
</div>
|
|
1210
|
-
</div>
|
|
1211
|
-
</div>
|
|
1212
|
-
</div>
|
|
1213
|
-
|
|
1214
|
-
<!-- ── Right: Calendar panel ── -->
|
|
1215
|
-
<div class="calendar-panel">
|
|
1216
|
-
|
|
1217
|
-
<div class="calendar-header">
|
|
1218
|
-
<button
|
|
1219
|
-
part="action" class="nav-btn"
|
|
1220
|
-
type="button"
|
|
1221
|
-
aria-label="Previous month"
|
|
1222
|
-
@click=${this.previousMonth}
|
|
1223
|
-
>
|
|
1224
|
-
<rel-icon name="chevron-left" size="sm"></rel-icon>
|
|
1225
|
-
</button>
|
|
1226
|
-
<span class="month-label">${this.getMonthName()} ${this.viewYear}</span>
|
|
1227
|
-
<button
|
|
1228
|
-
part="action" class="nav-btn"
|
|
1229
|
-
type="button"
|
|
1230
|
-
aria-label="Next month"
|
|
1231
|
-
@click=${this.nextMonth}
|
|
1232
|
-
>
|
|
1233
|
-
<rel-icon name="chevron-right" size="sm"></rel-icon>
|
|
1234
|
-
</button>
|
|
1235
|
-
</div>
|
|
1236
|
-
|
|
1237
|
-
<div class="week-header" role="row">
|
|
1238
|
-
${weekdayLabels.map(
|
|
1239
|
-
(label) => html`
|
|
1240
|
-
<div class="week-day" role="columnheader" aria-label="${label}">
|
|
1241
|
-
${label}
|
|
1242
|
-
</div>
|
|
1243
|
-
`
|
|
1244
|
-
)}
|
|
1245
|
-
</div>
|
|
1246
|
-
|
|
1247
|
-
<div
|
|
1248
|
-
part="list" class="calendar-grid"
|
|
1249
|
-
role="grid"
|
|
1250
|
-
aria-label="Select date range"
|
|
1251
|
-
@mouseleave=${() => { this.hoverDate = null; }}
|
|
1252
|
-
@keydown=${this.handleGridKeydown}
|
|
1253
|
-
>
|
|
1254
|
-
${days.map((day) => {
|
|
1255
|
-
const iso = this.formatISODate(day.date);
|
|
1256
|
-
const cellClasses = [
|
|
1257
|
-
"day-cell",
|
|
1258
|
-
day.isInRange ? "in-range" : "",
|
|
1259
|
-
day.isDraftFrom ? "range-start" : "",
|
|
1260
|
-
day.isDraftTo ? "range-end" : "",
|
|
1261
|
-
day.isToday ? "today" : "",
|
|
1262
|
-
day.isDisabled ? "disabled" : "",
|
|
1263
|
-
!day.isCurrentMonth ? "other-month" : "",
|
|
1264
|
-
day.isWeekend ? "weekend" : "",
|
|
1265
|
-
]
|
|
1266
|
-
.filter(Boolean)
|
|
1267
|
-
.join(" ");
|
|
1268
|
-
|
|
1269
|
-
return html`
|
|
1270
|
-
<div
|
|
1271
|
-
class="${cellClasses}"
|
|
1272
|
-
role="gridcell"
|
|
1273
|
-
tabindex="${day.isCurrentMonth && iso === rovingIso ? 0 : -1}"
|
|
1274
|
-
data-iso="${iso}"
|
|
1275
|
-
aria-label="${iso}"
|
|
1276
|
-
aria-selected="${day.isDraftFrom || day.isDraftTo || day.isInRange}"
|
|
1277
|
-
aria-disabled="${day.isDisabled ? "true" : nothing}"
|
|
1278
|
-
@click=${() => this.handleDayClick(day)}
|
|
1279
|
-
@mouseenter=${() => this.handleDayHover(day)}
|
|
1280
|
-
>
|
|
1281
|
-
<span class="day-inner">${day.day}</span>
|
|
1282
|
-
</div>
|
|
1283
|
-
`;
|
|
1284
|
-
})}
|
|
1285
|
-
</div>
|
|
1286
|
-
|
|
1287
|
-
<div part="footer" class="calendar-footer">
|
|
1288
|
-
<rel-button
|
|
1289
|
-
variant="secondary"
|
|
1290
|
-
size="small"
|
|
1291
|
-
border="corner-radius"
|
|
1292
|
-
?disabled=${isDraftEmpty}
|
|
1293
|
-
@click=${() => this.resetDraft()}
|
|
1294
|
-
>
|
|
1295
|
-
Reset
|
|
1296
|
-
</rel-button>
|
|
1297
|
-
<div class="footer-right">
|
|
1298
|
-
<rel-button
|
|
1299
|
-
variant="secondary"
|
|
1300
|
-
size="small"
|
|
1301
|
-
border="corner-radius"
|
|
1302
|
-
@click=${() => this.cancelPopover()}
|
|
1303
|
-
>
|
|
1304
|
-
Cancel
|
|
1305
|
-
</rel-button>
|
|
1306
|
-
<rel-button
|
|
1307
|
-
variant="primary"
|
|
1308
|
-
tone="default"
|
|
1309
|
-
size="small"
|
|
1310
|
-
border="corner-radius"
|
|
1311
|
-
?disabled=${isDraftEmpty}
|
|
1312
|
-
@click=${() => this.applySelection()}
|
|
1313
|
-
>
|
|
1314
|
-
Apply
|
|
1315
|
-
</rel-button>
|
|
1316
|
-
</div>
|
|
1317
|
-
</div>
|
|
1318
|
-
|
|
1319
|
-
</div>
|
|
1320
|
-
</div>
|
|
1321
|
-
</div>
|
|
1322
|
-
`;
|
|
1323
|
-
|
|
1324
|
-
}
|
|
1325
|
-
}
|
|
1326
|
-
|
|
1327
|
-
declare global {
|
|
1328
|
-
interface HTMLElementTagNameMap {
|
|
1329
|
-
"rel-range-picker": RelRangePicker;
|
|
1330
|
-
}
|
|
1331
|
-
}
|