@warp-ds/elements 2.2.0 → 2.3.0-next.1

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 (55) hide show
  1. package/dist/custom-elements.json +693 -0
  2. package/dist/index.d.ts +185 -0
  3. package/dist/packages/pagination/index.d.ts +32 -0
  4. package/dist/packages/pagination/index.js +2500 -0
  5. package/dist/packages/pagination/index.js.map +7 -0
  6. package/dist/packages/pagination/locales/da/messages.d.mts +1 -0
  7. package/dist/packages/pagination/locales/da/messages.mjs +1 -0
  8. package/dist/packages/pagination/locales/en/messages.d.mts +1 -0
  9. package/dist/packages/pagination/locales/en/messages.mjs +1 -0
  10. package/dist/packages/pagination/locales/fi/messages.d.mts +1 -0
  11. package/dist/packages/pagination/locales/fi/messages.mjs +1 -0
  12. package/dist/packages/pagination/locales/nb/messages.d.mts +1 -0
  13. package/dist/packages/pagination/locales/nb/messages.mjs +1 -0
  14. package/dist/packages/pagination/locales/sv/messages.d.mts +1 -0
  15. package/dist/packages/pagination/locales/sv/messages.mjs +1 -0
  16. package/dist/packages/pagination/pagination.react.stories.d.ts +21 -0
  17. package/dist/packages/pagination/pagination.react.stories.js +45 -0
  18. package/dist/packages/pagination/pagination.stories.d.ts +14 -0
  19. package/dist/packages/pagination/pagination.stories.js +56 -0
  20. package/dist/packages/pagination/pagination.test.d.ts +1 -0
  21. package/dist/packages/pagination/pagination.test.js +76 -0
  22. package/dist/packages/pagination/react.d.ts +5 -0
  23. package/dist/packages/pagination/react.js +15 -0
  24. package/dist/packages/pagination/styles.d.ts +1 -0
  25. package/dist/packages/pagination/styles.js +2 -0
  26. package/dist/packages/slider/Slider.d.ts +2 -0
  27. package/dist/packages/slider/Slider.js +8 -0
  28. package/dist/packages/slider/SliderThumb.d.ts +2 -0
  29. package/dist/packages/slider/SliderThumb.js +8 -0
  30. package/dist/packages/slider/index.d.ts +2 -0
  31. package/dist/packages/slider/index.js +2 -0
  32. package/dist/packages/slider/oddbird-css-anchor-positioning.d.ts +2 -0
  33. package/dist/packages/slider/oddbird-css-anchor-positioning.js +3 -0
  34. package/dist/packages/slider/react.d.ts +8 -0
  35. package/dist/packages/slider/react.js +20 -0
  36. package/dist/packages/slider/slider-thumb.d.ts +57 -0
  37. package/dist/packages/slider/slider-thumb.js +2705 -0
  38. package/dist/packages/slider/slider-thumb.js.map +7 -0
  39. package/dist/packages/slider/slider.d.ts +46 -0
  40. package/dist/packages/slider/slider.js +2587 -0
  41. package/dist/packages/slider/slider.js.map +7 -0
  42. package/dist/packages/slider/slider.react.stories.d.ts +18 -0
  43. package/dist/packages/slider/slider.react.stories.js +118 -0
  44. package/dist/packages/slider/slider.stories.d.ts +18 -0
  45. package/dist/packages/slider/slider.stories.js +197 -0
  46. package/dist/packages/slider/slider.test.d.ts +4 -0
  47. package/dist/packages/slider/slider.test.js +83 -0
  48. package/dist/packages/slider/styles/w-slider-thumb.styles.d.ts +1 -0
  49. package/dist/packages/slider/styles/w-slider-thumb.styles.js +167 -0
  50. package/dist/packages/slider/styles/w-slider.styles.d.ts +1 -0
  51. package/dist/packages/slider/styles/w-slider.styles.js +134 -0
  52. package/dist/packages/slider/styles.d.ts +1 -0
  53. package/dist/packages/slider/styles.js +2 -0
  54. package/dist/web-types.json +198 -1
  55. package/package.json +3 -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 './index.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 '.';
