@westpac/ui 1.9.1 → 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
@@ -3,7 +3,7 @@ export const styles = tv({
3
3
  slots: {
4
4
  root: 'relative inline-flex',
5
5
  select: 'form-control flex-1 overflow-hidden bg-no-repeat text-ellipsis group-first/add-on-before:rounded-r-none group-first/add-on-before:!border-x group-last/add-on-after:rounded-l-none group-last/add-on-after:!border-x group-[.input-group-after]:rounded-r-none group-[.input-group-after]:border-r-0 group-[.input-group-before]:rounded-l-none group-[.input-group-before]:border-l-0 disabled:form-control-disabled',
6
- caret: 'absolute top-1/2 right-2 z-100 -translate-y-1/2 text-surface-muted-vivid'
6
+ caret: 'pointer-events-none absolute top-1/2 right-2 z-100 -translate-y-1/2 text-surface-muted-vivid'
7
7
  },
8
8
  variants: {
9
9
  size: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@westpac/ui",
3
- "version": "1.9.1",
3
+ "version": "1.11.0",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "type": "module",
@@ -253,10 +253,10 @@
253
253
  "typescript": "^5.5.4",
254
254
  "vite": "^7.3.5",
255
255
  "vitest": "^3.2.6",
256
- "@westpac/style-config": "~1.0.2",
257
- "@westpac/test-config": "~0.0.0",
258
256
  "@westpac/eslint-config": "~1.1.0",
259
- "@westpac/ts-config": "~0.0.0"
257
+ "@westpac/style-config": "~1.0.2",
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
  /**
@@ -5,7 +5,7 @@ export const styles = tv({
5
5
  root: 'relative inline-flex',
6
6
  select:
7
7
  'form-control flex-1 overflow-hidden bg-no-repeat text-ellipsis group-first/add-on-before:rounded-r-none group-first/add-on-before:!border-x group-last/add-on-after:rounded-l-none group-last/add-on-after:!border-x group-[.input-group-after]:rounded-r-none group-[.input-group-after]:border-r-0 group-[.input-group-before]:rounded-l-none group-[.input-group-before]:border-l-0 disabled:form-control-disabled',
8
- caret: 'absolute top-1/2 right-2 z-100 -translate-y-1/2 text-surface-muted-vivid', // z-index to ensure caret displays correctly in certain focus states
8
+ caret: 'pointer-events-none absolute top-1/2 right-2 z-100 -translate-y-1/2 text-surface-muted-vivid', // z-index to ensure caret displays correctly in certain focus states
9
9
  },
10
10
  variants: {
11
11
  size: {