@warp-ds/elements 2.5.0 → 2.5.1-next.2
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/dist/.storybook/utilities.d.ts +1 -0
- package/dist/.storybook/utilities.js +22 -14
- package/dist/custom-elements.json +139 -0
- package/dist/index.d.ts +96 -0
- package/dist/packages/combobox/combobox.d.ts +5 -0
- package/dist/packages/combobox/combobox.js +12 -12
- package/dist/packages/combobox/combobox.js.map +3 -3
- package/dist/packages/combobox/combobox.stories.js +7 -7
- package/dist/packages/combobox/combobox.test.js +90 -0
- package/dist/packages/pagination/locales/da/messages.d.mts +1 -0
- package/dist/packages/pagination/locales/da/messages.mjs +1 -0
- package/dist/packages/pagination/locales/en/messages.d.mts +1 -0
- package/dist/packages/pagination/locales/en/messages.mjs +1 -0
- package/dist/packages/pagination/locales/fi/messages.d.mts +1 -0
- package/dist/packages/pagination/locales/fi/messages.mjs +1 -0
- package/dist/packages/pagination/locales/nb/messages.d.mts +1 -0
- package/dist/packages/pagination/locales/nb/messages.mjs +1 -0
- package/dist/packages/pagination/locales/sv/messages.d.mts +1 -0
- package/dist/packages/pagination/locales/sv/messages.mjs +1 -0
- package/dist/packages/pagination/pagination.d.ts +32 -0
- package/dist/packages/pagination/pagination.js +2503 -0
- package/dist/packages/pagination/pagination.js.map +7 -0
- package/dist/packages/pagination/pagination.react.stories.d.ts +21 -0
- package/dist/packages/pagination/pagination.react.stories.js +45 -0
- package/dist/packages/pagination/pagination.stories.d.ts +14 -0
- package/dist/packages/pagination/pagination.stories.js +56 -0
- package/dist/packages/pagination/pagination.test.d.ts +1 -0
- package/dist/packages/pagination/pagination.test.js +76 -0
- package/dist/packages/pagination/react.d.ts +5 -0
- package/dist/packages/pagination/react.js +15 -0
- package/dist/packages/pagination/styles.d.ts +1 -0
- package/dist/packages/pagination/styles.js +2 -0
- package/dist/web-types.json +40 -1
- package/package.json +5 -1
|
@@ -26,13 +26,13 @@ const meta = {
|
|
|
26
26
|
};
|
|
27
27
|
export default meta;
|
|
28
28
|
const sampleOptions = [
|
|
29
|
-
{ value: '
|
|
30
|
-
{ value: '
|
|
31
|
-
{ value: '
|
|
32
|
-
{ value: '
|
|
33
|
-
{ value: '
|
|
34
|
-
{ value: '
|
|
35
|
-
{ value: '
|
|
29
|
+
{ value: 'apple', label: 'Apple' },
|
|
30
|
+
{ value: 'banana', label: 'Banana' },
|
|
31
|
+
{ value: 'orange', label: 'Orange' },
|
|
32
|
+
{ value: 'grape', label: 'Grape' },
|
|
33
|
+
{ value: 'strawberry', label: 'Strawberry' },
|
|
34
|
+
{ value: 'pineapple', label: 'Pineapple' },
|
|
35
|
+
{ value: 'mango', label: 'Mango' },
|
|
36
36
|
];
|
|
37
37
|
export const Default = {
|
|
38
38
|
args: {},
|
|
@@ -19,3 +19,93 @@ test('renders with autocomplete attribute when provided', async () => {
|
|
|
19
19
|
const el = (await locator.element());
|
|
20
20
|
expect(el.getAttribute('autocomplete')).toBe('on');
|
|
21
21
|
});
|
|
22
|
+
test('displays initial value correctly when value prop is set', async () => {
|
|
23
|
+
const options = [
|
|
24
|
+
{ value: 'apple', label: 'Apple' },
|
|
25
|
+
{ value: 'banana', label: 'Banana' },
|
|
26
|
+
];
|
|
27
|
+
const component = html `<w-combobox
|
|
28
|
+
data-testid="combobox"
|
|
29
|
+
value="apple"
|
|
30
|
+
.options="${options}"
|
|
31
|
+
></w-combobox>`;
|
|
32
|
+
const page = render(component);
|
|
33
|
+
const locator = page.getByTestId('combobox');
|
|
34
|
+
await expect.element(locator).toBeVisible();
|
|
35
|
+
const el = (await locator.element());
|
|
36
|
+
// Get the textfield's input element
|
|
37
|
+
const textfield = el.shadowRoot?.querySelector('w-textfield');
|
|
38
|
+
const input = textfield?.shadowRoot?.querySelector('input');
|
|
39
|
+
// Verify the displayed text shows the label "Apple", not the value "apple"
|
|
40
|
+
expect(input?.value).toBe('Apple');
|
|
41
|
+
// Verify the combobox value is "apple"
|
|
42
|
+
expect(el.value).toBe('apple');
|
|
43
|
+
});
|
|
44
|
+
test('filters options by label, not value', async () => {
|
|
45
|
+
const options = [
|
|
46
|
+
{ value: 'us', label: 'United States' },
|
|
47
|
+
{ value: 'uk', label: 'United Kingdom' },
|
|
48
|
+
{ value: 'no', label: 'Norway' },
|
|
49
|
+
];
|
|
50
|
+
const component = html `<w-combobox
|
|
51
|
+
data-testid="combobox"
|
|
52
|
+
open-on-focus
|
|
53
|
+
.options="${options}"
|
|
54
|
+
></w-combobox>`;
|
|
55
|
+
const page = render(component);
|
|
56
|
+
const locator = page.getByTestId('combobox');
|
|
57
|
+
await expect.element(locator).toBeVisible();
|
|
58
|
+
const el = (await locator.element());
|
|
59
|
+
// Get the textfield's input element
|
|
60
|
+
const textfield = el.shadowRoot?.querySelector('w-textfield');
|
|
61
|
+
const input = textfield?.shadowRoot?.querySelector('input');
|
|
62
|
+
// Type "United" which should match labels "United States" and "United Kingdom"
|
|
63
|
+
// but NOT match any values (us, uk, no)
|
|
64
|
+
input?.focus();
|
|
65
|
+
input.value = 'United';
|
|
66
|
+
input.dispatchEvent(new InputEvent('input', { bubbles: true, composed: true }));
|
|
67
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
68
|
+
// Check that the dropdown shows the matching options
|
|
69
|
+
const listbox = el.shadowRoot?.querySelector('[role="listbox"]');
|
|
70
|
+
const visibleOptions = listbox?.querySelectorAll('[role="option"]');
|
|
71
|
+
// Should show 2 options: "United States" and "United Kingdom"
|
|
72
|
+
expect(visibleOptions?.length).toBe(2);
|
|
73
|
+
const optionTexts = Array.from(visibleOptions || []).map((opt) => opt.textContent?.trim());
|
|
74
|
+
expect(optionTexts).toContain('United States');
|
|
75
|
+
expect(optionTexts).toContain('United Kingdom');
|
|
76
|
+
expect(optionTexts).not.toContain('Norway');
|
|
77
|
+
});
|
|
78
|
+
test('displays option label in textfield but stores option value', async () => {
|
|
79
|
+
const optionsWithDifferentLabelAndValue = [
|
|
80
|
+
{ value: 'us', label: 'United States' },
|
|
81
|
+
{ value: 'uk', label: 'United Kingdom' },
|
|
82
|
+
{ value: 'no', label: 'Norway' },
|
|
83
|
+
];
|
|
84
|
+
const component = html `<w-combobox
|
|
85
|
+
data-testid="combobox"
|
|
86
|
+
open-on-focus
|
|
87
|
+
.options="${optionsWithDifferentLabelAndValue}"
|
|
88
|
+
></w-combobox>`;
|
|
89
|
+
const page = render(component);
|
|
90
|
+
const locator = page.getByTestId('combobox');
|
|
91
|
+
await expect.element(locator).toBeVisible();
|
|
92
|
+
const el = (await locator.element());
|
|
93
|
+
// Get the textfield's input element
|
|
94
|
+
const textfield = el.shadowRoot?.querySelector('w-textfield');
|
|
95
|
+
const input = textfield?.shadowRoot?.querySelector('input');
|
|
96
|
+
// Focus to open the dropdown
|
|
97
|
+
input?.focus();
|
|
98
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
99
|
+
// Find and click the "Norway" option (which has value "no")
|
|
100
|
+
const listbox = el.shadowRoot?.querySelector('[role="listbox"]');
|
|
101
|
+
const options = listbox?.querySelectorAll('[role="option"]');
|
|
102
|
+
const norwayOption = Array.from(options || []).find((opt) => opt.textContent?.trim() === 'Norway');
|
|
103
|
+
expect(norwayOption).toBeDefined();
|
|
104
|
+
// Simulate mousedown on the option
|
|
105
|
+
norwayOption?.dispatchEvent(new MouseEvent('mousedown', { bubbles: true }));
|
|
106
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
107
|
+
// Verify the displayed text is the label "Norway", not the value "no"
|
|
108
|
+
expect(input?.value).toBe('Norway');
|
|
109
|
+
// Verify the combobox value is "no", not "Norway"
|
|
110
|
+
expect(el.value).toBe('no');
|
|
111
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const messages: any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*eslint-disable*/ export const messages = JSON.parse("{\"pagination.aria.first-page\":[\"Første side\"],\"pagination.aria.icon-suffix\":[\"ikon\"],\"pagination.aria.next-page\":[\"Næste side\"],\"pagination.aria.page\":[\"Side \",[\"currentPage\"]],\"pagination.aria.pagination\":[\"Sider\"],\"pagination.aria.prev-page\":[\"Forrige side\"]}");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const messages: any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*eslint-disable*/ export const messages = JSON.parse("{\"pagination.aria.first-page\":[\"First page\"],\"pagination.aria.icon-suffix\":[\"icon\"],\"pagination.aria.next-page\":[\"Next page\"],\"pagination.aria.page\":[\"Page \",[\"currentPage\"]],\"pagination.aria.pagination\":[\"Pages\"],\"pagination.aria.prev-page\":[\"Previous page\"]}");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const messages: any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*eslint-disable*/ export const messages = JSON.parse("{\"pagination.aria.first-page\":[\"Ensimmäinen sivu\"],\"pagination.aria.icon-suffix\":[\"kuvake\"],\"pagination.aria.next-page\":[\"Seuraava sivu\"],\"pagination.aria.page\":[\"Sivu \",[\"currentPage\"]],\"pagination.aria.pagination\":[\"Sivut\"],\"pagination.aria.prev-page\":[\"Edellinen sivu\"]}");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const messages: any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*eslint-disable*/ export const messages = JSON.parse("{\"pagination.aria.first-page\":[\"Første side\"],\"pagination.aria.icon-suffix\":[\"ikon\"],\"pagination.aria.next-page\":[\"Neste side\"],\"pagination.aria.page\":[\"Side \",[\"currentPage\"]],\"pagination.aria.pagination\":[\"Sider\"],\"pagination.aria.prev-page\":[\"Forrige side\"]}");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const messages: any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*eslint-disable*/ export const messages = JSON.parse("{\"pagination.aria.first-page\":[\"Första sidan\"],\"pagination.aria.icon-suffix\":[\"ikon\"],\"pagination.aria.next-page\":[\"Nästa sida\"],\"pagination.aria.page\":[\"Sida \",[\"currentPage\"]],\"pagination.aria.pagination\":[\"Sidor\"],\"pagination.aria.prev-page\":[\"Föregående sida\"]}");
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import '@warp-ds/icons/elements/chevron-double-left-16';
|
|
3
|
+
import '@warp-ds/icons/elements/chevron-left-16';
|
|
4
|
+
import '@warp-ds/icons/elements/chevron-right-16';
|
|
5
|
+
/**
|
|
6
|
+
* Pagination allows users to navigate through multiple pages of content by providing navigation controls with page numbers and directional arrows.
|
|
7
|
+
*
|
|
8
|
+
* [See Storybook for usage examples](https://warp-ds.github.io/elements/?path=/docs/navigation-pagination--docs)
|
|
9
|
+
*
|
|
10
|
+
* @fires {CustomEvent} page-click - Triggered when a link button in the pagination is clicked. Contains the page number in `string` form.
|
|
11
|
+
*/
|
|
12
|
+
declare class WarpPagination extends LitElement {
|
|
13
|
+
#private;
|
|
14
|
+
baseUrl: string;
|
|
15
|
+
pages: number;
|
|
16
|
+
currentPageNumber: number;
|
|
17
|
+
visiblePages: number;
|
|
18
|
+
static styles: import("lit").CSSResult[];
|
|
19
|
+
constructor();
|
|
20
|
+
/** @internal */
|
|
21
|
+
get shouldShowShowFirstPageButton(): boolean;
|
|
22
|
+
/** @internal */
|
|
23
|
+
get shouldShowPreviousPageButton(): boolean;
|
|
24
|
+
/** @internal */
|
|
25
|
+
get shouldShowNextPageButton(): boolean;
|
|
26
|
+
/** @internal */
|
|
27
|
+
get currentPageIndex(): number;
|
|
28
|
+
/** @internal */
|
|
29
|
+
get visiblePageNumbers(): number[];
|
|
30
|
+
render(): import("lit").TemplateResult<1>;
|
|
31
|
+
}
|
|
32
|
+
export { WarpPagination };
|