Skip to content

Commit 7d91f12

Browse files
committed
chore: initial version of barcode generator
1 parent d3a160c commit 7d91f12

24 files changed

+674
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require("@mendix/prettier-config-web-widgets");
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Changelog
2+
3+
All notable changes to this widget will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
## [Unreleased]
8+
9+
## [1.0.0] - 2025-10-09
10+
11+
### Added
12+
13+
- Initial release of QR Code Generator widget
14+
- Generate QR codes from string input
15+
- Configurable QR code properties
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<!-- Please see [Barcode Generator](https://docs.mendix.com/appstore/widgets/barcode-generator) in the Mendix documentation for details. -->
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { test, expect } from "@playwright/test";
2+
3+
test.afterEach("Cleanup session", async ({ page }) => {
4+
// Because the test isolation that will open a new session for every test executed, and that exceeds Mendix's license limit of 5 sessions, so we need to force logout after each test.
5+
await page.evaluate(() => window.mx.session.logout());
6+
});
7+
8+
test.describe("BarcodeGenerator", () => {
9+
test.beforeEach(async ({ page }) => {
10+
await page.goto("/");
11+
await page.waitForLoadState("networkidle");
12+
});
13+
14+
test("renders barcode generator widget", async ({ page }) => {
15+
// TODO: Replace with actual barcode generator test when implementation is complete
16+
// Example test structure for barcode generator:
17+
// await expect(page.locator(".mx-name-barcodeGenerator").first()).toBeVisible();
18+
// await page.locator(".mx-name-textInput").fill("Test QR Code");
19+
// await expect(page.locator(".mx-name-barcodeGenerator canvas")).toBeVisible();
20+
21+
// Placeholder test for now
22+
await expect(page.locator("body")).toBeVisible();
23+
});
24+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import config from "@mendix/eslint-config-web-widgets/widget-ts.mjs";
2+
3+
export default config;
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"name": "@mendix/barcode-generator-web",
3+
"widgetName": "BarcodeGenerator",
4+
"version": "1.0.0",
5+
"description": "Generate barcodes and QR codes from a string input",
6+
"copyright": "© Mendix Technology BV 2025. All rights reserved.",
7+
"license": "Apache-2.0",
8+
"repository": {
9+
"type": "git",
10+
"url": "https://github.com/mendix/web-widgets.git"
11+
},
12+
"config": {},
13+
"mxpackage": {
14+
"name": "BarcodeGenerator",
15+
"type": "widget",
16+
"mpkName": "BarcodeGenerator.mpk"
17+
},
18+
"packagePath": "com.mendix.widget.web",
19+
"marketplace": {
20+
"minimumMXVersion": "9.6.0",
21+
"appNumber": -1,
22+
"appName": "Barcode Generator",
23+
"reactReady": true
24+
},
25+
"testProject": {
26+
"githubUrl": "https://github.com/mendix/testProjects",
27+
"branchName": "barcode-generator-web"
28+
},
29+
"scripts": {
30+
"build": "pluggable-widgets-tools build:web",
31+
"create-gh-release": "rui-create-gh-release",
32+
"create-translation": "rui-create-translation",
33+
"dev": "pluggable-widgets-tools start:web",
34+
"e2e": "echo \"Skipping barcode-generator-web e2e tests\"",
35+
"e2edev": "run-e2e dev --with-preps",
36+
"format": "prettier --ignore-path ./node_modules/@mendix/prettier-config-web-widgets/global-prettierignore --write .",
37+
"lint": "eslint src/ package.json",
38+
"publish-marketplace": "rui-publish-marketplace",
39+
"release": "pluggable-widgets-tools release:web",
40+
"start": "pluggable-widgets-tools start:server",
41+
"test": "pluggable-widgets-tools test:unit:web:enzyme-free",
42+
"update-changelog": "rui-update-changelog-widget",
43+
"verify": "rui-verify-package-format"
44+
},
45+
"dependencies": {
46+
"classnames": "^2.5.1",
47+
"jsbarcode": "^3.12.1",
48+
"qrcode.react": "^4.2.0"
49+
},
50+
"devDependencies": {
51+
"@mendix/automation-utils": "workspace:*",
52+
"@mendix/eslint-config-web-widgets": "workspace:*",
53+
"@mendix/pluggable-widgets-tools": "*",
54+
"@mendix/prettier-config-web-widgets": "workspace:*",
55+
"@mendix/run-e2e": "workspace:*",
56+
"@mendix/widget-plugin-component-kit": "workspace:*",
57+
"@mendix/widget-plugin-platform": "workspace:*",
58+
"@mendix/widget-plugin-test-utils": "workspace:*",
59+
"cross-env": "^7.0.3"
60+
}
61+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require("@mendix/run-e2e/playwright.config.cjs");
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { hidePropertiesIn, Properties } from "@mendix/pluggable-widgets-tools";
2+
import { BarcodeGeneratorPreviewProps } from "../typings/BarcodeGeneratorProps";
3+
4+
export type Problem = {
5+
property?: string; // key of the property, at which the problem exists
6+
severity?: "error" | "warning" | "deprecation"; // default = "error"
7+
message: string; // description of the problem
8+
studioMessage?: string; // studio-specific message, defaults to message
9+
url?: string; // link with more information about the problem
10+
studioUrl?: string; // studio-specific link
11+
};
12+
13+
export function getProperties(values: BarcodeGeneratorPreviewProps, defaultProperties: Properties): Properties {
14+
if (values.codeFormat === "QRCode") {
15+
hidePropertiesIn(defaultProperties, values, ["codeWidth", "codeHeight", "displayValue"]);
16+
} else {
17+
hidePropertiesIn(defaultProperties, values, ["qrSize"]);
18+
}
19+
20+
if (values.codeFormat !== "Custom") {
21+
hidePropertiesIn(defaultProperties, values, ["customCodeFormat"]);
22+
}
23+
return defaultProperties;
24+
}
25+
26+
export function check(_values: BarcodeGeneratorPreviewProps): Problem[] {
27+
const errors: Problem[] = [];
28+
29+
if (!_values.codeWidth || _values.codeWidth < 1) {
30+
errors.push({
31+
property: `codeWidth`,
32+
severity: "error",
33+
message: `The value of 'Bar width' must be at least 1.`
34+
});
35+
}
36+
37+
if (!_values.codeHeight || _values.codeHeight < 20) {
38+
errors.push({
39+
property: `codeHeight`,
40+
severity: "error",
41+
message: `The value of 'Code height' must be at least 20.`
42+
});
43+
}
44+
45+
if (!_values.qrSize || _values.qrSize < 50) {
46+
errors.push({
47+
property: `codeHeight`,
48+
severity: "error",
49+
message: `The value of 'QR size' must be at least 50.`
50+
});
51+
}
52+
53+
return errors;
54+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { ReactElement } from "react";
2+
import { BarcodeGeneratorPreviewProps } from "../typings/BarcodeGeneratorProps";
3+
import BarcodePreviewSVG from "./assets/BarcodeGeneratorPreview.svg";
4+
5+
export function preview(_props: BarcodeGeneratorPreviewProps): ReactElement {
6+
const doc = decodeURI(BarcodePreviewSVG);
7+
8+
return (
9+
<div className="barcode-generator-widget-preview">
10+
<img src={doc} alt="" />
11+
</div>
12+
);
13+
}
636 Bytes
Loading

0 commit comments

Comments
 (0)