@connectedxm/zpl-generator 0.0.4-beta.1 → 0.0.4-beta.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.
package/dist/index.es.js CHANGED
@@ -2948,7 +2948,7 @@ const fs = {
2948
2948
  Uppercase: "Uppercase",
2949
2949
  Lowercase: "Lowercase",
2950
2950
  Capitalize: "Capitalize"
2951
- }, Ms = k(J), rc = ge({
2951
+ }, Ms = k(J), nc = ge({
2952
2952
  word: V(),
2953
2953
  width: g(),
2954
2954
  spaceWidth: g()
@@ -3038,13 +3038,13 @@ const fs = {
3038
3038
  // Fields
3039
3039
  fields: _t(Vs)
3040
3040
  });
3041
- function oc(e) {
3041
+ function rc(e) {
3042
3042
  return wt.safeParse(e);
3043
3043
  }
3044
- function ic(e) {
3044
+ function oc(e) {
3045
3045
  return wt.parse(e);
3046
3046
  }
3047
- function sc(e, t) {
3047
+ function ic(e, t) {
3048
3048
  if (e.type === "thermal")
3049
3049
  return Bs(e, t);
3050
3050
  throw new Error(`Unsupported badge type: ${e.type}`);
@@ -3085,9 +3085,9 @@ function Ys(e, t) {
3085
3085
  case "text":
3086
3086
  return n = Gs(e, n), Hs(e, n);
3087
3087
  case "barcode":
3088
- return ec(e, n);
3088
+ return Qs(e, n);
3089
3089
  case "qrcode":
3090
- return tc(e, n);
3090
+ return ec(e, n);
3091
3091
  default: {
3092
3092
  const r = e;
3093
3093
  throw new Error(`Unsupported field type: ${r.type}`);
@@ -3159,20 +3159,20 @@ function Gs(e, t) {
3159
3159
  return e.maxCharacters !== void 0 && (t = t.slice(0, e.maxCharacters)), t;
3160
3160
  }
3161
3161
  function Hs(e, t) {
3162
- const n = e.fontOrientation, r = `^A${e.font}${n},${e.fontHeight}`, o = `^FB${e.maxWidth},${e.maxLines},${e.lineSpacing},${e.alignment},${e.hangingIndent}`, s = qs(e, t);
3163
- return `^FT${e.x},${e.y}${r}${o}^FD${s}^FS`;
3162
+ const n = e.fontOrientation, r = `^A${e.font}${n},${e.fontHeight}`;
3163
+ let o = e.maxLines;
3164
+ if (e.verticalAlignment === zt.End) {
3165
+ const i = qs(e, t);
3166
+ o = Math.min(i, e.maxLines);
3167
+ }
3168
+ const s = `^FB${e.maxWidth},${o},${e.lineSpacing},${e.alignment},${e.hangingIndent}`;
3169
+ return `^FT${e.x},${e.y}${r}${s}^FD${t}^FS`;
3164
3170
  }
3165
3171
  function qs(e, t) {
3166
- if (e.verticalAlignment !== zt.End)
3167
- return t;
3168
- const n = Xs(e, t), r = Math.max(0, e.maxLines - n);
3169
- return "\\&".repeat(r) + t;
3172
+ const n = t.split("\\&"), r = e.charsPerLine ?? 0;
3173
+ return Xs(n, r);
3170
3174
  }
3171
3175
  function Xs(e, t) {
3172
- const n = t.split("\\&");
3173
- return Qs(n, e.charsPerLine);
3174
- }
3175
- function Qs(e, t) {
3176
3176
  if (t <= 0)
3177
3177
  return e.length;
3178
3178
  let n = 0;
@@ -3180,11 +3180,11 @@ function Qs(e, t) {
3180
3180
  n += Math.max(1, Math.ceil(r.length / t));
3181
3181
  return n;
3182
3182
  }
3183
- function ec(e, t) {
3183
+ function Qs(e, t) {
3184
3184
  const n = `^BY${e.barWidth}`, r = `^BC${e.orientation},${e.height},${e.line},${e.lineAbove},${e.checkDigit},N`;
3185
3185
  return `^FT${e.x},${e.y}${n}${r}^FD>;${t}^FS`;
3186
3186
  }
3187
- function tc(e, t) {
3187
+ function ec(e, t) {
3188
3188
  const n = `^BQ${e.orientation},${e.model},${e.magnification},${e.errorCorrection},${e.mask}`;
3189
3189
  return `^FT${e.x},${e.y}${n}^FDQA,${t}^FS`;
3190
3190
  }
@@ -3207,14 +3207,13 @@ export {
3207
3207
  zt as VerticalAlignment,
3208
3208
  Cs as YesNo,
3209
3209
  Is as allMediaModeSchema,
3210
- qs as applyVerticalAlignment,
3211
3210
  ps as backfeedActionSchema,
3212
3211
  wt as badgeSchema,
3213
3212
  Ls as barcodeFieldSchema,
3214
- Xs as countLines,
3213
+ qs as countLines,
3215
3214
  Vs as fieldSchema,
3216
3215
  yt as fontOrientationSchema,
3217
- sc as generate,
3216
+ ic as generate,
3218
3217
  Ks as getFieldValue,
3219
3218
  hs as mediaTypeSchema,
3220
3219
  ys as mirrorModeSchema,
@@ -3230,9 +3229,9 @@ export {
3230
3229
  Us as textFieldSchema,
3231
3230
  Ms as textTransformationSchema,
3232
3231
  _s as thermalMediaTypeSchema,
3233
- oc as validateBadge,
3234
- ic as validateBadgeOrThrow,
3232
+ rc as validateBadge,
3233
+ oc as validateBadgeOrThrow,
3235
3234
  Rs as verticalAlignmentSchema,
3236
- rc as wordWidthSchema,
3235
+ nc as wordWidthSchema,
3237
3236
  ae as yesNoSchema
3238
3237
  };
@@ -2,16 +2,6 @@ import { Badge, Field, TextField } from './validate';
2
2
  import { SourceData } from './interfaces';
3
3
  export declare function generate(badge: Badge, data?: SourceData): string;
4
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
5
  /**
16
6
  * Counts how many lines the field data will occupy inside a ^FB field.
17
7
  * Exported so consuming projects (e.g. React label previews) can reuse
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@connectedxm/zpl-generator",
3
- "version": "0.0.4-beta.1",
3
+ "version": "0.0.4-beta.2",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "",