@format.dev/vue 0.2.0 → 0.4.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/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # @format.dev/vue
2
+
3
+ Vue components for building PDFs with Format. Write a document in Vue and CSS, and Format paginates it into a PDF.
4
+
5
+ Documentation: https://format.dev/docs. Full docs as Markdown for AI agents: https://format.dev/llms-full.txt.
6
+
7
+ ## Install
8
+
9
+ Start a new project with `npm create format@latest`.
10
+
11
+ To add Format to an existing project, install the CLI first, then run `init`:
12
+
13
+ ```bash
14
+ npm install @format.dev/cli --save-dev
15
+ npx format init
16
+ ```
17
+
18
+ Install the CLI before you run `npx format`. Without it, npx resolves `format` to an unrelated package.
19
+
20
+ Both routes install this package pinned to the version in `format.config.json`. Do not install it on its own.
21
+
22
+ ## Example
23
+
24
+ ```vue
25
+ <script setup lang="ts">
26
+ import { Document, Layout, Flow, PageNumber, PageCount } from '@format.dev/vue'
27
+
28
+ defineProps<{ data: { number: string; lines: { id: string; description: string }[] } }>()
29
+ </script>
30
+
31
+ <template>
32
+ <Document :title="`Invoice ${data.number}`" lang="en">
33
+ <Layout id="page" width="210mm" height="297mm">
34
+ <header>Invoice {{ data.number }}</header>
35
+ <Flow>
36
+ <p v-for="line in data.lines" :key="line.id">{{ line.description }}</p>
37
+ </Flow>
38
+ <footer><PageNumber /> of <PageCount /></footer>
39
+ </Layout>
40
+ </Document>
41
+ </template>
42
+ ```
43
+
44
+ The header and footer repeat on every page. The Flow's children paginate across as many pages as they need.
45
+
46
+ ## The model
47
+
48
+ - `Document` is the root: title, language, fonts, and one or more Layouts.
49
+ - `Layout` is a page design with a width and height. Its markup is the page.
50
+ - `Flow` paginates its content. Markup inside a Flow repeats per page; its children flow.
51
+ - `Stream` marks where flowing items land inside repeating markup, such as rows in a table whose head repeats.
52
+ - `PageBreak`, `PageNumber`, `PageCount`, `TableOfContents`, `RunningHead`, `Numbering`, `Counter`, `Ref`, `Footnote`, and `Bookmarks` cover the rest.
53
+
54
+ Pagination is automatic. Do not reach for `@media print` or `page-break-*`.
55
+
56
+ In `<style scoped>`, write `:global(:host)` rather than `:host`, or the selector never matches.
57
+
58
+ ## Preview and render
59
+
60
+ Preview documents in Format Studio with `npm run dev`. Render in production with `@format.dev/client` and a `FORMAT_API_KEY`.
61
+
62
+ ## For AI agents
63
+
64
+ Fetch https://format.dev/llms-full.txt before writing a document. Component names and props are documented there and in this package's `dist/index.d.ts`. The workflow for agents, including Studio, sign-in, and API keys, is in `node_modules/@format.dev/cli/AGENTS.md`.
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  let vue = require("vue");
2
2
 
3
3
  //#region src/Template.vue
