@wecareu/icons 1.1.3 → 1.2.2

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.mts CHANGED
@@ -12,6 +12,18 @@ type Props = SvgProps & {
12
12
  };
13
13
  declare const Icon: React.FC<Props>;
14
14
 
15
+ interface FlagIconProps {
16
+ /**
17
+ * ISO 3166-1 alpha-2 country code (e.g. 'BR', 'US', 'PT')
18
+ */
19
+ countryCode: string;
20
+ /**
21
+ * Size in pixels. Width will be proportional (3:2 ratio). Defaults to 20
22
+ */
23
+ size?: number;
24
+ }
25
+ declare function FlagIcon({ countryCode, size }: FlagIconProps): React.ReactElement;
26
+
15
27
  declare const ICON_NAMES: IconName[];
16
28
 
17
- export { ICONS, ICONS as ICONS_MAP, ICON_NAMES, Icon, type IconName };
29
+ export { FlagIcon, type FlagIconProps, ICONS, ICONS as ICONS_MAP, ICON_NAMES, Icon, type IconName };
package/dist/index.d.ts CHANGED
@@ -12,6 +12,18 @@ type Props = SvgProps & {
12
12
  };
13
13
  declare const Icon: React.FC<Props>;
14
14
 
15
+ interface FlagIconProps {
16
+ /**
17
+ * ISO 3166-1 alpha-2 country code (e.g. 'BR', 'US', 'PT')
18
+ */
19
+ countryCode: string;
20
+ /**
21
+ * Size in pixels. Width will be proportional (3:2 ratio). Defaults to 20
22
+ */
23
+ size?: number;
24
+ }
25
+ declare function FlagIcon({ countryCode, size }: FlagIconProps): React.ReactElement;
26
+
15
27
  declare const ICON_NAMES: IconName[];
16
28
 
17
- export { ICONS, ICONS as ICONS_MAP, ICON_NAMES, Icon, type IconName };
29
+ export { FlagIcon, type FlagIconProps, ICONS, ICONS as ICONS_MAP, ICON_NAMES, Icon, type IconName };
package/dist/index.js CHANGED
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.tsx
31
31
  var src_exports = {};
32
32
  __export(src_exports, {
33
+ FlagIcon: () => FlagIcon,
33
34
  ICONS: () => ICONS,
34
35
  ICONS_MAP: () => ICONS,
35
36
  ICON_NAMES: () => ICON_NAMES,
@@ -636,6 +637,28 @@ var Icon = ({ name, size, color, testID = "icon", ...rest }) => {
636
637
  );
637
638
  };
638
639
 
640
+ // src/FlagIcon.tsx
641
+ var import_react_native = require("react-native");
642
+ var import_jsx_runtime71 = require("react/jsx-runtime");
643
+ function countryCodeToEmoji(code) {
644
+ return [...code.toUpperCase().slice(0, 2)].map((c) => String.fromCodePoint(127462 + c.charCodeAt(0) - 65)).join("");
645
+ }
646
+ function FlagIcon({ countryCode, size = 20 }) {
647
+ const code = countryCode.toLowerCase().slice(0, 2);
648
+ if (import_react_native.Platform.OS === "web") {
649
+ return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
650
+ import_react_native.Image,
651
+ {
652
+ accessibilityLabel: countryCode.toUpperCase(),
653
+ resizeMode: "contain",
654
+ source: { uri: `https://flagcdn.com/w40/${code}.png` },
655
+ style: { borderRadius: 2, height: size, width: size * 1.5 }
656
+ }
657
+ );
658
+ }
659
+ return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_react_native.Text, { accessibilityLabel: countryCode, style: { fontSize: size, lineHeight: size + 4 }, children: countryCodeToEmoji(countryCode) });
660
+ }
661
+
639
662
  // src/LottieView.tsx
640
663
  var import_lottie_react_native = __toESM(require("lottie-react-native"));
641
664
 
