@sanity/ui 5.0.0-alpha.11 → 5.0.0-alpha.12
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.
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -19
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/components/icon/Icon.tsx +21 -11
- package/src/components/icon/icon.props.ts +1 -1
- package/src/version.ts +2 -2
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import clsx from 'clsx'
|
|
2
|
+
import {cloneElement, createElement, isValidElement, type ComponentType, type SVGProps} from 'react'
|
|
2
3
|
|
|
3
4
|
import {getProps} from '../../utils/getProps'
|
|
4
5
|
import {suffixClassName} from '../../utils/suffixClassName'
|
|
@@ -7,18 +8,27 @@ import {type IconProps, iconProps} from './icon.props'
|
|
|
7
8
|
const iconClassName = suffixClassName('sui-Icon')
|
|
8
9
|
|
|
9
10
|
/** @public */
|
|
10
|
-
export function Icon({size = 2, ...props}: IconProps) {
|
|
11
|
-
const {className, style,
|
|
11
|
+
export function Icon({icon, size = 2, ...props}: IconProps) {
|
|
12
|
+
const {className, style, ...rest} = getProps({size, ...props}, iconProps)
|
|
13
|
+
const iconElement = isValidElement(icon) ? icon : null
|
|
14
|
+
const ariaLabel =
|
|
15
|
+
props['aria-label'] || (iconElement ? iconElement.props['aria-label'] : undefined)
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
const svgProps = {
|
|
18
|
+
'className': clsx(
|
|
19
|
+
iconClassName,
|
|
20
|
+
className,
|
|
21
|
+
iconElement ? iconElement.props.className : undefined,
|
|
22
|
+
),
|
|
23
|
+
'style': iconElement ? {...iconElement.props.style, ...style} : style,
|
|
24
|
+
'data-ui': 'Icon',
|
|
25
|
+
'aria-hidden': ariaLabel ? undefined : true,
|
|
26
|
+
...rest,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return iconElement
|
|
30
|
+
? cloneElement(iconElement, svgProps)
|
|
31
|
+
: createElement(icon as ComponentType<SVGProps<SVGSVGElement>>, svgProps)
|
|
22
32
|
}
|
|
23
33
|
|
|
24
34
|
export type {IconProps}
|
|
@@ -13,7 +13,7 @@ export interface IconProps
|
|
|
13
13
|
/**
|
|
14
14
|
* The icon component to render.
|
|
15
15
|
*/
|
|
16
|
-
icon: React.ComponentType<SVGProps<SVGSVGElement>>
|
|
16
|
+
icon: React.ComponentType<SVGProps<SVGSVGElement>> | React.ReactElement<SVGProps<SVGSVGElement>>
|
|
17
17
|
/**
|
|
18
18
|
* Sets icon size.
|
|
19
19
|
*/
|
package/src/version.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// This file is generated by scripts/write-version.js. Do not edit.
|
|
2
|
-
export const VERSION = '
|
|
3
|
-
export const HASH = '
|
|
2
|
+
export const VERSION = '500alpha12'
|
|
3
|
+
export const HASH = '87c63f'
|