@proulr/sdui-components 0.1.35 → 0.1.38

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proulr/sdui-components",
3
- "version": "0.1.35",
3
+ "version": "0.1.38",
4
4
  "type": "module",
5
5
  "main": "./src/renderer/index.ts",
6
6
  "types": "./src/renderer/index.ts",
@@ -37,7 +37,8 @@
37
37
  "access": "public"
38
38
  },
39
39
  "dependencies": {
40
- "@proulr/sdui-contract": "^0.1.5"
40
+ "@proulr/sdui-contract": "^0.1.10",
41
+ "react-native-qrcode-svg": "^6.3.21"
41
42
  },
42
43
  "peerDependencies": {
43
44
  "expo-blur": ">=15",
@@ -45,7 +46,8 @@
45
46
  "react": ">=19",
46
47
  "react-native": ">=0.85",
47
48
  "react-native-google-mobile-ads": ">=16",
48
- "react-native-safe-area-context": ">=5"
49
+ "react-native-safe-area-context": ">=5",
50
+ "react-native-svg": ">=15"
49
51
  },
50
52
  "peerDependenciesMeta": {
51
53
  "react": {
@@ -65,6 +67,9 @@
65
67
  },
66
68
  "react-native-safe-area-context": {
67
69
  "optional": true
70
+ },
71
+ "react-native-svg": {
72
+ "optional": true
68
73
  }
69
74
  },
70
75
  "devDependencies": {
@@ -82,6 +87,7 @@
82
87
  "react-native": "0.85.3",
83
88
  "react-native-google-mobile-ads": "^16.3.4",
84
89
  "react-native-safe-area-context": "~5.7.0",
90
+ "react-native-svg": "^15.15.5",
85
91
  "typescript": "~6.0.3",
86
92
  "vitest": "^3.2.7"
87
93
  },
