@connectedxm/zpl-generator 0.0.2-beta.1 → 0.0.2-beta.7

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.
@@ -0,0 +1,30 @@
1
+ import { Badge, TextField } from './validate';
2
+ import { SourceData } from './interfaces';
3
+ /**
4
+ * Generates ZPL (Zebra Programming Language) from a Badge configuration.
5
+ * Switches on badge type and renders the complete label format for thermal printers.
6
+ */
7
+ export declare function generate(badge: Badge, data?: SourceData): string;
8
+ /**
9
+ * ZPL ^FB blocks have no vertical alignment — text always starts at line 1.
10
+ * To simulate "end" (bottom) alignment, we count how many lines the data
11
+ * will occupy and prepend empty ZPL line breaks (\&) to push it down.
12
+ *
13
+ * Two counting strategies:
14
+ * - wordWidths provided: simulate word-wrap using pre-measured pixel widths
15
+ * - wordWidths omitted: approximate chars per line from maxWidth / font width
16
+ */
17
+ export declare function applyVerticalAlignment(field: TextField, value: string): string;
18
+ /**
19
+ * Counts how many lines the field data will occupy inside a ^FB field.
20
+ * Exported so consuming projects (e.g. React label previews) can reuse
21
+ * the same logic to stay in sync with the generator.
22
+ *
23
+ * When wordWidths are provided, simulates ZPL word-wrap: words are placed
24
+ * on the current line until the next word would exceed maxWidth, then a
25
+ * new line is started. Explicit \& breaks always start a new line.
26
+ *
27
+ * When wordWidths are not provided, falls back to a character-width
28
+ * heuristic using fontWidth (or fontHeight).
29
+ */
30
+ export declare function countLines(field: TextField, value: string): number;
@@ -0,0 +1,39 @@
1
+ export interface SourceAccount {
2
+ firstName: string;
3
+ lastName: string;
4
+ username: string;
5
+ title: string | undefined;
6
+ company: string | undefined;
7
+ city: string | undefined;
8
+ state: string | undefined;
9
+ country: string | undefined;
10
+ }
11
+ export interface SourceAccountAttribute {
12
+ id: string;
13
+ value: string;
14
+ }
15
+ export interface SourceAccountTier {
16
+ id: string;
17
+ name: string;
18
+ }
19
+ export interface SourcePass {
20
+ id: string;
21
+ alternateId: string;
22
+ passType: string;
23
+ }
24
+ export interface SourcePassAttribute {
25
+ name: string;
26
+ value: string;
27
+ }
28
+ export interface SourcePassResponse {
29
+ questionId: string;
30
+ value: string;
31
+ }
32
+ export interface SourceData {
33
+ account: SourceAccount;
34
+ accountAttributes: SourceAccountAttribute[];
35
+ accountTier?: SourceAccountTier;
36
+ pass: SourcePass;
37
+ passResponses: SourcePassResponse[];
38
+ passAttributes: SourcePassAttribute[];
39
+ }