vobi_document 1.0.2 → 1.1.1
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/README.md +23 -6
- package/dist/blocks.cjs +108 -0
- package/dist/blocks.cjs.map +1 -0
- package/dist/blocks.d.cts +214 -0
- package/dist/blocks.d.ts +214 -0
- package/dist/blocks.js +7 -0
- package/dist/blocks.js.map +1 -0
- package/dist/catalogContext-DenbX-OW.d.cts +15 -0
- package/dist/catalogContext-HGMU-w_4.d.ts +15 -0
- package/dist/chunk-26DSIOEY.cjs +68 -0
- package/dist/chunk-26DSIOEY.cjs.map +1 -0
- package/dist/chunk-3FTKM37U.cjs +1354 -0
- package/dist/chunk-3FTKM37U.cjs.map +1 -0
- package/dist/chunk-CZB7F2LA.js +90 -0
- package/dist/chunk-CZB7F2LA.js.map +1 -0
- package/dist/chunk-ERKU5FDV.cjs +407 -0
- package/dist/chunk-ERKU5FDV.cjs.map +1 -0
- package/dist/chunk-FKX46GKE.cjs +36 -0
- package/dist/chunk-FKX46GKE.cjs.map +1 -0
- package/dist/chunk-GR76U6FP.cjs +194 -0
- package/dist/chunk-GR76U6FP.cjs.map +1 -0
- package/dist/chunk-I22MGPXO.cjs +117 -0
- package/dist/chunk-I22MGPXO.cjs.map +1 -0
- package/dist/chunk-JYSA6IM5.js +1327 -0
- package/dist/chunk-JYSA6IM5.js.map +1 -0
- package/dist/chunk-L5FXGEKX.cjs +114 -0
- package/dist/chunk-L5FXGEKX.cjs.map +1 -0
- package/dist/chunk-LNBAFOVK.cjs +14 -0
- package/dist/chunk-LNBAFOVK.cjs.map +1 -0
- package/dist/chunk-M6FQVH76.js +824 -0
- package/dist/chunk-M6FQVH76.js.map +1 -0
- package/dist/chunk-MUSSJOOA.js +109 -0
- package/dist/chunk-MUSSJOOA.js.map +1 -0
- package/dist/chunk-N3IDPT3B.js +182 -0
- package/dist/chunk-N3IDPT3B.js.map +1 -0
- package/dist/chunk-OJZJJEJX.js +904 -0
- package/dist/chunk-OJZJJEJX.js.map +1 -0
- package/dist/chunk-PLQNNXS2.js +382 -0
- package/dist/chunk-PLQNNXS2.js.map +1 -0
- package/dist/chunk-QJ5W5EED.cjs +94 -0
- package/dist/chunk-QJ5W5EED.cjs.map +1 -0
- package/dist/chunk-QYBWIJXZ.js +98 -0
- package/dist/chunk-QYBWIJXZ.js.map +1 -0
- package/dist/chunk-RO3Y2MSU.cjs +844 -0
- package/dist/chunk-RO3Y2MSU.cjs.map +1 -0
- package/dist/chunk-RZOR3HOA.cjs +933 -0
- package/dist/chunk-RZOR3HOA.cjs.map +1 -0
- package/dist/chunk-SOIYSSU3.js +108 -0
- package/dist/chunk-SOIYSSU3.js.map +1 -0
- package/dist/chunk-SP5LCPDG.cjs +119 -0
- package/dist/chunk-SP5LCPDG.cjs.map +1 -0
- package/dist/chunk-W52ULJCW.js +61 -0
- package/dist/chunk-W52ULJCW.js.map +1 -0
- package/dist/chunk-ZOJBDFKU.js +12 -0
- package/dist/chunk-ZOJBDFKU.js.map +1 -0
- package/dist/editor.cjs +60 -0
- package/dist/editor.cjs.map +1 -0
- package/dist/editor.d.cts +190 -0
- package/dist/editor.d.ts +190 -0
- package/dist/editor.js +7 -0
- package/dist/editor.js.map +1 -0
- package/dist/index.cjs +436 -3753
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +72 -7892
- package/dist/index.d.ts +72 -7892
- package/dist/index.js +22 -3662
- package/dist/index.js.map +1 -1
- package/dist/messages-Bi0JxNIH.d.cts +23 -0
- package/dist/messages-Bi0JxNIH.d.ts +23 -0
- package/dist/print.cjs +354 -0
- package/dist/print.cjs.map +1 -0
- package/dist/print.d.cts +43 -0
- package/dist/print.d.ts +43 -0
- package/dist/print.js +336 -0
- package/dist/print.js.map +1 -0
- package/dist/puck.cjs +8 -8
- package/dist/puck.cjs.map +1 -1
- package/dist/render.cjs +72 -0
- package/dist/render.cjs.map +1 -0
- package/dist/render.d.cts +93 -0
- package/dist/render.d.ts +93 -0
- package/dist/render.js +7 -0
- package/dist/render.js.map +1 -0
- package/dist/theme-BuEFpQeZ.d.cts +112 -0
- package/dist/theme-BuEFpQeZ.d.ts +112 -0
- package/dist/types-BgIugNWW.d.cts +25 -0
- package/dist/types-BgIugNWW.d.ts +25 -0
- package/dist/types-CvKSS1Sy.d.cts +38 -0
- package/dist/types-CvKSS1Sy.d.ts +38 -0
- package/dist/variables.cjs +111 -0
- package/dist/variables.cjs.map +1 -0
- package/dist/variables.d.cts +106 -0
- package/dist/variables.d.ts +106 -0
- package/dist/variables.js +6 -0
- package/dist/variables.js.map +1 -0
- package/package.json +39 -8
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkGR76U6FP_cjs = require('./chunk-GR76U6FP.cjs');
|
|
4
|
+
var chunkI22MGPXO_cjs = require('./chunk-I22MGPXO.cjs');
|
|
5
|
+
var chunkQJ5W5EED_cjs = require('./chunk-QJ5W5EED.cjs');
|
|
6
|
+
var chunkSP5LCPDG_cjs = require('./chunk-SP5LCPDG.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
Object.defineProperty(exports, "VARIABLE_MENU_MAX_HEIGHT", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () { return chunkGR76U6FP_cjs.VARIABLE_MENU_MAX_HEIGHT; }
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(exports, "VARIABLE_MENU_WIDTH", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return chunkGR76U6FP_cjs.VARIABLE_MENU_WIDTH; }
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "VariableMenu", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () { return chunkGR76U6FP_cjs.VariableMenu; }
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(exports, "placeVariableMenu", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () { return chunkGR76U6FP_cjs.placeVariableMenu; }
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(exports, "variableCatalogSchema", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function () { return chunkGR76U6FP_cjs.variableCatalogSchema; }
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "variableDefSchema", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () { return chunkGR76U6FP_cjs.variableDefSchema; }
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(exports, "variableTypeSchema", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: function () { return chunkGR76U6FP_cjs.variableTypeSchema; }
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(exports, "CHIP_CLASS", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function () { return chunkI22MGPXO_cjs.CHIP_CLASS; }
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "EMPTY_CHIP_CLASS", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () { return chunkI22MGPXO_cjs.EMPTY_CHIP_CLASS; }
|
|
45
|
+
});
|
|
46
|
+
Object.defineProperty(exports, "INVALID_CHIP_CLASS", {
|
|
47
|
+
enumerable: true,
|
|
48
|
+
get: function () { return chunkI22MGPXO_cjs.INVALID_CHIP_CLASS; }
|
|
49
|
+
});
|
|
50
|
+
Object.defineProperty(exports, "NOT_INFORMED_LABEL", {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
get: function () { return chunkI22MGPXO_cjs.NOT_INFORMED_LABEL; }
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "buildVariableChipHtml", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () { return chunkI22MGPXO_cjs.buildVariableChipHtml; }
|
|
57
|
+
});
|
|
58
|
+
Object.defineProperty(exports, "collectVariableIssues", {
|
|
59
|
+
enumerable: true,
|
|
60
|
+
get: function () { return chunkI22MGPXO_cjs.collectVariableIssues; }
|
|
61
|
+
});
|
|
62
|
+
Object.defineProperty(exports, "resolveVariableHtml", {
|
|
63
|
+
enumerable: true,
|
|
64
|
+
get: function () { return chunkI22MGPXO_cjs.resolveVariableHtml; }
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports, "formatResolvedValues", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function () { return chunkQJ5W5EED_cjs.formatResolvedValues; }
|
|
69
|
+
});
|
|
70
|
+
Object.defineProperty(exports, "formatValue", {
|
|
71
|
+
enumerable: true,
|
|
72
|
+
get: function () { return chunkQJ5W5EED_cjs.formatValue; }
|
|
73
|
+
});
|
|
74
|
+
Object.defineProperty(exports, "resolveDocumentVariables", {
|
|
75
|
+
enumerable: true,
|
|
76
|
+
get: function () { return chunkQJ5W5EED_cjs.resolveDocumentVariables; }
|
|
77
|
+
});
|
|
78
|
+
Object.defineProperty(exports, "CatalogProvider", {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function () { return chunkSP5LCPDG_cjs.CatalogProvider; }
|
|
81
|
+
});
|
|
82
|
+
Object.defineProperty(exports, "ResolvedProvider", {
|
|
83
|
+
enumerable: true,
|
|
84
|
+
get: function () { return chunkSP5LCPDG_cjs.ResolvedProvider; }
|
|
85
|
+
});
|
|
86
|
+
Object.defineProperty(exports, "extractBindingKeys", {
|
|
87
|
+
enumerable: true,
|
|
88
|
+
get: function () { return chunkSP5LCPDG_cjs.extractBindingKeys; }
|
|
89
|
+
});
|
|
90
|
+
Object.defineProperty(exports, "findInvalidBindings", {
|
|
91
|
+
enumerable: true,
|
|
92
|
+
get: function () { return chunkSP5LCPDG_cjs.findInvalidBindings; }
|
|
93
|
+
});
|
|
94
|
+
Object.defineProperty(exports, "useCatalog", {
|
|
95
|
+
enumerable: true,
|
|
96
|
+
get: function () { return chunkSP5LCPDG_cjs.useCatalog; }
|
|
97
|
+
});
|
|
98
|
+
Object.defineProperty(exports, "useResolvedVariables", {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
get: function () { return chunkSP5LCPDG_cjs.useResolvedVariables; }
|
|
101
|
+
});
|
|
102
|
+
Object.defineProperty(exports, "useTranslator", {
|
|
103
|
+
enumerable: true,
|
|
104
|
+
get: function () { return chunkSP5LCPDG_cjs.useTranslator; }
|
|
105
|
+
});
|
|
106
|
+
Object.defineProperty(exports, "useUnresolvedDisplay", {
|
|
107
|
+
enumerable: true,
|
|
108
|
+
get: function () { return chunkSP5LCPDG_cjs.useUnresolvedDisplay; }
|
|
109
|
+
});
|
|
110
|
+
//# sourceMappingURL=variables.cjs.map
|
|
111
|
+
//# sourceMappingURL=variables.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"variables.cjs"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { a as VariableCatalog, V as VariableDef, d as VariableType, R as ResolvedVariables, c as VariableResolver, b as VariableContext, U as UnresolvedDisplay } from './types-BgIugNWW.cjs';
|
|
3
|
+
import * as react from 'react';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
export { C as CatalogProvider, T as Translator, u as useCatalog, a as useTranslator } from './catalogContext-DenbX-OW.cjs';
|
|
6
|
+
|
|
7
|
+
type Schema<T> = z.ZodType<T, z.ZodTypeDef, unknown>;
|
|
8
|
+
declare const variableTypeSchema: Schema<VariableType>;
|
|
9
|
+
declare const variableDefSchema: Schema<VariableDef>;
|
|
10
|
+
declare const variableCatalogSchema: Schema<VariableCatalog>;
|
|
11
|
+
|
|
12
|
+
/** Format a raw resolved value by its catalog type, pt-BR. preview == PDF. */
|
|
13
|
+
declare function formatValue(type: VariableType, raw: unknown): string;
|
|
14
|
+
|
|
15
|
+
/** Walk any document structure and collect every distinct variable key. */
|
|
16
|
+
declare function extractBindingKeys(node: unknown): string[];
|
|
17
|
+
/** Variable keys present in the document but absent from the catalog (orphans). */
|
|
18
|
+
declare function findInvalidBindings(node: unknown, catalog: VariableDef[]): string[];
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Formata valores crus por tipo do catálogo. Keys sem valor ficam FORA do mapa
|
|
22
|
+
* (`undefined` = "não resolvida" — ver docs/variables.md).
|
|
23
|
+
*/
|
|
24
|
+
declare function formatResolvedValues(defs: VariableDef[], raw: Record<string, unknown>): ResolvedVariables;
|
|
25
|
+
/** Resolve os bindings de `node` em strings pt-BR formatadas (preview == PDF). */
|
|
26
|
+
declare function resolveDocumentVariables(node: unknown, catalog: VariableDef[], resolver: VariableResolver, ctx: VariableContext): Promise<ResolvedVariables>;
|
|
27
|
+
|
|
28
|
+
type Props = {
|
|
29
|
+
accept?: VariableType[];
|
|
30
|
+
model?: string;
|
|
31
|
+
onPick: (def: VariableDef) => void;
|
|
32
|
+
/** Altura máxima do painel em px. O host reduz quando não há espaço na viewport. */
|
|
33
|
+
maxHeight?: number;
|
|
34
|
+
};
|
|
35
|
+
declare const VARIABLE_MENU_WIDTH = 260;
|
|
36
|
+
declare const VARIABLE_MENU_MAX_HEIGHT = 320;
|
|
37
|
+
declare function VariableMenu({ accept, model, onPick, maxHeight }: Props): react.JSX.Element;
|
|
38
|
+
|
|
39
|
+
/** Retângulo da âncora em coordenadas de viewport (o que `getBoundingClientRect` devolve). */
|
|
40
|
+
type MenuAnchor = {
|
|
41
|
+
top: number;
|
|
42
|
+
bottom: number;
|
|
43
|
+
left: number;
|
|
44
|
+
};
|
|
45
|
+
type MenuViewport = {
|
|
46
|
+
width: number;
|
|
47
|
+
height: number;
|
|
48
|
+
};
|
|
49
|
+
type MenuPlacement = {
|
|
50
|
+
top: number;
|
|
51
|
+
left: number;
|
|
52
|
+
maxHeight: number;
|
|
53
|
+
placement: 'top' | 'bottom';
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Posiciona o menu de variáveis (`position: fixed`) ancorado no cursor: abre para baixo quando cabe,
|
|
57
|
+
* inverte para cima quando não cabe, e encolhe `maxHeight` ao espaço disponível.
|
|
58
|
+
* Sem isso o menu aberto no fim da página fica cortado pela viewport — ver docs/variables.md.
|
|
59
|
+
*/
|
|
60
|
+
declare const placeVariableMenu: (anchor: MenuAnchor, viewport: MenuViewport, options?: {
|
|
61
|
+
width?: number;
|
|
62
|
+
maxHeight?: number;
|
|
63
|
+
minHeight?: number;
|
|
64
|
+
}) => MenuPlacement;
|
|
65
|
+
|
|
66
|
+
declare const NOT_INFORMED_LABEL = "N\u00E3o informado";
|
|
67
|
+
declare const CHIP_CLASS = "dg-var";
|
|
68
|
+
declare const INVALID_CHIP_CLASS = "dg-var--invalid";
|
|
69
|
+
declare const EMPTY_CHIP_CLASS = "dg-var--empty";
|
|
70
|
+
/** Markup canônico do chip de variável — editores de host inserem por aqui. */
|
|
71
|
+
declare const buildVariableChipHtml: (def: {
|
|
72
|
+
key: string;
|
|
73
|
+
label?: string;
|
|
74
|
+
fullLabel?: string;
|
|
75
|
+
}) => string;
|
|
76
|
+
type ResolveOptions = {
|
|
77
|
+
keepChip?: boolean;
|
|
78
|
+
catalog?: VariableDef[];
|
|
79
|
+
unresolved?: UnresolvedDisplay;
|
|
80
|
+
};
|
|
81
|
+
/** Classifica os chips do documento em `unknown` (fora do catálogo) e `unresolved` (sem valor). */
|
|
82
|
+
declare const collectVariableIssues: (data: unknown, catalog?: VariableDef[], resolved?: ResolvedVariables) => {
|
|
83
|
+
unknown: string[];
|
|
84
|
+
unresolved: string[];
|
|
85
|
+
hasIssues: boolean;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Resolve os chips de variável de um HTML: valor, "Não informado" ou inválido (⚠).
|
|
89
|
+
* `keepChip: false` (render/PDF) mantém um span marcador (data-var-key/data-var-type, sem class).
|
|
90
|
+
* `unresolved: 'label'` (contexto de template) preserva o chip (texto + class) e não marca chip fora do
|
|
91
|
+
* catálogo como inválido — o template não está ligado a um documento, então "key desconhecida" ali é ruído.
|
|
92
|
+
* Ver docs/variables.md.
|
|
93
|
+
*/
|
|
94
|
+
declare const resolveVariableHtml: (html: string, resolved?: ResolvedVariables, { keepChip, catalog, unresolved }?: ResolveOptions) => string;
|
|
95
|
+
|
|
96
|
+
type EnsureResolved = (keys: string[]) => Promise<void>;
|
|
97
|
+
declare function ResolvedProvider({ resolved, ensureResolved, unresolvedDisplay, children }: {
|
|
98
|
+
resolved?: ResolvedVariables;
|
|
99
|
+
ensureResolved?: EnsureResolved;
|
|
100
|
+
unresolvedDisplay?: UnresolvedDisplay;
|
|
101
|
+
children: ReactNode;
|
|
102
|
+
}): react.JSX.Element;
|
|
103
|
+
declare function useResolvedVariables(): ResolvedVariables;
|
|
104
|
+
declare function useUnresolvedDisplay(): UnresolvedDisplay;
|
|
105
|
+
|
|
106
|
+
export { CHIP_CLASS, EMPTY_CHIP_CLASS, INVALID_CHIP_CLASS, type MenuAnchor, type MenuPlacement, type MenuViewport, NOT_INFORMED_LABEL, ResolvedProvider, ResolvedVariables, UnresolvedDisplay, VARIABLE_MENU_MAX_HEIGHT, VARIABLE_MENU_WIDTH, VariableCatalog, VariableContext, VariableDef, VariableMenu, VariableResolver, VariableType, buildVariableChipHtml, collectVariableIssues, extractBindingKeys, findInvalidBindings, formatResolvedValues, formatValue, placeVariableMenu, resolveDocumentVariables, resolveVariableHtml, useResolvedVariables, useUnresolvedDisplay, variableCatalogSchema, variableDefSchema, variableTypeSchema };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { a as VariableCatalog, V as VariableDef, d as VariableType, R as ResolvedVariables, c as VariableResolver, b as VariableContext, U as UnresolvedDisplay } from './types-BgIugNWW.js';
|
|
3
|
+
import * as react from 'react';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
export { C as CatalogProvider, T as Translator, u as useCatalog, a as useTranslator } from './catalogContext-HGMU-w_4.js';
|
|
6
|
+
|
|
7
|
+
type Schema<T> = z.ZodType<T, z.ZodTypeDef, unknown>;
|
|
8
|
+
declare const variableTypeSchema: Schema<VariableType>;
|
|
9
|
+
declare const variableDefSchema: Schema<VariableDef>;
|
|
10
|
+
declare const variableCatalogSchema: Schema<VariableCatalog>;
|
|
11
|
+
|
|
12
|
+
/** Format a raw resolved value by its catalog type, pt-BR. preview == PDF. */
|
|
13
|
+
declare function formatValue(type: VariableType, raw: unknown): string;
|
|
14
|
+
|
|
15
|
+
/** Walk any document structure and collect every distinct variable key. */
|
|
16
|
+
declare function extractBindingKeys(node: unknown): string[];
|
|
17
|
+
/** Variable keys present in the document but absent from the catalog (orphans). */
|
|
18
|
+
declare function findInvalidBindings(node: unknown, catalog: VariableDef[]): string[];
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Formata valores crus por tipo do catálogo. Keys sem valor ficam FORA do mapa
|
|
22
|
+
* (`undefined` = "não resolvida" — ver docs/variables.md).
|
|
23
|
+
*/
|
|
24
|
+
declare function formatResolvedValues(defs: VariableDef[], raw: Record<string, unknown>): ResolvedVariables;
|
|
25
|
+
/** Resolve os bindings de `node` em strings pt-BR formatadas (preview == PDF). */
|
|
26
|
+
declare function resolveDocumentVariables(node: unknown, catalog: VariableDef[], resolver: VariableResolver, ctx: VariableContext): Promise<ResolvedVariables>;
|
|
27
|
+
|
|
28
|
+
type Props = {
|
|
29
|
+
accept?: VariableType[];
|
|
30
|
+
model?: string;
|
|
31
|
+
onPick: (def: VariableDef) => void;
|
|
32
|
+
/** Altura máxima do painel em px. O host reduz quando não há espaço na viewport. */
|
|
33
|
+
maxHeight?: number;
|
|
34
|
+
};
|
|
35
|
+
declare const VARIABLE_MENU_WIDTH = 260;
|
|
36
|
+
declare const VARIABLE_MENU_MAX_HEIGHT = 320;
|
|
37
|
+
declare function VariableMenu({ accept, model, onPick, maxHeight }: Props): react.JSX.Element;
|
|
38
|
+
|
|
39
|
+
/** Retângulo da âncora em coordenadas de viewport (o que `getBoundingClientRect` devolve). */
|
|
40
|
+
type MenuAnchor = {
|
|
41
|
+
top: number;
|
|
42
|
+
bottom: number;
|
|
43
|
+
left: number;
|
|
44
|
+
};
|
|
45
|
+
type MenuViewport = {
|
|
46
|
+
width: number;
|
|
47
|
+
height: number;
|
|
48
|
+
};
|
|
49
|
+
type MenuPlacement = {
|
|
50
|
+
top: number;
|
|
51
|
+
left: number;
|
|
52
|
+
maxHeight: number;
|
|
53
|
+
placement: 'top' | 'bottom';
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Posiciona o menu de variáveis (`position: fixed`) ancorado no cursor: abre para baixo quando cabe,
|
|
57
|
+
* inverte para cima quando não cabe, e encolhe `maxHeight` ao espaço disponível.
|
|
58
|
+
* Sem isso o menu aberto no fim da página fica cortado pela viewport — ver docs/variables.md.
|
|
59
|
+
*/
|
|
60
|
+
declare const placeVariableMenu: (anchor: MenuAnchor, viewport: MenuViewport, options?: {
|
|
61
|
+
width?: number;
|
|
62
|
+
maxHeight?: number;
|
|
63
|
+
minHeight?: number;
|
|
64
|
+
}) => MenuPlacement;
|
|
65
|
+
|
|
66
|
+
declare const NOT_INFORMED_LABEL = "N\u00E3o informado";
|
|
67
|
+
declare const CHIP_CLASS = "dg-var";
|
|
68
|
+
declare const INVALID_CHIP_CLASS = "dg-var--invalid";
|
|
69
|
+
declare const EMPTY_CHIP_CLASS = "dg-var--empty";
|
|
70
|
+
/** Markup canônico do chip de variável — editores de host inserem por aqui. */
|
|
71
|
+
declare const buildVariableChipHtml: (def: {
|
|
72
|
+
key: string;
|
|
73
|
+
label?: string;
|
|
74
|
+
fullLabel?: string;
|
|
75
|
+
}) => string;
|
|
76
|
+
type ResolveOptions = {
|
|
77
|
+
keepChip?: boolean;
|
|
78
|
+
catalog?: VariableDef[];
|
|
79
|
+
unresolved?: UnresolvedDisplay;
|
|
80
|
+
};
|
|
81
|
+
/** Classifica os chips do documento em `unknown` (fora do catálogo) e `unresolved` (sem valor). */
|
|
82
|
+
declare const collectVariableIssues: (data: unknown, catalog?: VariableDef[], resolved?: ResolvedVariables) => {
|
|
83
|
+
unknown: string[];
|
|
84
|
+
unresolved: string[];
|
|
85
|
+
hasIssues: boolean;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Resolve os chips de variável de um HTML: valor, "Não informado" ou inválido (⚠).
|
|
89
|
+
* `keepChip: false` (render/PDF) mantém um span marcador (data-var-key/data-var-type, sem class).
|
|
90
|
+
* `unresolved: 'label'` (contexto de template) preserva o chip (texto + class) e não marca chip fora do
|
|
91
|
+
* catálogo como inválido — o template não está ligado a um documento, então "key desconhecida" ali é ruído.
|
|
92
|
+
* Ver docs/variables.md.
|
|
93
|
+
*/
|
|
94
|
+
declare const resolveVariableHtml: (html: string, resolved?: ResolvedVariables, { keepChip, catalog, unresolved }?: ResolveOptions) => string;
|
|
95
|
+
|
|
96
|
+
type EnsureResolved = (keys: string[]) => Promise<void>;
|
|
97
|
+
declare function ResolvedProvider({ resolved, ensureResolved, unresolvedDisplay, children }: {
|
|
98
|
+
resolved?: ResolvedVariables;
|
|
99
|
+
ensureResolved?: EnsureResolved;
|
|
100
|
+
unresolvedDisplay?: UnresolvedDisplay;
|
|
101
|
+
children: ReactNode;
|
|
102
|
+
}): react.JSX.Element;
|
|
103
|
+
declare function useResolvedVariables(): ResolvedVariables;
|
|
104
|
+
declare function useUnresolvedDisplay(): UnresolvedDisplay;
|
|
105
|
+
|
|
106
|
+
export { CHIP_CLASS, EMPTY_CHIP_CLASS, INVALID_CHIP_CLASS, type MenuAnchor, type MenuPlacement, type MenuViewport, NOT_INFORMED_LABEL, ResolvedProvider, ResolvedVariables, UnresolvedDisplay, VARIABLE_MENU_MAX_HEIGHT, VARIABLE_MENU_WIDTH, VariableCatalog, VariableContext, VariableDef, VariableMenu, VariableResolver, VariableType, buildVariableChipHtml, collectVariableIssues, extractBindingKeys, findInvalidBindings, formatResolvedValues, formatValue, placeVariableMenu, resolveDocumentVariables, resolveVariableHtml, useResolvedVariables, useUnresolvedDisplay, variableCatalogSchema, variableDefSchema, variableTypeSchema };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { VARIABLE_MENU_MAX_HEIGHT, VARIABLE_MENU_WIDTH, VariableMenu, placeVariableMenu, variableCatalogSchema, variableDefSchema, variableTypeSchema } from './chunk-N3IDPT3B.js';
|
|
2
|
+
export { CHIP_CLASS, EMPTY_CHIP_CLASS, INVALID_CHIP_CLASS, NOT_INFORMED_LABEL, buildVariableChipHtml, collectVariableIssues, resolveVariableHtml } from './chunk-MUSSJOOA.js';
|
|
3
|
+
export { formatResolvedValues, formatValue, resolveDocumentVariables } from './chunk-CZB7F2LA.js';
|
|
4
|
+
export { CatalogProvider, ResolvedProvider, extractBindingKeys, findInvalidBindings, useCatalog, useResolvedVariables, useTranslator, useUnresolvedDisplay } from './chunk-SOIYSSU3.js';
|
|
5
|
+
//# sourceMappingURL=variables.js.map
|
|
6
|
+
//# sourceMappingURL=variables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"variables.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vobi_document",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/"
|
|
6
6
|
},
|
|
@@ -20,11 +20,37 @@
|
|
|
20
20
|
"import": "./dist/index.js",
|
|
21
21
|
"require": "./dist/index.cjs"
|
|
22
22
|
},
|
|
23
|
+
"./blocks": {
|
|
24
|
+
"types": "./dist/blocks.d.ts",
|
|
25
|
+
"import": "./dist/blocks.js",
|
|
26
|
+
"require": "./dist/blocks.cjs"
|
|
27
|
+
},
|
|
28
|
+
"./editor": {
|
|
29
|
+
"types": "./dist/editor.d.ts",
|
|
30
|
+
"import": "./dist/editor.js",
|
|
31
|
+
"require": "./dist/editor.cjs"
|
|
32
|
+
},
|
|
33
|
+
"./render": {
|
|
34
|
+
"types": "./dist/render.d.ts",
|
|
35
|
+
"import": "./dist/render.js",
|
|
36
|
+
"require": "./dist/render.cjs"
|
|
37
|
+
},
|
|
38
|
+
"./print": {
|
|
39
|
+
"types": "./dist/print.d.ts",
|
|
40
|
+
"import": "./dist/print.js",
|
|
41
|
+
"require": "./dist/print.cjs"
|
|
42
|
+
},
|
|
43
|
+
"./variables": {
|
|
44
|
+
"types": "./dist/variables.d.ts",
|
|
45
|
+
"import": "./dist/variables.js",
|
|
46
|
+
"require": "./dist/variables.cjs"
|
|
47
|
+
},
|
|
23
48
|
"./puck": {
|
|
24
49
|
"types": "./dist/puck.d.ts",
|
|
25
50
|
"import": "./dist/puck.js",
|
|
26
51
|
"require": "./dist/puck.cjs"
|
|
27
|
-
}
|
|
52
|
+
},
|
|
53
|
+
"./package.json": "./package.json"
|
|
28
54
|
},
|
|
29
55
|
"files": [
|
|
30
56
|
"dist"
|
|
@@ -34,19 +60,19 @@
|
|
|
34
60
|
"node": ">=20"
|
|
35
61
|
},
|
|
36
62
|
"dependencies": {
|
|
37
|
-
"react-colorful": "^5.7.0"
|
|
38
|
-
"zod": "^3.24.1"
|
|
63
|
+
"react-colorful": "^5.7.0"
|
|
39
64
|
},
|
|
40
65
|
"peerDependencies": {
|
|
41
|
-
"@puckeditor/core": "^0.
|
|
66
|
+
"@puckeditor/core": "^0.23.0",
|
|
42
67
|
"react": "^18.2.0",
|
|
43
68
|
"react-dom": "^18.2.0",
|
|
44
|
-
"styled-components": "^5.3.5"
|
|
69
|
+
"styled-components": "^5.3.5",
|
|
70
|
+
"zod": "^3.24.1"
|
|
45
71
|
},
|
|
46
72
|
"devDependencies": {
|
|
47
73
|
"@eslint/eslintrc": "^3.2.0",
|
|
48
74
|
"@eslint/js": "^9.18.0",
|
|
49
|
-
"@puckeditor/core": "^0.
|
|
75
|
+
"@puckeditor/core": "^0.23.0",
|
|
50
76
|
"@testing-library/jest-dom": "^6.6.3",
|
|
51
77
|
"@testing-library/react": "^16.1.0",
|
|
52
78
|
"@types/jest": "^29.5.14",
|
|
@@ -75,19 +101,24 @@
|
|
|
75
101
|
"ts-jest": "^29.2.5",
|
|
76
102
|
"tsup": "^8.3.5",
|
|
77
103
|
"typescript": "^5.7.3",
|
|
78
|
-
"
|
|
104
|
+
"vite": "^6.0.7",
|
|
105
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
106
|
+
"yalc": "^1.0.0-pre.53",
|
|
107
|
+
"zod": "^3.24.1"
|
|
79
108
|
},
|
|
80
109
|
"scripts": {
|
|
81
110
|
"embed:pagedjs": "node scripts/embed-pagedjs.mjs",
|
|
82
111
|
"prebuild": "pnpm embed:pagedjs",
|
|
83
112
|
"build": "tsup",
|
|
84
113
|
"dev": "tsup --watch",
|
|
114
|
+
"play": "vite",
|
|
85
115
|
"pretest": "pnpm embed:pagedjs",
|
|
86
116
|
"test": "jest",
|
|
87
117
|
"test:watch": "jest --watch",
|
|
88
118
|
"test:coverage": "jest --coverage",
|
|
89
119
|
"pretypecheck": "pnpm embed:pagedjs",
|
|
90
120
|
"typecheck": "tsc --noEmit",
|
|
121
|
+
"typecheck:play": "tsc --noEmit -p tsconfig.playground.json",
|
|
91
122
|
"lint": "eslint .",
|
|
92
123
|
"lint:fix": "eslint . --fix",
|
|
93
124
|
"format": "prettier --write .",
|