2
+ export declare const Pagination: import("@lit/react").ReactWebComponent<WarpPagination, {
3
+ onPageClick: string;
4
+ 'onpage-click': string;
5
+ }>;
@@ -0,0 +1,15 @@
1
+ import { LitElement } from 'lit';
2
+ import { createComponent } from '@lit/react';
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}.flex{display:flex}.inline-flex{display:inline-flex}.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}.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)}`;
@@ -0,0 +1,2 @@
1
+ import { WarpSlider } from './slider.js';
2
+ export declare const Slider: import("@lit/react").ReactWebComponent<WarpSlider, {}>;
@@ -0,0 +1,8 @@
1
+ import { createComponent } from '@lit/react';
2
+ import React from 'react';
3
+ import { WarpSlider } from './slider.js';
4
+ export const Slider = createComponent({
5
+ tagName: 'w-slider',
6
+ elementClass: WarpSlider,
7
+ react: React,
8
+ });
@@ -0,0 +1,2 @@
1
+ import { WarpSliderThumb } from './slider-thumb.js';
2
+ export declare const SliderThumb: import("@lit/react").ReactWebComponent<WarpSliderThumb, {}>;
@@ -0,0 +1,8 @@
1
+ import { createComponent } from '@lit/react';
2
+ import React from 'react';
3
+ import { WarpSliderThumb } from './slider-thumb.js';
4
+ export const SliderThumb = createComponent({
5
+ tagName: 'w-slider-thumb',
6
+ elementClass: WarpSliderThumb,
7
+ react: React,
8
+ });
@@ -0,0 +1,2 @@
1
+ export * from './slider.js';
2
+ export * from './slider-thumb.js';
@@ -0,0 +1,2 @@
1
+ export * from './slider.js';
2
+ export * from './slider-thumb.js';
@@ -0,0 +1,2 @@
1
+ import polyfill from '@oddbird/css-anchor-positioning/fn';
2
+ export default polyfill;
@@ -0,0 +1,3 @@
1
+ // This file is only here to give the Storybook Vite dev server a target
2
+ import polyfill from '@oddbird/css-anchor-positioning/fn';
3
+ export default polyfill;
@@ -0,0 +1,8 @@
1
+ import { EventName } from '@lit/react';
2
+ import { WarpSlider } from './slider';
3
+ import { WarpSliderThumb } from './slider-thumb';
4
+ export declare const Slider: import("@lit/react").ReactWebComponent<WarpSlider, {}>;
5
+ export declare const SliderThumb: import("@lit/react").ReactWebComponent<WarpSliderThumb, {
6
+ onSliderValidity: EventName<CustomEvent>;
7
+ 'onslider-validity': EventName<CustomEvent>;
8
+ }>;
@@ -0,0 +1,20 @@
1
+ import { LitElement } from 'lit';
2
+ import React from 'react';
3
+ import { createComponent } from '@lit/react';
4
+ // decouple from CDN by providing a dummy class
5
+ class Component extends LitElement {
6
+ }
7
+ export const Slider = createComponent({
8
+ tagName: 'w-slider',
9
+ elementClass: Component,
10
+ react: React,
11
+ });
12
+ export const SliderThumb = createComponent({
13
+ tagName: 'w-slider-thumb',
14
+ elementClass: Component,
15
+ react: React,
16
+ events: {
17
+ onSliderValidity: 'slidervalidity',
18
+ 'onslider-validity': 'slidervalidity', // should be slider-validity
19
+ },
20
+ });
@@ -0,0 +1,57 @@
1
+ import { LitElement, PropertyValues } from 'lit';
2
+ import type { WarpTextField } from '../textfield/index.js';
3
+ declare const WarpSliderThumb_base: import("@open-wc/form-control").Constructor<import("@open-wc/form-control").FormControlInterface> & typeof LitElement;
4
+ /**
5
+ * Component to place inside a `<w-slider>`.
6
+ *
7
+ * [See Storybook for usage examples](https://warp-ds.github.io/elements/?path=/docs/forms-slider-and-range-slider--docs)
8
+ */
9
+ declare class WarpSliderThumb extends WarpSliderThumb_base {
10
+ #private;
11
+ static shadowRootOptions: {
12
+ delegatesFocus: boolean;
13
+ mode: ShadowRootMode;
14
+ serializable?: boolean;
15
+ slotAssignment?: SlotAssignmentMode;
16
+ };
17
+ static styles: import("lit").CSSResult[];
18
+ ariaLabel: string;
19
+ ariaDescription: string;
20
+ label: string;
21
+ name: string;
22
+ value: string;
23
+ disabled: boolean;
24
+ /** Set by `<w-slider>` */
25
+ markers: string;
26
+ /** Set by `<w-slider>` */
27
+ required: boolean;
28
+ /** Set by `<w-slider>` */
29
+ step: number;
30
+ /** Set by `<w-slider>` */
31
+ min: string;
32
+ /** Set by `<w-slider>` */
33
+ max: string;
34
+ /** Set by `<w-slider>` */
35
+ suffix: string;
36
+ /** @internal */
37
+ forceDisabled: boolean;
38
+ /** @internal */
39
+ forceInvalid: boolean;
40
+ /** JS hook to help you format the numeric value how you want. */
41
+ formatter: (value: string) => string;
42
+ range: HTMLInputElement;
43
+ textfield: WarpTextField;
44
+ /** @internal */
45
+ _invalid: boolean;
46
+ /** @internal */
47
+ _showTooltip: boolean;
48
+ /**
49
+ * Reference to the anchor positioning style element used by the polyfill.
50
+ * @internal
51
+ */
52
+ anchorPositioningStyleElement: HTMLStyleElement | null;
53
+ connectedCallback(): Promise<void>;
54
+ updated(changedProperties: PropertyValues<this>): void;
55
+ render(): import("lit").TemplateResult<1>;
56
+ }
57
+ export { WarpSliderThumb };