@@ -49,6 +49,26 @@ type ButtonProps = LayoutProps & {
49
49
 
50
50
  export const Button: BdcComponent = (props) => layoutBlock('button', props as ButtonProps);
51
51
 
52
+ type IconProps = LayoutProps & {
53
+ /** AppIconName kebab-case (catalog) — ex.: 'gift', 'share'. */
54
+ name: string;
55
+ size?: number;
56
+ /** ColorToken do tema M3 — ex.: 'primary', 'onSurfaceVariant'. */
57
+ color?: string;
58
+ };
59
+
60
+ export const Icon: BdcComponent = (props) => layoutBlock('icon', props as IconProps);
61
+
62
+ type QrCodeProps = LayoutProps & {
63
+ /** Conteúdo codificado no QR (URL de convite). */
64
+ value: string;
65
+ size?: number;
66
+ /** Rótulo exibido sob o QR (ex.: '@handle'). */
67
+ label?: string;
68
+ };
69
+
70
+ export const QrCode: BdcComponent = (props) => layoutBlock('qr_code', props as QrCodeProps);
71
+
52
72
  type InfoBannerProps = LayoutProps & {
53
73
  message: string;
54
74
  };
package/src/bdc/index.ts CHANGED
@@ -3,9 +3,11 @@ export {
3
3
  Button,
4
4
  Card,
5
5
  Column,
6
+ Icon,
6
7
  InfoBanner,
7
8
  ListItem,
8
9
  NativeAd,
10
+ QrCode,
9
11
  Row,
10
12
  Screen,
11
13
  Scroll,
@@ -2,7 +2,8 @@ import React from 'react';
2
2
  import { Platform, ScrollView, StyleSheet, Text, View } from 'react-native';
3
3
  import type { SduiBlock } from '@proulr/sdui-contract';
4
4
  import { AppButton } from '../ui/AppButton';
5
- import { colors, m3Type, spacing } from '../theme/proulr-theme';
5
+ import { AppIcon, isAppIconName } from '../ui/app-icon';
6
+ import { colors, m3Colors, m3Type, spacing } from '../theme/proulr-theme';
6
7
  import {
7
8
  resolveGapProp,
8
9
  resolvePaddingProp,
@@ -135,6 +136,27 @@ export function SduiButtonBlock({ block, onAction }: SduiBlockRenderProps) {
135
136
  );
136
137
  }
137
138
 
139
+ /**
140
+ * Bloco genérico de ícone vetorial (AppIcon). Wire: `name` = AppIconName
141
+ * kebab-case, `size` em px, `color` = ColorToken do tema. O container aceita
142
+ * StyleWire (background, borda, padding) para composições tipo hero circle.
143
+ */
144
+ export function SduiIconBlock({ block }: SduiBlockRenderProps) {
145
+ const name = typeof block.props.name === 'string' ? block.props.name : '';
146
+ if (!isAppIconName(name)) return null;
147
+
148
+ const size = typeof block.props.size === 'number' ? block.props.size : spacing.lg;
149
+ const colorToken = typeof block.props.color === 'string' ? block.props.color : undefined;
150
+ const color =
151
+ (colorToken ? m3Colors[colorToken as keyof typeof m3Colors] : undefined) ?? colors.onSurface;
152
+
153
+ return (
154
+ <View style={resolveViewStyleProps(block.props.style as Record<string, unknown>)}>
155
+ <AppIcon name={name} size={size} color={color} />
156
+ </View>
157
+ );
158
+ }
159
+
138
160
  export function SduiSpacerBlock({ block }: SduiBlockRenderProps) {
139
161
  const height = typeof block.props.height === 'number' ? block.props.height : spacing.md;
140
162
  return <View style={{ height }} />;
@@ -0,0 +1,51 @@
1
+ import React from 'react';
2
+ import { StyleSheet, Text, View } from 'react-native';
3
+ import QRCode from 'react-native-qrcode-svg';
4
+ import { m3Colors, m3Shape, m3Type, spacing } from '../theme/proulr-theme';
5
+ import { resolveViewStyleProps } from '../theme/resolve-style-props';
6
+ import type { SduiBlockRenderProps } from './SduiPrimitiveBlocks';
7
+
8
+ /**
9
+ * Nametag de QR estilo "cartão de convite" (ref. Instagram): cartão claro
10
+ * (inverseSurface) com QR de alto contraste e rótulo opcional (ex.: @handle).
11
+ * Wire: `value` = conteúdo do QR, `size` em px, `label` = texto sob o código.
12
+ */
13
+ export function SduiQrCodeBlock({ block }: SduiBlockRenderProps) {
14
+ const value = typeof block.props.value === 'string' ? block.props.value : '';
15
+ if (!value) return null;
16
+
17
+ const size = typeof block.props.size === 'number' ? block.props.size : 200;
18
+ const label = typeof block.props.label === 'string' ? block.props.label : '';
19
+
20
+ return (
21
+ <View
22
+ style={[styles.card, resolveViewStyleProps(block.props.style as Record<string, unknown>)]}
23
+ >
24
+ <QRCode
25
+ value={value}
26
+ size={size}
27
+ color={m3Colors.inverseOnSurface}
28
+ backgroundColor={m3Colors.inverseSurface}
29
+ />
30
+ {label ? <Text style={styles.label}>{label}</Text> : null}
31
+ </View>
32
+ );
33
+ }
34
+
35
+ const styles = StyleSheet.create({
36
+ card: {
37
+ alignSelf: 'center',
38
+ alignItems: 'center',
39
+ gap: spacing.lg,
40
+ backgroundColor: m3Colors.inverseSurface,
41
+ borderRadius: m3Shape.cornerExtraLarge,
42
+ paddingVertical: spacing.xl,
43
+ paddingHorizontal: spacing.xl,
44
+ },
45
+ label: {
46
+ ...m3Type.title,
47
+ color: m3Colors.inverseOnSurface,
48
+ letterSpacing: 2,
49
+ textTransform: 'uppercase',
50
+ },
51
+ });
@@ -3,6 +3,7 @@ import type { SduiBlock } from '@proulr/sdui-contract';
3
3
  import {
4
4
  SduiButtonBlock,
5
5
  SduiColumnBlock,
6
+ SduiIconBlock,
6
7
  SduiInfoBannerBlock,
7
8
  SduiRowBlock,
8
9
  SduiScrollBlock,
@@ -40,6 +41,7 @@ import {
40
41
  SduiSegmentedTabsBlock,
41
42
  } from './blocks/SduiInboxBlocks';
42
43
  import { SduiNativeAdBlock } from './blocks/SduiNativeAdBlock';
44
+ import { SduiQrCodeBlock } from './blocks/SduiQrCodeBlock';
43
45
  import {
44
46
  SduiAlbumDetailBlock,
45
47
  SduiAlbumGridBlock,
@@ -74,6 +76,8 @@ const REGISTRY: Record<string, SduiBlockComponent> = {
74
76
  row: SduiRowBlock,
75
77
  scroll: SduiScrollBlock,
76
78
  button: SduiButtonBlock,
79
+ icon: SduiIconBlock,
80
+ qr_code: SduiQrCodeBlock,
77
81
  spacer: SduiSpacerBlock,
78
82
  info_banner: SduiInfoBannerBlock,
79
83
  native_ad: SduiNativeAdBlock,
@@ -69,6 +69,7 @@ export function resolveTextStyleProps(
69
69
  color: resolveColor(style.color),
70
70
  marginTop: resolveSpacing(style.margin_top),
71
71
  opacity: style.opacity,
72
+ textAlign: style.text_align,
72
73
  };
73
74
  }
74
75