@officedk/pptxdk 0.0.0-stage → 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.
Files changed (194) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +48 -2
  3. package/dist/build.d.ts +94 -0
  4. package/dist/build.js +148 -0
  5. package/dist/capabilities/dist/all.js +32 -0
  6. package/dist/capabilities/dist/box/box-codegen.js +51 -0
  7. package/dist/capabilities/dist/box/box-declaration.js +31 -0
  8. package/dist/capabilities/dist/box/box-elements.js +17 -0
  9. package/dist/capabilities/dist/box/box.js +138 -0
  10. package/dist/capabilities/dist/chart/chart-codegen.js +77 -0
  11. package/dist/capabilities/dist/chart/chart-declaration.js +7 -0
  12. package/dist/capabilities/dist/chart/chart-elements.js +12 -0
  13. package/dist/capabilities/dist/chart/chart-import.js +2272 -0
  14. package/dist/capabilities/dist/chart/chart-labels.js +86 -0
  15. package/dist/capabilities/dist/chart/chart-model.js +9 -0
  16. package/dist/capabilities/dist/chart/chart-schemas.js +1078 -0
  17. package/dist/capabilities/dist/chart/chart-xml.js +788 -0
  18. package/dist/capabilities/dist/chart/chart.js +1124 -0
  19. package/dist/capabilities/dist/chart/preview/axes-and-grid.js +298 -0
  20. package/dist/capabilities/dist/chart/preview/bar-column.js +143 -0
  21. package/dist/capabilities/dist/chart/preview/data-labels.js +334 -0
  22. package/dist/capabilities/dist/chart/preview/error-bars.js +213 -0
  23. package/dist/capabilities/dist/chart/preview/index.js +190 -0
  24. package/dist/capabilities/dist/chart/preview/layout.js +519 -0
  25. package/dist/capabilities/dist/chart/preview/legend.js +273 -0
  26. package/dist/capabilities/dist/chart/preview/line-area.js +404 -0
  27. package/dist/capabilities/dist/chart/preview/markers.js +100 -0
  28. package/dist/capabilities/dist/chart/preview/number-format.js +247 -0
  29. package/dist/capabilities/dist/chart/preview/pie-doughnut.js +159 -0
  30. package/dist/capabilities/dist/chart/preview/scales.js +365 -0
  31. package/dist/capabilities/dist/chart/preview/scatter.js +131 -0
  32. package/dist/capabilities/dist/chart/preview/style.js +48 -0
  33. package/dist/capabilities/dist/chart/preview/text-render.js +116 -0
  34. package/dist/capabilities/dist/chart/preview/trendlines.js +537 -0
  35. package/dist/capabilities/dist/chart/preview/types.js +5 -0
  36. package/dist/capabilities/dist/document.js +148 -0
  37. package/dist/capabilities/dist/font/font-embedding.js +289 -0
  38. package/dist/capabilities/dist/font/font-family.js +10 -0
  39. package/dist/capabilities/dist/font/font-import.js +302 -0
  40. package/dist/capabilities/dist/font/font-subset.js +55 -0
  41. package/dist/capabilities/dist/font/font.js +25 -0
  42. package/dist/capabilities/dist/group/group-codegen.js +51 -0
  43. package/dist/capabilities/dist/group/group-declaration.js +42 -0
  44. package/dist/capabilities/dist/group/group-elements.js +12 -0
  45. package/dist/capabilities/dist/group/group-import.js +319 -0
  46. package/dist/capabilities/dist/group/group-xml.js +7 -0
  47. package/dist/capabilities/dist/group/group.js +211 -0
  48. package/dist/capabilities/dist/image/gif-decoder.js +244 -0
  49. package/dist/capabilities/dist/image/image-codegen.js +94 -0
  50. package/dist/capabilities/dist/image/image-declaration.js +8 -0
  51. package/dist/capabilities/dist/image/image-decode.js +221 -0
  52. package/dist/capabilities/dist/image/image-elements.js +12 -0
  53. package/dist/capabilities/dist/image/image-import.js +778 -0
  54. package/dist/capabilities/dist/image/image-schemas.js +149 -0
  55. package/dist/capabilities/dist/image/image-xml.js +12 -0
  56. package/dist/capabilities/dist/image/image.js +472 -0
  57. package/dist/capabilities/dist/masters/footer-placeholder.js +685 -0
  58. package/dist/capabilities/dist/masters/masters-codegen.js +21 -0
  59. package/dist/capabilities/dist/masters/masters.js +250 -0
  60. package/dist/capabilities/dist/motion/motion-api.js +527 -0
  61. package/dist/capabilities/dist/motion/motion-codegen.js +340 -0
  62. package/dist/capabilities/dist/motion/motion-elements.js +43 -0
  63. package/dist/capabilities/dist/motion/motion-import.js +1033 -0
  64. package/dist/capabilities/dist/motion/motion-plan.js +2189 -0
  65. package/dist/capabilities/dist/motion/motion-query.js +420 -0
  66. package/dist/capabilities/dist/motion/motion-schemas.js +216 -0
  67. package/dist/capabilities/dist/motion/motion.js +1372 -0
  68. package/dist/capabilities/dist/notes/notes-codegen.js +20 -0
  69. package/dist/capabilities/dist/notes/notes-declaration.js +8 -0
  70. package/dist/capabilities/dist/notes/notes-elements.js +12 -0
  71. package/dist/capabilities/dist/notes/notes-import.js +292 -0
  72. package/dist/capabilities/dist/notes/notes-schemas.js +35 -0
  73. package/dist/capabilities/dist/notes/notes-xml.js +38 -0
  74. package/dist/capabilities/dist/notes/notes.js +191 -0
  75. package/dist/capabilities/dist/placeholder/placeholder-codegen.js +23 -0
  76. package/dist/capabilities/dist/placeholder/placeholder-elements.js +12 -0
  77. package/dist/capabilities/dist/placeholder/placeholder.js +292 -0
  78. package/dist/capabilities/dist/shape/shape-codegen.js +166 -0
  79. package/dist/capabilities/dist/shape/shape-declaration.js +57 -0
  80. package/dist/capabilities/dist/shape/shape-elements.js +12 -0
  81. package/dist/capabilities/dist/shape/shape-import.js +579 -0
  82. package/dist/capabilities/dist/shape/shape-xml.js +6 -0
  83. package/dist/capabilities/dist/shape/shape.js +337 -0
  84. package/dist/capabilities/dist/shared/geometry.js +1423 -0
  85. package/dist/capabilities/dist/shared/identity.js +205 -0
  86. package/dist/capabilities/dist/shared/morph-api.js +11 -0
  87. package/dist/capabilities/dist/shared/placeholder-import.js +113 -0
  88. package/dist/capabilities/dist/shared/preset-definitions.js +21390 -0
  89. package/dist/capabilities/dist/shared/style-inheritance.js +166 -0
  90. package/dist/capabilities/dist/shared/style-parse.js +11 -0
  91. package/dist/capabilities/dist/shared/text-schemas.js +216 -0
  92. package/dist/capabilities/dist/shared/text-service.js +1883 -0
  93. package/dist/capabilities/dist/shared/visual.js +918 -0
  94. package/dist/capabilities/dist/slide-background/slide-background-codegen.js +44 -0
  95. package/dist/capabilities/dist/slide-background/slide-background-import.js +161 -0
  96. package/dist/capabilities/dist/slide-background/slide-background-xml.js +21 -0
  97. package/dist/capabilities/dist/slide-background/slide-background.js +221 -0
  98. package/dist/capabilities/dist/table/table-codegen.js +81 -0
  99. package/dist/capabilities/dist/table/table-declaration.js +15 -0
  100. package/dist/capabilities/dist/table/table-elements.js +27 -0
  101. package/dist/capabilities/dist/table/table-import.js +539 -0
  102. package/dist/capabilities/dist/table/table-schemas.js +279 -0
  103. package/dist/capabilities/dist/table/table-xml.js +37 -0
  104. package/dist/capabilities/dist/table/table.js +662 -0
  105. package/dist/capabilities/dist/text/text-codegen.js +129 -0
  106. package/dist/capabilities/dist/text/text-declaration.js +19 -0
  107. package/dist/capabilities/dist/text/text-elements.js +38 -0
  108. package/dist/capabilities/dist/text/text-import.js +1077 -0
  109. package/dist/capabilities/dist/text/text-xml.js +9 -0
  110. package/dist/capabilities/dist/text/text.js +335 -0
  111. package/dist/capabilities/dist/transition/transition-api.js +139 -0
  112. package/dist/capabilities/dist/transition/transition-codegen.js +45 -0
  113. package/dist/capabilities/dist/transition/transition-import.js +477 -0
  114. package/dist/capabilities/dist/transition/transition.js +260 -0
  115. package/dist/capability-D_xeNVIw.d.ts +29496 -0
  116. package/dist/cli.js +20 -0
  117. package/dist/codegen/dist/assets.js +78 -0
  118. package/dist/codegen/dist/codegen.js +611 -0
  119. package/dist/codegen/dist/identifiers.js +193 -0
  120. package/dist/codegen/dist/index.js +3 -0
  121. package/dist/codegen/dist/printer.js +143 -0
  122. package/dist/codegen/dist/types.js +49 -0
  123. package/dist/core/dist/author-ids.js +48 -0
  124. package/dist/core/dist/author-schemas.js +313 -0
  125. package/dist/core/dist/block-flex-layout.js +749 -0
  126. package/dist/core/dist/build.js +4 -0
  127. package/dist/core/dist/capability.js +13 -0
  128. package/dist/core/dist/declaration.js +15 -0
  129. package/dist/core/dist/diagnostics.js +21 -0
  130. package/dist/core/dist/document-internals.js +13 -0
  131. package/dist/core/dist/document.js +408 -0
  132. package/dist/core/dist/geometry-schemas.js +249 -0
  133. package/dist/core/dist/grid-layout.js +445 -0
  134. package/dist/core/dist/host.js +40 -0
  135. package/dist/core/dist/index.js +15 -0
  136. package/dist/core/dist/input-values.js +45 -0
  137. package/dist/core/dist/layout-protocol.js +66 -0
  138. package/dist/core/dist/layout-schemas.js +208 -0
  139. package/dist/core/dist/layout.js +299 -0
  140. package/dist/core/dist/masters.js +169 -0
  141. package/dist/core/dist/morph.js +30 -0
  142. package/dist/core/dist/placeholders.js +213 -0
  143. package/dist/core/dist/query.js +155 -0
  144. package/dist/core/dist/resolution.js +11 -0
  145. package/dist/core/dist/resolve.js +1827 -0
  146. package/dist/core/dist/stage-options.js +67 -0
  147. package/dist/core/dist/theme.js +931 -0
  148. package/dist/document-BHPUODPP.d.ts +27759 -0
  149. package/dist/emit/dist/emit.js +936 -0
  150. package/dist/emit/dist/index.js +5 -0
  151. package/dist/emit/dist/ooxml.js +606 -0
  152. package/dist/emit/dist/shape-tree.js +12 -0
  153. package/dist/import/dist/alternate-content.js +54 -0
  154. package/dist/import/dist/diagnostics.js +153 -0
  155. package/dist/import/dist/fonts.js +250 -0
  156. package/dist/import/dist/import.js +504 -0
  157. package/dist/import/dist/index.js +16 -0
  158. package/dist/import/dist/masters.js +1153 -0
  159. package/dist/import/dist/mechanism.js +10 -0
  160. package/dist/import/dist/namespaces.js +60 -0
  161. package/dist/import/dist/notes-masters.js +300 -0
  162. package/dist/import/dist/opc.js +233 -0
  163. package/dist/import/dist/resources.js +166 -0
  164. package/dist/import/dist/sections.js +139 -0
  165. package/dist/import/dist/themes.js +671 -0
  166. package/dist/import/dist/visual.js +761 -0
  167. package/dist/import/dist/xml-fragments.js +36 -0
  168. package/dist/import/dist/xml-reader.js +267 -0
  169. package/dist/index-B5m3hqjC.d.ts +7 -0
  170. package/dist/index-CCy-Yo8G.d.ts +1208 -0
  171. package/dist/index-DpxcZ4Gs.d.ts +725 -0
  172. package/dist/index.d.ts +7 -0
  173. package/dist/index.js +70 -0
  174. package/dist/node.d.ts +53 -0
  175. package/dist/node.js +194 -0
  176. package/dist/pptxdk/src/cli-commands.js +913 -0
  177. package/dist/pptxdk/src/compose.js +44 -0
  178. package/dist/pptxdk/src/slide.js +9 -0
  179. package/dist/preview/dist/index.js +240 -0
  180. package/dist/preview/dist/options.js +53 -0
  181. package/dist/preview-Cfw0QdMM.d.ts +86 -0
  182. package/dist/preview.d.ts +3 -0
  183. package/dist/preview.js +27 -0
  184. package/dist/react/dist/append.js +66 -0
  185. package/dist/react/dist/document-adapter.js +65 -0
  186. package/dist/react/dist/elements.js +59 -0
  187. package/dist/react/dist/index.js +68 -0
  188. package/dist/react/dist/reconciler.js +290 -0
  189. package/dist/react.d.ts +145 -0
  190. package/dist/react.js +27 -0
  191. package/dist/transition-Cips9wma.d.ts +82 -0
  192. package/dist/vanilla.d.ts +4 -0
  193. package/dist/vanilla.js +14 -0
  194. package/package.json +78 -3
