@officedk/pptxdk 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build.d.ts +14 -76
- package/dist/build.js +69 -97
- package/dist/cli.js +1 -1
- package/dist/core/dist/capabilities/audio/audio-declaration.js +7 -0
- package/dist/core/dist/capabilities/audio/audio-source.js +172 -0
- package/dist/core/dist/capabilities/audio/entry.js +122 -0
- package/dist/core/dist/capabilities/box/box-codegen.js +83 -0
- package/dist/core/dist/capabilities/box/box-declaration.js +32 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/box/box.js +32 -29
- package/dist/core/dist/capabilities/box/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-codegen.js +17 -22
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-import.js +1025 -471
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-labels.js +30 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-model.js +3 -3
- package/dist/{capabilities/dist/chart/preview/number-format.js → core/dist/capabilities/chart/chart-number-format.js} +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-schemas.js +216 -212
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-xml.js +41 -36
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart.js +228 -171
- package/dist/core/dist/capabilities/chart/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/axes-and-grid.js +23 -10
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/bar-column.js +1 -1
- package/dist/core/dist/capabilities/chart/preview/data-labels.js +474 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/error-bars.js +3 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/index.js +30 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/layout.js +160 -89
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/legend.js +4 -4
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/line-area.js +4 -4
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/markers.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/pie-doughnut.js +39 -60
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/scales.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/scatter.js +3 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/style.js +15 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/text-render.js +34 -24
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/trendlines.js +5 -5
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/types.js +1 -1
- package/dist/core/dist/capabilities/comment/comment-codegen.js +25 -0
- package/dist/core/dist/capabilities/comment/comment-declaration.js +37 -0
- package/dist/core/dist/capabilities/comment/comment-import.js +176 -0
- package/dist/core/dist/capabilities/comment/comment.js +141 -0
- package/dist/core/dist/capabilities/comment/entry.js +1 -0
- package/dist/core/dist/capabilities/footer-placeholder/entry.js +2 -0
- package/dist/core/dist/capabilities/footer-placeholder/footer-placeholder-codegen.js +16 -0
- package/dist/{capabilities/dist/masters → core/dist/capabilities/footer-placeholder}/footer-placeholder.js +194 -133
- package/dist/core/dist/capabilities/footer-placeholder/print-header-footer-import.js +121 -0
- package/dist/core/dist/capabilities/footer-placeholder/print-header-footer.js +123 -0
- package/dist/core/dist/capabilities/group/entry.js +2 -0
- package/dist/core/dist/capabilities/group/group-codegen.js +73 -0
- package/dist/core/dist/capabilities/group/group-declaration.js +41 -0
- package/dist/core/dist/capabilities/group/group-import.js +608 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-xml.js +4 -3
- package/dist/core/dist/capabilities/group/group.js +260 -0
- package/dist/core/dist/capabilities/image/entry.js +4 -0
- package/dist/core/dist/capabilities/image/image-codegen.js +59 -0
- package/dist/core/dist/capabilities/image/image-declaration.js +8 -0
- package/dist/core/dist/capabilities/image/image-import.js +26 -0
- package/dist/core/dist/capabilities/image/image.js +57 -0
- package/dist/core/dist/capabilities/line/entry.js +3 -0
- package/dist/core/dist/capabilities/line/line-codegen.js +88 -0
- package/dist/core/dist/capabilities/line/line-declaration.js +78 -0
- package/dist/core/dist/capabilities/line/line-import.js +424 -0
- package/dist/core/dist/capabilities/line/line-xml.js +9 -0
- package/dist/core/dist/capabilities/line/line.js +329 -0
- package/dist/core/dist/capabilities/masters/entry.js +1 -0
- package/dist/core/dist/capabilities/masters/masters-codegen.js +50 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/masters/masters.js +35 -47
- package/dist/core/dist/capabilities/motion/entry.js +5 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-codegen.js +97 -51
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-import.js +653 -102
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-plan.js +317 -163
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-query.js +9 -6
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion.js +357 -108
- package/dist/core/dist/capabilities/notes/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-codegen.js +5 -7
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-import.js +16 -13
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-schemas.js +12 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes.js +20 -42
- package/dist/{import/dist/sections.js → core/dist/capabilities/notes/sections-import.js} +5 -5
- package/dist/core/dist/capabilities/placeholder/entry.js +3 -0
- package/dist/core/dist/capabilities/placeholder/placeholder-codegen.js +44 -0
- package/dist/core/dist/capabilities/placeholder/placeholder-schemas.js +31 -0
- package/dist/core/dist/capabilities/placeholder/placeholder.js +394 -0
- package/dist/core/dist/capabilities/shape/entry.js +6 -0
- package/dist/core/dist/capabilities/shape/shape-codegen.js +112 -0
- package/dist/core/dist/capabilities/shape/shape-import.js +152 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shape/shape-xml.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/shape/shape.js +100 -103
- package/dist/core/dist/capabilities/shared/container-slots.js +59 -0
- package/dist/core/dist/capabilities/shared/date-time.js +98 -0
- package/dist/core/dist/capabilities/shared/font/font-embedding.js +118 -0
- package/dist/core/dist/capabilities/shared/font/font-engine.js +855 -0
- package/dist/core/dist/capabilities/shared/font/font-import.js +805 -0
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-subset.js +24 -9
- package/dist/core/dist/capabilities/shared/font/font.js +72 -0
- package/dist/{capabilities/dist/shape/shape-codegen.js → core/dist/capabilities/shared/geometry-codegen.js} +4 -69
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/geometry.js +384 -123
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/identity.js +56 -38
- package/dist/core/dist/capabilities/shared/image-codegen.js +94 -0
- package/dist/{capabilities/dist/image → core/dist/capabilities/shared}/image-decode.js +17 -56
- package/dist/{capabilities/dist/image → core/dist/capabilities/shared}/image-schemas.js +49 -61
- package/dist/core/dist/capabilities/shared/line-match.js +78 -0
- package/dist/core/dist/capabilities/shared/media-codegen.js +86 -0
- package/dist/core/dist/capabilities/shared/media-import.js +156 -0
- package/dist/core/dist/capabilities/shared/media-placement.js +20 -0
- package/dist/core/dist/capabilities/shared/media-poster.js +50 -0
- package/dist/core/dist/capabilities/shared/media-schemas.js +60 -0
- package/dist/core/dist/capabilities/shared/media-source.js +107 -0
- package/dist/core/dist/capabilities/shared/media-trim.js +102 -0
- package/dist/core/dist/capabilities/shared/media.js +134 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/morph-api.js +5 -5
- package/dist/core/dist/capabilities/shared/motion-api.js +770 -0
- package/dist/core/dist/capabilities/shared/motion-schemas.js +353 -0
- package/dist/{capabilities/dist/image/image-import.js → core/dist/capabilities/shared/picture-import.js} +313 -168
- package/dist/core/dist/capabilities/shared/picture-xml.js +13 -0
- package/dist/core/dist/capabilities/shared/picture.js +510 -0
- package/dist/core/dist/capabilities/shared/placeholder-import.js +268 -0
- package/dist/core/dist/capabilities/shared/placeholder-roles.js +42 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/preset-definitions.js +1221 -188
- package/dist/core/dist/capabilities/shared/print-xml.js +77 -0
- package/dist/core/dist/capabilities/shared/rich-text-codegen.js +119 -0
- package/dist/core/dist/capabilities/shared/rich-text-import.js +472 -0
- package/dist/core/dist/capabilities/shared/shape-declaration.js +45 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/style-inheritance.js +26 -24
- package/dist/core/dist/capabilities/shared/text-declaration.js +31 -0
- package/dist/core/dist/capabilities/shared/text-schemas.js +241 -0
- package/dist/core/dist/capabilities/shared/text-service.js +2563 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/visual.js +441 -137
- package/dist/core/dist/capabilities/slide-background/entry.js +1 -0
- package/dist/core/dist/capabilities/slide-background/slide-background-codegen.js +15 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background-import.js +12 -7
- package/dist/core/dist/capabilities/slide-background/slide-background-xml.js +33 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background.js +61 -50
- package/dist/core/dist/capabilities/table/entry.js +2 -0
- package/dist/core/dist/capabilities/table/table-codegen.js +118 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-import.js +116 -84
- package/dist/core/dist/capabilities/table/table-schemas.js +337 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-xml.js +13 -15
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table.js +284 -192
- package/dist/core/dist/capabilities/text/entry.js +3 -0
- package/dist/core/dist/capabilities/text/text-codegen.js +66 -0
- package/dist/core/dist/capabilities/text/text-import.js +468 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/text/text-xml.js +3 -4
- package/dist/{capabilities/dist → core/dist/capabilities}/text/text.js +103 -111
- package/dist/core/dist/capabilities/transition/entry.js +3 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-api.js +13 -16
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-codegen.js +2 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-import.js +25 -27
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition.js +23 -23
- package/dist/core/dist/capabilities/video/entry.js +77 -0
- package/dist/core/dist/capabilities/video/video-declaration.js +7 -0
- package/dist/core/dist/capabilities/video/video-source.js +42 -0
- package/dist/{codegen/dist → core/dist/codegen}/assets.js +16 -10
- package/dist/{codegen/dist → core/dist/codegen}/codegen.js +152 -140
- package/dist/{codegen/dist → core/dist/codegen}/identifiers.js +27 -1
- package/dist/{codegen/dist → core/dist/codegen}/index.js +2 -2
- package/dist/{codegen/dist → core/dist/codegen}/printer.js +23 -4
- package/dist/core/dist/document/all.js +41 -0
- package/dist/core/dist/document/default.js +10 -0
- package/dist/core/dist/document/document.js +218 -0
- package/dist/core/dist/document/index.js +62 -0
- package/dist/core/dist/document/stages.js +54 -0
- package/dist/{emit/dist → core/dist/emit}/emit.js +173 -90
- package/dist/core/dist/emit/index.js +6 -0
- package/dist/core/dist/emit/ooxml.js +241 -0
- package/dist/core/dist/import/import.js +547 -0
- package/dist/core/dist/import/index.js +19 -0
- package/dist/{import/dist → core/dist/import}/masters.js +404 -328
- package/dist/core/dist/import/media-timing.js +233 -0
- package/dist/{import/dist → core/dist/import}/notes-masters.js +48 -45
- package/dist/core/dist/index.js +47 -15
- package/dist/core/dist/{author-ids.js → kernel/author-ids.js} +9 -6
- package/dist/core/dist/{author-schemas.js → kernel/author-schemas.js} +105 -127
- package/dist/core/dist/{block-flex-layout.js → kernel/block-flex-layout.js} +225 -142
- package/dist/core/dist/kernel/build.js +4 -0
- package/dist/core/dist/kernel/capability.js +17 -0
- package/dist/core/dist/kernel/codegen.js +97 -0
- package/dist/core/dist/kernel/container-slots.js +104 -0
- package/dist/core/dist/kernel/date-time-format.js +18 -0
- package/dist/core/dist/kernel/declaration-snapshot.js +68 -0
- package/dist/core/dist/{declaration.js → kernel/declaration.js} +3 -2
- package/dist/core/dist/kernel/diagnostics.js +370 -0
- package/dist/core/dist/kernel/document-internals.js +26 -0
- package/dist/core/dist/{document.js → kernel/document.js} +23 -13
- package/dist/core/dist/kernel/drawing-units.js +14 -0
- package/dist/core/dist/kernel/font-seal.js +204 -0
- package/dist/core/dist/{geometry-schemas.js → kernel/geometry-schemas.js} +21 -18
- package/dist/core/dist/{grid-layout.js → kernel/grid-layout.js} +177 -72
- package/dist/core/dist/{host.js → kernel/host.js} +1 -1
- package/dist/core/dist/kernel/index.js +24 -0
- package/dist/core/dist/kernel/input-values.js +62 -0
- package/dist/core/dist/kernel/layout-definition.js +7 -0
- package/dist/core/dist/{layout-protocol.js → kernel/layout-protocol.js} +5 -10
- package/dist/core/dist/{layout-schemas.js → kernel/layout-schemas.js} +33 -44
- package/dist/core/dist/kernel/layout.js +339 -0
- package/dist/core/dist/kernel/masters.js +171 -0
- package/dist/core/dist/{morph.js → kernel/morph.js} +1 -1
- package/dist/core/dist/kernel/placeholders.js +289 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/alternate-content.js +1 -1
- package/dist/{import/dist → core/dist/kernel/pptx-read}/diagnostics.js +33 -29
- package/dist/core/dist/kernel/pptx-read/drawing-list-import.js +251 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/fonts.js +71 -12
- package/dist/core/dist/kernel/pptx-read/index.js +15 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/mechanism.js +1 -1
- package/dist/core/dist/kernel/pptx-read/media.js +26 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/namespaces.js +6 -7
- package/dist/{import/dist → core/dist/kernel/pptx-read}/opc.js +62 -13
- package/dist/{import/dist → core/dist/kernel/pptx-read}/resources.js +1 -1
- package/dist/core/dist/kernel/pptx-read/shape-tree.js +57 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/themes.js +182 -41
- package/dist/{import/dist → core/dist/kernel/pptx-read}/visual.js +175 -88
- package/dist/core/dist/kernel/pptx-read/xml-fragments.js +320 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/xml-reader.js +8 -1
- package/dist/{emit/dist → core/dist/kernel/pptx-write}/shape-tree.js +1 -1
- package/dist/core/dist/kernel/pptx-write/timing.js +52 -0
- package/dist/{emit/dist/ooxml.js → core/dist/kernel/pptx-write/xml.js} +133 -290
- package/dist/core/dist/{query.js → kernel/query.js} +76 -37
- package/dist/core/dist/{resolution.js → kernel/resolution.js} +2 -1
- package/dist/core/dist/kernel/resolve-work.js +58 -0
- package/dist/core/dist/{resolve.js → kernel/resolve.js} +797 -409
- package/dist/core/dist/kernel/resource-source.js +11 -0
- package/dist/core/dist/kernel/stage-options.js +312 -0
- package/dist/core/dist/{theme.js → kernel/theme.js} +399 -289
- package/dist/core/dist/kernel/transform-geometry.js +72 -0
- package/dist/core/dist/kernel/xml-values.js +13 -0
- package/dist/document-C0lPlH-L.d.ts +1442 -0
- package/dist/index-B9_OUeA-.d.ts +2238 -0
- package/dist/index-BJEzQxWV.d.ts +75 -0
- package/dist/index-DA9flrlR.d.ts +146 -0
- package/dist/index-GSt0t9VO.d.ts +54 -0
- package/dist/index.d.ts +7 -7
- package/dist/index.js +75 -61
- package/dist/node.d.ts +37 -35
- package/dist/node.js +125 -51
- package/dist/pptxdk/src/cli-commands.js +79 -81
- package/dist/pptxdk/src/compose.js +32 -24
- package/dist/pptxdk/src/preview-result.js +24 -0
- package/dist/{capabilities/dist/image → preview/dist}/gif-decoder.js +5 -5
- package/dist/preview/dist/index.js +229 -77
- package/dist/preview/dist/options.js +17 -26
- package/dist/preview/dist/raster.js +66 -0
- package/dist/preview/dist/svg-guard.js +1090 -0
- package/dist/preview.d.ts +6 -3
- package/dist/preview.js +8 -24
- package/dist/react/dist/append.js +3 -3
- package/dist/react/dist/author/audio-elements.js +14 -0
- package/dist/{capabilities/dist/box → react/dist/author}/box-elements.js +5 -3
- package/dist/react/dist/author/chart-elements.js +14 -0
- package/dist/react/dist/author/comment-elements.js +15 -0
- package/dist/react/dist/author/group-elements.js +14 -0
- package/dist/react/dist/author/image-elements.js +14 -0
- package/dist/react/dist/author/line-elements.js +14 -0
- package/dist/{capabilities/dist/motion → react/dist/author}/motion-elements.js +6 -4
- package/dist/react/dist/author/notes-elements.js +14 -0
- package/dist/react/dist/author/placeholder-elements.js +14 -0
- package/dist/react/dist/author/shape-elements.js +14 -0
- package/dist/{capabilities/dist/table → react/dist/author}/table-elements.js +6 -4
- package/dist/react/dist/author/text-elements.js +64 -0
- package/dist/react/dist/author/video-elements.js +14 -0
- package/dist/react/dist/document-adapter.js +376 -37
- package/dist/react/dist/elements.js +30 -4
- package/dist/react/dist/from-vanilla.js +57 -0
- package/dist/react/dist/index.js +47 -12
- package/dist/react/dist/mount.js +34 -0
- package/dist/react/dist/reconciler.js +26 -26
- package/dist/react.d.ts +174 -50
- package/dist/react.js +31 -27
- package/dist/stages-DYHSHKt4.d.ts +80 -0
- package/dist/vanilla.d.ts +4 -4
- package/dist/vanilla.js +14 -14
- package/package.json +6 -8
- package/README.md +0 -49
- package/dist/capabilities/dist/all.js +0 -32
- package/dist/capabilities/dist/box/box-codegen.js +0 -51
- package/dist/capabilities/dist/box/box-declaration.js +0 -31
- package/dist/capabilities/dist/chart/chart-elements.js +0 -12
- package/dist/capabilities/dist/chart/preview/data-labels.js +0 -334
- package/dist/capabilities/dist/document.js +0 -148
- package/dist/capabilities/dist/font/font-embedding.js +0 -289
- package/dist/capabilities/dist/font/font-family.js +0 -10
- package/dist/capabilities/dist/font/font-import.js +0 -302
- package/dist/capabilities/dist/font/font.js +0 -25
- package/dist/capabilities/dist/group/group-codegen.js +0 -51
- package/dist/capabilities/dist/group/group-declaration.js +0 -42
- package/dist/capabilities/dist/group/group-elements.js +0 -12
- package/dist/capabilities/dist/group/group-import.js +0 -319
- package/dist/capabilities/dist/group/group.js +0 -211
- package/dist/capabilities/dist/image/image-codegen.js +0 -94
- package/dist/capabilities/dist/image/image-declaration.js +0 -8
- package/dist/capabilities/dist/image/image-elements.js +0 -12
- package/dist/capabilities/dist/image/image-xml.js +0 -12
- package/dist/capabilities/dist/image/image.js +0 -472
- package/dist/capabilities/dist/masters/masters-codegen.js +0 -21
- package/dist/capabilities/dist/motion/motion-api.js +0 -527
- package/dist/capabilities/dist/motion/motion-schemas.js +0 -216
- package/dist/capabilities/dist/notes/notes-elements.js +0 -12
- package/dist/capabilities/dist/notes/notes-xml.js +0 -38
- package/dist/capabilities/dist/placeholder/placeholder-codegen.js +0 -23
- package/dist/capabilities/dist/placeholder/placeholder-elements.js +0 -12
- package/dist/capabilities/dist/placeholder/placeholder.js +0 -292
- package/dist/capabilities/dist/shape/shape-declaration.js +0 -57
- package/dist/capabilities/dist/shape/shape-elements.js +0 -12
- package/dist/capabilities/dist/shape/shape-import.js +0 -579
- package/dist/capabilities/dist/shared/placeholder-import.js +0 -113
- package/dist/capabilities/dist/shared/style-parse.js +0 -11
- package/dist/capabilities/dist/shared/text-schemas.js +0 -216
- package/dist/capabilities/dist/shared/text-service.js +0 -1883
- package/dist/capabilities/dist/slide-background/slide-background-codegen.js +0 -44
- package/dist/capabilities/dist/slide-background/slide-background-xml.js +0 -21
- package/dist/capabilities/dist/table/table-codegen.js +0 -81
- package/dist/capabilities/dist/table/table-schemas.js +0 -279
- package/dist/capabilities/dist/text/text-codegen.js +0 -129
- package/dist/capabilities/dist/text/text-declaration.js +0 -19
- package/dist/capabilities/dist/text/text-elements.js +0 -38
- package/dist/capabilities/dist/text/text-import.js +0 -1077
- package/dist/capability-D_xeNVIw.d.ts +0 -29496
- package/dist/codegen/dist/types.js +0 -49
- package/dist/core/dist/build.js +0 -4
- package/dist/core/dist/capability.js +0 -13
- package/dist/core/dist/diagnostics.js +0 -21
- package/dist/core/dist/document-internals.js +0 -13
- package/dist/core/dist/input-values.js +0 -45
- package/dist/core/dist/layout.js +0 -299
- package/dist/core/dist/masters.js +0 -169
- package/dist/core/dist/placeholders.js +0 -213
- package/dist/core/dist/stage-options.js +0 -67
- package/dist/document-BHPUODPP.d.ts +0 -27759
- package/dist/emit/dist/index.js +0 -5
- package/dist/import/dist/import.js +0 -504
- package/dist/import/dist/index.js +0 -16
- package/dist/import/dist/xml-fragments.js +0 -36
- package/dist/index-B5m3hqjC.d.ts +0 -7
- package/dist/index-CCy-Yo8G.d.ts +0 -1208
- package/dist/index-DpxcZ4Gs.d.ts +0 -725
- package/dist/pptxdk/src/slide.js +0 -9
- package/dist/preview-Cfw0QdMM.d.ts +0 -86
- package/dist/transition-Cips9wma.d.ts +0 -82
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { CapabilityError } from "
|
|
2
|
-
import { authorIdSchema } from "
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import "../../../core/dist/capability.js";
|
|
8
|
-
import { pxToEmu, xmlEscape } from "../../../emit/dist/ooxml.js";
|
|
9
|
-
import "../../../emit/dist/index.js";
|
|
10
|
-
import { motionPropsSchema } from "../motion/motion-schemas.js";
|
|
1
|
+
import { CapabilityError, zodIssueField } from "../../kernel/diagnostics.js";
|
|
2
|
+
import { authorIdSchema } from "../../kernel/author-ids.js";
|
|
3
|
+
import { layoutStyleShape } from "../../kernel/layout-schemas.js";
|
|
4
|
+
import { pxToEmu } from "../../kernel/drawing-units.js";
|
|
5
|
+
import { colorMapSchema, colorValueSchema, textStyleShape, themeOverrideSchema } from "../../kernel/theme.js";
|
|
6
|
+
import { linkTargetSchema } from "../../kernel/author-schemas.js";
|
|
11
7
|
import { morphKeySchema } from "../shared/morph-api.js";
|
|
8
|
+
import { motionPropsShape } from "../shared/motion-schemas.js";
|
|
9
|
+
import "../../kernel/capability.js";
|
|
10
|
+
import { xmlEscape } from "../../kernel/pptx-write/xml.js";
|
|
12
11
|
import { chartDataLabelPositions } from "./chart-labels.js";
|
|
13
12
|
import { z } from "zod";
|
|
14
|
-
// ../
|
|
13
|
+
// ../core/dist/capabilities/chart/chart-schemas.js
|
|
15
14
|
const maximumLineWidthEmu = 20116800;
|
|
16
15
|
const maximumShapeExtentEmu = 2147483647;
|
|
17
16
|
const maximumExplosionForCurrentValidationProfile = 2147483647;
|
|
@@ -26,15 +25,12 @@ function isValidXml10String(value) {
|
|
|
26
25
|
return false;
|
|
27
26
|
}
|
|
28
27
|
}
|
|
29
|
-
function addChartIssue(ctx, errorCode, message, path = []
|
|
28
|
+
function addChartIssue(ctx, errorCode, message, path = []) {
|
|
30
29
|
ctx.addIssue({
|
|
31
30
|
code: "custom",
|
|
32
31
|
message,
|
|
33
32
|
path: [...path],
|
|
34
|
-
params: {
|
|
35
|
-
errorCode,
|
|
36
|
-
...fieldPath === void 0 ? {} : { fieldPath }
|
|
37
|
-
}
|
|
33
|
+
params: { errorCode }
|
|
38
34
|
});
|
|
39
35
|
}
|
|
40
36
|
function nonEmptyStringSchema(errorCode, message) {
|
|
@@ -71,16 +67,23 @@ const chartKindSchema = z.enum([
|
|
|
71
67
|
"doughnut",
|
|
72
68
|
"scatter"
|
|
73
69
|
]);
|
|
74
|
-
const
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
70
|
+
const rawChartTextStyleObjectSchema = z.strictObject(textStyleShape).omit({ textWrap: true });
|
|
71
|
+
const rawChartTextStyleSchema = rawChartTextStyleObjectSchema.readonly();
|
|
72
|
+
const chartTextStyleKeys = Object.keys(rawChartTextStyleObjectSchema.shape);
|
|
73
|
+
const chartTextStyleSchema = rawChartTextStyleSchema;
|
|
74
|
+
const rawChartStyleObjectSchema = z.strictObject({
|
|
75
|
+
...rawChartTextStyleObjectSchema.shape,
|
|
76
|
+
...layoutStyleShape
|
|
77
|
+
});
|
|
78
|
+
const rawChartStyleSchema = rawChartStyleObjectSchema.readonly();
|
|
79
|
+
const chartStyleKeys = Object.keys(rawChartStyleObjectSchema.shape);
|
|
80
|
+
const chartStyleSchema = rawChartStyleSchema;
|
|
81
|
+
const rawChartTitleSchema = z.union([nonEmptyXmlStringSchema("invalid-parameter", "title"), z.strictObject({
|
|
80
82
|
text: nonEmptyXmlStringSchema("invalid-parameter", "title.text"),
|
|
81
|
-
style:
|
|
83
|
+
style: rawChartTextStyleSchema.optional()
|
|
82
84
|
}).readonly()]);
|
|
83
|
-
const
|
|
85
|
+
const chartTitleSchema = rawChartTitleSchema;
|
|
86
|
+
const rawChartLineDashSchema = z.enum([
|
|
84
87
|
"solid",
|
|
85
88
|
"dash",
|
|
86
89
|
"dot",
|
|
@@ -89,12 +92,12 @@ const chartLineDashSchema = z.enum([
|
|
|
89
92
|
"longDashDot",
|
|
90
93
|
"longDashDotDot"
|
|
91
94
|
]);
|
|
92
|
-
const
|
|
95
|
+
const rawChartLineSchema = z.strictObject({
|
|
93
96
|
color: colorValueSchema.optional(),
|
|
94
97
|
width: z.number().finite().positive().refine((value) => pxToEmu(value) <= maximumLineWidthEmu, { message: "width converted value exceeds writable line width range" }).optional(),
|
|
95
|
-
dash:
|
|
98
|
+
dash: rawChartLineDashSchema.optional()
|
|
96
99
|
}).readonly();
|
|
97
|
-
const
|
|
100
|
+
const rawChartMarkerSymbolSchema = z.enum([
|
|
98
101
|
"auto",
|
|
99
102
|
"circle",
|
|
100
103
|
"dash",
|
|
@@ -107,17 +110,18 @@ const chartMarkerSymbolSchema = z.enum([
|
|
|
107
110
|
"triangle",
|
|
108
111
|
"x"
|
|
109
112
|
]);
|
|
110
|
-
const
|
|
111
|
-
symbol:
|
|
113
|
+
const rawChartMarkerSchema = z.strictObject({
|
|
114
|
+
symbol: rawChartMarkerSymbolSchema.optional(),
|
|
112
115
|
size: z.number().int().min(2).max(72).optional(),
|
|
113
116
|
fill: colorValueSchema.optional(),
|
|
114
|
-
line:
|
|
117
|
+
line: rawChartLineSchema.optional()
|
|
115
118
|
}).readonly();
|
|
116
|
-
const
|
|
119
|
+
const rawChartMarkerOptionSchema = z.union([z.boolean(), rawChartMarkerSchema]);
|
|
120
|
+
const chartMarkerOptionSchema = rawChartMarkerOptionSchema;
|
|
117
121
|
const chartPointValueSchema = z.number().finite().nullable();
|
|
118
|
-
const
|
|
119
|
-
const
|
|
120
|
-
const
|
|
122
|
+
const rawChartSeriesValuesSchema = z.array(chartPointValueSchema).readonly();
|
|
123
|
+
const rawChartCategoriesSchema = z.array(xmlStringSchema("category")).readonly();
|
|
124
|
+
const rawChartDataLabelPositionSchema = z.enum([
|
|
121
125
|
"center",
|
|
122
126
|
"insideEnd",
|
|
123
127
|
"insideBase",
|
|
@@ -131,6 +135,9 @@ const chartDataLabelPositionSchema = z.enum([
|
|
|
131
135
|
const separatorStringSchema = z.string().min(1).superRefine((value, ctx) => {
|
|
132
136
|
if (!isValidXml10String(value)) addChartIssue(ctx, "invalid-xml-character", "separator contains characters not allowed in XML 1.0");
|
|
133
137
|
});
|
|
138
|
+
const pointLabelTextSchema = xmlStringSchema("text").superRefine((value, ctx) => {
|
|
139
|
+
if (value.length === 0) addChartIssue(ctx, "invalid-data-labels", "text must be a non-empty string");
|
|
140
|
+
}).optional();
|
|
134
141
|
const dataLabelCommonFields = {
|
|
135
142
|
value: z.boolean().optional(),
|
|
136
143
|
percent: z.boolean().optional(),
|
|
@@ -139,24 +146,20 @@ const dataLabelCommonFields = {
|
|
|
139
146
|
xValue: z.boolean().optional(),
|
|
140
147
|
separator: separatorStringSchema.optional(),
|
|
141
148
|
numberFormat: nonEmptyXmlStringSchema("invalid-data-labels", "numberFormat").optional(),
|
|
142
|
-
leaderLines: z.union([z.boolean(),
|
|
143
|
-
style:
|
|
149
|
+
leaderLines: z.union([z.boolean(), rawChartLineSchema]).optional(),
|
|
150
|
+
style: rawChartTextStyleSchema.optional()
|
|
144
151
|
};
|
|
145
152
|
const chartDataLabelsObjectSchema = z.strictObject({
|
|
146
153
|
...dataLabelCommonFields,
|
|
147
|
-
position:
|
|
154
|
+
position: rawChartDataLabelPositionSchema.optional()
|
|
148
155
|
});
|
|
149
|
-
const
|
|
150
|
-
const
|
|
151
|
-
style: true,
|
|
156
|
+
const rawChartDataLabelsBaseSchema = chartDataLabelsObjectSchema.readonly();
|
|
157
|
+
const rawChartDataLabelOverrideSchema = chartDataLabelsObjectSchema.omit({
|
|
152
158
|
leaderLines: true,
|
|
153
159
|
xValue: true
|
|
154
|
-
}).readonly();
|
|
155
|
-
chartDataLabelsObjectSchema.omit({
|
|
156
|
-
|
|
157
|
-
xValue: true
|
|
158
|
-
}).readonly();
|
|
159
|
-
chartDataLabelsObjectSchema.readonly();
|
|
160
|
+
}).extend({ text: pointLabelTextSchema }).readonly();
|
|
161
|
+
chartDataLabelsObjectSchema.omit({ xValue: true }).readonly();
|
|
162
|
+
chartDataLabelsObjectSchema.extend({ text: pointLabelTextSchema }).readonly();
|
|
160
163
|
const scatterDataLabelsObjectSchema = z.strictObject({
|
|
161
164
|
...dataLabelCommonFields,
|
|
162
165
|
position: z.enum([
|
|
@@ -167,20 +170,19 @@ const scatterDataLabelsObjectSchema = z.strictObject({
|
|
|
167
170
|
"center"
|
|
168
171
|
]).optional()
|
|
169
172
|
});
|
|
170
|
-
scatterDataLabelsObjectSchema.omit({
|
|
173
|
+
const rawScatterDataLabelsBaseSchema = scatterDataLabelsObjectSchema.omit({
|
|
171
174
|
percent: true,
|
|
172
175
|
category: true,
|
|
173
176
|
leaderLines: true
|
|
174
177
|
}).readonly();
|
|
175
|
-
const
|
|
176
|
-
style: true,
|
|
178
|
+
const rawScatterDataLabelOverrideSchema = scatterDataLabelsObjectSchema.omit({
|
|
177
179
|
percent: true,
|
|
178
180
|
category: true,
|
|
179
181
|
leaderLines: true
|
|
180
|
-
}).readonly();
|
|
182
|
+
}).extend({ text: pointLabelTextSchema }).readonly();
|
|
181
183
|
const chartPointSchema = z.strictObject({
|
|
182
184
|
color: colorValueSchema.optional(),
|
|
183
|
-
line:
|
|
185
|
+
line: rawChartLineSchema.optional(),
|
|
184
186
|
marker: z.unknown().optional(),
|
|
185
187
|
explosion: roundedIntInRangeSchema({
|
|
186
188
|
minimum: 0,
|
|
@@ -189,15 +191,13 @@ const chartPointSchema = z.strictObject({
|
|
|
189
191
|
errorCode: "invalid-chart-option",
|
|
190
192
|
label: "explosion"
|
|
191
193
|
}).optional(),
|
|
192
|
-
|
|
193
|
-
dataLabels: z.union([z.literal(false), chartDataLabelOverrideSchema]).optional()
|
|
194
|
+
dataLabels: z.union([z.literal(false), rawChartDataLabelOverrideSchema]).optional()
|
|
194
195
|
}).readonly();
|
|
195
|
-
const
|
|
196
|
+
const rawScatterChartPointSchema = z.strictObject({
|
|
196
197
|
color: colorValueSchema.optional(),
|
|
197
|
-
line:
|
|
198
|
-
marker:
|
|
199
|
-
|
|
200
|
-
dataLabels: z.union([z.literal(false), scatterDataLabelOverrideSchema]).optional()
|
|
198
|
+
line: rawChartLineSchema.optional(),
|
|
199
|
+
marker: rawChartMarkerOptionSchema.optional(),
|
|
200
|
+
dataLabels: z.union([z.literal(false), rawScatterDataLabelOverrideSchema]).optional()
|
|
201
201
|
}).readonly();
|
|
202
202
|
z.enum([
|
|
203
203
|
"linear",
|
|
@@ -208,7 +208,7 @@ z.enum([
|
|
|
208
208
|
"movingAverage"
|
|
209
209
|
]);
|
|
210
210
|
const trendlineBaseFields = {
|
|
211
|
-
line:
|
|
211
|
+
line: rawChartLineSchema.optional(),
|
|
212
212
|
forward: z.number().finite().positive().optional(),
|
|
213
213
|
backward: z.number().finite().positive().optional()
|
|
214
214
|
};
|
|
@@ -216,7 +216,7 @@ const trendlineDisplayFields = {
|
|
|
216
216
|
displayEquation: z.boolean().optional(),
|
|
217
217
|
displayRSquared: z.boolean().optional()
|
|
218
218
|
};
|
|
219
|
-
const
|
|
219
|
+
const rawChartTrendlineSchema = z.discriminatedUnion("type", [
|
|
220
220
|
z.strictObject({
|
|
221
221
|
...trendlineBaseFields,
|
|
222
222
|
...trendlineDisplayFields,
|
|
@@ -267,30 +267,30 @@ const chartTrendlineSchema = z.discriminatedUnion("type", [
|
|
|
267
267
|
displayRSquared: z.never().optional()
|
|
268
268
|
}).readonly()
|
|
269
269
|
]);
|
|
270
|
-
const
|
|
271
|
-
const
|
|
270
|
+
const rawChartErrorBarValuesSchema = z.array(z.number().finite().nonnegative().nullable()).readonly();
|
|
271
|
+
const rawChartErrorBarIncludeSchema = z.enum([
|
|
272
272
|
"both",
|
|
273
273
|
"plus",
|
|
274
274
|
"minus"
|
|
275
275
|
]);
|
|
276
276
|
const errorBarStyleFields = {
|
|
277
277
|
endCap: z.boolean().optional(),
|
|
278
|
-
line:
|
|
278
|
+
line: rawChartLineSchema.optional()
|
|
279
279
|
};
|
|
280
|
-
const
|
|
280
|
+
const rawChartCustomErrorBarsSchema = z.discriminatedUnion("include", [
|
|
281
281
|
z.strictObject({
|
|
282
282
|
...errorBarStyleFields,
|
|
283
283
|
type: z.literal("custom"),
|
|
284
284
|
include: z.literal("both").optional(),
|
|
285
|
-
plus:
|
|
286
|
-
minus:
|
|
285
|
+
plus: rawChartErrorBarValuesSchema,
|
|
286
|
+
minus: rawChartErrorBarValuesSchema,
|
|
287
287
|
value: z.never().optional()
|
|
288
288
|
}).readonly(),
|
|
289
289
|
z.strictObject({
|
|
290
290
|
...errorBarStyleFields,
|
|
291
291
|
type: z.literal("custom"),
|
|
292
292
|
include: z.literal("plus"),
|
|
293
|
-
plus:
|
|
293
|
+
plus: rawChartErrorBarValuesSchema,
|
|
294
294
|
minus: z.never().optional(),
|
|
295
295
|
value: z.never().optional()
|
|
296
296
|
}).readonly(),
|
|
@@ -298,15 +298,15 @@ const chartCustomErrorBarsSchema = z.union([
|
|
|
298
298
|
...errorBarStyleFields,
|
|
299
299
|
type: z.literal("custom"),
|
|
300
300
|
include: z.literal("minus"),
|
|
301
|
-
minus:
|
|
301
|
+
minus: rawChartErrorBarValuesSchema,
|
|
302
302
|
plus: z.never().optional(),
|
|
303
303
|
value: z.never().optional()
|
|
304
304
|
}).readonly()
|
|
305
305
|
]);
|
|
306
|
-
const
|
|
306
|
+
const rawChartErrorBarsSchema = z.discriminatedUnion("type", [
|
|
307
307
|
z.strictObject({
|
|
308
308
|
...errorBarStyleFields,
|
|
309
|
-
include:
|
|
309
|
+
include: rawChartErrorBarIncludeSchema.optional(),
|
|
310
310
|
type: z.enum([
|
|
311
311
|
"fixed",
|
|
312
312
|
"percentage",
|
|
@@ -318,24 +318,24 @@ const chartErrorBarsSchema = z.union([
|
|
|
318
318
|
}).readonly(),
|
|
319
319
|
z.strictObject({
|
|
320
320
|
...errorBarStyleFields,
|
|
321
|
-
include:
|
|
321
|
+
include: rawChartErrorBarIncludeSchema.optional(),
|
|
322
322
|
type: z.literal("standardError"),
|
|
323
323
|
value: z.never().optional(),
|
|
324
324
|
plus: z.never().optional(),
|
|
325
325
|
minus: z.never().optional()
|
|
326
326
|
}).readonly(),
|
|
327
|
-
|
|
327
|
+
rawChartCustomErrorBarsSchema
|
|
328
328
|
]);
|
|
329
|
-
const
|
|
330
|
-
x:
|
|
331
|
-
y:
|
|
329
|
+
const rawScatterErrorBarsSchema = z.strictObject({
|
|
330
|
+
x: rawChartErrorBarsSchema.optional(),
|
|
331
|
+
y: rawChartErrorBarsSchema.optional()
|
|
332
332
|
}).readonly().superRefine((value, ctx) => {
|
|
333
333
|
if (value.x === void 0 && value.y === void 0) addChartIssue(ctx, "invalid-error-bars", "errorBars must declare x, y, or both");
|
|
334
334
|
});
|
|
335
335
|
const chartSeriesFormatFields = {
|
|
336
336
|
name: nonEmptyStringSchema("invalid-data", "Series.name must be a non-empty string"),
|
|
337
337
|
color: colorValueSchema.optional(),
|
|
338
|
-
line:
|
|
338
|
+
line: rawChartLineSchema.optional(),
|
|
339
339
|
explosion: roundedIntInRangeSchema({
|
|
340
340
|
minimum: 0,
|
|
341
341
|
maximum: maximumExplosionForCurrentValidationProfile,
|
|
@@ -346,90 +346,92 @@ const chartSeriesFormatFields = {
|
|
|
346
346
|
dataLabels: z.union([z.literal(false), chartDataLabelsObjectSchema.readonly()]).optional(),
|
|
347
347
|
marker: z.unknown().optional(),
|
|
348
348
|
points: z.record(z.string(), chartPointSchema).readonly().optional(),
|
|
349
|
-
trendlines: z.array(
|
|
349
|
+
trendlines: z.array(rawChartTrendlineSchema).readonly().optional()
|
|
350
350
|
};
|
|
351
351
|
const chartSeriesSchema = z.strictObject({
|
|
352
352
|
...chartSeriesFormatFields,
|
|
353
|
-
values:
|
|
353
|
+
values: rawChartSeriesValuesSchema,
|
|
354
354
|
smooth: z.boolean().optional(),
|
|
355
|
-
errorBars:
|
|
355
|
+
errorBars: rawChartErrorBarsSchema.optional()
|
|
356
356
|
}).readonly();
|
|
357
357
|
const independentCategorySeriesSchema = z.strictObject({
|
|
358
358
|
...chartSeriesFormatFields,
|
|
359
|
-
categories:
|
|
360
|
-
values:
|
|
359
|
+
categories: rawChartCategoriesSchema,
|
|
360
|
+
values: rawChartSeriesValuesSchema,
|
|
361
361
|
smooth: z.boolean().optional(),
|
|
362
|
-
errorBars:
|
|
362
|
+
errorBars: rawChartErrorBarsSchema.optional()
|
|
363
363
|
}).readonly();
|
|
364
364
|
const scatterChartSeriesSchema = z.strictObject({
|
|
365
365
|
name: nonEmptyStringSchema("invalid-data", "Series.name must be a non-empty string"),
|
|
366
|
-
x:
|
|
367
|
-
y:
|
|
366
|
+
x: rawChartSeriesValuesSchema,
|
|
367
|
+
y: rawChartSeriesValuesSchema,
|
|
368
368
|
color: colorValueSchema.optional(),
|
|
369
|
-
line:
|
|
370
|
-
dataLabels: z.union([z.literal(false),
|
|
371
|
-
marker:
|
|
372
|
-
points: z.record(z.string(),
|
|
373
|
-
trendlines: z.array(
|
|
374
|
-
errorBars:
|
|
369
|
+
line: rawChartLineSchema.optional(),
|
|
370
|
+
dataLabels: z.union([z.literal(false), rawScatterDataLabelsBaseSchema]).optional(),
|
|
371
|
+
marker: rawChartMarkerOptionSchema.optional(),
|
|
372
|
+
points: z.record(z.string(), rawScatterChartPointSchema).readonly().optional(),
|
|
373
|
+
trendlines: z.array(rawChartTrendlineSchema).readonly().optional(),
|
|
374
|
+
errorBars: rawScatterErrorBarsSchema.optional()
|
|
375
375
|
}).readonly();
|
|
376
|
-
const
|
|
376
|
+
const rawSharedCategoryDataSchema = z.strictObject({
|
|
377
377
|
kind: z.literal("shared-categories"),
|
|
378
|
-
categories:
|
|
378
|
+
categories: rawChartCategoriesSchema
|
|
379
379
|
}).readonly();
|
|
380
|
-
const
|
|
381
|
-
const
|
|
382
|
-
const
|
|
380
|
+
const rawIndependentCategoryDataSchema = z.strictObject({ kind: z.literal("independent-categories") }).readonly();
|
|
381
|
+
const rawScatterDataSchema = z.strictObject({ kind: z.literal("xy") }).readonly();
|
|
382
|
+
const rawChartTickMarkSchema = z.enum([
|
|
383
383
|
"none",
|
|
384
384
|
"in",
|
|
385
385
|
"out",
|
|
386
386
|
"cross"
|
|
387
387
|
]);
|
|
388
|
-
const
|
|
388
|
+
const rawChartTickLabelPositionSchema = z.enum([
|
|
389
389
|
"nextTo",
|
|
390
390
|
"high",
|
|
391
391
|
"low",
|
|
392
392
|
"none"
|
|
393
393
|
]);
|
|
394
|
-
const
|
|
394
|
+
const rawChartAxisCrossingSchema = z.enum([
|
|
395
395
|
"autoZero",
|
|
396
396
|
"max",
|
|
397
397
|
"min"
|
|
398
398
|
]);
|
|
399
|
-
const
|
|
399
|
+
const rawChartAxisPositionSchema = z.enum([
|
|
400
400
|
"bottom",
|
|
401
401
|
"top",
|
|
402
402
|
"left",
|
|
403
403
|
"right"
|
|
404
404
|
]);
|
|
405
|
-
const
|
|
405
|
+
const rawChartDisplayBlanksAsSchema = z.enum([
|
|
406
406
|
"gap",
|
|
407
407
|
"zero",
|
|
408
408
|
"span"
|
|
409
409
|
]);
|
|
410
|
+
const chartDisplayBlanksAsSchema = rawChartDisplayBlanksAsSchema;
|
|
410
411
|
const axisBaseFields = {
|
|
411
412
|
visible: z.boolean().optional(),
|
|
412
|
-
gridlines: z.union([z.boolean(),
|
|
413
|
-
minorGridlines: z.union([z.boolean(),
|
|
414
|
-
line: z.union([z.boolean(),
|
|
415
|
-
style:
|
|
416
|
-
title:
|
|
417
|
-
majorTickMark:
|
|
418
|
-
minorTickMark:
|
|
419
|
-
tickLabelPosition:
|
|
413
|
+
gridlines: z.union([z.boolean(), rawChartLineSchema]).optional(),
|
|
414
|
+
minorGridlines: z.union([z.boolean(), rawChartLineSchema]).optional(),
|
|
415
|
+
line: z.union([z.boolean(), rawChartLineSchema]).optional(),
|
|
416
|
+
style: rawChartTextStyleSchema.optional(),
|
|
417
|
+
title: rawChartTitleSchema.optional(),
|
|
418
|
+
majorTickMark: rawChartTickMarkSchema.optional(),
|
|
419
|
+
minorTickMark: rawChartTickMarkSchema.optional(),
|
|
420
|
+
tickLabelPosition: rawChartTickLabelPositionSchema.optional(),
|
|
420
421
|
reversed: z.boolean().optional(),
|
|
421
|
-
position:
|
|
422
|
-
crosses:
|
|
422
|
+
position: rawChartAxisPositionSchema.optional(),
|
|
423
|
+
crosses: rawChartAxisCrossingSchema.optional(),
|
|
423
424
|
crossesAt: z.number().finite().optional()
|
|
424
425
|
};
|
|
425
|
-
const
|
|
426
|
+
const rawChartCategoryAxisSchema = z.strictObject({
|
|
426
427
|
kind: z.literal("category"),
|
|
427
428
|
...axisBaseFields
|
|
428
429
|
}).readonly().superRefine((value, ctx) => {
|
|
429
430
|
if (value.crosses !== void 0 && value.crossesAt !== void 0) addChartIssue(ctx, "invalid-axis", "axis must declare crosses or crossesAt, not both");
|
|
430
431
|
if (value.crossesAt !== void 0 && (!Number.isSafeInteger(value.crossesAt) || value.crossesAt < 1)) addChartIssue(ctx, "invalid-axis", "crossesAt must be a positive integer category position", ["crossesAt"]);
|
|
431
432
|
});
|
|
432
|
-
const
|
|
433
|
+
const chartCategoryAxisSchema = rawChartCategoryAxisSchema;
|
|
434
|
+
const rawChartValueAxisSchema = z.strictObject({
|
|
433
435
|
kind: z.literal("value"),
|
|
434
436
|
...axisBaseFields,
|
|
435
437
|
min: z.number().finite().optional(),
|
|
@@ -447,24 +449,25 @@ const chartValueAxisSchema = z.strictObject({
|
|
|
447
449
|
}
|
|
448
450
|
if (value.crosses !== void 0 && value.crossesAt !== void 0) addChartIssue(ctx, "invalid-axis", "axis must declare crosses or crossesAt, not both");
|
|
449
451
|
});
|
|
450
|
-
const
|
|
451
|
-
const
|
|
452
|
+
const chartValueAxisSchema = rawChartValueAxisSchema;
|
|
453
|
+
const rawChartAxisSchema = z.discriminatedUnion("kind", [rawChartCategoryAxisSchema, rawChartValueAxisSchema]);
|
|
454
|
+
const chartAxesSchema = z.record(z.string(), rawChartAxisSchema).readonly().superRefine((axes, ctx) => {
|
|
452
455
|
const names = Object.keys(axes);
|
|
453
456
|
if (names.length === 0) addChartIssue(ctx, "invalid-axis", "Chart.axes must define at least one axis");
|
|
454
457
|
for (const name of names) if (name.trim() === "") addChartIssue(ctx, "invalid-axis", "Chart.axes names must be non-empty strings", [name]);
|
|
455
458
|
});
|
|
456
|
-
const
|
|
459
|
+
const rawChartCategoryAxisReferencesSchema = z.strictObject({
|
|
457
460
|
category: nonEmptyStringSchema("invalid-chart-axes", "category axis reference must be non-empty"),
|
|
458
461
|
value: nonEmptyStringSchema("invalid-chart-axes", "value axis reference must be non-empty")
|
|
459
462
|
}).readonly();
|
|
460
|
-
const
|
|
463
|
+
const rawChartXYAxisReferencesSchema = z.strictObject({
|
|
461
464
|
x: nonEmptyStringSchema("invalid-chart-axes", "X axis reference must be non-empty"),
|
|
462
465
|
y: nonEmptyStringSchema("invalid-chart-axes", "Y axis reference must be non-empty")
|
|
463
466
|
}).readonly().superRefine((value, ctx) => {
|
|
464
467
|
if (value.x === value.y) addChartIssue(ctx, "invalid-chart-axes", "axes must reference two distinct X and Y value axes");
|
|
465
468
|
});
|
|
466
|
-
z.union([
|
|
467
|
-
const
|
|
469
|
+
z.union([rawChartCategoryAxisReferencesSchema, rawChartXYAxisReferencesSchema]);
|
|
470
|
+
const rawScatterLineSchema = z.union([
|
|
468
471
|
z.literal(false),
|
|
469
472
|
z.literal("straight"),
|
|
470
473
|
z.literal("smooth")
|
|
@@ -480,9 +483,8 @@ function validatePointIndexKeys(points, pointCount, seriesName, ctx, pathPrefix)
|
|
|
480
483
|
]);
|
|
481
484
|
}
|
|
482
485
|
}
|
|
483
|
-
function validateDataLabelSettingsForKind(labels, kind, stacking, ctx, path,
|
|
486
|
+
function validateDataLabelSettingsForKind(labels, kind, stacking, ctx, path, allowLeaderLines) {
|
|
484
487
|
if (labels === void 0 || labels === false) return;
|
|
485
|
-
if (!allowStyle && labels.style !== void 0) addChartIssue(ctx, "unknown-parameter", "dataLabels contains unimplemented parameter style", [...path, "style"]);
|
|
486
488
|
if (!allowLeaderLines && labels.leaderLines !== void 0) addChartIssue(ctx, "unknown-parameter", "dataLabels contains unimplemented parameter leaderLines", [...path, "leaderLines"]);
|
|
487
489
|
if (labels.xValue !== void 0 && kind !== "scatter") addChartIssue(ctx, "invalid-data-labels", "xValue is only supported for scatter charts", [...path, "xValue"]);
|
|
488
490
|
if (labels.percent === true && kind !== "pie" && kind !== "doughnut") addChartIssue(ctx, "invalid-data-labels", "percent is only supported for pie and doughnut charts", [...path, "percent"]);
|
|
@@ -557,7 +559,7 @@ function validateTrendlinesForGroup(trendlines, kind, stacking, pointCount, fitP
|
|
|
557
559
|
}
|
|
558
560
|
function validateCategoryGroupSeries(group, ctx) {
|
|
559
561
|
const { kind, data, series, stacking } = group;
|
|
560
|
-
validateDataLabelSettingsForKind(group.dataLabels, kind, stacking, ctx, ["dataLabels"], true
|
|
562
|
+
validateDataLabelSettingsForKind(group.dataLabels, kind, stacking, ctx, ["dataLabels"], true);
|
|
561
563
|
if (kind === "pie" && series.length !== 1) addChartIssue(ctx, "invalid-data", "pie chart currently only supports a single data series", ["series"]);
|
|
562
564
|
for (const [seriesIndex, item] of series.entries()) {
|
|
563
565
|
const seriesPath = ["series", seriesIndex];
|
|
@@ -586,7 +588,7 @@ function validateCategoryGroupSeries(group, ctx) {
|
|
|
586
588
|
}
|
|
587
589
|
}
|
|
588
590
|
if (item.smooth !== void 0 && kind !== "line") addChartIssue(ctx, "invalid-smooth", `Series "${item.name}".smooth is only applicable to line chart series`, [...seriesPath, "smooth"]);
|
|
589
|
-
validateDataLabelSettingsForKind(item.dataLabels, kind, stacking, ctx, [...seriesPath, "dataLabels"],
|
|
591
|
+
validateDataLabelSettingsForKind(item.dataLabels, kind, stacking, ctx, [...seriesPath, "dataLabels"], true);
|
|
590
592
|
validatePointIndexKeys(item.points, categories.length, item.name, ctx, seriesPath);
|
|
591
593
|
if (item.points !== void 0) for (const [rawIndex, point] of Object.entries(item.points)) {
|
|
592
594
|
if (kind === "area" && point.color !== void 0) addChartIssue(ctx, "invalid-data", "Area chart data points do not support individual fill colors; set the series color instead.", [
|
|
@@ -594,7 +596,7 @@ function validateCategoryGroupSeries(group, ctx) {
|
|
|
594
596
|
"points",
|
|
595
597
|
rawIndex,
|
|
596
598
|
"color"
|
|
597
|
-
]
|
|
599
|
+
]);
|
|
598
600
|
if (point.marker !== void 0) {
|
|
599
601
|
if (kind !== "line") addChartIssue(ctx, "invalid-marker", `Series "${item.name}" data point ${rawIndex}.marker is only applicable to line and scatter chart series and points`, [
|
|
600
602
|
...seriesPath,
|
|
@@ -627,7 +629,7 @@ function validateCategoryGroupSeries(group, ctx) {
|
|
|
627
629
|
"points",
|
|
628
630
|
rawIndex,
|
|
629
631
|
"dataLabels"
|
|
630
|
-
], false
|
|
632
|
+
], false);
|
|
631
633
|
}
|
|
632
634
|
validateErrorBarsForKind(item.errorBars, kind, categories.length, ctx, [...seriesPath, "errorBars"]);
|
|
633
635
|
validateTrendlinesForGroup(item.trendlines, kind, stacking, categories.length, item.values.flatMap((value, pointIndex) => value === null ? [] : [{
|
|
@@ -638,45 +640,47 @@ function validateCategoryGroupSeries(group, ctx) {
|
|
|
638
640
|
}
|
|
639
641
|
const columnOrBarCommonFields = {
|
|
640
642
|
kind: z.enum(["column", "bar"]),
|
|
641
|
-
data:
|
|
643
|
+
data: rawSharedCategoryDataSchema,
|
|
642
644
|
series: z.array(chartSeriesSchema).min(1).readonly(),
|
|
643
|
-
axes:
|
|
645
|
+
axes: rawChartCategoryAxisReferencesSchema.optional(),
|
|
644
646
|
gapWidth: z.number().finite().min(0).max(500).optional(),
|
|
645
647
|
overlap: z.number().finite().min(-100).max(100).optional()
|
|
646
648
|
};
|
|
647
649
|
const ColumnOrBarUnstackedGroupSchema = z.strictObject({
|
|
648
650
|
...columnOrBarCommonFields,
|
|
649
651
|
stacking: z.undefined().optional(),
|
|
650
|
-
dataLabels: z.union([z.literal(false),
|
|
652
|
+
dataLabels: z.union([z.literal(false), rawChartDataLabelsBaseSchema]).optional()
|
|
651
653
|
}).readonly();
|
|
652
654
|
const ColumnOrBarStackedGroupSchema = z.strictObject({
|
|
653
655
|
...columnOrBarCommonFields,
|
|
654
656
|
stacking: z.enum(["stacked", "percent"]),
|
|
655
|
-
dataLabels: z.union([z.literal(false),
|
|
657
|
+
dataLabels: z.union([z.literal(false), rawChartDataLabelsBaseSchema]).optional()
|
|
656
658
|
}).readonly();
|
|
657
659
|
const columnOrBarChartGroupSchema = z.union([ColumnOrBarUnstackedGroupSchema, ColumnOrBarStackedGroupSchema]).superRefine((group, ctx) => {
|
|
658
660
|
validateCategoryGroupSeries(group, ctx);
|
|
659
661
|
});
|
|
660
|
-
const
|
|
662
|
+
const LineChartGroupRawSchema = z.strictObject({
|
|
661
663
|
kind: z.literal("line"),
|
|
662
|
-
data:
|
|
664
|
+
data: rawSharedCategoryDataSchema,
|
|
663
665
|
series: z.array(chartSeriesSchema).min(1).readonly(),
|
|
664
|
-
axes:
|
|
666
|
+
axes: rawChartCategoryAxisReferencesSchema.optional(),
|
|
665
667
|
stacking: z.enum(["stacked", "percent"]).optional(),
|
|
666
|
-
dataLabels: z.union([z.literal(false),
|
|
668
|
+
dataLabels: z.union([z.literal(false), rawChartDataLabelsBaseSchema]).optional()
|
|
667
669
|
}).readonly().superRefine((group, ctx) => {
|
|
668
670
|
validateCategoryGroupSeries(group, ctx);
|
|
669
671
|
});
|
|
670
|
-
const
|
|
672
|
+
const lineChartGroupSchema = LineChartGroupRawSchema;
|
|
673
|
+
const AreaChartGroupRawSchema = z.strictObject({
|
|
671
674
|
kind: z.literal("area"),
|
|
672
|
-
data:
|
|
675
|
+
data: rawSharedCategoryDataSchema,
|
|
673
676
|
series: z.array(chartSeriesSchema).min(1).readonly(),
|
|
674
|
-
axes:
|
|
677
|
+
axes: rawChartCategoryAxisReferencesSchema.optional(),
|
|
675
678
|
stacking: z.enum(["stacked", "percent"]).optional(),
|
|
676
|
-
dataLabels: z.union([z.literal(false),
|
|
679
|
+
dataLabels: z.union([z.literal(false), rawChartDataLabelsBaseSchema]).optional()
|
|
677
680
|
}).readonly().superRefine((group, ctx) => {
|
|
678
681
|
validateCategoryGroupSeries(group, ctx);
|
|
679
682
|
});
|
|
683
|
+
const areaChartGroupSchema = AreaChartGroupRawSchema;
|
|
680
684
|
const pieOptionsFields = {
|
|
681
685
|
explosion: roundedIntInRangeSchema({
|
|
682
686
|
minimum: 0,
|
|
@@ -693,15 +697,16 @@ const pieOptionsFields = {
|
|
|
693
697
|
label: "firstSliceAngle"
|
|
694
698
|
}).optional()
|
|
695
699
|
};
|
|
696
|
-
const
|
|
700
|
+
const PieChartGroupRawSchema = z.strictObject({
|
|
697
701
|
kind: z.literal("pie"),
|
|
698
|
-
data:
|
|
702
|
+
data: rawSharedCategoryDataSchema,
|
|
699
703
|
series: z.array(chartSeriesSchema).min(1).readonly(),
|
|
700
704
|
...pieOptionsFields,
|
|
701
|
-
dataLabels: z.union([z.literal(false),
|
|
705
|
+
dataLabels: z.union([z.literal(false), rawChartDataLabelsBaseSchema]).optional()
|
|
702
706
|
}).readonly().superRefine((group, ctx) => {
|
|
703
707
|
validateCategoryGroupSeries(group, ctx);
|
|
704
708
|
});
|
|
709
|
+
const pieChartGroupSchema = PieChartGroupRawSchema;
|
|
705
710
|
const doughnutOptionsFields = {
|
|
706
711
|
kind: z.literal("doughnut"),
|
|
707
712
|
...pieOptionsFields,
|
|
@@ -712,27 +717,27 @@ const doughnutOptionsFields = {
|
|
|
712
717
|
errorCode: "invalid-chart-option",
|
|
713
718
|
label: "holeSize"
|
|
714
719
|
}).optional(),
|
|
715
|
-
dataLabels: z.union([z.literal(false),
|
|
720
|
+
dataLabels: z.union([z.literal(false), rawChartDataLabelsBaseSchema]).optional()
|
|
716
721
|
};
|
|
717
722
|
const DoughnutSharedGroupRawSchema = z.strictObject({
|
|
718
723
|
...doughnutOptionsFields,
|
|
719
|
-
data:
|
|
724
|
+
data: rawSharedCategoryDataSchema,
|
|
720
725
|
series: z.array(chartSeriesSchema).min(1).readonly()
|
|
721
726
|
}).readonly();
|
|
722
727
|
const DoughnutIndependentGroupRawSchema = z.strictObject({
|
|
723
728
|
...doughnutOptionsFields,
|
|
724
|
-
data:
|
|
729
|
+
data: rawIndependentCategoryDataSchema,
|
|
725
730
|
series: z.array(independentCategorySeriesSchema).min(1).readonly()
|
|
726
731
|
}).readonly();
|
|
727
732
|
const doughnutChartGroupSchema = z.union([DoughnutSharedGroupRawSchema, DoughnutIndependentGroupRawSchema]).superRefine((group, ctx) => {
|
|
728
733
|
validateCategoryGroupSeries(group, ctx);
|
|
729
734
|
});
|
|
730
|
-
const
|
|
735
|
+
const rawScatterChartGroupSchema = z.strictObject({
|
|
731
736
|
kind: z.literal("scatter"),
|
|
732
|
-
data:
|
|
737
|
+
data: rawScatterDataSchema,
|
|
733
738
|
series: z.array(scatterChartSeriesSchema).min(1).readonly(),
|
|
734
|
-
axes:
|
|
735
|
-
line:
|
|
739
|
+
axes: rawChartXYAxisReferencesSchema.optional(),
|
|
740
|
+
line: rawScatterLineSchema.optional(),
|
|
736
741
|
markers: z.boolean().optional(),
|
|
737
742
|
dataLabels: z.union([z.literal(false), scatterDataLabelsObjectSchema.readonly()]).optional()
|
|
738
743
|
}).readonly().superRefine((group, ctx) => {
|
|
@@ -740,13 +745,13 @@ const scatterChartGroupSchema = z.strictObject({
|
|
|
740
745
|
const markers = group.markers ?? true;
|
|
741
746
|
const showLine = line !== void 0 && line !== false;
|
|
742
747
|
if (!showLine && !markers) addChartIssue(ctx, "invalid-scatter-presentation", "scatter group must draw markers or a connecting line");
|
|
743
|
-
validateDataLabelSettingsForKind(group.dataLabels, "scatter", void 0, ctx, ["dataLabels"],
|
|
748
|
+
validateDataLabelSettingsForKind(group.dataLabels, "scatter", void 0, ctx, ["dataLabels"], false);
|
|
744
749
|
for (const [seriesIndex, item] of group.series.entries()) {
|
|
745
750
|
const seriesPath = ["series", seriesIndex];
|
|
746
751
|
if (item.x.length !== item.y.length) addChartIssue(ctx, "invalid-data", `Series "${item.name}" has ${item.x.length} X and ${item.y.length} Y observations`, [...seriesPath]);
|
|
747
752
|
if (!showLine && item.line !== void 0) addChartIssue(ctx, "invalid-line", `Series "${item.name}".line requires a connecting line on its scatter group`, [...seriesPath, "line"]);
|
|
748
753
|
if (!markers && item.marker !== void 0 && item.marker !== false) addChartIssue(ctx, "invalid-marker", `Series "${item.name}".marker requires the scatter group to enable markers`, [...seriesPath, "marker"]);
|
|
749
|
-
validateDataLabelSettingsForKind(item.dataLabels, "scatter", void 0, ctx, [...seriesPath, "dataLabels"], false
|
|
754
|
+
validateDataLabelSettingsForKind(item.dataLabels, "scatter", void 0, ctx, [...seriesPath, "dataLabels"], false);
|
|
750
755
|
validatePointIndexKeys(item.points, item.x.length, item.name, ctx, seriesPath);
|
|
751
756
|
if (item.points !== void 0) for (const [rawIndex, point] of Object.entries(item.points)) {
|
|
752
757
|
if (!markers && point.marker !== void 0 && point.marker !== false) addChartIssue(ctx, "invalid-marker", `Series "${item.name}" data point ${rawIndex}.marker requires the scatter group to enable markers`, [
|
|
@@ -760,7 +765,7 @@ const scatterChartGroupSchema = z.strictObject({
|
|
|
760
765
|
"points",
|
|
761
766
|
rawIndex,
|
|
762
767
|
"dataLabels"
|
|
763
|
-
], false
|
|
768
|
+
], false);
|
|
764
769
|
}
|
|
765
770
|
if (item.errorBars !== void 0) {
|
|
766
771
|
validateErrorBarsForKind(item.errorBars.x, "scatter", item.x.length, ctx, [
|
|
@@ -783,68 +788,61 @@ const scatterChartGroupSchema = z.strictObject({
|
|
|
783
788
|
}), ctx, [...seriesPath, "trendlines"]);
|
|
784
789
|
}
|
|
785
790
|
});
|
|
791
|
+
const scatterChartGroupSchema = rawScatterChartGroupSchema;
|
|
786
792
|
const chartGroupSchema = z.union([
|
|
787
793
|
columnOrBarChartGroupSchema,
|
|
788
794
|
lineChartGroupSchema,
|
|
789
795
|
areaChartGroupSchema,
|
|
790
796
|
pieChartGroupSchema,
|
|
791
797
|
doughnutChartGroupSchema,
|
|
792
|
-
|
|
798
|
+
rawScatterChartGroupSchema
|
|
793
799
|
]);
|
|
794
|
-
const
|
|
800
|
+
const rawChartLegendSchema = z.union([z.literal(false), z.enum([
|
|
795
801
|
"top",
|
|
796
802
|
"bottom",
|
|
797
803
|
"left",
|
|
798
804
|
"right",
|
|
799
805
|
"topRight"
|
|
800
806
|
])]);
|
|
801
|
-
const
|
|
807
|
+
const chartLegendSchema = rawChartLegendSchema;
|
|
808
|
+
const rawChartPlotAreaSchema = z.strictObject({
|
|
802
809
|
left: z.number().finite().nonnegative(),
|
|
803
810
|
top: z.number().finite().nonnegative(),
|
|
804
811
|
width: z.number().finite().positive(),
|
|
805
812
|
height: z.number().finite().positive()
|
|
806
813
|
}).readonly();
|
|
814
|
+
const chartPlotAreaSchema = rawChartPlotAreaSchema;
|
|
807
815
|
const chartCoordinateSchema = z.number().finite().min(-1e6).max(1e6);
|
|
808
816
|
const chartExtentSchema = z.number().finite().positive().superRefine((value, ctx) => {
|
|
809
817
|
const emu = pxToEmu(value);
|
|
810
818
|
if (emu < 1 || emu > maximumShapeExtentEmu) addChartIssue(ctx, "invalid-coordinate", `converted value must be within closed interval of 1 to ${maximumShapeExtentEmu} EMU`);
|
|
811
819
|
});
|
|
812
|
-
const motionPropsShape = motionPropsSchema.unwrap().shape;
|
|
813
820
|
const chartPropsObjectSchema = z.strictObject({
|
|
814
821
|
id: authorIdSchema.optional(),
|
|
815
822
|
name: xmlStringSchema("Chart.name").optional(),
|
|
816
823
|
placeholder: z.string().optional(),
|
|
817
|
-
nativePlaceholder: nativePlaceholderRefSchema.optional(),
|
|
818
824
|
morphKey: morphKeySchema.optional(),
|
|
819
825
|
link: linkTargetSchema.optional(),
|
|
820
|
-
x: chartCoordinateSchema.optional(),
|
|
821
|
-
y: chartCoordinateSchema.optional(),
|
|
822
|
-
width: chartExtentSchema.optional(),
|
|
823
|
-
height: chartExtentSchema.optional(),
|
|
824
826
|
axes: chartAxesSchema.optional(),
|
|
825
827
|
groups: z.array(chartGroupSchema).min(1).readonly(),
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
828
|
+
colorMapOverride: colorMapSchema.optional(),
|
|
829
|
+
themeOverride: themeOverrideSchema.optional(),
|
|
830
|
+
title: rawChartTitleSchema.optional(),
|
|
831
|
+
displayBlanksAs: rawChartDisplayBlanksAsSchema.optional(),
|
|
832
|
+
legend: rawChartLegendSchema.optional(),
|
|
833
|
+
legendStyle: rawChartTextStyleSchema.optional(),
|
|
834
|
+
plotArea: rawChartPlotAreaSchema.optional(),
|
|
835
|
+
style: rawChartStyleSchema.optional(),
|
|
836
|
+
...motionPropsShape
|
|
834
837
|
});
|
|
835
838
|
chartPropsObjectSchema.readonly();
|
|
836
839
|
const chartAllowedPropKeys = Object.keys(chartPropsObjectSchema.shape);
|
|
837
840
|
/** Maps a Zod validation issue inside chart authoring data to a stable `CapabilityError` code. */
|
|
838
|
-
function resolveChartZodError(issue, fallbackCode
|
|
839
|
-
if (issue.code === "custom" && "params" in issue && isPlainRecord(issue.params) && typeof issue.params["errorCode"] === "string") {
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
code: issue.params["errorCode"],
|
|
844
|
-
message: issue.message,
|
|
845
|
-
...fieldPath === void 0 ? {} : { fieldPath }
|
|
846
|
-
};
|
|
847
|
-
}
|
|
841
|
+
function resolveChartZodError(issue, fallbackCode) {
|
|
842
|
+
if (issue.code === "custom" && "params" in issue && isPlainRecord(issue.params) && typeof issue.params["errorCode"] === "string") return {
|
|
843
|
+
code: issue.params["errorCode"],
|
|
844
|
+
message: issue.message
|
|
845
|
+
};
|
|
848
846
|
const path = issue.path;
|
|
849
847
|
if (issue.code === "unrecognized_keys") return {
|
|
850
848
|
code: "unknown-parameter",
|
|
@@ -855,7 +853,7 @@ function resolveChartZodError(issue, fallbackCode, groupLabel) {
|
|
|
855
853
|
code: "invalid-font-size",
|
|
856
854
|
message: `${pathStr}: ${issue.message}`
|
|
857
855
|
};
|
|
858
|
-
if (pathStr.endsWith(".color") || pathStr.endsWith(".fill")
|
|
856
|
+
if (pathStr.endsWith(".color") || pathStr.endsWith(".fill")) return {
|
|
859
857
|
code: "invalid-color",
|
|
860
858
|
message: `${pathStr}: ${issue.message}`
|
|
861
859
|
};
|
|
@@ -942,14 +940,19 @@ function resolveChartZodError(issue, fallbackCode, groupLabel) {
|
|
|
942
940
|
}
|
|
943
941
|
function throwChartZodError(error, fallbackCode, label) {
|
|
944
942
|
const issue = error.issues[0];
|
|
945
|
-
if (issue === void 0) throw new CapabilityError(fallbackCode, `${label} is invalid
|
|
946
|
-
const resolved = resolveChartZodError(issue, fallbackCode
|
|
947
|
-
|
|
943
|
+
if (issue === void 0) throw new CapabilityError(fallbackCode, `${label} is invalid`, void 0, { field: label });
|
|
944
|
+
const resolved = resolveChartZodError(issue, fallbackCode);
|
|
945
|
+
const prop = issue.code === "unrecognized_keys" ? issue.keys[0] : void 0;
|
|
946
|
+
const field = zodIssueField(issue, label);
|
|
947
|
+
throw new CapabilityError(resolved.code, resolved.message, void 0, {
|
|
948
|
+
field,
|
|
949
|
+
prop
|
|
950
|
+
});
|
|
948
951
|
}
|
|
949
952
|
/** Validates and parses a chart axis entry using the local `ChartAxis` Zod schemas. */
|
|
950
953
|
function parseChartAxisBySchema(value, label, expected) {
|
|
951
|
-
if (!isPlainRecord(value)) throw new CapabilityError("invalid-axis", `${label} must be an object
|
|
952
|
-
if (value["kind"] !== expected) throw new CapabilityError("invalid-chart-axis-role", `${label} must declare kind "${expected}" as referenced by its chart group`);
|
|
954
|
+
if (!isPlainRecord(value)) throw new CapabilityError("invalid-axis", `${label} must be an object`, void 0, { field: label });
|
|
955
|
+
if (value["kind"] !== expected) throw new CapabilityError("invalid-chart-axis-role", `${label} must declare kind "${expected}" as referenced by its chart group`, void 0, { field: `${label}.kind` });
|
|
953
956
|
const parsed = (expected === "category" ? chartCategoryAxisSchema : chartValueAxisSchema).safeParse(value);
|
|
954
957
|
if (!parsed.success) {
|
|
955
958
|
const first = parsed.error.issues[0];
|
|
@@ -960,41 +963,39 @@ function parseChartAxisBySchema(value, label, expected) {
|
|
|
960
963
|
"minorUnit",
|
|
961
964
|
"numberFormat",
|
|
962
965
|
"logBase"
|
|
963
|
-
].includes(k))) throw new CapabilityError("invalid-axis", `${label}.${first.keys[0]} is only applicable to value axis`);
|
|
966
|
+
].includes(k))) throw new CapabilityError("invalid-axis", `${label}.${first.keys[0]} is only applicable to value axis`, void 0, { field: `${label}.${first.keys[0]}` });
|
|
964
967
|
throwChartZodError(parsed.error, "invalid-axis", label);
|
|
965
968
|
}
|
|
966
969
|
return parsed.data;
|
|
967
970
|
}
|
|
971
|
+
const commonGroupShape = ColumnOrBarStackedGroupSchema.unwrap().pick({
|
|
972
|
+
kind: true,
|
|
973
|
+
data: true,
|
|
974
|
+
series: true,
|
|
975
|
+
axes: true,
|
|
976
|
+
dataLabels: true
|
|
977
|
+
}).shape;
|
|
978
|
+
function groupOptionKeysFromShape(shape) {
|
|
979
|
+
return Object.keys(shape).filter((key) => !Object.hasOwn(commonGroupShape, key));
|
|
980
|
+
}
|
|
968
981
|
const groupOptionsByKind = {
|
|
969
|
-
column:
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
"gapWidth",
|
|
977
|
-
"overlap"
|
|
978
|
-
],
|
|
979
|
-
line: ["stacking"],
|
|
980
|
-
area: ["stacking"],
|
|
981
|
-
pie: ["explosion", "firstSliceAngle"],
|
|
982
|
-
doughnut: [
|
|
983
|
-
"explosion",
|
|
984
|
-
"firstSliceAngle",
|
|
985
|
-
"holeSize"
|
|
986
|
-
],
|
|
987
|
-
scatter: ["line", "markers"]
|
|
982
|
+
column: groupOptionKeysFromShape(ColumnOrBarStackedGroupSchema.unwrap().shape),
|
|
983
|
+
bar: groupOptionKeysFromShape(ColumnOrBarStackedGroupSchema.unwrap().shape),
|
|
984
|
+
line: groupOptionKeysFromShape(LineChartGroupRawSchema.unwrap().shape),
|
|
985
|
+
area: groupOptionKeysFromShape(AreaChartGroupRawSchema.unwrap().shape),
|
|
986
|
+
pie: groupOptionKeysFromShape(PieChartGroupRawSchema.unwrap().shape),
|
|
987
|
+
doughnut: groupOptionKeysFromShape(DoughnutSharedGroupRawSchema.unwrap().shape),
|
|
988
|
+
scatter: groupOptionKeysFromShape(rawScatterChartGroupSchema.unwrap().shape)
|
|
988
989
|
};
|
|
989
990
|
/** Validates and parses one chart group entry via its kind-specific local Zod schema. */
|
|
990
991
|
function parseChartGroupBySchema(value, label) {
|
|
991
|
-
if (!isPlainRecord(value)) throw new CapabilityError("invalid-chart-groups", `${label} must be an object
|
|
992
|
+
if (!isPlainRecord(value)) throw new CapabilityError("invalid-chart-groups", `${label} must be an object`, void 0, { field: label });
|
|
992
993
|
const kindParsed = chartKindSchema.safeParse(value["kind"]);
|
|
993
|
-
if (!kindParsed.success) throw new CapabilityError("unsupported-chart-kind", `Unsupported chart kind ${String(value["kind"])}`);
|
|
994
|
+
if (!kindParsed.success) throw new CapabilityError("unsupported-chart-kind", `Unsupported chart kind ${String(value["kind"])}`, void 0, { field: `${label}.kind` });
|
|
994
995
|
const kind = kindParsed.data;
|
|
995
996
|
for (const key of Object.keys(value)) if (key !== "kind" && key !== "data" && key !== "series" && key !== "axes" && key !== "dataLabels" && !groupOptionsByKind[kind].includes(key)) {
|
|
996
997
|
const isKnownOtherGroupOption = Object.values(groupOptionsByKind).flat().includes(key);
|
|
997
|
-
throw new CapabilityError(isKnownOtherGroupOption ? "invalid-chart-option" : "unknown-parameter", isKnownOtherGroupOption ? `${kind} chart group does not support ${key}` : `${label} contains unimplemented parameter ${key}`);
|
|
998
|
+
throw new CapabilityError(isKnownOtherGroupOption ? "invalid-chart-option" : "unknown-parameter", isKnownOtherGroupOption ? `${kind} chart group does not support ${key}` : `${label} contains unimplemented parameter ${key}`, void 0, { field: `${label}.${key}` });
|
|
998
999
|
}
|
|
999
1000
|
if (kind === "scatter") {
|
|
1000
1001
|
const parsed = scatterChartGroupSchema.safeParse(value);
|
|
@@ -1036,37 +1037,40 @@ function parseChartTitleBySchema(value, label) {
|
|
|
1036
1037
|
function parseChartPlotAreaBySchema(value, box) {
|
|
1037
1038
|
if (value === void 0) return void 0;
|
|
1038
1039
|
const parsed = chartPlotAreaSchema.safeParse(value);
|
|
1039
|
-
if (!parsed.success) throwChartZodError(parsed.error, "invalid-plot-area", "
|
|
1040
|
+
if (!parsed.success) throwChartZodError(parsed.error, "invalid-plot-area", "plotArea");
|
|
1040
1041
|
const result = parsed.data;
|
|
1041
|
-
if (box !== void 0 && (result.left + result.width > box.width || result.top + result.height > box.height)) throw new CapabilityError("invalid-plot-area", "Chart.plotArea must be inside chart box with positive width and height");
|
|
1042
|
+
if (box !== void 0 && (result.left + result.width > box.width || result.top + result.height > box.height)) throw new CapabilityError("invalid-plot-area", "Chart.plotArea must be inside chart box with positive width and height", void 0, { field: "plotArea" });
|
|
1042
1043
|
return result;
|
|
1043
1044
|
}
|
|
1044
1045
|
/** Validates and parses `Chart.legend` using `chartLegendSchema`. */
|
|
1045
1046
|
function parseChartLegendBySchema(value) {
|
|
1046
1047
|
if (value === void 0) return void 0;
|
|
1047
1048
|
const parsed = chartLegendSchema.safeParse(value);
|
|
1048
|
-
if (!parsed.success) throw new CapabilityError("invalid-legend", "Chart.legend must be false, top, bottom, left, right, or topRight");
|
|
1049
|
+
if (!parsed.success) throw new CapabilityError("invalid-legend", "Chart.legend must be false, top, bottom, left, right, or topRight", void 0, { field: "legend" });
|
|
1049
1050
|
return parsed.data;
|
|
1050
1051
|
}
|
|
1051
1052
|
/** Validates and parses a chart coordinate (`x` or `y`) via `chartCoordinateSchema`. */
|
|
1052
1053
|
function parseChartCoordinateBySchema(value, label) {
|
|
1053
1054
|
if (value === void 0) return 0;
|
|
1054
1055
|
const parsed = chartCoordinateSchema.safeParse(value);
|
|
1055
|
-
if (!parsed.success) throw new CapabilityError("invalid-coordinate", `${label} must be a finite pixel value between -1000000 and 1000000
|
|
1056
|
+
if (!parsed.success) throw new CapabilityError("invalid-coordinate", `${label} must be a finite pixel value between -1000000 and 1000000`, void 0, { field: label === "x" ? "style.left" : "style.top" });
|
|
1056
1057
|
return parsed.data;
|
|
1057
1058
|
}
|
|
1058
1059
|
/** Validates and parses a chart extent (`width` or `height`) via `chartExtentSchema`. */
|
|
1059
1060
|
function parseChartExtentBySchema(value, label) {
|
|
1060
|
-
if (typeof value
|
|
1061
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
1062
|
+
if (value === 0 || pxToEmu(value) === 0) throw new CapabilityError("invalid-coordinate", `Computed ${label} is 0px; ${label} must be greater than 0px`, void 0, { field: `style.${label}` });
|
|
1063
|
+
if (value < 0 || pxToEmu(value) < 1) throw new CapabilityError("invalid-coordinate", `Computed ${label} is ${value}px; ${label} must be greater than 0px`, void 0, { field: `style.${label}` });
|
|
1064
|
+
} else throw new CapabilityError("invalid-coordinate", `${label} must be a finite positive pixel value`, void 0, { field: `style.${label}` });
|
|
1061
1065
|
const parsed = chartExtentSchema.safeParse(value);
|
|
1062
|
-
if (!parsed.success) throwChartZodError(parsed.error, "invalid-coordinate", `
|
|
1066
|
+
if (!parsed.success) throwChartZodError(parsed.error, "invalid-coordinate", `style.${label}`);
|
|
1063
1067
|
return parsed.data;
|
|
1064
1068
|
}
|
|
1065
1069
|
/** Validates and parses `Chart.displayBlanksAs` via `chartDisplayBlanksAsSchema`. */
|
|
1066
1070
|
function parseChartDisplayBlanksAsBySchema(value) {
|
|
1067
1071
|
if (value === void 0) return void 0;
|
|
1068
1072
|
const parsed = chartDisplayBlanksAsSchema.safeParse(value);
|
|
1069
|
-
if (!parsed.success) throw new CapabilityError("invalid-chart-missing-values", "Chart.displayBlanksAs must be gap, zero, or span");
|
|
1073
|
+
if (!parsed.success) throw new CapabilityError("invalid-chart-missing-values", "Chart.displayBlanksAs must be gap, zero, or span", void 0, { field: "displayBlanksAs" });
|
|
1070
1074
|
return parsed.data;
|
|
1071
1075
|
}
|
|
1072
1076
|
/** Validates an XML 1.0 string via `xmlStringSchema`. */
|
|
@@ -1075,4 +1079,4 @@ function parseChartXmlTextBySchema(value, label) {
|
|
|
1075
1079
|
if (!parsed.success) throwChartZodError(parsed.error, "invalid-xml-character", label);
|
|
1076
1080
|
return parsed.data;
|
|
1077
1081
|
}
|
|
1078
|
-
export { areaChartGroupSchema, chartAllowedPropKeys, chartAxesSchema,
|
|
1082
|
+
export { areaChartGroupSchema, chartAllowedPropKeys, chartAxesSchema, chartCategoryAxisSchema, chartCoordinateSchema, chartDisplayBlanksAsSchema, chartExtentSchema, chartGroupSchema, chartKindSchema, chartLegendSchema, chartMarkerOptionSchema, chartPlotAreaSchema, chartPointSchema, chartPointValueSchema, chartSeriesSchema, chartStyleKeys, chartStyleSchema, chartTextStyleKeys, chartTextStyleSchema, chartTitleSchema, chartValueAxisSchema, columnOrBarChartGroupSchema, doughnutChartGroupSchema, independentCategorySeriesSchema, lineChartGroupSchema, parseChartAxisBySchema, parseChartCoordinateBySchema, parseChartDisplayBlanksAsBySchema, parseChartExtentBySchema, parseChartGroupBySchema, parseChartLegendBySchema, parseChartPlotAreaBySchema, parseChartTitleBySchema, parseChartXmlTextBySchema, pieChartGroupSchema, resolveChartZodError, scatterChartGroupSchema, scatterChartSeriesSchema };
|