vpt-sebraeds 0.0.107 → 0.0.108

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.
@@ -0,0 +1,92 @@
1
+ import React from 'react';
2
+ import { View, Text } from 'react-native';
3
+ import colors from '@styles/tokens/colors';
4
+ import Icon from './index';
5
+ import remixIcons from './remix/remixIcons.generated';
6
+
7
+ const officialIconNames = Object.keys(remixIcons);
8
+
9
+ const meta = {
10
+ title: 'Atom/Icon',
11
+ component: Icon,
12
+ tags: ['autodocs'],
13
+ parameters: {
14
+ layout: 'padded',
15
+ docs: {
16
+ description: {
17
+ component:
18
+ 'Ícone do Design System. Nomes listados em `components/Icon/remix/manifest.json` usam o SVG oficial do pacote `remixicon`; os demais usam o catálogo legado `react-native-remix-icon`.',
19
+ },
20
+ },
21
+ },
22
+ argTypes: {
23
+ name: {
24
+ description: 'Nome do ícone Remix. Ícones oficiais disponíveis: ' + officialIconNames.join(', '),
25
+ control: 'text',
26
+ },
27
+ size: {
28
+ description: 'Largura e altura do ícone em pixels',
29
+ control: { type: 'range', min: 12, max: 96, step: 1 },
30
+ },
31
+ color: {
32
+ description: 'Cor de preenchimento do ícone',
33
+ control: 'color',
34
+ },
35
+ opacity: {
36
+ description: 'Opacidade do SVG (prop adicional repassada ao react-native-svg)',
37
+ control: { type: 'range', min: 0, max: 1, step: 0.1 },
38
+ },
39
+ },
40
+ };
41
+
42
+ export default meta;
43
+
44
+ export const Default = {
45
+ args: {
46
+ name: 'send-ins-line',
47
+ },
48
+ };
49
+
50
+ export const CustomSize = {
51
+ args: {
52
+ name: 'send-ins-line',
53
+ size: 48,
54
+ },
55
+ };
56
+
57
+ export const CustomColor = {
58
+ args: {
59
+ name: 'send-ins-line',
60
+ size: 48,
61
+ color: colors.text.title,
62
+ },
63
+ };
64
+
65
+ const sizes = [16, 24, 32, 48, 64];
66
+
67
+ export const Sizes = {
68
+ args: {
69
+ name: 'send-ins-line',
70
+ color: colors.text.title,
71
+ },
72
+ render: args => (
73
+ <View style={{ flexDirection: 'row', alignItems: 'flex-end', gap: 16 }}>
74
+ {sizes.map(size => (
75
+ <View key={size} style={{ alignItems: 'center', gap: 4 }}>
76
+ <Icon {...args} size={size} />
77
+ <Text style={{ fontSize: 10, color: colors.text.tertiary }}>{size}px</Text>
78
+ </View>
79
+ ))}
80
+ </View>
81
+ ),
82
+ };
83
+
84
+ export const AdditionalSvgProps = {
85
+ args: {
86
+ name: 'send-ins-line',
87
+ size: 48,
88
+ color: colors.text.title,
89
+ opacity: 0.4,
90
+ accessibilityLabel: 'Enviar',
91
+ },
92
+ };
@@ -0,0 +1,92 @@
1
+ # Icon — Guia técnico de integração
2
+
3
+ ## 1) O que é
4
+
5
+ `Icon` é o componente central de ícones do Design System. Ele resolve o `name` em duas fontes:
6
+
7
+ 1. **Remix Icon oficial** (pacote [`remixicon`](https://www.npmjs.com/package/remixicon)): ícones listados em `remix/manifest.json`, renderizados a partir da geometria do SVG oficial.
8
+ 2. **Catálogo legado** ([`react-native-remix-icon`](https://www.npmjs.com/package/react-native-remix-icon) `4.7.0`): todos os demais nomes, com o mesmo comportamento de antes.
9
+
10
+ Ícones oficiais disponíveis hoje: `send-ins-line` (`remixicon/icons/Business/send-ins-line.svg`).
11
+
12
+ ## 2) Dependências
13
+
14
+ | Pacote | Tipo | Uso |
15
+ |---|---|---|
16
+ | `react-native-svg` | peerDependency (já existente) | Renderização (`Svg` + `Path`) |
17
+ | `react-native-remix-icon` | dependency (já existente) | Catálogo legado |
18
+ | `remixicon` | devDependency | **Apenas** fonte dos SVGs para o gerador; não é usado em runtime |
19
+
20
+ Não há configuração de Metro, Vite, Babel ou `react-native-svg-transformer`. Os SVGs são convertidos em dados JavaScript no momento da geração (seção 5), por isso o `dist/` publicado e o app consumidor não precisam de nenhuma configuração extra.
21
+
22
+ ## 3) Uso
23
+
24
+ ```jsx
25
+ import { Icon } from 'vpt-sebraeds';
26
+
27
+ <Icon name="send-ins-line" size={24} color={colors.text.title} />
28
+ ```
29
+
30
+ O prefixo `ri-` é aceito (`ri-send-ins-line`), como no catálogo legado.
31
+
32
+ ## 4) Props API
33
+
34
+ | Prop | Tipo | Padrão | Descrição |
35
+ |---|---|---|---|
36
+ | `name` | `string` | — | Nome do ícone Remix |
37
+ | `size` | `number` | `24` | Largura e altura |
38
+ | `color` | `string` | `'#4F7CFE'` | Cor de preenchimento (`fill`) |
39
+ | `style` | `object` | `{}` | Estilo do SVG |
40
+ | `custom` | `'boletoDasMei' \| 'libras' \| null` | `null` | Ícone customizado do projeto; ignora `name` |
41
+ | demais | `SvgProps` | — | Repassadas ao `Svg` (ex.: `opacity`, `testID`, `accessibilityLabel`). **Somente para ícones oficiais**; no catálogo legado as props extras continuam sendo ignoradas |
42
+
43
+ Para ícones oficiais, as props extras são aplicadas depois de `width`/`height`/`fill`/`style`; um `fill` ou `width` passado explicitamente pelo consumidor prevalece sobre `color`/`size`.
44
+
45
+ **Nomes inválidos:** se o nome não está no manifest, segue para o catálogo legado, que renderiza o texto `Invalid Icon Name` (comportamento inalterado).
46
+
47
+ ## 5) Como adicionar um ícone oficial
48
+
49
+ 1. Encontre o nome em [remixicon.com](https://remixicon.com) (ex.: `chat-ai-line`).
50
+ 2. Adicione-o em `components/Icon/remix/manifest.json`.
51
+ 3. Rode `pnpm icons:generate`.
52
+ 4. Faça commit do `manifest.json` e do `remixIcons.generated.js`.
53
+
54
+ O gerador (`scripts/generate-remix-icons.js`):
55
+
56
+ - indexa todas as categorias de `remixicon/icons/` e falha se houver nome duplicado entre categorias;
57
+ - falha se um nome do manifest não existir no pacote;
58
+ - valida que o SVG tem a estrutura esperada (`<svg viewBox fill="currentColor">` + `<path d>`) e falha caso contrário, em vez de gerar algo incorreto;
59
+ - copia `viewBox` e `d` sem alteração e registra o caminho de origem em comentário.
60
+
61
+ `pnpm icons:check` falha se o arquivo gerado estiver desatualizado em relação ao manifest e à versão instalada do `remixicon` (útil em CI).
62
+
63
+ > Adicionar ao manifest um nome que já existe no catálogo legado faz esse nome passar a usar o SVG oficial em todos os consumidores. Confira visualmente, pois o desenho pode ter mudado entre versões do Remix Icon.
64
+
65
+ ## 6) Como atualizar o pacote oficial
66
+
67
+ ```bash
68
+ pnpm add -D remixicon@<versao>
69
+ pnpm icons:generate
70
+ ```
71
+
72
+ Revise o diff do `remixIcons.generated.js`: ele mostra exatamente quais geometrias mudaram.
73
+
74
+ ## 7) Estratégia de expansão e performance
75
+
76
+ - Somente os ícones do manifest entram no bundle (~1 KB por ícone). Gerar o catálogo completo (3.229 ícones na v4.9.1) adicionaria cerca de 2 MB de geometria ao bundle do app, por isso a inclusão é seletiva.
77
+ - Recomendação: migrar gradualmente adicionando ao manifest os nomes efetivamente usados (`iconEnums.ts` é um bom ponto de partida). Quando todos os nomes usados pelo Design System e pelo superApp estiverem no manifest, o `react-native-remix-icon` pode ser removido.
78
+
79
+ ## 8) Limitações conhecidas
80
+
81
+ - `react-native-remix-icon` continua necessário: `Icon`, `SEIcon`, `Card` (V1) e `ListItem` (V1) ainda o usam para o catálogo legado, e consumidores podem passar qualquer nome Remix.
82
+ - A cor é aplicada via `fill` no `Svg` raiz. Isso funciona para todos os ícones do `remixicon` 4.x, que usam apenas `fill="currentColor"`; o gerador falha se um SVG fugir desse padrão.
83
+
84
+ ## 9) Testes
85
+
86
+ `__tests__/Icon.test.tsx`: fidelidade ao SVG oficial, tamanho, cor, props extras, prefixo `ri-` e delegação ao catálogo legado.
87
+
88
+ ---
89
+
90
+ ## Changelog
91
+
92
+ - 2026-11-24 — integração com o pacote oficial `remixicon` via gerador de dados (`send-ins-line`), story `Atom/Icon`, testes e documentação.
@@ -1,15 +1,56 @@
1
1
  import React from 'react';
2
+ import Svg, { Path } from 'react-native-svg';
2
3
  import IconRemix from 'react-native-remix-icon';
3
4
  import { iconEnums } from './iconEnums';
5
+ import remixIcons from './remix/remixIcons.generated';
4
6
 
7
+ /**
8
+ * Ícone do Design System.
9
+ *
10
+ * Resolução do `name`:
11
+ * 1. Ícones oficiais do pacote `remixicon` listados em `remix/manifest.json`
12
+ * (ex.: `send-ins-line`), renderizados a partir do SVG oficial.
13
+ * 2. Demais nomes: biblioteca `react-native-remix-icon` (catálogo legado).
14
+ *
15
+ * @param {Object} props
16
+ * @param {string} props.name - Nome do ícone Remix (ex.: `'send-ins-line'`). O prefixo `ri-` é aceito.
17
+ * @param {number} [props.size=24] - Largura e altura em pixels.
18
+ * @param {string} [props.color='#4F7CFE'] - Cor de preenchimento do ícone.
19
+ * @param {Object} [props.style] - Estilo aplicado ao SVG.
20
+ * @param {string|null} [props.custom] - Ícone customizado do projeto (`'boletoDasMei'`, `'libras'`).
21
+ * Demais props compatíveis com `SvgProps` (ex.: `opacity`, `testID`, `accessibilityLabel`) são repassadas
22
+ * ao SVG apenas para ícones oficiais; o catálogo legado mantém o comportamento anterior.
23
+ */
5
24
  const Icon = ({
6
25
  name,
7
26
  size = 24,
8
27
  color = '#4F7CFE',
9
28
  style = {},
10
29
  custom = null,
30
+ ...svgProps
11
31
  }) => {
12
32
  if (!custom) {
33
+ const officialName = typeof name === 'string' && name.startsWith('ri-') ? name.substring(3) : name;
34
+ const official = Object.prototype.hasOwnProperty.call(remixIcons, officialName)
35
+ ? remixIcons[officialName]
36
+ : null;
37
+ if (official) {
38
+ return (
39
+ <Svg
40
+ width={size}
41
+ height={size}
42
+ viewBox={official.viewBox}
43
+ fill={color}
44
+ style={style}
45
+ {...svgProps}
46
+ >
47
+ {official.paths.map((d, index) => (
48
+ <Path key={index} d={d} />
49
+ ))}
50
+ </Svg>
51
+ );
52
+ }
53
+
13
54
  try {
14
55
  return <IconRemix {...{ style, size, color, name }} />;
15
56
  } catch (error) {
@@ -0,0 +1,3 @@
1
+ [
2
+ "send-ins-line"
3
+ ]
@@ -0,0 +1,22 @@
1
+ // ARQUIVO GERADO AUTOMATICAMENTE — não edite manualmente.
2
+ // Fonte: remixicon@4.9.1. Gerador: scripts/generate-remix-icons.js
3
+ // Para adicionar ícones, edite components/Icon/remix/manifest.json e rode `pnpm icons:generate`.
4
+
5
+ /**
6
+ * @typedef {Object} RemixIconData
7
+ * @property {string} viewBox - viewBox original do SVG oficial.
8
+ * @property {string[]} paths - Atributos `d` dos elementos `<path>` originais.
9
+ */
10
+
11
+ /** @type {Record<string, RemixIconData>} */
12
+ const remixIcons = {
13
+ // remixicon/icons/Business/send-ins-line.svg
14
+ 'send-ins-line': {
15
+ viewBox: '0 0 24 24',
16
+ paths: [
17
+ 'M19.4999 2C20.0945 1.99965 20.6988 2.15061 21.2499 2.46875C22.924 3.43525 23.4977 5.57598 22.5312 7.25L15.0312 20.2402C14.0647 21.9142 11.924 22.488 10.2499 21.5215C9.41368 21.0386 8.85171 20.2606 8.62005 19.3975L6.85345 12.8037L2.02533 7.97461C0.65837 6.60765 0.658729 4.39208 2.02533 3.02539C2.65755 2.39311 3.53385 2.00011 4.49994 2H19.4999ZM4.49994 4C4.08555 4.00011 3.71182 4.167 3.43939 4.43945C2.85354 5.0254 2.85378 5.97494 3.43939 6.56055L7.914 11.0352L14.8906 7.00684C15.3688 6.7308 15.9806 6.89487 16.2568 7.37305C16.5327 7.85124 16.3687 8.46312 15.8906 8.73926L8.914 12.7676L10.5517 18.8789C10.6515 19.2509 10.8913 19.5819 11.2499 19.7891C11.9673 20.2032 12.8845 19.9575 13.2988 19.2402L20.7988 6.25C21.213 5.53256 20.9674 4.61539 20.2499 4.20117C20.0128 4.06427 19.7555 3.99982 19.5009 4H4.49994Z',
18
+ ],
19
+ },
20
+ };
21
+
22
+ export default remixIcons;
@@ -1,10 +1,27 @@
1
1
  export default Icon;
2
- declare function Icon({ name, size, color, style, custom, }: {
3
- name: any;
2
+ /**
3
+ * Ícone do Design System.
4
+ *
5
+ * Resolução do `name`:
6
+ * 1. Ícones oficiais do pacote `remixicon` listados em `remix/manifest.json`
7
+ * (ex.: `send-ins-line`), renderizados a partir do SVG oficial.
8
+ * 2. Demais nomes: biblioteca `react-native-remix-icon` (catálogo legado).
9
+ *
10
+ * @param {Object} props
11
+ * @param {string} props.name - Nome do ícone Remix (ex.: `'send-ins-line'`). O prefixo `ri-` é aceito.
12
+ * @param {number} [props.size=24] - Largura e altura em pixels.
13
+ * @param {string} [props.color='#4F7CFE'] - Cor de preenchimento do ícone.
14
+ * @param {Object} [props.style] - Estilo aplicado ao SVG.
15
+ * @param {string|null} [props.custom] - Ícone customizado do projeto (`'boletoDasMei'`, `'libras'`).
16
+ * Demais props compatíveis com `SvgProps` (ex.: `opacity`, `testID`, `accessibilityLabel`) são repassadas
17
+ * ao SVG apenas para ícones oficiais; o catálogo legado mantém o comportamento anterior.
18
+ */
19
+ declare function Icon({ name, size, color, style, custom, ...svgProps }: {
20
+ name: string;
4
21
  size?: number | undefined;
5
22
  color?: string | undefined;
6
- style?: {} | undefined;
7
- custom?: null | undefined;
23
+ style?: Object | undefined;
24
+ custom?: string | null | undefined;
8
25
  }): React.JSX.Element | null | undefined;
9
26
  import React from 'react';
10
27
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/Icon/index.jsx"],"names":[],"mappings":";AAIA;;;;;;yCAkCC;kBAtCiB,OAAO"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/Icon/index.jsx"],"names":[],"mappings":";AAMA;;;;;;;;;;;;;;;;GAgBG;AACH,yEARG;IAAsB,IAAI,EAAlB,MAAM;IACS,IAAI;IACJ,KAAK;IACL,KAAK;IACA,MAAM;CAGpC,wCAyDA;kBA/EiB,OAAO"}
@@ -1,8 +1,36 @@
1
1
  import React from 'react';
2
+ import Svg, { Path } from 'react-native-svg';
2
3
  import IconRemix from 'react-native-remix-icon';
3
4
  import { iconEnums } from './iconEnums';
4
- const Icon = ({ name, size = 24, color = '#4F7CFE', style = {}, custom = null, }) => {
5
+ import remixIcons from './remix/remixIcons.generated';
6
+ /**
7
+ * Ícone do Design System.
8
+ *
9
+ * Resolução do `name`:
10
+ * 1. Ícones oficiais do pacote `remixicon` listados em `remix/manifest.json`
11
+ * (ex.: `send-ins-line`), renderizados a partir do SVG oficial.
12
+ * 2. Demais nomes: biblioteca `react-native-remix-icon` (catálogo legado).
13
+ *
14
+ * @param {Object} props
15
+ * @param {string} props.name - Nome do ícone Remix (ex.: `'send-ins-line'`). O prefixo `ri-` é aceito.
16
+ * @param {number} [props.size=24] - Largura e altura em pixels.
17
+ * @param {string} [props.color='#4F7CFE'] - Cor de preenchimento do ícone.
18
+ * @param {Object} [props.style] - Estilo aplicado ao SVG.
19
+ * @param {string|null} [props.custom] - Ícone customizado do projeto (`'boletoDasMei'`, `'libras'`).
20
+ * Demais props compatíveis com `SvgProps` (ex.: `opacity`, `testID`, `accessibilityLabel`) são repassadas
21
+ * ao SVG apenas para ícones oficiais; o catálogo legado mantém o comportamento anterior.
22
+ */
23
+ const Icon = ({ name, size = 24, color = '#4F7CFE', style = {}, custom = null, ...svgProps }) => {
5
24
  if (!custom) {
25
+ const officialName = typeof name === 'string' && name.startsWith('ri-') ? name.substring(3) : name;
26
+ const official = Object.prototype.hasOwnProperty.call(remixIcons, officialName)
27
+ ? remixIcons[officialName]
28
+ : null;
29
+ if (official) {
30
+ return (<Svg width={size} height={size} viewBox={official.viewBox} fill={color} style={style} {...svgProps}>
31
+ {official.paths.map((d, index) => (<Path key={index} d={d}/>))}
32
+ </Svg>);
33
+ }
6
34
  try {
7
35
  return <IconRemix {...{ style, size, color, name }}/>;
8
36
  }
@@ -0,0 +1,19 @@
1
+ export default remixIcons;
2
+ export type RemixIconData = {
3
+ /**
4
+ * - viewBox original do SVG oficial.
5
+ */
6
+ viewBox: string;
7
+ /**
8
+ * - Atributos `d` dos elementos `<path>` originais.
9
+ */
10
+ paths: string[];
11
+ };
12
+ /**
13
+ * @typedef {Object} RemixIconData
14
+ * @property {string} viewBox - viewBox original do SVG oficial.
15
+ * @property {string[]} paths - Atributos `d` dos elementos `<path>` originais.
16
+ */
17
+ /** @type {Record<string, RemixIconData>} */
18
+ declare const remixIcons: Record<string, RemixIconData>;
19
+ //# sourceMappingURL=remixIcons.generated.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remixIcons.generated.d.ts","sourceRoot":"","sources":["../../../../components/Icon/remix/remixIcons.generated.js"],"names":[],"mappings":";;;;;aAMc,MAAM;;;;WACN,MAAM,EAAE;;AAHtB;;;;GAIG;AAEH,4CAA4C;AAC5C,0BADW,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAStC"}
@@ -0,0 +1,19 @@
1
+ // ARQUIVO GERADO AUTOMATICAMENTE — não edite manualmente.
2
+ // Fonte: remixicon@4.9.1. Gerador: scripts/generate-remix-icons.js
3
+ // Para adicionar ícones, edite components/Icon/remix/manifest.json e rode `pnpm icons:generate`.
4
+ /**
5
+ * @typedef {Object} RemixIconData
6
+ * @property {string} viewBox - viewBox original do SVG oficial.
7
+ * @property {string[]} paths - Atributos `d` dos elementos `<path>` originais.
8
+ */
9
+ /** @type {Record<string, RemixIconData>} */
10
+ const remixIcons = {
11
+ // remixicon/icons/Business/send-ins-line.svg
12
+ 'send-ins-line': {
13
+ viewBox: '0 0 24 24',
14
+ paths: [
15
+ 'M19.4999 2C20.0945 1.99965 20.6988 2.15061 21.2499 2.46875C22.924 3.43525 23.4977 5.57598 22.5312 7.25L15.0312 20.2402C14.0647 21.9142 11.924 22.488 10.2499 21.5215C9.41368 21.0386 8.85171 20.2606 8.62005 19.3975L6.85345 12.8037L2.02533 7.97461C0.65837 6.60765 0.658729 4.39208 2.02533 3.02539C2.65755 2.39311 3.53385 2.00011 4.49994 2H19.4999ZM4.49994 4C4.08555 4.00011 3.71182 4.167 3.43939 4.43945C2.85354 5.0254 2.85378 5.97494 3.43939 6.56055L7.914 11.0352L14.8906 7.00684C15.3688 6.7308 15.9806 6.89487 16.2568 7.37305C16.5327 7.85124 16.3687 8.46312 15.8906 8.73926L8.914 12.7676L10.5517 18.8789C10.6515 19.2509 10.8913 19.5819 11.2499 19.7891C11.9673 20.2032 12.8845 19.9575 13.2988 19.2402L20.7988 6.25C21.213 5.53256 20.9674 4.61539 20.2499 4.20117C20.0128 4.06427 19.7555 3.99982 19.5009 4H4.49994Z',
16
+ ],
17
+ },
18
+ };
19
+ export default remixIcons;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vpt-sebraeds",
3
- "version": "0.0.107",
3
+ "version": "0.0.108",
4
4
  "description": "Biblioteca de componentes React Native do Sebrae",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -38,7 +38,9 @@
38
38
  "storybook:android": "cross-env STORYBOOK_ENABLED='true' react-native run-android",
39
39
  "storybook-generate": "sb-rn-get-stories --config-path .rnstorybook",
40
40
  "storybook:web": "storybook dev -p 6006",
41
- "build-android": "scripts/build-android.sh"
41
+ "build-android": "scripts/build-android.sh",
42
+ "icons:generate": "node scripts/generate-remix-icons.js",
43
+ "icons:check": "node scripts/generate-remix-icons.js --check"
42
44
  },
43
45
  "peerDependencies": {
44
46
  "react": ">=18.0.0",
@@ -99,6 +101,7 @@
99
101
  "react-native-svg": "^15.12.1",
100
102
  "react-native-web": "^0.20.0",
101
103
  "react-test-renderer": "19.0.0",
104
+ "remixicon": "4.9.1",
102
105
  "storybook": "^8.6.12",
103
106
  "typescript": "^5.8.3",
104
107
  "vite": "^6.3.4"