Feature/gs1 databar variants#21
Merged
Merged
Conversation
…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.
There was a problem hiding this comment.
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.