@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.
Files changed (34) hide show
  1. package/dist/.storybook/utilities.d.ts +1 -0
  2. package/dist/.storybook/utilities.js +22 -14
  3. package/dist/custom-elements.json +139 -0
  4. package/dist/index.d.ts +96 -0
  5. package/dist/packages/combobox/combobox.d.ts +5 -0
  6. package/dist/packages/combobox/combobox.js +12 -12
  7. package/dist/packages/combobox/combobox.js.map +3 -3
  8. package/dist/packages/combobox/combobox.stories.js +7 -7
  9. package/dist/packages/combobox/combobox.test.js +90 -0
  10. package/dist/packages/pagination/locales/da/messages.d.mts +1 -0
  11. package/dist/packages/pagination/locales/da/messages.mjs +1 -0
  12. package/dist/packages/pagination/locales/en/messages.d.mts +1 -0
  13. package/dist/packages/pagination/locales/en/messages.mjs +1 -0
  14. package/dist/packages/pagination/locales/fi/messages.d.mts +1 -0
  15. package/dist/packages/pagination/locales/fi/messages.mjs +1 -0
  16. package/dist/packages/pagination/locales/nb/messages.d.mts +1 -0
  17. package/dist/packages/pagination/locales/nb/messages.mjs +1 -0
  18. package/dist/packages/pagination/locales/sv/messages.d.mts +1 -0
  19. package/dist/packages/pagination/locales/sv/messages.mjs +1 -0
  20. package/dist/packages/pagination/pagination.d.ts +32 -0
  21. package/dist/packages/pagination/pagination.js +2503 -0
  22. package/dist/packages/pagination/pagination.js.map +7 -0
  23. package/dist/packages/pagination/pagination.react.stories.d.ts +21 -0
  24. package/dist/packages/pagination/pagination.react.stories.js +45 -0
  25. package/dist/packages/pagination/pagination.stories.d.ts +14 -0
  26. package/dist/packages/pagination/pagination.stories.js +56 -0
  27. package/dist/packages/pagination/pagination.test.d.ts +1 -0
  28. package/dist/packages/pagination/pagination.test.js +76 -0
  29. package/dist/packages/pagination/react.d.ts +5 -0
  30. package/dist/packages/pagination/react.js +15 -0
  31. package/dist/packages/pagination/styles.d.ts +1 -0
  32. package/dist/packages/pagination/styles.js +2 -0
  33. package/dist/web-types.json +40 -1
  34. package/package.json +5 -1
