@joralvmel/cosmos-elements 0.3.0 → 0.4.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/README.md +9 -4
- package/dist/components/badge/cosm-badge.d.ts +64 -0
- package/dist/components/badge/cosm-badge.d.ts.map +1 -0
- package/dist/components/badge/cosm-badge.js +162 -0
- package/dist/components/badge/cosm-badge.js.map +1 -0
- package/dist/components/button/cosm-button.d.ts.map +1 -1
- package/dist/components/button/cosm-button.js +2 -0
- package/dist/components/button/cosm-button.js.map +1 -1
- package/dist/components/calendar/cosm-calendar.d.ts +77 -0
- package/dist/components/calendar/cosm-calendar.d.ts.map +1 -0
- package/dist/components/calendar/cosm-calendar.js +696 -0
- package/dist/components/calendar/cosm-calendar.js.map +1 -0
- package/dist/components/checkbox/cosm-checkbox.d.ts +122 -0
- package/dist/components/checkbox/cosm-checkbox.d.ts.map +1 -0
- package/dist/components/checkbox/cosm-checkbox.js +433 -0
- package/dist/components/checkbox/cosm-checkbox.js.map +1 -0
- package/dist/components/dialog/cosm-dialog.d.ts +103 -0
- package/dist/components/dialog/cosm-dialog.d.ts.map +1 -0
- package/dist/components/dialog/cosm-dialog.js +497 -0
- package/dist/components/dialog/cosm-dialog.js.map +1 -0
- package/dist/components/icon/cosm-icon.d.ts +7 -15
- package/dist/components/icon/cosm-icon.d.ts.map +1 -1
- package/dist/components/icon/cosm-icon.js +29 -30
- package/dist/components/icon/cosm-icon.js.map +1 -1
- package/dist/components/icon-button/cosm-icon-button.d.ts.map +1 -1
- package/dist/components/icon-button/cosm-icon-button.js +6 -0
- package/dist/components/icon-button/cosm-icon-button.js.map +1 -1
- package/dist/components/listbox/cosm-listbox.d.ts +1 -5
- package/dist/components/listbox/cosm-listbox.d.ts.map +1 -1
- package/dist/components/listbox/cosm-listbox.js +3 -18
- package/dist/components/listbox/cosm-listbox.js.map +1 -1
- package/dist/components/pagination/cosm-pagination.d.ts +118 -0
- package/dist/components/pagination/cosm-pagination.d.ts.map +1 -0
- package/dist/components/pagination/cosm-pagination.js +315 -0
- package/dist/components/pagination/cosm-pagination.js.map +1 -0
- package/dist/components/popover/cosm-popover.d.ts +0 -22
- package/dist/components/popover/cosm-popover.d.ts.map +1 -1
- package/dist/components/popover/cosm-popover.js +21 -54
- package/dist/components/popover/cosm-popover.js.map +1 -1
- package/dist/components/radio-group/cosm-radio-group.d.ts +111 -0
- package/dist/components/radio-group/cosm-radio-group.d.ts.map +1 -0
- package/dist/components/radio-group/cosm-radio-group.js +478 -0
- package/dist/components/radio-group/cosm-radio-group.js.map +1 -0
- package/dist/components/select/cosm-select.d.ts +126 -0
- package/dist/components/select/cosm-select.d.ts.map +1 -0
- package/dist/components/select/cosm-select.js +682 -0
- package/dist/components/select/cosm-select.js.map +1 -0
- package/dist/components/switch/cosm-switch.d.ts +103 -0
- package/dist/components/switch/cosm-switch.d.ts.map +1 -0
- package/dist/components/switch/cosm-switch.js +359 -0
- package/dist/components/switch/cosm-switch.js.map +1 -0
- package/dist/components/text-field/cosm-text-field.d.ts +8 -18
- package/dist/components/text-field/cosm-text-field.d.ts.map +1 -1
- package/dist/components/text-field/cosm-text-field.js +30 -67
- package/dist/components/text-field/cosm-text-field.js.map +1 -1
- package/dist/components/textarea/cosm-textarea.d.ts +131 -0
- package/dist/components/textarea/cosm-textarea.d.ts.map +1 -0
- package/dist/components/textarea/cosm-textarea.js +445 -0
- package/dist/components/textarea/cosm-textarea.js.map +1 -0
- package/dist/custom-elements.json +5915 -1330
- package/dist/index.d.ts +10 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/current-page.d.ts +7 -0
- package/dist/internal/current-page.d.ts.map +1 -0
- package/dist/internal/current-page.js +18 -0
- package/dist/internal/current-page.js.map +1 -0
- package/llms.md +306 -20
- package/package.json +39 -3
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { getPaginationView, paginationContract, } from '@joralvmel/cosmos-core';
|
|
2
|
+
import { chevronLeft } from '@joralvmel/cosmos-icons/chevron-left';
|
|
3
|
+
import { chevronRight } from '@joralvmel/cosmos-icons/chevron-right';
|
|
4
|
+
import { chevronsLeft } from '@joralvmel/cosmos-icons/chevrons-left';
|
|
5
|
+
import { chevronsRight } from '@joralvmel/cosmos-icons/chevrons-right';
|
|
6
|
+
import { css, html, LitElement, nothing } from 'lit';
|
|
7
|
+
import { keyed } from 'lit/directives/keyed.js';
|
|
8
|
+
import { repeat } from 'lit/directives/repeat.js';
|
|
9
|
+
import { CosmElement } from '../../internal/cosm-element.js';
|
|
10
|
+
import { setCurrentPage } from '../../internal/current-page.js';
|
|
11
|
+
import { define } from '../../internal/define.js';
|
|
12
|
+
import { boxSizing } from '../../internal/styles.js';
|
|
13
|
+
import '../button/cosm-button.js';
|
|
14
|
+
import '../icon-button/cosm-icon-button.js';
|
|
15
|
+
import '../icon/cosm-icon.js';
|
|
16
|
+
const styles = css `
|
|
17
|
+
:host {
|
|
18
|
+
display: inline-block;
|
|
19
|
+
max-width: 100%;
|
|
20
|
+
color: var(--cosm-fg, oklch(0.24 0.01 268));
|
|
21
|
+
font-family: var(--cosm-font-sans, system-ui, sans-serif);
|
|
22
|
+
font-size: var(--cosm-text-sm, 0.875rem);
|
|
23
|
+
--_control-height: var(--cosm-control-md, 2.5rem);
|
|
24
|
+
--_page-font-size: var(--cosm-text-sm, 0.875rem);
|
|
25
|
+
}
|
|
26
|
+
:host([size='sm']) { --_control-height: var(--cosm-control-sm, 2rem); }
|
|
27
|
+
:host([size='lg']) {
|
|
28
|
+
--_control-height: var(--cosm-control-lg, 3rem);
|
|
29
|
+
--_page-font-size: var(--cosm-text-md, 1rem);
|
|
30
|
+
}
|
|
31
|
+
nav {
|
|
32
|
+
display: flex;
|
|
33
|
+
align-items: center;
|
|
34
|
+
flex-wrap: wrap;
|
|
35
|
+
gap: var(--cosm-pagination-gap, var(--cosm-space-xs, 0.25rem));
|
|
36
|
+
}
|
|
37
|
+
cosm-button, cosm-icon-button { flex: 0 0 auto; }
|
|
38
|
+
cosm-button::part(base), cosm-icon-button::part(base) {
|
|
39
|
+
min-height: var(--cosm-pagination-min-height, var(--_control-height));
|
|
40
|
+
min-width: var(--cosm-pagination-min-height, var(--_control-height));
|
|
41
|
+
border-radius: var(--cosm-pagination-radius, var(--cosm-radius-md, 0.5rem));
|
|
42
|
+
}
|
|
43
|
+
cosm-button::part(base) {
|
|
44
|
+
padding-inline: var(--cosm-space-sm, 0.5rem);
|
|
45
|
+
transition:
|
|
46
|
+
background-color var(--cosm-duration-normal, 200ms) var(--cosm-easing-standard, ease),
|
|
47
|
+
border-color var(--cosm-duration-normal, 200ms) var(--cosm-easing-standard, ease),
|
|
48
|
+
color var(--cosm-duration-normal, 200ms) var(--cosm-easing-standard, ease);
|
|
49
|
+
}
|
|
50
|
+
cosm-button[data-current]::part(base) {
|
|
51
|
+
/* Resolve the composed Button's state colors when no pagination hook is supplied. */
|
|
52
|
+
background: var(--cosm-pagination-current-background, var(--_bg));
|
|
53
|
+
color: var(--cosm-pagination-current-color, var(--_fg));
|
|
54
|
+
border-color: var(--cosm-pagination-current-border, var(--_border));
|
|
55
|
+
}
|
|
56
|
+
[part='summary'] { padding-inline: var(--cosm-space-sm, 0.5rem); }
|
|
57
|
+
[part='ellipsis'] {
|
|
58
|
+
display: inline-flex;
|
|
59
|
+
align-items: center;
|
|
60
|
+
justify-content: center;
|
|
61
|
+
min-height: var(--cosm-pagination-min-height, var(--_control-height));
|
|
62
|
+
min-width: var(--cosm-pagination-min-height, var(--_control-height));
|
|
63
|
+
padding-inline: var(--cosm-space-sm, 0.5rem);
|
|
64
|
+
border: 1px solid transparent;
|
|
65
|
+
font-size: var(--_page-font-size);
|
|
66
|
+
font-weight: var(--cosm-button-font-weight, var(--cosm-weight-semibold, 600));
|
|
67
|
+
}
|
|
68
|
+
.cell { display: inline-grid; place-items: center; font-variant-numeric: tabular-nums; }
|
|
69
|
+
.cell::before {
|
|
70
|
+
content: attr(data-total);
|
|
71
|
+
visibility: hidden;
|
|
72
|
+
grid-area: 1 / 1;
|
|
73
|
+
}
|
|
74
|
+
.cell > span { grid-area: 1 / 1; }
|
|
75
|
+
.entering {
|
|
76
|
+
animation: page-enter var(--cosm-duration-normal, 200ms) var(--cosm-easing-standard, ease);
|
|
77
|
+
}
|
|
78
|
+
.leaving {
|
|
79
|
+
pointer-events: none;
|
|
80
|
+
animation: page-exit var(--cosm-duration-normal, 200ms) var(--cosm-easing-standard, ease) forwards;
|
|
81
|
+
}
|
|
82
|
+
@keyframes page-enter {
|
|
83
|
+
from { opacity: 0; }
|
|
84
|
+
to { opacity: 1; }
|
|
85
|
+
}
|
|
86
|
+
@keyframes page-exit {
|
|
87
|
+
from { opacity: 1; visibility: visible; }
|
|
88
|
+
to { opacity: 0; visibility: hidden; }
|
|
89
|
+
}
|
|
90
|
+
@media (prefers-reduced-motion: reduce) {
|
|
91
|
+
cosm-button::part(base) { transition: none; }
|
|
92
|
+
.cell > span { animation: none; }
|
|
93
|
+
.leaving { display: none; }
|
|
94
|
+
}
|
|
95
|
+
`;
|
|
96
|
+
/**
|
|
97
|
+
* Button-based, localized pagination with controlled or autonomous state.
|
|
98
|
+
* @tag cosm-pagination
|
|
99
|
+
* @csspart base - Navigation landmark.
|
|
100
|
+
* @csspart control - Navigation control.
|
|
101
|
+
* @csspart page - Numbered page control.
|
|
102
|
+
* @csspart current - Current page control.
|
|
103
|
+
* @csspart ellipsis - Decorative omitted range.
|
|
104
|
+
* @csspart summary - Compact summary.
|
|
105
|
+
* @fires {CustomEvent<PaginationChangeDetail>} cosm-change - Proposed page.
|
|
106
|
+
* @cssprop --cosm-pagination-gap - Control gap.
|
|
107
|
+
* @cssprop --cosm-pagination-min-height - Minimum control dimensions.
|
|
108
|
+
* @cssprop --cosm-pagination-radius - Control corner radius.
|
|
109
|
+
* @cssprop --cosm-pagination-current-background - Current background.
|
|
110
|
+
* @cssprop --cosm-pagination-current-color - Current foreground.
|
|
111
|
+
* @cssprop --cosm-pagination-current-border - Current border.
|
|
112
|
+
*/
|
|
113
|
+
export class CosmPagination extends CosmElement {
|
|
114
|
+
static shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFocus: true };
|
|
115
|
+
static properties = {
|
|
116
|
+
totalPages: { type: Number, attribute: 'total-pages' },
|
|
117
|
+
page: { type: Number, noAccessor: true },
|
|
118
|
+
defaultPage: { type: Number, attribute: 'default-page' },
|
|
119
|
+
label: {},
|
|
120
|
+
previousLabel: { attribute: 'previous-label' },
|
|
121
|
+
nextLabel: { attribute: 'next-label' },
|
|
122
|
+
firstLabel: { attribute: 'first-label' },
|
|
123
|
+
lastLabel: { attribute: 'last-label' },
|
|
124
|
+
pageLabel: { attribute: 'page-label' },
|
|
125
|
+
summaryLabel: { attribute: 'summary-label' },
|
|
126
|
+
locale: {},
|
|
127
|
+
direction: {},
|
|
128
|
+
presentation: { reflect: true },
|
|
129
|
+
variant: { reflect: true },
|
|
130
|
+
size: { reflect: true },
|
|
131
|
+
showFirstLast: { type: Boolean, attribute: 'show-first-last' },
|
|
132
|
+
disabled: { type: Boolean, reflect: true },
|
|
133
|
+
};
|
|
134
|
+
static styles = [boxSizing, styles];
|
|
135
|
+
pageControlled = false;
|
|
136
|
+
#requested;
|
|
137
|
+
#owned = 1;
|
|
138
|
+
#effective = 1;
|
|
139
|
+
#initialized = false;
|
|
140
|
+
#view;
|
|
141
|
+
#previousView;
|
|
142
|
+
#restoreFocus = false;
|
|
143
|
+
#focusedPage = null;
|
|
144
|
+
#pointerActivation = false;
|
|
145
|
+
constructor() {
|
|
146
|
+
super();
|
|
147
|
+
const defaults = paginationContract.props;
|
|
148
|
+
this.totalPages = Number.NaN;
|
|
149
|
+
this.defaultPage = defaults.defaultPage.default;
|
|
150
|
+
this.label = '';
|
|
151
|
+
this.previousLabel = defaults.previousLabel.default;
|
|
152
|
+
this.nextLabel = defaults.nextLabel.default;
|
|
153
|
+
this.firstLabel = defaults.firstLabel.default;
|
|
154
|
+
this.lastLabel = defaults.lastLabel.default;
|
|
155
|
+
this.pageLabel = defaults.pageLabel.default;
|
|
156
|
+
this.summaryLabel = defaults.summaryLabel.default;
|
|
157
|
+
this.locale = undefined;
|
|
158
|
+
this.direction = defaults.direction.default;
|
|
159
|
+
this.presentation = defaults.presentation.default;
|
|
160
|
+
this.variant = defaults.variant.default;
|
|
161
|
+
this.size = defaults.size.default;
|
|
162
|
+
this.showFirstLast = defaults.showFirstLast.default;
|
|
163
|
+
this.disabled = defaults.disabled.default;
|
|
164
|
+
}
|
|
165
|
+
willUpdate() {
|
|
166
|
+
const focused = this.shadowRoot?.activeElement;
|
|
167
|
+
if (focused)
|
|
168
|
+
this.#restoreFocus = true;
|
|
169
|
+
this.#focusedPage = focused?.getAttribute('data-page') ?? null;
|
|
170
|
+
if (!this.#initialized) {
|
|
171
|
+
this.#owned = this.defaultPage;
|
|
172
|
+
this.#initialized = true;
|
|
173
|
+
}
|
|
174
|
+
this.#previousView = this.#view;
|
|
175
|
+
this.#view = getPaginationView({
|
|
176
|
+
totalPages: this.totalPages,
|
|
177
|
+
defaultPage: this.defaultPage,
|
|
178
|
+
page: this.pageControlled ? this.#requested : undefined,
|
|
179
|
+
label: this.label,
|
|
180
|
+
previousLabel: this.previousLabel,
|
|
181
|
+
nextLabel: this.nextLabel,
|
|
182
|
+
firstLabel: this.firstLabel,
|
|
183
|
+
lastLabel: this.lastLabel,
|
|
184
|
+
pageLabel: this.pageLabel,
|
|
185
|
+
summaryLabel: this.summaryLabel,
|
|
186
|
+
locale: this.locale,
|
|
187
|
+
direction: this.direction,
|
|
188
|
+
presentation: this.presentation,
|
|
189
|
+
variant: this.variant,
|
|
190
|
+
size: this.size,
|
|
191
|
+
disabled: this.disabled,
|
|
192
|
+
showFirstLast: this.showFirstLast,
|
|
193
|
+
}, this.pageControlled ? (this.#requested ?? this.#owned) : this.#owned);
|
|
194
|
+
this.#effective = this.#view.page;
|
|
195
|
+
if (!this.pageControlled)
|
|
196
|
+
this.#owned = this.#effective;
|
|
197
|
+
}
|
|
198
|
+
async updated() {
|
|
199
|
+
for (const button of this.renderRoot.querySelectorAll('cosm-button[data-page]'))
|
|
200
|
+
setCurrentPage(button, button.hasAttribute('data-current'));
|
|
201
|
+
if (!this.#restoreFocus)
|
|
202
|
+
return;
|
|
203
|
+
this.#restoreFocus = false;
|
|
204
|
+
const focusVisible = !this.#pointerActivation;
|
|
205
|
+
this.#pointerActivation = false;
|
|
206
|
+
const focusedPage = this.#focusedPage;
|
|
207
|
+
const controls = [
|
|
208
|
+
...this.renderRoot.querySelectorAll('cosm-button, cosm-icon-button'),
|
|
209
|
+
];
|
|
210
|
+
await Promise.all(controls.map(control => control.updateComplete));
|
|
211
|
+
const root = this.getRootNode();
|
|
212
|
+
if ('activeElement' in root &&
|
|
213
|
+
root.activeElement &&
|
|
214
|
+
root.activeElement !== this &&
|
|
215
|
+
root.activeElement !== this.ownerDocument.body)
|
|
216
|
+
return;
|
|
217
|
+
const focused = this.shadowRoot?.activeElement;
|
|
218
|
+
if (focused &&
|
|
219
|
+
!focused.hasAttribute('data-unavailable') &&
|
|
220
|
+
(focusedPage === null || focused.getAttribute('data-page') === focusedPage))
|
|
221
|
+
return;
|
|
222
|
+
const target = controls.find(control => focusedPage !== null &&
|
|
223
|
+
control.getAttribute('data-page') === focusedPage &&
|
|
224
|
+
!control.hasAttribute('data-unavailable')) ??
|
|
225
|
+
controls.find(control => control.hasAttribute('data-current') && !control.hasAttribute('data-unavailable')) ??
|
|
226
|
+
controls.find(control => !control.hasAttribute('data-unavailable'));
|
|
227
|
+
// Restoring focus after a pointer activation should not show the keyboard focus ring.
|
|
228
|
+
target?.focus({ preventScroll: true, focusVisible });
|
|
229
|
+
}
|
|
230
|
+
get page() {
|
|
231
|
+
return this.#effective;
|
|
232
|
+
}
|
|
233
|
+
set page(value) {
|
|
234
|
+
this.#requested = value;
|
|
235
|
+
this.pageControlled = value !== undefined;
|
|
236
|
+
this.requestUpdate();
|
|
237
|
+
}
|
|
238
|
+
#activate(event, page) {
|
|
239
|
+
event.stopPropagation();
|
|
240
|
+
if (this.disabled || page < 1 || page > this.totalPages || page === this.page)
|
|
241
|
+
return;
|
|
242
|
+
this.#restoreFocus = Boolean(this.shadowRoot?.activeElement);
|
|
243
|
+
if (!this.pageControlled)
|
|
244
|
+
this.#owned = page;
|
|
245
|
+
this.requestUpdate();
|
|
246
|
+
this.emit('cosm-change', { page });
|
|
247
|
+
}
|
|
248
|
+
#onPointerDown = () => {
|
|
249
|
+
this.#pointerActivation = true;
|
|
250
|
+
};
|
|
251
|
+
#onKeyDown = () => {
|
|
252
|
+
this.#pointerActivation = false;
|
|
253
|
+
};
|
|
254
|
+
#navigation(kind) {
|
|
255
|
+
const previous = kind === 'first' || kind === 'previous';
|
|
256
|
+
const rtl = this.direction === 'rtl';
|
|
257
|
+
const edge = kind === 'first' || kind === 'last';
|
|
258
|
+
const icon = edge
|
|
259
|
+
? previous !== rtl
|
|
260
|
+
? chevronsLeft
|
|
261
|
+
: chevronsRight
|
|
262
|
+
: previous !== rtl
|
|
263
|
+
? chevronLeft
|
|
264
|
+
: chevronRight;
|
|
265
|
+
const page = kind === 'first' ? 1 : kind === 'last' ? this.totalPages : this.page + (previous ? -1 : 1);
|
|
266
|
+
const disabled = this.disabled || (previous ? this.page === 1 : this.page === this.totalPages);
|
|
267
|
+
return html `<cosm-icon-button part="control" data-kind=${kind}
|
|
268
|
+
?data-unavailable=${disabled}
|
|
269
|
+
.label=${this[`${kind}Label`]} .variant=${'ghost'} .size=${this.size}
|
|
270
|
+
.disabled=${disabled} .type=${'button'}
|
|
271
|
+
@cosm-press=${(event) => this.#activate(event, page)}>
|
|
272
|
+
<cosm-icon .icon=${icon} .size=${18}></cosm-icon>
|
|
273
|
+
</cosm-icon-button>`;
|
|
274
|
+
}
|
|
275
|
+
render() {
|
|
276
|
+
const view = this.#view;
|
|
277
|
+
if (!view || this.totalPages <= 1)
|
|
278
|
+
return nothing;
|
|
279
|
+
const cell = (content, index) => {
|
|
280
|
+
const previous = this.#previousView;
|
|
281
|
+
const oldItem = previous?.totalPages === view.totalPages && previous.presentation === 'numbered'
|
|
282
|
+
? previous.items[index]
|
|
283
|
+
: undefined;
|
|
284
|
+
const oldContent = typeof oldItem === 'number'
|
|
285
|
+
? previous?.number(oldItem)
|
|
286
|
+
: oldItem === 'ellipsis'
|
|
287
|
+
? '…'
|
|
288
|
+
: undefined;
|
|
289
|
+
return html `<span class="cell" data-total=${view.number(this.totalPages)}>${keyed(content, html `${oldContent !== undefined && oldContent !== content
|
|
290
|
+
? html `<span class="leaving" aria-hidden="true">${oldContent}</span>`
|
|
291
|
+
: nothing}<span class="entering">${content}</span>`)}</span>`;
|
|
292
|
+
};
|
|
293
|
+
return html `<nav part="base" aria-label=${this.label} dir=${this.direction}
|
|
294
|
+
@pointerdown=${this.#onPointerDown} @keydown=${this.#onKeyDown}>
|
|
295
|
+
${this.showFirstLast ? this.#navigation('first') : nothing}
|
|
296
|
+
${this.#navigation('previous')}
|
|
297
|
+
${this.presentation === 'compact'
|
|
298
|
+
? html `<span part="summary">${view.summary}</span>`
|
|
299
|
+
: repeat(view.items, (_, index) => index, (item, index) => typeof item !== 'number'
|
|
300
|
+
? html `<span part="ellipsis" aria-hidden="true">${cell('…', index)}</span>`
|
|
301
|
+
: html `<cosm-button part=${item === this.page ? 'page current' : 'page'}
|
|
302
|
+
data-page=${item} ?data-current=${item === this.page}
|
|
303
|
+
?data-unavailable=${this.disabled}
|
|
304
|
+
.label=${view.pageName(item)}
|
|
305
|
+
.variant=${item === this.page ? this.variant : 'ghost'}
|
|
306
|
+
.size=${this.size} .disabled=${this.disabled} .type=${'button'}
|
|
307
|
+
@cosm-press=${(event) => this.#activate(event, item)}
|
|
308
|
+
>${cell(view.number(item), index)}</cosm-button>`)}
|
|
309
|
+
${this.#navigation('next')}
|
|
310
|
+
${this.showFirstLast ? this.#navigation('last') : nothing}
|
|
311
|
+
</nav>`;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
define('cosm-pagination', CosmPagination);
|
|
315
|
+
//# sourceMappingURL=cosm-pagination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cosm-pagination.js","sourceRoot":"","sources":["../../../src/components/pagination/cosm-pagination.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAEjB,kBAAkB,GACnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,0BAA0B,CAAC;AAClC,OAAO,oCAAoC,CAAC;AAC5C,OAAO,sBAAsB,CAAC;AAI9B,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+EjB,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,cAAe,SAAQ,WAAW;IAC7C,MAAM,CAAU,iBAAiB,GAAG,EAAE,GAAG,UAAU,CAAC,iBAAiB,EAAE,cAAc,EAAE,IA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a,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO;WACpD,CAAC;IACV,CAAC;;AAGH,MAAM,CAAC,iBAAiB,EAAE,cAAc,CAAC,CAAC"}
|
|
@@ -47,9 +47,6 @@ export declare class CosmPopover extends CosmElement {
|
|
|
47
47
|
closeLabel: {
|
|
48
48
|
attribute: string;
|
|
49
49
|
};
|
|
50
|
-
gap: {
|
|
51
|
-
type: NumberConstructor;
|
|
52
|
-
};
|
|
53
50
|
arrow: {
|
|
54
51
|
type: BooleanConstructor;
|
|
55
52
|
};
|
|
@@ -61,42 +58,23 @@ export declare class CosmPopover extends CosmElement {
|
|
|
61
58
|
type: BooleanConstructor;
|
|
62
59
|
attribute: string;
|
|
63
60
|
};
|
|
64
|
-
initialFocus: {
|
|
65
|
-
type: BooleanConstructor;
|
|
66
|
-
attribute: string;
|
|
67
|
-
};
|
|
68
|
-
restoreFocus: {
|
|
69
|
-
type: BooleanConstructor;
|
|
70
|
-
attribute: string;
|
|
71
|
-
};
|
|
72
61
|
side: {
|
|
73
62
|
reflect: boolean;
|
|
74
63
|
};
|
|
75
64
|
align: {
|
|
76
65
|
reflect: boolean;
|
|
77
66
|
};
|
|
78
|
-
flip: {
|
|
79
|
-
type: BooleanConstructor;
|
|
80
|
-
};
|
|
81
|
-
shift: {
|
|
82
|
-
type: BooleanConstructor;
|
|
83
|
-
};
|
|
84
67
|
};
|
|
85
68
|
static styles: import("lit").CSSResult[];
|
|
86
69
|
defaultOpen: Props['defaultOpen'];
|
|
87
70
|
triggerMode: Props['triggerMode'];
|
|
88
71
|
closable: Props['closable'];
|
|
89
72
|
closeLabel: Props['closeLabel'];
|
|
90
|
-
gap: Props['gap'];
|
|
91
73
|
arrow: Props['arrow'];
|
|
92
74
|
closeOnEscape: Props['closeOnEscape'];
|
|
93
75
|
closeOnOutsidePress: Props['closeOnOutsidePress'];
|
|
94
|
-
initialFocus: Props['initialFocus'];
|
|
95
|
-
restoreFocus: Props['restoreFocus'];
|
|
96
76
|
side: PopoverSide;
|
|
97
77
|
align: PopoverAlign;
|
|
98
|
-
flip: Props['flip'];
|
|
99
|
-
shift: Props['shift'];
|
|
100
78
|
/** Set by adapters to distinguish a bound `open` value from autonomous state. */
|
|
101
79
|
openControlled: boolean;
|
|
102
80
|
get open(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cosm-popover.d.ts","sourceRoot":"","sources":["../../../src/components/popover/cosm-popover.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,uBAAuB,EAC5B,eAAe,EAChB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,sBAAsB,CAAC;AAC9B,OAAO,oCAAoC,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAI7D,KAAK,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,eAAe,EAAE,KAAK,CAAC,CAAC,CAAC;AACpE,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;AACxC,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"cosm-popover.d.ts","sourceRoot":"","sources":["../../../src/components/popover/cosm-popover.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,uBAAuB,EAC5B,eAAe,EAChB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,sBAAsB,CAAC;AAC9B,OAAO,oCAAoC,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAI7D,KAAK,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,eAAe,EAAE,KAAK,CAAC,CAAC,CAAC;AACpE,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;AACxC,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,OA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visibility: hidden;
|
|
43
43
|
pointer-events: none;
|
|
44
|
+
column-gap: var(--cosm-space-sm, 0.5rem);
|
|
44
45
|
padding:
|
|
45
46
|
env(safe-area-inset-top, 0px)
|
|
46
47
|
env(safe-area-inset-right, 0px)
|
|
@@ -80,16 +81,11 @@ export class CosmPopover extends CosmElement {
|
|
|
80
81
|
triggerMode: { attribute: 'trigger-mode' },
|
|
81
82
|
closable: { type: Boolean },
|
|
82
83
|
closeLabel: { attribute: 'close-label' },
|
|
83
|
-
gap: { type: Number },
|
|
84
84
|
arrow: { type: Boolean },
|
|
85
85
|
closeOnEscape: { type: Boolean, attribute: 'close-on-escape' },
|
|
86
86
|
closeOnOutsidePress: { type: Boolean, attribute: 'close-on-outside-press' },
|
|
87
|
-
initialFocus: { type: Boolean, attribute: 'initial-focus' },
|
|
88
|
-
restoreFocus: { type: Boolean, attribute: 'restore-focus' },
|
|
89
87
|
side: { reflect: true },
|
|
90
88
|
align: { reflect: true },
|
|
91
|
-
flip: { type: Boolean },
|
|
92
|
-
shift: { type: Boolean },
|
|
93
89
|
};
|
|
94
90
|
static styles = [boxSizing, focusRing, styles];
|
|
95
91
|
/** Set by adapters to distinguish a bound `open` value from autonomous state. */
|
|
@@ -130,16 +126,11 @@ export class CosmPopover extends CosmElement {
|
|
|
130
126
|
this.triggerMode = props.triggerMode.default;
|
|
131
127
|
this.closable = props.closable.default;
|
|
132
128
|
this.closeLabel = props.closeLabel.default;
|
|
133
|
-
this.gap = props.gap.default;
|
|
134
129
|
this.arrow = props.arrow.default;
|
|
135
130
|
this.closeOnEscape = props.closeOnEscape.default;
|
|
136
131
|
this.closeOnOutsidePress = props.closeOnOutsidePress.default;
|
|
137
|
-
this.initialFocus = props.initialFocus.default;
|
|
138
|
-
this.restoreFocus = props.restoreFocus.default;
|
|
139
132
|
this.side = props.side.default;
|
|
140
133
|
this.align = props.align.default;
|
|
141
|
-
this.flip = props.flip.default;
|
|
142
|
-
this.shift = props.shift.default;
|
|
143
134
|
this.#setOpen(props.open.default);
|
|
144
135
|
}
|
|
145
136
|
connectedCallback() {
|
|
@@ -185,9 +176,6 @@ export class CosmPopover extends CosmElement {
|
|
|
185
176
|
super.disconnectedCallback();
|
|
186
177
|
}
|
|
187
178
|
willUpdate() {
|
|
188
|
-
if (!Number.isFinite(this.gap) || this.gap < 0) {
|
|
189
|
-
throw new RangeError('cosm-popover gap must be a finite non-negative number.');
|
|
190
|
-
}
|
|
191
179
|
if (this.closable && !this.closeLabel?.trim()) {
|
|
192
180
|
throw new Error('cosm-popover requires a non-empty closeLabel when closable.');
|
|
193
181
|
}
|
|
@@ -204,11 +192,6 @@ export class CosmPopover extends CosmElement {
|
|
|
204
192
|
this.#showPanelInTopLayer();
|
|
205
193
|
this.#installOpenListeners();
|
|
206
194
|
this.#positionPanel();
|
|
207
|
-
if (this.initialFocus &&
|
|
208
|
-
this.#openingReason !== 'hover' &&
|
|
209
|
-
this.#openingReason !== 'focus') {
|
|
210
|
-
this.#focusPanel();
|
|
211
|
-
}
|
|
212
195
|
}
|
|
213
196
|
else {
|
|
214
197
|
this.#hidePanelFromTopLayer();
|
|
@@ -222,9 +205,6 @@ export class CosmPopover extends CosmElement {
|
|
|
222
205
|
}
|
|
223
206
|
if (changed.has('side') ||
|
|
224
207
|
changed.has('align') ||
|
|
225
|
-
changed.has('flip') ||
|
|
226
|
-
changed.has('shift') ||
|
|
227
|
-
changed.has('gap') ||
|
|
228
208
|
changed.has('arrow') ||
|
|
229
209
|
changed.has('closable')) {
|
|
230
210
|
this.#positionPanel();
|
|
@@ -584,24 +564,6 @@ export class CosmPopover extends CosmElement {
|
|
|
584
564
|
(element.hasAttribute('tabindex') && element.tabIndex === -1) ||
|
|
585
565
|
element.matches('a[href], area[href], button, input, select, textarea, summary, iframe'));
|
|
586
566
|
}
|
|
587
|
-
#focusablePanelContent() {
|
|
588
|
-
const slot = this.#panelSlot();
|
|
589
|
-
for (const assigned of slot?.assignedElements({ flatten: true }) ?? []) {
|
|
590
|
-
const root = assigned;
|
|
591
|
-
if (this.#focusable(root))
|
|
592
|
-
return root;
|
|
593
|
-
for (const descendant of root.querySelectorAll('a[href], area[href], button, input, select, textarea, summary, iframe, [tabindex]')) {
|
|
594
|
-
if (this.#focusable(descendant))
|
|
595
|
-
return descendant;
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
return null;
|
|
599
|
-
}
|
|
600
|
-
#focusPanel() {
|
|
601
|
-
(this.renderRoot.querySelector('.close') ??
|
|
602
|
-
this.#focusablePanelContent() ??
|
|
603
|
-
this.#panel())?.focus();
|
|
604
|
-
}
|
|
605
567
|
#activeElement() {
|
|
606
568
|
return this.shadowRoot?.activeElement ?? document.activeElement;
|
|
607
569
|
}
|
|
@@ -617,13 +579,20 @@ export class CosmPopover extends CosmElement {
|
|
|
617
579
|
const active = this.#activeElement();
|
|
618
580
|
const focusWasLostByHiding = this.#focusWasInsideBeforeClose &&
|
|
619
581
|
(active === document.body || active === document.documentElement || active === this);
|
|
620
|
-
if (!this
|
|
582
|
+
if (!this.#isInsidePanel(active) && !focusWasLostByHiding)
|
|
621
583
|
return;
|
|
622
584
|
const trigger = this.#triggerElement();
|
|
623
585
|
if (!trigger?.isConnected || !this.#focusable(trigger))
|
|
624
586
|
return;
|
|
625
587
|
trigger.focus();
|
|
626
588
|
}
|
|
589
|
+
/** Trigger-to-panel distance: the theme `space-sm` token, resolved to pixels by the probe. */
|
|
590
|
+
#gap() {
|
|
591
|
+
const probe = this.renderRoot.querySelector('.safe-area-probe');
|
|
592
|
+
const resolved = probe ? getComputedStyle(probe).columnGap : '';
|
|
593
|
+
const value = resolved.endsWith('px') ? Number.parseFloat(resolved) : Number.NaN;
|
|
594
|
+
return Number.isFinite(value) && value >= 0 ? value : 8;
|
|
595
|
+
}
|
|
627
596
|
#viewportBounds() {
|
|
628
597
|
const viewport = window.visualViewport;
|
|
629
598
|
const left = viewport?.offsetLeft ?? 0;
|
|
@@ -659,7 +628,7 @@ export class CosmPopover extends CosmElement {
|
|
|
659
628
|
: this.align === 'start'
|
|
660
629
|
? trigger.top
|
|
661
630
|
: trigger.bottom - panelHeight;
|
|
662
|
-
const distance = this
|
|
631
|
+
const distance = this.#gap() + (this.arrow ? 8 : 0);
|
|
663
632
|
switch (side) {
|
|
664
633
|
case 'top':
|
|
665
634
|
return { left: horizontalAlign, top: trigger.top - panelHeight - distance };
|
|
@@ -699,19 +668,17 @@ export class CosmPopover extends CosmElement {
|
|
|
699
668
|
};
|
|
700
669
|
let side = this.side;
|
|
701
670
|
let point = this.#coordinates(side, triggerRect, panelRect.width, panelRect.height);
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
point.top = Math.min(Math.max(point.top, bounds.top), Math.max(bounds.top, bounds.bottom - panelRect.height));
|
|
714
|
-
}
|
|
671
|
+
// Flip only when the opposite side reduces main-axis overflow; ties keep the request.
|
|
672
|
+
const flippedSide = opposite[side];
|
|
673
|
+
const flippedPoint = this.#coordinates(flippedSide, triggerRect, panelRect.width, panelRect.height);
|
|
674
|
+
if (this.#mainOverflow(flippedSide, flippedPoint, panelRect, bounds) <
|
|
675
|
+
this.#mainOverflow(side, point, panelRect, bounds)) {
|
|
676
|
+
side = flippedSide;
|
|
677
|
+
point = flippedPoint;
|
|
678
|
+
}
|
|
679
|
+
// Then shift within the available viewport/safe-area bounds.
|
|
680
|
+
point.left = Math.min(Math.max(point.left, bounds.left), Math.max(bounds.left, bounds.right - panelRect.width));
|
|
681
|
+
point.top = Math.min(Math.max(point.top, bounds.top), Math.max(bounds.top, bounds.bottom - panelRect.height));
|
|
715
682
|
panel.style.left = `${point.left}px`;
|
|
716
683
|
panel.style.top = `${point.top}px`;
|
|
717
684
|
panel.dataset.placement = side;
|