@office-open/core 0.6.10 → 0.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@office-open/core",
3
- "version": "0.6.10",
3
+ "version": "0.7.1",
4
4
  "description": "Shared OOXML infrastructure: XmlComponent, value validators, unit converters",
5
5
  "keywords": [
6
6
  "core",
@@ -55,7 +55,8 @@
55
55
  "fflate": "0.8.3",
56
56
  "hash.js": "1.1.7",
57
57
  "nanoid": "5.1.11",
58
- "@office-open/xml": "0.6.10"
58
+ "undio": "0.2.0",
59
+ "@office-open/xml": "0.7.1"
59
60
  },
60
61
  "scripts": {
61
62
  "dev": "basis build --stub",
@@ -1,617 +0,0 @@
1
- import { a as BuilderElement, g as wrapEl, l as chartAttr, o as EmptyElement, y as XmlComponent } from "./xml-components-xJkfJ6ff.mjs";
2
- //#region src/chart/axes.ts
3
- /**
4
- * c:scaling — axis scaling configuration (minOccurs=1 in EG_AxShared).
5
- */
6
- var Scaling = class extends XmlComponent {
7
- constructor() {
8
- super("c:scaling");
9
- this.root.push(wrapEl("c:orientation", chartAttr({ val: "minMax" })));
10
- }
11
- };
12
- /**
13
- * c:catAx — category axis.
14
- *
15
- * XSD sequence: EG_AxShared (axId, scaling, delete, axPos, ..., crossAx, crosses)
16
- * then: auto, lblAlgn, lblOffset, tickLblSkip, tickMarkSkip, noMultiLvlLbl
17
- */
18
- var CatAx = class extends XmlComponent {
19
- constructor(axId, crossAx) {
20
- super("c:catAx");
21
- this.root.push(wrapEl("c:axId", chartAttr({ val: axId })));
22
- this.root.push(new Scaling());
23
- this.root.push(wrapEl("c:delete", chartAttr({ val: 0 })));
24
- this.root.push(wrapEl("c:axPos", chartAttr({ val: "b" })));
25
- this.root.push(wrapEl("c:crossAx", chartAttr({ val: crossAx })));
26
- this.root.push(wrapEl("c:crosses", chartAttr({ val: "autoZero" })));
27
- this.root.push(wrapEl("c:auto", chartAttr({ val: 1 })));
28
- this.root.push(wrapEl("c:lblOffset", chartAttr({ val: 100 })));
29
- this.root.push(wrapEl("c:noMultiLvlLbl", chartAttr({ val: 0 })));
30
- }
31
- };
32
- /**
33
- * c:valAx — value axis.
34
- *
35
- * XSD sequence: EG_AxShared (axId, scaling, delete, axPos, ..., spPr, ..., crossAx, crosses)
36
- * then: crossBetween, majorUnit, minorUnit, dispUnits
37
- */
38
- var ValAx = class extends XmlComponent {
39
- constructor(axId, crossAx) {
40
- super("c:valAx");
41
- this.root.push(wrapEl("c:axId", chartAttr({ val: axId })));
42
- this.root.push(new Scaling());
43
- this.root.push(wrapEl("c:delete", chartAttr({ val: 0 })));
44
- this.root.push(wrapEl("c:axPos", chartAttr({ val: "l" })));
45
- this.root.push(wrapEl("c:numFmt", chartAttr({
46
- formatCode: "General",
47
- sourceLinked: 1
48
- })));
49
- this.root.push(new BuilderElement({ name: "c:spPr" }));
50
- this.root.push(wrapEl("c:crossAx", chartAttr({ val: crossAx })));
51
- this.root.push(wrapEl("c:crosses", chartAttr({ val: "autoZero" })));
52
- }
53
- };
54
- //#endregion
55
- //#region src/chart/series/series-data.ts
56
- const createStrRef = (values) => {
57
- return new StrRef(typeof values === "string" ? [values] : values);
58
- };
59
- const createNumRef = (values) => new NumRef(values);
60
- var StrRef = class extends XmlComponent {
61
- constructor(values) {
62
- super("c:strRef");
63
- this.root.push(new EmptyElement("c:f"));
64
- this.root.push(new StrCache(values));
65
- }
66
- };
67
- var StrCache = class extends XmlComponent {
68
- constructor(values) {
69
- super("c:strCache");
70
- this.root.push(wrapEl("c:ptCount", chartAttr({ val: values.length })));
71
- for (let i = 0; i < values.length; i++) this.root.push(new StrPt(i, values[i]));
72
- }
73
- };
74
- var StrPt = class extends XmlComponent {
75
- constructor(index, value) {
76
- super("c:pt");
77
- this.root.push(chartAttr({ idx: index }));
78
- this.root.push(new StringValue("c:v", value));
79
- }
80
- };
81
- var NumRef = class extends XmlComponent {
82
- constructor(values) {
83
- super("c:numRef");
84
- this.root.push(new EmptyElement("c:f"));
85
- this.root.push(new NumCache(values));
86
- }
87
- };
88
- var NumCache = class extends XmlComponent {
89
- constructor(values) {
90
- super("c:numCache");
91
- this.root.push(new FormatCode("General"));
92
- this.root.push(wrapEl("c:ptCount", chartAttr({ val: values.length })));
93
- for (let i = 0; i < values.length; i++) this.root.push(new NumPt(i, values[i]));
94
- }
95
- };
96
- var NumPt = class extends XmlComponent {
97
- constructor(index, value) {
98
- super("c:pt");
99
- this.root.push(chartAttr({ idx: index }));
100
- this.root.push(new StringValue("c:v", String(value)));
101
- }
102
- };
103
- var FormatCode = class extends XmlComponent {
104
- constructor(code) {
105
- super("c:formatCode");
106
- this.root.push(code);
107
- }
108
- };
109
- var StringValue = class extends XmlComponent {
110
- constructor(name, val) {
111
- super(name);
112
- this.root.push(val);
113
- }
114
- };
115
- //#endregion
116
- //#region src/chart/chart-types/area-chart.ts
117
- var AreaChart = class extends XmlComponent {
118
- constructor(options) {
119
- super("c:areaChart");
120
- this.root.push(wrapEl("c:grouping", chartAttr({ val: "standard" })));
121
- for (let i = 0; i < options.series.length; i++) this.root.push(new AreaSeries(i, options.series[i], options.categories));
122
- this.root.push(wrapEl("c:axId", chartAttr({ val: 10 })));
123
- this.root.push(wrapEl("c:axId", chartAttr({ val: 20 })));
124
- }
125
- };
126
- var AreaSeries = class extends XmlComponent {
127
- constructor(index, series, categories) {
128
- super("c:ser");
129
- this.root.push(wrapEl("c:idx", chartAttr({ val: index })));
130
- this.root.push(wrapEl("c:order", chartAttr({ val: index })));
131
- this.root.push(new SeriesTx$4(series.name));
132
- this.root.push(new EmptyElement("c:spPr"));
133
- this.root.push(new SeriesCat$4(categories));
134
- this.root.push(new SeriesVal$4(series.values));
135
- }
136
- };
137
- var SeriesTx$4 = class extends XmlComponent {
138
- constructor(name) {
139
- super("c:tx");
140
- this.root.push(createStrRef(name));
141
- }
142
- };
143
- var SeriesCat$4 = class extends XmlComponent {
144
- constructor(categories) {
145
- super("c:cat");
146
- this.root.push(createStrRef(categories));
147
- }
148
- };
149
- var SeriesVal$4 = class extends XmlComponent {
150
- constructor(values) {
151
- super("c:val");
152
- this.root.push(createNumRef(values));
153
- }
154
- };
155
- //#endregion
156
- //#region src/chart/chart-types/bar-chart.ts
157
- var BarChart = class extends XmlComponent {
158
- constructor(options) {
159
- super("c:barChart");
160
- this.root.push(wrapEl("c:barDir", chartAttr({ val: options.barDirection })));
161
- this.root.push(wrapEl("c:grouping", chartAttr({ val: "clustered" })));
162
- for (let i = 0; i < options.series.length; i++) this.root.push(new BarSeries(i, options.series[i], options.categories));
163
- this.root.push(wrapEl("c:axId", chartAttr({ val: 10 })));
164
- this.root.push(wrapEl("c:axId", chartAttr({ val: 20 })));
165
- }
166
- };
167
- var BarSeries = class extends XmlComponent {
168
- constructor(index, series, categories) {
169
- super("c:ser");
170
- this.root.push(wrapEl("c:idx", chartAttr({ val: index })));
171
- this.root.push(wrapEl("c:order", chartAttr({ val: index })));
172
- this.root.push(new SeriesTx$3(series.name));
173
- this.root.push(new EmptyElement("c:spPr"));
174
- this.root.push(new SeriesCat$3(categories));
175
- this.root.push(new SeriesVal$3(series.values));
176
- }
177
- };
178
- var SeriesTx$3 = class extends XmlComponent {
179
- constructor(name) {
180
- super("c:tx");
181
- this.root.push(createStrRef(name));
182
- }
183
- };
184
- var SeriesCat$3 = class extends XmlComponent {
185
- constructor(categories) {
186
- super("c:cat");
187
- this.root.push(createStrRef(categories));
188
- }
189
- };
190
- var SeriesVal$3 = class extends XmlComponent {
191
- constructor(values) {
192
- super("c:val");
193
- this.root.push(createNumRef(values));
194
- }
195
- };
196
- //#endregion
197
- //#region src/chart/chart-types/line-chart.ts
198
- var LineChart = class extends XmlComponent {
199
- constructor(options) {
200
- super("c:lineChart");
201
- this.root.push(wrapEl("c:grouping", chartAttr({ val: "standard" })));
202
- for (let i = 0; i < options.series.length; i++) this.root.push(new LineSeries(i, options.series[i], options.categories));
203
- this.root.push(wrapEl("c:axId", chartAttr({ val: 10 })));
204
- this.root.push(wrapEl("c:axId", chartAttr({ val: 20 })));
205
- }
206
- };
207
- var LineSeries = class extends XmlComponent {
208
- constructor(index, series, categories) {
209
- super("c:ser");
210
- this.root.push(wrapEl("c:idx", chartAttr({ val: index })));
211
- this.root.push(wrapEl("c:order", chartAttr({ val: index })));
212
- this.root.push(new SeriesTx$2(series.name));
213
- this.root.push(new EmptyElement("c:spPr"));
214
- this.root.push(new SeriesCat$2(categories));
215
- this.root.push(new SeriesVal$2(series.values));
216
- }
217
- };
218
- var SeriesTx$2 = class extends XmlComponent {
219
- constructor(name) {
220
- super("c:tx");
221
- this.root.push(createStrRef(name));
222
- }
223
- };
224
- var SeriesCat$2 = class extends XmlComponent {
225
- constructor(categories) {
226
- super("c:cat");
227
- this.root.push(createStrRef(categories));
228
- }
229
- };
230
- var SeriesVal$2 = class extends XmlComponent {
231
- constructor(values) {
232
- super("c:val");
233
- this.root.push(createNumRef(values));
234
- }
235
- };
236
- //#endregion
237
- //#region src/chart/chart-types/pie-chart.ts
238
- var PieChart = class extends XmlComponent {
239
- constructor(options) {
240
- super("c:pieChart");
241
- this.root.push(wrapEl("c:varyColors", chartAttr({ val: true })));
242
- for (let i = 0; i < options.series.length; i++) this.root.push(new PieSeries(i, options.series[i], options.categories));
243
- }
244
- };
245
- var PieSeries = class extends XmlComponent {
246
- constructor(index, series, categories) {
247
- super("c:ser");
248
- this.root.push(wrapEl("c:idx", chartAttr({ val: index })));
249
- this.root.push(wrapEl("c:order", chartAttr({ val: index })));
250
- this.root.push(new SeriesTx$1(series.name));
251
- this.root.push(new EmptyElement("c:spPr"));
252
- this.root.push(new SeriesCat$1(categories));
253
- this.root.push(new SeriesVal$1(series.values));
254
- }
255
- };
256
- var SeriesTx$1 = class extends XmlComponent {
257
- constructor(name) {
258
- super("c:tx");
259
- this.root.push(createStrRef(name));
260
- }
261
- };
262
- var SeriesCat$1 = class extends XmlComponent {
263
- constructor(categories) {
264
- super("c:cat");
265
- this.root.push(createStrRef(categories));
266
- }
267
- };
268
- var SeriesVal$1 = class extends XmlComponent {
269
- constructor(values) {
270
- super("c:val");
271
- this.root.push(createNumRef(values));
272
- }
273
- };
274
- //#endregion
275
- //#region src/chart/chart-types/scatter-chart.ts
276
- var ScatterChart = class extends XmlComponent {
277
- constructor(options) {
278
- super("c:scatterChart");
279
- this.root.push(wrapEl("c:scatterStyle", chartAttr({ val: "line" })));
280
- for (let i = 0; i < options.series.length; i++) this.root.push(new ScatterSeries(i, options.series[i], options.categories));
281
- this.root.push(wrapEl("c:axId", chartAttr({ val: 10 })));
282
- this.root.push(wrapEl("c:axId", chartAttr({ val: 20 })));
283
- }
284
- };
285
- var ScatterSeries = class extends XmlComponent {
286
- constructor(index, series, categories) {
287
- super("c:ser");
288
- this.root.push(wrapEl("c:idx", chartAttr({ val: index })));
289
- this.root.push(wrapEl("c:order", chartAttr({ val: index })));
290
- this.root.push(new SeriesTx(series.name));
291
- this.root.push(new EmptyElement("c:spPr"));
292
- this.root.push(new SeriesCat(categories));
293
- this.root.push(new SeriesVal(series.values));
294
- this.root.push(new EmptyElement("c:size"));
295
- }
296
- };
297
- var SeriesTx = class extends XmlComponent {
298
- constructor(name) {
299
- super("c:tx");
300
- this.root.push(createStrRef(name));
301
- }
302
- };
303
- var SeriesCat = class extends XmlComponent {
304
- constructor(categories) {
305
- super("c:cat");
306
- this.root.push(createStrRef(categories));
307
- }
308
- };
309
- var SeriesVal = class extends XmlComponent {
310
- constructor(values) {
311
- super("c:val");
312
- this.root.push(createNumRef(values));
313
- }
314
- };
315
- //#endregion
316
- //#region src/chart/create-chart-type.ts
317
- const createChartType = (options) => {
318
- switch (options.type) {
319
- case "column":
320
- case "bar": return new BarChart({
321
- barDirection: options.type === "column" ? "col" : "bar",
322
- categories: options.categories,
323
- series: options.series
324
- });
325
- case "line": return new LineChart({
326
- categories: options.categories,
327
- series: options.series
328
- });
329
- case "pie": return new PieChart({
330
- categories: options.categories,
331
- series: options.series
332
- });
333
- case "area": return new AreaChart({
334
- categories: options.categories,
335
- series: options.series
336
- });
337
- case "scatter": return new ScatterChart({
338
- categories: options.categories,
339
- series: options.series
340
- });
341
- default: throw new Error(`Unsupported chart type: ${options.type}`);
342
- }
343
- };
344
- //#endregion
345
- //#region src/chart/title.ts
346
- var ChartTitle = class extends XmlComponent {
347
- constructor(title) {
348
- super("c:title");
349
- this.root.push(new TitleTx(title));
350
- this.root.push(new TitleOverlay());
351
- }
352
- };
353
- var TitleTx = class extends XmlComponent {
354
- constructor(title) {
355
- super("c:tx");
356
- const rich = new class extends XmlComponent {
357
- constructor() {
358
- super("c:rich");
359
- }
360
- }();
361
- rich["root"].push(new class extends XmlComponent {
362
- constructor() {
363
- super("a:bodyPr");
364
- }
365
- }());
366
- rich["root"].push(new class extends XmlComponent {
367
- constructor() {
368
- super("a:lstStyle");
369
- }
370
- }());
371
- const p = new class extends XmlComponent {
372
- constructor() {
373
- super("a:p");
374
- }
375
- }();
376
- const r = new class extends XmlComponent {
377
- constructor() {
378
- super("a:r");
379
- }
380
- }();
381
- r["root"].push(new class extends XmlComponent {
382
- constructor() {
383
- super("a:t");
384
- this.root.push(title);
385
- }
386
- }());
387
- p["root"].push(r);
388
- rich["root"].push(p);
389
- this.root.push(rich);
390
- }
391
- };
392
- var TitleOverlay = class extends XmlComponent {
393
- constructor() {
394
- super("c:overlay");
395
- this.root.push(chartAttr({ val: 0 }));
396
- }
397
- };
398
- //#endregion
399
- //#region src/chart/chart-space.ts
400
- /**
401
- * ChartSpace — root element for chart XML parts (c:chartSpace).
402
- *
403
- * Full XSD-compliant implementation with all optional elements.
404
- *
405
- * @module
406
- */
407
- /**
408
- * c:chartSpace — root element for chart XML parts.
409
- */
410
- var ChartSpace = class extends XmlComponent {
411
- constructor(options) {
412
- super("c:chartSpace");
413
- this.root.push(chartAttr({
414
- "xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main",
415
- "xmlns:c": "http://schemas.openxmlformats.org/drawingml/2006/chart",
416
- "xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships"
417
- }));
418
- this.root.push(wrapEl("c:date1904", chartAttr({ val: 0 })));
419
- this.root.push(wrapEl("c:lang", chartAttr({ val: "en-US" })));
420
- this.root.push(wrapEl("c:roundedCorners", chartAttr({ val: 0 })));
421
- if (options.style !== void 0) this.root.push(new ChartStyle(options.style));
422
- const chart = new ChartContainer();
423
- if (options.title) chart["root"].push(new ChartTitle(options.title));
424
- chart["root"].push(wrapEl("c:autoTitleDeleted", chartAttr({ val: 0 })));
425
- const plotArea = new PlotArea();
426
- plotArea["root"].push(new BuilderElement({ name: "c:layout" }));
427
- plotArea["root"].push(createChartType({
428
- categories: options.categories,
429
- series: options.series,
430
- type: options.type
431
- }));
432
- if (options.type !== "pie") if (options.type === "scatter") {
433
- plotArea["root"].push(new ValAx(10, 20));
434
- plotArea["root"].push(new ValAx(20, 10));
435
- } else {
436
- plotArea["root"].push(new CatAx(10, 20));
437
- plotArea["root"].push(new ValAx(20, 10));
438
- }
439
- chart["root"].push(plotArea);
440
- if (options.showLegend !== false) chart["root"].push(createLegend());
441
- this.root.push(chart);
442
- this.root.push(createChartSpPr());
443
- this.root.push(createChartTxPr());
444
- }
445
- };
446
- var ChartContainer = class extends XmlComponent {
447
- constructor() {
448
- super("c:chart");
449
- }
450
- };
451
- var PlotArea = class extends XmlComponent {
452
- constructor() {
453
- super("c:plotArea");
454
- }
455
- };
456
- function createLegend() {
457
- const legend = new class extends XmlComponent {
458
- constructor() {
459
- super("c:legend");
460
- }
461
- }();
462
- legend["root"].push(wrapEl("c:legendPos", chartAttr({ val: "b" })));
463
- legend["root"].push(new BuilderElement({ name: "c:layout" }));
464
- legend["root"].push(wrapEl("c:overlay", chartAttr({ val: 0 })));
465
- legend["root"].push(createNoFillSpPr());
466
- legend["root"].push(createTxPr());
467
- return legend;
468
- }
469
- function createNoFillSpPr() {
470
- const spPr = new class extends XmlComponent {
471
- constructor() {
472
- super("c:spPr");
473
- }
474
- }();
475
- spPr["root"].push(new class extends XmlComponent {
476
- constructor() {
477
- super("a:noFill");
478
- }
479
- }());
480
- spPr["root"].push(new class extends XmlComponent {
481
- constructor() {
482
- super("a:ln");
483
- this.root.push(new class extends XmlComponent {
484
- constructor() {
485
- super("a:noFill");
486
- }
487
- }());
488
- }
489
- }());
490
- spPr["root"].push(new BuilderElement({ name: "a:effectLst" }));
491
- return spPr;
492
- }
493
- function createChartSpPr() {
494
- const spPr = new class extends XmlComponent {
495
- constructor() {
496
- super("c:spPr");
497
- }
498
- }();
499
- spPr["root"].push(new class extends XmlComponent {
500
- constructor() {
501
- super("a:noFill");
502
- }
503
- }());
504
- spPr["root"].push(new class extends XmlComponent {
505
- constructor() {
506
- super("a:ln");
507
- this.root.push(new class extends XmlComponent {
508
- constructor() {
509
- super("a:noFill");
510
- }
511
- }());
512
- }
513
- }());
514
- spPr["root"].push(new BuilderElement({ name: "a:effectLst" }));
515
- return spPr;
516
- }
517
- function createChartTxPr() {
518
- const txPr = new class extends XmlComponent {
519
- constructor() {
520
- super("c:txPr");
521
- }
522
- }();
523
- txPr["root"].push(new BuilderElement({ name: "a:bodyPr" }));
524
- txPr["root"].push(new BuilderElement({ name: "a:lstStyle" }));
525
- txPr["root"].push(createTextParagraph());
526
- return txPr;
527
- }
528
- function createTxPr() {
529
- const txPr = new class extends XmlComponent {
530
- constructor() {
531
- super("c:txPr");
532
- }
533
- }();
534
- txPr["root"].push(createBodyPr());
535
- txPr["root"].push(new BuilderElement({ name: "a:lstStyle" }));
536
- txPr["root"].push(createTextParagraph());
537
- return txPr;
538
- }
539
- function createBodyPr() {
540
- return new BuilderElement({
541
- name: "a:bodyPr",
542
- attributes: {
543
- rot: {
544
- key: "rot",
545
- value: "0"
546
- },
547
- spcFirstLastPara: {
548
- key: "spcFirstLastPara",
549
- value: "1"
550
- },
551
- vertOverflow: {
552
- key: "vertOverflow",
553
- value: "ellipsis"
554
- },
555
- vert: {
556
- key: "vert",
557
- value: "horz"
558
- },
559
- wrap: {
560
- key: "wrap",
561
- value: "square"
562
- },
563
- anchor: {
564
- key: "anchor",
565
- value: "ctr"
566
- },
567
- anchorCtr: {
568
- key: "anchorCtr",
569
- value: "1"
570
- }
571
- }
572
- });
573
- }
574
- function createTextParagraph() {
575
- const p = new class extends XmlComponent {
576
- constructor() {
577
- super("a:p");
578
- }
579
- }();
580
- const pPr = new class extends XmlComponent {
581
- constructor() {
582
- super("a:pPr");
583
- }
584
- }();
585
- pPr["root"].push(new BuilderElement({ name: "a:defRPr" }));
586
- p["root"].push(pPr);
587
- p["root"].push(new BuilderElement({
588
- name: "a:endParaRPr",
589
- attributes: { lang: {
590
- key: "lang",
591
- value: "en-US"
592
- } }
593
- }));
594
- return p;
595
- }
596
- var ChartStyle = class extends XmlComponent {
597
- constructor(val) {
598
- super("c:style");
599
- this.root.push(chartAttr({ val: String(val) }));
600
- }
601
- };
602
- //#endregion
603
- //#region src/chart/chart-collection.ts
604
- var ChartCollection = class {
605
- map;
606
- constructor() {
607
- this.map = /* @__PURE__ */ new Map();
608
- }
609
- addChart(key, chartData) {
610
- this.map.set(key, chartData);
611
- }
612
- get array() {
613
- return [...this.map.values()];
614
- }
615
- };
616
- //#endregion
617
- export { ScatterChart as a, BarChart as c, createStrRef as d, CatAx as f, createChartType as i, AreaChart as l, ChartSpace as n, PieChart as o, ValAx as p, ChartTitle as r, LineChart as s, ChartCollection as t, createNumRef as u };