@ostack.tech/ui 1.3.0-beta.2 → 1.3.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.
Files changed (36) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +13 -1
  3. package/dist/chunks/{en-W4OWqPrv.js → en-Czf-_HZt.js} +9 -11
  4. package/dist/chunks/en-Czf-_HZt.js.map +1 -0
  5. package/dist/locales/en-GB.js +1 -1
  6. package/dist/locales/en-US.js +1 -1
  7. package/dist/locales/fr-FR.js +8 -10
  8. package/dist/locales/fr-FR.js.map +1 -1
  9. package/dist/locales/pt-PT.js +8 -10
  10. package/dist/locales/pt-PT.js.map +1 -1
  11. package/dist/ostack-ui.css +69 -6
  12. package/dist/ostack-ui.js +854 -540
  13. package/dist/ostack-ui.js.map +1 -1
  14. package/package.json +3 -1
  15. package/scss/_utils.scss +1 -0
  16. package/scss/components/ButtonGroup/_ButtonGroup.scss +2 -5
  17. package/scss/components/Pagination/_Pagination-variables.scss +89 -0
  18. package/scss/components/Pagination/_Pagination.scss +135 -0
  19. package/scss/components/Select/_Select-variables.scss +1 -1
  20. package/scss/components/Tabs/_Tabs-variables.scss +1 -1
  21. package/scss/components/Tabs/_Tabs.scss +3 -2
  22. package/scss/index.scss +1 -0
  23. package/scss/scss/placeholders/button/_button-variables.scss +3 -0
  24. package/scss/scss/placeholders/button/_button.scss +4 -3
  25. package/scss/scss/placeholders/menu/_menu-variables.scss +4 -1
  26. package/scss/scss/placeholders/menu/_menu.scss +4 -0
  27. package/types/components/DataTable/DataTablePagination.d.ts +7 -16
  28. package/types/components/DataTable/PagedDataTablePagination.d.ts +5 -5
  29. package/types/components/DataTable/sanitizeProps.d.ts +0 -2
  30. package/types/components/Pagination/Pagination.d.ts +93 -0
  31. package/types/components/Pagination/index.d.ts +1 -0
  32. package/types/components/Pagination/paginationItems.d.ts +7 -0
  33. package/types/index.d.ts +1 -0
  34. package/types/providers/LocalizationProvider/LocalizationObject.d.ts +3 -1
  35. package/types/utils/sanitizeProps.d.ts +2 -0
  36. package/dist/chunks/en-W4OWqPrv.js.map +0 -1
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@ostack.tech/ui",
3
- "version": "1.3.0-beta.2",
3
+ "version": "1.3.0",
4
4
  "description": "Accessible React component library.",
5
5
  "homepage": "https://ui.ostack.tech/",
6
+ "license": "Apache-2.0",
6
7
  "author": {
7
8
  "name": "Opensoft",
8
9
  "url": "https://opensoft.pt/en/"
@@ -43,6 +44,7 @@
43
44
  "./package.json": "./package.json"
44
45
  },
