@office-open/core 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +111 -0
- package/dist/_chunks/id-generators-Ch07cHW1.mjs +72 -0
- package/dist/_chunks/index-3uVYzs32.d.mts +241 -0
- package/dist/_chunks/values-BrGywpRh.d.mts +400 -0
- package/dist/_chunks/xml-components-DazgCiyL.mjs +364 -0
- package/dist/archive.d.mts +42 -0
- package/dist/archive.mjs +101 -0
- package/dist/chart/index.d.mts +83 -0
- package/dist/chart/index.mjs +360 -0
- package/dist/drawingml/index.d.mts +3119 -0
- package/dist/drawingml/index.mjs +3698 -0
- package/dist/index.d.mts +126 -0
- package/dist/index.mjs +118 -0
- package/dist/smartart/index.d.mts +69 -0
- package/dist/smartart/index.mjs +304 -0
- package/dist/values.d.mts +2 -0
- package/dist/values.mjs +371 -0
- package/package.json +70 -0
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
import { T as XmlComponent, b as wrapEl, o as EmptyElement, p as chartAttr } from "../_chunks/xml-components-DazgCiyL.mjs";
|
|
2
|
+
//#region src/chart/chart-collection.ts
|
|
3
|
+
var ChartCollection = class {
|
|
4
|
+
map;
|
|
5
|
+
constructor() {
|
|
6
|
+
this.map = /* @__PURE__ */ new Map();
|
|
7
|
+
}
|
|
8
|
+
addChart(key, chartData) {
|
|
9
|
+
this.map.set(key, chartData);
|
|
10
|
+
}
|
|
11
|
+
get Array() {
|
|
12
|
+
return [...this.map.values()];
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/chart/series/series-data.ts
|
|
17
|
+
const createStrRef = (values) => {
|
|
18
|
+
return new StrRef(typeof values === "string" ? [values] : values);
|
|
19
|
+
};
|
|
20
|
+
const createNumRef = (values) => new NumRef(values);
|
|
21
|
+
var StrRef = class extends XmlComponent {
|
|
22
|
+
constructor(values) {
|
|
23
|
+
super("c:strRef");
|
|
24
|
+
this.root.push(new EmptyElement("c:f"));
|
|
25
|
+
this.root.push(new StrCache(values));
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
var StrCache = class extends XmlComponent {
|
|
29
|
+
constructor(values) {
|
|
30
|
+
super("c:strCache");
|
|
31
|
+
this.root.push(wrapEl("c:ptCount", chartAttr({ val: values.length })));
|
|
32
|
+
for (let i = 0; i < values.length; i++) this.root.push(new StrPt(i, values[i]));
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
var StrPt = class extends XmlComponent {
|
|
36
|
+
constructor(index, value) {
|
|
37
|
+
super("c:pt");
|
|
38
|
+
this.root.push(chartAttr({ idx: index }));
|
|
39
|
+
this.root.push(new StringValue("c:v", value));
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var NumRef = class extends XmlComponent {
|
|
43
|
+
constructor(values) {
|
|
44
|
+
super("c:numRef");
|
|
45
|
+
this.root.push(new EmptyElement("c:f"));
|
|
46
|
+
this.root.push(new NumCache(values));
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var NumCache = class extends XmlComponent {
|
|
50
|
+
constructor(values) {
|
|
51
|
+
super("c:numCache");
|
|
52
|
+
this.root.push(wrapEl("c:ptCount", chartAttr({ val: values.length })));
|
|
53
|
+
this.root.push(new FormatCode("General"));
|
|
54
|
+
for (let i = 0; i < values.length; i++) this.root.push(new NumPt(i, values[i]));
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
var NumPt = class extends XmlComponent {
|
|
58
|
+
constructor(index, value) {
|
|
59
|
+
super("c:pt");
|
|
60
|
+
this.root.push(chartAttr({ idx: index }));
|
|
61
|
+
this.root.push(new StringValue("c:v", String(value)));
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
var FormatCode = class extends XmlComponent {
|
|
65
|
+
constructor(code) {
|
|
66
|
+
super("c:formatCode");
|
|
67
|
+
this.root.push(code);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
var StringValue = class extends XmlComponent {
|
|
71
|
+
constructor(name, val) {
|
|
72
|
+
super(name);
|
|
73
|
+
this.root.push(val);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/chart/chart-types/area-chart.ts
|
|
78
|
+
var AreaChart = class extends XmlComponent {
|
|
79
|
+
constructor(options) {
|
|
80
|
+
super("c:areaChart");
|
|
81
|
+
this.root.push(wrapEl("c:grouping", chartAttr({ val: "standard" })));
|
|
82
|
+
for (let i = 0; i < options.series.length; i++) this.root.push(new AreaSeries(i, options.series[i], options.categories));
|
|
83
|
+
this.root.push(wrapEl("c:axId", chartAttr({ val: 10 })));
|
|
84
|
+
this.root.push(wrapEl("c:axId", chartAttr({ val: 20 })));
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
var AreaSeries = class extends XmlComponent {
|
|
88
|
+
constructor(index, series, categories) {
|
|
89
|
+
super("c:ser");
|
|
90
|
+
this.root.push(wrapEl("c:idx", chartAttr({ val: index })));
|
|
91
|
+
this.root.push(wrapEl("c:order", chartAttr({ val: index })));
|
|
92
|
+
this.root.push(new SeriesTx$4(series.name));
|
|
93
|
+
this.root.push(new SeriesCat$4(categories));
|
|
94
|
+
this.root.push(new SeriesVal$4(series.values));
|
|
95
|
+
this.root.push(new EmptyElement("c:spPr"));
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
var SeriesTx$4 = class extends XmlComponent {
|
|
99
|
+
constructor(name) {
|
|
100
|
+
super("c:tx");
|
|
101
|
+
this.root.push(createStrRef(name));
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
var SeriesCat$4 = class extends XmlComponent {
|
|
105
|
+
constructor(categories) {
|
|
106
|
+
super("c:cat");
|
|
107
|
+
this.root.push(createStrRef(categories));
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
var SeriesVal$4 = class extends XmlComponent {
|
|
111
|
+
constructor(values) {
|
|
112
|
+
super("c:val");
|
|
113
|
+
this.root.push(createNumRef(values));
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region src/chart/chart-types/bar-chart.ts
|
|
118
|
+
var BarChart = class extends XmlComponent {
|
|
119
|
+
constructor(options) {
|
|
120
|
+
super("c:barChart");
|
|
121
|
+
this.root.push(wrapEl("c:barDir", chartAttr({ val: options.barDirection })));
|
|
122
|
+
this.root.push(wrapEl("c:grouping", chartAttr({ val: "clustered" })));
|
|
123
|
+
for (let i = 0; i < options.series.length; i++) this.root.push(new BarSeries(i, options.series[i], options.categories));
|
|
124
|
+
this.root.push(wrapEl("c:axId", chartAttr({ val: 10 })));
|
|
125
|
+
this.root.push(wrapEl("c:axId", chartAttr({ val: 20 })));
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
var BarSeries = class extends XmlComponent {
|
|
129
|
+
constructor(index, series, categories) {
|
|
130
|
+
super("c:ser");
|
|
131
|
+
this.root.push(wrapEl("c:idx", chartAttr({ val: index })));
|
|
132
|
+
this.root.push(wrapEl("c:order", chartAttr({ val: index })));
|
|
133
|
+
this.root.push(new SeriesTx$3(series.name));
|
|
134
|
+
this.root.push(new SeriesCat$3(categories));
|
|
135
|
+
this.root.push(new SeriesVal$3(series.values));
|
|
136
|
+
this.root.push(new EmptyElement("c:spPr"));
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
var SeriesTx$3 = class extends XmlComponent {
|
|
140
|
+
constructor(name) {
|
|
141
|
+
super("c:tx");
|
|
142
|
+
this.root.push(createStrRef(name));
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
var SeriesCat$3 = class extends XmlComponent {
|
|
146
|
+
constructor(categories) {
|
|
147
|
+
super("c:cat");
|
|
148
|
+
this.root.push(createStrRef(categories));
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
var SeriesVal$3 = class extends XmlComponent {
|
|
152
|
+
constructor(values) {
|
|
153
|
+
super("c:val");
|
|
154
|
+
this.root.push(createNumRef(values));
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
//#endregion
|
|
158
|
+
//#region src/chart/chart-types/line-chart.ts
|
|
159
|
+
var LineChart = class extends XmlComponent {
|
|
160
|
+
constructor(options) {
|
|
161
|
+
super("c:lineChart");
|
|
162
|
+
this.root.push(wrapEl("c:grouping", chartAttr({ val: "standard" })));
|
|
163
|
+
for (let i = 0; i < options.series.length; i++) this.root.push(new LineSeries(i, options.series[i], options.categories));
|
|
164
|
+
this.root.push(wrapEl("c:axId", chartAttr({ val: 10 })));
|
|
165
|
+
this.root.push(wrapEl("c:axId", chartAttr({ val: 20 })));
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
var LineSeries = class extends XmlComponent {
|
|
169
|
+
constructor(index, series, categories) {
|
|
170
|
+
super("c:ser");
|
|
171
|
+
this.root.push(wrapEl("c:idx", chartAttr({ val: index })));
|
|
172
|
+
this.root.push(wrapEl("c:order", chartAttr({ val: index })));
|
|
173
|
+
this.root.push(new SeriesTx$2(series.name));
|
|
174
|
+
this.root.push(new SeriesCat$2(categories));
|
|
175
|
+
this.root.push(new SeriesVal$2(series.values));
|
|
176
|
+
this.root.push(new EmptyElement("c:spPr"));
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
var SeriesTx$2 = class extends XmlComponent {
|
|
180
|
+
constructor(name) {
|
|
181
|
+
super("c:tx");
|
|
182
|
+
this.root.push(createStrRef(name));
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
var SeriesCat$2 = class extends XmlComponent {
|
|
186
|
+
constructor(categories) {
|
|
187
|
+
super("c:cat");
|
|
188
|
+
this.root.push(createStrRef(categories));
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
var SeriesVal$2 = class extends XmlComponent {
|
|
192
|
+
constructor(values) {
|
|
193
|
+
super("c:val");
|
|
194
|
+
this.root.push(createNumRef(values));
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
//#endregion
|
|
198
|
+
//#region src/chart/chart-types/pie-chart.ts
|
|
199
|
+
var PieChart = class extends XmlComponent {
|
|
200
|
+
constructor(options) {
|
|
201
|
+
super("c:pieChart");
|
|
202
|
+
this.root.push(wrapEl("c:varyColors", chartAttr({ val: true })));
|
|
203
|
+
for (let i = 0; i < options.series.length; i++) this.root.push(new PieSeries(i, options.series[i], options.categories));
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
var PieSeries = class extends XmlComponent {
|
|
207
|
+
constructor(index, series, categories) {
|
|
208
|
+
super("c:ser");
|
|
209
|
+
this.root.push(wrapEl("c:idx", chartAttr({ val: index })));
|
|
210
|
+
this.root.push(wrapEl("c:order", chartAttr({ val: index })));
|
|
211
|
+
this.root.push(new SeriesTx$1(series.name));
|
|
212
|
+
this.root.push(new SeriesCat$1(categories));
|
|
213
|
+
this.root.push(new SeriesVal$1(series.values));
|
|
214
|
+
this.root.push(new EmptyElement("c:spPr"));
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
var SeriesTx$1 = class extends XmlComponent {
|
|
218
|
+
constructor(name) {
|
|
219
|
+
super("c:tx");
|
|
220
|
+
this.root.push(createStrRef(name));
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
var SeriesCat$1 = class extends XmlComponent {
|
|
224
|
+
constructor(categories) {
|
|
225
|
+
super("c:cat");
|
|
226
|
+
this.root.push(createStrRef(categories));
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
var SeriesVal$1 = class extends XmlComponent {
|
|
230
|
+
constructor(values) {
|
|
231
|
+
super("c:val");
|
|
232
|
+
this.root.push(createNumRef(values));
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
//#endregion
|
|
236
|
+
//#region src/chart/chart-types/scatter-chart.ts
|
|
237
|
+
var ScatterChart = class extends XmlComponent {
|
|
238
|
+
constructor(options) {
|
|
239
|
+
super("c:scatterChart");
|
|
240
|
+
this.root.push(wrapEl("c:scatterStyle", chartAttr({ val: "line" })));
|
|
241
|
+
for (let i = 0; i < options.series.length; i++) this.root.push(new ScatterSeries(i, options.series[i], options.categories));
|
|
242
|
+
this.root.push(wrapEl("c:axId", chartAttr({ val: 10 })));
|
|
243
|
+
this.root.push(wrapEl("c:axId", chartAttr({ val: 20 })));
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
var ScatterSeries = class extends XmlComponent {
|
|
247
|
+
constructor(index, series, categories) {
|
|
248
|
+
super("c:ser");
|
|
249
|
+
this.root.push(wrapEl("c:idx", chartAttr({ val: index })));
|
|
250
|
+
this.root.push(wrapEl("c:order", chartAttr({ val: index })));
|
|
251
|
+
this.root.push(new SeriesTx(series.name));
|
|
252
|
+
this.root.push(new SeriesCat(categories));
|
|
253
|
+
this.root.push(new SeriesVal(series.values));
|
|
254
|
+
this.root.push(new EmptyElement("c:spPr"));
|
|
255
|
+
this.root.push(new EmptyElement("c:size"));
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
var SeriesTx = class extends XmlComponent {
|
|
259
|
+
constructor(name) {
|
|
260
|
+
super("c:tx");
|
|
261
|
+
this.root.push(createStrRef(name));
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
var SeriesCat = class extends XmlComponent {
|
|
265
|
+
constructor(categories) {
|
|
266
|
+
super("c:cat");
|
|
267
|
+
this.root.push(createStrRef(categories));
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
var SeriesVal = class extends XmlComponent {
|
|
271
|
+
constructor(values) {
|
|
272
|
+
super("c:val");
|
|
273
|
+
this.root.push(createNumRef(values));
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
//#endregion
|
|
277
|
+
//#region src/chart/create-chart-type.ts
|
|
278
|
+
const createChartType = (options) => {
|
|
279
|
+
switch (options.type) {
|
|
280
|
+
case "column":
|
|
281
|
+
case "bar": return new BarChart({
|
|
282
|
+
barDirection: options.type === "column" ? "col" : "bar",
|
|
283
|
+
categories: options.categories,
|
|
284
|
+
series: options.series
|
|
285
|
+
});
|
|
286
|
+
case "line": return new LineChart({
|
|
287
|
+
categories: options.categories,
|
|
288
|
+
series: options.series
|
|
289
|
+
});
|
|
290
|
+
case "pie": return new PieChart({
|
|
291
|
+
categories: options.categories,
|
|
292
|
+
series: options.series
|
|
293
|
+
});
|
|
294
|
+
case "area": return new AreaChart({
|
|
295
|
+
categories: options.categories,
|
|
296
|
+
series: options.series
|
|
297
|
+
});
|
|
298
|
+
case "scatter": return new ScatterChart({
|
|
299
|
+
categories: options.categories,
|
|
300
|
+
series: options.series
|
|
301
|
+
});
|
|
302
|
+
default: throw new Error(`Unsupported chart type: ${options.type}`);
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
//#endregion
|
|
306
|
+
//#region src/chart/title.ts
|
|
307
|
+
var ChartTitle = class extends XmlComponent {
|
|
308
|
+
constructor(title) {
|
|
309
|
+
super("c:title");
|
|
310
|
+
this.root.push(new TitleTx(title));
|
|
311
|
+
this.root.push(new TitleOverlay());
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
var TitleTx = class extends XmlComponent {
|
|
315
|
+
constructor(title) {
|
|
316
|
+
super("c:tx");
|
|
317
|
+
const rich = new class extends XmlComponent {
|
|
318
|
+
constructor() {
|
|
319
|
+
super("c:rich");
|
|
320
|
+
}
|
|
321
|
+
}();
|
|
322
|
+
rich["root"].push(new class extends XmlComponent {
|
|
323
|
+
constructor() {
|
|
324
|
+
super("a:bodyPr");
|
|
325
|
+
}
|
|
326
|
+
}());
|
|
327
|
+
rich["root"].push(new class extends XmlComponent {
|
|
328
|
+
constructor() {
|
|
329
|
+
super("a:lstStyle");
|
|
330
|
+
}
|
|
331
|
+
}());
|
|
332
|
+
const p = new class extends XmlComponent {
|
|
333
|
+
constructor() {
|
|
334
|
+
super("a:p");
|
|
335
|
+
}
|
|
336
|
+
}();
|
|
337
|
+
const r = new class extends XmlComponent {
|
|
338
|
+
constructor() {
|
|
339
|
+
super("a:r");
|
|
340
|
+
}
|
|
341
|
+
}();
|
|
342
|
+
r["root"].push(new class extends XmlComponent {
|
|
343
|
+
constructor() {
|
|
344
|
+
super("a:t");
|
|
345
|
+
this.root.push(title);
|
|
346
|
+
}
|
|
347
|
+
}());
|
|
348
|
+
p["root"].push(r);
|
|
349
|
+
rich["root"].push(p);
|
|
350
|
+
this.root.push(rich);
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
var TitleOverlay = class extends XmlComponent {
|
|
354
|
+
constructor() {
|
|
355
|
+
super("c:overlay");
|
|
356
|
+
this.root.push(chartAttr({ val: 0 }));
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
//#endregion
|
|
360
|
+
export { AreaChart, BarChart, ChartCollection, ChartTitle, LineChart, PieChart, ScatterChart, createChartType, createNumRef, createStrRef };
|