@officedk/pptxdk 0.0.0-stage → 0.2.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 (206) hide show
  1. package/LICENSE +21 -0
  2. package/dist/build-zrZuX4fK.d.ts +3 -0
  3. package/dist/build.d.ts +35 -0
  4. package/dist/build.js +128 -0
  5. package/dist/capabilities/dist/all.js +34 -0
  6. package/dist/capabilities/dist/box/box-codegen.js +84 -0
  7. package/dist/capabilities/dist/box/box-declaration.js +32 -0
  8. package/dist/capabilities/dist/box/box-elements.js +17 -0
  9. package/dist/capabilities/dist/box/box.js +142 -0
  10. package/dist/capabilities/dist/chart/chart-codegen.js +79 -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 +2403 -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 +1088 -0
  17. package/dist/capabilities/dist/chart/chart-xml.js +788 -0
  18. package/dist/capabilities/dist/chart/chart.js +1119 -0
  19. package/dist/capabilities/dist/chart/preview/axes-and-grid.js +311 -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 +192 -0
  24. package/dist/capabilities/dist/chart/preview/layout.js +592 -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 +60 -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 +168 -0
  37. package/dist/capabilities/dist/font/font-embedding.js +119 -0
  38. package/dist/capabilities/dist/font/font-engine.js +834 -0
  39. package/dist/capabilities/dist/font/font-import.js +766 -0
  40. package/dist/capabilities/dist/font/font-subset.js +55 -0
  41. package/dist/capabilities/dist/font/font.js +72 -0
  42. package/dist/capabilities/dist/group/group-codegen.js +74 -0
  43. package/dist/capabilities/dist/group/group-declaration.js +41 -0
  44. package/dist/capabilities/dist/group/group-elements.js +12 -0
  45. package/dist/capabilities/dist/group/group-import.js +649 -0
  46. package/dist/capabilities/dist/group/group-xml.js +8 -0
  47. package/dist/capabilities/dist/group/group.js +260 -0
  48. package/dist/capabilities/dist/image/gif-decoder.js +244 -0
  49. package/dist/capabilities/dist/image/image-codegen.js +164 -0
  50. package/dist/capabilities/dist/image/image-declaration.js +8 -0
  51. package/dist/capabilities/dist/image/image-decode.js +244 -0
  52. package/dist/capabilities/dist/image/image-elements.js +12 -0
  53. package/dist/capabilities/dist/image/image-import.js +984 -0
  54. package/dist/capabilities/dist/image/image-schemas.js +147 -0
  55. package/dist/capabilities/dist/image/image-xml.js +12 -0
  56. package/dist/capabilities/dist/image/image.js +552 -0
  57. package/dist/capabilities/dist/line/line-codegen.js +89 -0
  58. package/dist/capabilities/dist/line/line-declaration.js +72 -0
  59. package/dist/capabilities/dist/line/line-elements.js +12 -0
  60. package/dist/capabilities/dist/line/line-import.js +504 -0
  61. package/dist/capabilities/dist/line/line-xml.js +9 -0
  62. package/dist/capabilities/dist/line/line.js +331 -0
  63. package/dist/capabilities/dist/masters/footer-placeholder.js +683 -0
  64. package/dist/capabilities/dist/masters/masters-codegen.js +69 -0
  65. package/dist/capabilities/dist/masters/masters.js +250 -0
  66. package/dist/capabilities/dist/motion/motion-api.js +757 -0
  67. package/dist/capabilities/dist/motion/motion-codegen.js +406 -0
  68. package/dist/capabilities/dist/motion/motion-elements.js +43 -0
  69. package/dist/capabilities/dist/motion/motion-import.js +1568 -0
  70. package/dist/capabilities/dist/motion/motion-plan.js +2340 -0
  71. package/dist/capabilities/dist/motion/motion-query.js +423 -0
  72. package/dist/capabilities/dist/motion/motion-schemas.js +339 -0
  73. package/dist/capabilities/dist/motion/motion.js +1617 -0
  74. package/dist/capabilities/dist/notes/notes-codegen.js +19 -0
  75. package/dist/capabilities/dist/notes/notes-declaration.js +8 -0
  76. package/dist/capabilities/dist/notes/notes-elements.js +12 -0
  77. package/dist/capabilities/dist/notes/notes-import.js +292 -0
  78. package/dist/capabilities/dist/notes/notes-schemas.js +38 -0
  79. package/dist/capabilities/dist/notes/notes-xml.js +38 -0
  80. package/dist/capabilities/dist/notes/notes.js +194 -0
  81. package/dist/capabilities/dist/placeholder/placeholder-codegen.js +54 -0
  82. package/dist/capabilities/dist/placeholder/placeholder-elements.js +13 -0
  83. package/dist/capabilities/dist/placeholder/placeholder-schemas.js +33 -0
  84. package/dist/capabilities/dist/placeholder/placeholder.js +451 -0
  85. package/dist/capabilities/dist/shape/shape-codegen.js +236 -0
  86. package/dist/capabilities/dist/shape/shape-declaration.js +45 -0
  87. package/dist/capabilities/dist/shape/shape-elements.js +12 -0
  88. package/dist/capabilities/dist/shape/shape-import.js +628 -0
  89. package/dist/capabilities/dist/shape/shape-xml.js +6 -0
  90. package/dist/capabilities/dist/shape/shape.js +320 -0
  91. package/dist/capabilities/dist/shared/geometry.js +1681 -0
  92. package/dist/capabilities/dist/shared/identity.js +205 -0
  93. package/dist/capabilities/dist/shared/morph-api.js +11 -0
  94. package/dist/capabilities/dist/shared/placeholder-import.js +238 -0
  95. package/dist/capabilities/dist/shared/preset-definitions.js +22423 -0
  96. package/dist/capabilities/dist/shared/style-inheritance.js +161 -0
  97. package/dist/capabilities/dist/shared/text-schemas.js +241 -0
  98. package/dist/capabilities/dist/shared/text-service.js +2252 -0
  99. package/dist/capabilities/dist/shared/visual.js +1197 -0
  100. package/dist/capabilities/dist/slide-background/slide-background-codegen.js +44 -0
  101. package/dist/capabilities/dist/slide-background/slide-background-import.js +166 -0
  102. package/dist/capabilities/dist/slide-background/slide-background-xml.js +34 -0
  103. package/dist/capabilities/dist/slide-background/slide-background.js +238 -0
  104. package/dist/capabilities/dist/table/table-codegen.js +125 -0
  105. package/dist/capabilities/dist/table/table-declaration.js +15 -0
  106. package/dist/capabilities/dist/table/table-elements.js +27 -0
  107. package/dist/capabilities/dist/table/table-import.js +606 -0
  108. package/dist/capabilities/dist/table/table-schemas.js +334 -0
  109. package/dist/capabilities/dist/table/table-xml.js +30 -0
  110. package/dist/capabilities/dist/table/table.js +739 -0
  111. package/dist/capabilities/dist/text/text-codegen.js +198 -0
  112. package/dist/capabilities/dist/text/text-declaration.js +27 -0
  113. package/dist/capabilities/dist/text/text-elements.js +54 -0
  114. package/dist/capabilities/dist/text/text-import.js +1224 -0
  115. package/dist/capabilities/dist/text/text-xml.js +9 -0
  116. package/dist/capabilities/dist/text/text.js +320 -0
  117. package/dist/capabilities/dist/transition/transition-api.js +136 -0
  118. package/dist/capabilities/dist/transition/transition-codegen.js +45 -0
  119. package/dist/capabilities/dist/transition/transition-import.js +477 -0
  120. package/dist/capabilities/dist/transition/transition.js +260 -0
  121. package/dist/capability-BbKW9w4O.d.ts +2131 -0
  122. package/dist/cli.js +20 -0
  123. package/dist/codegen/dist/assets.js +79 -0
  124. package/dist/codegen/dist/codegen.js +691 -0
  125. package/dist/codegen/dist/identifiers.js +203 -0
  126. package/dist/codegen/dist/index.js +3 -0
  127. package/dist/codegen/dist/printer.js +143 -0
  128. package/dist/codegen/dist/types.js +77 -0
  129. package/dist/core/dist/author-ids.js +51 -0
  130. package/dist/core/dist/author-schemas.js +330 -0
  131. package/dist/core/dist/block-flex-layout.js +801 -0
  132. package/dist/core/dist/build.js +4 -0
  133. package/dist/core/dist/capability.js +15 -0
  134. package/dist/core/dist/declaration.js +16 -0
  135. package/dist/core/dist/diagnostics.js +353 -0
  136. package/dist/core/dist/document-internals.js +26 -0
  137. package/dist/core/dist/document.js +417 -0
  138. package/dist/core/dist/font-seal.js +204 -0
  139. package/dist/core/dist/geometry-schemas.js +256 -0
  140. package/dist/core/dist/grid-layout.js +449 -0
  141. package/dist/core/dist/host.js +40 -0
  142. package/dist/core/dist/index.js +15 -0
  143. package/dist/core/dist/input-values.js +61 -0
  144. package/dist/core/dist/layout-protocol.js +61 -0
  145. package/dist/core/dist/layout-schemas.js +201 -0
  146. package/dist/core/dist/layout.js +340 -0
  147. package/dist/core/dist/masters.js +194 -0
  148. package/dist/core/dist/morph.js +30 -0
  149. package/dist/core/dist/placeholders.js +275 -0
  150. package/dist/core/dist/query.js +190 -0
  151. package/dist/core/dist/resolution.js +12 -0
  152. package/dist/core/dist/resolve.js +2246 -0
  153. package/dist/core/dist/stage-options.js +300 -0
  154. package/dist/core/dist/theme.js +1023 -0
  155. package/dist/core/dist/transform-geometry.js +72 -0
  156. package/dist/document-41spD7bq.d.ts +1350 -0
  157. package/dist/emit/dist/emit.js +957 -0
  158. package/dist/emit/dist/index.js +5 -0
  159. package/dist/emit/dist/ooxml.js +661 -0
  160. package/dist/emit/dist/shape-tree.js +12 -0
  161. package/dist/import/dist/alternate-content.js +54 -0
  162. package/dist/import/dist/diagnostics.js +157 -0
  163. package/dist/import/dist/fonts.js +309 -0
  164. package/dist/import/dist/import.js +513 -0
  165. package/dist/import/dist/index.js +16 -0
  166. package/dist/import/dist/masters.js +1293 -0
  167. package/dist/import/dist/mechanism.js +10 -0
  168. package/dist/import/dist/namespaces.js +61 -0
  169. package/dist/import/dist/notes-masters.js +300 -0
  170. package/dist/import/dist/opc.js +233 -0
  171. package/dist/import/dist/resources.js +166 -0
  172. package/dist/import/dist/sections.js +139 -0
  173. package/dist/import/dist/themes.js +777 -0
  174. package/dist/import/dist/visual.js +821 -0
  175. package/dist/import/dist/xml-fragments.js +277 -0
  176. package/dist/import/dist/xml-reader.js +267 -0
  177. package/dist/index-1ag7U9Jt.d.ts +63 -0
  178. package/dist/index-BEwhk7c8.d.ts +72 -0
  179. package/dist/index-cK2KtukZ.d.ts +161 -0
  180. package/dist/index-v77CTJev.d.ts +55 -0
  181. package/dist/index.d.ts +8 -0
  182. package/dist/index.js +82 -0
  183. package/dist/node.d.ts +53 -0
  184. package/dist/node.js +225 -0
  185. package/dist/pptxdk/src/cli-commands.js +907 -0
  186. package/dist/pptxdk/src/compose.js +53 -0
  187. package/dist/pptxdk/src/slide.js +9 -0
  188. package/dist/preview/dist/index.js +342 -0
  189. package/dist/preview/dist/options.js +40 -0
  190. package/dist/preview/dist/svg-guard.js +1089 -0
  191. package/dist/preview.d.ts +12 -0
  192. package/dist/preview.js +29 -0
  193. package/dist/react/dist/append.js +66 -0
  194. package/dist/react/dist/document-adapter.js +404 -0
  195. package/dist/react/dist/elements.js +82 -0
  196. package/dist/react/dist/from-vanilla.js +57 -0
  197. package/dist/react/dist/index.js +89 -0
  198. package/dist/react/dist/mount.js +34 -0
  199. package/dist/react/dist/reconciler.js +290 -0
  200. package/dist/react.d.ts +235 -0
  201. package/dist/react.js +31 -0
  202. package/dist/transition-6n8GZxSg.d.ts +9 -0
  203. package/dist/vanilla.d.ts +4 -0
  204. package/dist/vanilla.js +15 -0
  205. package/package.json +79 -3
  206. package/README.md +0 -3
