@westpac/ui 0.43.0 → 0.44.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 (49) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/component-type.json +1 -1
  3. package/dist/components/accordion/components/accordion-item/accordion-item.component.js +3 -1
  4. package/dist/components/accordion/components/accordion-item/accordion-item.styles.d.ts +3 -0
  5. package/dist/components/accordion/components/accordion-item/accordion-item.styles.js +2 -1
  6. package/dist/components/pagination/components/pagination-item/pagination-item.component.js +5 -1
  7. package/dist/components/pagination/components/pagination-item/pagination-item.styles.d.ts +2 -2
  8. package/dist/components/pagination/components/pagination-item/pagination-item.styles.js +1 -1
  9. package/dist/components/pagination/components/pagination-pages/pagination-pages.component.d.ts +2 -0
  10. package/dist/components/pagination/components/pagination-pages/pagination-pages.component.js +185 -0
  11. package/dist/components/pagination/components/pagination-pages/pagination-pages.types.d.ts +36 -0
  12. package/dist/components/pagination/components/pagination-pages/pagination-pages.types.js +1 -0
  13. package/dist/components/pagination/components/pagination-presentational/pagination-presentational.component.d.ts +2 -0
  14. package/dist/components/pagination/components/pagination-presentational/pagination-presentational.component.js +44 -0
  15. package/dist/components/pagination/{pagination.styles.d.ts → components/pagination-presentational/pagination-presentational.styles.d.ts} +3 -0
  16. package/dist/components/pagination/{pagination.styles.js → components/pagination-presentational/pagination-presentational.styles.js} +2 -1
  17. package/dist/components/pagination/components/pagination-presentational/pagination-presentational.types.d.ts +41 -0
  18. package/dist/components/pagination/components/pagination-presentational/pagination-presentational.types.js +1 -0
  19. package/dist/components/pagination/components/pagination-total-pages/pagination-total-pages.component.d.ts +2 -0
  20. package/dist/components/pagination/components/pagination-total-pages/pagination-total-pages.component.js +188 -0
  21. package/dist/components/pagination/components/pagination-total-pages/pagination-total-pages.types.d.ts +40 -0
  22. package/dist/components/pagination/components/pagination-total-pages/pagination-total-pages.types.js +1 -0
  23. package/dist/components/pagination/pagination.component.d.ts +1 -1
  24. package/dist/components/pagination/pagination.component.js +26 -121
  25. package/dist/components/pagination/pagination.types.d.ts +33 -29
  26. package/dist/components/pagination/pagination.utils.d.ts +2 -0
  27. package/dist/components/pagination/pagination.utils.js +12 -0
  28. package/dist/components/progress-indicator/progress-indicator.component.js +1 -1
  29. package/dist/css/westpac-ui.css +3 -0
  30. package/dist/css/westpac-ui.min.css +3 -0
  31. package/dist/hook/breakpoints.hook.d.ts +1 -0
  32. package/dist/hook/breakpoints.hook.js +21 -0
  33. package/package.json +3 -3
  34. package/src/components/accordion/components/accordion-item/accordion-item.component.tsx +1 -1
  35. package/src/components/accordion/components/accordion-item/accordion-item.styles.ts +2 -1
  36. package/src/components/pagination/components/pagination-item/pagination-item.component.tsx +2 -0
  37. package/src/components/pagination/components/pagination-item/pagination-item.styles.ts +1 -1
  38. package/src/components/pagination/components/pagination-pages/pagination-pages.component.tsx +212 -0
  39. package/src/components/pagination/components/pagination-pages/pagination-pages.types.ts +47 -0
  40. package/src/components/pagination/components/pagination-presentational/pagination-presentational.component.tsx +81 -0
  41. package/src/components/pagination/{pagination.styles.ts → components/pagination-presentational/pagination-presentational.styles.ts} +2 -0
  42. package/src/components/pagination/components/pagination-presentational/pagination-presentational.types.ts +48 -0
  43. package/src/components/pagination/components/pagination-total-pages/pagination-total-pages.component.tsx +234 -0
  44. package/src/components/pagination/components/pagination-total-pages/pagination-total-pages.types.ts +48 -0
  45. package/src/components/pagination/pagination.component.tsx +34 -142
  46. package/src/components/pagination/pagination.types.ts +34 -31
  47. package/src/components/pagination/pagination.utils.ts +11 -0
  48. package/src/components/progress-indicator/progress-indicator.component.tsx +1 -1
  49. package/src/hook/breakpoints.hook.ts +29 -0
@@ -1,46 +1,32 @@
1
- import { HTMLAttributes, ReactNode } from 'react';
1
+ import { ReactNode } from 'react';
2
2
 
3
- import { type PaginationItemProps } from './components/index.js';
3
+ import { Breakpoint } from '../../tailwind/constants/breakpoints.js';
4
+
5
+ import { PaginationItemProps } from './components/index.js';
6
+ import { PaginationPageProps } from './components/pagination-pages/pagination-pages.types.js';
7
+ import { PaginationTotalPagesProps } from './components/pagination-total-pages/pagination-total-pages.types.js';
4
8
 