@@ -657,7 +680,7 @@ var LOTTIE_ANIMATIONS = {
657
680
  var LOTTIE_ANIMATION_NAMES = ["dots", "locations", "notification"];
658
681
 
659
682
  // src/LottieView.tsx
660
- var import_jsx_runtime71 = require("react/jsx-runtime");
683
+ var import_jsx_runtime72 = require("react/jsx-runtime");
661
684
  function Lottie({
662
685
  autoPlay = true,
663
686
  loop = true,
@@ -669,7 +692,7 @@ function Lottie({
669
692
  }) {
670
693
  const source = LOTTIE_ANIMATIONS[name];
671
694
  const sizeStyle = size != null ? { height: size, width: size } : {};
672
- return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
695
+ return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
673
696
  import_lottie_react_native.default,
674
697
  {
675
698
  autoPlay,
@@ -686,6 +709,7 @@ function Lottie({
686
709
  var ICON_NAMES = Object.keys(ICONS);
687
710
  // Annotate the CommonJS export names for ESM import in node:
688
711
  0 && (module.exports = {
712
+ FlagIcon,
689
713
  ICONS,
690
714
  ICONS_MAP,
691
715
  ICON_NAMES,
package/dist/index.mjs CHANGED
@@ -600,9 +600,32 @@ var Icon = ({ name, size, color, testID = "icon", ...rest }) => {
600
600
  );
601
601
  };
602
602
 
603
+ // src/FlagIcon.tsx
604
+ import { Image as Image2, Platform, Text } from "react-native";
605
+ import { jsx as jsx71 } from "react/jsx-runtime";
606
+ function countryCodeToEmoji(code) {
607
+ return [...code.toUpperCase().slice(0, 2)].map((c) => String.fromCodePoint(127462 + c.charCodeAt(0) - 65)).join("");
608
+ }
609
+ function FlagIcon({ countryCode, size = 20 }) {
610
+ const code = countryCode.toLowerCase().slice(0, 2);
611
+ if (Platform.OS === "web") {
612
+ return /* @__PURE__ */ jsx71(
613
+ Image2,
614
+ {
615
+ accessibilityLabel: countryCode.toUpperCase(),
616
+ resizeMode: "contain",
617
+ source: { uri: `https://flagcdn.com/w40/${code}.png` },
618
+ style: { borderRadius: 2, height: size, width: size * 1.5 }
619
+ }
620
+ );
621
+ }
622
+ return /* @__PURE__ */ jsx71(Text, { accessibilityLabel: countryCode, style: { fontSize: size, lineHeight: size + 4 }, children: countryCodeToEmoji(countryCode) });
623
+ }
624
+
603
625
  // src/index.tsx
604
626
  var ICON_NAMES = Object.keys(ICONS);
605
627
  export {
628
+ FlagIcon,
606
629
  ICONS,
607
630
  ICONS as ICONS_MAP,
608
631
  ICON_NAMES,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wecareu/icons",
3
- "version": "1.1.3",
3
+ "version": "1.2.2",
4
4
  "description": "Sistema de ícones SVG para WeCareU Design System",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+
3
+ interface FlagIconProps {
4
+ /**
5
+ * ISO 3166-1 alpha-2 country code (e.g. 'BR', 'US', 'PT')
6
+ */
7
+ countryCode: string;
8
+ /**
9
+ * Size in pixels. Width will be proportional (3:2 ratio). Defaults to 20
10
+ */
11
+ size?: number;
12
+ }
13
+ export declare function FlagIcon({ countryCode, size }: FlagIconProps): React.ReactElement;
14
+ export type { FlagIconProps };
15
+ //# sourceMappingURL=FlagIcon.d.ts.map
@@ -0,0 +1,41 @@
1
+ import React from 'react'
2
+
3
+ import { Image, Platform, Text } from 'react-native'
4
+
5
+ interface FlagIconProps {
6
+ /**
7
+ * ISO 3166-1 alpha-2 country code (e.g. 'BR', 'US', 'PT')
8
+ */
9
+ countryCode: string
10
+ /**
11
+ * Size in pixels. Width will be proportional (3:2 ratio). Defaults to 20
12
+ */
13
+ size?: number
14
+ }
15
+
16
+ function countryCodeToEmoji(code: string): string {
17
+ return [...code.toUpperCase().slice(0, 2)]
18
+ .map(c => String.fromCodePoint(0x1f1e6 + c.charCodeAt(0) - 65))
19
+ .join('')
20
+ }
21
+
22
+ export function FlagIcon({ countryCode, size = 20 }: FlagIconProps): React.ReactElement {
23
+ const code = countryCode.toLowerCase().slice(0, 2)
24
+
25
+ if (Platform.OS === 'web') {
26
+ return (
27
+ <Image
28
+ accessibilityLabel={countryCode.toUpperCase()}
29
+ resizeMode="contain"
30
+ source={{ uri: `https://flagcdn.com/w40/${code}.png` }}
31
+ style={{ borderRadius: 2, height: size, width: size * 1.5 }}
32
+ />
33
+ )
34
+ }
35
+
36
+ return (
37
+ <Text accessibilityLabel={countryCode} style={{ fontSize: size, lineHeight: size + 4 }}>
38
+ {countryCodeToEmoji(countryCode)}
39
+ </Text>
40
+ )
41
+ }
package/src/index.d.ts CHANGED
@@ -2,6 +2,8 @@ import type { IconName } from './Icon';
2
2
  export { Icon, ICONS } from './Icon';
3
3
  export type { IconName } from './Icon';
4
4
  export { ICONS as ICONS_MAP } from './icons-map';
5
+ export { FlagIcon } from './FlagIcon';
6
+ export type { FlagIconProps } from './FlagIcon';
5
7
  export type { LottieAnimationName } from './lottie-map';
6
8
  export { LOTTIE_ANIMATION_NAMES, LOTTIE_ANIMATIONS } from './lottie-map';
7
9
  export declare const ICON_NAMES: IconName[];
package/src/index.tsx CHANGED
@@ -6,6 +6,9 @@ export { Icon, ICONS } from './Icon'
6
6
  export type { IconName } from './Icon'
7
7
  export { ICONS as ICONS_MAP } from './icons-map'
8
8
 
9
+ // Flag emojis
10
+ export { FlagIcon } from './FlagIcon'
11
+
9
12
  // Lottie component and metadata
10
13
  export { Lottie } from './LottieView'
11
14
  export type { LottieAnimationName } from './lottie-map'