@connectedxm/zpl-generator 0.0.2-beta.3 → 0.0.2

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