@@ -0,0 +1,76 @@
1
+ import { userEvent } from '@vitest/browser/context';
2
+ import { html } from 'lit';
3
+ import { expect, test, vi } from 'vitest';
4
+ import { render } from 'vitest-browser-lit';
5
+ import './pagination.js';
6
+ test('current page is the active page', async () => {
7
+ const component = html `<w-pagination current-page="5" pages="10" base-url="/page/"></w-pagination>`;
8
+ const page = render(component);
9
+ await expect.element(page.getByLabelText('Page 5')).toBeInTheDocument();
10
+ await expect.element(page.getByLabelText('Page 5')).toHaveAttribute('aria-current', 'page');
11
+ });
12
+ test('limits the number of displayed pages', async () => {
13
+ const component = html `<w-pagination current-page="10" pages="20" visible-pages="5" base-url="/page/"></w-pagination>`;
14
+ const page = render(component);
15
+ await expect.poll(() => page.getByRole('link').and(page.getByLabelText('Page ')).all()).toHaveLength(5);
16
+ });
17
+ test('shows link to first page if current page is page 3 or beyond', async () => {
18
+ const component = html `<w-pagination current-page="10" pages="20" base-url="/page/"></w-pagination>`;
19
+ const page = render(component);
20
+ await expect.poll(() => page.getByText('First page')).toBeInTheDocument();
21
+ });
22
+ test('does not show link to first page if current page is page 1 or 2', async () => {
23
+ for (let i = 1; i <= 2; i++) {
24
+ const component = html `<w-pagination current-page="${i}" pages="20" base-url="/page/"></w-pagination>`;
25
+ const page = render(component);
26
+ await expect.poll(() => page.getByText('First page').query()).not.toBeInTheDocument();
27
+ }
28
+ });
29
+ test('shows link to previous page if current page is page 2 or beyond', async () => {
30
+ const component = html `<w-pagination current-page="10" pages="20" base-url="/page/"></w-pagination>`;
31
+ const page = render(component);
32
+ await expect.poll(() => page.getByText('Previous page')).toBeInTheDocument();
33
+ });
34
+ test('does not show link to previous page if current page is the first page', async () => {
35
+ const component = html `<w-pagination current-page="1" pages="20" base-url="/page/"></w-pagination>`;
36
+ const page = render(component);
37
+ await expect.poll(() => page.getByText('Previous page').query()).not.toBeInTheDocument();
38
+ });
39
+ test('shows link to next page', async () => {
40
+ const component = html `<w-pagination current-page="15" pages="20" base-url="/page/"></w-pagination>`;
41
+ const page = render(component);
42
+ await expect.poll(() => page.getByText('Next page').query()).toBeInTheDocument();
43
+ });
44
+ test('does not show link to next page if current page is the last page', async () => {
45
+ const component = html `<w-pagination current-page="20" pages="20" base-url="/page/"></w-pagination>`;
46
+ const page = render(component);
47
+ await expect.poll(() => page.getByText('Next page').query()).not.toBeInTheDocument();
48
+ });
49
+ test('is able to get the correct data-page-number attribute from the element on click', async () => {
50
+ const component = html `<w-pagination current-page="15" pages="20" base-url="/page/" data-testid="pagination"></w-pagination>`;
51
+ const page = render(component);
52
+ await expect.poll(() => page.getByText('14').query()).toBeInTheDocument();
53
+ let clickedPage = null;
54
+ page
55
+ .getByTestId('pagination')
56
+ .element()
57
+ .addEventListener('click', (e) => {
58
+ e.preventDefault();
59
+ });
60
+ page
61
+ .getByTestId('pagination')
62
+ .element()
63
+ .addEventListener('page-click', (e) => {
64
+ clickedPage = e.detail.clickedPage;
65
+ });
66
+ const element = page.getByLabelText('page 14');
67
+ await userEvent.click(element);
68
+ await vi.waitFor(() => {
69
+ if (clickedPage === null) {
70
+ throw new Error('clickedPage was not set');
71
+ }
72
+ }, {
73
+ interval: 100,
74
+ });
75
+ expect(clickedPage).toEqual('14');
76
+ });
@@ -0,0 +1,5 @@
1
+ import { WarpPagination } from './pagination.js';
2
+ export declare const Pagination: import("@lit/react").ReactWebComponent<WarpPagination, {
3
+ onPageClick: string;
4
+ 'onpage-click': string;
5
+ }>;
@@ -0,0 +1,15 @@
1
+ import { createComponent } from '@lit/react';
2
+ import { LitElement } from 'lit';
3
+ import React from 'react';
4
+ // decouple from CDN by providing a dummy class
5
+ class Component extends LitElement {
6
+ }
7
+ export const Pagination = createComponent({
8
+ tagName: 'w-pagination',
9
+ elementClass: Component,
10
+ react: React,
11
+ events: {
12
+ onPageClick: 'page-click',
13
+ 'onpage-click': 'page-click',
14
+ },
15
+ });
@@ -0,0 +1 @@
1
+ export declare const styles: import("lit").CSSResult;
@@ -0,0 +1,2 @@
1
+ import { css } from 'lit';
2
+ export const styles = css `*,:before,:after{--w-rotate:0;--w-rotate-x:0;--w-rotate-y:0;--w-rotate-z:0;--w-scale-x:1;--w-scale-y:1;--w-scale-z:1;--w-skew-x:0;--w-skew-y:0;--w-translate-x:0;--w-translate-y:0;--w-translate-z:0}.hover\\:bg-clip-padding:hover{-webkit-background-clip:padding-box;background-clip:padding-box}.hover\\:bg-\\[--w-color-button-pill-background-hover\\]:hover{background-color:var(--w-color-button-pill-background-hover)}.active\\:bg-\\[--w-color-button-pill-background-active\\]:active{background-color:var(--w-color-button-pill-background-active)}.border-0{border-width:0}.rounded-full{border-radius:9999px}.block{display:block}.flex{display:flex}.inline-flex{display:inline-flex}.hidden{display:none}.hover\\:no-underline:hover,.focus\\:no-underline:focus{text-decoration:none}.focusable:focus{outline:2px solid var(--w-s-color-border-focus);outline-offset:var(--w-outline-offset,1px)}.focusable:focus-visible{outline:2px solid var(--w-s-color-border-focus);outline-offset:var(--w-outline-offset,1px)}.focusable:not(:focus-visible){outline:none}.items-center{align-items:center}.justify-center{justify-content:center}.static{position:static}.s-bg-primary{background-color:var(--w-s-color-background-primary)}.s-text-inverted{color:var(--w-s-color-text-inverted)}.s-text-link{color:var(--w-s-color-text-link)}.s-icon{color:var(--w-s-color-icon)}.min-h-\\[44px\\]{min-height:44px}.min-w-\\[44px\\]{min-width:44px}.p-4{padding:.4rem}.p-8{padding:.8rem}.visible{visibility:visible}.font-bold{font-weight:700}.pointer-events-none{pointer-events:none}.sr-only{clip:rect(0,0,0,0);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}@media (min-width:768px){.md\\:block{display:block}.md\\:hidden{display:none}}`;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
3
3
  "name": "@warp-ds/elements",
4
- "version": "2.5.0-next.2",
4
+ "version": "2.5.1-next.1",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
@@ -1134,6 +1134,45 @@
1134
1134
  ],
1135
1135
  "events": []
1136
1136
  }
1137
+ },
1138
+ {
1139
+ "name": "w-pagination",
1140
+ "description": "Pagination allows users to navigate through multiple pages of content by providing navigation controls with page numbers and directional arrows.\n\n[See Storybook for usage examples](https://warp-ds.github.io/elements/?path=/docs/navigation-pagination--docs)\n---\n\n\n### **Events:**\n - **page-click** - Triggered when a link button in the pagination is clicked. Contains the page number in `string` form.",
1141
+ "doc-url": "",
1142
+ "attributes": [
1143
+ { "name": "base-url", "value": { "type": "string" } },
1144
+ { "name": "pages", "value": { "type": "number" } },
1145
+ {
1146
+ "name": "current-page",
1147
+ "value": { "type": "number", "default": "1" }
1148
+ },
1149
+ {
1150
+ "name": "visible-pages",
1151
+ "value": { "type": "number", "default": "7" }
1152
+ }
1153
+ ],
1154
+ "events": [
1155
+ {
1156
+ "name": "page-click",
1157
+ "type": "CustomEvent",
1158
+ "description": "Triggered when a link button in the pagination is clicked. Contains the page number in `string` form."
1159
+ }
1160
+ ],
1161
+ "js": {
1162
+ "properties": [
1163
+ { "name": "baseUrl", "type": "string" },
1164
+ { "name": "pages", "type": "number" },
1165
+ { "name": "currentPageNumber", "type": "number" },
1166
+ { "name": "visiblePages", "type": "number" }
1167
+ ],
1168
+ "events": [
1169
+ {
1170
+ "name": "page-click",
1171
+ "type": "CustomEvent",
1172
+ "description": "Triggered when a link button in the pagination is clicked. Contains the page number in `string` form."
1173
+ }
1174
+ ]
1175
+ }
1137
1176
  }
1138
1177
  ]
1139
1178
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@warp-ds/elements",
3
3
  "type": "module",
4
- "version": "2.5.0",
4
+ "version": "2.5.1-next.2",
5
5
  "packageManager": "pnpm@10.20.0",
6
6
  "description": "Custom elements for Warp",
7
7
  "exports": {
@@ -117,6 +117,10 @@
117
117
  "types": "./dist/packages/page-indicator/react.d.ts",
118
118
  "import": "./dist/packages/page-indicator/react.js"
119
119
  },
120
+ "./react/pagination": {
121
+ "types": "./dist/packages/pagination/react.d.ts",
122
+ "import": "./dist/packages/pagination/react.js"
123
+ },
120
124
  "./react/*": {
121
125
  "types": "./dist/packages/*/react.d.ts",
122
126
  "import": "./dist/packages/*/react.js"