Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/core/src/registry/symbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ export const DEFAULT_GS_SYMBOL_META =
* for which codes round-trip cleanly. */
export const GS_SYMBOL_CODES: ReadonlySet<string> = new Set(GS_SYMBOLS.map((s) => s.code));

/** UL and CSA are protected certification marks, legal only on products
* certified by the issuing organisation. */
export const CERTIFICATION_MARK_CODES: ReadonlySet<SymbolCode> = new Set(['D', 'E']);

export interface SymbolProps {
/** Single-letter ZPL ^GS code that selects which symbol the printer
* renders. A=®, B=©, C=™, D=UL logo, E=CSA logo. */
Expand Down
1 change: 1 addition & 0 deletions src/locales/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ const ar = {
symbolTrademark: 'علامة تجارية (™)',
symbolUL: 'اعتماد UL',
symbolCSA: 'اعتماد CSA',
certMarkWarningFmt: '{mark} علامة اعتماد محمية. استخدمها فقط على المنتجات المعتمدة من الجهة المُصدرة.',
},
upca: {
content: 'المحتوى (11 رقم)',
Expand Down
1 change: 1 addition & 0 deletions src/locales/bg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ const bg = {
symbolTrademark: 'Търговска марка (™)',
symbolUL: 'UL одобрение',
symbolCSA: 'CSA одобрение',
certMarkWarningFmt: '{mark} е защитен сертификационен знак. Използвайте го само за продукти, сертифицирани от издаващата организация.',
},
upca: {
content: 'Съдържание (11 цифри)',
Expand Down
1 change: 1 addition & 0 deletions src/locales/cs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ const cs = {
symbolTrademark: 'Ochranná známka (™)',
symbolUL: 'Schválení UL',
symbolCSA: 'Schválení CSA',
certMarkWarningFmt: '{mark} je chráněná certifikační značka. Používejte ji pouze u produktů certifikovaných příslušnou organizací.',
},
upca: {
content: 'Obsah (11 číslic)',
Expand Down
1 change: 1 addition & 0 deletions src/locales/da.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ const da = {
symbolTrademark: 'Varemærke (™)',
symbolUL: 'UL-godkendelse',
symbolCSA: 'CSA-godkendelse',
certMarkWarningFmt: '{mark} er et beskyttet certificeringsmærke. Brug det kun på produkter certificeret af den udstedende organisation.',
},
upca: {
content: 'Indhold (11 cifre)',
Expand Down
1 change: 1 addition & 0 deletions src/locales/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,7 @@ const de = {
symbolTrademark: 'Markenzeichen (™)',
symbolUL: 'UL-Zulassung',
symbolCSA: 'CSA-Zulassung',
certMarkWarningFmt: '{mark} ist ein geschütztes Zertifizierungszeichen. Nur auf Produkten verwenden, die von der jeweiligen Organisation zertifiziert sind.',
},
upca: {
content: 'Inhalt (11 Ziffern)',
Expand Down
1 change: 1 addition & 0 deletions src/locales/el.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ const el = {
symbolTrademark: 'Εμπορικό σήμα (™)',
symbolUL: 'Έγκριση UL',
symbolCSA: 'Έγκριση CSA',
certMarkWarningFmt: 'Το {mark} είναι προστατευόμενο σήμα πιστοποίησης. Χρησιμοποιήστε το μόνο σε προϊόντα πιστοποιημένα από τον εκδίδοντα οργανισμό.',
},
upca: {
content: 'Περιεχόμενο (11 ψηφία)',
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,7 @@ const en = {
symbolTrademark: 'Trademark (™)',
symbolUL: 'UL approval',
symbolCSA: 'CSA approval',
certMarkWarningFmt: '{mark} is a protected certification mark. Use it only on products certified by the issuing organisation.',
},
upca: {
content: 'Content (11 digits)',
Expand Down
1 change: 1 addition & 0 deletions src/locales/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ const es = {
symbolTrademark: 'Marca registrada (™)',
symbolUL: 'Aprobación UL',
symbolCSA: 'Aprobación CSA',
certMarkWarningFmt: '{mark} es una marca de certificación protegida. Utilícela solo en productos certificados por la organización emisora.',
},
upca: {
content: 'Contenido (11 dígitos)',
Expand Down
1 change: 1 addition & 0 deletions src/locales/et.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ const et = {
symbolTrademark: 'Kaubamärk (™)',
symbolUL: 'UL heakskiit',
symbolCSA: 'CSA heakskiit',
certMarkWarningFmt: '{mark} on kaitstud sertifitseerimismärk. Kasutage seda ainult toodetel, mille on sertifitseerinud väljastav organisatsioon.',
},
upca: {
content: 'Sisu (11 numbrit)',
Expand Down
1 change: 1 addition & 0 deletions src/locales/fa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ const fa = {
symbolTrademark: 'علامت تجاری (™)',
symbolUL: 'تأیید UL',
symbolCSA: 'تأیید CSA',
certMarkWarningFmt: '{mark} یک علامت گواهی حفاظت‌شده است. تنها آن را روی محصولاتی استفاده کنید که توسط سازمان صادرکننده گواهی شده‌اند.',
},
upca: {
content: 'محتوا (۱۱ رقم)',
Expand Down
1 change: 1 addition & 0 deletions src/locales/fi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ const fi = {
symbolTrademark: 'Tavaramerkki (™)',
symbolUL: 'UL-hyväksyntä',
symbolCSA: 'CSA-hyväksyntä',
certMarkWarningFmt: '{mark} on suojattu sertifiointimerkki. Käytä sitä vain tuotteissa, jotka myöntävä organisaatio on sertifioinut.',
},
upca: {
content: 'Sisältö (11 numeroa)',
Expand Down
1 change: 1 addition & 0 deletions src/locales/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ const fr = {
symbolTrademark: 'Marque déposée (™)',
symbolUL: 'Approbation UL',
symbolCSA: 'Approbation CSA',
certMarkWarningFmt: "{mark} est une marque de certification protégée. Utilisez-la uniquement sur des produits certifiés par l'organisme émetteur.",
},
upca: {
content: 'Contenu (11 chiffres)',
Expand Down
1 change: 1 addition & 0 deletions src/locales/he.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ const he = {
symbolTrademark: 'סימן מסחרי (™)',
symbolUL: 'אישור UL',
symbolCSA: 'אישור CSA',
certMarkWarningFmt: '{mark} הוא סימן הסמכה מוגן. יש להשתמש בו רק במוצרים המוסמכים על ידי הגוף המנפיק.',
},
upca: {
content: 'תוכן (11 ספרות)',
Expand Down
1 change: 1 addition & 0 deletions src/locales/hr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ const hr = {
symbolTrademark: 'Zaštitni znak (™)',
symbolUL: 'UL odobrenje',
symbolCSA: 'CSA odobrenje',
certMarkWarningFmt: '{mark} je zaštićena certifikacijska oznaka. Koristite je samo na proizvodima koje je certificirala izdavačka organizacija.',
},
upca: {
content: 'Sadržaj (11 znamenki)',
Expand Down
1 change: 1 addition & 0 deletions src/locales/hu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ const hu = {
symbolTrademark: 'Védjegy (™)',
symbolUL: 'UL-jóváhagyás',
symbolCSA: 'CSA-jóváhagyás',
certMarkWarningFmt: 'A(z) {mark} védett tanúsítási jelölés. Csak a kibocsátó szervezet által tanúsított termékeken használja.',
},
upca: {
content: 'Tartalom (11 számjegy)',
Expand Down
1 change: 1 addition & 0 deletions src/locales/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ const it = {
symbolTrademark: 'Marchio registrato (™)',
symbolUL: 'Approvazione UL',
symbolCSA: 'Approvazione CSA',
certMarkWarningFmt: "{mark} è un marchio di certificazione protetto. Utilizzarlo solo su prodotti certificati dall'ente emittente.",
},
upca: {
content: 'Contenuto (11 cifre)',
Expand Down
1 change: 1 addition & 0 deletions src/locales/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ const ja = {
symbolTrademark: '商標 (™)',
symbolUL: 'UL認証',
symbolCSA: 'CSA認証',
certMarkWarningFmt: '{mark}は保護された認証マークです。発行団体が認証した製品にのみ使用してください。',
},
upca: {
content: '内容(11桁)',
Expand Down
1 change: 1 addition & 0 deletions src/locales/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ const ko = {
symbolTrademark: '상표 (™)',
symbolUL: 'UL 승인',
symbolCSA: 'CSA 승인',
certMarkWarningFmt: '{mark}는 보호되는 인증 마크입니다. 발행 기관이 인증한 제품에만 사용하세요.',
},
upca: {
content: '내용 (11자리)',
Expand Down
1 change: 1 addition & 0 deletions src/locales/lt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ const lt = {
symbolTrademark: 'Prekės ženklas (™)',
symbolUL: 'UL patvirtinimas',
symbolCSA: 'CSA patvirtinimas',
certMarkWarningFmt: '{mark} yra saugomas sertifikavimo ženklas. Naudokite jį tik produktams, kuriuos sertifikavo juos išduodanti organizacija.',
},
upca: {
content: 'Turinys (11 skaitmenų)',
Expand Down
1 change: 1 addition & 0 deletions src/locales/lv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ const lv = {
symbolTrademark: 'Preču zīme (™)',
symbolUL: 'UL apstiprinājums',
symbolCSA: 'CSA apstiprinājums',
certMarkWarningFmt: '{mark} ir aizsargāta sertifikācijas zīme. Izmantojiet to tikai produktiem, kurus sertificējusi izdevēja organizācija.',
},
upca: {
content: 'Saturs (11 cipari)',
Expand Down
1 change: 1 addition & 0 deletions src/locales/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ const nl = {
symbolTrademark: 'Handelsmerk (™)',
symbolUL: 'UL-goedkeuring',
symbolCSA: 'CSA-goedkeuring',
certMarkWarningFmt: '{mark} is een beschermd certificeringsmerk. Gebruik het alleen op producten die door de uitgevende organisatie zijn gecertificeerd.',
},
upca: {
content: 'Inhoud (11 cijfers)',
Expand Down
1 change: 1 addition & 0 deletions src/locales/no.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ const no = {
symbolTrademark: 'Varemerke (™)',
symbolUL: 'UL-godkjenning',
symbolCSA: 'CSA-godkjenning',
certMarkWarningFmt: '{mark} er et beskyttet sertifiseringsmerke. Bruk det kun på produkter sertifisert av den utstedende organisasjonen.',
},
upca: {
content: 'Innhold (11 siffer)',
Expand Down
1 change: 1 addition & 0 deletions src/locales/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ const pl = {
symbolTrademark: 'Znak towarowy (™)',
symbolUL: 'Aprobata UL',
symbolCSA: 'Aprobata CSA',
certMarkWarningFmt: '{mark} to chroniony znak certyfikacji. Używaj go wyłącznie na produktach certyfikowanych przez wydającą je organizację.',
},
upca: {
content: 'Zawartość (11 cyfr)',
Expand Down
1 change: 1 addition & 0 deletions src/locales/pt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ const pt = {
symbolTrademark: 'Marca registrada (™)',
symbolUL: 'Aprovação UL',
symbolCSA: 'Aprovação CSA',
certMarkWarningFmt: '{mark} é uma marca de certificação protegida. Utilize-a apenas em produtos certificados pela organização emissora.',
},
upca: {
content: 'Conteúdo (11 dígitos)',
Expand Down
1 change: 1 addition & 0 deletions src/locales/ro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ const ro = {
symbolTrademark: 'Marcă comercială (™)',
symbolUL: 'Aprobare UL',
symbolCSA: 'Aprobare CSA',
certMarkWarningFmt: '{mark} este o marcă de certificare protejată. Utilizați-o doar pe produse certificate de organizația emitentă.',
},
upca: {
content: 'Conținut (11 cifre)',
Expand Down
1 change: 1 addition & 0 deletions src/locales/sk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ const sk = {
symbolTrademark: 'Ochranná známka (™)',
symbolUL: 'Schválenie UL',
symbolCSA: 'Schválenie CSA',
certMarkWarningFmt: '{mark} je chránená certifikačná značka. Používajte ju iba na produktoch certifikovaných vydávajúcou organizáciou.',
},
upca: {
content: 'Obsah (11 číslic)',
Expand Down
1 change: 1 addition & 0 deletions src/locales/sl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ const sl = {
symbolTrademark: 'Blagovna znamka (™)',
symbolUL: 'UL odobritev',
symbolCSA: 'CSA odobritev',
certMarkWarningFmt: '{mark} je zaščitena certifikacijska znamka. Uporabljajte jo samo na izdelkih, ki jih je certificirala izdajateljska organizacija.',
},
upca: {
content: 'Vsebina (11 števk)',
Expand Down
1 change: 1 addition & 0 deletions src/locales/sr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ const sr = {
symbolTrademark: 'Заштитни знак (™)',
symbolUL: 'UL одобрење',
symbolCSA: 'CSA одобрење',
certMarkWarningFmt: '{mark} је заштићена сертификациона ознака. Користите је само на производима које је сертификовала издавачка организација.',
},
upca: {
content: 'Садржај (11 цифара)',
Expand Down
1 change: 1 addition & 0 deletions src/locales/sv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ const sv = {
symbolTrademark: 'Varumärke (™)',
symbolUL: 'UL-godkännande',
symbolCSA: 'CSA-godkännande',
certMarkWarningFmt: '{mark} är ett skyddat certifieringsmärke. Använd det endast på produkter certifierade av den utfärdande organisationen.',
},
upca: {
content: 'Innehåll (11 siffror)',
Expand Down
1 change: 1 addition & 0 deletions src/locales/tr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ const tr = {
symbolTrademark: 'Ticari marka (™)',
symbolUL: 'UL onayı',
symbolCSA: 'CSA onayı',
certMarkWarningFmt: '{mark} korumalı bir sertifikasyon işaretidir. Yalnızca veren kuruluş tarafından sertifikalandırılmış ürünlerde kullanın.',
},
upca: {
content: 'İçerik (11 hane)',
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh-hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ const zhHans = {
symbolTrademark: '商标 (™)',
symbolUL: 'UL 认证',
symbolCSA: 'CSA 认证',
certMarkWarningFmt: '{mark} 是受保护的认证标志。仅可用于经发证机构认证的产品。',
},
upca: {
content: '内容(11位)',
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh-hant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ const zhHant = {
symbolTrademark: '商標 (™)',
symbolUL: 'UL 認證',
symbolCSA: 'CSA 認證',
certMarkWarningFmt: '{mark} 是受保護的認證標誌。僅可用於經發證機構認證的產品。',
},
upca: {
content: '內容(11位)',
Expand Down
88 changes: 88 additions & 0 deletions src/registry/symbol.panel.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// @vitest-environment jsdom
import { describe, it, expect, afterEach, beforeEach } from "vitest";
import { render, cleanup, act } from "@testing-library/react";
import { symbolPanel } from "./symbol.panel";
import { useLabelStore } from "../store/labelStore";
import { fallbackTranslations as en } from "../locales";
import type { SymbolProps } from "@zplab/core/registry/symbol";
import type { LabelObjectBase } from "@zplab/core/types/LabelObject";

afterEach(cleanup);
beforeEach(() => {
act(() => {
useLabelStore.setState({ showZplCommands: false } as never);
});
});

const makeObj = (symbol: SymbolProps["symbol"]): LabelObjectBase & { props: SymbolProps } => ({
id: "sym-1",
type: "symbol",
x: 0,
y: 0,
rotation: 0,
props: { symbol, height: 40, width: 40, rotation: "N" },
});

const Panel = symbolPanel.PropertiesPanel;

describe("symbol panel certification-mark gate", () => {
it("hides UL/CSA options without power-user mode", () => {
const { getByRole, getAllByRole, queryByRole } = render(
<Panel obj={makeObj("B")} onChange={() => undefined} />,
);
// Options only mount once the listbox is open; asserting against the
// closed trigger would pass even with the gate removed.
act(() => {
getByRole("button", { name: en.registry.symbol.symbol }).click();
});
expect(getAllByRole("option").length).toBeGreaterThan(0);
expect(queryByRole("option", { name: /UL/ })).toBeNull();
expect(queryByRole("option", { name: /CSA/ })).toBeNull();
});

it("offers UL/CSA in power-user mode", () => {
act(() => {
useLabelStore.setState({ showZplCommands: true } as never);
});
const { getByRole, getByText } = render(
<Panel obj={makeObj("B")} onChange={() => undefined} />,
);
act(() => {
getByRole("button", { name: en.registry.symbol.symbol }).click();
});
expect(getByText(new RegExp(en.registry.symbol.symbolUL))).toBeTruthy();
expect(getByText(new RegExp(en.registry.symbol.symbolCSA))).toBeTruthy();
});

it("keeps a carried UL selectable without power-user mode and shows the disclaimer", () => {
const { getByRole, getByText, getAllByText, queryByText } = render(
<Panel obj={makeObj("D")} onChange={() => undefined} />,
);
expect(getByText(en.registry.symbol.certMarkWarningFmt.replace("{mark}", "UL"))).toBeTruthy();
act(() => {
getByRole("button", { name: en.registry.symbol.symbol }).click();
});
// Current value stays listed (trigger + option); CSA stays hidden.
expect(getAllByText(new RegExp(en.registry.symbol.symbolUL)).length).toBeGreaterThan(1);
expect(queryByText(new RegExp(en.registry.symbol.symbolCSA))).toBeNull();
});

it("mirrors the carried-value exception for CSA", () => {
const { getByRole, getByText, getAllByText, queryByText } = render(
<Panel obj={makeObj("E")} onChange={() => undefined} />,
);
expect(getByText(en.registry.symbol.certMarkWarningFmt.replace("{mark}", "CSA"))).toBeTruthy();
act(() => {
getByRole("button", { name: en.registry.symbol.symbol }).click();
});
expect(getAllByText(new RegExp(en.registry.symbol.symbolCSA)).length).toBeGreaterThan(1);
expect(queryByText(new RegExp(en.registry.symbol.symbolUL))).toBeNull();
});

it("shows no disclaimer for plain trademark symbols", () => {
const { queryByText } = render(
<Panel obj={makeObj("C")} onChange={() => undefined} />,
);
expect(queryByText(/certification mark/)).toBeNull();
});
});
Loading
Loading