5
9
  export type PageProps = {
6
10
  href: string;
7
11
  text: ReactNode;
8
12
  };
9
13
 
10
- export type PaginationAsLinkProps = {
11
- /**
12
- * on page change
13
- */
14
- onChange?: never;
14
+ export type PaginationBase = {
15
15
  /**
16
- * Pages items
17
- */
18
- pages: PageProps[];
19
- };
20
-
21
- export type PaginationAsButtonProps = {
22
- /**
23
- * on page change
16
+ * Back aria label
17
+ * @default Back
24
18
  */
25
- onChange: (page: number) => unknown;
26
- /**
27
- * Pages items
28
- */
29
- pages: Omit<PageProps, 'href'>[];
30
- };
31
-
32
- export type PaginationHookProps = {
33
- defaultCurrent?: number;
34
- infinite?: boolean;
35
- pages: (Omit<PageProps, 'href'> & { href?: string })[];
36
- };
37
-
38
- export type PaginationProps = {
19
+ backAriaLabel?: string;
39
20
  /**
40
21
  * Back label
41
22
  * @default Back
42
23
  */
43
24
  backLabel?: ReactNode;
25
+ /**
26
+ * boundaryCount
27
+ * @default 1
28
+ */
29
+ boundaryCount?: number | Partial<Record<Breakpoint | 'initial', number>>;
44
30
  /**
45
31
  * Current page
46
32
  */
@@ -54,15 +40,32 @@ export type PaginationProps = {
54
40
  * Link component to render
55
41
  */
56
42
  linkComponent?: PaginationItemProps['tag'];
43
+ /**
44
+ * Next aria label
45
+ * @default Next
46
+ */
47
+ nextAriaLabel?: string;
57
48
  /**
58
49
  * Next label
59
50
  * @default Next
60
51
  */
61
52
  nextLabel?: ReactNode;
53
+ /**
54
+ * siblingCount
55
+ * @default 1
56
+ */
57
+ siblingCount?: number | Partial<Record<Breakpoint | 'initial', number>>;
62
58
  /**
63
59
  * Tag to render
64
60
  * @default nav
65
61
  */
66
62
  tag?: keyof JSX.IntrinsicElements;
67
- } & (PaginationAsLinkProps | PaginationAsButtonProps) &
68
- Omit<HTMLAttributes<Element>, 'onChange'>;
63
+ };
64
+
65
+ export type PaginationHookProps = {
66
+ defaultCurrent?: number;
67
+ infinite?: boolean;
68
+ pages: (Omit<PageProps, 'href'> & { href?: string })[];
69
+ };
70
+
71
+ export type PaginationProps = PaginationPageProps | PaginationTotalPagesProps;
@@ -0,0 +1,11 @@
1
+ import { Breakpoint } from '../../tailwind/index.js';
2
+
3
+ export function getSiblingOrBoundaryCount(
4
+ count: Partial<Record<Breakpoint | 'initial', number>>,
5
+ breakpoint: Breakpoint | 'initial',
6
+ ) {
7
+ const finalBreakPoint = [breakpoint, 'initial', 'xsl', 'sm', 'md', 'lg', 'xl'].find(
8
+ currentBreakpoint => count[currentBreakpoint as Breakpoint | 'initial'] !== undefined,
9
+ ) as Breakpoint | 'initial';
10
+ return count[finalBreakPoint] || 0;
11
+ }
@@ -34,7 +34,7 @@ export function ProgressIndicator({
34
34
 
35
35
  return (
36
36
  <div aria-label={ariaLabel} className={styles.container()}>
37
- <div className="relative">
37
+ <div className="relative flex items-center justify-center">
38
38
  <Icon viewBox="0 0 180 180" fill="none" color={color} className={styles.base({ className })} {...props}>
39
39
  <defs>
40
40
  <linearGradient id={`${id}-1`}>
@@ -0,0 +1,29 @@
1
+ import { useEffect, useState } from 'react';
2
+
3
+ import { BREAKPOINTS, Breakpoint } from '../tailwind/constants/index.js';
4
+
5
+ function checkBreakpoint(): Breakpoint | 'initial' {
6
+ const breakpointsAsArray = Object.entries(BREAKPOINTS).reverse() as [Breakpoint, string][];
7
+ const breakpoint = breakpointsAsArray.find(([, value]) => window.matchMedia(`(min-width: ${value})`).matches) as [
8
+ Breakpoint,
9
+ string,
10
+ ];
11
+ return breakpoint ? breakpoint[0] : 'initial';
12
+ }
13
+
14
+ export function useBreakpoint() {
15
+ const [breakpoint, setBreakpoint] = useState<Breakpoint | 'initial'>(checkBreakpoint());
16
+
17
+ useEffect(() => {
18
+ const listener = () => {
19
+ const breakpoint = checkBreakpoint();
20
+ setBreakpoint(breakpoint);
21
+ };
22
+ window.addEventListener('resize', listener);
23
+ return () => {
24
+ window.removeEventListener('resize', listener);
25
+ };
26
+ }, []);
27
+
28
+ return breakpoint;
29
+ }