@skbkontur/icons 2.0.0-beta.18 → 2.0.0-beta.21
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/i.d.ts +1 -2
- package/m.d.ts +2 -2
- package/m.js +1 -1
- package/package.json +2 -1
- package/src/BaseIcon.d.ts +7 -0
- package/src/{internal/BaseIcon.js → BaseIcon.js} +3 -4
- package/src/forwardRef.d.ts +17 -0
- package/src/{helpers/forwardRef.js → forwardRef.js} +2 -4
- package/src/types.d.ts +10 -0
- package/src/helpers/forwardRef.d.ts +0 -7
- package/src/helpers/types.d.ts +0 -12
- package/src/internal/BaseIcon.d.ts +0 -7
- package/src/internal/Icon.d.ts +0 -16
- package/src/internal/Icon.js +0 -7
- /package/src/{helpers/types.js → types.js} +0 -0
- /package/src/{internal/useIsomorphicLayoutEffect.d.ts → useIsomorphicLayoutEffect.d.ts} +0 -0
- /package/src/{internal/useIsomorphicLayoutEffect.js → useIsomorphicLayoutEffect.js} +0 -0
- /package/src/{internal/utils.d.ts → utils.d.ts} +0 -0
- /package/src/{internal/utils.js → utils.js} +0 -0
package/i.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
type
|
|
2
|
-
export type C = import("react").FunctionComponent<P>;
|
|
1
|
+
export type C = import("./src/types.js").IconComponent;
|
package/m.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { IconProps } from "./
|
|
2
|
-
export declare const s: (viewBoxSize:
|
|
1
|
+
import type { IconProps, IconSize } from "./types.js";
|
|
2
|
+
export declare const s: (viewBoxSize: IconSize, paths: string[]) => (props: IconProps) => import("react").FunctionComponentElement<import("./src/BaseIcon.js").BaseIconProps & import("react").RefAttributes<SVGSVGElement>>;
|
package/m.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skbkontur/icons",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.21",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"files": [
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
],
|
|
13
13
|
"exports": {
|
|
14
14
|
"./package.json": "./package.json",
|
|
15
|
+
".": "./src/types.js",
|
|
15
16
|
"./IconAnimalPawLight16": "./IconAnimalPawLight16.js",
|
|
16
17
|
"./IconAnimalPawLight20": "./IconAnimalPawLight20.js",
|
|
17
18
|
"./IconAnimalPawRegular16": "./IconAnimalPawRegular16.js",
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IconProps, IconSize } from "./types.js";
|
|
2
|
+
export interface BaseIconProps extends IconProps {
|
|
3
|
+
viewBoxSize?: IconSize;
|
|
4
|
+
paths?: string[];
|
|
5
|
+
}
|
|
6
|
+
export type BaseIconRefType = SVGSVGElement;
|
|
7
|
+
export declare const BaseIcon: import("./forwardRef.js").ReactUIComponentWithRef<SVGSVGElement, BaseIconProps>;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useRef, useState } from "react";
|
|
3
|
-
import { forwardRef } from "
|
|
4
|
-
import { IconDataTids } from "./Icon.js";
|
|
3
|
+
import { forwardRef } from "./forwardRef.js";
|
|
5
4
|
import { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect.js";
|
|
6
5
|
import { isDocument, isShadowRoot, ZERO_WIDTH_SPACE } from "./utils.js";
|
|
7
|
-
export const BaseIcon = forwardRef("BaseIcon", ({ color, size, style, "aria-hidden": ariaHidden = true, viewBoxSize = 16, align = "center", children, tabIndex, onKeyUp, onBlur, paths, ...rest }, ref) => {
|
|
6
|
+
export const BaseIcon = forwardRef("BaseIcon", ({ color, size, style, "aria-hidden": ariaHidden = true, viewBoxSize = 16, align = "center", children, tabIndex, onKeyUp, onBlur, paths = [], ...rest }, ref) => {
|
|
8
7
|
const zeroWidthSpaceRef = useRef(null);
|
|
9
8
|
const [focusVisible, setFocusVisible] = useState(false);
|
|
10
9
|
useIsomorphicLayoutEffect(() => {
|
|
@@ -37,7 +36,7 @@ export const BaseIcon = forwardRef("BaseIcon", ({ color, size, style, "aria-hidd
|
|
|
37
36
|
focusVisible && setFocusVisible(false);
|
|
38
37
|
onBlur?.(e);
|
|
39
38
|
}, [focusVisible, onBlur]);
|
|
40
|
-
const icon = (_jsx("svg", { role: "img", "aria-label": "ui-icons", "data-tid":
|
|
39
|
+
const icon = (_jsx("svg", { role: "img", "aria-label": "ui-icons", "data-tid": "Icon__root", ref: ref, width: size || viewBoxSize, height: size || viewBoxSize, style: {
|
|
41
40
|
fill: color ?? "currentColor",
|
|
42
41
|
marginBottom: align === "none" || align === "center" ? 0 : "-0.1875em",
|
|
43
42
|
flexShrink: 0,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ForwardRefExoticComponent, NamedExoticComponent, PropsWithoutRef, ReactElement, RefAttributes } from "react";
|
|
2
|
+
interface MutableRefObject<T> {
|
|
3
|
+
current: T;
|
|
4
|
+
}
|
|
5
|
+
type ForwardedRef<T> = ((instance: T | null) => void) | MutableRefObject<T | null> | null;
|
|
6
|
+
interface ForwardRefRenderFunction<T, P = Record<string, unknown>> {
|
|
7
|
+
(props: P, ref: ForwardedRef<T>): ReactElement | null;
|
|
8
|
+
displayName?: string | undefined;
|
|
9
|
+
defaultProps?: never | undefined;
|
|
10
|
+
propTypes?: never | undefined;
|
|
11
|
+
}
|
|
12
|
+
export interface ReactUIComponentWithRef<T, P> extends NamedExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>, Pick<ForwardRefExoticComponent<P>, "propTypes"> {
|
|
13
|
+
__KONTUR_REACT_UI__: string;
|
|
14
|
+
__KONTUR_ICON__: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare function forwardRef<ElementType, Props>(name: string, render: ForwardRefRenderFunction<ElementType, PropsWithoutRef<Props>>): ReactUIComponentWithRef<ElementType, Props>;
|
|
17
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { forwardRef as ReactForwardRef } from "react";
|
|
2
2
|
function forwardNameAndTag(name, render) {
|
|
3
3
|
render.displayName = name;
|
|
4
4
|
render.__KONTUR_REACT_UI__ = name;
|
|
@@ -6,7 +6,5 @@ function forwardNameAndTag(name, render) {
|
|
|
6
6
|
return render;
|
|
7
7
|
}
|
|
8
8
|
export function forwardRef(name, render) {
|
|
9
|
-
return forwardNameAndTag(name,
|
|
10
|
-
// @ts-expect-error: 1
|
|
11
|
-
React.forwardRef(render));
|
|
9
|
+
return forwardNameAndTag(name, ReactForwardRef(render));
|
|
12
10
|
}
|
package/src/types.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AllHTMLAttributes, AriaAttributes, FunctionComponent, SVGAttributes } from "react";
|
|
2
|
+
export type IconSize = 16 | 20 | 24 | 32 | 64;
|
|
3
|
+
export type IconWeight = "light" | "regular" | "solid";
|
|
4
|
+
export interface IconProps extends SVGAttributes<SVGElement>, Pick<AllHTMLAttributes<SVGElement>, "role" | "title" | "tabIndex">, Pick<AriaAttributes, "aria-label" | "aria-hidden"> {
|
|
5
|
+
size?: number | undefined;
|
|
6
|
+
weight?: IconWeight | undefined;
|
|
7
|
+
color?: string | undefined;
|
|
8
|
+
align?: "center" | "baseline" | "none" | undefined;
|
|
9
|
+
}
|
|
10
|
+
export type IconComponent = FunctionComponent<IconProps>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { ForwardRefRenderFunction } from "./types.js";
|
|
3
|
-
export interface ReactUIComponentWithRef<T, P> extends React.NamedExoticComponent<React.PropsWithoutRef<P> & React.RefAttributes<T>>, Pick<React.ForwardRefExoticComponent<P>, "propTypes"> {
|
|
4
|
-
__KONTUR_REACT_UI__: string;
|
|
5
|
-
__KONTUR_ICON__: boolean;
|
|
6
|
-
}
|
|
7
|
-
export declare function forwardRef<ElementType, Props>(name: string, render: ForwardRefRenderFunction<ElementType, Props>): ReactUIComponentWithRef<ElementType, Props>;
|
package/src/helpers/types.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { ReactElement } from "react";
|
|
2
|
-
interface MutableRefObject<T> {
|
|
3
|
-
current: T;
|
|
4
|
-
}
|
|
5
|
-
type ForwardedRef<T> = ((instance: T | null) => void) | MutableRefObject<T | null> | null;
|
|
6
|
-
export interface ForwardRefRenderFunction<T, P = Record<string, unknown>> {
|
|
7
|
-
(props: P, ref: ForwardedRef<T>): ReactElement | null;
|
|
8
|
-
displayName?: string | undefined;
|
|
9
|
-
defaultProps?: never | undefined;
|
|
10
|
-
propTypes?: never | undefined;
|
|
11
|
-
}
|
|
12
|
-
export {};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { breakpoints, IconProps } from "./Icon.js";
|
|
2
|
-
export interface BaseIconProps extends IconProps {
|
|
3
|
-
viewBoxSize?: (typeof breakpoints)[number];
|
|
4
|
-
paths: string[];
|
|
5
|
-
}
|
|
6
|
-
export type BaseIconRefType = SVGSVGElement;
|
|
7
|
-
export declare const BaseIcon: import("../helpers/forwardRef.js").ReactUIComponentWithRef<SVGSVGElement, BaseIconProps>;
|
package/src/internal/Icon.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type React from "react";
|
|
2
|
-
import type { AllHTMLAttributes, AriaAttributes } from "react";
|
|
3
|
-
export declare const breakpoints: number[];
|
|
4
|
-
export declare const weights: readonly ["light", "regular", "solid"];
|
|
5
|
-
export declare const MAX_LIGHT_POSITION = 1;
|
|
6
|
-
export declare const MAX_SOLID_POSITION = 2;
|
|
7
|
-
export type IconWeight = (typeof weights)[number];
|
|
8
|
-
export interface IconProps extends React.SVGAttributes<SVGElement>, Pick<AllHTMLAttributes<SVGElement>, "role" | "title" | "tabIndex">, Pick<AriaAttributes, "aria-label" | "aria-hidden"> {
|
|
9
|
-
size?: number;
|
|
10
|
-
weight?: IconWeight;
|
|
11
|
-
color?: string;
|
|
12
|
-
align?: "center" | "baseline" | "none";
|
|
13
|
-
}
|
|
14
|
-
export declare const IconDataTids: {
|
|
15
|
-
root: string;
|
|
16
|
-
};
|
package/src/internal/Icon.js
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|