Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/primitives/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Internal

- Refactor to TypeScript ([#84309](https://github.com/WordPress/gutenberg/pull/84309)).

## 4.57.0 (2026-10-07)

### Bug Fixes
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,79 +1,91 @@
import clsx from 'clsx';
import type { ComponentPropsWithoutRef, ForwardedRef } from 'react';
import { createElement, forwardRef } from '@wordpress/element';
import type { SVGProps } from './types';

/** @typedef {{isPressed?: boolean} & React.ComponentPropsWithoutRef<'svg'>} SVGProps */
export type { SVGProps } from './types';

/**
* @param {React.ComponentPropsWithoutRef<'circle'>} props
*
* @return {React.JSX.Element} Circle component
*/
export const Circle = ( props ) => createElement( 'circle', props );
export const Circle = ( props: ComponentPropsWithoutRef< 'circle' > ) =>
createElement( 'circle', props );

/**
* @param {React.ComponentPropsWithoutRef<'g'>} props
*
* @return {React.JSX.Element} G component
*/
export const G = ( props ) => createElement( 'g', props );
export const G = ( props: ComponentPropsWithoutRef< 'g' > ) =>
createElement( 'g', props );

/**
* @param {React.ComponentPropsWithoutRef<'line'>} props
*
* @return {React.JSX.Element} Path component
*/
export const Line = ( props ) => createElement( 'line', props );
export const Line = ( props: ComponentPropsWithoutRef< 'line' > ) =>
createElement( 'line', props );

/**
* @param {React.ComponentPropsWithoutRef<'path'>} props
*
* @return {React.JSX.Element} Path component
*/
export const Path = ( props ) => createElement( 'path', props );
export const Path = ( props: ComponentPropsWithoutRef< 'path' > ) =>
createElement( 'path', props );

/**
* @param {React.ComponentPropsWithoutRef<'polygon'>} props
*
* @return {React.JSX.Element} Polygon component
*/
export const Polygon = ( props ) => createElement( 'polygon', props );
export const Polygon = ( props: ComponentPropsWithoutRef< 'polygon' > ) =>
createElement( 'polygon', props );

/**
* @param {React.ComponentPropsWithoutRef<'rect'>} props
*
* @return {React.JSX.Element} Rect component
*/
export const Rect = ( props ) => createElement( 'rect', props );
export const Rect = ( props: ComponentPropsWithoutRef< 'rect' > ) =>
createElement( 'rect', props );

/**
* @param {React.ComponentPropsWithoutRef<'defs'>} props
*
* @return {React.JSX.Element} Defs component
*/
export const Defs = ( props ) => createElement( 'defs', props );
export const Defs = ( props: ComponentPropsWithoutRef< 'defs' > ) =>
createElement( 'defs', props );

/**
* @param {React.ComponentPropsWithoutRef<'radialGradient'>} props
*
* @return {React.JSX.Element} RadialGradient component
*/
export const RadialGradient = ( props ) =>
createElement( 'radialGradient', props );
export const RadialGradient = (
props: ComponentPropsWithoutRef< 'radialGradient' >
) => createElement( 'radialGradient', props );

/**
* @param {React.ComponentPropsWithoutRef<'linearGradient'>} props
*
* @return {React.JSX.Element} LinearGradient component
*/
export const LinearGradient = ( props ) =>
createElement( 'linearGradient', props );
export const LinearGradient = (
props: ComponentPropsWithoutRef< 'linearGradient' >
) => createElement( 'linearGradient', props );

/**
* @param {React.ComponentPropsWithoutRef<'stop'>} props
*
* @return {React.JSX.Element} Stop component
*/
export const Stop = ( props ) => createElement( 'stop', props );
export const Stop = ( props: ComponentPropsWithoutRef< 'stop' > ) =>
createElement( 'stop', props );

export const SVG = forwardRef(
/**
Expand All @@ -83,7 +95,10 @@ export const SVG = forwardRef(
*
* @return {React.JSX.Element} Stop component
*/
( { className, isPressed, ...props }, ref ) => {
(
{ className, isPressed, ...props }: SVGProps,
ref: ForwardedRef< SVGSVGElement >
) => {
const appliedProps = {
...props,
className:
Expand All @@ -92,8 +107,6 @@ export const SVG = forwardRef(
focusable: false,
};

// Disable reason: We need to have a way to render HTML tag for web.
// eslint-disable-next-line react/forbid-elements
return <svg { ...appliedProps } ref={ ref } />;
}
);
Expand Down
8 changes: 8 additions & 0 deletions packages/primitives/src/svg/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { ComponentPropsWithoutRef } from 'react';

export type SVGProps = {
/**
* Indicates whether the SVG should appear as pressed.
*/
isPressed?: boolean;
} & ComponentPropsWithoutRef< 'svg' >;
5 changes: 0 additions & 5 deletions tools/eslint/suppressions.json
Original file line number Diff line number Diff line change
Expand Up @@ -7943,11 +7943,6 @@
"count": 7
}
},
"packages/primitives/src/svg/index.jsx": {
"react/jsx-filename-extension": {
"count": 1
}
},
"packages/private-apis/src/test/index.jsx": {
"react/jsx-filename-extension": {
"count": 1
Expand Down
Loading