@connectedxm/zpl-generator 0.0.1 → 0.0.2-beta.18
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 +0 -1
- package/dist/index.es.js +1045 -977
- package/dist/src/generate.d.ts +27 -0
- package/dist/src/interfaces.d.ts +37 -0
- package/dist/src/validate.d.ts +1343 -0
- package/package.json +1 -1
|
@@ -0,0 +1,27 @@
|
|
|
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;
|
|
5
|
+
/**
|
|
6
|
+
* ZPL ^FB blocks have no vertical alignment — text always starts at line 1.
|
|
7
|
+
* To simulate "end" (bottom) alignment, we count how many lines the data
|
|
8
|
+
* will occupy and prepend empty ZPL line breaks (\&) to push it down.
|
|
9
|
+
*
|
|
10
|
+
* Two counting strategies:
|
|
11
|
+
* - wordWidths provided: simulate word-wrap using pre-measured pixel widths
|
|
12
|
+
* - wordWidths omitted: approximate chars per line from maxWidth / fontHeight
|
|
13
|
+
*/
|
|
14
|
+
export declare function applyVerticalAlignment(field: TextField, value: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Counts how many lines the field data will occupy inside a ^FB field.
|
|
17
|
+
* Exported so consuming projects (e.g. React label previews) can reuse
|
|
18
|
+
* the same logic to stay in sync with the generator.
|
|
19
|
+
*
|
|
20
|
+
* When wordWidths are provided, simulates ZPL word-wrap: words are placed
|
|
21
|
+
* on the current line until the next word would exceed maxWidth, then a
|
|
22
|
+
* new line is started. Explicit \& breaks always start a new line.
|
|
23
|
+
*
|
|
24
|
+
* When wordWidths are not provided, falls back to a character-width
|
|
25
|
+
* heuristic using fontHeight.
|
|
26
|
+
*/
|
|
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
|
+
}
|