@westpac/ui 1.10.0 → 1.11.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.
@@ -1,2 +1,8 @@
1
- import { type HeadingProps } from './heading.types.js';
2
- export declare function Heading({ className, tag, brandHeading, size, children, uppercase, ...props }: HeadingProps): import("react/jsx-runtime").JSX.Element;
1
+ import React from 'react';
2
+ export declare const Heading: React.ForwardRefExoticComponent<{
3
+ brandHeading?: import("../../types/responsive-variants.types.js").ResponsiveVariants<boolean | undefined>;
4
+ children?: React.ReactNode;
5
+ size: import("../../types/responsive-variants.types.js").ResponsiveVariants<2 | 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | undefined>;
6
+ tag?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
7
+ uppercase?: boolean;
8
+ } & React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLHeadingElement>>;
@@ -1,9 +1,9 @@
1
1
  'use client';
2
- import React from 'react';
2
+ import React, { forwardRef } from 'react';
3
3
  import { useBreakpoint } from '../../hook/breakpoints.hook.js';
4
4
  import { resolveResponsiveVariant } from '../../utils/breakpoint.util.js';
5
5
  import { styles } from './heading.styles.js';
6
- export function Heading({ className, tag, brandHeading, size, children, uppercase, ...props }) {
6
+ function BaseHeading({ className, tag, brandHeading, size, children, uppercase, ...props }, ref) {
7
7
  const sizeToTag = {
8
8
  1: 'h1',
9
9
  2: 'h2',
@@ -25,6 +25,8 @@ export function Heading({ className, tag, brandHeading, size, children, uppercas
25
25
  size: resolveResponsiveVariant(size, breakpoint),
26
26
  uppercase
27
27
  }),
28
+ ref: ref,
28
29
  ...props
29
30
  }, children);
30
31
  }
32
+ export const Heading = forwardRef(BaseHeading);
@@ -3,6 +3,7 @@ import { type VariantProps } from 'tailwind-variants';
3
3
  import { ResponsiveVariants } from '../../types/responsive-variants.types.js';
4
4
  import { styles } from './heading.styles.js';
5
5
  type Variants = VariantProps<typeof styles>;
6
+ export type HeadingRef = HTMLHeadingElement;
6
7
  export type HeadingProps = {
7
8
  /**
8
9
  * Whether it should be a brand heading
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@westpac/ui",
3
- "version": "1.10.0",
3
+ "version": "1.11.0",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "type": "module",
@@ -254,9 +254,9 @@
254
254
  "vite": "^7.3.5",
255
255
  "vitest": "^3.2.6",
256
256
  "@westpac/eslint-config": "~1.1.0",
257
- "@westpac/test-config": "~0.0.0",
258
257
  "@westpac/style-config": "~1.0.2",
259
- "@westpac/ts-config": "~0.0.0"
258
+ "@westpac/ts-config": "~0.0.0",
259
+ "@westpac/test-config": "~0.0.0"
260
260
  },
261
261
  "dependencies": {
262
262
  "@internationalized/date": "~3.10.0",
@@ -1,14 +1,17 @@
1
1
  'use client';
2
2
 
3
- import React from 'react';
3
+ import React, { forwardRef, Ref } from 'react';
4
4
 
5
5
  import { useBreakpoint } from '../../hook/breakpoints.hook.js';
6
6
  import { resolveResponsiveVariant } from '../../utils/breakpoint.util.js';
7
7
 
8
8
  import { styles } from './heading.styles.js';
9
- import { type HeadingProps } from './heading.types.js';
9
+ import { HeadingRef, type HeadingProps } from './heading.types.js';
10
10
 
11
- export function Heading({ className, tag, brandHeading, size, children, uppercase, ...props }: HeadingProps) {
11
+ function BaseHeading(
12
+ { className, tag, brandHeading, size, children, uppercase, ...props }: HeadingProps,
13
+ ref: Ref<HeadingRef>,
14
+ ) {
12
15
  const sizeToTag = {
13
16
  1: 'h1',
14
17
  2: 'h2',
@@ -32,9 +35,12 @@ export function Heading({ className, tag, brandHeading, size, children, uppercas
32
35
  size: resolveResponsiveVariant(size, breakpoint),
33
36
  uppercase,
34
37
  })}
38
+ ref={ref}
35
39
  {...props}
36
40
  >
37
41
  {children}
38
42
  </Tag>
39
43
  );
40
44
  }
45
+
46
+ export const Heading = forwardRef(BaseHeading);
@@ -6,6 +6,7 @@ import { ResponsiveVariants } from '../../types/responsive-variants.types.js';
6
6
  import { styles } from './heading.styles.js';
7
7
 
8
8
  type Variants = VariantProps<typeof styles>;
9
+ export type HeadingRef = HTMLHeadingElement;
9
10
 
10
11
  export type HeadingProps = {
11
12
  /**