vobi_document 1.0.1 → 1.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.
Files changed (102) hide show
  1. package/README.md +23 -6
  2. package/dist/blocks.cjs +100 -0
  3. package/dist/blocks.cjs.map +1 -0
  4. package/dist/blocks.d.cts +201 -0
  5. package/dist/blocks.d.ts +201 -0
  6. package/dist/blocks.js +7 -0
  7. package/dist/blocks.js.map +1 -0
  8. package/dist/catalogContext-DenbX-OW.d.cts +15 -0
  9. package/dist/catalogContext-HGMU-w_4.d.ts +15 -0
  10. package/dist/chunk-2EBYURIX.js +90 -0
  11. package/dist/chunk-2EBYURIX.js.map +1 -0
  12. package/dist/chunk-6GRYRVU5.js +824 -0
  13. package/dist/chunk-6GRYRVU5.js.map +1 -0
  14. package/dist/chunk-ABIEQHS2.js +159 -0
  15. package/dist/chunk-ABIEQHS2.js.map +1 -0
  16. package/dist/chunk-AQ5FAAP6.cjs +168 -0
  17. package/dist/chunk-AQ5FAAP6.cjs.map +1 -0
  18. package/dist/chunk-ERKU5FDV.cjs +407 -0
  19. package/dist/chunk-ERKU5FDV.cjs.map +1 -0
  20. package/dist/chunk-FKX46GKE.cjs +36 -0
  21. package/dist/chunk-FKX46GKE.cjs.map +1 -0
  22. package/dist/chunk-GVBGVF6Y.js +3 -0
  23. package/dist/{chunk-SY4NYXKN.js.map → chunk-GVBGVF6Y.js.map} +1 -1
  24. package/dist/chunk-HMTCQOEV.js +1319 -0
  25. package/dist/chunk-HMTCQOEV.js.map +1 -0
  26. package/dist/chunk-IRFFN74K.cjs +89 -0
  27. package/dist/chunk-IRFFN74K.cjs.map +1 -0
  28. package/dist/chunk-IUDN2CGP.js +863 -0
  29. package/dist/chunk-IUDN2CGP.js.map +1 -0
  30. package/dist/chunk-JEVWEGSE.js +95 -0
  31. package/dist/chunk-JEVWEGSE.js.map +1 -0
  32. package/dist/chunk-KCZKC3OG.js +61 -0
  33. package/dist/chunk-KCZKC3OG.js.map +1 -0
  34. package/dist/chunk-KUB3TYG2.cjs +102 -0
  35. package/dist/chunk-KUB3TYG2.cjs.map +1 -0
  36. package/dist/chunk-L5FXGEKX.cjs +114 -0
  37. package/dist/chunk-L5FXGEKX.cjs.map +1 -0
  38. package/dist/chunk-LNBAFOVK.cjs +14 -0
  39. package/dist/chunk-LNBAFOVK.cjs.map +1 -0
  40. package/dist/chunk-M2TPAU2F.js +79 -0
  41. package/dist/chunk-M2TPAU2F.js.map +1 -0
  42. package/dist/chunk-MHTTFNK2.cjs +890 -0
  43. package/dist/chunk-MHTTFNK2.cjs.map +1 -0
  44. package/dist/chunk-NDHTMYPA.cjs +844 -0
  45. package/dist/chunk-NDHTMYPA.cjs.map +1 -0
  46. package/dist/chunk-PLQNNXS2.js +382 -0
  47. package/dist/chunk-PLQNNXS2.js.map +1 -0
  48. package/dist/chunk-QYBWIJXZ.js +98 -0
  49. package/dist/chunk-QYBWIJXZ.js.map +1 -0
  50. package/dist/chunk-U56KVTK5.cjs +68 -0
  51. package/dist/chunk-U56KVTK5.cjs.map +1 -0
  52. package/dist/chunk-X2BLERM5.cjs +1346 -0
  53. package/dist/chunk-X2BLERM5.cjs.map +1 -0
  54. package/dist/chunk-ZOJBDFKU.js +12 -0
  55. package/dist/chunk-ZOJBDFKU.js.map +1 -0
  56. package/dist/chunk-ZXWOZZXO.cjs +94 -0
  57. package/dist/chunk-ZXWOZZXO.cjs.map +1 -0
  58. package/dist/editor.cjs +60 -0
  59. package/dist/editor.cjs.map +1 -0
  60. package/dist/editor.d.cts +190 -0
  61. package/dist/editor.d.ts +190 -0
  62. package/dist/editor.js +7 -0
  63. package/dist/editor.js.map +1 -0
  64. package/dist/index.cjs +418 -3746
  65. package/dist/index.cjs.map +1 -1
  66. package/dist/index.d.cts +73 -7893
  67. package/dist/index.d.ts +73 -7893
  68. package/dist/index.js +23 -3658
  69. package/dist/index.js.map +1 -1
  70. package/dist/messages-Bi0JxNIH.d.cts +23 -0
  71. package/dist/messages-Bi0JxNIH.d.ts +23 -0
  72. package/dist/print.cjs +354 -0
  73. package/dist/print.cjs.map +1 -0
  74. package/dist/print.d.cts +43 -0
  75. package/dist/print.d.ts +43 -0
  76. package/dist/print.js +336 -0
  77. package/dist/print.js.map +1 -0
  78. package/dist/puck.cjs +11 -7
  79. package/dist/puck.cjs.map +1 -1
  80. package/dist/puck.d.cts +1 -1
  81. package/dist/puck.d.ts +1 -1
  82. package/dist/puck.js +1 -1
  83. package/dist/render.cjs +72 -0
  84. package/dist/render.cjs.map +1 -0
  85. package/dist/render.d.cts +93 -0
  86. package/dist/render.d.ts +93 -0
  87. package/dist/render.js +7 -0
  88. package/dist/render.js.map +1 -0
  89. package/dist/theme-BuEFpQeZ.d.cts +112 -0
  90. package/dist/theme-BuEFpQeZ.d.ts +112 -0
  91. package/dist/types-BgIugNWW.d.cts +25 -0
  92. package/dist/types-BgIugNWW.d.ts +25 -0
  93. package/dist/types-CvKSS1Sy.d.cts +38 -0
  94. package/dist/types-CvKSS1Sy.d.ts +38 -0
  95. package/dist/variables.cjs +95 -0
  96. package/dist/variables.cjs.map +1 -0
  97. package/dist/variables.d.cts +74 -0
  98. package/dist/variables.d.ts +74 -0
  99. package/dist/variables.js +6 -0
  100. package/dist/variables.js.map +1 -0
  101. package/package.json +39 -8
  102. package/dist/chunk-SY4NYXKN.js +0 -3
