@warp-ds/elements 2.9.1-next.3 → 2.9.1-next.4

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 (91) hide show
  1. package/dist/custom-elements.json +83 -239
  2. package/dist/docs/affix/affix.md +9 -10
  3. package/dist/docs/affix/api.md +9 -10
  4. package/dist/docs/alert/alert.md +4 -2
  5. package/dist/docs/alert/api.md +4 -2
  6. package/dist/docs/attention/api.md +16 -14
  7. package/dist/docs/attention/attention.md +16 -14
  8. package/dist/docs/badge/api.md +5 -6
  9. package/dist/docs/badge/badge.md +5 -6
  10. package/dist/docs/box/api.md +3 -4
  11. package/dist/docs/box/box.md +3 -4
  12. package/dist/docs/breadcrumbs/accessibility.md +46 -0
  13. package/dist/docs/breadcrumbs/api.md +8 -8
  14. package/dist/docs/breadcrumbs/breadcrumbs.md +127 -9
  15. package/dist/docs/breadcrumbs/examples.md +35 -0
  16. package/dist/docs/breadcrumbs/usage.md +36 -0
  17. package/dist/docs/button/api.md +15 -13
  18. package/dist/docs/button/button.md +15 -13
  19. package/dist/docs/card/api.md +5 -6
  20. package/dist/docs/card/card.md +5 -6
  21. package/dist/docs/combobox/api.md +18 -19
  22. package/dist/docs/combobox/combobox.md +18 -19
  23. package/dist/docs/datepicker/api.md +38 -39
  24. package/dist/docs/datepicker/datepicker.md +38 -39
  25. package/dist/docs/expandable/api.md +11 -12
  26. package/dist/docs/expandable/expandable.md +11 -12
  27. package/dist/docs/link/api.md +8 -6
  28. package/dist/docs/link/link.md +8 -6
  29. package/dist/docs/page-indicator/api.md +7 -8
  30. package/dist/docs/page-indicator/page-indicator.md +7 -8
  31. package/dist/docs/pagination/api.md +17 -9
  32. package/dist/docs/pagination/pagination.md +17 -9
  33. package/dist/docs/pill/api.md +30 -17
  34. package/dist/docs/pill/pill.md +30 -17
  35. package/dist/docs/select/api.md +17 -9
  36. package/dist/docs/select/select.md +17 -9
  37. package/dist/docs/slider/api.md +37 -116
  38. package/dist/docs/slider/examples.md +331 -0
  39. package/dist/docs/slider/slider.md +378 -118
  40. package/dist/docs/slider/usage.md +10 -0
  41. package/dist/docs/slider-thumb/api.md +26 -55
  42. package/dist/docs/slider-thumb/slider-thumb.md +26 -57
  43. package/dist/docs/step/api.md +3 -4
  44. package/dist/docs/step/step.md +3 -4
  45. package/dist/docs/step-indicator/api.md +3 -4
  46. package/dist/docs/step-indicator/step-indicator.md +3 -4
  47. package/dist/docs/switch/api.md +13 -5
  48. package/dist/docs/switch/switch.md +13 -5
  49. package/dist/docs/tab/api.md +9 -62
  50. package/dist/docs/tab/tab.md +9 -70
  51. package/dist/docs/tab-panel/api.md +7 -11
  52. package/dist/docs/tab-panel/tab-panel.md +7 -19
  53. package/dist/docs/tabs/accessibility.md +11 -0
  54. package/dist/docs/tabs/api.md +10 -18
  55. package/dist/docs/tabs/examples.md +68 -0
  56. package/dist/docs/tabs/tabs.md +97 -20
  57. package/dist/docs/tabs/usage.md +8 -0
  58. package/dist/docs/textarea/api.md +15 -16
  59. package/dist/docs/textarea/textarea.md +15 -16
  60. package/dist/docs/textfield/api.md +14 -15
  61. package/dist/docs/textfield/textfield.md +14 -15
  62. package/dist/index.d.ts +124 -224
  63. package/dist/packages/breadcrumbs/breadcrumbs.d.ts +7 -1
  64. package/dist/packages/breadcrumbs/breadcrumbs.js.map +2 -2
  65. package/dist/packages/pagination/pagination.test.js +38 -0
  66. package/dist/packages/slider/slider.d.ts +34 -45
  67. package/dist/packages/slider/slider.js +1 -1
  68. package/dist/packages/slider/slider.js.map +2 -2
  69. package/dist/packages/slider-thumb/slider-thumb.d.ts +36 -31
  70. package/dist/packages/slider-thumb/slider-thumb.js +1 -1
  71. package/dist/packages/slider-thumb/slider-thumb.js.map +2 -2
  72. package/dist/packages/tab/tab.d.ts +29 -24
  73. package/dist/packages/tab/tab.js +3 -3
  74. package/dist/packages/tab/tab.js.map +2 -2
  75. package/dist/packages/tab-panel/tab-panel.d.ts +9 -8
  76. package/dist/packages/tab-panel/tab-panel.js +3 -3
  77. package/dist/packages/tab-panel/tab-panel.js.map +2 -2
  78. package/dist/packages/tabs/index.d.ts +1 -0
  79. package/dist/packages/tabs/index.js +0 -1
  80. package/dist/packages/tabs/react.d.ts +4 -3
  81. package/dist/packages/tabs/tabs.d.ts +9 -3
  82. package/dist/packages/tabs/tabs.js.map +2 -2
  83. package/dist/packages/tabs/tabs.react.stories.d.ts +2 -2
  84. package/dist/web-types.json +201 -93
  85. package/package.json +2 -1
  86. package/dist/docs/tab/accessibility.md +0 -1
  87. package/dist/docs/tab/examples.md +0 -1
  88. package/dist/docs/tab/usage.md +0 -1
  89. package/dist/docs/tab-panel/accessibility.md +0 -1
  90. package/dist/docs/tab-panel/examples.md +0 -1
  91. package/dist/docs/tab-panel/usage.md +0 -1
