Skip to content

Commit 4a75e52

Browse files
committed
before bump - test to sync validity ui status
1 parent 029592c commit 4a75e52

5 files changed

Lines changed: 48 additions & 18 deletions

File tree

dist-types/client/europlate.client.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { SmartLogFn, BadgeFn } from "./logger/ensureBadgeLogger.js";
2+
export declare function ensureDepsOnce(opts: EuroPlateOptions, log: Logger, BADGE?: BadgeFn, LOG?: SmartLogFn): Promise<void>;
13
/** Lingue supportate dall’SDK. */
24
export type I18nCode = "AUTO" | "IT" | "EN";
35
/** Tipi veicolo supportati dal validatore. */

dist-types/client/europlate.client.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/assets/css/epv.css

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
/* --- Contenitore interno (flag + input + dropdown) --- */
1616
.plate-epv {
17-
position: relative; /* 👈 dropdown assoluto ancorato qui */
17+
position: relative; /* 👈 dropdown assoluto ancorato qui */
1818
display: flex;
1919
align-items: center;
2020
gap: 8px;
@@ -30,13 +30,12 @@
3030
/* --- Input targa --- */
3131
.plate-input {
3232
flex: 1 1 auto;
33-
min-width: 0; /* 👈 importante in flex per evitare overflow */
33+
min-width: 0; /* 👈 importante in flex per evitare overflow */
3434
border: none;
3535
outline: none;
3636
font-size: 1rem;
3737
background: transparent;
3838
letter-spacing: 0.5px;
39-
4039
}
4140

4241
/* --- Bottone bandiera --- */
@@ -85,11 +84,11 @@
8584
.dropdown {
8685
position: absolute;
8786
z-index: 9999;
88-
top: calc(100% + 6px); /* 👈 esci sotto al box */
89-
left: 0; /* 👈 allinea al bordo sinistro del container */
90-
min-width: max(280px, 100%); /* 👈 almeno 280px, ma non più stretto del box */
87+
top: calc(100% + 6px); /* 👈 esci sotto al box */
88+
left: 0; /* 👈 allinea al bordo sinistro del container */
89+
min-width: max(280px, 100%); /* 👈 almeno 280px, ma non più stretto del box */
9190
max-height: 320px;
92-
right: auto;
91+
right: auto;
9392
overflow: auto;
9493
background: #fff;
9594
border: 1px solid #e5e7eb;
@@ -145,9 +144,14 @@
145144
border-color: #198754;
146145
box-shadow: 0 0 0 3px rgba(25, 135, 84, 0.25);
147146
}
148-
147+
.plate-input.valid {
148+
color: #16a34a;
149+
}
149150
/* --- Stato non valido (rosso) --- */
150151

152+
.plate-input.invalid {
153+
color: #dc2626;
154+
}
151155
.invalid .plate-epv {
152156
border-color: #dc3545;
153157
box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.25);

src/client/europlate.client.ts

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,29 @@ import {
2828
getCountryName,
2929
} from "../countries.js";
3030

31+
// 👇 in cima al file (scope di modulo)
32+
let __depsOnce: Promise<void> | null = null;
33+
34+
export async function ensureDepsOnce(opts: EuroPlateOptions, log: Logger, BADGE: BadgeFn = () => {}, LOG: SmartLogFn = () => {}) {
35+
if (!__depsOnce) {
36+
__depsOnce = (async () => {
37+
BADGE("EPV[Deps]", "Ensuring dependencies…", "info");
38+
try {
39+
await ensureDeps(opts, log, BADGE, LOG);
40+
BADGE("EPV[Deps]", "Dependencies ensured successfully", "ok");
41+
} catch (err) {
42+
BADGE("EPV[Deps]", `Error during ensureDeps: ${(err as Error)?.message || err}`, "err");
43+
throw err;
44+
} finally {
45+
BADGE("EPV[Deps]", "ensureDeps finished", "debug");
46+
}
47+
})();
48+
} else {
49+
BADGE("EPV[Deps]", "Deps ensure already in-flight / done", "debug");
50+
}
51+
return __depsOnce;
52+
}
53+
3154
/* ============================================================
3255
* Tipi PUBBLICI (API surface)
3356
* ============================================================ */
@@ -1112,13 +1135,13 @@ export function createEuroPlate(EuroMod: any, opts: EuroPlateOptions): EuroPlate
11121135
let log: Logger = makeBaseLogger(logPrefix, DBG, logger);
11131136

11141137
// ---------- DEPS (fire & forget, ora con BADGE/LOG in chiaro)
1115-
void ensureDeps(opts, log, BADGE, LOG).then(() => {
1116-
if (useToastrLogger === true && getToastr() && !logger) {
1138+
void ensureDepsOnce(opts, log, BADGE, LOG).then(() => {
1139+
const G = window as any;
1140+
1141+
if (useToastrLogger && getToastr() && !logger && !G.CC_EPV_TOASTR_LOGGER_ATTACHED) {
11171142
log = makeToastrLogger(logPrefix, DBG);
1118-
//log.info?.("Toastr logger attached");
1119-
BADGE("EuroPlate", "Toastr logger attached", "debug");
1120-
(opts.autoLoadDeps ||= {}).toastr = false;
1121-
(opts.autoLoadDeps ||= {}).jquery = false;
1143+
G.CC_EPV_TOASTR_LOGGER_ATTACHED = true;
1144+
BADGE("EuroPlate", "Toastr logger attached (once)", "debug");
11221145
}
11231146
// se IM arriva dopo e non siamo in AUTO, prova ad applicare la mask
11241147
if (hasIMBound() && selected !== "AUTO") {
@@ -1320,7 +1343,8 @@ export function createEuroPlate(EuroMod: any, opts: EuroPlateOptions): EuroPlate
13201343
iconEl.textContent = ok ? "✓" : "!";
13211344
} else if (statusIcon === "pill") {
13221345
iconEl.classList.add("pill", ok ? "ok" : "err");
1323-
iconEl.textContent = ok ? "OK" : "ERR";
1346+
//iconEl.textContent = ok ? "OK" : "ERR";
1347+
iconEl.textContent = ok ? "✓" : "!";
13241348
} else {
13251349
iconEl.textContent = "";
13261350
}

src/client/logger/ensureBadgeLogger.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ export function ensureBadgeLogger(prefix: string, debug: boolean) {
2525
function localBADGE(mod: string, msg: string, colorKey?: ColorKey | string) {
2626
if (!debug) return;
2727
const c = G.CC_COLORS[colorKey as keyof CCColors] || colorKey || G.CC_COLORS.gold;
28-
const txc = [G.CC_COLORS["gold"], G.CC_COLORS["info"], G.CC_COLORS["ok"]].includes(c) ? "#000" : "#fff";
28+
const txc = [G.CC_COLORS["bg1"], G.CC_COLORS["bg1"]].includes(c) ? "#fff" : "#000";
2929
//const tag = `%c CodeCorn™ ${mod} %c ${prefix} ${msg} %c`;
3030
// ⚠️ niente prefix qui: lo aggiunge il wrapper BADGE sotto
3131
const tag = `%c CodeCorn™ ${mod} %c ${msg} %c`;
3232
const css1 = `background:${G.CC_COLORS.bg1};color:#fff;padding:3px 6px;border-radius:4px 0 0 4px;`;
33-
const css2 = `background:${c};color:${txc};font-weight:bold;padding:3px 6px;`;
33+
const css2 = `background:${c};color:${txc};font-weight:bold;padding:3px 6px;text-transform:uppercase;`;
3434
const css3 = `background:${G.CC_COLORS.bg3};color:#fff;padding:3px 6px;border-radius:0 4px 4px 0;`;
3535
try {
3636
console.log(tag, css1, css2, css3);

0 commit comments

Comments
 (0)