المكوّنات · تأكيد حذف بكتابة الاسم
تأكيد حذف بكتابة الاسم
لا يُفعَّل الزرّ إلّا بكتابة اسم المورد حرفًا بحرف
12 تصاميم من هذه العائلة
<div class="fb fbc"><div class="dlg" role="alertdialog" aria-labelledby="fbc-t" aria-describedby="fbc-d">
<h4 id="fbc-t" data-ar="حذف المشروع نهائيًّا" data-en="Delete project permanently">حذف المشروع نهائيًّا</h4>
<p id="fbc-d"><span data-ar="سيُحذف المشروع و" data-en="This deletes the project and ">سيُحذف المشروع و</span><b class="cnt num"></b><span data-ar=" من ملفّاته. لا يمكن التراجع." data-en=" of its files. This cannot be undone.'"> من ملفّاته. لا يمكن التراجع.</span></p>
<label><span data-ar="اكتب اسم المشروع للتأكيد" data-en="Type the project name to confirm">اكتب اسم المشروع للتأكيد</span>
<code class="target"></code>
<input class="ty" type="text" autocomplete="off" spellcheck="false" dir="ltr"></label>
<div class="acts">
<button class="cancel" data-ar="إلغاء" data-en="Cancel">إلغاء</button>
<button class="del" disabled data-ar="احذف نهائيًّا" data-en="Delete permanently">احذف نهائيًّا</button>
</div>
<p class="out" role="status"></p>
</div></div>
/* pt-scoped */
/* feedback-confirm — لوحة تحكّم */
.fbc{width:100%;height:100%;display:flex;flex-direction:column;
font-size:10px;color:var(--pt-text-secondary);overflow:hidden}
.fbc h4{margin:0;font-size:11px;color:var(--pt-text-primary);font-weight:600;line-height:1.5}
.fbc p{margin:0;font-size:9px;line-height:1.85;color:var(--pt-text-muted)}
.fbc .num{font-variant-numeric:tabular-nums}
.fbc button{font:inherit;cursor:pointer}
.fbc button:focus-visible, .fbc input:focus-visible, .fbc a:focus-visible{
outline:2px solid var(--pt-focus-ring);outline-offset:2px}
.fbc button:disabled{cursor:not-allowed;opacity:.45}
/* كل حالة تُعلَن لقارئ الشاشة: تغيّرٌ لا يُرى ولا يُسمَع لم يحدث */
.fbc [role=status], .fbc [role=alert]{display:block}
@media(pointer:coarse){.fbc button{min-height:44px}
}
/* شخصية: حوار مرتفع، حدّ خطر، انحناء متوسّط */
.fbc{align-items:center;justify-content:center;padding:11px}
.fbc .dlg{display:flex;flex-direction:column;gap:6px;width:100%;max-width:290px;padding:12px 14px;
border-radius:var(--pt-radius-md);background:var(--pt-bg-overlay);
border:1px solid var(--pt-border-default);box-shadow:var(--pt-shadow-4)}
.fbc label{display:flex;flex-direction:column;gap:3px}
.fbc label > span{font-size:8px;color:var(--pt-text-muted)}
.fbc .target{font-family:var(--pt-font-mono);font-size:9px;color:var(--pt-text-primary);
padding:3px 7px;border-radius:var(--pt-radius-xs);background:var(--pt-bg-inset);
align-self:flex-start;user-select:all}
.fbc .ty{padding:5px 8px;border-radius:var(--pt-radius-xs);
border:1px solid var(--pt-border-default);background:var(--pt-bg-inset);
font:inherit;font-family:var(--pt-font-mono);font-size:9px;
color:var(--pt-text-primary);outline:none}
.fbc .ty[aria-invalid=true]{border-color:var(--pt-color-danger-400)}
.fbc .acts{display:flex;gap:5px;margin-top:2px}
.fbc .acts button{flex:1;padding:6px;border-radius:var(--pt-radius-xs);font-size:9px;font-weight:600}
.fbc .cancel{border:1px solid var(--pt-border-default);background:transparent;
color:var(--pt-text-secondary)}
.fbc .del{border:0;background:var(--pt-color-danger-500);color:#fff}
.fbc .out{font-size:8px;min-height:10px;color:var(--pt-text-muted)}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.fbc');
if (!host) return;
var snapshot = host.innerHTML;
var timers = [];
var ac = null;
/* الجسم كما كتبه المولِّد. يستقبل بدائل مظلَّلة لـ root وdocument
والمؤقّتات، فينظّف نفسه دون أن يعرف أنه قابل لإعادة التركيب. */
function run(root, document, setTimeout, setInterval) {
var ar = document.documentElement.lang !== 'en';
var n = function (v, d) { return Number(v).toLocaleString('en-US', {
minimumFractionDigits: d || 0, maximumFractionDigits: d || 0 }); };
var NAME = 'orders-api-prod', FILES = 1284;
var ty = root.querySelector('.ty'), del = root.querySelector('.del');
var out = root.querySelector('.out');
root.querySelector('.target').textContent = NAME;
root.querySelector('.cnt').textContent = n(FILES);
/* المطابقة حرفيّة تمامًا — لا تجاهل لحالة الأحرف ولا للمسافات الطرفية.
المقصود إجبار القراءة، والتساهل يُبطل الغرض. */
function match() { return ty.value === NAME; }
ty.addEventListener('input', function () {
var ok = match();
del.disabled = !ok;
ty.setAttribute('aria-invalid', String(ty.value.length > 0 && !ok));
out.textContent = ty.value.length && !ok
? (ar ? 'الاسم غير مطابق' : 'Name does not match') : '';
});
del.addEventListener('click', function () {
if (!match()) return;
del.disabled = true; ty.disabled = true;
out.textContent = ar ? '✓ حُذف المشروع و' + n(FILES) + ' ملفًّا'
: '✓ Deleted project and ' + n(FILES) + ' files';
});
root.querySelector('.cancel').addEventListener('click', function () {
ty.value = ''; ty.disabled = false; del.disabled = true;
ty.removeAttribute('aria-invalid');
out.textContent = ar ? 'أُلغي — لم يُحذف شيء' : 'Cancelled — nothing was deleted';
});
}
function mount() {
ac = new AbortController();
var real = window.document;
/* وسيط يمرّر كل شيء إلى المستند الحقيقي، ويعلّق كل مستمع بإشارة
تُقطع عند إعادة التركيب — فلا يبقى مستمع من نسخة ماتت. */
var doc = new Proxy(real, {
get: function (t, k) {
if (k === 'addEventListener') {
return function (type, fn, opts) {
var o = (opts && typeof opts === 'object') ? Object.assign({}, opts)
: { capture: !!opts };
o.signal = ac.signal;
return t.addEventListener(type, fn, o);
};
}
var v = t[k];
return typeof v === 'function' ? v.bind(t) : v;
}
});
function track(fn) {
return function (f, ms) { var id = fn(f, ms); timers.push(id); return id; };
}
run(host, doc, track(window.setTimeout.bind(window)),
track(window.setInterval.bind(window)));
}
function unmount() {
if (ac) ac.abort();
// المعرّفان يتشاركان فضاءً واحدًا في المتصفّح، فالإلغاء المزدوج آمن
timers.forEach(function (id) { window.clearTimeout(id); window.clearInterval(id); });
timers = [];
host.innerHTML = snapshot;
}
mount();
addEventListener('pt-lang', function () { unmount(); mount(); });
})();
# Type-to-Confirm Delete
**Role:** You are an Arabic-first UI designer and front-end engineer. Read the whole
specification before writing a single line, then follow it literally. If two requirements
conflict, favour usability over visual effect.
**Goal:** Type-to-Confirm Delete — The button unlocks only when the resource name is typed exactly
**Why this component matters:** For irreversible deletes, make the user type the resource name. A plain OK/Cancel is muscle memory; typing forces them to read what they are about to destroy.
**Direction:** Genuine RTL — not a mirrored Latin layout. Use logical properties
(`margin-inline-start`, `padding-inline`, `inset-inline-start`, `text-align: start`),
never physical ones (`margin-left`, `left`). The layout must flip with `dir` on its own,
with no duplicated rules.
**Typography:** Cairo for Arabic, IBM Plex Sans for Latin. Arabic line-height must be
`0.18` higher than the Latin equivalent — dots, hamzas and maddas need more vertical room.
Arabic font-size runs `1.06×` the Latin size at the same optical weight.
**Numerals:** Western digits in both languages (`1,234.50`). Only the currency changes:
`ر.س` **after** the number in Arabic, `$` **before** it in English. Jordanian dinar
uses **three** decimal places, not two.
**Colors:** Dark mode — background `#0D142B` · surfaces `#211F54` · borders `#545C91` · text `#918FC2`.
Accent `#ADA9E8` must never exceed 8% of the screen area.
**Language:** Bilingual — every string carries both Arabic and English, and the layout
flips with `dir` automatically.
**States:** `default` · `hover` · `focus` · `active` · `disabled` · `loading` · `error`.
Do not design the resting state alone.
**Accessibility:** Contrast ratio at least `4.5:1`, complete keyboard navigation,
visible focus rings, and honour `prefers-reduced-motion`.
**Output:** Clean HTML and CSS in two separate files. No frameworks, no libraries,
no external dependencies.