4
- const _sfc_main$17 = /* @__PURE__ */ (0, vue.defineComponent)({
4
+ const _sfc_main$19 = /* @__PURE__ */ (0, vue.defineComponent)({
5
5
  __name: "Template",
6
6
  setup(__props) {
7
7
  const attrs = (0, vue.useAttrs)();
@@ -21,19 +21,19 @@ const _sfc_main$17 = /* @__PURE__ */ (0, vue.defineComponent)({
21
21
  };
22
22
  }
23
23
  });
24
- var Template_default = _sfc_main$17;
24
+ var Template_default = _sfc_main$19;
25
25
 
26
26
  //#endregion
27
27
  //#region src/engine-target.ts
28
- const engineTarget = "0.2.0";
28
+ const engineTarget = "0.4.0";
29
29
 
30
30
  //#endregion
31
31
  //#region src/sdk-version.ts
32
- const sdkVersion = "0.2.0";
32
+ const sdkVersion = "0.4.0";
33
33
 
34
34
  //#endregion
35
35
  //#region src/Document.vue
36
- const _sfc_main$16 = /* @__PURE__ */ (0, vue.defineComponent)({
36
+ const _sfc_main$18 = /* @__PURE__ */ (0, vue.defineComponent)({
37
37
  inheritAttrs: false,
38
38
  __name: "Document",
39
39
  props: {
@@ -41,6 +41,7 @@ const _sfc_main$16 = /* @__PURE__ */ (0, vue.defineComponent)({
41
41
  subject: {},
42
42
  author: {},
43
43
  keywords: {},
44
+ lang: {},
44
45
  fonts: {}
45
46
  },
46
47
  setup(__props) {
@@ -55,6 +56,7 @@ const _sfc_main$16 = /* @__PURE__ */ (0, vue.defineComponent)({
55
56
  "data-subject": __props.subject,
56
57
  "data-author": __props.author,
57
58
  "data-keywords": keywordsString.value,
59
+ "data-lang": __props.lang,
58
60
  "data-fonts": __props.fonts
59
61
  }, {
60
62
  default: (0, vue.withCtx)(() => [(0, vue.renderSlot)(_ctx.$slots, "default")]),
@@ -66,16 +68,17 @@ const _sfc_main$16 = /* @__PURE__ */ (0, vue.defineComponent)({
66
68
  "data-subject",
67
69
  "data-author",
68
70
  "data-keywords",
71
+ "data-lang",
69
72
  "data-fonts"
70
73
  ]);
71
74
  };
72
75
  }
73
76
  });
74
- var Document_default = _sfc_main$16;
77
+ var Document_default = _sfc_main$18;
75
78
 
76
79
  //#endregion
77
80
  //#region src/Layout.vue
78
- const _sfc_main$15 = /* @__PURE__ */ (0, vue.defineComponent)({
81
+ const _sfc_main$17 = /* @__PURE__ */ (0, vue.defineComponent)({
79
82
  __name: "Layout",
80
83
  props: {
81
84
  id: {},
@@ -86,14 +89,15 @@ const _sfc_main$15 = /* @__PURE__ */ (0, vue.defineComponent)({
86
89
  },
87
90
  setup(__props) {
88
91
  const props = __props;
89
- const widthPx = (0, vue.computed)(() => `${props.width}px`);
90
- const heightPx = (0, vue.computed)(() => `${props.height}px`);
92
+ const pageLength = (value) => typeof value === "number" ? `${value}px` : value;
93
+ const width = (0, vue.computed)(() => pageLength(props.width));
94
+ const height = (0, vue.computed)(() => pageLength(props.height));
91
95
  return (_ctx, _cache) => {
92
96
  return (0, vue.openBlock)(), (0, vue.createBlock)(Template_default, {
93
97
  "data-type": "layout",
94
98
  "data-id": __props.id,
95
- "data-width": widthPx.value,
96
- "data-height": heightPx.value,
99
+ "data-width": width.value,
100
+ "data-height": height.value,
97
101
  "data-pagination-strategy": __props.paginationStrategy,
98
102
  "data-split-granularity": __props.splitGranularity
99
103
  }, {
@@ -109,11 +113,11 @@ const _sfc_main$15 = /* @__PURE__ */ (0, vue.defineComponent)({
109
113
  };
110
114
  }
111
115
  });
112
- var Layout_default = _sfc_main$15;
116
+ var Layout_default = _sfc_main$17;
113
117
 
114
118
  //#endregion
115
119
  //#region src/Flow.vue
116
- const _sfc_main$14 = /* @__PURE__ */ (0, vue.defineComponent)({
120
+ const _sfc_main$16 = /* @__PURE__ */ (0, vue.defineComponent)({
117
121
  __name: "Flow",
118
122
  props: {
119
123
  splitGranularity: {},
@@ -138,11 +142,11 @@ const _sfc_main$14 = /* @__PURE__ */ (0, vue.defineComponent)({
138
142
  };
139
143
  }
140
144
  });
141
- var Flow_default = _sfc_main$14;
145
+ var Flow_default = _sfc_main$16;
142
146
 
143
147
  //#endregion
144
148
  //#region src/Stream.vue
145
- const _sfc_main$13 = /* @__PURE__ */ (0, vue.defineComponent)({
149
+ const _sfc_main$15 = /* @__PURE__ */ (0, vue.defineComponent)({
146
150
  __name: "Stream",
147
151
  setup(__props) {
148
152
  return (_ctx, _cache) => {
@@ -153,11 +157,11 @@ const _sfc_main$13 = /* @__PURE__ */ (0, vue.defineComponent)({
153
157
  };
154
158
  }
155
159
  });
156
- var Stream_default = _sfc_main$13;
160
+ var Stream_default = _sfc_main$15;
157
161
 
158
162
  //#endregion
159
163
  //#region src/PageBreak.vue
160
- const _sfc_main$12 = /* @__PURE__ */ (0, vue.defineComponent)({
164
+ const _sfc_main$14 = /* @__PURE__ */ (0, vue.defineComponent)({
161
165
  __name: "PageBreak",
162
166
  setup(__props) {
163
167
  return (_ctx, _cache) => {
@@ -165,11 +169,11 @@ const _sfc_main$12 = /* @__PURE__ */ (0, vue.defineComponent)({
165
169
  };
166
170
  }
167
171
  });
168
- var PageBreak_default = _sfc_main$12;
172
+ var PageBreak_default = _sfc_main$14;
169
173
 
170
174
  //#endregion
171
175
  //#region src/PageCounter.vue
172
- const _sfc_main$11 = /* @__PURE__ */ (0, vue.defineComponent)({
176
+ const _sfc_main$13 = /* @__PURE__ */ (0, vue.defineComponent)({
173
177
  __name: "PageCounter",
174
178
  props: {
175
179
  type: {},
@@ -187,11 +191,11 @@ const _sfc_main$11 = /* @__PURE__ */ (0, vue.defineComponent)({
187
191
  };
188
192
  }
189
193
  });
190
- var PageCounter_default = _sfc_main$11;
194
+ var PageCounter_default = _sfc_main$13;
191
195
 
192
196
  //#endregion
193
197
  //#region src/PageNumber.vue
194
- const _sfc_main$10 = /* @__PURE__ */ (0, vue.defineComponent)({
198
+ const _sfc_main$12 = /* @__PURE__ */ (0, vue.defineComponent)({
195
199
  __name: "PageNumber",
196
200
  props: {
197
201
  as: {},
@@ -204,11 +208,11 @@ const _sfc_main$10 = /* @__PURE__ */ (0, vue.defineComponent)({
204
208
  };
205
209
  }
206
210
  });
207
- var PageNumber_default = _sfc_main$10;
211
+ var PageNumber_default = _sfc_main$12;
208
212
 
209
213
  //#endregion
210
214
  //#region src/PageCount.vue
211
- const _sfc_main$9 = /* @__PURE__ */ (0, vue.defineComponent)({
215
+ const _sfc_main$11 = /* @__PURE__ */ (0, vue.defineComponent)({
212
216
  __name: "PageCount",
213
217
  props: {
214
218
  as: {},
@@ -221,11 +225,11 @@ const _sfc_main$9 = /* @__PURE__ */ (0, vue.defineComponent)({
221
225
  };
222
226
  }
223
227
  });
224
- var PageCount_default = _sfc_main$9;
228
+ var PageCount_default = _sfc_main$11;
225
229
 
226
230
  //#endregion
227
231
  //#region src/Counter.vue
228
- const _sfc_main$8 = /* @__PURE__ */ (0, vue.defineComponent)({
232
+ const _sfc_main$10 = /* @__PURE__ */ (0, vue.defineComponent)({
229
233
  __name: "Counter",
230
234
  props: {
231
235
  name: {},
@@ -260,11 +264,11 @@ const _sfc_main$8 = /* @__PURE__ */ (0, vue.defineComponent)({
260
264
  };
261
265
  }
262
266
  });
263
- var Counter_default = _sfc_main$8;
267
+ var Counter_default = _sfc_main$10;
264
268
 
265
269
  //#endregion
266
270
  //#region src/Ref.vue
267
- const _sfc_main$7 = /* @__PURE__ */ (0, vue.defineComponent)({
271
+ const _sfc_main$9 = /* @__PURE__ */ (0, vue.defineComponent)({
268
272
  __name: "Ref",
269
273
  props: {
270
274
  to: {},
@@ -293,11 +297,47 @@ const _sfc_main$7 = /* @__PURE__ */ (0, vue.defineComponent)({
293
297
  };
294
298
  }
295
299
  });
296
- var Ref_default = _sfc_main$7;
300
+ var Ref_default = _sfc_main$9;
301
+
302
+ //#endregion
303
+ //#region src/RunningHead.vue
304
+ const _sfc_main$8 = /* @__PURE__ */ (0, vue.defineComponent)({
305
+ __name: "RunningHead",
306
+ props: {
307
+ match: {},
308
+ show: {},
309
+ within: {},
310
+ format: {},
311
+ counterStyle: {},
312
+ rangeSeparator: {},
313
+ as: { default: "span" }
314
+ },
315
+ setup(__props) {
316
+ return (_ctx, _cache) => {
317
+ return (0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)(__props.as), {
318
+ "data-type": "running-head",
319
+ "data-match": __props.match,
320
+ "data-show": __props.show,
321
+ "data-within": __props.within,
322
+ "data-format": __props.format,
323
+ "data-counter-style": __props.counterStyle,
324
+ "data-range-separator": __props.rangeSeparator
325
+ }, null, 8, [
326
+ "data-match",
327
+ "data-show",
328
+ "data-within",
329
+ "data-format",
330
+ "data-counter-style",
331
+ "data-range-separator"
332
+ ]);
333
+ };
334
+ }
335
+ });
336
+ var RunningHead_default = _sfc_main$8;
297
337
 
298
338
  //#endregion
299
339
  //#region src/TableOfContents.vue
300
- const _sfc_main$6 = /* @__PURE__ */ (0, vue.defineComponent)({
340
+ const _sfc_main$7 = /* @__PURE__ */ (0, vue.defineComponent)({
301
341
  __name: "TableOfContents",
302
342
  props: {
303
343
  collect: {},
@@ -305,7 +345,8 @@ const _sfc_main$6 = /* @__PURE__ */ (0, vue.defineComponent)({
305
345
  repeatHead: {
306
346
  type: Boolean,
307
347
  default: void 0
308
- }
348
+ },
349
+ within: {}
309
350
  },
310
351
  setup(__props) {
311
352
  return (_ctx, _cache) => {
@@ -313,23 +354,25 @@ const _sfc_main$6 = /* @__PURE__ */ (0, vue.defineComponent)({
313
354
  "data-type": "toc",
314
355
  "data-collect": __props.collect,
315
356
  "data-leader": __props.leader,
316
- "data-repeat-head": __props.repeatHead === void 0 ? void 0 : __props.repeatHead ? "true" : "false"
357
+ "data-repeat-head": __props.repeatHead === void 0 ? void 0 : __props.repeatHead ? "true" : "false",
358
+ "data-within": __props.within
317
359
  }, {
318
360
  default: (0, vue.withCtx)(() => [(0, vue.renderSlot)(_ctx.$slots, "default")]),
319
361
  _: 3
320
362
  }, 8, [
321
363
  "data-collect",
322
364
  "data-leader",
323
- "data-repeat-head"
365
+ "data-repeat-head",
366
+ "data-within"
324
367
  ]);
325
368
  };
326
369
  }
327
370
  });
328
- var TableOfContents_default = _sfc_main$6;
371
+ var TableOfContents_default = _sfc_main$7;
329
372
 
330
373
  //#endregion
331
374
  //#region src/Footnote.vue
332
- const _sfc_main$5 = /* @__PURE__ */ (0, vue.defineComponent)({
375
+ const _sfc_main$6 = /* @__PURE__ */ (0, vue.defineComponent)({
333
376
  __name: "Footnote",
334
377
  setup(__props) {
335
378
  return (_ctx, _cache) => {
@@ -340,11 +383,11 @@ const _sfc_main$5 = /* @__PURE__ */ (0, vue.defineComponent)({
340
383
  };
341
384
  }
342
385
  });
343
- var Footnote_default = _sfc_main$5;
386
+ var Footnote_default = _sfc_main$6;
344
387
 
345
388
  //#endregion
346
389
  //#region src/Footnotes.vue
347
- const _sfc_main$4 = /* @__PURE__ */ (0, vue.defineComponent)({
390
+ const _sfc_main$5 = /* @__PURE__ */ (0, vue.defineComponent)({
348
391
  __name: "Footnotes",
349
392
  props: {
350
393
  counterStyle: {},
@@ -372,11 +415,11 @@ const _sfc_main$4 = /* @__PURE__ */ (0, vue.defineComponent)({
372
415
  };
373
416
  }
374
417
  });
375
- var Footnotes_default = _sfc_main$4;
418
+ var Footnotes_default = _sfc_main$5;
376
419
 
377
420
  //#endregion
378
421
  //#region src/CounterDef.vue
379
- const _sfc_main$3 = /* @__PURE__ */ (0, vue.defineComponent)({
422
+ const _sfc_main$4 = /* @__PURE__ */ (0, vue.defineComponent)({
380
423
  __name: "CounterDef",
381
424
  props: {
382
425
  name: {},
@@ -392,11 +435,11 @@ const _sfc_main$3 = /* @__PURE__ */ (0, vue.defineComponent)({
392
435
  };
393
436
  }
394
437
  });
395
- var CounterDef_default = _sfc_main$3;
438
+ var CounterDef_default = _sfc_main$4;
396
439
 
397
440
  //#endregion
398
441
  //#region src/Numbering.vue
399
- const _sfc_main$2 = /* @__PURE__ */ (0, vue.defineComponent)({
442
+ const _sfc_main$3 = /* @__PURE__ */ (0, vue.defineComponent)({
400
443
  __name: "Numbering",
401
444
  props: {
402
445
  counterStyle: {},
@@ -418,11 +461,11 @@ const _sfc_main$2 = /* @__PURE__ */ (0, vue.defineComponent)({
418
461
  };
419
462
  }
420
463
  });
421
- var Numbering_default = _sfc_main$2;
464
+ var Numbering_default = _sfc_main$3;
422
465
 
423
466
  //#endregion
424
467
  //#region src/NumberingRule.vue
425
- const _sfc_main$1 = /* @__PURE__ */ (0, vue.defineComponent)({
468
+ const _sfc_main$2 = /* @__PURE__ */ (0, vue.defineComponent)({
426
469
  __name: "NumberingRule",
427
470
  props: {
428
471
  match: {},
@@ -458,7 +501,30 @@ const _sfc_main$1 = /* @__PURE__ */ (0, vue.defineComponent)({
458
501
  };
459
502
  }
460
503
  });
461
- var NumberingRule_default = _sfc_main$1;
504
+ var NumberingRule_default = _sfc_main$2;
505
+
506
+ //#endregion
507
+ //#region src/Bookmarks.vue
508
+ const _sfc_main$1 = /* @__PURE__ */ (0, vue.defineComponent)({
509
+ __name: "Bookmarks",
510
+ props: {
511
+ numbers: {
512
+ type: Boolean,
513
+ default: void 0
514
+ },
515
+ separator: {}
516
+ },
517
+ setup(__props) {
518
+ return (_ctx, _cache) => {
519
+ return (0, vue.openBlock)(), (0, vue.createBlock)(Template_default, {
520
+ "data-type": "bookmarks",
521
+ "data-numbers": __props.numbers === void 0 ? void 0 : __props.numbers ? "true" : "false",
522
+ "data-separator": __props.separator
523
+ }, null, 8, ["data-numbers", "data-separator"]);
524
+ };
525
+ }
526
+ });
527
+ var Bookmarks_default = _sfc_main$1;
462
528
 
463
529
  //#endregion
464
530
  //#region src/Scope.vue
@@ -520,6 +586,7 @@ function css(parts, ...vals) {
520
586
  }
521
587
 
522
588
  //#endregion
589
+ exports.Bookmarks = Bookmarks_default;
523
590
  exports.Counter = Counter_default;
524
591
  exports.CounterDef = CounterDef_default;
525
592
  exports.Document = Document_default;
@@ -533,6 +600,7 @@ exports.PageBreak = PageBreak_default;
533
600
  exports.PageCount = PageCount_default;
534
601
  exports.PageNumber = PageNumber_default;
535
602
  exports.Ref = Ref_default;
603
+ exports.RunningHead = RunningHead_default;
536
604
  exports.Scope = Scope_default;
537
605
  exports.SplitGranularity = SplitGranularity;
538
606
  exports.Stream = Stream_default;