islamic-icons 2.0.4 → 2.1.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.
@@ -4,7 +4,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
4
4
  * Use this only for the RN build; the web build uses IconWrapper.tsx (DOM SVG).
5
5
  */
6
6
  import React from 'react';
7
- import Svg from 'react-native-svg';
7
+ import Svg, { Image as RNSvgImage } from 'react-native-svg';
8
8
  const DEFAULT_SIZE = 24;
9
9
  const DEFAULT_VIEWBOX = '0 0 24 24';
10
10
  const HEX_FILL_REGEX = /^#[0-9A-Fa-f]{3,8}$/;
@@ -12,32 +12,27 @@ function nodeHasExplicitFill(node) {
12
12
  if (!React.isValidElement(node))
13
13
  return false;
14
14
  const fill = node.props?.fill;
15
- return typeof fill === 'string' && HEX_FILL_REGEX.test(fill);
15
+ if (typeof fill !== 'string')
16
+ return false;
17
+ if (HEX_FILL_REGEX.test(fill))
18
+ return true;
19
+ return fill.startsWith('url(');
16
20
  }
17
- /** True if any descendant has explicit fill (e.g. hex #...); then root uses fill="none" so child colors are preserved */
18
- function contentHasExplicitFills(node) {
21
+ /** Deep scan: explicit fills, gradients, or raster <Image> root fill stays none */
22
+ function subtreeNeedsTransparentRoot(node) {
19
23
  if (!React.isValidElement(node))
20
24
  return false;
21
- const children = node.props?.children;
25
+ if (nodeHasExplicitFill(node))
26
+ return true;
27
+ const type = node.type;
28
+ const tag = typeof type === 'string' ? type.toLowerCase() : '';
29
+ if (tag === 'image' || type === RNSvgImage)
30
+ return true;
31
+ const children = node.props.children;
22
32
  if (children == null)
23
33
  return false;
24
34
  const list = Array.isArray(children) ? children : [children];
25
- for (const child of list) {
26
- if (React.isValidElement(child)) {
27
- if (nodeHasExplicitFill(child))
28
- return true;
29
- // Recurse one level (e.g. Paths inside a Fragment or G)
30
- const grand = child.props?.children;
31
- if (grand != null) {
32
- const grandList = Array.isArray(grand) ? grand : [grand];
33
- for (const g of grandList) {
34
- if (React.isValidElement(g) && nodeHasExplicitFill(g))
35
- return true;
36
- }
37
- }
38
- }
39
- }
40
- return false;
35
+ return list.some((c) => subtreeNeedsTransparentRoot(c));
41
36
  }
42
37
  /** Extract inner content and viewBox if passed a full Svg element (from generator) */
43
38
  function normalizeContent(node) {
@@ -55,7 +50,7 @@ function normalizeContent(node) {
55
50
  }
56
51
  export function createIconComponentRN(displayName, defaultAriaLabel, svgContent) {
57
52
  const { content, viewBox } = normalizeContent(svgContent);
58
- const isMultiColor = contentHasExplicitFills(svgContent);
53
+ const isMultiColor = subtreeNeedsTransparentRoot(svgContent);
59
54
  const IconComponent = ({ size = DEFAULT_SIZE, color, style, 'aria-label': ariaLabel, title, ...rest }) => {
60
55
  const sizeNum = typeof size === 'number' ? size : parseFloat(String(size)) || DEFAULT_SIZE;
61
56
  const rootFill = isMultiColor ? 'none' : (color ?? 'currentColor');