@@ -0,0 +1,279 @@
1
+ import { CapabilityError } from "../../../core/dist/diagnostics.js";
2
+ import { layoutStyleSchema } from "../../../core/dist/layout-schemas.js";
3
+ import { colorValueSchema, textStyleSchema } from "../../../core/dist/theme.js";
4
+ import { linkTargetSchema } from "../../../core/dist/author-schemas.js";
5
+ import { nativePlaceholderRefSchema } from "../../../core/dist/placeholders.js";
6
+ import "../../../core/dist/capability.js";
7
+ import { pxToEmu } from "../../../emit/dist/ooxml.js";
8
+ import "../../../emit/dist/index.js";
9
+ import "../../../import/dist/index.js";
10
+ import { ooxmlBoolSchema, ooxmlNonNegativeIntSchema, ooxmlPositiveIntSchema } from "../../../import/dist/xml-fragments.js";
11
+ import { motionPropsSchema } from "../motion/motion-schemas.js";
12
+ import { optionalNameSchema } from "../shared/identity.js";
13
+ import { morphKeySchema } from "../shared/morph-api.js";
14
+ import { parseTextInsets, textCoordinateSchema, textPaddingValueSchema, textPositiveSizeSchema } from "../shared/text-schemas.js";
15
+ import { z } from "zod";
16
+ // ../capabilities/dist/table/table-schemas.js
17
+ const frColumnPattern = /^\d+(?:\.\d+)?fr$/u;
18
+ const maximumExtentEmu = 2147483647;
19
+ const tableVerticalAlignSchema = z.enum([
20
+ "top",
21
+ "middle",
22
+ "bottom"
23
+ ]);
24
+ const tableColumnPxSchema = z.number().finite().positive();
25
+ const tableColumnFrSchema = z.string().regex(frColumnPattern).refine((value) => Number(value.slice(0, -2)) > 0);
26
+ /** Column width in px; Nfr allocates from remaining width, auto uses shared font measurement. */
27
+ const tableColumnSchema = z.union([
28
+ tableColumnPxSchema,
29
+ tableColumnFrSchema,
30
+ z.literal("auto")
31
+ ]);
32
+ const nonNegativeTableInsetSchema = z.number().finite().nonnegative().refine((value) => Number.isSafeInteger(pxToEmu(value)));
33
+ z.union([
34
+ nonNegativeTableInsetSchema,
35
+ z.tuple([nonNegativeTableInsetSchema, nonNegativeTableInsetSchema]).readonly(),
36
+ z.tuple([
37
+ nonNegativeTableInsetSchema,
38
+ nonNegativeTableInsetSchema,
39
+ nonNegativeTableInsetSchema,
40
+ nonNegativeTableInsetSchema
41
+ ]).readonly()
42
+ ]);
43
+ const coreTextStyleShape = textStyleSchema.unwrap().shape;
44
+ const tableTextStyleObjectSchema = z.strictObject({
45
+ fontFamily: coreTextStyleShape.fontFamily,
46
+ fontSize: coreTextStyleShape.fontSize,
47
+ fontWeight: coreTextStyleShape.fontWeight,
48
+ fontStyle: coreTextStyleShape.fontStyle,
49
+ color: coreTextStyleShape.color,
50
+ lineHeight: coreTextStyleShape.lineHeight,
51
+ verticalAlign: coreTextStyleShape.verticalAlign,
52
+ letterSpacing: coreTextStyleShape.letterSpacing,
53
+ textTransform: coreTextStyleShape.textTransform,
54
+ textDecoration: coreTextStyleShape.textDecoration,
55
+ textShadow: coreTextStyleShape.textShadow,
56
+ lang: coreTextStyleShape.lang
57
+ });
58
+ tableTextStyleObjectSchema.readonly();
59
+ const tableStyleSchema = z.strictObject({
60
+ ...tableTextStyleObjectSchema.shape,
61
+ ...layoutStyleSchema.unwrap().shape
62
+ }).readonly();
63
+ const tableRowOwnStyleObjectSchema = z.strictObject({
64
+ /** When unspecified, row height is determined from text measurement of unmerged cells in this row. */
65
+ height: textPositiveSizeSchema.optional(),
66
+ backgroundColor: colorValueSchema.optional()
67
+ });
68
+ const tableRowStyleSchema = z.strictObject({
69
+ ...tableTextStyleObjectSchema.shape,
70
+ ...tableRowOwnStyleObjectSchema.shape
71
+ }).readonly();
72
+ const tableBorderStyleSchema = z.enum([
73
+ "solid",
74
+ "dashed",
75
+ "dotted"
76
+ ]);
77
+ const tableCellOwnStyleObjectSchema = z.strictObject({
78
+ backgroundColor: colorValueSchema.optional(),
79
+ borderColor: colorValueSchema.optional(),
80
+ borderWidth: z.number().finite().nonnegative().optional(),
81
+ borderStyle: tableBorderStyleSchema.optional(),
82
+ padding: textPaddingValueSchema.optional(),
83
+ paddingTop: z.number().finite().nonnegative().optional(),
84
+ paddingRight: z.number().finite().nonnegative().optional(),
85
+ paddingBottom: z.number().finite().nonnegative().optional(),
86
+ paddingLeft: z.number().finite().nonnegative().optional()
87
+ });
88
+ const tableCellStyleSchema = z.strictObject({
89
+ ...tableTextStyleObjectSchema.shape,
90
+ ...tableCellOwnStyleObjectSchema.shape
91
+ }).readonly();
92
+ const tableMergeSpanSchema = z.number().int().min(1);
93
+ const motionPropsShape = motionPropsSchema.unwrap().shape;
94
+ const tableDeclarationPropsObjectSchema = z.strictObject({
95
+ id: optionalNameSchema.optional(),
96
+ name: optionalNameSchema.optional(),
97
+ placeholder: z.string().optional(),
98
+ nativePlaceholder: nativePlaceholderRefSchema.optional(),
99
+ morphKey: morphKeySchema.optional(),
100
+ link: linkTargetSchema.optional(),
101
+ x: textCoordinateSchema.optional(),
102
+ y: textCoordinateSchema.optional(),
103
+ /** Provides allocatable width for fr columns; when omitted, all columns are sized to natural content width. */
104
+ width: textPositiveSizeSchema.optional(),
105
+ columns: z.array(tableColumnSchema).nonempty().readonly(),
106
+ style: tableStyleSchema.optional(),
107
+ enter: motionPropsShape.enter,
108
+ emphasis: motionPropsShape.emphasis,
109
+ motion: motionPropsShape.motion
110
+ });
111
+ const tableDeclarationPropsSchema = tableDeclarationPropsObjectSchema.readonly();
112
+ const rowDeclarationPropsObjectSchema = z.strictObject({
113
+ id: optionalNameSchema.optional(),
114
+ style: tableRowStyleSchema.optional()
115
+ });
116
+ const rowDeclarationPropsSchema = rowDeclarationPropsObjectSchema.readonly();
117
+ const cellDeclarationPropsObjectSchema = z.strictObject({
118
+ id: optionalNameSchema.optional(),
119
+ colSpan: tableMergeSpanSchema.optional(),
120
+ rowSpan: tableMergeSpanSchema.optional(),
121
+ style: tableCellStyleSchema.optional()
122
+ });
123
+ const cellDeclarationPropsSchema = cellDeclarationPropsObjectSchema.readonly();
124
+ const tableAllowedParameters = [...Object.keys(tableDeclarationPropsObjectSchema.shape), "children"];
125
+ const rowAllowedParameters = Object.keys(rowDeclarationPropsObjectSchema.shape);
126
+ const cellAllowedParameters = Object.keys(cellDeclarationPropsObjectSchema.shape);
127
+ const tableTextStyleKeys = Object.keys(tableTextStyleObjectSchema.shape);
128
+ const tableStyleKeys = Object.keys(tableStyleSchema.unwrap().shape);
129
+ const rowStyleKeys = Object.keys(tableRowOwnStyleObjectSchema.shape);
130
+ const cellStyleKeys = Object.keys(tableCellOwnStyleObjectSchema.shape);
131
+ /** OOXML `<p:cNvPr>` attribute fragment schema inside `<p:graphicFrame>`. */
132
+ const nonVisualGraphicFrameIdSchema = z.object({
133
+ id: ooxmlNonNegativeIntSchema,
134
+ name: z.string().optional()
135
+ });
136
+ /** OOXML `<a:graphicFrameLocks>` attribute fragment schema. */
137
+ const graphicFrameLocksXmlSchema = z.object({
138
+ noGrp: ooxmlBoolSchema.optional(),
139
+ noDrilldown: ooxmlBoolSchema.optional(),
140
+ noSelect: ooxmlBoolSchema.optional(),
141
+ noChangeAspect: ooxmlBoolSchema.optional(),
142
+ noMove: ooxmlBoolSchema.optional(),
143
+ noResize: ooxmlBoolSchema.optional()
144
+ });
145
+ /** OOXML `<a:tblPr>` attribute fragment schema. */
146
+ const tblPrXmlSchema = z.object({
147
+ firstRow: ooxmlBoolSchema.optional(),
148
+ firstCol: ooxmlBoolSchema.optional(),
149
+ lastRow: ooxmlBoolSchema.optional(),
150
+ lastCol: ooxmlBoolSchema.optional(),
151
+ bandRow: ooxmlBoolSchema.optional(),
152
+ bandCol: ooxmlBoolSchema.optional(),
153
+ rtl: ooxmlBoolSchema.optional()
154
+ });
155
+ /** OOXML `<a:gridCol w="..."/>` fragment schema. */
156
+ const tblGridColXmlSchema = z.object({ w: ooxmlPositiveIntSchema });
157
+ /** OOXML `<a:tr h="..."/>` fragment schema. */
158
+ const tblRowXmlSchema = z.object({ h: ooxmlPositiveIntSchema });
159
+ /** OOXML `<a:tc gridSpan="..." rowSpan="..." hMerge="..." vMerge="..."/>` fragment schema. */
160
+ const tblCellXmlSchema = z.object({
161
+ gridSpan: ooxmlPositiveIntSchema.optional(),
162
+ rowSpan: ooxmlPositiveIntSchema.optional(),
163
+ hMerge: ooxmlBoolSchema.optional(),
164
+ vMerge: ooxmlBoolSchema.optional()
165
+ });
166
+ /** OOXML `<a:tcPr .../>` attribute fragment schema. */
167
+ const tblCellPrXmlSchema = z.object({
168
+ marL: ooxmlNonNegativeIntSchema.optional(),
169
+ marR: ooxmlNonNegativeIntSchema.optional(),
170
+ marT: ooxmlNonNegativeIntSchema.optional(),
171
+ marB: ooxmlNonNegativeIntSchema.optional(),
172
+ anchor: z.enum([
173
+ "t",
174
+ "ctr",
175
+ "b"
176
+ ]).optional(),
177
+ vert: z.string().optional(),
178
+ horzOverflow: z.string().optional(),
179
+ anchorCtr: ooxmlBoolSchema.optional()
180
+ });
181
+ /** Validates a plain object parameter map against allowed parameter keys. */
182
+ function assertAllowedTableKeys(value, allowed, label, path) {
183
+ const unknown = Object.keys(value).find((key) => !allowed.includes(key));
184
+ if (unknown !== void 0) throw new CapabilityError("unknown-parameter", `${label} contains unsupported parameter ${unknown}`, path);
185
+ }
186
+ /** Validates an optional non-empty author ID on Row or Cell. */
187
+ function parseOptionalTableId(value, path) {
188
+ if (value === void 0) return void 0;
189
+ const parsed = optionalNameSchema.safeParse(value);
190
+ if (!parsed.success) throw new CapabilityError("invalid-parameter", "id must be a non-empty string", path);
191
+ return parsed.data;
192
+ }
193
+ /** Validates table coordinate (`x` or `y`) via shared coordinate schema, defaulting omitted to `0`. */
194
+ function parseTableCoordinate(value, label) {
195
+ if (value === void 0) return 0;
196
+ const parsed = textCoordinateSchema.safeParse(value);
197
+ if (!parsed.success) throw new CapabilityError("invalid-table-geometry", `${label} must be a finite pixel number between -1000000 and 1000000`);
198
+ return parsed.data;
199
+ }
200
+ /** Validates positive pixel extent (`width` or `Row.style.height`) via shared positive size schema. */
201
+ function parseTablePositiveSize(value, label, path) {
202
+ if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) throw new CapabilityError("invalid-table-geometry", `${label} must be a finite positive pixel number`, path);
203
+ const parsed = textPositiveSizeSchema.safeParse(value);
204
+ if (!parsed.success) throw new CapabilityError("invalid-table-geometry", `${label} exceeds writable table dimension range after conversion`, path);
205
+ return parsed.data;
206
+ }
207
+ /** Validates EMU extent bounds for resolved table tracks and borders. */
208
+ function assertTableEmuExtent(value, label, path) {
209
+ const emu = pxToEmu(value);
210
+ if (!Number.isSafeInteger(emu) || emu < 1 || emu > maximumExtentEmu) throw new CapabilityError("invalid-table-geometry", `${label} exceeds writable table dimension range after conversion`, path);
211
+ return emu;
212
+ }
213
+ /** Validates vertical alignment via Zod schema. */
214
+ function parseTableVerticalAlign(value, path) {
215
+ if (value === void 0) return void 0;
216
+ const parsed = tableVerticalAlignSchema.safeParse(value);
217
+ if (!parsed.success) throw new CapabilityError("invalid-vertical-align", "verticalAlign must be top, middle, or bottom", path);
218
+ return parsed.data;
219
+ }
220
+ /** Validates non-empty `Table.columns` tracks via Zod schema. */
221
+ function parseTableColumns(value) {
222
+ if (!Array.isArray(value) || value.length === 0) throw new CapabilityError("invalid-table-column", "Table.columns must be a non-empty array");
223
+ return value.map((column, index) => {
224
+ const parsed = tableColumnSchema.safeParse(column);
225
+ if (!parsed.success) {
226
+ if (typeof column === "number" && (!Number.isFinite(column) || column <= 0) || typeof column === "string" && frColumnPattern.test(column) && Number(column.slice(0, -2)) <= 0) {
227
+ const kindLabel = typeof column === "number" ? "width" : "fraction";
228
+ throw new CapabilityError("invalid-table-column", `column ${index + 1} ${kindLabel} must be greater than 0`);
229
+ }
230
+ throw new CapabilityError("invalid-table-column", `Invalid width for column ${index + 1}; use positive px number, positive "Nfr", or "auto"`);
231
+ }
232
+ if (typeof parsed.data === "number") return {
233
+ kind: "px",
234
+ value: parsed.data
235
+ };
236
+ if (parsed.data === "auto") return { kind: "auto" };
237
+ return {
238
+ kind: "fr",
239
+ value: Number(parsed.data.slice(0, -2))
240
+ };
241
+ });
242
+ }
243
+ /** Validates `colSpan` or `rowSpan` via Zod schema. */
244
+ function parseTableMergeSpan(value, label, path) {
245
+ if (value === void 0) return 1;
246
+ const parsed = tableMergeSpanSchema.safeParse(value);
247
+ if (!parsed.success) throw new CapabilityError("invalid-table-merge", `${label} must be a positive integer`, path);
248
+ return parsed.data;
249
+ }
250
+ /** Validates cell padding declarations by reusing shared `parseTextInsets`. */
251
+ function parseTableCellPadding(style, path) {
252
+ try {
253
+ return parseTextInsets(style);
254
+ } catch (error) {
255
+ if (error instanceof CapabilityError && error.code === "invalid-text-insets") throw new CapabilityError("invalid-table-padding", error.message, path);
256
+ throw error;
257
+ }
258
+ }
259
+ /** Validates cell border width, style, and color via Zod schemas and shared theme color resolver. */
260
+ function parseTableCellBorder(style, resolveColor, theme, path) {
261
+ const borderColor = resolveColor(style["borderColor"], "borderColor", path);
262
+ const widthValue = style["borderWidth"];
263
+ const styleValue = style["borderStyle"];
264
+ if (widthValue !== void 0) {
265
+ if (!z.number().finite().nonnegative().safeParse(widthValue).success) throw new CapabilityError("invalid-table-border", "borderWidth must be a finite non-negative pixel number", path);
266
+ }
267
+ if (styleValue !== void 0) {
268
+ if (!tableBorderStyleSchema.safeParse(styleValue).success) throw new CapabilityError("invalid-table-border", "borderStyle must be solid, dashed, or dotted", path);
269
+ }
270
+ const width = typeof widthValue === "number" ? widthValue : borderColor === void 0 ? 0 : 1;
271
+ if (width === 0) return void 0;
272
+ assertTableEmuExtent(width, "borderWidth", path);
273
+ return {
274
+ color: borderColor ?? theme.resolveColor("dk1"),
275
+ width,
276
+ dash: styleValue === "dashed" ? "dash" : styleValue === "dotted" ? "dot" : "solid"
277
+ };
278
+ }
279
+ export { assertAllowedTableKeys, assertTableEmuExtent, cellAllowedParameters, cellDeclarationPropsSchema, cellStyleKeys, graphicFrameLocksXmlSchema, nonVisualGraphicFrameIdSchema, parseOptionalTableId, parseTableCellBorder, parseTableCellPadding, parseTableColumns, parseTableCoordinate, parseTableMergeSpan, parseTablePositiveSize, parseTableVerticalAlign, rowAllowedParameters, rowDeclarationPropsSchema, rowStyleKeys, tableAllowedParameters, tableBorderStyleSchema, tableCellStyleSchema, tableColumnSchema, tableDeclarationPropsSchema, tableMergeSpanSchema, tableRowStyleSchema, tableStyleKeys, tableStyleSchema, tableTextStyleKeys, tableVerticalAlignSchema, tblCellPrXmlSchema, tblCellXmlSchema, tblGridColXmlSchema, tblPrXmlSchema, tblRowXmlSchema };
@@ -0,0 +1,37 @@
1
+ import { placeholderRefXml, pxToEmu, resolvedColorXml, xmlEscape } from "../../../emit/dist/ooxml.js";
2
+ import "../../../emit/dist/index.js";
3
+ // ../capabilities/dist/table/table-xml.js
4
+ const tableUri = "http://schemas.openxmlformats.org/drawingml/2006/table";
5
+ function fillXml(value) {
6
+ return value === void 0 ? "<a:noFill/>" : `<a:solidFill>${resolvedColorXml(value)}</a:solidFill>`;
7
+ }
8
+ function lineXml(side, border) {
9
+ if (border === void 0) return `<a:ln${side}><a:noFill/></a:ln${side}>`;
10
+ const width = Math.max(1, pxToEmu(border.width));
11
+ const dash = border.dash === "solid" ? "" : `<a:prstDash val="${border.dash}"/>`;
12
+ return `<a:ln${side} w="${width}"><a:solidFill>${resolvedColorXml(border.color)}</a:solidFill>${dash}</a:ln${side}>`;
13
+ }
14
+ /** Writes the resolved cell margins, vertical anchor, borders, and fill into a:tcPr. */
15
+ function tableCellPropertiesXml(padding, vertical, border, fill) {
16
+ const lines = [
17
+ "L",
18
+ "R",
19
+ "T",
20
+ "B"
21
+ ].map((side) => lineXml(side, border)).join("");
22
+ const anchor = vertical === "middle" ? "ctr" : vertical === "bottom" ? "b" : "t";
23
+ return `<a:tcPr marL="${pxToEmu(padding.left)}" marR="${pxToEmu(padding.right)}" marT="${pxToEmu(padding.top)}" marB="${pxToEmu(padding.bottom)}" anchor="${anchor}">${lines}${fillXml(fill)}</a:tcPr>`;
24
+ }
25
+ /** Writes an empty continuation cell covered by a merged cell. */
26
+ function emptyTableCellXml(lang) {
27
+ return `<a:txBody><a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr${lang !== void 0 ? ` lang="${xmlEscape(lang)}"` : ""}/></a:p></a:txBody><a:tcPr/>`;
28
+ }
29
+ /** Writes the native graphicFrame and a:tbl once the capability has resolved tracks and cell bodies. */
30
+ function tableFrameXml(id, escapedName, x, y, widths, heights, rows, linkXml, placeholder) {
31
+ const columnXml = widths.map((width) => `<a:gridCol w="${pxToEmu(width)}"/>`).join("");
32
+ const rowXml = rows.map((cells, row) => `<a:tr h="${pxToEmu(heights[row])}">${cells}</a:tr>`).join("");
33
+ const width = widths.reduce((sum, value) => sum + pxToEmu(value), 0);
34
+ const height = heights.reduce((sum, value) => sum + pxToEmu(value), 0);
35
+ return `<p:graphicFrame><p:nvGraphicFramePr><p:cNvPr id="${id}" name="${escapedName}">${linkXml}</p:cNvPr>${placeholder === void 0 ? "<p:cNvGraphicFramePr/>" : "<p:cNvGraphicFramePr><a:graphicFrameLocks noGrp=\"1\"/></p:cNvGraphicFramePr>"}${placeholder === void 0 ? "<p:nvPr/>" : `<p:nvPr>${placeholderRefXml(placeholder)}</p:nvPr>`}</p:nvGraphicFramePr><p:xfrm><a:off x="${pxToEmu(x)}" y="${pxToEmu(y)}"/><a:ext cx="${width}" cy="${height}"/></p:xfrm><a:graphic><a:graphicData uri="${tableUri}"><a:tbl><a:tblPr/><a:tblGrid>${columnXml}</a:tblGrid>${rowXml}</a:tbl></a:graphicData></a:graphic></p:graphicFrame>`;
36
+ }
37
+ export { emptyTableCellXml, tableCellPropertiesXml, tableFrameXml };