@2hoch1/pixel-icon-library-react 1.1.1 → 1.1.3
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/LICENSE +21 -21
- package/README.md +0 -2
- package/dist/index.cjs +48 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -31
- package/dist/index.d.ts +32 -31
- package/dist/index.js +48 -48
- package/dist/index.js.map +1 -1
- package/package.json +108 -84
package/dist/index.d.cts
CHANGED
|
@@ -467,44 +467,45 @@ interface DynamicPixelIconProps extends Omit<SVGProps<SVGSVGElement>, 'ref'> {
|
|
|
467
467
|
name: IconName;
|
|
468
468
|
variant?: IconVariant;
|
|
469
469
|
size?: number | string;
|
|
470
|
+
title?: string;
|
|
470
471
|
fallback?: ReactNode;
|
|
471
472
|
}
|
|
472
473
|
/**
|
|
473
474
|
* DynamicPixelIcon - Lazy-loads icons at runtime for better code-splitting.
|
|
474
475
|
* Falls back to `fallback` or null if the icon cannot be resolved.
|
|
475
476
|
*/
|
|
476
|
-
declare const DynamicPixelIcon: ({ name, variant, size, fallback, ...props }: DynamicPixelIconProps) => string | number | boolean | Iterable<ReactNode> | react_jsx_runtime.JSX.Element | null;
|
|
477
|
+
declare const DynamicPixelIcon: ({ name, variant, size, title, fallback, ...props }: DynamicPixelIconProps) => string | number | boolean | Iterable<ReactNode> | react_jsx_runtime.JSX.Element | null;
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Minimal SVG element names supported by the icon set.
|
|
481
|
+
* Mirrors the React 19 `SVGElementType` addition while staying backward compatible.
|
|
482
|
+
*/
|
|
483
|
+
type IconSvgElement =
|
|
484
|
+
| 'circle'
|
|
485
|
+
| 'ellipse'
|
|
486
|
+
| 'g'
|
|
487
|
+
| 'line'
|
|
488
|
+
| 'path'
|
|
489
|
+
| 'polygon'
|
|
490
|
+
| 'polyline'
|
|
491
|
+
| 'rect';
|
|
492
|
+
|
|
493
|
+
type IconNode = [elementName: IconSvgElement, attrs: Record<string, string>][];
|
|
494
|
+
|
|
495
|
+
type SVGAttributes = Partial<SVGProps<SVGSVGElement>>;
|
|
496
|
+
type ElementAttributes = RefAttributes<SVGSVGElement> & SVGAttributes;
|
|
497
|
+
|
|
498
|
+
interface IconBaseProps extends ElementAttributes {
|
|
499
|
+
size?: string | number;
|
|
500
|
+
absoluteStrokeWidth?: boolean;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
type IconComponent = ForwardRefExoticComponent<
|
|
504
|
+
Omit<IconBaseProps, 'ref'> & RefAttributes<SVGSVGElement>
|
|
505
|
+
>;
|
|
477
506
|
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
* Mirrors the React 19 `SVGElementType` addition while staying backward compatible.
|
|
481
|
-
*/
|
|
482
|
-
type IconSvgElement =
|
|
483
|
-
| 'circle'
|
|
484
|
-
| 'ellipse'
|
|
485
|
-
| 'g'
|
|
486
|
-
| 'line'
|
|
487
|
-
| 'path'
|
|
488
|
-
| 'polygon'
|
|
489
|
-
| 'polyline'
|
|
490
|
-
| 'rect';
|
|
491
|
-
|
|
492
|
-
type IconNode = [elementName: IconSvgElement, attrs: Record<string, string>][];
|
|
493
|
-
|
|
494
|
-
type SVGAttributes = Partial<SVGProps<SVGSVGElement>>;
|
|
495
|
-
type ElementAttributes = RefAttributes<SVGSVGElement> & SVGAttributes;
|
|
496
|
-
|
|
497
|
-
interface IconBaseProps extends ElementAttributes {
|
|
498
|
-
size?: string | number;
|
|
499
|
-
absoluteStrokeWidth?: boolean;
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
type IconComponent = ForwardRefExoticComponent<
|
|
503
|
-
Omit<IconBaseProps, 'ref'> & RefAttributes<SVGSVGElement>
|
|
504
|
-
>;
|
|
505
|
-
|
|
506
|
-
// Legacy/simple component typing used by the generated registry
|
|
507
|
-
type IconProps = SVGProps<SVGSVGElement> & { title?: string };
|
|
507
|
+
// Legacy/simple component typing used by the generated registry
|
|
508
|
+
type IconProps = SVGProps<SVGSVGElement> & { title?: string };
|
|
508
509
|
type IconComponentFn = ComponentType<IconProps>;
|
|
509
510
|
|
|
510
511
|
export { DynamicPixelIcon, type ElementAttributes, type IconBaseProps, type IconComponent, type IconComponentFn, IconName, type IconNode, type IconProps, type IconSvgElement, IconVariant, PixelIcon, type SVGAttributes };
|
package/dist/index.d.ts
CHANGED
|
@@ -467,44 +467,45 @@ interface DynamicPixelIconProps extends Omit<SVGProps<SVGSVGElement>, 'ref'> {
|
|
|
467
467
|
name: IconName;
|
|
468
468
|
variant?: IconVariant;
|
|
469
469
|
size?: number | string;
|
|
470
|
+
title?: string;
|
|
470
471
|
fallback?: ReactNode;
|
|
471
472
|
}
|
|
472
473
|
/**
|
|
473
474
|
* DynamicPixelIcon - Lazy-loads icons at runtime for better code-splitting.
|
|
474
475
|
* Falls back to `fallback` or null if the icon cannot be resolved.
|
|
475
476
|
*/
|
|
476
|
-
declare const DynamicPixelIcon: ({ name, variant, size, fallback, ...props }: DynamicPixelIconProps) => string | number | boolean | Iterable<ReactNode> | react_jsx_runtime.JSX.Element | null;
|
|
477
|
+
declare const DynamicPixelIcon: ({ name, variant, size, title, fallback, ...props }: DynamicPixelIconProps) => string | number | boolean | Iterable<ReactNode> | react_jsx_runtime.JSX.Element | null;
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Minimal SVG element names supported by the icon set.
|
|
481
|
+
* Mirrors the React 19 `SVGElementType` addition while staying backward compatible.
|
|
482
|
+
*/
|
|
483
|
+
type IconSvgElement =
|
|
484
|
+
| 'circle'
|
|
485
|
+
| 'ellipse'
|
|
486
|
+
| 'g'
|
|
487
|
+
| 'line'
|
|
488
|
+
| 'path'
|
|
489
|
+
| 'polygon'
|
|
490
|
+
| 'polyline'
|
|
491
|
+
| 'rect';
|
|
492
|
+
|
|
493
|
+
type IconNode = [elementName: IconSvgElement, attrs: Record<string, string>][];
|
|
494
|
+
|
|
495
|
+
type SVGAttributes = Partial<SVGProps<SVGSVGElement>>;
|
|
496
|
+
type ElementAttributes = RefAttributes<SVGSVGElement> & SVGAttributes;
|
|
497
|
+
|
|
498
|
+
interface IconBaseProps extends ElementAttributes {
|
|
499
|
+
size?: string | number;
|
|
500
|
+
absoluteStrokeWidth?: boolean;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
type IconComponent = ForwardRefExoticComponent<
|
|
504
|
+
Omit<IconBaseProps, 'ref'> & RefAttributes<SVGSVGElement>
|
|
505
|
+
>;
|
|
477
506
|
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
* Mirrors the React 19 `SVGElementType` addition while staying backward compatible.
|
|
481
|
-
*/
|
|
482
|
-
type IconSvgElement =
|
|
483
|
-
| 'circle'
|
|
484
|
-
| 'ellipse'
|
|
485
|
-
| 'g'
|
|
486
|
-
| 'line'
|
|
487
|
-
| 'path'
|
|
488
|
-
| 'polygon'
|
|
489
|
-
| 'polyline'
|
|
490
|
-
| 'rect';
|
|
491
|
-
|
|
492
|
-
type IconNode = [elementName: IconSvgElement, attrs: Record<string, string>][];
|
|
493
|
-
|
|
494
|
-
type SVGAttributes = Partial<SVGProps<SVGSVGElement>>;
|
|
495
|
-
type ElementAttributes = RefAttributes<SVGSVGElement> & SVGAttributes;
|
|
496
|
-
|
|
497
|
-
interface IconBaseProps extends ElementAttributes {
|
|
498
|
-
size?: string | number;
|
|
499
|
-
absoluteStrokeWidth?: boolean;
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
type IconComponent = ForwardRefExoticComponent<
|
|
503
|
-
Omit<IconBaseProps, 'ref'> & RefAttributes<SVGSVGElement>
|
|
504
|
-
>;
|
|
505
|
-
|
|
506
|
-
// Legacy/simple component typing used by the generated registry
|
|
507
|
-
type IconProps = SVGProps<SVGSVGElement> & { title?: string };
|
|
507
|
+
// Legacy/simple component typing used by the generated registry
|
|
508
|
+
type IconProps = SVGProps<SVGSVGElement> & { title?: string };
|
|
508
509
|
type IconComponentFn = ComponentType<IconProps>;
|
|
509
510
|
|
|
510
511
|
export { DynamicPixelIcon, type ElementAttributes, type IconBaseProps, type IconComponent, type IconComponentFn, IconName, type IconNode, type IconProps, type IconSvgElement, IconVariant, PixelIcon, type SVGAttributes };
|
package/dist/index.js
CHANGED
|
@@ -458,36 +458,39 @@ var dynamicIconImports = {
|
|
|
458
458
|
"window-close-solid": () => loadIcon("@hackernoon/pixel-icon-library/icons/SVG/solid/window-close-solid.svg")
|
|
459
459
|
};
|
|
460
460
|
var dynamicIconImports_default = dynamicIconImports;
|
|
461
|
-
|
|
461
|
+
|
|
462
|
+
// src/utils/resolveIconName.ts
|
|
463
|
+
function resolveIconName(name, variant) {
|
|
464
|
+
const hasBrandsSuffix = name.endsWith("-brands");
|
|
465
|
+
const hasPurcatsSuffix = name.endsWith("-purcats");
|
|
466
|
+
const hasSolidSuffix = name.endsWith("-solid");
|
|
467
|
+
const baseName = name.replace(/-brands$/, "").replace(/-purcats$/, "").replace(/-solid$/, "");
|
|
468
|
+
let targetVariant;
|
|
469
|
+
if (variant) {
|
|
470
|
+
targetVariant = variant;
|
|
471
|
+
} else if (hasBrandsSuffix) {
|
|
472
|
+
targetVariant = "brands";
|
|
473
|
+
} else if (hasPurcatsSuffix) {
|
|
474
|
+
targetVariant = "purcats";
|
|
475
|
+
} else if (hasSolidSuffix) {
|
|
476
|
+
targetVariant = "solid";
|
|
477
|
+
} else {
|
|
478
|
+
targetVariant = "regular";
|
|
479
|
+
}
|
|
480
|
+
const candidate = targetVariant === "regular" ? baseName : `${baseName}-${targetVariant}`;
|
|
481
|
+
return dynamicIconImports_default[candidate] ? candidate : void 0;
|
|
482
|
+
}
|
|
483
|
+
var DEFAULT_SIZE = 24;
|
|
462
484
|
function PixelIcon({
|
|
463
485
|
name,
|
|
464
486
|
variant,
|
|
465
|
-
size =
|
|
487
|
+
size = DEFAULT_SIZE,
|
|
466
488
|
title,
|
|
467
489
|
fallback = null,
|
|
468
490
|
...rest
|
|
469
491
|
}) {
|
|
470
492
|
const [IconComponent, setIconComponent] = useState();
|
|
471
|
-
const resolvedName = useMemo(() =>
|
|
472
|
-
const hasBrandsSuffix = name.endsWith("-brands");
|
|
473
|
-
const hasPurcatsSuffix = name.endsWith("-purcats");
|
|
474
|
-
const hasSolidSuffix = name.endsWith("-solid");
|
|
475
|
-
let baseName = name.replace(/-brands$/, "").replace(/-purcats$/, "").replace(/-solid$/, "");
|
|
476
|
-
let targetVariant;
|
|
477
|
-
if (variant) {
|
|
478
|
-
targetVariant = variant;
|
|
479
|
-
} else if (hasBrandsSuffix) {
|
|
480
|
-
targetVariant = "brands";
|
|
481
|
-
} else if (hasPurcatsSuffix) {
|
|
482
|
-
targetVariant = "purcats";
|
|
483
|
-
} else if (hasSolidSuffix) {
|
|
484
|
-
targetVariant = "solid";
|
|
485
|
-
} else {
|
|
486
|
-
targetVariant = "regular";
|
|
487
|
-
}
|
|
488
|
-
const candidate = targetVariant === "regular" ? baseName : `${baseName}-${targetVariant}`;
|
|
489
|
-
return dynamicIconImports_default[candidate] ? candidate : void 0;
|
|
490
|
-
}, [name, variant]);
|
|
493
|
+
const resolvedName = useMemo(() => resolveIconName(name, variant), [name, variant]);
|
|
491
494
|
useEffect(() => {
|
|
492
495
|
let cancelled = false;
|
|
493
496
|
if (!resolvedName) {
|
|
@@ -508,7 +511,7 @@ function PixelIcon({
|
|
|
508
511
|
};
|
|
509
512
|
}, [resolvedName]);
|
|
510
513
|
if (!IconComponent) return fallback ?? null;
|
|
511
|
-
const dimension = typeof size === "number" ? `${size}px` : size ?? `${
|
|
514
|
+
const dimension = typeof size === "number" ? `${size}px` : size ?? `${DEFAULT_SIZE}px`;
|
|
512
515
|
return /* @__PURE__ */ jsx(
|
|
513
516
|
IconComponent,
|
|
514
517
|
{
|
|
@@ -522,41 +525,38 @@ function PixelIcon({
|
|
|
522
525
|
}
|
|
523
526
|
);
|
|
524
527
|
}
|
|
528
|
+
var lazyCache = /* @__PURE__ */ new Map();
|
|
529
|
+
var DEFAULT_SIZE2 = 24;
|
|
525
530
|
var DynamicPixelIcon = ({
|
|
526
531
|
name,
|
|
527
532
|
variant,
|
|
528
|
-
size =
|
|
533
|
+
size = DEFAULT_SIZE2,
|
|
534
|
+
title,
|
|
529
535
|
fallback = null,
|
|
530
536
|
...props
|
|
531
537
|
}) => {
|
|
532
|
-
const dimension = typeof size === "number" ? `${size}px` : size ??
|
|
533
|
-
const resolvedName = useMemo(() =>
|
|
534
|
-
const hasBrandsSuffix = name.endsWith("-brands");
|
|
535
|
-
const hasPurcatsSuffix = name.endsWith("-purcats");
|
|
536
|
-
const hasSolidSuffix = name.endsWith("-solid");
|
|
537
|
-
let baseName = name.replace(/-brands$/, "").replace(/-purcats$/, "").replace(/-solid$/, "");
|
|
538
|
-
let targetVariant;
|
|
539
|
-
if (variant) {
|
|
540
|
-
targetVariant = variant;
|
|
541
|
-
} else if (hasBrandsSuffix) {
|
|
542
|
-
targetVariant = "brands";
|
|
543
|
-
} else if (hasPurcatsSuffix) {
|
|
544
|
-
targetVariant = "purcats";
|
|
545
|
-
} else if (hasSolidSuffix) {
|
|
546
|
-
targetVariant = "solid";
|
|
547
|
-
} else {
|
|
548
|
-
targetVariant = "regular";
|
|
549
|
-
}
|
|
550
|
-
const candidate = targetVariant === "regular" ? baseName : `${baseName}-${targetVariant}`;
|
|
551
|
-
return dynamicIconImports_default[candidate] ? candidate : void 0;
|
|
552
|
-
}, [name, variant]);
|
|
538
|
+
const dimension = typeof size === "number" ? `${size}px` : size ?? `${DEFAULT_SIZE2}px`;
|
|
539
|
+
const resolvedName = useMemo(() => resolveIconName(name, variant), [name, variant]);
|
|
553
540
|
const LazyIcon = useMemo(() => {
|
|
554
541
|
if (!resolvedName) return void 0;
|
|
555
|
-
|
|
556
|
-
|
|
542
|
+
if (lazyCache.has(resolvedName)) return lazyCache.get(resolvedName);
|
|
543
|
+
const component = lazy(dynamicIconImports_default[resolvedName]);
|
|
544
|
+
lazyCache.set(resolvedName, component);
|
|
545
|
+
return component;
|
|
557
546
|
}, [resolvedName]);
|
|
558
547
|
if (!LazyIcon) return fallback ?? null;
|
|
559
|
-
return /* @__PURE__ */ jsx(Suspense, { fallback, children: /* @__PURE__ */ jsx(
|
|
548
|
+
return /* @__PURE__ */ jsx(Suspense, { fallback, children: /* @__PURE__ */ jsx(
|
|
549
|
+
LazyIcon,
|
|
550
|
+
{
|
|
551
|
+
...props,
|
|
552
|
+
width: props.width ?? dimension,
|
|
553
|
+
height: props.height ?? dimension,
|
|
554
|
+
"aria-label": props["aria-label"] ?? title ?? name,
|
|
555
|
+
role: props.role ?? "img",
|
|
556
|
+
focusable: props.focusable ?? "false",
|
|
557
|
+
title
|
|
558
|
+
}
|
|
559
|
+
) });
|
|
560
560
|
};
|
|
561
561
|
var SvgAndroid = (props) => /* @__PURE__ */ jsxs("svg", { id: "Android", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", ...props, children: [
|
|
562
562
|
/* @__PURE__ */ jsx("rect", { x: 5, y: 10, width: 1, height: 2 }),
|