@@ -1,8 +1,14 @@
1
+ import { i18n } from '@lingui/core';
1
2
  import { userEvent } from '@vitest/browser/context';
2
3
  import { html } from 'lit';
3
4
  import { expect, test, vi } from 'vitest';
4
5
  import { render } from 'vitest-browser-lit';
6
+ import { detectLocale } from '../i18n.js';
5
7
  import './pagination.js';
8
+ function restoreDocumentLang(lang) {
9
+ document.documentElement.lang = lang;
10
+ i18n.activate(detectLocale());
11
+ }
6
12
  test('current page is the active page', async () => {
7
13
  const component = html `<w-pagination current-page="5" pages="10" base-url="/page/"></w-pagination>`;
8
14
  const page = render(component);
@@ -92,3 +98,35 @@ test('defaults to visible-pages=7 when no visible-pages attribute is set', async
92
98
  // But 7 pages should be visible (the default)
93
99
  await expect.poll(() => page.getByRole('link').and(page.getByLabelText('Page ')).all()).toHaveLength(7);
94
100
  });
101
+ test('uses the document lang attribute for Norwegian labels', async () => {
102
+ const originalLang = document.documentElement.lang;
103
+ try {
104
+ document.documentElement.lang = 'nb';
105
+ const component = html `<w-pagination current-page="5" pages="10" base-url="/page/"></w-pagination>`;
106
+ const page = render(component);
107
+ await expect.element(page.getByLabelText('Side 5')).toHaveAttribute('aria-current', 'page');
108
+ await expect.element(page.getByText('Første side')).toBeInTheDocument();
109
+ await expect.element(page.getByText('Forrige side')).toBeInTheDocument();
110
+ await expect.element(page.getByText('Neste side')).toBeInTheDocument();
111
+ await expect.element(page.getByText('Side 5')).toBeInTheDocument();
112
+ }
113
+ finally {
114
+ restoreDocumentLang(originalLang);
115
+ }
116
+ });
117
+ test.skip('updates labels when the document lang attribute changes', async () => {
118
+ const originalLang = document.documentElement.lang;
119
+ try {
120
+ document.documentElement.lang = 'en';
121
+ const component = html `<w-pagination current-page="5" pages="10" base-url="/page/"></w-pagination>`;
122
+ const page = render(component);
123
+ await expect.element(page.getByLabelText('Page 5')).toHaveAttribute('aria-current', 'page');
124
+ document.documentElement.lang = 'nb';
125
+ await expect.poll(() => page.getByLabelText('Side 5').query()).toBeInTheDocument();
126
+ await expect.element(page.getByLabelText('Side 5')).toHaveAttribute('aria-current', 'page');
127
+ await expect.element(page.getByText('Første side')).toBeInTheDocument();
128
+ }
129
+ finally {
130
+ restoreDocumentLang(originalLang);
131
+ }
132
+ });
@@ -3,8 +3,6 @@ import type { SliderSlot } from '../slider-thumb/slider-thumb.js';
3
3
  /**
4
4
  * Parent component for sliders (both single and range sliders). Used in combination with a `<w-slider-thumb>`.
5
5
  *
6
- * [See Storybook for usage examples](https://warp-ds.github.io/elements/?path=/docs/forms-slider-and-range-slider--docs)
7
- *
8
6
  * @slot - For single sliders place a `<w-slider-thumb>` in the default slot.
9
7
  * @slot label - Label for the slider or range slider as a whole.
10
8
  * @slot description - Optional description between the label and slider.
@@ -13,6 +11,7 @@ import type { SliderSlot } from '../slider-thumb/slider-thumb.js';
13
11
  */
14
12
  declare class WarpSlider extends LitElement {
15
13
  #private;
14
+ /** @internal */
16
15
  static shadowRootOptions: {
17
16
  delegatesFocus: boolean;
18
17
  clonable?: boolean;
@@ -26,99 +25,89 @@ declare class WarpSlider extends LitElement {
26
25
  * The slider fieldset label. Required for proper accessibility.
27
26
  *
28
27
  * If you need to display HTML, use the `label` slot instead (f. ex. `<legend class="sr-only" slot="label">Production year</legend>`)
29
-
30
- * @summary
31
- * @description
32
- */
33
- label: string;
34
- /**
35
- * @summary
36
- * @description
37
28
  */
29
+ label: string;
38
30
  disabled: boolean;
39
31
  /**
40
32
  * Whether or not to allow values outside the range such as "Before 1950" and "2025+".
41
-
42
- * @summary
43
- * @description
44
33
  */
45
34
  openEnded: boolean;
46
35
  /**
47
- * @summary
48
- * @description
36
+ * Validation error text, if any
49
37
  */
50
38
  error: string;
51
39
  /**
52
- * @summary
53
- * @description
40
+ * Additional description to show below the fieldset
54
41
  */
55
42
  helpText: string;
56
43
  /**
57
- * @summary
58
- * @description
44
+ * Sets the form fields and fieldset in an invalid state
59
45
  */
60
46
  invalid: boolean;
61
- /** Ensures a child slider thumb has a value before allowing the containing form to submit.
62
- * @summary
63
- * @description
47
+ /**
48
+ * Ensures a child slider thumb has a value before allowing the containing form to submit
64
49
  */
65
50
  required: boolean;
66
51
  /**
67
- * @summary
68
- * @description
52
+ * The minimum allowed value in the range inputs
53
+ * @default 0
69
54
  */
70
55
  min: string;
71
56
  /**
72
- * @summary
73
- * @description
57
+ * The maximum allowed value in the range inputs
58
+ * @default 100
74
59
  */
75
60
  max: string;
76
- /** Pass a value similar to step to create visual markers at that interval
77
- * @summary
78
- * @description
61
+ /**
62
+ * Pass a value similar to step to create visual markers at that interval
79
63
  */
80
64
  markers: number;
81
65
  /**
82
- * @summary
83
- * @description
66
+ * ets step on the range input to jump between values when dragging
84
67
  */
85
68
  step: number;
86
- /** Suffix used in text input fields and for the min and max values of the slider.
87
- * @summary
88
- * @description
69
+ /**
70
+ * Suffix used in text input fields and for the min and max values of the slider
89
71
  */
90
72
  suffix: string;
91
73
  /**
92
- * @summary
93
- * @description
74
+ * Should only be used in special cases
94
75
  */
95
76
  hiddenTextfield: boolean;
96
- /** Formatter for the tooltip and input mask values.
97
- * @summary
98
- * @description
77
+ /**
78
+ * Formatter for the tooltip and input mask values
99
79
  */
100
80
  valueFormatter: (value: string, slot: SliderSlot) => string;
101
- /** Replaces {@link valueFormatter} for the tooltip. Use in open-ended sliders to show for example "300+ hk" instead of "Max" in the tooltip.
102
- * @summary
103
- * @description
81
+ /**
82
+ * Overrides {@link valueFormatter} for the tooltip.
83
+ *
84
+ * Use in open-ended sliders to show for example "300+ hk" instead of "Max" in the tooltip.
104
85
  */
105
86
  tooltipFormatter: (value: string, slot: SliderSlot) => string;
106
- /** Formatter for the min and max labels below the range.
107
- * @summary
108
- * @description
87
+ /**
88
+ * Formatter for the min and max labels below the range.
109
89
  */
110
90
  labelFormatter: (slot: SliderSlot) => string;
91
+ /** @internal */
111
92
  fieldset: HTMLFieldSetElement;
93
+ /** @internal */
112
94
  _invalidMessage: string;
95
+ /** @internal */
113
96
  _hasInternalError: boolean;
97
+ /** @internal */
114
98
  _showError: boolean;
99
+ /** @internal */
115
100
  _tabbableElements: Array<HTMLElement>;
116
101
  constructor();
102
+ /** @internal */
117
103
  get edgeMin(): string;
104
+ /** @internal */
118
105
  get edgeMax(): string;
119
106
  connectedCallback(): Promise<void>;
120
107
  updated(changedProperties: PropertyValues<this>): void;
108
+ /** @internal */
121
109
  get componentHasError(): boolean;
110
+ /** @internal */
122
111
  get errorText(): string;
123
112
  render(): import("lit").TemplateResult<1>;
124
113
  }
@@ -2637,5 +2637,5 @@ Please compile your catalog first.
2637
2637
  ${this.helpText}
2638
2638
  </p>`:j}
2639
2639
  </fieldset>
2640
- `}};l=new WeakSet,m=function(){var a;let e=this.querySelectorAll("w-slider-thumb"),o=!1;for(let i of e.values())i.min=this.edgeMin,i.max=this.edgeMax,i.step=this.step,i.suffix=(a=this.suffix)!=null?a:"",i.required=this.required,i.labelFormatter=this.labelFormatter,i.valueFormatter=this.valueFormatter,i.tooltipFormatter=this.tooltipFormatter,i.openEnded=this.openEnded,i._hiddenTextfield=this.hiddenTextfield,i.ariaLabel||(i.slot||(i.ariaLabel=this.label),i.slot==="from"&&(i.ariaLabel=`${this.label} min`),i.slot==="to"&&(i.ariaLabel=`${this.label} max`)),(i.slot==="from"||i.slot==="to")&&(o=!0),i.disabled=this.disabled,i.invalid=!!this.errorText,h(this,l,L).call(this,i);o?(this.fieldset.style.setProperty("--active-range-inline-start-padding","var(--w-slider-thumb-size, 28px)"),this.fieldset.style.setProperty("--active-range-inline-end-padding","var(--w-slider-thumb-size, 28px)")):this.fieldset.style.setProperty("--active-range-border-radius","4px")},ce=function(e){let o=e.target;h(this,l,L).call(this,o)},be=function(e){let o=e.target;h(this,l,L).call(this,o),o.slot&&h(this,l,pe).call(this)},he=function(){this.componentHasError?this._showError=!0:this._showError=!1,h(this,l,m).call(this)},ge=function(e){if(e.key==="Tab"){let o=this._tabbableElements.indexOf(e.target.shadowRoot.activeElement);if(o===-1)return;let a=e.shiftKey?-1:1,i=this._tabbableElements[o+a];if(!i)return;e.preventDefault(),i.focus()}},pe=function(){let e,o,a=this.querySelectorAll("w-slider-thumb");for(let i of a.values())i.slot==="from"&&(e=i),i.slot==="to"&&(o=i);!e||!o||!e.invalid&&o.invalid},ue=function(e){e.stopPropagation();let o=this._hasInternalError||this.invalid,a=e.target;if(this._hasInternalError=!!e.detail.invalid||this.invalid,this._invalidMessage=e.detail.invalid,o===!0&&this._hasInternalError===!1){let i=this.querySelectorAll("w-slider-thumb");for(let s of i.values())s!==a&&s.updateFieldAfterValidation()}},q=function(e,o){return(o.value===void 0||o.value===null)&&(o.value=this.openEnded?"":e),o.value===""?e:o.value},L=function(e){let o=e.slot;o||this.fieldset.style.setProperty("--from","0"),o==="from"&&this.fieldset.style.setProperty("--from",h(this,l,q).call(this,this.edgeMin,e)),(!o||o==="to")&&this.fieldset.style.setProperty("--to",h(this,l,q).call(this,this.edgeMax,e))},d.shadowRootOptions={...de.shadowRootOptions,delegatesFocus:!0},d.styles=[oe,le],b([g({reflect:!0})],d.prototype,"label",2),b([g({type:Boolean,reflect:!0})],d.prototype,"disabled",2),b([g({type:Boolean,attribute:"open-ended"})],d.prototype,"openEnded",2),b([g({type:String,reflect:!0})],d.prototype,"error",2),b([g({type:String,reflect:!0,attribute:"help-text"})],d.prototype,"helpText",2),b([g({type:Boolean,reflect:!0})],d.prototype,"invalid",2),b([g({type:Boolean,reflect:!0})],d.prototype,"required",2),b([g({reflect:!0})],d.prototype,"min",2),b([g({reflect:!0})],d.prototype,"max",2),b([g({type:Number,reflect:!0})],d.prototype,"markers",2),b([g({type:Number,reflect:!0})],d.prototype,"step",2),b([g({reflect:!0})],d.prototype,"suffix",2),b([g({type:Boolean,reflect:!0,attribute:"hidden-textfield"})],d.prototype,"hiddenTextfield",2),b([g({attribute:!1})],d.prototype,"valueFormatter",2),b([g({attribute:!1})],d.prototype,"tooltipFormatter",2),b([g({attribute:!1})],d.prototype,"labelFormatter",2),b([je("fieldset")],d.prototype,"fieldset",2),b([T()],d.prototype,"_invalidMessage",2),b([T()],d.prototype,"_hasInternalError",2),b([T()],d.prototype,"_showError",2),b([T()],d.prototype,"_tabbableElements",2);customElements.get("w-slider")||customElements.define("w-slider",d);export{d as WarpSlider};
2640
+ `}};l=new WeakSet,m=function(){var a;let e=this.querySelectorAll("w-slider-thumb"),o=!1;for(let i of e.values())i.min=this.edgeMin,i.max=this.edgeMax,i.step=this.step,i.suffix=(a=this.suffix)!=null?a:"",i.required=this.required,i.labelFormatter=this.labelFormatter,i.valueFormatter=this.valueFormatter,i.tooltipFormatter=this.tooltipFormatter,i.openEnded=this.openEnded,i._hiddenTextfield=this.hiddenTextfield,i.ariaLabel||(i.slot||(i.ariaLabel=this.label),i.slot==="from"&&(i.ariaLabel=`${this.label} min`),i.slot==="to"&&(i.ariaLabel=`${this.label} max`)),(i.slot==="from"||i.slot==="to")&&(o=!0),i.disabled=this.disabled,i.invalid=!!this.errorText,h(this,l,L).call(this,i);o?(this.fieldset.style.setProperty("--active-range-inline-start-padding","var(--w-slider-thumb-size, 28px)"),this.fieldset.style.setProperty("--active-range-inline-end-padding","var(--w-slider-thumb-size, 28px)")):this.fieldset.style.setProperty("--active-range-border-radius","4px")},ce=function(e){e.stopPropagation();let o=e.target;h(this,l,L).call(this,o)},be=function(e){let o=e.target;h(this,l,L).call(this,o),o.slot&&h(this,l,pe).call(this)},he=function(){this.componentHasError?this._showError=!0:this._showError=!1,h(this,l,m).call(this)},ge=function(e){if(e.key==="Tab"){let o=this._tabbableElements.indexOf(e.target.shadowRoot.activeElement);if(o===-1)return;let a=e.shiftKey?-1:1,i=this._tabbableElements[o+a];if(!i)return;e.preventDefault(),i.focus()}},pe=function(){let e,o,a=this.querySelectorAll("w-slider-thumb");for(let i of a.values())i.slot==="from"&&(e=i),i.slot==="to"&&(o=i);!e||!o||!e.invalid&&o.invalid},ue=function(e){e.stopPropagation();let o=this._hasInternalError||this.invalid,a=e.target;if(this._hasInternalError=!!e.detail.invalid||this.invalid,this._invalidMessage=e.detail.invalid,o===!0&&this._hasInternalError===!1){let i=this.querySelectorAll("w-slider-thumb");for(let s of i.values())s!==a&&s.updateFieldAfterValidation()}},q=function(e,o){return(o.value===void 0||o.value===null)&&(o.value=this.openEnded?"":e),o.value===""?e:o.value},L=function(e){let o=e.slot;o||this.fieldset.style.setProperty("--from","0"),o==="from"&&this.fieldset.style.setProperty("--from",h(this,l,q).call(this,this.edgeMin,e)),(!o||o==="to")&&this.fieldset.style.setProperty("--to",h(this,l,q).call(this,this.edgeMax,e))},d.shadowRootOptions={...de.shadowRootOptions,delegatesFocus:!0},d.styles=[oe,le],b([g({reflect:!0})],d.prototype,"label",2),b([g({type:Boolean,reflect:!0})],d.prototype,"disabled",2),b([g({type:Boolean,attribute:"open-ended"})],d.prototype,"openEnded",2),b([g({type:String,reflect:!0})],d.prototype,"error",2),b([g({type:String,reflect:!0,attribute:"help-text"})],d.prototype,"helpText",2),b([g({type:Boolean,reflect:!0})],d.prototype,"invalid",2),b([g({type:Boolean,reflect:!0})],d.prototype,"required",2),b([g({reflect:!0})],d.prototype,"min",2),b([g({reflect:!0})],d.prototype,"max",2),b([g({type:Number,reflect:!0})],d.prototype,"markers",2),b([g({type:Number,reflect:!0})],d.prototype,"step",2),b([g({reflect:!0})],d.prototype,"suffix",2),b([g({type:Boolean,reflect:!0,attribute:"hidden-textfield"})],d.prototype,"hiddenTextfield",2),b([g({attribute:!1})],d.prototype,"valueFormatter",2),b([g({attribute:!1})],d.prototype,"tooltipFormatter",2),b([g({attribute:!1})],d.prototype,"labelFormatter",2),b([je("fieldset")],d.prototype,"fieldset",2),b([T()],d.prototype,"_invalidMessage",2),b([T()],d.prototype,"_hasInternalError",2),b([T()],d.prototype,"_showError",2),b([T()],d.prototype,"_tabbableElements",2);customElements.get("w-slider")||customElements.define("w-slider",d);export{d as WarpSlider};
2641
2641
  //# sourceMappingURL=slider.js.map