Skip to content

Feature/gs1 databar variants#21

Merged
u8array merged 7 commits into
mainfrom
feature/gs1-databar-variants
May 6, 2026
Merged

Feature/gs1 databar variants#21
u8array merged 7 commits into
mainfrom
feature/gs1-databar-variants

Conversation

@u8array
Copy link
Copy Markdown
Owner

@u8array u8array commented May 6, 2026

No description provided.

u8array added 6 commits May 6, 2026 23:10
…spec)

Segments must be even (2-22). The hardcoded 1 was spec-invalid; Zebra
firmware ignores it for Omnidirectional but the output was technically wrong.
Replaces the createBarcode1D delegation with a dedicated Gs1DatabarProps
interface supporting all 7 symbologies (Omnidirectional through Expanded
Stacked). Parser reads symbology and segments from ^BR. bwip-js renders
each variant with the correct bcid. Segments input is shown only for
Expanded Stacked (symbology 7, must be even 2-22).

Script: add_locale_key.local.py extended with optional 'indent' and 'block'
fields for inserting into nested registry sub-blocks.
- New test cases for sym 2 (Truncated), 3 (Stacked), 4 (Stacked Omni),
  5 (Limited), 6 (Expanded). Sym 7 (Expanded Stacked) excluded: bwip-js
  requires (AI)data parens, Labelary's ^BR sym 7 silently rejects them.
- Sym 1 (Omnidirectional) is the only variant where bwip-js dimensions
  match Labelary exactly. Sym 2-6 have intrinsic-height divergences;
  ZPL output is still validated, dimension and pixel checks are skipped.
- Drop the segments parameter from ^BR for non-Stacked variants:
  including it makes Labelary stack the symbol incorrectly.
- bwip-js content prep: auto-compute GTIN-14 check digit (sym 1-5) and
  wrap fixed-length AIs in parens (sym 6/7) so the canonical model can
  store raw digits.
Moves gtin14WithCheck, wrapGs1AIs, the Expanded-symbology set, and the
default segments constant out of bwipHelpers.ts (rendering layer) into
src/lib/gs1.ts where ZPL generation and bwip-js prep can share them.

- bwipHelpers and gs1databar both import from lib/gs1
- Magic value 22 replaced by GS1_DATABAR_DEFAULT_SEGMENTS
- EXPANDED_SYMBOLOGIES set is now single-source-of-truth
- 11 new unit tests cover GTIN-14 check digit and AI wrapping edge cases
- Remove the `p.content || "…"` defensive fallbacks in buildBwipOptions:
  defaultProps already populates content, the fallback was dead code.
- Drop the redundant `as Gs1DatabarProps` cast — the switch case narrows
  obj.props automatically.
- Replace the hardcoded 100 in toZPL with ZPL_HEIGHT_PLACEHOLDER, with a
  comment documenting why the value doesn't reflect actual bar height.
- Document SYMBOLOGY_LABELS being intentionally not i18n'd (matches the
  convention used for other barcode-type names).
- Test side: drop the partial `as { symbology?: number }` cast — proper
  type narrowing reaches obj.props.symbology directly.
- zplParser BR handler imports GS1_DATABAR_DEFAULT_SEGMENTS instead of
  the bare 22 literal.
- Object.entries(SYMBOLOGY_LABELS) cast removed: TS infers the right
  [string, string][] tuple shape from the Record's value type.
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request expands GS1 Databar support by implementing all seven symbology variants (Omnidirectional, Truncated, Stacked, Stacked Omni, Limited, Expanded, and Expanded Stacked). It introduces domain helpers for GTIN check digit calculation and Application Identifier (AI) wrapping, updates the ZPL parser to handle complex ^BR parameters, and adds a dedicated properties panel for symbology-specific configuration. Feedback was provided regarding the segments input logic to ensure values remain within the valid range (2-22) after rounding to the nearest even number.

Comment thread src/registry/gs1databar.tsx
Direct numeric typing (or paste) bypasses the HTML max attribute. With the
prior round-to-even logic, an input of 23 would land on 24 — outside the
ZPL spec range. Clamp via Math.max(2, Math.min(22, …)) after rounding.
@u8array u8array merged commit dd05902 into main May 6, 2026
2 checks passed
@u8array u8array deleted the feature/gs1-databar-variants branch May 7, 2026 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant