@warp-ds/elements 2.6.0-next.4 → 2.6.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/dist/custom-elements.json +145 -143
- package/dist/index.d.ts +52 -52
- package/dist/packages/affix/affix.d.ts +1 -2
- package/dist/packages/affix/affix.js +35 -19
- package/dist/packages/affix/affix.js.map +4 -4
- package/dist/packages/alert/alert.d.ts +2 -5
- package/dist/packages/alert/alert.js +32 -16
- package/dist/packages/alert/alert.js.map +4 -4
- package/dist/packages/alert/alert.test.js +1 -3
- package/dist/packages/attention/attention.d.ts +2 -2
- package/dist/packages/attention/attention.js +53 -26
- package/dist/packages/attention/attention.js.map +4 -4
- package/dist/packages/button/button.react.stories.d.ts +1 -1
- package/dist/packages/button/button.stories.d.ts +1 -4
- package/dist/packages/button/button.stories.js +11 -16
- package/dist/packages/card/card.d.ts +1 -1
- package/dist/packages/combobox/combobox.react.stories.d.ts +1 -1
- package/dist/packages/datepicker/datepicker.d.ts +1 -3
- package/dist/packages/datepicker/datepicker.js +66 -41
- package/dist/packages/datepicker/datepicker.js.map +4 -4
- package/dist/packages/datepicker/datepicker.react.stories.d.ts +1 -1
- package/dist/packages/expandable/expandable.d.ts +1 -2
- package/dist/packages/expandable/expandable.js +39 -23
- package/dist/packages/expandable/expandable.js.map +4 -4
- package/dist/packages/icon/icon.js +2 -2
- package/dist/packages/icon/icon.js.map +4 -4
- package/dist/packages/icon/icon.react.stories.js +274 -2
- package/dist/packages/icon/icon.stories.js +273 -1
- package/dist/packages/link/link.react.stories.d.ts +1 -1
- package/dist/packages/modal-header/modal-header.d.ts +1 -2
- package/dist/packages/modal-header/modal-header.js +39 -14
- package/dist/packages/modal-header/modal-header.js.map +4 -4
- package/dist/packages/page-indicator/page-indicator.test.js +40 -20
- package/dist/packages/pagination/pagination.a11y.test.d.ts +1 -0
- package/dist/packages/pagination/pagination.a11y.test.js +36 -0
- package/dist/packages/pagination/pagination.d.ts +1 -3
- package/dist/packages/pagination/pagination.js +57 -34
- package/dist/packages/pagination/pagination.js.map +4 -4
- package/dist/packages/pill/pill.d.ts +1 -1
- package/dist/packages/pill/pill.js +38 -13
- package/dist/packages/pill/pill.js.map +4 -4
- package/dist/packages/pill/pill.test.js +1 -3
- package/dist/packages/select/select.d.ts +1 -1
- package/dist/packages/select/select.js +44 -19
- package/dist/packages/select/select.js.map +4 -4
- package/dist/packages/select/select.react.stories.d.ts +1 -1
- package/dist/packages/step/step.d.ts +1 -1
- package/dist/packages/step/step.js +38 -13
- package/dist/packages/step/step.js.map +4 -4
- package/dist/packages/step-indicator/step-indicator.a11y.test.d.ts +2 -0
- package/dist/packages/step-indicator/step-indicator.a11y.test.js +66 -0
- package/dist/packages/textarea/textarea.a11y.test.d.ts +1 -0
- package/dist/packages/textarea/textarea.a11y.test.js +115 -0
- package/dist/packages/textarea/textarea.js +6 -6
- package/dist/packages/textarea/textarea.js.map +4 -4
- package/dist/packages/textarea/textarea.react.stories.d.ts +1 -1
- package/dist/packages/textarea/textarea.test.js +3 -1
- package/dist/packages/textfield/textfield.react.stories.d.ts +1 -1
- package/dist/packages/toast/toast.d.ts +1 -4
- package/dist/packages/toast/toast.js +38 -13
- package/dist/packages/toast/toast.js.map +4 -4
- package/dist/setup-tests.d.ts +10 -0
- package/dist/setup-tests.js +61 -0
- package/dist/web-types.json +47 -47
- package/package.json +2 -2
|
@@ -5,18 +5,22 @@ import './page-indicator.js';
|
|
|
5
5
|
test('renders the correct number of dots', async () => {
|
|
6
6
|
const component = html `<w-page-indicator page-count="5" selected-page="1"></w-page-indicator>`;
|
|
7
7
|
const page = render(component);
|
|
8
|
-
await expect
|
|
8
|
+
await expect
|
|
9
|
+
.poll(() => {
|
|
9
10
|
const element = page.container.querySelector('w-page-indicator');
|
|
10
11
|
return element?.shadowRoot?.querySelectorAll('.w-page-indicator--dot').length;
|
|
11
|
-
})
|
|
12
|
+
})
|
|
13
|
+
.toBe(5);
|
|
12
14
|
});
|
|
13
15
|
test('renders a single dot when page-count is 1', async () => {
|
|
14
16
|
const component = html `<w-page-indicator page-count="1" selected-page="1"></w-page-indicator>`;
|
|
15
17
|
const page = render(component);
|
|
16
|
-
await expect
|
|
18
|
+
await expect
|
|
19
|
+
.poll(() => {
|
|
17
20
|
const element = page.container.querySelector('w-page-indicator');
|
|
18
21
|
return element?.shadowRoot?.querySelectorAll('.w-page-indicator--dot').length;
|
|
19
|
-
})
|
|
22
|
+
})
|
|
23
|
+
.toBe(1);
|
|
20
24
|
});
|
|
21
25
|
test('has aria-label on the container', async () => {
|
|
22
26
|
const component = html `<w-page-indicator page-count="5" selected-page="3"></w-page-indicator>`;
|
|
@@ -27,75 +31,91 @@ test('has aria-label on the container', async () => {
|
|
|
27
31
|
test('marks the selected dot with correct class', async () => {
|
|
28
32
|
const component = html `<w-page-indicator page-count="5" selected-page="2"></w-page-indicator>`;
|
|
29
33
|
const page = render(component);
|
|
30
|
-
await expect
|
|
34
|
+
await expect
|
|
35
|
+
.poll(() => {
|
|
31
36
|
const element = page.container.querySelector('w-page-indicator');
|
|
32
37
|
const dots = element?.shadowRoot?.querySelectorAll('.w-page-indicator--dot');
|
|
33
38
|
const selectedDots = element?.shadowRoot?.querySelectorAll('.w-page-indicator--selecteddot');
|
|
34
39
|
return dots?.length === 5 && selectedDots?.length === 1;
|
|
35
|
-
})
|
|
40
|
+
})
|
|
41
|
+
.toBe(true);
|
|
36
42
|
});
|
|
37
43
|
test('selected dot is at correct position', async () => {
|
|
38
44
|
const component = html `<w-page-indicator page-count="3" selected-page="2"></w-page-indicator>`;
|
|
39
45
|
const page = render(component);
|
|
40
|
-
await expect
|
|
46
|
+
await expect
|
|
47
|
+
.poll(() => {
|
|
41
48
|
const element = page.container.querySelector('w-page-indicator');
|
|
42
49
|
const dots = element?.shadowRoot?.querySelectorAll('.w-page-indicator--dot');
|
|
43
50
|
return dots?.[1]?.classList.contains('w-page-indicator--selecteddot');
|
|
44
|
-
})
|
|
51
|
+
})
|
|
52
|
+
.toBe(true);
|
|
45
53
|
});
|
|
46
54
|
test('validates page-count to minimum of 1', async () => {
|
|
47
55
|
const component = html `<w-page-indicator page-count="0" selected-page="1"></w-page-indicator>`;
|
|
48
56
|
const page = render(component);
|
|
49
|
-
await expect
|
|
57
|
+
await expect
|
|
58
|
+
.poll(() => {
|
|
50
59
|
const element = page.container.querySelector('w-page-indicator');
|
|
51
60
|
return element?.shadowRoot?.querySelectorAll('.w-page-indicator--dot').length;
|
|
52
|
-
})
|
|
61
|
+
})
|
|
62
|
+
.toBe(1);
|
|
53
63
|
});
|
|
54
64
|
test('validates page-count for negative values', async () => {
|
|
55
65
|
const component = html `<w-page-indicator page-count="-5" selected-page="1"></w-page-indicator>`;
|
|
56
66
|
const page = render(component);
|
|
57
|
-
await expect
|
|
67
|
+
await expect
|
|
68
|
+
.poll(() => {
|
|
58
69
|
const element = page.container.querySelector('w-page-indicator');
|
|
59
70
|
return element?.shadowRoot?.querySelectorAll('.w-page-indicator--dot').length;
|
|
60
|
-
})
|
|
71
|
+
})
|
|
72
|
+
.toBe(1);
|
|
61
73
|
});
|
|
62
74
|
test('clamps selected-page to valid range (too high)', async () => {
|
|
63
75
|
const component = html `<w-page-indicator page-count="3" selected-page="10"></w-page-indicator>`;
|
|
64
76
|
const page = render(component);
|
|
65
77
|
// Should clamp to page 3 (the max) - verify selected dot is at position 3 (index 2)
|
|
66
|
-
await expect
|
|
78
|
+
await expect
|
|
79
|
+
.poll(() => {
|
|
67
80
|
const element = page.container.querySelector('w-page-indicator');
|
|
68
81
|
const dots = element?.shadowRoot?.querySelectorAll('.w-page-indicator--dot');
|
|
69
82
|
return dots?.[2]?.classList.contains('w-page-indicator--selecteddot');
|
|
70
|
-
})
|
|
83
|
+
})
|
|
84
|
+
.toBe(true);
|
|
71
85
|
});
|
|
72
86
|
test('clamps selected-page to valid range (too low)', async () => {
|
|
73
87
|
const component = html `<w-page-indicator page-count="3" selected-page="0"></w-page-indicator>`;
|
|
74
88
|
const page = render(component);
|
|
75
89
|
// Should clamp to page 1 (the min) - verify selected dot is at position 1 (index 0)
|
|
76
|
-
await expect
|
|
90
|
+
await expect
|
|
91
|
+
.poll(() => {
|
|
77
92
|
const element = page.container.querySelector('w-page-indicator');
|
|
78
93
|
const dots = element?.shadowRoot?.querySelectorAll('.w-page-indicator--dot');
|
|
79
94
|
return dots?.[0]?.classList.contains('w-page-indicator--selecteddot');
|
|
80
|
-
})
|
|
95
|
+
})
|
|
96
|
+
.toBe(true);
|
|
81
97
|
});
|
|
82
98
|
test('handles decimal page-count by flooring', async () => {
|
|
83
99
|
const component = html `<w-page-indicator page-count="3.7" selected-page="1"></w-page-indicator>`;
|
|
84
100
|
const page = render(component);
|
|
85
|
-
await expect
|
|
101
|
+
await expect
|
|
102
|
+
.poll(() => {
|
|
86
103
|
const element = page.container.querySelector('w-page-indicator');
|
|
87
104
|
return element?.shadowRoot?.querySelectorAll('.w-page-indicator--dot').length;
|
|
88
|
-
})
|
|
105
|
+
})
|
|
106
|
+
.toBe(3);
|
|
89
107
|
});
|
|
90
108
|
test('handles decimal selected-page by flooring', async () => {
|
|
91
109
|
const component = html `<w-page-indicator page-count="5" selected-page="2.9"></w-page-indicator>`;
|
|
92
110
|
const page = render(component);
|
|
93
111
|
// Should floor to page 2 - verify selected dot is at position 2 (index 1)
|
|
94
|
-
await expect
|
|
112
|
+
await expect
|
|
113
|
+
.poll(() => {
|
|
95
114
|
const element = page.container.querySelector('w-page-indicator');
|
|
96
115
|
const dots = element?.shadowRoot?.querySelectorAll('.w-page-indicator--dot');
|
|
97
116
|
return dots?.[1]?.classList.contains('w-page-indicator--selecteddot');
|
|
98
|
-
})
|
|
117
|
+
})
|
|
118
|
+
.toBe(true);
|
|
99
119
|
});
|
|
100
120
|
test('updates when selected-page changes', async () => {
|
|
101
121
|
const container = document.createElement('div');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './pagination.js';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
import { describe, expect, test } from 'vitest';
|
|
3
|
+
import { render } from 'vitest-browser-lit';
|
|
4
|
+
import './pagination.js';
|
|
5
|
+
describe('w-pagination accessibility (WCAG 2.2)', () => {
|
|
6
|
+
describe('axe-core automated checks', () => {
|
|
7
|
+
test('default state has no violations', async () => {
|
|
8
|
+
const page = render(html `<w-pagination current-page="5" pages="10" base-url="/page/"></w-pagination>`);
|
|
9
|
+
await expect(page).toHaveNoAxeViolations();
|
|
10
|
+
});
|
|
11
|
+
test('first page (no first or previous links) has no violations', async () => {
|
|
12
|
+
const page = render(html `<w-pagination current-page="1" pages="10" base-url="/page/"></w-pagination>`);
|
|
13
|
+
await expect(page).toHaveNoAxeViolations();
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
describe('WCAG 1.3.1 - Info and Relationships', () => {
|
|
17
|
+
test('page links expose accessible names', async () => {
|
|
18
|
+
const page = render(html `<w-pagination current-page="3" pages="5" base-url="/page/"></w-pagination>`);
|
|
19
|
+
await expect.element(page.getByRole('link', { name: 'Page 3' })).toBeVisible();
|
|
20
|
+
await expect.element(page.getByRole('link', { name: 'Page 2' })).toBeVisible();
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
describe('WCAG 4.1.2 - Name, Role, Value', () => {
|
|
24
|
+
test('current page is exposed via aria-current', async () => {
|
|
25
|
+
const page = render(html `<w-pagination current-page="4" pages="8" base-url="/page/"></w-pagination>`);
|
|
26
|
+
await expect.element(page.getByRole('link', { name: 'Page 4' })).toHaveAttribute('aria-current', 'page');
|
|
27
|
+
await expect.element(page.getByRole('link', { name: 'Page 3' })).not.toHaveAttribute('aria-current', 'page');
|
|
28
|
+
});
|
|
29
|
+
test('navigation controls have accessible names', async () => {
|
|
30
|
+
const page = render(html `<w-pagination current-page="4" pages="8" base-url="/page/"></w-pagination>`);
|
|
31
|
+
await expect.element(page.getByRole('link', { name: 'First page' })).toBeVisible();
|
|
32
|
+
await expect.element(page.getByRole('link', { name: 'Previous page' })).toBeVisible();
|
|
33
|
+
await expect.element(page.getByRole('link', { name: 'Next page' })).toBeVisible();
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
|
-
import '
|
|
3
|
-
import '@warp-ds/icons/elements/chevron-left-16';
|
|
4
|
-
import '@warp-ds/icons/elements/chevron-right-16';
|
|
2
|
+
import '../icon/icon.js';
|
|
5
3
|
/**
|
|
6
4
|
* Pagination allows users to navigate through multiple pages of content by providing navigation controls with page numbers and directional arrows.
|
|
7
5
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var
|
|
2
|
-
`],["r","\r"],["t"," "],["v","\v"],["0","\0"]]);function
|
|
1
|
+
var ke=Object.create;var F=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var ye=Object.getOwnPropertyNames;var _e=Object.getPrototypeOf,ze=Object.prototype.hasOwnProperty;var B=o=>{throw TypeError(o)};var G=(o,e)=>()=>(e||o((e={exports:{}}).exports,e),e.exports);var Pe=(o,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of ye(e))!ze.call(o,a)&&a!==r&&F(o,a,{get:()=>e[a],enumerable:!(t=q(e,a))||t.enumerable});return o};var Me=(o,e,r)=>(r=o!=null?ke(_e(o)):{},Pe(e||!o||!o.__esModule?F(r,"default",{value:o,enumerable:!0}):r,o));var g=(o,e,r,t)=>{for(var a=t>1?void 0:t?q(e,r):e,s=o.length-1,i;s>=0;s--)(i=o[s])&&(a=(t?i(e,r,a):i(a))||a);return t&&a&&F(e,r,a),a};var Se=(o,e,r)=>e.has(o)||B("Cannot "+r);var J=(o,e,r)=>e.has(o)?B("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(o):e.set(o,r);var V=(o,e,r)=>(Se(o,e,"access private method"),r);var K=G(w=>{"use strict";Object.defineProperty(w,"__esModule",{value:!0});w.errorMessages=w.ErrorType=void 0;var k;(function(o){o.MalformedUnicode="MALFORMED_UNICODE",o.MalformedHexadecimal="MALFORMED_HEXADECIMAL",o.CodePointLimit="CODE_POINT_LIMIT",o.OctalDeprecation="OCTAL_DEPRECATION",o.EndOfString="END_OF_STRING"})(k=w.ErrorType||(w.ErrorType={}));w.errorMessages=new Map([[k.MalformedUnicode,"malformed Unicode character escape sequence"],[k.MalformedHexadecimal,"malformed hexadecimal character escape sequence"],[k.CodePointLimit,"Unicode codepoint must not be greater than 0x10FFFF in escape sequence"],[k.OctalDeprecation,'"0"-prefixed octal literals and octal escape sequences are deprecated; for octal literals use the "0o" prefix instead'],[k.EndOfString,"malformed escape sequence at end of string"]])});var ee=G(b=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0});b.unraw=b.errorMessages=b.ErrorType=void 0;var l=K();Object.defineProperty(b,"ErrorType",{enumerable:!0,get:function(){return l.ErrorType}});Object.defineProperty(b,"errorMessages",{enumerable:!0,get:function(){return l.errorMessages}});function Ee(o){return!o.match(/[^a-f0-9]/i)?parseInt(o,16):NaN}function M(o,e,r){let t=Ee(o);if(Number.isNaN(t)||r!==void 0&&r!==o.length)throw new SyntaxError(l.errorMessages.get(e));return t}function Ce(o){let e=M(o,l.ErrorType.MalformedHexadecimal,2);return String.fromCharCode(e)}function Q(o,e){let r=M(o,l.ErrorType.MalformedUnicode,4);if(e!==void 0){let t=M(e,l.ErrorType.MalformedUnicode,4);return String.fromCharCode(r,t)}return String.fromCharCode(r)}function $e(o){return o.charAt(0)==="{"&&o.charAt(o.length-1)==="}"}function Ne(o){if(!$e(o))throw new SyntaxError(l.errorMessages.get(l.ErrorType.MalformedUnicode));let e=o.slice(1,-1),r=M(e,l.ErrorType.MalformedUnicode);try{return String.fromCodePoint(r)}catch(t){throw t instanceof RangeError?new SyntaxError(l.errorMessages.get(l.ErrorType.CodePointLimit)):t}}function Le(o,e=!1){if(e)throw new SyntaxError(l.errorMessages.get(l.ErrorType.OctalDeprecation));let r=parseInt(o,8);return String.fromCharCode(r)}var Oe=new Map([["b","\b"],["f","\f"],["n",`
|
|
2
|
+
`],["r","\r"],["t"," "],["v","\v"],["0","\0"]]);function Fe(o){return Oe.get(o)||o}var De=/\\(?:(\\)|x([\s\S]{0,2})|u(\{[^}]*\}?)|u([\s\S]{4})\\u([^{][\s\S]{0,3})|u([\s\S]{0,4})|([0-3]?[0-7]{1,2})|([\s\S])|$)/g;function W(o,e=!1){return o.replace(De,function(r,t,a,s,i,n,c,p,v){if(t!==void 0)return"\\";if(a!==void 0)return Ce(a);if(s!==void 0)return Ne(s);if(i!==void 0)return Q(i,n);if(c!==void 0)return Q(c);if(p==="0")return"\0";if(p!==void 0)return Le(p,!e);if(v!==void 0)return Fe(v);throw new SyntaxError(l.errorMessages.get(l.ErrorType.EndOfString))})}b.unraw=W;b.default=W});var te=Me(ee(),1);var u=o=>typeof o=="string",Te=o=>typeof o=="function",re=new Map,ae="en";function Y(o){return[...Array.isArray(o)?o:[o],ae]}function A(o,e,r){let t=Y(o);r||(r="default");let a;if(typeof r=="string")switch(a={day:"numeric",month:"short",year:"numeric"},r){case"full":a.weekday="long";case"long":a.month="long";break;case"short":a.month="numeric";break}else a=r;return S(()=>E("date",t,r),()=>new Intl.DateTimeFormat(t,a)).format(u(e)?new Date(e):e)}function je(o,e,r){let t;if(r||(r="default"),typeof r=="string")switch(t={second:"numeric",minute:"numeric",hour:"numeric"},r){case"full":case"long":t.timeZoneName="short";break;case"short":delete t.second}else t=r;return A(o,e,t)}function D(o,e,r){let t=Y(o);return S(()=>E("number",t,r),()=>new Intl.NumberFormat(t,r)).format(e)}function oe(o,e,r,{offset:t=0,...a}){var n,c;let s=Y(o),i=e?S(()=>E("plural-ordinal",s),()=>new Intl.PluralRules(s,{type:"ordinal"})):S(()=>E("plural-cardinal",s),()=>new Intl.PluralRules(s,{type:"cardinal"}));return(c=(n=a[r])!=null?n:a[i.select(r-t)])!=null?c:a.other}function S(o,e){let r=o(),t=re.get(r);return t||(t=e(),re.set(r,t)),t}function E(o,e,r){let t=e.join("-");return`${o}-${t}-${JSON.stringify(r)}`}var ie=/\\u[a-fA-F0-9]{4}|\\x[a-fA-F0-9]{2}/,ne="%__lingui_octothorpe__%",Ye=(o,e,r={})=>{let t=e||o,a=i=>typeof i=="object"?i:r[i],s=(i,n)=>{let c=Object.keys(r).length?a("number"):void 0,p=D(t,i,c);return n.replace(new RegExp(ne,"g"),p)};return{plural:(i,n)=>{let{offset:c=0}=n,p=oe(t,!1,i,n);return s(i-c,p)},selectordinal:(i,n)=>{let{offset:c=0}=n,p=oe(t,!0,i,n);return s(i-c,p)},select:Ae,number:(i,n)=>D(t,i,a(n)||{style:n}),date:(i,n)=>A(t,i,a(n)||n),time:(i,n)=>je(t,i,a(n)||n)}},Ae=(o,e)=>{var r;return(r=e[o])!=null?r:e.other};function Ie(o,e,r){return(t={},a)=>{let s=Ye(e,r,a),i=(c,p=!1)=>Array.isArray(c)?c.reduce((v,z)=>{if(z==="#"&&p)return v+ne;if(u(z))return v+z;let[Z,f,H]=z,L={};f==="plural"||f==="selectordinal"||f==="select"?Object.entries(H).forEach(([O,xe])=>{L[O]=i(xe,f==="plural"||f==="selectordinal")}):L=H;let P;if(f){let O=s[f];P=O(t[Z],L)}else P=t[Z];return P==null?v:v+P},""):c,n=i(o);return u(n)&&ie.test(n)?(0,te.unraw)(n):u(n)?n:n?String(n):""}}var Re=Object.defineProperty,Ue=(o,e,r)=>e in o?Re(o,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[e]=r,Xe=(o,e,r)=>(Ue(o,typeof e!="symbol"?e+"":e,r),r),T=class{constructor(){Xe(this,"_events",{})}on(e,r){var a;var t;return(a=(t=this._events)[e])!=null||(t[e]=[]),this._events[e].push(r),()=>this.removeListener(e,r)}removeListener(e,r){let t=this._getListeners(e);if(!t)return;let a=t.indexOf(r);~a&&t.splice(a,1)}emit(e,...r){let t=this._getListeners(e);t&&t.map(a=>a.apply(this,r))}_getListeners(e){let r=this._events[e];return Array.isArray(r)?r:!1}},Ze=Object.defineProperty,He=(o,e,r)=>e in o?Ze(o,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[e]=r,x=(o,e,r)=>(He(o,typeof e!="symbol"?e+"":e,r),r),j=class extends T{constructor(e){var r;super(),x(this,"_locale",""),x(this,"_locales"),x(this,"_localeData",{}),x(this,"_messages",{}),x(this,"_missing"),x(this,"_messageCompiler"),x(this,"t",this._.bind(this)),e.missing!=null&&(this._missing=e.missing),e.messages!=null&&this.load(e.messages),e.localeData!=null&&this.loadLocaleData(e.localeData),(typeof e.locale=="string"||e.locales)&&this.activate((r=e.locale)!=null?r:ae,e.locales)}get locale(){return this._locale}get locales(){return this._locales}get messages(){var e;return(e=this._messages[this._locale])!=null?e:{}}get localeData(){var e;return(e=this._localeData[this._locale])!=null?e:{}}_loadLocaleData(e,r){let t=this._localeData[e];t?Object.assign(t,r):this._localeData[e]=r}setMessagesCompiler(e){return this._messageCompiler=e,this}loadLocaleData(e,r){typeof e=="string"?this._loadLocaleData(e,r):Object.keys(e).forEach(t=>this._loadLocaleData(t,e[t])),this.emit("change")}_load(e,r){let t=this._messages[e];t?Object.assign(t,r):this._messages[e]=r}load(e,r){typeof e=="string"&&typeof r=="object"?this._load(e,r):Object.entries(e).forEach(([t,a])=>this._load(t,a)),this.emit("change")}loadAndActivate({locale:e,locales:r,messages:t}){this._locale=e,this._locales=r||void 0,this._messages[this._locale]=t,this.emit("change")}activate(e,r){this._locale=e,this._locales=r,this.emit("change")}_(e,r,t){if(!this.locale)throw new Error("Lingui: Attempted to call a translation function without setting a locale.\nMake sure to call `i18n.activate(locale)` before using Lingui functions.\nThis issue may also occur due to a race condition in your initialization logic.");let a=t==null?void 0:t.message;e||(e=""),u(e)||(r=e.values||r,a=e.message,e=e.id);let s=this.messages[e],i=s===void 0,n=this._missing;if(n&&i)return Te(n)?n(this._locale,e):n;i&&this.emit("missing",{id:e,locale:this._locale});let c=s||a||e;return u(c)&&(this._messageCompiler?c=this._messageCompiler(c):console.warn(`Uncompiled message detected! Message:
|
|
3
3
|
|
|
4
4
|
> ${c}
|
|
5
5
|
|
|
@@ -7,7 +7,32 @@ That means you use raw catalog or your catalog doesn't have a translation for th
|
|
|
7
7
|
ICU features such as interpolation and plurals will not work properly for that message.
|
|
8
8
|
|
|
9
9
|
Please compile your catalog first.
|
|
10
|
-
`)),u(c)&&
|
|
10
|
+
`)),u(c)&&ie.test(c)?JSON.parse(`"${c}"`):u(c)?c:Ie(c,this._locale,this._locales)(r,t==null?void 0:t.formats)}date(e,r){return A(this._locales||this._locale,e,r)}number(e,r){return D(this._locales||this._locale,e,r)}};function qe(o={}){return new j(o)}var d=qe();import{css as or,html as _,LitElement as tr,nothing as U}from"lit";import{property as C}from"lit/decorators.js";import{html as Ge,LitElement as Je}from"lit";import{property as I,state as Ve}from"lit/decorators.js";import{classMap as Ke}from"lit/directives/class-map.js";import{css as Be}from"lit";var se=Be`
|
|
11
|
+
:host {
|
|
12
|
+
display: inline-block;
|
|
13
|
+
}
|
|
14
|
+
.w-icon {
|
|
15
|
+
--_w-icon-size: var(--w-icon-size, 24px);
|
|
16
|
+
height: var(--_w-icon-size);
|
|
17
|
+
width: var(--_w-icon-size);
|
|
18
|
+
display: flex;
|
|
19
|
+
}
|
|
20
|
+
.w-icon svg {
|
|
21
|
+
pointer-events: none;
|
|
22
|
+
height: var(--_w-icon-size);
|
|
23
|
+
width: var(--_w-icon-size);
|
|
24
|
+
}
|
|
25
|
+
.w-icon--s {
|
|
26
|
+
--w-icon-size: 16px;
|
|
27
|
+
}
|
|
28
|
+
.w-icon--m {
|
|
29
|
+
--w-icon-size: 24px;
|
|
30
|
+
}
|
|
31
|
+
.w-icon--l {
|
|
32
|
+
--w-icon-size: 32px;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
`;var R=new Map,Qe='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"></svg>';function We(o,e={}){var t;let r=(t=e.responseParser)!=null?t:(a=>a.text());return R.has(o)||R.set(o,fetch(o).then(r)),R.get(o)}var h=class extends Je{constructor(){super(...arguments);this.name="";this.size="medium";this.locale="en";this.svg=null}async fetchIcon(r){let t=`https://assets.finn.no/pkg/eikons/v1/${this.locale}/${r}.svg`;try{let a=await We(t);return new DOMParser().parseFromString(a,"text/html").body.querySelector("svg")}catch(a){return null}}firstUpdated(){this.loadIcon()}updated(r){(r.has("name")||r.has("locale"))&&this.loadIcon()}async loadIcon(){if(!this.name){this.svg=null;return}let r=await this.fetchIcon(this.name);r||(r=new DOMParser().parseFromString(Qe,"text/html").body.firstElementChild),this.svg=r}render(){let r={"w-icon":!0,"w-icon--s":this.size==="small","w-icon--m":this.size==="medium","w-icon--l":this.size==="large"},t=typeof this.size=="string"&&this.size.endsWith("px")?`--w-icon-size: ${this.size};`:"";return Ge`<div class="${Ke(r)}" style="${t}" part="w-${this.name.toLowerCase()}">${this.svg}</div>`}};h.styles=[se],g([I({type:String,reflect:!0})],h.prototype,"name",2),g([I({type:String,reflect:!0})],h.prototype,"size",2),g([I({type:String,reflect:!0})],h.prototype,"locale",2),g([Ve()],h.prototype,"svg",2);customElements.get("w-icon")||customElements.define("w-icon",h);var er=["en","nb","fi","da","sv"],le="en",ce=o=>er.find(e=>o===e||o.toLowerCase().includes(e))||le;function y(){if(typeof window=="undefined"){let o=process.env.NMP_LANGUAGE||Intl.DateTimeFormat().resolvedOptions().locale;return ce(o)}try{let o=document.documentElement.lang;return ce(o)}catch(o){return console.warn("could not detect locale, falling back to source locale",o),le}}var de=(o,e,r,t,a)=>{d.load("en",o),d.load("nb",e),d.load("fi",r),d.load("da",t),d.load("sv",a);let s=y();d.activate(s)};import{css as pe}from"lit";var ge=pe`
|
|
11
36
|
*,
|
|
12
37
|
:before,
|
|
13
38
|
:after {
|
|
@@ -280,7 +305,7 @@ Please compile your catalog first.
|
|
|
280
305
|
svg {
|
|
281
306
|
pointer-events: none;
|
|
282
307
|
}
|
|
283
|
-
`,
|
|
308
|
+
`,kr=pe`*, :before, :after {
|
|
284
309
|
--w-rotate: 0;
|
|
285
310
|
--w-rotate-x: 0;
|
|
286
311
|
--w-rotate-y: 0;
|
|
@@ -2446,58 +2471,56 @@ Please compile your catalog first.
|
|
|
2446
2471
|
display: none
|
|
2447
2472
|
}
|
|
2448
2473
|
}
|
|
2449
|
-
`;var
|
|
2474
|
+
`;var be=JSON.parse('{"pagination.aria.first-page":["F\xF8rste side"],"pagination.aria.icon-suffix":["ikon"],"pagination.aria.next-page":["N\xE6ste side"],"pagination.aria.page":["Side ",["currentPage"]],"pagination.aria.pagination":["Sider"],"pagination.aria.prev-page":["Forrige side"]}');var ue=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"]}');var he=JSON.parse('{"pagination.aria.first-page":["Ensimm\xE4inen 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"]}');var me=JSON.parse('{"pagination.aria.first-page":["F\xF8rste 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"]}');var ve=JSON.parse('{"pagination.aria.first-page":["F\xF6rsta sidan"],"pagination.aria.icon-suffix":["ikon"],"pagination.aria.next-page":["N\xE4sta sida"],"pagination.aria.page":["Sida ",["currentPage"]],"pagination.aria.pagination":["Sidor"],"pagination.aria.prev-page":["F\xF6reg\xE5ende sida"]}');import{css as rr}from"lit";var fe=rr`*,: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}}`;var X=()=>d._({id:"pagination.aria.icon-suffix",message:"icon",comment:"Suffix added at the end of icon titles when img semantics are lost on an html element"}),$="hover:no-underline focus:no-underline focusable inline-flex justify-center items-center transition-colors ease-in-out min-h-[44px] min-w-[44px] p-4 rounded-full border-0 hover:bg-clip-padding",N,we,m=class extends tr{constructor(){super();J(this,N);this.currentPageNumber=1;this.visiblePages=7;de(ue,me,he,be,ve)}get shouldShowShowFirstPageButton(){return this.currentPageNumber-2>0}get shouldShowPreviousPageButton(){return this.currentPageNumber-1>0}get shouldShowNextPageButton(){return this.currentPageNumber<this.pages}get currentPageIndex(){return this.currentPageNumber-1}get visiblePageNumbers(){if(this.pages<=this.visiblePages)return Array.from({length:this.pages},(s,i)=>i+1);let r=Math.floor(this.visiblePages/2),t=Math.max(1,this.currentPageNumber-r),a=Math.min(this.pages,t+this.visiblePages-1);return a-t+1<this.visiblePages&&(t=Math.max(1,a-this.visiblePages+1)),Array.from({length:a-t+1},(s,i)=>t+i)}render(){let r=this.visiblePageNumbers;return _`<nav class="flex items-center justify-center p-8" @click="${V(this,N,we)}">
|
|
2450
2475
|
<h1 class="sr-only">
|
|
2451
|
-
${
|
|
2476
|
+
${d._({id:"pagination.aria.pagination",message:"Pages",comment:"Default screenreader message for pagination container in the pagination component"})}
|
|
2452
2477
|
</h1>
|
|
2453
2478
|
<div class="flex items-center s-text-link">
|
|
2454
|
-
${this.shouldShowShowFirstPageButton?
|
|
2479
|
+
${this.shouldShowShowFirstPageButton?_`<a
|
|
2455
2480
|
data-page-number="1"
|
|
2456
2481
|
href="${this.baseUrl}1"
|
|
2457
|
-
class="${
|
|
2482
|
+
class="${$+" s-icon hover:bg-[--w-color-button-pill-background-hover] active:bg-[--w-color-button-pill-background-active]"}">
|
|
2458
2483
|
<span class="sr-only"
|
|
2459
|
-
>${
|
|
2484
|
+
>${d._({id:"pagination.aria.first-page",message:"First page",comment:"Default screenreader message for first page link in the pagination component"})},</span
|
|
2460
2485
|
>
|
|
2461
|
-
<w-icon
|
|
2462
|
-
<span class="sr-only">${
|
|
2463
|
-
</a>`:
|
|
2464
|
-
${this.shouldShowPreviousPageButton?
|
|
2486
|
+
<w-icon name="ChevronDoubleLeft" size="small" locale="${y()}" class="pointer-events-none flex items-center" class="flex"></w-icon>
|
|
2487
|
+
<span class="sr-only">${X()}</span>
|
|
2488
|
+
</a>`:U}
|
|
2489
|
+
${this.shouldShowPreviousPageButton?_`<a
|
|
2465
2490
|
data-page-number="${this.currentPageNumber-1}"
|
|
2466
2491
|
href="${this.baseUrl}${this.currentPageNumber-1}"
|
|
2467
|
-
class="${
|
|
2492
|
+
class="${$+" s-icon hover:bg-[--w-color-button-pill-background-hover] active:bg-[--w-color-button-pill-background-active]"}">
|
|
2468
2493
|
<span class="sr-only"
|
|
2469
|
-
>${
|
|
2494
|
+
>${d._({id:"pagination.aria.prev-page",message:"Previous page",comment:"Default screenreader message for previous page link in the pagination component"})},</span
|
|
2470
2495
|
>
|
|
2471
|
-
<w-icon
|
|
2472
|
-
<span class="sr-only">${
|
|
2473
|
-
</a>`:
|
|
2496
|
+
<w-icon name="ChevronLeft" size="small" locale="${y()}" class="pointer-events-none flex items-center" class="flex"></w-icon>
|
|
2497
|
+
<span class="sr-only">${X()}</span>
|
|
2498
|
+
</a>`:U}
|
|
2474
2499
|
<div class="hidden md:block">
|
|
2475
|
-
${
|
|
2500
|
+
${r.map(t=>{let a=t===this.currentPageNumber,s=`${this.baseUrl}${t}`,i=$;a?i+=" s-bg-primary s-text-inverted":i+=" hover:bg-[--w-color-button-pill-background-hover] active:bg-[--w-color-button-pill-background-active]";let n=d._({id:"pagination.aria.page",message:"Page {currentPage}",values:{currentPage:t},comment:"Default screenreader message for page link in the pagination component"});return _`<a
|
|
2476
2501
|
data-page-number="${t}"
|
|
2477
|
-
aria-label="${
|
|
2478
|
-
href="${
|
|
2479
|
-
class="${
|
|
2502
|
+
aria-label="${n}"
|
|
2503
|
+
href="${s}"
|
|
2504
|
+
class="${i}"
|
|
2480
2505
|
aria-current="${a?"page":""}"
|
|
2481
2506
|
>${t}</a
|
|
2482
2507
|
>`})}
|
|
2483
2508
|
</div>
|
|
2484
|
-
<span class="block md:hidden p-8 font-bold">${
|
|
2485
|
-
${this.shouldShowNextPageButton?
|
|
2509
|
+
<span class="block md:hidden p-8 font-bold">${d._({id:"pagination.label.current-page",message:"Page {currentPage}",values:{currentPage:this.currentPageNumber},comment:"Default message for current page label in the pagination component"})}</span>
|
|
2510
|
+
${this.shouldShowNextPageButton?_`<a
|
|
2486
2511
|
data-page-number="${this.currentPageNumber+1}"
|
|
2487
2512
|
href="${this.baseUrl}${this.currentPageNumber+1}"
|
|
2488
|
-
class="${
|
|
2513
|
+
class="${$+" s-icon hover:bg-[--w-color-button-pill-background-hover] active:bg-[--w-color-button-pill-background-active]"}">
|
|
2489
2514
|
<span class="sr-only">
|
|
2490
|
-
${
|
|
2515
|
+
${d._({id:"pagination.aria.next-page",message:"Next page",comment:"Default screenreader message for next page link in the pagination component"})},</span
|
|
2491
2516
|
>
|
|
2492
|
-
<w-icon
|
|
2493
|
-
<span class="sr-only">${
|
|
2494
|
-
</a>`:
|
|
2517
|
+
<w-icon name="ChevronRight" size="small" locale="${y()}" class="pointer-events-none flex items-center" class="flex"></w-icon>
|
|
2518
|
+
<span class="sr-only">${X()}</span>
|
|
2519
|
+
</a>`:U}
|
|
2495
2520
|
</div>
|
|
2496
|
-
</nav>`}};
|
|
2497
|
-
w-icon
|
|
2498
|
-
w-icon-chevron-double-left-16,
|
|
2499
|
-
w-icon-chevron-right-16 {
|
|
2521
|
+
</nav>`}};N=new WeakSet,we=function(r){let t=r.target.getAttribute("data-page-number");this.dispatchEvent(new CustomEvent("page-click",{detail:{clickedPage:t},bubbles:!0,composed:!0}))},m.styles=[ge,fe,or`
|
|
2522
|
+
w-icon {
|
|
2500
2523
|
height: 16px;
|
|
2501
2524
|
}
|
|
2502
|
-
`],
|
|
2525
|
+
`],g([C({type:String,reflect:!0,attribute:"base-url"})],m.prototype,"baseUrl",2),g([C({type:Number,reflect:!0})],m.prototype,"pages",2),g([C({type:Number,reflect:!0,attribute:"current-page"})],m.prototype,"currentPageNumber",2),g([C({type:Number,reflect:!0,attribute:"visible-pages"})],m.prototype,"visiblePages",2);customElements.get("w-pagination")||customElements.define("w-pagination",m);export{m as WarpPagination};
|
|
2503
2526
|
//# sourceMappingURL=pagination.js.map
|