@warp-ds/elements 2.5.1-next.1 → 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 (29) 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 +131 -0
  4. package/dist/index.d.ts +96 -0
  5. package/dist/packages/pagination/locales/da/messages.d.mts +1 -0
  6. package/dist/packages/pagination/locales/da/messages.mjs +1 -0
  7. package/dist/packages/pagination/locales/en/messages.d.mts +1 -0
  8. package/dist/packages/pagination/locales/en/messages.mjs +1 -0
  9. package/dist/packages/pagination/locales/fi/messages.d.mts +1 -0
  10. package/dist/packages/pagination/locales/fi/messages.mjs +1 -0
  11. package/dist/packages/pagination/locales/nb/messages.d.mts +1 -0
  12. package/dist/packages/pagination/locales/nb/messages.mjs +1 -0
  13. package/dist/packages/pagination/locales/sv/messages.d.mts +1 -0
  14. package/dist/packages/pagination/locales/sv/messages.mjs +1 -0
  15. package/dist/packages/pagination/pagination.d.ts +32 -0
  16. package/dist/packages/pagination/pagination.js +2503 -0
  17. package/dist/packages/pagination/pagination.js.map +7 -0
  18. package/dist/packages/pagination/pagination.react.stories.d.ts +21 -0
  19. package/dist/packages/pagination/pagination.react.stories.js +45 -0
  20. package/dist/packages/pagination/pagination.stories.d.ts +14 -0
  21. package/dist/packages/pagination/pagination.stories.js +56 -0
  22. package/dist/packages/pagination/pagination.test.d.ts +1 -0
  23. package/dist/packages/pagination/pagination.test.js +76 -0
  24. package/dist/packages/pagination/react.d.ts +5 -0
  25. package/dist/packages/pagination/react.js +15 -0
  26. package/dist/packages/pagination/styles.d.ts +1 -0
  27. package/dist/packages/pagination/styles.js +2 -0
  28. package/dist/web-types.json +40 -1
  29. package/package.json +5 -1
@@ -3,6 +3,7 @@
3
3
  *
4
4
  * - Empty strings are treated as not set.
5
5
  * - Boolean false don't get set.
6
+ * - camelCase property names are converted to kebab-case attribute names.
6
7
  *
7
8
  * @example
8
9
  * ```ts
@@ -1,8 +1,16 @@
1
+ /**
2
+ * Converts camelCase to kebab-case.
3
+ * @example camelToKebab('openOnFocus') // 'open-on-focus'
4
+ */
5
+ function camelToKebab(str) {
6
+ return str.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
7
+ }
1
8
  /**
2
9
  * Massages storybook args before being spread to HTML attributes.
3
10
  *
4
11
  * - Empty strings are treated as not set.
5
12
  * - Boolean false don't get set.
13
+ * - camelCase property names are converted to kebab-case attribute names.
6
14
  *
7
15
  * @example
8
16
  * ```ts
