@json-to-office/core-docx 0.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.
- package/LICENSE +18 -0
- package/README.md +9 -0
- package/dist/cache/index.d.ts +7 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/key-generator.d.ts +34 -0
- package/dist/cache/key-generator.d.ts.map +1 -0
- package/dist/components/columns.d.ts +12 -0
- package/dist/components/columns.d.ts.map +1 -0
- package/dist/components/footer.d.ts +12 -0
- package/dist/components/footer.d.ts.map +1 -0
- package/dist/components/header.d.ts +12 -0
- package/dist/components/header.d.ts.map +1 -0
- package/dist/components/heading.d.ts +12 -0
- package/dist/components/heading.d.ts.map +1 -0
- package/dist/components/highcharts.d.ts +21 -0
- package/dist/components/highcharts.d.ts.map +1 -0
- package/dist/components/image.d.ts +12 -0
- package/dist/components/image.d.ts.map +1 -0
- package/dist/components/index.d.ts +19 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/list.d.ts +12 -0
- package/dist/components/list.d.ts.map +1 -0
- package/dist/components/paragraph.d.ts +12 -0
- package/dist/components/paragraph.d.ts.map +1 -0
- package/dist/components/section.d.ts +12 -0
- package/dist/components/section.d.ts.map +1 -0
- package/dist/components/statistic.d.ts +12 -0
- package/dist/components/statistic.d.ts.map +1 -0
- package/dist/components/table.d.ts +13 -0
- package/dist/components/table.d.ts.map +1 -0
- package/dist/components/text-box.d.ts +9 -0
- package/dist/components/text-box.d.ts.map +1 -0
- package/dist/components/text-space-after.d.ts +35 -0
- package/dist/components/text-space-after.d.ts.map +1 -0
- package/dist/components/toc/index.d.ts +30 -0
- package/dist/components/toc/index.d.ts.map +1 -0
- package/dist/core/cached-render.d.ts +46 -0
- package/dist/core/cached-render.d.ts.map +1 -0
- package/dist/core/content.d.ts +263 -0
- package/dist/core/content.d.ts.map +1 -0
- package/dist/core/generator.d.ts +93 -0
- package/dist/core/generator.d.ts.map +1 -0
- package/dist/core/index.d.ts +14 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/layout.d.ts +107 -0
- package/dist/core/layout.d.ts.map +1 -0
- package/dist/core/render.d.ts +26 -0
- package/dist/core/render.d.ts.map +1 -0
- package/dist/core/structure.d.ts +67 -0
- package/dist/core/structure.d.ts.map +1 -0
- package/dist/examples/test-spacing-debug.d.ts +2 -0
- package/dist/examples/test-spacing-debug.d.ts.map +1 -0
- package/dist/examples/test-spacing.d.ts +6 -0
- package/dist/examples/test-spacing.d.ts.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7726 -0
- package/dist/index.js.map +1 -0
- package/dist/json/filesystem.d.ts +81 -0
- package/dist/json/filesystem.d.ts.map +1 -0
- package/dist/json/index.d.ts +6 -0
- package/dist/json/index.d.ts.map +1 -0
- package/dist/json/normalizer.d.ts +30 -0
- package/dist/json/normalizer.d.ts.map +1 -0
- package/dist/json/parser.d.ts +9 -0
- package/dist/json/parser.d.ts.map +1 -0
- package/dist/plugin/createComponent.d.ts +113 -0
- package/dist/plugin/createComponent.d.ts.map +1 -0
- package/dist/plugin/createDocumentGenerator.d.ts +18 -0
- package/dist/plugin/createDocumentGenerator.d.ts.map +1 -0
- package/dist/plugin/example/columns-layout.component.d.ts +29 -0
- package/dist/plugin/example/columns-layout.component.d.ts.map +1 -0
- package/dist/plugin/example/index.d.ts +6 -0
- package/dist/plugin/example/index.d.ts.map +1 -0
- package/dist/plugin/example/index.js +7449 -0
- package/dist/plugin/example/index.js.map +1 -0
- package/dist/plugin/example/nested-section.component.d.ts +16 -0
- package/dist/plugin/example/nested-section.component.d.ts.map +1 -0
- package/dist/plugin/example/plugin-demo.json +103 -0
- package/dist/plugin/example/text-space-after.component.d.ts +22 -0
- package/dist/plugin/example/text-space-after.component.d.ts.map +1 -0
- package/dist/plugin/example/weather.component.d.ts +29 -0
- package/dist/plugin/example/weather.component.d.ts.map +1 -0
- package/dist/plugin/index.d.ts +35 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/schema.d.ts +30 -0
- package/dist/plugin/schema.d.ts.map +1 -0
- package/dist/plugin/types.d.ts +144 -0
- package/dist/plugin/types.d.ts.map +1 -0
- package/dist/plugin/validation.d.ts +45 -0
- package/dist/plugin/validation.d.ts.map +1 -0
- package/dist/plugin/version-resolver.d.ts +10 -0
- package/dist/plugin/version-resolver.d.ts.map +1 -0
- package/dist/styles/index.d.ts +13 -0
- package/dist/styles/index.d.ts.map +1 -0
- package/dist/styles/theme-resolver.d.ts +6 -0
- package/dist/styles/theme-resolver.d.ts.map +1 -0
- package/dist/styles/theme-validator.d.ts +7 -0
- package/dist/styles/theme-validator.d.ts.map +1 -0
- package/dist/styles/themeToDocxAdapter.d.ts +22 -0
- package/dist/styles/themeToDocxAdapter.d.ts.map +1 -0
- package/dist/styles/utils/borderUtils.d.ts +88 -0
- package/dist/styles/utils/borderUtils.d.ts.map +1 -0
- package/dist/styles/utils/cellUtils.d.ts +55 -0
- package/dist/styles/utils/cellUtils.d.ts.map +1 -0
- package/dist/styles/utils/colorUtils.d.ts +27 -0
- package/dist/styles/utils/colorUtils.d.ts.map +1 -0
- package/dist/styles/utils/componentDefaults.d.ts +97 -0
- package/dist/styles/utils/componentDefaults.d.ts.map +1 -0
- package/dist/styles/utils/layoutUtils.d.ts +87 -0
- package/dist/styles/utils/layoutUtils.d.ts.map +1 -0
- package/dist/styles/utils/styleHelpers.d.ts +90 -0
- package/dist/styles/utils/styleHelpers.d.ts.map +1 -0
- package/dist/templates/documents/index.d.ts +34 -0
- package/dist/templates/documents/index.d.ts.map +1 -0
- package/dist/templates/documents/proposal.docx.json +171 -0
- package/dist/templates/documents/quarterly-report.docx.json +117 -0
- package/dist/templates/documents/technical-guide.docx.json +178 -0
- package/dist/templates/themes/corporate.docx.theme.json +118 -0
- package/dist/templates/themes/index.d.ts +5765 -0
- package/dist/templates/themes/index.d.ts.map +1 -0
- package/dist/templates/themes/minimal.docx.theme.json +194 -0
- package/dist/templates/themes/modern.docx.theme.json +115 -0
- package/dist/themes/defaults.d.ts +1300 -0
- package/dist/themes/defaults.d.ts.map +1 -0
- package/dist/themes/json/index.d.ts +44 -0
- package/dist/themes/json/index.d.ts.map +1 -0
- package/dist/themes/json/loader.d.ts +26 -0
- package/dist/themes/json/loader.d.ts.map +1 -0
- package/dist/themes/json/parser.d.ts +25 -0
- package/dist/themes/json/parser.d.ts.map +1 -0
- package/dist/themes/json/validator.d.ts +35 -0
- package/dist/themes/json/validator.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/index.d.ts +158 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/plugin.d.ts +67 -0
- package/dist/types/plugin.d.ts.map +1 -0
- package/dist/utils/alignmentUtils.d.ts +10 -0
- package/dist/utils/alignmentUtils.d.ts.map +1 -0
- package/dist/utils/bookmarkRegistry.d.ts +49 -0
- package/dist/utils/bookmarkRegistry.d.ts.map +1 -0
- package/dist/utils/docxImagePositioning.d.ts +18 -0
- package/dist/utils/docxImagePositioning.d.ts.map +1 -0
- package/dist/utils/environment.d.ts +14 -0
- package/dist/utils/environment.d.ts.map +1 -0
- package/dist/utils/exampleRunner.d.ts +17 -0
- package/dist/utils/exampleRunner.d.ts.map +1 -0
- package/dist/utils/fixFloatingImageIds.d.ts +18 -0
- package/dist/utils/fixFloatingImageIds.d.ts.map +1 -0
- package/dist/utils/formatters.d.ts +2 -0
- package/dist/utils/formatters.d.ts.map +1 -0
- package/dist/utils/imageUtils.d.ts +84 -0
- package/dist/utils/imageUtils.d.ts.map +1 -0
- package/dist/utils/numberingConfig.d.ts +84 -0
- package/dist/utils/numberingConfig.d.ts.map +1 -0
- package/dist/utils/placeholderImage.d.ts +31 -0
- package/dist/utils/placeholderImage.d.ts.map +1 -0
- package/dist/utils/placeholderProcessor.d.ts +58 -0
- package/dist/utils/placeholderProcessor.d.ts.map +1 -0
- package/dist/utils/textParser.d.ts +35 -0
- package/dist/utils/textParser.d.ts.map +1 -0
- package/dist/utils/unicode.d.ts +6 -0
- package/dist/utils/unicode.d.ts.map +1 -0
- package/dist/utils/warningsDocument.d.ts +17 -0
- package/dist/utils/warningsDocument.d.ts.map +1 -0
- package/dist/utils/widthUtils.d.ts +27 -0
- package/dist/utils/widthUtils.d.ts.map +1 -0
- package/package.json +88 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ComponentDefinition } from '@json-to-office/shared-docx';
|
|
2
|
+
/**
|
|
3
|
+
* Nested sections component that generates nested sections for embedding in documents
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```json
|
|
7
|
+
* {
|
|
8
|
+
* "name": "nestedSections",
|
|
9
|
+
* "props": {}
|
|
10
|
+
* }
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare const nestedSectionsComponent: import("../createComponent").CustomComponent<ComponentDefinition, {
|
|
14
|
+
'1.0.0': import("../createComponent").ComponentVersion<ComponentDefinition, import("@sinclair/typebox").TObject<{}>>;
|
|
15
|
+
}, "nestedSections">;
|
|
16
|
+
//# sourceMappingURL=nested-section.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nested-section.component.d.ts","sourceRoot":"","sources":["../../../src/plugin/example/nested-section.component.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAYvE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,uBAAuB;;oBA0ElC,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../../../../../output/examples/plugin-demo-schema.json",
|
|
3
|
+
"name": "docx",
|
|
4
|
+
"props": {
|
|
5
|
+
"title": "Plugin Demo"
|
|
6
|
+
},
|
|
7
|
+
"children": [
|
|
8
|
+
{
|
|
9
|
+
"name": "nestedSections",
|
|
10
|
+
"props": {}
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"name": "section",
|
|
14
|
+
"props": {
|
|
15
|
+
"title": "Weather Information"
|
|
16
|
+
},
|
|
17
|
+
"children": [
|
|
18
|
+
{
|
|
19
|
+
"name": "paragraph",
|
|
20
|
+
"props": {
|
|
21
|
+
"content": "Here's the current weather for major cities:"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"name": "weather",
|
|
26
|
+
"props": {
|
|
27
|
+
"city": "London",
|
|
28
|
+
"units": "metric",
|
|
29
|
+
"showDetails": true
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "weather",
|
|
34
|
+
"props": {
|
|
35
|
+
"city": "New York",
|
|
36
|
+
"units": "imperial",
|
|
37
|
+
"showDetails": false
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"name": "section",
|
|
44
|
+
"props": {
|
|
45
|
+
"title": "Sales Data"
|
|
46
|
+
},
|
|
47
|
+
"children": [
|
|
48
|
+
{
|
|
49
|
+
"name": "paragraph",
|
|
50
|
+
"props": {
|
|
51
|
+
"content": "Recent sales performance:"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"name": "dataTable",
|
|
56
|
+
"props": {
|
|
57
|
+
"query": "SELECT * FROM sales ORDER BY date DESC",
|
|
58
|
+
"title": "Q1 Sales Report",
|
|
59
|
+
"showRowNumbers": true,
|
|
60
|
+
"maxRows": 10
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"name": "section",
|
|
67
|
+
"props": {
|
|
68
|
+
"title": "Quick Links"
|
|
69
|
+
},
|
|
70
|
+
"children": [
|
|
71
|
+
{
|
|
72
|
+
"name": "paragraph",
|
|
73
|
+
"props": {
|
|
74
|
+
"content": "Scan these QR codes to access our resources:"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"name": "section",
|
|
81
|
+
"props": {
|
|
82
|
+
"title": "More Data Examples"
|
|
83
|
+
},
|
|
84
|
+
"children": [
|
|
85
|
+
{
|
|
86
|
+
"name": "dataTable",
|
|
87
|
+
"props": {
|
|
88
|
+
"query": "SELECT * FROM users WHERE role = \"Admin\"",
|
|
89
|
+
"title": "System Administrators"
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"name": "dataTable",
|
|
94
|
+
"props": {
|
|
95
|
+
"query": "SELECT * FROM inventory WHERE stock < 50",
|
|
96
|
+
"title": "Low Stock Items",
|
|
97
|
+
"showRowNumbers": false
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
]
|
|
103
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ComponentDefinition } from '@json-to-office/shared-docx';
|
|
2
|
+
/**
|
|
3
|
+
* Text space after component that adds space after text
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```json
|
|
7
|
+
* {
|
|
8
|
+
* "name": "text-space-after",
|
|
9
|
+
* "props": {
|
|
10
|
+
* "text": "Hello, world!",
|
|
11
|
+
* "spaceAfter": 100
|
|
12
|
+
* }
|
|
13
|
+
* }
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare const textSpaceAfterComponent: import("../createComponent").CustomComponent<ComponentDefinition, {
|
|
17
|
+
'1.0.0': import("../createComponent").ComponentVersion<ComponentDefinition, import("@sinclair/typebox").TObject<{
|
|
18
|
+
text: import("@sinclair/typebox").TString;
|
|
19
|
+
spaceAfter: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
20
|
+
}>>;
|
|
21
|
+
}, "text-space-after">;
|
|
22
|
+
//# sourceMappingURL=text-space-after.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-space-after.component.d.ts","sourceRoot":"","sources":["../../../src/plugin/example/text-space-after.component.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAsBvE;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,uBAAuB;;;;;sBAwBlC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ComponentDefinition } from '@json-to-office/shared-docx';
|
|
2
|
+
/**
|
|
3
|
+
* Weather component that fetches and displays weather information
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```json
|
|
7
|
+
* {
|
|
8
|
+
* "name": "weather",
|
|
9
|
+
* "props": {
|
|
10
|
+
* "city": "London",
|
|
11
|
+
* "units": "metric",
|
|
12
|
+
* "showDetails": true
|
|
13
|
+
* }
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const weatherComponent: import("../createComponent").CustomComponent<ComponentDefinition, {
|
|
18
|
+
'1.0.0': import("../createComponent").ComponentVersion<ComponentDefinition, import("@sinclair/typebox").TObject<{
|
|
19
|
+
city: import("@sinclair/typebox").TString;
|
|
20
|
+
units: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"metric">, import("@sinclair/typebox").TLiteral<"imperial">]>>;
|
|
21
|
+
showDetails: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
22
|
+
}>>;
|
|
23
|
+
'2.0.0': import("../createComponent").ComponentVersion<ComponentDefinition, import("@sinclair/typebox").TObject<{
|
|
24
|
+
city: import("@sinclair/typebox").TString;
|
|
25
|
+
units: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"metric">, import("@sinclair/typebox").TLiteral<"imperial">]>>;
|
|
26
|
+
days: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
27
|
+
}>>;
|
|
28
|
+
}, "weather">;
|
|
29
|
+
//# sourceMappingURL=weather.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"weather.component.d.ts","sourceRoot":"","sources":["../../../src/plugin/example/weather.component.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAoIvE;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;aAgG3B,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin system for json-to-docx
|
|
3
|
+
*
|
|
4
|
+
* Provides a functional, type-safe way to create versioned custom components
|
|
5
|
+
* that can be composed into document generators using a builder pattern.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { createComponent, createVersion, createDocumentGenerator } from '@json-to-docx/core/plugin';
|
|
10
|
+
* import { Type } from '@sinclair/typebox';
|
|
11
|
+
*
|
|
12
|
+
* const weatherComponent = createComponent({
|
|
13
|
+
* name: 'weather',
|
|
14
|
+
* versions: {
|
|
15
|
+
* '1.0.0': createVersion({
|
|
16
|
+
* propsSchema: Type.Object({ city: Type.String() }),
|
|
17
|
+
* render: async ({ props }) => [{
|
|
18
|
+
* name: 'paragraph',
|
|
19
|
+
* props: { text: `Weather in ${props.city}` }
|
|
20
|
+
* }]
|
|
21
|
+
* })
|
|
22
|
+
* }
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* const generator = createDocumentGenerator({ theme: myTheme })
|
|
26
|
+
* .addComponent(weatherComponent);
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export { createComponent, createVersion, type CustomComponent, type ComponentVersion, type ComponentVersionMap, type RenderFunction, type RenderContext, } from './createComponent';
|
|
30
|
+
export { createDocumentGenerator, type DocumentGeneratorOptions, } from './createDocumentGenerator';
|
|
31
|
+
export { type DocumentGenerator, type DocumentGeneratorBuilder, type GenerationResult, type BufferGenerationResult, type FileGenerationResult, type ValidationResult, type ExtractCustomComponentType, type CustomComponentUnion, type ExtendedComponentDefinition, type ExtendedReportComponent, type InferCustomComponents, type InferBuilderComponents, type InferDocumentType, type InferComponentDefinition, } from './types';
|
|
32
|
+
export { validateComponentProps, validateDocument, cleanComponentProps, ComponentValidationError, DuplicateComponentError, type ValidationError, } from './validation';
|
|
33
|
+
export { generatePluginDocumentSchema, exportPluginSchema, generateComponentSchemas, mergeSchemas, createUnionSchema, } from './schema';
|
|
34
|
+
export { resolveComponentVersion } from './version-resolver';
|
|
35
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EACL,eAAe,EACf,aAAa,EACb,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,aAAa,GACnB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,uBAAuB,EACvB,KAAK,wBAAwB,GAC9B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,0BAA0B,EAC/B,KAAK,oBAAoB,EACzB,KAAK,2BAA2B,EAChC,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,GAC9B,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,mBAAmB,EACnB,wBAAwB,EACxB,uBAAuB,EACvB,KAAK,eAAe,GACrB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,4BAA4B,EAC5B,kBAAkB,EAClB,wBAAwB,EACxB,YAAY,EACZ,iBAAiB,GAClB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { TSchema } from '@sinclair/typebox';
|
|
2
|
+
import type { CustomComponent } from './createComponent';
|
|
3
|
+
/**
|
|
4
|
+
* Generate a JSON schema for plugin-enhanced documents at RUNTIME.
|
|
5
|
+
*
|
|
6
|
+
* Iterates each component's versions map to produce per-version
|
|
7
|
+
* CustomComponentInfo entries for the unified schema generator.
|
|
8
|
+
*/
|
|
9
|
+
export declare function generatePluginDocumentSchema(customComponents: CustomComponent<any, any, any>[], includeStandardComponents?: boolean): TSchema;
|
|
10
|
+
/**
|
|
11
|
+
* Create a union type from an array of schemas
|
|
12
|
+
*/
|
|
13
|
+
export declare function createUnionSchema(schemas: TSchema[]): TSchema;
|
|
14
|
+
/**
|
|
15
|
+
* Export a plugin-enhanced JSON schema to a file at RUNTIME
|
|
16
|
+
*/
|
|
17
|
+
export declare function exportPluginSchema(customComponents: CustomComponent<any, any, any>[], outputPath: string, options?: {
|
|
18
|
+
includeStandardComponents?: boolean;
|
|
19
|
+
prettyPrint?: boolean;
|
|
20
|
+
}): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Generate schemas for individual custom components (version-aware).
|
|
23
|
+
* Produces per-version schemas keyed as `name` or `name@version`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function generateComponentSchemas(customComponents: CustomComponent<any, any, any>[]): Record<string, TSchema>;
|
|
26
|
+
/**
|
|
27
|
+
* Merge custom component schemas with standard schemas
|
|
28
|
+
*/
|
|
29
|
+
export declare function mergeSchemas(customComponents: CustomComponent<any, any, any>[], standardSchemas?: Record<string, TSchema>): Record<string, TSchema>;
|
|
30
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/plugin/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,OAAO,EAAW,MAAM,mBAAmB,CAAC;AAE3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAezD;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,gBAAgB,EAAE,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,EAClD,yBAAyB,UAAO,GAC/B,OAAO,CAiCT;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAQ7D;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,gBAAgB,EAAE,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,EAClD,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE;IACP,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,WAAW,CAAC,EAAE,OAAO,CAAC;CAClB,GACL,OAAO,CAAC,IAAI,CAAC,CAiBf;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,gBAAgB,EAAE,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,GACjD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA6DzB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,gBAAgB,EAAE,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,EAClD,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACxC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAsDzB"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic type utilities for extending document types with custom components
|
|
3
|
+
*/
|
|
4
|
+
/// <reference types="node" />
|
|
5
|
+
import type { Static, TSchema } from '@sinclair/typebox';
|
|
6
|
+
import type { CustomComponent } from './createComponent';
|
|
7
|
+
import type { ComponentDefinition as BaseComponentDefinition } from '@json-to-office/shared-docx';
|
|
8
|
+
import type { ReportComponent, GenerationWarning } from '@json-to-office/shared-docx';
|
|
9
|
+
import type { ReportComponentDefinition } from '../types';
|
|
10
|
+
import type { Document } from 'docx';
|
|
11
|
+
/**
|
|
12
|
+
* Helper to infer the versions map type from a CustomComponent
|
|
13
|
+
*/
|
|
14
|
+
type InferVersionMap<T> = T extends CustomComponent<any, infer V, any> ? V : never;
|
|
15
|
+
/**
|
|
16
|
+
* Helper to infer the name literal type from a CustomComponent
|
|
17
|
+
*/
|
|
18
|
+
type InferName<T> = T extends CustomComponent<any, any, infer N> ? N : never;
|
|
19
|
+
/**
|
|
20
|
+
* Extract the component type definition from a versioned CustomComponent.
|
|
21
|
+
*
|
|
22
|
+
* Produces a discriminated union:
|
|
23
|
+
* - One variant per version with `version: V` (required) and version-specific props
|
|
24
|
+
* - One fallback variant with `version?: never` accepting any version's props
|
|
25
|
+
*
|
|
26
|
+
* This enables TypeScript to narrow props by the `version` discriminant:
|
|
27
|
+
* { version: '1.0.0'; props: V1Props } | { version: '2.0.0'; props: V2Props } | { version?: never; props: V1Props | V2Props }
|
|
28
|
+
*/
|
|
29
|
+
export type ExtractCustomComponentType<T extends CustomComponent<any, any, any>> = {
|
|
30
|
+
[V in keyof InferVersionMap<T> & string]: {
|
|
31
|
+
name: InferName<T>;
|
|
32
|
+
version: V;
|
|
33
|
+
id?: string;
|
|
34
|
+
props: Static<InferVersionMap<T>[V]['propsSchema']>;
|
|
35
|
+
children?: InferVersionMap<T>[V] extends {
|
|
36
|
+
hasChildren: true;
|
|
37
|
+
} ? BaseComponentDefinition[] : never;
|
|
38
|
+
};
|
|
39
|
+
}[keyof InferVersionMap<T> & string] | {
|
|
40
|
+
name: InferName<T>;
|
|
41
|
+
version?: never;
|
|
42
|
+
id?: string;
|
|
43
|
+
props: {
|
|
44
|
+
[V in keyof InferVersionMap<T> & string]: Static<InferVersionMap<T>[V]['propsSchema']>;
|
|
45
|
+
}[keyof InferVersionMap<T> & string];
|
|
46
|
+
children?: {
|
|
47
|
+
[V in keyof InferVersionMap<T> & string]: InferVersionMap<T>[V] extends {
|
|
48
|
+
hasChildren: true;
|
|
49
|
+
} ? BaseComponentDefinition[] : never;
|
|
50
|
+
}[keyof InferVersionMap<T> & string];
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Union type of all custom component definitions from an array of custom components
|
|
54
|
+
*/
|
|
55
|
+
export type CustomComponentUnion<T extends readonly CustomComponent<any, any, any>[]> = {
|
|
56
|
+
[K in keyof T]: T[K] extends CustomComponent<any, any, any> ? ExtractCustomComponentType<T[K]> : never;
|
|
57
|
+
}[number];
|
|
58
|
+
/**
|
|
59
|
+
* Extended ComponentDefinition that includes both standard components and custom components
|
|
60
|
+
*/
|
|
61
|
+
export type ExtendedComponentDefinition<TCustomComponents extends readonly CustomComponent<any, any, any>[] = readonly []> = TCustomComponents extends readonly [] ? BaseComponentDefinition : BaseComponentDefinition | CustomComponentUnion<TCustomComponents>;
|
|
62
|
+
/**
|
|
63
|
+
* Extended ReportComponent that includes custom components in its children array
|
|
64
|
+
*/
|
|
65
|
+
export type ExtendedReportComponent<TCustomComponents extends readonly CustomComponent<any, any, any>[] = readonly []> = Omit<ReportComponent, 'children'> & {
|
|
66
|
+
children?: ExtendedComponentDefinition<TCustomComponents>[];
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Helper type to infer custom components array from createDocumentGenerator options
|
|
70
|
+
*/
|
|
71
|
+
export type InferCustomComponents<T> = T extends {
|
|
72
|
+
customComponents: infer M;
|
|
73
|
+
} ? M extends readonly CustomComponent<any, any, any>[] ? M : readonly [] : readonly [];
|
|
74
|
+
/**
|
|
75
|
+
* Result of document generation
|
|
76
|
+
*/
|
|
77
|
+
export interface GenerationResult {
|
|
78
|
+
/** The generated document */
|
|
79
|
+
document: Document;
|
|
80
|
+
/** Warnings collected during generation, null if no warnings */
|
|
81
|
+
warnings: GenerationWarning[] | null;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Result of buffer generation
|
|
85
|
+
*/
|
|
86
|
+
export interface BufferGenerationResult {
|
|
87
|
+
/** The generated buffer */
|
|
88
|
+
buffer: Buffer;
|
|
89
|
+
/** Warnings collected during generation, null if no warnings */
|
|
90
|
+
warnings: GenerationWarning[] | null;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Result of file generation
|
|
94
|
+
*/
|
|
95
|
+
export interface FileGenerationResult {
|
|
96
|
+
/** Warnings collected during generation, null if no warnings */
|
|
97
|
+
warnings: GenerationWarning[] | null;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Result of document validation
|
|
101
|
+
*/
|
|
102
|
+
export interface ValidationResult {
|
|
103
|
+
valid: boolean;
|
|
104
|
+
errors?: Array<{
|
|
105
|
+
path: string;
|
|
106
|
+
message: string;
|
|
107
|
+
}>;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Document generator with custom components and full type safety
|
|
111
|
+
*/
|
|
112
|
+
export interface DocumentGenerator<TCustomComponents extends readonly CustomComponent<any, any, any>[] = readonly []> {
|
|
113
|
+
generate: (document: ExtendedReportComponent<TCustomComponents>) => Promise<GenerationResult>;
|
|
114
|
+
generateBuffer: (document: ExtendedReportComponent<TCustomComponents>) => Promise<BufferGenerationResult>;
|
|
115
|
+
generateFile: (document: ExtendedReportComponent<TCustomComponents>, outputPath: string) => Promise<FileGenerationResult>;
|
|
116
|
+
getComponentNames: () => string[];
|
|
117
|
+
validate: (document: ExtendedReportComponent<TCustomComponents>) => ValidationResult;
|
|
118
|
+
generateSchema: (includeStandardComponents?: boolean) => TSchema;
|
|
119
|
+
exportSchema: (outputPath: string, options?: {
|
|
120
|
+
includeStandardComponents?: boolean;
|
|
121
|
+
prettyPrint?: boolean;
|
|
122
|
+
}) => Promise<void>;
|
|
123
|
+
getStandardComponentsDefinition: (document: ExtendedReportComponent<TCustomComponents>) => Promise<ReportComponentDefinition>;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Document generator builder with chainable .addComponent() method.
|
|
127
|
+
*/
|
|
128
|
+
export interface DocumentGeneratorBuilder<TComponents extends readonly CustomComponent<any, any, any>[] = readonly []> extends DocumentGenerator<TComponents> {
|
|
129
|
+
addComponent<TNewComponent extends CustomComponent<any, any, any>>(component: TNewComponent): DocumentGeneratorBuilder<readonly [...TComponents, TNewComponent]>;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Infer the components tuple from a DocumentGeneratorBuilder
|
|
133
|
+
*/
|
|
134
|
+
export type InferBuilderComponents<T> = T extends DocumentGeneratorBuilder<infer M> ? M : never;
|
|
135
|
+
/**
|
|
136
|
+
* Infer the document type accepted by a builder
|
|
137
|
+
*/
|
|
138
|
+
export type InferDocumentType<T> = T extends DocumentGeneratorBuilder<infer M> ? ExtendedReportComponent<M> : never;
|
|
139
|
+
/**
|
|
140
|
+
* Infer the component definition type accepted by a builder.
|
|
141
|
+
*/
|
|
142
|
+
export type InferComponentDefinition<T> = T extends DocumentGeneratorBuilder<infer M> ? ExtendedComponentDefinition<M> : T extends DocumentGenerator<infer M> ? ExtendedComponentDefinition<M> : never;
|
|
143
|
+
export {};
|
|
144
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/plugin/types.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,mBAAmB,IAAI,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAClG,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,E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vC,uBAAuB,CAAC,CAAC,CAAC,GAC1B,KAAK,CAAC;AAEZ;;GAEG;AACH,MAAM,MAAM,wBAAwB,CAAC,CAAC,IACpC,CAAC,SAAS,wBAAwB,CAAC,MAAM,CAAC,CAAC,GACvC,2BAA2B,CAAC,CAAC,CAAC,GAC9B,CAAC,SAAS,iBAAiB,CAAC,MAAM,CAAC,CAAC,GAClC,2BAA2B,CAAC,CAAC,CAAC,GAC9B,KAAK,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { TSchema } from '@sinclair/typebox';
|
|
2
|
+
import type { CustomComponent } from './createComponent';
|
|
3
|
+
import type { ReportComponentDefinition } from '../types';
|
|
4
|
+
import { type ValidationError, type ComponentValidationResult } from '@json-to-office/shared-docx/validation/unified';
|
|
5
|
+
import type { ValidationResult } from '@json-to-office/shared';
|
|
6
|
+
/**
|
|
7
|
+
* Error thrown when attempting to register a component with a duplicate name
|
|
8
|
+
*/
|
|
9
|
+
export declare class DuplicateComponentError extends Error {
|
|
10
|
+
readonly componentName: string;
|
|
11
|
+
readonly code = "DUPLICATE_COMPONENT";
|
|
12
|
+
constructor(componentName: string);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Custom validation error class
|
|
16
|
+
*/
|
|
17
|
+
export declare class ComponentValidationError extends Error {
|
|
18
|
+
errors: ValidationError[];
|
|
19
|
+
props: unknown;
|
|
20
|
+
constructor(errors: ValidationError[], props?: unknown);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Validate a component props against a schema.
|
|
24
|
+
* Accepts a narrower interface — only needs { propsSchema }.
|
|
25
|
+
*/
|
|
26
|
+
export declare function validateComponentProps<TPropsSchema extends TSchema>(schema: {
|
|
27
|
+
propsSchema: TPropsSchema;
|
|
28
|
+
}, props: unknown): ComponentValidationResult<TPropsSchema>;
|
|
29
|
+
/**
|
|
30
|
+
* Validate document and all custom components (version-aware)
|
|
31
|
+
*/
|
|
32
|
+
export declare function validateDocument(document: ReportComponentDefinition, customComponents: CustomComponent<any, any, any>[]): ValidationResult & {
|
|
33
|
+
success: boolean;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Validates component props and returns the typed props or throws.
|
|
37
|
+
* Accepts a narrower interface — only needs { propsSchema }.
|
|
38
|
+
*/
|
|
39
|
+
export declare function getValidatedProps<TPropsSchema extends TSchema>(schema: {
|
|
40
|
+
propsSchema: TPropsSchema;
|
|
41
|
+
}, props: unknown): TPropsSchema;
|
|
42
|
+
export type { ValidationError } from '@json-to-office/shared-docx/validation/unified';
|
|
43
|
+
export type { ComponentValidationResult } from '@json-to-office/shared-docx/validation/unified';
|
|
44
|
+
export declare const cleanComponentProps: typeof getValidatedProps;
|
|
45
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/plugin/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAE1D,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,yBAAyB,EAC/B,MAAM,gDAAgD,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,SAAgB,aAAa,EAAE,MAAM,CAAC;IACtC,SAAgB,IAAI,yBAAyB;gBAEjC,aAAa,EAAE,MAAM;CAalC;AAED;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,KAAK;IAC1C,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,KAAK,EAAE,OAAO,CAAC;gBAEV,MAAM,EAAE,eAAe,EAAE,EAAE,KAAK,CAAC,EAAE,OAAO;CAWvD;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,YAAY,SAAS,OAAO,EACjE,MAAM,EAAE;IAAE,WAAW,EAAE,YAAY,CAAA;CAAE,EACrC,KAAK,EAAE,OAAO,GACb,yBAAyB,CAAC,YAAY,CAAC,CAKzC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,yBAAyB,EACnC,gBAAgB,EAAE,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,GACjD,gBAAgB,GAAG;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAiEzC;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,YAAY,SAAS,OAAO,EAC5D,MAAM,EAAE;IAAE,WAAW,EAAE,YAAY,CAAA;CAAE,EACrC,KAAK,EAAE,OAAO,GACb,YAAY,CAQd;AAGD,YAAY,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AACtF,YAAY,EAAE,yBAAyB,EAAE,MAAM,gDAAgD,CAAC;AAGhG,eAAO,MAAM,mBAAmB,0BAAoB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ComponentVersion, ComponentVersionMap } from './createComponent';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve the correct version entry for a component.
|
|
4
|
+
*
|
|
5
|
+
* - If `requestedVersion` is provided and found, return it.
|
|
6
|
+
* - If `requestedVersion` is provided but missing, throw with available versions.
|
|
7
|
+
* - If `requestedVersion` is absent, return the latest semver version.
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolveComponentVersion(componentName: string, versions: ComponentVersionMap, requestedVersion?: string): ComponentVersion;
|
|
10
|
+
//# sourceMappingURL=version-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version-resolver.d.ts","sourceRoot":"","sources":["../../src/plugin/version-resolver.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE/E;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,mBAAmB,EAC7B,gBAAgB,CAAC,EAAE,MAAM,GACxB,gBAAgB,CAgBlB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main styles module export
|
|
3
|
+
* This file provides a unified interface to the styles system
|
|
4
|
+
*/
|
|
5
|
+
export type { ThemeConfigJson as ThemeConfig, StyleDefinitions, DocumentMargins, PageDimensions, Page, FontDefinition, Fonts, ComponentDefaults, HeadingComponentDefaults, ParagraphComponentDefaults, ImageComponentDefaults, StatisticComponentDefaults, TableComponentDefaults, SectionComponentDefaults, ColumnsComponentDefaults, ListComponentDefaults, } from '@json-to-office/shared-docx';
|
|
6
|
+
export { themes, getTheme, getThemeNames, getThemeWithFallback, hasTheme, isValidThemeName, } from '../templates/themes';
|
|
7
|
+
export type { ThemeName } from '../templates/themes';
|
|
8
|
+
export { getBodyTextStyle } from './utils/styleHelpers';
|
|
9
|
+
export { getTableStyle, getDocumentMargins, getPageSetup, } from './utils/layoutUtils';
|
|
10
|
+
export { minimalTheme, corporateTheme, modernTheme, } from '../templates/themes';
|
|
11
|
+
export { ThemeConfigSchema, isValidThemeConfig, loadThemeFromJson, loadThemeFromFile, exportThemeToJson, validateThemeJsonString, ThemeValidationError, ThemeParseError, ThemeFileError, } from '../themes/json';
|
|
12
|
+
export type { ThemeConfigJson } from '../themes/json';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/styles/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,YAAY,EACV,eAAe,IAAI,WAAW,EAC9B,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,IAAI,EACJ,cAAc,EACd,KAAK,EACL,iBAAiB,EACjB,wBAAwB,EACxB,0BAA0B,EAC1B,sBAAsB,EACtB,0BAA0B,EAC1B,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,MAAM,EACN,QAAQ,EACR,aAAa,EACb,oBAAoB,EACpB,QAAQ,EACR,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAG7B,YAAY,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,YAAY,GACb,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,YAAY,EACZ,cAAc,EACd,WAAW,GACZ,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,oBAAoB,EACpB,eAAe,EACf,cAAc,GACf,MAAM,gBAAgB,CAAC;AAGxB,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-resolver.d.ts","sourceRoot":"","sources":["../../src/styles/theme-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAG3C;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,WAAW,CAiBtE"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ThemeConfig } from './index';
|
|
2
|
+
/**
|
|
3
|
+
* Validate a theme configuration
|
|
4
|
+
* Now uses unified validation from shared package
|
|
5
|
+
*/
|
|
6
|
+
export declare function validateTheme(theme?: ThemeConfig | string): ThemeConfig | undefined;
|
|
7
|
+
//# sourceMappingURL=theme-validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-validator.d.ts","sourceRoot":"","sources":["../../src/styles/theme-validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAG3C;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,KAAK,CAAC,EAAE,WAAW,GAAG,MAAM,GAC3B,WAAW,GAAG,SAAS,CAoBzB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { IStylesOptions, IRunStylePropertiesOptions, IParagraphStylePropertiesOptions } from 'docx';
|
|
2
|
+
import type { ThemeConfig } from './index';
|
|
3
|
+
export interface WordStyleDefinition {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
basedOn?: string;
|
|
7
|
+
next?: string;
|
|
8
|
+
quickFormat?: boolean;
|
|
9
|
+
run?: IRunStylePropertiesOptions;
|
|
10
|
+
paragraph?: IParagraphStylePropertiesOptions;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Creates Word document styles from theme configuration
|
|
14
|
+
* @param themeNameOrObject The theme to use for styling (name string or theme object)
|
|
15
|
+
* @returns IStylesOptions for docx Document
|
|
16
|
+
*/
|
|
17
|
+
export declare function createWordStyles(themeNameOrObject?: string | ThemeConfig): IStylesOptions;
|
|
18
|
+
/**
|
|
19
|
+
* Maps section levels to Word style IDs
|
|
20
|
+
*/
|
|
21
|
+
export declare function getStyleIdForLevel(level: number): string;
|
|
22
|
+
//# sourceMappingURL=themeToDocxAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"themeToDocxAdapter.d.ts","sourceRoot":"","sources":["../../src/styles/themeToDocxAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,0BAA0B,EAC1B,gCAAgC,EAGjC,MAAM,MAAM,CAAC;AAEd,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAuT3C,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,GAAG,CAAC,EAAE,0BAA0B,CAAC;IACjC,SAAS,CAAC,EAAE,gCAAgC,CAAC;CAC9C;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,iBAAiB,GAAE,MAAM,GAAG,WAAuB,GAClD,cAAc,CAqiBhB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAUxD"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Border utilities for consistent border styling across modules
|
|
3
|
+
*/
|
|
4
|
+
import { BorderStyle } from 'docx';
|
|
5
|
+
import { ThemeConfig } from '../index';
|
|
6
|
+
/**
|
|
7
|
+
* Standard "no borders" configuration for tables
|
|
8
|
+
* Used when borders should be invisible/disabled
|
|
9
|
+
*/
|
|
10
|
+
export declare const NONE_BORDERS: {
|
|
11
|
+
readonly top: {
|
|
12
|
+
readonly style: "none";
|
|
13
|
+
readonly size: 0;
|
|
14
|
+
readonly color: "000000";
|
|
15
|
+
};
|
|
16
|
+
readonly right: {
|
|
17
|
+
readonly style: "none";
|
|
18
|
+
readonly size: 0;
|
|
19
|
+
readonly color: "000000";
|
|
20
|
+
};
|
|
21
|
+
readonly bottom: {
|
|
22
|
+
readonly style: "none";
|
|
23
|
+
readonly size: 0;
|
|
24
|
+
readonly color: "000000";
|
|
25
|
+
};
|
|
26
|
+
readonly left: {
|
|
27
|
+
readonly style: "none";
|
|
28
|
+
readonly size: 0;
|
|
29
|
+
readonly color: "000000";
|
|
30
|
+
};
|
|
31
|
+
readonly insideHorizontal: {
|
|
32
|
+
readonly style: "none";
|
|
33
|
+
readonly size: 0;
|
|
34
|
+
readonly color: "000000";
|
|
35
|
+
};
|
|
36
|
+
readonly insideVertical: {
|
|
37
|
+
readonly style: "none";
|
|
38
|
+
readonly size: 0;
|
|
39
|
+
readonly color: "000000";
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Maps border style string to docx BorderStyle enum
|
|
44
|
+
* @param s - Border style string ('dashed', 'dotted', 'double', 'none', 'single')
|
|
45
|
+
* @returns Corresponding BorderStyle enum value
|
|
46
|
+
*/
|
|
47
|
+
export declare function mapBorderStyle(s?: string): (typeof BorderStyle)[keyof typeof BorderStyle];
|
|
48
|
+
/**
|
|
49
|
+
* Border configuration object
|
|
50
|
+
*/
|
|
51
|
+
export interface BorderConfig {
|
|
52
|
+
style?: string;
|
|
53
|
+
width?: number;
|
|
54
|
+
color?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Converts border configuration to docx border format
|
|
58
|
+
* @param b - Border configuration object
|
|
59
|
+
* @param theme - Theme configuration for color resolution
|
|
60
|
+
* @returns Docx border object or undefined if no border
|
|
61
|
+
*/
|
|
62
|
+
export declare function convertBorder(b: BorderConfig | undefined, theme: ThemeConfig): {
|
|
63
|
+
style: (typeof BorderStyle)[keyof typeof BorderStyle];
|
|
64
|
+
size: number;
|
|
65
|
+
color: string;
|
|
66
|
+
} | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Borders configuration for all four sides
|
|
69
|
+
*/
|
|
70
|
+
export interface BordersConfig {
|
|
71
|
+
top?: BorderConfig;
|
|
72
|
+
right?: BorderConfig;
|
|
73
|
+
bottom?: BorderConfig;
|
|
74
|
+
left?: BorderConfig;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Converts borders configuration object to docx borders format
|
|
78
|
+
* Returns undefined if no borders are defined
|
|
79
|
+
* @param bordersConfig - Configuration for all four borders
|
|
80
|
+
* @param theme - Theme configuration for color resolution
|
|
81
|
+
* @returns Docx borders object or undefined
|
|
82
|
+
*/
|
|
83
|
+
export declare function convertBorders(bordersConfig: BordersConfig | undefined, theme: ThemeConfig): Record<string, {
|
|
84
|
+
style: (typeof BorderStyle)[keyof typeof BorderStyle];
|
|
85
|
+
size: number;
|
|
86
|
+
color: string;
|
|
87
|
+
}> | undefined;
|
|
88
|
+
//# sourceMappingURL=borderUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"borderUtils.d.ts","sourceRoot":"","sources":["../../../src/styles/utils/borderUtils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAEnC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC;;;GAGG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAOf,CAAC;AAEX;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,CAAC,CAAC,EAAE,MAAM,GACT,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAahD;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,CAAC,EAAE,YAAY,GAAG,SAAS,EAC3B,KAAK,EAAE,WAAW,GAEhB;IACE,KAAK,EAAE,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,GACD,SAAS,CAQZ;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,EAAE,YAAY,CAAC;IACnB,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB;AAED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