45
46
  "scripts": {
47
+ "prepack": "cpy ../../LICENSE ./",
46
48
  "build": "tsc -b && vite build && npm run copy:scss",
47
49
  "copy:scss": "cpy 'src/**/*.scss' '!src/**/*.stories.scss' scss/",
48
50
  "test": "vitest --run"
package/scss/_utils.scss CHANGED
@@ -50,6 +50,7 @@
50
50
  @forward "components/Link/Link-variables";
51
51
  @forward "components/Mark/Mark-variables";
52
52
  @forward "components/Overlay/Overlay-variables";
53
+ @forward "components/Pagination/Pagination-variables";
53
54
  @forward "components/RadioGroup/Radio-variables";
54
55
  @forward "components/Root/Root-variables";
55
56
  @forward "components/Select/Select-variables";
@@ -6,14 +6,11 @@
6
6
  @use "../../scss/utils/spacing" as *;
7
7
 
8
8
  .#{$prefix}button-group {
9
- $button: ".#{$prefix}button";
10
- $icon-button: ".#{$prefix}icon-button";
11
-
12
9
  position: relative;
13
10
  display: inline-flex;
14
11
 
15
- > #{$button},
16
- > #{$icon-button} {
12
+ > .#{$prefix}button,
13
+ > .#{$prefix}icon-button {
17
14
  position: relative;
18
15
  flex: 1 1 auto;
19
16
 
@@ -0,0 +1,89 @@
1
+ @use "../../scss/base-variables" as *;
2
+ @use "../../scss/utils/spacing" as *;
3
+ @use "../../scss/utils/css-color-functions" as *;
4
+ @use "../../scss/placeholders/button/button-variables" as *;
5
+ @use "../IconButton/IconButton-variables" as *;
6
+
7
+ // Layout
8
+ $pagination-grouped: false !default;
9
+ $pagination-gap-x: spacing(0.5) !default;
10
+
11
+ // Button
12
+ $pagination-button-padding-y: 0 !default;
13
+ $pagination-button-padding-x: 0.25em !default;
14
+ $pagination-button-background-color: null !default;
15
+ $pagination-button-background-image: null !default;
16
+ $pagination-button-color: var(--#{$prefix}neutral-a12) !default;
17
+ $pagination-button-border-color: null !default;
18
+ $pagination-button-box-shadow: null !default;
19
+ $pagination-button-font-family: null !default;
20
+ $pagination-button-font-weight: $font-weight-normal !default;
21
+
22
+ // Button - Hover
23
+ $pagination-button-hover-background-color: null !default;
24
+ $pagination-button-hover-background-image: null !default;
25
+ $pagination-button-hover-color: null !default;
26
+ $pagination-button-hover-border-color: null !default;
27
+ $pagination-button-hover-box-shadow: null !default;
28
+ $pagination-button-hover-z-index: null !default;
29
+
30
+ // Button - Current
31
+ $pagination-button-current-background-color: var(--#{$prefix}neutral-a4) !default;
32
+ $pagination-button-current-background-image: null !default;
33
+ $pagination-button-current-color: null !default;
34
+ $pagination-button-current-border-color: null !default;
35
+ $pagination-button-current-box-shadow: null !default;
36
+ $pagination-button-current-z-index: $pagination-button-hover-z-index !default;
37
+
38
+ // Button - Current + Hover
39
+ $pagination-button-current-hover-background-color: null !default;
40
+ $pagination-button-current-hover-background-image: null !default;
41
+ $pagination-button-current-hover-color: null !default;
42
+ $pagination-button-current-hover-border-color: null !default;
43
+ $pagination-button-current-hover-box-shadow: null !default;
44
+
45
+ // Button - Current + Active
46
+ $pagination-button-current-active-background-color: null !default;
47
+ $pagination-button-current-active-background-image: null !default;
48
+ $pagination-button-current-active-color: null !default;
49
+ $pagination-button-current-active-border-color: null !default;
50
+ $pagination-button-current-active-box-shadow: null !default;
51
+
52
+ // Button - Current + Focus
53
+ $pagination-button-current-focus-outline-offset: null !default;
54
+ $pagination-button-current-focus-outline-color: null !default;
55
+ $pagination-button-current-focus-z-index: null !default;
56
+
57
+ // Button - Size
58
+ $pagination-button-sm-min-size: $icon-button-sm-min-size !default;
59
+ $pagination-button-md-min-size: $icon-button-md-min-size !default;
60
+ $pagination-button-lg-min-size: $icon-button-lg-min-size !default;
61
+ $pagination-button-xl-min-size: $icon-button-xl-min-size !default;
62
+
63
+ // Arrow
64
+ $pagination-arrow-color: var(--#{$prefix}neutral-a12) !default;
65
+
66
+ // Arrow - Size
67
+ $pagination-arrow-sm-font-size: var(--#{$prefix}font-size-2xs) !default;
68
+ $pagination-arrow-md-font-size: var(--#{$prefix}font-size-xs) !default;
69
+ $pagination-arrow-lg-font-size: var(--#{$prefix}font-size-sm) !default;
70
+ $pagination-arrow-xl-font-size: var(--#{$prefix}font-size-md) !default;
71
+
72
+ // Ellipsis
73
+ $pagination-ellipsis-color: var(--#{$prefix}neutral-a11) !default;
74
+
75
+ // Sizes
76
+ $pagination-sizes: $icon-button-sizes !default;
77
+
78
+ $pagination-button-min-size-by-size: (
79
+ sm: $pagination-button-sm-min-size,
80
+ md: $pagination-button-md-min-size,
81
+ lg: $pagination-button-lg-min-size,
82
+ xl: $pagination-button-xl-min-size,
83
+ ) !default;
84
+ $pagination-arrow-font-size-by-size: (
85
+ sm: $pagination-arrow-sm-font-size,
86
+ md: $pagination-arrow-md-font-size,
87
+ lg: $pagination-arrow-lg-font-size,
88
+ xl: $pagination-arrow-xl-font-size,
89
+ ) !default;
@@ -0,0 +1,135 @@
1
+ @use "sass:map";
2
+ @use "Pagination-variables" as *;
3
+ @use "../../scss/base-variables" as *;
4
+ @use "../../scss/utils/declare-var" as *;
5
+ @use "../../scss/utils/spacing" as *;
6
+
7
+ .#{$prefix}pagination {
8
+ min-width: 0;
9
+ width: auto;
10
+
11
+ &__list {
12
+ display: inline-flex;
13
+ align-items: stretch;
14
+ margin: 0;
15
+ padding: 0;
16
+ list-style: none;
17
+ }
18
+
19
+ &__item {
20
+ display: flex;
21
+ }
22
+
23
+ &__item:not(:first-child) > &__button {
24
+ margin-left: $pagination-gap-x;
25
+
26
+ @if $pagination-grouped {
27
+ border-top-left-radius: 0;
28
+ border-bottom-left-radius: 0;
29
+ }
30
+ }
31
+
32
+ @if $pagination-grouped {
33
+ &__item:not(:last-child) > &__button {
34
+ border-top-right-radius: 0;
35
+ border-bottom-right-radius: 0;
36
+ }
37
+ }
38
+
39
+ // Button
40
+ &__button {
41
+ position: relative;
42
+ min-width: var(--#{$prefix}pagination-button-min-size);
43
+ min-height: var(--#{$prefix}pagination-button-min-size);
44
+
45
+ background-color: $pagination-button-background-color;
46
+ background-image: $pagination-button-background-image;
47
+ color: $pagination-button-color;
48
+ border-color: $pagination-button-border-color;
49
+ box-shadow: $pagination-button-box-shadow;
50
+ font-family: $pagination-button-font-family;
51
+ font-weight: $pagination-button-font-weight;
52
+
53
+ &:not([data-current]:hover) {
54
+ transition: none;
55
+ }
56
+
57
+ &:hover:not(:disabled, [data-disabled]) {
58
+ background-color: $pagination-button-hover-background-color;
59
+ background-image: $pagination-button-hover-background-image;
60
+ color: $pagination-button-hover-color;
61
+ border-color: $pagination-button-hover-border-color;
62
+ box-shadow: $pagination-button-hover-box-shadow;
63
+ z-index: $pagination-button-hover-z-index;
64
+ }
65
+
66
+ &[data-current] {
67
+ background-color: $pagination-button-current-background-color;
68
+ background-image: $pagination-button-current-background-image;
69
+ color: $pagination-button-current-color;
70
+ border-color: $pagination-button-current-border-color;
71
+ box-shadow: $pagination-button-current-box-shadow;
72
+ z-index: $pagination-button-current-z-index;
73
+
74
+ &:hover:not(:disabled, [data-disabled]) {
75
+ background-color: $pagination-button-current-hover-background-color;
76
+ background-image: $pagination-button-current-hover-background-image;
77
+ color: $pagination-button-current-hover-color;
78
+ border-color: $pagination-button-current-hover-border-color;
79
+ box-shadow: $pagination-button-current-hover-box-shadow;
80
+ }
81
+
82
+ &:active:not(:disabled, [data-disabled]) {
83
+ background-color: $pagination-button-current-active-background-color;
84
+ background-image: $pagination-button-current-active-background-image;
85
+ color: $pagination-button-current-active-color;
86
+ border-color: $pagination-button-current-active-border-color;
87
+ box-shadow: $pagination-button-current-active-box-shadow;
88
+ }
89
+
90
+ &:focus-visible {
91
+ outline-offset: $pagination-button-current-focus-outline-offset;
92
+ outline-color: $pagination-button-current-focus-outline-color;
93
+ z-index: $pagination-button-current-focus-z-index;
94
+ }
95
+ }
96
+ }
97
+
98
+ &__page,
99
+ &__ellipsis {
100
+ padding: $pagination-button-padding-y $pagination-button-padding-x;
101
+ }
102
+
103
+ // Ellipsis
104
+ &__ellipsis {
105
+ color: $pagination-ellipsis-color;
106
+ pointer-events: none;
107
+ }
108
+
109
+ // Arrow
110
+ &__arrow {
111
+ @if ($pagination-arrow-color != NULL) {
112
+ color: $pagination-arrow-color;
113
+ }
114
+ font-size: var(--#{$prefix}pagination-arrow-font-size);
115
+ }
116
+
117
+ // Loading
118
+ &__loading > .#{$prefix}button__spinner {
119
+ margin: 0;
120
+ }
121
+
122
+ // Sizes
123
+ @each $size in $pagination-sizes {
124
+ &__button:is(.#{$prefix}button--#{$size}, .#{$prefix}icon-button--#{$size}) {
125
+ @include declare-var(
126
+ --#{$prefix}pagination-button-min-size,
127
+ map.get($pagination-button-min-size-by-size, $size)
128
+ );
129
+ @include declare-var(
130
+ --#{$prefix}pagination-arrow-font-size,
131
+ map.get($pagination-arrow-font-size-by-size, $size)
132
+ );
133
+ }
134
+ }
135
+ }
@@ -45,7 +45,7 @@ $select-multiple-value-tag-line-height: var(--#{$prefix}line-height-xs) !default
45
45
  $select-multiple-value-tag-text-transform: null !default;
46
46
 
47
47
  // Arrow
48
- $select-arrow-font-size: var(--#{$prefix}font-size-2xs) !default;
48
+ $select-arrow-font-size: var(--#{$prefix}font-size-xs) !default;
49
49
  $select-arrow-color: var(--#{$prefix}neutral-11) !default;
50
50
 
51
51
  // Status
@@ -169,7 +169,7 @@ $tabs-tab-inner-annexes-active-status-background-color: null !default;
169
169
  // Scroll button
170
170
  $tabs-scroll-button-padding-x: spacing(2) !default;
171
171
  $tabs-scroll-button-color: null !default;
172
- $tabs-scroll-button-font-size: var(--#{$prefix}font-size-sm) !default;
172
+ $tabs-scroll-button-font-size: null !default;
173
173
  $tabs-scroll-button-overflow-indicator-width: 4px !default;
174
174
  $tabs-scroll-button-overflow-indicator-extra-height: 4px !default;
175
175
  $tabs-scroll-button-overflow-indicator-color: var(--#{$prefix}neutral-a8) !default;
@@ -5,6 +5,7 @@
5
5
  @use "../../scss/utils/animation" as *;
6
6
  @use "../../scss/utils/button-reset" as *;
7
7
  @use "../../scss/utils/declare-var" as *;
8
+ @use "../../scss/utils/maybe-important" as *;
8
9
  @use "../../scss/utils/transition" as *;
9
10
 
10
11
  .#{$prefix}tabs {
@@ -364,8 +365,8 @@
364
365
  min-width: auto;
365
366
  min-height: auto;
366
367
  padding: 0 $tabs-scroll-button-padding-x;
367
- font-size: $tabs-scroll-button-font-size !important;
368
- color: $tabs-scroll-button-color !important;
368
+ font-size: maybe-important($tabs-scroll-button-font-size);
369
+ color: maybe-important($tabs-scroll-button-color);
369
370
 
370
371
  border-bottom-left-radius: 0;
371
372
  border-bottom-right-radius: 0;
package/scss/index.scss CHANGED
@@ -48,6 +48,7 @@
48
48
  @forward "components/MenuList/MenuList";
49
49
  @forward "components/Output/Output";
50
50
  @forward "components/Overlay/Overlay";
51
+ @forward "components/Pagination/Pagination";
51
52
  @forward "components/Popover/Popover";
52
53
  @forward "components/RadioGroup/Radio";
53
54
  @forward "components/RadioGroup/RadioGroup";
@@ -22,6 +22,9 @@ $button-disabled-opacity: 0.65 !default;
22
22
  $button-disabled-cursor: not-allowed !default;
23
23
  $button-disabled-box-shadow: none !default;
24
24
 
25
+ // Spinning
26
+ $button-spinning-cursor: progress !default;
27
+
25
28
  // Solid variant
26
29
  $button-solid-background-color: var(--#{$prefix}accent-a9) !default;
27
30
  $button-solid-background-image: null !default;
@@ -39,15 +39,16 @@
39
39
  cursor: $button-disabled-cursor;
40
40
  opacity: $button-disabled-opacity;
41
41
  box-shadow: $button-disabled-box-shadow;
42
- }
43
42
 
44
- &:focus {
45
- z-index: $button-focus-z-index;
43
+ &[data-spinning] {
44
+ cursor: $button-spinning-cursor;
45
+ }
46
46
  }
47
47
 
48
48
  &:focus-visible {
49
49
  outline: $button-focus-outline-width solid $button-focus-outline-color;
50
50
  outline-offset: var(--#{$prefix}button-focus-outline-offset);
51
+ z-index: $button-focus-z-index;
51
52
  }
52
53
 
53
54
  &[aria-haspopup][aria-expanded="true"]:not([data-inactive]) {
@@ -41,6 +41,9 @@ $menu-item-text-cursor: null !default;
41
41
  $menu-item-disabled-cursor: not-allowed !default;
42
42
  $menu-item-disabled-opacity: 0.5 !default;
43
43
 
44
+ // Item - Spinning
45
+ $menu-item-spinning-cursor: progress !default;
46
+
44
47
  // Item - Focus
45
48
  $menu-item-focus-outline-width: 2px !default;
46
49
  $menu-item-focus-outline-color: var(--#{$prefix}primary-8) !default;
@@ -208,7 +211,7 @@ $menu-item-keybinds-subtle-highlighted-selected-color: $menu-item-keybinds-subtl
208
211
  $menu-item-keybinds-subtle-highlighted-selected-accent-color: null !default;
209
212
 
210
213
  // Sub trigger icon
211
- $menu-sub-trigger-icon-font-size: var(--#{$prefix}font-size-2xs) !default;
214
+ $menu-sub-trigger-icon-font-size: var(--#{$prefix}font-size-xs) !default;
212
215
 
213
216
  // Checkable
214
217
  $menu-checkable-size: 16px !default;
@@ -101,6 +101,10 @@
101
101
  &:is(:disabled, [data-disabled]) {
102
102
  cursor: $menu-item-disabled-cursor;
103
103
  opacity: $menu-item-disabled-opacity;
104
+
105
+ &[data-spinning] {
106
+ cursor: $menu-item-spinning-cursor;
107
+ }
104
108
  }
105
109
 
106
110
  &:focus-visible {
@@ -1,21 +1,16 @@
1
1
  import type { ComponentProps, ReactNode } from "react";
2
2
  import { type UseMarginPropsOptions } from "../../utils/useMarginProps.ts";
3
- import type { IconButtonProps } from "../IconButton";
3
+ import type { PaginationProps } from "../Pagination";
4
4
  /** Properties of the data table pagination component. */
5
- export interface DataTablePaginationProps extends UseMarginPropsOptions, ComponentProps<"div"> {
5
+ export interface DataTablePaginationProps extends UseMarginPropsOptions, ComponentProps<"div">, Pick<PaginationProps, "size" | "siblingCount" | "boundaryCount" | "label" | "previousPageButtonLabel" | "nextPageButtonLabel" | "pageButtonLabel" | "previousPageButtonProps" | "nextPageButtonProps" | "pageButtonProps" | "ellipsisButtonProps" | "loadingButtonProps"> {
6
6
  /**
7
- * Function used to render the range of displayed rows.
7
+ * Function used to render the range of displayed rows (only relevant is scrolled mode).
8
8
  *
9
- * @param range Node representing the range of rows (note that, in paged mode, this is a select).
9
+ * @param rangeStart Start of the range.
10
+ * @param rangeEnd End of the range.
10
11
  * @param total Total number of rows.
11
12
  */
12
- rowsRange?: (range: ReactNode, total: number) => ReactNode;
13
- /** Label of the rows range select (only relevant in paged mode). */
14
- rowsRangeSelectLabel?: (total: number) => string;
15
- /** Label of the previous page button (only relevant in paged mode). */
16
- previousPageButtonLabel?: string;
17
- /** Label of the next page button (only relevant in paged mode). */
18
- nextPageButtonLabel?: string;
13
+ rowsRange?: (rangeStart: number, rangeEnd: number, total: number) => ReactNode;
19
14
  /**
20
15
  * Whether the component should preferably be aligned to the right. This only has an effect when
21
16
  * the component is nested directly under the `DataTable`.
@@ -23,10 +18,6 @@ export interface DataTablePaginationProps extends UseMarginPropsOptions, Compone
23
18
  * @default true
24
19
  */
25
20
  preferRightAlignment?: boolean;
26
- /** Properties to pass to the previous page button (only relevant in paged mode). */
27
- previousPageButtonProps?: IconButtonProps;
28
- /** Properties to pass to the next page button (only relevant in paged mode). */
29
- nextPageButtonProps?: IconButtonProps;
30
21
  }
31
22
  /** Component used to provide pagination to the data table. */
32
- export declare function DataTablePagination({ rowsRange: rowsRangeProp, rowsRangeSelectLabel: rowsRangeSelectLabelProp, previousPageButtonLabel: previousPageButtonLabelProp, nextPageButtonLabel: nextPageButtonLabelProp, previousPageButtonProps, nextPageButtonProps, preferRightAlignment, style, ...otherProps }: DataTablePaginationProps): import("react").JSX.Element | null;
23
+ export declare function DataTablePagination({ rowsRange: rowsRangeProp, size, siblingCount, boundaryCount, label: labelProp, previousPageButtonLabel: previousPageButtonLabelProp, nextPageButtonLabel: nextPageButtonLabelProp, pageButtonLabel: pageButtonLabelProp, previousPageButtonProps, nextPageButtonProps, pageButtonProps, ellipsisButtonProps, loadingButtonProps, preferRightAlignment, style, ...otherProps }: DataTablePaginationProps): import("react").JSX.Element | null;
@@ -1,7 +1,7 @@
1
- import { type ComponentProps } from "react";
1
+ import { type PaginationProps } from "../Pagination";
2
2
  import type { DataTablePaginationProps } from "./DataTablePagination.tsx";
3
- /** Properties of the scrolled data table pagination. */
4
- export interface PagedDataTablePaginationProps extends ComponentProps<"div">, Pick<DataTablePaginationProps, "rowsRange" | "rowsRangeSelectLabel" | "previousPageButtonLabel" | "nextPageButtonLabel" | "preferRightAlignment" | "previousPageButtonProps" | "nextPageButtonProps"> {
3
+ /** Properties of the paged data table pagination. */
4
+ export interface PagedDataTablePaginationProps extends Pick<DataTablePaginationProps, "preferRightAlignment">, Omit<PaginationProps, "count" | "defaultPage" | "page" | "onPageChange" | "disabled" | "loading"> {
5
5
  }
6
- /** Pagination component of the scrolled data table. */
7
- export declare function PagedDataTablePagination({ rowsRange, rowsRangeSelectLabel, previousPageButtonLabel, nextPageButtonLabel, preferRightAlignment, previousPageButtonProps, nextPageButtonProps, className, "aria-label": ariaLabelProp, ...otherProps }: PagedDataTablePaginationProps): import("react").JSX.Element;
6
+ /** Pagination component of the paged data table. */
7
+ export declare function PagedDataTablePagination({ preferRightAlignment, className, ...otherProps }: PagedDataTablePaginationProps): import("react").JSX.Element;
@@ -1,7 +1,5 @@
1
1
  import type { SortDirection } from "../../utils/sorting.ts";
2
2
  import type { DataTableColumnObject } from "./DataTableColumn.tsx";
3
- /** Sanitizes an integer property. */
4
- export declare function sanitizeInt(value: number | string | undefined): number | undefined;
5
3
  /** Sanitizes the `sortBy` property. */
6
4
  export declare function sanitizeSortBy<T>(sortBy: string | null | undefined, leaves: Record<string, DataTableColumnObject<T>>): string | null | undefined;
7
5
  /** Sanitizes the `sortDirection` property. */
@@ -0,0 +1,93 @@
1
+ import { type ComponentProps, type ReactNode } from "react";
2
+ import { type ButtonColor, type ButtonProps, type ButtonSize, type ButtonVariant } from "../Button";
3
+ import { type IconButtonProps } from "../IconButton";
4
+ /** Pagination buttons' variant. */
5
+ export type PaginationVariant = ButtonVariant;
6
+ /** Pagination button's colour. */
7
+ export type PaginationColor = ButtonColor;
8
+ /** Pagination buttons' size. */
9
+ export type PaginationSize = ButtonSize;
10
+ /** Properties of the pagination component. */
11
+ export interface PaginationProps extends ComponentProps<"nav"> {
12
+ /** Total number of pages. */
13
+ count: number;
14
+ /**
15
+ * Default (uncontrolled) current page, starting at `1`.
16
+ *
17
+ * @default 1
18
+ */
19
+ defaultPage?: string | number;
20
+ /** Controlled current page, starting at `1`. Use together with `onPageChange`. */
21
+ page?: string | number;
22
+ /** Function called with the new page (starting at `1`) when the page changes. */
23
+ onPageChange?: (page: number) => void;
24
+ /**
25
+ * Size of the pagination buttons.
26
+ *
27
+ * @default "md"
28
+ */
29
+ size?: PaginationSize;
30
+ /**
31
+ * Number of pages shown on each side of the current page.
32
+ *
33
+ * @default 1
34
+ */
35
+ siblingCount?: number;
36
+ /**
37
+ * Number of pages always shown at the start and end.
38
+ *
39
+ * @default 1
40
+ */
41
+ boundaryCount?: number;
42
+ /** Whether to disable all pagination buttons. */
43
+ disabled?: boolean;
44
+ /**
45
+ * Renders the pagination in a **loading** state.
46
+ *
47
+ * When `true`, the page buttons are replaced by a single loading indicator, and the previous/next
48
+ * page buttons are “soft-disabled”: they look disabled and ignore user interaction but remain
49
+ * focusable.
50
+ *
51
+ * @default false
52
+ */
53
+ loading?: boolean;
54
+ /** Navigation's label (for assistive technologies). */
55
+ label?: ReactNode;
56
+ /** Label of the previous page button. */
57
+ previousPageButtonLabel?: ReactNode;
58
+ /** Label of the next page button. */
59
+ nextPageButtonLabel?: ReactNode;
60
+ /** Accessible label of each page button. */
61
+ pageButtonLabel?: (page: string) => ReactNode;
62
+ /** Properties to pass to the previous page button. */
63
+ previousPageButtonProps?: Partial<IconButtonProps>;
64
+ /** Properties to pass to the next page button. */
65
+ nextPageButtonProps?: Partial<IconButtonProps>;
66
+ /** Properties to pass to each page button. */
67
+ pageButtonProps?: Omit<ButtonProps, "children">;
68
+ /** Properties to pass to each ellipsis button. */
69
+ ellipsisButtonProps?: Omit<ButtonProps, "children">;
70
+ /** Properties to pass to the loading button. */
71
+ loadingButtonProps?: Omit<ButtonProps, "children">;
72
+ }
73
+ /**
74
+ * The pagination component allows users to navigate between pages of content.
75
+ *
76
+ * Pages are numbered starting at `1`.
77
+ *
78
+ * Built on top of the browser's [`<nav>`
79
+ * element](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/nav) and the
80
+ * [`Button`](/docs/ostack-ui-forms-button--docs)/[`IconButton`](/docs/ostack-ui-forms-icon-button--docs)
81
+ * components.
82
+ *
83
+ * Example usage:
84
+ *
85
+ * ```tsx
86
+ * import { Pagination } from "@ostack.tech/ui";
87
+ *
88
+ * function SearchResultsPagination() {
89
+ * return <Pagination count={20} />;
90
+ * }
91
+ * ```
92
+ */
93
+ export declare function Pagination({ count, defaultPage, page: controllablePage, onPageChange, size, siblingCount, boundaryCount, disabled, loading, label: labelProp, previousPageButtonLabel: previousPageButtonLabelProp, nextPageButtonLabel: nextPageButtonLabelProp, pageButtonLabel: pageButtonLabelProp, previousPageButtonProps, nextPageButtonProps, pageButtonProps, ellipsisButtonProps, loadingButtonProps, className, ...otherProps }: PaginationProps): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ export * from "./Pagination.tsx";
@@ -0,0 +1,7 @@
1
+ /** Item of a pagination: a page number or an ellipsis. */
2
+ export type PaginationItem = number | "start-ellipsis" | "end-ellipsis";
3
+ /**
4
+ * Computes the items to display in a pagination, e.g. `[1, "start-ellipsis", 4, 5, 6,
5
+ * "end-ellipsis", 20]`.
6
+ */
7
+ export declare function paginationItems(page: number, count: number, siblingCount: number, boundaryCount: number): PaginationItem[];
package/types/index.d.ts CHANGED
@@ -44,6 +44,7 @@ export * from "./components/Mark";
44
44
  export * from "./components/MenuList";
45
45
  export * from "./components/NumericInput";
46
46
  export * from "./components/Output";
47
+ export * from "./components/Pagination";
47
48
  export * from "./components/Popover";
48
49
  export * from "./components/Portal";
49
50
  export * from "./components/Printer";
@@ -16,6 +16,7 @@ import type { InputProps } from "../../components/Input";
16
16
  import type { KeybindsProps } from "../../components/Keybinds";
17
17
  import type { LabelProps } from "../../components/Label";
18
18
  import type { NumericInputProps } from "../../components/NumericInput";
19
+ import type { PaginationProps } from "../../components/Pagination/Pagination.tsx";
19
20
  import type { RadioGroupProps } from "../../components/RadioGroup";
20
21
  import type { SelectProps } from "../../components/Select";
21
22
  import type { StepperFinishTriggerChildlessProps, StepperNextTriggerChildlessProps, StepperPreviousTriggerChildlessProps, StepProps } from "../../components/Stepper";
@@ -40,7 +41,7 @@ export interface LocalizationObject {
40
41
  DataTable: Pick<DataTableProps, "selectAllRowsLabel" | "selectRowLabel">;
41
42
  DataTableContent: Pick<DataTableContentProps, "emptyMessage">;
42
43
  DataTableFilter: Pick<DataTableFilterProps, "aria-label" | "placeholder">;
43
- DataTablePagination: Pick<DataTablePaginationProps, "aria-label" | "rowsRange" | "rowsRangeSelectLabel" | "previousPageButtonLabel" | "nextPageButtonLabel">;
44
+ DataTablePagination: Pick<DataTablePaginationProps, "rowsRange" | "label" | "previousPageButtonLabel" | "nextPageButtonLabel" | "pageButtonLabel">;
44
45
  DataTableRowsPerPage: Pick<DataTableRowsPerPageProps, "label">;
45
46
  DateInput: Pick<DateInputProps, "format" | "announcedFormat" | "placeholder" | "formatDescription" | "selectedDateDescription" | "calendarButtonLabel">;
46
47
  DateRangeInput: Pick<DateRangeInputProps, "startInputLabel" | "endInputLabel" | "selectedDateRangeDescription" | "calendarButtonLabel">;
@@ -53,6 +54,7 @@ export interface LocalizationObject {
53
54
  Keybinds: Pick<KeybindsProps, "keybindsSeparatorLabel" | "keyPressesSeparatorLabel" | "keysSeparatorLabel" | "keySymbols" | "keyLabels">;
54
55
  Label: Pick<LabelProps, "helperButtonLabel">;
55
56
  NumericInput: Pick<NumericInputProps, "decimalSeparator" | "groupingStyle" | "groupSeparator">;
57
+ Pagination: Pick<PaginationProps, "label" | "previousPageButtonLabel" | "nextPageButtonLabel" | "pageButtonLabel">;
56
58
  RadioGroup: Pick<RadioGroupProps, "clearDescription">;
57
59
  Select: Pick<SelectProps, "placeholder" | "clearDescription" | "searchLabel" | "searchPlaceholder" | "emptyMessage" | "optionsLabel" | "loadingOptionsLabel" | "valueTagCloseButtonLabel">;
58
60
  Step: Pick<StepProps, "stepNumberLabel" | "completedLabel">;
@@ -0,0 +1,2 @@
1
+ /** Sanitizes an integer property. */
2
+ export declare function sanitizeInt(value: number | string | undefined): number | undefined;
@@ -1 +0,0 @@
1
- {"version":3,"file":"en-W4OWqPrv.js","names":["_Fragment"],"sources":["../../src/locales/en.tsx"],"sourcesContent":["import type { LocalizationObject } from \"../providers/LocalizationProvider\";\nimport { IS_APPLE } from \"../utils/platformUtils.ts\";\n\n/** `en` locale (partial). */\nexport const en: Omit<LocalizationObject, \"languageTag\" | \"dayPickerLocale\"> = {\n ActionSplit: {\n splitLabel: \"More options\",\n },\n ActionsSecondary: {\n label: \"More actions\",\n },\n AlertDialog: {\n okText: \"OK\",\n },\n Calendar: {\n monthSelectLabel: \"Month\",\n yearSelectLabel: \"Year\",\n previousMonthLabel: \"Previous month\",\n nextMonthLabel: \"Next month\",\n },\n CloseButton: {\n label: \"Close\",\n },\n CollapsibleTrigger: {\n expandLabel: \"Show\",\n collapseLabel: \"Hide\",\n },\n CommandMenu: {\n searchPlaceholder: \"Search…\",\n listLabel: \"Suggestions\",\n loadingLabel: \"Loading…\",\n emptyMessage: \"No results found.\",\n },\n CommandMenuDialog: {\n title: \"Command palette\",\n description: \"Search for a command…\",\n },\n ConfirmDialog: {\n cancelText: \"Cancel\",\n },\n ControlCode: {\n visuallyHiddenPrefix: \"Field\",\n },\n DataTable: {\n selectAllRowsLabel: \"Select all\",\n selectRowLabel: \"Select\",\n },\n DataTableContent: {\n emptyMessage: \"Nothing to show.\",\n },\n DataTableFilter: {\n \"aria-label\": \"Search table\",\n placeholder: \"Search…\",\n },\n DataTablePagination: {\n \"aria-label\": \"Table pagination\",\n rowsRangeSelectLabel: (total) => `Visible rows out of ${total}`,\n rowsRange: (range, total) => (\n <>\n Rows&nbsp;{range}&nbsp;of {total}\n </>\n ),\n previousPageButtonLabel: \"Previous page\",\n nextPageButtonLabel: \"Next page\",\n },\n DataTableRowsPerPage: {\n label: \"Rows per page:\",\n },\n DateInput: {\n selectedDateDescription: (date) => `Selected date, ${date}`,\n calendarButtonLabel: \"Open calendar\",\n },\n DateRangeInput: {\n startInputLabel: \"Start date\",\n endInputLabel: \"End date\",\n selectedDateRangeDescription: ({ start, end }) =>\n `Selected date range, ${start || \"missing start date\"} to ${end || \"missing end date\"}`,\n },\n ErrorBoundary: {\n fallbackMessage: (\n <>\n Something went wrong.\n <br />\n Press the button on the right to try again. If the problem persists, please try again later.\n </>\n ),\n resetButtonLabel: \"Retry\",\n },\n Feedback: {\n visuallyHiddenPrefix: (type) =>\n type === \"error\" ? \"Error,\" : type === \"warning\" ? \"Warning,\" : null,\n },\n FeedbackPopover: {\n label: \"Show feedback\",\n },\n FieldGroupHeader: {\n visuallyHiddenCodePrefix: \"Section\",\n },\n Form: {\n submitErrorMessage: \"An error occurred during submission. Please try again later.\",\n nativeErrorMessages: {\n valueMissing: \"Required.\",\n badInput: \"Unrecognized format.\",\n typeMismatch: (el) => {\n const type = (el as HTMLInputElement).type;\n return type === \"email\" ? \"Invalid email.\" : \"Invalid URL.\";\n },\n patternMismatch: \"Invalid format.\",\n tooShort: (el) => {\n const minLength = (el as HTMLInputElement).minLength;\n return `Requires at least ${minLength} ${minLength === 1 ? \"character\" : \"characters\"}.`;\n },\n tooLong: (el) => {\n const maxLength = (el as HTMLInputElement).maxLength;\n return `Limited to at most ${maxLength} ${maxLength === 1 ? \"character\" : \"characters\"}.`;\n },\n rangeUnderflow: (el) => {\n const min = (el as HTMLInputElement).min;\n return `Below minimum of ${min}.`;\n },\n rangeOverflow: (el) => {\n const max = (el as HTMLInputElement).max;\n return `Above maximum of ${max}.`;\n },\n stepMismatch: \"Invalid value increment.\",\n },\n },\n Input: {\n loadingDescription: \"Loading…\",\n clearButtonLabel: \"Clear\",\n },\n Keybinds: {\n keybindsSeparatorLabel: \"or\",\n keyPressesSeparatorLabel: \"then\",\n keyLabels: {\n Meta: IS_APPLE ? undefined : \"Windows Key\",\n },\n },\n Label: {\n helperButtonLabel: \"Show help\",\n },\n NumericInput: {\n decimalSeparator: \".\",\n groupingStyle: \"thousand\",\n groupSeparator: \",\",\n },\n RadioGroup: {\n clearDescription: \"Press Backspace or Delete to clear.\",\n },\n Select: {\n placeholder: \"Select…\",\n clearDescription: \"Press Backspace or Delete to clear.\",\n searchLabel: \"Search options\",\n optionsLabel: \"Options\",\n valueTagCloseButtonLabel: \"Remove\",\n },\n Step: {\n stepNumberLabel: (number) => `Step ${number}`,\n completedLabel: \"Completed\",\n },\n StepperFinishTrigger: {\n label: \"Finish\",\n },\n StepperNextTrigger: {\n label: \"Next\",\n },\n StepperPreviousTrigger: {\n label: \"Back\",\n },\n TableColumn: {\n helperButtonLabel: \"Show help\",\n },\n TableHead: {\n sortByColumnDescription: (sortDirection) =>\n sortDirection === null\n ? \"Clear sort\"\n : `Sort ${sortDirection === \"asc\" ? \"ascending\" : \"descending\"}`,\n },\n TabList: {\n scrollLeftButtonLabel: \"Scroll left\",\n scrollRightButtonLabel: \"Scroll right\",\n },\n ToastProvider: {\n label: \"Notification\",\n },\n ToastViewport: {\n label: \"Notifications ({hotkey})\",\n },\n};\n"],"mappings":"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"}