@@ -26,27 +34,27 @@
26
34
  * ```
27
35
  */
28
36
  export function prespread(args) {
29
- const newArgs = {
30
- ...args,
31
- };
32
- for (const field of Object.keys(newArgs)) {
37
+ const newArgs = {};
38
+ for (const field of Object.keys(args)) {
33
39
  const value = args[field];
40
+ // Skip empty strings
41
+ if (value === '') {
42
+ continue;
43
+ }
44
+ // Convert camelCase to kebab-case for attribute names
45
+ const attrName = camelToKebab(field);
34
46
  // Add Lit syntax for boolean attributes
35
47
  if (typeof value === 'boolean') {
36
- newArgs[`?${field}`] = value;
37
- delete newArgs[field];
48
+ newArgs[`?${attrName}`] = value;
49
+ continue;
38
50
  }
39
- // Add Lit syntax for complex properties
51
+ // Add Lit syntax for complex properties (keep camelCase for properties)
40
52
  if (typeof value === 'object') {
41
53
  newArgs[`.${field}`] = value;
42
- delete newArgs[field];
43
- }
44
- // The manifest has a bunch of default empty strings (which we should probably investigate)
45
- // that turn on features that should be off in Storybook canvases.
46
- // Remove the empty strings.
47
- if (newArgs[field] === '') {
48
- delete newArgs[field];
54
+ continue;
49
55
  }
56
+ // String and number values use kebab-case attribute names
57
+ newArgs[attrName] = value;
50
58
  }
51
59
  return newArgs;
52
60
  }
@@ -4858,6 +4858,137 @@
4858
4858
  }
4859
4859
  }
4860
4860
  ]
4861
+ },
4862
+ {
4863
+ "kind": "javascript-module",
4864
+ "path": "packages/pagination/pagination.ts",
4865
+ "declarations": [
4866
+ {
4867
+ "kind": "class",
4868
+ "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)",
4869
+ "name": "WarpPagination",
4870
+ "members": [
4871
+ {
4872
+ "kind": "field",
4873
+ "name": "baseUrl",
4874
+ "type": {
4875
+ "text": "string"
4876
+ },
4877
+ "attribute": "base-url",
4878
+ "reflects": true
4879
+ },
4880
+ {
4881
+ "kind": "field",
4882
+ "name": "pages",
4883
+ "type": {
4884
+ "text": "number"
4885
+ },
4886
+ "attribute": "pages",
4887
+ "reflects": true
4888
+ },
4889
+ {
4890
+ "kind": "field",
4891
+ "name": "currentPageNumber",
4892
+ "type": {
4893
+ "text": "number"
4894
+ },
4895
+ "default": "1",
4896
+ "attribute": "current-page",
4897
+ "reflects": true
4898
+ },
4899
+ {
4900
+ "kind": "field",
4901
+ "name": "visiblePages",
4902
+ "type": {
4903
+ "text": "number"
4904
+ },
4905
+ "default": "7",
4906
+ "attribute": "visible-pages",
4907
+ "reflects": true
4908
+ },
4909
+ {
4910
+ "kind": "method",
4911
+ "name": "#dispatchClickPage",
4912
+ "privacy": "private",
4913
+ "parameters": [
4914
+ {
4915
+ "name": "e",
4916
+ "type": {
4917
+ "text": "PointerEvent"
4918
+ }
4919
+ }
4920
+ ]
4921
+ }
4922
+ ],
4923
+ "events": [
4924
+ {
4925
+ "name": "page-click",
4926
+ "type": {
4927
+ "text": "CustomEvent"
4928
+ },
4929
+ "description": "Triggered when a link button in the pagination is clicked. Contains the page number in `string` form."
4930
+ }
4931
+ ],
4932
+ "attributes": [
4933
+ {
4934
+ "name": "base-url",
4935
+ "type": {
4936
+ "text": "string"
4937
+ },
4938
+ "fieldName": "baseUrl"
4939
+ },
4940
+ {
4941
+ "name": "pages",
4942
+ "type": {
4943
+ "text": "number"
4944
+ },
4945
+ "fieldName": "pages"
4946
+ },
4947
+ {
4948
+ "name": "current-page",
4949
+ "type": {
4950
+ "text": "number"
4951
+ },
4952
+ "default": "1",
4953
+ "fieldName": "currentPageNumber"
4954
+ },
4955
+ {
4956
+ "name": "visible-pages",
4957
+ "type": {
4958
+ "text": "number"
4959
+ },
4960
+ "default": "7",
4961
+ "fieldName": "visiblePages"
4962
+ }
4963
+ ],
4964
+ "superclass": {
4965
+ "name": "LitElement",
4966
+ "package": "lit"
4967
+ },
4968
+ "tagName": "w-pagination",
4969
+ "customElement": true,
4970
+ "modulePath": "packages/pagination/pagination.ts",
4971
+ "definitionPath": "packages/pagination/pagination.ts"
4972
+ }
4973
+ ],
4974
+ "exports": [
4975
+ {
4976
+ "kind": "custom-element-definition",
4977
+ "name": "w-pagination",
4978
+ "declaration": {
4979
+ "name": "WarpPagination",
4980
+ "module": "packages/pagination/pagination.ts"
4981
+ }
4982
+ },
4983
+ {
4984
+ "kind": "js",
4985
+ "name": "WarpPagination",
4986
+ "declaration": {
4987
+ "name": "WarpPagination",
4988
+ "module": "packages/pagination/pagination.ts"
4989
+ }
4990
+ }
4991
+ ]
4861
4992
  }
4862
4993
  ]
4863
4994
  }
package/dist/index.d.ts CHANGED
@@ -23,6 +23,7 @@ import type { WarpTab } from "./packages/tab/tab.ts";
23
23
  import type { WarpTabPanel } from "./packages/tab-panel/tab-panel.ts";
24
24
  import type { WarpTabs } from "./packages/tabs/tabs.ts";
25
25
  import type { WIcon } from "./packages/icon/icon.ts";
26
+ import type { WarpPagination } from "./packages/pagination/pagination.ts";
26
27
 
27
28
  /**
28
29
  * This type can be used to create scoped tags for your components.
@@ -1268,6 +1269,50 @@ export type WIconSolidJsProps = {
1268
1269
  textContent?: string | number;
1269
1270
  };
1270
1271
 
1272
+ export type WarpPaginationProps = {
1273
+ /** */
1274
+ "base-url"?: WarpPagination["baseUrl"];
1275
+ /** */
1276
+ baseUrl?: WarpPagination["baseUrl"];
1277
+ /** */
1278
+ pages?: WarpPagination["pages"];
1279
+ /** */
1280
+ "current-page"?: WarpPagination["currentPageNumber"];
1281
+ /** */
1282
+ currentPageNumber?: WarpPagination["currentPageNumber"];
1283
+ /** */
1284
+ "visible-pages"?: WarpPagination["visiblePages"];
1285
+ /** */
1286
+ visiblePages?: WarpPagination["visiblePages"];
1287
+
1288
+ /** Triggered when a link button in the pagination is clicked. Contains the page number in `string` form. */
1289
+ "onpage-click"?: (e: CustomEvent) => void;
1290
+ };
1291
+
1292
+ export type WarpPaginationSolidJsProps = {
1293
+ /** */
1294
+ "attr:base-url"?: WarpPagination["baseUrl"];
1295
+ /** */
1296
+ "prop:baseUrl"?: WarpPagination["baseUrl"];
1297
+ /** */
1298
+ "prop:pages"?: WarpPagination["pages"];
1299
+ /** */
1300
+ "attr:current-page"?: WarpPagination["currentPageNumber"];
1301
+ /** */
1302
+ "prop:currentPageNumber"?: WarpPagination["currentPageNumber"];
1303
+ /** */
1304
+ "attr:visible-pages"?: WarpPagination["visiblePages"];
1305
+ /** */
1306
+ "prop:visiblePages"?: WarpPagination["visiblePages"];
1307
+ /** Triggered when a link button in the pagination is clicked. Contains the page number in `string` form. */
1308
+ "on:page-click"?: (e: CustomEvent) => void;
1309
+
1310
+ /** Set the innerHTML of the element */
1311
+ innerHTML?: string;
1312
+ /** Set the textContent of the element */
1313
+ textContent?: string | number;
1314
+ };
1315
+
1271
1316
  export type CustomElements = {
1272
1317
  /**
1273
1318
  * This component is usually used in other components like form elements to show a prefix or suffix. See for example `w-textfield`.
@@ -1910,6 +1955,30 @@ export type CustomElements = {
1910
1955
  * - `locale`: Locale used in CDN URL
1911
1956
  */
1912
1957
  "w-icon": Partial<WIconProps & BaseProps<WIcon> & BaseEvents>;
1958
+
1959
+ /**
1960
+ * Pagination allows users to navigate through multiple pages of content by providing navigation controls with page numbers and directional arrows.
1961
+ *
1962
+ * [See Storybook for usage examples](https://warp-ds.github.io/elements/?path=/docs/navigation-pagination--docs)
1963
+ *
1964
+ * ## Attributes & Properties
1965
+ *
1966
+ * Component attributes and properties that can be applied to the element or by using JavaScript.
1967
+ *
1968
+ * - `base-url`/`baseUrl`: undefined
1969
+ * - `pages`: undefined
1970
+ * - `current-page`/`currentPageNumber`: undefined
1971
+ * - `visible-pages`/`visiblePages`: undefined
1972
+ *
1973
+ * ## Events
1974
+ *
1975
+ * Events that will be emitted by the component.
1976
+ *
1977
+ * - `page-click`: Triggered when a link button in the pagination is clicked. Contains the page number in `string` form.
1978
+ */
1979
+ "w-pagination": Partial<
1980
+ WarpPaginationProps & BaseProps<WarpPagination> & BaseEvents
1981
+ >;
1913
1982
  };
1914
1983
 
1915
1984
  export type CustomElementsSolidJs = {
@@ -2624,6 +2693,33 @@ export type CustomElementsSolidJs = {
2624
2693
  "w-icon": Partial<
2625
2694
  WIconProps & WIconSolidJsProps & BaseProps<WIcon> & BaseEvents
2626
2695
  >;
2696
+
2697
+ /**
2698
+ * Pagination allows users to navigate through multiple pages of content by providing navigation controls with page numbers and directional arrows.
2699
+ *
2700
+ * [See Storybook for usage examples](https://warp-ds.github.io/elements/?path=/docs/navigation-pagination--docs)
2701
+ *
2702
+ * ## Attributes & Properties
2703
+ *
2704
+ * Component attributes and properties that can be applied to the element or by using JavaScript.
2705
+ *
2706
+ * - `base-url`/`baseUrl`: undefined
2707
+ * - `pages`: undefined
2708
+ * - `current-page`/`currentPageNumber`: undefined
2709
+ * - `visible-pages`/`visiblePages`: undefined
2710
+ *
2711
+ * ## Events
2712
+ *
2713
+ * Events that will be emitted by the component.
2714
+ *
2715
+ * - `page-click`: Triggered when a link button in the pagination is clicked. Contains the page number in `string` form.
2716
+ */
2717
+ "w-pagination": Partial<
2718
+ WarpPaginationProps &
2719
+ WarpPaginationSolidJsProps &
2720
+ BaseProps<WarpPagination> &
2721
+ BaseEvents
2722
+ >;
2627
2723
  };
2628
2724
 
2629
2725
  export type CustomCssProperties = {};
@@ -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 };