package/README.md CHANGED
@@ -17,11 +17,11 @@ Montar documentos num app de gestão normalmente vira três implementações que
17
17
  ## Principais recursos
18
18
 
19
19
  - **Editor visual** — drag-and-drop de blocos, painel de estrutura (outline), bloqueio de blocos por permissão, header customizável via render-prop.
20
- - **Blocos prontos** — texto, botão, divisor, quebra de página, imagem, grade de imagens, orçamento, tabela, ícone + texto, imagem + texto e duas colunas (`defaultBlocks`).
20
+ - **Blocos prontos** — 14 blocos genéricos em `defaultBlocks`: texto, título, lista, destaque, botão, divisor, espaço, imagem, grade de imagens, duas colunas, imagem + texto, ícone + texto, tabela e quebra de página. Todos com `propsSchema` e com as variáveis já resolvidas.
21
21
  - **Blocos customizados** — o host cria os seus com `defineBlock` e registra no mesmo registry; entradas posteriores sobrescrevem por `key`.
22
22
  - **Tema** — cores (brand/texto/fundo), fonte (allow-list Google Fonts), logo, formato e margens de página, tudo validado por Zod (`themeSchema`) e aplicado via CSS vars no `PageFrame`.
23
23
  - **Variáveis dinâmicas** — chips no texto (`<span class="dg-var" data-var-key="customer.name">`) resolvidos a partir de um catálogo + resolver fornecidos pelo host; valores formatados em pt-BR; suporte a variáveis não resolvidas com placeholder ou label.
24
- - **Paginação para impressão** — `buildDocumentHtml` gera HTML paginado com Paged.js embarcado: capa (`coverBlockKey`), header/footer com dados da empresa, repetição de cabeçalho de tabela entre páginas e blocos protegidos de corte (`noCutBlockKeys`).
24
+ - **Paginação para impressão** — `buildDocumentHtml` (em `vobi_document/print`) gera HTML paginado com Paged.js embarcado: capa (`coverBlockKey`), header/footer com dados da empresa, repetição de cabeçalho de tabela entre páginas e blocos protegidos de corte (`noCutBlockKeys`).
25
25
  - **Schemas Zod** — `parseDocument` / `safeParseDocument` validam o documento completo antes de persistir ou renderizar.
26
26
  - **Autosave** — `useDocumentAutosave` com debounce para persistência incremental no host.
27
27
 
@@ -31,13 +31,13 @@ Montar documentos num app de gestão normalmente vira três implementações que
31
31
  pnpm add vobi_document
32
32
  ```
33
33
 
34
- Peer dependencies (o host deve declarar as quatro — precisam ser instância única compartilhada com a lib):
34
+ Peer dependencies (o host deve declarar as cinco — precisam ser instância única compartilhada com a lib):
35
35
 
36
36
  ```bash
37
- pnpm add react react-dom styled-components @puckeditor/core
37
+ pnpm add react react-dom styled-components @puckeditor/core zod
38
38
  ```
39
39
 
40
- > Duas cópias de `@puckeditor/core` ou `styled-components` não geram erro de versão — falham silenciosamente (contexto errado no `usePuck`, estilos ausentes no HTML publicado). Detalhes em `docs/build-and-consume.md`.
40
+ > Duas cópias de `@puckeditor/core`, `styled-components` ou `zod` não geram erro de versão — falham silenciosamente (contexto errado no `usePuck`, estilos ausentes no HTML publicado, `instanceof ZodError` falso). Detalhes em `docs/build-and-consume.md`.
41
41
 
42
42
  ## Uso básico
43
43
 
@@ -71,12 +71,29 @@ const registry = [...defaultBlocks, meuBlocoCustomizado];
71
71
  />
72
72
  ```
73
73
 
74
- Primitivas do Puck ficam no subpath dedicado, fora do barrel principal:
74
+ ### Entry points
75
+
76
+ O barrel principal traz tudo que roda no browser. As camadas também têm subpath próprio, para import granular:
77
+
78
+ | Subpath | Contém |
79
+ |---------|--------|
80
+ | `vobi_document` | core + reexport de blocks/editor/render/variables |
81
+ | `vobi_document/blocks` | `defineBlock`, `defaultBlocks`, `ContentIcon` |
82
+ | `vobi_document/editor` | `DocumentEditor`, settings, color picker, autosave |
83
+ | `vobi_document/render` | `DocumentRenderer`, capa, header/footer |
84
+ | `vobi_document/print` | `buildDocumentHtml`, `buildPageCss` — **não sai do barrel** |
85
+ | `vobi_document/variables` | catálogo, resolver, chips |
86
+ | `vobi_document/puck` | primitivas cruas do Puck |
75
87
 
76
88
  ```ts
89
+ import { buildDocumentHtml } from 'vobi_document/print'; // servidor / preview
77
90
  import { Puck, Render, usePuck } from 'vobi_document/puck';
78
91
  ```
79
92
 
93
+ `./print` fica fora do barrel porque carrega o Paged.js embutido (~513kb) e `react-dom/server` — um
94
+ host que só monta editor ou viewer não deve arriscar carregá-los. Isso derrubou o barrel de 631kb para
95
+ 131kb e o `index.d.ts` de 387kb para 9,3kb. Migração de 1.0.x em `docs/build-and-consume.md`.
96
+
80
97
  ## Desenvolvimento
81
98
 
82
99
  Requer Node >= 20 e **pnpm** (nunca npm/yarn).
