Skip to content

Commit 01a6f9f

Browse files
samuelreichertclaude
authored andcommitted
docs(openspec): record margin, visibility and verification outcomes
Add requirements for the dedicated Data Matrix sizing/quiet zone and for format-scoped property visibility, resolve the design doc's open question on sizing props with the bwip-js scaling evidence, and update the task list: the build now succeeds (~228 KB minified / ~73 KB gzipped for the tree-shaken Data Matrix encoders) and e2e is written but dormant. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent dd34f1e commit 01a6f9f

3 files changed

Lines changed: 38 additions & 4 deletions

File tree

  • packages/pluggableWidgets/barcode-generator-web/openspec/changes/add-datamatrix-generation

packages/pluggableWidgets/barcode-generator-web/openspec/changes/add-datamatrix-generation/design.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ Additive, no data migration. New dependency added to `package.json`; `typings/Ba
4848
## Open Questions
4949

5050
- Exact bwip-js option for rectangular DataMatrix (shape flag vs explicit `rows`/`columns`) — confirm at implementation.
51-
- Whether to reuse `codeMargin`/`qrSize`-style sizing or add dedicated `dmSize`/`dmMargin` props — lean toward dedicated to avoid overloading 1D "bar width" semantics.
51+
- ~~Whether to reuse `codeMargin`/`qrSize`-style sizing or add dedicated `dmSize`/`dmMargin` props — lean toward dedicated to avoid overloading 1D "bar width" semantics.~~ Resolved: dedicated `dmSize` and `dmMargin`. bwip-js `paddingwidth`/`paddingheight` are multiplied by `scale`, so the Data Matrix margin is in module units like `qrMargin`, not pixels like `codeMargin` — reusing `codeMargin` would have mislabelled the unit and let a 1D margin of 0 strip the required quiet zone.

packages/pluggableWidgets/barcode-generator-web/openspec/changes/add-datamatrix-generation/specs/barcode-generation/spec.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,39 @@ The widget SHALL allow downloading a generated DataMatrix as a PNG using the exi
8484
- **WHEN** downloads are enabled and the user activates the download button on a DataMatrix
8585
- **THEN** a PNG file of the rendered DataMatrix is downloaded, using the configured or an auto-generated filename
8686

87+
### Requirement: DataMatrix sizing and quiet zone
88+
89+
The widget SHALL expose dedicated size and margin properties for Data Matrix, with the margin expressed in module units so the required quiet zone can be controlled independently of the 1D barcode margin.
90+
91+
#### Scenario: Margin is independent of the 1D and QR margins
92+
93+
- **WHEN** the format is "Data Matrix" and the Data Matrix margin is set to 6 while the 1D margin is 4 and the QR margin is 8
94+
- **THEN** the rendered symbol uses a quiet zone of 6 module units, and changing the 1D or QR margin has no effect on it
95+
96+
#### Scenario: Missing quiet zone is flagged
97+
98+
- **WHEN** the format is "Data Matrix" and the Data Matrix margin is set to 0
99+
- **THEN** Studio Pro shows a warning that at least 1 module unit is needed for the symbol to stay scannable
100+
101+
### Requirement: Format-scoped property visibility
102+
103+
The widget SHALL only show the property groups that apply to the selected barcode format, so Data Matrix settings are hidden for other formats and 1D/QR settings are hidden for Data Matrix.
104+
105+
#### Scenario: Data Matrix settings are scoped to the Data Matrix format
106+
107+
- **WHEN** the Barcode Format is "Barcode", "QR Code" or "Custom"
108+
- **THEN** the "Advanced Data Matrix Settings" properties (GS1 mode, symbol shape, size) are hidden in Studio Pro
109+
110+
#### Scenario: 1D and QR settings are hidden for Data Matrix
111+
112+
- **WHEN** the Barcode Format is "Data Matrix"
113+
- **THEN** bar width, code height, display value, the 1D pixel margin, the advanced barcode settings (EAN-128, flat, last character, Mod43), the EAN addon properties and the QR properties are all hidden, and the Data Matrix margin is shown in their place
114+
115+
#### Scenario: Design-time validation follows the visible properties
116+
117+
- **WHEN** the Barcode Format is "Data Matrix" and the Data Matrix size is below the supported minimum
118+
- **THEN** Studio Pro reports the problem on the Data Matrix size property and does not report problems on hidden 1D or QR sizing properties
119+
87120
### Requirement: DataMatrix editor preview
88121

89122
The widget SHALL show a representative DataMatrix preview in the Studio Pro editor when the Data Matrix format is selected.

packages/pluggableWidgets/barcode-generator-web/openspec/changes/add-datamatrix-generation/tasks.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
- [x] 1.1 Add `@bwip-js/browser` to `packages/pluggableWidgets/barcode-generator-web/package.json` dependencies
44
- [x] 1.2 Add `DataMatrix` enum value to top-level `codeFormat` in `src/BarcodeGenerator.xml`
5-
- [x] 1.3 Add "Advanced Data Matrix Settings" property group in XML: `dmGs1Mode` (boolean, default false), `dmShape` (enum square/rectangle, default square), and sizing property (`dmSize` / reuse margin)
5+
- [x] 1.3 Add "Advanced Data Matrix Settings" property group in XML: `dmGs1Mode` (boolean, default false), `dmShape` (enum square/rectangle, default square), `dmSize` (integer, default 128) and `dmMargin` (integer, default 2, module units — bwip-js scales `paddingwidth`, so this is not the pixel-based `codeMargin`)
66
- [x] 1.4 Build to regenerate `typings/BarcodeGeneratorProps.d.ts` and confirm `CodeFormatEnum` includes `DataMatrix`
7+
- [x] 1.5 Scope property visibility per format in `src/BarcodeGenerator.editorConfig.ts`: hide `dm*` unless `codeFormat === "DataMatrix"`, and hide 1D/QR-only properties (bar sizing, display value, EAN-128, flat, last char, Mod43, EAN addons) when Data Matrix is selected; gate `check()` sizing validation to the visible properties
78

89
## 2. Config Model
910

@@ -31,11 +32,11 @@
3132
## 6. Tests & Changelog
3233

3334
- [x] 6.1 Unit tests: config mapping for DataMatrix, GS1 vs plain `bcid` selection, shape option, validation (valid GS1 AI, malformed AI, plain string, empty value)
34-
- [ ] 6.2 Playwright E2E: render + download a DataMatrix per `docs/requirements/e2e-test-guidelines.md` _(blocked: existing e2e spec is a placeholder; needs the external Mendix testProjects page configured with a DataMatrix widget instance)_
35+
- [~] 6.2 Playwright E2E: `e2e/BarcodeGenerator.spec.js` covers plain render, GS1 render, rectangular shape, value re-render and PNG download _(dormant: `mendix/testProjects` has no `barcode-generator-web` branch — only `barcode-scanner-web` — so `package.json` keeps `"e2e": "echo ..."`. Create the branch with a `/p/datamatrix` page using the mx-names listed in the spec header, then swap the script to `run-e2e ci`.)_
3536
- [x] 6.3 Add user-facing `CHANGELOG.md` entry ("Added Data Matrix and GS1 Data Matrix generation support")
3637

3738
## 7. Verification
3839

3940
- [x] 7.1 `cd packages/pluggableWidgets/barcode-generator-web && pnpm run test` passes
40-
- [ ] 7.2 `pnpm run build` succeeds; confirm bundle delta small (bwip-js tree-shaken to DataMatrix encoder only) _(blocked: local build env has a broken rollup binary — stale `.bin/rollup` shim points to uninstalled rollup@3.29.5; unrelated to this change. Code verified via `tsc --noEmit` + jest instead.)_
41+
- [x] 7.2 `pnpm run build` succeeds; bwip-js is tree-shaken to the Data Matrix encoders (no aztec/pdf417/royalmail/codablockf in the bundle), but they still add ~228 KB minified / ~73 KB gzipped because the bwipp runtime core comes along — larger than "small", acceptable for the feature but worth noting in the PR
4142
- [ ] 7.3 Live Studio Pro test: plain DataMatrix scans via Barcode Scanner (round-trip); GS1 value `(01)09501101020917(17)261231(10)ABC123` renders + decodes; PNG download works; rectangular shape renders _(requires human: live Studio Pro session with `MX_PROJECT_PATH` set)_

0 commit comments

Comments
 (0)