@latty-ds/web 0.2.0
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/LICENSE +21 -0
- package/README.md +106 -0
- package/custom-elements.json +8785 -0
- package/dist/base/index.d.ts +1 -0
- package/dist/base/index.js +35 -0
- package/dist/base/themeable-element.d.ts +20 -0
- package/dist/components/accordion/accordion.d.ts +82 -0
- package/dist/components/accordion/accordion.styles.d.ts +1 -0
- package/dist/components/accordion/accordion.types.d.ts +10 -0
- package/dist/components/accordion/index.d.ts +8 -0
- package/dist/components/accordion/index.js +468 -0
- package/dist/components/alert/alert.d.ts +51 -0
- package/dist/components/alert/alert.styles.d.ts +1 -0
- package/dist/components/alert/alert.types.d.ts +2 -0
- package/dist/components/alert/index.d.ts +2 -0
- package/dist/components/alert/index.js +746 -0
- package/dist/components/avatar/avatar.d.ts +27 -0
- package/dist/components/avatar/avatar.styles.d.ts +1 -0
- package/dist/components/avatar/avatar.types.d.ts +3 -0
- package/dist/components/avatar/index.d.ts +2 -0
- package/dist/components/avatar/index.js +222 -0
- package/dist/components/badge/badge.d.ts +29 -0
- package/dist/components/badge/badge.styles.d.ts +1 -0
- package/dist/components/badge/badge.types.d.ts +3 -0
- package/dist/components/badge/index.d.ts +2 -0
- package/dist/components/badge/index.js +277 -0
- package/dist/components/breadcrumb/breadcrumb.d.ts +53 -0
- package/dist/components/breadcrumb/breadcrumb.styles.d.ts +2 -0
- package/dist/components/breadcrumb/breadcrumb.types.d.ts +1 -0
- package/dist/components/breadcrumb/index.d.ts +2 -0
- package/dist/components/breadcrumb/index.js +166 -0
- package/dist/components/button/button.d.ts +111 -0
- package/dist/components/button/button.styles.d.ts +1 -0
- package/dist/components/button/button.types.d.ts +38 -0
- package/dist/components/button/index.d.ts +8 -0
- package/dist/components/button/index.js +466 -0
- package/dist/components/calendar/calendar.d.ts +84 -0
- package/dist/components/calendar/calendar.styles.d.ts +1 -0
- package/dist/components/calendar/calendar.types.d.ts +15 -0
- package/dist/components/calendar/index.d.ts +1 -0
- package/dist/components/calendar/index.js +958 -0
- package/dist/components/checkbox/checkbox.d.ts +113 -0
- package/dist/components/checkbox/checkbox.styles.d.ts +1 -0
- package/dist/components/checkbox/checkbox.types.d.ts +21 -0
- package/dist/components/checkbox/index.d.ts +8 -0
- package/dist/components/checkbox/index.js +320 -0
- package/dist/components/chip/chip.d.ts +35 -0
- package/dist/components/chip/chip.styles.d.ts +1 -0
- package/dist/components/chip/chip.types.d.ts +3 -0
- package/dist/components/chip/index.d.ts +2 -0
- package/dist/components/chip/index.js +282 -0
- package/dist/components/color-input/color-input.d.ts +55 -0
- package/dist/components/color-input/color-input.styles.d.ts +1 -0
- package/dist/components/color-input/color-input.types.d.ts +2 -0
- package/dist/components/color-input/index.d.ts +1 -0
- package/dist/components/color-input/index.js +489 -0
- package/dist/components/combobox/combobox.d.ts +59 -0
- package/dist/components/combobox/combobox.styles.d.ts +1 -0
- package/dist/components/combobox/combobox.types.d.ts +7 -0
- package/dist/components/combobox/index.d.ts +2 -0
- package/dist/components/combobox/index.js +1988 -0
- package/dist/components/date-input/date-input.d.ts +66 -0
- package/dist/components/date-input/date-input.styles.d.ts +1 -0
- package/dist/components/date-input/date-input.types.d.ts +3 -0
- package/dist/components/date-input/index.d.ts +2 -0
- package/dist/components/date-input/index.js +2863 -0
- package/dist/components/datepicker/datepicker.d.ts +52 -0
- package/dist/components/datepicker/datepicker.styles.d.ts +1 -0
- package/dist/components/datepicker/datepicker.types.d.ts +3 -0
- package/dist/components/datepicker/index.d.ts +2 -0
- package/dist/components/datepicker/index.js +416 -0
- package/dist/components/dialog/dialog.d.ts +114 -0
- package/dist/components/dialog/dialog.styles.d.ts +1 -0
- package/dist/components/dialog/dialog.types.d.ts +11 -0
- package/dist/components/dialog/index.d.ts +2 -0
- package/dist/components/dialog/index.js +920 -0
- package/dist/components/divider/divider.d.ts +35 -0
- package/dist/components/divider/divider.styles.d.ts +1 -0
- package/dist/components/divider/divider.types.d.ts +2 -0
- package/dist/components/divider/index.d.ts +2 -0
- package/dist/components/divider/index.js +149 -0
- package/dist/components/dropdown/dropdown-item.d.ts +24 -0
- package/dist/components/dropdown/dropdown-item.styles.d.ts +1 -0
- package/dist/components/dropdown/dropdown.d.ts +30 -0
- package/dist/components/dropdown/dropdown.styles.d.ts +1 -0
- package/dist/components/dropdown/dropdown.types.d.ts +1 -0
- package/dist/components/dropdown/index.d.ts +3 -0
- package/dist/components/dropdown/index.js +1791 -0
- package/dist/components/header/header.d.ts +19 -0
- package/dist/components/header/header.styles.d.ts +1 -0
- package/dist/components/header/header.types.d.ts +1 -0
- package/dist/components/header/index.d.ts +2 -0
- package/dist/components/header/index.js +104 -0
- package/dist/components/icon-button/icon-button.d.ts +52 -0
- package/dist/components/icon-button/icon-button.styles.d.ts +1 -0
- package/dist/components/icon-button/icon-button.types.d.ts +8 -0
- package/dist/components/icon-button/index.d.ts +1 -0
- package/dist/components/icon-button/index.js +342 -0
- package/dist/components/image/image.d.ts +26 -0
- package/dist/components/image/image.styles.d.ts +1 -0
- package/dist/components/image/image.types.d.ts +0 -0
- package/dist/components/image/index.d.ts +1 -0
- package/dist/components/image/index.js +105 -0
- package/dist/components/link/index.d.ts +1 -0
- package/dist/components/link/index.js +108 -0
- package/dist/components/link/link.d.ts +22 -0
- package/dist/components/link/link.styles.d.ts +1 -0
- package/dist/components/link/link.types.d.ts +1 -0
- package/dist/components/list/index.d.ts +9 -0
- package/dist/components/list/index.js +254 -0
- package/dist/components/list/list-item.d.ts +41 -0
- package/dist/components/list/list-item.styles.d.ts +1 -0
- package/dist/components/list/list.d.ts +85 -0
- package/dist/components/list/list.styles.d.ts +1 -0
- package/dist/components/list/list.types.d.ts +16 -0
- package/dist/components/nav/index.d.ts +3 -0
- package/dist/components/nav/index.js +345 -0
- package/dist/components/nav/nav-item.d.ts +73 -0
- package/dist/components/nav/nav.d.ts +49 -0
- package/dist/components/nav/nav.styles.d.ts +2 -0
- package/dist/components/nav/nav.types.d.ts +1 -0
- package/dist/components/pagination/index.d.ts +2 -0
- package/dist/components/pagination/index.js +210 -0
- package/dist/components/pagination/pagination.d.ts +34 -0
- package/dist/components/pagination/pagination.styles.d.ts +1 -0
- package/dist/components/pagination/pagination.types.d.ts +1 -0
- package/dist/components/progress/index.d.ts +2 -0
- package/dist/components/progress/index.js +167 -0
- package/dist/components/progress/progress.d.ts +44 -0
- package/dist/components/progress/progress.styles.d.ts +1 -0
- package/dist/components/progress/progress.types.d.ts +2 -0
- package/dist/components/radio/index.d.ts +8 -0
- package/dist/components/radio/index.js +294 -0
- package/dist/components/radio/radio.d.ts +96 -0
- package/dist/components/radio/radio.styles.d.ts +1 -0
- package/dist/components/radio/radio.types.d.ts +21 -0
- package/dist/components/radio-group/index.d.ts +8 -0
- package/dist/components/radio-group/index.js +384 -0
- package/dist/components/radio-group/radio-group.d.ts +100 -0
- package/dist/components/radio-group/radio-group.styles.d.ts +1 -0
- package/dist/components/radio-group/radio-group.types.d.ts +8 -0
- package/dist/components/select/index.d.ts +8 -0
- package/dist/components/select/index.js +2123 -0
- package/dist/components/select/select.d.ts +129 -0
- package/dist/components/select/select.styles.d.ts +1 -0
- package/dist/components/select/select.types.d.ts +37 -0
- package/dist/components/shared/backdrop.styles.d.ts +1 -0
- package/dist/components/shared/floating.d.ts +10 -0
- package/dist/components/sidepanel/index.d.ts +1 -0
- package/dist/components/sidepanel/index.js +768 -0
- package/dist/components/sidepanel/sidepanel.d.ts +48 -0
- package/dist/components/sidepanel/sidepanel.styles.d.ts +1 -0
- package/dist/components/sidepanel/sidepanel.types.d.ts +1 -0
- package/dist/components/skeleton/index.d.ts +2 -0
- package/dist/components/skeleton/index.js +129 -0
- package/dist/components/skeleton/skeleton.d.ts +39 -0
- package/dist/components/skeleton/skeleton.styles.d.ts +1 -0
- package/dist/components/skeleton/skeleton.types.d.ts +1 -0
- package/dist/components/slider/index.d.ts +2 -0
- package/dist/components/slider/index.js +635 -0
- package/dist/components/slider/slider.d.ts +33 -0
- package/dist/components/slider/slider.styles.d.ts +1 -0
- package/dist/components/slider/slider.types.d.ts +1 -0
- package/dist/components/snackbar/index.d.ts +2 -0
- package/dist/components/snackbar/index.js +358 -0
- package/dist/components/snackbar/snackbar.d.ts +63 -0
- package/dist/components/snackbar/snackbar.styles.d.ts +1 -0
- package/dist/components/snackbar/snackbar.types.d.ts +1 -0
- package/dist/components/spinner/index.d.ts +8 -0
- package/dist/components/spinner/index.js +131 -0
- package/dist/components/spinner/spineer.styles.d.ts +1 -0
- package/dist/components/spinner/spinner.d.ts +52 -0
- package/dist/components/spinner/spinner.types.d.ts +18 -0
- package/dist/components/surface/index.d.ts +8 -0
- package/dist/components/surface/index.js +128 -0
- package/dist/components/surface/surface.d.ts +48 -0
- package/dist/components/surface/surface.styles.d.ts +1 -0
- package/dist/components/surface/surface.types.d.ts +20 -0
- package/dist/components/switch/index.d.ts +8 -0
- package/dist/components/switch/index.js +293 -0
- package/dist/components/switch/switch.d.ts +90 -0
- package/dist/components/switch/switch.styles.d.ts +1 -0
- package/dist/components/switch/switch.types.d.ts +21 -0
- package/dist/components/tab/index.d.ts +9 -0
- package/dist/components/tab/index.js +252 -0
- package/dist/components/tab/tab-panel.d.ts +28 -0
- package/dist/components/tab/tab-panel.styles.d.ts +1 -0
- package/dist/components/tab/tab.d.ts +59 -0
- package/dist/components/tab/tab.styles.d.ts +1 -0
- package/dist/components/tab/tab.types.d.ts +7 -0
- package/dist/components/tab-group/index.d.ts +8 -0
- package/dist/components/tab-group/index.js +441 -0
- package/dist/components/tab-group/tab-group.d.ts +99 -0
- package/dist/components/tab-group/tab-group.styles.d.ts +1 -0
- package/dist/components/tab-group/tab-group.types.d.ts +11 -0
- package/dist/components/table/index.d.ts +2 -0
- package/dist/components/table/index.js +582 -0
- package/dist/components/table/table.d.ts +160 -0
- package/dist/components/table/table.styles.d.ts +1 -0
- package/dist/components/table/table.types.d.ts +106 -0
- package/dist/components/text/index.d.ts +1 -0
- package/dist/components/text/index.js +207 -0
- package/dist/components/text/text.d.ts +32 -0
- package/dist/components/text/text.styles.d.ts +1 -0
- package/dist/components/text/text.types.d.ts +2 -0
- package/dist/components/textfield/index.d.ts +8 -0
- package/dist/components/textfield/index.js +718 -0
- package/dist/components/textfield/textfield.d.ts +168 -0
- package/dist/components/textfield/textfield.styles.d.ts +1 -0
- package/dist/components/textfield/textfield.types.d.ts +40 -0
- package/dist/components/tooltip/index.d.ts +2 -0
- package/dist/components/tooltip/index.js +379 -0
- package/dist/components/tooltip/tooltip.d.ts +42 -0
- package/dist/components/tooltip/tooltip.styles.d.ts +1 -0
- package/dist/components/tooltip/tooltip.types.d.ts +1 -0
- package/dist/css/font-face.css +22 -0
- package/dist/css/latty.css +57 -0
- package/dist/fonts/HankenGrotesk-Variable.woff2 +0 -0
- package/dist/fonts/HankenGrotesk-VariableItalic.woff2 +0 -0
- package/dist/index.cjs +12739 -0
- package/dist/index.d.ts +101 -0
- package/dist/index.js +11406 -0
- package/dist/manifest.json +2396 -0
- package/dist/utils/click-outside.d.ts +22 -0
- package/dist/utils/color.d.ts +14 -0
- package/dist/utils/dispatch.d.ts +18 -0
- package/dist/utils/index.d.ts +3 -0
- package/package.json +231 -0
|
@@ -0,0 +1,2863 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
+
if (decorator = decorators[i])
|
|
7
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
+
if (kind && result) __defProp(target, key, result);
|
|
9
|
+
return result;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// src/components/date-input/date-input.ts
|
|
13
|
+
import { html as html3, nothing } from "lit";
|
|
14
|
+
import { customElement as customElement3, property as property4, state as state2 } from "lit/decorators.js";
|
|
15
|
+
|
|
16
|
+
// src/base/themeable-element.ts
|
|
17
|
+
import { LitElement } from "lit";
|
|
18
|
+
import { property } from "lit/decorators.js";
|
|
19
|
+
var ThemeableElement = class extends LitElement {
|
|
20
|
+
willUpdate(changed) {
|
|
21
|
+
super.willUpdate(changed);
|
|
22
|
+
if (changed.has("theme")) {
|
|
23
|
+
this._syncThemeAttribute();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
_syncThemeAttribute() {
|
|
27
|
+
if (this.theme === "dark" || this.theme === "light") {
|
|
28
|
+
this.setAttribute("data-theme", this.theme);
|
|
29
|
+
} else {
|
|
30
|
+
this.removeAttribute("data-theme");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
__decorateClass([
|
|
35
|
+
property({ reflect: true })
|
|
36
|
+
], ThemeableElement.prototype, "theme", 2);
|
|
37
|
+
|
|
38
|
+
// src/components/date-input/date-input.ts
|
|
39
|
+
import "@latty-ds/icons";
|
|
40
|
+
|
|
41
|
+
// src/components/calendar/calendar.ts
|
|
42
|
+
import { html } from "lit";
|
|
43
|
+
import { customElement, property as property2, state } from "lit/decorators.js";
|
|
44
|
+
import "@latty-ds/icons";
|
|
45
|
+
|
|
46
|
+
// src/components/calendar/calendar.styles.ts
|
|
47
|
+
import { css } from "lit";
|
|
48
|
+
var calendarStyles = css`
|
|
49
|
+
:host {
|
|
50
|
+
display: inline-block;
|
|
51
|
+
font-family: 'Hanken Grotesk', sans-serif;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.calendar {
|
|
55
|
+
background: var(--lt-bg-default);
|
|
56
|
+
border-radius: var(--lt-border-radius);
|
|
57
|
+
border: 1px solid var(--lt-border-default);
|
|
58
|
+
display: flex;
|
|
59
|
+
flex-direction: column;
|
|
60
|
+
gap: var(--lt-spacing-2);
|
|
61
|
+
padding: var(--lt-spacing-3);
|
|
62
|
+
width: 17.25rem;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* ── Header ── */
|
|
66
|
+
|
|
67
|
+
.header {
|
|
68
|
+
align-items: center;
|
|
69
|
+
display: flex;
|
|
70
|
+
justify-content: space-between;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.month-label-btn {
|
|
74
|
+
align-items: center;
|
|
75
|
+
background: transparent;
|
|
76
|
+
border-radius: var(--lt-border-radius);
|
|
77
|
+
border: 1px solid transparent;
|
|
78
|
+
color: var(--lt-text-default);
|
|
79
|
+
cursor: pointer;
|
|
80
|
+
display: inline-flex;
|
|
81
|
+
font-family: inherit;
|
|
82
|
+
font-size: 0.9375rem;
|
|
83
|
+
font-weight: 600;
|
|
84
|
+
gap: var(--lt-spacing-1);
|
|
85
|
+
letter-spacing: 0.01em;
|
|
86
|
+
padding: var(--lt-spacing-1) var(--lt-spacing-2);
|
|
87
|
+
transition:
|
|
88
|
+
background 120ms ease,
|
|
89
|
+
border-color 120ms ease;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.month-label-btn:hover:not(:disabled) {
|
|
93
|
+
background: var(--lt-bg-neutral-subtle);
|
|
94
|
+
border-color: var(--lt-border-default);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.month-label-btn--open {
|
|
98
|
+
background: var(--lt-bg-neutral-subtle);
|
|
99
|
+
border-color: var(--lt-border-default);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.month-label-btn:disabled {
|
|
103
|
+
cursor: not-allowed;
|
|
104
|
+
opacity: 0.6;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.picker-chevron {
|
|
108
|
+
color: var(--lt-text-subtle);
|
|
109
|
+
transition: transform 150ms ease;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.month-label-btn--open .picker-chevron {
|
|
113
|
+
transform: rotate(180deg);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.nav-btn {
|
|
117
|
+
align-items: center;
|
|
118
|
+
background: transparent;
|
|
119
|
+
border-radius: var(--lt-border-radius);
|
|
120
|
+
border: 1px solid transparent;
|
|
121
|
+
color: var(--lt-text-subtle);
|
|
122
|
+
cursor: pointer;
|
|
123
|
+
display: inline-flex;
|
|
124
|
+
height: 2rem;
|
|
125
|
+
justify-content: center;
|
|
126
|
+
padding: 0;
|
|
127
|
+
transition:
|
|
128
|
+
background 120ms ease,
|
|
129
|
+
border-color 120ms ease,
|
|
130
|
+
color 120ms ease;
|
|
131
|
+
width: 2rem;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.nav-btn:hover:not(:disabled) {
|
|
135
|
+
background: var(--lt-bg-neutral-subtle);
|
|
136
|
+
border-color: var(--lt-border-default);
|
|
137
|
+
color: var(--lt-text-default);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.nav-btn:disabled {
|
|
141
|
+
color: var(--lt-text-disabled);
|
|
142
|
+
cursor: not-allowed;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/* ── Weekday headers ── */
|
|
146
|
+
|
|
147
|
+
.weekdays {
|
|
148
|
+
column-gap: 0;
|
|
149
|
+
display: grid;
|
|
150
|
+
grid-template-columns: repeat(7, 1fr);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.weekday {
|
|
154
|
+
color: var(--lt-text-muted);
|
|
155
|
+
font-size: 0.75rem;
|
|
156
|
+
font-weight: 500;
|
|
157
|
+
text-align: center;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/* ── Day grid ── */
|
|
161
|
+
|
|
162
|
+
.grid {
|
|
163
|
+
column-gap: 0;
|
|
164
|
+
display: grid;
|
|
165
|
+
grid-template-columns: repeat(7, 1fr);
|
|
166
|
+
row-gap: var(--lt-spacing-1);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
[role='row'] {
|
|
170
|
+
display: contents;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/* Day button — strip layer in range mode */
|
|
174
|
+
.day {
|
|
175
|
+
align-items: center;
|
|
176
|
+
background: transparent;
|
|
177
|
+
border: none;
|
|
178
|
+
color: var(--lt-text-default);
|
|
179
|
+
cursor: pointer;
|
|
180
|
+
display: inline-flex;
|
|
181
|
+
font-family: inherit;
|
|
182
|
+
font-size: 0.8125rem;
|
|
183
|
+
font-weight: 400;
|
|
184
|
+
height: 2.25rem;
|
|
185
|
+
justify-content: center;
|
|
186
|
+
outline: none;
|
|
187
|
+
padding: 0;
|
|
188
|
+
transition: background 100ms ease;
|
|
189
|
+
width: 100%;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.day:disabled {
|
|
193
|
+
cursor: not-allowed;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/* Day inner — the visible circle */
|
|
197
|
+
.day__inner {
|
|
198
|
+
align-items: center;
|
|
199
|
+
background: transparent;
|
|
200
|
+
border: 2px solid transparent;
|
|
201
|
+
border-radius: 50%;
|
|
202
|
+
color: inherit;
|
|
203
|
+
display: inline-flex;
|
|
204
|
+
font-size: inherit;
|
|
205
|
+
font-weight: inherit;
|
|
206
|
+
height: 2.25rem;
|
|
207
|
+
justify-content: center;
|
|
208
|
+
transition:
|
|
209
|
+
background 100ms ease,
|
|
210
|
+
border-color 100ms ease,
|
|
211
|
+
color 100ms ease;
|
|
212
|
+
width: 2.25rem;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
.day:hover:not(:disabled) .day__inner {
|
|
216
|
+
background: var(--lt-bg-neutral-subtle);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.day:focus-visible .day__inner {
|
|
220
|
+
outline: 2px solid var(--lt-border-focus);
|
|
221
|
+
outline-offset: 1px;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/* Today ring */
|
|
225
|
+
.day--today .day__inner {
|
|
226
|
+
border-color: var(--lt-border-primary);
|
|
227
|
+
font-weight: 600;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/* Single-mode selected */
|
|
231
|
+
.day--selected .day__inner {
|
|
232
|
+
background: var(--lt-interactive-primary-bg);
|
|
233
|
+
border-color: transparent;
|
|
234
|
+
color: var(--lt-text-on-primary);
|
|
235
|
+
font-weight: 600;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.day--selected:hover:not(:disabled) .day__inner {
|
|
239
|
+
background: var(--lt-interactive-primary-bg-hover);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/* Outside days */
|
|
243
|
+
.day--outside {
|
|
244
|
+
color: var(--lt-text-muted);
|
|
245
|
+
opacity: 0.5;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/* Empty filler cell */
|
|
249
|
+
.day--empty {
|
|
250
|
+
background: transparent;
|
|
251
|
+
border: none;
|
|
252
|
+
cursor: default;
|
|
253
|
+
pointer-events: none;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.day:disabled .day__inner {
|
|
257
|
+
color: var(--lt-text-disabled);
|
|
258
|
+
opacity: 0.4;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/* ── Range strips (on .day button = strip layer) ── */
|
|
262
|
+
|
|
263
|
+
/* Start: transparent on left, strip on right */
|
|
264
|
+
.day--range-left {
|
|
265
|
+
background: linear-gradient(to right, transparent 50%, var(--lt-bg-primary-subtle) 50%);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/* End: strip on left, transparent on right */
|
|
269
|
+
.day--range-right {
|
|
270
|
+
background: linear-gradient(to right, var(--lt-bg-primary-subtle) 50%, transparent 50%);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/* Same-day start+end — no strip needed */
|
|
274
|
+
.day--range-left.day--range-right {
|
|
275
|
+
background: transparent;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/* Days between confirmed endpoints */
|
|
279
|
+
.day--in-range {
|
|
280
|
+
background: var(--lt-bg-primary-subtle);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
.day--in-range:hover:not(:disabled) .day__inner {
|
|
284
|
+
background: var(--lt-bg-neutral-subtle);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/* Days between hover preview endpoints */
|
|
288
|
+
.day--in-hover-range {
|
|
289
|
+
background: var(--lt-bg-primary-subtle);
|
|
290
|
+
opacity: 0.45;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/* Confirmed range endpoint circle */
|
|
294
|
+
.day--range-confirmed .day__inner {
|
|
295
|
+
background: var(--lt-interactive-primary-bg);
|
|
296
|
+
border-color: transparent;
|
|
297
|
+
color: var(--lt-text-on-primary);
|
|
298
|
+
font-weight: 600;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
.day--range-confirmed:hover:not(:disabled) .day__inner {
|
|
302
|
+
background: var(--lt-interactive-primary-bg-hover);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/* Hover preview endpoint circle (semi-transparent) */
|
|
306
|
+
.day--range-hover .day__inner {
|
|
307
|
+
background: var(--lt-interactive-primary-bg);
|
|
308
|
+
border-color: transparent;
|
|
309
|
+
color: var(--lt-text-on-primary);
|
|
310
|
+
opacity: 0.5;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/* ── Multi-month layout ── */
|
|
314
|
+
|
|
315
|
+
.calendar--multi {
|
|
316
|
+
width: auto;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
.month-label-row {
|
|
320
|
+
display: flex;
|
|
321
|
+
flex: 1;
|
|
322
|
+
justify-content: space-around;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
.month-label {
|
|
326
|
+
color: var(--lt-text-default);
|
|
327
|
+
font-size: 0.9375rem;
|
|
328
|
+
font-weight: 600;
|
|
329
|
+
letter-spacing: 0.01em;
|
|
330
|
+
text-align: center;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
.month-panels {
|
|
334
|
+
display: flex;
|
|
335
|
+
gap: var(--lt-spacing-4);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
.month-col {
|
|
339
|
+
width: 17.25rem;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/* ── Month/year picker ── */
|
|
343
|
+
|
|
344
|
+
.picker-months {
|
|
345
|
+
display: grid;
|
|
346
|
+
gap: var(--lt-spacing-1);
|
|
347
|
+
grid-template-columns: repeat(3, 1fr);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
.picker-month-btn {
|
|
351
|
+
background: transparent;
|
|
352
|
+
border-radius: var(--lt-border-radius);
|
|
353
|
+
border: 1px solid transparent;
|
|
354
|
+
color: var(--lt-text-default);
|
|
355
|
+
cursor: pointer;
|
|
356
|
+
font-family: inherit;
|
|
357
|
+
font-size: 0.8125rem;
|
|
358
|
+
font-weight: 400;
|
|
359
|
+
padding: var(--lt-spacing-2) 0;
|
|
360
|
+
text-align: center;
|
|
361
|
+
transition:
|
|
362
|
+
background 100ms ease,
|
|
363
|
+
border-color 100ms ease;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
.picker-month-btn:hover:not(:disabled) {
|
|
367
|
+
background: var(--lt-bg-neutral-subtle);
|
|
368
|
+
border-color: var(--lt-border-default);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
.picker-month-btn--current {
|
|
372
|
+
background: var(--lt-interactive-primary-bg);
|
|
373
|
+
border-color: transparent;
|
|
374
|
+
color: var(--lt-text-on-primary);
|
|
375
|
+
font-weight: 600;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
.picker-month-btn--current:hover:not(:disabled) {
|
|
379
|
+
background: var(--lt-interactive-primary-bg-hover);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
.picker-month-btn:disabled {
|
|
383
|
+
color: var(--lt-text-disabled);
|
|
384
|
+
cursor: not-allowed;
|
|
385
|
+
opacity: 0.5;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/* ── Footer ── */
|
|
389
|
+
|
|
390
|
+
.footer {
|
|
391
|
+
border-top: 1px solid var(--lt-border-subtle);
|
|
392
|
+
display: flex;
|
|
393
|
+
justify-content: flex-end;
|
|
394
|
+
padding-top: var(--lt-spacing-1);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
.today-btn {
|
|
398
|
+
background: transparent;
|
|
399
|
+
border-radius: var(--lt-border-radius);
|
|
400
|
+
border: 1px solid var(--lt-border-default);
|
|
401
|
+
color: var(--lt-text-subtle);
|
|
402
|
+
cursor: pointer;
|
|
403
|
+
font-family: inherit;
|
|
404
|
+
font-size: 0.75rem;
|
|
405
|
+
font-weight: 500;
|
|
406
|
+
padding: var(--lt-spacing-1) var(--lt-spacing-2);
|
|
407
|
+
transition:
|
|
408
|
+
background 120ms ease,
|
|
409
|
+
border-color 120ms ease,
|
|
410
|
+
color 120ms ease;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
.today-btn:hover:not(:disabled) {
|
|
414
|
+
background: var(--lt-bg-neutral-subtle);
|
|
415
|
+
border-color: var(--lt-border-strong);
|
|
416
|
+
color: var(--lt-text-default);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
.today-btn:disabled {
|
|
420
|
+
color: var(--lt-text-disabled);
|
|
421
|
+
cursor: not-allowed;
|
|
422
|
+
opacity: 0.5;
|
|
423
|
+
}
|
|
424
|
+
`;
|
|
425
|
+
|
|
426
|
+
// src/utils/dispatch.ts
|
|
427
|
+
var dispatch = (host, name, detail, init) => host.dispatchEvent(new CustomEvent(name, { detail, bubbles: true, composed: true, ...init }));
|
|
428
|
+
|
|
429
|
+
// src/utils/click-outside.ts
|
|
430
|
+
var createClickOutsideHandler = (host, onOutside, options) => {
|
|
431
|
+
const eventName = options?.event ?? "pointerdown";
|
|
432
|
+
const capture = options?.capture ?? false;
|
|
433
|
+
const handler = (e) => {
|
|
434
|
+
if (!e.composedPath().includes(host)) onOutside();
|
|
435
|
+
};
|
|
436
|
+
document.addEventListener(eventName, handler, capture ? { capture: true } : void 0);
|
|
437
|
+
return () => document.removeEventListener(eventName, handler, capture ? { capture: true } : void 0);
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
// src/components/calendar/calendar.ts
|
|
441
|
+
var Calendar = class extends ThemeableElement {
|
|
442
|
+
constructor() {
|
|
443
|
+
super(...arguments);
|
|
444
|
+
this.mode = "single";
|
|
445
|
+
this.value = "";
|
|
446
|
+
this.valueStart = "";
|
|
447
|
+
this.valueEnd = "";
|
|
448
|
+
this.min = "";
|
|
449
|
+
this.max = "";
|
|
450
|
+
this.locale = "en-US";
|
|
451
|
+
this.weekStart = "0";
|
|
452
|
+
this.showOutsideDays = true;
|
|
453
|
+
this.disabled = false;
|
|
454
|
+
this.months = 1;
|
|
455
|
+
/** Specific dates to disable, as an array of Date objects. Not reflected as an attribute. */
|
|
456
|
+
this.disabledDates = [];
|
|
457
|
+
this._viewYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
458
|
+
this._viewMonth = (/* @__PURE__ */ new Date()).getMonth();
|
|
459
|
+
this._focusedDate = null;
|
|
460
|
+
this._hoverDate = null;
|
|
461
|
+
this._pickingMonthYear = false;
|
|
462
|
+
this._pickerYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
463
|
+
this._handleCalendarKeyDown = (e) => {
|
|
464
|
+
if (e.key === "Escape" && this._pickingMonthYear) {
|
|
465
|
+
e.stopPropagation();
|
|
466
|
+
this._closePicker();
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
this._handleGridMouseOver = (e) => {
|
|
470
|
+
if (this.mode !== "range" || this.valueEnd) return;
|
|
471
|
+
const btn = e.target.closest("[data-date]");
|
|
472
|
+
if (btn?.dataset.date) {
|
|
473
|
+
const d = this._parseDate(btn.dataset.date);
|
|
474
|
+
if (d && (!this._hoverDate || !this._isSameDay(d, this._hoverDate))) {
|
|
475
|
+
this._hoverDate = d;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
this._handleGridMouseLeave = () => {
|
|
480
|
+
if (this.mode === "range") this._hoverDate = null;
|
|
481
|
+
};
|
|
482
|
+
this._handleKeyDown = (e) => {
|
|
483
|
+
const today = /* @__PURE__ */ new Date();
|
|
484
|
+
const focusedDate = this._focusedDate ?? this._parseDate(this.value) ?? new Date(this._viewYear, this._viewMonth, today.getDate() || 1);
|
|
485
|
+
const next = new Date(focusedDate);
|
|
486
|
+
const weekStart = Number(this.weekStart);
|
|
487
|
+
switch (e.key) {
|
|
488
|
+
case "ArrowRight":
|
|
489
|
+
next.setDate(next.getDate() + 1);
|
|
490
|
+
break;
|
|
491
|
+
case "ArrowLeft":
|
|
492
|
+
next.setDate(next.getDate() - 1);
|
|
493
|
+
break;
|
|
494
|
+
case "ArrowDown":
|
|
495
|
+
next.setDate(next.getDate() + 7);
|
|
496
|
+
break;
|
|
497
|
+
case "ArrowUp":
|
|
498
|
+
next.setDate(next.getDate() - 7);
|
|
499
|
+
break;
|
|
500
|
+
case "Home": {
|
|
501
|
+
const offset3 = (next.getDay() - weekStart + 7) % 7;
|
|
502
|
+
next.setDate(next.getDate() - offset3);
|
|
503
|
+
break;
|
|
504
|
+
}
|
|
505
|
+
case "End": {
|
|
506
|
+
const offset3 = (next.getDay() - weekStart + 7) % 7;
|
|
507
|
+
next.setDate(next.getDate() + (6 - offset3));
|
|
508
|
+
break;
|
|
509
|
+
}
|
|
510
|
+
case "PageUp":
|
|
511
|
+
e.preventDefault();
|
|
512
|
+
this._navigate(-1);
|
|
513
|
+
return;
|
|
514
|
+
case "PageDown":
|
|
515
|
+
e.preventDefault();
|
|
516
|
+
this._navigate(1);
|
|
517
|
+
return;
|
|
518
|
+
case "Enter":
|
|
519
|
+
case " ": {
|
|
520
|
+
e.preventDefault();
|
|
521
|
+
const days = this._buildDays();
|
|
522
|
+
const day = days.find((d) => this._isSameDay(d.date, focusedDate));
|
|
523
|
+
if (day && !day.isDisabled) this._selectDay(day);
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
default:
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
e.preventDefault();
|
|
530
|
+
if (next.getFullYear() !== this._viewYear || next.getMonth() !== this._viewMonth) {
|
|
531
|
+
this._viewYear = next.getFullYear();
|
|
532
|
+
this._viewMonth = next.getMonth();
|
|
533
|
+
}
|
|
534
|
+
this._focusedDate = next;
|
|
535
|
+
this._focusCell(this._toIso(next));
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
willUpdate(changed) {
|
|
539
|
+
super.willUpdate(changed);
|
|
540
|
+
if (changed.has("value") && this.value) {
|
|
541
|
+
const d = this._parseDate(this.value);
|
|
542
|
+
if (d) {
|
|
543
|
+
this._viewYear = d.getFullYear();
|
|
544
|
+
this._viewMonth = d.getMonth();
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
if (changed.has("valueStart") && this.valueStart) {
|
|
548
|
+
const d = this._parseDate(this.valueStart);
|
|
549
|
+
if (d) {
|
|
550
|
+
this._viewYear = d.getFullYear();
|
|
551
|
+
this._viewMonth = d.getMonth();
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
if (changed.has("months") && this.months > 1 && this._pickingMonthYear) {
|
|
555
|
+
this._pickingMonthYear = false;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
_monthAtOffset(offset3) {
|
|
559
|
+
let m = this._viewMonth + offset3;
|
|
560
|
+
let y = this._viewYear;
|
|
561
|
+
while (m > 11) {
|
|
562
|
+
m -= 12;
|
|
563
|
+
y++;
|
|
564
|
+
}
|
|
565
|
+
return { year: y, month: m };
|
|
566
|
+
}
|
|
567
|
+
_parseDate(iso) {
|
|
568
|
+
if (!iso) return null;
|
|
569
|
+
const d = /* @__PURE__ */ new Date(`${iso}T00:00:00`);
|
|
570
|
+
return isNaN(d.getTime()) ? null : d;
|
|
571
|
+
}
|
|
572
|
+
_toIso(date) {
|
|
573
|
+
const y = date.getFullYear();
|
|
574
|
+
const m = String(date.getMonth() + 1).padStart(2, "0");
|
|
575
|
+
const d = String(date.getDate()).padStart(2, "0");
|
|
576
|
+
return `${y}-${m}-${d}`;
|
|
577
|
+
}
|
|
578
|
+
_isSameDay(a, b) {
|
|
579
|
+
return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
580
|
+
}
|
|
581
|
+
_isDisabled(date) {
|
|
582
|
+
if (this.disabled) return true;
|
|
583
|
+
if (this.min) {
|
|
584
|
+
const min2 = this._parseDate(this.min);
|
|
585
|
+
if (min2 && date < min2) return true;
|
|
586
|
+
}
|
|
587
|
+
if (this.max) {
|
|
588
|
+
const max2 = this._parseDate(this.max);
|
|
589
|
+
if (max2 && date > max2) return true;
|
|
590
|
+
}
|
|
591
|
+
return this.disabledDates.some((d) => this._isSameDay(d, date));
|
|
592
|
+
}
|
|
593
|
+
_buildDays(year = this._viewYear, month = this._viewMonth) {
|
|
594
|
+
const today = /* @__PURE__ */ new Date();
|
|
595
|
+
const selected = this._parseDate(this.value);
|
|
596
|
+
const weekStart = Number(this.weekStart);
|
|
597
|
+
const rangeStart = this.mode === "range" ? this._parseDate(this.valueStart) : null;
|
|
598
|
+
const rangeEnd = this.mode === "range" ? this._parseDate(this.valueEnd) : null;
|
|
599
|
+
let visHoverStart = null;
|
|
600
|
+
let visHoverEnd = null;
|
|
601
|
+
if (rangeStart && !rangeEnd && this._hoverDate) {
|
|
602
|
+
if (this._hoverDate >= rangeStart) {
|
|
603
|
+
visHoverStart = rangeStart;
|
|
604
|
+
visHoverEnd = this._hoverDate;
|
|
605
|
+
} else {
|
|
606
|
+
visHoverStart = this._hoverDate;
|
|
607
|
+
visHoverEnd = rangeStart;
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
const firstOfMonth = new Date(year, month, 1);
|
|
611
|
+
const lastOfMonth = new Date(year, month + 1, 0);
|
|
612
|
+
const startOffset = (firstOfMonth.getDay() - weekStart + 7) % 7;
|
|
613
|
+
const totalCurrent = startOffset + lastOfMonth.getDate();
|
|
614
|
+
const endOffset = totalCurrent % 7 === 0 ? 0 : 7 - totalCurrent % 7;
|
|
615
|
+
const days = [];
|
|
616
|
+
const buildDay = (date, isCurrentMonth) => {
|
|
617
|
+
const isRangeStart = !!rangeStart && this._isSameDay(date, rangeStart);
|
|
618
|
+
const isRangeEnd = !!rangeEnd && this._isSameDay(date, rangeEnd);
|
|
619
|
+
const isInRange = !!rangeStart && !!rangeEnd && date > rangeStart && date < rangeEnd && !this._isSameDay(date, rangeStart) && !this._isSameDay(date, rangeEnd);
|
|
620
|
+
const isRangeHoverStart = !!visHoverStart && this._isSameDay(date, visHoverStart);
|
|
621
|
+
const isRangeHoverEnd = !!visHoverEnd && !this._isSameDay(visHoverStart, visHoverEnd) && this._isSameDay(date, visHoverEnd);
|
|
622
|
+
const isInHoverRange = !!visHoverStart && !!visHoverEnd && date > visHoverStart && date < visHoverEnd;
|
|
623
|
+
return {
|
|
624
|
+
date,
|
|
625
|
+
isCurrentMonth,
|
|
626
|
+
isToday: this._isSameDay(date, today),
|
|
627
|
+
isSelected: this.mode === "single" && selected ? this._isSameDay(date, selected) : false,
|
|
628
|
+
isDisabled: this._isDisabled(date),
|
|
629
|
+
isRangeStart,
|
|
630
|
+
isRangeEnd,
|
|
631
|
+
isInRange,
|
|
632
|
+
isRangeHoverStart,
|
|
633
|
+
isRangeHoverEnd,
|
|
634
|
+
isInHoverRange
|
|
635
|
+
};
|
|
636
|
+
};
|
|
637
|
+
for (let i = startOffset; i > 0; i--) {
|
|
638
|
+
days.push(buildDay(new Date(year, month, 1 - i), false));
|
|
639
|
+
}
|
|
640
|
+
for (let d = 1; d <= lastOfMonth.getDate(); d++) {
|
|
641
|
+
days.push(buildDay(new Date(year, month, d), true));
|
|
642
|
+
}
|
|
643
|
+
for (let d = 1; d <= endOffset; d++) {
|
|
644
|
+
days.push(buildDay(new Date(year, month + 1, d), false));
|
|
645
|
+
}
|
|
646
|
+
return days;
|
|
647
|
+
}
|
|
648
|
+
_getWeekdayLabels() {
|
|
649
|
+
const weekStart = Number(this.weekStart);
|
|
650
|
+
const fmt = new Intl.DateTimeFormat(this.locale, { weekday: "narrow" });
|
|
651
|
+
const refSunday = new Date(2026, 0, 4);
|
|
652
|
+
return Array.from({ length: 7 }, (_, i) => {
|
|
653
|
+
const date = new Date(refSunday);
|
|
654
|
+
date.setDate(refSunday.getDate() + weekStart + i);
|
|
655
|
+
return fmt.format(date);
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
_navigate(delta) {
|
|
659
|
+
if (this._pickingMonthYear) {
|
|
660
|
+
this._pickerYear += delta;
|
|
661
|
+
return;
|
|
662
|
+
}
|
|
663
|
+
let month = this._viewMonth + delta;
|
|
664
|
+
let year = this._viewYear;
|
|
665
|
+
while (month < 0) {
|
|
666
|
+
month += 12;
|
|
667
|
+
year--;
|
|
668
|
+
}
|
|
669
|
+
while (month > 11) {
|
|
670
|
+
month -= 12;
|
|
671
|
+
year++;
|
|
672
|
+
}
|
|
673
|
+
this._viewMonth = month;
|
|
674
|
+
this._viewYear = year;
|
|
675
|
+
this._focusedDate = null;
|
|
676
|
+
dispatch(this, "month-change", { year: this._viewYear, month: this._viewMonth });
|
|
677
|
+
}
|
|
678
|
+
_openPicker() {
|
|
679
|
+
this._pickerYear = this._viewYear;
|
|
680
|
+
this._pickingMonthYear = true;
|
|
681
|
+
}
|
|
682
|
+
_closePicker() {
|
|
683
|
+
this._pickingMonthYear = false;
|
|
684
|
+
}
|
|
685
|
+
_selectPickerMonth(month) {
|
|
686
|
+
this._viewYear = this._pickerYear;
|
|
687
|
+
this._viewMonth = month;
|
|
688
|
+
this._pickingMonthYear = false;
|
|
689
|
+
this._focusedDate = null;
|
|
690
|
+
dispatch(this, "month-change", { year: this._viewYear, month: this._viewMonth });
|
|
691
|
+
}
|
|
692
|
+
_selectDay(day) {
|
|
693
|
+
if (day.isDisabled || this.disabled) return;
|
|
694
|
+
if (!day.isCurrentMonth) {
|
|
695
|
+
this._viewMonth = day.date.getMonth();
|
|
696
|
+
this._viewYear = day.date.getFullYear();
|
|
697
|
+
}
|
|
698
|
+
if (this.mode === "range") {
|
|
699
|
+
const iso2 = this._toIso(day.date);
|
|
700
|
+
const hasStart = !!this.valueStart;
|
|
701
|
+
const hasEnd = !!this.valueEnd;
|
|
702
|
+
if (!hasStart || hasEnd) {
|
|
703
|
+
this.valueStart = iso2;
|
|
704
|
+
this.valueEnd = "";
|
|
705
|
+
this._hoverDate = null;
|
|
706
|
+
} else {
|
|
707
|
+
const startDate = this._parseDate(this.valueStart);
|
|
708
|
+
if (this._isSameDay(day.date, startDate)) {
|
|
709
|
+
this.valueStart = "";
|
|
710
|
+
} else if (day.date < startDate) {
|
|
711
|
+
this.valueEnd = this.valueStart;
|
|
712
|
+
this.valueStart = iso2;
|
|
713
|
+
} else {
|
|
714
|
+
this.valueEnd = iso2;
|
|
715
|
+
}
|
|
716
|
+
if (this.valueStart && this.valueEnd) {
|
|
717
|
+
dispatch(this, "change", { valueStart: this.valueStart, valueEnd: this.valueEnd });
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
this._focusedDate = day.date;
|
|
721
|
+
return;
|
|
722
|
+
}
|
|
723
|
+
const iso = this._toIso(day.date);
|
|
724
|
+
this.value = iso;
|
|
725
|
+
this._focusedDate = day.date;
|
|
726
|
+
dispatch(this, "change", { value: iso });
|
|
727
|
+
}
|
|
728
|
+
_goToToday() {
|
|
729
|
+
const today = /* @__PURE__ */ new Date();
|
|
730
|
+
this._viewYear = today.getFullYear();
|
|
731
|
+
this._viewMonth = today.getMonth();
|
|
732
|
+
this._focusedDate = null;
|
|
733
|
+
this._pickingMonthYear = false;
|
|
734
|
+
}
|
|
735
|
+
_dayAriaLabel(date) {
|
|
736
|
+
return new Intl.DateTimeFormat(this.locale, {
|
|
737
|
+
weekday: "long",
|
|
738
|
+
year: "numeric",
|
|
739
|
+
month: "long",
|
|
740
|
+
day: "numeric"
|
|
741
|
+
}).format(date);
|
|
742
|
+
}
|
|
743
|
+
_focusCell(iso) {
|
|
744
|
+
this.updateComplete.then(() => {
|
|
745
|
+
const target = this.shadowRoot?.querySelector(`[data-date="${iso}"]`);
|
|
746
|
+
target?.focus();
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
_renderDay(day, rovingDate) {
|
|
750
|
+
if (!day.isCurrentMonth && !this.showOutsideDays) {
|
|
751
|
+
return html`<div role="gridcell" aria-hidden="true" class="day day--empty"></div>`;
|
|
752
|
+
}
|
|
753
|
+
const isRangeLeft = day.isRangeStart || day.isRangeHoverStart;
|
|
754
|
+
const isRangeRight = day.isRangeEnd || day.isRangeHoverEnd;
|
|
755
|
+
const isRangeConfirmed = day.isRangeStart || day.isRangeEnd;
|
|
756
|
+
const isRangeHoverPoint = !isRangeConfirmed && (day.isRangeHoverStart || day.isRangeHoverEnd);
|
|
757
|
+
const classes = [
|
|
758
|
+
"day",
|
|
759
|
+
!day.isCurrentMonth ? "day--outside" : "",
|
|
760
|
+
day.isToday ? "day--today" : "",
|
|
761
|
+
day.isSelected ? "day--selected" : "",
|
|
762
|
+
isRangeLeft ? "day--range-left" : "",
|
|
763
|
+
isRangeRight ? "day--range-right" : "",
|
|
764
|
+
isRangeConfirmed ? "day--range-confirmed" : "",
|
|
765
|
+
isRangeHoverPoint ? "day--range-hover" : "",
|
|
766
|
+
day.isInRange ? "day--in-range" : "",
|
|
767
|
+
day.isInHoverRange ? "day--in-hover-range" : ""
|
|
768
|
+
].filter(Boolean).join(" ");
|
|
769
|
+
const iso = this._toIso(day.date);
|
|
770
|
+
const isSelected = day.isSelected || day.isRangeStart || day.isRangeEnd;
|
|
771
|
+
return html`
|
|
772
|
+
<button
|
|
773
|
+
role="gridcell"
|
|
774
|
+
class=${classes}
|
|
775
|
+
data-date=${iso}
|
|
776
|
+
?disabled=${day.isDisabled}
|
|
777
|
+
aria-selected=${isSelected ? "true" : "false"}
|
|
778
|
+
aria-label=${this._dayAriaLabel(day.date)}
|
|
779
|
+
tabindex=${this._isSameDay(day.date, rovingDate) ? 0 : -1}
|
|
780
|
+
@click=${() => this._selectDay(day)}
|
|
781
|
+
@keydown=${this._handleKeyDown}
|
|
782
|
+
>
|
|
783
|
+
<span class="day__inner">${day.date.getDate()}</span>
|
|
784
|
+
</button>
|
|
785
|
+
`;
|
|
786
|
+
}
|
|
787
|
+
_renderMonthGrid(year, month, gridLabel, rovingDate) {
|
|
788
|
+
const days = this._buildDays(year, month);
|
|
789
|
+
const weekdayLabels = this._getWeekdayLabels();
|
|
790
|
+
const weeks = [];
|
|
791
|
+
for (let i = 0; i < days.length; i += 7) weeks.push(days.slice(i, i + 7));
|
|
792
|
+
return html`
|
|
793
|
+
<div class="weekdays" aria-hidden="true">
|
|
794
|
+
${weekdayLabels.map((label) => html`<div class="weekday">${label}</div>`)}
|
|
795
|
+
</div>
|
|
796
|
+
<div
|
|
797
|
+
class="grid"
|
|
798
|
+
role="grid"
|
|
799
|
+
aria-label="${gridLabel}"
|
|
800
|
+
@mouseover=${this._handleGridMouseOver}
|
|
801
|
+
@mouseleave=${this._handleGridMouseLeave}
|
|
802
|
+
>
|
|
803
|
+
${weeks.map((week) => html` <div role="row">${week.map((day) => this._renderDay(day, rovingDate))}</div> `)}
|
|
804
|
+
</div>
|
|
805
|
+
`;
|
|
806
|
+
}
|
|
807
|
+
render() {
|
|
808
|
+
const today = /* @__PURE__ */ new Date();
|
|
809
|
+
const isMulti = this.months > 1;
|
|
810
|
+
const rovingAnchor = this._parseDate(this.mode === "range" ? this.valueStart : this.value);
|
|
811
|
+
const rovingDate = this._focusedDate ?? rovingAnchor ?? (today.getFullYear() === this._viewYear && today.getMonth() === this._viewMonth ? today : null) ?? new Date(this._viewYear, this._viewMonth, 1);
|
|
812
|
+
const footer = html`
|
|
813
|
+
<div class="footer">
|
|
814
|
+
<button class="today-btn" ?disabled=${this.disabled} @click=${this._goToToday}>Today</button>
|
|
815
|
+
</div>
|
|
816
|
+
`;
|
|
817
|
+
if (isMulti) {
|
|
818
|
+
const panelLabels = Array.from({ length: this.months }, (_, i) => {
|
|
819
|
+
const { year, month } = this._monthAtOffset(i);
|
|
820
|
+
return new Intl.DateTimeFormat(this.locale, { month: "long", year: "numeric" }).format(new Date(year, month));
|
|
821
|
+
});
|
|
822
|
+
return html`
|
|
823
|
+
<div class="calendar calendar--multi" part="base" @keydown=${this._handleCalendarKeyDown}>
|
|
824
|
+
<div class="header">
|
|
825
|
+
<button
|
|
826
|
+
class="nav-btn"
|
|
827
|
+
aria-label="Previous month"
|
|
828
|
+
?disabled=${this.disabled}
|
|
829
|
+
@click=${() => this._navigate(-1)}
|
|
830
|
+
>
|
|
831
|
+
<lt-icon name="arrow-left" size="sm"></lt-icon>
|
|
832
|
+
</button>
|
|
833
|
+
<div class="month-label-row">
|
|
834
|
+
${panelLabels.map(
|
|
835
|
+
(label, i) => html`<span class="month-label" aria-live=${i === 0 ? "polite" : "off"} aria-atomic="true"
|
|
836
|
+
>${label}</span
|
|
837
|
+
>`
|
|
838
|
+
)}
|
|
839
|
+
</div>
|
|
840
|
+
<button
|
|
841
|
+
class="nav-btn"
|
|
842
|
+
aria-label="Next month"
|
|
843
|
+
?disabled=${this.disabled}
|
|
844
|
+
@click=${() => this._navigate(1)}
|
|
845
|
+
>
|
|
846
|
+
<lt-icon name="arrow-right" size="sm"></lt-icon>
|
|
847
|
+
</button>
|
|
848
|
+
</div>
|
|
849
|
+
<div class="month-panels">
|
|
850
|
+
${Array.from(
|
|
851
|
+
{ length: this.months },
|
|
852
|
+
(_, i) => html`
|
|
853
|
+
<div class="month-col">
|
|
854
|
+
${this._renderMonthGrid(
|
|
855
|
+
this._monthAtOffset(i).year,
|
|
856
|
+
this._monthAtOffset(i).month,
|
|
857
|
+
panelLabels[i],
|
|
858
|
+
rovingDate
|
|
859
|
+
)}
|
|
860
|
+
</div>
|
|
861
|
+
`
|
|
862
|
+
)}
|
|
863
|
+
</div>
|
|
864
|
+
${footer}
|
|
865
|
+
</div>
|
|
866
|
+
`;
|
|
867
|
+
}
|
|
868
|
+
const monthLabel = new Intl.DateTimeFormat(this.locale, { month: "long", year: "numeric" }).format(
|
|
869
|
+
new Date(this._viewYear, this._viewMonth)
|
|
870
|
+
);
|
|
871
|
+
const prevLabel = this._pickingMonthYear ? "Previous year" : "Previous month";
|
|
872
|
+
const nextLabel = this._pickingMonthYear ? "Next year" : "Next month";
|
|
873
|
+
const header = html`
|
|
874
|
+
<div class="header">
|
|
875
|
+
<button class="nav-btn" aria-label=${prevLabel} ?disabled=${this.disabled} @click=${() => this._navigate(-1)}>
|
|
876
|
+
<lt-icon name="arrow-left" size="sm"></lt-icon>
|
|
877
|
+
</button>
|
|
878
|
+
<button
|
|
879
|
+
class="month-label-btn ${this._pickingMonthYear ? "month-label-btn--open" : ""}"
|
|
880
|
+
aria-expanded=${this._pickingMonthYear ? "true" : "false"}
|
|
881
|
+
aria-label="Choose month and year"
|
|
882
|
+
?disabled=${this.disabled}
|
|
883
|
+
@click=${() => this._pickingMonthYear ? this._closePicker() : this._openPicker()}
|
|
884
|
+
>
|
|
885
|
+
<span aria-live="polite" aria-atomic="true">${this._pickingMonthYear ? this._pickerYear : monthLabel}</span>
|
|
886
|
+
<lt-icon name="arrow-down" size="sm" class="picker-chevron"></lt-icon>
|
|
887
|
+
</button>
|
|
888
|
+
<button class="nav-btn" aria-label=${nextLabel} ?disabled=${this.disabled} @click=${() => this._navigate(1)}>
|
|
889
|
+
<lt-icon name="arrow-right" size="sm"></lt-icon>
|
|
890
|
+
</button>
|
|
891
|
+
</div>
|
|
892
|
+
`;
|
|
893
|
+
const pickerBody = this._pickingMonthYear ? html`
|
|
894
|
+
<div class="picker-months">
|
|
895
|
+
${Array.from({ length: 12 }, (_, i) => {
|
|
896
|
+
const label = new Intl.DateTimeFormat(this.locale, { month: "short" }).format(
|
|
897
|
+
new Date(this._pickerYear, i)
|
|
898
|
+
);
|
|
899
|
+
const isCurrent = i === this._viewMonth && this._pickerYear === this._viewYear;
|
|
900
|
+
return html`
|
|
901
|
+
<button
|
|
902
|
+
class="picker-month-btn ${isCurrent ? "picker-month-btn--current" : ""}"
|
|
903
|
+
?disabled=${this.disabled}
|
|
904
|
+
@click=${() => this._selectPickerMonth(i)}
|
|
905
|
+
>
|
|
906
|
+
${label}
|
|
907
|
+
</button>
|
|
908
|
+
`;
|
|
909
|
+
})}
|
|
910
|
+
</div>
|
|
911
|
+
` : this._renderMonthGrid(this._viewYear, this._viewMonth, monthLabel, rovingDate);
|
|
912
|
+
return html`
|
|
913
|
+
<div class="calendar" part="base" @keydown=${this._handleCalendarKeyDown}>${header} ${pickerBody} ${footer}</div>
|
|
914
|
+
`;
|
|
915
|
+
}
|
|
916
|
+
};
|
|
917
|
+
Calendar.styles = calendarStyles;
|
|
918
|
+
__decorateClass([
|
|
919
|
+
property2({ reflect: true })
|
|
920
|
+
], Calendar.prototype, "mode", 2);
|
|
921
|
+
__decorateClass([
|
|
922
|
+
property2({ reflect: true })
|
|
923
|
+
], Calendar.prototype, "value", 2);
|
|
924
|
+
__decorateClass([
|
|
925
|
+
property2({ reflect: true, attribute: "value-start" })
|
|
926
|
+
], Calendar.prototype, "valueStart", 2);
|
|
927
|
+
__decorateClass([
|
|
928
|
+
property2({ reflect: true, attribute: "value-end" })
|
|
929
|
+
], Calendar.prototype, "valueEnd", 2);
|
|
930
|
+
__decorateClass([
|
|
931
|
+
property2({ reflect: true })
|
|
932
|
+
], Calendar.prototype, "min", 2);
|
|
933
|
+
__decorateClass([
|
|
934
|
+
property2({ reflect: true })
|
|
935
|
+
], Calendar.prototype, "max", 2);
|
|
936
|
+
__decorateClass([
|
|
937
|
+
property2({ reflect: true })
|
|
938
|
+
], Calendar.prototype, "locale", 2);
|
|
939
|
+
__decorateClass([
|
|
940
|
+
property2({ attribute: "week-start", reflect: true })
|
|
941
|
+
], Calendar.prototype, "weekStart", 2);
|
|
942
|
+
__decorateClass([
|
|
943
|
+
property2({ type: Boolean, attribute: "show-outside-days", reflect: true })
|
|
944
|
+
], Calendar.prototype, "showOutsideDays", 2);
|
|
945
|
+
__decorateClass([
|
|
946
|
+
property2({ type: Boolean, reflect: true })
|
|
947
|
+
], Calendar.prototype, "disabled", 2);
|
|
948
|
+
__decorateClass([
|
|
949
|
+
property2({ type: Number, reflect: true })
|
|
950
|
+
], Calendar.prototype, "months", 2);
|
|
951
|
+
__decorateClass([
|
|
952
|
+
state()
|
|
953
|
+
], Calendar.prototype, "_viewYear", 2);
|
|
954
|
+
__decorateClass([
|
|
955
|
+
state()
|
|
956
|
+
], Calendar.prototype, "_viewMonth", 2);
|
|
957
|
+
__decorateClass([
|
|
958
|
+
state()
|
|
959
|
+
], Calendar.prototype, "_focusedDate", 2);
|
|
960
|
+
__decorateClass([
|
|
961
|
+
state()
|
|
962
|
+
], Calendar.prototype, "_hoverDate", 2);
|
|
963
|
+
__decorateClass([
|
|
964
|
+
state()
|
|
965
|
+
], Calendar.prototype, "_pickingMonthYear", 2);
|
|
966
|
+
__decorateClass([
|
|
967
|
+
state()
|
|
968
|
+
], Calendar.prototype, "_pickerYear", 2);
|
|
969
|
+
Calendar = __decorateClass([
|
|
970
|
+
customElement("lt-calendar")
|
|
971
|
+
], Calendar);
|
|
972
|
+
|
|
973
|
+
// src/components/text/text.ts
|
|
974
|
+
import { customElement as customElement2, property as property3 } from "lit/decorators.js";
|
|
975
|
+
import { html as html2, unsafeStatic } from "lit/static-html.js";
|
|
976
|
+
|
|
977
|
+
// src/components/text/text.styles.ts
|
|
978
|
+
import { css as css2 } from "lit";
|
|
979
|
+
var textStyles = css2`
|
|
980
|
+
:host {
|
|
981
|
+
display: block;
|
|
982
|
+
color: inherit;
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
/* Inline variants sit in text flow */
|
|
986
|
+
:host([variant='caption']),
|
|
987
|
+
:host([variant='overline']),
|
|
988
|
+
:host([variant='label']) {
|
|
989
|
+
display: inline;
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
[part='base'] {
|
|
993
|
+
margin: 0;
|
|
994
|
+
color: inherit;
|
|
995
|
+
font-family: var(--lt-typography-fontfamily);
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
/* ── Display ─────────────────────────────────────────────────────────── */
|
|
999
|
+
|
|
1000
|
+
:host([variant='display-2xl']) [part='base'] {
|
|
1001
|
+
font-size: clamp(2.5rem, 6vw, 4.5rem);
|
|
1002
|
+
font-weight: var(--lt-text-weight, 200);
|
|
1003
|
+
line-height: 1.1;
|
|
1004
|
+
letter-spacing: -0.02em;
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
:host([variant='display-xl']) [part='base'] {
|
|
1008
|
+
font-size: clamp(2rem, 5vw, 3.75rem);
|
|
1009
|
+
font-weight: var(--lt-text-weight, 200);
|
|
1010
|
+
line-height: 1.1;
|
|
1011
|
+
letter-spacing: -0.02em;
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
:host([variant='display-lg']) [part='base'] {
|
|
1015
|
+
font-size: clamp(2rem, 4vw, 3rem);
|
|
1016
|
+
font-weight: var(--lt-text-weight, 200);
|
|
1017
|
+
line-height: 1.15;
|
|
1018
|
+
letter-spacing: -0.01em;
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
/* ── Headings ─────────────────────────────────────────────────────────── */
|
|
1022
|
+
|
|
1023
|
+
:host([variant='h1']) [part='base'] {
|
|
1024
|
+
font-size: clamp(1.75rem, 2.5vw + 0.75rem, 2.5rem);
|
|
1025
|
+
font-weight: var(--lt-text-weight, 600);
|
|
1026
|
+
line-height: 1.2;
|
|
1027
|
+
letter-spacing: -0.02em;
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
:host([variant='h2']) [part='base'] {
|
|
1031
|
+
font-size: clamp(1.5rem, 2vw + 0.5rem, 2rem);
|
|
1032
|
+
font-weight: var(--lt-text-weight, 600);
|
|
1033
|
+
line-height: 1.25;
|
|
1034
|
+
letter-spacing: -0.01em;
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
:host([variant='h3']) [part='base'] {
|
|
1038
|
+
font-size: clamp(1.25rem, 1.5vw + 0.5rem, 1.5rem);
|
|
1039
|
+
font-weight: var(--lt-text-weight, 600);
|
|
1040
|
+
line-height: 1.3;
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
:host([variant='h4']) [part='base'] {
|
|
1044
|
+
font-size: 1.25rem;
|
|
1045
|
+
font-weight: var(--lt-text-weight, 600);
|
|
1046
|
+
line-height: 1.35;
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
:host([variant='h5']) [part='base'] {
|
|
1050
|
+
font-size: 1.125rem;
|
|
1051
|
+
font-weight: var(--lt-text-weight, 600);
|
|
1052
|
+
line-height: 1.4;
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
:host([variant='h6']) [part='base'] {
|
|
1056
|
+
font-size: 1rem;
|
|
1057
|
+
font-weight: var(--lt-text-weight, 600);
|
|
1058
|
+
line-height: 1.4;
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
/* ── Body ─────────────────────────────────────────────────────────────── */
|
|
1062
|
+
|
|
1063
|
+
:host([variant='lead']) [part='base'] {
|
|
1064
|
+
font-size: 1.25rem;
|
|
1065
|
+
font-weight: var(--lt-text-weight, 400);
|
|
1066
|
+
line-height: 1.6;
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
:host([variant='body']) [part='base'],
|
|
1070
|
+
:host(:not([variant])) [part='base'] {
|
|
1071
|
+
font-size: 1rem;
|
|
1072
|
+
font-weight: var(--lt-text-weight, 400);
|
|
1073
|
+
line-height: 1.6;
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
:host([variant='body-sm']) [part='base'] {
|
|
1077
|
+
font-size: 0.875rem;
|
|
1078
|
+
font-weight: var(--lt-text-weight, 400);
|
|
1079
|
+
line-height: 1.6;
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
/* ── Inline ───────────────────────────────────────────────────────────── */
|
|
1083
|
+
|
|
1084
|
+
:host([variant='caption']) [part='base'] {
|
|
1085
|
+
font-size: 0.75rem;
|
|
1086
|
+
font-weight: var(--lt-text-weight, 400);
|
|
1087
|
+
line-height: 1.5;
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
:host([variant='overline']) [part='base'] {
|
|
1091
|
+
font-size: 0.6875rem;
|
|
1092
|
+
font-weight: var(--lt-text-weight, 600);
|
|
1093
|
+
line-height: 1.2;
|
|
1094
|
+
letter-spacing: 0.08em;
|
|
1095
|
+
text-transform: uppercase;
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
:host([variant='label']) [part='base'] {
|
|
1099
|
+
font-size: 0.875rem;
|
|
1100
|
+
font-weight: var(--lt-text-weight, 600);
|
|
1101
|
+
line-height: 1.4;
|
|
1102
|
+
}
|
|
1103
|
+
`;
|
|
1104
|
+
|
|
1105
|
+
// src/components/text/text.ts
|
|
1106
|
+
var VARIANT_TAG = {
|
|
1107
|
+
"display-2xl": "p",
|
|
1108
|
+
"display-xl": "p",
|
|
1109
|
+
"display-lg": "p",
|
|
1110
|
+
h1: "h1",
|
|
1111
|
+
h2: "h2",
|
|
1112
|
+
h3: "h3",
|
|
1113
|
+
h4: "h4",
|
|
1114
|
+
h5: "h5",
|
|
1115
|
+
h6: "h6",
|
|
1116
|
+
lead: "p",
|
|
1117
|
+
body: "p",
|
|
1118
|
+
"body-sm": "p",
|
|
1119
|
+
caption: "span",
|
|
1120
|
+
overline: "span",
|
|
1121
|
+
label: "span"
|
|
1122
|
+
};
|
|
1123
|
+
var Text = class extends ThemeableElement {
|
|
1124
|
+
constructor() {
|
|
1125
|
+
super(...arguments);
|
|
1126
|
+
this.variant = "body";
|
|
1127
|
+
this.as = "";
|
|
1128
|
+
}
|
|
1129
|
+
render() {
|
|
1130
|
+
const tag = unsafeStatic(this.as || VARIANT_TAG[this.variant] || "p");
|
|
1131
|
+
return html2`<${tag} part="base"><slot></slot></${tag}>`;
|
|
1132
|
+
}
|
|
1133
|
+
};
|
|
1134
|
+
Text.styles = textStyles;
|
|
1135
|
+
__decorateClass([
|
|
1136
|
+
property3({ reflect: true })
|
|
1137
|
+
], Text.prototype, "variant", 2);
|
|
1138
|
+
__decorateClass([
|
|
1139
|
+
property3({ reflect: true })
|
|
1140
|
+
], Text.prototype, "as", 2);
|
|
1141
|
+
Text = __decorateClass([
|
|
1142
|
+
customElement2("lt-text")
|
|
1143
|
+
], Text);
|
|
1144
|
+
|
|
1145
|
+
// src/components/date-input/date-input.styles.ts
|
|
1146
|
+
import { css as css4 } from "lit";
|
|
1147
|
+
|
|
1148
|
+
// ../../node_modules/.pnpm/@floating-ui+utils@0.2.11/node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
|
|
1149
|
+
var min = Math.min;
|
|
1150
|
+
var max = Math.max;
|
|
1151
|
+
var round = Math.round;
|
|
1152
|
+
var floor = Math.floor;
|
|
1153
|
+
var createCoords = (v) => ({
|
|
1154
|
+
x: v,
|
|
1155
|
+
y: v
|
|
1156
|
+
});
|
|
1157
|
+
var oppositeSideMap = {
|
|
1158
|
+
left: "right",
|
|
1159
|
+
right: "left",
|
|
1160
|
+
bottom: "top",
|
|
1161
|
+
top: "bottom"
|
|
1162
|
+
};
|
|
1163
|
+
function clamp(start, value, end) {
|
|
1164
|
+
return max(start, min(value, end));
|
|
1165
|
+
}
|
|
1166
|
+
function evaluate(value, param) {
|
|
1167
|
+
return typeof value === "function" ? value(param) : value;
|
|
1168
|
+
}
|
|
1169
|
+
function getSide(placement) {
|
|
1170
|
+
return placement.split("-")[0];
|
|
1171
|
+
}
|
|
1172
|
+
function getAlignment(placement) {
|
|
1173
|
+
return placement.split("-")[1];
|
|
1174
|
+
}
|
|
1175
|
+
function getOppositeAxis(axis) {
|
|
1176
|
+
return axis === "x" ? "y" : "x";
|
|
1177
|
+
}
|
|
1178
|
+
function getAxisLength(axis) {
|
|
1179
|
+
return axis === "y" ? "height" : "width";
|
|
1180
|
+
}
|
|
1181
|
+
function getSideAxis(placement) {
|
|
1182
|
+
const firstChar = placement[0];
|
|
1183
|
+
return firstChar === "t" || firstChar === "b" ? "y" : "x";
|
|
1184
|
+
}
|
|
1185
|
+
function getAlignmentAxis(placement) {
|
|
1186
|
+
return getOppositeAxis(getSideAxis(placement));
|
|
1187
|
+
}
|
|
1188
|
+
function getAlignmentSides(placement, rects, rtl) {
|
|
1189
|
+
if (rtl === void 0) {
|
|
1190
|
+
rtl = false;
|
|
1191
|
+
}
|
|
1192
|
+
const alignment = getAlignment(placement);
|
|
1193
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
1194
|
+
const length = getAxisLength(alignmentAxis);
|
|
1195
|
+
let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
|
|
1196
|
+
if (rects.reference[length] > rects.floating[length]) {
|
|
1197
|
+
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
1198
|
+
}
|
|
1199
|
+
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
|
1200
|
+
}
|
|
1201
|
+
function getExpandedPlacements(placement) {
|
|
1202
|
+
const oppositePlacement = getOppositePlacement(placement);
|
|
1203
|
+
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
1204
|
+
}
|
|
1205
|
+
function getOppositeAlignmentPlacement(placement) {
|
|
1206
|
+
return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
|
|
1207
|
+
}
|
|
1208
|
+
var lrPlacement = ["left", "right"];
|
|
1209
|
+
var rlPlacement = ["right", "left"];
|
|
1210
|
+
var tbPlacement = ["top", "bottom"];
|
|
1211
|
+
var btPlacement = ["bottom", "top"];
|
|
1212
|
+
function getSideList(side, isStart, rtl) {
|
|
1213
|
+
switch (side) {
|
|
1214
|
+
case "top":
|
|
1215
|
+
case "bottom":
|
|
1216
|
+
if (rtl) return isStart ? rlPlacement : lrPlacement;
|
|
1217
|
+
return isStart ? lrPlacement : rlPlacement;
|
|
1218
|
+
case "left":
|
|
1219
|
+
case "right":
|
|
1220
|
+
return isStart ? tbPlacement : btPlacement;
|
|
1221
|
+
default:
|
|
1222
|
+
return [];
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
1226
|
+
const alignment = getAlignment(placement);
|
|
1227
|
+
let list = getSideList(getSide(placement), direction === "start", rtl);
|
|
1228
|
+
if (alignment) {
|
|
1229
|
+
list = list.map((side) => side + "-" + alignment);
|
|
1230
|
+
if (flipAlignment) {
|
|
1231
|
+
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
return list;
|
|
1235
|
+
}
|
|
1236
|
+
function getOppositePlacement(placement) {
|
|
1237
|
+
const side = getSide(placement);
|
|
1238
|
+
return oppositeSideMap[side] + placement.slice(side.length);
|
|
1239
|
+
}
|
|
1240
|
+
function expandPaddingObject(padding) {
|
|
1241
|
+
return {
|
|
1242
|
+
top: 0,
|
|
1243
|
+
right: 0,
|
|
1244
|
+
bottom: 0,
|
|
1245
|
+
left: 0,
|
|
1246
|
+
...padding
|
|
1247
|
+
};
|
|
1248
|
+
}
|
|
1249
|
+
function getPaddingObject(padding) {
|
|
1250
|
+
return typeof padding !== "number" ? expandPaddingObject(padding) : {
|
|
1251
|
+
top: padding,
|
|
1252
|
+
right: padding,
|
|
1253
|
+
bottom: padding,
|
|
1254
|
+
left: padding
|
|
1255
|
+
};
|
|
1256
|
+
}
|
|
1257
|
+
function rectToClientRect(rect) {
|
|
1258
|
+
const {
|
|
1259
|
+
x,
|
|
1260
|
+
y,
|
|
1261
|
+
width,
|
|
1262
|
+
height
|
|
1263
|
+
} = rect;
|
|
1264
|
+
return {
|
|
1265
|
+
width,
|
|
1266
|
+
height,
|
|
1267
|
+
top: y,
|
|
1268
|
+
left: x,
|
|
1269
|
+
right: x + width,
|
|
1270
|
+
bottom: y + height,
|
|
1271
|
+
x,
|
|
1272
|
+
y
|
|
1273
|
+
};
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
// ../../node_modules/.pnpm/@floating-ui+core@1.7.5/node_modules/@floating-ui/core/dist/floating-ui.core.mjs
|
|
1277
|
+
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
1278
|
+
let {
|
|
1279
|
+
reference,
|
|
1280
|
+
floating
|
|
1281
|
+
} = _ref;
|
|
1282
|
+
const sideAxis = getSideAxis(placement);
|
|
1283
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
1284
|
+
const alignLength = getAxisLength(alignmentAxis);
|
|
1285
|
+
const side = getSide(placement);
|
|
1286
|
+
const isVertical = sideAxis === "y";
|
|
1287
|
+
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
1288
|
+
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
1289
|
+
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
|
|
1290
|
+
let coords;
|
|
1291
|
+
switch (side) {
|
|
1292
|
+
case "top":
|
|
1293
|
+
coords = {
|
|
1294
|
+
x: commonX,
|
|
1295
|
+
y: reference.y - floating.height
|
|
1296
|
+
};
|
|
1297
|
+
break;
|
|
1298
|
+
case "bottom":
|
|
1299
|
+
coords = {
|
|
1300
|
+
x: commonX,
|
|
1301
|
+
y: reference.y + reference.height
|
|
1302
|
+
};
|
|
1303
|
+
break;
|
|
1304
|
+
case "right":
|
|
1305
|
+
coords = {
|
|
1306
|
+
x: reference.x + reference.width,
|
|
1307
|
+
y: commonY
|
|
1308
|
+
};
|
|
1309
|
+
break;
|
|
1310
|
+
case "left":
|
|
1311
|
+
coords = {
|
|
1312
|
+
x: reference.x - floating.width,
|
|
1313
|
+
y: commonY
|
|
1314
|
+
};
|
|
1315
|
+
break;
|
|
1316
|
+
default:
|
|
1317
|
+
coords = {
|
|
1318
|
+
x: reference.x,
|
|
1319
|
+
y: reference.y
|
|
1320
|
+
};
|
|
1321
|
+
}
|
|
1322
|
+
switch (getAlignment(placement)) {
|
|
1323
|
+
case "start":
|
|
1324
|
+
coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
1325
|
+
break;
|
|
1326
|
+
case "end":
|
|
1327
|
+
coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
1328
|
+
break;
|
|
1329
|
+
}
|
|
1330
|
+
return coords;
|
|
1331
|
+
}
|
|
1332
|
+
async function detectOverflow(state3, options) {
|
|
1333
|
+
var _await$platform$isEle;
|
|
1334
|
+
if (options === void 0) {
|
|
1335
|
+
options = {};
|
|
1336
|
+
}
|
|
1337
|
+
const {
|
|
1338
|
+
x,
|
|
1339
|
+
y,
|
|
1340
|
+
platform: platform2,
|
|
1341
|
+
rects,
|
|
1342
|
+
elements,
|
|
1343
|
+
strategy
|
|
1344
|
+
} = state3;
|
|
1345
|
+
const {
|
|
1346
|
+
boundary = "clippingAncestors",
|
|
1347
|
+
rootBoundary = "viewport",
|
|
1348
|
+
elementContext = "floating",
|
|
1349
|
+
altBoundary = false,
|
|
1350
|
+
padding = 0
|
|
1351
|
+
} = evaluate(options, state3);
|
|
1352
|
+
const paddingObject = getPaddingObject(padding);
|
|
1353
|
+
const altContext = elementContext === "floating" ? "reference" : "floating";
|
|
1354
|
+
const element = elements[altBoundary ? altContext : elementContext];
|
|
1355
|
+
const clippingClientRect = rectToClientRect(await platform2.getClippingRect({
|
|
1356
|
+
element: ((_await$platform$isEle = await (platform2.isElement == null ? void 0 : platform2.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform2.getDocumentElement == null ? void 0 : platform2.getDocumentElement(elements.floating)),
|
|
1357
|
+
boundary,
|
|
1358
|
+
rootBoundary,
|
|
1359
|
+
strategy
|
|
1360
|
+
}));
|
|
1361
|
+
const rect = elementContext === "floating" ? {
|
|
1362
|
+
x,
|
|
1363
|
+
y,
|
|
1364
|
+
width: rects.floating.width,
|
|
1365
|
+
height: rects.floating.height
|
|
1366
|
+
} : rects.reference;
|
|
1367
|
+
const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
|
|
1368
|
+
const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
|
|
1369
|
+
x: 1,
|
|
1370
|
+
y: 1
|
|
1371
|
+
} : {
|
|
1372
|
+
x: 1,
|
|
1373
|
+
y: 1
|
|
1374
|
+
};
|
|
1375
|
+
const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
1376
|
+
elements,
|
|
1377
|
+
rect,
|
|
1378
|
+
offsetParent,
|
|
1379
|
+
strategy
|
|
1380
|
+
}) : rect);
|
|
1381
|
+
return {
|
|
1382
|
+
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
1383
|
+
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
1384
|
+
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
1385
|
+
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
1386
|
+
};
|
|
1387
|
+
}
|
|
1388
|
+
var MAX_RESET_COUNT = 50;
|
|
1389
|
+
var computePosition = async (reference, floating, config) => {
|
|
1390
|
+
const {
|
|
1391
|
+
placement = "bottom",
|
|
1392
|
+
strategy = "absolute",
|
|
1393
|
+
middleware = [],
|
|
1394
|
+
platform: platform2
|
|
1395
|
+
} = config;
|
|
1396
|
+
const platformWithDetectOverflow = platform2.detectOverflow ? platform2 : {
|
|
1397
|
+
...platform2,
|
|
1398
|
+
detectOverflow
|
|
1399
|
+
};
|
|
1400
|
+
const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
|
|
1401
|
+
let rects = await platform2.getElementRects({
|
|
1402
|
+
reference,
|
|
1403
|
+
floating,
|
|
1404
|
+
strategy
|
|
1405
|
+
});
|
|
1406
|
+
let {
|
|
1407
|
+
x,
|
|
1408
|
+
y
|
|
1409
|
+
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
1410
|
+
let statefulPlacement = placement;
|
|
1411
|
+
let resetCount = 0;
|
|
1412
|
+
const middlewareData = {};
|
|
1413
|
+
for (let i = 0; i < middleware.length; i++) {
|
|
1414
|
+
const currentMiddleware = middleware[i];
|
|
1415
|
+
if (!currentMiddleware) {
|
|
1416
|
+
continue;
|
|
1417
|
+
}
|
|
1418
|
+
const {
|
|
1419
|
+
name,
|
|
1420
|
+
fn
|
|
1421
|
+
} = currentMiddleware;
|
|
1422
|
+
const {
|
|
1423
|
+
x: nextX,
|
|
1424
|
+
y: nextY,
|
|
1425
|
+
data,
|
|
1426
|
+
reset
|
|
1427
|
+
} = await fn({
|
|
1428
|
+
x,
|
|
1429
|
+
y,
|
|
1430
|
+
initialPlacement: placement,
|
|
1431
|
+
placement: statefulPlacement,
|
|
1432
|
+
strategy,
|
|
1433
|
+
middlewareData,
|
|
1434
|
+
rects,
|
|
1435
|
+
platform: platformWithDetectOverflow,
|
|
1436
|
+
elements: {
|
|
1437
|
+
reference,
|
|
1438
|
+
floating
|
|
1439
|
+
}
|
|
1440
|
+
});
|
|
1441
|
+
x = nextX != null ? nextX : x;
|
|
1442
|
+
y = nextY != null ? nextY : y;
|
|
1443
|
+
middlewareData[name] = {
|
|
1444
|
+
...middlewareData[name],
|
|
1445
|
+
...data
|
|
1446
|
+
};
|
|
1447
|
+
if (reset && resetCount < MAX_RESET_COUNT) {
|
|
1448
|
+
resetCount++;
|
|
1449
|
+
if (typeof reset === "object") {
|
|
1450
|
+
if (reset.placement) {
|
|
1451
|
+
statefulPlacement = reset.placement;
|
|
1452
|
+
}
|
|
1453
|
+
if (reset.rects) {
|
|
1454
|
+
rects = reset.rects === true ? await platform2.getElementRects({
|
|
1455
|
+
reference,
|
|
1456
|
+
floating,
|
|
1457
|
+
strategy
|
|
1458
|
+
}) : reset.rects;
|
|
1459
|
+
}
|
|
1460
|
+
({
|
|
1461
|
+
x,
|
|
1462
|
+
y
|
|
1463
|
+
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
1464
|
+
}
|
|
1465
|
+
i = -1;
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
return {
|
|
1469
|
+
x,
|
|
1470
|
+
y,
|
|
1471
|
+
placement: statefulPlacement,
|
|
1472
|
+
strategy,
|
|
1473
|
+
middlewareData
|
|
1474
|
+
};
|
|
1475
|
+
};
|
|
1476
|
+
var flip = function(options) {
|
|
1477
|
+
if (options === void 0) {
|
|
1478
|
+
options = {};
|
|
1479
|
+
}
|
|
1480
|
+
return {
|
|
1481
|
+
name: "flip",
|
|
1482
|
+
options,
|
|
1483
|
+
async fn(state3) {
|
|
1484
|
+
var _middlewareData$arrow, _middlewareData$flip;
|
|
1485
|
+
const {
|
|
1486
|
+
placement,
|
|
1487
|
+
middlewareData,
|
|
1488
|
+
rects,
|
|
1489
|
+
initialPlacement,
|
|
1490
|
+
platform: platform2,
|
|
1491
|
+
elements
|
|
1492
|
+
} = state3;
|
|
1493
|
+
const {
|
|
1494
|
+
mainAxis: checkMainAxis = true,
|
|
1495
|
+
crossAxis: checkCrossAxis = true,
|
|
1496
|
+
fallbackPlacements: specifiedFallbackPlacements,
|
|
1497
|
+
fallbackStrategy = "bestFit",
|
|
1498
|
+
fallbackAxisSideDirection = "none",
|
|
1499
|
+
flipAlignment = true,
|
|
1500
|
+
...detectOverflowOptions
|
|
1501
|
+
} = evaluate(options, state3);
|
|
1502
|
+
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
1503
|
+
return {};
|
|
1504
|
+
}
|
|
1505
|
+
const side = getSide(placement);
|
|
1506
|
+
const initialSideAxis = getSideAxis(initialPlacement);
|
|
1507
|
+
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
1508
|
+
const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
|
|
1509
|
+
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
1510
|
+
const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
|
|
1511
|
+
if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
|
|
1512
|
+
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
1513
|
+
}
|
|
1514
|
+
const placements2 = [initialPlacement, ...fallbackPlacements];
|
|
1515
|
+
const overflow = await platform2.detectOverflow(state3, detectOverflowOptions);
|
|
1516
|
+
const overflows = [];
|
|
1517
|
+
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
1518
|
+
if (checkMainAxis) {
|
|
1519
|
+
overflows.push(overflow[side]);
|
|
1520
|
+
}
|
|
1521
|
+
if (checkCrossAxis) {
|
|
1522
|
+
const sides2 = getAlignmentSides(placement, rects, rtl);
|
|
1523
|
+
overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
|
|
1524
|
+
}
|
|
1525
|
+
overflowsData = [...overflowsData, {
|
|
1526
|
+
placement,
|
|
1527
|
+
overflows
|
|
1528
|
+
}];
|
|
1529
|
+
if (!overflows.every((side2) => side2 <= 0)) {
|
|
1530
|
+
var _middlewareData$flip2, _overflowsData$filter;
|
|
1531
|
+
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
|
1532
|
+
const nextPlacement = placements2[nextIndex];
|
|
1533
|
+
if (nextPlacement) {
|
|
1534
|
+
const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
|
|
1535
|
+
if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
|
|
1536
|
+
// overflows the main axis.
|
|
1537
|
+
overflowsData.every((d) => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
|
|
1538
|
+
return {
|
|
1539
|
+
data: {
|
|
1540
|
+
index: nextIndex,
|
|
1541
|
+
overflows: overflowsData
|
|
1542
|
+
},
|
|
1543
|
+
reset: {
|
|
1544
|
+
placement: nextPlacement
|
|
1545
|
+
}
|
|
1546
|
+
};
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
let resetPlacement = (_overflowsData$filter = overflowsData.filter((d) => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
|
|
1550
|
+
if (!resetPlacement) {
|
|
1551
|
+
switch (fallbackStrategy) {
|
|
1552
|
+
case "bestFit": {
|
|
1553
|
+
var _overflowsData$filter2;
|
|
1554
|
+
const placement2 = (_overflowsData$filter2 = overflowsData.filter((d) => {
|
|
1555
|
+
if (hasFallbackAxisSideDirection) {
|
|
1556
|
+
const currentSideAxis = getSideAxis(d.placement);
|
|
1557
|
+
return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
|
|
1558
|
+
// reading directions favoring greater width.
|
|
1559
|
+
currentSideAxis === "y";
|
|
1560
|
+
}
|
|
1561
|
+
return true;
|
|
1562
|
+
}).map((d) => [d.placement, d.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
|
|
1563
|
+
if (placement2) {
|
|
1564
|
+
resetPlacement = placement2;
|
|
1565
|
+
}
|
|
1566
|
+
break;
|
|
1567
|
+
}
|
|
1568
|
+
case "initialPlacement":
|
|
1569
|
+
resetPlacement = initialPlacement;
|
|
1570
|
+
break;
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
if (placement !== resetPlacement) {
|
|
1574
|
+
return {
|
|
1575
|
+
reset: {
|
|
1576
|
+
placement: resetPlacement
|
|
1577
|
+
}
|
|
1578
|
+
};
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
return {};
|
|
1582
|
+
}
|
|
1583
|
+
};
|
|
1584
|
+
};
|
|
1585
|
+
var originSides = /* @__PURE__ */ new Set(["left", "top"]);
|
|
1586
|
+
async function convertValueToCoords(state3, options) {
|
|
1587
|
+
const {
|
|
1588
|
+
placement,
|
|
1589
|
+
platform: platform2,
|
|
1590
|
+
elements
|
|
1591
|
+
} = state3;
|
|
1592
|
+
const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
|
|
1593
|
+
const side = getSide(placement);
|
|
1594
|
+
const alignment = getAlignment(placement);
|
|
1595
|
+
const isVertical = getSideAxis(placement) === "y";
|
|
1596
|
+
const mainAxisMulti = originSides.has(side) ? -1 : 1;
|
|
1597
|
+
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
1598
|
+
const rawValue = evaluate(options, state3);
|
|
1599
|
+
let {
|
|
1600
|
+
mainAxis,
|
|
1601
|
+
crossAxis,
|
|
1602
|
+
alignmentAxis
|
|
1603
|
+
} = typeof rawValue === "number" ? {
|
|
1604
|
+
mainAxis: rawValue,
|
|
1605
|
+
crossAxis: 0,
|
|
1606
|
+
alignmentAxis: null
|
|
1607
|
+
} : {
|
|
1608
|
+
mainAxis: rawValue.mainAxis || 0,
|
|
1609
|
+
crossAxis: rawValue.crossAxis || 0,
|
|
1610
|
+
alignmentAxis: rawValue.alignmentAxis
|
|
1611
|
+
};
|
|
1612
|
+
if (alignment && typeof alignmentAxis === "number") {
|
|
1613
|
+
crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
|
|
1614
|
+
}
|
|
1615
|
+
return isVertical ? {
|
|
1616
|
+
x: crossAxis * crossAxisMulti,
|
|
1617
|
+
y: mainAxis * mainAxisMulti
|
|
1618
|
+
} : {
|
|
1619
|
+
x: mainAxis * mainAxisMulti,
|
|
1620
|
+
y: crossAxis * crossAxisMulti
|
|
1621
|
+
};
|
|
1622
|
+
}
|
|
1623
|
+
var offset = function(options) {
|
|
1624
|
+
if (options === void 0) {
|
|
1625
|
+
options = 0;
|
|
1626
|
+
}
|
|
1627
|
+
return {
|
|
1628
|
+
name: "offset",
|
|
1629
|
+
options,
|
|
1630
|
+
async fn(state3) {
|
|
1631
|
+
var _middlewareData$offse, _middlewareData$arrow;
|
|
1632
|
+
const {
|
|
1633
|
+
x,
|
|
1634
|
+
y,
|
|
1635
|
+
placement,
|
|
1636
|
+
middlewareData
|
|
1637
|
+
} = state3;
|
|
1638
|
+
const diffCoords = await convertValueToCoords(state3, options);
|
|
1639
|
+
if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
1640
|
+
return {};
|
|
1641
|
+
}
|
|
1642
|
+
return {
|
|
1643
|
+
x: x + diffCoords.x,
|
|
1644
|
+
y: y + diffCoords.y,
|
|
1645
|
+
data: {
|
|
1646
|
+
...diffCoords,
|
|
1647
|
+
placement
|
|
1648
|
+
}
|
|
1649
|
+
};
|
|
1650
|
+
}
|
|
1651
|
+
};
|
|
1652
|
+
};
|
|
1653
|
+
var shift = function(options) {
|
|
1654
|
+
if (options === void 0) {
|
|
1655
|
+
options = {};
|
|
1656
|
+
}
|
|
1657
|
+
return {
|
|
1658
|
+
name: "shift",
|
|
1659
|
+
options,
|
|
1660
|
+
async fn(state3) {
|
|
1661
|
+
const {
|
|
1662
|
+
x,
|
|
1663
|
+
y,
|
|
1664
|
+
placement,
|
|
1665
|
+
platform: platform2
|
|
1666
|
+
} = state3;
|
|
1667
|
+
const {
|
|
1668
|
+
mainAxis: checkMainAxis = true,
|
|
1669
|
+
crossAxis: checkCrossAxis = false,
|
|
1670
|
+
limiter = {
|
|
1671
|
+
fn: (_ref) => {
|
|
1672
|
+
let {
|
|
1673
|
+
x: x2,
|
|
1674
|
+
y: y2
|
|
1675
|
+
} = _ref;
|
|
1676
|
+
return {
|
|
1677
|
+
x: x2,
|
|
1678
|
+
y: y2
|
|
1679
|
+
};
|
|
1680
|
+
}
|
|
1681
|
+
},
|
|
1682
|
+
...detectOverflowOptions
|
|
1683
|
+
} = evaluate(options, state3);
|
|
1684
|
+
const coords = {
|
|
1685
|
+
x,
|
|
1686
|
+
y
|
|
1687
|
+
};
|
|
1688
|
+
const overflow = await platform2.detectOverflow(state3, detectOverflowOptions);
|
|
1689
|
+
const crossAxis = getSideAxis(getSide(placement));
|
|
1690
|
+
const mainAxis = getOppositeAxis(crossAxis);
|
|
1691
|
+
let mainAxisCoord = coords[mainAxis];
|
|
1692
|
+
let crossAxisCoord = coords[crossAxis];
|
|
1693
|
+
if (checkMainAxis) {
|
|
1694
|
+
const minSide = mainAxis === "y" ? "top" : "left";
|
|
1695
|
+
const maxSide = mainAxis === "y" ? "bottom" : "right";
|
|
1696
|
+
const min2 = mainAxisCoord + overflow[minSide];
|
|
1697
|
+
const max2 = mainAxisCoord - overflow[maxSide];
|
|
1698
|
+
mainAxisCoord = clamp(min2, mainAxisCoord, max2);
|
|
1699
|
+
}
|
|
1700
|
+
if (checkCrossAxis) {
|
|
1701
|
+
const minSide = crossAxis === "y" ? "top" : "left";
|
|
1702
|
+
const maxSide = crossAxis === "y" ? "bottom" : "right";
|
|
1703
|
+
const min2 = crossAxisCoord + overflow[minSide];
|
|
1704
|
+
const max2 = crossAxisCoord - overflow[maxSide];
|
|
1705
|
+
crossAxisCoord = clamp(min2, crossAxisCoord, max2);
|
|
1706
|
+
}
|
|
1707
|
+
const limitedCoords = limiter.fn({
|
|
1708
|
+
...state3,
|
|
1709
|
+
[mainAxis]: mainAxisCoord,
|
|
1710
|
+
[crossAxis]: crossAxisCoord
|
|
1711
|
+
});
|
|
1712
|
+
return {
|
|
1713
|
+
...limitedCoords,
|
|
1714
|
+
data: {
|
|
1715
|
+
x: limitedCoords.x - x,
|
|
1716
|
+
y: limitedCoords.y - y,
|
|
1717
|
+
enabled: {
|
|
1718
|
+
[mainAxis]: checkMainAxis,
|
|
1719
|
+
[crossAxis]: checkCrossAxis
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
};
|
|
1723
|
+
}
|
|
1724
|
+
};
|
|
1725
|
+
};
|
|
1726
|
+
|
|
1727
|
+
// ../../node_modules/.pnpm/@floating-ui+utils@0.2.11/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
|
|
1728
|
+
function hasWindow() {
|
|
1729
|
+
return typeof window !== "undefined";
|
|
1730
|
+
}
|
|
1731
|
+
function getNodeName(node) {
|
|
1732
|
+
if (isNode(node)) {
|
|
1733
|
+
return (node.nodeName || "").toLowerCase();
|
|
1734
|
+
}
|
|
1735
|
+
return "#document";
|
|
1736
|
+
}
|
|
1737
|
+
function getWindow(node) {
|
|
1738
|
+
var _node$ownerDocument;
|
|
1739
|
+
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
1740
|
+
}
|
|
1741
|
+
function getDocumentElement(node) {
|
|
1742
|
+
var _ref;
|
|
1743
|
+
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
|
1744
|
+
}
|
|
1745
|
+
function isNode(value) {
|
|
1746
|
+
if (!hasWindow()) {
|
|
1747
|
+
return false;
|
|
1748
|
+
}
|
|
1749
|
+
return value instanceof Node || value instanceof getWindow(value).Node;
|
|
1750
|
+
}
|
|
1751
|
+
function isElement(value) {
|
|
1752
|
+
if (!hasWindow()) {
|
|
1753
|
+
return false;
|
|
1754
|
+
}
|
|
1755
|
+
return value instanceof Element || value instanceof getWindow(value).Element;
|
|
1756
|
+
}
|
|
1757
|
+
function isHTMLElement(value) {
|
|
1758
|
+
if (!hasWindow()) {
|
|
1759
|
+
return false;
|
|
1760
|
+
}
|
|
1761
|
+
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
|
1762
|
+
}
|
|
1763
|
+
function isShadowRoot(value) {
|
|
1764
|
+
if (!hasWindow() || typeof ShadowRoot === "undefined") {
|
|
1765
|
+
return false;
|
|
1766
|
+
}
|
|
1767
|
+
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
|
1768
|
+
}
|
|
1769
|
+
function isOverflowElement(element) {
|
|
1770
|
+
const {
|
|
1771
|
+
overflow,
|
|
1772
|
+
overflowX,
|
|
1773
|
+
overflowY,
|
|
1774
|
+
display
|
|
1775
|
+
} = getComputedStyle2(element);
|
|
1776
|
+
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
|
|
1777
|
+
}
|
|
1778
|
+
function isTableElement(element) {
|
|
1779
|
+
return /^(table|td|th)$/.test(getNodeName(element));
|
|
1780
|
+
}
|
|
1781
|
+
function isTopLayer(element) {
|
|
1782
|
+
try {
|
|
1783
|
+
if (element.matches(":popover-open")) {
|
|
1784
|
+
return true;
|
|
1785
|
+
}
|
|
1786
|
+
} catch (_e) {
|
|
1787
|
+
}
|
|
1788
|
+
try {
|
|
1789
|
+
return element.matches(":modal");
|
|
1790
|
+
} catch (_e) {
|
|
1791
|
+
return false;
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1794
|
+
var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
|
|
1795
|
+
var containRe = /paint|layout|strict|content/;
|
|
1796
|
+
var isNotNone = (value) => !!value && value !== "none";
|
|
1797
|
+
var isWebKitValue;
|
|
1798
|
+
function isContainingBlock(elementOrCss) {
|
|
1799
|
+
const css5 = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
|
|
1800
|
+
return isNotNone(css5.transform) || isNotNone(css5.translate) || isNotNone(css5.scale) || isNotNone(css5.rotate) || isNotNone(css5.perspective) || !isWebKit() && (isNotNone(css5.backdropFilter) || isNotNone(css5.filter)) || willChangeRe.test(css5.willChange || "") || containRe.test(css5.contain || "");
|
|
1801
|
+
}
|
|
1802
|
+
function getContainingBlock(element) {
|
|
1803
|
+
let currentNode = getParentNode(element);
|
|
1804
|
+
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
1805
|
+
if (isContainingBlock(currentNode)) {
|
|
1806
|
+
return currentNode;
|
|
1807
|
+
} else if (isTopLayer(currentNode)) {
|
|
1808
|
+
return null;
|
|
1809
|
+
}
|
|
1810
|
+
currentNode = getParentNode(currentNode);
|
|
1811
|
+
}
|
|
1812
|
+
return null;
|
|
1813
|
+
}
|
|
1814
|
+
function isWebKit() {
|
|
1815
|
+
if (isWebKitValue == null) {
|
|
1816
|
+
isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
|
|
1817
|
+
}
|
|
1818
|
+
return isWebKitValue;
|
|
1819
|
+
}
|
|
1820
|
+
function isLastTraversableNode(node) {
|
|
1821
|
+
return /^(html|body|#document)$/.test(getNodeName(node));
|
|
1822
|
+
}
|
|
1823
|
+
function getComputedStyle2(element) {
|
|
1824
|
+
return getWindow(element).getComputedStyle(element);
|
|
1825
|
+
}
|
|
1826
|
+
function getNodeScroll(element) {
|
|
1827
|
+
if (isElement(element)) {
|
|
1828
|
+
return {
|
|
1829
|
+
scrollLeft: element.scrollLeft,
|
|
1830
|
+
scrollTop: element.scrollTop
|
|
1831
|
+
};
|
|
1832
|
+
}
|
|
1833
|
+
return {
|
|
1834
|
+
scrollLeft: element.scrollX,
|
|
1835
|
+
scrollTop: element.scrollY
|
|
1836
|
+
};
|
|
1837
|
+
}
|
|
1838
|
+
function getParentNode(node) {
|
|
1839
|
+
if (getNodeName(node) === "html") {
|
|
1840
|
+
return node;
|
|
1841
|
+
}
|
|
1842
|
+
const result = (
|
|
1843
|
+
// Step into the shadow DOM of the parent of a slotted node.
|
|
1844
|
+
node.assignedSlot || // DOM Element detected.
|
|
1845
|
+
node.parentNode || // ShadowRoot detected.
|
|
1846
|
+
isShadowRoot(node) && node.host || // Fallback.
|
|
1847
|
+
getDocumentElement(node)
|
|
1848
|
+
);
|
|
1849
|
+
return isShadowRoot(result) ? result.host : result;
|
|
1850
|
+
}
|
|
1851
|
+
function getNearestOverflowAncestor(node) {
|
|
1852
|
+
const parentNode = getParentNode(node);
|
|
1853
|
+
if (isLastTraversableNode(parentNode)) {
|
|
1854
|
+
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
|
1855
|
+
}
|
|
1856
|
+
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
1857
|
+
return parentNode;
|
|
1858
|
+
}
|
|
1859
|
+
return getNearestOverflowAncestor(parentNode);
|
|
1860
|
+
}
|
|
1861
|
+
function getOverflowAncestors(node, list, traverseIframes) {
|
|
1862
|
+
var _node$ownerDocument2;
|
|
1863
|
+
if (list === void 0) {
|
|
1864
|
+
list = [];
|
|
1865
|
+
}
|
|
1866
|
+
if (traverseIframes === void 0) {
|
|
1867
|
+
traverseIframes = true;
|
|
1868
|
+
}
|
|
1869
|
+
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
1870
|
+
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
|
1871
|
+
const win = getWindow(scrollableAncestor);
|
|
1872
|
+
if (isBody) {
|
|
1873
|
+
const frameElement = getFrameElement(win);
|
|
1874
|
+
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
|
|
1875
|
+
} else {
|
|
1876
|
+
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
function getFrameElement(win) {
|
|
1880
|
+
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1883
|
+
// ../../node_modules/.pnpm/@floating-ui+dom@1.7.6/node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
|
|
1884
|
+
function getCssDimensions(element) {
|
|
1885
|
+
const css5 = getComputedStyle2(element);
|
|
1886
|
+
let width = parseFloat(css5.width) || 0;
|
|
1887
|
+
let height = parseFloat(css5.height) || 0;
|
|
1888
|
+
const hasOffset = isHTMLElement(element);
|
|
1889
|
+
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
|
1890
|
+
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
|
1891
|
+
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
|
1892
|
+
if (shouldFallback) {
|
|
1893
|
+
width = offsetWidth;
|
|
1894
|
+
height = offsetHeight;
|
|
1895
|
+
}
|
|
1896
|
+
return {
|
|
1897
|
+
width,
|
|
1898
|
+
height,
|
|
1899
|
+
$: shouldFallback
|
|
1900
|
+
};
|
|
1901
|
+
}
|
|
1902
|
+
function unwrapElement(element) {
|
|
1903
|
+
return !isElement(element) ? element.contextElement : element;
|
|
1904
|
+
}
|
|
1905
|
+
function getScale(element) {
|
|
1906
|
+
const domElement = unwrapElement(element);
|
|
1907
|
+
if (!isHTMLElement(domElement)) {
|
|
1908
|
+
return createCoords(1);
|
|
1909
|
+
}
|
|
1910
|
+
const rect = domElement.getBoundingClientRect();
|
|
1911
|
+
const {
|
|
1912
|
+
width,
|
|
1913
|
+
height,
|
|
1914
|
+
$
|
|
1915
|
+
} = getCssDimensions(domElement);
|
|
1916
|
+
let x = ($ ? round(rect.width) : rect.width) / width;
|
|
1917
|
+
let y = ($ ? round(rect.height) : rect.height) / height;
|
|
1918
|
+
if (!x || !Number.isFinite(x)) {
|
|
1919
|
+
x = 1;
|
|
1920
|
+
}
|
|
1921
|
+
if (!y || !Number.isFinite(y)) {
|
|
1922
|
+
y = 1;
|
|
1923
|
+
}
|
|
1924
|
+
return {
|
|
1925
|
+
x,
|
|
1926
|
+
y
|
|
1927
|
+
};
|
|
1928
|
+
}
|
|
1929
|
+
var noOffsets = /* @__PURE__ */ createCoords(0);
|
|
1930
|
+
function getVisualOffsets(element) {
|
|
1931
|
+
const win = getWindow(element);
|
|
1932
|
+
if (!isWebKit() || !win.visualViewport) {
|
|
1933
|
+
return noOffsets;
|
|
1934
|
+
}
|
|
1935
|
+
return {
|
|
1936
|
+
x: win.visualViewport.offsetLeft,
|
|
1937
|
+
y: win.visualViewport.offsetTop
|
|
1938
|
+
};
|
|
1939
|
+
}
|
|
1940
|
+
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
|
1941
|
+
if (isFixed === void 0) {
|
|
1942
|
+
isFixed = false;
|
|
1943
|
+
}
|
|
1944
|
+
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
|
|
1945
|
+
return false;
|
|
1946
|
+
}
|
|
1947
|
+
return isFixed;
|
|
1948
|
+
}
|
|
1949
|
+
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
|
1950
|
+
if (includeScale === void 0) {
|
|
1951
|
+
includeScale = false;
|
|
1952
|
+
}
|
|
1953
|
+
if (isFixedStrategy === void 0) {
|
|
1954
|
+
isFixedStrategy = false;
|
|
1955
|
+
}
|
|
1956
|
+
const clientRect = element.getBoundingClientRect();
|
|
1957
|
+
const domElement = unwrapElement(element);
|
|
1958
|
+
let scale = createCoords(1);
|
|
1959
|
+
if (includeScale) {
|
|
1960
|
+
if (offsetParent) {
|
|
1961
|
+
if (isElement(offsetParent)) {
|
|
1962
|
+
scale = getScale(offsetParent);
|
|
1963
|
+
}
|
|
1964
|
+
} else {
|
|
1965
|
+
scale = getScale(element);
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
|
|
1969
|
+
let x = (clientRect.left + visualOffsets.x) / scale.x;
|
|
1970
|
+
let y = (clientRect.top + visualOffsets.y) / scale.y;
|
|
1971
|
+
let width = clientRect.width / scale.x;
|
|
1972
|
+
let height = clientRect.height / scale.y;
|
|
1973
|
+
if (domElement) {
|
|
1974
|
+
const win = getWindow(domElement);
|
|
1975
|
+
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
|
1976
|
+
let currentWin = win;
|
|
1977
|
+
let currentIFrame = getFrameElement(currentWin);
|
|
1978
|
+
while (currentIFrame && offsetParent && offsetWin !== currentWin) {
|
|
1979
|
+
const iframeScale = getScale(currentIFrame);
|
|
1980
|
+
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
1981
|
+
const css5 = getComputedStyle2(currentIFrame);
|
|
1982
|
+
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css5.paddingLeft)) * iframeScale.x;
|
|
1983
|
+
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css5.paddingTop)) * iframeScale.y;
|
|
1984
|
+
x *= iframeScale.x;
|
|
1985
|
+
y *= iframeScale.y;
|
|
1986
|
+
width *= iframeScale.x;
|
|
1987
|
+
height *= iframeScale.y;
|
|
1988
|
+
x += left;
|
|
1989
|
+
y += top;
|
|
1990
|
+
currentWin = getWindow(currentIFrame);
|
|
1991
|
+
currentIFrame = getFrameElement(currentWin);
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1994
|
+
return rectToClientRect({
|
|
1995
|
+
width,
|
|
1996
|
+
height,
|
|
1997
|
+
x,
|
|
1998
|
+
y
|
|
1999
|
+
});
|
|
2000
|
+
}
|
|
2001
|
+
function getWindowScrollBarX(element, rect) {
|
|
2002
|
+
const leftScroll = getNodeScroll(element).scrollLeft;
|
|
2003
|
+
if (!rect) {
|
|
2004
|
+
return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
|
|
2005
|
+
}
|
|
2006
|
+
return rect.left + leftScroll;
|
|
2007
|
+
}
|
|
2008
|
+
function getHTMLOffset(documentElement, scroll) {
|
|
2009
|
+
const htmlRect = documentElement.getBoundingClientRect();
|
|
2010
|
+
const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
|
|
2011
|
+
const y = htmlRect.top + scroll.scrollTop;
|
|
2012
|
+
return {
|
|
2013
|
+
x,
|
|
2014
|
+
y
|
|
2015
|
+
};
|
|
2016
|
+
}
|
|
2017
|
+
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
2018
|
+
let {
|
|
2019
|
+
elements,
|
|
2020
|
+
rect,
|
|
2021
|
+
offsetParent,
|
|
2022
|
+
strategy
|
|
2023
|
+
} = _ref;
|
|
2024
|
+
const isFixed = strategy === "fixed";
|
|
2025
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
2026
|
+
const topLayer = elements ? isTopLayer(elements.floating) : false;
|
|
2027
|
+
if (offsetParent === documentElement || topLayer && isFixed) {
|
|
2028
|
+
return rect;
|
|
2029
|
+
}
|
|
2030
|
+
let scroll = {
|
|
2031
|
+
scrollLeft: 0,
|
|
2032
|
+
scrollTop: 0
|
|
2033
|
+
};
|
|
2034
|
+
let scale = createCoords(1);
|
|
2035
|
+
const offsets = createCoords(0);
|
|
2036
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
2037
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
2038
|
+
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
|
|
2039
|
+
scroll = getNodeScroll(offsetParent);
|
|
2040
|
+
}
|
|
2041
|
+
if (isOffsetParentAnElement) {
|
|
2042
|
+
const offsetRect = getBoundingClientRect(offsetParent);
|
|
2043
|
+
scale = getScale(offsetParent);
|
|
2044
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
2045
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
2048
|
+
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
|
2049
|
+
return {
|
|
2050
|
+
width: rect.width * scale.x,
|
|
2051
|
+
height: rect.height * scale.y,
|
|
2052
|
+
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
|
|
2053
|
+
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
|
|
2054
|
+
};
|
|
2055
|
+
}
|
|
2056
|
+
function getClientRects(element) {
|
|
2057
|
+
return Array.from(element.getClientRects());
|
|
2058
|
+
}
|
|
2059
|
+
function getDocumentRect(element) {
|
|
2060
|
+
const html4 = getDocumentElement(element);
|
|
2061
|
+
const scroll = getNodeScroll(element);
|
|
2062
|
+
const body = element.ownerDocument.body;
|
|
2063
|
+
const width = max(html4.scrollWidth, html4.clientWidth, body.scrollWidth, body.clientWidth);
|
|
2064
|
+
const height = max(html4.scrollHeight, html4.clientHeight, body.scrollHeight, body.clientHeight);
|
|
2065
|
+
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
2066
|
+
const y = -scroll.scrollTop;
|
|
2067
|
+
if (getComputedStyle2(body).direction === "rtl") {
|
|
2068
|
+
x += max(html4.clientWidth, body.clientWidth) - width;
|
|
2069
|
+
}
|
|
2070
|
+
return {
|
|
2071
|
+
width,
|
|
2072
|
+
height,
|
|
2073
|
+
x,
|
|
2074
|
+
y
|
|
2075
|
+
};
|
|
2076
|
+
}
|
|
2077
|
+
var SCROLLBAR_MAX = 25;
|
|
2078
|
+
function getViewportRect(element, strategy) {
|
|
2079
|
+
const win = getWindow(element);
|
|
2080
|
+
const html4 = getDocumentElement(element);
|
|
2081
|
+
const visualViewport = win.visualViewport;
|
|
2082
|
+
let width = html4.clientWidth;
|
|
2083
|
+
let height = html4.clientHeight;
|
|
2084
|
+
let x = 0;
|
|
2085
|
+
let y = 0;
|
|
2086
|
+
if (visualViewport) {
|
|
2087
|
+
width = visualViewport.width;
|
|
2088
|
+
height = visualViewport.height;
|
|
2089
|
+
const visualViewportBased = isWebKit();
|
|
2090
|
+
if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
|
|
2091
|
+
x = visualViewport.offsetLeft;
|
|
2092
|
+
y = visualViewport.offsetTop;
|
|
2093
|
+
}
|
|
2094
|
+
}
|
|
2095
|
+
const windowScrollbarX = getWindowScrollBarX(html4);
|
|
2096
|
+
if (windowScrollbarX <= 0) {
|
|
2097
|
+
const doc = html4.ownerDocument;
|
|
2098
|
+
const body = doc.body;
|
|
2099
|
+
const bodyStyles = getComputedStyle(body);
|
|
2100
|
+
const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
|
|
2101
|
+
const clippingStableScrollbarWidth = Math.abs(html4.clientWidth - body.clientWidth - bodyMarginInline);
|
|
2102
|
+
if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
|
|
2103
|
+
width -= clippingStableScrollbarWidth;
|
|
2104
|
+
}
|
|
2105
|
+
} else if (windowScrollbarX <= SCROLLBAR_MAX) {
|
|
2106
|
+
width += windowScrollbarX;
|
|
2107
|
+
}
|
|
2108
|
+
return {
|
|
2109
|
+
width,
|
|
2110
|
+
height,
|
|
2111
|
+
x,
|
|
2112
|
+
y
|
|
2113
|
+
};
|
|
2114
|
+
}
|
|
2115
|
+
function getInnerBoundingClientRect(element, strategy) {
|
|
2116
|
+
const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
|
|
2117
|
+
const top = clientRect.top + element.clientTop;
|
|
2118
|
+
const left = clientRect.left + element.clientLeft;
|
|
2119
|
+
const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
|
|
2120
|
+
const width = element.clientWidth * scale.x;
|
|
2121
|
+
const height = element.clientHeight * scale.y;
|
|
2122
|
+
const x = left * scale.x;
|
|
2123
|
+
const y = top * scale.y;
|
|
2124
|
+
return {
|
|
2125
|
+
width,
|
|
2126
|
+
height,
|
|
2127
|
+
x,
|
|
2128
|
+
y
|
|
2129
|
+
};
|
|
2130
|
+
}
|
|
2131
|
+
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
|
2132
|
+
let rect;
|
|
2133
|
+
if (clippingAncestor === "viewport") {
|
|
2134
|
+
rect = getViewportRect(element, strategy);
|
|
2135
|
+
} else if (clippingAncestor === "document") {
|
|
2136
|
+
rect = getDocumentRect(getDocumentElement(element));
|
|
2137
|
+
} else if (isElement(clippingAncestor)) {
|
|
2138
|
+
rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
|
2139
|
+
} else {
|
|
2140
|
+
const visualOffsets = getVisualOffsets(element);
|
|
2141
|
+
rect = {
|
|
2142
|
+
x: clippingAncestor.x - visualOffsets.x,
|
|
2143
|
+
y: clippingAncestor.y - visualOffsets.y,
|
|
2144
|
+
width: clippingAncestor.width,
|
|
2145
|
+
height: clippingAncestor.height
|
|
2146
|
+
};
|
|
2147
|
+
}
|
|
2148
|
+
return rectToClientRect(rect);
|
|
2149
|
+
}
|
|
2150
|
+
function hasFixedPositionAncestor(element, stopNode) {
|
|
2151
|
+
const parentNode = getParentNode(element);
|
|
2152
|
+
if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
|
|
2153
|
+
return false;
|
|
2154
|
+
}
|
|
2155
|
+
return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
|
|
2156
|
+
}
|
|
2157
|
+
function getClippingElementAncestors(element, cache) {
|
|
2158
|
+
const cachedResult = cache.get(element);
|
|
2159
|
+
if (cachedResult) {
|
|
2160
|
+
return cachedResult;
|
|
2161
|
+
}
|
|
2162
|
+
let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
|
|
2163
|
+
let currentContainingBlockComputedStyle = null;
|
|
2164
|
+
const elementIsFixed = getComputedStyle2(element).position === "fixed";
|
|
2165
|
+
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
|
2166
|
+
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
2167
|
+
const computedStyle = getComputedStyle2(currentNode);
|
|
2168
|
+
const currentNodeIsContaining = isContainingBlock(currentNode);
|
|
2169
|
+
if (!currentNodeIsContaining && computedStyle.position === "fixed") {
|
|
2170
|
+
currentContainingBlockComputedStyle = null;
|
|
2171
|
+
}
|
|
2172
|
+
const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
|
|
2173
|
+
if (shouldDropCurrentNode) {
|
|
2174
|
+
result = result.filter((ancestor) => ancestor !== currentNode);
|
|
2175
|
+
} else {
|
|
2176
|
+
currentContainingBlockComputedStyle = computedStyle;
|
|
2177
|
+
}
|
|
2178
|
+
currentNode = getParentNode(currentNode);
|
|
2179
|
+
}
|
|
2180
|
+
cache.set(element, result);
|
|
2181
|
+
return result;
|
|
2182
|
+
}
|
|
2183
|
+
function getClippingRect(_ref) {
|
|
2184
|
+
let {
|
|
2185
|
+
element,
|
|
2186
|
+
boundary,
|
|
2187
|
+
rootBoundary,
|
|
2188
|
+
strategy
|
|
2189
|
+
} = _ref;
|
|
2190
|
+
const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
|
2191
|
+
const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
|
2192
|
+
const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
|
|
2193
|
+
let top = firstRect.top;
|
|
2194
|
+
let right = firstRect.right;
|
|
2195
|
+
let bottom = firstRect.bottom;
|
|
2196
|
+
let left = firstRect.left;
|
|
2197
|
+
for (let i = 1; i < clippingAncestors.length; i++) {
|
|
2198
|
+
const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i], strategy);
|
|
2199
|
+
top = max(rect.top, top);
|
|
2200
|
+
right = min(rect.right, right);
|
|
2201
|
+
bottom = min(rect.bottom, bottom);
|
|
2202
|
+
left = max(rect.left, left);
|
|
2203
|
+
}
|
|
2204
|
+
return {
|
|
2205
|
+
width: right - left,
|
|
2206
|
+
height: bottom - top,
|
|
2207
|
+
x: left,
|
|
2208
|
+
y: top
|
|
2209
|
+
};
|
|
2210
|
+
}
|
|
2211
|
+
function getDimensions(element) {
|
|
2212
|
+
const {
|
|
2213
|
+
width,
|
|
2214
|
+
height
|
|
2215
|
+
} = getCssDimensions(element);
|
|
2216
|
+
return {
|
|
2217
|
+
width,
|
|
2218
|
+
height
|
|
2219
|
+
};
|
|
2220
|
+
}
|
|
2221
|
+
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
2222
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
2223
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
2224
|
+
const isFixed = strategy === "fixed";
|
|
2225
|
+
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
|
|
2226
|
+
let scroll = {
|
|
2227
|
+
scrollLeft: 0,
|
|
2228
|
+
scrollTop: 0
|
|
2229
|
+
};
|
|
2230
|
+
const offsets = createCoords(0);
|
|
2231
|
+
function setLeftRTLScrollbarOffset() {
|
|
2232
|
+
offsets.x = getWindowScrollBarX(documentElement);
|
|
2233
|
+
}
|
|
2234
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
2235
|
+
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
|
|
2236
|
+
scroll = getNodeScroll(offsetParent);
|
|
2237
|
+
}
|
|
2238
|
+
if (isOffsetParentAnElement) {
|
|
2239
|
+
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
|
2240
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
2241
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
2242
|
+
} else if (documentElement) {
|
|
2243
|
+
setLeftRTLScrollbarOffset();
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
if (isFixed && !isOffsetParentAnElement && documentElement) {
|
|
2247
|
+
setLeftRTLScrollbarOffset();
|
|
2248
|
+
}
|
|
2249
|
+
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
|
2250
|
+
const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
|
|
2251
|
+
const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
|
|
2252
|
+
return {
|
|
2253
|
+
x,
|
|
2254
|
+
y,
|
|
2255
|
+
width: rect.width,
|
|
2256
|
+
height: rect.height
|
|
2257
|
+
};
|
|
2258
|
+
}
|
|
2259
|
+
function isStaticPositioned(element) {
|
|
2260
|
+
return getComputedStyle2(element).position === "static";
|
|
2261
|
+
}
|
|
2262
|
+
function getTrueOffsetParent(element, polyfill) {
|
|
2263
|
+
if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
|
|
2264
|
+
return null;
|
|
2265
|
+
}
|
|
2266
|
+
if (polyfill) {
|
|
2267
|
+
return polyfill(element);
|
|
2268
|
+
}
|
|
2269
|
+
let rawOffsetParent = element.offsetParent;
|
|
2270
|
+
if (getDocumentElement(element) === rawOffsetParent) {
|
|
2271
|
+
rawOffsetParent = rawOffsetParent.ownerDocument.body;
|
|
2272
|
+
}
|
|
2273
|
+
return rawOffsetParent;
|
|
2274
|
+
}
|
|
2275
|
+
function getOffsetParent(element, polyfill) {
|
|
2276
|
+
const win = getWindow(element);
|
|
2277
|
+
if (isTopLayer(element)) {
|
|
2278
|
+
return win;
|
|
2279
|
+
}
|
|
2280
|
+
if (!isHTMLElement(element)) {
|
|
2281
|
+
let svgOffsetParent = getParentNode(element);
|
|
2282
|
+
while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
|
|
2283
|
+
if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
|
|
2284
|
+
return svgOffsetParent;
|
|
2285
|
+
}
|
|
2286
|
+
svgOffsetParent = getParentNode(svgOffsetParent);
|
|
2287
|
+
}
|
|
2288
|
+
return win;
|
|
2289
|
+
}
|
|
2290
|
+
let offsetParent = getTrueOffsetParent(element, polyfill);
|
|
2291
|
+
while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
|
|
2292
|
+
offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
|
2293
|
+
}
|
|
2294
|
+
if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
|
|
2295
|
+
return win;
|
|
2296
|
+
}
|
|
2297
|
+
return offsetParent || getContainingBlock(element) || win;
|
|
2298
|
+
}
|
|
2299
|
+
var getElementRects = async function(data) {
|
|
2300
|
+
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
2301
|
+
const getDimensionsFn = this.getDimensions;
|
|
2302
|
+
const floatingDimensions = await getDimensionsFn(data.floating);
|
|
2303
|
+
return {
|
|
2304
|
+
reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
|
|
2305
|
+
floating: {
|
|
2306
|
+
x: 0,
|
|
2307
|
+
y: 0,
|
|
2308
|
+
width: floatingDimensions.width,
|
|
2309
|
+
height: floatingDimensions.height
|
|
2310
|
+
}
|
|
2311
|
+
};
|
|
2312
|
+
};
|
|
2313
|
+
function isRTL(element) {
|
|
2314
|
+
return getComputedStyle2(element).direction === "rtl";
|
|
2315
|
+
}
|
|
2316
|
+
var platform = {
|
|
2317
|
+
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
2318
|
+
getDocumentElement,
|
|
2319
|
+
getClippingRect,
|
|
2320
|
+
getOffsetParent,
|
|
2321
|
+
getElementRects,
|
|
2322
|
+
getClientRects,
|
|
2323
|
+
getDimensions,
|
|
2324
|
+
getScale,
|
|
2325
|
+
isElement,
|
|
2326
|
+
isRTL
|
|
2327
|
+
};
|
|
2328
|
+
function rectsAreEqual(a, b) {
|
|
2329
|
+
return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
|
|
2330
|
+
}
|
|
2331
|
+
function observeMove(element, onMove) {
|
|
2332
|
+
let io = null;
|
|
2333
|
+
let timeoutId;
|
|
2334
|
+
const root = getDocumentElement(element);
|
|
2335
|
+
function cleanup() {
|
|
2336
|
+
var _io;
|
|
2337
|
+
clearTimeout(timeoutId);
|
|
2338
|
+
(_io = io) == null || _io.disconnect();
|
|
2339
|
+
io = null;
|
|
2340
|
+
}
|
|
2341
|
+
function refresh(skip, threshold) {
|
|
2342
|
+
if (skip === void 0) {
|
|
2343
|
+
skip = false;
|
|
2344
|
+
}
|
|
2345
|
+
if (threshold === void 0) {
|
|
2346
|
+
threshold = 1;
|
|
2347
|
+
}
|
|
2348
|
+
cleanup();
|
|
2349
|
+
const elementRectForRootMargin = element.getBoundingClientRect();
|
|
2350
|
+
const {
|
|
2351
|
+
left,
|
|
2352
|
+
top,
|
|
2353
|
+
width,
|
|
2354
|
+
height
|
|
2355
|
+
} = elementRectForRootMargin;
|
|
2356
|
+
if (!skip) {
|
|
2357
|
+
onMove();
|
|
2358
|
+
}
|
|
2359
|
+
if (!width || !height) {
|
|
2360
|
+
return;
|
|
2361
|
+
}
|
|
2362
|
+
const insetTop = floor(top);
|
|
2363
|
+
const insetRight = floor(root.clientWidth - (left + width));
|
|
2364
|
+
const insetBottom = floor(root.clientHeight - (top + height));
|
|
2365
|
+
const insetLeft = floor(left);
|
|
2366
|
+
const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
|
|
2367
|
+
const options = {
|
|
2368
|
+
rootMargin,
|
|
2369
|
+
threshold: max(0, min(1, threshold)) || 1
|
|
2370
|
+
};
|
|
2371
|
+
let isFirstUpdate = true;
|
|
2372
|
+
function handleObserve(entries) {
|
|
2373
|
+
const ratio = entries[0].intersectionRatio;
|
|
2374
|
+
if (ratio !== threshold) {
|
|
2375
|
+
if (!isFirstUpdate) {
|
|
2376
|
+
return refresh();
|
|
2377
|
+
}
|
|
2378
|
+
if (!ratio) {
|
|
2379
|
+
timeoutId = setTimeout(() => {
|
|
2380
|
+
refresh(false, 1e-7);
|
|
2381
|
+
}, 1e3);
|
|
2382
|
+
} else {
|
|
2383
|
+
refresh(false, ratio);
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
|
|
2387
|
+
refresh();
|
|
2388
|
+
}
|
|
2389
|
+
isFirstUpdate = false;
|
|
2390
|
+
}
|
|
2391
|
+
try {
|
|
2392
|
+
io = new IntersectionObserver(handleObserve, {
|
|
2393
|
+
...options,
|
|
2394
|
+
// Handle <iframe>s
|
|
2395
|
+
root: root.ownerDocument
|
|
2396
|
+
});
|
|
2397
|
+
} catch (_e) {
|
|
2398
|
+
io = new IntersectionObserver(handleObserve, options);
|
|
2399
|
+
}
|
|
2400
|
+
io.observe(element);
|
|
2401
|
+
}
|
|
2402
|
+
refresh(true);
|
|
2403
|
+
return cleanup;
|
|
2404
|
+
}
|
|
2405
|
+
function autoUpdate(reference, floating, update, options) {
|
|
2406
|
+
if (options === void 0) {
|
|
2407
|
+
options = {};
|
|
2408
|
+
}
|
|
2409
|
+
const {
|
|
2410
|
+
ancestorScroll = true,
|
|
2411
|
+
ancestorResize = true,
|
|
2412
|
+
elementResize = typeof ResizeObserver === "function",
|
|
2413
|
+
layoutShift = typeof IntersectionObserver === "function",
|
|
2414
|
+
animationFrame = false
|
|
2415
|
+
} = options;
|
|
2416
|
+
const referenceEl = unwrapElement(reference);
|
|
2417
|
+
const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
|
|
2418
|
+
ancestors.forEach((ancestor) => {
|
|
2419
|
+
ancestorScroll && ancestor.addEventListener("scroll", update, {
|
|
2420
|
+
passive: true
|
|
2421
|
+
});
|
|
2422
|
+
ancestorResize && ancestor.addEventListener("resize", update);
|
|
2423
|
+
});
|
|
2424
|
+
const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
|
|
2425
|
+
let reobserveFrame = -1;
|
|
2426
|
+
let resizeObserver = null;
|
|
2427
|
+
if (elementResize) {
|
|
2428
|
+
resizeObserver = new ResizeObserver((_ref) => {
|
|
2429
|
+
let [firstEntry] = _ref;
|
|
2430
|
+
if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
|
|
2431
|
+
resizeObserver.unobserve(floating);
|
|
2432
|
+
cancelAnimationFrame(reobserveFrame);
|
|
2433
|
+
reobserveFrame = requestAnimationFrame(() => {
|
|
2434
|
+
var _resizeObserver;
|
|
2435
|
+
(_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
|
|
2436
|
+
});
|
|
2437
|
+
}
|
|
2438
|
+
update();
|
|
2439
|
+
});
|
|
2440
|
+
if (referenceEl && !animationFrame) {
|
|
2441
|
+
resizeObserver.observe(referenceEl);
|
|
2442
|
+
}
|
|
2443
|
+
if (floating) {
|
|
2444
|
+
resizeObserver.observe(floating);
|
|
2445
|
+
}
|
|
2446
|
+
}
|
|
2447
|
+
let frameId;
|
|
2448
|
+
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
|
|
2449
|
+
if (animationFrame) {
|
|
2450
|
+
frameLoop();
|
|
2451
|
+
}
|
|
2452
|
+
function frameLoop() {
|
|
2453
|
+
const nextRefRect = getBoundingClientRect(reference);
|
|
2454
|
+
if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
|
|
2455
|
+
update();
|
|
2456
|
+
}
|
|
2457
|
+
prevRefRect = nextRefRect;
|
|
2458
|
+
frameId = requestAnimationFrame(frameLoop);
|
|
2459
|
+
}
|
|
2460
|
+
update();
|
|
2461
|
+
return () => {
|
|
2462
|
+
var _resizeObserver2;
|
|
2463
|
+
ancestors.forEach((ancestor) => {
|
|
2464
|
+
ancestorScroll && ancestor.removeEventListener("scroll", update);
|
|
2465
|
+
ancestorResize && ancestor.removeEventListener("resize", update);
|
|
2466
|
+
});
|
|
2467
|
+
cleanupIo == null || cleanupIo();
|
|
2468
|
+
(_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
|
|
2469
|
+
resizeObserver = null;
|
|
2470
|
+
if (animationFrame) {
|
|
2471
|
+
cancelAnimationFrame(frameId);
|
|
2472
|
+
}
|
|
2473
|
+
};
|
|
2474
|
+
}
|
|
2475
|
+
var offset2 = offset;
|
|
2476
|
+
var shift2 = shift;
|
|
2477
|
+
var flip2 = flip;
|
|
2478
|
+
var computePosition2 = (reference, floating, options) => {
|
|
2479
|
+
const cache = /* @__PURE__ */ new Map();
|
|
2480
|
+
const mergedOptions = {
|
|
2481
|
+
platform,
|
|
2482
|
+
...options
|
|
2483
|
+
};
|
|
2484
|
+
const platformWithCache = {
|
|
2485
|
+
...mergedOptions.platform,
|
|
2486
|
+
_c: cache
|
|
2487
|
+
};
|
|
2488
|
+
return computePosition(reference, floating, {
|
|
2489
|
+
...mergedOptions,
|
|
2490
|
+
platform: platformWithCache
|
|
2491
|
+
});
|
|
2492
|
+
};
|
|
2493
|
+
|
|
2494
|
+
// src/components/shared/floating.ts
|
|
2495
|
+
import { css as css3 } from "lit";
|
|
2496
|
+
async function openFloating(reference, floating, opts) {
|
|
2497
|
+
const { placement = "bottom-start", offsetPx = 4, matchWidth = false } = opts ?? {};
|
|
2498
|
+
floating.style.display = "block";
|
|
2499
|
+
floating.style.visibility = "hidden";
|
|
2500
|
+
floating.showPopover?.();
|
|
2501
|
+
const reposition = async () => {
|
|
2502
|
+
if (matchWidth) {
|
|
2503
|
+
floating.style.width = `${reference.getBoundingClientRect().width}px`;
|
|
2504
|
+
}
|
|
2505
|
+
const { x, y } = await computePosition2(reference, floating, {
|
|
2506
|
+
strategy: "fixed",
|
|
2507
|
+
placement,
|
|
2508
|
+
middleware: [offset2(offsetPx), flip2(), shift2({ padding: 8 })]
|
|
2509
|
+
});
|
|
2510
|
+
floating.style.left = `${x}px`;
|
|
2511
|
+
floating.style.top = `${y}px`;
|
|
2512
|
+
};
|
|
2513
|
+
await reposition();
|
|
2514
|
+
floating.style.visibility = "";
|
|
2515
|
+
const cleanup = autoUpdate(reference, floating, reposition);
|
|
2516
|
+
return cleanup;
|
|
2517
|
+
}
|
|
2518
|
+
function closeFloating(floating, cleanup) {
|
|
2519
|
+
cleanup?.();
|
|
2520
|
+
floating.hidePopover?.();
|
|
2521
|
+
floating.style.display = "";
|
|
2522
|
+
}
|
|
2523
|
+
var floatingPanelReset = css3`
|
|
2524
|
+
[popover] {
|
|
2525
|
+
border: 0;
|
|
2526
|
+
inset: unset;
|
|
2527
|
+
margin: 0;
|
|
2528
|
+
overflow: visible;
|
|
2529
|
+
padding: 0;
|
|
2530
|
+
position: fixed;
|
|
2531
|
+
}
|
|
2532
|
+
`;
|
|
2533
|
+
|
|
2534
|
+
// src/components/date-input/date-input.styles.ts
|
|
2535
|
+
var dateInputStyles = [
|
|
2536
|
+
floatingPanelReset,
|
|
2537
|
+
css4`
|
|
2538
|
+
:host {
|
|
2539
|
+
display: block;
|
|
2540
|
+
font-family: 'Hanken Grotesk', sans-serif;
|
|
2541
|
+
}
|
|
2542
|
+
|
|
2543
|
+
.wrapper {
|
|
2544
|
+
display: flex;
|
|
2545
|
+
flex-direction: column;
|
|
2546
|
+
gap: var(--lt-spacing-1);
|
|
2547
|
+
}
|
|
2548
|
+
|
|
2549
|
+
label {
|
|
2550
|
+
color: var(--lt-text-default);
|
|
2551
|
+
cursor: default;
|
|
2552
|
+
}
|
|
2553
|
+
|
|
2554
|
+
.required-indicator {
|
|
2555
|
+
color: var(--lt-color-error-500);
|
|
2556
|
+
margin-left: 2px;
|
|
2557
|
+
}
|
|
2558
|
+
|
|
2559
|
+
/* ── Field ── */
|
|
2560
|
+
|
|
2561
|
+
.field {
|
|
2562
|
+
position: relative;
|
|
2563
|
+
}
|
|
2564
|
+
|
|
2565
|
+
.field-btn {
|
|
2566
|
+
align-items: center;
|
|
2567
|
+
background: var(--lt-bg-surface);
|
|
2568
|
+
border-radius: var(--lt-border-radius);
|
|
2569
|
+
border: 1px solid var(--lt-border-default);
|
|
2570
|
+
color: var(--lt-text-default);
|
|
2571
|
+
cursor: pointer;
|
|
2572
|
+
display: flex;
|
|
2573
|
+
font-family: inherit;
|
|
2574
|
+
justify-content: space-between;
|
|
2575
|
+
outline: none;
|
|
2576
|
+
text-align: left;
|
|
2577
|
+
transition:
|
|
2578
|
+
border-color 150ms ease,
|
|
2579
|
+
box-shadow 150ms ease;
|
|
2580
|
+
width: 100%;
|
|
2581
|
+
}
|
|
2582
|
+
|
|
2583
|
+
.field-btn:focus-visible {
|
|
2584
|
+
border-color: var(--lt-border-primary);
|
|
2585
|
+
box-shadow: 0 0 0 3px var(--lt-bg-primary-subtle);
|
|
2586
|
+
}
|
|
2587
|
+
|
|
2588
|
+
.field-btn:disabled {
|
|
2589
|
+
background: var(--lt-bg-neutral-subtle);
|
|
2590
|
+
color: var(--lt-text-subtle);
|
|
2591
|
+
cursor: not-allowed;
|
|
2592
|
+
}
|
|
2593
|
+
|
|
2594
|
+
.display-value {
|
|
2595
|
+
flex: 1;
|
|
2596
|
+
overflow: hidden;
|
|
2597
|
+
text-overflow: ellipsis;
|
|
2598
|
+
white-space: nowrap;
|
|
2599
|
+
}
|
|
2600
|
+
|
|
2601
|
+
.display-value--placeholder {
|
|
2602
|
+
color: var(--lt-text-muted);
|
|
2603
|
+
}
|
|
2604
|
+
|
|
2605
|
+
.calendar-icon {
|
|
2606
|
+
color: var(--lt-text-subtle);
|
|
2607
|
+
flex-shrink: 0;
|
|
2608
|
+
line-height: 0;
|
|
2609
|
+
margin-left: var(--lt-spacing-2);
|
|
2610
|
+
}
|
|
2611
|
+
|
|
2612
|
+
/* ── Sizes ── */
|
|
2613
|
+
|
|
2614
|
+
:host([size='sm']) .field-btn {
|
|
2615
|
+
font-size: 0.8125rem;
|
|
2616
|
+
height: 32px;
|
|
2617
|
+
padding: 0 var(--lt-spacing-2);
|
|
2618
|
+
}
|
|
2619
|
+
|
|
2620
|
+
:host([size='md']) .field-btn,
|
|
2621
|
+
:host(:not([size])) .field-btn {
|
|
2622
|
+
font-size: 0.9375rem;
|
|
2623
|
+
height: 40px;
|
|
2624
|
+
padding: 0 var(--lt-spacing-3);
|
|
2625
|
+
}
|
|
2626
|
+
|
|
2627
|
+
:host([size='lg']) .field-btn {
|
|
2628
|
+
font-size: 1rem;
|
|
2629
|
+
height: 48px;
|
|
2630
|
+
padding: 0 var(--lt-spacing-4);
|
|
2631
|
+
}
|
|
2632
|
+
|
|
2633
|
+
/* ── Variants ── */
|
|
2634
|
+
|
|
2635
|
+
:host([variant='success']) .field-btn {
|
|
2636
|
+
border-color: var(--lt-color-success-500);
|
|
2637
|
+
}
|
|
2638
|
+
|
|
2639
|
+
:host([variant='success']) .field-btn:focus-visible {
|
|
2640
|
+
box-shadow: 0 0 0 3px var(--lt-bg-success-subtle);
|
|
2641
|
+
}
|
|
2642
|
+
|
|
2643
|
+
:host([variant='warning']) .field-btn {
|
|
2644
|
+
border-color: var(--lt-color-warning-500);
|
|
2645
|
+
}
|
|
2646
|
+
|
|
2647
|
+
:host([variant='warning']) .field-btn:focus-visible {
|
|
2648
|
+
box-shadow: 0 0 0 3px var(--lt-bg-warning-subtle);
|
|
2649
|
+
}
|
|
2650
|
+
|
|
2651
|
+
:host([variant='error']) .field-btn {
|
|
2652
|
+
border-color: var(--lt-color-error-500);
|
|
2653
|
+
}
|
|
2654
|
+
|
|
2655
|
+
:host([variant='error']) .field-btn:focus-visible {
|
|
2656
|
+
box-shadow: 0 0 0 3px var(--lt-bg-error-subtle);
|
|
2657
|
+
}
|
|
2658
|
+
|
|
2659
|
+
/* ── Dropdown ── */
|
|
2660
|
+
|
|
2661
|
+
.dropdown {
|
|
2662
|
+
display: none;
|
|
2663
|
+
filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.08));
|
|
2664
|
+
z-index: 9999;
|
|
2665
|
+
}
|
|
2666
|
+
|
|
2667
|
+
/* ── Helper text ── */
|
|
2668
|
+
|
|
2669
|
+
.helper-text {
|
|
2670
|
+
color: var(--lt-text-subtle);
|
|
2671
|
+
font-size: 0.8125rem;
|
|
2672
|
+
}
|
|
2673
|
+
|
|
2674
|
+
:host([variant='error']) .helper-text {
|
|
2675
|
+
color: var(--lt-color-error-600);
|
|
2676
|
+
}
|
|
2677
|
+
|
|
2678
|
+
:host([variant='success']) .helper-text {
|
|
2679
|
+
color: var(--lt-color-success-600);
|
|
2680
|
+
}
|
|
2681
|
+
|
|
2682
|
+
:host([variant='warning']) .helper-text {
|
|
2683
|
+
color: var(--lt-color-warning-700);
|
|
2684
|
+
}
|
|
2685
|
+
`
|
|
2686
|
+
];
|
|
2687
|
+
|
|
2688
|
+
// src/components/date-input/date-input.ts
|
|
2689
|
+
var DateInput = class extends ThemeableElement {
|
|
2690
|
+
constructor() {
|
|
2691
|
+
super(...arguments);
|
|
2692
|
+
this.value = "";
|
|
2693
|
+
this.min = "";
|
|
2694
|
+
this.max = "";
|
|
2695
|
+
this.locale = "en-US";
|
|
2696
|
+
this.format = "medium";
|
|
2697
|
+
this.weekStart = "0";
|
|
2698
|
+
this.label = "";
|
|
2699
|
+
this.placeholder = "Select a date";
|
|
2700
|
+
this.helperText = "";
|
|
2701
|
+
this.variant = "default";
|
|
2702
|
+
this.size = "md";
|
|
2703
|
+
this.disabled = false;
|
|
2704
|
+
this.required = false;
|
|
2705
|
+
this.name = "";
|
|
2706
|
+
/** Individual dates to disable in the calendar, as Date objects. */
|
|
2707
|
+
this.disabledDates = [];
|
|
2708
|
+
this._open = false;
|
|
2709
|
+
this._cleanupClickOutside = null;
|
|
2710
|
+
this._floatingCleanup = null;
|
|
2711
|
+
}
|
|
2712
|
+
get _displayValue() {
|
|
2713
|
+
if (!this.value) return "";
|
|
2714
|
+
const [y, m, d] = this.value.split("-").map(Number);
|
|
2715
|
+
const date = new Date(y, m - 1, d);
|
|
2716
|
+
return new Intl.DateTimeFormat(this.locale, { dateStyle: this.format }).format(date);
|
|
2717
|
+
}
|
|
2718
|
+
async _openDropdown() {
|
|
2719
|
+
if (this.disabled || this._open) return;
|
|
2720
|
+
this._open = true;
|
|
2721
|
+
await this.updateComplete;
|
|
2722
|
+
const btn = this.shadowRoot?.querySelector("#field-btn");
|
|
2723
|
+
const dropdown = this.shadowRoot?.querySelector(".dropdown");
|
|
2724
|
+
if (btn && dropdown) {
|
|
2725
|
+
this._floatingCleanup = await openFloating(btn, dropdown);
|
|
2726
|
+
}
|
|
2727
|
+
this._cleanupClickOutside = createClickOutsideHandler(this, () => this._closeDropdown());
|
|
2728
|
+
}
|
|
2729
|
+
_closeDropdown() {
|
|
2730
|
+
const dropdown = this.shadowRoot?.querySelector(".dropdown");
|
|
2731
|
+
if (dropdown) closeFloating(dropdown, this._floatingCleanup);
|
|
2732
|
+
this._floatingCleanup = null;
|
|
2733
|
+
this._open = false;
|
|
2734
|
+
this._cleanupClickOutside?.();
|
|
2735
|
+
this._cleanupClickOutside = null;
|
|
2736
|
+
}
|
|
2737
|
+
disconnectedCallback() {
|
|
2738
|
+
super.disconnectedCallback();
|
|
2739
|
+
this._floatingCleanup?.();
|
|
2740
|
+
this._floatingCleanup = null;
|
|
2741
|
+
this._cleanupClickOutside?.();
|
|
2742
|
+
this._cleanupClickOutside = null;
|
|
2743
|
+
}
|
|
2744
|
+
_handleCalendarChange(e) {
|
|
2745
|
+
e.stopPropagation();
|
|
2746
|
+
this.value = e.detail.value;
|
|
2747
|
+
dispatch(this, "change", { value: this.value });
|
|
2748
|
+
this._closeDropdown();
|
|
2749
|
+
this.shadowRoot?.querySelector(".field-btn")?.focus();
|
|
2750
|
+
}
|
|
2751
|
+
_handleDropdownKeyDown(e) {
|
|
2752
|
+
if (e.key === "Escape") {
|
|
2753
|
+
e.stopPropagation();
|
|
2754
|
+
this._closeDropdown();
|
|
2755
|
+
this.shadowRoot?.querySelector(".field-btn")?.focus();
|
|
2756
|
+
}
|
|
2757
|
+
}
|
|
2758
|
+
render() {
|
|
2759
|
+
const displayText = this._displayValue || this.placeholder;
|
|
2760
|
+
const isPlaceholder = !this._displayValue;
|
|
2761
|
+
return html3`
|
|
2762
|
+
<div class="wrapper">
|
|
2763
|
+
${this.label ? html3`<label for="field-btn">
|
|
2764
|
+
<lt-text variant="label" as="span">${this.label}</lt-text>
|
|
2765
|
+
${this.required ? html3`<span class="required-indicator" aria-hidden="true">*</span>` : nothing}
|
|
2766
|
+
</label>` : nothing}
|
|
2767
|
+
|
|
2768
|
+
<div class="field">
|
|
2769
|
+
<button
|
|
2770
|
+
id="field-btn"
|
|
2771
|
+
type="button"
|
|
2772
|
+
class="field-btn"
|
|
2773
|
+
aria-haspopup="dialog"
|
|
2774
|
+
aria-expanded=${this._open ? "true" : "false"}
|
|
2775
|
+
?disabled=${this.disabled}
|
|
2776
|
+
?required=${this.required}
|
|
2777
|
+
@click=${this._openDropdown}
|
|
2778
|
+
>
|
|
2779
|
+
<span class=${isPlaceholder ? "display-value display-value--placeholder" : "display-value"}>
|
|
2780
|
+
${displayText}
|
|
2781
|
+
</span>
|
|
2782
|
+
<span class="calendar-icon" aria-hidden="true">
|
|
2783
|
+
<lt-icon name="calendar" size="sm"></lt-icon>
|
|
2784
|
+
</span>
|
|
2785
|
+
</button>
|
|
2786
|
+
|
|
2787
|
+
<div
|
|
2788
|
+
class="dropdown"
|
|
2789
|
+
popover="manual"
|
|
2790
|
+
role="dialog"
|
|
2791
|
+
aria-label="Date picker"
|
|
2792
|
+
@keydown=${this._handleDropdownKeyDown}
|
|
2793
|
+
>
|
|
2794
|
+
${this._open ? html3`<lt-calendar
|
|
2795
|
+
value=${this.value}
|
|
2796
|
+
min=${this.min}
|
|
2797
|
+
max=${this.max}
|
|
2798
|
+
locale=${this.locale}
|
|
2799
|
+
week-start=${this.weekStart}
|
|
2800
|
+
.disabledDates=${this.disabledDates}
|
|
2801
|
+
@change=${this._handleCalendarChange}
|
|
2802
|
+
></lt-calendar>` : nothing}
|
|
2803
|
+
</div>
|
|
2804
|
+
</div>
|
|
2805
|
+
|
|
2806
|
+
${this.name ? html3`<input type="hidden" name=${this.name} .value=${this.value} />` : nothing}
|
|
2807
|
+
${this.helperText ? html3`<span class="helper-text">${this.helperText}</span>` : nothing}
|
|
2808
|
+
</div>
|
|
2809
|
+
`;
|
|
2810
|
+
}
|
|
2811
|
+
};
|
|
2812
|
+
DateInput.styles = dateInputStyles;
|
|
2813
|
+
__decorateClass([
|
|
2814
|
+
property4({ reflect: true })
|
|
2815
|
+
], DateInput.prototype, "value", 2);
|
|
2816
|
+
__decorateClass([
|
|
2817
|
+
property4({ reflect: true })
|
|
2818
|
+
], DateInput.prototype, "min", 2);
|
|
2819
|
+
__decorateClass([
|
|
2820
|
+
property4({ reflect: true })
|
|
2821
|
+
], DateInput.prototype, "max", 2);
|
|
2822
|
+
__decorateClass([
|
|
2823
|
+
property4({ reflect: true })
|
|
2824
|
+
], DateInput.prototype, "locale", 2);
|
|
2825
|
+
__decorateClass([
|
|
2826
|
+
property4({ reflect: true })
|
|
2827
|
+
], DateInput.prototype, "format", 2);
|
|
2828
|
+
__decorateClass([
|
|
2829
|
+
property4({ attribute: "week-start", reflect: true })
|
|
2830
|
+
], DateInput.prototype, "weekStart", 2);
|
|
2831
|
+
__decorateClass([
|
|
2832
|
+
property4()
|
|
2833
|
+
], DateInput.prototype, "label", 2);
|
|
2834
|
+
__decorateClass([
|
|
2835
|
+
property4()
|
|
2836
|
+
], DateInput.prototype, "placeholder", 2);
|
|
2837
|
+
__decorateClass([
|
|
2838
|
+
property4({ attribute: "helper-text" })
|
|
2839
|
+
], DateInput.prototype, "helperText", 2);
|
|
2840
|
+
__decorateClass([
|
|
2841
|
+
property4({ reflect: true })
|
|
2842
|
+
], DateInput.prototype, "variant", 2);
|
|
2843
|
+
__decorateClass([
|
|
2844
|
+
property4({ reflect: true })
|
|
2845
|
+
], DateInput.prototype, "size", 2);
|
|
2846
|
+
__decorateClass([
|
|
2847
|
+
property4({ type: Boolean, reflect: true })
|
|
2848
|
+
], DateInput.prototype, "disabled", 2);
|
|
2849
|
+
__decorateClass([
|
|
2850
|
+
property4({ type: Boolean, reflect: true })
|
|
2851
|
+
], DateInput.prototype, "required", 2);
|
|
2852
|
+
__decorateClass([
|
|
2853
|
+
property4()
|
|
2854
|
+
], DateInput.prototype, "name", 2);
|
|
2855
|
+
__decorateClass([
|
|
2856
|
+
state2()
|
|
2857
|
+
], DateInput.prototype, "_open", 2);
|
|
2858
|
+
DateInput = __decorateClass([
|
|
2859
|
+
customElement3("lt-date-input")
|
|
2860
|
+
], DateInput);
|
|
2861
|
+
export {
|
|
2862
|
+
DateInput
|
|
2863
|
+
};
|