@@ -0,0 +1,100 @@
1
+ 'use strict';
2
+
3
+ var chunkMHTTFNK2_cjs = require('./chunk-MHTTFNK2.cjs');
4
+ require('./chunk-L5FXGEKX.cjs');
5
+ require('./chunk-LNBAFOVK.cjs');
6
+ require('./chunk-KUB3TYG2.cjs');
7
+ require('./chunk-IRFFN74K.cjs');
8
+
9
+
10
+
11
+ Object.defineProperty(exports, "ButtonBlock", {
12
+ enumerable: true,
13
+ get: function () { return chunkMHTTFNK2_cjs.ButtonBlock; }
14
+ });
15
+ Object.defineProperty(exports, "CONTENT_ICON_CATALOG", {
16
+ enumerable: true,
17
+ get: function () { return chunkMHTTFNK2_cjs.CONTENT_ICON_CATALOG; }
18
+ });
19
+ Object.defineProperty(exports, "CONTENT_ICON_NAMES", {
20
+ enumerable: true,
21
+ get: function () { return chunkMHTTFNK2_cjs.CONTENT_ICON_NAMES; }
22
+ });
23
+ Object.defineProperty(exports, "ContentIcon", {
24
+ enumerable: true,
25
+ get: function () { return chunkMHTTFNK2_cjs.ContentIcon; }
26
+ });
27
+ Object.defineProperty(exports, "DividerBlock", {
28
+ enumerable: true,
29
+ get: function () { return chunkMHTTFNK2_cjs.DividerBlock; }
30
+ });
31
+ Object.defineProperty(exports, "HeadingBlock", {
32
+ enumerable: true,
33
+ get: function () { return chunkMHTTFNK2_cjs.HeadingBlock; }
34
+ });
35
+ Object.defineProperty(exports, "IconTextBlock", {
36
+ enumerable: true,
37
+ get: function () { return chunkMHTTFNK2_cjs.IconTextBlock; }
38
+ });
39
+ Object.defineProperty(exports, "ImageBlock", {
40
+ enumerable: true,
41
+ get: function () { return chunkMHTTFNK2_cjs.ImageBlock; }
42
+ });
43
+ Object.defineProperty(exports, "ImageGridBlock", {
44
+ enumerable: true,
45
+ get: function () { return chunkMHTTFNK2_cjs.ImageGridBlock; }
46
+ });
47
+ Object.defineProperty(exports, "ImageTextBlock", {
48
+ enumerable: true,
49
+ get: function () { return chunkMHTTFNK2_cjs.ImageTextBlock; }
50
+ });
51
+ Object.defineProperty(exports, "ListBlock", {
52
+ enumerable: true,
53
+ get: function () { return chunkMHTTFNK2_cjs.ListBlock; }
54
+ });
55
+ Object.defineProperty(exports, "PageBreakBlock", {
56
+ enumerable: true,
57
+ get: function () { return chunkMHTTFNK2_cjs.PageBreakBlock; }
58
+ });
59
+ Object.defineProperty(exports, "QuoteBlock", {
60
+ enumerable: true,
61
+ get: function () { return chunkMHTTFNK2_cjs.QuoteBlock; }
62
+ });
63
+ Object.defineProperty(exports, "RichText", {
64
+ enumerable: true,
65
+ get: function () { return chunkMHTTFNK2_cjs.RichText; }
66
+ });
67
+ Object.defineProperty(exports, "SpacerBlock", {
68
+ enumerable: true,
69
+ get: function () { return chunkMHTTFNK2_cjs.SpacerBlock; }
70
+ });
71
+ Object.defineProperty(exports, "TableBlock", {
72
+ enumerable: true,
73
+ get: function () { return chunkMHTTFNK2_cjs.TableBlock; }
74
+ });
75
+ Object.defineProperty(exports, "TextBlock", {
76
+ enumerable: true,
77
+ get: function () { return chunkMHTTFNK2_cjs.TextBlock; }
78
+ });
79
+ Object.defineProperty(exports, "TwoColumnsBlock", {
80
+ enumerable: true,
81
+ get: function () { return chunkMHTTFNK2_cjs.TwoColumnsBlock; }
82
+ });
83
+ Object.defineProperty(exports, "blocksByKey", {
84
+ enumerable: true,
85
+ get: function () { return chunkMHTTFNK2_cjs.blocksByKey; }
86
+ });
87
+ Object.defineProperty(exports, "defaultBlocks", {
88
+ enumerable: true,
89
+ get: function () { return chunkMHTTFNK2_cjs.defaultBlocks; }
90
+ });
91
+ Object.defineProperty(exports, "defineBlock", {
92
+ enumerable: true,
93
+ get: function () { return chunkMHTTFNK2_cjs.defineBlock; }
94
+ });
95
+ Object.defineProperty(exports, "overrideBlock", {
96
+ enumerable: true,
97
+ get: function () { return chunkMHTTFNK2_cjs.overrideBlock; }
98
+ });
99
+ //# sourceMappingURL=blocks.cjs.map
100
+ //# sourceMappingURL=blocks.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"blocks.cjs"}
@@ -0,0 +1,201 @@
1
+ import { B as BlockEntry, R as Registry } from './types-CvKSS1Sy.cjs';
2
+ export { D as DocumentConfig } from './types-CvKSS1Sy.cjs';
3
+ import * as react from 'react';
4
+ import { ElementType, CSSProperties } from 'react';
5
+ import { Slot } from '@puckeditor/core';
6
+ import 'zod';
7
+
8
+ /** Helper tipado para declarar um bloco (`fields`/`defaultProps` alinhados às props). */
9
+ declare function defineBlock<Props extends Record<string, unknown>>(entry: BlockEntry<Props>): BlockEntry<Props>;
10
+
11
+ /**
12
+ * Deriva um bloco a partir de um default da lib: herda a entry inteira e aplica `patch`
13
+ * por cima.
14
+ *
15
+ * ```ts
16
+ * const MeuTexto = overrideBlock('Text', { component: MeuRichText });
17
+ * const Copia = overrideBlock('Text', { key: 'TextoLegal' }); // clona sob outra key
18
+ * ```
19
+ *
20
+ * `key` desconhecida avisa em dev e devolve a entry só com o `patch` — para bloco que é
21
+ * só do host, use `defineBlock`, que não promete herança nenhuma.
22
+ */
23
+ declare function overrideBlock<Props extends Record<string, unknown> = Record<string, unknown>>(key: string, patch?: Partial<BlockEntry<Props>>): BlockEntry<Props>;
24
+
25
+ type TextBlockProps = {
26
+ content: string;
27
+ puck?: {
28
+ isEditing?: boolean;
29
+ };
30
+ };
31
+ declare const TextBlock: BlockEntry<TextBlockProps>;
32
+
33
+ type HeadingBlockProps = {
34
+ text: string;
35
+ level: 1 | 2 | 3 | 4;
36
+ puck?: {
37
+ isEditing?: boolean;
38
+ };
39
+ };
40
+ declare const HeadingBlock: BlockEntry<HeadingBlockProps>;
41
+
42
+ type ListItem = {
43
+ text: string;
44
+ };
45
+ type ListBlockProps = {
46
+ items: ListItem[];
47
+ ordered: boolean;
48
+ puck?: {
49
+ isEditing?: boolean;
50
+ };
51
+ };
52
+ declare const ListBlock: BlockEntry<ListBlockProps>;
53
+
54
+ type QuoteBlockProps = {
55
+ content: string;
56
+ author?: string;
57
+ puck?: {
58
+ isEditing?: boolean;
59
+ };
60
+ };
61
+ declare const QuoteBlock: BlockEntry<QuoteBlockProps>;
62
+
63
+ type ButtonBlockProps = {
64
+ text: string;
65
+ href: string;
66
+ };
67
+ declare const ButtonBlock: BlockEntry<ButtonBlockProps>;
68
+
69
+ type DividerBlockProps = {
70
+ variant: 'solid' | 'dashed' | 'dotted';
71
+ spacing: 'none' | 'small' | 'medium' | 'large';
72
+ };
73
+ declare const DividerBlock: BlockEntry<DividerBlockProps>;
74
+
75
+ type SpacerBlockProps = {
76
+ height: number;
77
+ puck?: {
78
+ isEditing?: boolean;
79
+ };
80
+ };
81
+ declare const SpacerBlock: BlockEntry<SpacerBlockProps>;
82
+
83
+ type ImageBlockProps = {
84
+ src: string;
85
+ alt: string;
86
+ caption?: string;
87
+ size: 'small' | 'medium' | 'large';
88
+ opacity: number;
89
+ puck?: {
90
+ isEditing?: boolean;
91
+ };
92
+ };
93
+ declare const ImageBlock: BlockEntry<ImageBlockProps>;
94
+
95
+ type GridImage = {
96
+ src: string;
97
+ alt?: string;
98
+ };
99
+ type ImageGridBlockProps = {
100
+ images: GridImage[];
101
+ columns: number;
102
+ gap: 'none' | 'small' | 'medium' | 'large';
103
+ ratio: 'square' | 'landscape' | 'portrait' | 'auto';
104
+ puck?: {
105
+ isEditing?: boolean;
106
+ };
107
+ };
108
+ declare const ImageGridBlock: BlockEntry<ImageGridBlockProps>;
109
+
110
+ type TwoColumnsBlockProps = {
111
+ left: Slot;
112
+ right: Slot;
113
+ ratio: number;
114
+ gap: 'none' | 'small' | 'medium' | 'large';
115
+ align: 'start' | 'center';
116
+ };
117
+ declare const TwoColumnsBlock: BlockEntry<TwoColumnsBlockProps>;
118
+
119
+ type ImageTextBlockProps = {
120
+ image: Slot;
121
+ text: Slot;
122
+ ratio: number;
123
+ imageRight: boolean;
124
+ gap: 'none' | 'small' | 'medium' | 'large';
125
+ };
126
+ declare const ImageTextBlock: BlockEntry<ImageTextBlockProps>;
127
+
128
+ type IconTextBlockProps = {
129
+ icon: string;
130
+ content: string;
131
+ iconSize: number;
132
+ iconRight: boolean;
133
+ gap: 'none' | 'small' | 'medium' | 'large';
134
+ puck?: {
135
+ isEditing?: boolean;
136
+ };
137
+ };
138
+ declare const IconTextBlock: BlockEntry<IconTextBlockProps>;
139
+
140
+ type TableCell = {
141
+ value: string;
142
+ };
143
+ type TableRow = {
144
+ cells: TableCell[];
145
+ };
146
+ type TableBlockProps = {
147
+ rows: TableRow[];
148
+ headerRow: boolean;
149
+ puck?: {
150
+ isEditing?: boolean;
151
+ };
152
+ };
153
+ declare const TableBlock: BlockEntry<TableBlockProps>;
154
+
155
+ type PageBreakBlockProps = {
156
+ puck?: {
157
+ isEditing?: boolean;
158
+ };
159
+ };
160
+ declare const PageBreakBlock: BlockEntry<PageBreakBlockProps>;
161
+
162
+ declare const defaultBlocks: Registry;
163
+ declare const blocksByKey: Record<string, BlockEntry>;
164
+
165
+ type RichTextProps = {
166
+ html?: string;
167
+ editing?: boolean;
168
+ as?: ElementType;
169
+ className?: string;
170
+ };
171
+ declare function RichText({ html, editing, as, className }: RichTextProps): react.JSX.Element;
172
+
173
+ type ContentIconDef = {
174
+ label: string;
175
+ group: string;
176
+ viewBox: string;
177
+ inner: string;
178
+ variant?: 'fill' | 'stroke';
179
+ };
180
+ /**
181
+ * SVG inline com width/height explícitos: o HTML do documento (iframe, link público, PDF)
182
+ * não carrega CSS global nenhum, e sem dimensão o svg cai no default 300x150.
183
+ *
184
+ * As `key`s são contrato de dado — ficam gravadas em `appearance.icon` no documento.
185
+ * Renomear uma exige migração; trocar o desenho, não.
186
+ */
187
+ declare const CONTENT_ICON_CATALOG: Record<string, ContentIconDef>;
188
+ declare const CONTENT_ICON_NAMES: string[];
189
+ type ContentIconProps = {
190
+ name?: string;
191
+ /** Aceita número (px) ou qualquer unidade CSS. Default `1em` — acompanha o font-size do contexto. */
192
+ size?: number | string;
193
+ color?: string;
194
+ /** Espessura do traço, em unidades do viewBox (24). Ignorado por ícone preenchido. */
195
+ strokeWidth?: number;
196
+ style?: CSSProperties;
197
+ className?: string;
198
+ };
199
+ declare function ContentIcon({ name, size, color, strokeWidth, style, className }: ContentIconProps): react.JSX.Element | null;
200
+
201
+ export { BlockEntry, ButtonBlock, CONTENT_ICON_CATALOG, CONTENT_ICON_NAMES, ContentIcon, type ContentIconDef, type ContentIconProps, DividerBlock, HeadingBlock, IconTextBlock, ImageBlock, ImageGridBlock, ImageTextBlock, ListBlock, PageBreakBlock, QuoteBlock, Registry, RichText, type RichTextProps, SpacerBlock, TableBlock, TextBlock, TwoColumnsBlock, blocksByKey, defaultBlocks, defineBlock, overrideBlock };
@@ -0,0 +1,201 @@
1
+ import { B as BlockEntry, R as Registry } from './types-CvKSS1Sy.js';
2
+ export { D as DocumentConfig } from './types-CvKSS1Sy.js';
3
+ import * as react from 'react';
4
+ import { ElementType, CSSProperties } from 'react';
5
+ import { Slot } from '@puckeditor/core';
6
+ import 'zod';
7
+
8
+ /** Helper tipado para declarar um bloco (`fields`/`defaultProps` alinhados às props). */
9
+ declare function defineBlock<Props extends Record<string, unknown>>(entry: BlockEntry<Props>): BlockEntry<Props>;
10
+
11
+ /**
12
+ * Deriva um bloco a partir de um default da lib: herda a entry inteira e aplica `patch`
13
+ * por cima.
14
+ *
15
+ * ```ts
16
+ * const MeuTexto = overrideBlock('Text', { component: MeuRichText });
17
+ * const Copia = overrideBlock('Text', { key: 'TextoLegal' }); // clona sob outra key
18
+ * ```
19
+ *
20
+ * `key` desconhecida avisa em dev e devolve a entry só com o `patch` — para bloco que é
21
+ * só do host, use `defineBlock`, que não promete herança nenhuma.
22
+ */
23
+ declare function overrideBlock<Props extends Record<string, unknown> = Record<string, unknown>>(key: string, patch?: Partial<BlockEntry<Props>>): BlockEntry<Props>;
24
+
25
+ type TextBlockProps = {
26
+ content: string;
27
+ puck?: {
28
+ isEditing?: boolean;
29
+ };
30
+ };
31
+ declare const TextBlock: BlockEntry<TextBlockProps>;
32
+
33
+ type HeadingBlockProps = {
34
+ text: string;
35
+ level: 1 | 2 | 3 | 4;
36
+ puck?: {
37
+ isEditing?: boolean;
38
+ };
39
+ };
40
+ declare const HeadingBlock: BlockEntry<HeadingBlockProps>;
41
+
42
+ type ListItem = {
43
+ text: string;
44
+ };
45
+ type ListBlockProps = {
46
+ items: ListItem[];
47
+ ordered: boolean;
48
+ puck?: {
49
+ isEditing?: boolean;
50
+ };
51
+ };
52
+ declare const ListBlock: BlockEntry<ListBlockProps>;
53
+
54
+ type QuoteBlockProps = {
55
+ content: string;
56
+ author?: string;
57
+ puck?: {
58
+ isEditing?: boolean;
59
+ };
60
+ };
61
+ declare const QuoteBlock: BlockEntry<QuoteBlockProps>;
62
+
63
+ type ButtonBlockProps = {
64
+ text: string;
65
+ href: string;
66
+ };
67
+ declare const ButtonBlock: BlockEntry<ButtonBlockProps>;
68
+
69
+ type DividerBlockProps = {
70
+ variant: 'solid' | 'dashed' | 'dotted';
71
+ spacing: 'none' | 'small' | 'medium' | 'large';
72
+ };
73
+ declare const DividerBlock: BlockEntry<DividerBlockProps>;
74
+
75
+ type SpacerBlockProps = {
76
+ height: number;
77
+ puck?: {
78
+ isEditing?: boolean;
79
+ };
80
+ };
81
+ declare const SpacerBlock: BlockEntry<SpacerBlockProps>;
82
+
83
+ type ImageBlockProps = {
84
+ src: string;
85
+ alt: string;
86
+ caption?: string;
87
+ size: 'small' | 'medium' | 'large';
88
+ opacity: number;
89
+ puck?: {
90
+ isEditing?: boolean;
91
+ };
92
+ };
93
+ declare const ImageBlock: BlockEntry<ImageBlockProps>;
94
+
95
+ type GridImage = {
96
+ src: string;
97
+ alt?: string;
98
+ };
99
+ type ImageGridBlockProps = {
100
+ images: GridImage[];
101
+ columns: number;
102
+ gap: 'none' | 'small' | 'medium' | 'large';
103
+ ratio: 'square' | 'landscape' | 'portrait' | 'auto';
104
+ puck?: {
105
+ isEditing?: boolean;
106
+ };
107
+ };
108
+ declare const ImageGridBlock: BlockEntry<ImageGridBlockProps>;
109
+
110
+ type TwoColumnsBlockProps = {
111
+ left: Slot;
112
+ right: Slot;
113
+ ratio: number;
114
+ gap: 'none' | 'small' | 'medium' | 'large';
115
+ align: 'start' | 'center';
116
+ };
117
+ declare const TwoColumnsBlock: BlockEntry<TwoColumnsBlockProps>;
118
+
119
+ type ImageTextBlockProps = {
120
+ image: Slot;
121
+ text: Slot;
122
+ ratio: number;
123
+ imageRight: boolean;
124
+ gap: 'none' | 'small' | 'medium' | 'large';
125
+ };
126
+ declare const ImageTextBlock: BlockEntry<ImageTextBlockProps>;
127
+
128
+ type IconTextBlockProps = {
129
+ icon: string;
130
+ content: string;
131
+ iconSize: number;
132
+ iconRight: boolean;
133
+ gap: 'none' | 'small' | 'medium' | 'large';
134
+ puck?: {
135
+ isEditing?: boolean;
136
+ };
137
+ };
138
+ declare const IconTextBlock: BlockEntry<IconTextBlockProps>;
139
+
140
+ type TableCell = {
141
+ value: string;
142
+ };
143
+ type TableRow = {
144
+ cells: TableCell[];
145
+ };
146
+ type TableBlockProps = {
147
+ rows: TableRow[];
148
+ headerRow: boolean;
149
+ puck?: {
150
+ isEditing?: boolean;
151
+ };
152
+ };
153
+ declare const TableBlock: BlockEntry<TableBlockProps>;
154
+
155
+ type PageBreakBlockProps = {
156
+ puck?: {
157
+ isEditing?: boolean;
158
+ };
159
+ };
160
+ declare const PageBreakBlock: BlockEntry<PageBreakBlockProps>;
161
+
162
+ declare const defaultBlocks: Registry;
163
+ declare const blocksByKey: Record<string, BlockEntry>;
164
+
165
+ type RichTextProps = {
166
+ html?: string;
167
+ editing?: boolean;
168
+ as?: ElementType;
169
+ className?: string;
170
+ };
171
+ declare function RichText({ html, editing, as, className }: RichTextProps): react.JSX.Element;
172
+
173
+ type ContentIconDef = {
174
+ label: string;
175
+ group: string;
176
+ viewBox: string;
177
+ inner: string;
178
+ variant?: 'fill' | 'stroke';
179
+ };
180
+ /**
181
+ * SVG inline com width/height explícitos: o HTML do documento (iframe, link público, PDF)
182
+ * não carrega CSS global nenhum, e sem dimensão o svg cai no default 300x150.
183
+ *
184
+ * As `key`s são contrato de dado — ficam gravadas em `appearance.icon` no documento.
185
+ * Renomear uma exige migração; trocar o desenho, não.
186
+ */
187
+ declare const CONTENT_ICON_CATALOG: Record<string, ContentIconDef>;
188
+ declare const CONTENT_ICON_NAMES: string[];
189
+ type ContentIconProps = {
190
+ name?: string;
191
+ /** Aceita número (px) ou qualquer unidade CSS. Default `1em` — acompanha o font-size do contexto. */
192
+ size?: number | string;
193
+ color?: string;
194
+ /** Espessura do traço, em unidades do viewBox (24). Ignorado por ícone preenchido. */
195
+ strokeWidth?: number;
196
+ style?: CSSProperties;
197
+ className?: string;
198
+ };
199
+ declare function ContentIcon({ name, size, color, strokeWidth, style, className }: ContentIconProps): react.JSX.Element | null;
200
+
201
+ export { BlockEntry, ButtonBlock, CONTENT_ICON_CATALOG, CONTENT_ICON_NAMES, ContentIcon, type ContentIconDef, type ContentIconProps, DividerBlock, HeadingBlock, IconTextBlock, ImageBlock, ImageGridBlock, ImageTextBlock, ListBlock, PageBreakBlock, QuoteBlock, Registry, RichText, type RichTextProps, SpacerBlock, TableBlock, TextBlock, TwoColumnsBlock, blocksByKey, defaultBlocks, defineBlock, overrideBlock };
package/dist/blocks.js ADDED
@@ -0,0 +1,7 @@
1
+ export { ButtonBlock, CONTENT_ICON_CATALOG, CONTENT_ICON_NAMES, ContentIcon, DividerBlock, HeadingBlock, IconTextBlock, ImageBlock, ImageGridBlock, ImageTextBlock, ListBlock, PageBreakBlock, QuoteBlock, RichText, SpacerBlock, TableBlock, TextBlock, TwoColumnsBlock, blocksByKey, defaultBlocks, defineBlock, overrideBlock } from './chunk-IUDN2CGP.js';
2
+ import './chunk-QYBWIJXZ.js';
3
+ import './chunk-ZOJBDFKU.js';
4
+ import './chunk-JEVWEGSE.js';
5
+ import './chunk-M2TPAU2F.js';
6
+ //# sourceMappingURL=blocks.js.map
7
+ //# sourceMappingURL=blocks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"blocks.js"}
@@ -0,0 +1,15 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+ import { V as VariableDef } from './types-BgIugNWW.cjs';
4
+
5
+ /** Mapa model → label amigável pt-BR (ex: `{ customer: 'Cliente' }`). */
6
+ type Translator = Record<string, string>;
7
+ declare function CatalogProvider({ catalog, translator, children }: {
8
+ catalog?: VariableDef[];
9
+ translator?: Translator;
10
+ children: ReactNode;
11
+ }): react.JSX.Element;
12
+ declare function useCatalog(): VariableDef[];
13
+ declare function useTranslator(): Translator;
14
+
15
+ export { CatalogProvider as C, type Translator as T, useTranslator as a, useCatalog as u };
@@ -0,0 +1,15 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+ import { V as VariableDef } from './types-BgIugNWW.js';
4
+
5
+ /** Mapa model → label amigável pt-BR (ex: `{ customer: 'Cliente' }`). */
6
+ type Translator = Record<string, string>;
7
+ declare function CatalogProvider({ catalog, translator, children }: {
8
+ catalog?: VariableDef[];
9
+ translator?: Translator;
10
+ children: ReactNode;
11
+ }): react.JSX.Element;
12
+ declare function useCatalog(): VariableDef[];
13
+ declare function useTranslator(): Translator;
14
+
15
+ export { CatalogProvider as C, type Translator as T, useTranslator as a, useCatalog as u };