@sebgroup/green-core 2.19.0 → 2.20.0-rc.20251215154321804
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/components/badge/badge.component.d.ts +0 -23
- package/components/badge/badge.component.js +18 -105
- package/components/badge/badge.styles.js +96 -2
- package/components/checkbox/checkbox.component.js +24 -22
- package/components/checkbox/checkbox.styles.js +0 -8
- package/components/dropdown/dropdown.component.js +4 -1
- package/components/index.d.ts +2 -0
- package/components/index.js +2 -0
- package/components/input/input.styles.js +10 -1
- package/components/pagination/index.d.ts +1 -0
- package/components/pagination/index.js +1 -0
- package/components/pagination/pagination.component.d.ts +82 -0
- package/components/pagination/pagination.component.js +441 -0
- package/components/pagination/pagination.d.ts +2 -0
- package/components/pagination/pagination.js +6 -0
- package/components/pagination/pagination.styles.d.ts +1 -0
- package/components/pagination/pagination.styles.js +19 -0
- package/components/table/index.d.ts +2 -0
- package/components/table/index.js +6 -0
- package/components/table/table.component.d.ts +140 -0
- package/components/table/table.component.js +1090 -0
- package/components/table/table.d.ts +2 -0
- package/components/table/table.imports.d.ts +6 -0
- package/components/table/table.imports.js +63 -0
- package/components/table/table.js +6 -0
- package/components/table/table.stories.data.d.ts +53 -0
- package/components/table/table.stories.data.js +401 -0
- package/components/table/table.styles.d.ts +1 -0
- package/components/table/table.styles.js +788 -0
- package/components/table/table.types.d.ts +155 -0
- package/components/table/table.types.js +24 -0
- package/custom-elements.json +12280 -10492
- package/gds-element.js +1 -1
- package/generated/locales/da.d.ts +32 -0
- package/generated/locales/da.js +32 -0
- package/generated/locales/de.d.ts +32 -0
- package/generated/locales/de.js +32 -0
- package/generated/locales/fi.d.ts +32 -0
- package/generated/locales/fi.js +32 -0
- package/generated/locales/fr.d.ts +32 -0
- package/generated/locales/fr.js +32 -0
- package/generated/locales/it.d.ts +32 -0
- package/generated/locales/it.js +32 -0
- package/generated/locales/nl.d.ts +32 -0
- package/generated/locales/nl.js +32 -0
- package/generated/locales/no.d.ts +32 -0
- package/generated/locales/no.js +33 -1
- package/generated/locales/sv.d.ts +32 -0
- package/generated/locales/sv.js +32 -0
- package/generated/react/index.d.ts +8 -6
- package/generated/react/index.js +8 -6
- package/generated/react/input/index.d.ts +1 -1
- package/generated/react/pagination/index.d.ts +395 -0
- package/generated/react/pagination/index.js +13 -0
- package/generated/react/table/index.d.ts +395 -0
- package/generated/react/table/index.js +13 -0
- package/package.json +8 -1
- package/primitives/field-base/field-base.component.d.ts +1 -0
- package/primitives/field-base/field-base.component.js +8 -0
- package/primitives/field-base/field-base.styles.js +9 -1
- package/pure.d.ts +2 -0
- package/pure.js +2 -0
- package/shared-styles/rbcb-toggle.style.js +41 -12
- package/utils/helpers/custom-element-scoping.js +1 -1
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__decorateClass,
|
|
3
|
+
__privateAdd,
|
|
4
|
+
__privateGet,
|
|
5
|
+
__privateMethod
|
|
6
|
+
} from "../../chunks/chunk.QU3DSPNU.js";
|
|
7
|
+
var _GdsPagination_instances, pageCount_get, config_get, getVisiblePages_fn, renderPageButton_fn, renderPageButtons_fn, renderJumpFirstButton_fn, renderPreviousButton_fn, renderNextButton_fn, renderJumpLastButton_fn, renderNavigationControls_fn, renderPageSizeOption_fn, renderPageSizeMenu_fn, renderLabel_fn, handlePageChange_fn, handlePageSizeMenuClick_fn, handlePopoverStateChange_fn, handleCustomPageInput_fn;
|
|
8
|
+
import { localized, msg } from "@lit/localize";
|
|
9
|
+
import { property, query, state } from "lit/decorators.js";
|
|
10
|
+
import { classMap } from "lit/directives/class-map.js";
|
|
11
|
+
import { when } from "lit/directives/when.js";
|
|
12
|
+
import { GdsElement } from "../../gds-element.js";
|
|
13
|
+
import { tokens } from "../../tokens.style.js";
|
|
14
|
+
import { watchMediaQuery } from "../../utils/decorators/index.js";
|
|
15
|
+
import {
|
|
16
|
+
gdsCustomElement,
|
|
17
|
+
html
|
|
18
|
+
} from "../../utils/helpers/custom-element-scoping.js";
|
|
19
|
+
import {
|
|
20
|
+
withLayoutChildProps,
|
|
21
|
+
withMarginProps,
|
|
22
|
+
withSizeXProps
|
|
23
|
+
} from "../../utils/mixins/declarative-layout-mixins.js";
|
|
24
|
+
import { GdsButton } from "../button/button.component.js";
|
|
25
|
+
import {
|
|
26
|
+
GdsContextMenu,
|
|
27
|
+
GdsMenuItem
|
|
28
|
+
} from "../context-menu/context-menu.component.js";
|
|
29
|
+
import { GdsDropdown } from "../dropdown/dropdown.component.js";
|
|
30
|
+
import { IconChevronBottom } from "../icon/icons/chevron-bottom.component.js";
|
|
31
|
+
import { IconChevronDoubleLeft } from "../icon/icons/chevron-double-left.component.js";
|
|
32
|
+
import { IconChevronDoubleRight } from "../icon/icons/chevron-double-right.component.js";
|
|
33
|
+
import { IconChevronLeftSmall } from "../icon/icons/chevron-left-small.component.js";
|
|
34
|
+
import { IconChevronRightSmall } from "../icon/icons/chevron-right-small.component.js";
|
|
35
|
+
import { IconChevronRight } from "../icon/icons/chevron-right.component.js";
|
|
36
|
+
import { GdsInput } from "../input/input.component.js";
|
|
37
|
+
import { GdsPopover } from "../popover/popover.component.js";
|
|
38
|
+
import { GdsText } from "../text/text.component.js";
|
|
39
|
+
import { PaginationStyles } from "./pagination.styles.js";
|
|
40
|
+
const DENSITY_CONFIG = {
|
|
41
|
+
compact: {
|
|
42
|
+
button: "small",
|
|
43
|
+
font: "detail-book-s",
|
|
44
|
+
gap: "xl",
|
|
45
|
+
navGap: "xs",
|
|
46
|
+
input: "small",
|
|
47
|
+
inputWidth: "140px",
|
|
48
|
+
inputPadding: "m"
|
|
49
|
+
},
|
|
50
|
+
comfortable: {
|
|
51
|
+
button: "small",
|
|
52
|
+
font: "detail-book-s",
|
|
53
|
+
gap: "2xl",
|
|
54
|
+
navGap: "s",
|
|
55
|
+
input: "small",
|
|
56
|
+
inputWidth: "140px",
|
|
57
|
+
inputPadding: "m"
|
|
58
|
+
},
|
|
59
|
+
spacious: {
|
|
60
|
+
button: "medium",
|
|
61
|
+
font: "detail-book-m",
|
|
62
|
+
gap: "2xl",
|
|
63
|
+
navGap: "s",
|
|
64
|
+
input: "large",
|
|
65
|
+
inputWidth: "200px",
|
|
66
|
+
inputPadding: "xl"
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
let GdsPagination = class extends withMarginProps(
|
|
70
|
+
withSizeXProps(withLayoutChildProps(GdsElement))
|
|
71
|
+
) {
|
|
72
|
+
constructor() {
|
|
73
|
+
super(...arguments);
|
|
74
|
+
__privateAdd(this, _GdsPagination_instances);
|
|
75
|
+
this.page = 1;
|
|
76
|
+
this.rows = 10;
|
|
77
|
+
this.total = 0;
|
|
78
|
+
this.options = [5, 10, 25, 50];
|
|
79
|
+
this.jump = false;
|
|
80
|
+
this.density = "comfortable";
|
|
81
|
+
this.label = "";
|
|
82
|
+
this._isMobile = false;
|
|
83
|
+
this._jumpPopoverOpen = false;
|
|
84
|
+
}
|
|
85
|
+
_handleMobile(matches) {
|
|
86
|
+
this._isMobile = matches;
|
|
87
|
+
}
|
|
88
|
+
render() {
|
|
89
|
+
return html`
|
|
90
|
+
<gds-flex
|
|
91
|
+
align-items="center"
|
|
92
|
+
justify-content="space-between"
|
|
93
|
+
width="100%"
|
|
94
|
+
gap="${__privateGet(this, _GdsPagination_instances, config_get).gap}"
|
|
95
|
+
>
|
|
96
|
+
${__privateMethod(this, _GdsPagination_instances, renderLabel_fn).call(this)}
|
|
97
|
+
<gds-flex aling-items="center" gap="${__privateGet(this, _GdsPagination_instances, config_get).gap}" flex="1">
|
|
98
|
+
${[__privateMethod(this, _GdsPagination_instances, renderNavigationControls_fn).call(this), __privateMethod(this, _GdsPagination_instances, renderPageSizeMenu_fn).call(this)]}
|
|
99
|
+
</gds-flex>
|
|
100
|
+
</gds-flex>
|
|
101
|
+
`;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
_GdsPagination_instances = new WeakSet();
|
|
105
|
+
pageCount_get = function() {
|
|
106
|
+
return Math.ceil(this.total / this.rows);
|
|
107
|
+
};
|
|
108
|
+
config_get = function() {
|
|
109
|
+
return DENSITY_CONFIG[this.density];
|
|
110
|
+
};
|
|
111
|
+
getVisiblePages_fn = function(pageCount) {
|
|
112
|
+
if (pageCount <= 7) {
|
|
113
|
+
return Array.from({ length: pageCount }, (_, i) => i + 1);
|
|
114
|
+
}
|
|
115
|
+
const lastPage = pageCount;
|
|
116
|
+
const pages = [];
|
|
117
|
+
pages.push(1);
|
|
118
|
+
if (this.page <= 4) {
|
|
119
|
+
pages.push(2, 3, 4, 5, "...", lastPage);
|
|
120
|
+
} else if (this.page >= pageCount - 3) {
|
|
121
|
+
pages.push(
|
|
122
|
+
"...",
|
|
123
|
+
pageCount - 4,
|
|
124
|
+
pageCount - 3,
|
|
125
|
+
pageCount - 2,
|
|
126
|
+
pageCount - 1,
|
|
127
|
+
lastPage
|
|
128
|
+
);
|
|
129
|
+
} else {
|
|
130
|
+
pages.push(
|
|
131
|
+
"...",
|
|
132
|
+
this.page - 1,
|
|
133
|
+
this.page,
|
|
134
|
+
this.page + 1,
|
|
135
|
+
"...",
|
|
136
|
+
lastPage
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
return pages;
|
|
140
|
+
};
|
|
141
|
+
renderPageButton_fn = function(page) {
|
|
142
|
+
if (page === "...") {
|
|
143
|
+
return html`
|
|
144
|
+
<gds-popover
|
|
145
|
+
disableMobileStyles
|
|
146
|
+
@gds-ui-state=${__privateMethod(this, _GdsPagination_instances, handlePopoverStateChange_fn)}
|
|
147
|
+
>
|
|
148
|
+
<gds-button
|
|
149
|
+
size="${__privateGet(this, _GdsPagination_instances, config_get).button}"
|
|
150
|
+
rank="tertiary"
|
|
151
|
+
slot="trigger"
|
|
152
|
+
label="${msg("Jump to page")}"
|
|
153
|
+
aria-expanded="${this._jumpPopoverOpen}"
|
|
154
|
+
aria-haspopup="dialog"
|
|
155
|
+
>
|
|
156
|
+
...
|
|
157
|
+
</gds-button>
|
|
158
|
+
<gds-flex
|
|
159
|
+
flex-direction="column"
|
|
160
|
+
padding="${__privateGet(this, _GdsPagination_instances, config_get).inputPadding}"
|
|
161
|
+
width="${__privateGet(this, _GdsPagination_instances, config_get).inputWidth}"
|
|
162
|
+
max-height="280px"
|
|
163
|
+
>
|
|
164
|
+
<gds-input
|
|
165
|
+
size="${__privateGet(this, _GdsPagination_instances, config_get).input}"
|
|
166
|
+
label="${msg("Go to page")}"
|
|
167
|
+
type="number"
|
|
168
|
+
min="1"
|
|
169
|
+
max="${__privateGet(this, _GdsPagination_instances, pageCount_get)}"
|
|
170
|
+
@change=${__privateMethod(this, _GdsPagination_instances, handleCustomPageInput_fn)}
|
|
171
|
+
>
|
|
172
|
+
<gds-button
|
|
173
|
+
size="xs"
|
|
174
|
+
label="${msg("Go")}"
|
|
175
|
+
rank="secondary"
|
|
176
|
+
@click=${__privateMethod(this, _GdsPagination_instances, handleCustomPageInput_fn)}
|
|
177
|
+
slot="trail"
|
|
178
|
+
>
|
|
179
|
+
<gds-icon-chevron-right></gds-icon-chevron-right>
|
|
180
|
+
</gds-button>
|
|
181
|
+
</gds-input>
|
|
182
|
+
</gds-flex>
|
|
183
|
+
</gds-popover>
|
|
184
|
+
`;
|
|
185
|
+
}
|
|
186
|
+
const pageNum = page;
|
|
187
|
+
const isActive = this.page === pageNum;
|
|
188
|
+
const currentPageLabel = `${msg("Current page")}, ${msg("page")} ${pageNum}`;
|
|
189
|
+
const goToPageLabel = `${msg("Go to page")} ${pageNum}`;
|
|
190
|
+
const label = isActive ? currentPageLabel : goToPageLabel;
|
|
191
|
+
return html`
|
|
192
|
+
<gds-button
|
|
193
|
+
size="${__privateGet(this, _GdsPagination_instances, config_get).button}"
|
|
194
|
+
rank="${isActive ? "primary" : "tertiary"}"
|
|
195
|
+
label="${label}"
|
|
196
|
+
aria-current="${isActive ? "page" : "false"}"
|
|
197
|
+
@click=${() => __privateMethod(this, _GdsPagination_instances, handlePageChange_fn).call(this, pageNum)}
|
|
198
|
+
>
|
|
199
|
+
${pageNum}
|
|
200
|
+
</gds-button>
|
|
201
|
+
`;
|
|
202
|
+
};
|
|
203
|
+
renderPageButtons_fn = function() {
|
|
204
|
+
const pageCount = __privateGet(this, _GdsPagination_instances, pageCount_get);
|
|
205
|
+
const visiblePages = __privateMethod(this, _GdsPagination_instances, getVisiblePages_fn).call(this, pageCount);
|
|
206
|
+
return html`${visiblePages.map((page) => __privateMethod(this, _GdsPagination_instances, renderPageButton_fn).call(this, page))}`;
|
|
207
|
+
};
|
|
208
|
+
renderJumpFirstButton_fn = function() {
|
|
209
|
+
return html`
|
|
210
|
+
<gds-button
|
|
211
|
+
size="${__privateGet(this, _GdsPagination_instances, config_get).button}"
|
|
212
|
+
rank="secondary"
|
|
213
|
+
label="${msg("Go to first page")}"
|
|
214
|
+
?disabled=${this.page === 1}
|
|
215
|
+
@click=${() => __privateMethod(this, _GdsPagination_instances, handlePageChange_fn).call(this, 1)}
|
|
216
|
+
>
|
|
217
|
+
<gds-icon-chevron-double-left size="l"></gds-icon-chevron-double-left>
|
|
218
|
+
</gds-button>
|
|
219
|
+
`;
|
|
220
|
+
};
|
|
221
|
+
renderPreviousButton_fn = function() {
|
|
222
|
+
return html`
|
|
223
|
+
<gds-button
|
|
224
|
+
size="${__privateGet(this, _GdsPagination_instances, config_get).button}"
|
|
225
|
+
rank="secondary"
|
|
226
|
+
label="${msg("Go to previous page")}"
|
|
227
|
+
?disabled=${this.page === 1}
|
|
228
|
+
@click=${() => __privateMethod(this, _GdsPagination_instances, handlePageChange_fn).call(this, this.page - 1)}
|
|
229
|
+
>
|
|
230
|
+
<gds-icon-chevron-left-small size="l"></gds-icon-chevron-left-small>
|
|
231
|
+
</gds-button>
|
|
232
|
+
`;
|
|
233
|
+
};
|
|
234
|
+
renderNextButton_fn = function() {
|
|
235
|
+
const pageCount = __privateGet(this, _GdsPagination_instances, pageCount_get);
|
|
236
|
+
return html`
|
|
237
|
+
<gds-button
|
|
238
|
+
size="${__privateGet(this, _GdsPagination_instances, config_get).button}"
|
|
239
|
+
rank="secondary"
|
|
240
|
+
label="${msg("Go to next page")}"
|
|
241
|
+
?disabled=${this.page === pageCount}
|
|
242
|
+
@click=${() => __privateMethod(this, _GdsPagination_instances, handlePageChange_fn).call(this, this.page + 1)}
|
|
243
|
+
>
|
|
244
|
+
<gds-icon-chevron-right-small size="l"></gds-icon-chevron-right-small>
|
|
245
|
+
</gds-button>
|
|
246
|
+
`;
|
|
247
|
+
};
|
|
248
|
+
renderJumpLastButton_fn = function() {
|
|
249
|
+
const pageCount = __privateGet(this, _GdsPagination_instances, pageCount_get);
|
|
250
|
+
return html`
|
|
251
|
+
<gds-button
|
|
252
|
+
size="${__privateGet(this, _GdsPagination_instances, config_get).button}"
|
|
253
|
+
rank="secondary"
|
|
254
|
+
label="${msg("Go to last page")}"
|
|
255
|
+
?disabled=${this.page === pageCount}
|
|
256
|
+
@click=${() => __privateMethod(this, _GdsPagination_instances, handlePageChange_fn).call(this, pageCount)}
|
|
257
|
+
>
|
|
258
|
+
<gds-icon-chevron-double-right size="l"></gds-icon-chevron-double-right>
|
|
259
|
+
</gds-button>
|
|
260
|
+
`;
|
|
261
|
+
};
|
|
262
|
+
renderNavigationControls_fn = function() {
|
|
263
|
+
return html`
|
|
264
|
+
<gds-flex
|
|
265
|
+
gap="${__privateGet(this, _GdsPagination_instances, config_get).navGap}"
|
|
266
|
+
align-items="center"
|
|
267
|
+
class="navigation-controls"
|
|
268
|
+
justify-content="center; m{flex-end}"
|
|
269
|
+
flex="1"
|
|
270
|
+
>
|
|
271
|
+
${[
|
|
272
|
+
when(this.jump, () => __privateMethod(this, _GdsPagination_instances, renderJumpFirstButton_fn).call(this)),
|
|
273
|
+
__privateMethod(this, _GdsPagination_instances, renderPreviousButton_fn).call(this)
|
|
274
|
+
]}
|
|
275
|
+
<gds-flex gap="4xs" align-items="center">
|
|
276
|
+
${__privateMethod(this, _GdsPagination_instances, renderPageButtons_fn).call(this)}
|
|
277
|
+
</gds-flex>
|
|
278
|
+
${[
|
|
279
|
+
__privateMethod(this, _GdsPagination_instances, renderNextButton_fn).call(this),
|
|
280
|
+
when(this.jump, () => __privateMethod(this, _GdsPagination_instances, renderJumpLastButton_fn).call(this))
|
|
281
|
+
]}
|
|
282
|
+
</gds-flex>
|
|
283
|
+
`;
|
|
284
|
+
};
|
|
285
|
+
renderPageSizeOption_fn = function(size) {
|
|
286
|
+
const isSelected = this.rows === size;
|
|
287
|
+
return html`
|
|
288
|
+
<gds-menu-item
|
|
289
|
+
data-value=${size}
|
|
290
|
+
class=${classMap({ selected: isSelected })}
|
|
291
|
+
size="${__privateGet(this, _GdsPagination_instances, config_get).button}"
|
|
292
|
+
>
|
|
293
|
+
${size}
|
|
294
|
+
</gds-menu-item>
|
|
295
|
+
`;
|
|
296
|
+
};
|
|
297
|
+
renderPageSizeMenu_fn = function() {
|
|
298
|
+
if (this._isMobile) return null;
|
|
299
|
+
const rowsLabel = `${msg("Rows per page")}, ${this.rows} ${msg("selected")}`;
|
|
300
|
+
return html`
|
|
301
|
+
<gds-flex align-items="center" gap="s">
|
|
302
|
+
<gds-text
|
|
303
|
+
font="${__privateGet(this, _GdsPagination_instances, config_get).font}"
|
|
304
|
+
color="neutral-01"
|
|
305
|
+
id="rows-per-page-label"
|
|
306
|
+
>
|
|
307
|
+
${msg("Rows per page")}
|
|
308
|
+
</gds-text>
|
|
309
|
+
<gds-context-menu @gds-menu-item-click=${__privateMethod(this, _GdsPagination_instances, handlePageSizeMenuClick_fn)}>
|
|
310
|
+
<gds-button
|
|
311
|
+
slot="trigger"
|
|
312
|
+
size="${__privateGet(this, _GdsPagination_instances, config_get).button}"
|
|
313
|
+
rank="secondary"
|
|
314
|
+
label="${rowsLabel}"
|
|
315
|
+
aria-labelledby="rows-per-page-label"
|
|
316
|
+
>
|
|
317
|
+
${this.rows}
|
|
318
|
+
<gds-icon-chevron-bottom
|
|
319
|
+
slot="trail"
|
|
320
|
+
size="m"
|
|
321
|
+
></gds-icon-chevron-bottom>
|
|
322
|
+
</gds-button>
|
|
323
|
+
${this.options.map((size) => __privateMethod(this, _GdsPagination_instances, renderPageSizeOption_fn).call(this, size))}
|
|
324
|
+
</gds-context-menu>
|
|
325
|
+
</gds-flex>
|
|
326
|
+
`;
|
|
327
|
+
};
|
|
328
|
+
renderLabel_fn = function() {
|
|
329
|
+
if (this._isMobile || !this.label) return null;
|
|
330
|
+
return html`
|
|
331
|
+
<gds-text
|
|
332
|
+
font="${__privateGet(this, _GdsPagination_instances, config_get).font}"
|
|
333
|
+
color="neutral-02"
|
|
334
|
+
aria-live="polite"
|
|
335
|
+
aria-atomic="true"
|
|
336
|
+
>
|
|
337
|
+
${this.label}
|
|
338
|
+
</gds-text>
|
|
339
|
+
`;
|
|
340
|
+
};
|
|
341
|
+
handlePageChange_fn = function(newPage) {
|
|
342
|
+
this.dispatchEvent(
|
|
343
|
+
new CustomEvent("gds-page-change", {
|
|
344
|
+
detail: { page: newPage },
|
|
345
|
+
bubbles: true
|
|
346
|
+
})
|
|
347
|
+
);
|
|
348
|
+
};
|
|
349
|
+
handlePageSizeMenuClick_fn = function(e) {
|
|
350
|
+
const item = e.target;
|
|
351
|
+
const limit = parseInt(item.dataset.value || "10");
|
|
352
|
+
if (limit !== this.rows) {
|
|
353
|
+
this.dispatchEvent(
|
|
354
|
+
new CustomEvent("gds-rows-change", {
|
|
355
|
+
detail: { rows: limit },
|
|
356
|
+
bubbles: true
|
|
357
|
+
})
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
handlePopoverStateChange_fn = function(e) {
|
|
362
|
+
this._jumpPopoverOpen = e.detail.open;
|
|
363
|
+
if (e.detail.open) {
|
|
364
|
+
const popover = e.target;
|
|
365
|
+
const input = popover.querySelector("gds-input");
|
|
366
|
+
if (input) {
|
|
367
|
+
requestAnimationFrame(() => {
|
|
368
|
+
input.focus();
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
handleCustomPageInput_fn = function(e) {
|
|
374
|
+
const input = e.target;
|
|
375
|
+
const pageInput = input.closest("gds-input");
|
|
376
|
+
if (pageInput) {
|
|
377
|
+
const pageNum = parseInt(pageInput.value, 10);
|
|
378
|
+
if (pageNum && pageNum >= 1 && pageNum <= __privateGet(this, _GdsPagination_instances, pageCount_get)) {
|
|
379
|
+
__privateMethod(this, _GdsPagination_instances, handlePageChange_fn).call(this, pageNum);
|
|
380
|
+
const popover = pageInput.closest("gds-popover");
|
|
381
|
+
if (popover) popover.hide();
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
GdsPagination.styles = [tokens, PaginationStyles];
|
|
386
|
+
__decorateClass([
|
|
387
|
+
property({ type: Number })
|
|
388
|
+
], GdsPagination.prototype, "page", 2);
|
|
389
|
+
__decorateClass([
|
|
390
|
+
property({ type: Number })
|
|
391
|
+
], GdsPagination.prototype, "rows", 2);
|
|
392
|
+
__decorateClass([
|
|
393
|
+
property({ type: Number })
|
|
394
|
+
], GdsPagination.prototype, "total", 2);
|
|
395
|
+
__decorateClass([
|
|
396
|
+
property({ type: Array })
|
|
397
|
+
], GdsPagination.prototype, "options", 2);
|
|
398
|
+
__decorateClass([
|
|
399
|
+
property({ type: Boolean })
|
|
400
|
+
], GdsPagination.prototype, "jump", 2);
|
|
401
|
+
__decorateClass([
|
|
402
|
+
property({ reflect: false })
|
|
403
|
+
], GdsPagination.prototype, "density", 2);
|
|
404
|
+
__decorateClass([
|
|
405
|
+
property()
|
|
406
|
+
], GdsPagination.prototype, "label", 2);
|
|
407
|
+
__decorateClass([
|
|
408
|
+
query("#page-input")
|
|
409
|
+
], GdsPagination.prototype, "_elInput", 2);
|
|
410
|
+
__decorateClass([
|
|
411
|
+
state()
|
|
412
|
+
], GdsPagination.prototype, "_isMobile", 2);
|
|
413
|
+
__decorateClass([
|
|
414
|
+
state()
|
|
415
|
+
], GdsPagination.prototype, "_jumpPopoverOpen", 2);
|
|
416
|
+
__decorateClass([
|
|
417
|
+
watchMediaQuery("(max-width: 768px)")
|
|
418
|
+
], GdsPagination.prototype, "_handleMobile", 1);
|
|
419
|
+
GdsPagination = __decorateClass([
|
|
420
|
+
localized(),
|
|
421
|
+
gdsCustomElement("gds-pagination", {
|
|
422
|
+
dependsOn: [
|
|
423
|
+
GdsButton,
|
|
424
|
+
GdsPopover,
|
|
425
|
+
GdsText,
|
|
426
|
+
GdsInput,
|
|
427
|
+
GdsDropdown,
|
|
428
|
+
GdsContextMenu,
|
|
429
|
+
GdsMenuItem,
|
|
430
|
+
IconChevronBottom,
|
|
431
|
+
IconChevronLeftSmall,
|
|
432
|
+
IconChevronDoubleLeft,
|
|
433
|
+
IconChevronRight,
|
|
434
|
+
IconChevronRightSmall,
|
|
435
|
+
IconChevronDoubleRight
|
|
436
|
+
]
|
|
437
|
+
})
|
|
438
|
+
], GdsPagination);
|
|
439
|
+
export {
|
|
440
|
+
GdsPagination
|
|
441
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PaginationStyles: import("lit").CSSResult;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import "../../chunks/chunk.QU3DSPNU.js";
|
|
2
|
+
import { css } from "lit";
|
|
3
|
+
const PaginationStyles = css`
|
|
4
|
+
:host {
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
justify-content: center;
|
|
8
|
+
gap: var(--gds-sys-space-xl);
|
|
9
|
+
--_appearance-spin-button: none;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.navigation-controls ::part(_button) {
|
|
13
|
+
padding: 0;
|
|
14
|
+
aspect-ratio: 1/1;
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
17
|
+
export {
|
|
18
|
+
PaginationStyles
|
|
19
|
+
};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { GdsElement } from '../../gds-element';
|
|
2
|
+
import * as Types from './table.types';
|
|
3
|
+
export * as Types from './table.types';
|
|
4
|
+
/**
|
|
5
|
+
* @element gds-table
|
|
6
|
+
* @status beta
|
|
7
|
+
*
|
|
8
|
+
* @summary A data table component with async data loading, pagination, sorting, filtering, and customizable cell rendering.
|
|
9
|
+
*
|
|
10
|
+
* @slot `header-lead` - Content displayed at the start of the table header (after search).
|
|
11
|
+
* @slot `header-trail` - Content displayed at the end of the table header (before settings).
|
|
12
|
+
* @slot `error` - Custom error state content when data loading fails.
|
|
13
|
+
* @slot `empty` - Custom empty state content when no data is available.
|
|
14
|
+
* @slot `no-results` - Custom no results content when search returns empty.
|
|
15
|
+
*
|
|
16
|
+
* @event gds-table-data-loaded - Fired when data is successfully loaded.
|
|
17
|
+
* @event gds-table-data-error - Fired when data loading fails.
|
|
18
|
+
* @event gds-table-selection - Fired when row selection changes.
|
|
19
|
+
*/
|
|
20
|
+
export declare class GdsTable<T extends Types.Row = Types.Row> extends GdsElement {
|
|
21
|
+
#private;
|
|
22
|
+
static styles: (import("lit").CSSResult | import("lit").CSSResult[])[];
|
|
23
|
+
/**
|
|
24
|
+
* Configurable options for rows per page.
|
|
25
|
+
* Accepts: number array (e.g., `[5, 10, 20, 50, 100]`)
|
|
26
|
+
*/
|
|
27
|
+
options: number[];
|
|
28
|
+
/**
|
|
29
|
+
* Current page number in pagination.
|
|
30
|
+
*/
|
|
31
|
+
page: number;
|
|
32
|
+
/**
|
|
33
|
+
* Number of rows displayed per page.
|
|
34
|
+
*/
|
|
35
|
+
rows: number;
|
|
36
|
+
/**
|
|
37
|
+
* Defines table column structure.
|
|
38
|
+
* Accepts: array of column configurations with keys, labels, etc.
|
|
39
|
+
*/
|
|
40
|
+
columns: Types.Column[];
|
|
41
|
+
/**
|
|
42
|
+
* Asynchronous data provider function.
|
|
43
|
+
* Accepts: function that returns Promise with rows and total count
|
|
44
|
+
*/
|
|
45
|
+
data: (request: Types.Request) => Promise<Types.Response<T>>;
|
|
46
|
+
/**
|
|
47
|
+
* Controls row density.
|
|
48
|
+
* Accepts: `comfortable`, `compact`, `spacious`
|
|
49
|
+
*/
|
|
50
|
+
density: Types.Density;
|
|
51
|
+
/**
|
|
52
|
+
* Enables row selection functionality.
|
|
53
|
+
*/
|
|
54
|
+
selectable: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Transforms table layout for mobile screens.
|
|
57
|
+
*/
|
|
58
|
+
responsive: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Removes table header and footer.
|
|
61
|
+
*/
|
|
62
|
+
plain: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Adds search input for data filtering.
|
|
65
|
+
*/
|
|
66
|
+
searchable: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Enables column visibility settings.
|
|
69
|
+
*/
|
|
70
|
+
settings: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Applies alternating row background colors.
|
|
73
|
+
*/
|
|
74
|
+
striped: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Defines row-level actions.
|
|
77
|
+
* Accepts: action configuration or custom rendering function
|
|
78
|
+
*/
|
|
79
|
+
actions?: Types.Actions | ((row: T, index: number) => any);
|
|
80
|
+
/**
|
|
81
|
+
* Disables data caching mechanism.
|
|
82
|
+
*/
|
|
83
|
+
nocache: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Key to trigger data reloading when changed. Setting this to a new value
|
|
86
|
+
* forces the table to clear the cache and request new data from the data provider.
|
|
87
|
+
*
|
|
88
|
+
* The value can be any string that is not equal to the previous value.
|
|
89
|
+
*/
|
|
90
|
+
dataLoadKey?: string;
|
|
91
|
+
/**
|
|
92
|
+
* Style Expression Property that controls the height property.
|
|
93
|
+
* Supports space tokens and all valid CSS width values.
|
|
94
|
+
*
|
|
95
|
+
* Sets the height of the table content area and enables vertical scrolling
|
|
96
|
+
* with a sticky header that remains visible.
|
|
97
|
+
*/
|
|
98
|
+
height?: string;
|
|
99
|
+
/**
|
|
100
|
+
* Sets the visual variant of the table container card.
|
|
101
|
+
* Forwards to the underlying `gds-card` component.
|
|
102
|
+
* Accepts: `primary`, `secondary` (default), `tertiary`.
|
|
103
|
+
*
|
|
104
|
+
* > Variant naming will change in the next major release.
|
|
105
|
+
*/
|
|
106
|
+
variant: 'primary' | 'secondary' | 'tertiary';
|
|
107
|
+
private _isMobile;
|
|
108
|
+
private _handleMobile;
|
|
109
|
+
private _view;
|
|
110
|
+
private _loaded;
|
|
111
|
+
private _loading;
|
|
112
|
+
private _rowsState;
|
|
113
|
+
private _total;
|
|
114
|
+
private _selected;
|
|
115
|
+
private _error;
|
|
116
|
+
private _onDataChange;
|
|
117
|
+
private _onColumnsChange;
|
|
118
|
+
connectedCallback(): void;
|
|
119
|
+
render(): any;
|
|
120
|
+
/**
|
|
121
|
+
* Public API
|
|
122
|
+
* Clear all selections
|
|
123
|
+
*/
|
|
124
|
+
clearSelection(): void;
|
|
125
|
+
/**
|
|
126
|
+
* Select all rows
|
|
127
|
+
*/
|
|
128
|
+
selectAll(): void;
|
|
129
|
+
/**
|
|
130
|
+
* Select specific rows by indices
|
|
131
|
+
*/
|
|
132
|
+
setSelection(indices: number[]): void;
|
|
133
|
+
/**
|
|
134
|
+
* Get selected row data
|
|
135
|
+
*/
|
|
136
|
+
getSelection(): {
|
|
137
|
+
indices: number[];
|
|
138
|
+
data: T[];
|
|
139
|
+
};
|
|
140
|
+
}
|