@@ -0,0 +1,334 @@
1
+ import { CapabilityError } from "../../../core/dist/diagnostics.js";
2
+ import { layoutStyleShape } from "../../../core/dist/layout-schemas.js";
3
+ import { backgroundValueSchema, borderValueSchema, textStyleShape, validateTextStyle } from "../../../core/dist/theme.js";
4
+ import { nativePlaceholderRefSchema } from "../../../core/dist/placeholders.js";
5
+ import { linkTargetSchema } from "../../../core/dist/author-schemas.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, ooxmlWritablePositiveExtentEmuSchema } from "../../../import/dist/xml-fragments.js";
11
+ import { motionPropsShape } 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
+ const rawTableColumnSchema = z.union([
27
+ tableColumnPxSchema,
28
+ tableColumnFrSchema,
29
+ z.literal("auto")
30
+ ]);
31
+ /** Column width in px; Nfr allocates from remaining width, auto uses shared font measurement. */
32
+ const tableColumnSchema = rawTableColumnSchema;
33
+ const tableTextStyleObjectSchema = z.strictObject({
34
+ fontFamily: textStyleShape.fontFamily,
35
+ eastAsianFontFamily: textStyleShape.eastAsianFontFamily,
36
+ fontSize: textStyleShape.fontSize,
37
+ fontWeight: textStyleShape.fontWeight,
38
+ fontStyle: textStyleShape.fontStyle,
39
+ color: textStyleShape.color,
40
+ lineHeight: textStyleShape.lineHeight,
41
+ align: textStyleShape.align,
42
+ verticalAlign: textStyleShape.verticalAlign,
43
+ letterSpacing: textStyleShape.letterSpacing,
44
+ textTransform: textStyleShape.textTransform,
45
+ textDecoration: textStyleShape.textDecoration,
46
+ textShadow: textStyleShape.textShadow,
47
+ lang: textStyleShape.lang
48
+ });
49
+ tableTextStyleObjectSchema.readonly();
50
+ const tableStyleObjectSchema = z.strictObject({
51
+ ...tableTextStyleObjectSchema.shape,
52
+ ...layoutStyleShape,
53
+ background: backgroundValueSchema.optional(),
54
+ border: borderValueSchema.optional(),
55
+ borderTop: borderValueSchema.optional(),
56
+ borderRight: borderValueSchema.optional(),
57
+ borderBottom: borderValueSchema.optional(),
58
+ borderLeft: borderValueSchema.optional()
59
+ });
60
+ const rawTableStyleSchema = tableStyleObjectSchema.readonly();
61
+ const tableStyleSchema = rawTableStyleSchema;
62
+ const tableRowOwnStyleObjectSchema = z.strictObject({
63
+ /** When unspecified, row height is determined from text measurement of unmerged cells in this row. */
64
+ height: textPositiveSizeSchema.optional(),
65
+ background: backgroundValueSchema.optional(),
66
+ border: borderValueSchema.optional(),
67
+ borderTop: borderValueSchema.optional(),
68
+ borderRight: borderValueSchema.optional(),
69
+ borderBottom: borderValueSchema.optional(),
70
+ borderLeft: borderValueSchema.optional()
71
+ });
72
+ const rawTableRowStyleSchema = z.strictObject({
73
+ ...tableTextStyleObjectSchema.shape,
74
+ ...tableRowOwnStyleObjectSchema.shape
75
+ }).readonly();
76
+ const tableRowStyleSchema = rawTableRowStyleSchema;
77
+ const tableCellOwnStyleObjectSchema = z.strictObject({
78
+ background: backgroundValueSchema.optional(),
79
+ border: borderValueSchema.optional(),
80
+ borderTop: borderValueSchema.optional(),
81
+ borderRight: borderValueSchema.optional(),
82
+ borderBottom: borderValueSchema.optional(),
83
+ borderLeft: borderValueSchema.optional(),
84
+ padding: textPaddingValueSchema.optional(),
85
+ paddingTop: z.number().finite().nonnegative().optional(),
86
+ paddingRight: z.number().finite().nonnegative().optional(),
87
+ paddingBottom: z.number().finite().nonnegative().optional(),
88
+ paddingLeft: z.number().finite().nonnegative().optional()
89
+ });
90
+ const tableCellStyleObjectSchema = z.strictObject({
91
+ ...tableTextStyleObjectSchema.shape,
92
+ ...tableCellOwnStyleObjectSchema.shape
93
+ });
94
+ const rawTableCellStyleSchema = tableCellStyleObjectSchema.readonly();
95
+ const tableCellStyleSchema = rawTableCellStyleSchema;
96
+ const tableMergeSpanSchema = z.number().int().min(1);
97
+ const tableDeclarationPropsObjectSchema = z.strictObject({
98
+ id: optionalNameSchema.optional(),
99
+ name: optionalNameSchema.optional(),
100
+ placeholder: z.string().optional(),
101
+ nativePlaceholder: nativePlaceholderRefSchema.optional(),
102
+ morphKey: morphKeySchema.optional(),
103
+ link: linkTargetSchema.optional(),
104
+ columns: z.array(rawTableColumnSchema).nonempty().readonly(),
105
+ style: rawTableStyleSchema.optional(),
106
+ ...motionPropsShape
107
+ });
108
+ tableDeclarationPropsObjectSchema.readonly();
109
+ const rowDeclarationPropsObjectSchema = z.strictObject({
110
+ id: optionalNameSchema.optional(),
111
+ style: rawTableRowStyleSchema.optional()
112
+ });
113
+ rowDeclarationPropsObjectSchema.readonly();
114
+ const cellDeclarationPropsObjectSchema = z.strictObject({
115
+ id: optionalNameSchema.optional(),
116
+ colSpan: tableMergeSpanSchema.optional(),
117
+ rowSpan: tableMergeSpanSchema.optional(),
118
+ style: rawTableCellStyleSchema.optional()
119
+ });
120
+ cellDeclarationPropsObjectSchema.readonly();
121
+ const tableDeclarationAllowedPropKeys = Object.keys(tableDeclarationPropsObjectSchema.shape);
122
+ const tableAllowedParameters = [...tableDeclarationAllowedPropKeys, "children"];
123
+ const rowAllowedParameters = Object.keys(rowDeclarationPropsObjectSchema.shape);
124
+ const cellAllowedParameters = Object.keys(cellDeclarationPropsObjectSchema.shape);
125
+ const tableTextStyleKeys = Object.keys(tableTextStyleObjectSchema.shape);
126
+ const tableStyleKeys = Object.keys(tableStyleObjectSchema.shape);
127
+ const rowStyleKeys = Object.keys(tableRowOwnStyleObjectSchema.shape);
128
+ const cellStyleKeys = Object.keys(tableCellOwnStyleObjectSchema.shape);
129
+ const tableCellAllStyleKeys = Object.keys(tableCellStyleObjectSchema.shape);
130
+ /** OOXML `<p:cNvPr>` attribute fragment schema inside `<p:graphicFrame>`. */
131
+ const nonVisualGraphicFrameIdSchema = z.object({
132
+ id: ooxmlNonNegativeIntSchema,
133
+ name: z.string().optional()
134
+ });
135
+ /** OOXML `<a:graphicFrameLocks>` attribute fragment schema. */
136
+ const graphicFrameLocksXmlSchema = z.object({
137
+ noGrp: ooxmlBoolSchema.optional(),
138
+ noDrilldown: ooxmlBoolSchema.optional(),
139
+ noSelect: ooxmlBoolSchema.optional(),
140
+ noChangeAspect: ooxmlBoolSchema.optional(),
141
+ noMove: ooxmlBoolSchema.optional(),
142
+ noResize: ooxmlBoolSchema.optional()
143
+ });
144
+ /** OOXML `<a:tblPr>` attribute fragment schema. */
145
+ const tblPrXmlSchema = z.object({
146
+ firstRow: ooxmlBoolSchema.optional(),
147
+ firstCol: ooxmlBoolSchema.optional(),
148
+ lastRow: ooxmlBoolSchema.optional(),
149
+ lastCol: ooxmlBoolSchema.optional(),
150
+ bandRow: ooxmlBoolSchema.optional(),
151
+ bandCol: ooxmlBoolSchema.optional(),
152
+ rtl: ooxmlBoolSchema.optional()
153
+ });
154
+ /** OOXML `<a:gridCol w="..."/>` fragment schema bounded to `1 .. 2_147_483_647` EMU. */
155
+ const tblGridColXmlSchema = z.object({ w: ooxmlWritablePositiveExtentEmuSchema });
156
+ /** OOXML `<a:tr h="..."/>` fragment schema bounded to `1 .. 2_147_483_647` EMU. */
157
+ const tblRowXmlSchema = z.object({ h: ooxmlWritablePositiveExtentEmuSchema });
158
+ /** OOXML `<a:tc gridSpan="..." rowSpan="..." hMerge="..." vMerge="..."/>` fragment schema. */
159
+ const tblCellXmlSchema = z.object({
160
+ gridSpan: ooxmlPositiveIntSchema.optional(),
161
+ rowSpan: ooxmlPositiveIntSchema.optional(),
162
+ hMerge: ooxmlBoolSchema.optional(),
163
+ vMerge: ooxmlBoolSchema.optional()
164
+ });
165
+ /** OOXML `<a:tcPr .../>` non-margin attribute fragment schema. */
166
+ const tblCellPrXmlSchema = z.object({
167
+ anchor: z.enum([
168
+ "t",
169
+ "ctr",
170
+ "b"
171
+ ]).optional(),
172
+ vert: z.string().optional(),
173
+ horzOverflow: z.string().optional(),
174
+ anchorCtr: ooxmlBoolSchema.optional()
175
+ });
176
+ /** Validates a plain object parameter map against allowed parameter keys. */
177
+ function assertAllowedTableKeys(value, allowed, label, path) {
178
+ const unknown = Object.keys(value).find((key) => !allowed.includes(key));
179
+ if (unknown !== void 0) throw new CapabilityError("unknown-parameter", `${label} contains unsupported parameter ${unknown}`, path);
180
+ }
181
+ /** Validates an optional non-empty author ID on Row or Cell. */
182
+ function parseOptionalTableId(value, path) {
183
+ if (value === void 0) return void 0;
184
+ const parsed = optionalNameSchema.safeParse(value);
185
+ if (!parsed.success) throw new CapabilityError("invalid-parameter", "id must be a non-empty string", path);
186
+ return parsed.data;
187
+ }
188
+ /** Validates table coordinate (`x` or `y`) via shared coordinate schema, defaulting omitted to `0`. */
189
+ function parseTableCoordinate(value, label) {
190
+ if (value === void 0) return 0;
191
+ const parsed = textCoordinateSchema.safeParse(value);
192
+ if (!parsed.success) throw new CapabilityError("invalid-table-geometry", `${label} must be a finite pixel number between -1000000 and 1000000`);
193
+ return parsed.data;
194
+ }
195
+ /** Validates positive pixel extent (`width` or `Row.style.height`) via shared positive size schema. */
196
+ function parseTablePositiveSize(value, label, path) {
197
+ if (typeof value === "number" && Number.isFinite(value)) {
198
+ if (value === 0 || pxToEmu(value) === 0) throw new CapabilityError("invalid-table-geometry", `Computed ${label} is 0px; ${label} must be greater than 0px`, path);
199
+ if (value < 0 || pxToEmu(value) < 1) throw new CapabilityError("invalid-table-geometry", `Computed ${label} is ${value}px; ${label} must be greater than 0px`, path);
200
+ } else throw new CapabilityError("invalid-table-geometry", `${label} must be a finite positive pixel number`, path);
201
+ const parsed = textPositiveSizeSchema.safeParse(value);
202
+ if (!parsed.success) throw new CapabilityError("invalid-table-geometry", `${label} exceeds writable table dimension range after conversion`, path);
203
+ return parsed.data;
204
+ }
205
+ /** Validates EMU extent bounds for resolved table tracks and borders. */
206
+ function assertTableEmuExtent(value, label, path) {
207
+ const emu = pxToEmu(value);
208
+ if (Number.isFinite(value) && (value === 0 || emu === 0)) throw new CapabilityError("invalid-table-geometry", `Computed ${label} is 0px; ${label} must be greater than 0px`, path);
209
+ if (Number.isFinite(value) && (value < 0 || emu < 1)) throw new CapabilityError("invalid-table-geometry", `Computed ${label} is ${value}px; ${label} must be greater than 0px`, path);
210
+ if (!Number.isSafeInteger(emu) || 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 a single unified `BorderValue` (`"none"` or `{ color, width?, style? }`) on Table, Row, or Cell. */
260
+ function parseTableBorderValue(value, label, theme, path) {
261
+ if (value === "none") return void 0;
262
+ const parsed = borderValueSchema.safeParse(value);
263
+ if (!parsed.success || parsed.data === "none") {
264
+ const issue = parsed.success ? void 0 : parsed.error.issues[0];
265
+ throw new CapabilityError("invalid-table-border", issue?.message ?? `${label} must be "none" or { color, width?, style? }`, path);
266
+ }
267
+ const width = parsed.data.width ?? 1;
268
+ if (width === 0) return void 0;
269
+ assertTableEmuExtent(width, `${label}.width`, path);
270
+ let resolvedColor;
271
+ try {
272
+ resolvedColor = theme.resolveColor(parsed.data.color);
273
+ } catch (error) {
274
+ if (error instanceof CapabilityError) throw new CapabilityError(error.code, `${label}.color: ${error.message}`, path);
275
+ throw error;
276
+ }
277
+ return {
278
+ color: resolvedColor,
279
+ width,
280
+ dash: parsed.data.style === "dashed" ? "dash" : parsed.data.style === "dotted" ? "dot" : "solid"
281
+ };
282
+ }
283
+ /** Validates optional `align` on Table, Row, or Cell using shared core text style validation. */
284
+ function assertTableTextAlignment(align, path) {
285
+ if (align === void 0) return;
286
+ try {
287
+ validateTextStyle({ align });
288
+ } catch (error) {
289
+ if (error instanceof CapabilityError) throw new CapabilityError(error.code, error.message, path);
290
+ throw error;
291
+ }
292
+ }
293
+ const tableBorderSideEntries = [
294
+ ["borderTop", "top"],
295
+ ["borderRight", "right"],
296
+ ["borderBottom", "bottom"],
297
+ ["borderLeft", "left"]
298
+ ];
299
+ /**
300
+ * Resolves 4-side borders for a Table, Row, or Cell layer by applying `border` shorthand
301
+ * then individual `borderTop`/`borderRight`/`borderBottom`/`borderLeft` overrides over inherited borders.
302
+ */
303
+ function resolveTableLayerBorders(style, inherited, label, theme, path) {
304
+ let top = inherited.top;
305
+ let right = inherited.right;
306
+ let bottom = inherited.bottom;
307
+ let left = inherited.left;
308
+ if (Object.hasOwn(style, "border") && style["border"] !== void 0) {
309
+ const baseBorder = parseTableBorderValue(style["border"], `${label}.style.border`, theme, path);
310
+ top = baseBorder;
311
+ right = baseBorder;
312
+ bottom = baseBorder;
313
+ left = baseBorder;
314
+ }
315
+ for (const [sideKey, sideName] of tableBorderSideEntries) {
316
+ if (!Object.hasOwn(style, sideKey) || style[sideKey] === void 0) continue;
317
+ const sideValue = parseTableBorderValue(style[sideKey], `${label}.style.${sideKey}`, theme, path);
318
+ if (sideName === "top") top = sideValue;
319
+ else if (sideName === "right") right = sideValue;
320
+ else if (sideName === "bottom") bottom = sideValue;
321
+ else left = sideValue;
322
+ }
323
+ return {
324
+ ...top === void 0 ? {} : { top },
325
+ ...right === void 0 ? {} : { right },
326
+ ...bottom === void 0 ? {} : { bottom },
327
+ ...left === void 0 ? {} : { left }
328
+ };
329
+ }
330
+ /** Resolves final 4-side borders for a Cell by cascading Table -> Row -> Cell.border -> Cell.border{Side}. */
331
+ function resolveTableCellBorders(style, inheritedBorders, theme, path) {
332
+ return resolveTableLayerBorders(style, inheritedBorders, "Cell", theme, path);
333
+ }
334
+ export { assertAllowedTableKeys, assertTableEmuExtent, assertTableTextAlignment, cellAllowedParameters, cellStyleKeys, graphicFrameLocksXmlSchema, nonVisualGraphicFrameIdSchema, parseOptionalTableId, parseTableBorderValue, parseTableCellPadding, parseTableColumns, parseTableCoordinate, parseTableMergeSpan, parseTablePositiveSize, parseTableVerticalAlign, resolveTableCellBorders, resolveTableLayerBorders, rowAllowedParameters, rowStyleKeys, tableAllowedParameters, tableCellAllStyleKeys, tableCellStyleSchema, tableColumnSchema, tableDeclarationAllowedPropKeys, tableMergeSpanSchema, tableRowStyleSchema, tableStyleKeys, tableStyleSchema, tableTextStyleKeys, tableVerticalAlignSchema, tblCellPrXmlSchema, tblCellXmlSchema, tblGridColXmlSchema, tblPrXmlSchema, tblRowXmlSchema };
@@ -0,0 +1,30 @@
1
+ import { placeholderRefXml, pxToEmu, resolvedColorXml, xmlEscape } from "../../../emit/dist/ooxml.js";
2
+ import "../../../emit/dist/index.js";
3
+ import { emitFillXml } from "../shared/visual.js";
4
+ // ../capabilities/dist/table/table-xml.js
5
+ const tableUri = "http://schemas.openxmlformats.org/drawingml/2006/table";
6
+ function lineXml(side, border) {
7
+ if (border === void 0) return `<a:ln${side}><a:noFill/></a:ln${side}>`;
8
+ const width = Math.max(1, pxToEmu(border.width));
9
+ const dash = border.dash === "solid" ? "" : `<a:prstDash val="${border.dash}"/>`;
10
+ return `<a:ln${side} w="${width}"><a:solidFill>${resolvedColorXml(border.color)}</a:solidFill>${dash}</a:ln${side}>`;
11
+ }
12
+ /** Writes the resolved cell margins, vertical anchor, borders, and fill into a:tcPr. */
13
+ function tableCellPropertiesXml(padding, vertical, borders, fill, registerResource, box) {
14
+ const lines = lineXml("L", borders.left) + lineXml("R", borders.right) + lineXml("T", borders.top) + lineXml("B", borders.bottom);
15
+ const anchor = vertical === "middle" ? "ctr" : vertical === "bottom" ? "b" : "t";
16
+ return `<a:tcPr marL="${pxToEmu(padding.left)}" marR="${pxToEmu(padding.right)}" marT="${pxToEmu(padding.top)}" marB="${pxToEmu(padding.bottom)}" anchor="${anchor}">${lines}${emitFillXml(fill, registerResource, box)}</a:tcPr>`;
17
+ }
18
+ /** Writes an empty continuation cell covered by a merged cell. */
19
+ function emptyTableCellXml(lang) {
20
+ return `<a:txBody><a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr${lang !== void 0 ? ` lang="${xmlEscape(lang)}"` : ""}/></a:p></a:txBody><a:tcPr/>`;
21
+ }
22
+ /** Writes the native graphicFrame and a:tbl once the capability has resolved tracks and cell bodies. */
23
+ function tableFrameXml(id, escapedName, x, y, widths, heights, rows, linkXml, placeholder) {
24
+ const columnXml = widths.map((width) => `<a:gridCol w="${pxToEmu(width)}"/>`).join("");
25
+ const rowXml = rows.map((cells, row) => `<a:tr h="${pxToEmu(heights[row])}">${cells}</a:tr>`).join("");
26
+ const width = widths.reduce((sum, value) => sum + pxToEmu(value), 0);
27
+ const height = heights.reduce((sum, value) => sum + pxToEmu(value), 0);
28
+ 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>`;
29
+ }
30
+ export { emptyTableCellXml, tableCellPropertiesXml, tableFrameXml };