@joralvmel/cosmos-elements 0.2.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 +15 -0
- 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 +79 -0
- package/dist/components/icon-button/cosm-icon-button.d.ts.map +1 -0
- package/dist/components/icon-button/cosm-icon-button.js +212 -0
- package/dist/components/icon-button/cosm-icon-button.js.map +1 -0
- package/dist/components/listbox/cosm-listbox.d.ts +136 -0
- package/dist/components/listbox/cosm-listbox.d.ts.map +1 -0
- package/dist/components/listbox/cosm-listbox.js +565 -0
- package/dist/components/listbox/cosm-listbox.js.map +1 -0
- 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 +100 -0
- package/dist/components/popover/cosm-popover.d.ts.map +1 -0
- package/dist/components/popover/cosm-popover.js +776 -0
- package/dist/components/popover/cosm-popover.js.map +1 -0
- 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 +193 -0
- package/dist/components/text-field/cosm-text-field.d.ts.map +1 -0
- package/dist/components/text-field/cosm-text-field.js +642 -0
- package/dist/components/text-field/cosm-text-field.js.map +1 -0
- 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 +7605 -78
- package/dist/index.d.ts +14 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -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 +455 -7
- package/package.json +55 -3
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { type ContractProps, paginationContract } from '@joralvmel/cosmos-core';
|
|
2
|
+
import { nothing } from 'lit';
|
|
3
|
+
import { CosmElement } from '../../internal/cosm-element.js';
|
|
4
|
+
import '../button/cosm-button.js';
|
|
5
|
+
import '../icon-button/cosm-icon-button.js';
|
|
6
|
+
import '../icon/cosm-icon.js';
|
|
7
|
+
type Props = ContractProps<typeof paginationContract, 'web'>;
|
|
8
|
+
/**
|
|
9
|
+
* Button-based, localized pagination with controlled or autonomous state.
|
|
10
|
+
* @tag cosm-pagination
|
|
11
|
+
* @csspart base - Navigation landmark.
|
|
12
|
+
* @csspart control - Navigation control.
|
|
13
|
+
* @csspart page - Numbered page control.
|
|
14
|
+
* @csspart current - Current page control.
|
|
15
|
+
* @csspart ellipsis - Decorative omitted range.
|
|
16
|
+
* @csspart summary - Compact summary.
|
|
17
|
+
* @fires {CustomEvent<PaginationChangeDetail>} cosm-change - Proposed page.
|
|
18
|
+
* @cssprop --cosm-pagination-gap - Control gap.
|
|
19
|
+
* @cssprop --cosm-pagination-min-height - Minimum control dimensions.
|
|
20
|
+
* @cssprop --cosm-pagination-radius - Control corner radius.
|
|
21
|
+
* @cssprop --cosm-pagination-current-background - Current background.
|
|
22
|
+
* @cssprop --cosm-pagination-current-color - Current foreground.
|
|
23
|
+
* @cssprop --cosm-pagination-current-border - Current border.
|
|
24
|
+
*/
|
|
25
|
+
export declare class CosmPagination extends CosmElement {
|
|
26
|
+
#private;
|
|
27
|
+
static shadowRootOptions: {
|
|
28
|
+
delegatesFocus: boolean;
|
|
29
|
+
clonable?: boolean;
|
|
30
|
+
customElementRegistry?: CustomElementRegistry | null;
|
|
31
|
+
mode: ShadowRootMode;
|
|
32
|
+
serializable?: boolean;
|
|
33
|
+
slotAssignment?: SlotAssignmentMode;
|
|
34
|
+
};
|
|
35
|
+
static properties: {
|
|
36
|
+
totalPages: {
|
|
37
|
+
type: NumberConstructor;
|
|
38
|
+
attribute: string;
|
|
39
|
+
};
|
|
40
|
+
page: {
|
|
41
|
+
type: NumberConstructor;
|
|
42
|
+
noAccessor: boolean;
|
|
43
|
+
};
|
|
44
|
+
defaultPage: {
|
|
45
|
+
type: NumberConstructor;
|
|
46
|
+
attribute: string;
|
|
47
|
+
};
|
|
48
|
+
label: {};
|
|
49
|
+
previousLabel: {
|
|
50
|
+
attribute: string;
|
|
51
|
+
};
|
|
52
|
+
nextLabel: {
|
|
53
|
+
attribute: string;
|
|
54
|
+
};
|
|
55
|
+
firstLabel: {
|
|
56
|
+
attribute: string;
|
|
57
|
+
};
|
|
58
|
+
lastLabel: {
|
|
59
|
+
attribute: string;
|
|
60
|
+
};
|
|
61
|
+
pageLabel: {
|
|
62
|
+
attribute: string;
|
|
63
|
+
};
|
|
64
|
+
summaryLabel: {
|
|
65
|
+
attribute: string;
|
|
66
|
+
};
|
|
67
|
+
locale: {};
|
|
68
|
+
direction: {};
|
|
69
|
+
presentation: {
|
|
70
|
+
reflect: boolean;
|
|
71
|
+
};
|
|
72
|
+
variant: {
|
|
73
|
+
reflect: boolean;
|
|
74
|
+
};
|
|
75
|
+
size: {
|
|
76
|
+
reflect: boolean;
|
|
77
|
+
};
|
|
78
|
+
showFirstLast: {
|
|
79
|
+
type: BooleanConstructor;
|
|
80
|
+
attribute: string;
|
|
81
|
+
};
|
|
82
|
+
disabled: {
|
|
83
|
+
type: BooleanConstructor;
|
|
84
|
+
reflect: boolean;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
static styles: import("lit").CSSResult[];
|
|
88
|
+
totalPages: number;
|
|
89
|
+
defaultPage: number;
|
|
90
|
+
label: string;
|
|
91
|
+
previousLabel: string;
|
|
92
|
+
nextLabel: string;
|
|
93
|
+
firstLabel: string;
|
|
94
|
+
lastLabel: string;
|
|
95
|
+
pageLabel: string;
|
|
96
|
+
summaryLabel: string;
|
|
97
|
+
locale: string | undefined;
|
|
98
|
+
direction: NonNullable<Props['direction']>;
|
|
99
|
+
presentation: NonNullable<Props['presentation']>;
|
|
100
|
+
variant: NonNullable<Props['variant']>;
|
|
101
|
+
size: NonNullable<Props['size']>;
|
|
102
|
+
showFirstLast: boolean;
|
|
103
|
+
disabled: boolean;
|
|
104
|
+
pageControlled: boolean;
|
|
105
|
+
constructor();
|
|
106
|
+
protected willUpdate(): void;
|
|
107
|
+
protected updated(): Promise<void>;
|
|
108
|
+
get page(): number;
|
|
109
|
+
set page(value: number | undefined);
|
|
110
|
+
protected render(): import("lit-html").TemplateResult<1> | typeof nothing;
|
|
111
|
+
}
|
|
112
|
+
declare global {
|
|
113
|
+
interface HTMLElementTagNameMap {
|
|
114
|
+
'cosm-pagination': CosmPagination;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
export {};
|
|
118
|
+
//# sourceMappingURL=cosm-pagination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cosm-pagination.d.ts","sourceRoot":"","sources":["../../../src/components/pagination/cosm-pagination.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAGlB,kBAAkB,EACnB,MAAM,wBAAwB,CAAC;AAKhC,OAAO,EAAyB,OAAO,EAAE,MAAM,KAAK,CAAC;AAGrD,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAI7D,OAAO,0BAA0B,CAAC;AAClC,OAAO,oCAAoC,CAAC;AAC5C,OAAO,sBAAsB,CAAC;AAE9B,KAAK,KAAK,GAAG,aAAa,CAAC,OAAO,kBAAkB,EAAE,KAAK,CAAC,CAAC;AAmF7D;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,cAAe,SAAQ,WAAW;;IAC7C,OAAgB,iBAAiB;;;;;;;MAA6D;IAC9F,OAAgB,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAkBxB;IACF,OAAgB,MAAM,4BAAuB;IAErC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,SAAS,EAAE,WAAW,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;IAC3C,YAAY,EAAE,WAAW,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;IACjD,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;IACvC,IAAI,EAAE,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IACjC,aAAa,EAAE,OAAO,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAE1B,cAAc,UAAS;;cAgCJ,UAAU,IAAI,IAAI;cAmCZ,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IA8CjD,IAAI,IAAI,IAAI,MAAM,CAEjB;IACD,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAIjC;cA0CkB,MAAM;CAmD1B;AAID,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,iBAAiB,EAAE,cAAc,CAAC;KACnC;CACF"}
|
|
@@ -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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
|
+
import '../icon-button/cosm-icon-button.js';
|
|
4
|
+
import { CosmElement } from '../../internal/cosm-element.js';
|
|
5
|
+
type Props = Required<ContractProps<typeof popoverContract, 'web'>>;
|
|
6
|
+
export type PopoverSide = Props['side'];
|
|
7
|
+
export type PopoverAlign = Props['align'];
|
|
8
|
+
/**
|
|
9
|
+
* Non-modal content anchored to a consumer-provided trigger. Trigger naming, trigger
|
|
10
|
+
* appearance and panel semantics are supplied by the consumer.
|
|
11
|
+
*
|
|
12
|
+
* @tag cosm-popover
|
|
13
|
+
* @slot trigger - Consumer-supplied keyboard-operable trigger.
|
|
14
|
+
* @slot - Consumer-supplied panel content and semantics.
|
|
15
|
+
* @csspart trigger - Container for the trigger slot.
|
|
16
|
+
* @csspart panel - Non-modal anchored surface.
|
|
17
|
+
* @csspart body - Scrollable content.
|
|
18
|
+
* @csspart close - Optional close IconButton.
|
|
19
|
+
* @csspart arrow - Decorative pointer matching the panel.
|
|
20
|
+
* @fires {CustomEvent<PopoverOpenChangeDetail>} cosm-open-change - Proposes a visibility change.
|
|
21
|
+
* @cssprop --cosm-popover-z-index - Stacking level of the panel.
|
|
22
|
+
* @cssprop --cosm-popover-padding - Panel padding.
|
|
23
|
+
* @cssprop --cosm-popover-radius - Panel corner radius.
|
|
24
|
+
* @cssprop --cosm-popover-shadow - Panel shadow.
|
|
25
|
+
* @remarks Uses the native manual Popover API to escape clipping and transformed ancestors when
|
|
26
|
+
* available. Without that API, it falls back to fixed positioning, which can still be clipped or
|
|
27
|
+
* displaced by ancestor overflow, transforms or containment.
|
|
28
|
+
*/
|
|
29
|
+
export declare class CosmPopover extends CosmElement {
|
|
30
|
+
#private;
|
|
31
|
+
static shadowRootOptions: ShadowRootInit;
|
|
32
|
+
static properties: {
|
|
33
|
+
open: {
|
|
34
|
+
type: BooleanConstructor;
|
|
35
|
+
reflect: boolean;
|
|
36
|
+
};
|
|
37
|
+
defaultOpen: {
|
|
38
|
+
type: BooleanConstructor;
|
|
39
|
+
attribute: string;
|
|
40
|
+
};
|
|
41
|
+
triggerMode: {
|
|
42
|
+
attribute: string;
|
|
43
|
+
};
|
|
44
|
+
closable: {
|
|
45
|
+
type: BooleanConstructor;
|
|
46
|
+
};
|
|
47
|
+
closeLabel: {
|
|
48
|
+
attribute: string;
|
|
49
|
+
};
|
|
50
|
+
arrow: {
|
|
51
|
+
type: BooleanConstructor;
|
|
52
|
+
};
|
|
53
|
+
closeOnEscape: {
|
|
54
|
+
type: BooleanConstructor;
|
|
55
|
+
attribute: string;
|
|
56
|
+
};
|
|
57
|
+
closeOnOutsidePress: {
|
|
58
|
+
type: BooleanConstructor;
|
|
59
|
+
attribute: string;
|
|
60
|
+
};
|
|
61
|
+
side: {
|
|
62
|
+
reflect: boolean;
|
|
63
|
+
};
|
|
64
|
+
align: {
|
|
65
|
+
reflect: boolean;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
static styles: import("lit").CSSResult[];
|
|
69
|
+
defaultOpen: Props['defaultOpen'];
|
|
70
|
+
triggerMode: Props['triggerMode'];
|
|
71
|
+
closable: Props['closable'];
|
|
72
|
+
closeLabel: Props['closeLabel'];
|
|
73
|
+
arrow: Props['arrow'];
|
|
74
|
+
closeOnEscape: Props['closeOnEscape'];
|
|
75
|
+
closeOnOutsidePress: Props['closeOnOutsidePress'];
|
|
76
|
+
side: PopoverSide;
|
|
77
|
+
align: PopoverAlign;
|
|
78
|
+
/** Set by adapters to distinguish a bound `open` value from autonomous state. */
|
|
79
|
+
openControlled: boolean;
|
|
80
|
+
get open(): boolean;
|
|
81
|
+
set open(value: boolean | undefined);
|
|
82
|
+
constructor();
|
|
83
|
+
connectedCallback(): void;
|
|
84
|
+
disconnectedCallback(): void;
|
|
85
|
+
protected willUpdate(): void;
|
|
86
|
+
protected updated(changed: Map<PropertyKey, unknown>): void;
|
|
87
|
+
/** Requests closure with reason `action` only while the panel is open. */
|
|
88
|
+
requestClose(): void;
|
|
89
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
|
90
|
+
}
|
|
91
|
+
declare global {
|
|
92
|
+
interface HTMLElementTagNameMap {
|
|
93
|
+
'cosm-popover': CosmPopover;
|
|
94
|
+
}
|
|
95
|
+
interface HTMLElementEventMap {
|
|
96
|
+
'cosm-open-change': CustomEvent<PopoverOpenChangeDetail>;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
export {};
|
|
100
|
+
//# sourceMappingURL=cosm-popover.d.ts.map
|
|
@@ -0,0 +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;AAgD1C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,WAAY,SAAQ,WAAW;;IAC1C,OAAgB,iBAAiB,EAAE,cAAc,CAG/C;IAEF,OAAgB,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAWxB;IAEF,OAAgB,MAAM,4BAAkC;IAEhD,WAAW,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;IAClC,WAAW,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;IAClC,QAAQ,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IAC5B,UAAU,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;IAChC,KAAK,EAAE,KAAK,CAA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