المكوّنات · تسجيل برقم الجوّال
تسجيل برقم الجوّال
يقبل السعودي والأردني، ويصحّح الصيغة الدولية تلقائيًّا
12 تصاميم من هذه العائلة
<div class="sg sgp">
<h5 data-ar="أنشئ حسابك" data-en="Create your account">أنشئ حسابك</h5>
<p class="sub" data-ar="نرسل رمزًا للتحقّق" data-en="We send a verification code">نرسل رمزًا للتحقّق</p>
<label><span data-ar="رقم الجوّال" data-en="Mobile number">رقم الجوّال</span>
<span class="row">
<select class="cc" aria-label="الدولة"><option value="966">🇸🇦 966+</option>
<option value="962">🇯🇴 962+</option></select>
<input class="ph" type="tel" inputmode="numeric" placeholder="5X XXX XXXX"
aria-describedby="phe"></span>
<span class="err" id="phe"></span></label>
<p class="norm"></p>
<button class="go" data-ar="أرسل الرمز" data-en="Send code">أرسل الرمز</button>
</div>
/* pt-scoped */
/* signup-phone — منصّة طبّية */
.sgp{width:100%;height:100%;display:flex;flex-direction:column;
font-size:10px;color:var(--pt-text-secondary);overflow:hidden}
.sgp h5{margin:0;font-size:11px;color:var(--pt-text-primary);font-weight:600}
.sgp .sub{margin:0;font-size:8.5px;color:var(--pt-text-muted)}
.sgp label{display:flex;flex-direction:column;gap:3px}
.sgp label > span{font-size:8.5px;color:var(--pt-text-muted)}
.sgp input, .sgp select{width:100%;font:inherit;font-size:9.5px;
color:var(--pt-text-primary);outline:none}
.sgp input::placeholder{color:var(--pt-text-muted)}
.sgp .err{font-size:8px;color:var(--pt-color-danger-400);min-height:0}
.sgp .ok{color:var(--pt-accent)}
.sgp button{font:inherit;cursor:pointer}
.sgp button:focus-visible, .sgp input:focus-visible{outline:2px solid var(--pt-focus-ring);
outline-offset:1px}
/* شخصية: كبسولية، حقل مركّب برمز الدولة، انحناء كبير */
.sgp{padding:11px;gap:7px;justify-content:center;
border:1px solid var(--pt-border-subtle);border-radius:var(--pt-radius-xl);
background:var(--pt-surface)}
.sgp .row{display:flex;gap:5px}
.sgp .cc{flex:none;width:74px;padding:6px 7px;border-radius:var(--pt-radius-full);
border:1px solid var(--pt-border-default);background:var(--pt-bg-raised)}
.sgp .ph{flex:1;padding:6px 11px;border-radius:var(--pt-radius-full);
border:1px solid var(--pt-border-default);background:var(--pt-bg-raised);
direction:ltr;text-align:start;letter-spacing:.04em}
.sgp .ph[aria-invalid=true]{border-color:var(--pt-color-danger-400)}
.sgp .norm{margin:0;font-size:8.5px;color:var(--pt-accent);direction:ltr;min-height:11px}
.sgp .go{padding:7px;border-radius:var(--pt-radius-full);border:0;
background:var(--pt-accent);color:var(--pt-color-ink-900);font-size:9.5px;font-weight:600}
.sgp .go:disabled{opacity:.45;cursor:not-allowed}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.sgp');
if (!host) return;
var snapshot = host.innerHTML;
var timers = [];
var ac = null;
/* الجسم كما كتبه المولِّد. يستقبل بدائل مظلَّلة لـ root وdocument
والمؤقّتات، فينظّف نفسه دون أن يعرف أنه قابل لإعادة التركيب. */
function run(root, document, setTimeout, setInterval) {
/* الخطأ يظهر بعد مغادرة الحقل لا مع كل حرف: القراءة أثناء الكتابة
تُشعر المستخدم بالفشل قبل أن ينتهي من الإدخال. */
function bind(input, check, msg) {
var box = input.closest('label') || input.parentElement;
var err = box.querySelector('.err') || box.parentElement.querySelector('.err');
var touched = false;
function paint() {
var good = check(input.value);
input.setAttribute('aria-invalid', String(touched && !good));
if (err) err.textContent = touched && !good ? msg : '';
return good;
}
input.addEventListener('blur', function () { touched = true; paint(); });
input.addEventListener('input', function () { if (touched) paint(); });
return paint;
}
var cc = root.querySelector('.cc');
var ph = root.querySelector('.ph');
var out = root.querySelector('.norm');
var go = root.querySelector('.go');
/* السعودية: 5 ثم تسع خانات. الأردن: 7 ثم ثماني خانات.
ولا يكفي عدّ الخانات — البادئة تحدّد المشغّل وصحّة الرقم. */
var RULES = { '966': /^5\d{8}$/, '962': /^7[789]\d{7}$/ };
function digits(v) {
return String(v).replace(/[\u0660-\u0669]/g, function (d) { return d.charCodeAt(0) - 0x0660; })
.replace(/\D/g, '');
}
function local(v) {
var d = digits(v);
var c = cc.value;
if (d.indexOf(c) === 0) d = d.slice(c.length); // 96650…
if (d.indexOf('00' + c) === 0) d = d.slice(2 + c.length);
if (d[0] === '0') d = d.slice(1); // 050…
return d;
}
function valid(v) { return RULES[cc.value].test(local(v)); }
var paint = bind(ph, valid, 'رقم غير صالح لهذه الدولة');
function refresh() {
var ok = valid(ph.value);
go.disabled = !ok;
out.textContent = ok ? '+' + cc.value + local(ph.value) : '';
}
ph.addEventListener('input', refresh);
ph.addEventListener('blur', function () { if (valid(ph.value)) ph.value = local(ph.value); refresh(); });
cc.addEventListener('change', function () { paint(); refresh(); });
refresh();
}
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(); });
})();
# Phone Sign-up
**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:** Phone Sign-up — Accepts Saudi and Jordanian numbers and normalises the international form
**Why this component matters:** Users type 0501234567, +966501234567 or 966501234567 interchangeably. Normalise to a single canonical form on blur, and validate the operator prefix — not just the digit count.
**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.
**Important:** This component has no equivalent in any global library. Do not imitate a
Latin pattern and translate its labels — build it from Gulf market requirements directly.